Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How can i draw a ellipse

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2002
    Posts
    27

    How can i draw a ellipse

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

  2. #2
    Intern Contributor
    Join Date
    Mar 2002
    Location
    Figueira da Foz, Portugal
    Posts
    84

    Re: How can i draw a ellipse

    Originally from Mancha (http://www.opengl.org/discussion_boa...ML/009191.html)

    Code :
    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).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •