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 "vtkRenderingOpenGLModule.h" // For export macro
00045 #include "vtkObject.h"
00046 
00047 // Values for GetType()/SetType()
00048 enum vtkShader2Type
00049 {
00050   VTK_SHADER_TYPE_VERTEX = 0,
00051   VTK_SHADER_TYPE_TESSELLATION_CONTROL = 3, // new, not supported yet
00052   VTK_SHADER_TYPE_TESSELLATION_EVALUATION = 4, // new, not supported yet
00053   VTK_SHADER_TYPE_GEOMETRY = 1,
00054   VTK_SHADER_TYPE_FRAGMENT = 2
00055 };
00056 
00057 class vtkOpenGLRenderWindow;
00058 class vtkUniformVariables;
00059 
00060 class VTKRENDERINGOPENGL_EXPORT vtkShader2 : public vtkObject
00061 {
00062 public:
00063   static vtkShader2 *New();
00064   vtkTypeMacro(vtkShader2,vtkObject);
00065   void PrintSelf(ostream &os, vtkIndent indent);
00066 
00068 
00069   static bool IsSupported(vtkOpenGLRenderWindow *context);
00070   static bool LoadExtensions(vtkOpenGLRenderWindow *context);
00072 
00074 
00076   vtkGetStringMacro(SourceCode);
00077   vtkSetStringMacro(SourceCode);
00079 
00081 
00086   vtkGetMacro(Type,int);
00088 
00090 
00095   vtkSetMacro(Type,int);
00097 
00099   const char *GetTypeAsString();
00100 
00104   void Compile();
00105 
00108   bool GetLastCompileStatus();
00109 
00112   const char *GetLastCompileLog();
00113 
00115 
00119   void SetContext(vtkOpenGLRenderWindow *context);
00120   vtkGetObjectMacro(Context,vtkOpenGLRenderWindow);
00122 
00124   virtual void ReleaseGraphicsResources();
00125 
00127 
00128   vtkGetMacro(Id,unsigned int);
00130 
00132 
00134   vtkGetObjectMacro(UniformVariables,vtkUniformVariables);
00135   virtual void SetUniformVariables(vtkUniformVariables *variables);
00137 
00138 protected:
00140   vtkShader2();
00141 
00143   virtual ~vtkShader2();
00144 
00145   char *SourceCode;
00146   int Type;
00147 
00148   unsigned int Id; // actually GLuint. Initial value is 0.
00149 
00150   bool LastCompileStatus; // Initial value is false.
00151   char *LastCompileLog; // Initial value is the empty string ""='\0'.
00152   size_t LastCompileLogCapacity; // Initial value is 8.
00153 
00154   vtkTimeStamp LastCompileTime;
00155   vtkUniformVariables *UniformVariables; // Initial values is an empty list
00156   vtkOpenGLRenderWindow *Context;
00157 
00158   bool ExtensionsLoaded;
00159   bool SupportGeometryShader;
00160 
00161 private:
00162   vtkShader2(const vtkShader2&); // Not implemented.
00163   void operator=(const vtkShader2&); // Not implemented.
00164 };
00165 
00166 #endif