VTK
dox/Rendering/vtkShaderProgram2.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkShaderProgram2.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 =========================================================================*/
00027 #ifndef __vtkShaderProgram2_h
00028 #define __vtkShaderProgram2_h
00029 
00030 #include "vtkObject.h"
00031 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
00032 
00033 class vtkWindow;
00034 class vtkOpenGLRenderWindow;
00035 class vtkOpenGLExtensionManager;
00036 class vtkShaderProgram2Uniforms; // internal
00037 class vtkShader2Collection;
00038 class vtkUniformVariables;
00039 
00040 // Values for GetLastBuildStatus()
00041 enum vtkShaderProgram2BuildStatus
00042 {
00043   // one of the shaders failed to compile
00044   VTK_SHADER_PROGRAM2_COMPILE_FAILED=0,
00045   // all the shaders compiled successfully but the link failed
00046   VTK_SHADER_PROGRAM2_LINK_FAILED=1,
00047   // all the shaders compiled successfully and the link succeeded
00048   VTK_SHADER_PROGRAM2_LINK_SUCCEEDED=2
00049 };
00050 
00051 class VTK_RENDERING_EXPORT vtkShaderProgram2 : public vtkObject
00052 {
00053 public:
00054   static vtkShaderProgram2* New();
00055   vtkTypeMacro(vtkShaderProgram2, vtkObject);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059 
00060   static bool IsSupported(vtkOpenGLRenderWindow *context);
00061   static bool LoadExtensions(vtkOpenGLRenderWindow *context);
00063   
00065 
00070   vtkGetMacro(PrintErrors,bool);
00071   vtkSetMacro(PrintErrors,bool);
00073   
00075 
00079   void SetContext(vtkOpenGLRenderWindow *context);
00080   vtkGetObjectMacro(Context,vtkOpenGLRenderWindow);
00082 
00084 
00086   vtkGetObjectMacro(Shaders,vtkShader2Collection);
00088 
00092   bool HasVertexShaders();
00093   
00096   bool HasTessellationControlShaders();
00097   
00100   bool HasTessellationEvaluationShaders();
00101   
00103   bool HasGeometryShaders();
00104   
00108   bool HasFragmentShaders();
00109   
00111   bool IsValid();
00112   
00116   void Build();
00117   
00119   void SendUniforms();
00120   
00122 
00124   void PrintActiveUniformVariables(ostream &os,
00125                                    vtkIndent indent);
00127   
00130   void PrintActiveUniformVariablesOnCout();
00131   
00133   bool IsUsed();
00134   
00139   void Use();
00140   
00142   void Restore();
00143   
00146   void RestoreFixedPipeline();
00147 
00154   int GetLastBuildStatus();
00155   
00158   const char *GetLastLinkLog();
00159   
00162   const char *GetLastValidateLog();
00163   
00165   virtual void ReleaseGraphicsResources();
00166 
00170   int GetAttributeLocation(const char *name);
00171   
00173 
00175   vtkGetObjectMacro(UniformVariables,vtkUniformVariables);
00176   virtual void SetUniformVariables(vtkUniformVariables *variables);
00178   
00183   bool DisplayListUnderCreationInCompileMode();
00184   
00185 protected:
00186   vtkShaderProgram2();
00187   virtual ~vtkShaderProgram2();
00188   
00189   unsigned int Id; // actually GLuint. Initial value is 0.
00190   unsigned int SavedId;
00191   
00192   vtkTimeStamp LastLinkTime;
00193   vtkTimeStamp LastSendUniformsTime;
00194   
00195   vtkShaderProgram2Uniforms *Uniforms;
00196   vtkShader2Collection *Shaders;
00197   
00198   int LastBuildStatus; // Initial value is VTK_SHADER_PROGRAM2_COMPILE_FAILED
00199   
00200   char *LastLinkLog; // Initial value is the empty string ""='\0'
00201   size_t LastLinkLogCapacity; // Initial value is 8.
00202   
00203   char *LastValidateLog; // Initial value is the empty string ""='\0'
00204   size_t LastValidateLogCapacity; // Initial value is 8.
00205   
00206   vtkUniformVariables *UniformVariables; // Initial values is an empty list
00207   
00208   bool PrintErrors; // use vtkErrorMacro ?
00209   
00210   vtkOpenGLRenderWindow *Context;
00211   bool ExtensionsLoaded;
00212   
00213 private:
00214   vtkShaderProgram2(const vtkShaderProgram2&); // Not implemented.
00215   void operator=(const vtkShaderProgram2&); // Not implemented.
00216 };
00217 
00218 #endif