What is a Blit in SDL?

前端 未结 4 1378
野趣味
野趣味 2021-02-18 14:29

In the SDL wiki it says

Use this function to perform a fast blit from the source surface to the destination surface.

However that

相关标签:
4条回答
  • 2021-02-18 14:45

    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.

    0 讨论(0)
  • 2021-02-18 14:47

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

    0 讨论(0)
  • 2021-02-18 14:53

    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.

    0 讨论(0)
  • 2021-02-18 14:55

    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.

    0 讨论(0)
提交回复
热议问题