- Online Community Forums » Programming Questions » Allegro 5 iOS screen orientation.

This thread is locked; no one can reply to it. rss feed Print
Allegro 5 iOS screen orientation.
Member #14,982
March 2013

Hi everyone!

I'm new to the forums, altough not new to allegro. I just started using Allegro 5 for iOS and i'm new to iOS programming in general (been a windows programmer always).

Now i have a question regarding the screen orientation:

I set these display options and flags before creating the display, and i've set the orientation to "landscape left" in Xcode.


The question is, do i have to use ALLEGRO_TRANSFORM and rotate all of the bitmaps i'm drawing to get them to the right position, or is there another way? ???

| <- the bitmap
[ ] <- iphone

[ |] <- the bitmap goes there
[- ] <- where i want it to go

P.S. What tags can i use here, so i can show the attached pictures?

Thomas Fjellstrom
Member #476
June 2000

Yeah, I believe you want to rotate the screen using a global transform. You should only need to set it up once (and in some of the display events).

Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" --

Member #14,982
March 2013

Okay that was fast :P! Have my thanks! :)

Trent Gamblin
Member #261
April 2000

If you've done it right you shouldn't have to use any ALLEGRO_TRANSFORM for screen orientation on iOS. But that may be a 5.1 feature... are you using 5.0 or 5.1?

Member #14,982
March 2013

I'm on Allegro 5.1 and i'm building for iOS 6.1.

This is my source:

1//In AppDelegate.m, i have this in addition to the default functions: 2 3-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 4{ 5 6 return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 7} 8 9//In main.m: 10 11const int screenWidth = 960; 12const int screenHeight = 480; 13ALLEGRO_DISPLAY *display; 14 15int main(int argc, char **argv) { 16 17 al_init(); 18 al_init_image_addon(); 19 al_init_primitives_addon(); 20 21 al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS, 22 ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE, ALLEGRO_REQUIRE); 23 24 al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW); 25 al_set_app_name("TestApp"); 26 display = al_create_display(screenWidth, screenHeight); 27 28 ALLEGRO_BITMAP *mLogo = al_load_bitmap ("mlogo.png"); 29 30 al_clear_to_color(al_map_rgb(0,0,0)); 31 al_draw_bitmap(mLogo,0,0, 0); 32 33 al_flip_display(); 34 al_rest(5.0); 35 36 al_destroy_bitmap(mLogo); 37 return 0; 38}

And like i said, the orientation is set to "Landscape Left" in Xcode project settings under "Supported Interface Orientations".

The global transformation method should work, but i'm too interested in hearing what the alternative could be :)

EDIT: So i got it to work under iOS 5.1 with the same source code. So it must be with the view controllers. I read that shouldAutorotateToInterfaceOrientation is deprecated in iOS 6.0.

Go to: