glClearColor 被忽略

glClearColor is ignored

我试图将背景颜色设置为蓝色,但 glClearColor 被完全忽略了。
代码:

glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(640, 480, "3D Shooter", NULL, NULL);
glClearColor(0.5f, 0.5f, 1.0f, 1.0f);
while (!glfwWindowShouldClose(window)) {
    glClear(GL_COLOR_BUFFER_BIT);
    glfwSwapBuffers(window);
    glfwPollEvents();
}

你好像少了一个

glfwMakeContextCurrent(window);

https://www.glfw.org/docs/3.3/quick.html