词条 | glFlush |
释义 | 函数简介glFlush()是OpenGL中的函数,用于强制刷新缓冲,保证绘图命令将被执行,而不是存储在缓冲区中等待其他的OpenGL命令。 函数作用简单地说glFlush()就是强制刷新,OpenGL是使用一条渲染管线线性处理命令的,一般情况下,我们提交给OpenGL的指令并不是马上送到驱动程序里执行的,而是放到一个缓冲区里面,等这个缓冲区满了再一次过发到驱动程序里执行;很多时候只有几条指令是填充不满那个缓冲区的,就是说这些指令根本没有被发送到驱动里,所以我们要调用glFlush来强制把这些指令送到驱动里进行处理。 MSDN中的解释glFlush The glFlush function forces execution of OpenGL functions in finite time. void glFlush( void ); Parameters This function has no parameters. Remarks Different OpenGL implementations buffer commands in several different locations, including network buffers and the graphics accelerator itself. The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine. Though this execution may not be completed in any particular time period, it does complete in a finite amount of time. Because any OpenGL program might be executed over a network, or on an accelerator that buffers commands, be sure to call glFlush in any programs requiring that all of their previously issued commands have been completed. For example, call glFlush before waiting for user input that depends on the generated image. The glFlush function can return at any time. It does not wait until the execution of all previously issued OpenGL functions is complete. SwapBuffers The SwapBuffers function exchanges the front and back buffers if the current pixel format for the window referenced by the specified device context includes a back buffer. BOOL SwapBuffers( HDC hdc // device context whose buffers get swapped ); Parameters hdc Specifies a device context. If the current pixel format for the window referenced by this device context includes a back buffer, the function exchanges the front and back buffers. Return Values If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To get extended error information, call GetLastError. Remarks If the current pixel format for the window referenced by the device context does not include a back buffer, this call has no effect and the content of the back buffer is undefined when the function returns. With multithread applications, flush the drawing commands in any other threads drawing to the same window before calling SwapBuffers. |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。