]> Creatis software - clitk.git/blob - vv/vvBlendImageActor.cxx
Merge branch 'master' into GammaIndex3D
[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 #include <vtkOpenGLRenderWindow.h>
22 #include <vtkOpenGLExtensionManager.h>
23 #include <vtkOpenGLRenderer.h>
24 #include <vtkOpenGL.h>
25 #include <vtkgl.h>
26 #include <vtkObjectFactory.h>
27
28 vtkStandardNewMacro(vvBlendImageActor);
29
30 vvBlendImageActor::vvBlendImageActor()
31 {
32 }
33
34 vvBlendImageActor::~vvBlendImageActor()
35 {
36 }
37
38 // Actual actor render method.
39 void vvBlendImageActor::Render(vtkRenderer *ren)
40 {
41   //Change blending to maximum per component instead of weighted sum
42   vtkOpenGLRenderWindow *renwin = dynamic_cast<vtkOpenGLRenderWindow*>(ren->GetRenderWindow());
43   vtkOpenGLExtensionManager *extensions = renwin->GetExtensionManager();
44   if (extensions->ExtensionSupported("GL_EXT_blend_minmax")) {
45     extensions->LoadExtension("GL_EXT_blend_minmax");
46     vtkgl::BlendEquationEXT( vtkgl::MAX );
47   }
48
49   //Call normal render
50   VTK_IMAGE_ACTOR::Render(ren);
51
52   //Move back blending to weighted sum
53   if (vtkgl::BlendEquationEXT!=0) {
54     vtkgl::BlendEquationEXT( vtkgl::FUNC_ADD );
55   }
56 }
57
58 void vvBlendImageActor::PrintSelf(ostream& os, vtkIndent indent)
59 {
60   this->Superclass::PrintSelf(os,indent);
61 }