【问题标题】:LWJGL - A function that is not available in the current context was calledLWJGL - 调用了当前上下文中不可用的函数
【发布时间】:2017-08-04 03:12:59
【问题描述】:

我刚开始使用 LWJGL 和 OpenGL,但遇到了问题。我试图弄清楚如何为我正在使用我找到的游戏引擎制作的游戏画一条简单的线。

这是我正在使用的引擎的链接:https://github.com/SilverTiger/SilenceEngine

在渲染器类中我尝试添加这个函数 -

 public void drawLine(Point point, Point point2) {

        GL11.glColor3f(0.0f, 1.0f, 0.2f);
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex2d(point.x, point.y);
        GL11.glVertex2d(point2.x, point2.y);
        GL11.glEnd();

 }

我得到的错误如下:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007fff32b524cd, pid=3016, tid=0x0000000000002548
#
# JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [lwjgl.dll+0x124cd]
#
# 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\sambu\workspace\NextGen Engine - 0.3.1\hs_err_pid3016.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.
#
[LWJGL] A function that is not available in the current context was called. The JVM will abort execution. Inspect the crash log to find the responsible Java frames.

我对此很陌生,不知道如何解决这个问题。

【问题讨论】:

    标签: java opengl lwjgl


    【解决方案1】:

    在引擎中创建的窗口具有版本 3.2 的 OpenGL 上下文。在 3.2 版中,您不能调用旧的原始绘图调用。所有绘图调用都需要使用顶点数组和缓冲区来完成。这是一个关于如何做到这一点的教程(请记住,这是用 C++ 编写的):Draw Your First Triangle。这是引擎的入门论坛(称为新手问题)。 Forum

    【讨论】:

    • 嗨。我目前正在学习 VAO 和 VBO。在实现了我所遵循的教程中的代码后,调用 glGenVertexArrays(); 时出现错误。我想指出,我使用的是 LWJGL 教程,所以可能会有所不同。
    • @pebble225 向 SO 提问。如果没有看到代码或您遇到什么错误,我无法说出任何事情。不过,请确保您正确初始化了 OpenGL 上下文。
    • 我解决了。事实证明,我试图在设置上下文之前初始化 VAO。
    猜你喜欢
    • 2017-08-19
    • 2015-02-23
    • 1970-01-01
    • 2013-10-20
    • 2014-09-23
    • 2014-12-17
    • 1970-01-01
    相关资源
    最近更新 更多