我一直在努力解决这个问题,而且这个代码对我来说不明原因崩溃了.我正在创建一个FBO,绑定一个纹理,然后第一个glDrawArrays()在我的iPhone模拟器上崩溃了"EXC_BAD_ACCESS".
这是我用来创建FBO的代码(并绑定纹理和......)
glGenFramebuffers(1, &lastFrameBuffer); glGenRenderbuffers(1, &lastFrameDepthBuffer); glGenTextures(1, &lastFrameTexture); glBindTexture(GL_TEXTURE1, lastFrameTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 768, 1029, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, NULL); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //Bind/alloc depthbuf glBindRenderbuffer(GL_RENDERBUFFER, lastFrameDepthBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 768, 1029); glBindFramebuffer(GL_FRAMEBUFFER, lastFrameBuffer); //binding the texture to the FBO :D glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, lastFrameTexture, 0); // attach the renderbuffer to depth attachment point glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, lastFrameDepthBuffer); [self checkFramebufferStatus];
正如您所看到的,它参与了一个对象,checkFrameBufferStatus如下所示:
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); switch(status) { case GL_FRAMEBUFFER_COMPLETE: JNLogString(@"Framebuffer complete."); return TRUE; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: JNLogString(@"[ERROR] Framebuffer incomplete: Attachment is NOT complete."); return false; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: JNLogString(@"[ERROR] Framebuffer incomplete: No image is attached to FBO."); return false; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: JNLogString(@"[ERROR] Framebuffer incomplete: Attached images have different dimensions."); return false; case GL_FRAMEBUFFER_UNSUPPORTED: JNLogString(@"[ERROR] Unsupported by FBO implementation."); return false; default: JNLogString(@"[ERROR] Unknown error."); return false;
JNLogString只是一个NSLog,在这种情况下它给了我:
2010-04-03 02:46:54.854 Bubbleeh[6634:207] ES2Renderer.m:372 [ERROR] Unknown error.
当我在那里打电话的时候.
所以,它崩溃,诊断告诉我有一个未知的错误,我有点卡住了.我基本上复制了OpenGL ES 2.0编程指南中的代码...
我究竟做错了什么?