Manages an OpenGL shader program. More...
#include <juce_OpenGLShaderProgram.h>
Classes | |
struct | Attribute |
Represents an openGL vertex attribute value. More... | |
struct | Uniform |
Represents an openGL uniform value. More... | |
Public Member Functions | |
OpenGLShaderProgram (const OpenGLContext &) noexcept | |
Creates a shader for use in a particular GL context. | |
~OpenGLShaderProgram () noexcept | |
Destructor. | |
bool | addShader (const String &shaderSourceCode, GLenum shaderType) |
Compiles and adds a shader to this program. | |
bool | addVertexShader (const String &shaderSourceCode) |
Compiles and adds a fragment shader to this program. | |
bool | addFragmentShader (const String &shaderSourceCode) |
Compiles and adds a fragment shader to this program. | |
bool | link () noexcept |
Links all the compiled shaders into a usable program. | |
const String & | getLastError () const noexcept |
Get the output for the last shader compilation or link that failed. | |
void | use () const noexcept |
Selects this program into the current context. | |
void | release () noexcept |
Deletes the program. | |
GLint | getUniformIDFromName (const char *uniformName) const noexcept |
Get the uniform ID from the variable name. | |
void | setUniform (const char *uniformName, GLfloat value) noexcept |
Sets a float uniform. | |
void | setUniform (const char *uniformName, GLint value) noexcept |
Sets an int uniform. | |
void | setUniform (const char *uniformName, GLfloat x, GLfloat y) noexcept |
Sets a vec2 uniform. | |
void | setUniform (const char *uniformName, GLfloat x, GLfloat y, GLfloat z) noexcept |
Sets a vec3 uniform. | |
void | setUniform (const char *uniformName, GLfloat x, GLfloat y, GLfloat z, GLfloat w) noexcept |
Sets a vec4 uniform. | |
void | setUniform (const char *uniformName, GLint x, GLint y, GLint z, GLint w) noexcept |
Sets a vec4 uniform. | |
void | setUniform (const char *uniformName, const GLfloat *values, GLsizei numValues) noexcept |
Sets a vector float uniform. | |
void | setUniformMat2 (const char *uniformName, const GLfloat *values, GLint count, GLboolean transpose) noexcept |
Sets a 2x2 matrix float uniform. | |
void | setUniformMat3 (const char *uniformName, const GLfloat *values, GLint count, GLboolean transpose) noexcept |
Sets a 3x3 matrix float uniform. | |
void | setUniformMat4 (const char *uniformName, const GLfloat *values, GLint count, GLboolean transpose) noexcept |
Sets a 4x4 matrix float uniform. | |
GLuint | getProgramID () const noexcept |
The ID number of the compiled program. | |
Static Public Member Functions | |
static double | getLanguageVersion () |
Returns the version of GLSL that the current context supports. | |
Manages an OpenGL shader program.
|
noexcept |
Creates a shader for use in a particular GL context.
|
noexcept |
Destructor.
|
static |
Returns the version of GLSL that the current context supports.
E.g.
Compiles and adds a shader to this program.
After adding all your shaders, remember to call link() to link them into a usable program.
If your app is built in debug mode, this method will assert if the program fails to compile correctly.
The shaderType parameter could be GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc.
bool OpenGLShaderProgram::addVertexShader | ( | const String & | shaderSourceCode | ) |
Compiles and adds a fragment shader to this program.
This is equivalent to calling addShader() with a type of GL_VERTEX_SHADER.
bool OpenGLShaderProgram::addFragmentShader | ( | const String & | shaderSourceCode | ) |
Compiles and adds a fragment shader to this program.
This is equivalent to calling addShader() with a type of GL_FRAGMENT_SHADER.
|
noexcept |
Links all the compiled shaders into a usable program.
If your app is built in debug mode, this method will assert if the program fails to link correctly.
|
noexcept |
Get the output for the last shader compilation or link that failed.
|
noexcept |
Selects this program into the current context.
|
noexcept |
Deletes the program.
|
noexcept |
Get the uniform ID from the variable name.
|
noexcept |
Sets a float uniform.
|
noexcept |
Sets an int uniform.
Sets a vec2 uniform.
|
noexcept |
Sets a vec3 uniform.
|
noexcept |
Sets a vec4 uniform.
|
noexcept |
Sets a vec4 uniform.
|
noexcept |
Sets a vector float uniform.
|
noexcept |
Sets a 2x2 matrix float uniform.
|
noexcept |
Sets a 3x3 matrix float uniform.
|
noexcept |
Sets a 4x4 matrix float uniform.
|
noexcept |
The ID number of the compiled program.