Multithreading and VBOs

Hi everybody.

I’m new to this message board.

I have a problem using VBOs ina multithread application. Shortly I have two threads, the “renderer” which draws data with VBOs and the “updater” which update the VBOs’ content. To achieve this, I create two GL contexes, one for each thread. Moreover, whenever both threads should refer to the same VBO I guarantee mutual exclusion on that. The problem is that the updater never update the vbo content.

This is the actual order of operations:

  1. Create rendering (main) GL context;
  2. Create empty VBOs.
  3. Launch the “updater” thread.
    3-a) create the updater GL context and make it current.
    3-b) call wglShareLists(rendering_ctx, updater_ctx).
  4. When the renderer wants to render a vbo, locks it, draw it and unlock it.
  5. Similarly, when the updater wants to update the content of a vbo, locks it, update it and unlock it.

In effect, I get a GL_INVALID_VALUE after a glBufferSubData() in the updater thread (yes, I checked thousand times the parameters passed and they are ok).

Some help?

Thanks in advance :slight_smile:



in another thread i found this:

Originally posted by Relic:
Create your window,
select and set a pixelformat (once!),
create the main rendering thread,
create your main rendering OpenGL context,
wglMakeCurrent in the main thread,
create your texture loading OpenGL context,
NOW: wglShareList(mainContext, textureLoadingContext)!
Create the texture loading thread,
wglMakeCurrent of the texture loading OpenGL context to the texture loading thread.

I had to create the secondary context on the main thread.

Thanks ALOT!!!

You’re welcome. :slight_smile:
I think your analysis of the root cause is not correct.
In your case 3-b) call wglShareLists(rendering_ctx, updater_ctx) should have failed because the parameter hglrc2 was made current.
During debugging you would have caught this if you asserted on the boolean return value.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.