Multiple Windows on Diffrent Threads

Started by gudenau, November 17, 2015, 03:53:59

Previous topic - Next topic

gudenau

How would I go about implementing a program with two windows with shared assets, both on there own thread.

(java.lang.String was not the correct answer on the question to register, what is wrong with that?)

Kai

First, you must create every GLFW window on the "main" thread.
You must also always invoke glfwWaitEvents/glfwPollEvents in the "main" thread.
Other than that you are free to create any number of windows with their own render context threads.
GLFW.glfwMakeContextCurrent(window) makes the GLFW-managed OpenGL context current in the calling thread.
GL.createCapabilities() lets LWJGL know about a context being current in the calling thread and lets LWJGL initialize itself for OpenGL.
You can also once create GL.createCapabilities() in any OpenGL context thread and then reuse the same returned GLCapabilities object in each other rendering thread via GL.setCapabilities(GLCapabilities).

spasi

The LWJGL repository includes a sample of what Kai describes, here.

Quote from: gudenau on November 17, 2015, 03:53:59(java.lang.String was not the correct answer on the question to register, what is wrong with that?)

Just "String" should work.

gudenau

Thanks for helping a noob.
Does the pollEvents method poll all windows?

Quote from: spasi on November 17, 2015, 10:03:02
The LWJGL repository includes a sample of what Kai describes, here.

Quote from: gudenau on November 17, 2015, 03:53:59(java.lang.String was not the correct answer on the question to register, what is wrong with that?)

Just "String" should work.

Clearly, since I made the topic. I just thought it was strange that the package was not part of it; since you could have a diffrent String class.

spasi

Quote from: gudenau on November 17, 2015, 13:49:00Does the pollEvents method poll all windows?

Yes. You can find more information in the GLFW documentation.

gudenau

How strange.
GL11.glColor3f(0, 0, 0) does not return in my second thread.


Nevermind, I was being stupid.