Jump to content
  • Advertisement
Sign in to follow this  
Dark Star

Drawing Circles in DX

This topic is 5112 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

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 this post


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

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
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!