Skip to content

Instantly share code, notes, and snippets.

@cdave1
Created March 29, 2011 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdave1/893606 to your computer and use it in GitHub Desktop.
Save cdave1/893606 to your computer and use it in GitHub Desktop.
Changes to ftglBegin and ftglEnd on android...
GLvoid ftglBegin(GLenum prim)
{
if (!ftglesQuadIndicesInitted)
{
for (int i = 0; i < FTGLES_GLUE_MAX_VERTICES * 3 / 2; i += 6)
{
int q = i / 6 * 4;
ftglesGlueArrays.quadIndices[i + 0] = q + 0;
ftglesGlueArrays.quadIndices[i + 1] = q + 1;
ftglesGlueArrays.quadIndices[i + 2] = q + 2;
ftglesGlueArrays.quadIndices[i + 3] = q + 0;
ftglesGlueArrays.quadIndices[i + 4] = q + 2;
ftglesGlueArrays.quadIndices[i + 5] = q + 3;
}
ftglesQuadIndicesInitted = true;
}
ftglesGlueArrays.currIndex = 0;
ftglesCurrentPrimitive = prim;
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ftglesVertex_t), ftglesGlueArrays.vertices[0].xyz);
glTexCoordPointer(2, GL_FLOAT, sizeof(ftglesVertex_t), ftglesGlueArrays.vertices[0].st);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ftglesVertex_t), ftglesGlueArrays.vertices[0].rgba);
}
GLvoid ftglEnd()
{
if (ftglesGlueArrays.currIndex == 0)
{
ftglesCurrentPrimitive = 0;
return;
}
if (ftglesCurrentPrimitive == GL_QUADS)
{
glDrawElements(GL_TRIANGLES, ftglesGlueArrays.currIndex / 4 * 6, GL_UNSIGNED_SHORT, ftglesGlueArrays.quadIndices);
}
else
{
glDrawArrays(ftglesCurrentPrimitive, 0, ftglesGlueArrays.currIndex);
}
ftglesGlueArrays.currIndex = 0;
ftglesCurrentPrimitive = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment