Android OpenGL致命信号11(SIGSEGV),代码2

时间:2015-06-14 02:18:10

标签: android opengl-es

我收到此错误

Fatal signal 11 (SIGSEGV), code 2, fault addr 0xa4b7b000 in tid 10818 (GLThread 54114)

当我的应用启动时我正在测试渲染很多点。它以10,000点的速度崩溃并且在3,000点上工作正常。

public class PointRenderer implements GLSurfaceView.Renderer {
    private int size = 10000;
    private FloatBuffer floatBuffer;

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        floatBuffer = ByteBuffer.allocateDirect(4*2*size).asFloatBuffer();

        Random r = new Random();
        for (int i = 0; i < 2*size; i++) {
            floatBuffer.put(r.nextFloat()*100);
        }
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        gl.glViewport(0, 0, w, h);
    }

    public void onDrawFrame(GL10 gl) {
        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        gl.glPushMatrix();
            gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
            gl.glVertexPointer(2, GL10.GL_FLOAT, 0, floatBuffer);
            gl.glDrawArrays(GL10.GL_POINTS, 0, size);
            gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glPopMatrix();
    }
}

0 个答案:

没有答案