Lines in SDL

Started by
6 comments, last by Mizipzor 18 years, 7 months ago
I have my own wrapper class for SDL, if I want to add support for drawing primitives (circles, lines and squares) whats the best way to do it? Get some algoritm and draw every pixel? Or are there already functions like these included in SDL but I havent found it? Say I want to draw a square, its easy to calculate which pixels needs to be drawn if I know the topleft and downright coordinate. But is that way of idividually drawing pixels to slow? Has anyone else done this?
Advertisement
You might be interested in the SDL_gfx library.
Jooleem. Get addicted.
Exactly what I was looking for. A big thanks and a rating to you. :)
Glad to be of service. :)
Jooleem. Get addicted.
I just found a very nice tutorial on SDL_gfx, which you might find interesting.
Jooleem. Get addicted.
Quote:Original post by Peregrin
You might be interested in the SDL_gfx library.


Don't forget about SDL_draw too [wink] (Just note the license though, so you might not want to OTOH)
If you're still interested on getting your hands dirty, yes, you lock the video surface, plot each single pixel that describes your shapes, unlock the surface and flip.

The Bresenham Algorithms are still the best ones for drawing lines and circles on 2D.
That tutorial helped me out alot. And those algorithms looks interesting if I ever want to redo this myself.

Thanks everyone. :)

This topic is closed to new replies.

Advertisement