My Project
Classes | Typedefs | Enumerations | Enumerator | Functions | Variables | Friends
Shaders

Classes

struct  ParaEngine::VertexAttrib
 
struct  ParaEngine::Uniform
 
struct  ParaEngine::GLProgram::flag_struct
 
class  ParaEngine::GLProgram
 GLProgram Class that implements a glProgram. More...
 
class  ParaEngine::GLProgramCache
 GLProgramCache Singleton that stores manages GLProgram objects (shaders) More...
 

Typedefs

typedef void(* ParaEngine::GLInfoFunction) (GLuint program, GLenum pname, GLint *params)
 
typedef void(* ParaEngine::GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog)
 

Enumerations

enum  {
  VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_COLOR, VERTEX_ATTRIB_TEX_COORD, VERTEX_ATTRIB_NORMAL,
  VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_BLEND_INDEX, VERTEX_ATTRIB_MAX, VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD
}
 
enum  {
  UNIFORM_P_MATRIX, UNIFORM_MV_MATRIX, UNIFORM_MVP_MATRIX, UNIFORM_TIME,
  UNIFORM_SIN_TIME, UNIFORM_COS_TIME, UNIFORM_RANDOM01, UNIFORM_SAMPLER0,
  UNIFORM_SAMPLER1, UNIFORM_SAMPLER2, UNIFORM_SAMPLER3, UNIFORM_MAX
}
 

Functions

static GLProgramParaEngine::GLProgram::createWithByteArrays (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 Initializes the GLProgram with a vertex and fragment with bytes array initWithString initWithString. More...
 
bool ParaEngine::GLProgram::initWithByteArrays (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 
static GLProgramParaEngine::GLProgram::createWithFilenames (const std::string &vShaderFilename, const std::string &fShaderFilename)
 Initializes the GLProgram with a vertex and fragment with contents of filenames init init.
 
bool ParaEngine::GLProgram::initWithFilenames (const std::string &vShaderFilename, const std::string &fShaderFilename)
 
UniformParaEngine::GLProgram::getUniform (const std::string &name)
 
VertexAttribParaEngine::GLProgram::getVertexAttrib (const std::string &name)
 
void ParaEngine::GLProgram::bindAttribLocation (const std::string &attributeName, GLuint index) const
 It will add a new attribute to the shader by calling glBindAttribLocation.
 
GLint ParaEngine::GLProgram::getAttribLocation (const std::string &attributeName) const
 calls glGetAttribLocation
 
GLint ParaEngine::GLProgram::getUniformLocation (const std::string &attributeName) const
 calls glGetUniformLocation()
 
bool ParaEngine::GLProgram::link ()
 links the glProgram
 
void ParaEngine::GLProgram::use ()
 it will call glUseProgram()
 
void ParaEngine::GLProgram::updateUniforms ()
 It will create 4 uniforms: More...
 
GLint ParaEngine::GLProgram::getUniformLocationForName (const char *name) const
 calls retrieves the named uniform location for this shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith1i (GLint location, GLint i1)
 calls glUniform1i only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith2i (GLint location, GLint i1, GLint i2)
 calls glUniform2i only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith3i (GLint location, GLint i1, GLint i2, GLint i3)
 calls glUniform3i only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith4i (GLint location, GLint i1, GLint i2, GLint i3, GLint i4)
 calls glUniform4i only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith2iv (GLint location, GLint *ints, unsigned int numberOfArrays)
 calls glUniform2iv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith3iv (GLint location, GLint *ints, unsigned int numberOfArrays)
 calls glUniform3iv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith4iv (GLint location, GLint *ints, unsigned int numberOfArrays)
 calls glUniform4iv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith1f (GLint location, GLfloat f1)
 calls glUniform1f only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith2f (GLint location, GLfloat f1, GLfloat f2)
 calls glUniform2f only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith3f (GLint location, GLfloat f1, GLfloat f2, GLfloat f3)
 calls glUniform3f only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith4f (GLint location, GLfloat f1, GLfloat f2, GLfloat f3, GLfloat f4)
 calls glUniform4f only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith2fv (GLint location, const GLfloat *floats, unsigned int numberOfArrays)
 calls glUniform2fv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith3fv (GLint location, const GLfloat *floats, unsigned int numberOfArrays)
 calls glUniform3fv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWith4fv (GLint location, const GLfloat *floats, unsigned int numberOfArrays)
 calls glUniform4fv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWithMatrix2fv (GLint location, const GLfloat *matrixArray, unsigned int numberOfMatrices)
 calls glUniformMatrix2fv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWithMatrix3fv (GLint location, const GLfloat *matrixArray, unsigned int numberOfMatrices)
 calls glUniformMatrix3fv only if the values are different than the previous call for this same shader program. More...
 
void ParaEngine::GLProgram::setUniformLocationWithMatrix4fv (GLint location, const GLfloat *matrixArray, unsigned int numberOfMatrices)
 calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. More...
 
std::string ParaEngine::GLProgram::getVertexShaderLog () const
 returns the vertexShader error log
 
std::string ParaEngine::GLProgram::getFragmentShaderLog () const
 returns the fragmentShader error log
 
std::string ParaEngine::GLProgram::getProgramLog () const
 returns the program error log
 
void ParaEngine::GLProgram::reset ()
 
const GLuint ParaEngine::GLProgram::getProgram () const
 
bool ParaEngine::GLProgram::initWithVertexShaderByteArray (const GLchar *vertexByteArray, const GLchar *fragByteArray)
 
bool ParaEngine::GLProgram::initWithVertexShaderFilename (const std::string &vertexFilename, const std::string &fragFilename)
 
void ParaEngine::GLProgram::addAttribute (const std::string &attributeName, GLuint index) const
 
bool ParaEngine::GLProgram::updateUniformLocation (GLint location, const GLvoid *data, unsigned int bytes)
 
void ParaEngine::GLProgram::bindPredefinedVertexAttribs ()
 
void ParaEngine::GLProgram::parseVertexAttribs ()
 
void ParaEngine::GLProgram::parseUniforms ()
 
bool ParaEngine::GLProgram::compileShader (GLuint *shader, GLenum type, const GLchar *source)
 
std::string ParaEngine::GLProgram::logForOpenGLObject (GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const
 
 ParaEngine::GLProgramCache::GLProgramCache ()
 ctor
 
 ParaEngine::GLProgramCache::~GLProgramCache ()
 NA NA
 
static GLProgramCacheParaEngine::GLProgramCache::getInstance ()
 returns the shared instance
 
static void ParaEngine::GLProgramCache::destroyInstance ()
 purges the cache. More...
 
static GLProgramCacheParaEngine::GLProgramCache::sharedShaderCache ()
 
static void ParaEngine::GLProgramCache::purgeSharedShaderCache ()
 
void ParaEngine::GLProgramCache::loadDefaultGLPrograms ()
 loads the default shaders
 
void ParaEngine::GLProgramCache::loadDefaultShaders ()
 
void ParaEngine::GLProgramCache::reloadDefaultGLPrograms ()
 reload the default shaders
 
void ParaEngine::GLProgramCache::reloadDefaultShaders ()
 
GLProgramParaEngine::GLProgramCache::getGLProgram (const std::string &key)
 returns a GL program for a given key
 
GLProgramParaEngine::GLProgramCache::getProgram (const std::string &key)
 
GLProgramParaEngine::GLProgramCache::programForKey (const std::string &key)
 
void ParaEngine::GLProgramCache::addGLProgram (GLProgram *program, const std::string &key)
 adds a GLProgram to the cache for a given name
 
void ParaEngine::GLProgramCache::addProgram (GLProgram *program, const std::string &key)
 

Variables

GLuint ParaEngine::VertexAttrib::index
 
GLint ParaEngine::VertexAttrib::size
 
GLenum ParaEngine::VertexAttrib::type
 
std::string ParaEngine::VertexAttrib::name
 
GLint ParaEngine::Uniform::location
 
GLint ParaEngine::Uniform::size
 
GLenum ParaEngine::Uniform::type
 
std::string ParaEngine::Uniform::name
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV = "ShaderPositionTextureColorAlphaTest_NoMV"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP = "ShaderPositionColor_noMVP"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR = "ShaderPositionTextureA8Color"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR = "ShaderPositionLengthTextureColor"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_LABEL_NORMAL = "ShaderLabelNormal"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_LABEL_OUTLINE = "ShaderLabelOutline"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL = "ShaderLabelDFNormal"
 
static const char * ParaEngine::GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW = "ShaderLabelDFGlow"
 
static const char * ParaEngine::GLProgram::SHADER_3D_POSITION = "Shader3DPosition"
 
static const char * ParaEngine::GLProgram::SHADER_3D_POSITION_TEXTURE = "Shader3DPositionTexture"
 
static const char * ParaEngine::GLProgram::SHADER_3D_SKINPOSITION_TEXTURE = "Shader3DSkinPositionTexture"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_P_MATRIX = "CC_PMatrix"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_MV_MATRIX = "CC_MVMatrix"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_MVP_MATRIX = "CC_MVPMatrix"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_TIME = "CC_Time"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_SIN_TIME = "CC_SinTime"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_COS_TIME = "CC_CosTime"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_RANDOM01 = "CC_Random01"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_SAMPLER0 = "CC_Texture0"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_SAMPLER1 = "CC_Texture1"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_SAMPLER2 = "CC_Texture2"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_SAMPLER3 = "CC_Texture3"
 
static const char * ParaEngine::GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE = "CC_alpha_value"
 
static const char * ParaEngine::GLProgram::ATTRIBUTE_NAME_COLOR = "a_color"
 
static const char * ParaEngine::GLProgram::ATTRIBUTE_NAME_POSITION = "a_position"
 
static const char * ParaEngine::GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"
 
static const char * ParaEngine::GLProgram::ATTRIBUTE_NAME_NORMAL = "a_normal"
 
static const char * ParaEngine::GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight"
 
static const char * ParaEngine::GLProgram::ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex"
 
GLuint ParaEngine::GLProgram::_program
 
GLuint ParaEngine::GLProgram::_vertShader
 
GLuint ParaEngine::GLProgram::_fragShader
 
GLint ParaEngine::GLProgram::_builtInUniforms [UNIFORM_MAX]
 
struct _hashUniformEntryParaEngine::GLProgram::_hashForUniforms
 
bool ParaEngine::GLProgram::_hasShaderCompiler
 
unsigned int ParaEngine::GLProgram::flag_struct::usesTime: 1
 
unsigned int ParaEngine::GLProgram::flag_struct::usesMVP: 1
 
unsigned int ParaEngine::GLProgram::flag_struct::usesMV: 1
 
unsigned int ParaEngine::GLProgram::flag_struct::usesP: 1
 
unsigned int ParaEngine::GLProgram::flag_struct::usesRandom: 1
 
struct ParaEngine::GLProgram::flag_struct ParaEngine::GLProgram::_flags
 
std::unordered_map< std::string, UniformParaEngine::GLProgram::_userUniforms
 
std::unordered_map< std::string, VertexAttribParaEngine::GLProgram::_vertexAttribs
 

Friends

class ParaEngine::GLProgram::GLProgramState
 

Detailed Description

Function Documentation

§ createWithByteArrays()

GLProgram * GLProgram::createWithByteArrays ( const GLchar *  vShaderByteArray,
const GLchar *  fShaderByteArray 
)
static

Initializes the GLProgram with a vertex and fragment with bytes array initWithString initWithString.

Initializes the GLProgram with a vertex and fragment with bytes array initWithString initWithString

§ destroyInstance()

void GLProgramCache::destroyInstance ( )
static

purges the cache.

It releases the retained instance.

§ getUniformLocationForName()

GLint GLProgram::getUniformLocationForName ( const char *  name) const

calls retrieves the named uniform location for this shader program.

§ purgeSharedShaderCache()

void GLProgramCache::purgeSharedShaderCache ( )
static

§ setUniformLocationWith1f()

void GLProgram::setUniformLocationWith1f ( GLint  location,
GLfloat  f1 
)

calls glUniform1f only if the values are different than the previous call for this same shader program.

In js or lua,please use setUniformLocationF32 NA

§ setUniformLocationWith1i()

void GLProgram::setUniformLocationWith1i ( GLint  location,
GLint  i1 
)

calls glUniform1i only if the values are different than the previous call for this same shader program.

setUniformLocationI32 setUniformLocationI32

§ setUniformLocationWith2f()

void GLProgram::setUniformLocationWith2f ( GLint  location,
GLfloat  f1,
GLfloat  f2 
)

calls glUniform2f only if the values are different than the previous call for this same shader program.

In js or lua,please use setUniformLocationF32 NA

§ setUniformLocationWith2fv()

void GLProgram::setUniformLocationWith2fv ( GLint  location,
const GLfloat *  floats,
unsigned int  numberOfArrays 
)

calls glUniform2fv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith2i()

void GLProgram::setUniformLocationWith2i ( GLint  location,
GLint  i1,
GLint  i2 
)

calls glUniform2i only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith2iv()

void GLProgram::setUniformLocationWith2iv ( GLint  location,
GLint *  ints,
unsigned int  numberOfArrays 
)

calls glUniform2iv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith3f()

void GLProgram::setUniformLocationWith3f ( GLint  location,
GLfloat  f1,
GLfloat  f2,
GLfloat  f3 
)

calls glUniform3f only if the values are different than the previous call for this same shader program.

In js or lua,please use setUniformLocationF32 NA

§ setUniformLocationWith3fv()

void GLProgram::setUniformLocationWith3fv ( GLint  location,
const GLfloat *  floats,
unsigned int  numberOfArrays 
)

calls glUniform3fv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith3i()

void GLProgram::setUniformLocationWith3i ( GLint  location,
GLint  i1,
GLint  i2,
GLint  i3 
)

calls glUniform3i only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith3iv()

void GLProgram::setUniformLocationWith3iv ( GLint  location,
GLint *  ints,
unsigned int  numberOfArrays 
)

calls glUniform3iv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith4f()

void GLProgram::setUniformLocationWith4f ( GLint  location,
GLfloat  f1,
GLfloat  f2,
GLfloat  f3,
GLfloat  f4 
)

calls glUniform4f only if the values are different than the previous call for this same shader program.

In js or lua,please use setUniformLocationF32 NA

§ setUniformLocationWith4fv()

void GLProgram::setUniformLocationWith4fv ( GLint  location,
const GLfloat *  floats,
unsigned int  numberOfArrays 
)

calls glUniform4fv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith4i()

void GLProgram::setUniformLocationWith4i ( GLint  location,
GLint  i1,
GLint  i2,
GLint  i3,
GLint  i4 
)

calls glUniform4i only if the values are different than the previous call for this same shader program.

§ setUniformLocationWith4iv()

void GLProgram::setUniformLocationWith4iv ( GLint  location,
GLint *  ints,
unsigned int  numberOfArrays 
)

calls glUniform4iv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWithMatrix2fv()

void GLProgram::setUniformLocationWithMatrix2fv ( GLint  location,
const GLfloat *  matrixArray,
unsigned int  numberOfMatrices 
)

calls glUniformMatrix2fv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWithMatrix3fv()

void GLProgram::setUniformLocationWithMatrix3fv ( GLint  location,
const GLfloat *  matrixArray,
unsigned int  numberOfMatrices 
)

calls glUniformMatrix3fv only if the values are different than the previous call for this same shader program.

§ setUniformLocationWithMatrix4fv()

void GLProgram::setUniformLocationWithMatrix4fv ( GLint  location,
const GLfloat *  matrixArray,
unsigned int  numberOfMatrices 
)

calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program.

§ sharedShaderCache()

GLProgramCache * GLProgramCache::sharedShaderCache ( )
static

§ updateUniforms()

void GLProgram::updateUniforms ( )

It will create 4 uniforms:

  • kUniformPMatrix
  • kUniformMVMatrix
  • kUniformMVPMatrix
  • GLProgram::UNIFORM_SAMPLER

And it will bind "GLProgram::UNIFORM_SAMPLER" to 0