Java崩溃?使用OpenGL



最近每当我运行我的OpenGL游戏,我得到这个奇怪的错误:

I am on OS x

这个错误是什么意思?

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000001276eff9f, pid=461, tid=5379
#
# JRE version: Java(TM) SE Runtime Environment (8.0_11-b12) (build 1.8.0_11-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.11-b03 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [GLEngine+0x15bf9f]  gleRunVertexSubmitImmediate+0x27ef
#
# 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:
# /Users/amit/workspace/Evox Voxel Engine GL 2.1/hs_err_pid461.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

每当我绘制

时,就会产生这个错误:
            GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount,
                    GL11.GL_UNSIGNED_INT, 0);

这是我的问题:

我使用全局索引VBO的所有块,因为我认为它不会有关系,如果我画一点索引比我实际拥有。事实证明,这会导致某种缓冲区溢出或读/写无效地址,导致整个游戏崩溃。

所以教训是总是准确地计算每个对象的索引数量,然后将其提供给draw方法,否则它可能会导致奇怪的行为。

另一个可能的问题是你的索引VBO受到它的类型的限制,例如byte/short/int。如果你的索引超过了byte/short/int所能容纳的数量,这可能会导致你的游戏崩溃。

快乐编程。

最新更新