Drawing a circle with vertices?

Started by
14 comments, last by Sardius2 20 years, 8 months ago
quote:Original post by Anonymous Poster
Yes, amazingly, no one here has figured out how to draw circles, and frankly, we're quite upset about it, so no need to rub salt in old wounds!!

This is as far as we've gotten (we are presently working on getting more DARPA funding)
1. Create a vertex buffer, fill it with 2 vertices to draw a line. If you can draw it, have a beer.
2. Add one more vertex to the buffer and draw a line strip. If the strip draws, have another beer.
3. Use the aforementioned equations when adding more points to the vertex buffer. If you can implement the equations, have another beer.

At this point, we usually pass out and wake up with serious headaches (we're lightweights), forcing us to start at #1. Perhaps you can get farther.


4. Learn about loops, have a beer.

5. Do these things,! Have 6 more beers!

EDIT: DONT TAKE SHORTCUTS have another 6 beers.

[edited by - RhoneRanger on August 14, 2003 11:55:16 PM]
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Advertisement
[kenobi]Use the for, loop...[kenobi]
quote:Original post by Irrelevant
[kenobi]Use the for, loop...[kenobi]


lol, classic
"Let Us Now Try Liberty"-- Frederick Bastiat
Circles are round, and directX can only draw in triangles. A circle can never be made from a triangle. The obvious solution is to change the laws of Geometry to accomodate your plan. I would kill for round triangles.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

quote:Original post by Etnu
Circles are round, and directX can only draw in triangles. A circle can never be made from a triangle. The obvious solution is to change the laws of Geometry to accomodate your plan. I would kill for round triangles.


I wonder, can DX draw Line Strips?

I also wonder if we want our circle filled or not?

Although you wont get a perfectly round circle, depending on how many iterations, you can come close.
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
//-----------------------------------------------------------------------------------//Draw a simple circle centered around the given point, using the given//radius and color//-----------------------------------------------------------------------------------void DrawCircle(POINT pt, float radius, D3DCOLOR color, LPDIRECT3DDEVICE8 dev){	const int NUMPOINTS = 24;	D3DTLVERTEX Circle[NUMPOINTS + 1];	int i;	float X;	float Y;	float Theta;	float WedgeAngle;	//Size of angle between two points on the circle (single wedge)	//Precompute WedgeAngle	WedgeAngle = (float)((2*PI) / NUMPOINTS);	//Set up vertices for a circle	//Used <= in the for statement to ensure last point meets first point (closed circle)	for(i=0; i<=NUMPOINTS; i++)	{		//Calculate theta for this vertex		Theta = i * WedgeAngle;				//Compute X and Y locations		X = (float)(pt.x + radius * cos(Theta));		Y = (float)(pt.y - radius * sin(Theta));		Circle[i] = CreateD3DTLVERTEX(X, Y, 0.0f, 1.0f, color, 0.0f, 0.0f);	}	//Now draw the circle	dev->SetVertexShader(D3DFVF_TL);	dev->SetTexture(0, NULL);	dev->DrawPrimitiveUP(D3DPT_LINESTRIP, NUMPOINTS, &Circle[0], sizeof(Circle[0]));}//DrawCircle

If you increase the NumPoints variable, you'll get more line segments drawing the circle, and thus a more round-looking circle. However, it will also increase your draw time.

[edited by - Teric on August 15, 2003 1:10:25 PM]
I am always open to feedback, positive or negative...

This topic is closed to new replies.

Advertisement