Hi All,
Just want to ask if anyone else has had this happen… Most people would of course be creating their GL context and thats it for the run of the program, however I’m writing a 3D editor with 4 viewports, separated by splitter windows… MFC doc/view architecture.
Anyway, its been working like a dream for over 2 years with this method:
-Create GL context on a HDC from CMainFrame
-When a CView OnDraw is called I would call: wglMakeCurrent(pDC->GetSafeHdc(), hGLRC) then do all my GL drawing. NOTE: I’m not changing my GL context, because I only have one. I’m changing the DC the context will draw to.
This ran fine with everything I threw at it, pixel shaders, stencil shadowing, AA, AF etc.
Now I added FBO support, and suddenly I’m getting this happening:
-I have 2 FBO’s, one unique texture to each as a color buffer.
-I draw the scene into a texture (copytexsubimage2d).
-draw into FBO1, reading the scene texture
loop
{
-draw into FBO2, reading FBO1’s color buffer
-draw into FBO1, reading FBO2’s color buffer
}
-Draw to window system framebuffer (0), from FBO1’s color buffer.
If I run the above loop more then once, every 10 frames I’ll get a ONE SECOND pause (as timed by QueryPerformanceCounter) when calling;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FrameBuffers[fb]);
!!!
In between (the other 9 frames) it’ll run as you’d expect with however many of the above loops I’m calling. NOTE: I dont get ANY GL errors, or FBO errors.
I’ve finally narrowed it down to wglMakeCurrent. If I only call it once and keep drawing to that same HDC with my GLRC, the slowdown doesnt happen.
The moment wglMakeCurrent is called however, it’ll have the pausing happen from then on, no matter what else changes.
I’m using a Geforce 6800GT, and this happens on 77.x and 78.01 drivers.
So to me it looks like theres something either wrong in nvidias drivers, or theres some limitation theyre not telling us about when it comes to context switches. The EXT_framebuffer_object spec doesnt mention anything like this causing a problem…
Oh, and wglMakeCurrent’s documentation (MSDN) says you can switch between DC’s as long as they point to the same device, which mine do, theyre all windows drawn on the same desktop… and I’m not changing RC’s, only the DC I’m drawing to.
Anyone? Anyone? Bueller? Bueller?