API reference / Windows and drawing
SDL_RenderLine
Function, SDL3
Draws a line between two points, one pixel wide.
Declaration
#include <SDL3/SDL.h>
bool SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);Parameters
renderer | The renderer. |
x1 | The x position of the first point. |
y1 | The y position of the first point. |
x2 | The x position of the second point. |
y2 | The y position of the second point. |
Return value
True on success. On failure it returns false.
Example
float half_width = SDL_sqrtf(radius * radius - dy * dy);
SDL_RenderLine(renderer, x - half_width, y + dy, x + half_width, y + dy);See this code run in Draw shapes. Download the full program (.zip)
In SDL2
Use SDL_RenderDrawLineF for float positions.