GL_ARRAY_BUFFER_ARB - doesn't work good

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);

// ----- in rendering loop ------

glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glVertexPointer(3, GL_FLOAT, 0, 0);

// first triangle
glDrawArrays(GL_TRIANGLES, 0, 3);


// second triangle

glVertex3f(-20, -20, 0);
glVertex3f(20, -20, 0);
glVertex3f(20, 20, 0);


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 ?

IIRC, the size argument to glBufferData is in bytes, so you need to use:


instead of the original line.

If you want to compare vertex arrays versus glBegin/glEnd, use larger arrays. Draw 10000 triangles in one batch and see if Begin/End is still faster.

  • elias

[This message has been edited by elias (edited 08-20-2003).]

[This message has been edited by elias (edited 08-20-2003).]

It works!!! Thanks a lot!!
I’ve made my tests with 720000 triangles using GL_TRIANGLES and Vertex Arrays had 13 FPS and Begin/End had 18 FPS.
Do you know if there is any limit of vertex buffer size? When I put more that 340000 triangles (only 3 floats per vertex) something is happening (not of them are drawn and program works very slow).

Large vertex buffers cause weird app behavior for me on a GF4 Ti, latest drivers. Worse problems occured on older drivers, so I guess they’re slowly working it out.

Radeons have a 32 MB limit per buffer, I believe.

For me large Vertex Buffers work very well (Radeon 9800). I think NVidia messed up the Drivers. The bigger the VB the better for the App, due to less state-switching (I’m not sure, but this is what i found out after many tries).


I’ve made a benchmark (really chaotic code - but it’s… working).
Now i see that Begin/End and Vertex Arrays are the slowest. GL_ARRAY_BUFFER_ARB and GL_VERTEX_ARRAY_RANGE_NV are the fastest but only for static scenes. When I write to buffers before every frame then NV buffer wins. I have GF4 4200 - i think NVidia drivers are not so good for mapping the ARB buffer.