Is it possible to change the adapter of the display during runtime ?
I have a dual screen and I want to switch between the two monitors, when I use :
// FullScreen
al_set_display_flag(_windowDisplay, ALLEGRO_WINDOWED, false);
al_set_display_flag(_windowDisplay, ALLEGRO_FULLSCREEN_WINDOW, true);
// Windowed
al_set_display_flag(_windowDisplay, ALLEGRO_FULLSCREEN_WINDOW, false);
al_set_display_flag(_windowDisplay, ALLEGRO_WINDOWED, true);
in "ALLEGRO_FULLSCREEN_WINDOW", the window stay in the first defined monitor, even if I force it with "set_new_display_adapter(another_monitor)".
al_set_display_flag only modifies the current display. You'll want to set the new adapter and create a new window, or simply have one window on each that you modify the 'windowedness' of and then minimize.
I want a behavior like a "normal" window :
{"name":"514852dualscreen.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/f\/8f77e1457a68859f9105b9374a9e6d7a.png","w":640,"h":360,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/f\/8f77e1457a68859f9105b9374a9e6d7a"}
I don't think that Allegro detects which monitor it is over when going to fullscreen. The adapter you create the window on is the adapter it will be fullscreen on when you change the window. I can test this at home tonight, but I think that's how it works.
Allegro could probably be patched to fix this, but I don't know how much work it would be.
I don't think that (currently) you can 'go fullscreen' on any adapter but the original one it was created on.
There is an easy trick for that, just get the window position in the desktop,
If the window Position is in "Monitor[i] zone" then the current adapter MUST be monitor[i] and when I want to go in fullscreen, just need to set the proper adapter.
The problem is 'set_new_display_adapter()' of allegro 5.2.11 don't change/set/modify anything.
We can use it only once time (at initialization before create display) !
That's why it's called al_set_NEW_display_adapter", because it only affects the displays created AFTER it.
Like I said, I don't know what the 'affinity' of a display is to an adapter. Right now it stays with the adapter it was created with.
There would have to be a new function or new settings in order to create the behavior you're expecting.
Like I said, I can look at this tonight, but not until I get home where I have a dual monitor setup.
Regardless, you can work around this by creating a NEW display on the NEW adapter.
I've made a little program to test my Window manager, for my 2D Game Engine.
I join a zip here, you can test it !
For this problem, maybe I need to make one display for each Monitor. I'll keep going to search a solution.
Your test program won't change back from a fullscreen window to a window. No matter what I press. I'm still not home, but I'm going to write a test program too.
Source + Static binary here (7-zip format)
I wrote up a simple test program. You can move and resize the window. You can press M to maximize and N to minimize (restore, actually) (al_set_display_flag(display , ALLEGRO_MAXIMIZED , false);).
You can press F to toggle ALLEGRO_FULLSCREEN_WINDOW, but it always goes fullscreen on the adapter it was created with. You can press O for OpenGL and D for Direct3D. Press a number key to switch adapters.
The program confirms what I thought before. The adapter you create the display on is the adapter that it will go fullscreen window on. There is some other behavior though, like toggling the ALLEGRO_MAXIMIZE flag. It maximizes on the monitor it is currently over. What with it being a window and all, it shouldn't be too hard to get the behavior you want.
Perhaps a few functions like :
al_get_display_adapter_position
al_set_display_adapter_affinity
or the like. Just ideas.
I'll take a look at allegro over the next few days and see what I can dig up.
Source code for my test program here :
Yes, new functions could be great !!
I don't really like the idea to destroy/create display when you want to change adapter. not very elegant, but this is currently the only solution.
Maybe a new minor release of Allegro5 soon !
The majority of the work is done in the _al_win_set_display_flag function in allegro5/src/win/wwindow.c. The adapter there on line 1195 could easily be changed to affect which monitor the window goes fullscreen on.
I dont' know how hard it would be to get allegro to do the same thing on other platforms.
If it's work fine on Windows , I'll be already happy.
It's possible to recompile this module, and add an argument like :
...(..,...,int monitor)
or something else.
_al_set_win_display_flag is probably part of the display driver, and if you change it's arguments then the ABI compatibility would be broken. It might be possible to add an element to the WIN_DISPLAY_DRIVER struct to store a preferred adapter, but that might end up doing the same thing.