Hi,
i have a proglem with GL_ARRAY_BUFFER_ARB.
Look through this code:
//------ in initialisation section –
GLfloat data[9];GLuint buffer = 0;
int w = 0;
data[w++] = -20;
data[w++] = -20;
data[w++] = 0;data[w++] = 20;
data[w++] = -20;
data[w++] = 0;data[w++] = 20;
data[w++] = 20;
data[w++] = 0;glGenBuffersARB(1, &buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, 9, data, GL_STATIC_DRAW_ARB);// ----- in rendering loop ------
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, 0);// first triangle
glDrawArrays(GL_TRIANGLES, 0, 3);glDisableClientState(GL_VERTEX_ARRAY);
// second triangle
glBegin(GL_TRIANGLES);glVertex3f(-20, -20, 0);
glVertex3f(20, -20, 0);
glVertex3f(20, 20, 0);glEnd();
It should draw two identical triangles, but it doesn’t
It makes something like this:
This bigger triangle is the second one, ane this small one is the first one. Do you know why this happen?
Thanks for help.
Btw. have you noticed that normal vertex arrays are much slower than using glBegin…glVertex3f…glEnd ?