LWJGL Forum

Programming => OpenGL => Topic started by: doev on July 14, 2015, 14:24:15

Title: Invalid X server connection specified
Post by: doev on July 14, 2015, 14:24:15
If I init lwjgl3 in the main-thread and then use GLContext.createFromCurrent() in another thread, I get the error: "Invalid X server connection specified".

Is this still this issue?

https://github.com/LWJGL/lwjgl3/issues/39

Or am I doing something wrong?
Title: Re: Invalid X server connection specified
Post by: spasi on July 14, 2015, 15:06:08
Issue #39 should be fixed. Have you called glfwMakeContextCurrent in the secondary thread?
Title: Re: Invalid X server connection specified
Post by: doev on July 15, 2015, 11:42:46
Quote from: spasi on July 14, 2015, 15:06:08
Issue #39 should be fixed. Have you called glfwMakeContextCurrent in the secondary thread?

Yes, I have. Finally I only get it to work, when I setup lwjgl and the window in the same thread.
Title: Re: Invalid X server connection specified
Post by: spasi on July 15, 2015, 14:33:30
Quote from: doev on July 15, 2015, 11:42:46Yes, I have. Finally I only get it to work, when I setup lwjgl and the window in the same thread.

There is no such limitation. The only constraint is that GLFW initialization, window creation and event handling (i.e. glfwPollEvents()) must be done in the main thread. The contexts associated with the GLFW windows can be made current in other threads. See this example (https://github.com/LWJGL/lwjgl3/blob/master/modules/core/src/test/java/org/lwjgl/demo/glfw/Threads.java) of how it can work in practice.

Could you post some code that triggers the "Invalid X server connection" error?
Title: Re: Invalid X server connection specified
Post by: doev on July 16, 2015, 12:04:36
Thank you for the example. Its working fine.