Context creation problem from Vista service.

Hi all,

We have a problem with context creation on Vista. For the same console demo application, if we launch it via command prompt, we get the expect render context. But if we launch it via windows service, we get “GDI Generic” context. The demo app simply creates a disabled window and the render context and then prints the “glGetString(GL_RENDERER)”.

The same test on WinXP shows that we get expected render context in both the cases.

To further investigate the problem on Vista, I’ve found that the function “ChoosePixelFormat()” returns different values in the two cases, which results different render context.

So, is there a way to solve this problem or it’s a dead end?

This is our “SetDCPixelFormat()”.

	void SetDCPixelFormat()

		memset(&pixelFormat, 0, sizeof(PIXELFORMATDESCRIPTOR));
		pixelFormat.nSize			= sizeof(PIXELFORMATDESCRIPTOR);
		pixelFormat.nVersion		= 1;
		pixelFormat.iPixelType		= PFD_TYPE_RGBA;
		pixelFormat.cAlphaBits		= 8;
		pixelFormat.cColorBits		= 24;
		pixelFormat.cDepthBits		= 24;
		pixelFormat.cStencilBits	= 8;
		pixelFormat.iLayerType		= PFD_MAIN_PLANE;

		// Choose a pixel format that best matches that described in pfd		
		BOOL spfResult;
			m_nPixelFormat = ChoosePixelFormat( m_hDC, &pixelFormat );

			if( m_nPixelFormat == 0 )
				MVTESTFAILED(L"ChoosePixelFormat failed");

			spfResult = SetPixelFormat(m_hDC, m_nPixelFormat, &pixelFormat);
			MVTESTFAILED( L"SetPixelFormat failed!");


A windows service not always have access to the video screen. Without it, no acceleration as the video driver is not used.

Not sure about this, but I remind there is some check box or something to allow a service to access the screen.

Yes. There’s a check box for “Allow service to interact with desktop”. But enabling it doesn’t help in Vista.

In XP though, we can get hardware accelerated context even without enabling “Allow service to interact with desktop”.

The test’s been carried out on several cards, including [GeForce 9400 GT/PCI/SSE2], [ATI Radeon X300] and [Intel® 82G965].

Starting from Vista, services can no longer interact with the desktop, period.

The recommended solution is to spit the GUI into a different process that is launched by the service as needed.