06-17-2003, 05:17 PM

please help me....i really need to know how to create this thing with openGL.can somebody help me.i'm new in openGL

View Full Version : how to create a line,elipse and circle

06-17-2003, 05:17 PM

please help me....i really need to know how to create this thing with openGL.can somebody help me.i'm new in openGL

mikael_aronsson

06-17-2003, 10:18 PM

Hi !

You use DDA (Digital Differential Analyzer) for lines and sin and cos for circles and ellipses, use google to search for it.

OpenGL already has support for lines so I don't know why you need it, circles and ellipses area very easy (just draw line segments between the caclulated points using GL_LINESTRIP.

Something like this:

x = xpos + xradius * cos( v)

y = ypos + yradius * sin( v)

If I remember correct http://www.opengl.org/discussion_boards/ubb/biggrin.gif, v is the angle in radians (2*pi is a full circle).

Mikael

This pdf might get you started: www.cs.ucr.edu/~vbz/cs130-03.pdf (http://www.cs.ucr.edu/~vbz/cs130-03.pdf)

Mikael

You use DDA (Digital Differential Analyzer) for lines and sin and cos for circles and ellipses, use google to search for it.

OpenGL already has support for lines so I don't know why you need it, circles and ellipses area very easy (just draw line segments between the caclulated points using GL_LINESTRIP.

Something like this:

x = xpos + xradius * cos( v)

y = ypos + yradius * sin( v)

If I remember correct http://www.opengl.org/discussion_boards/ubb/biggrin.gif, v is the angle in radians (2*pi is a full circle).

Mikael

This pdf might get you started: www.cs.ucr.edu/~vbz/cs130-03.pdf (http://www.cs.ucr.edu/~vbz/cs130-03.pdf)

Mikael

Sourpotato

06-18-2003, 04:36 PM

Originally posted by mael:

please help me....i really need to know how to create this thing with openGL.can somebody help me.i'm new in openGL

/*

for the line

*/

glBegin(GL_LINES);

glVertex3f(1.0f,0.0f,0.0f);

glVertex3f(0.0f,0.0f,0.0f);

glEnd();

//for the circle or elipse

first when you set your projection mode

you need to use glOrtho

you can use either DDA or midpoint algorithm (also called bresenham algorithm )to draw the circle or elipse

Also you can use gluSphere ,check the REDbook/msdn for the more detailed explaination

[This message has been edited by RunningRabbit (edited 06-18-2003).]

[This message has been edited by RunningRabbit (edited 06-19-2003).]

please help me....i really need to know how to create this thing with openGL.can somebody help me.i'm new in openGL

/*

for the line

*/

glBegin(GL_LINES);

glVertex3f(1.0f,0.0f,0.0f);

glVertex3f(0.0f,0.0f,0.0f);

glEnd();

//for the circle or elipse

first when you set your projection mode

you need to use glOrtho

you can use either DDA or midpoint algorithm (also called bresenham algorithm )to draw the circle or elipse

Also you can use gluSphere ,check the REDbook/msdn for the more detailed explaination

[This message has been edited by RunningRabbit (edited 06-18-2003).]

[This message has been edited by RunningRabbit (edited 06-19-2003).]

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.