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 "vtkObject.h"
31 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
32 
33 class vtkWindow;
36 class vtkShaderProgram2Uniforms; // internal
39 
40 // Values for GetLastBuildStatus()
42 {
43  // one of the shaders failed to compile
45  // all the shaders compiled successfully but the link failed
47  // all the shaders compiled successfully and the link succeeded
49 };
50 
52 {
58 };
59 
61 {
65 };
66 
68 {
69 public:
70  static vtkShaderProgram2* New();
71  vtkTypeMacro(vtkShaderProgram2, vtkObject);
72  void PrintSelf(ostream& os, vtkIndent indent);
73 
75 
76  static bool IsSupported(vtkOpenGLRenderWindow *context);
77  static bool LoadExtensions(vtkOpenGLRenderWindow *context);
79 
81 
86  vtkGetMacro(PrintErrors,bool);
87  vtkSetMacro(PrintErrors,bool);
89 
91 
95  void SetContext(vtkOpenGLRenderWindow *context);
96  vtkGetObjectMacro(Context,vtkOpenGLRenderWindow);
98 
100 
102  vtkGetObjectMacro(Shaders,vtkShader2Collection);
104 
108  bool HasVertexShaders();
109 
112  bool HasTessellationControlShaders();
113 
116  bool HasTessellationEvaluationShaders();
117 
119  bool HasGeometryShaders();
120 
124  bool HasFragmentShaders();
125 
130  bool IsValid();
131 
136  void Build();
137 
142  void SendUniforms();
143 
145 
149  void PrintActiveUniformVariables(ostream &os,
150  vtkIndent indent);
152 
157  void PrintActiveUniformVariablesOnCout();
158 
162  bool IsUsed();
163 
168  void Use();
169 
173  void Restore();
174 
179  void RestoreFixedPipeline();
180 
187  int GetLastBuildStatus();
188 
191  const char *GetLastLinkLog();
192 
195  const char *GetLastValidateLog();
196 
198  virtual void ReleaseGraphicsResources();
199 
205  int GetAttributeLocation(const char *name);
206 
208 
210  vtkGetObjectMacro(UniformVariables,vtkUniformVariables);
211  virtual void SetUniformVariables(vtkUniformVariables *variables);
213 
220  bool DisplayListUnderCreationInCompileMode();
221 
223 
233  vtkSetMacro(GeometryTypeIn,int);
234  vtkGetMacro(GeometryTypeIn,int);
236 
238 
245  vtkSetMacro(GeometryVerticesOut,int);
246  vtkGetMacro(GeometryVerticesOut,int);
248 
250 
258  vtkSetMacro(GeometryTypeOut,int);
259  vtkGetMacro(GeometryTypeOut,int);
261 
262 protected:
264  virtual ~vtkShaderProgram2();
265 
266  unsigned int Id; // actually GLuint. Initial value is 0.
267  unsigned int SavedId;
268 
271 
272  vtkShaderProgram2Uniforms *Uniforms;
274 
275  int LastBuildStatus; // Initial value is VTK_SHADER_PROGRAM2_COMPILE_FAILED
276 
277  char *LastLinkLog; // Initial value is the empty string ""='\0'
278  size_t LastLinkLogCapacity; // Initial value is 8.
279 
280  char *LastValidateLog; // Initial value is the empty string ""='\0'
281  size_t LastValidateLogCapacity; // Initial value is 8.
282 
283  vtkUniformVariables *UniformVariables; // Initial values is an empty list
284 
285  bool PrintErrors; // use vtkErrorMacro ?
286 
289 
293 
294 private:
295  vtkShaderProgram2(const vtkShaderProgram2&); // Not implemented.
296  void operator=(const vtkShaderProgram2&); // Not implemented.
297 };
298 
299 #endif