SDL School

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

rendererThe renderer.
rectThe rectangle. NULL means the full window.

Return value

True on success. On failure it returns false.

Example

Draw a rectangle
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

In SDL2

Use SDL_RenderFillRectF for an SDL_FRect. SDL_RenderFillRect takes an SDL_Rect of int values.

See also