SDL School

API reference / Windows and drawing

SDL_RenderLines

Function, SDL3

Joins a list of points in order with straight lines.

Declaration

#include <SDL3/SDL.h>

bool SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);

Parameters

rendererThe renderer.
pointsAn array of points.
countThe number of points. This is one more than the number of lines.

Return value

True on success. On failure it returns false.

Example

Draw shapes
SDL_FPoint points[6];

for (int i = 0; i < 6; i++) {
    points[i].x = x - RADIUS + (float)i * 24.0f;
    points[i].y = y + ((i % 2 == 0) ? -RADIUS : RADIUS);
}
SDL_RenderLines(renderer, points, 6);

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

Notes

In SDL2

Use SDL_RenderDrawLinesF for float positions.

See also