PDA

View Full Version : VBO Woes


CyberSlag5k
03-14-2005, 09:49 PM
I'm using the OpenGL Vertex Buffer Object extension to speed up my rendering, but it's crashing for some reason. Can anybody see why?

Here is the VBO setup code:


pglGenBuffersARB(2, buffList);



pglBindBufferARB(GL_ARRAY_BUFFER_ARB, buffList[0]);

pglBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(*vertList) * numVerts, vertList,

GL_STATIC_DRAW);

pglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffList[1]);

pglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(*indices) * numInd, indices, GL_STATIC_DRAW);


and here is the render code:


pglBindBufferARB(GL_ARRAY_BUFFER_ARB, buffList[0]);

glNormalPointer(GL_TRIANGLES, sizeof(*vertList), BUFFER_OFFSET(0));

glVertexPointer(3, GL_TRIANGLES, sizeof(*vertList), BUFFER_OFFSET(12));

pglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffList[1]);

pglDrawRangeElements(GL_TRIANGLES, 0, numVerts-1, numInd, GL_UNSIGNED_INT, BUFFER_OFFSET(0));



The program crashes with a memory access error on the call to pglDrawRangeElements and I really can't figure out why. I check to make sure that the extension is indeed supported.

Can anybody see what I'm doing wrong?

Axodoss
03-14-2005, 11:27 PM
One thing might be that you are using the functions: glVertexPointer (http://pyopengl.sourceforge.net/documentation/manual/glVertexPointer.3G.html) and glNormalPointer (http://pyopengl.sourceforge.net/documentation/manual/glNormalPointer.3G.html) in a wrong way.

Here is how I use them when using VBO's:
glVertexPointer(3,GL_FLOAT,0,(char*)NULL); // I use (X,Y,Z) hence the value 3
glNormalPointer(GL_FLOAT,0,(char*)NULL);

CyberSlag5k
03-15-2005, 01:39 AM
Doh! Now that you mention it I am using those calls wrong. I'm passing it a size, when I should be passing it a 0 since I'm using the VBOs. I'll give it a shot first thing tomorrow morning.

Thanks Axodoss!

CGTalk Moderation
03-15-2005, 01:39 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.