void ReportDDrawSurfDesc( DDSURFACEDESC2 ddsd) { TCHAR szFlags[4096]; TCHAR szMsg[4096]; OutputDebugString(_T("*** Surface description ***\n")); SurfaceDescHelper( ddsd.dwFlags, szFlags); OutputDebugString(szFlags); wsprintf( szMsg, _T(" dwWidth x dwHeight: %ld x %ld\n"), ddsd.dwWidth, ddsd.dwHeight); OutputDebugString(szMsg); wsprintf( szMsg, _T(" lPitch: %ld\n"), ddsd.lPitch); OutputDebugString(szMsg); OutputDebugString(_T(" (dwLinearSize)\n")); wsprintf( szMsg, _T(" dwBackBufferCount: %ld\n"), ddsd.dwBackBufferCount); OutputDebugString(szMsg); wsprintf( szMsg, _T(" dwMipMapCount: %ld\n"), ddsd.dwMipMapCount); OutputDebugString(szMsg); OutputDebugString(_T(" (dwRefreshRate)")); wsprintf( szMsg, _T(" dwAlphaBitDepth: %ld\n"), (LONG)ddsd.dwAlphaBitDepth); OutputDebugString(szMsg); wsprintf( szMsg, _T(" lpSurface: %x\n"), (LONG_PTR)(ddsd.lpSurface)); OutputDebugString(szMsg); ReportPixelFormat( ddsd.ddpfPixelFormat ); ReportDDSCAPS2( ddsd.ddsCaps ); wsprintf( szMsg, _T(" dwTextureStage: %ld\n"), ddsd.dwTextureStage); OutputDebugString(szMsg); OutputDebugString(_T("***************************\n")); }
static int SetupGL(int colorbits, int depthbits, int stencilbits, int multisamples) { PIXELFORMATDESCRIPTOR pfd; int pixelformat; // create the main window Win_Init(); if (colorbits == 0) colorbits = 24; if (depthbits == 0) depthbits = colorbits > 16 ? 24 : 16; if (depthbits < 24) stencilbits = 0; // choose pixel format if (qwglChoosePixelFormatARB && multisamples > 1) { int iAttributes[20]; UINT numFormats; iAttributes[0] = WGL_DRAW_TO_WINDOW_ARB; iAttributes[1] = TRUE; iAttributes[2] = WGL_SUPPORT_OPENGL_ARB; iAttributes[3] = TRUE; iAttributes[4] = WGL_DOUBLE_BUFFER_ARB; iAttributes[5] = TRUE; iAttributes[6] = WGL_PIXEL_TYPE_ARB; iAttributes[7] = WGL_TYPE_RGBA_ARB; iAttributes[8] = WGL_COLOR_BITS_ARB; iAttributes[9] = colorbits; iAttributes[10] = WGL_DEPTH_BITS_ARB; iAttributes[11] = depthbits; iAttributes[12] = WGL_STENCIL_BITS_ARB; iAttributes[13] = stencilbits; iAttributes[14] = WGL_SAMPLE_BUFFERS_ARB; iAttributes[15] = 1; iAttributes[16] = WGL_SAMPLES_ARB; iAttributes[17] = multisamples; iAttributes[18] = 0; iAttributes[19] = 0; if (qwglChoosePixelFormatARB(win.dc, iAttributes, NULL, 1, &pixelformat, &numFormats) == FALSE) { ReportLastError("wglChoosePixelFormatARB"); goto soft; } if (numFormats == 0) { Com_EPrintf("No suitable OpenGL pixelformat found for %d multisamples\n", multisamples); goto soft; } } else { memset(&pfd, 0, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = colorbits; pfd.cDepthBits = depthbits; pfd.cStencilBits = stencilbits; pfd.iLayerType = PFD_MAIN_PLANE; if (glw.minidriver) { if ((pixelformat = qwglChoosePixelFormat(win.dc, &pfd)) == 0) { ReportLastError("wglChoosePixelFormat"); goto soft; } } else { if ((pixelformat = ChoosePixelFormat(win.dc, &pfd)) == 0) { ReportLastError("ChoosePixelFormat"); goto soft; } } } // set pixel format if (glw.minidriver) { qwglDescribePixelFormat(win.dc, pixelformat, sizeof(pfd), &pfd); ReportPixelFormat(pixelformat, &pfd); if (qwglSetPixelFormat(win.dc, pixelformat, &pfd) == FALSE) { ReportLastError("wglSetPixelFormat"); goto soft; } } else { DescribePixelFormat(win.dc, pixelformat, sizeof(pfd), &pfd); ReportPixelFormat(pixelformat, &pfd); if (SetPixelFormat(win.dc, pixelformat, &pfd) == FALSE) { ReportLastError("SetPixelFormat"); goto soft; } } // check for software emulation if (pfd.dwFlags & PFD_GENERIC_FORMAT) { if (!gl_allow_software->integer) { Com_EPrintf("No hardware OpenGL acceleration detected\n"); goto soft; } Com_WPrintf("...using software emulation\n"); } else if (pfd.dwFlags & PFD_GENERIC_ACCELERATED) { Com_DPrintf("...MCD acceleration found\n"); win.flags |= QVF_ACCELERATED; } else { Com_DPrintf("...ICD acceleration found\n"); win.flags |= QVF_ACCELERATED; } // startup the OpenGL subsystem by creating a context and making it current if ((glw.hGLRC = qwglCreateContext(win.dc)) == NULL) { ReportLastError("wglCreateContext"); goto hard; } if (qwglMakeCurrent(win.dc, glw.hGLRC) == FALSE) { ReportLastError("wglMakeCurrent"); qwglDeleteContext(glw.hGLRC); glw.hGLRC = NULL; goto hard; } return FAIL_OK; soft: // it failed, clean up Win_Shutdown(); return FAIL_SOFT; hard: Win_Shutdown(); return FAIL_HARD; }