Browse Source

Support viewports with different background colors.

Julian Panetta 6 years ago
parent
commit
724eda9174
1 changed files with 5 additions and 0 deletions
  1. 5 0
      include/igl/opengl/ViewerCore.cpp

+ 5 - 0
include/igl/opengl/ViewerCore.cpp

@@ -87,11 +87,16 @@ IGL_INLINE void igl::opengl::ViewerCore::get_scale_and_shift_to_fit_mesh(
 
 IGL_INLINE void igl::opengl::ViewerCore::clear_framebuffers()
 {
+  // The glScissor call ensures we only clear this core's buffers,
+  // (in case the user wants different background colors in each viewport.)
+  glScissor(viewport(0), viewport(1), viewport(2), viewport(3));
+  glEnable(GL_SCISSOR_TEST);
   glClearColor(background_color[0],
                background_color[1],
                background_color[2],
                background_color[3]);
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  glDisable(GL_SCISSOR_TEST);
 }
 
 IGL_INLINE void igl::opengl::ViewerCore::draw(