SDL School

API reference / Windows and drawing

SDL_RenderGeometry

Function, SDL3

Draws triangles from a list of vertices. The graphics card fills each triangle and blends the vertex colors across it.

Declaration

#include <SDL3/SDL.h>

bool SDL_RenderGeometry(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Vertex *vertices, int num_vertices, const int *indices, int num_indices);

Parameters

rendererThe renderer.
textureA texture for the triangles, or NULL for plain color.
verticesAn array of vertices.
num_verticesThe number of vertices.
indicesAn optional array that lists vertices in order, or NULL to use them in order.
num_indicesThe number of indices, or 0.

Return value

True on success. On failure it returns false.

Example

Draw shapes
SDL_RenderGeometry(renderer, NULL, vertices, 3, NULL, 0);

See this code run in Draw shapes. Download the full program (.zip)

Notes

In SDL2

The name is the same, but a vertex color is an SDL_Color, with parts from 0 to 255.

See also