Skip to content

Commit

Permalink
window resize
Browse files Browse the repository at this point in the history
  • Loading branch information
mlivesu committed Dec 5, 2023
1 parent 2fa29cf commit ff99e21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion include/cinolib/gl/glcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,14 @@ bool GLcanvas::unproject(const vec2d & p2d, const GLdouble & depth, vec3d & p3d)

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

CINO_INLINE
void GLcanvas::resize(int width, int height)
{
glfwSetWindowSize(window,width,height);
}

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

CINO_INLINE
void GLcanvas::project(const vec3d & p3d, vec2d & p2d, GLdouble & depth) const
{
Expand All @@ -555,9 +563,10 @@ void GLcanvas::window_size_event(GLFWwindow *window, int width, int height)
GLcanvas* v = static_cast<GLcanvas*>(glfwGetWindowUserPointer(window));
v->camera.height = height;
v->camera.width = width;
v->camera.reset();
v->trackball.last_click_2d = vec2d(inf_double); // fixes crazy translation deltas after window resizing!
v->camera.reset_projection(); // update the camera frustum
v->update_GL_projection(); // update OpenGL's projection matrix
v->update_GL_projection(); // update OpenGL's projection matrix
#ifdef WIN32
// this fixes canvas resize issues under Windows, but also breaks in on Mac....
glViewport(0,0,width,height); // update viewport
Expand Down
4 changes: 4 additions & 0 deletions include/cinolib/gl/glcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class GLcanvas
GLcanvas(const int width = 700, const int height = 700);
~GLcanvas();

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

void resize(int width, int height);

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Main application loop. This is the typical return statement in
Expand Down

0 comments on commit ff99e21

Please sign in to comment.