瀏覽代碼

Remove buggy viewport resize.

Jérémie Dumas 6 年之前
父節點
當前提交
cf3b31ce47
共有 2 個文件被更改,包括 7 次插入16 次删除
  1. 6 16
      include/igl/opengl/glfw/Viewer.cpp
  2. 1 0
      include/igl/opengl/glfw/Viewer.h

+ 6 - 16
include/igl/opengl/glfw/Viewer.cpp

@@ -906,27 +906,17 @@ namespace glfw
     }
     else
     {
-      int original_w = 0;
-      int original_h = 0;
-      for (auto c: core_list)
-      {
-        int cur_x = c.viewport(0) + c.viewport(2);
-        int cur_y = c.viewport(1) + c.viewport(3);
-        if (original_w < cur_x) original_w = cur_x;
-        if (original_h < cur_y) original_h = cur_y;
-      }
-      for (auto &c: core_list)
-      {
-        c.viewport(0) *= w/original_w;
-        c.viewport(2) *= w/original_w;
-        c.viewport(1) *= h/original_h;
-        c.viewport(3) *= h/original_h;
-      }
+      // It is up to the user to define the behavior of the post_resize() function
+      // when there are multiple viewports (through the `callback_post_resize` callback)
     }
     for (unsigned int i = 0; i<plugins.size(); ++i)
     {
       plugins[i]->post_resize(w, h);
     }
+    if (callback_post_resize)
+    {
+      callback_post_resize(*this, w, h);
+    }
   }
 
   IGL_INLINE void Viewer::snap_to_canonical_quaternion()

+ 1 - 0
include/igl/opengl/glfw/Viewer.h

@@ -200,6 +200,7 @@ public:
     std::function<bool(Viewer& viewer, int mouse_x, int mouse_y)> callback_mouse_move;
     std::function<bool(Viewer& viewer, float delta_y)> callback_mouse_scroll;
     std::function<bool(Viewer& viewer, unsigned int key, int modifiers)> callback_key_pressed;
+    std::function<bool(Viewer& viewer, int w, int h)> callback_post_resize;
     // THESE SHOULD BE DEPRECATED:
     std::function<bool(Viewer& viewer, unsigned int key, int modifiers)> callback_key_down;
     std::function<bool(Viewer& viewer, unsigned int key, int modifiers)> callback_key_up;