无法创建 GLFW window?

Failed to create GLFW window?

我试图用最简单的代码创建一个 window:

#include <stdio.h>
#include <stdlib.h>

#include <GL/glew.h> // Always include it before glfw.h
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>

int main(void) {
    glfwInit();
    glfwWindowHint(GLFW_VERSION_MAJOR, 3); // OpenGL 3.3
    glfwWindowHint(GLFW_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); // Mac

    GLFWwindow* window = glfwCreateWindow(720, 480, "OpenGL", NULL, NULL); // Create a window

    if (window == NULL) {
        fprintf(stderr, "Failed to create window\n");
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);

    return 0;
} 

这是我的 Makefile:

game:
    g++ src/main.cpp -std=c++17 -o play -I include -L lib -l glfw.3 -l GLEW.2.2

当我编译我的代码时没有错误,但是当我尝试播放我的代码时出现这个错误:

Failed to create window
Invalid window hint 0x00000003
Invalid window hint 0x00000003
Context profiles are only defined for OpenGL version 3.2 and above

有人可以帮助我吗?我不知道为什么我的 window 不想创建...

GLFW_VERSION_MAJOR & GLFW_VERSION_MINOR 不是 glfwWindowHint:

的有效参数
glfwWindowHint(GLFW_VERSION_MAJOR, 3); // OpenGL 3.3
               ^^^^^^^^^^^^^^^^^^ nope
glfwWindowHint(GLFW_VERSION_MINOR, 3);
               ^^^^^^^^^^^^^^^^^^ also nope

改用 GLFW_CONTEXT_VERSION_MAJOR & GLFW_CONTEXT_VERSION_MINOR

根据 the docs,强调我的:

GLFW_CONTEXT_VERSION_MAJOR and GLFW_CONTEXT_VERSION_MINOR specify the client API version that the created context must be compatible with. The exact behavior of these hints depend on the requested client API.

Note: Do not confuse these hints with GLFW_VERSION_MAJOR and GLFW_VERSION_MINOR, which provide the API version of the GLFW header.