www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: mifritscher on October 31, 2011, 09:52:03 am

Title: Mixing Swing & OpenGL?
Post by: mifritscher on October 31, 2011, 09:52:03 am
Hi,

can I mix Swing and OpenGL? I don't need only one big OpenGL Area, but a few small, e.g. (ASCII-art ;) )
G=OpenGL
S=Swing

SSSSSSSS
GGGSGGG
GGGSGGG
SSSSSSSS
SSSSSSSS
SSSSGGGG
SSSSGGGG
SSSSSSSS

Is something like this possible?
Title: Re: Mixing Swing & OpenGL?
Post by: EgonOlsen on October 31, 2011, 01:49:04 pm
Short answer: Yes!

Long answer: Yes, but...

You can obtain an AWT canvas with the gl content from the FrameBuffer via this method: http://www.jpct.net/doc/com/threed/jpct/FrameBuffer.html#enableGLCanvasRenderer() (http://www.jpct.net/doc/com/threed/jpct/FrameBuffer.html#enableGLCanvasRenderer())
If you want multiple gl outputs, you can create multiple FrameBuffer for this. However, they are all heavyweight AWT components, i.e. the usual restrictions when mixing light- and heavyweight components apply.
In addition, some gl drivers seem to have problems with this mix...