Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / VBO Woes Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
CyberSlag5k

March 14, 2005, 05:39 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:


  1.  
  2.  
  3. pglGenBuffersARB(2, buffList);
  4.  
  5. pglBindBufferARB(GL_ARRAY_BUFFER_ARB, buffList[0]);
  6.  
  7. pglBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(*vertList) * numVerts, vertList,
  8.  
  9. GL_STATIC_DRAW);
  10.  
  11. pglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffList[1]);
  12.  
  13. pglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(*indices) * numInd, indices, GL_STATIC_DRAW);
  14.  
  15.  


and here is the render code:


  1.  
  2.  
  3. pglBindBufferARB(GL_ARRAY_BUFFER_ARB, buffList[0]);
  4.  
  5. glNormalPointer(GL_TRIANGLES, sizeof(*vertList), BUFFER_OFFSET(0));
  6.  
  7. glVertexPointer(3, GL_TRIANGLES, sizeof(*vertList), BUFFER_OFFSET(12));
  8.  
  9. pglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffList[1]);
  10.  
  11. pglDrawRangeElements(GL_TRIANGLES, 0, numVerts-1, numInd, GL_UNSIGNED_INT, BUFFER_OFFSET(0));
  12.  
  13.  


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?

 
Reedbeta

March 14, 2005, 11:27 PM

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

Shouldn't you be passing GL_FLOAT instead of GL_TRIANGLES there?

 
Erik Faye-Lund

March 15, 2005, 09:50 AM

yeah, and also...
glEnableClientState(GL_VERTEX_POINTER);
glEnableClientState(GL_NORMAL_POINTER);
before drawing

 
CyberSlag5k

March 15, 2005, 01:31 PM



Reedbeta wrote: glNormalPointer(GL_TRIANGLES, sizeof(*vertList), BUFFER_OFFSET(0)); glVertexPointer(3, GL_TRIANGLES, sizeof(*vertList), BUFFER_OFFSET(12)); Shouldn't you be passing GL_FLOAT instead of GL_TRIANGLES there?


Yeah somebody on another forum caught that, too. Thanks.

And yeah, I enable the client states. It no longer crashes, but the shape definitely doesn't draw right. Refer to this thread for an update:

http://www.gamedev.net/community/forums/topic.asp?topic_id=306942

Thanks guys!

 
CyberSlag5k

March 16, 2005, 08:34 AM

Thanks for everyone's response. Someone on the gamedev boards noticed I waasn't decalring a stride size for my interleaved arrays. That took care of it.

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.