Skip to main content
gamedev.net
🔒 Locked

Draw A Circle?

Started by LeLe Nov 15, 2001 at 12:46 AM 2 replies 650+ views
Original Post
LeLe
LeLe
I want to draw a circle on the screen. How can I do in D3D. Have I to caculate these vertices on a circle?
JY
JY
I don''t mean to be pedantic but do you mean a circle or a sphere? Either way, if you want to manipulate it and do different things with it (transformations and texturing etc.) you would probably have to calculate all the vertices.

If it''s just for show you could probably get away with a bitmap?

It all depends on what you are doing with it.
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
invective
invective
if you can, use a texture. if you wanted a sphere D3DXCreateSphere, if you want a circle, just make a trinagle fan with the origin at the center and the rest of the vertices:
      
vertex = new vertexType [numberSegments + 1]
float theta = 0.0f;
vertex[0].x = vertex[0].y = vertex[0].z =0.0f;
for (int i=1; i < numberSegments+1; i++)
{
vertex[i].x = cos (theta);
vertex[i].y = sin (theta);
vertex[i].z = 0.0f;
theta += 2.0f*PI/numberSegments;
}



That is a unit circle of course. You need to apply any necessary transforms.

Edited by - invective on November 15, 2001 7:10:23 AM
LeLe
LeLe
Thank you very much. And I have to add a RHW to the format since I only want to draw at screen plan.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.