LWJGL sypie wyjątkami i nie chce utworzyć okna GLFW

0

Witam,

Zapisałem przykladowy kod z oficjalnego tutoriala http://www.lwjgl.org/guide. Podłączyłem pliki .jar i native do projektu i niestety otrzymuję wyjątek:

Exception in thread "main" java.lang.RuntimeException: Failed to create the GLFW window
at HelloWorld.init(HelloWorld.java:54)
at HelloWorld.run(HelloWorld.java:22)
at HelloWorld.main(HelloWorld.java:107)

Dlaczego otrzymuję ten wyjątek i nie mogę utworzyć okna? Czy ma to związek z systemem operacyjnym (Windows 10) i zintegrowaną kartą graficzną? Nigdzie nie mogę znaleźć podobnych problemów.

kod:

 import org.lwjgl.Sys;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
 
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryUtil.*;

public class HelloWorld {

	// We need to strongly reference callback instances.
    private GLFWErrorCallback errorCallback;
    private GLFWKeyCallback   keyCallback;
 
    // The window handle
    private long window;
 
    public void run() {
        System.out.println("Hello LWJGL " + Sys.getVersion() + "!");
 
        try {
            init();
            loop();
 
            // Release window and window callbacks
            glfwDestroyWindow(window);
            keyCallback.release();
        } finally {
            // Terminate GLFW and release the GLFWErrorCallback
            glfwTerminate();
        }
    }
 
    private void init() {
        // Setup an error callback. The default implementation
        // will print the error message in System.err.
       
 
        // Initialize GLFW. Most GLFW functions will not work before doing this.
        if ( glfwInit() != GL11.GL_TRUE )
            throw new IllegalStateException("Unable to initialize GLFW");
 
        // Configure our window
        glfwDefaultWindowHints(); // optional, the current window hints are already the default
        glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation
        glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable
 
        int WIDTH = 300;
        int HEIGHT = 300;
 
        // Create the window
        window = glfwCreateWindow(200, 200, "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, keyCallback = new GLFWKeyCallback() {
            @Override
            public void invoke(long window, int key, int scancode, int action, int mods) {
                if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
                    glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop
            }
        });
 
       
        // Center our window
        glfwSetWindowPos(
            window,
            100,
            100
        );
 
        // 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.
        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) == GL_FALSE ) {
            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();
    }
}
0

Dodałem GLFWErrorCallback i oto jaki błąd otrzymuję:
LWJGL] GLFW_API_UNAVAILABLE error
Description : WGL: The driver does not appear to support OpenGL
Stacktrace :
org.lwjgl.glfw.GLFW.nglfwCreateWindow(GLFW.java:1146)
org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:1227)
HelloWorld.init(HelloWorld.java:54)
HelloWorld.run(HelloWorld.java:22)
HelloWorld.main(HelloWorld.java:109)
Exception in thread "main" java.lang.RuntimeException: Failed to create the GLFW window
at HelloWorld.init(HelloWorld.java:56)
at HelloWorld.run(HelloWorld.java:22)
at HelloWorld.main(HelloWorld.java:109)

Niestety posiadam integrę na lapku (Intel HD Graphics). Czy to oznacza, że o aplikacjach OpenGL w javie mogę zapomnieć? W C++ nie miałem problemów i zawsze wywołania WGL zwracały odpowiedni deskryptor pikseli. Czy jest jakiś sposób aby to naprawić?

0

Nie wiem jak zrobili w LWJGL3 (bo nie doszukałem się wiki na stronie), ale w LWJGL2 można było wybierać wersję OpenGL -> http://wiki.lwjgl.org/wiki/Version_selection

Spróbuj ustawić niższą (np. 2.1).

1 użytkowników online, w tym zalogowanych: 0, gości: 1