VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkOpenGLProperty.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00022 #ifndef vtkOpenGLProperty_h 00023 #define vtkOpenGLProperty_h 00024 00025 #include "vtkRenderingOpenGLModule.h" // For export macro 00026 #include "vtkProperty.h" 00027 00028 class vtkGLSLShaderDeviceAdapter2; 00029 class vtkOpenGLRenderer; 00030 class vtkOpenGLRenderWindow; 00031 class vtkShader2; 00032 class vtkShader2Collection; 00033 class vtkShaderDeviceAdapter2; 00034 class vtkShaderProgram2; 00035 00036 class VTKRENDERINGOPENGL_EXPORT vtkOpenGLProperty : public vtkProperty 00037 { 00038 public: 00039 static vtkOpenGLProperty *New(); 00040 vtkTypeMacro(vtkOpenGLProperty, vtkProperty); 00041 virtual void PrintSelf(ostream& os, vtkIndent indent); 00042 00044 void Render(vtkActor *a, vtkRenderer *ren); 00045 00047 void BackfaceRender(vtkActor *a, vtkRenderer *ren); 00048 00049 //BTX 00051 00053 virtual void PostRender(vtkActor *a, 00054 vtkRenderer *r); 00056 00060 virtual void ReleaseGraphicsResources(vtkWindow *win); 00061 00063 00065 vtkGetObjectMacro(PropProgram, vtkShaderProgram2); 00066 void SetPropProgram(vtkShaderProgram2 *); 00068 00070 virtual vtkShaderDeviceAdapter2* GetShaderDeviceAdapter2(); 00071 00073 00074 vtkGetObjectMacro(CurrentShaderProgram2, vtkShaderProgram2); 00075 //ETX 00077 00079 00083 virtual void AddShaderVariable(const char *name, int numVars, int *x); 00084 virtual void AddShaderVariable(const char *name, int numVars, float *x); 00085 virtual void AddShaderVariable(const char *name, int numVars, double *x); 00087 00089 00090 static void SetMaterialProperties(unsigned int face, 00091 double ambient, const double ambient_color[3], 00092 double diffuse, const double diffuse_color[3], 00093 double specular, const double specular_color[3], double specular_power, 00094 double opacity, vtkOpenGLRenderWindow* context); 00096 00097 protected: 00098 vtkOpenGLProperty(); 00099 ~vtkOpenGLProperty(); 00100 00104 bool RenderShaders(vtkActor* actor, vtkRenderer* renderer); 00105 00107 00109 bool RenderTextures(vtkActor* actor, vtkRenderer* renderer, 00110 bool using_shader_program2); 00112 00114 void LoadMultiTexturingExtensions(vtkRenderer* ren); 00115 00116 // Owned. Result of merging the shader program of the renderer 00117 // and the PropProgram. 00118 vtkShaderProgram2 *CachedShaderProgram2; 00119 00120 vtkShaderProgram2 *LastRendererShaderProgram2; // just a ref 00121 vtkShaderProgram2 *LastPropProgram; // just a ref 00122 vtkShaderProgram2 *PropProgram; // owned 00123 00124 // Point to CachedShaderProgram2 if Shading is on and the context 00125 // supports it. 00126 vtkShaderProgram2 *CurrentShaderProgram2; 00127 00128 vtkShader2 *DefaultMainVS; 00129 vtkShader2 *DefaultMainFS; 00130 vtkShader2 *DefaultPropVS; 00131 vtkShader2 *DefaultPropFS; 00132 bool UseDefaultMainVS; 00133 bool UseDefaultMainFS; 00134 bool UseDefaultPropVS; 00135 bool UseDefaultPropFS; 00136 vtkGLSLShaderDeviceAdapter2 *ShaderDeviceAdapter2; 00137 00138 private: 00139 vtkOpenGLProperty(const vtkOpenGLProperty&); // Not implemented. 00140 void operator=(const vtkOpenGLProperty&); // Not implemented. 00141 }; 00142 00143 #endif