I'm writing a program in which more than one window can be opened. I call the following function every frame :
Code:
void swap_buffers(void){
Window *win = G->window->first;
while (win){
wglMakeCurrent(win->hdc, win->hrc);
SwapBuffers(win->hdc);
win = win->next;
}
}
Here, Window is a self defined structure which is linked in a linked list, and contains the handles to the rendering context and the device context.
The problem is the following :
- when I have 1 window opened, my framerate is 85 fps (on average).
- when I have 2 windows opened, my framerate is 42.5 fps.
- when I have 3 windows opened, my framerate is 28.3 fps.
- when I have 4 windows opened, my framerate is 21.25 fps.
=> fps = my monitor refresh rate devided by the number of windows opened.
I suspect that the problem lies with the vertical sync which limits the pfs to (in my case) 85 fps. I don't mind having a maximum of 85 fps, but when I open 8 windows, my fps is about 10 fps which is to low. this is probably caused by calling SwapBuffers(...) more than once each frame (once for each window). But I don't know how I can solve this, because all windows have to be redrawn each frame.
Can anyone help me here ?
Thanks in advance.