concurrent display list creation

Started by Krux, February 12, 2011, 14:26:16

Previous topic - Next topic

Krux

Hello

We have a problem with creating DisplayLists in the background. In our project we have many objects that are not available at program start, because data needs to be transmittet from the server before we can use them. We do not want to interrupt the rendering loop while the romote objects are loaded, so we exported the loading of those objects into different threads. The loading thread renders the loaded object into a glDisplayList, so that the main loop only needs to check weather the displayList is already available and then if available makes a glCalDisplayList.

But the main problem is that always the glGenLists is called from that other threat, it throws a NullPointerException.

My question is now, how can I render indo DisplayLists (or any other suitable gl structures) from concurrent threads without getting this NullPointerException?

Matthias

I strongly advice against doing multi threaded OpenGL code - most drivers are not stable enough for that.

spasi

You need to use a Pbuffer or a SharedDrawable in the loading thread, that is, a new OpenGL context that shares objects with the main loop context. All loading should happen in the loading thread context, when an object is ready you notify the main loop context and it can use the object immediately (object = display list, texture, whatever). See org.lwjgl.test.opengl.multithread.BackgroundLoadTest in the LWJGL test package for an example of how this can be done.