00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkShader2.h,v $ 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 =========================================================================*/ 00033 #ifndef __vtkShader2_h 00034 #define __vtkShader2_h 00035 00036 #include "vtkObject.h" 00037 00038 // Values for GetType()/SetType() 00039 enum vtkShader2Type 00040 { 00041 VTK_SHADER_TYPE_VERTEX=0, 00042 VTK_SHADER_TYPE_GEOMETRY=1, 00043 VTK_SHADER_TYPE_FRAGMENT=2 00044 // VTK_SHADER_TYPE_HULL=3, // speculation on DX11, not supported yet. 00045 // VTK_SHADER_TYPE_DOMAIN=4 // speculation on DX11, not supported yet. 00046 }; 00047 00048 class vtkOpenGLRenderWindow; 00049 class vtkUniformVariables; 00050 00051 class VTK_RENDERING_EXPORT vtkShader2 : public vtkObject 00052 { 00053 public: 00054 static vtkShader2 *New(); 00055 vtkTypeRevisionMacro(vtkShader2,vtkObject); 00056 void PrintSelf(ostream &os, vtkIndent indent); 00057 00059 00060 static bool IsSupported(vtkOpenGLRenderWindow *context); 00061 static bool LoadExtensions(vtkOpenGLRenderWindow *context); 00063 00065 00067 vtkGetStringMacro(SourceCode); 00068 vtkSetStringMacro(SourceCode); 00070 00072 00075 vtkGetMacro(Type,int); 00077 00079 00082 vtkSetMacro(Type,int); 00084 00086 const char *GetTypeAsString(); 00087 00091 void Compile(); 00092 00095 bool GetLastCompileStatus(); 00096 00099 const char *GetLastCompileLog(); 00100 00102 00106 void SetContext(vtkOpenGLRenderWindow *context); 00107 vtkGetObjectMacro(Context,vtkOpenGLRenderWindow); 00109 00111 virtual void ReleaseGraphicsResources(); 00112 00114 00115 vtkGetMacro(Id,unsigned int); 00117 00119 00121 vtkGetObjectMacro(UniformVariables,vtkUniformVariables); 00122 virtual void SetUniformVariables(vtkUniformVariables *variables); 00124 00125 protected: 00127 vtkShader2(); 00128 00130 virtual ~vtkShader2(); 00131 00132 char *SourceCode; 00133 int Type; 00134 00135 unsigned int Id; // actually GLuint. Initial value is 0. 00136 00137 bool LastCompileStatus; // Initial value is false. 00138 char *LastCompileLog; // Initial value is the empty string ""='\0'. 00139 size_t LastCompileLogCapacity; // Initial value is 8. 00140 00141 vtkTimeStamp LastCompileTime; 00142 vtkUniformVariables *UniformVariables; // Initial values is an empty list 00143 vtkOpenGLRenderWindow *Context; 00144 00145 bool ExtensionsLoaded; 00146 bool SupportGeometryShader; 00147 00148 private: 00149 vtkShader2(const vtkShader2&); // Not implemented. 00150 void operator=(const vtkShader2&); // Not implemented. 00151 }; 00152 00153 #endif