Jump to content
  • Advertisement
Sign in to follow this  
honge

Mixing Java 2D and OpenGL

This topic is 4807 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
Advertisement
If you mean using Java2D and OpenGL within the same Java widget/surface, then I'd say no way (for what you're trying to do).

If on the other hand, you're building an editor or some kind, then you can have one window with Java2D/Swing widgets, and have the other window your OpenGL renderer...say to provide a real-time rendering of whatever you're editing in the other window.

As far as your space invaders game goes though, no I don't think you can mix them.

Can you not just change the paint method of each Java2D object to render OpenGL code, rather than Java2D code?


Share this post


Link to post
Share on other sites
I haven't used it myself, but it appears JOGL lets you combine AWT/Swing with OpenGL rendering. For example, you can have an OpenGL viewport inside an AWT/Swing component. I don't think you can do this with LWJGL. I'm not 100% sure if any of this helps you. You may have to port your space invaders game entirely for LWJGL.

Share this post


Link to post
Share on other sites
Thanks guys, re writing the grapics code to all be openGL is deffinately an option, but not one i am too keen on.

Turns out though that some very helpful guys over at the java games forum gave me the suggestion that i render the OGL to an offscreen context such as a Pbuffer and then capture that onto a BufferedImage and pass it back to be rendered as Java2d. Think this is the road i will go down. If anyone has any knowledge of using off screen rendering, Pbuffers etc it would certainly help.

So far i have created the buffer, rendered to it and am writing the code to capture it now onto the BufferedImage.

Any suggestions would be great.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!