title: OpenGL drawing a Hexigon with vertices
body: <p>Im trying to make a basic shape ( Hexigon ) to start and learn some basics about OpenGL on the Android platform and i have a little problem.</p>
  
  <p>I have successfully made a pointy Hexagon, but when i convert it into a flat Hexygon it doesnt render correctly. Here is some code, for you guys to figure out the problem ( probably a easy fix.. )</p>
  
  <p>vertices / indices</p>
  
  <pre><code>//flat hexagon
  private float verticesFlat[] = {     
      0.0f,   0.0f, 0.0f,    //center
      -0.5f,   1.0f, 0.0f,    // left top
      0.5f,   1.0f, 0.0f,    // right top
      1.0f,   0.0f, 0.0f,    // right
      0.5f,   1.0f, 0.0f,    // right bottom
      -0.5f,  -1.0f, 0.0f,    // left bottom
      -1.0f,   0.0f, 0.0f,     // left
  };
  
  private short[] indices = { 0, 1, 2, 3, 4, 5, 6, 1 };
  </code></pre>
  
  <p>standard vertex / index Buffers.. </p>
  
  <pre><code>// a float is 4 bytes, therefore we multiply the number if
  // vertices with 4.
  ByteBuffer vbb = ByteBuffer.allocateDirect(verticesFlat.length * 4);
  vbb.order(ByteOrder.nativeOrder());
  vertexBuffer = vbb.asFloatBuffer();
  vertexBuffer.put(verticesFlat);
  vertexBuffer.position(0);
  
  // short is 2 bytes, therefore we multiply the number if
  // vertices with 2.
  ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
  ibb.order(ByteOrder.nativeOrder());
  indexBuffer = ibb.asShortBuffer();
  indexBuffer.put(indices);
  indexBuffer.position(0);
  </code></pre>
  
  <p>The onDraw(GL10 gl):</p>
  
  <pre><code>gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  
  gl.glMatrixMode(GL10.GL_MODELVIEW);
  gl.glLoadIdentity();
  
  GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);    
  
  gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  
  gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
  gl.glDrawElements(GL10.GL_TRIANGLE_FAN, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);
  
  gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
  </code></pre>
  
  <p>The result im getting is illustrated in the image below:</p>
  
  <p><img src="https://i.stack.imgur.com/vUhmU.png" alt="Wrong rendering of hexagon"></p>