Please advice - how to draw a circle in 3D space

Hi!

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

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.

Hi.

I think what you are looking for is gluDisk.

Don’t know about speed, but its preety easy to learn. :slight_smile:

yup, that’s it, gluDisc. Wow, that one completely slipped my mind :stuck_out_tongue:

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)?

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++) 

  Q := gluNewQuadric; 
  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.

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