There are many GDI functions, such as SetPixel(), but it is very expensive to set each pixel to a certain color, so I wonder what function does the library use.
Searched the SDL2 source code, didn't find the drawing function.
There are many GDI functions, such as SetPixel(), but it is very expensive to set each pixel to a certain color, so I wonder what function does the library use.
Searched the SDL2 source code, didn't find the drawing function.
Searched the SDL2 source code, didn't find the drawing function.
You mean this one? As you can see, SDL2's software renderer just works with surfaces like SDL1 did, and a SDL_RenderCopy
roughly translates to a SDL_BlitSurface
.
SDL_BlitSurface
is an alias for SDL_UpperBlit
, which calls SDL_LowerBlit
, which calls src->map->blit
, which can be many things but might be for example SDL_BlitCopy
, and that finally does the copying of pixels. Of course pixels aren't set one by one manually. Well, unless you use SDL_RenderDrawPoints
(that translates to SDL_DrawPoints
for a software renderer).