看來,最近我的應用程序崩潰,因爲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