Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » ALLEGRO_FULLSCREEN on OSX

Credits go to Neil Roy for helping out!
This thread is locked; no one can reply to it. rss feed Print
ALLEGRO_FULLSCREEN on OSX
waden87
Member #10,051
August 2008

Hi,

I've been unable to create a fullscreen display using ALLEGRO_FULLSCREEN on OSX. I've read a post found somewhere through google that confirmed this was an open issue a couple of years ago. I read the change log for 5.2 (April 2016?) that listed some fixes to full screen under the Mac OSX section. However, al_create_display is returning a NULL pointer for me. I am currently using 5.2.0.1 and the same code works on Windows. Sorry if this is the wrong place to post this or if it's a duplicate post - I searched the forums for "FULLSCREEN" and didn't see anything that matched my issue.

Thanks!

Neil Roy
Member #2,229
April 2002
avatar

Have you tried "ALLEGRO_FULLSCREEN_WINDOW" perhaps? Which is like a Fullscreen, only it creates a window the size of your display, with no border. I prefer it over fullscreen myself as you can more quickly switch between that and your desktop or whatever.

---
“I love you too.” - last words of Wanda Roy

waden87
Member #10,051
August 2008

This looks like it might work for me. Thanks for the suggestion!

Neil Roy
Member #2,229
April 2002
avatar

Awesome! Let us know how that works out.

Out of curiosity, what are you working on?

---
“I love you too.” - last words of Wanda Roy

waden87
Member #10,051
August 2008

I'm working on a game based on Allegro. Your typical endless side project ;D. An odd thing occurs when I use the ALLEGRO_FULLSCREEN_WINDOW option on OSX. I'm drawing on a bitmap that is 480 x 270 which is then scaled up to an Allegro display that is 1920 x 1080. It looks like some additional space is added to the bottom of the display which flickers between black and white. I have some code that displays the mouse position and it is able to go beyond what I specified for the vertical size of the display. I'll try to post some pictures later of the problem.

Gideon Weems
Member #3,925
October 2003

That's odd. I would only expect such behavior if the screen bitmap had a different aspect ratio than the screen. Are you able to post any code you use for transforming ("scaling"), and does it more or less match this?

waden87
Member #10,051
August 2008

I'm actually scaling up from 480x270 to 960x540 on my mac that has a display size of 1440x900. I guess I need to create an allegro display equal to my physical display and just center the main bitmap on the allegro display.

#SelectExpand
1 al_set_target_bitmap (draw_buffer); //draw buffer is 480x270 2 3/* draw some primitives and bitmaps */ 4 5 6 al_set_target_bitmap ( al_get_backbuffer ( main_display ) );//display is 960 x 540 7 8#if 0 9 al_draw_scaled_bitmap ( draw_buffer, 10 0, 11 0, 12 SCREEN_WIDTH, //480 13 SCREEN_HEIGHT,//270 14 0, 15 0, 16 MAIN_DISPLAY_WIDTH,//960 17 MAIN_DISPLAY_HEIGHT,//540 18 0); 19#else 20// calculate scaling factor 21 sx = MAIN_DISPLAY_WIDTH / SCREEN_WIDTH; 22 sy = MAIN_DISPLAY_HEIGHT / SCREEN_HEIGHT; 23 scale = G_MIN(sx, sy); 24 25 // calculate how much the buffer should be scaled 26 scaleW = SCREEN_WIDTH * scale; 27 scaleH = SCREEN_HEIGHT * scale; 28 scaleX = (MAIN_DISPLAY_WIDTH - scaleW) / 2; 29 scaleY = (MAIN_DISPLAY_HEIGHT - scaleH) / 2; 30 31 al_draw_scaled_bitmap(draw_buffer, 32 0, 33 0, 34 SCREEN_WIDTH,//480 35 SCREEN_HEIGHT,//270 36 scaleX, //0 37 scaleY, //0 38 scaleW,//960 39 scaleH,//540 40 0); 41#endif 42 al_flip_display ();

The key thing I was missing earlier was that I was not matching the allegro display size with my physical screen size. With the code below I can center the final bitmap in the display with a letterbox effect.

#SelectExpand
1 num_full_displays = al_get_num_display_modes(); 2 main_display_return = al_get_display_mode(0, &main_display_mode); 3 main_display = al_create_display ( main_display_mode.width, 4 main_display_mode.height ); 5 6 7 display_width = al_get_display_width(main_display); 8 display_height = al_get_display_height(main_display); 9 10 // calculate scaling factor 11 sx = display_width / SCREEN_WIDTH; 12 sy = display_height / SCREEN_HEIGHT; 13 scale = G_MIN(sx, sy); 14 15 // calculate how much the buffer should be scaled 16 scaleW = SCREEN_WIDTH * scale; 17 scaleH = SCREEN_HEIGHT * scale; 18 scaleX = (display_width - scaleW) / 2; 19 scaleY = (display_height - scaleH) / 2;

Gideon Weems
Member #3,925
October 2003

8:5 (1440×900) is a somewhat uncommon aspect ratio, but now that you've solved the problem, your Allegro app should display perfectly on any screen. Good job.

Go to: