VTK
dox/Rendering/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 "vtkObject.h"
00045 
00046 // Values for GetType()/SetType()
00047 enum vtkShader2Type
00048 {
00049   VTK_SHADER_TYPE_VERTEX=0,
00050   VTK_SHADER_TYPE_TESSELLATION_CONTROL=3, // new, not supported yet
00051   VTK_SHADER_TYPE_TESSELLATION_EVALUATION=4, // new, not supported yet
00052   VTK_SHADER_TYPE_GEOMETRY=1,
00053   VTK_SHADER_TYPE_FRAGMENT=2
00054 };
00055 
00056 class vtkOpenGLRenderWindow;
00057 class vtkUniformVariables;
00058 
00059 class VTK_RENDERING_EXPORT vtkShader2 : public vtkObject
00060 {
00061 public:
00062   static vtkShader2 *New();
00063   vtkTypeMacro(vtkShader2,vtkObject);
00064   void PrintSelf(ostream &os, vtkIndent indent);
00065   
00067 
00068   static bool IsSupported(vtkOpenGLRenderWindow *context);
00069   static bool LoadExtensions(vtkOpenGLRenderWindow *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(vtkOpenGLRenderWindow *context);
00119   vtkGetObjectMacro(Context,vtkOpenGLRenderWindow);
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   
00144   char *SourceCode;
00145   int Type;
00146   
00147   unsigned int Id; // actually GLuint. Initial value is 0.
00148   
00149   bool LastCompileStatus; // Initial value is false.
00150   char *LastCompileLog; // Initial value is the empty string ""='\0'.
00151   size_t LastCompileLogCapacity; // Initial value is 8.
00152   
00153   vtkTimeStamp LastCompileTime;
00154   vtkUniformVariables *UniformVariables; // Initial values is an empty list
00155   vtkOpenGLRenderWindow *Context;
00156   
00157   bool ExtensionsLoaded;
00158   bool SupportGeometryShader;
00159   
00160 private:
00161   vtkShader2(const vtkShader2&); // Not implemented.
00162   void operator=(const vtkShader2&); // Not implemented.
00163 };
00164 
00165 #endif