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
32class vtkWindow;
33
34class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLShaderCache : public vtkObject
35{
36public:
39 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
40
41 // make sure the specified shaders are compiled, linked, and bound
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
52 std::map<vtkShader::Type,vtkShader *> shaders,
53 vtkTransformFeedback *cap = NULL);
54
55 // make sure the specified shaders are compiled, linked, and bound
57 vtkShaderProgram *shader, vtkTransformFeedback *cap = NULL);
58
65
70
75 virtual void ClearLastShaderBound() { this->LastShaderBound = NULL; }
76 vtkGetObjectMacro(LastShaderBound, vtkShaderProgram);
77
78protected:
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);
93 std::map<vtkShader::Type,vtkShader *> shaders);
94 virtual int BindShader(vtkShaderProgram* shader);
95
96 class Private;
97 Private *Internal;
99
100private:
101 vtkOpenGLShaderCache(const vtkOpenGLShaderCache&) VTK_DELETE_FUNCTION;
102 void operator=(const vtkOpenGLShaderCache&) VTK_DELETE_FUNCTION;
103
104};
105
106#endif
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
manage Shader Programs within a context
virtual int BindShader(vtkShaderProgram *shader)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual vtkShaderProgram * ReadyShaderProgram(const char *vertexCode, const char *fragmentCode, const char *geometryCode, vtkTransformFeedback *cap=NULL)
virtual vtkShaderProgram * ReadyShaderProgram(std::map< vtkShader::Type, vtkShader * > shaders, vtkTransformFeedback *cap=NULL)
vtkShaderProgram * LastShaderBound
void ReleaseCurrentShader()
Release the current shader.
virtual unsigned int ReplaceShaderValues(std::string &VSSource, std::string &FSSource, std::string &GSSource)
static vtkOpenGLShaderCache * New()
virtual vtkShaderProgram * GetShaderProgram(std::map< vtkShader::Type, vtkShader * > shaders)
virtual vtkShaderProgram * ReadyShaderProgram(vtkShaderProgram *shader, vtkTransformFeedback *cap=NULL)
virtual void ReleaseGraphicsResources(vtkWindow *win)
Free up any resources being used by the provided shader.
virtual void ClearLastShaderBound()
Get/Clear the last Shader bound, called by shaders as they release their graphics resources.
virtual vtkShaderProgram * GetShaderProgram(const char *vertexCode, const char *fragmentCode, const char *geometryCode)
The ShaderProgram uses one or more Shader objects.
Manages a TransformFeedback buffer.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ string
Definition: vtkX3D.h:490