samedi 25 août 2018

Cocos2d-x GL_TRIANGLE_STRIP rendering issue

Anyone have any ideas why the terrain get degraded when getting further to the right X axis? I feel like it’s a floating point issue when X gets big it's corrupting the triangles. This happens on iOS and Android works fine.

Any help or suggestions would be greatly appreciated!

screenshot

void Terrain::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
    _customCommand.init(0);
    _customCommand.func = CC_CALLBACK_0(Terrain::onDrawCallback, this, renderer, transform, flags);
    renderer->addCommand(&_customCommand);
}
void Terrain::onDrawCallback(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{  
    CC_NODE_DRAW_SETUP();
    GL::bindTexture2D(getSprite()->getTexture()->getName());
    GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORD);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _texCoords);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nVertices);
}

Aucun commentaire:

Enregistrer un commentaire