diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index a97154f5e5..6d53872640 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -539,6 +539,20 @@ void CCTiledGrid3D::blit(void) // Attributes // ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords ); +#ifdef EMSCRIPTEN + int numQuads = m_sGridSize.width * m_sGridSize.height; + + // position + setGLBufferData(m_pVertices, (numQuads*4*sizeof(ccVertex3F)), 0); + glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0); + + // texCoords + setGLBufferData(m_pTexCoordinates, (numQuads*4*sizeof(ccVertex2F)), 1); + glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); + + setGLIndexData(m_pIndices, n * 12, 0); + glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); +#else // position glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, m_pVertices); @@ -546,6 +560,8 @@ void CCTiledGrid3D::blit(void) glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, m_pTexCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, m_pIndices); +#endif // EMSCRIPTEN + CC_INCREMENT_GL_DRAWS(1); }