Skip to content
  • 0 Votes
    4 Posts
    829 Views
    S

    Here are all the WGL functions
    https://docs.microsoft.com/en-us/windows/win32/opengl/wgl-functions

    The function of interest is
    wglMakeCurrent
    https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-wglmakecurrent

    The line of interest is
    "A thread must set a current rendering context before calling any OpenGL functions. Otherwise, all OpenGL calls are ignored."

    so, what I recommend is to call
    wglMakeCurrent(NULL, NULL); (or whatever the Qt equivalent is.)
    from your GUI thread.

    Then, in your other thread, make a context current by calling.
    wglMakeCurrent(hdc, glcontext); (or whatever the Qt equivalent is.)
    and now, you can make gl funciton calls.

    When you are finished, call
    wglMakeCurrent(NULL, NULL);
    then, release the GL context, destroy the GL context and all that stuff.