Off-screen context creation

Just getting back into the world of GPGPU and I find that an NVIDIA driver update has broken my terribly fragile context creation code. It had to break in the end, I guess, so I should get round to doing it properly now. :smiley:

My previous approach went something along these lines:

	// Create the hidden window.
	_window = CreateWindow("GLOffWindow", "GLOffWindow",
          0, 0, 0, 0, NULL, NULL, hinstance, NULL);

	// Obtain the device context from the hidden window.
	_windowDC = GetDC(_window);

	// Set up an off-screen pixel format.
	  PFD_TYPE_RGBA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	  PFD_MAIN_PLANE, 0, 0, 0, 0
	int pixelformat = ChoosePixelFormat(_windowDC, &pfd);
	SetPixelFormat(_windowDC, pixelformat, &pfd);

	// Create an OpenGL context with the window.
	_windowRC = wglCreateContext(_windowDC);

	// Associate the OpenGL context with this thread.
	wglMakeCurrent(_windowDC, _windowRC);

This now causes a horrible full-screen flicker on exit, and things are running slower than they should be (but perhaps something else has broken in that respect).

Is there a proper way to create an off-screen OpenGL context, or is the only approach (with true acceleration; i.e. so I can get handles on the FBO extension pointers) to create a visible window and live with it?

Many thanks for any input. :smiley:

If you create a visible window, even if just a tiny one, do you get the full-screen flicker at exit too? If you do, I don’t have any ideas. If not, perhaps one or both of the following could work:

Could OWNDC help?

Could you create a (1x1) visible, but TRANSPARENT window, grab the DC from that, and then hide the window (to not get e.g. mousemove’s or even unintentionally swallowing a mouseclick)?

I always create a 100x100 window, but I never show it. Never had problems with that

Yes, if I create a visible window the same problem occurs. I’m using CS_OWNDC in the class creation.

The problem seems to stem from the ChoosePixelFormat() call. If I cease execution before this point then I get no flicker on exit; but making this call (and not even SetPixelFormat()) induces the flicker.

I gave this a shot on my GeForce Go 6800 Ultra laptop, with 77.24 drivers and the problem doesn’t arise. I wonder if it’s worth trying a reinstall… :confused:


I have a Geforce 6800 (FW 84.21, Win32 XP SP2) and I experience a strange flicker on app exit, as well. I didn’t have this experience pre-84.21, for what it’s worth. In fact, the flicker seems to occur when any OpenGL application terminates, including GLinfo and Google Earth, for instance. Although, in my case, the operation of all apps seems to be perfectly normal, flickering exit aside.


I have too report strange PBuffer slowdown on 6600GT and 7600GT after switching to forceware 84.xx in my application for processing motion capture data.

I already switch to FBO, but im afraid of comptibility with other applications that use pbuffers.

I’m happy to report that the flicker is gone with the FW 91.28 Beta. (I also noticed a substantially improved compile/link time with a particular GLSL shader of mine. Nice new control panel, too.)


Just to follow this up, I’ve since upgraded my entire system to an Asus A8N-E mobo and GeForce 7900 GTX.

The flicker has gone, with 84.21 drivers. Ah well. :slight_smile: