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
renderer | The renderer. |
points | An array of points. |
count | The number of points. This is one more than the number of lines. |
Return value
True on success. On failure it returns false.
Example
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
- To close a shape, repeat the first point at the end of the list.
In SDL2
Use SDL_RenderDrawLinesF for float positions.