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 6 of 6

Thread: drawing circles in opengl

  1. #1
    Guest

    drawing circles in opengl

    i need to develop a simple drawing tool in opengl which will let me draw points, lines, circles and ellipses. these options must be availble by clicking the right mouse button. i can include a line and points but can't get circles to work.

    help please

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: drawing circles in opengl

    You'll need to "simulate" circles with lines.
    - Michael Steinberg

  3. #3
    Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Dunblane, Scotland
    Posts
    353

    Re: drawing circles in opengl

    You'll need to "simulate" circles with lines.

    try a for-next loop and rotate and then translate out the length of the radius.
    I did something like this before, allowing you to choose the number of lines is usefull so you can have anything from a pentagon to a pixel perfect circle.
    Reality is for idiots only the best over come it!

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    839

    Re: drawing circles in opengl

    Rotate and translate out of the radius? huh!? It's far easier just to zzap the verticies:

    glBegin(GL_LINES);
    for(int i=0; i<CIRCLE_RESOLUTION; i++) {
    float ang=((float)i/(foat)CIRCLE_RESOLUTION)*2.0*3.14159265;
    glVertex2f(cos(ang)*rad, sin(ang)*rad);
    }
    glEnd();


    cheers,
    John

    I wanna be a nudist \ And live by the sea \ I wanna be a buisness man \ Drinking lots of coffee --- Regurgitator

  5. #5
    Intern Contributor
    Join Date
    Aug 2000
    Location
    St. Andrews, Fife, Scotland
    Posts
    61

    Re: drawing circles in opengl

    It may be easier, but it isn't as nice and it isn't as fast.
    From the man with the
    mac and hence the
    mission POSSIBLE.

  6. #6
    Guest

    Re: drawing circles in opengl

    simulating the circle is easiest done with sin and cos, it is useful to know that sin and cos are modelled on a circle, sin and cos of an angle will produce two new values which can represent proportional vertices of a circle.

Posting Permissions

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