I have the following code:
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#define GLFW_INCLUDE_NONE
#include <stdio.h>
#include <stdlib.h>
static void error_callback(int error, const char *description)
{
printf("Error: %s\n", description);
}
int main()
{
glfwInit();
glfwSetErrorCallback(error_callback);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
GLFWwindow *window = glfwCreateWindow(800, 600, "Learn OpenGL", NULL, NULL);
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
printf("Failed to initialize GLAD. Fatal error.\n");
return -1;
}
glfwSwapInterval(1);
while (!glfwWindowShouldClose(window))
{
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
glClearColor(0.0f, 0.5f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
When the code is set the way it is above, with GLFW_CONTEXT_VERSION set to 2.0, it works pretty well. When I resize the window, as soon as I stop resizing, it renders the new portion. However, when I set the version to 3.3 (which is the version I want to use) it lags a bit in spreading the blue across the whole window (even after I have stopped resizing it), as can be seen here: (I'm running Windows by the way)
This does not happen when the version is 2.0. Why is this, and how can I get it so it renders in 3.3 as well as it does in 2.0?
When I set GLFW_OPENGL_PROFILE
to GLFW_OPENGL_COMPAT_PROFILE
it works in 3.3 just like in 2.0 but on GLFW_OPENGL_CORE_PROFILE
(which is what I want to use) it doesn't. How do I fix it so it works in CORE_PROFILE
?
(I suspect GLFW is using some sort of deprecated function... I don't know. I'm using glfw3, so shouldn't it not have any deprecated functions though?)
Here is what worked for me. I have an Intel UHD Graphics 620 GPU, and I updated my driver, and now it works.
Old driver version was 24.something, new driver version is 30.0.101.1660.