GraphicsEnvironment.getLocalGraphicsEnvironment().get.isDisplayChangeSupported()

Started by AGP, January 11, 2012, 07:06:45 PM

Previous topic - Next topic

AGP

I'm printing out FrameBuffer's list of compatible video modes, and using one of them. But the test device.isDisplayChangeSupported() comes back false every time. I'm confused, because display changes are supported (just about every game makes them).


      VideoMode[] videoModes = FrameBuffer.getVideoModes(IRenderer.RENDERER_OPENGL);
for (int i = 0; i < videoModes.length; i++)
System.out.println(videoModes[i]);
      buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
      if (engineData.fullScreen) {
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
System.out.println("Width: "+engineData.width +" Height: "+engineData.height);//COMPATIBLE VALUES
if (!device.isDisplayChangeSupported()) {
     System.err.println("No support for current mode!");return;}//RETURNS EVERY TIME
this.setUndecorated(true);
this.setIgnoreRepaint(true);
device.setFullScreenWindow(this);
device.setDisplayMode(new java.awt.DisplayMode(engineData.width, engineData.height, 32, java.awt.DisplayMode.REFRESH_RATE_UNKNOWN));
      }

AGP

Update: switching the order to

      if (engineData.fullScreen) {
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
this.setUndecorated(true);
this.setIgnoreRepaint(true);
device.setFullScreenWindow(this);
if (!device.isDisplayChangeSupported()){
     System.err.println("No support for current mode!");return;}
device.setDisplayMode(new java.awt.DisplayMode(engineData.width, engineData.height, 32, java.awt.DisplayMode.REFRESH_RATE_UNKNOWN));
      }

has worked.

AGP

It's no longer getting stuck on that test, but it's producing a black screen with the hardware renderer. Also, BufferStrategy is being used for software full screen. Why?

EgonOlsen

Which test? I've no idea why it creates a black screen in hardware mode. Could be everything...do you have the log output avialable? BufferStrategy is usually used to get proper, double buffered fullscreen support.

BTW: The list that FrameBuffer returns is based on what the OpenGL driver reports. It has nothing to do with Java2D.

AGP

I've never used BufferStrategy. I double-buffer manually for 2d, but never double-buffered at all in 3d. What's the benefit (the screen already doesn't flicker)?

It's not black in hardware windowed, just hardware full screen. It doesn't complain (no log output) and runs as if all is well (I know I can play it by its sounds). The display is done by calling buffer.displayGLOnly() and awtCanvas.repaint();

EgonOlsen

So you are using the hardware renderer in form of an AWTGLRenderer? Not the "native" one?

AGP

Yes. Originally the game was going to be windowed-only. Why?

And what's the benefit of double-buffering in 3D if the screen already doesn't flicker?

EgonOlsen

There's no benefit. Maybe it's not needed...i don't really know. I can't remember if i've seen the AWTGLRenderer working in a fullscreen AWT frame...maybe that's a combination that just doesn't work. But that's an LWJGL/AWT issue, not a jPCT one, so i really can't comment much on it. If possible, i would go for the native GL renderer all the time.

AGP

But AWT is so much nicer. Plus, I always use the software renderer as an alternative to the hardware one.

Should I post on the lwjgl boards? Would you (I think they'd take you more seriously)?

EgonOlsen

They don't even take the AWT support of LWJGL serious. They already wanted to remove it and just stopped because some people (including me) interfered because it's the only may to make LWJGL render into different frames at a time.
I'll try to create myself a test case to see what actually happens if you combine these two things...


EgonOlsen

So...the render thread (which is the AWT event dispatch thread in this case) actually runs and the paint-method gets called. You just can't see any output and i'm not sure if it's even possible to achieve this in fullscreen mode. You might want to ask in the LWJGL forum if this is even possible, but i doubt that anybody can/will tell this.
   
What's the point in using AWT for this anyway? In which way is it nicer?

AGP

For one thing, it's nice to have the same frame (and code) for both the hardware and the software renderers. That's why they created the AWTGLCanvas (and why you created your KeyMapper) in the first place, after all. And as a habit, maybe it's a bad habit, I don't know, my main classes usually extend AWT frames, rather than instantiate them.