SDL_UpdateRect在双缓冲屏幕上的精确时序和效果如何?
使用双缓冲屏幕和Simple DirectMedia Layer,调用SDL_UpdateRect
在位图传输多个图像后调用一次,或者在位图传输每个单独的图像后调用一次在调用 SDL_Flip
之前?换句话说,SDL_UpdateRect
会导致屏幕立即更新,或者它只是告诉简单 DirectMedia 层在屏幕翻转时必须更新哪些区域?它通常应该如何与双缓冲屏幕一起使用?
作为参考,以下是 SDL_UpdateRect
的描述。
确保给定区域在给定屏幕上更新。这 矩形必须限制在屏幕边界内(无裁剪 完成)。
如果“x”、“y”、“w”和“h”均为 0 ,
SDL_UpdateRect
将更新 整个屏幕。
Using a double-buffered screen with the Simple DirectMedia Layer, is it more efficient to call SDL_UpdateRect
once after blitting multiple images or to call it once after blitting each individual image before calling SDL_Flip
? In other words, will SDL_UpdateRect
cause the screen to be updated immediately, or does it simply tell the Simple DirectMedia Layer which areas must be updated when the screen is flipped? How should it typically be used with a double-buffered screen?
For reference, here is the description of SDL_UpdateRect
.
Makes sure the given area is updated on the given screen. The
rectangle must be confined within the screen boundaries (no clipping
is done).If 'x', 'y', 'w' and 'h' are all 0,
SDL_UpdateRect
will update the
entire screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,
SDL_UpdateRect
立即更新屏幕(或矩形)。不需要联合使用
SDL_UpdateRect
和SDL_Flip
,它们做同样的事情但方式不同。区别在于,
SDL_UpdateRect
只能更新部分屏幕(通过将像素从表面复制到屏幕来工作),而SDL_Flip
则刷新整个屏幕(通过翻转来工作)缓冲区)。因此,如果您使用双缓冲屏幕,则无需调用
SDL_UpdateRect
,只需在所有 blits 之后调用SDL_Flip
即可。http://www.libsdl.org/docs/html/sdlsetvideomode.html
不要忘记,双缓冲仅适用于
SDL_HWSURFACE
和SDL_FULLSCREEN
视频模式。Yes,
SDL_UpdateRect
update screen (or rect) immediately.No need to use the
SDL_UpdateRect
andSDL_Flip
jointly, they do the same things but different ways.The difference is that
SDL_UpdateRect
can update only part of the screen (and work by copying pixels from your surface to screen), andSDL_Flip
refresh the entire screen (and works by flip buffers).So, if you use double-buffered screen no need to call
SDL_UpdateRect
, just callSDL_Flip
after all blits.http://www.libsdl.org/docs/html/sdlsetvideomode.html
And don't forget that double buffering works only with
SDL_HWSURFACE
andSDL_FULLSCREEN
video mode.