Sulea Cosmin
Sulea Cosmin

Reputation: 598

ipad2 framebuffer initialized to retina size

I'm using a iPhone/ipad app with an empty view set to use my EAGLView class. I initialize the framebuffer with:

self.contentScaleFactor = [[UIScreen mainScreen] scale];
self.layer.contentsScale = [[UIScreen mainScreen] scale]; //this is 1.0
glGenFramebuffersOES(1, &defaultFramebuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
    glGenRenderbuffersOES(1, &colorRenderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
    [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];

    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &framebufferWidth);
    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &framebufferHeight);

after that, framebufferWidth is 1568 and framebufferHeight is 1216. My device is reported by [[UIDevice currentDevice] model] as @"ipad", iOS 4.3.5. Xcode 4.5.1, SDK 6, deployment target 4.3.

Anyone has any idea why I got this sizes and not the 1024x768 ?

Thanks.

Later Edit: same code worked perfectly with Xcode 3.x and SDK 4.3, with deployment target 4.0.

Upvotes: 1

Views: 626

Answers (2)

Sulea Cosmin
Sulea Cosmin

Reputation: 598

One solution that I found is to put some code in layoutSubviews of my EAGLView object:

- (void)layoutSubviews

{ // The framebuffer will be re-created at the beginning of the next setFramebuffer method call. [self deleteFramebuffer];

CGRect  rect = [[UIScreen mainScreen] bounds];
self.layer.frame = rect;
self.frame = rect;

}

Now it works correctly, still I get one openGL error 1282 while calling:

glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, framebufferWidth, framebufferHeight);

I'm still investigating this error, any ideas ? Thanks,

Upvotes: 1

Tommy
Tommy

Reputation: 100652

1568x1216 must be the size of your EAGLView — are you loading it from a NIB or creating it programmatically. Assuming the former, what size is it in there and how are your springs and struts set up? I'll wager than if you log the view's frame you'll see those numbers.

Under iOS 5 or newer you should probably just use GLKView rather than rolling your own; is 4.3 deployment still that important to you?

Upvotes: 1

Related Questions