Fullscreen on other than main screen?
APrince

Hello guys,
is it somehow possible to create a fullscreen window on a screen other than the main one? Looking at the docs I see nothing of the sort...

Thanks

Edgar Reynaldo

al_set_new_display_adapter

Does that work for you? I can't test it atm.

APrince

Hm, okay. It will be easier if I describe what I want to achieve...

I have a window with my application and on it there is a "fullscreen button". And I want this button to make the window a fullscreen window on the monitor it is currently on... The function you linked seems to "link" only new windows and not existing ones. Currently it always gets maximized on the main screen.

I imagine I could delete the window and recreate it, but I am not sure if that's not too complicated (if only I knew this at the beginning...) - I have the pointer distributed all over the app (not a good approach, I know...).

Edgar Reynaldo

It should maximize on the monitor it was created on. Don't think allegro lets you change the adapter in use without recreating your display.

If you have a global pointer in use, just use a reference to change it directly. Then all your other references can just see the change normally.

#include <cassert>

ALLEGRO_DISPLAY* ChangeRes(ALLEGRO_DISPLAY** pdisplay , bool fs , int adapter , int ww , int wh) {
   assert(pdisplay);
   if (*pdisplay) {al_destroy_display(*pdisplay);}
   al_set_new_display_adapter(adapter);
   al_set_new_display_option(fs?ALLEGRO_FULLSCREEN_WINDOW:ALLEGRO_WINDOWED | ALLEGRO_OPENGL);
   *pdisplay = al_create_display(ww , wh);
   return *pdisplay;
}

#include "allegro5/allegro.h"

int main(int argc , char** argv) {
   if (!al_init()) {return -1;}
   ALLEGRO_DISPLAY* display = 0;
   if (!ChangeRes(&display , true , 0 , 800 , 600)) {return -2;}
   al_clear_to_color(al_map_rgb(0,0,0));
   al_flip_display();
   al_rest(3.0);
   return 0;
}

Something else you can do is monitor the window position and the monitor areas. You can easily detect when a window overlaps with a monitor, and then choose that monitor (adapter) for your new fullscreen window.

APrince

Well I know on which monitor the window is but I was asking if I can do this without recreating the display. That's a tricky part... I don't know whether this issue was fixed in any of the releases I missed, but I use 5.0.9 and there is this issue with antialiased windows that has been there for ages and I don't think anyone fixed it...

When I create start the application (Windows) with AA flags set, it tries some combinations of AA settings which makes the window flicker for a few seconds. This is annoying but, but I somehow get along with it. But recreating the windows just switch it to fullscreen and thus seeing this again... Well, I don't like it.

But thinking about it... I don't use the real fullscreen window, but rather the fake one (ALLEGRO_FULLSCREEN_WINDOW). Wouldn't it be possible to set this one without recreating the display? I mean, it's still a window, only the size, position and style (the borders) change...

Edgar Reynaldo

Allegro doesn't support toggling fullscreen between monitors, only on the one it was created on. You either have to recreate the window, or use an ALLEGRO_FRAMELESS | ALLEGRO_WINDOWED driver. You can then resize and position the window at will.

5.0.9 is older than dirt. Upgrade.

EDIT
You'll have to toggle the window attribute, for WS_EX_TOPMOST or whatever it is, to cover the taskbar.

APrince

OK, thanks for the tips... I'll see what I can do.

Edgar Reynaldo

If you get it working, you can always submit a patch to allegro.

Make sure to post your progress, I want to see how it goes. ;)

Thread #617422. Printed from Allegro.cc