Jump to content
  • Advertisement
Sign in to follow this  
industrion

VBObjects rebuild bringing about random framerate...

This topic is 4272 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 everyone. I've just added vertex buffer object support to my terrain engine, and I'm allowing me to modify the terrain in real time, and so, I've allowed another option to rebuild the VBOs in order to see the changes made to the terrain (alternatively, I could've added the rebuild method to the end of each terrain modification method). However, each time I rebuild, my program seems to 'set itself' a new framerate. It's not that the framerate drops each time I rebuild; the last test I just did had the program running at a considerably lower framerate (150fps) than when I rebuilt a few times (jumping from values in between up to a more reasonable 300fps). Note that this framerate doesn't really change *during* the rebuilds, that's why I said 'set itself a new framerate'. I've added my code below. I don't know if there's anything else I should be doing before I rebuild VBOs, but, either way, can anyone help me out with the fluctuating FPS thing? Thanks. void CTerrain::BuildVBOs() { glGenBuffersARB( 1, &m_unVBOVerticesID ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_unVBOVerticesID ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_nTotalVertices*3*sizeof(float), m_pcVertices, GL_STATIC_DRAW_ARB ); glGenBuffersARB( 1, &m_unVBOTexCoordsID ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_unVBOTexCoordsID ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_nTotalVertices*2*sizeof(float), m_pcTexCoords, GL_STATIC_DRAW_ARB ); glGenBuffersARB( 1, &m_unVBOColoursID ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_unVBOColoursID ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_nTotalVertices*3*sizeof(float), m_pcColours, GL_STATIC_DRAW_ARB ); glGenBuffersARB( 1, &m_unVBONormalsID ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_unVBONormalsID ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_nTotalVertices*3*sizeof(float), m_pcNormals, GL_STATIC_DRAW_ARB ); }

Share this post


Link to post
Share on other sites
Advertisement
You are generating new buffers each time without deleting the old buffers first. Somewhen you will run out of memory! Fortunately, you don't need to generate new buffers:
1) Bind desired VBO
2) Replace data with glBufferSubData()

This will be considerably faster and you will not run out of memory :)

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!