1 Pluspunkt 0 Minuspunkte

Ich habe dieses Codebeispiel mit GLFW

#include <iostream>
#include <GLFW/glfw3.h>

int main(void){

    GLFWwindow* window;

    if(!glfwInit()){
        std::cout << "Failed to initialize GLFW!" << std::endl;
        return -1;
    }

    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if(!window){
        glfwTerminate();
        std:: cout << "Failed to initialize Window!" << std::endl;
        return -1;
    }

    glfwMakeContextCurrent(window);

    while(!glfwWindowShouldClose(window)){
        glClear(GL_COLOR_BUFFER_BIT);

        glfwSwapBuffers(window);

        glfwPollEvents();
    }
    glfwTerminate();
    return 0;
}

aber bekomme mein build eine Fehlermeldung.

Wayland: Failed to connect to display
The GLFW library is not initialized
main: ./src/posix_thread.c:64: _glfwPlatformGetTls: Assertion `tls->posix.allocated == GLFW_TRUE' failed.
Aborted (core dumped)

Wie kann ich GLFW richtig initialisieren?

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Setze die Zeile

GLFWwindow* window;

unter die Initialisierung.

if(!glfwInit()){
    std::cout << "Failed to initialize GLFW!" << std::endl;
    return -1;
}

GLFWwindow* window;

von (532 Punkte)