-
class
SGFXAPI::
ShaderProgram
¶ Bundles up shaders and links them into a single “program” for the GPU pipeline to use.
- See
- getHandle(const ShaderProgram& sp)
Public Functions
-
void
Attach
(Shader &shader)¶ Attaches a shader to this ShaderProgram.
Note on lifetimes: it is safe to delete the shader right after attaching it to the ShaderProgram.
-
int
GetUniformLocation
(const char *name)¶ Get the index of a uniform variable in the shader program. Each uniform variable has an index.
-
void
Use
()¶ Call this before drawing to activate the shader program.
-
void
Deselect
()¶ If this shader program is in use, deactivate it.
Note that this method will check with the driver if this shader program is in use before deactivating it; use DeselectAll() if you want to deactivate all shaders from being in use.
-
void
BindTexture
(int index, TextureUnit &textureUnit, Texture &texture, const std::string &samplerName)¶ This binds a texture to this shader program, so that it can be used in a shader.
- Note
The shader program must be in the InUse() state to call this function.
The TextureUnit
textureUnit
parameter must be active to call this function.The Texture
texture
parameter must be bound to call this function.- Parameters
index
-the texture unit index
textureUnit
-the TextureUnit associated with the Texture
texture
-the texture to bind
samplerName
-the name of the texture/sampler within the shaders
-
void
SetUniform
(const float4x4 &matrix, const std::string &name)¶ set a uniform variable by name
-
void
SetUniform
(const float value, const std::string &name)¶ set a uniform variable by name
-
void
SetUniform
(const int value, const std::string &name)¶ set a uniform variable by name
-
void
SetUniform
(const float v1, const float v2, const float v3, const std::string &name)¶ set a uniform variable by name
Public Static Functions
-
void
DeselectAll
()¶ Deselects all shader programs.
-
void
SetFloat4x4
(int parameterIndex, const float4x4 &matrix)¶ set a uniform variable by uniform location index, this static method operates on the currently bound texture.
-
void
SetFloat
(int parameterIndex, const float value)¶ set a uniform variable by uniform location index, this static method operates on the currently bound texture.
-
void
SetInt
(int parameterIndex, const int value)¶ set a uniform variable by uniform location index, this static method operates on the currently bound texture.
-
void
SetFloat3
(int parameterIndex, const float v1, const float v2, const float v3)¶ set a uniform variable by uniform location index, this static method operates on the currently bound texture.