Android的 - 为什么我越来越致命的信号? [英] Android - Why i'm getting fatal signal?

查看:201
本文介绍了Android的 - 为什么我越来越致命的信号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着以显示与OpenGL ES的屏幕上的一些要点。
这里是OnDraw中的code:

Im trying to display some points on the screen with opengl es. here is the code of ondraw:

gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glColor4f(0, 255, 0, 0);     
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, buffer);
gl.glDrawArrays(GL10.GL_POINTS, 0, points.length);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

谁能告诉我,我做错了什么?

Can someone tell me what I'm doing wrong???

编辑:code生成缓冲区,并分

the code to generate the buffer and points

    points = new float[12288];
    int pos = 0;
    for (float y = 0; y < 64; y++) {
        for (float x = 0; x < 64; x++) {
            points[pos++] = x/100;
            points[pos++] = y/100;
            points[pos++] = 0;
        }
    }

    ByteBuffer vertexByteBuffer = ByteBuffer.allocateDirect(points.length * 4);
    vertexByteBuffer.order(ByteOrder.nativeOrder());     
    // allocates the memory from the byte buffer
    buffer = vertexByteBuffer.asFloatBuffer();   
    // fill the vertexBuffer with the vertices
    buffer.put(points);  
    // set the cursor position to the beginning of the buffer
    buffer.position(0);

和在logcat的错误:

and the error at logcat:

6月四日至17日:38:11.296:A / libc的(24276):在0x41719000致命信号11(SIGSEGV)(code = 2)

04-17 06:38:11.296: A/libc(24276): Fatal signal 11 (SIGSEGV) at 0x41719000 (code=2)

此错误发生在gl.glDrawArrays

This error happens at gl.glDrawArrays

推荐答案

我相信这就是问题所在:

I believe this is the problem:

gl.glDrawArrays(GL10.GL_POINTS,0,points.length);

调用glDrawArrays 需要的,你想画的顶点的数量。你给它的数量浮动,这是3倍太大。因此OpenGL的实际上是试图读取12288个顶点= 36,XXX从点阵列,它的方式超过你的数组的边界浮动。

glDrawArrays takes the number of vertices that you want to draw. You are giving it the number of floats, which is 3x too big. Therefore opengl is actually attempting to read 12288 vertices = 36,xxx floats from your points array, which way exceeds the bounds of your array.

这篇关于Android的 - 为什么我越来越致命的信号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆