From 781663596392e0778ccb3f8f5f54bfa168d0cb0a Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 25 Dec 2013 16:38:43 +0800 Subject: [PATCH] fix ShadeNodeTest->ShaderNode --- .../TestCpp/Classes/ShaderTest/ShaderTest.cpp | 24 +++++++++++++------ .../TestCpp/Classes/ShaderTest/ShaderTest.h | 3 +++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index 687aa6940b..8874fead6f 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -1,6 +1,8 @@ #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" +#include "renderer/CCCustomCommand.h" +#include "renderer/CCRenderer.h" static int sceneIdx = -1; @@ -194,30 +196,38 @@ void ShaderNode::setPosition(const Point &newPosition) void ShaderNode::draw() { - CC_NODE_DRAW_SETUP(); + CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(ShaderNode::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(cmd); +} +void ShaderNode::onDraw() +{ + return; + CC_NODE_DRAW_SETUP(); + float w = SIZE_X, h = SIZE_Y; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; - + // // Uniforms // getShaderProgram()->setUniformLocationWith2f(_uniformCenter, _center.x, _center.y); getShaderProgram()->setUniformLocationWith2f(_uniformResolution, _resolution.x, _resolution.y); - + // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version glUniform1f(_uniformTime, _time); - + GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); - + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - + glDrawArrays(GL_TRIANGLES, 0, 6); CC_INCREMENT_GL_DRAWS(1); } - /// ShaderMonjori ShaderMonjori::ShaderMonjori() diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h index 274654d808..ef5c04ef76 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h @@ -126,6 +126,9 @@ public: static ShaderNode* shaderNodeWithVertex(const char *vert, const char *frag); +protected: + void onDraw(); + private: Vertex2F _center;