OpenGL ES:在每一帧上调用 glClear 的目的 [英] OpenGL ES:Purpose of calling glClear on every frame

查看:78
本文介绍了OpenGL ES:在每一帧上调用 glClear 的目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 OpenGL ES 的新手,我尝试绘制三角形,但我不明白在每一帧上调用 glClear(GL10.GL_COLOR_BUFFER_BIT) 的目的是什么?没有它,屏幕上会出现一些奇怪的伪影.我应该每次在每一帧开始时都调用这个?谢谢

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

推荐答案

简化:如果您绘制一个三角形,则只会重新绘制实际包含三角形的帧缓冲区部分.因此,如果您绘制一次,然后将其移动一点并在下一帧中再次绘制,而无需调用 glClear,则前一帧的内容仍将存在于帧缓冲区中.

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.

这就是造成伪影的原因,也是每次您怀疑显示的图像中改变时应该glClear帧缓冲区的原因.对于大多数应用程序,这确实意味着:每一帧.

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.

这篇关于OpenGL ES:在每一帧上调用 glClear 的目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆