Stuart McDonald
10-13-2008, 11:08 PM
I was drawing a HUD and I noticed the following code with glDrawArrays doesn't work. If I use 3D points it does work.
GLfloat x = 100;
GLfloat y = 100;
GLfloat w = 50;
GLfloat h = 50;
GLfloat box[2*3][2] = {
{ x, y },
{ x, y-h },
{ x+w, y },
{ x+w, y },
{ x, y-h },
{ x+w, y-h }
};
glColor4f(1,1,1,1);
#if 0
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &box[0][0]);
glDrawArrays(GL_TRIANGLES, 0, 2*3);
glDisableClientState(GL_VERTEX_ARRAY);
#else
glBegin(GL_TRIANGLES);
glVertex2f(x, y);
glVertex2f(x, y-h);
glVertex2f(x+w, y);
glVertex2f(x+w, y);
glVertex2f(x, y-h);
glVertex2f(x+w, y-h);
glEnd();
#endif
With my basic understanding I thought the two bits of code were equivalent. Can someone explain the difference. Thanks!
GLfloat x = 100;
GLfloat y = 100;
GLfloat w = 50;
GLfloat h = 50;
GLfloat box[2*3][2] = {
{ x, y },
{ x, y-h },
{ x+w, y },
{ x+w, y },
{ x, y-h },
{ x+w, y-h }
};
glColor4f(1,1,1,1);
#if 0
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &box[0][0]);
glDrawArrays(GL_TRIANGLES, 0, 2*3);
glDisableClientState(GL_VERTEX_ARRAY);
#else
glBegin(GL_TRIANGLES);
glVertex2f(x, y);
glVertex2f(x, y-h);
glVertex2f(x+w, y);
glVertex2f(x+w, y);
glVertex2f(x, y-h);
glVertex2f(x+w, y-h);
glEnd();
#endif
With my basic understanding I thought the two bits of code were equivalent. Can someone explain the difference. Thanks!