glFinish這是OpenGL的一個函式,用於向圖形硬體提交緩衝區裡的指令,並等待所有指令執行完成後再返回。
原型,補充,
原型
:void glFinish( void );
下面是MSDN中的說明:
Parameters
This function has no parameters.
This function has no parameters.
Remarks
The glFinish function does not return until the effects of all previously called OpenGL functions are complete. Such effects include all changes to the OpenGL state, all changes to the connection state, and all changes to the framebuffer contents.
The glFinish function does not return until the effects of all previously called OpenGL functions are complete. Such effects include all changes to the OpenGL state, all changes to the connection state, and all changes to the framebuffer contents.
The glFinish function requires a round trip to the server.
Error Codes
The following is the error code generated and its condition.
The following is the error code generated and its condition.
Error code Condition
GL_INVALID_OPERATION glFinish was called between a call to glBegin and the corresponding call to glEnd.
GL_INVALID_OPERATION glFinish was called between a call to glBegin and the corresponding call to glEnd.
補充
:
glFinish和glFlush的區別
我們提交給OpenGL的繪圖指令並不是馬上送給圖形硬體執行,而是放到一個緩衝區裡面,等待緩衝區滿了再將這些指令送給圖形硬體執行,所以指令較少或者簡單時是無法填滿緩衝區的,自然這些指令不能馬上執行以達到所需要的效果。
因此每次在寫完繪圖代碼需要讓其完成效果時我們需要在代碼後面添加glFlush()或gLFinish()函式:
(1)gLFlush()作用是將緩衝區中的指令(無論是否為滿)立刻送給圖形硬體執行,傳送完立即返回;
(2)glFinish()作用也是將緩衝區中的指令(無論是否為滿)立刻送給圖形硬體執行,但是要等待圖形硬體執行完這些指令才返回。