GL Studio C++ Runtime API
GlsEffect Class Reference

#include <gls_es20_effect.h>

Public Member Functions

GlsUniformGetStdUniform (StdUniforms_e uniform)
 
GlsUniformGetCustomUniform (GLint uniform)
 
GLuint GetAttribLocation (StdAttribs_e attribute)
 
GLuint CreateShader (const GLchar *vertexShader, const GLchar *fragmentShader)
 
GLint CreateCustomUniform (const char *uniformName)
 
bool IsInitialized (void)
 
void UseProgram (void)
 
GLuint GetProgramObject (void)
 
 ~GlsEffect ()
 

Protected Member Functions

void FreeShaders (GLuint vertObject, GLuint fragObject)
 
GLuint LoadAndCompileShader (GLenum shaderType, const char *shaderSource)
 

Protected Attributes

GLuint _programObject
 
GlsUniform _stdUniforms [MAX_STD_UNIFORMS]
 
DynamicArray< GlsUniform, false > _customUniforms
 
GLint _attribLocations [MAX_STD_ATTRIBS]
 

Friends

class GlsEffectFactoryImpl
 

Detailed Description

The GlsEffect Class. This class stores program objects and lists of uniforms. Because all construction methods are private, Effects can be only created with the friend Factory class.

Constructor & Destructor Documentation

~GlsEffect ( )

dtor

Member Function Documentation

GLint CreateCustomUniform ( const char *  uniformName)

Create a custom uniform to add to this effect's list of custom uniforms

Parameters
[in]uniformNameThe string representing the name of this uniform
Returns
the ID corresponding to this custom uniform's position in the array, or -1 on failure
GLuint CreateShader ( const GLchar *  vertexShader,
const GLchar *  fragmentShader 
)

Compile and link vertex and fragment shaders, creating a program object.

Parameters
[in]vertexShaderThe vertex shader.
[in]fragmentShaderThe fragment shader.
Returns
The newly created program object, or 0 on error.
void FreeShaders ( GLuint  vertObject,
GLuint  fragObject 
)
protected

Delete/destroy the shader program and its shaders

Precondition
none
Postcondition
shaders are deleted
_programObject == 0
GLuint GetAttribLocation ( StdAttribs_e  attribute)

Get attribute location

Parameters
[in]attributeThe standard attribute to query (
See also
StdAttribs_e)
Precondition
attribute is a valid StdAttribs_e
Returns
The attribute's location
GlsUniform* GetCustomUniform ( GLint  uniform)

Get uniform data for one of the custom uniforms.

Parameters
[in]uniformThe custom uniform's ID
Returns
the uniform
GLuint GetProgramObject ( void  )

Get the program object associated with this effect.

Returns
the program object
GlsUniform* GetStdUniform ( StdUniforms_e  uniform)

Get uniform data for one of the standard uniforms.

Parameters
[in]uniformThe standard uniform enum (
See also
StdUniforms_e)
Precondition
uniform is a valid StdUniforms_e
Returns
the uniform
bool IsInitialized ( void  )

Indicates if this effect was successfully loaded or not

Returns
true if the effect has been successfully loaded
GLuint LoadAndCompileShader ( GLenum  shaderType,
const char *  shaderSource 
)
protected

Load and compile a new shader.

Parameters
[in]shaderTypeThe type of shader this is
[in]shaderSourceThe code for the shader
Precondition
shaderType is GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
Returns
The shader object's ID or 0 on failure.
void UseProgram ( void  )

Use the program for this effect.

Friends And Related Function Documentation

friend class GlsEffectFactoryImpl
friend

Only the effect factory should be creating new effects.

Member Data Documentation

GLint _attribLocations[MAX_STD_ATTRIBS]
protected

The attributes for this effect.

DynamicArray<GlsUniform, false> _customUniforms
protected

Custom uniform types for custom shaders.

GLuint _programObject
protected

This effect's program object.

GlsUniform _stdUniforms[MAX_STD_UNIFORMS]
protected

Standard uniform types. Index values can be acquired from the factory.


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