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