SW vs HW renderer

Hello,

In my app, I scan for each available rendering driver until I find one supporting HW accel.
If none is found, I re-iterate over the list until I succeed in initializing a SW renderer.

Pseudo code :

// Attempt to init an HW renderer
for each driver
if (renderer initialization(driver, SDL_RENDERER_ACCELERATED) succeeds) {
return renderer
}
end

// Attempt to init an SW renderer.
for each driver
if (renderer initialization(driver) succeeds) {
return renderer
}
end

My questions are:

  1. Is it a good manner to initialize the video renderer, given that I want to get a HW accelerated one if available, else I initialize a SW one.
    Also, is it needed to pass in the SDL_RENDERER_SOFTWARE flag instead of passing no flags at all ?

  2. Do I have to manage 2 separate codes, one for SW rendering and one for HW rendering, the first one using classical SDL_Surface’s and the other one using SDL_Texure’s ?

  3. If answer of 2 is yes, do I have also to manage separate code to blit on the screen, one using the old style SDL_BlitSurface and SDL_UpdateRects / SDL_Flip and the other using SDL_RenderCopy and SDL_RenderPresent ?

Thanks !

Julien CLEMENT
@Julien_Clement1

  1. That’ll work, but I’m pretty sure SDL already indexes renderers such that the software backend (there’s only one) is the last one. So just go through all of them. I can verify that it does indeed do this on Windows and Linux, at least.
    Also, the default renderer (-1) should be a hardware accelerated one if it is available.
    In other words, there’s simpler solutions to the same problems.

  2. No. When you use the software renderer, you use the same interfaces as with the hardware ones. The old blit API is exposed for compatibility purposes, although it can also be useful in texture pre-processing. Note that SDL_SetClipRect is broken now, though.------------------------
    EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/