OpenGL multithreading in LWJGL (JAVA)

At the beginning of the game I'm loading models and stuff, it's taking some time and therefore there is an empty black screen while loading.

So what I want to do is to put all the model loading and the display list creation into one thread and to make (render) some loading in the other. Now that I learned that OpenGL doesn't work well with multithreading and OpenGL commands can be called only from one thread my oreginal thread solution doesn't work. Both thread should be able to call OpenGL commands: rendering and display lists creation.

Does anyone knows (familiar) an easy solution to this? A good link with example will do.

Answers


You have to remember the model for interpretation of GL commands is client-server. That is, a program (the client) issues commands, and these commands are interpreted and processed by the GL (the server) - (taken from the specs).

So you can easily send from commands from both threads - that's no problem. But by playing with multithreading you're opening a big potential can of worms if you don't know what you're doing.

When loading I would just make a loading screen and update it when some of the resources have been loaded. Not everything needs a super perfect solution - especially not a minor thing as this :)


Need Your Help

Can SwapChainBackgroundPanel be added as a sub control?

windows-runtime winrt-xaml xna-4.0 windows-8.1 monogame

I created a sample app with mono wizard "MonoGame Windows Store(XAML) Project".

Java - putting comma separated integers from a text file into an array

java arrays file integer

Had a quick question based on an assignment I'm working on.