API reference / Windows and drawing
SDL_RenderFillRect
Function, SDL3
Fills a rectangle with the current draw color.
Declaration
#include <SDL3/SDL.h>
bool SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);Parameters
renderer | The renderer. |
rect | The rectangle. NULL means the full window. |
Return value
True on success. On failure it returns false.
Example
SDL_SetRenderDrawColor(renderer, 32, 96, 160, SDL_ALPHA_OPAQUE);
SDL_RenderFillRect(renderer, &blue);See this code run in Draw a rectangle. Download the full program (.zip)
Notes
- An
SDL_FRectholdsx,y,w, andh, in that order. Thexandygive the top-left corner.
In SDL2
Use SDL_RenderFillRectF for an SDL_FRect. SDL_RenderFillRect takes an SDL_Rect of int values.