]> Creatis software - clitk.git/blob - vv/vvBlendImageActor.cxx
f28ba324b82bfa6e995b5a4a2dffb135bdd95dcb
[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://oncora1.lyon.fnclcc.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     {
46     extensions->LoadExtension("GL_EXT_blend_minmax");
47     vtkgl::BlendEquationEXT( vtkgl::MAX );
48     }
49
50   //Call normal render
51   vtkOpenGLImageActor::Render(ren);
52
53   //Move back blending to weighted sum
54   if (vtkgl::BlendEquationEXT!=0)
55     {
56     vtkgl::BlendEquationEXT( vtkgl::FUNC_ADD );
57     }
58 }
59
60 void vvBlendImageActor::PrintSelf(ostream& os, vtkIndent indent)
61 {
62   this->Superclass::PrintSelf(os,indent);
63 }