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 7 of 7

Thread: wglMakeCurrent returning ERROR_BUSY #2

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    4

    wglMakeCurrent returning ERROR_BUSY #2

    I have same problem as in this topic(http://www.opengl.org/discussion_boa...208&page=2)

    I have different theads and each thread has different OpenGL context (each context has different Window (and DC)). These threads work simultaneously.

    Each thread makes:
    1. Set current context.
    2. Make OpenGL operation.
    3. Set current context NULL.
    4. Any CPU work.
    5. Set current context.
    6. and so on.

    Sometime very rarely I have ERROR_BUSY after wglMakeCurrent (I use getLastError).

    I work under Windows.

  2. #2
    Advanced Member Frequent Contributor Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    943

    Re: wglMakeCurrent returning ERROR_BUSY #2

    If you've got separate contexts for each thread, you do not need to make them current on each draw call. Just once, at startup.
    What you get is quite a normal behavior.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    4

    Re: wglMakeCurrent returning ERROR_BUSY #2

    I must make SetCurrentContext for each rendering, because my component is used in big software system.

  4. #4
    Advanced Member Frequent Contributor Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    943

    Re: wglMakeCurrent returning ERROR_BUSY #2

    Then make your method to access rendering context that tries to get it untill succeedes. In other words, make a wrapper around MakeCurrent. That's what I did long time ago to make it work properly with multithread access.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    4

    Re: wglMakeCurrent returning ERROR_BUSY #2

    Thanks.

    I tried this method. But if I tried MakeCurrent second time, it returned ok, but next call of MakeCurrent for this thread return ERROR_BUSY. It makes my component very slow.

    I hope there is normal method for fix this problem.

  6. #6
    Advanced Member Frequent Contributor Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    943

    Re: wglMakeCurrent returning ERROR_BUSY #2

    Quote Originally Posted by Unick
    I hope there is normal method for fix this problem.
    A "normal" method would be using critical sections (or similar synchronization mechanism) to protect access to each context, or implementing all drawing in threads that own contexts and develop a mechanism to send them messages telling them what to draw.

  7. #7
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    4

    Re: wglMakeCurrent returning ERROR_BUSY #2

    Yes, critical sections are my current solution!

    But I want to make multi-threaded render, I think it can be faster.

    May be somebody knows the reason why this error occurs.

Posting Permissions

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