smk::Window Class Reference

#include <Window.hpp>

Inheritance diagram for smk::Window:

A window. You can draw objects on the window. More...

Description

A window. You can draw objects on the window.

Example:

auto window = smk::Window(640, 480, "Window title");
A window. You can draw objects on the window.
Definition: Window.hpp:31
GLFWwindow * window() const
The window handle.
Definition: Window.cpp:260
Examples
bezier.cpp, framebuffer.cpp, rounded_rectangle.cpp, shape_2d.cpp, shape_3d.cpp, sound.cpp, sprite.cpp, sprite_move.cpp, text.cpp, texture_subrectangle.cpp, touch.cpp, and vibrate.cpp.

Definition at line 31 of file Window.hpp.

Public Member Functions

 Window ()
 A null window. More...
 
 Window (int width, int height, const std::string &title)
 The window construtor. More...
 
GLFWwindow * window () const
 The window handle. More...
 
float time () const
 The last time Window::PoolEvent() was called. More...
 
Inputinput ()
 Return an object for querying the input state. More...
 
void ExecuteMainLoop (const std::function< void(void)> &loop)
 Helper function. Execute the main loop of the application. On web based application: registers the loop in 'requestAnimationFrame'. On desktop based applications: This is a simple 'while' loop. The loop stops when the user presses the 'escape' button or when the |loop| function returns 'false'. More...
 
void ExecuteMainLoopUntil (const std::function< bool(void)> &loop)
 Helper function. Execute the main loop of the application. On web based application: registers the loop in 'requestAnimationFrame'. On desktop based applications: This is a simple 'while' loop. The loop stops when the user presses the 'escape' button or when the |loop| function returns 'false'. More...
 
void PoolEvents ()
 Handle all the new input events. This update the input() object. More...
 
void Display ()
 Present what has been draw to the screen. More...
 
void LimitFrameRate (float fps)
 
bool ShouldClose ()
 Returns true when the user wants to close the window. More...
 
 Window (Window &&) noexcept
 
 Window (const Window &)=delete
 
Windowoperator= (Window &&) noexcept
 
Windowoperator= (const Window &)=delete
 
void Clear (const glm::vec4 &color)
 Clear the surface with a single color. More...
 
void SetView (const View &view)
 Set the View to use. More...
 
void SetView (const glm::mat4 &mat)
 Set the View to use. More...
 
const Viewview () const
 Return the View currently assigned to this RenderTarget. More...
 
void SetShaderProgram (ShaderProgram &shader_program)
 Set the ShaderProgram to be used. More...
 
ShaderProgramshader_program_2d ()
 Return the default predefined 2D shader program. It is bound by default. More...
 
ShaderProgramshader_program_3d ()
 Return the default predefined 3D shader program. More...
 
virtual void Draw (const Drawable &drawable)
 Draw on the surface. More...
 
virtual void Draw (RenderState &state)
 Draw on the surface. More...
 
glm::vec2 dimensions () const
 the dimension (width, height) of the drawing area. More...
 
int width () const
 the width of the surface. More...
 
int height () const
 the height of the surface. More...
 

Static Public Member Functions

static void Bind (RenderTarget *target)
 

Protected Member Functions

void InitRenderTarget ()
 

Protected Attributes

int width_ = 0
 
int height_ = 0
 
glm::mat4 projection_matrix_ = glm::mat4(1)
 
smk::View view_
 
Shader vertex_shader_2d_
 
Shader fragment_shader_2d_
 
ShaderProgram shader_program_2d_
 
Shader vertex_shader_3d_
 
Shader fragment_shader_3d_
 
ShaderProgram shader_program_3d_
 
ShaderProgram shader_program_
 
GLuint frame_buffer_ = 0
 

Constructor & Destructor Documentation

◆ Window() [1/3]

smk::Window::Window ( )

A null window.

Definition at line 117 of file Window.cpp.

117 {
118 id_ = ++g_next_id;
119 window_by_id[id_] = this;
120}

◆ Window() [2/3]

smk::Window::Window ( int  width,
int  height,
const std::string &  title 
)

The window construtor.

Parameters
widthThe desired width of the window.
heightThe desired height of the window.
titleThe window's title.

Definition at line 126 of file Window.cpp.

126 {
127 input_ = std::make_unique<InputImpl>();
128 id_ = ++g_next_id;
129 window_by_id[id_] = this;
130 width_ = width;
131 height_ = height;
132
133 glfwSetErrorCallback(GLFWErrorCallback);
134 // initialize the GLFW library
135 if (!glfwInit()) {
136 throw std::runtime_error("Couldn't init GLFW");
137 }
138
139 // setting the opengl version
140#ifdef __EMSCRIPTEN__
141 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
142 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
143#else
144 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
145 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
146 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
147 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
148#endif
149
150 glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
151 glfwWindowHint(GLFW_SAMPLES, 4);
152
153 // create the window_
154 window_ = glfwCreateWindow(width_, height_, title.c_str(), nullptr, nullptr);
155 if (!window_) {
156 glfwTerminate();
157 throw std::runtime_error("Couldn't create a window_");
158 }
159 window_by_glfw_window[window_] = this;
160
161 glfwMakeContextCurrent(window_);
162
163#ifndef __EMSCRIPTEN__
164 glewExperimental = GL_TRUE;
165 GLenum err = glewInit();
166
167 if (err != GLEW_OK) {
168 glfwTerminate();
169 std::string error = (const char*)glewGetErrorString(err); // NOLINT
170 throw std::runtime_error("Could initialize GLEW, error = " + error);
171 }
172#endif
173
174#if !defined NDEBUG && !defined __EMSCRIPTEN__ && __linux__
175 glEnable(GL_DEBUG_OUTPUT);
176 glDebugMessageCallback(OpenGLDebugMessageCallback, 0);
177#endif
178
179 // get version info
180 const GLubyte* renderer = glGetString(GL_RENDERER);
181 const GLubyte* version = glGetString(GL_VERSION);
182 std::cout << "Renderer: " << renderer << std::endl;
183 std::cout << "OpenGL version supported " << version << std::endl;
184
185 // Alpha transparency.
186 glEnable(GL_BLEND);
187 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
188
189 InitRenderTarget();
190
191#ifndef __EMSCRIPTEN__
192 if (GLEW_KHR_parallel_shader_compile) {
193 glMaxShaderCompilerThreadsKHR(4);
194 g_khr_parallel_shader = true;
195 }
196#else
197 g_khr_parallel_shader = emscripten_webgl_enable_extension(
198 emscripten_webgl_get_current_context(), "KHR_parallel_shader_compile");
199
200 MakeCanvasSelectable(id_);
201
202 module_canvas_selector_ = "[smk='" + std::to_string(id_) + "']";
203
204 emscripten_set_touchstart_callback(module_canvas_selector_.c_str(),
205 (void*)id_, true, OnTouchEvent);
206 emscripten_set_touchend_callback(module_canvas_selector_.c_str(), (void*)id_,
207 true, OnTouchEvent);
208 emscripten_set_touchmove_callback(module_canvas_selector_.c_str(), (void*)id_,
209 true, OnTouchEvent);
210 emscripten_set_touchcancel_callback(module_canvas_selector_.c_str(),
211 (void*)id_, true, OnTouchEvent);
212#endif
213 glfwSetScrollCallback(window_, GLFWScrollCallback);
214 glfwSetCharCallback(window_, GLFWCharCallback);
215}
int height() const
the height of the surface.
int width() const
the width of the surface.

◆ ~Window()

smk::Window::~Window ( )

Definition at line 254 of file Window.cpp.

254 {
255 window_by_id.erase(id_);
256 // glfwTerminate(); // Needed? What about multiple windows?
257}

◆ Window() [3/3]

smk::Window::Window ( Window &&  window)
noexcept

Definition at line 217 of file Window.cpp.

217 {
218 operator=(std::move(window));
219}

Member Function Documentation

◆ Bind()

void smk::RenderTarget::Bind ( RenderTarget target)
staticinherited

Definition at line 28 of file RenderTarget.cpp.

28 {
29 if (render_target == target) {
30 return;
31 }
32 render_target = target;
33 glBindFramebuffer(GL_FRAMEBUFFER, render_target->frame_buffer_);
34 glViewport(0, 0, render_target->width_, render_target->height_);
35}

◆ Clear()

void smk::RenderTarget::Clear ( const glm::vec4 &  color)
inherited

Clear the surface with a single color.

Parameters
colorAn opaque color to fill the surface.

Definition at line 65 of file RenderTarget.cpp.

65 {
66 Bind(this);
67 glClearColor(color.r, color.g, color.b, color.a); // NOLINT
68 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
69 glDisable(GL_DEPTH_TEST);
70 glDisable(GL_CULL_FACE);
71}

◆ dimensions()

glm::vec2 smk::RenderTarget::dimensions ( ) const
inherited

the dimension (width, height) of the drawing area.

Returns
the dimensions in (pixels, pixels) of the surface.

Definition at line 219 of file RenderTarget.cpp.

219 {
220 return glm::vec2(width_, height_);
221}

◆ Display()

void smk::Window::Display ( )

Present what has been draw to the screen.

Definition at line 244 of file Window.cpp.

244 {
245 // Swap Front and Back buffers (double buffering)
246 glfwSwapBuffers(window_);
247
248 // Detect window_ related changes
249 UpdateDimensions();
250
251 time_ = static_cast<float>(glfwGetTime());
252}

◆ Draw() [1/2]

void smk::RenderTarget::Draw ( const Drawable drawable)
virtualinherited

Draw on the surface.

Parameters
drawableThe object to be drawn on the surface.
Examples
sprite_move.cpp.

Definition at line 162 of file RenderTarget.cpp.

162 {
163 Bind(this);
164 RenderState state;
165 state.shader_program = shader_program_;
166 state.view = glm::mat4(1.F);
167 state.color = smk::Color::White;
168 state.blend_mode = smk::BlendMode::Alpha;
169 drawable.Draw(*this, state);
170}
const glm::vec4 White
White.
Definition: Color.cpp:29
static const BlendMode Alpha
destination = source * source.a + destination * (1 - souce.a)
Definition: BlendMode.hpp:68

◆ Draw() [2/2]

void smk::RenderTarget::Draw ( RenderState state)
virtualinherited

Draw on the surface.

Parameters
stateThe RenderState to be usd for drawing.

Definition at line 174 of file RenderTarget.cpp.

174 {
175 // Vertex Array
176 if (cached_render_state_.vertex_array != state.vertex_array) {
177 cached_render_state_.vertex_array = state.vertex_array;
178 state.vertex_array.Bind();
179 }
180
181 // Shader
182 if (cached_render_state_.shader_program != state.shader_program) {
183 cached_render_state_.shader_program = state.shader_program;
184 cached_render_state_.shader_program.Use();
185 }
186
187 // Color
188 if (cached_render_state_.color != state.color) {
189 cached_render_state_.color = state.color;
190 cached_render_state_.shader_program.SetUniform("color", state.color);
191 }
192
193 // View (not cached)
194 state.shader_program.SetUniform("projection", projection_matrix_);
195 state.shader_program.SetUniform("view", state.view);
196
197 // Texture
198 const auto& texture = state.texture.id() ? state.texture : WhiteTexture();
199 if (cached_render_state_.texture != texture || g_invalidate_textures) {
200 cached_render_state_.texture = texture;
201 texture.Bind();
202 g_invalidate_textures = false;
203 }
204
205 if (cached_render_state_.blend_mode != state.blend_mode) {
206 cached_render_state_.blend_mode = state.blend_mode;
207 glEnable(GL_BLEND);
208 glBlendEquationSeparate(state.blend_mode.equation_rgb,
209 state.blend_mode.equation_alpha);
210 glBlendFuncSeparate(state.blend_mode.src_rgb, state.blend_mode.dst_rgb,
211 state.blend_mode.src_alpha, state.blend_mode.dst_alpha);
212 }
213
214 glDrawArrays(GL_TRIANGLES, 0, GLsizei(state.vertex_array.size()));
215}

◆ ExecuteMainLoop()

void smk::Window::ExecuteMainLoop ( const std::function< void(void)> &  loop)

Helper function. Execute the main loop of the application. On web based application: registers the loop in 'requestAnimationFrame'. On desktop based applications: This is a simple 'while' loop. The loop stops when the user presses the 'escape' button or when the |loop| function returns 'false'.

Parameters
loopThe function to be called for each new frame.

Definition at line 297 of file Window.cpp.

297 {
298#ifdef __EMSCRIPTEN__
299 main_loop = loop;
300 emscripten_set_main_loop(&MainLoop, 0, 1);
301#else
302 while (!input().IsKeyPressed(GLFW_KEY_ESCAPE) && !ShouldClose()) {
303 loop();
304 LimitFrameRate(60.F); // NOLINT
305 };
306#endif
307}
bool ShouldClose()
Returns true when the user wants to close the window.
Definition: Window.cpp:340
Input & input()
Return an object for querying the input state.
Definition: Window.cpp:270
void LimitFrameRate(float fps)
Definition: Window.cpp:327

◆ ExecuteMainLoopUntil()

void smk::Window::ExecuteMainLoopUntil ( const std::function< bool(void)> &  loop)

Helper function. Execute the main loop of the application. On web based application: registers the loop in 'requestAnimationFrame'. On desktop based applications: This is a simple 'while' loop. The loop stops when the user presses the 'escape' button or when the |loop| function returns 'false'.

Parameters
loopThe function to be called for each new frame.

Definition at line 280 of file Window.cpp.

280 {
281#ifdef __EMSCRIPTEN__
282 main_loop = [my_loop = loop] { (void)my_loop(); };
283 emscripten_set_main_loop(&MainLoop, 0, 1);
284#else
285 while (loop()) {
286 LimitFrameRate(60.F); // NOLINT
287 }
288#endif
289}

◆ height()

int smk::RenderTarget::height ( ) const
inherited

the height of the surface.

Returns
the height in pixels of the surface.

Definition at line 231 of file RenderTarget.cpp.

231 {
232 return height_;
233}

◆ InitRenderTarget()

void smk::RenderTarget::InitRenderTarget ( )
protectedinherited

Definition at line 235 of file RenderTarget.cpp.

235 {
236 View default_view;
237 default_view.SetCenter(float(width_) / 2.F, float(height_) / 2.F); // NOLINT
238 default_view.SetSize(float(width_), float(height_));
239 SetView(default_view);
240
241 vertex_shader_2d_ = Shader::FromString(R"(
242 layout(location = 0) in vec2 space_position;
243 layout(location = 1) in vec2 texture_position;
244
245 uniform mat4 projection;
246 uniform mat4 view;
247
248 out vec2 f_texture_position;
249
250 void main() {
251 f_texture_position = texture_position;
252 gl_Position = projection * view * vec4(space_position, 0.F, 1.F);
253 }
254 )",
255 GL_VERTEX_SHADER);
256
257 fragment_shader_2d_ = Shader::FromString(R"(
258 in vec2 f_texture_position;
259 uniform sampler2D texture_0;
260 uniform vec4 color;
261 out vec4 out_color;
262
263 void main() {
264 out_color = texture(texture_0, f_texture_position) * color;
265 }
266 )",
267 GL_FRAGMENT_SHADER);
268
269 shader_program_2d_.AddShader(vertex_shader_2d_);
270 shader_program_2d_.AddShader(fragment_shader_2d_);
271 shader_program_2d_.Link();
272
273 vertex_shader_3d_ = Shader::FromString(R"(
274 layout(location = 0) in vec3 space_position;
275 layout(location = 1) in vec3 normal;
276 layout(location = 2) in vec2 texture_position;
277
278 uniform mat4 projection;
279 uniform mat4 view;
280
281 out vec4 fPosition;
282 out vec2 fTexture;
283 out vec3 fNormal;
284
285 void main() {
286 fTexture = texture_position;
287 fPosition = view * vec4(space_position,1.F);
288 fNormal = vec3(view * vec4(normal,0.F));
289
290 gl_Position = projection * fPosition;
291 }
292 )",
293 GL_VERTEX_SHADER);
294
295 fragment_shader_3d_ = Shader::FromString(R"(
296 uniform sampler2D texture_0;
297 uniform vec4 color;
298
299 uniform vec4 light_position;
300 uniform float ambient;
301 uniform float diffuse;
302 uniform float specular;
303 uniform float specular_power;
304
305 in vec4 fPosition;
306 in vec2 fTexture;
307 in vec3 fNormal;
308
309 out vec4 out_color;
310
311 void main(void)
312 {
313 vec3 object_dir =-normalize(fPosition.xyz);
314 vec3 normal_dir = normalize(fNormal);
315 vec3 light_dir = normalize(light_position.xyz-fPosition.xyz);
316 vec3 reflect_dir = -reflect(object_dir,normal_dir);
317
318 float diffuse_strength = max(0.F, dot(normal_dir, light_dir));
319 float specular_strength = pow(max(0.F, dot(reflect_dir, light_dir)),
320 specular_power);
321
322 out_color = texture(texture_0, fTexture);
323 out_color.rgb *= ambient +
324 diffuse * diffuse_strength +
325 specular * specular_strength;
326 out_color *= color;
327 }
328 )",
329 GL_FRAGMENT_SHADER);
330
331 shader_program_3d_.AddShader(vertex_shader_3d_);
332 shader_program_3d_.AddShader(fragment_shader_3d_);
333 shader_program_3d_.Link();
334
335 shader_program_3d_.Use();
336 constexpr auto default_light_position = glm::vec4(0.F, 5.F, 0.F, 1.F);
337 constexpr auto default_ambient = 0.3F;
338 constexpr auto default_diffuse = 0.5F;
339 constexpr auto default_specular = 0.5F;
340 constexpr auto default_specular_power = 4.F;
341 shader_program_3d_.SetUniform("light_position", default_light_position);
342 shader_program_3d_.SetUniform("ambient", default_ambient);
343 shader_program_3d_.SetUniform("diffuse", default_diffuse);
344 shader_program_3d_.SetUniform("specular", default_specular);
345 shader_program_3d_.SetUniform("specular_power", default_specular_power);
346
347 SetShaderProgram(shader_program_2d_);
348}
void SetView(const View &view)
Set the View to use.
void SetShaderProgram(ShaderProgram &shader_program)
Set the ShaderProgram to be used.
void SetUniform(const std::string &name, float x, float y, float z)
Assign shader vec3 uniform.
Definition: Shader.cpp:377
void AddShader(const Shader &shader)
Add a Shader to the program list. This must called multiple time for each shader components before ca...
Definition: Shader.cpp:224
void Use() const
Bind the ShaderProgram. Future draw will use it. This unbind any previously bound ShaderProgram.
Definition: Shader.cpp:429
void Link() const
Add a Shader to the program list.
Definition: Shader.cpp:236
static Shader FromString(const std::string &content, GLenum type)
Load a shader from a std::string.
Definition: Shader.cpp:60

◆ input()

Input & smk::Window::input ( )

Return an object for querying the input state.

Definition at line 270 of file Window.cpp.

270 {
271 return *(input_.get());
272}

◆ LimitFrameRate()

void smk::Window::LimitFrameRate ( float  fps)

If needed, insert pause in the execution to maintain a given framerate.

Parameters
fpsthe desired frame rate.

Definition at line 327 of file Window.cpp.

327 {
328 const float delta = static_cast<float>(glfwGetTime()) - time_last_sleep_;
329 const float target = 1.f / fps;
330 float sleep_duration = target - delta;
331 sleep_duration = std::min(target, sleep_duration);
332 if (sleep_duration > 0.f) {
333 std::this_thread::sleep_for(
334 std::chrono::microseconds(int(sleep_duration * 1'000'000))); // NOLINT
335 }
336 time_last_sleep_ = static_cast<float>(glfwGetTime());
337}

◆ operator=()

Window & smk::Window::operator= ( Window &&  other)
noexcept

Definition at line 221 of file Window.cpp.

221 {
222 if (&other == this) {
223 return *this;
224 }
225 std::swap(window_, other.window_);
226 std::swap(time_, other.time_);
227 std::swap(time_last_sleep_, other.time_last_sleep_);
228 std::swap(input_, other.input_);
229 std::swap(id_, other.id_);
230 std::swap(module_canvas_selector_, other.module_canvas_selector_);
231 RenderTarget::operator=(std::move(other));
232 window_by_id[id_] = this;
233 window_by_glfw_window[window_] = this;
234 return *this;
235}
RenderTarget & operator=(RenderTarget &&other) noexcept
Move operator.

◆ PoolEvents()

void smk::Window::PoolEvents ( )

Handle all the new input events. This update the input() object.

Definition at line 238 of file Window.cpp.

238 {
239 glfwPollEvents();
240 input_->Update(window_);
241}

◆ SetShaderProgram()

void smk::RenderTarget::SetShaderProgram ( ShaderProgram shader_program)
inherited

Set the ShaderProgram to be used.

Parameters
shader_programThe ShaderProgram to be used.

Example:

auto shader_vertex = Shader::FromString(R"(
layout(location = 0) in vec2 space_position;
layout(location = 1) in vec2 texture_position;
uniform mat4 projection;
uniform mat4 view;
out vec2 f_texture_position;
void main() {
f_texture_position = texture_position;
gl_Position = projection * view * vec4(space_position, 0.F, 1.F);
}
)", GL_VERTEX_SHADER);
fragment_shader_2d_ = Shader::FromString(R"(
in vec2 f_texture_position;
uniform sampler2D texture_0;
uniform vec4 color;
out vec4 out_color;
void main() {
vec4 inverted_color = vec4(1.F) - color;
out_color = texture(texture_0, f_texture_position) * inverted_color.
}
)";
auto shader_program = smk::ShaderProgram>();
shader_program.AddShader(vertex_shader_2d_);
shader_program.AddShader(fragment_shader_2d_);
shader_program.Link();
window.SetShaderProgram(shader_program);
A shader program is a set of shader (for instance vertex shader + pixel shader) defining the renderin...
Definition: Shader.hpp:114

{

Definition at line 140 of file RenderTarget.cpp.

140 {
141 shader_program_ = shader_program;
142 shader_program_.Use();
143 shader_program_.SetUniform("texture_0", 0);
144 shader_program_.SetUniform("color", glm::vec4(1.F, 1.F, 1.F, 1.F));
145 shader_program_.SetUniform("projection", glm::mat4(1.F));
146 shader_program_.SetUniform("view", glm::mat4(1.F));
147}

◆ SetView() [1/2]

void smk::RenderTarget::SetView ( const glm::mat4 &  mat)
inherited

Set the View to use.

Parameters
matThe matrix to transform from/to the OpenGL space [-1,1]^3 to the screen space.

Definition at line 90 of file RenderTarget.cpp.

90 {
91 projection_matrix_ = mat;
92}

◆ SetView() [2/2]

void smk::RenderTarget::SetView ( const View view)
inherited

Set the View to use.

Parameters
viewThe view to use.

Definition at line 75 of file RenderTarget.cpp.

75 {
76 view_ = view;
77 float z_x = +2.F / view.width_; // NOLINT [0, width] -> [-1,1]
78 float z_y = -2.F / view.height_; // NOLINT [0, height] -> [-1,1]
79 float t_x = -view.x_ * z_x;
80 float t_y = -view.y_ * z_y;
81 SetView(glm::mat4(z_x, 0.F, 0.F, 0.F, //
82 0.F, z_y, 0.F, 0.F, //
83 0.F, 0.F, 1.F, 0.F, //
84 t_x, t_y, 0.F, 1.F)); //
85}
const View & view() const
Return the View currently assigned to this RenderTarget.
float x_
<
Definition: View.hpp:27

◆ shader_program_2d()

ShaderProgram & smk::RenderTarget::shader_program_2d ( )
inherited

Return the default predefined 2D shader program. It is bound by default.

Definition at line 151 of file RenderTarget.cpp.

151 {
152 return shader_program_2d_;
153};

◆ shader_program_3d()

ShaderProgram & smk::RenderTarget::shader_program_3d ( )
inherited

Return the default predefined 3D shader program.

Definition at line 156 of file RenderTarget.cpp.

156 {
157 return shader_program_3d_;
158};

◆ ShouldClose()

bool smk::Window::ShouldClose ( )

Returns true when the user wants to close the window.

Definition at line 340 of file Window.cpp.

340 {
341 return glfwWindowShouldClose(window_);
342}

◆ time()

float smk::Window::time ( ) const

The last time Window::PoolEvent() was called.

Definition at line 265 of file Window.cpp.

265 {
266 return time_;
267}

◆ view()

const View & smk::RenderTarget::view ( ) const
inherited

Return the View currently assigned to this RenderTarget.

Definition at line 95 of file RenderTarget.cpp.

95 {
96 return view_;
97}

◆ width()

int smk::RenderTarget::width ( ) const
inherited

the width of the surface.

Returns
the height of the surface.

Definition at line 225 of file RenderTarget.cpp.

225 {
226 return width_;
227}

◆ window()

GLFWwindow * smk::Window::window ( ) const

The window handle.

Definition at line 260 of file Window.cpp.

260 {
261 return window_;
262}

Member Data Documentation

◆ fragment_shader_2d_

Shader smk::RenderTarget::fragment_shader_2d_
protectedinherited

Definition at line 71 of file RenderTarget.hpp.

◆ fragment_shader_3d_

Shader smk::RenderTarget::fragment_shader_3d_
protectedinherited

Definition at line 75 of file RenderTarget.hpp.

◆ frame_buffer_

GLuint smk::RenderTarget::frame_buffer_ = 0
protectedinherited

Definition at line 81 of file RenderTarget.hpp.

◆ height_

int smk::RenderTarget::height_ = 0
protectedinherited

Definition at line 63 of file RenderTarget.hpp.

◆ projection_matrix_

glm::mat4 smk::RenderTarget::projection_matrix_ = glm::mat4(1)
protectedinherited

Definition at line 66 of file RenderTarget.hpp.

◆ shader_program_

ShaderProgram smk::RenderTarget::shader_program_
protectedinherited

Definition at line 79 of file RenderTarget.hpp.

◆ shader_program_2d_

ShaderProgram smk::RenderTarget::shader_program_2d_
protectedinherited

Definition at line 72 of file RenderTarget.hpp.

◆ shader_program_3d_

ShaderProgram smk::RenderTarget::shader_program_3d_
protectedinherited

Definition at line 76 of file RenderTarget.hpp.

◆ vertex_shader_2d_

Shader smk::RenderTarget::vertex_shader_2d_
protectedinherited

Definition at line 70 of file RenderTarget.hpp.

◆ vertex_shader_3d_

Shader smk::RenderTarget::vertex_shader_3d_
protectedinherited

Definition at line 74 of file RenderTarget.hpp.

◆ view_

smk::View smk::RenderTarget::view_
protectedinherited

Definition at line 67 of file RenderTarget.hpp.

◆ width_

int smk::RenderTarget::width_ = 0
protectedinherited

Definition at line 62 of file RenderTarget.hpp.


The documentation for this class was generated from the following files: