PDA

View Full Version : coordinates



Jmolar
02-05-2004, 03:41 AM
I am having problems specifying the coordinates. It is not drawing the lines where I want it to be. I want to use Gl_Line_Strip to draw an Hexagon.
Please can any one help me?

nexusone
02-05-2004, 03:46 AM
I find drawing things out on graph paper sometimes helps to get an idea of coordinates.



Originally posted by Jmolar:
I am having problems specifying the coordinates. It is not drawing the lines where I want it to be. I want to use Gl_Line_Strip to draw an Hexagon.
Please can any one help me?

dovkruger
02-05-2004, 05:39 PM
This is not the most efficient way to do it, but it gets it done. I assume you mean a regular polygon:

int n = 6;
float pi2 = M_PI * 2;
glBegin(GL_LINE_LOOP)
for (int i = 0; i < n; i++) {
glVertex2f(cos(pi2 * i / n), sin(pi2 * i / n);
}
glEnd();