Sign in to follow this  
Dunge

Drawing circle with SDL_draw vs SDL_gfx

Recommended Posts

Dunge    405
We are using SDL for drawing on a arm embedded device for drawing on the linux framebuffer, so speed is important, but the problem also occurs in Windows. We plan on drawing a few hundreds of small circle one next to another. We actually draw the circle once on a temp surface, then blit it multiple times on the main surface. We first used SDL_draw, and it worked fine, until we realized it assume the surface we will draw on is the same bit depth as the primary (backbuffer) surface. Our video driver only support 16bits, but we use some 32bits surfaces to support alpha, and while it works, SDL_draw was trying to draw in 16bit on these and was not rendering properly. I then modified it's source so it use the passed surface to check bit depth instead of using SDL_GetVideoSurface, and after that it worked for alpha surface, but caused heap corruption on regular 16bits surfaces. I then though this lib seems crappy, and tried the other one which seems more used (SDL_gfx). While it draw correctly on all type of surfaces and don't crash, the filledCircleColor function actually draw a circle bigger than what you ask for, and it seems stretched and look ugly. aacircleColor() seems a bit better, but ask too much performance, is not filled, and still draw bigger than what I ask. My surface is 14x14, I draw at (7,7) with a 7radius, and the bottom/right pixels are missing. SDL_draw though draw the circle perfectly. Anything I can do?! Both libs have problems. Should I write my own circle drawing code? I can't simply load a png, cause the circle size can change.

Share this post


Link to post
Share on other sites
Dunge    405
The SDL_draw heap corruption I had was due to my modification. I really wonder why the guys coded it that way with macro and functions pointers, it's just pointless in this case but anyway. I managed to trim it back to normal functions who always check the BPP and then call the correct draw function, and it works great. Still pretty lame that both these libs are considered the best ones out there for SDL drawing, since they both are pretty bad.

[Edited by - Dunge on February 18, 2010 9:59:17 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this