看来,最近我的应用程序崩溃,因为renderbufferStorage方法返回false。我不知道会发生什么,所以我之前已经添加了测试,但他们从未提出异常。我在主线程,目前情况下似乎罚款,该eaglLayer过,但无论如何,它崩溃的renderbufferStorage ..OpenGL ES 2.0 renderbufferStorage崩溃
EAGLContext* defaultEAGLContext = getDefaultContext();
EAGLContext* currentContext = [EAGLContext currentContext];
if(![NSThread isMainThread]) {
NSLog(@"ERROR : renderbufferStorage not called on main thread");
@throw [NSException exceptionWithName:@"ERROR"
reason:@"renderbufferStorage not called on main thread"
userInfo:nil];
}
if(!currentContext) {
@throw [NSException exceptionWithName:@"ERROR"
reason:@"Current context is null"
userInfo:nil];
}
if(!defaultEAGLContext) {
@throw [NSException exceptionWithName:@"ERROR"
reason:@"Default context is null"
userInfo:nil];
}
if(defaultEAGLContext != currentContext) {
@throw [NSException exceptionWithName:@"ERROR"
reason:@"Default context is different than current context"
userInfo:nil];
}
if(!_eaglLayer) {
@throw [NSException exceptionWithName:@"ERROR"
reason:@"EAGL layer error"
userInfo:nil];
}
if (![defaultEAGLContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:_eaglLayer]) {
NSLog(@"ERROR : Failed to obtain renderbuffer storage from layer");
@throw [NSException exceptionWithName:@"ERROR"
reason:@"Failed to obtain renderbuffer storage from layer"
userInfo:nil];
}
你知道为什么这个方法将返回false,甚至随意?在此先感谢
谢谢你的回答。我已经有了这部分代码,但是:方法只是返回false,不幸的是没有日志。如果渲染缓冲区没有设置,它会崩溃,所以我提出异常之前用crashlytics检索它。它是一个不好主意? 编辑:它也随机崩溃,一些用户得到它,但我从来没有repro它:( – Xys
我明白了,所以该方法不会崩溃,但返回false ...您的渲染缓冲区是否绑定在当时? –
是,建立上下文(并将其设定电流)后,我结合这样的缓冲: glGenRenderbuffers(1,_colorRenderBuffer); glBindRenderbuffer(GL_RENDERBUFFER,_colorRenderBuffer); – Xys