【问题标题】:JOGL drawArrays JRE errorJOGL drawArrays JRE 错误
【发布时间】:2018-02-04 16:48:26
【问题描述】:

我在使用 JOGL 时遇到了问题。以下是代码和错误信息:

@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);
    }

错误信息:

#
# 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.
#

这个问题可以跟什么连接?这是我正在制作缓冲区的代码(位于 init 函数中):

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);

这些缓冲区中有大约 5000 个元素

【问题讨论】:

  • 当我在 LWJGL 中遇到这样的错误时,问题通常是我连接了两个类型错误的缓冲区,或者一个操作和一个缓冲区类型错误的缓冲区。尝试删除绘图调用,直到错误消失,然后关注最后更改的部分,尤其是其声明的(到 OpenGL)类型。

标签: java jogl


【解决方案1】:

所以,错误就在这一行

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

我改成

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

现在一切正常

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多