Creating Multiple Windows


Is there a way to create multiple windows in JME using the same application instance and show them on different screens?

I see an example (TestMultiViews) that shows how to create different cameras and render them all to the screen in JmeTests, but nothing that will open an additional window into the same scene.

I need to have 6 windows running on 6 screens, on two different graphics cards (3 screens each) on one machine. In other engines I was able create new windows and specify their graphics context, and what monitor to use fairly easily, so far I didn’t see this on the forums or in examples.

I’m thinking the graphics context should be shared between all the windows on the same card, to reuse memory, and since there will be 2 GPUs in the system…I would need 2 graphics contexts for 6 screens.

Is there some example some one knows about that demonstrates how to open more windows?
Of if nothing is available, does someone know how to do this?

Thank you,

Well you could create a window (but only windows) that spans all monitors if it is for that, and then set a hidden lwjgl flag for undecorated window. (see their wiki) Opengl can span multiple devices without any hacks out of the box. (At least if all use the same driver)

Alternativle you could render to a Bufferedimage a offscreen buffer (there is one example on how to do that in the examples), and then use parts of that for different jframes.

Right, having one window across two cards at 6 screens wont work, last time I tried… you see the picture on all screens but when you check the GPUs you see that only one is actually doing all the work.
Without the context split, one card ends up doing all the work, and we want to avoid that. Also, the way our monitors are configured, it would be impossible to span one window on them.

I know openGL supports multiple windows on Windows and Linux, and I know you can run multiple instances of JME on different screens. So it seems (and i’m guessing here) there should be a way to do multiple windows from a single JME app also. I saw an example from JME2 of doing this from 2006, so im hoping its also possible with JME3

The default window, is that made by jframe? Can the default window be opened multiple times with different cameras assigned to them?

In short no not possible lwjgl is incapable of that (jme itself could)
It might work using jogl but no idea how good supported that is.
The alternative is to use multiple applications for rendering, and have one main application with the logic, and doing it via network sync or similar.

Yes, I read a few conflicting threads on having multiple windows with lwjgl. Something about the window itself being Static?
There is this thread…for JME2:
Actually people talk about the keyboard and mouse controls being the problem, which is fine, i can live with just the main window receiving input. I just want the other windows to display.

But you are saying that JME itself can make multiple windows…how?
I’m used to c++ graphics engines…so I come from a different world.

There is an example that uses AWT that comes with JME…for some reason the example crashes for me, but can that be used to create something like this? Or does AWT have bad performance?

Well multiple applications in one jvm seem to have some problems with lwjgl.
I never tried to really use it, as the above window over multipe monitors is fine enough for me.

AWT /Swing will reduce performance, however the cost is constant and mostly in a background thread. This might or might not satisfy your reqirements.

I would generally use a network synced solution as described above when having a similar problem (+ I could add more computers for rendering if necessary). Since I dont know what you need to display I cannot really give more detailed informations.

Depending on what you want to do you can also use a wide canvas window spanning all screens, in contrast to the AWT window it draws directly to the screen. Otherwise, as Empire said its hard to give suggestions without knowing what you want to do :slight_smile:

Do you have multiple cards on your rig? Would you be able to tell me if you see activity on just one GPU or both when you span your window across all the screens?
If all the GPUs are being used…I might be able to use that option. Id have to rebuild a few hardware setup…but it’s better than losing performance.

With AWT, what would be the performance loss, if you can estimate? If im running at 100fps on a normal window, what would it be on ATW? 10% less, 50% or is it constant like 10ftps less, 30fps less, even if you are running at 60fps originally?

It’s still better to have a context per card though since refresh start on each card will be at different times and the software can then sync each window to the correct GPU. If you have a spanning window…across cards…you will get screen tearing on the monitors that are controlled by the slave card.

Networking solution with multiple machines becomes a very expensive rig when you have to deal with many screens. With each card now supporting up to 4 screens, a single machine with 2 cards is a much cheaper solution.

I’m creating an airport tower simulator. I will need 6 monitors, with windows in full screen mode.

AWT is based on memory/cpu throughput, so based on mostly based on resolution.

The networked solution can of course also let all applications run on the same machine, why not?

Screen tearing can be eliminated, at least the ati linux driver has an option to make a global vsync logic. I suppose there are similar solutions for other setups.

Then the question is, if you have 60hz if a small 1ms delay will even be noticable.

For fullscreen you can instead use fullscreen resolution windows, without decoration, jme can do that already (via lwjgl hidden properties)

Then if it is a tower, how long is the acceptable delay between input and reaction? 50ms ? 100ms? 10ms? (eg if you render with multiple apps you can easily sync the images via software then.

Then using the spanning window, might it be a cheaper solution using a 6monitor gpu instead? (assuming you don’t work for free) and for doing any of the multi application approaches you will need some time.


AWT is based on memory/cpu throughput, so based on mostly based on resolution.
Sorry, so based on what?
The networked solution can of course also let all applications run on the same machine
You mentioned that there could be problems with multiple lwjgl windows on the same jvm though, right?
Then the question is, if you have 60hz if a small 1ms delay will even be noticable.
Are you saying that if my software runs at 60hz the delay is only about 1ms? Also will it grow to 2ms if i go to 120hs, or still be 1ms as an overhead?

The delay needs to be minimal, esp when you have planes moving between screens. Also, when you start to move around the airport, the other screens can’t be playing catchup. I’ve used and developed systems like that before, and yes you can get them to run almost seamlessly…but if for some reason you have a lot of network traffic…which we could…things fail.

The spanning is a possible solution if it uses multiple GPUs. 6 screens running of one card, becomes very taxing for the GPU. Also VRAM will get used up a lot faster if it’s not spread out. You mentioned you have a spanning window system…do you use multiple cards?

I basically want to have an ability to create multiple windows…without forcing the user to have a certain window configuration…like in one long line or 3x2 layout. This way the user can just drag the window to whatever screen he wants…or pick it from a menu or a config file.
Because 6 screens will be taxing on the GPU I want to pick the best performing implementation. One that can use all the GPUs on the multiple cards at once, and hopefully not produce screen tearing. We will be running NVidia cards on the machines.

What i meant is several seperate jvms running on the same machine, then lwjgl makes no problems.

Yes I have a tripple head with one R600 card and one cheap 30€ something card.
What might very well the case that only one card did the work for spanned windows, not sure about that.

Since I don’t know what your targeted grafic will be it might be good enough with one gpu or might not, depends entirly on the applications.

For the awt my suggestion is to test it, as it is highly based on several machine parameters.

Yeh…I looked more into lwjgl, and it looks like in 3.0 they will have support for multiple windows. Not sure why they have been so short sighted as of now.
I guess I will have to wait for JME to convert to lwjgl 3.0 when that comes out before trying the lwjgl approach.
How quickly does JME convert to new library versions when they are released?

For now I will try the Span window, and report my findings. I do expect to have problems with only one GPU being used instead of two and having sync problems on half the screens. But maybe SLI can help…or there is some gsync option that exists for non industrial cards.