Author Topic: Integrating with AWT / Swing  (Read 2846 times)

Offline zngga

  • byte
  • *
  • Posts: 6
    • View Profile
Integrating with AWT / Swing
« on: March 09, 2012, 04:29:36 pm »
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)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Integrating with AWT / Swing
« Reply #1 on: March 09, 2012, 08:26:14 pm »
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.

Offline zngga

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Integrating with AWT / Swing
« Reply #2 on: March 09, 2012, 08:34:28 pm »
If you use software rendering, is it still hardware accelerated?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Integrating with AWT / Swing
« Reply #3 on: March 09, 2012, 08:49:30 pm »
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.

Offline zngga

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Integrating with AWT / Swing
« Reply #4 on: March 10, 2012, 09:53:01 pm »
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?