From 8a9586fd9d2954fe24b4b6cb77c942eaf5d4c020 Mon Sep 17 00:00:00 2001 From: James Gregory Date: Mon, 8 Apr 2013 21:08:34 -0700 Subject: [PATCH] More client side buffer fixes. --- cocos2dx/misc_nodes/CCMotionStreak.cpp | 1 + cocos2dx/textures/CCTexture2D.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 0c6787674a..4fef149986 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -338,6 +338,7 @@ void CCMotionStreak::draw() ccGLBindTexture2D( m_pTexture->getName() ); #ifdef EMSCRIPTEN + // Size calculations from ::initWithFade setGLBufferData(m_pVertices, (sizeof(ccVertex2F) * m_uMaxPoints * 2), 0); glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index d51856987f..234f0c8c1b 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -488,8 +488,16 @@ void CCTexture2D::drawAtPoint(const CCPoint& point) ccGLBindTexture2D( m_uName ); +#ifdef EMSCRIPTEN + setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); + glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + + setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); + glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); +#else glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates); +#endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } @@ -513,8 +521,16 @@ void CCTexture2D::drawInRect(const CCRect& rect) ccGLBindTexture2D( m_uName ); +#ifdef EMSCRIPTEN + setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); + glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + + setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); + glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); +#else glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates); +#endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); }