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 UseProgram ()
 
GLuint GetProgramObject ()
 
 ~GlsEffect ()
 

Protected Member Functions

void FreeShaders (GLuint vertObject, GLuint fragObject)
 
GLuint LoadAndCompileShader (GLenum shaderType, const char *shaderSource)
 
std::size_t HashShader (const GLchar *vertexShader, const GLchar *fragmentShader)
 

Protected Attributes

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

Friends

class GlsEffectFactoryImpl
 
class std::map< GLuint, GlsEffect >
 
class DynamicArray< GlsEffect, false >
 

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()

~GlsEffect ( )

dtor

Member Function Documentation

◆ CreateCustomUniform()

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

◆ CreateShader()

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.

◆ FreeShaders()

void FreeShaders ( GLuint  vertObject,
GLuint  fragObject 
)
protected

Delete/destroy the shader program and its shaders.

Parameters
vertObjectGL index of the vertex shader program.
fragObjectGL index of the fragment shader program.
Precondition
none
Postcondition
shaders are deleted
_programObject == 0

◆ GetAttribLocation()

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

◆ GetCustomUniform()

GlsUniform * GetCustomUniform ( GLint  uniform)

Get uniform data for one of the custom uniforms.

Parameters
[in]uniformThe custom uniform's ID
Returns
the uniform

◆ GetProgramObject()

GLuint GetProgramObject ( )

Get the program object associated with this effect.

Returns
the program object

◆ GetStdUniform()

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

◆ HashShader()

std::size_t HashShader ( const GLchar *  vertexShader,
const GLchar *  fragmentShader 
)
protected

Hashes the shader programs, used to determine the filename of the precompiled shader for platforms that do not support inline shader compilation.

Parameters
vertexShaderThe vertex shader program source code.
fragmentShaderThe fragment shader program source code.
Returns
A hash of the shader programs.

◆ IsInitialized()

bool IsInitialized ( )

Indicates if this effect was successfully loaded or not

Returns
true if the effect has been successfully loaded

◆ LoadAndCompileShader()

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.

◆ UseProgram()

void UseProgram ( )

Use the program for this effect.

Friends And Related Function Documentation

◆ GlsEffectFactoryImpl

friend class GlsEffectFactoryImpl
friend

Only the effect factory should be creating new effects.

Member Data Documentation

◆ _attribLocations

GLint _attribLocations[MAX_STD_ATTRIBS]
protected

The attributes for this effect.

◆ _customUniforms

DynamicArray<GlsUniform, false> _customUniforms
protected

Custom uniform types for custom shaders.

◆ _programObject

GLuint _programObject
protected

This effect's program object.

◆ _stdUniforms

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: