Iphone sideways?

Member
Posts: 194
Joined: 2009.02
Post: #1
Is there an api call to rotate the view 90 degrees to "landscape"(and keep it that way for the duration of the program) that would precede any opengl calls?
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #2
set UIInterfaceOrientation to UIInterfaceOrientationLandscapeRight in your info.plist. That signals the OS that your game is in Landscape mode. Then in OpenGL simply rotate your view by 90 degrees. (In SlotZ and Grunts we actually change the rotation based on what angle the device is rotated to).
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #3
I did just that and it works fine(though in opengl I had to rotate -90 not 90), except that the screen origin for events is where is still where it use to be(bottom left of portrait and bottom right in landscape). What's the best way to fix this?
Quote this message in a reply
Member
Posts: 87
Joined: 2006.08
Post: #4
If you want UIKit to translate the event locations for you, you can set a 90-degree transform on the UIView/CALayer itself. However, we usually advise against this because of the performance cost: If you ask for a rotation during composting, then you'll get it. It is less expensive to tell the compositor to pass the image right on through to the display.

So instead we usually advise that you keep a 320x480 (or whatever) buffer unrotated by UIKit/CoreAnimation, and rotate the content yourself. One way to do this is to:
a) add a glRotate(), usually to your projection matrix
b) swap the width/height arguments to glViewport/glScissor. Similar changes need to be done anyplace else you work screen coordinates (such as gl_FragCoord in ES2, DrawTex in ES1).
c) perform your own transform on incoming events. It might be convenient to override UIView's event handling methods to abstract this extra transform away.

Setting the UIInterfaceOrientation is also important, because it sets the overall mode of UIKit, including the orientation of pop-up dialogs (location confirmation, wifi, etc), and I believe the keyboard.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #5
Frogblast Wrote:So instead we usually advise that you keep a 320x480 (or whatever) buffer unrotated by UIKit/CoreAnimation, and rotate the content yourself. One way to do this is to:
a) add a glRotate(), usually to your projection matrix
b) swap the width/height arguments to glViewport/glScissor. Similar changes need to be done anyplace else you work screen coordinates (such as gl_FragCoord in ES2, DrawTex in ES1).
c) perform your own transform on incoming events. It might be convenient to override UIView's event handling methods to abstract this extra transform away.

Setting the UIInterfaceOrientation is also important, because it sets the overall mode of UIKit, including the orientation of pop-up dialogs (location confirmation, wifi, etc), and I believe the keyboard.

Please excuse my ignorance, but are you saying that I need to do a, b and c or just one of these 3? Also for c, how would one go about transforming event coords?
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #6
Sorry to bump this but I'm terribly confused and have tried everything I can think of.
Quote this message in a reply
Post Reply