Android OpenGL ES致命信号崩溃

Android OpenGL ES致命信号崩溃,android,opengl-es,Android,Opengl Es,我试图以.obj格式渲染导出的模型(从blender导出)。这是一个球体,我的应用程序只在Nexus5手机上崩溃。它正在Andy emulator和其他Android设备上工作 调试时,我尝试更改“count”参数的值,以查看会发生什么。我的球体有960个面(因此我应该绘制2880个面来查看完整的模型)。然而,如果我把1785或更多,它将崩溃。使用1784或更少,它不会崩溃(但我只看到模型的一部分) 它在GLES20.gldrawArray(GLES20.GL_三角形,01784)上崩溃 我的O

我试图以.obj格式渲染导出的模型(从blender导出)。这是一个球体,我的应用程序只在Nexus5手机上崩溃。它正在Andy emulator和其他Android设备上工作

调试时,我尝试更改“count”参数的值,以查看会发生什么。我的球体有960个面(因此我应该绘制2880个面来查看完整的模型)。然而,如果我把1785或更多,它将崩溃。使用1784或更少,它不会崩溃(但我只看到模型的一部分)

它在
GLES20.gldrawArray(GLES20.GL_三角形,01784)上崩溃

我的OBJ阅读器

public static void readModel(Context context, int resId) {

    // read in all the lines and put in their respective arraylists of strings
    // reason I do this is to get a count of the faces to be used to initialize the
    // float arrays
    ArrayList<String> vertexes = new ArrayList<String>();
    ArrayList<String> vertexNormals = new ArrayList<String>();
    ArrayList<String> textures = new ArrayList<String>();
    ArrayList<String> faces = new ArrayList<String>();

    InputStream iStream = context.getResources().openRawResource(resId);
    InputStreamReader isr = new InputStreamReader(iStream);
    BufferedReader bReader = new BufferedReader(isr);
    String line;
    try {
        while ((line = bReader.readLine()) != null) {
            // do not read in the leading v, vt or f
            if (line.startsWith("v ")) vertexes.add(line.substring(2));
            if (line.startsWith("vn ")) vertexNormals.add(line.substring(3));
            if (line.startsWith("vt ")) textures.add(line.substring(3));                
            if (line.startsWith("f ")) faces.add(line.substring(2));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    // holding arrays for the vertices, texture coords and indexes

    float[] vCoords = new float[faces.size() *3*3];
    float[] vNCoords = new float[faces.size()*3*3];
    float[] vtCoords = new float[faces.size()*3*2];

    totalCaras = faces.size();
    int vertexIndex = 0;
    int faceIndex = 0;
    int textureIndex = 0;

    // for each face
    for (String i : faces) {
        // for each face component
        for (String j : i.split(" ")) {
            String[] faceComponent = j.split("//");

            String vertex = vertexes.get(Integer.parseInt(faceComponent[0]) - 1);
            String normal = vertexNormals.get(Integer.parseInt(faceComponent[1]) - 1);
            String vertexComp[] = vertex.split(" ");
            String normalComp[] = normal.split(" ");

            for (String v : vertexComp) {
                vCoords[vertexIndex++] = Float.parseFloat(v);
            }
             for (String n : normalComp) {
                vNCoords[faceIndex++] = Float.parseFloat(n);
            }


        }
    }


    mCubePositions = ByteBuffer.allocateDirect(vCoords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    mCubePositions.put(vCoords).position(0);

    mCubeNormals = ByteBuffer.allocateDirect(vNCoords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    mCubeNormals.put(vNCoords).position(0);


}
公共静态void readModel(上下文,int resId){
//读入所有的行并放入它们各自的字符串数组列表
//我这样做的原因是获取用于初始化
//浮点数组
ArrayList顶点=新的ArrayList();
ArrayList vertexNormals=新建ArrayList();
ArrayList纹理=新建ArrayList();
ArrayList faces=新的ArrayList();
InputStream iStream=context.getResources().openRawResource(resId);
InputStreamReader isr=新的InputStreamReader(iStream);
BufferedReader bReader=新的BufferedReader(isr);
弦线;
试一试{
而((line=bReader.readLine())!=null){
//不要读取前导v、vt或f
if(line.startsWith(“v”)顶点添加(line.substring(2));
if(line.startsWith(“vn”))vertexNormals.add(line.substring(3));
if(line.startsWith(“vt”))纹理添加(line.substring(3));
如果(带(“f”)的行开始)面添加(行子字符串(2));
}
}捕获(IOE异常){
e、 printStackTrace();
}
//为顶点、纹理坐标和索引保留数组
float[]vCoords=新的float[faces.size()*3*3];
float[]vNCoords=newfloat[faces.size()*3*3];
float[]vtCoords=新的float[faces.size()*3*2];
totalCaras=faces.size();
int vertexIndex=0;
int faceIndex=0;
int-textureIndex=0;
//每一张脸
用于(字符串i:面){
//对于每个面组件
用于(字符串j:i.split(“”){
字符串[]faceComponent=j.split(“/”);
String vertex=vertexs.get(Integer.parseInt(faceComponent[0])-1);
String normal=vertexNormals.get(Integer.parseInt(faceComponent[1])-1);
字符串vertexComp[]=vertex.split(“”);
字符串normalComp[]=normal.split(“”);
用于(字符串v:vertexComp){
vCoords[vertexIndex++]=Float.parseFloat(v);
}
用于(字符串n:normalComp){
vNCoords[faceIndex++]=Float.parseFloat(n);
}
}
}
mCubePositions=ByteBuffer.allocateDirect(vCoords.length*4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubePositions.put(vCoords.position)(0);
mCubeNormals=ByteBuffer.allocateDirect(vNCoords.length*4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubeNormals.put(vNCoords.position)(0);
}
logcat显示的唯一跟踪:

06-10 09:08:32.016: D/OpenGLRenderer(6041): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-10 09:08:32.027: D/Atlas(6041): Validating map...
06-10 09:08:32.074: I/Adreno-EGL(6041): <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/14/15, ab0075f, Id3510ff6dc
06-10 09:08:32.075: I/OpenGLRenderer(6041): Initialized EGL, version 1.4

06-10 09:05:05.724: D/OpenGLRenderer(5242): Enabling debug mode 0
06-10 09:05:05.878: A/libc(5242): Fatal signal 11 (SIGSEGV), code 2, fault addr 0x74615000 in tid 5279 (GLThread 13643)
06-10 09:08:32.016:D/OpenGLRenderer(6041):使用EGL\u交换\u行为\u保留:true
06-10 09:08:32.027:D/地图集(6041):正在验证地图。。。
06-10 09:08:32.074:I/Adreno EGL(6041):高通公司生产日期:2015年1月14日,ab0075f,Id3510ff6dc
06-10 09:08:32.075:I/OpenGLRenderer(6041):初始化EGL,版本1.4
06-10 09:05:05.724:D/OpenGLRenderer(5242):启用调试模式0
06-10 09:05:05.878:A/libc(5242):tid 5279(GL13643)中的致命信号11(SIGSEGV),代码2,故障地址0x74615000

什么是
mCubePositions
?包含顶点坐标的浮点缓冲区是的,但这是您的代码,可能错误在那里?例如,您没有在对象中分配足够的存储空间?我在问题中添加了obj阅读器,但我认为我分配了足够的存储空间,因为它可以在其他功能较弱的设备上工作
06-10 09:08:32.016: D/OpenGLRenderer(6041): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-10 09:08:32.027: D/Atlas(6041): Validating map...
06-10 09:08:32.074: I/Adreno-EGL(6041): <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/14/15, ab0075f, Id3510ff6dc
06-10 09:08:32.075: I/OpenGLRenderer(6041): Initialized EGL, version 1.4

06-10 09:05:05.724: D/OpenGLRenderer(5242): Enabling debug mode 0
06-10 09:05:05.878: A/libc(5242): Fatal signal 11 (SIGSEGV), code 2, fault addr 0x74615000 in tid 5279 (GLThread 13643)