#include <ImFusion/Core/GL/ProgramCache.h>
Helper class to manage instances of the same base shader with different abstract includes and/or defines.
More...
Helper class to manage instances of the same base shader with different abstract includes and/or defines.
Both abstract shader includes and defines change the actual source code of an OpenGL shader. Often the same base shader is used for different combinations of shader includes/defines. ProgramCache class facilitates managing these shader instances for combinations of multiple abstract includes. Based on the type of the abstract include, it will return (and if needed lazy-instantiate it) the correct shader variant that has the corresponding include code expanded.
GL::Program& p1 = cache.getProgram(
"#define SOME_DEFINE");
GL::Program& p2 = cache.getProgram({abstractInclude1, abstractInclude2},
"#define SOME_DEFINE");
Helper class to manage instances of the same base shader with different abstract includes and/or defi...
Definition ProgramCache.h:39
OpenGL GLSL program with a fragment and optional vertex and geometry shader.
Definition Program.h:99
static std::unique_ptr< Program > createVertexFragment(const std::string &vertexShaderName, const std::string &framentShaderName, const std::string &defines="", Compilation compileBehavior=Compilation::Immediate)
Convenience function to instantiate a new OpenGL program consisting of a vertex and a fragment shader...
- Warning
- Make sure not to alter the abstract includes and/or defines of shaders returned by this class. Doing so may lead to subtle bugs or even crashes as ProgramCache does not track any changes to these shader settings done from the outside.
- See also
- GL::Program, GL::AbstractInclude
◆ ProgramCache()
Instantiates a ProgramCache based on the given reference shader.
- Parameters
-
referenceProgram | Reference shader, must not be null. |
cacheSize | Number of instances that can be cached. |
- Exceptions
-
◆ getProgram() [1/2]
Retrieves the correct shader version w.r.t the given abstract includes.
- Parameters
-
includes | Vector of abstract includes |
additionalDefines | Set of defines inserted into the shader header. |
- Exceptions
-
◆ getProgram() [2/2]
Convenience overload that retrieves the shader with the given additional defines but without any additional includes.
- Parameters
-
additionalDefines | Set of defines inserted into the shader header. |
- Exceptions
-
The documentation for this class was generated from the following file:
- ImFusion/Core/GL/ProgramCache.h