You're heading in the right direction. There are many ways to draw using OpenGL, and while folks will argue this is the the fastest way, it will get you a hexagon on the screen. To draw multiple hexagons, wrap your glBegin(GL_POLYGON)
... glEnd()
snippet in a for
loop that renders the appropriate number of hexagons.
To adjust the size of a hexagon, you need to adjust the values that you pass into glVertex3f
. In your original post, you're drawing a hexagon that's contained in a circle of radius one (since the coefficients to your sin
and cos
functions is also one). If you use a smaller radius (i.e., a value less than one), you'll get a smaller hexagon.
Finally, each of your hexagons is currently centered at the origin. To move them to a different place within your viewing area of [-1,1] in x and y, merely add offsets to the x and y coordinates that you pass into glVertex3f
. Since each hexagon will presumably have its own offset, you'll probably want to use an array sized for the number of hexagons, and index that by your outer loop.