static int GLimp_InitGL( void ) { PIXELFORMATDESCRIPTOR pfd = { sizeof( PIXELFORMATDESCRIPTOR ), // size of this pfd 1, // version number PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | // support OpenGL PFD_DOUBLEBUFFER, // double buffered PFD_TYPE_RGBA, // RGBA type 32, // 32-bit color depth 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha buffer 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored 24, // 32-bit z-buffer 0, // no stencil buffer 0, // no auxiliary buffer PFD_MAIN_PLANE, // main layer 0, // reserved 0, 0, 0 // layer masks ignored }; int pixelformat; cvar_t *stereo; stereo = Cvar_Get( "cl_stereo", "0", 0 ); pfd.cStencilBits = max( 0, r_stencilbits->integer ); if( pfd.cStencilBits != 0 ) glState.stencilEnabled = qtrue; else glState.stencilEnabled = qfalse; /* ** set PFD_STEREO if necessary */ if( stereo->integer != 0 ) { Com_Printf( "...attempting to use stereo\n" ); pfd.dwFlags |= PFD_STEREO; glState.stereoEnabled = qtrue; } else { glState.stereoEnabled = qfalse; } /* ** figure out if we're running on a minidriver or not */ if( strstr( gl_driver->string, "opengl32" ) != 0 ) glw_state.minidriver = qfalse; else glw_state.minidriver = qtrue; /* ** Get a DC for the specified window */ if( glw_state.hDC != NULL ) Com_Printf( "GLimp_Init() - non-NULL DC exists\n" ); if( ( glw_state.hDC = GetDC( glw_state.hWnd ) ) == NULL ) { Com_Printf( "GLimp_Init() - GetDC failed\n" ); return qfalse; } if( glw_state.minidriver ) { if( ( pixelformat = qwglChoosePixelFormat( glw_state.hDC, &pfd ) ) == 0 ) { Com_Printf( "GLimp_Init() - qwglChoosePixelFormat failed\n" ); return qfalse; } if( qwglSetPixelFormat( glw_state.hDC, pixelformat, &pfd ) == FALSE ) { Com_Printf( "GLimp_Init() - qwglSetPixelFormat failed\n" ); return qfalse; } qwglDescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); } else { if( ( pixelformat = ChoosePixelFormat( glw_state.hDC, &pfd ) ) == 0 ) { Com_Printf( "GLimp_Init() - ChoosePixelFormat failed\n" ); return qfalse; } if( SetPixelFormat( glw_state.hDC, pixelformat, &pfd ) == FALSE ) { Com_Printf( "GLimp_Init() - SetPixelFormat failed\n" ); return qfalse; } DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); if( !( pfd.dwFlags & PFD_GENERIC_ACCELERATED ) ) { extern cvar_t *r_allow_software; if( r_allow_software->integer ) glw_state.mcd_accelerated = qtrue; else glw_state.mcd_accelerated = qfalse; } else { glw_state.mcd_accelerated = qtrue; } } /* ** report if stereo is desired but unavailable */ if( !( pfd.dwFlags & PFD_STEREO ) && ( stereo->integer != 0 ) ) { Com_Printf( "...failed to select stereo pixel format\n" ); Cvar_SetValue( "cl_stereo", 0 ); glState.stereoEnabled = qfalse; } /* ** startup the OpenGL subsystem by creating a context and making ** it current */ if( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 ) { Com_Printf( "GLimp_Init() - qwglCreateContext failed\n" ); goto fail; } if( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) { Com_Printf( "GLimp_Init() - qwglMakeCurrent failed\n" ); goto fail; } if( !VerifyDriver() ) { Com_Printf( "GLimp_Init() - no hardware acceleration detected\n" ); goto fail; } /* ** print out PFD specifics */ Com_Printf( "GL PFD: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", ( int ) pfd.cColorBits, ( int ) pfd.cDepthBits, ( int )pfd.cStencilBits ); return qtrue; fail: if( glw_state.hGLRC ) { qwglDeleteContext( glw_state.hGLRC ); glw_state.hGLRC = NULL; } if( glw_state.hDC ) { ReleaseDC( glw_state.hWnd, glw_state.hDC ); glw_state.hDC = NULL; } return qfalse; }
qboolean GLimp_InitGL (void) { PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd 1, // version number PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | // support OpenGL PFD_DOUBLEBUFFER, // double buffered PFD_TYPE_RGBA, // RGBA type 32, // 32-bit color depth // was 24 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha buffer 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored //Knightmare 12/24/2001- stencil buffer 24, // 24-bit z-buffer, was 32 8, // 8-bit stencil buffer //end Knightmare 0, // no auxiliary buffer PFD_MAIN_PLANE, // main layer 0, // reserved 0, 0, 0 // layer masks ignored }; int pixelformat; cvar_t *stereo; stereo = Cvar_Get( "cl_stereo", "0", 0 ); /* ** set PFD_STEREO if necessary */ if ( stereo->value != 0 ) { VID_Printf( PRINT_ALL, "...attempting to use stereo\n" ); pfd.dwFlags |= PFD_STEREO; gl_state.stereo_enabled = true; } else { gl_state.stereo_enabled = false; } /* ** figure out if we're running on a minidriver or not */ if ( strstr( gl_driver->string, "opengl32" ) != 0 ) glw_state.minidriver = false; else glw_state.minidriver = true; /* ** Get a DC for the specified window */ if ( glw_state.hDC != NULL ) VID_Printf( PRINT_ALL, "GLimp_Init() - non-NULL DC exists\n" ); if ( ( glw_state.hDC = GetDC( glw_state.hWnd ) ) == NULL ) { VID_Printf( PRINT_ALL, "GLimp_Init() - GetDC failed\n" ); return false; } if ( glw_state.minidriver ) { if ( (pixelformat = qwglChoosePixelFormat( glw_state.hDC, &pfd)) == 0 ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglChoosePixelFormat failed\n"); return false; } if ( qwglSetPixelFormat( glw_state.hDC, pixelformat, &pfd) == FALSE ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglSetPixelFormat failed\n"); return false; } qwglDescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); } else { if ( ( pixelformat = ChoosePixelFormat( glw_state.hDC, &pfd)) == 0 ) { VID_Printf (PRINT_ALL, "GLimp_Init() - ChoosePixelFormat failed\n"); return false; } if ( SetPixelFormat( glw_state.hDC, pixelformat, &pfd) == FALSE ) { VID_Printf (PRINT_ALL, "GLimp_Init() - SetPixelFormat failed\n"); return false; } DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); if ( !( pfd.dwFlags & PFD_GENERIC_ACCELERATED ) ) { extern cvar_t *gl_allow_software; if ( gl_allow_software->value ) glw_state.mcd_accelerated = true; else glw_state.mcd_accelerated = false; } else { glw_state.mcd_accelerated = true; } } /* ** report if stereo is desired but unavailable */ if ( !( pfd.dwFlags & PFD_STEREO ) && ( stereo->value != 0 ) ) { VID_Printf( PRINT_ALL, "...failed to select stereo pixel format\n" ); Cvar_SetValue( "cl_stereo", 0 ); gl_state.stereo_enabled = false; } /* ** startup the OpenGL subsystem by creating a context and making ** it current */ if ( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglCreateContext failed\n"); goto fail; } if ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglMakeCurrent failed\n"); goto fail; } if ( !VerifyDriver() ) { VID_Printf( PRINT_ALL, "GLimp_Init() - no hardware acceleration detected.\nPlease install drivers provided by your video card/GPU vendor.\n" ); goto fail; } /* ** print out PFD specifics */ VID_Printf( PRINT_ALL, "PIXELFORMAT: color(%d-bits) Z(%d-bit)\n", ( int ) pfd.cColorBits, ( int ) pfd.cDepthBits ); //Knightmare- Vic's hardware gamma stuff if ( !r_ignorehwgamma->value ) { if( qwglGetDeviceGammaRamp3DFX ) { WORD newramp[3*256]; int j; gl_state.gammaRamp = qwglGetDeviceGammaRamp3DFX ( glw_state.hDC, newramp ); for( j = 0; j < 256; j++ ) { original_ramp[0][j] = newramp[j+0]; original_ramp[1][j] = newramp[j+256]; original_ramp[2][j] = newramp[j+512]; } } else { gl_state.gammaRamp = GetDeviceGammaRamp ( glw_state.hDC, original_ramp ); } } else { gl_state.gammaRamp = false; } if (gl_state.gammaRamp) vid_gamma->modified = true; // moved these to GL_SetDefaultState //gl_state.blend = false; //gl_state.alphaTest = false; //end Knightmare //Knightmare- 12/24/2001- stecil buffer { char buffer[1024]; strcpy( buffer, qglGetString( GL_RENDERER ) ); strlwr( buffer ); if (strstr(buffer, "Voodoo3")) { VID_Printf( PRINT_ALL, "... Voodoo3 has no stencil buffer\n" ); gl_config.have_stencil = false; } else { if (pfd.cStencilBits) { VID_Printf( PRINT_ALL, "... Using stencil buffer\n" ); gl_config.have_stencil = true; // Stencil shadows - MrG } } } //if (pfd.cStencilBits) // gl_config.have_stencil = true; //end Knightmare /* Moved to GL_SetDefaultState in r_glstate.c // Vertex arrays qglEnableClientState (GL_TEXTURE_COORD_ARRAY); qglEnableClientState (GL_VERTEX_ARRAY); qglEnableClientState (GL_COLOR_ARRAY); qglTexCoordPointer (2, GL_FLOAT, sizeof(texCoordArray[0][0]), texCoordArray[0][0]); qglVertexPointer (3, GL_FLOAT, sizeof(vertexArray[0]), vertexArray[0]); qglColorPointer (4, GL_FLOAT, sizeof(colorArray[0]), colorArray[0]); //gl_state.activetmu[0] = true; // end vertex arrays */ return true; fail: if ( glw_state.hGLRC ) { qwglDeleteContext( glw_state.hGLRC ); glw_state.hGLRC = NULL; } if ( glw_state.hDC ) { ReleaseDC( glw_state.hWnd, glw_state.hDC ); glw_state.hDC = NULL; } return false; }
qboolean GLimp_InitGL (void) { PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd 1, // version number PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | // support OpenGL PFD_DOUBLEBUFFER, // double buffered PFD_TYPE_RGBA, // RGBA type 32, // 32-bit color depth 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha buffer 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored 24, // 24-bit z-buffer 8, // 8bit stencil buffer // Stencil Shadows - MrG 0, // no auxiliary buffer PFD_MAIN_PLANE, // main layer 0, // reserved 0, 0, 0 // layer masks ignored }; int pixelformat; cvar_t *stereo; stereo = ri.Cvar_Get("cl_stereo", "0", 0); /* ** set PFD_STEREO if necessary */ if (stereo->value) { ri.Con_Printf(PRINT_ALL, "...attempting to use stereo.\n"); pfd.dwFlags |= PFD_STEREO; gl_state.stereo_enabled = true; } else { gl_state.stereo_enabled = false; } /* ** figure out if we're running on a minidriver or not */ if (strstr(gl_driver->string, "opengl32")) glw_state.minidriver = false; else glw_state.minidriver = true; /* ** Get a DC for the specified window */ if (glw_state.hDC != NULL) ri.Con_Printf(PRINT_ALL, "GLimp_Init() - non-NULL DC exists.\n"); if ((glw_state.hDC = GetDC(glw_state.hWnd)) == NULL) { ri.Con_Printf(PRINT_ALL, "GLimp_Init() - GetDC failed.\n"); return false; } if (glw_state.minidriver) { if ((pixelformat = qgl.wChoosePixelFormat(glw_state.hDC, &pfd)) == 0) { ri.Con_Printf(PRINT_ALL, "GLimp_Init() - qgl.wChoosePixelFormat failed.\n"); return false; } if (qgl.wSetPixelFormat(glw_state.hDC, pixelformat, &pfd) == FALSE) { ri.Con_Printf(PRINT_ALL, "GLimp_Init() - qgl.wSetPixelFormat failed.\n"); return false; } qgl.wDescribePixelFormat(glw_state.hDC, pixelformat, sizeof(pfd), &pfd); } else { if ((pixelformat = ChoosePixelFormat(glw_state.hDC, &pfd)) == 0) { ri.Con_Printf (PRINT_ALL, "GLimp_Init() - ChoosePixelFormat failed.\n"); return false; } if (SetPixelFormat(glw_state.hDC, pixelformat, &pfd) == FALSE) { ri.Con_Printf (PRINT_ALL, "GLimp_Init() - SetPixelFormat failed.\n"); return false; } DescribePixelFormat(glw_state.hDC, pixelformat, sizeof(pfd), &pfd); // PFD_GENERIC_FORMAT only = software // PFD_GENERIC_ACCELERATED only = MCD accelerated // Neither PFD_GENERIC_ACCELERATED nor PFD_GENERIC_FORMAT = ICD accelerated // I imagine PFD_SUPPORT_OPENGL must be true, otherwise we're screwed. if ((!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) && (pfd.dwFlags & PFD_GENERIC_FORMAT)) || !(pfd.dwFlags & PFD_SUPPORT_OPENGL)) { int mb; extern cvar_t *gl_allow_software; static int prompted = 0; // Only pop this up once, otherwise it will hit on the retry. if (!prompted) { prompted = 1; mb = MessageBox(NULL, "You do not have graphic drivers installed that support hardware accelerated OpenGL. Would you like to load a web page that will help you find appropriate drivers?", "Paintball 2 - No Drivers", MB_YESNO | MB_ICONEXCLAMATION); if (mb == IDYES) { ShellExecute(NULL, "open", "http://www.digitalpaint.org/drivers/", NULL, NULL, SW_SHOWNORMAL); } } if (gl_allow_software->value) glw_state.mcd_accelerated = true; else glw_state.mcd_accelerated = false; } else { glw_state.mcd_accelerated = true; } } /* ** report if stereo is desired but unavailable */ if (!(pfd.dwFlags & PFD_STEREO) && (stereo->value != 0)) { ri.Con_Printf(PRINT_ALL, "...failed to select stereo pixel format.\n"); ri.Cvar_SetValue("cl_stereo", 0); gl_state.stereo_enabled = false; } /* ** startup the OpenGL subsystem by creating a context and making ** it current */ if ((glw_state.hGLRC = qgl.wCreateContext(glw_state.hDC)) == 0) { ri.Con_Printf (PRINT_ALL, "GLimp_Init() - qgl.wCreateContext failed.\n"); goto fail; } if (!qgl.wMakeCurrent(glw_state.hDC, glw_state.hGLRC)) { ri.Con_Printf (PRINT_ALL, "GLimp_Init() - qgl.wMakeCurrent failed.\n"); goto fail; } if (!VerifyDriver()) { ri.Con_Printf(PRINT_ALL, "GLimp_Init() - no hardware acceleration detected.\n"); goto fail; } /* ** print out PFD specifics */ ri.Con_Printf(PRINT_ALL, "GL PFD: Color(%dbits) Depth(%dbits) Stencil(%dbits)\n", (int)pfd.cColorBits, (int)pfd.cDepthBits, (int)pfd.cStencilBits); { char buffer[1024]; strcpy( buffer, qgl.GetString(GL_RENDERER)); if (!((int)pfd.cStencilBits)) // jit { if (gl_debug->value) ri.Con_Printf(PRINT_ALL, "... No stencil buffer.\n"); have_stencil = false; } else { if (pfd.cStencilBits) { if (gl_debug->value) ri.Con_Printf(PRINT_ALL, "... Using stencil buffer.\n"); have_stencil = true; // Stencil shadows - MrG } } } //jitrscript - moved RS_ScanPathForScripts(ri.FS_Gamedir()); // load all found scripts // Vertex arrays /*qgl.EnableClientState (GL_VERTEX_ARRAY); qgl.EnableClientState (GL_TEXTURE_COORD_ARRAY); qgl.TexCoordPointer (2, GL_FLOAT, sizeof(tex_array[0]), tex_array[0]); qgl.VertexPointer (3, GL_FLOAT, sizeof(vert_array[0]), vert_array[0]); qgl.ColorPointer (4, GL_FLOAT, sizeof(col_array[0]), col_array[0]);*/ /* ZeroMemory(original_ramp,sizeof(original_ramp)); gl_state.gammaramp = GetDeviceGammaRamp(glw_state.hDC,original_ramp); */ gl_state.gammaramp = GetDeviceGammaRamp(glw_state.hDC,original_ramp); //jitgamma if (!vid_gamma_hw->value) // gl_state.gammaramp = false; if (gl_state.gammaramp && vid_gamma_hw->value) // jitgamma vid_gamma->modified = true; return true; fail: if ( glw_state.hGLRC ) { qgl.wDeleteContext( glw_state.hGLRC ); glw_state.hGLRC = NULL; } if ( glw_state.hDC ) { ReleaseDC( glw_state.hWnd, glw_state.hDC ); glw_state.hDC = NULL; } return false; }
qboolean GLimp_InitGL (void) { PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd 1, // version number PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | // support OpenGL PFD_DOUBLEBUFFER, // double buffered PFD_TYPE_RGBA, // RGBA type 24, // 24-bit color depth 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha buffer 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored 24, // 32-bit z-buffer 8, // no stencil buffer 0, // no auxiliary buffer PFD_MAIN_PLANE, // main layer 0, // reserved 0, 0, 0 // layer masks ignored }; int pixelformat; cvar_t *stereo; stereo = Cvar_Get( "cl_stereo", "0", 0 ); /* ** set PFD_STEREO if necessary */ if (stereo->integer) { Com_Printf ( "...attempting to use stereo\n" ); pfd.dwFlags |= PFD_STEREO; gl_state.stereo_enabled = true; } else { gl_state.stereo_enabled = false; } /* ** figure out if we're running on a minidriver or not */ if (Q_stristr( gl_driver->string, "opengl32" ) != 0 ) glw_state.minidriver = false; else glw_state.minidriver = true; /* ** Get a DC for the specified window */ if ( glw_state.hDC != NULL ) Com_Printf ( "GLimp_Init() - non-NULL DC exists\n" ); if ( ( glw_state.hDC = GetDC( glw_state.hWnd ) ) == NULL ) { PrintWinError("GLimp_Init() - GetDC", false); return false; } if ( glw_state.minidriver ) { if ( (pixelformat = qwglChoosePixelFormat( glw_state.hDC, &pfd)) == 0 ) { PrintWinError("GLimp_Init() - wglChoosePixelFormat", false); return false; } if ( qwglSetPixelFormat( glw_state.hDC, pixelformat, &pfd) == FALSE ) { PrintWinError("GLimp_Init() - wglSetPixelFormat", false); return false; } qwglDescribePixelFormat(glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); } else { if ((pixelformat = ChoosePixelFormat(glw_state.hDC, &pfd)) == 0) { PrintWinError("GLimp_Init() - ChoosePixelFormat", false); return false; } if (SetPixelFormat( glw_state.hDC, pixelformat, &pfd) == FALSE) { PrintWinError("GLimp_Init() - SetPixelFormat", false); return false; } DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); if ( !( pfd.dwFlags & PFD_GENERIC_ACCELERATED ) ) { extern cvar_t *gl_allow_software; if ( gl_allow_software->integer ) glw_state.mcd_accelerated = true; else glw_state.mcd_accelerated = false; } else { glw_state.mcd_accelerated = true; } } /* ** report if stereo is desired but unavailable */ if ( !( pfd.dwFlags & PFD_STEREO ) && ( stereo->value != 0 ) ) { Com_Printf("...failed to select stereo pixel format\n"); Cvar_Set("cl_stereo", "0"); gl_state.stereo_enabled = false; } /* ** startup the OpenGL subsystem by creating a context and making ** it current */ if ((glw_state.hGLRC = qwglCreateContext(glw_state.hDC)) == 0) { PrintWinError("GLimp_Init() - wglCreateContext", false); return false; } if (!qwglMakeCurrent(glw_state.hDC, glw_state.hGLRC)) { PrintWinError("GLimp_Init() - wglMakeCurrent", false); return false; } if (!VerifyDriver()) { Com_Error(ERR_FATAL, "GLimp_Init() - no hardware acceleration detected"); return false; } /* ** print out PFD specifics */ Com_Printf("GL PFD: Color(%dbits) Depth(%dbits) Stencil(%dbits)\n", (int)pfd.cColorBits, (int)pfd.cDepthBits, (int)pfd.cStencilBits); { char buffer[1024]; Q_strncpyz( buffer, (const char *)qglGetString( GL_RENDERER ), sizeof(buffer)); Q_strlwr( buffer ); gl_state.stencil = false; if (strstr(buffer, "voodoo3")) { Com_Printf("... Voodoo3 has no stencil buffer\n"); } else { if (pfd.cStencilBits > 0) { Com_Printf("... Using stencil buffer\n"); gl_state.stencil = true; // Stencil shadows -MrG } } } return true; }