Search code examples
c++csdl

SDL2 2D texture allocation/pooling


I have two questions regarding SDL2's hardware-accelerated texture rendering:

  1. When using SDL_Createtexture(...), are textures automatically pooled/transferred between system RAM and VRAM when VRAM is at a premium? In order to ensure I don't inundate VRAM, I was considering loading textures into surfaces and converting them to textures as and when required (it's unlikely that all textures will fit into VRAM at once).
  2. When minimizing a fullscreen application and/or changing screen resolutions, will SDL_Texture instances need to be recreated?

Solution

  • No, you don't need to recreate your SDL_Texture instances after minimize a window or change its resolutions. Maybe you only need to redraw things in the screen after change its resolutions, but not after minimize it.

    Also, I recommend you to look at these SDL2 tutorials: https://lazyfoo.net/tutorials/SDL/index.php