I'm quite new to openGL and I have been trying out some sample codes from a book about game programming on the iphone that I'm currently reading. One of the samples was a 3d game and I am able to successfully compile and run it on the iOS simulator (fullscreen).
The problem I have is when I run it on the actual hardware (an ipod touch 4G), the game does not go full screen (it only occupies like 1/4 of the screen). I was able to narrow the problem down to the code below:
GLint backingWidth, backingHeight;
- (BOOL) bindLayer
{
....
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
....
}
For some reason, backingWidth and backingHeight is set to 640 and 960 respectively after the calls above (I expected it to be 320 x 480 which is the iphone's screen size). On the iOS simulator and an older ipod touch (2g), it works just fine.
The code above is part of an object which subclasses UIView, and overrides the drawRect method (it is empty though). The thing that baffled me is when I removed the drawRect method (hence not overriding it), it somehow fixed the problem I described above.
Can anyone shed some light on this? Is it not safe to override a view's drawRect method when you are drawing in openGL? Why does it work on the simulator and an older ipod touch?