0

I am drawing a an arrow in using opengl es 1.0. I drew the arrow using a rectangle as the shaft and a pyramid as the tip. When the arrow is rotating from certain angles the shaft can be seen through the edge of the arrow tip.

Image of what is occuring: https://i.stack.imgur.com/fqjqd.png

My draw method

    public void draw(GL10 gl) {
    gl.glFrontFace(GL10.GL_CW);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);

    gl.glDrawElements(GL10.GL_TRIANGLES, indexBuffer.capacity(), GL10.GL_UNSIGNED_BYTE, indexBuffer);

    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);  

}

I think it may have something to do with culling, but why would it only occur at the edge of the tip?

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
user994121
  • 77
  • 6

1 Answers1

1

Depth testing must be enabled for this to look right. Use this:

gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthMask(GL10.GL_TRUE);

And then don't forget to clear the bits before drawing a frame:

gl.glClear(GL10.GL_DEPTH_BUFFER_BIT | GL10.GL_COLOR_BUFFER_BIT);