Drawing shapesSDL 3.2
SDL_RenderLine
Draws a one-pixel line between two points.
Signature
bool SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
How it works
Coordinates are floats, so the line can start and end between pixels. For many connected lines (a graph, a path) SDL_RenderLines takes an array of points and is faster than a loop of single calls. Lines are always 1 pixel wide; for thick lines draw a quad with SDL_RenderGeometry.
Parameters
rendererSDL_Renderer *
The renderer.
x1float
Start x.
y1float
Start y.
x2float
End x.
y2float
End y.
Return value
true on success, false on failure.
Example
example.cpp
1SDL_RenderLine(renderer, 0.0f, 0.0f, 1280.0f, 720.0f); // corner to corner