Search code examples
opengl-esiphone-5

opengl 1.1 renderbuffer generation does only 960px not 1136px width


I'm currently in the progress to port my iPhone game to the iPhone 5 resolution. I included the Default-568h@2x.png and

[[UIscreen mainScreen] bounds].size;

gives me the iPhone 5 resolution (320x568px). But the renderBuffer I create in OpenglES 1.1 gets only the old iPhone resolution (640x960px). The way I create the render buffer looks like this:

glGenFramebuffersOES(1, &viewFramebuffer);
glGenRenderbuffersOES(1, &viewRenderbuffer);

glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);

GLint frameBufferWidth, frameBufferHeight;
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &frameBufferWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &frameBufferHeight);

When I'm running the game on the iPhone 5 the game only covers the first 960 pixels of the screen and is squeezed.

Does anybody have an idea how I can create a render buffer that fits the size of the iPhone 5 screen?


Solution

  • I found the solution. It wasn't a opengl problem. The size option in interface builder of the main window of my application wasn't set after upgrading Xcode to v4.5. Setting the option to "Retina 3.5 full screen" fixed the problem (By doing so the main view is scaled automatically to the 3.5 or 4 inch of the iPhone screen).

    This post helped me: How to make a uitableview in interface builder compatible with a 4 inch iPhone