Initialize openGL before window is displayed

Started by Rednax, December 15, 2012, 21:01:47

Previous topic - Next topic

Rednax

Greeting LWJGL community,

I'm currently working on a small game, which is comming along just fine.
But I want to reduce the loading time by pre-loading various textures and models into the openGL context while the player is still in a simple swing gui to find other players to play with. Creating the Display class the normal way is no good, since the openGL window just pops up.

I have searched through the Displays methods, but there is no way to make it invisible after creation from the Display class.
A possible solution might be to create a parent frame and attach the display to an invisible frame. This solution is not optimal because it removes the option to initialize a fullscreen window.

An other way is to create the window with a minimal amount of pixel (like 4x4) without borders, set it to resizable and resize and place it such that the whole screen is taken at the right moment.

Are there better, less ugly hax around ways of doing this?

kappa

You could use a PBuffer, see LWJGL's PBuffer class. Then just use a shared context when creating your Display so that resources loaded in the PBuffer context are usable.

Rednax

When creating a Pbuffer I cannot specify the openGL version, hence I assume no context is ever created.
Since I have found no implementation of the Drawable interface, I assume I have to get the "Drawable" from the Display. (Assuming the Drawable contains the context).
But that forces me to create the Display before creating a Pbuffer with a shared context, hence I have reached nothing...

Im getting really confused here!

Let me make the question very concrete:
Is it possible to create an openGL context, hence execute openGL commands, without creating a Display.
And is it then possible to let the Display use this context when creating the Display?

Example: load and compile shaders before creating the Display.

spasi

It is in fact possible to specify the OpenGL version when creating a Pbuffer, there's a ContextAttribs parameter. You can do all preloading using the pbuffer context and then pass it as the shared drawable to Display.create.