#Trying to redraw the window while its being resized

6 messages · Page 1 of 1 (latest)

smoky sleet
#

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

odd otterBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

balmy river
#

use a glfwSetWindowUserPointer to store a pointer to your Application

#

then you can get that pointer in the static function to call the member function on the instance

smoky sleet
#

!solved