异常访问违规?

时间:2015-02-23 22:24:49

标签: lwjgl

我不明白,我正在学习LWJGL,但是当我把这段代码写下来时:

public void render()
    {
        glBindBuffer(GL_ARRAY_BUFFER, vID);
        glVertexPointer(3, GL_FLOAT, 0, 0L);

        glEnableClientState(GL_VERTEX_ARRAY);

        glDrawArrays(GL_QUADS, 0, CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE * (3 * 4 * 6));

        glDisableClientState(GL_VERTEX_ARRAY);

    }

java throw:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000056fda8e0, pid=8840, tid=8336
#
# JRE version: Java(TM) SE Runtime Environment (7.0_75-b13) (build 1.7.0_75-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.75-b04 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [atio6axx.dll+0x21a8e0]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Chargon\Desktop\Programming\JavaRessource\PandorasGame\hs_err_pid8840.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.
#

我该如何解决这类问题?我启用了客户端状态,而vertexPointer浮动是' 3'。我真的需要一些帮助x.x非常感谢

1 个答案:

答案 0 :(得分:1)

LWJGL中的访问冲突主要是由缓冲区大小和渲染调用计数不适合引起的。

您应该检查 vID 是否真的包含要绘制的CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE * (3 * 4 * 6)元素。请参阅here

我的猜测是它应该是CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE * (4 * 6):CHUNK_SIZE ^ 3个元素,其中6个边各包含4个顶点。