My Project
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
ParaEngine::GLProgram Class Reference

GLProgram Class that implements a glProgram. More...

#include <GLProgram.h>

Inheritance diagram for ParaEngine::GLProgram:
ParaEngine::CRefCountedOne ParaEngine::CRefCounted

Classes

struct  flag_struct
 

Public Types

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
}
 

Public Member Functions

bool initWithByteArrays (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 
bool initWithFilenames (const std::string &vShaderFilename, const std::string &fShaderFilename)
 
UniformgetUniform (const std::string &name)
 
VertexAttribgetVertexAttrib (const std::string &name)
 
void bindAttribLocation (const std::string &attributeName, GLuint index) const
 It will add a new attribute to the shader by calling glBindAttribLocation.
 
GLint getAttribLocation (const std::string &attributeName) const
 calls glGetAttribLocation
 
GLint getUniformLocation (const std::string &attributeName) const
 calls glGetUniformLocation()
 
bool link ()
 links the glProgram
 
void use ()
 it will call glUseProgram()
 
void updateUniforms ()
 It will create 4 uniforms: More...
 
GLint getUniformLocationForName (const char *name) const
 calls retrieves the named uniform location for this shader program. More...
 
void setUniformLocationWith1i (GLint location, GLint i1)
 calls glUniform1i only if the values are different than the previous call for this same shader program. More...
 
void 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 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 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 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 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 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 setUniformLocationWith1f (GLint location, GLfloat f1)
 calls glUniform1f only if the values are different than the previous call for this same shader program. More...
 
void 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 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 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 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 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 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 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 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 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 getVertexShaderLog () const
 returns the vertexShader error log
 
std::string getFragmentShaderLog () const
 returns the fragmentShader error log
 
std::string getProgramLog () const
 returns the program error log
 
void reset ()
 
const GLuint getProgram () const
 
bool initWithVertexShaderByteArray (const GLchar *vertexByteArray, const GLchar *fragByteArray)
 
bool initWithVertexShaderFilename (const std::string &vertexFilename, const std::string &fragFilename)
 
void addAttribute (const std::string &attributeName, GLuint index) const
 
- Public Member Functions inherited from ParaEngine::CRefCounted
void addref () const
 add reference count of the object. More...
 
bool delref () const
 decrease reference count of the object. More...
 
int GetRefCount () const
 get the reference count
 
virtual int Release ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 

Static Public Member Functions

static GLProgramcreateWithByteArrays (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 Initializes the GLProgram with a vertex and fragment with bytes array initWithString initWithString. More...
 
static GLProgramcreateWithFilenames (const std::string &vShaderFilename, const std::string &fShaderFilename)
 Initializes the GLProgram with a vertex and fragment with contents of filenames init init.
 

Static Public Attributes

static const char * SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor"
 
static const char * SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP"
 
static const char * SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest"
 
static const char * SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV = "ShaderPositionTextureColorAlphaTest_NoMV"
 
static const char * SHADER_NAME_POSITION_COLOR = "ShaderPositionColor"
 
static const char * SHADER_NAME_POSITION_COLOR_NO_MVP = "ShaderPositionColor_noMVP"
 
static const char * SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture"
 
static const char * SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor"
 
static const char * SHADER_NAME_POSITION_TEXTURE_A8_COLOR = "ShaderPositionTextureA8Color"
 
static const char * SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor"
 
static const char * SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR = "ShaderPositionLengthTextureColor"
 
static const char * SHADER_NAME_LABEL_NORMAL = "ShaderLabelNormal"
 
static const char * SHADER_NAME_LABEL_OUTLINE = "ShaderLabelOutline"
 
static const char * SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL = "ShaderLabelDFNormal"
 
static const char * SHADER_NAME_LABEL_DISTANCEFIELD_GLOW = "ShaderLabelDFGlow"
 
static const char * SHADER_3D_POSITION = "Shader3DPosition"
 
static const char * SHADER_3D_POSITION_TEXTURE = "Shader3DPositionTexture"
 
static const char * SHADER_3D_SKINPOSITION_TEXTURE = "Shader3DSkinPositionTexture"
 
static const char * UNIFORM_NAME_P_MATRIX = "CC_PMatrix"
 
static const char * UNIFORM_NAME_MV_MATRIX = "CC_MVMatrix"
 
static const char * UNIFORM_NAME_MVP_MATRIX = "CC_MVPMatrix"
 
static const char * UNIFORM_NAME_TIME = "CC_Time"
 
static const char * UNIFORM_NAME_SIN_TIME = "CC_SinTime"
 
static const char * UNIFORM_NAME_COS_TIME = "CC_CosTime"
 
static const char * UNIFORM_NAME_RANDOM01 = "CC_Random01"
 
static const char * UNIFORM_NAME_SAMPLER0 = "CC_Texture0"
 
static const char * UNIFORM_NAME_SAMPLER1 = "CC_Texture1"
 
static const char * UNIFORM_NAME_SAMPLER2 = "CC_Texture2"
 
static const char * UNIFORM_NAME_SAMPLER3 = "CC_Texture3"
 
static const char * UNIFORM_NAME_ALPHA_TEST_VALUE = "CC_alpha_value"
 
static const char * ATTRIBUTE_NAME_COLOR = "a_color"
 
static const char * ATTRIBUTE_NAME_POSITION = "a_position"
 
static const char * ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"
 
static const char * ATTRIBUTE_NAME_NORMAL = "a_normal"
 
static const char * ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight"
 
static const char * ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex"
 

Protected Member Functions

bool updateUniformLocation (GLint location, const GLvoid *data, unsigned int bytes)
 
void bindPredefinedVertexAttribs ()
 
void parseVertexAttribs ()
 
void parseUniforms ()
 
bool compileShader (GLuint *shader, GLenum type, const GLchar *source)
 
std::string logForOpenGLObject (GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const
 

Protected Attributes

GLuint _program
 
GLuint _vertShader
 
GLuint _fragShader
 
GLint _builtInUniforms [UNIFORM_MAX]
 
struct _hashUniformEntry_hashForUniforms
 
bool _hasShaderCompiler
 
struct ParaEngine::GLProgram::flag_struct _flags
 
std::unordered_map< std::string, Uniform_userUniforms
 
std::unordered_map< std::string, VertexAttrib_vertexAttribs
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 

Friends

class GLProgramState
 

Detailed Description

GLProgram Class that implements a glProgram.

Since
v2.0.0

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