VTK
vtkShaderProgram2.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkShaderProgram2.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
27 #ifndef __vtkShaderProgram2_h
28 #define __vtkShaderProgram2_h
29 
30 #include "vtkRenderingOpenGLModule.h" // For export macro
31 #include "vtkObject.h"
32 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
33 
34 class vtkWindow;
37 class vtkShaderProgram2Uniforms; // internal
40 
41 // Values for GetLastBuildStatus()
43 {
44  // one of the shaders failed to compile
46  // all the shaders compiled successfully but the link failed
48  // all the shaders compiled successfully and the link succeeded
50 };
51 
53 {
59 };
60 
62 {
66 };
67 
68 class VTKRENDERINGOPENGL_EXPORT vtkShaderProgram2 : public vtkObject
69 {
70 public:
71  static vtkShaderProgram2* New();
72  vtkTypeMacro(vtkShaderProgram2, vtkObject);
73  void PrintSelf(ostream& os, vtkIndent indent);
74 
76 
77  static bool IsSupported(vtkOpenGLRenderWindow *context);
78  static bool LoadExtensions(vtkOpenGLRenderWindow *context);
80 
82 
87  vtkGetMacro(PrintErrors,bool);
88  vtkSetMacro(PrintErrors,bool);
90 
92 
96  void SetContext(vtkOpenGLRenderWindow *context);
97  vtkGetObjectMacro(Context,vtkOpenGLRenderWindow);
99 
101 
103  vtkGetObjectMacro(Shaders,vtkShader2Collection);
105 
109  bool HasVertexShaders();
110 
113  bool HasTessellationControlShaders();
114 
117  bool HasTessellationEvaluationShaders();
118 
120  bool HasGeometryShaders();
121 
125  bool HasFragmentShaders();
126 
131  bool IsValid();
132 
137  void Build();
138 
143  void SendUniforms();
144 
146 
150  void PrintActiveUniformVariables(ostream &os,
151  vtkIndent indent);
153 
158  void PrintActiveUniformVariablesOnCout();
159 
163  bool IsUsed();
164 
169  void Use();
170 
174  void Restore();
175 
180  void RestoreFixedPipeline();
181 
188  int GetLastBuildStatus();
189 
192  const char *GetLastLinkLog();
193 
196  const char *GetLastValidateLog();
197 
199  virtual void ReleaseGraphicsResources();
200 
206  int GetAttributeLocation(const char *name);
207 
209 
211  vtkGetObjectMacro(UniformVariables,vtkUniformVariables);
212  virtual void SetUniformVariables(vtkUniformVariables *variables);
214 
221  bool DisplayListUnderCreationInCompileMode();
222 
224 
234  vtkSetMacro(GeometryTypeIn,int);
235  vtkGetMacro(GeometryTypeIn,int);
237 
239 
246  vtkSetMacro(GeometryVerticesOut,int);
247  vtkGetMacro(GeometryVerticesOut,int);
249 
251 
259  vtkSetMacro(GeometryTypeOut,int);
260  vtkGetMacro(GeometryTypeOut,int);
262 
263 protected:
265  virtual ~vtkShaderProgram2();
266 
267  unsigned int Id; // actually GLuint. Initial value is 0.
268  unsigned int SavedId;
269 
272 
273  vtkShaderProgram2Uniforms *Uniforms;
275 
276  int LastBuildStatus; // Initial value is VTK_SHADER_PROGRAM2_COMPILE_FAILED
277 
278  char *LastLinkLog; // Initial value is the empty string ""='\0'
279  size_t LastLinkLogCapacity; // Initial value is 8.
280 
281  char *LastValidateLog; // Initial value is the empty string ""='\0'
282  size_t LastValidateLogCapacity; // Initial value is 8.
283 
284  vtkUniformVariables *UniformVariables; // Initial values is an empty list
285 
286  bool PrintErrors; // use vtkErrorMacro ?
287 
290 
294 
295 private:
296  vtkShaderProgram2(const vtkShaderProgram2&); // Not implemented.
297  void operator=(const vtkShaderProgram2&); // Not implemented.
298 };
299 
300 #endif