wglMakeCurrent issues

I am currently using two rendering contexts in the same thread to draw to two different OpenGL windows. I am using wglMakeCurrent to switch between the two each time it’s time to draw to each window. On my personal machine I haven’t seen any speed issues, but on other machines (they have been WinXP SP3 usually with OpenGL 3.X.X) I have seen where the OpenGL graphics slow down, which in turn slows down the entire application since all the OpenGL drawing is done in the main GUI thread. I put some logging in and narrowed it down to the wglMakeCurrent call. When things are working fine, the function call takes less then 0.1 milliseconds. When the problem happens, the function call takes anywhere from 30ms to 100ms. I am trying to draw OpenGL stuff every 30ms or so and my draw function takes less than a few milliseconds except for this wglMakeCurrent call.

Any ideas why wglMakeCurrent may be taking so long?

Thanks.

Context switching is a heavy operation. Can you give more details about the two computers you’ve tested on it? Maybe some code may help as well
Even though context switching is heavy-weight I don’t see why it should take that long.

are you swapping buffers after you are done drawing the window ? If so your speed issues are there. With double buffered windows you are essentially limited to RefreshRate/NumberOfWindows.

So 60hz/4 windows = 15fps max.

You could either disable vsync, or use swap groups if you have a quadro card :slight_smile: