glFlush

glFlush是OpenGL中的函式,用於強制刷新緩衝,保證繪圖命令將被執行,而不是存儲在緩衝區中等待其他的OpenGL命令。

函式簡介

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.

相關詞條

相關搜尋

熱門詞條

聯絡我們