]> Creatis software - clitk.git/commitdiff
Ensure compilation with OpenGL2 (VTK7)
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 6 Jun 2016 07:44:44 +0000 (09:44 +0200)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 6 Jun 2016 07:44:44 +0000 (09:44 +0200)
cmake/dependencies.cmake
vv/vvBlendImageActor.cxx

index a871fecd0d19523b2fa28823856adcf5637c32ed..ef74409c2d9c59dcf0de030f08df7c488356c44d 100644 (file)
@@ -31,6 +31,9 @@ if(VTK_FOUND)
       vtkQVTK
     )
   endif(VTK_VERSION VERSION_LESS 5.6.0)
+  if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
+    add_definitions(-DVTKGL2)
+  endif()
 else(VTK_FOUND)
   message(FATAL_ERROR "Please set VTK_DIR.")
 endif(VTK_FOUND)
index 2093c7d7e0721c21330520c976261269f7b0651b..4f47ecc7f65a3acb4f9b4fee08bdeefb425a2486 100644 (file)
@@ -18,11 +18,18 @@ It is distributed under dual licence
 
 #include "vvBlendImageActor.h"
 
+
+#include <vtkVersion.h>
+#ifdef VTKGL2
+#include "vtk_glew.h"
+#else
+#include "vtkOpenGLExtensionManager.h"
+#include "vtkOpenGLExtensionManagerConfigure.h"
+#include "vtkgl.h"
+#endif
 #include <vtkOpenGLRenderWindow.h>
-#include <vtkOpenGLExtensionManager.h>
 #include <vtkOpenGLRenderer.h>
 #include <vtkOpenGL.h>
-#include <vtkgl.h>
 #include <vtkObjectFactory.h>
 
 vtkStandardNewMacro(vvBlendImageActor);
@@ -40,6 +47,21 @@ void vvBlendImageActor::Render(vtkRenderer *ren)
 {
   //Change blending to maximum per component instead of weighted sum
   vtkOpenGLRenderWindow *renwin = dynamic_cast<vtkOpenGLRenderWindow*>(ren->GetRenderWindow());
+#ifdef VTKGL2
+  const char *extensions = renwin->ReportCapabilities();
+  //if (extensions->ExtensionSupported("GL_EXT_blend_minmax")) {
+  //  extensions->LoadExtension("GL_EXT_blend_minmax");
+  //glBlendEquationEXT( GL_MAX_EXT );
+  //}
+
+  //Call normal render
+  VTK_IMAGE_ACTOR::Render(ren);
+
+  //Move back blending to weighted sum
+  if (glBlendEquationEXT!=0) {
+    glBlendEquationEXT( GL_FUNC_ADD_EXT );
+  }
+#else
   vtkOpenGLExtensionManager *extensions = renwin->GetExtensionManager();
   if (extensions->ExtensionSupported("GL_EXT_blend_minmax")) {
     extensions->LoadExtension("GL_EXT_blend_minmax");
@@ -53,6 +75,7 @@ void vvBlendImageActor::Render(vtkRenderer *ren)
   if (vtkgl::BlendEquationEXT!=0) {
     vtkgl::BlendEquationEXT( vtkgl::FUNC_ADD );
   }
+#endif
 }
 
 void vvBlendImageActor::PrintSelf(ostream& os, vtkIndent indent)