View Full Version : Rendering with 2 contexts killing the fps

12-30-2008, 01:38 PM

I want to use openGL to render on 2 different windows. To achieve this, I made 2 context, and swap between each of them thanks to the wlgMakeCurrent function. This happens to take my fps from capped at Vsync to around 35.

The first window is 800*600, the second is 600*200. Full scene is computed on the big window, the second only renders one triangle.

Based on this, it seems to me that I am doing something wrong, rather than having openGL take that much more ressources to perform on 2 separate windows.

Code runs on windows xp 32 bits btw.

Any inputs are welcomed

12-30-2008, 02:27 PM
I don't see really a problem here, do you need to display the 2nd window? If not you can create a fbo instead and use only one window, thus one RC.

12-30-2008, 02:47 PM
Yes I need both the windows to be displayed and rendering.

This I have done, my problem is how performing this reduces dramatically the fps, even when the second context runs on a small window, with a very simple scene. Matter of fact, just running the second window and only clearing its background already has a huge impact on the performances.

hDC = GetDC(WinWnd);
PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, PixelFormat, &pfd);
hRC = wglCreateContext(hDC);

This is the code used to create a context. Each window has its own handle, hDC and hRC.

12-30-2008, 06:16 PM
well if you've got vsync on then the first contexts swapbuffers will wait for the monitor vsync before returning, then you draw using the second context and swap, which also waits. This means that each window is being drawn every other monitor refresh. So I can sort of deduce that you must be running your desktop at about 70hz refresh rate.

BTW, this problem has been discussed here:-

12-31-2008, 03:02 AM
Indeed, knackered, that is the problem. Both the contexts were running in double buffered mode, as soon as I ran one in single mode, problem was fixed.

Thanks for the explanation and the link.

01-05-2009, 08:18 AM
if you got a quadro card you can use the

Otherwise for consumer cards you are probably [censored] out of luck.
(unless you disable vsync)

01-05-2009, 10:51 AM
last time i tried to use swapgroups on winxp with a quadro card, but without a gsync card, it would lock up the machine forcing a hard restart. Maybe they've fixed the problem now, but it scared me off using it unless i was syncing between machines. I think it will be a while before nvidia become as good as 3dlabs with this sort of thing.

01-12-2009, 11:35 PM
Another solution would be to use two rendering threads instead of one.
Because they would be running in parallel (and using independend GL contexts), they won't wait on each other's vsync, resulting in full fps for each window.