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 =========================================================================*/
21 #ifndef vtkOpenGLShaderCache_h
22 #define vtkOpenGLShaderCache_h
23 
24 #include "vtkRenderingOpenGL2Module.h" // For export macro
25 #include "vtkObject.h"
26 #include "vtkShader.h" // for vtkShader::Type
27 #include <map> // for methods
28 
29 class vtkShaderProgram;
30 class vtkWindow;
31 
33 {
34 public:
35  static vtkOpenGLShaderCache *New();
37  virtual void PrintSelf(ostream& os, vtkIndent indent);
38 
39  // make sure the specified shaders are compiled, linked, and bound
40  virtual vtkShaderProgram *ReadyShaderProgram(
41  const char *vertexCode,
42  const char *fragmentCode,
43  const char *geometryCode);
44 
45  // make sure the specified shaders are compiled, linked, and bound
46  // will increment the reference count on the shaders if it
47  // needs to keep them around
48  virtual vtkShaderProgram *ReadyShaderProgram(
49  std::map<vtkShader::Type,vtkShader *> shaders);
50 
51  // make sure the specified shaders are compiled, linked, and bound
52  virtual vtkShaderProgram *ReadyShaderProgram(vtkShaderProgram *shader);
53 
57  void ReleaseCurrentShader();
58 
60  virtual void ReleaseGraphicsResources(vtkWindow *win);
61 
63 
65  virtual void ClearLastShaderBound() { this->LastShaderBound = NULL; }
66  vtkGetObjectMacro(LastShaderBound, vtkShaderProgram);
68 
69 protected:
72 
73  // perform System and Output replacments in place. Returns
74  // the number of outputs
75  virtual unsigned int ReplaceShaderValues(
76  std::string &VSSource,
77  std::string &FSSource,
78  std::string &GSSource);
79 
80  virtual vtkShaderProgram* GetShaderProgram(const char *vertexCode,
81  const char *fragmentCode,
82  const char *geometryCode);
83  virtual vtkShaderProgram* GetShaderProgram(
84  std::map<vtkShader::Type,vtkShader *> shaders);
85  virtual int BindShader(vtkShaderProgram* shader);
86 
87  class Private;
88  Private *Internal;
90 
91 private:
92  vtkOpenGLShaderCache(const vtkOpenGLShaderCache&); // Not implemented.
93  void operator=(const vtkOpenGLShaderCache&); // Not implemented.
94 
95 };
96 
97 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:61
manage Shader Programs within a context
#define VTKRENDERINGOPENGL2_EXPORT
virtual void ClearLastShaderBound()
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkShaderProgram * LastShaderBound
static vtkObject * New()
The ShaderProgram uses one or more Shader objects.