OpenGL invalid framebuffer operation after glClear(GL_COLOR_BUFFER_BIT);
Asked Answered
I

2

9

Every time after I call glClear(GL_COLOR_BUFFER_BIT);, I get the OpenGL error "invalid framebuffer operation".

The call seems to work just fine, and nothing seems wrong. I call glClear(GL_COLOR_BUFFER_BIT); first thing in the ::paintGL() method.

Huh? Should I just disregard this error?

Interchangeable answered 18/6, 2012 at 19:18 Comment(10)
@cbamber85: no, but I've just put in a glClearColor(0,0,0,0) to see if it made any difference, and the other is still there.Interchangeable
Very possibly the error has been raised by a previous OpenGL call that the code didn't check. Verify that all OpenGL operations are guarded by error checking.Cookshop
@StefanHanke: the call to glClear() has error-checking code before and after. The error is not set directly before, and it is set directly after. Clearly it's the glClear() call that is the culprit.Interchangeable
Does the code use FBOs for some rendering?Cookshop
@StefanHanke: for now, no, it's just a simple program drawing some GL_QUADS.Interchangeable
What version of OpenGL are you using?Uzzi
@cbamber85: 1.7.7 (the default version bundled with Mac OS X Lion).Interchangeable
@Interchangeable I don't know what that number is, but it can't be OpenGL. On Linux, you would type glxinfo and look at OpenGL version string - you'll have to search for MacOS equivalent. For example, my says: 4.2.0 NVIDIA 295.49, which is the version number, vendor, and driver version.Uzzi
@cbamber85: I took that 1.7.7 from the bundle plist. Anyway, running glxinfo | grep "OpenGL version string" gives 2.1 APPLE-7.18.18.Interchangeable
Could also be a driver bug: stackoverflow.com/questions/21241786Recrement
R
5

My best guess is that your framebuffer is not complete and calling glClear on an incomplete framebuffer is throwing the error.

Check the status of the framebuffer using glCheckFramebufferStatus and make sure it returns GL_FRAMEBUFFER_COMPLETE.

Roadside answered 27/7, 2012 at 15:20 Comment(2)
I got the same error as the original poster, and I verified my framebuffers are complete. I'm running OpenGL-ES3 on iPhone and the texture which is being cleared is an sRGB-texture - when changing that to a normal "rgb"-texture, the "invalid framebuffer operation" error on glClear stops. From the info given by the OP I can't tell if this is the same in this case, but either way this may provide a hint to someone else running into this issue.Ichthyornis
Update: in my case srgb8 isn't supported as "ColorRenderable" (using GL_SRGB8_ALPHA8 as an alternative works). As James said, glCheckFrameBufferStatus should have returned an error, but it doesn't, meaning there is a bug in the openGL implementation I'm using ( OpenGL-ES3 in xcode 7.3 on osx).Ichthyornis
A
3

I was having this issue on osx using NSOpenGLView with a CVDisplayLink to trigger the render callback.

Be sure to wait for the NSOpenGLView to be fully displayed before starting rendering, i.e. :

-(void)viewDidAppear {
    [super viewDidAppear];

    CVDisplayLinkStart(_displayLink);
}

Doing it in viewDidLoad is too early.

Aekerly answered 15/3, 2017 at 13:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.