# Secondary Thread for Loading

**URL:** <https://discourse.glfw.org/t/secondary-thread-for-loading/1724>\
**Category:** support\
**Created:** [January 2, 2021, 12:00am UTC](https://discourse.glfw.org/t/secondary-thread-for-loading/1724 "2021-01-02T00:00:35Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [January 2, 2021, 6:58pm UTC](https://discourse.glfw.org/t/secondary-thread-for-loading/1724/4 "2021-01-02T18:58:00Z")

</div>

There is a related issue for multi contexts from a single window which may be of interest:

> <https://github.com/glfw/glfw/issues/1687#issuecomment-638399075>
>
> The following thread on discourse discusses a need for multiple contexts for a w…indow:
> https://discourse.glfw.org/t/fullscreen-window-blinking/1538/4
> 
> I am unsure about the overall benefit of multiple contexts for OpenGL these days, and I think it's best to keep GLFW as lean as possible, however this is something which is currently not possible to do with GLFW without altering core GLFW code so I think it's reasonable to consider.
> 
> Potential approaches:
> 
> 1. Expose the required OS specific information via the GLFW native API, for example on Windows WGL requires the device context \`window-\>context.wgl.dc\` which is not currently exposed. Users could then write their own OS specific code to create contexts.
> 2. Add \`GLFWUserContext\* glfwCreateUserGLContext(GLFWwindow\* window)\` and supporting functions, see below. I have named these User Contexts to differentiate from the GLFW context created along with the window.
> 
> For 2 we would need
> \`\`\`
> // Create a new context for a window
> GLFWUserContext\* glfwCreateUserGLContext(GLFWwindow\* window);
> 
> // Delete a context
> void glfwDestroyUserContext(GLFWUserContext\* context);
> 
> // Make a context current
> void glfwMakeUserContextCurrent(GLFWUserContext\* context);
> 
> // Get current context - returns NULL if primary window context is current,
> // in which case glfwGetCurrentContext would return window, and
> // glfwGetCurrentContext will return NULL if a user context is current.
> GLFWUserContext\* glfwGetCurrentUserContext(void);
> \`\`\`
> 
> I can create the Windows versions of the API, and sdegrande can help with the GLX and potentially Mac.
> 
> This is potentially related to #1501

along with a question on this forum:

> [@Fullscreen window blinking](https://discourse.glfw.org/t/fullscreen-window-blinking/1538):
>
> Hi. I’m using GLFW for a VR painting project at work. I use threads to async-load heavy 3D Models, with their own opengl context, created using an invisible window, as proposed in the GLFW doc. The temp windows are created and destructed in the main thread. It works well. But, on windows (10), if the main window (main thread) is fullscreen, there is a black blink when a temp window is destructed. There is no such issue on Linux. I traced it down to the call to win32 DestroyWindow(). So my qu…

I have an in-progress branch:

> **[Commits · dougbinks/glfw](https://github.com/dougbinks/glfw/commits/multi-context-windows)**
>
> A multi-platform library for OpenGL, window and input - Commits · dougbinks/glfw

The functionality is mostly complete, but I need to update the docs and choose a better name prior to submitting a PR.

---

_[View the full topic](https://discourse.glfw.org/t/secondary-thread-for-loading/1724)._
