1

在将应用程序从 iphone 4s 移植到 iPhone 5 时,调用此代码后出现错误 GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:

glBindFramebuffer(GL_FRAMEBUFFER, 1);

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 1);

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 2);

根据 OpenGLES 规范,错误是由“附件的宽度和高度不同”引起的,但我对颜色和深度缓冲区都使用了 1136 x 640。

相同的代码在 iphone 4s(具有 960 x 640 缓冲区)上运行良好。

4

1 回答 1

2

Depth and color buffer have diff size. For get real size color buffer:

    [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer]
    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &w);
    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &h);

Also you need set scale to CAEAGLLayer:

    layer.contentsScale = [[UIScreen mainScreen] scale];

You can see how it's done in Ogre3D, SDL, Cocos2d-x.

于 2013-05-07T23:55:16.300 回答