Integrating with AWT / Swing

Started by zngga, March 09, 2012, 04:29:36 PM

Previous topic - Next topic

zngga

On the features page it implies that you can integrate jPCT with awt/swing... how would you do this. I am looking for a way to have a hardware render in the back with a standard canvas or jpanel in front (for displaying debugging and eventually a simple gui)

EgonOlsen

You have basically three options:


  • Use the software renderer. It will return an Image with the renderer scene that you can use in every way you like.
  • Use the AWTGLRenderer, which renders hardware accelerated into a java.awt.Canvas.
  • Use the native GL renderer and bind it to a component. This is a lwjgl based option. jPCT doesn't support it in any way, but it doesn't prevent you from doing it either.

While options 2 and 3 render into some component, it's difficult to make gui elements that are part of this component.

zngga

If you use software rendering, is it still hardware accelerated?

EgonOlsen

No! Software rendering is...just software rendering. Everything is done on the cpu, i.e. you'll trade speed and quality for the fact that it'll run on everything that supports Java and doesn't need any kind of gpu or OpenGL drivers installed.

zngga

If I use the AWTGLRender... how does that actually render? Does it render directly to the canvas, or to a bufferStrategy built from the canvas? I will take a look at the javadocs to see for myself, but thought I'd ask anyway. My thought process it to use this render method and simply have another render method to render the gui and debug to a bufferedImage with alpha support and draw it over top of the gl render. What do you think?