Both the functions SDL_GetRenderer(SDL_Window*)
and SDL_CreateRenderer(SDL_Window*, int, Uint32)
seem to do the same thing: return a pointer to SDL_Renderer
from the window. However, what method is more appropriate for the task? The SDL Wiki does not provide much information on where which method should be used, so please explain what each method does, how they differ and where they should be used.
SDL_CreateRenderer
allows you to create a renderer for a window by specifying some options. It's stored in the specific window data which you can query with SDL_GetRenderer
(so the latter is equivalent to (SDL_Renderer *)SDL_GetWindowData(window, SDL_WINDOWRENDERDATA)
)
If you call SDL_GetRenderer
without having created it beforehand, you'll get a NULL pointer.
If you call SDL_CreateRenderer
on a window twice, the second call will fail with SDL_SetError("Renderer already associated with window");
(see line 805).
See here