cost of switching render color vs. new functions

I’m working on implementations of curve drawing functions using Bresenham’s algorithms, and they call SDL_RenderDrawPoints for the “stroke” version or SDL_RenderDrawLine for the “fill” version.

I could do both stroke and fill in the same function but it would require switching the render color between iterations (drawing the line for fill, then points for stroke.) My question is whether changing the render color that often is expensive enough to matter, or is it better to keep separate functions, the way SDL has FillRect and DrawRect?

The render color is just a field (or rather 4 fields) inside SDL_Renderer. Changing the color doesn’t affect anything outside of SDL. The cost is no more than the usual overhead of a function call.

1 Like