glGenVertexArrays returns 0 without glError in worker-thread?
To change the scene-graph during runtime I'm using several working threads which disable the render-loop and update the gl-context (load/unload shaders / replace buffers etc.) e.g.
If I try to generate a vao in a worker thread with:
vaoId (the vertex array name) is 0 and glGenVertexArrays doesn't cast any error message.
I use a library for the gl-context processing but the code looks like this:
glXMakeCurrent(_glfw.x11.display, window->x11.handle, window->glx.context);
This behaviour isn't described in the SDK documatation about glGenVertexArrays.
I'm using a 3.2 core context (also tested with 4.3). My actual workaround would be to create a name-heap at startup and manage them by myself instead of using the gl-Is and gl-delete functions.
There's really no point in threading this like that. If you're using the same context, then shutting down the rendering thread is ultimately no different from simply letting the rendering thread do all of this stuff itself.
So just do it in the rendering thread, as a post-rendering operation. Either that, or make a new, shared context. But that won't help you, because VAOs are container objects and therefore are not shared.
Could you explan why vao creation doesn't work within a differen thread, if the context is current?
Originally Posted by Alfonse Reinheart
Update: The difference is a introduction of thread-lock this is bad if you use services for example.
To answer my own question:
Enabling the current context in one thread doesn't disable it on another.
So I have to notify the renderloop (via semapohre) to give up the context (= NULL) before the new thread can claim it.
To reply Reinhearts suggestion:
I actually try to remove this synchronous and a-synchronous dispatching as much as possible. It is complicated and slow.
Last edited by yousry; 05-16-2013 at 04:32 AM.
Tags for this Thread