Drawing Circles in DX

Started by
2 comments, last by GameDev.net 19 years, 7 months ago
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
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Advertisement
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)
(-X, Y)
(-X, -Y)
(Y,X)
(Y,-X)
(-Y,X)
(-Y,-X)
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...
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.

This topic is closed to new replies.

Advertisement