LegacyOpenGLShader Class
An OpenGL-specific implementation of a Shader program, consisting of a vertex and a fragment shader. More...
Declaration
Base class
| class | Shader |
|
Abstract representation of a Shader program (e.g. composed of vertex/fragment shader). More... | |
Public Constructors Index
| LegacyOpenGLShader (const LegacyOpenGLShader &)=delete | |
|
Rule of three. More... | |
| LegacyOpenGLShader (const std::string &vertexShaderPath, const std::string &fragmentShaderPath, const helios::util::io::StringFileReader &stringFileReader) | |
|
Creates and initializes this LegacyOpenGLShader. An instance of this class is guaranteed to have a progId_ != 0, hence shader-files where successfully loaded and compiled, ready to be used. More... | |
Public Destructor Index
| ~LegacyOpenGLShader () override | |
|
Deletes the program object upon destruction of this instance. More... | |
Public Operators Index
| LegacyOpenGLShader & | operator= (const LegacyOpenGLShader &)=delete |
Public Member Functions Index
| void | use () const noexcept override |
|
Activates this LegacyOpenGLShader for subsequent draw calls. This implementation calls `glUseProgram` with the `progId_` received after compilation. More... | |
| void | setUniformLocationMap (std::unique_ptr< const OpenGLUniformLocationMap > uniformLocationMap) noexcept |
|
Sets the OpenGLUniformLocationMap for this LegacyOpenGLShader. Ownership is transferred to this instance. More... | |
| int | uniformLocation (helios::rendering::shader::UniformSemantics uniformSemantics) const noexcept |
|
Returns the uniform location for the uniform represented by the specified UniformSemantics. More... | |
| void | applyUniformValues (const helios::rendering::shader::UniformValueMap &uniformValueMap) const noexcept override |
|
Applies the specified UniformValueMap to the uniforms defined by the shader. This method does not change the binding state of the shader, but it passes the uniform values to the underlying rendering backend. Implementations should ensure that the shader is properly bound before this method is called. More... | |
Private Member Functions Index
| void | load (const std::string &vertexShaderPath, const std::string &fragmentShaderPath, const helios::util::io::StringFileReader &stringFileReader) |
|
Loads the specified vertex and fragment shader. More... | |
| void | compile () |
|
Compiles the vertex and fragment shader represented by this instance. More... | |
Protected Member Attributes Index
| unsigned int | progId_ = 0 |
|
The program id as assigned by the underlying rendering backend. More... | |
| std::unique_ptr< const OpenGLUniformLocationMap > | uniformLocationMap_ = nullptr |
|
A unique pointer to the OpenGLUniformLocationMap this shader uses. More... | |
Private Member Attributes Index
| std::string | vertexShaderSource_ |
|
Source of the shader. Not guaranteed to be persisted once compilation was successful. More... | |
| std::string | fragmentShaderSource_ |
|
Source of the shader. Not guaranteed to be persisted once compilation was successful. More... | |
Description
An OpenGL-specific implementation of a Shader program, consisting of a vertex and a fragment shader.
This class manages the lifecycle of the Shaders. Source files are getting loaded via a StringFileReader and immediately compiled after loading. Any occupied memory for source-files and file-paths to the shader is being cleared once compilation succeeded and are not guaranteed to persist the compilation process.
Definition at line 36 of file LegacyOpenGLShader.ixx.
Public Constructors
LegacyOpenGLShader()
| delete |
Rule of three.
Prevent copying.
Definition at line 160 of file LegacyOpenGLShader.ixx.
Reference LegacyOpenGLShader.
Referenced by LegacyOpenGLShader and operator=.
LegacyOpenGLShader()
| inline |
Creates and initializes this LegacyOpenGLShader. An instance of this class is guaranteed to have a progId_ != 0, hence shader-files where successfully loaded and compiled, ready to be used.
- Parameters
-
vertexShaderPath The path to the vertex shader.
fragmentShaderPath The path to the fragment shader.
stringFileReader The StringFileReader used for loading the shader source files.
- Exceptions
-
if creating this shader failed.
Definition at line 175 of file LegacyOpenGLShader.ixx.
Reference helios::rendering::shader::Shader::logger_.
Public Destructor
~LegacyOpenGLShader()
| inline |
Deletes the program object upon destruction of this instance.
Definition at line 209 of file LegacyOpenGLShader.ixx.
Reference progId_.
Public Operators
operator=()
| delete |
Definition at line 161 of file LegacyOpenGLShader.ixx.
Reference LegacyOpenGLShader.
Public Member Functions
applyUniformValues()
| inline noexcept virtual |
Applies the specified UniformValueMap to the uniforms defined by the shader. This method does not change the binding state of the shader, but it passes the uniform values to the underlying rendering backend. Implementations should ensure that the shader is properly bound before this method is called.
- Parameters
-
uniformValueMap A const ref to the `UniformValueMap` containing the values for the uniforms in this shader.
Definition at line 249 of file LegacyOpenGLShader.ixx.
References helios::rendering::shader::MaterialBaseColor, helios::rendering::shader::ModelMatrix, helios::rendering::shader::ProjectionMatrix, helios::rendering::shader::TextColor, helios::rendering::shader::TextTexture, uniformLocation and helios::rendering::shader::ViewMatrix.
setUniformLocationMap()
| inline noexcept |
Sets the OpenGLUniformLocationMap for this LegacyOpenGLShader. Ownership is transferred to this instance.
- Parameters
-
uniformLocationMap The OpenGLUniformMap providing the mappings for the uniforms of the underlying GLSL shader.
Definition at line 222 of file LegacyOpenGLShader.ixx.
Reference uniformLocationMap_.
uniformLocation()
| inline nodiscard noexcept |
Returns the uniform location for the uniform represented by the specified UniformSemantics.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier.
- Returns
The integer representing the uniform variable location in the shader, or -1 if no location map was registered with this shader or if the uniform with the specified semantics was not found.
Definition at line 237 of file LegacyOpenGLShader.ixx.
Reference uniformLocationMap_.
Referenced by applyUniformValues.
use()
| inline noexcept virtual |
Activates this LegacyOpenGLShader for subsequent draw calls. This implementation calls `glUseProgram` with the `progId_` received after compilation.
Definition at line 197 of file LegacyOpenGLShader.ixx.
References helios::rendering::shader::Shader::logger_ and progId_.
Private Member Functions
compile()
| inline |
Compiles the vertex and fragment shader represented by this instance.
- Returns
true if compilation succeeded, otherwise false.
- Exceptions
-
if compilation failed.
Definition at line 80 of file LegacyOpenGLShader.ixx.
load()
| inline |
Loads the specified vertex and fragment shader.
- Returns
true if loading succeeded, otherwise false.
- Exceptions
-
if loading the specified files failed.
Definition at line 59 of file LegacyOpenGLShader.ixx.
Protected Member Attributes
progId_
| protected |
The program id as assigned by the underlying rendering backend.
Definition at line 145 of file LegacyOpenGLShader.ixx.
Referenced by use and ~LegacyOpenGLShader.
uniformLocationMap_
| protected |
A unique pointer to the OpenGLUniformLocationMap this shader uses.
Definition at line 150 of file LegacyOpenGLShader.ixx.
Referenced by setUniformLocationMap and uniformLocation.
Private Member Attributes
fragmentShaderSource_
|
Source of the shader. Not guaranteed to be persisted once compilation was successful.
Definition at line 50 of file LegacyOpenGLShader.ixx.
vertexShaderSource_
|
Source of the shader. Not guaranteed to be persisted once compilation was successful.
Definition at line 43 of file LegacyOpenGLShader.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.