glBegin( GL_QUADS );
glTexCoord2i(0, 0);
glVertex3f( 0-(ButtonSprites[index].Width/2), 0-(ButtonSprites[index].Height/2), 0 );
glTexCoord2i(1, 0);
glVertex3f( 0+(ButtonSprites[index].Width/2), 0-(ButtonSprites[index].Height/2), 0 );
glTexCoord2i(1, 1);
glVertex3f( 0+(ButtonSprites[index].Width/2), 0+(ButtonSprites[index].Height/2), 0 );
glTexCoord2i(0, 1);
glVertex3f( 0-(ButtonSprites[index].Width/2), 0+(ButtonSprites[index].Height/2), 0 );
glEnd();
get converted into
int numvertices = 4;
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
float* vertices= new float[3*numvertices]; //3 coordiantes per vertex
float* textcoord= new float[2*numvertices]; //2 texture coordiantes per vertex
//fill in your array of vertices and texture coordinates with data
textcoord[0] = 0;
textcoord[1] = 0;
textcoord[2] = 1;
textcoord[3] = 0;
textcoord[4] = 1;
textcoord[5] = 1;
textcoord[6] = 0;
textcoord[7] = 1;
vertices[0] = -(ButtonSprites[index].Width/2);
vertices[1] = -(ButtonSprites[index].Height/2);
vertices[2] = 0;
vertices[3] = (ButtonSprites[index].Width/2);
vertices[4] = -(ButtonSprites[index].Height/2);
vertices[5] = 0;
vertices[6] = (ButtonSprites[index].Width/2);
vertices[7] = (ButtonSprites[index].Height/2);
vertices[8] = 0;
vertices[9] = -(ButtonSprites[index].Width/2);
vertices[10] = (ButtonSprites[index].Height/2);
vertices[11] = 0;
glVertexPointer( 3, GL_FLOAT, 0, vertices ); // Set The Vertex Pointer To Vertex Data
glTexCoordPointer( 2, GL_FLOAT, 0, textcoord ); // Set The Vertex Pointer To TexCoord Data
glDrawArrays( GL_TRIANGLE_FAN, 0, numvertices ); //Draw the vertices
No comments:
Post a Comment