Lines in SDL
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?
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.
The Bresenham Algorithms are still the best ones for drawing lines and circles on 2D.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement