# Drawing Circles in DX

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

## Recommended Posts

Hi Guys, Im drawing primitives in DirectX 8.0 and I was wondering ig DirectX can draw circle primitives. I cannot seem to find a function that does it. Can it do it? Thanks in advance DarkStar UK

##### Share on other sites
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
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)
(-X, Y)
(-X, -Y)
(Y,X)
(Y,-X)
(-Y,X)
(-Y,-X)

##### 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 on other sites
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.

• 18
• 18
• 11
• 21
• 16