PDA

View Full Version : drawing hexagon



ajbiv
01-31-2009, 07:29 AM
I want to draw a hexagon. I am limited to open gl es, but i can translate for the most part.

My real question. What should my approach be to thinking about the polygon. I have some graph paper and a pencil, and I started drawing it out. I am not sure whether I am drawing several squares and triangles that all make up the hexagon? or whether I am drawing one big shape. I'm guessing there are tons of approaches, but any suggestions on where to start?


Eventually, I want to draw a 3D hexagon that looks similar to a pencil.

Ginkgo
01-31-2009, 08:52 AM
This should do, what you want.
It simply draws a circle with 6 Points.



glBegin(GL_POLYGON);
for(int i = 0; i < 6; ++i) {
glVertex2d(sin(i/6.0*2*M_PI),
cos(i/6.0*2*M_PI));
}
glEnd();

ajbiv
01-31-2009, 11:54 AM
that makes sense, thanks