/** \brief The OglSdlSurface function \param w width \param h height \param isFullscreen if true, go fullscreen \return if true, changed video mode */ boolean OglSdlSurface(INT32 w, INT32 h) { INT32 cbpp; const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL; cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value; glvendor = pglGetString(GL_VENDOR); // Get info and extensions. //BP: why don't we make it earlier ? //Hurdler: we cannot do that before intialising gl context glrenderer = pglGetString(GL_RENDERER); glversion = pglGetString(GL_VERSION); gl_extensions = pglGetString(GL_EXTENSIONS); DBG_Printf("Vendor : %s\n", glvendor); DBG_Printf("Renderer : %s\n", glrenderer); DBG_Printf("Version : %s\n", glversion); DBG_Printf("Extensions : %s\n", gl_extensions); oglflags = 0; if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions)) pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy); else maximumAnisotropy = 1; SetupGLFunc13(); granisotropicmode_cons_t[1].value = maximumAnisotropy; SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); SetModelView(w, h); SetStates(); pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); HWR_Startup(); textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1; return true; }
// ======================================================================== // Sets a video mode // ======================================================================== INT32 VID_SetMode(INT32 modenum) { int vstat; vmode_t *pnewmode; if (dedicated) return 0; DEBPRINT(va("VID_SetMode(%d)\n", modenum)); // if mode 0 (windowed) we must not be fullscreen already, // if other mode, check it is not mode 0 and existing if ((modenum >= NUMSPECIALMODES) || bAppFullScreen) { if (modenum > numvidmodes || modenum < NUMSPECIALMODES) { if (!pcurrentmode) modenum = 0; // revert to the default base vid mode else I_Error("Unknown video mode: %d\n", modenum); } } pnewmode = VID_GetModePtr(modenum); // dont switch to the same display mode if (pnewmode == pcurrentmode) return 1; // initialize the new mode pcurrentmode = pnewmode; // initialize vidbuffer size for setmode vid.width = pcurrentmode->width; vid.height = pcurrentmode->height; vid.rowbytes = pcurrentmode->rowbytes; vid.bpp = pcurrentmode->bytesperpixel; if (modenum) // if not 320x200 windowed mode, it's actually a hack { if (rendermode == render_opengl) { // don't accept depth < 16 for OpenGL mode (too much ugly) if (cv_scr_depth.value < 16) CV_SetValue(&cv_scr_depth, 16); vid.bpp = cv_scr_depth.value/8; vid.u.windowed = (bWinParm || !cv_fullscreen.value); pcurrentmode->bytesperpixel = vid.bpp; pcurrentmode->windowed = vid.u.windowed; } } vstat = (*pcurrentmode->setmode)(&vid, pcurrentmode); if (vstat == -1) I_Error("Not enough mem for VID_SetMode\n"); else if (vstat == -2) I_Error("Couldn't set video mode because it failed the test\n"); else if (vstat == -3) I_Error("Couldn't set video mode because it failed the change?\n"); else if (!vstat) I_Error("Couldn't set video mode %d (%dx%d %d bits)\n", modenum, vid.width, vid.height, (vid.bpp*8));// hardware could not setup mode else CONS_Printf(M_GetText("Mode changed to %d (%s)\n"), modenum, pcurrentmode->name); vid.modenum = modenum; // tell game engine to recalc all tables and realloc buffers based on new values vid.recalc = 1; if (modenum < NUMSPECIALMODES) { // we are in startup windowed mode bAppFullScreen = FALSE; bDIBMode = TRUE; } else { // we switch to fullscreen bAppFullScreen = TRUE; bDIBMode = FALSE; #ifdef HWRENDER if (rendermode != render_soft) { // purge all patch graphics stored in software format //Z_FreeTags (PU_PURGELEVEL, PU_PURGELEVEL+100); HWR_Startup(); } #endif } I_RestartSysMouse(); return 1; }
/** \brief The OglSdlSurface function \param w width \param h height \param isFullscreen if true, go fullscreen \return if true, changed video mode */ boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen) { INT32 cbpp; Uint32 OGLFlags; const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL; cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value; if (vidSurface) { //Alam: SDL_Video system free vidSurface for me #ifdef VOODOOSAFESWITCHING SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_InitSubSystem(SDL_INIT_VIDEO); #endif } if (isFullscreen) OGLFlags = FOGLFlags; else OGLFlags = WOGLFlags; cbpp = SDL_VideoModeOK(w, h, cbpp, OGLFlags); if (cbpp < 16) return true; //Alam: Let just say we did, ok? vidSurface = SDL_SetVideoMode(w, h, cbpp, OGLFlags); if (!vidSurface) return false; glvendor = pglGetString(GL_VENDOR); // Get info and extensions. //BP: why don't we make it earlier ? //Hurdler: we cannot do that before intialising gl context glrenderer = pglGetString(GL_RENDERER); glversion = pglGetString(GL_VERSION); gl_extensions = pglGetString(GL_EXTENSIONS); DBG_Printf("Vendor : %s\n", glvendor); DBG_Printf("Renderer : %s\n", glrenderer); DBG_Printf("Version : %s\n", glversion); DBG_Printf("Extensions : %s\n", gl_extensions); oglflags = 0; #ifdef _WIN32 // BP: disable advenced feature that don't work on somes hardware // Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04 if (strstr(glrenderer, "810")) oglflags |= GLF_NOZBUFREAD; #elif defined (unix) || defined (UNIXCOMMON) // disable advanced features not working on somes hardware if (strstr(glrenderer, "G200")) oglflags |= GLF_NOTEXENV; if (strstr(glrenderer, "G400")) oglflags |= GLF_NOTEXENV; #endif DBG_Printf("oglflags : 0x%X\n", oglflags ); #ifdef USE_PALETTED_TEXTURE if (isExtAvailable("GL_EXT_paletted_texture", gl_extensions)) glColorTableEXT = SDL_GL_GetProcAddress("glColorTableEXT"); else glColorTableEXT = NULL; #endif #ifdef USE_WGL_SWAP if (isExtAvailable("WGL_EXT_swap_control", gl_extensions)) wglSwapIntervalEXT = SDL_GL_GetProcAddress("wglSwapIntervalEXT"); else wglSwapIntervalEXT = NULL; #else if (isExtAvailable("GLX_SGI_swap_control", gl_extensions)) glXSwapIntervalSGIEXT = SDL_GL_GetProcAddress("glXSwapIntervalSGI"); else glXSwapIntervalSGIEXT = NULL; #endif #ifndef KOS_GL_COMPATIBILITY if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions)) pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy); else #endif maximumAnisotropy = 0; granisotropicmode_cons_t[1].value = maximumAnisotropy; SetModelView(w, h); SetStates(); pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); HWR_Startup(); #ifdef KOS_GL_COMPATIBILITY textureformatGL = GL_ARGB4444; #else textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1; #endif return true; }