Advertisement Jump to content
Sign in to follow this  

OpenGL Strange latency when updating dynamic VBO with glUnmapBuffer()

This topic is 1168 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

I use a custom immediate-mode renderer for things like GUI, debug drawing. This works a lot like the old OpenGL immediate mode. To render something, the operations that I am doing are:

  1. orphan the previous buffer memory with glBufferData( NULL ), usage = GL_DYNAMIC_DRAW;
  2. map vertex buffers for position, normal, uv, etc with glMapBuffer();
  3. write vertex data directly to the mapped buffer pointers.
  4. unmap vertex buffers with glUnmapBuffer();
  5. render the data in the buffers.

This works pretty well in most cases and is also pretty fast. However, I am getting a strange artifact when I render dynamic vertex data (e.g. frustum of a rotating camera). The rendered output seems to lag behind the rest of my scene by a few frames. i.e. on frame (n) it seems to render the scene from frame (n) combined with the immediate mode output from frame (n-3). This looks like really bad jitter when the motion is fast.


The only thing I can think that is causing this is that there is some significant latency between when I call glUnmapBuffer() and when the vertex buffers are actually used for rendering. My understanding that glUnmapBuffer() should block the caller until the vertex data has been copied to the GPU, but this doesn't seem to be the case.


If I can't get it to work without these artifacts I will try next to just build the vertex buffers in CPU memory and then glBufferData() to copy the data to the buffers.


Any ideas as to the cause/fix of this problem?

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!