glBindFramebuffer with a valid framebuffer gives GL_INVALID_OPERATION

I try to bind a framebuffer, and it fails. Here’s the code:

errorCode = glGetError(); // returns GL_NO_ERROR
ASSERT(glIsFramebuffer(framebuffer)); // glIsFramebuffer returns true
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
errorCode = glGetError(); // returns GL_INVALID_OPERATION

According to the specification, glBindFrambuffer should only throw GL_INVALID_OPERATION if the framebuffer name is invalid, but then glIsFramebuffer should also return false.

I’m stuck. What other reason could there be?

Another detail: the code above usually works. This error only occurs right after I delete some shader programs and create new ones. But the framebuffers don’t change at all, and in the next frame everything works perfectly again. I also get the same error if I use glBlitNamedFramebuffer without binding.

Also, it’s Windows 10, GTX 1080, driver 388.31.

Hi korteur,

Thanks for your report. I did a quick try but cannot reproduce the error.

As you mentioned the error was only observed in a certain condition. If you could put together a minimized sample program that can reproduce the problem reliably, it will help us root cause the issue.

I am having a similar problem.

In my case, I’m running on a P1000 GPU under Linux.

Our test app has multiple windows each with their own framebuffer for rendering. The primary window/framebuffer works fine. The secondary just shows a black screen. Stepping through the events in Nsight Graphics though, I see the secondary buffer being rendered. Is the secondary framebuffer also being flipped when the primary one is or is the primary framebuffer somehow interfering with the secondary one?

Some things to note: Our code works when running on Windows - on both OpenGL and DirectX. It works when running over Remote Desktop on Linux (which uses a software renderer). It only breaks when running locally on a Linux machine.

I am also having a similar problem with the GeForce Game Ready Driver version 516.94 on Windows 11.

I have an app that uses OpenVR with multiple framebuffers to drive the graphics in both eyes in a VR headset. It works fine in Linux with the same code and hardware.

For some reason, OpenGL starts producing GL_INVALID_OPERATION errors when trying to bind GL_FRAMEBUFFER to an existing framebuffer ID. I tried inserting a call to glIsFramebuffer() to validate the ID, but then that call produced the same error. I tried inserting a bind of framebuffer 0 before these, and then that call produced the error. If I’m not mistaken, binding framebuffer 0 should never result in this error.

Sorry, but I don’t think I can reduce this to a simple example, as it requires a lot of setup.

If it helps, I tried running the same app on a different computer with a different GPU (RTX 2060) and the same driver (on Windows 10) and this problem did not occur. My GPU is an RTX 2080.