What is a Blit in SDL?

前端 未结 4 1367
野趣味
野趣味 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.

提交回复
热议问题