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?