OpenGL ES:Purpose of calling glClear on every frame

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-27 15:06:10

问题


I'am new to OpenGL ES and I try to draw triangle,but I can't understand what is a purpose of calling glClear(GL10.GL_COLOR_BUFFER_BIT) on every frame?Without it some strange artifacts occur on screen.Should I call this every time at every frame beginning? Thanks


回答1:


Simplified: If you draw a triangle, only the part of the framebuffer that actually contains the triangle is being redrawn. So if you draw it once, then shift it a little bit and draw it again in the next frame, without a call to glClear, the contents of the previous frame will still be present in the framebuffer.

That's the cause of your artifacts and the reason why you should glClear your framebuffer every time you suspect something has changed in the image displayed. For most applications, this would indeed mean: Every frame.



来源:https://stackoverflow.com/questions/15506110/opengl-espurpose-of-calling-glclear-on-every-frame

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