Drawing shapesSDL 3.2
SDL_RenderFillRect
Draws a filled rectangle in the current draw colour.
Signature
bool SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
How it works
SDL_FRect is {x, y, w, h} in floats: the top-left corner, then width and height. y grows downwards. In SDL3 every drawing function takes floats, so positions can move smoothly by fractions of a pixel.
Parameters
rendererSDL_Renderer *
The renderer.
rectconst SDL_FRect *
The rectangle, or NULL to fill the whole target.
Return value
true on success, false on failure.
Example
example.cpp
1SDL_FRect paddle{player.x, 680.0f, 120.0f, 16.0f};
2SDL_SetRenderDrawColor(renderer, 240, 240, 240, 255);
3SDL_RenderFillRect(renderer, &paddle);