SDL 中的 Blit 是什么?
在 SDL wiki 中它说
使用此函数执行从源表面到目标表面的快速位图传输。
但这对我没有多大帮助。
在这种情况下,术语“表面位块传输”是什么意思?
In the SDL wiki it says
Use this function to perform a fast blit from the source surface to the destination surface.
However that doesn't help me much.
What does the term surface blitting mean in this context?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
基本上,这意味着将图像从一个表面复制到另一个表面——可能会被裁剪和移动。
Basically it means copying the image from one surface to another -- possibly cropped and shifted.
Blitting 是指维基百科定义的位边界块传输或块信息传输,在 Pygame 开发人员中众所周知。假设您有一个 Surface(您的屏幕)。您想在屏幕上画一个圆圈。所以你要做的是,绘制圆并将缓冲区的圆块传输到屏幕缓冲区,这个过程称为“Blitting”。您可以在此处继续阅读有关 Blit 的更多信息。
Blitting means bit-boundary block transfer as defined by Wikipedia or Block Information Transfer, well known among the Pygame developers. Assume you have a Surface(your screen). And you would like to draw a circle on the screen. So what you want to do is, draw the circle and transfer the circle block of the buffer to the screen buffer, this process is called "Blitting". You can go ahead and read more about Blit here.
官方代码示例
直观上,它的意思是“在另一个表面上绘制一个精灵”。
此操作可以通过
SDL_Texture
+SDL_RenderCopy
进行 GPU 加速。看看 http://hg.libsdl.org/SDL/ file/e12c38730512/test/testsprite2.c 为例,特别是注释:
它明确指出
SDL_RenderCopy
是一种 blit 方式。在该示例中,纹理仅创建并发送到 GPU 内存一次,从那时起,它就会被有效地重用,另请参阅:表面和纹理之间的差异(SDL/通用)
当我在 Ubuntu 15.10 上运行此示例时,
nvidia-settings
表示 GPU 使用情况已消失到 100%,并且我获得的 FPS 比逐像素绘制到屏幕上要高得多,因此它是 GPU 加速的。Official code sample
Intuitively, it means to "draw a sprite on top of another surface".
This operation can be GPU accelerated with
SDL_Texture
+SDL_RenderCopy
.Have a look at http://hg.libsdl.org/SDL/file/e12c38730512/test/testsprite2.c for an example, in particular the comment:
which explicitly says that
SDL_RenderCopy
is a way to blit.In that example, the texture is created and sent to the GPU memory only once, and from then on it is reused efficiently, see also: Difference between surface and texture (SDL / general)
When I run this example on Ubuntu 15.10,
nvidia-settings
says that GPU usage is goes to 100%, and I get a much higher FPS than by drawing pixel by pixel to the screen, so it is GPU accelerated.它将内存从内存中的一个位置(源)复制到内存中的另一个位置(目标)。
例如。它可以将像素从一个位图复制到另一个位图,从位图复制到纹理,或将上述任何一种复制到屏幕表面或屏幕的后台缓冲区表面。
假设您有一个要在屏幕上显示的图像/图块。您可以执行“blit”将构成图像的内存复制到屏幕上使用的内存。
本质上,它调用一个与 memcpy() 非常相似的函数,它将指定为源的字节一一复制到指定为目标的字节。
It copies memory from one place in memory (source) to another place in memory (destination).
Eg. It can copy the pixels from one bitmap to another, from a bitmap to texture, or any of the above to the screen's surface or the screen's back buffer surface.
Say you have an image/tile that you want to display on the screen. You would perform a "blit" to copy the memory making up the image to the memory that is used on the screen.
It is, essentially, calling a function very much similar to memcpy() which copies the bytes specified as the source one-by-one to the bytes specified as the destination.