im new to c++ and opengl, and im trying to update the window content while its being resized but I cant call the draw function (a member function) from a static function.
this is the code im talking about
class Application {
public:
Application(int width, int height);
void run();
private:
int WIDTH;
int HEIGHT;
GLFWwindow* window;
void init();
void draw();
static void framebuffer_size_callback(GLFWwindow* window, int width, int height);
};
void Application::init() {
//...
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
}
void Application::draw() {
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
}
void Application::framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
draw();
}
and here's the full code:
https://pastebin.com/2gJiSHCw
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.