Mixing Java2D and LWJGL

Hi,

Lately i have finished writing a Java version of space invaders using the Java2D api. But then i got thinking, is there a way i can use my very simple particle system that i wrote before space invaders to jazz things up a bit. The problem is though that my particle system is written using the LWJGL library to access OpenGL through Java.

So i was wondering, is there anyway to use both Java2D and LWJGL together at the same time ? I fear i may have to write all of the graphics using OpenGL if i want to use this particle system though :-\

Thanks,

If I’ve understood the question:

Use lwjgl, draw to pbuffers, capture pbuffers to a bufferedimage and draw it to a Java2D graphics. Use RGBA for best performance.

Mik

Hi, thanks for the response. Yea, sounds like that is what i am after. I get the theory but actually implementing it i am not so sure of. Will give it a try a though.

Oh, and when setting up the class which will contain the OpenGL code, do i need to set up a display ? or do i just set up a Pbuffer and ignore making a display ?

Okay, so here goes…

I have managed to put some test code together that allows me to create a Pbuffer, select the Pbuffer as the current context and render to it. Now i am just wondering how to capture the Pbuffer to the buffered image.

Is glReadPixels going in the right direction … i am not sure ? Surely even if this did work it would be a very slow way of doing it ?

Any suggestions would be brilliant :stuck_out_tongue:

Have 2 transparent panes.
The underlying pane is using opengl. Draw your OGL entities/particles onto that pane.
The top pane is where you will do your Java2D rendering.

This may be slower than the PBuffer solution.

Don’t mix Java2D and LWJGL.

Cas :slight_smile:

:’( Yea, thats what i feared and am now realising …