Search code examples
csdl-2

SDL2 How to draw dotted line


Is is just possible to draw a simple dotted line using SDL2 (or with gfx) like

int drawDottedLine(SDL_Renderer *renderer,Sint16 x1,Sint16 y1, Sint16 x2, Sint16 y2, int r, int g, int b, int a);

found absolutely nothing on the web wtf is it so hard ?


Solution

  • You can simply implement it yourself ... Check the "Bresenham algorithm" for draw a line.

    For a doted line, it's just many full line, so a pencil and paper with trigonometry should work out :)

    Edit : For a dotted line, you even don't have the use to the "Bresenham algorithm", you just need trigonometry.

    And by the way, for those who have downvoted, explain yourself ?