OpenGL invalid framebuffer operation after glClear(GL_COLOR_BUFFER_BIT);

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

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?

回答1:

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.



回答2:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!