VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004 
00005   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00023 #ifndef vtkOpenGLPolyDataMapper_h
00024 #define vtkOpenGLPolyDataMapper_h
00025 
00026 #include "vtkRenderingOpenGL2Module.h" // For export macro
00027 #include "vtkPolyDataMapper.h"
00028 #include "vtkglVBOHelper.h" // used for ivars
00029 
00030 class vtkOpenGLTexture;
00031 class vtkMatrix4x4;
00032 class vtkMatrix3x3;
00033 
00034 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLPolyDataMapper : public vtkPolyDataMapper
00035 {
00036 public:
00037   static vtkOpenGLPolyDataMapper* New();
00038   vtkTypeMacro(vtkOpenGLPolyDataMapper, vtkPolyDataMapper)
00039   void PrintSelf(ostream& os, vtkIndent indent);
00040 
00042   virtual void RenderPiece(vtkRenderer *ren, vtkActor *act);
00043 
00045 
00046   virtual void RenderPieceStart(vtkRenderer *ren, vtkActor *act);
00047   virtual void RenderPieceDraw(vtkRenderer *ren, vtkActor *act);
00048   virtual void RenderPieceFinish(vtkRenderer *ren, vtkActor *act);
00049   virtual void RenderEdges(vtkRenderer *ren, vtkActor *act);
00051 
00055   void ReleaseGraphicsResources(vtkWindow *);
00056 
00057   vtkGetMacro(PopulateSelectionSettings,int);
00058   void SetPopulateSelectionSettings(int v) { this->PopulateSelectionSettings = v; };
00059 
00064   virtual bool GetSupportsSelection() { return true; }
00065 
00074   virtual bool GetIsOpaque();
00075 
00076   // used by RenderPiece and functions it calls to reduce
00077   // calls to get the input and allow for rendering of
00078   // other polydata (not the input)
00079   vtkPolyData *CurrentInput;
00080 
00084   virtual vtkIdType GetConvertedPickValue(vtkIdType idIn, int fieldassociation, vtkActor *act);
00085 
00086 protected:
00087   vtkOpenGLPolyDataMapper();
00088   ~vtkOpenGLPolyDataMapper();
00089 
00094   virtual void ComputeBounds();
00095 
00099   virtual void UpdateShader(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
00100 
00102   virtual bool GetNeedToRebuildShader(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
00103 
00105 
00106   virtual void BuildShader(std::string &VertexCode,
00107                            std::string &fragmentCode,
00108                            std::string &geometryCode,
00109                            int lightComplexity,
00110                            vtkRenderer *ren, vtkActor *act);
00112 
00114 
00115   virtual void GetShaderTemplate(std::string &VertexCode,
00116                            std::string &fragmentCode,
00117                            std::string &geometryCode,
00118                            int lightComplexity,
00119                            vtkRenderer *ren, vtkActor *act);
00121 
00123 
00124   virtual void ReplaceShaderValues(std::string &VertexCode,
00125                            std::string &fragmentCode,
00126                            std::string &geometryCode,
00127                            int lightComplexity,
00128                            vtkRenderer *ren, vtkActor *act);
00130 
00132 
00134   virtual void ReplaceShaderColorMaterialValues(std::string &VertexCode,
00135                            std::string &fragmentCode,
00136                            std::string &geometryCode,
00137                            int lightComplexity,
00138                            vtkRenderer *ren, vtkActor *act);
00140 
00143   virtual void SetMapperShaderParameters(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
00144 
00147   virtual void SetLightingShaderParameters(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
00148 
00151   virtual void SetCameraShaderParameters(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
00152 
00155   virtual void SetPropertyShaderParameters(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
00156 
00158   virtual void UpdateBufferObjects(vtkRenderer *ren, vtkActor *act);
00159 
00161   virtual bool GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act);
00162 
00164   virtual void BuildBufferObjects(vtkRenderer *ren, vtkActor *act);
00165 
00166   // The VBO and its layout.
00167   vtkgl::BufferObject VBO;
00168   vtkgl::VBOLayout Layout;
00169 
00170   // Structures for the various cell types we render.
00171   vtkgl::CellBO Points;
00172   vtkgl::CellBO Lines;
00173   vtkgl::CellBO Tris;
00174   vtkgl::CellBO TriStrips;
00175   vtkgl::CellBO TrisEdges;
00176   vtkgl::CellBO TriStripsEdges;
00177   vtkgl::CellBO *LastBoundBO;
00178   bool DrawingEdges;
00179 
00180   // values we use to determine if we need to rebuild
00181   int LastLightComplexity;
00182   vtkTimeStamp LightComplexityChanged;
00183 
00184   bool LastSelectionState;
00185   vtkTimeStamp SelectionStateChanged;
00186 
00187   int LastDepthPeeling;
00188   vtkTimeStamp DepthPeelingChanged;
00189 
00190   bool UsingScalarColoring;
00191   vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
00192   vtkOpenGLTexture* InternalColorTexture;
00193 
00194   int PopulateSelectionSettings;
00195   int pickingAttributeIDOffset;
00196 
00197   vtkMatrix4x4 *TempMatrix4;
00198   vtkMatrix3x3 *TempMatrix3;
00199 
00200   // this vector can be used while building
00201   // the shader program to record specific variables
00202   // that are being used by the program. This is
00203   // useful later on when setting uniforms. At
00204   // that point IsShaderVariableUsed can be called
00205   // to see if the uniform should be set or not.
00206   std::vector<std::string> ShaderVariablesUsed;
00207 
00208   // used to see if the shader building code indicated that
00209   // a specific variable is being used. Only some variables
00210   // are currently populated.
00211   bool IsShaderVariableUsed(const char *);
00212 
00213 private:
00214   vtkOpenGLPolyDataMapper(const vtkOpenGLPolyDataMapper&); // Not implemented.
00215   void operator=(const vtkOpenGLPolyDataMapper&); // Not implemented.
00216 };
00217 
00218 #endif