opengl中 先用glFlush();然后glutSwapBuffers();有什么作用啊

代码中。。。glFlush();glutSwapBuffers();这样有什么作用啊,难道不重复?我是新手,请指教... 代码中
。。。
glFlush();
glutSwapBuffers();
这样有什么作用啊,难道不重复?
我是新手,请指教
展开
 我来答
匿名用户
推荐于2018-04-10
展开全部
楼上照抄MSDN,请自重

简单地说glFlush就是强制刷新吧,要知道OPENGL是使用一条渲染管线线性处理命令的,一般情况下,我们提交给OPENGL的指令并不是马上送到驱动程序里执行的,而是放到一个缓冲区里面,等这个缓冲区满了再一次过发到驱动程序里执行;很多时候只有几条指令是填充不满那个缓冲区的,这就是说这些指令根本没有被发送到驱动里,所以我们要调用glFlush来强制把这些指令送到驱动里进行处理。

glutSwapBuffers其实就是交换缓冲区啦,估计是你的程序使用的是双缓冲技术吧;用了这种技术的话,你所有的绘制都是绘制到一个后台的缓冲区里面的,如果不交换缓冲区,就看不到绘制的东西了,就这么回事~
eryarfly
2009-05-26 · TA获得超过103个赞
知道小有建树答主
回答量:253
采纳率:100%
帮助的人:180万
展开全部
来自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.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式