VTK
vtkOpenGLShaderCache.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenGLTexture.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 =========================================================================*/
22 #ifndef vtkOpenGLShaderCache_h
23 #define vtkOpenGLShaderCache_h
24 
25 #include "vtkRenderingOpenGL2Module.h" // For export macro
26 #include "vtkObject.h"
27 #include "vtkShader.h" // for vtkShader::Type
28 #include <map> // for methods
29 
31 class vtkShaderProgram;
32 class vtkWindow;
33 
34 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLShaderCache : public vtkObject
35 {
36 public:
37  static vtkOpenGLShaderCache *New();
39  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
40 
41  // make sure the specified shaders are compiled, linked, and bound
42  virtual vtkShaderProgram *ReadyShaderProgram(
43  const char *vertexCode,
44  const char *fragmentCode,
45  const char *geometryCode,
46  vtkTransformFeedback *cap = NULL);
47 
48  // make sure the specified shaders are compiled, linked, and bound
49  // will increment the reference count on the shaders if it
50  // needs to keep them around
51  virtual vtkShaderProgram *ReadyShaderProgram(
52  std::map<vtkShader::Type,vtkShader *> shaders,
53  vtkTransformFeedback *cap = NULL);
54 
55  // make sure the specified shaders are compiled, linked, and bound
56  virtual vtkShaderProgram *ReadyShaderProgram(
57  vtkShaderProgram *shader, vtkTransformFeedback *cap = NULL);
58 
64  void ReleaseCurrentShader();
65 
69  virtual void ReleaseGraphicsResources(vtkWindow *win);
70 
75  virtual void ClearLastShaderBound() { this->LastShaderBound = NULL; }
76  vtkGetObjectMacro(LastShaderBound, vtkShaderProgram);
77 
78 protected:
81 
82  // perform System and Output replacments in place. Returns
83  // the number of outputs
84  virtual unsigned int ReplaceShaderValues(
85  std::string &VSSource,
86  std::string &FSSource,
87  std::string &GSSource);
88 
89  virtual vtkShaderProgram* GetShaderProgram(const char *vertexCode,
90  const char *fragmentCode,
91  const char *geometryCode);
92  virtual vtkShaderProgram* GetShaderProgram(
93  std::map<vtkShader::Type,vtkShader *> shaders);
94  virtual int BindShader(vtkShaderProgram* shader);
95 
96  class Private;
97  Private *Internal;
99 
100 private:
101  vtkOpenGLShaderCache(const vtkOpenGLShaderCache&) VTK_DELETE_FUNCTION;
102  void operator=(const vtkOpenGLShaderCache&) VTK_DELETE_FUNCTION;
103 
104 };
105 
106 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
manage Shader Programs within a context
virtual void ClearLastShaderBound()
Get/Clear the last Shader bound, called by shaders as they release their graphics resources...
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
a simple class to control print indentation
Definition: vtkIndent.h:39
Manages a TransformFeedback buffer.
vtkShaderProgram * LastShaderBound
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
The ShaderProgram uses one or more Shader objects.