Merge pull request #11181 from dabingnn/v3_comments

V3 comments
This commit is contained in:
Huabing.Xu 2015-03-27 11:09:17 +08:00
commit 49bf8d5e13
4 changed files with 50 additions and 37 deletions

View File

@ -422,15 +422,16 @@ public:
/** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */ /** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */
void setUniformLocationWithMatrix4fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices); void setUniformLocationWithMatrix4fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices);
/** @{ /**
will update the builtin uniforms if they are different than the previous call for this same shader program. Update the builtin uniforms if they are different than the previous call for this same shader program.
@param modelView modelView matrix applied to the built in uniform of the shader. */
*/
void setUniformsForBuiltins(); void setUniformsForBuiltins();
/**
Update the builtin uniforms if they are different than the previous call for this same shader program.
@param modelView modelView matrix applied to the built in uniform of the shader.
*/
void setUniformsForBuiltins(const Mat4 &modelView); void setUniformsForBuiltins(const Mat4 &modelView);
/**@]*/
/** returns the vertexShader error log */ /** returns the vertexShader error log */
std::string getVertexShaderLog() const; std::string getVertexShaderLog() const;

View File

@ -50,28 +50,23 @@ class CC_DLL UniformValue
friend class GLProgram; friend class GLProgram;
friend class GLProgramState; friend class GLProgramState;
public: public:
/**@{ /**
Construtor. If contruct the UniformValue with no param, the Uniform and Glprogram will be nullptr. Construtor. The Uniform and Glprogram will be nullptr.
*/
UniformValue();
/**
Construtor with uniform and glprogram.
@param uniform Uniform to apply the value. @param uniform Uniform to apply the value.
@param glprogram Specify the owner GLProgram of this uniform and uniform value. @param glprogram Specify the owner GLProgram of this uniform and uniform value.
*/ */
UniformValue();
UniformValue(Uniform *uniform, GLProgram* glprogram); UniformValue(Uniform *uniform, GLProgram* glprogram);
/**
@}
*/
/**Destructor.*/ /**Destructor.*/
~UniformValue(); ~UniformValue();
/**@{ /**@{
Set data to Uniform value. Generally, there are many type of data could be supported, Set data to Uniform value. Generally, there are many type of data could be supported,
including float, int, Vec2/3/4, Mat4 and texture. Besides of this, there are also custom call including float, int, Vec2/3/4, Mat4.
back functions for sending data when you want to send struct or array data.
If we want to send texture to uniform, there are two value to send, first one is texture handle ID,
the second one the texture unit.
@param value Value to be sent, support float, int, Vec2/3/4, Mat4. @param value Value to be sent, support float, int, Vec2/3/4, Mat4.
@param textureID The texture handle.
@param textureUnit The binding texture unit to be used in shader.
@param callback Callback function to send data to OpenGL pipeline.
*/ */
void setFloat(float value); void setFloat(float value);
void setInt(int value); void setInt(int value);
@ -79,12 +74,22 @@ public:
void setVec3(const Vec3& value); void setVec3(const Vec3& value);
void setVec4(const Vec4& value); void setVec4(const Vec4& value);
void setMat4(const Mat4& value); void setMat4(const Mat4& value);
void setCallback(const std::function<void(GLProgram*, Uniform*)> &callback);
void setTexture(GLuint textureId, GLuint textureUnit);
/** /**
@} @}
*/ */
/**
Set call back to uniform value, which could be used for array and struct.
@param callback Callback function to send data to OpenGL pipeline.
*/
void setCallback(const std::function<void(GLProgram*, Uniform*)> &callback);
/**
Set texture to uniform value.
@param textureId The texture handle.
@param textureUnit The binding texture unit to be used in shader.
*/
void setTexture(GLuint textureId, GLuint textureUnit);
/**Apply the uniform value to openGL pipeline.*/ /**Apply the uniform value to openGL pipeline.*/
void apply(); void apply();
@ -132,16 +137,19 @@ class CC_DLL VertexAttribValue
public: public:
/** /**
@{ Constructor.
Constuctor and Destructor. @param vertexAttrib VertexAttrib from shader.
@paran vertexAttrib VertexAttrib from shader.
*/ */
VertexAttribValue(VertexAttrib *vertexAttrib); VertexAttribValue(VertexAttrib *vertexAttrib);
/**
Constructor.
*/
VertexAttribValue(); VertexAttribValue();
/**
Destructor.
*/
~VertexAttribValue(); ~VertexAttribValue();
/**@}*/
/** /**
Set the data pointer, which is similar as glVertexAttribPointer. Set the data pointer, which is similar as glVertexAttribPointer.
@param size The number of type in the vertex attribute. @param size The number of type in the vertex attribute.
@ -200,21 +208,25 @@ public:
/** gets-or-creates an instance of GLProgramState for a given GLProgramName */ /** gets-or-creates an instance of GLProgramState for a given GLProgramName */
static GLProgramState* getOrCreateWithGLProgramName(const std::string &glProgramName ); static GLProgramState* getOrCreateWithGLProgramName(const std::string &glProgramName );
/** @{ /**
Apply GLProgram, attributes and uniforms. Apply GLProgram, attributes and uniforms.
`apply` function will apply all the states, include GLProgram, attributes and uniforms. @param modelView The applied modelView matrix to shader.
`applyGLProgram` function will apply GLProgram and built in uniform.
`applyAttributes` will apply the vertex attributes.
`applyUniforms` will apply user defined uniforms.
@param The applied modelView matrix to shader.
@param applyAttribFlags Call GL::enableVertexAttribs(_vertexAttribsFlags) or not.
*/ */
void apply(const Mat4& modelView); void apply(const Mat4& modelView);
/**
Apply GLProgram, and built in uniforms.
@param modelView The applied modelView matrix to shader.
*/
void applyGLProgram(const Mat4& modelView); void applyGLProgram(const Mat4& modelView);
/**
Apply attributes.
@param applyAttribFlags Call GL::enableVertexAttribs(_vertexAttribsFlags) or not.
*/
void applyAttributes(bool applyAttribFlags = true); void applyAttributes(bool applyAttribFlags = true);
/**
Apply user defined uniforms.
*/
void applyUniforms(); void applyUniforms();
/**@}*/
/**@{ /**@{
Setter and Getter of the owner GLProgram binded in this program state. Setter and Getter of the owner GLProgram binded in this program state.

View File

@ -39,7 +39,7 @@ class CC_DLL PrimitiveCommand : public RenderCommand
{ {
public: public:
/**@{ /**@{
@Constructor and Destructor. Constructor and Destructor.
*/ */
PrimitiveCommand(); PrimitiveCommand();
~PrimitiveCommand(); ~PrimitiveCommand();

View File

@ -46,7 +46,7 @@ public:
/** Initializes the command. /** Initializes the command.
@param globalOrder GlobalZOrder of the command. @param globalOrder GlobalZOrder of the command.
@param textureID The openGL handle of the used texture. @param textureID The openGL handle of the used texture.
@param glProgramState The specified glProgram and its uniform. @param shader The specified glProgram and its uniform.
@param blendType Blend function for the command. @param blendType Blend function for the command.
@param quads Rendered quads for the command. @param quads Rendered quads for the command.
@param quadCount The number of quads when rendering. @param quadCount The number of quads when rendering.