Horizontal view

Member
Posts: 241
Joined: 2008.07
Post: #1
I'm trying to get OpenGL ES setup so that Y is up when the phone is being held horizontally. I don't need it to auto-rotate, in fact, it needs not to. I just want the view to rotate horizontally so that you hold the phone that way when playing the game.

The only thing I can find regarding setting the orientation of the view involves a view controller and I am not good at all with IBoutlets and InterfaceBuilder. If there's a way to do it without a view controller, and anybody can help, it would be greatly appreciated. I've been trying to figure this out for a while now.
Quote this message in a reply
Member
Posts: 268
Joined: 2005.04
Post: #2
You can rotate your projection matrix.

Code:
glMatrixMode( GL_PROJECTION );   // Select the projection matrix
glLoadIdentity();                // and reset it
    
glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);    // rotate the coordinate system to switch to landscape view
glOrthof(0.0, 480.0f, 320.0f, 0.0f, 1, -1);  // Set up ortho or perspective here

glMatrixMode( GL_MODELVIEW );    // Select the modelview matrix
glLoadIdentity();                // and reset it
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #3
Is there a way to actually rotate the view?
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #4
This isn't working for me, no matter what I try.

I put the rotation in there that you suggested but once I get the 3D rotated back to the way it should be, it turns out to be exactly the same as before I changed anything. The only thing different is when the phone is rotated, the Y axis actually is up but it looks exactly the same otherwise.

The issue is, the perspective appears to go into the phone to the right.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #5
I finally got the view just right, or so it seems. Here's what I had to do:

1) Rotate local Z + 90
2) Translate local X + 5
3) Rotate world X + 70.

This gives me a slightly tilted birds-eye perspective when the phone is horizontal.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #6
Here I go replying to myself yet again. I found a better way to do it.

starting in landscape mode without status bar. There are several good topics in that website. Check it out.

Cheers!
Quote this message in a reply
Post Reply