Problem with ALLEGRO_FULLSCREEN_WINDOW and multi monitor
Edgar Reynaldo

The following code works. When changing it to use ALLEGRO_FULLSCREEN_WINDOW however it does not. src + BG.png here : https://www.allegro.cc/files/attachment/611139

https://pastebin.com/3YW7ddns

#SelectExpand
1#include "allegro5/allegro.h" 2#include "allegro5/allegro_font.h" 3#include "allegro5/allegro_ttf.h" 4#include "allegro5/allegro_image.h" 5#include "allegro5/allegro_primitives.h" 6 7 8 9void DrawLightB(int x , int y , int r , float fr , float fg , float fb); 10void DrawLightB(int x , int y , int r , float fr , float fg , float fb) { 11 al_draw_filled_circle(x,y,r,al_map_rgb_f(fr,fg,fb)); 12} 13void DrawLightA(int x , int y , int r , float fr , float fg , float fb); 14void DrawLightA(int x , int y , int r , float fr , float fg , float fb) { 15 int rad = r; 16 float l = 1. / ((float) r); 17 while (rad > 0) { 18 al_draw_filled_circle(x , y , rad , al_map_rgb_f(fr*l,fg*l,fb*l)); 19 rad -= 1; 20 } 21} 22void DrawLightC(int x , int y , int r , float fr , float fg , float fb); 23void DrawLightC(int x , int y , int r , float fr , float fg , float fb) { 24 int rad = r; 25 while (rad > 0) { 26 float l = (r-rad)/(float)(r*10.0);///1. / ((float) r); 27 al_draw_filled_circle(x , y , rad , al_map_rgb_f(fr*l,fg*l,fb*l)); 28 rad -= 10; 29 } 30} 31 32 33 34///#include "allegro5/allegro_direct3d.h" 35 36 37 38int main(int argc , char** argv) { 39 40 (void)argc; 41 (void)argv; 42 43 44 if (!al_init()) { 45 return 1; 46 } 47 if (!al_init_image_addon()) {return 2;} 48 if (!al_init_font_addon()) {return 3;} 49 if (!al_init_ttf_addon()) {return 4;} 50 if (!al_init_primitives_addon()) {return 5;} 51 52 al_install_keyboard(); 53 al_install_mouse(); 54 55 al_set_new_display_flags(ALLEGRO_FULLSCREEN | ALLEGRO_OPENGL); 56/// al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW | ALLEGRO_OPENGL); 57 ALLEGRO_DISPLAY* d = al_create_display(1920,1080); 58 59 ALLEGRO_TIMER* t = al_create_timer(1.0/60.0); 60 61 ALLEGRO_EVENT_QUEUE* q = al_create_event_queue(); 62 63 al_register_event_source(q , al_get_timer_event_source(t)); 64 al_register_event_source(q , al_get_display_event_source(d)); 65 al_register_event_source(q , al_get_keyboard_event_source()); 66 al_register_event_source(q , al_get_mouse_event_source()); 67 68 ALLEGRO_BITMAP* lmap = al_create_bitmap(1920,1080); 69 ALLEGRO_BITMAP* bg = al_load_bitmap("BG.png"); 70 71 if (!bg || !lmap) {return 7;} 72 73 int mx = 0; 74 int my = 0; 75 76 77 78 ALLEGRO_BITMAP* lmap2 = al_create_bitmap(2048,2048); 79 80 /// draw our light map 81 al_set_target_bitmap(lmap2); 82 al_clear_to_color(al_map_rgb(0,0,0)); 83 84 mx = 1024; 85 my = 1024; 86 87 // Additive blending 88 al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); 89/// DrawLight(0 , 0 , 200); 90/// DrawLight(mx , my , 200 , 1.0 , 1.0 , 1.0); 91 DrawLightA(mx - 100 , my - 100 , 400 , 1.0 , 0.0 , 0.0); 92 DrawLightA(mx + 100 , my - 100 , 400 , 0.0 , 1.0 , 0.0); 93 DrawLightA(mx , my + 73 , 400 , 0.0 , 0.0 , 1.0); 94 95 al_start_timer(t); 96 97 bool run = true; 98 bool draw = true; 99 while (run) { 100 if (draw) { 101 /// draw our light map 102 al_set_target_bitmap(lmap); 103 al_clear_to_color(al_map_rgb(0,0,0)); 104 105 // Additive blending 106 al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); 107 108 al_draw_bitmap(lmap2 , mx - 1024 , my - 1024 , 0); 109 110/// DrawLight(0 , 0 , 200); 111/// DrawLight(mx , my , 200 , 1.0 , 1.0 , 1.0); 112/** 113 114 DrawLightA(mx - 100 , my - 100 , 400 , 1.0 , 0.0 , 0.0); 115 DrawLightA(mx + 100 , my - 100 , 400 , 0.0 , 1.0 , 0.0); 116 DrawLightA(mx , my + 73 , 400 , 0.0 , 0.0 , 1.0); 117 118 DrawLightB(mx - 100 , my - 100 , 300 , 1.0 , 0.0 , 0.0); 119 DrawLightB(mx + 100 , my - 100 , 300 , 0.0 , 1.0 , 0.0); 120 DrawLightB(mx , my + 73 , 300 , 0.0 , 0.0 , 1.0); 121 122 DrawLightC(mx - 100 , my - 100 , 400 , 1.0 , 0.0 , 0.0); 123 DrawLightC(mx + 100 , my - 100 , 400 , 0.0 , 1.0 , 0.0); 124 DrawLightC(mx , my + 73 , 400 , 0.0 , 0.0 , 1.0); 125*/ 126 127 al_set_target_backbuffer(d); 128 al_clear_to_color(al_map_rgb_f(1,1,1)); 129 130 // Default blending (premult alpha) 131 al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); 132 al_draw_bitmap(bg , (1920 - al_get_bitmap_width(bg))/2 , (1080 - al_get_bitmap_height(bg))/2 , 0); 133 134 // Mult source & dest blending 135 al_set_blender(ALLEGRO_ADD, ALLEGRO_DEST_COLOR, ALLEGRO_ZERO); 136 al_draw_bitmap(lmap , 0 , 0 , 0); 137 al_flip_display(); 138 draw = false; 139 } 140 141 do { 142 ALLEGRO_EVENT ev; 143 al_wait_for_event(q , &ev); 144 if (ev.type == ALLEGRO_EVENT_MOUSE_AXES) { 145 mx = ev.mouse.x; 146 my = ev.mouse.y; 147 draw = true; 148 } 149 if (ev.type == ALLEGRO_EVENT_KEY_DOWN && ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { 150 run = false; 151 } 152 if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { 153 run = false; 154 } 155 if (ev.type == ALLEGRO_EVENT_TIMER) { 156 draw = true; 157 } 158 } while (!al_is_event_queue_empty(q)); 159 160 } 161 return 0; 162}

If you change line 55 to use ALLEGRO_FULLSCREEN_WINDOW, it goes crazy and can't display itself properly. I have to unplug the second monitor before it becomes responsive again using a dual monitor setup where the second display is cloned from the first.

This is on Windows 10 with MinGW-W64 Gcc 7.1 and Allegro 5.2.3.

It should look like this :
{"name":"611138","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e9be3b4f5126be6d638296adfc6aa11c.png","w":1026,"h":801,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e9be3b4f5126be6d638296adfc6aa11c"}611138

Thread #617167. Printed from Allegro.cc