1

我正在尝试将 OpenGL 项目正确渲染到 iphone 视网膜显示器,但我似乎遇到了一些困难。我已经为设备设置了内容比例因子,但现在无法创建帧缓冲区。

这一切都在 EAGLView int createFramebuffer 方法的子类中完成。

这是我的设置:

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

glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);

self.contentScaleFactor = [[UIScreen mainScreen] scale];
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);


glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);//Depth
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);


glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);



NSLog(@"scale Factor: %f",self.contentScaleFactor);

比例因子报告正确,但显示不会渲染,缓冲区创建失败。我在这里错过了什么吗?

4

1 回答 1

0

我遇到了同样的问题。正如我在此答案中所述,您只需将帧大小乘以屏幕比例即可。

于 2013-10-04T14:05:52.847 回答