struct vert3d_struct
{
GLfloat x;
GLfloat y;
GLfloat z;
};
typedef struct vert3d_struct vert3d;
vert3d *vertices;
GLushort *indices;
GLuint vboBuffers[2];
vertices[0].x = -20.0;
vertices[0].y = -20.0;
vertices[0].z = 0;
vertices[1].x = 20.0;
vertices[1].y = -20.0;
vertices[1].z = 0;
vertices[2].x = 20.0;
vertices[2].y = 20.0;
vertices[2].z = 0;
vertices[3].x = -20.0;
vertices[3].y = 20.0;
vertices[3].z = 0;
verticesCount = 4;
indices[0]=0;
indices[1]=1;
indices[2]=2;
indices[3]=3;
vertices = (vert3d *) malloc ( 4 * (sizeof(vert3d)));
indices = (GLushort *) malloc( 4 * sizeof(GLushort) );
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboBuffers[0]); //vertex data
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vboBuffers[1]); //indicies
glBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * (sizeof(vert3d)), vertices, GL_STATIC_DRAW_ARB);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 4 * sizeof(GLushort), indices, GL_STATIC_DRAW_ARB);
glEnableClientState(GL_VERTEX_ARRAY);
glColor3f(0.0, 0.0, 1.0);
glDrawElements(GL_QUADS, verticesCount, GL_UNSIGNED_SHORT, 0);
glDisableClientState(GL_VERTEX_ARRAY);