简体   繁体   English

Android OpenGL ES 1-多边形边缘

[英]Android OpenGL ES 1 - Polygon Edge

I am drawing a an arrow in using opengl es 1.0. 我在使用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: http://i.imgur.com/9K41OE8.png 正在发生的图像: http : //i.imgur.com/9K41OE8.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? 我认为这可能与剔除有关,但是为什么它仅发生在尖端的边缘?

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM