SDL2 understanding the basic model

295 views Asked by At

SDL I don't get the basic model or structure that sdl presents, by that I mean the basic elements in SDL library. I don't get when to use surface, when texture and when render.

1

There are 1 answers

0
joeforker On

The main difference between SDL and SDL2 is that the Surface API has been largely replaced with the Render API. The rule of thumb is to use Surface when you need to do software pixel manipulation, and use Render when you need to draw lots of stuff to the screen really fast.

For example it would be reasonable to load an image into a SDL_Surface, combine it with some text originating in a second surface, and then convert the composite image to a SDL_Texture that is rendered to the screen every frame.

If you want to draw to the screen, use the Render API.