Class for handling compiling, linking and using shader programs.
More...
#include <sgct/shaderprogram.h>
|
| static void | unbind () |
| | Unset the shader program in the current rendering pipeline.
|
Class for handling compiling, linking and using shader programs.
Uniform and attribute handling must be managed explicitly.
◆ ShaderProgram() [1/4]
| sgct::ShaderProgram::ShaderProgram |
( |
| ) |
|
|
default |
◆ ShaderProgram() [2/4]
| sgct::ShaderProgram::ShaderProgram |
( |
std::string | name | ) |
|
Default only sets the program name.
Shaders objects won't be created until any shader source code is set. The program will be created when the createAndLink() function is called. Make sure the shader sources are set before calling it.
- Parameters
-
| name | Name of the shader program. Must be unique |
◆ ShaderProgram() [3/4]
| sgct::ShaderProgram::ShaderProgram |
( |
const ShaderProgram & | | ) |
|
|
delete |
◆ ShaderProgram() [4/4]
| sgct::ShaderProgram::ShaderProgram |
( |
ShaderProgram && | | ) |
|
|
noexcept |
◆ ~ShaderProgram()
| sgct::ShaderProgram::~ShaderProgram |
( |
| ) |
|
The destructor clears the shader data vector but the program can still be used.
The program have to be destroyed explicitly by calling deleteProgram. This is so that programs can be copied when storing in containers.
◆ addFragmentShader()
| void sgct::ShaderProgram::addFragmentShader |
( |
std::string_view | src | ) |
|
Will create and add a fragment shader to the program.
- Parameters
-
| src | The shader source string |
- Exceptions
-
| std::runtime_error | If the adding of the shaders failed |
◆ addVertexShader()
| void sgct::ShaderProgram::addVertexShader |
( |
std::string_view | src | ) |
|
Will create and add a vertex shader to the program.
- Parameters
-
| src | The shader source string |
- Exceptions
-
| std::runtime_error | If the adding of the shaders failed |
◆ bind()
| void sgct::ShaderProgram::bind |
( |
| ) |
const |
Use the shader program in the current rendering pipeline.
◆ createAndLinkProgram()
| void sgct::ShaderProgram::createAndLinkProgram |
( |
| ) |
|
Will create the program and link the shaders.
The shader sources must have been set before the program can be linked. After the program is created and linked no modification to the shader sources can be made.
◆ deleteProgram()
| void sgct::ShaderProgram::deleteProgram |
( |
| ) |
|
Will detach all attached shaders, delete them and then delete the program.
◆ id()
| unsigned int sgct::ShaderProgram::id |
( |
| ) |
const |
◆ name()
| std::string_view sgct::ShaderProgram::name |
( |
| ) |
const |
- Returns
- The name of the program
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ unbind()
| void sgct::ShaderProgram::unbind |
( |
| ) |
|
|
static |
Unset the shader program in the current rendering pipeline.
The documentation for this class was generated from the following file: