Support for drawing triangles

Has there been any consideration for extending SDL_Renderer with the
ability to render 2d triangles?

Since the Renderer has the ability to rasterize lines and quads it
doesn’t seem such a far stretch to add
triangle support, which would open up many interesting opportunities.

Does anyone have ideas about how feasible this is? Would the community
be open to this? What may
I have to consider if I was to add this to SDL2?

My initial idea would be something like this:

// draw a triangle on screen using the current draw colour
int SDL_RenderFillTriangle( SDL_Renderer* renderer, const SDL_Point point[3] );

// draw a collection of triangles stored in a vertex list
int SDL_RenderFillTriangles( SDL_Renderer* renderer, const SDL_Point* point, int count );

1 Like

Gabriel Jacobo proposed a direct triangle rendering function as
"SDL_RenderGeometry", which hasn’t been worked into the mainline SDL2 yet.
It is more useful than just flat-filled triangles. You might look at his
patch on this mailing list.

Also, SDL_gpu has the equivalent functionality already.

Jonny DOn Fri, Jun 13, 2014 at 9:18 AM, Aidan Dodds wrote:

Has there been any consideration for extending SDL_Renderer with the
ability to render 2d triangles?

Since the Renderer has the ability to rasterize lines and quads it doesn’t
seem such a far stretch to add
triangle support, which would open up many interesting opportunities.

Does anyone have ideas about how feasible this is? Would the community be
open to this? What may
I have to consider if I was to add this to SDL2?

My initial idea would be something like this:

// draw a triangle on screen using the current draw colour
int SDL_RenderFillTriangle( SDL_Renderer* renderer, const SDL_Point
point[3] );

// draw a collection of triangles stored in a vertex list
int SDL_RenderFillTriangles( SDL_Renderer* renderer, const SDL_Point*
point, int count );


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org