• Advertisement
Sign in to follow this  

Windows message queue gets flooded when rendering

Recommended Posts

I encapsulated the the Windows API's CreateWindow around a class I call GLWindow, to which I render images using OpenGL. It took me some time, I even encapsulated the message queue, so basically my main function looks like that:

int main()
{
    GLWindow win;
    win.create("OpenGL Window", false, 1600, 800, -1, -1, true);
    win.hideCursor();
    win.moveMouseToCenter();

    init(); //initialize some opengl stuff

    bool quit = false;
    WindowEvent ev;

    while (!quit) {
        if (win.pollEvent(ev))
        {
            if (ev.type == ev.WindowClosed || (ev.type == ev.KeyboardKeyPressed && ev.keyboardKey.key == Keyboard::Key::Escape))
                quit = true;
            else
                handleEvent(ev);
        }

        updateCamera(&win);

        render(&win);
    }

    return 0;
}
The render() function obviously takes the most time, and it causes the window procedure function to get flooded with messages, which eventually creates a delay in the WM_KEYDOWN and WM_MOUSEMOVE messages and because of that the camera update is delayed as well. (inside updateCamera())
 
Any idea what can I do?

Share this post


Link to post
Share on other sites
Advertisement

:lol:  :lol:  :lol:

Silly me. Thanks!

 

Don't feel too bad; I've seen a lot of people doing that who should definitely have known better.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement