mWindows
mWindows

Reputation: 63

GLFW multiple windows multiple threads OpenGL and Vulkan mix

Qustion about GLFW I have a program that has windows in OpenGL and one window with Vulkan. When creating the Vulkan window I set

glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);

when I create OpenGL

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

My problem is after I create the Vulkan window I cannot create any other new windows. If I call glfwCreateWindow it does not work.

Glfw Error 65546: The specified window has no context

(I found this as a problem when working with ImGUI and multiple Viewports. that creates new window when dragging out of main window)

The creation on windows are on different threads. How come one effects the others, and how to restore functionality to get the OpenGL Context back. so I can create more windows? I am missing something here. Thanks.

Upvotes: 2

Views: 854

Answers (1)

httpdigest
httpdigest

Reputation: 5797

Before creating the OpenGL window, you must set the client API to OpenGL again via:

glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);

so that GLFW also creates an OpenGL context (and not only the window). The default of this setting is GLFW_OPENGL_API, but when you explicitly disable OpenGL context creation for Vulkan via glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); you must reenable OpenGL context creation back for the OpenGL window.

See: https://www.glfw.org/docs/3.3/window_guide.html#GLFW_CLIENT_API_hint

Upvotes: 2

Related Questions