시작 예 (https://www.lwjgl.org/guide (변경되지 않은 상태))에서 LWJGL을 사용하려고하지만 OpenGL ES를 사용하도록 변경했습니다. 3.0 대신 (이 질문과 무관 한 이유로).현재 스레드에 OpenGL ES 컨텍스트 현재 없음 - OpenGL ES 3.0을 사용하는 LWJGL
필자는 최신 LWJGL Release 3.1.1을 사용하고 Minimal OpenGL ES를 사전 설정 (https://www.lwjgl.org/download)으로 선택하고 Windows 원어민을 사용하고 있습니다. (저는 Windows 10 64 비트를 실행 중입니다)
저는 고생하고 있습니다. 어떻게 고쳐야할지 모르겠습니다.
내가 오류가 있습니다 : 스레드 "주요"java.lang.IllegalStateException에서
예외 : 현재의 thread에 더는 OpenGL ES의 상황에 맞는 전류가 없습니다.
전체 오류 :
Exception in thread "main" java.lang.IllegalStateException: There is no OpenGL ES context current in the current thread.
at org.lwjgl.opengles.GLES.createCapabilities(GLES.java:222)
at com.test.desktop.HelloWorld.loop(HelloWorld.java:93)
at com.test.desktop.HelloWorld.run(HelloWorld.java:31)
at com.test.desktop.HelloWorld.main(HelloWorld.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
완전한 소스 :
import org.lwjgl.opengl.*;
그리고, 변경 : 내가 주석을 해제하는 경우가 ... 주목할 가치가 있는지 여부
package com.test.desktop;
import org.lwjgl.*;
import org.lwjgl.glfw.*;
//import org.lwjgl.opengl.*;
import org.lwjgl.opengles.GLES;
import org.lwjgl.system.*;
import java.nio.*;
import static org.lwjgl.glfw.Callbacks.*;
import static org.lwjgl.glfw.GLFW.*;
//import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengles.GLES20.*;
import static org.lwjgl.opengles.GLES30.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
public class HelloWorld {
// The window handle
private long window;
static final int WIDTH = 1024;
static final int HEIGHT = 768;
public void run() {
System.out.println("Hello LWJGL " + Version.getVersion() + "!");
init();
loop();
// Free the window callbacks and destroy the window
glfwFreeCallbacks(window);
glfwDestroyWindow(window);
// Terminate GLFW and free the error callback
glfwTerminate();
glfwSetErrorCallback(null).free();
}
private void init() {
// Setup an error callback. The default implementation
// will print the error message in System.err.
GLFWErrorCallback.createPrint(System.err).set();
// Initialize GLFW. Most GLFW functions will not work before doing this.
if (!glfwInit())
throw new IllegalStateException("Unable to initialize GLFW");
// Configure GLFW
glfwDefaultWindowHints(); // optional, the current window hints are already the default
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
// Create the window
window = glfwCreateWindow(WIDTH, HEIGHT, "Hello World!", NULL, NULL);
if (window == NULL)
throw new RuntimeException("Failed to create the GLFW window");
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE)
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
});
// Get the resolution of the primary monitor
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
// Center the window
glfwSetWindowPos(
window,
(vidmode.width() - WIDTH)/2,
(vidmode.height() - HEIGHT)/2
);
// Make the OpenGL context current
glfwMakeContextCurrent(window);
// Enable v-sync
glfwSwapInterval(1);
// Make the window visible
glfwShowWindow(window);
}
private void loop() {
// This line is critical for LWJGL's interoperation with GLFW's
// OpenGL context, or any context that is managed externally.
// LWJGL detects the context that is current in the current thread,
// creates the GLCapabilities instance and makes the OpenGL
// bindings available for use.
GLES.createCapabilities();
// GL.createCapabilities();
// Set the clear color
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
// Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key.
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
glfwSwapBuffers(window); // swap the color buffers
// Poll for window events. The key callback above will only be
// invoked during this call.
glfwPollEvents();
}
}
public static void main(String[] args) {
new HelloWorld().run();
}
}
GLES.createCapabilities();
그리고, 대신 다음을 사용 : 스레드 "주요"java.lang.IllegalStateException에서
예외 : 현재 스레드 설정 없음 GLESCapabilities 인스턴스
GL.createCapabilities();
나는이 오류가 발생합니다. 가능한 해결책 :