]> Creatis software - clitk.git/blob - vv/vvBlendImageActor.cxx
Merge branch 'master' into OpenGL2
[clitk.git] / vv / vvBlendImageActor.cxx
1 /*=========================================================================
2 Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4 Authors belong to:
5 - University of LYON              http://www.universite-lyon.fr/
6 - Léon Bérard cancer center       http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE.  See the copyright notices for more information.
12
13 It is distributed under dual licence
14
15 - BSD        See included LICENSE.txt file
16 - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18
19 #include "vvBlendImageActor.h"
20
21
22 #include <vtkVersion.h>
23 #ifdef VTKGL2
24 #include "vtk_glew.h"
25 #else
26 #include "vtkOpenGLExtensionManager.h"
27 #include "vtkOpenGLExtensionManagerConfigure.h"
28 #include "vtkgl.h"
29 #endif
30 #include <vtkOpenGLRenderWindow.h>
31 #include <vtkOpenGLRenderer.h>
32 #include <vtkOpenGL.h>
33 #include <vtkObjectFactory.h>
34
35 vtkStandardNewMacro(vvBlendImageActor);
36
37 vvBlendImageActor::vvBlendImageActor()
38 {
39 }
40
41 vvBlendImageActor::~vvBlendImageActor()
42 {
43 }
44
45 // Actual actor render method.
46 void vvBlendImageActor::Render(vtkRenderer *ren)
47 {
48   //Change blending to maximum per component instead of weighted sum
49   vtkOpenGLRenderWindow *renwin = dynamic_cast<vtkOpenGLRenderWindow*>(ren->GetRenderWindow());
50 #ifdef VTKGL2
51   const char *extensions = renwin->ReportCapabilities();
52   //if (extensions->ExtensionSupported("GL_EXT_blend_minmax")) {
53   //  extensions->LoadExtension("GL_EXT_blend_minmax");
54   //glBlendEquationEXT( GL_MAX_EXT );
55   //}
56
57   //Call normal render
58   VTK_IMAGE_ACTOR::Render(ren);
59
60   //Move back blending to weighted sum
61   if (glBlendEquationEXT!=0) {
62     glBlendEquationEXT( GL_FUNC_ADD_EXT );
63   }
64 #else
65   vtkOpenGLExtensionManager *extensions = renwin->GetExtensionManager();
66   if (extensions->ExtensionSupported("GL_EXT_blend_minmax")) {
67     extensions->LoadExtension("GL_EXT_blend_minmax");
68     vtkgl::BlendEquationEXT( vtkgl::MAX );
69   }
70
71   //Call normal render
72   VTK_IMAGE_ACTOR::Render(ren);
73
74   //Move back blending to weighted sum
75   if (vtkgl::BlendEquationEXT!=0) {
76     vtkgl::BlendEquationEXT( vtkgl::FUNC_ADD );
77   }
78 #endif
79 }
80
81 void vvBlendImageActor::PrintSelf(ostream& os, vtkIndent indent)
82 {
83   this->Superclass::PrintSelf(os,indent);
84 }