From ff99e211741f332f05664962ef4a92b4c4b4ef75 Mon Sep 17 00:00:00 2001 From: Marco Livesu Date: Tue, 5 Dec 2023 14:48:51 +0100 Subject: [PATCH] window resize --- include/cinolib/gl/glcanvas.cpp | 11 ++++++++++- include/cinolib/gl/glcanvas.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/cinolib/gl/glcanvas.cpp b/include/cinolib/gl/glcanvas.cpp index feb1d734..e8db8a38 100644 --- a/include/cinolib/gl/glcanvas.cpp +++ b/include/cinolib/gl/glcanvas.cpp @@ -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 { @@ -555,9 +563,10 @@ void GLcanvas::window_size_event(GLFWwindow *window, int width, int height) GLcanvas* v = static_cast(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 diff --git a/include/cinolib/gl/glcanvas.h b/include/cinolib/gl/glcanvas.h index ef2316dd..f4920446 100644 --- a/include/cinolib/gl/glcanvas.h +++ b/include/cinolib/gl/glcanvas.h @@ -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