SDL2 was missing a lot of base functions that I never really understood why, for example, SDL2 lacked set and get pixel functions, why? It also lacked basic line drawing and primitives other than SDL_FillRect().
Does anyone know why these basic functions where never accepted into the project and if they will be added to SDL3?
In SDL2 it is possible to use SDL_GetWindowSurface to obtain the surface of the window, then use ->pixels to get the native array of pixels. The set and get pixel functions there are simply the native integer read/write operations in C, allowing software rendering to be done. SDL_UpdateWindowSurface on each frame gets the surface contents natively to the screen.
They are provided in the companion SDL2_gfx project, which I have extended to include more anti-aliased drawing functions (see here for my modified version).
It seems to me entirely reasonable for this functionality to be in a companion project rather than bloating core SDL (as with SDL2_mixer, SDL2_image etc.), but I don’t know what the plans for SDL3 are in this regard.
Note that in SDL 1.2 we used to pass SDL_Surfaces to the drawing functions. SDL 2 added SDL_Texture so now we normally pass SDL_Renderer to the drawing functions instead which is able to handle both textures and surfaces (use SDL_CreateSoftwareRenderer to create a renderer to a surface).
That’s interesting, so would SDL_RenderDrawLine draw a line ontop of say an OpenGL render surface, because I know traditionally it’s not officially supported to render 2D directly to a 3D graphics context in SDL.