码迷,mamicode.com
首页 > 其他好文 > 详细

OpenGL glFlush and glFinish

时间:2014-07-23 13:24:46      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:opengl

Similar to computer IO buffer, OpenGL commands are not executed immediately. 

All commands are stored in buffers first, including network buffers and the graphics 

accelerator itself, and are awaiting execution until buffers are full. For example, if

 an application runs over the network, it is much more efficient to send a collection

 of commands in a single packet than to send each command over network one at a time.


glFlush() empties all commands in these buffers and forces all pending commands

 will to be executed immediately without waiting buffers are full. 

Therefore glFlush() guarantees that all OpenGL commands made up to that point 

will complete executions in a finite amount time after calling glFlush().

 And glFlush() does not wait until previous executions are complete and may return

 immediately to your program. So you are free to send more commands even though 

previously issued commands are not finished.


glFinish() flushes buffers and forces commands to begin execution as glFlush() does,

 but glFinish() blocks other OpenGL commands and waits for all execution is complete. 

Consequently, glFinish() does not return to your program until all previously called 

commands are complete. It might be used to synchronize tasks or to measure exact 

elapsed time that certain OpenGL commands are executed.


所以两个命令都是使命令缓存中的指令立即执行并清空缓存,

只是glFlush()立即返回,而glFinish()等到指令执行完成之后才返回。

OpenGL glFlush and glFinish

标签:opengl

原文地址:http://blog.csdn.net/aganlengzi/article/details/38057913

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!