JUCE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Classes | Public Member Functions | Static Public Member Functions | List of all members
OpenGLShaderProgram Class Reference

Manages an OpenGL shader program. More...

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
 
 ~OpenGLShaderProgram () noexcept
 
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 StringgetLastError () 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.
 
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.
 

Detailed Description

Manages an OpenGL shader program.

Constructor & Destructor Documentation

OpenGLShaderProgram::OpenGLShaderProgram ( const OpenGLContext )
noexcept
OpenGLShaderProgram::~OpenGLShaderProgram ( )
noexcept

Member Function Documentation

static double OpenGLShaderProgram::getLanguageVersion ( )
static

Returns the version of GLSL that the current context supports.

E.g.

{
// ..do something that requires GLSL 1.2 or above..
}
bool OpenGLShaderProgram::addShader ( const String shaderSourceCode,
GLenum  shaderType 
)

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.

Returns
true if the shader compiled successfully. If not, you can call getLastError() to find out what happened.
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.

bool OpenGLShaderProgram::link ( )
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.

Returns
true if the program linked successfully. If not, you can call getLastError() to find out what happened.
const String& OpenGLShaderProgram::getLastError ( ) const
noexcept

Get the output for the last shader compilation or link that failed.

void OpenGLShaderProgram::use ( ) const
noexcept

Selects this program into the current context.

void OpenGLShaderProgram::release ( )
noexcept

Deletes the program.

GLuint OpenGLShaderProgram::getProgramID ( ) const
noexcept

The ID number of the compiled program.


The documentation for this class was generated from the following file: