简体   繁体   中英

JOGL drawArrays JRE error

I encountered a problem when working with JOGL. Here is the code and error message:

@Override
    public void display(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();
        gl.glLoadIdentity();
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
        gl.glBindTexture(GL2.GL_TEXTURE_2D, tex);
        gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
        gl.glEnableClientState(GL2.GL_NORMAL_ARRAY);
        gl.glVertexPointer(3, GL2.GL_FLOAT, 0, vertices);
        gl.glTexCoordPointer(3, GL2.GL_FLOAT, 0, texCoords);
        gl.glTexCoordPointer(3, GL2.GL_FLOAT, 0, normals);
        gl.glDrawArrays(gl.GL_QUADS, 0, 4); // error
        for (Model.VerticesDescriptor vd : model.vd) {
            //if (vd.POLYTYPE == vd.POLY_TYPE_TRIANGLES) gl.glDrawArrays(gl.GL_TRIANGLES, vd.START, vd.END); // error
            //if (vd.POLYTYPE == vd.POLY_TYPE_QUADS) gl.glDrawArrays(gl.GL_QUADS, vd.START, vd.END); // error
            //else if (vd.POLYTYPE == vd.POLY_TYPE_POLYGON) gl.glDrawArrays(gl.GL_POLYGON, vd.START, vd.END); // error
        }
        gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
        gl.glDisableClientState(GL2.GL_NORMAL_ARRAY);
    }

Error message:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007efd2dd1fe23, pid=7101, tid=0x00007efcc6bda700
#
# JRE version: OpenJDK Runtime Environment (8.0_151-b12) (build 1.8.0_151-8u151-b12-1~deb9u1-b12)
# Java VM: OpenJDK 64-Bit Server VM (25.151-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libc.so.6+0x128e23]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/congard/Разработка/eclipse-workspace/Turbo Fly 3D/hs_err_pid7101.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

With what this problem can be connected? Here is the code I am making buffers (located in the init function):

vertices = Buffers.newDirectFloatBuffer(model.vertices.length);
        vertices.put(model.vertices).position(0);

        texCoords = Buffers.newDirectFloatBuffer(model.texCoords.length);
        texCoords.put(model.texCoords).position(0);

        normals = Buffers.newDirectFloatBuffer(model.normals.length);
        normals.put(model.normals).position(0);

There are ~5000 elements in these buffers

So, the error was on this line

gl.glTexCoordPointer(3, GL2.GL_FLOAT, 0, normals);

I changed it to

gl.glNormalPointer(GL2.GL_FLOAT, 0, normals);

And everything work now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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