Allegro.cc Forums » Programming Questions » Clipping / Rotation

 Kev Callahan Member #6,022 July 2005 An interesting issue/problem I think -I'm using a landscape screen in portrait mode and before I draw everything to screen I setup transformation as follows -```// initiate portrait rotation al_identity_transform(&transf); al_translate_transform(&transf, screen_w/-2, screen_w/-2); // move to centre al_rotate_transform(&transf, screen_angle_rad); // rotate al_translate_transform(&transf, screen_w/2, screen_w/2); // return to top left corner al_use_transform(&transf); ``` However, this (obviously) doesn't affect the clipping coordinates..I have a method to convert from landscape to portrait values by subtracting/adding x,y,width & height values from the screen dimensions, which works fine for (say a specific) 90 degree rotation..I wondered if there was a more flexible method to create the new clipping rectangle after a rotation?Anyone..?
 Kev Callahan Member #6,022 July 2005 Sorry I'm not explaining myself very well I do the following so I can use a 'standard screen in portrait mode (ie rotate 90 degrees c/w) - ```al_build_transform(&transf, screen_w, 0.0, 1.0, 1.0, screen_angle_rad); al_use_transform (&transf); ``` I have the clipping rectangle defined for portrait mode but the above transformation has no effect on the clipping values, so I have to adjust them as follows (clx,y,w,h are original portrait values, lx,y,w,h are landscape ones that Allegro expects)- ```// fix clipping rectangle for portrait (rotation transforms don't affect clipping) lx = screen_w - cly - clh/2; ly = clx - clw/2; lw = clh; lh = clw; ``` I just wondered if there was a quick method that would work for any angle rotation.