Hello all,
I’m trying to change the background color in a GLFW generated window, but it’s not changing. I tried changing the values in glClearColor() and putting glClear() in various places, even encapsulating in a class method.
Code below is very similar to the code snippet in the GLFW docs.
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
if (!window)
{
// Window or OpenGL context creation failed
std::cout << "Error creating window!" << std::endl;
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glClearColor(1.0f, 0.2f, 0.0f, 1.0f);
while (!glfwWindowShouldClose(window))
{
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
Everything compiles and links well. I’m on Ubuntu 20.04, and when I tried a similar code on Visual Studio on Windows 10, everything worked perfectly.
I recompiled the GLFW library several times to determine if it was the problem.
I can’t draw anything because I can’t control color so I’m not sure how to go forward.