From 1dc169b19f170e69c1c28c28b62a903831c1d4c4 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 9 Jan 2014 14:26:22 -0800 Subject: [PATCH] Camera is working again Projection is passed in the shader. Since P is in the shader, QuadCommand uses `Vec3Transform` instead of `Vec3TransformCoord` since it is faster. --- .../2d/ccShader_PositionTextureColor_noMVP_vert.h | 2 +- cocos/2d/renderer/CCQuadCommand.cpp | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h b/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h index fb511ba1dd..bae95bcfea 100644 --- a/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h +++ b/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h @@ -38,7 +38,7 @@ varying vec2 v_texCoord; \n\ \n\ void main() \n\ { \n\ - gl_Position = a_position; \n\ + gl_Position = CC_PMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ diff --git a/cocos/2d/renderer/CCQuadCommand.cpp b/cocos/2d/renderer/CCQuadCommand.cpp index bbb7ba018c..b69fd075d3 100644 --- a/cocos/2d/renderer/CCQuadCommand.cpp +++ b/cocos/2d/renderer/CCQuadCommand.cpp @@ -58,12 +58,6 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* _capacity = quadCount; } - kmMat4 p, mvp; - kmGLGetMatrix(KM_GL_PROJECTION, &p); - - kmMat4Multiply(&mvp, &p, &mv); - - _quadCount = quadCount; memcpy(_quad, quad, sizeof(V3F_C4B_T2F_Quad) * quadCount); @@ -74,7 +68,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec1.x = q->bl.vertices.x; vec1.y = q->bl.vertices.y; vec1.z = q->bl.vertices.z; - kmVec3TransformCoord(&out1, &vec1, &mvp); + kmVec3Transform(&out1, &vec1, &mv); q->bl.vertices.x = out1.x; q->bl.vertices.y = out1.y; q->bl.vertices.z = out1.z; @@ -83,7 +77,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec2.x = q->br.vertices.x; vec2.y = q->br.vertices.y; vec2.z = q->br.vertices.z; - kmVec3TransformCoord(&out2, &vec2, &mvp); + kmVec3Transform(&out2, &vec2, &mv); q->br.vertices.x = out2.x; q->br.vertices.y = out2.y; q->br.vertices.z = out2.z; @@ -92,7 +86,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec3.x = q->tr.vertices.x; vec3.y = q->tr.vertices.y; vec3.z = q->tr.vertices.z; - kmVec3TransformCoord(&out3, &vec3, &mvp); + kmVec3Transform(&out3, &vec3, &mv); q->tr.vertices.x = out3.x; q->tr.vertices.y = out3.y; q->tr.vertices.z = out3.z; @@ -101,7 +95,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec4.x = q->tl.vertices.x; vec4.y = q->tl.vertices.y; vec4.z = q->tl.vertices.z; - kmVec3TransformCoord(&out4, &vec4, &mvp); + kmVec3Transform(&out4, &vec4, &mv); q->tl.vertices.x = out4.x; q->tl.vertices.y = out4.y; q->tl.vertices.z = out4.z;