打开GL ES Retina显示器设置

时间:2012-08-16 19:29:09

标签: iphone opengl-es retina-display

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

这都是在createFramebuffer方法的EAGLView的子类中完成的。

这是我的设置:

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);

正确报告比例因子但显示不会呈现,并且无法创建缓冲区。我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:0)

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