OpenGL ES 1.1 rotate to landscape mode

From WebOS101

Jump to: navigation, search

When rotating an OpenGL ES surface you won't be able to simply specify your dimensions with SDL_SetVideoMode like you can when using a software surface. The screen needs to be rotated after setting up the OpenGL surface.

Note: This code assumes that a DEVICE macro is sent from the compiler when building for a device.

#ifdef DEVICE
screen = SDL_SetVideoMode(0, 0, 0, SDL_OPENGL);
#else
screen = SDL_SetVideoMode(480, 320, 32, SDL_OPENGL);
#endif
 
// setup openGL
glClearColor(0, 0, 0, 1.0f);
 
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
 
#ifdef DEVICE
// -90 rotates the screen so that the bottom is the left side of the device.
// 90 rotates the screen so that the bottom is the right side of the device.
glRotatef(-90, 0, 0, 1);
#endif
 
glOrthof(0, 480, 320, 0, -1, 1);
Personal tools