Hello Guest

AWTGLCanvas triggers unwanted fullscreen exclusive mode

  • 5 Replies
  • 7803 Views
AWTGLCanvas triggers unwanted fullscreen exclusive mode
« on: January 06, 2011, 16:40:47 »
Hi,

When I add a AWTGLCanvas into a JFrame, and the frame is configured with the size of the screen resolution, *something* is causing the application to go into fullscreen exclusive mode. This is a problem for me because I'm trying to overlap another window on top of my application which is not possible in fullscreen exclusive mode.

Please run the attached testcase and let me know if you can reproduce the problem and how I can fix it.

Thank you,
Gili
« Last Edit: January 06, 2011, 17:32:44 by cowwoc »

*

Offline kappa

  • *****
  • 1319
Re: AWTGLCanvas triggers unwanted fullscreen exclusive mode
« Reply #1 on: January 06, 2011, 16:53:51 »
Your testcase seems to be a blank text file.

Make sure you don't have anywhere in your code Display.setFullscreen(true).

Alternatively, you could just use Display.setParent() to embed on a JFrame instead of AWTGLCanvas (plus it should work better).

« Last Edit: January 06, 2011, 16:58:47 by kappa »

Re: AWTGLCanvas triggers unwanted fullscreen exclusive mode
« Reply #2 on: January 06, 2011, 17:33:32 »
Your testcase seems to be a blank text file.

Make sure you don't have anywhere in your code Display.setFullscreen(true).

Alternatively, you could just use Display.setParent() to embed on a JFrame instead of AWTGLCanvas (plus it should work better).

My mistake! I've updated the testcase.

Why would Display.setParent() work better than AWTGLCanvas?

Thanks,
Gili

*

Offline kappa

  • *****
  • 1319
Re: AWTGLCanvas triggers unwanted fullscreen exclusive mode
« Reply #3 on: January 06, 2011, 19:43:12 »
Why would Display.setParent() work better than AWTGLCanvas?

The Display.setParent() was originally added to supersede the AWTGLCanvas, if it wasn't for the fact that AWTGLCanvas is the only way to get multiple displays in LWJGL it would have been removed. In future (possibly LWJGL 3.0) the native display may get support for multiple windows and then its likely AWTGLCanvas will get the chop.

Using Display.setParent() essentially uses the native LWJGL window and just sticks it on top of an AWT Canvas, this gives you almost all the power, speed and compatibility of the native LWJGL Display.

Using AWTGLCanvas limits the rendering speed to the awt/swing update/rendering cycle which makes it slower then Display.setParent().

There are compatibility problems on weaker drivers when using AWTGLCanvas as there can be conflicts between Java2D/AWT acceleration and LWJGL OpenGL. You have to jump through all sorts of hoops to try disable acceleration on the Java2D side and even then it fails in odd cases. That is also the reason the java applet plugin has the "noddraw.check" parameter, since other bindings like JOGL also hit the same problem and there was no other way to stop applets using ddraw acceleration (other then manually changing it in the control panel) and this hack was added to the java plugin itself. The native Display is clearly better in these cases as it handles all its own rendering and bypasses theses issues altogether.

If you want fast low latency input LWJGL Keyboard and Mouse classes are the way to go (AWT just isn't fast enough in certain cases), these classes work with Display.setParent() but not AWTGLCanvas.

On the Mac there is a new AWT/Swing renderer (might even move to other platforms now that Apple is part of OpenJDK). This renderer removes all heavyweight AWT components and everything is rendered through lightweight components (except stuff like Window's and Dialog's). At the moment its only switched on for plugin2 applets (hence why LWJGL applets are currently broken on mac plugin2) but will likely be the default for all AWT/Swing rendering in the future on the Mac. This render breaks all opengl bindings as there is no longer a heavyweight components on which to bind to OpenGL. Its unlikely that the current AWTGLCanvas will ever work with this renderer (at least not anytime soon), although currently Display.setParent is also broken (for different reasons then AWTGLCanvas) there is a fix coming soon and this will work by bypassing the new renderer, again by somehow sticking a native Display on it.

Lastly AWTGLCanvas (api wise) is slightly easier to use and more familiar to the ppl coming from AWT, so if it is removed there will likely be a replacement that wraps Display.setParent() in a nice similar API.
« Last Edit: January 06, 2011, 19:58:16 by kappa »

Re: AWTGLCanvas triggers unwanted fullscreen exclusive mode
« Reply #4 on: January 06, 2011, 19:53:25 »
Is it possible to mix Swing and LWJGL using the Display.setParent() approach? Where can I find example code for it?

Thanks,
Gili

*

Offline kappa

  • *****
  • 1319
Re: AWTGLCanvas triggers unwanted fullscreen exclusive mode
« Reply #5 on: January 06, 2011, 19:55:32 »
If you look at the LWJGL Wiki, there is a Basic LWJGL Applet example tutorial, should be pretty easy to adapt to an application.