VTK  9.1.0
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 "vtkObject.h"
26#include "vtkRenderingOpenGL2Module.h" // For export macro
27#include "vtkShader.h" // for vtkShader::Type
28#include <map> // for methods
29
32class vtkWindow;
34
35class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLShaderCache : public vtkObject
36{
37public:
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
42 // make sure the specified shaders are compiled, linked, and bound
43 virtual vtkShaderProgram* ReadyShaderProgram(const char* vertexCode, const char* fragmentCode,
44 const char* geometryCode, vtkTransformFeedback* cap = nullptr);
45
46 // make sure the specified shaders are compiled, linked, and bound
47 // will increment the reference count on the shaders if it
48 // needs to keep them around
50 std::map<vtkShader::Type, vtkShader*> shaders, vtkTransformFeedback* cap = nullptr);
51
52 // make sure the specified shaders are compiled, linked, and bound
54 vtkShaderProgram* shader, vtkTransformFeedback* cap = nullptr);
55
62
67
72 virtual void ClearLastShaderBound() { this->LastShaderBound = nullptr; }
73 vtkGetObjectMacro(LastShaderBound, vtkShaderProgram);
74
75 // Set the time in seconds elapsed since the first render
76 void SetElapsedTime(float val) { this->ElapsedTime = val; }
77
78protected:
81
82 // perform System and Output replacements in place. Returns
83 // the number of outputs
84 virtual unsigned int ReplaceShaderValues(
85 std::string& VSSource, std::string& FSSource, std::string& GSSource);
86
88 const char* vertexCode, const char* fragmentCode, const char* geometryCode);
89 virtual vtkShaderProgram* GetShaderProgram(std::map<vtkShader::Type, vtkShader*> shaders);
90 virtual int BindShader(vtkShaderProgram* shader);
91
92 class Private;
93 Private* Internal;
95
98
100
101private:
103 void operator=(const vtkOpenGLShaderCache&) = delete;
104};
105
106#endif
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
OpenGL rendering window.
manage Shader Programs within a context
virtual vtkShaderProgram * ReadyShaderProgram(std::map< vtkShader::Type, vtkShader * > shaders, vtkTransformFeedback *cap=nullptr)
virtual int BindShader(vtkShaderProgram *shader)
~vtkOpenGLShaderCache() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetElapsedTime(float val)
virtual vtkShaderProgram * ReadyShaderProgram(vtkShaderProgram *shader, vtkTransformFeedback *cap=nullptr)
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 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)
virtual vtkShaderProgram * ReadyShaderProgram(const char *vertexCode, const char *fragmentCode, const char *geometryCode, vtkTransformFeedback *cap=nullptr)
The ShaderProgram uses one or more Shader objects.
Manages a TransformFeedback buffer.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39