Android OpenGL ES点云渲染

时间:2014-04-25 14:08:38

标签: android opengl-es

我有一个包含网格中所有点的浮点数组,我试图将其渲染为点云,但无论如何,我得到的只是毛刺OpenGL glitches

以下是相关代码:

public Plane()
{
    ...

    ByteBuffer bb = ByteBuffer.allocateDirect(vertexCoords.length * 4);
    bb.order(ByteOrder.nativeOrder());
    vertexBuffer = bb.asFloatBuffer();
    vertexBuffer.put(vertexCoords);
    vertexBuffer.position(0);
     ...
}

public void draw(GL10 gl)
{
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPointSize(3);

    // Specifies the location and data format of an array of vertex
    // coordinates to use when rendering.
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);

    gl.glDrawArrays(GL10.GL_POINTS, 0, vertexCoords.length / 3);

    // Disable the vertices buffer.
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}

MyRenderer.java:

    public void onSurfaceChanged(GL10 gl10, int i, int i2) {
    // Sets the current view port to the new size.
    gl10.glViewport(0, 0, i, i2);
    // Select the projection matrix
    gl10.glMatrixMode(GL10.GL_PROJECTION);
    // Reset the projection matrix
    gl10.glLoadIdentity();
    // Calculate the aspect ratio of the window
    GLU.gluPerspective(gl10, 45.0f,
            (float) i / (float) i2,
            0.1f, 100.0f);
    // Select the modelview matrix
    gl10.glMatrixMode(GL10.GL_MODELVIEW);
    // Reset the modelview matrix
    gl10.glLoadIdentity();
}

我从另一个StackOverflow问题中得到了渲染代码,但无论我做什么,我得到的只是静态的东西。作为参考,当我尝试对其进行三角测量时,我得到相同(或类似)的效果。 (使用和索引缓冲区)。

0 个答案:

没有答案