Jump to content
  • Advertisement
Sign in to follow this  
pengzhe1979

OpenGL Question about OpenGL Extension ARB_vertex_buffer_object

This topic is 4825 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, All I'm trying to store all vertex data as vertex array in GPU memory using ARB_vertex_buffer_object extension in order to get a high FPS while rendering a terrain map. I use Quadtree and construct triangle fans. I access one vextex data each time. My code works while without using ARB_vertex_buffer_object, the fps can be 400-500. When I use ARB_vertex_buffer_object, the code can render correctly, but it only gets 2 FPS. Did I miss sth. or I used wrong Extension? can anyone help me? Thanks Here is my code: //initialization glGenBuffersARBExt(1,&m_iVertexBufferID); glBindBufferARBExt(GL_ARRAY_BUFFER_ARB,m_iVertexBufferID); glBufferDataARBExt(GL_ARRAY_BUFFER_ARB,bufferSize,buffer,GL_STATIC_DRAW_ARB); //draw glBindBufferARBExt(GL_ARRAY_BUFFER_ARB,m_iVertexBufferID); glVertexPointer(3,GL_FLOAT,0,0); glTexCoordPointer(2,GL_FLOAT,0,(void *)(m_iMapWidth*m_iMapLength*3*sizeof(float))); glColorPointer(3,GL_UNSIGNED_BYTE,0,(void *)(m_iMapWidth*m_iMapLength*5*sizeof(float))); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glArrayElement(z*m_iMapLength+x); [Edited by - pengzhe1979 on September 23, 2005 3:54:14 PM]

Share this post


Link to post
Share on other sites
Advertisement
glArrayElement only renders one vertex per call. It'd be much faster to call glDrawArrays and do many vertices at once - and probably even better to use indexed arrays and call glDrawElements to render them.

Share this post


Link to post
Share on other sites
I tried glDrawElements even use GL_LINE_STRIP to draw whatever it can draw. But I still got 2 fps. I saw another thread got the same problem because he enabled GL_SELECTION, but I didn't use selection render mode. My video adapter is READON X600 series with latest driver. I just dont know why? Is there any open gl command can explicitly disable selection?

Share this post


Link to post
Share on other sites
I think that's not the problem cuz I didn't use Indic. I just use glDrawElements to go through all vertex in buffer, but I still get 2 fps comparing to 500 fps without using VBO. Even if the glArrayElement make cause some inefficiency, it shouldn't have so much differences.

Share this post


Link to post
Share on other sites
Quote:
Original post by pengzhe1979
I think that's not the problem cuz I didn't use Indic. I just use glDrawElements to go through all vertex in buffer, but I still get 2 fps comparing to 500 fps without using VBO. Even if the glArrayElement make cause some inefficiency, it shouldn't have so much differences.


You can only pass indices to glDrawElements, not the vertices themselves. I think you're thinking of glDrawArrays.

Share this post


Link to post
Share on other sites
I tryed all what you said, but no help. Maybe VBO doesn't work well with my computer. My laptop uses Geforce2 go which does not support VBO, what a pitty~~~~

Share this post


Link to post
Share on other sites
Dont use unsigned bytes as your color data. Use floats, this will fix the problem... I "guarantee" it.

Jeff

Share this post


Link to post
Share on other sites
Quote:
Original post by duke
Dont use unsigned bytes as your color data. Use floats, this will fix the problem... I "guarantee" it.


You're infact better off using unsigned bytes for colours, however you need to make sure your alignment stays correct, this means using 4 bytes instead of 3 to keep things aligned (either use RGBA colour and send 4 colour values or put an extra byte in and just skip it as dummy data and just tell it there are 3 colour values).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!