我有一个使用 GLKViewController 的 iOS 应用程序,我将渲染缓冲区设置如下:
里面
@interface RootViewController : GLKViewController<UIKeyInput>
- viewDidLoad {
[super viewDidLoad];
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
GLKView* view = (GLKView*)self.view;
view.context = _context;
view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
view.drawableStencilFormat = GLKViewDrawableStencilFormat8;
view.drawableMultisample = GLKViewDrawableMultisampleNone;
self.preferredFramesPerSecond = 60;
[EAGLContext setCurrentContext:_context];
}
但是,当我稍后调用 draw 时:
glDrawElements(getGlPrimitiveType(ePrimType), numIndis, GL_UNSIGNED_SHORT, startIndis);
它导致黑屏Capture GPU Frame
,然后出现此错误:
Your app rendered with STENCIL_TEST enabled into a framebuffer without an attached stencil buffer.
有什么我错过的吗?
我记得之前由于深度测试而遇到过同样的问题,我用我不确定模板测试来修复它view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
,viewDidLoad
Apple 的文档要么非常少,要么非常笼统,到处都是理论(即:几乎没用)。