Fullscreen / Two monitors

Started by lagz85, February 10, 2010, 15:57:36

Previous topic - Next topic

lagz85

Hi,

I am interested in using LWJGL in my application and have a question about Fullscreen support (similar questions have been asked on this forum, but I haven't found a definitive answer).

Basically I want my application to enable users with two monitors to run my application's OpenGL output window on one monitor (of their choice) and a Swing control application on another monitor. Is this possible using LWJGL? As I understand it LWJGL uses "proper" fullscreen windows, which in my experience will usually only display on the primary monitor and often turn the secondary monitor off. Is this the case with LWJGL? Also, is it possible to specify on which monitor a fullscreen LWJGL window will appear?

My previous plan had been to use JOGL (which unfortunately seems like a fairly dead project at the moment). Since it supports AWT, you can "fake" a fullscreen window on any monitor by creating an AWT window with no decoration that is always on top. Is this kind of "fake fullscreen" approach possible in LWJGL? I cant see any way of removing window decoration in the JavaDoc.

Thanks

lagz85

To answer my own question, yes it is possible! I would still appreciate any advice...

The way I've achieved my "fake fullscreen" mode is to use Display.setParent to effectively put a display inside a Canvas object that is inside an undecorated JFrame that is sized to match the dimensions of the screen. It looks as though the OpenGl rendering doesn't get pushed onto the EDT, which is ideal in case as I don't want any slow swing code in my GUI control application to slow the rendering down.

So....Is there any better way to do this?

p.s. Am I crazy or is a Display not resizable when in windowed mode? Seems very strange?

kappa

answering only part of your original question, yes it is possible to remove the decoration from the lwjgl window (see hidden switch txt file the in the doc's folder of lwjgl download)

simply start vm with the parameter

-Dorg.lwjgl.opengl.Window.undecorated

spasi

I've been using dual monitors for many years, LWJGL never turned my secondary monitor off. An undecorated non-fullscreen window set at the primary monitor's resolution looks exactly like fullscreen and also lets you use any other windows on the secondary monitor. On Windows at least, not sure about other OSes. Unfortunately it turns off WDM on Vista/7, we may have to fix that somehow. Not sure why it happens, but if the undecorated window is smaller than the monitor resolution WDM remains enabled.

Support for multiple Displays would require some serious refactoring, not sure if we have plans to do that.

lagz85

On Mac you have a problem using this approach because the toolbar along the top remains visible, as does the dock. This happens even if the window is set toFront. Using the normal Display fullscreen mode turns off a secondary monitor on a Mac. On windows it doesn't turn off a secondary monitor for me, although I'm pretty sure I have seen both behaviours (may be graphics driver specific).

For my application I think I am going to have to implement two modes:
1: Primary monitor only (use the normal Display class in fullscreen)
2: Secondary monitor whilst keeping primary monitor turned on (use "fake fullscreen" - will work on Mac because the toolbar/dock are usually on the primary monitor).

The problem of fullscreen on the primary monitor + secondary monitor still turned on is still a problem though. It would be great if LWJGL could support multiple monitors (i.e. fullscreen on any monitor, option as to whether the other monitors can be disabled), although it is fairly niche. I would guess it is also a minefield to get everything working correctly, since graphics drivers and OSs seem geared towards turning secondary monitors off for fullscreen apps :-(.


EDIT : Something else I have observed is that the "fake fullscreen" approach on Windows behaves differently between primary and secondary monitors. When put on the primary monitor the secondary monitor goes black for a second before being restored (this is identical to the behaviour I see when using "proper" fullscreen mode). On the secondary monitor this doesn't happen. If I make the window 1 pixel smaller then the effect on the primary monitor disappears.

There must be a dodgy optimisation somewhere, either in the Java API or in LWJGL that is checking whether the window bounds is equal to the bounds of the primary monitor and if so pushing it into fullscreen-exclusive mode. I haven't been able to track it down, but from the behaviour I see, I think it must be there. This optimisation is bad - if someone wants fullscreen exclusive mode they can ask for it!

princec

Currently the behaviour of Display is quite heavily influenced by the graphics drivers. On Nvidia, for example, you can tell the OS that your pair of monitors are actually a single huge monitor arranged howsoever you want, and LWJGL gets back a list of huge display resolutions when it queries the OS about what available resolutions there are. Or you can tell it that there are two separate monitors that are independent, in which case LWJGL only uses the primary one and essentially ignores the secondary monitor - what happens to it is, I think, driver specific at this stage.

I think if you want really decent multimonitor support you are probably better off using the fairly comprehensive AWT APIs and then using Display.setParent() on a fullscreen AWT Frame defined how you want it, which is probably going to work as expected across all OSes. We want to keep the Display API very simple for the 99% of cases where that's all it really needs to do.

Cas :)

lagz85

Quote from: princec on February 15, 2010, 10:08:37
I think if you want really decent multimonitor support you are probably better off using the fairly comprehensive AWT APIs and then using Display.setParent() on a fullscreen AWT Frame defined how you want it, which is probably going to work as expected across all OSes. We want to keep the Display API very simple for the 99% of cases where that's all it really needs to do.

I understand (and agree) that Display should be kept simple for the 99% of cases.

As I said in the previous post using a fullscreen AWT Frame doesn't seem to work on Mac OSs because the menu bar and dock still get rendered above the window. I believe that you can configure an application to be in "presentation mode" so that they are hidden, but ideally I only want them hidden when the OpenGL output window of my application is actually visible (my app consists of a swing control app and an OpenGL window that is not always visible). I believe "presentation mode" is something that you cannot change dynamically from the application itself.

Admittedly I don't have a Mac and I am only borrowing one for testing. Hence there may be a way to solve the issue above that I haven't yet discovered. If anyone knows, please let me know! I guess one option is to write a bit of native code to do it, but I would rather avoid that if possible!

Cheers

spasi

Quote from: lagz85 on February 15, 2010, 10:01:46EDIT : Something else I have observed is that the "fake fullscreen" approach on Windows behaves differently between primary and secondary monitors. When put on the primary monitor the secondary monitor goes black for a second before being restored (this is identical to the behaviour I see when using "proper" fullscreen mode). On the secondary monitor this doesn't happen. If I make the window 1 pixel smaller then the effect on the primary monitor disappears.

There must be a dodgy optimisation somewhere, either in the Java API or in LWJGL that is checking whether the window bounds is equal to the bounds of the primary monitor and if so pushing it into fullscreen-exclusive mode. I haven't been able to track it down, but from the behaviour I see, I think it must be there. This optimisation is bad - if someone wants fullscreen exclusive mode they can ask for it!

That's exactly what I'm seeing too. Even though it isn't fullscreen-exclusive (I can still move the mouse to the secondary monitor, as if it's windowed mode), atm using an undecorated window at the size of the primary monitor's resolution behaves like it's semi-fullscreen (disables WDM, 2ndary monitor goes black, etc). I don't think there's an optimization in LWJGL that causes this, it should be related to the window flags we pass to the OS. There should be a better way to handle this on Vista/7.

What OS are you on lagz85?

lagz85

I experience that behavior on Windows 7.