mirror of https://github.com/axmolengine/axmol.git
fix ShadeNodeTest->SpriteBlur
This commit is contained in:
parent
6b6b37b1ad
commit
2eaba86d76
|
@ -204,7 +204,6 @@ void ShaderNode::draw()
|
|||
|
||||
void ShaderNode::onDraw()
|
||||
{
|
||||
return;
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
float w = SIZE_X, h = SIZE_Y;
|
||||
|
@ -448,6 +447,8 @@ public:
|
|||
|
||||
GLuint blurLocation;
|
||||
GLuint subLocation;
|
||||
protected:
|
||||
void onDraw();
|
||||
};
|
||||
|
||||
SpriteBlur::~SpriteBlur()
|
||||
|
@ -530,39 +531,47 @@ void SpriteBlur::initProgram()
|
|||
}
|
||||
|
||||
void SpriteBlur::draw()
|
||||
{
|
||||
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(cmd);
|
||||
}
|
||||
|
||||
void SpriteBlur::onDraw()
|
||||
{
|
||||
GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
BlendFunc blend = getBlendFunc();
|
||||
GL::blendFunc(blend.src, blend.dst);
|
||||
|
||||
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins();
|
||||
getShaderProgram()->setUniformLocationWith2f(blurLocation, blur_.x, blur_.y);
|
||||
getShaderProgram()->setUniformLocationWith4fv(subLocation, sub_, 1);
|
||||
|
||||
|
||||
GL::bindTexture2D( getTexture()->getName());
|
||||
|
||||
|
||||
//
|
||||
// Attributes
|
||||
//
|
||||
#define kQuadSize sizeof(_quad.bl)
|
||||
long offset = (long)&_quad;
|
||||
|
||||
|
||||
// vertex
|
||||
int diff = offsetof( V3F_C4B_T2F, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
|
||||
|
||||
|
||||
// texCoods
|
||||
diff = offsetof( V3F_C4B_T2F, texCoords);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
|
||||
|
||||
|
||||
// color
|
||||
diff = offsetof( V3F_C4B_T2F, colors);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
|
||||
|
||||
|
||||
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
|
||||
CC_INCREMENT_GL_DRAWS(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue