I’d like to add some code to my program which will push a VBO to the graphics card in a separate thread from the one responsible for drawing, but I can’t for the life of me figure out how to create a new LWJGL context in the new thread. I know it’s a nooby question, but can anyone shed light on the situation?
Firstly, is it that you want to create the VBOs on one thread and draw them in another, because you also need to share the contexts in order to do this. In LWJGL, (as I’m sure you know) you create the context by calling one of the Display.create() methods. One of these methods takes a Drawable argument meant for sharing contexts but I’ve only ever seen this used for sharing OpenGL and OpenCL contexts, never two OpenGL contexts. I don’t actually know of any way to create a context without having a display in LWJGL.
Very sorry that I can’t be of more help but the LWJGL website keeps giving me a 403 permission denied error so I can’t get at the documentation and I find my offline copy very unreadable. I’ve never actually found a good program to read it in. But I digress. I hope I will have been of some help.
You have to use:
SharedDrawable drawable = new SharedDrawable(Display.getDrawable());
on the main thread, then call drawable.makeCurrent() on the secondary thread.
There’s a complete sample in the LWJGL test package, doing texture uploads on a background thread.
And that actually creates a new, shared context? I overlooked this before now.