1

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.

4

2 回答 2

1

我发现的一种解决方案是在我的 EAGLView 对象的 layoutSubviews 中放置一些代码:

- (void)layoutSubviews

{ // 帧缓冲区将在下一次 setFramebuffer 方法调用开始时重新创建。[自我删除帧缓冲区];

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

}

现在它可以正常工作了,但我在调用时仍然收到一个 openGL 错误 1282:

glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, framebufferWidth, framebufferHeight);

我仍在调查这个错误,有什么想法吗?谢谢,

于 2012-10-31T23:30:02.953 回答
1

1568x1216 必须是您的大小EAGLView——您是从 NIB 加载它还是以编程方式创建它。假设是前者,它的尺寸是多少,你的弹簧和支柱是如何设置的?我敢打赌,如果您记录视图的框架,您会看到这些数字。

在 iOS 5 或更高版本下,您可能应该只使用GLKView而不是自己滚动;4.3 部署对您来说还那么重要吗?

于 2012-10-30T05:40:16.953 回答