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?
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?
