Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: glGenVertexArrays returns 0 without glError in worker-thread?

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16

    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.

    stop render-loop
    get context
    update
    continue render-loop

    If I try to generate a vao in a worker thread with:

    glGenVertexArrays(1, &vaoId);

    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.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16
    Quote Originally Posted by Alfonse Reinheart View Post
    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?

    Update: The difference is a introduction of thread-lock this is bad if you use services for example.

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16
    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. Reason: Typo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •