1

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.

MoonBun
  • 4,322
  • 3
  • 37
  • 69

1 Answers1

2

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 :)

Mads
  • 724
  • 3
  • 10
  • "that's no problem" - when I'm calling GL11.glGenLists from a new thread I get null exception. Is that the worm or what? – MoonBun Apr 18 '12 at 22:03
  • I have never done OpenGL in java, and I can't understand why people do it. I love java for work and such, but with OpenGL C++ just seem the natural choice - there's MANY more resources for it as well. But remember you can't see the other threads data. – Mads Apr 18 '12 at 22:20
  • I can only attest to using JOGL, but I didn't have much issue with references (it's a _very_ thin binding no effort to OO it at all). The benefit of OpenGL is of course it's speed along with portability, the benefit of Java is that the business logic of the program is generally easier to write. There is little trade off but as mentioned by the JOGL implementers a 10% speed reduction was observed against C/C++ implementations. – Quaternion Apr 18 '12 at 23:19