+GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
+ unsigned char layer_type )
+{
+#if defined(_WIN32_WCE)
+ return GL_TRUE;
+#else
+ PIXELFORMATDESCRIPTOR pfd;
+ PIXELFORMATDESCRIPTOR* ppfd = &pfd;
+ int pixelformat;
+
+ fghFillPFD( ppfd, window->Window.Device, layer_type );
+ pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
+
+ /* windows hack for multismapling/sRGB */
+ if ( ( fgState.DisplayMode & GLUT_MULTISAMPLE ) ||
+ ( fgState.DisplayMode & GLUT_SRGB ) )
+ {
+ HGLRC rc, rc_before=wglGetCurrentContext();
+ HWND hWnd;
+ HDC hDC, hDC_before=wglGetCurrentDC();
+ WNDCLASS wndCls;
+
+ /* create a dummy window */
+ ZeroMemory(&wndCls, sizeof(wndCls));
+ wndCls.lpfnWndProc = DefWindowProc;
+ wndCls.hInstance = fgDisplay.Instance;
+ wndCls.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
+ wndCls.lpszClassName = _T("FREEGLUT_dummy");
+ RegisterClass( &wndCls );
+
+ hWnd=CreateWindow(_T("FREEGLUT_dummy"), _T(""), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW , 0,0,0,0, 0, 0, fgDisplay.Instance, 0 );
+ hDC=GetDC(hWnd);
+ SetPixelFormat( hDC, pixelformat, ppfd );
+
+ rc = wglCreateContext( hDC );
+ wglMakeCurrent(hDC, rc);
+
+ if ( fghIsExtensionSupported( hDC, "WGL_ARB_multisample" ) )
+ {
+ PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARBProc =
+ (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress("wglChoosePixelFormatARB");
+ if ( wglChoosePixelFormatARBProc )
+ {
+ int attributes[100];
+ int iPixelFormat;
+ BOOL bValid;
+ float fAttributes[] = { 0, 0 };
+ UINT numFormats;
+ fghFillPixelFormatAttributes( attributes, ppfd );
+ bValid = wglChoosePixelFormatARBProc(window->Window.Device, attributes, fAttributes, 1, &iPixelFormat, &numFormats);
+
+ if ( bValid && numFormats > 0 )
+ {
+ pixelformat = iPixelFormat;
+ }
+ }
+ }
+
+ wglMakeCurrent( hDC_before, rc_before);
+ wglDeleteContext(rc);
+ ReleaseDC(hWnd, hDC);
+ DestroyWindow(hWnd);
+ UnregisterClass(_T("FREEGLUT_dummy"), fgDisplay.Instance);
+ }
+
+ return ( pixelformat != 0 ) && ( checkOnly || SetPixelFormat( window->Window.Device, pixelformat, ppfd ) );
+#endif /* defined(_WIN32_WCE) */
+}
+
+#endif /* TARGET_HOST_MS_WINDOWS */
+