Is there a way to set which monitor to open the window on. LWJGL command glfwSetWindowMonitor() offers this options with the 2nd parameter. I don’t see this command as an option under JME?

jME doesn’t offer this. I’ve been tempted to implement it multiple times :smiley: Seems easy enough to do. But unfortunately my current setup is single screen only so never got to it…

As far as I know, this wouldn’t be then supported by LWJGL 2. But I don’t see that as an issue at all.

1 Like

Is the community open to some changes to support Multiple Monitor options inside the core.
Basically would be for LWJGL3.

Changes inside AppSetting for getter/setter of “DesiredMonitor” and then inside lwjglWindow inside LWJGL3 lib, change function createContext(). To check if DesiredMonitor is set and if so alter the LWJGL call to glfwCreateWindow()

Right now it is HARD CODED to either NULL or if FullScreen to grab the PrimaryMonitor().

Then it ALWAYS grabs GLFWVidMode from primaryMonitor().

We could assign the monitor to another monitor integer value based on appsettings. This way it can be set and also when reloading it could grab that from an ini file and set it so creation of window re-creates in on the monitor you had previously.

If so, I’m willing to make the changes and submit it to github for approval.


I can’t speak for the core team. But I’d say this would be superb!


Okay, I have a working copy that works with monitor selection. You can set through AppSettings, it has getter/setter for Monitor. It holds an Int.
Inside jme-LWJGL3 LwjglWindow.createContext(final AppSettings settings) .

It makes a call to a function

 monitor = getMonitor(settings.getMonitor());

     * This routines return the monitor ID by position in an array of monitors returned
     * by glfwGetMonitors().
     * @param pos  the position of the monitor in the list of monitors returned.
     * @return return the monitorID if found otherwise return Primary Monitor
    private long getMonitor(int pos) {
       Monitors monitors = getMonitors();
       if (pos < monitors.size())
          return monitors.get(pos);
       LOGGER.log(Level.SEVERE,"Couldn't locate Monitor requested in the list of Monitors. pos:"+pos+" size: "+ monitors.size());
       return glfwGetPrimaryMonitor();
     * This returns an arraylist of all the monitors returned by OpenGL get Monitor
     * call.
     * @return returns an ArrayList of all Monitors returned by glfwGetMonitors()
    public Monitors getMonitors()
       PointerBuffer monitors = glfwGetMonitors();
       Monitors monitorList = new Monitors();
       for ( int i = 0; i < monitors.limit(); i++ ) {
           long monitorI = monitors.get(i);
           int monPos = monitorList.addNewMonitor(monitorI);
           final GLFWVidMode modes = glfwGetVideoMode(monitorI);

           int width = modes.width();
           int height = modes.height();
           int rate = modes.refreshRate();
           monitorList.setInfo(monPos, width, height, rate);
           LOGGER.log(Level.INFO, "Monitor id: "+monitorI+" Resolution: " + width + " x " + height + " @ " + rate);
        return monitorList;    

Then it creates the window based on what was passed into the Window Class. If it can’t locate the monitor, it will create it on the “Primary Monitor” as default.

Also, made changes to JmeContext. to support getting a list of Monitors and get the primaryMonitor Position.

This way the games “settings” and show a list of monitors if they wish and allow the user to select the monitor. Use can save the position number and have the AppSettings updated so it can be saved/loaded for future use.

This should be able to get full support for the monitor selection.

I have 2 monitors and it works great, and if I disconnect the 2nd monitor it reverts to primary monitor. Also it works great with Horizontal Monitors.

My “Time Pilot” game works great on Horizontal, it automatically figure the height and adjust the width to support the original horizontal play game. Then if it open on Monitor 2, (which is veritical), it works nicely with that and has huge black bars on the side to create the horizontal look.

If I missed something let me know.


I have another question. I know the default settings windows is something no launch game uses, would there be a need to have a selection for monitor inside this. I would think know since this is not really used in the real world.

I also created a TestMonitorApp that I put under the Examples. Showing how to get the monitor list so that you can display a monitor selection in the gui setup settings. I did a quick example of keyboard input to select which monitor to use and save those results in a file for the AppSettings, so on next load it uses what was selected from the monitor list.

user setting gui

The last option is “Monitor” you can scroll through all the different monitors.

The 2 monitors are the same resolution, one is rotated. The game will handle this and adjust the screen. Requires a reset to activate screen changes. Of course this setting is for “Full Screen” only.

1 Like

About this, I would incorporate it to the default settings window. It would be nice to expose it also as a visible example. But surely this can be done separately as well. Again, just my opinion.

Good work!


I’ve finished the code for Multiple Monitors and submitted. Could some check it out for integration.