I’ve been trying to draw an oval shape or an elipse in opengl. I have figured out how to draw a sphere. But what I am really trying to do is find an elipse. Any help? txs

The only way I know how to do it is to specify the points that will be ‘the elipse’ and then use GL_LINE_LOOP to connect the dots.

Roach

You can use a sphere and scale with different values on each axes…

This draws an elipse because of the multiplication from 1/2 with cos.

float PI=3.14159

for(float x=0.0; x<=2*PI; x+=0.06)

{

glBegin(GL_LINES);

glVertex2f(sin(x), 1/2 * cos(x));

glVertex2f(sin(x+0.06), 1/2 * cos(x+0.06));

glEnd();

}

assuming you want to scale your sphere in the x-axis do the glScalef(X,0,0) operation

where X is the amount you want to scale (e.g. if it is 2 then the sphere wil have double size in the x axis)

Oups, I just wanted to correct the previous post, if you want to scale only on the X axis you can call glScale(X, 1,1) …otherwise it will be “empty”

I guess you wrote it a bit too fast spaceman

Sure, glScale is an option but i think it’s important to show the math behind this operation.

I prefer the manual way in many things.

Originally posted by DaleAT:

I’ve been trying to draw an oval shape or an elipse in opengl. I have figured out how to draw a sphere. But what I am really trying to do is find an elipse. Any help? txs

Have you tried using the gluDisk or gluCylinder commands?By tweaking the inner and outer radius parameters you can get a decent ellipse.Or perhaps you can draw the sphere and rotate on the -z/z axis.

there is a good tutorial that has a texture mapped object that when you press SPACEBAR it changes from square->circle->donut->sphere->partial disk, the partial disk part you may find interesting it shows how to draw partial or complete arcs. The tutorial is on NeHe Tutorials, unfortunately I cant give you any code , BECAUSE THEIR DAMN SYSTEM IS DOWN…

calm down, calm down… It will be back up soon