1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkOpenGLVolumeTextureMapper3D.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 // .NAME vtkOpenGLVolumeTextureMapper3D - concrete implementation of 3D volume texture mapping 16 17 // .SECTION Description 18 // vtkOpenGLVolumeTextureMapper3D renders a volume using 3D texture mapping. 19 // See vtkVolumeTextureMapper3D for full description. 20 21 // .SECTION see also 22 // vtkVolumeTextureMapper3D vtkVolumeMapper 23 24 #ifndef vtkOpenGLVolumeTextureMapper3D_h 25 #define vtkOpenGLVolumeTextureMapper3D_h 26 27 #include "vtkRenderingVolumeOpenGLModule.h" // For export macro 28 #include "vtkVolumeTextureMapper3D.h" 29 #include "vtkOpenGL.h" // GLfloat type is used in some method signatures. 30 31 class vtkRenderWindow; 32 class vtkVolumeProperty; 33 34 class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLVolumeTextureMapper3D 35 : public vtkVolumeTextureMapper3D 36 { 37 public: 38 vtkTypeMacro(vtkOpenGLVolumeTextureMapper3D,vtkVolumeTextureMapper3D); 39 void PrintSelf(ostream& os, vtkIndent indent); 40 41 static vtkOpenGLVolumeTextureMapper3D *New(); 42 43 // Description: 44 // Is hardware rendering supported? No if the input data is 45 // more than one independent component, or if the hardware does 46 // not support the required extensions 47 int IsRenderSupported(vtkVolumeProperty *, 48 vtkRenderer *ren); 49 50 //BTX 51 52 // Description: 53 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE 54 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS 55 // Render the volume 56 virtual void Render(vtkRenderer *ren, vtkVolume *vol); 57 58 //ETX 59 60 // Desciption: 61 // Initialize when we go to render, or go to answer the 62 // IsRenderSupported question. Don't call unless we have 63 // a valid OpenGL context! 64 vtkGetMacro( Initialized, int ); 65 66 // Description: 67 // Release any graphics resources that are being consumed by this texture. 68 // The parameter window could be used to determine which graphic 69 // resources to release. 70 void ReleaseGraphicsResources(vtkWindow *); 71 72 protected: 73 vtkOpenGLVolumeTextureMapper3D(); 74 ~vtkOpenGLVolumeTextureMapper3D(); 75 76 //BTX 77 78 void GetLightInformation(vtkRenderer *ren, 79 vtkVolume *vol, 80 GLfloat lightDirection[2][4], 81 GLfloat lightDiffuseColor[2][4], 82 GLfloat lightSpecularColor[2][4], 83 GLfloat halfwayVector[2][4], 84 GLfloat *ambient ); 85 //ETX 86 87 int Initialized; 88 GLuint Volume1Index; 89 GLuint Volume2Index; 90 GLuint Volume3Index; 91 GLuint ColorLookupIndex; 92 GLuint AlphaLookupIndex; 93 vtkRenderWindow *RenderWindow; 94 95 bool SupportsCompressedTexture; 96 bool SupportsNonPowerOfTwoTextures; 97 98 // Actual internal texture format (uncompressed vs compressed) 99 // Computed in Render() 100 int InternalAlpha; // GLint 101 int InternalLA; // GLint 102 int InternalRGB; // GLint 103 int InternalRGBA; // GLint 104 105 void Initialize(vtkRenderer *r); 106 107 virtual void RenderNV(vtkRenderer *ren, vtkVolume *vol); 108 virtual void RenderFP(vtkRenderer *ren, vtkVolume *vol); 109 110 void RenderOneIndependentNoShadeFP( vtkRenderer *ren, 111 vtkVolume *vol ); 112 void RenderOneIndependentShadeFP( vtkRenderer *ren, vtkVolume *vol ); 113 void RenderTwoDependentNoShadeFP( vtkRenderer *ren, vtkVolume *vol ); 114 void RenderTwoDependentShadeFP( vtkRenderer *ren, vtkVolume *vol ); 115 void RenderFourDependentNoShadeFP( vtkRenderer *ren, vtkVolume *vol ); 116 void RenderFourDependentShadeFP( vtkRenderer *ren, vtkVolume *vol ); 117 118 void RenderOneIndependentNoShadeNV( vtkRenderer *ren, vtkVolume *vol ); 119 void RenderOneIndependentShadeNV( vtkRenderer *ren, vtkVolume *vol ); 120 void RenderTwoDependentNoShadeNV( vtkRenderer *ren, vtkVolume *vol ); 121 void RenderTwoDependentShadeNV( vtkRenderer *ren, vtkVolume *vol ); 122 void RenderFourDependentNoShadeNV( vtkRenderer *ren, vtkVolume *vol ); 123 void RenderFourDependentShadeNV( vtkRenderer *ren, vtkVolume *vol ); 124 125 void SetupOneIndependentTextures( vtkRenderer *ren, vtkVolume *vol ); 126 void SetupTwoDependentTextures( vtkRenderer *ren, vtkVolume *vol ); 127 void SetupFourDependentTextures( vtkRenderer *ren, vtkVolume *vol ); 128 129 void SetupRegisterCombinersNoShadeNV( vtkRenderer *ren, 130 vtkVolume *vol, 131 int components ); 132 133 void SetupRegisterCombinersShadeNV( vtkRenderer *ren, 134 vtkVolume *vol, 135 int components ); 136 137 void DeleteTextureIndex( GLuint *index ); 138 void CreateTextureIndex( GLuint *index ); 139 140 void RenderPolygons( vtkRenderer *ren, 141 vtkVolume *vol, 142 int stages[4] ); 143 144 void SetupProgramLocalsForShadingFP( vtkRenderer *ren, vtkVolume *vol ); 145 146 // Description: 147 // Check if we can support this texture size for the number of components. 148 int IsTextureSizeSupported(int size[3], 149 int components); 150 151 // Description: 152 // Common code for setting up interpolation / clamping on 3D textures 153 void Setup3DTextureParameters( vtkVolumeProperty *property ); 154 155 private: 156 vtkOpenGLVolumeTextureMapper3D(const vtkOpenGLVolumeTextureMapper3D&); // Not implemented. 157 void operator=(const vtkOpenGLVolumeTextureMapper3D&); // Not implemented. 158 }; 159 160 #endif 161