VTK
dox/Rendering/OpenGL/vtkShader2.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkShader2.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 =========================================================================*/
00041 #ifndef __vtkShader2_h
00042 #define __vtkShader2_h
00043 
00044 #include "vtkWeakPointer.h" // for ren context
00045 #include "vtkRenderingOpenGLModule.h" // For export macro
00046 #include "vtkObject.h"
00047 
00048 // Values for GetType()/SetType()
00049 enum vtkShader2Type
00050 {
00051   VTK_SHADER_TYPE_VERTEX = 0,
00052   VTK_SHADER_TYPE_TESSELLATION_CONTROL = 3, // new, not supported yet
00053   VTK_SHADER_TYPE_TESSELLATION_EVALUATION = 4, // new, not supported yet
00054   VTK_SHADER_TYPE_GEOMETRY = 1,
00055   VTK_SHADER_TYPE_FRAGMENT = 2
00056 };
00057 
00058 class vtkRenderWindow;
00059 class vtkUniformVariables;
00060 
00061 class VTKRENDERINGOPENGL_EXPORT vtkShader2 : public vtkObject
00062 {
00063 public:
00064   static vtkShader2 *New();
00065   vtkTypeMacro(vtkShader2,vtkObject);
00066   void PrintSelf(ostream &os, vtkIndent indent);
00067 
00070   static bool IsSupported(vtkRenderWindow *context);
00071 
00073 
00075   vtkGetStringMacro(SourceCode);
00076   vtkSetStringMacro(SourceCode);
00078 
00080 
00085   vtkGetMacro(Type,int);
00087 
00089 
00094   vtkSetMacro(Type,int);
00096 
00098   const char *GetTypeAsString();
00099 
00103   void Compile();
00104 
00107   bool GetLastCompileStatus();
00108 
00111   const char *GetLastCompileLog();
00112 
00114 
00118   void SetContext(vtkRenderWindow *context);
00119   vtkRenderWindow *GetContext();
00121 
00123   virtual void ReleaseGraphicsResources();
00124 
00126 
00127   vtkGetMacro(Id,unsigned int);
00129 
00131 
00133   vtkGetObjectMacro(UniformVariables,vtkUniformVariables);
00134   virtual void SetUniformVariables(vtkUniformVariables *variables);
00136 
00137 protected:
00139   vtkShader2();
00140 
00142   virtual ~vtkShader2();
00143 
00145   bool LoadRequiredExtensions(vtkRenderWindow *context);
00146 
00147   char *SourceCode;
00148   int Type;
00149 
00150   unsigned int Id; // actually GLuint. Initial value is 0.
00151 
00152   bool LastCompileStatus; // Initial value is false.
00153   char *LastCompileLog; // Initial value is the empty string ""='\0'.
00154   size_t LastCompileLogCapacity; // Initial value is 8.
00155 
00156   vtkTimeStamp LastCompileTime;
00157   vtkUniformVariables *UniformVariables; // Initial values is an empty list
00158 
00159   vtkWeakPointer<vtkRenderWindow> Context;
00160 
00161   bool ExtensionsLoaded;
00162   bool SupportGeometryShader;
00163 
00164 private:
00165   vtkShader2(const vtkShader2&); // Not implemented.
00166   void operator=(const vtkShader2&); // Not implemented.
00167 };
00168 
00169 #endif