GLProgramState holds the 'state' (uniforms and attributes) of the GLProgram. More...
#include <CCGLProgramState.h>
Public Member Functions | |
| void | apply (const Mat4 &modelView) |
| void | applyGLProgram (const Mat4 &modelView) |
| void | applyAttributes (bool applyAttribFlags=true) |
| apply vertex attributes More... | |
| void | applyUniforms () |
| void | setGLProgram (GLProgram *glprogram) |
| GLProgram * | getGLProgram () const |
| uint32_t | getVertexAttribsFlags () const |
| ssize_t | getVertexAttribCount () const |
| void | setVertexAttribCallback (const std::string &name, const std::function< void(VertexAttrib *)> &callback) |
| void | setVertexAttribPointer (const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) |
| ssize_t | getUniformCount () const |
| void | setUniformInt (const std::string &uniformName, int value) |
| void | setUniformFloat (const std::string &uniformName, float value) |
| void | setUniformVec2 (const std::string &uniformName, const Vec2 &value) |
| void | setUniformVec3 (const std::string &uniformName, const Vec3 &value) |
| void | setUniformVec4 (const std::string &uniformName, const Vec4 &value) |
| void | setUniformMat4 (const std::string &uniformName, const Mat4 &value) |
| void | setUniformCallback (const std::string &uniformName, const std::function< void(GLProgram *, Uniform *)> &callback) |
| void | setUniformTexture (const std::string &uniformName, Texture2D *texture) |
| void | setUniformTexture (const std::string &uniformName, GLuint textureId) |
| void | setUniformInt (GLint uniformLocation, int value) |
| void | setUniformFloat (GLint uniformLocation, float value) |
| void | setUniformVec2 (GLint uniformLocation, const Vec2 &value) |
| void | setUniformVec3 (GLint uniformLocation, const Vec3 &value) |
| void | setUniformVec4 (GLint uniformLocation, const Vec4 &value) |
| void | setUniformMat4 (GLint uniformLocation, const Mat4 &value) |
| void | setUniformCallback (GLint uniformLocation, const std::function< void(GLProgram *, Uniform *)> &callback) |
| void | setUniformTexture (GLint uniformLocation, Texture2D *texture) |
| void | setUniformTexture (GLint uniformLocation, GLuint textureId) |
Public Member Functions inherited from Ref | |
| void | retain () |
| Retains the ownership. More... | |
| void | release () |
| Releases the ownership immediately. More... | |
| Ref * | autorelease () |
| Releases the ownership sometime soon automatically. More... | |
| unsigned int | getReferenceCount () const |
| Returns the Ref's current reference count. More... | |
| virtual | ~Ref () |
Static Public Member Functions | |
| static GLProgramState * | create (GLProgram *glprogram) |
| returns a new instance of GLProgramState for a given GLProgram More... | |
| static GLProgramState * | getOrCreateWithGLProgram (GLProgram *glprogram) |
| gets-or-creates an instance of GLProgramState for a given GLProgram More... | |
| static GLProgramState * | getOrCreateWithGLProgramName (const std::string &glProgramName) |
| gets-or-creates an instance of GLProgramState for a given GLProgramName More... | |
Protected Member Functions | |
| GLProgramState () | |
| ~GLProgramState () | |
| bool | init (GLProgram *program) |
| void | resetGLProgram () |
| void | updateUniformsAndAttributes () |
| VertexAttribValue * | getVertexAttribValue (const std::string &attributeName) |
| UniformValue * | getUniformValue (const std::string &uniformName) |
| UniformValue * | getUniformValue (GLint uniformLocation) |
Protected Member Functions inherited from Ref | |
| Ref () | |
| Constructor. More... | |
| Ref () | |
| Constructor. More... | |
Protected Attributes | |
| bool | _uniformAttributeValueDirty |
| std::unordered_map < std::string, GLint > | _uniformsByName |
| std::unordered_map< GLint, UniformValue > | _uniforms |
| std::unordered_map < std::string, VertexAttribValue > | _attributes |
| std::unordered_map < std::string, int > | _boundTextureUnits |
| int | _textureUnitIndex |
| uint32_t | _vertexAttribsFlags |
| GLProgram * | _glprogram |
| EventListenerCustom * | _backToForegroundlistener |
Protected Attributes inherited from Ref | |
| unsigned int | _referenceCount |
| count of references More... | |
| var | _referenceCount |
| count of references More... | |
| local | _referenceCount |
| count of references More... | |
Friends | |
| class | GLProgramStateCache |
GLProgramState holds the 'state' (uniforms and attributes) of the GLProgram.
A GLProgram can be used by thousands of Nodes, but if different uniform values are going to be used, then each node will need its own GLProgramState
|
protected |
|
protected |
| void apply | ( | const Mat4 & | modelView | ) |
| void applyAttributes | ( | bool | applyAttribFlags = true | ) |
apply vertex attributes
| applyAttribFlags | Call GL::enableVertexAttribs(_vertexAttribsFlags) or not |
| void applyGLProgram | ( | const Mat4 & | modelView | ) |
| void applyUniforms | ( | ) |
|
static |
returns a new instance of GLProgramState for a given GLProgram
|
inline |
|
static |
gets-or-creates an instance of GLProgramState for a given GLProgram
|
static |
gets-or-creates an instance of GLProgramState for a given GLProgramName
|
inline |
|
protected |
|
protected |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
| void setGLProgram | ( | GLProgram * | glprogram | ) |
| void setUniformCallback | ( | const std::string & | uniformName, |
| const std::function< void(GLProgram *, Uniform *)> & | callback | ||
| ) |
| void setUniformCallback | ( | GLint | uniformLocation, |
| const std::function< void(GLProgram *, Uniform *)> & | callback | ||
| ) |
| void setUniformFloat | ( | const std::string & | uniformName, |
| float | value | ||
| ) |
| void setUniformFloat | ( | GLint | uniformLocation, |
| float | value | ||
| ) |
| void setUniformInt | ( | const std::string & | uniformName, |
| int | value | ||
| ) |
| void setUniformInt | ( | GLint | uniformLocation, |
| int | value | ||
| ) |
| void setUniformMat4 | ( | const std::string & | uniformName, |
| const Mat4 & | value | ||
| ) |
| void setUniformMat4 | ( | GLint | uniformLocation, |
| const Mat4 & | value | ||
| ) |
| void setUniformTexture | ( | const std::string & | uniformName, |
| Texture2D * | texture | ||
| ) |
| void setUniformTexture | ( | const std::string & | uniformName, |
| GLuint | textureId | ||
| ) |
| void setUniformTexture | ( | GLint | uniformLocation, |
| Texture2D * | texture | ||
| ) |
| void setUniformTexture | ( | GLint | uniformLocation, |
| GLuint | textureId | ||
| ) |
| void setUniformVec2 | ( | const std::string & | uniformName, |
| const Vec2 & | value | ||
| ) |
| void setUniformVec2 | ( | GLint | uniformLocation, |
| const Vec2 & | value | ||
| ) |
| void setUniformVec3 | ( | const std::string & | uniformName, |
| const Vec3 & | value | ||
| ) |
| void setUniformVec3 | ( | GLint | uniformLocation, |
| const Vec3 & | value | ||
| ) |
| void setUniformVec4 | ( | const std::string & | uniformName, |
| const Vec4 & | value | ||
| ) |
| void setUniformVec4 | ( | GLint | uniformLocation, |
| const Vec4 & | value | ||
| ) |
| void setVertexAttribCallback | ( | const std::string & | name, |
| const std::function< void(VertexAttrib *)> & | callback | ||
| ) |
| void setVertexAttribPointer | ( | const std::string & | name, |
| GLint | size, | ||
| GLenum | type, | ||
| GLboolean | normalized, | ||
| GLsizei | stride, | ||
| GLvoid * | pointer | ||
| ) |
|
protected |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |