SDL 中的 Blit 是什么?

发布于 2024-09-18 17:32:34 字数 136 浏览 3 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

‘画卷フ 2024-09-25 17:32:34

基本上,这意味着将图像从一个表面复制到另一个表面——可能会被裁剪和移动。

Basically it means copying the image from one surface to another -- possibly cropped and shifted.

冧九 2024-09-25 17:32:34

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.

回忆躺在深渊里 2024-09-25 17:32:34

官方代码示例

直观上,它的意思是“在另一个表面上绘制一个精灵”。

此操作可以通过 SDL_Texture + SDL_RenderCopy 进行 GPU 加速。

看看 http://hg.libsdl.org/SDL/ file/e12c38730512/test/testsprite2.c 为例,特别是注释:

/* Blit the sprite onto the screen */
SDL_RenderCopy(renderer, sprite, NULL, position);

它明确指出 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:

/* Blit the sprite onto the screen */
SDL_RenderCopy(renderer, sprite, NULL, position);

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.

一个人的旅程 2024-09-25 17:32:34

它将内存从内存中的一个位置(源)复制到内存中的另一个位置(目标)。

例如。它可以将像素从一个位图复制到另一个位图,从位图复制到纹理,或将上述任何一种复制到屏幕表面或屏幕的后台缓冲区表面。

假设您有一个要在屏幕上显示的图像/图块。您可以执行“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文