Vertex Buffer Objects with Dynamic Data

Started by
2 comments, last by RobTheBloke 18 years, 1 month ago
Are there any good tutorials about using Vertex Buffer Objects properly with dynamic data? I want to render models where the vertices are recalculated each time (because I'm interpolating between frames), though the normals and texture coordinates are precalculated. I could understand that using VBOs for the vertices doesn't give any benefit, but I'm actually finding them slower than ordinary vertex arrays! First some performance figures. "Mixed" means that I'm using VBOs for the normals/texture-coords, but using an ordinary vertex array for the vertices. The figure in brackets is with normals disabled. Scene 1 - 700K triangles: No VBOs: 15FPS (19FPS) All VBOs: 15FPS (16FPS) Mixed: 28FPS (28FPS) Scene 2 - 130K triangles: No VBOs: 85FPS (110FPS) All VBOs: 85FPS (89FPS) Mixed: 178FPS (178FPS) Scene 3 - 772 triangles: No VBOs: 1200FPS (1200FPS) All VBOs: 1125FPS (1125FPS) Mixed: 1200FPS (1200FPS) So there are two things to conclude: - "Mixed" gives a significant advantage, presumably as the color/texture-coord data is cached on the gfx card rather than being sent each frame. But using a VBO for the vertices too loses this performance gain! - If normals are disabled, using a VBO for the vertices makes things slightly slower than not using VBOs at all. The code I'm using is: glGenBuffersARB( 1, &vbo_vertices ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, vbo_vertices ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, 3*n_vertices*sizeof(float), NULL, GL_STREAM_DRAW_ARB ); for initialisation, and then rendering each frame with: glBindBufferARB( GL_ARRAY_BUFFER_ARB, vbo_vertices ); glBufferSubDataARB( GL_ARRAY_BUFFER_ARB, 0, 3*n_vertices*sizeof(float), va_vertices_temp ); glVertexPointer(3, GL_FLOAT, 0, (char *)NULL); I've tried calling glBufferDataARB each frame to set the data, but that doesn't help. I'm using glDrawRangeElements to draw the arrays. Am I doing something wrong here? Or is this yet another case of VBOs being implemented poorly? I've looked at the many other threads on similar subjects, and can't see what I'm doing wrong. I've got a Radeon 9800, and have the latest OpenGL drivers. Okay, I can just use my "Mixed" method, and get a nice performance increase - but my reading from various forums is that this isn't the method I'm supposed to be using! Any ideas? thanks in advance, mark

http://erebusrpg.sourceforge.net/ - Erebus, Open Source RPG for Windows/Linux/Android
http://conquests.sourceforge.net/ - Conquests, Open Source Civ-like Game for Windows/Linux

Advertisement
i sujjest searching these forums or the opengl.org advanced forum theres been quite a few detailed discussions on it
Mark,
I guess your vertex array implementation is too good, so VBO cannot catch up :).
Have you tried map/umap instead of just copying new data into VBO?
Here is my note about VBO:
VBO

At the bottom, there is an example using map/unmap VBO. Try it on your system.
==song==

[Edited by - songho on March 6, 2006 2:38:14 PM]
http://www.robthebloke.org/opengl_programming.html#5

check out the MD2 loader example. It does basically the same thing you are doing, using VBO you *should* see a speed up (unless all of your data is dynamic, in which case you'll get similar performance to vertex arrays).

This topic is closed to new replies.

Advertisement