VTK
vtkShader2.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkShader2.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 =========================================================================*/
42 #ifndef vtkShader2_h
43 #define vtkShader2_h
44 
45 #include "vtkWeakPointer.h" // for ren context
46 #include "vtkRenderingOpenGLModule.h" // For export macro
47 #include "vtkObject.h"
48 
49 // Values for GetType()/SetType()
51 {
53  VTK_SHADER_TYPE_TESSELLATION_CONTROL = 3, // new, not supported yet
54  VTK_SHADER_TYPE_TESSELLATION_EVALUATION = 4, // new, not supported yet
57 };
58 
59 class vtkRenderWindow;
61 
62 class VTKRENDERINGOPENGL_EXPORT vtkShader2 : public vtkObject
63 {
64 public:
65  static vtkShader2 *New();
66  vtkTypeMacro(vtkShader2,vtkObject);
67  void PrintSelf(ostream &os, vtkIndent indent);
68 
73  static bool IsSupported(vtkRenderWindow *context);
74 
76 
80  vtkGetStringMacro(SourceCode);
81  vtkSetStringMacro(SourceCode);
83 
85 
93  vtkGetMacro(Type,int);
95 
97 
106  vtkSetMacro(Type,int);
108 
112  const char *GetTypeAsString();
113 
120  void Compile();
121 
127 
133  const char *GetLastCompileLog();
134 
136 
142  void SetContext(vtkRenderWindow *context);
145 
149  virtual void ReleaseGraphicsResources();
150 
152 
155  vtkGetMacro(Id,unsigned int);
157 
159 
163  vtkGetObjectMacro(UniformVariables,vtkUniformVariables);
164  virtual void SetUniformVariables(vtkUniformVariables *variables);
166 
167 protected:
172 
176  virtual ~vtkShader2();
177 
182 
183  char *SourceCode;
184  int Type;
185 
186  unsigned int Id; // actually GLuint. Initial value is 0.
187 
188  bool LastCompileStatus; // Initial value is false.
189  char *LastCompileLog; // Initial value is the empty string ""='\0'.
190  size_t LastCompileLogCapacity; // Initial value is 8.
191 
193  vtkUniformVariables *UniformVariables; // Initial values is an empty list
194 
196 
199 
200 private:
201  vtkShader2(const vtkShader2&) VTK_DELETE_FUNCTION;
202  void operator=(const vtkShader2&) VTK_DELETE_FUNCTION;
203 };
204 
205 #endif
vtkShader2::GetLastCompileLog
const char * GetLastCompileLog()
Return the log of the last call to compile as a string.
VTK_SHADER_TYPE_TESSELLATION_CONTROL
@ VTK_SHADER_TYPE_TESSELLATION_CONTROL
Definition: vtkShader2.h:53
vtkShader2::SetUniformVariables
virtual void SetUniformVariables(vtkUniformVariables *variables)
vtkShader2::LastCompileLog
char * LastCompileLog
Definition: vtkShader2.h:189
vtkShader2::GetTypeAsString
const char * GetTypeAsString()
Return the shader type as a string.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkShader2::SourceCode
char * SourceCode
Definition: vtkShader2.h:183
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkShader2::SetContext
void SetContext(vtkRenderWindow *context)
Get/Set the context.
vtkShader2::Context
vtkWeakPointer< vtkRenderWindow > Context
Definition: vtkShader2.h:195
vtkShader2::GetLastCompileStatus
bool GetLastCompileStatus()
Tells if the last call to compile succeeded (true) or not (false).
vtkShader2::LastCompileLogCapacity
size_t LastCompileLogCapacity
Definition: vtkShader2.h:190
VTK_SHADER_TYPE_FRAGMENT
@ VTK_SHADER_TYPE_FRAGMENT
Definition: vtkShader2.h:56
vtkShader2::IsSupported
static bool IsSupported(vtkRenderWindow *context)
Returns if the context supports the required extensions.
vtkShader2::Id
unsigned int Id
Definition: vtkShader2.h:186
vtkShader2::LastCompileStatus
bool LastCompileStatus
Definition: vtkShader2.h:188
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkShader2::LoadRequiredExtensions
bool LoadRequiredExtensions(vtkRenderWindow *context)
Load the required OpenGL extensions.
vtkShader2::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources()
Release OpenGL resource (shader id).
vtkShader2::SupportGeometryShader
bool SupportGeometryShader
Definition: vtkShader2.h:198
vtkWeakPointer.h
vtkShader2::~vtkShader2
virtual ~vtkShader2()
Destructor.
vtkGetStringMacro
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkShader2::UniformVariables
vtkUniformVariables * UniformVariables
Definition: vtkShader2.h:193
vtkUniformVariables
GLSL uniform variables.
Definition: vtkUniformVariables.h:39
vtkShader2::Type
int Type
Definition: vtkShader2.h:184
vtkObject.h
vtkShader2::GetContext
vtkRenderWindow * GetContext()
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
VTK_SHADER_TYPE_TESSELLATION_EVALUATION
@ VTK_SHADER_TYPE_TESSELLATION_EVALUATION
Definition: vtkShader2.h:54
vtkShader2Type
vtkShader2Type
Definition: vtkShader2.h:51
VTK_SHADER_TYPE_VERTEX
@ VTK_SHADER_TYPE_VERTEX
Definition: vtkShader2.h:52
vtkShader2
GLSL Shader.
Definition: vtkShader2.h:63
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:87
vtkShader2::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkShader2::Compile
void Compile()
Compile the shader code.
vtkShader2::New
static vtkShader2 * New()
vtkShader2::vtkShader2
vtkShader2()
Default constructor.
vtkShader2::ExtensionsLoaded
bool ExtensionsLoaded
Definition: vtkShader2.h:197
vtkWeakPointer< vtkRenderWindow >
vtkShader2::LastCompileTime
vtkTimeStamp LastCompileTime
Definition: vtkShader2.h:192
VTK_SHADER_TYPE_GEOMETRY
@ VTK_SHADER_TYPE_GEOMETRY
Definition: vtkShader2.h:55