Sign in to follow this  
Dark Star

Drawing Circles in DX

Recommended Posts

I haven't heard of any DirectX function to do it, but you could either [google] it and find probably a few algorithms that could do it fast, or you could just program your own circle drawing function in DirectX.

Here's some pseudo-code to help get you started
Cartesian coordinates: X, Y
Radius = R
Angle = Theta

X = R * Cosine(Theta)
Y = R * Sine(Theta)

Choose Theta from 0 to 45 degrees only and mirror the coordinates as such:

(-X, Y)
(-X, -Y)

Share this post

Link to post
Share on other sites
The absolute *fastest* way to do it (IMHO) it to texture a quad with a circle texture that only has non-alpha values inside the circle, so that the only part of the 2 primitives that show are circle inside of them.

And no, there is no such thing as a "circle primitive". You have to use triangle primitives in this day and age. [wink]

Alternatively you can also precalc a circle of triangle primitives, then resize that to whatever size you need. Make things run a little faster that way too, but it might take a little more work to make it dynamic (refer to above post about creating circles out of triangles in realtime)

Mushu - trying to help those he doesn't know, with things he doesn't know.
Why won't he just go away? An question the universe may never have an answer to...

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
You have to be more specific. Are we talking about DirectDraw or Direct3D. DirectDraw is too simple. Direct3d is more interesting. In D3D you can use geometry or pixel shaders to draw some simple 2D primitives. With PS 2.0+ you can draw AAed lines, circles and more.

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