Detecting Monitores

Is there a way in JME you can detect how many monitors are connected to the computer?

I’m trying to stretch a window (in full and window mode) across whatever monitors are available on the system, assuming they all have the same resolution( there is a way to find out resolution i think…right?), is there a way to find out how many screens are there, and which one starts at 0, or -1920, or etc…?

org.lwjgl.opengl.Display might be of use, you can certainly get at current resolutions/freqs, not so sure about monitor offsets though.

You may have to resort to java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() which can certainly do this, but means it will only work on Java that has AWT (i.e. not Android).

RR

@rockfire

Thanks! That gave me a good start. Is there a way to find out how many monitors the system has without using AWT?

You could use the resolutions, and ask the user.

Pro tip, for any autodetection allways allow a manual setting, way to often overengeenerd autodetections simply fail and annoy the hell out of people. (like the recent trend to not allow direct ip connect, making server setup a hassle)

@EmpirePhoenix

Correct, eventually I will build in a manual override. I kind of have one, but it’s not exposed. But that’s step #2 when I have a good UI so the user can actually control things. For now I need the program to start and function automatically.
Right now I can detect the number of screens using AWT (which i want to avoid) when i look at the resolution using Display.getDesktopDisplayMode() , I don’t get the resolution for all screens, just the main one.

Can Display or lwjgl give me the number of screens? and maybe a resolution for each? Also I would need their offset…

It seems from the lwjgl forums that this is a feature meant to be with lwjgl 3, wich is basically a larger rewrite of core parts.

The 2x releases of it are only designed for single monitor devices, hence the limitations.

So basically
-> Try to switch to lwjgl3
-> Try to switch to the jogl renderer

-> Do it via awt
-> Use swing or jfx for the main screen, and let them handle it.

@EmpirePhoenix

Is there a performance difference between running JME3 on lwjgl2 and jogl?

I know lwjgl2 has a static window, but i was hoping they still had tools to detect other screens. Oh well.

AWT has a huge performance drop, and won’t work on android, so using that is out of the question.
Also…lwjgl2 and 3, are they even compatible APIs? 3 is not out yet, so I can’t risk working with an unstable product. I cant wait for it to come out, and hope JME3 converts to it not too long after.

The window is resizable even with lwjgl, you have to enable it however.

Since they are mostly opengl wrappers, the only incompatible things are probably the native window management. Except they decided to rework the way the api is implemented

@EmpirePhoenix

Right, i was able to resize the window with lwjgl, thats not a problem. I just need to know what to resize it too without using awt to detect settings.

It looks like in the main settings window of JME awt is used to do the resolution and screen detection also. So maybe there is no other good way to do it until lwjgl3 comes out?

Only manual settings probably.

1 Like

@EmpirePhoenix

Right,

Which will come later in the game when I have a GUI… oh well, I guess its AWT detection until then.