PDA

View Full Version : Please advice - how to draw a circle in 3D space

anuchka
07-06-2004, 07:33 AM
Hi!

I need to draw a circle(not a ball!) in 3d space.
Please advice - what is the fastest and easy way to it?

Aeluned
07-06-2004, 07:56 AM
You could draw your circle in photoshop, save it onto a transparent background and then use it as a texture onto a quad and position your quad wherever you want in 3D Space.

or you could use math to approximate the circle using a series of lines.

HairyFotr
07-06-2004, 11:01 AM
Hi.

I think what you are looking for is gluDisk.

Don't know about speed, but its preety easy to learn. :)

Aeluned
07-06-2004, 12:13 PM
yup, that's it, gluDisc. Wow, that one completely slipped my mind :p

anuchka
07-06-2004, 08:54 PM
Thanks for the answers,but gluDisk at first look
looks a little complicated.
Do Nehe has a sample code for it (somewhere in his tutorial)?

HairyFotr
07-07-2004, 02:25 AM
First you have to make a quadric object. You usually only need one.

var
Q: PGLUQuadric; //variable declaration (in delphi, dont know, how it goes in c++)

gluQuadricTexture(Q, GL_TRUE); // This enables texturing Then you just use the gluDisk command (you can also use gluSphere or gluCylinder with the same quadric object)

If you are not sure, ask again or google for it and you'll find all the data on the reference pages.

-NiCo-
07-07-2004, 03:04 AM
Why not make one yourself and store it in a display list?

GLuint circle;

circle=glGenLists(1);
glNewList(circle,GL_COMPILE);

int detail=100;

glBegin(GL_LINE_LOOP)
for (int i=0;i<detail;++i)
glVertex2d(cos(2*i*PI/detail),sin(2*i*PI/detail));
glEnd();

glEndList();if you want the circles to be filled, use:

glBegin(GL_TRIANGLE_FAN)
glVertex2d(0.0,0.0);
for (int i=0;i<=detail;++i)
glVertex2d(cos(2*i*PI/detail),sin(2*i*PI/detail));
glEnd();Nico