About JOGL mixing 2D & 3D

hi all:

I glad to see you-all here and feel impassioned discussion. my question is does Applet can implement mix 2D and 3D together to render? I saw some topic include how a Swing UI using Java Web Start to show how to mix 2D and 3D, but didn’t see a Applet example.

I’ve tried to use Applet, put a JPanel on it, and this panle also populated a GLCanvas to render 3D things. when I invoke getGraphics() of GLCanvas for rendering 2D things, it always return NULL.

But I do the same things in a JFrame, I mean it’s not a Applet application. it works fine. only 2D things will be flicker.

plz help me, I am a fresher.

thanks
Mikael

This is a tricky problem at the moment. Afaik you will only be able to mix Java2D and JOGL content when using the opengl pipeline, which is not enabled by default on windows and has some robustness problems. Best would be to do everything in JOGL and using parallel projection to draw your 2D stuff. If you need a GUI you can look at FengGUI (http://www.fenggui.org/doku.php)

thanks a lot, cylab. it 's a exciting webpage, it will help me.

And I expect someone can answer why the Applet cannot display mixing 2D/3D

I couldn’t send you a PM because your inbox is full.

So here my reply to your PM to me:

I have not much personal experience in applet development, sorry. But from what I heard it will only be reliable on the next java plugin version, which is not released yet. Go with FengGUI or don’t try to intermix the Java2D/OGL parts.

You can use Swing/Java2D outside of the GLCanvas without problems though, so you could “frame” your 3D part with GUI elements. Another possibility is to use OpenGL for the 2D part, too (maybe using parallel projection or some 2D OGL functions like glDrawPixes or something in GLUT). The last alternative is drawing with Java2D to a BufferedImage and copy the result to a displayed texture using glTexSubImage2D.

thanks Mathias!

I probably understand. Anyway, it is very new feature. I think to use draw Texture instead directly drawImage is best choice.

thank you!

Mikael