Landscape Mode in OpenGL ES - Help

Apprentice
Posts: 16
Joined: 2008.10
Post: #1
I've read on the OS guide to modify my view transform to rotate everything on a 90 degree angle when I want to render in landscape mode.

To do this I:

glTranslate( 0, 0, 0 );
glRotate( 90, 0, 0, 0 );
[_mytexture] drawAtPoint:CGPointMake(0,0);

The problem is nothing happens.....I looked at the helper code for drawAtPoint and it appears to be just drawing a quad at the given coordinates. What do I need to do in order for it to accept the rotate transform?

Is there an easier way to do Landscape mode? It seems all you would have to do is rotate your view and be done with it.

I am not new to 3D programming but am VERY new to OpenGL. Help with this would be appreciated.

Thanks!
Quote this message in a reply
Member
Posts: 283
Joined: 2006.05
Post: #2
Once you've done the glRotate, everything afterwards will have the same rotation - you're manipulating the matrix. All the values are relative, so translating by (0,0,0) has no effect.

Have a look at the man page for glRotate; I suspect you'll want something like glRotate(90,0,0,1).

And by itself, this code will do the same transformation every frame. You'll probably want to call glPushMatrix() at the start and glPopMatrix() at the end of the drawing code.
Quote this message in a reply
Apprentice
Posts: 16
Joined: 2008.10
Post: #3
maximile Wrote:Once you've done the glRotate, everything afterwards will have the same rotation - you're manipulating the matrix. All the values are relative, so translating by (0,0,0) has no effect.

Have a look at the man page for glRotate; I suspect you'll want something like glRotate(90,0,0,1).

And by itself, this code will do the same transformation every frame. You'll probably want to call glPushMatrix() at the start and glPopMatrix() at the end of the drawing code.

Yeah, thanks. I didn't realize it was rotating by the value in the other 3 parms.

One question, the OS docs mention that you should also change your glViewport settings. Is that really necessary or should all I have to do is glRotatef()?
Quote this message in a reply
Member
Posts: 254
Joined: 2005.10
Post: #4
You should modify the viewport settings because you are changing the dimensions of the screen from 420x380 to 380x420 and if you don't the screen should look squished funny.
Quote this message in a reply
Member
Posts: 32
Joined: 2008.10
Post: #5
Blacktiger Wrote:You should modify the viewport settings because you are changing the dimensions of the screen from 420x380 to 380x420 and if you don't the screen should look squished funny.

Dont you mean 480x320?
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #6
You need to specify how much to rotate. (the last parameter)
Like so:
Code:
glOrthof(-160.0f, 160.0f, -240.0f, 240.0f, -1.0f, 1.0f);
glRotatef(90.0f, 0.0f, 0.0f, 1.0f);

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Attempting to add landscape IB buttons to an openGL View Madrayken 1 3,741 Oct 17, 2010 07:03 AM
Last Post: iamflimflam1
  Landscape app sometimes thinks portrait bruss14 1 2,192 Dec 30, 2009 01:32 PM
Last Post: bruss14
  Chipmunk moonbuggy dynamic landscape wonza 5 3,652 Nov 6, 2009 01:08 AM
Last Post: wonza
  iPhone opengl 2d sprites landscape mode mnorton 6 5,567 Sep 9, 2009 08:27 PM
Last Post: mnorton
  How can I add autorotate (landscape, portrait) to an OpenGL ES app? riruilo 6 9,215 Feb 12, 2009 07:51 AM
Last Post: AnotherJake