Ziggurat

07-14-2002, 07:49 AM

I need to aproximate an ellipse using ogl primitives. Also i need to draw it rotated without using glRotatef. Thanks.

View Full Version : How can i draw a ellipse

Ziggurat

07-14-2002, 07:49 AM

I need to aproximate an ellipse using ogl primitives. Also i need to draw it rotated without using glRotatef. Thanks.

t0y

07-14-2002, 08:05 AM

Originally from Mancha (http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/009191.html)

glBegin( GL_LINE_STRIP );

Segments=10.f;

for( float angle = 0.0f; angle <= (2.0f*PI); angle += (2.f*PI/Segments){

x = cos(angle)*XRadius;

y = sin(angle)*YRadius;

glVertex3f( x, y, 0);

}

glEnd();

edit:

Segments are the number of lines that'll approximate the ellipse;

XRadius/YRadius are the radius you want for both the axis (if both are 1, you'll have a circle with radius 1)

[This message has been edited by t0y (edited 07-14-2002).]

glBegin( GL_LINE_STRIP );

Segments=10.f;

for( float angle = 0.0f; angle <= (2.0f*PI); angle += (2.f*PI/Segments){

x = cos(angle)*XRadius;

y = sin(angle)*YRadius;

glVertex3f( x, y, 0);

}

glEnd();

edit:

Segments are the number of lines that'll approximate the ellipse;

XRadius/YRadius are the radius you want for both the axis (if both are 1, you'll have a circle with radius 1)

[This message has been edited by t0y (edited 07-14-2002).]

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.