| GL Studio C++ Runtime API

Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
GlsEffect Class Reference

`#include <gls_es20_effect.h>`

## Public Member Functions
GlsUniform * | GetStdUniform (StdUniforms_e uniform)
GlsUniform * | GetCustomUniform (GLint uniform)
GLuint | GetAttribLocation (StdAttribs_e attribute)
GLuint | CreateShader (const char *vertexShader, const char *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 char *vertexShader, const char *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] | uniformName | The 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 char * | vertexShader,
|  | const char * | fragmentShader
| ) |  |

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

Parameters

  [in] | vertexShader | The vertex shader.
  [in] | fragmentShader | The 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

  vertObject | GL index of the vertex shader program.
  fragObject | GL 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] | attribute | The 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] | uniform | The 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] | uniform | The standard uniform enum (

See also
  StdUniforms_e)

Precondition
  uniform is a valid StdUniforms_e

Returns
  the uniform

## ◆ HashShader()

std::size_t HashShader | ( | const char * | vertexShader,
|  | const char * | 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

  vertexShader | The vertex shader program source code.
  fragmentShader | The 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] | shaderType | The type of shader this is
  [in] | shaderSource | The 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:

- gls_es20_effect.h