diff --git a/include/igl/viewer/Viewer.cpp b/include/igl/viewer/Viewer.cpp index f987dabe2..16626691a 100644 --- a/include/igl/viewer/Viewer.cpp +++ b/include/igl/viewer/Viewer.cpp @@ -154,7 +154,7 @@ static void glfw_window_size(GLFWwindow* window, int width, int height) int w = width*highdpi; int h = height*highdpi; - __viewer->resize(w, h); + __viewer->resize_callback(w, h); // TODO: repositioning of the nanogui } @@ -841,6 +841,11 @@ namespace viewer } IGL_INLINE void Viewer::resize(int w,int h) + { + glfwSetWindowSize(window, w/highdpi, h/highdpi); + } + + IGL_INLINE void Viewer::resize_callback(int w,int h) { core.viewport = Eigen::Vector4f(0,0,w,h); } @@ -895,7 +900,11 @@ namespace viewer } else { - window = glfwCreateWindow(1280,800,"libigl viewer",nullptr,nullptr); + if (core.viewport.tail<2>().any()) { + window = glfwCreateWindow(core.viewport(2),core.viewport(3),"libigl viewer",nullptr,nullptr); + } else { + window = glfwCreateWindow(1280,800,"libigl viewer",nullptr,nullptr); + } } if (!window) diff --git a/include/igl/viewer/Viewer.h b/include/igl/viewer/Viewer.h index b82f3ea32..f915c1124 100644 --- a/include/igl/viewer/Viewer.h +++ b/include/igl/viewer/Viewer.h @@ -119,7 +119,8 @@ namespace viewer IGL_INLINE void draw(); // OpenGL context resize - IGL_INLINE void resize(int w,int h); + IGL_INLINE void resize(int w,int h); // explicitly set window size + IGL_INLINE void resize_callback(int w,int h); // external resize due to user interaction // Helper functions IGL_INLINE void snap_to_canonical_quaternion(); diff --git a/python/tutorial/shared.py b/python/tutorial/shared.py index 7afbde052..1adf98024 100644 --- a/python/tutorial/shared.py +++ b/python/tutorial/shared.py @@ -1,8 +1,8 @@ import pyigl as igl import sys +import os - -TUTORIAL_SHARED_PATH = "../../tutorial/shared/" +TUTORIAL_SHARED_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../tutorial/shared/") def check_dependencies(deps): available = [hasattr(igl, m) for m in deps]