函数glfwSwapBuffers有什么用?

小白日常笔记,如有错误欢迎批评指正~

glfwSwapBuffers(GLFWwindow *window)

SwapBuffers翻译过来是交换缓冲区的意思,既然buffer加了s,也就意味着不止一个buffer,所以这里涉及到了一个双缓冲的概念.

关于双缓冲英文解释如下:
Double Buffer:
When an application draws in a single buffer image might display flickering issues. This is because the resulting output is not drawn in an instant ,but drawn pixel by pixel and usually from left to right ,top to bottom.Because this image is not drawn in an instant to the user while still being rendered to,the result may contain artifacts.To circumvent these issues,window application apply a double buffer for rendering.The front buffercontains the final output image that is shown at the screen,while all the rendering commands draw the back buffer.As soon as all the rendering commands are finished we swap the back buffer to the front buffer,so the image is instantly displayed to the user,removing all the aforementioned artifact.

总结中文解释如下:
因为电脑绘图是一个个像素逐一画的,需要时间,如果单一缓冲,我们可能会看到具体绘画过程,会造成屏幕闪烁等问题,而我们用户不需要具体看到你绘制的过程,所以为了解决这个问题,这里用了双缓冲技术,用两个内存区域来保存数据,分为前缓冲区和后缓冲区,前缓冲区用于展示屏幕上的内容,而后缓冲区就用来绘制,然后每一帧开始的时候,将两个缓冲区交换,这样后缓冲区又可以画新的内容。

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值