Search code examples
cgraphicssdlsdl-2renderer

SDL_CreateRenderer() vs SDL_CreateSoftwareRenderer()


Does a renderer created with SDL_CreateSoftwareRenderer() behave any differently than one created with SDL_CreateRenderer() using the SDL_RENDERER_SOFTWARE flag?


Solution

  • There are differences on how these two operate, or even their intended use. SDL_CreateSoftwareRenderer creates software renderer drawing to given surface. There is no requirement for this surface to be window surface, you can draw to backbuffer, convert it to texture and feed the result to d3d or opengl renderer.

    SDL_CreateRenderer creates renderer for a given window, meaning it is supposed to draw to that window - with some checks, like opengl or vulkan requires window to be created with specific flags. It goes through list of available rendering backends and tries to find the one that matches your flags the best. Eventually if it decides to use software renderer (either nothing else is supported or software is explicitly requested, although there is more than one way to do so - see the last paragraph) it calls more-or-less SDL_CreateSoftwareRenderer(SDL_GetWindowSurface(window)) (not exactly so, but if you'll trace the code it is the same).

    flags in SDL_CreateRenderer are not absolute; if a hint says to use direct3d or opengl, your SDL_RENDERER_SOFTWARE will be ignored. SDL_CreateSoftwareRenderer is always software.