Jump to content
  • Advertisement
Sign in to follow this  
Mizipzor

Lines in SDL

This topic is 4822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
That tutorial helped me out alot. And those algorithms looks interesting if I ever want to redo this myself.

Thanks everyone. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!