NV: VBO Bug?

I’ve found a problem in a program and I’m not sure whether it’s a bug or I did something wrong. So if you’re familiar with VBO here’s your chance to help me

When I use a vertex program with generic attributes and VBO to draw something, then use standard vertex arrays and draw something again the latter won’t be displayed.

To make it simple I’ve created a minimal app that shows my problem: I’m just drawing two quads. The first with VBO and a vertex program using generic attributes:


glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboHandle);

glVertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (char*)0);
glVertexAttribPointerARB(3, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (char*)12);

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, &indices[0] );


The second one goes like that:

glVertexPointer( 3,GL_FLOAT, sizeof(Vertex), &verts[0].x );
glColorPointer( 3,GL_FLOAT, sizeof(Vertex), &verts[0].r );
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, &indices[0] );

This quad won’t be shown on the screen!

I’ve only seen that issue on my GeForce 3 Ti with latest official detonators and the inofficial 44.65. The code runs fine on my ATI M9.

The full source code is available on http://home.augustakom.net/as120108/VBOBug.zip . You can use the key ‘v’ to switch between using VBO / standard vertex arrays for the first quad and ‘a’ to switch between generic attributes and conventional attributes. You can see the current mode in the console window (But make sure you press the keys in the app window…)


Add this line:

glGenProgramsARB(1, &vertexProgAttrib);

before you ever use vertexProgAttrib and your program will work fine.

Thanks Jason - what a stupid mistake!

You don’t HAVE to use glGenBuffersARB; you just have to make sure vertexProgAttrib is a unique non-zero number.

You don’t HAVE to use glGenBuffersARB; you just have to make sure vertexProgAttrib is a unique non-zero number.

Where in the spec does it say this?

Originally posted by Korval:
Where in the spec does it say this?

It works like texture objects. Every time you call the Gen function, you get a previous+1. You can use 0 which I guess disables the vp.

glGenBuffersARB …

… These names are marked as used, for the purposes of GenBuffersARB only…

Implies that glGenBuffers is mearly a helper function. State isn’t attached to the buffer before it’s bound anyway so it effectively doesn’t exist until that point beyond the booking of glGenBuffers. The example code also just directly starts using buffer 1 without generating it. I believe textures work the same way.

On the other hand I’d like it much better if glGen* was mandatory in all cases.

[EDIT: spelling and got beaten to the punch … ]

[This message has been edited by genglish (edited 07-09-2003).]

The problem was that the variable vertexProgAttrib was a global variable and as such was initialized to zero and this is of course the default program.
So: You needn’t call glGenProgram, but if you don’t make sure not to use 0 for the program object…

(It’s really depressing if you have a strange problem in a big app, try to break it down into a small test case, reproduce a strange behaviour - but just due to an additional bug)