我在开发OpenGL应用程序时遇到错误,我无法找到任何有用的文档。在完整的帧缓冲区上调用glClear()时,会设置OpenGL错误GL_INVALID_FRAMEBUFFER_OPERATION。似乎没有副作用 - glClear调用甚至按预期工作。无论如何,它会抛出许多不必要的错误,使得很难找到有效的错误。
帧缓冲的设置如下:(在这种情况下,大小是显示分辨率的两倍)
glGenFramebuffers(1, &buffer);
glBindFramebuffer(GL_FRAMEBUFFER, buffer);
textures = new GLuint[1];
glGenTextures(1, textures);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Size.width, Size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], 0);
renderBuffers = new GLuint[1];
glGenRenderbuffers(1, renderBuffers);
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffers[0]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, Size.width, Size.height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderBuffers[0]);
auto state = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if(state != GL_FRAMEBUFFER_COMPLETE)
printf("Incomplete frambuffer: %d\n", state); //Never hit, framebuffer reports complete
glBindFramebuffer(GL_FRAMEBUFFER, 0);
然后,当绑定帧缓冲区时:
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer);
glViewport(0,0,size.width, size.height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Sets GL_INVALID_FRAMEBUFFER_OPERATION error
到目前为止,这只发生在Radeon卡上,并且只出现在看似随机的帧上。如果场景没有改变,则错误通常不会再发生。
答案 0 :(得分:0)
最终,我们偶然发现了解决方案。在旧代码中调用glInterleavedArrays()导致调用glClear()以无意义的方式中断。
没有明显的原因,所以现在我认为这是一个非常具体的驱动程序错误。