0

I can't seem to get GLFWInit's function working, I keep getting the "X11: The DISPLAY environment variable is missing" error.

I've tried export DISPLAY=<my_ip>:0.0 I've tried export DISPLAY=localhost:0.0 I've tried export DISPLAY=:0

Basically everything on these stackoverflow articles:

glfwInit fails inside library X11: The DISPLAY environment variable is missing

Visual Studio - X11: The DISPLAY environment variable is missing

I'm on linux, Manjaro GNOME, I have my GPU drivers installed.

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

GLFWwindow* window;

int canvas(size_t width, size_t height) {
    auto init_val = glfwInit();
    auto ptr = "";
    glfwGetError(&ptr);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    window = glfwCreateWindow(width, height, "Canvas", nullptr, nullptr);
    if (!window) {
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(window);
    return 0;
}

int main() {
    canvas(300, 500);
    // while (!glfwWindowShouldClose(window)) {
    //     glfwSwapBuffers(window);
    //     glfwPollEvents();
    // }
    std::cout << window << std::endl;
    std::cout << "Hello World!" << std::endl;
}

Expected output is a window to show up briefly, but instead ptr becomes an error string and window is a nullptr.

genpfault
  • 51,148
  • 11
  • 85
  • 139
JohnkaS
  • 622
  • 8
  • 18

0 Answers0