JOGL Drawing on Image (e.g. JButton)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JOGL Drawing on Image (e.g. JButton)

raysmith619
JOGL Drawing on Image (e.g. JButton)

We are investigating computer graphics with the hope of creating graphics programs/games for children of the ages 4-8 years old.

We are currently using JOGL. To add images, such as animals, to the 3D viewing area we provide JButtons containing a text title with an image below. To add abstract blocks such as "box", "ball" or "cone", we provide a JButton with a text string. We would prefer to provide a JButton containing a miniature graphic similar to those we generate inside our "display()" calls such as "drawBall(GLAutoDrawable... glut.glutSolidSphere(...".

While we might, for each button, create a complete miniature view, containing an instance of the block, I fear that this would be very computationally expensive as well as programmably cumbersome.

Instead, I'm hoping someone might point me in a better direction. I would like to reuse the JOGL code I use to draw instances of the objects in my various views. Fantastic would be instructions on how I could "draw" in to an Image class via a "GLAutoDrawable" or "GL2"., which I could then create a JButton(String, Image) instance with minimal additional overhead.

Thanks for your consideration.
Ray
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Drawing on Image (e.g. JButton)

gouessej
Administrator
Hey

You can call com.jogamp.opengl.util.awt.AWTGLReadBufferUtil.readPixelsToBufferedImage(GL gl, boolean awtOrientation) to capture your rendering and copy it into a buffered image.
Julien Gouesse | Personal blog | Website