/* ** GLimp_SetMode */ rserr_t GLimp_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullscreen, bool stereo, bool borderless ) { const char *win_fs[] = { "W", "FS" }; ri.Com_Printf( "Setting video mode:" ); // disable fullscreen if rendering to a parent window if( glw_state.parenthWnd ) { RECT parentWindowRect; fullscreen = false; GetWindowRect( glw_state.parenthWnd, &parentWindowRect ); width = parentWindowRect.right - parentWindowRect.left; height = parentWindowRect.bottom - parentWindowRect.top; } ri.Com_Printf( " %d %d %s\n", width, height, win_fs[fullscreen] ); // destroy the existing window if( glw_state.hWnd ) { GLimp_Shutdown(); } glw_state.win_x = x; glw_state.win_y = y; glConfig.width = width; glConfig.height = height; glConfig.fullScreen = ( fullscreen ? GLimp_SetFullscreenMode( displayFrequency, fullscreen ) == rserr_ok : false ); glConfig.stereoEnabled = stereo; glConfig.borderless = borderless; GLimp_CreateWindow(); // init all the gl stuff for the window if( !GLimp_InitGL() ) { ri.Com_Printf( "GLimp_CreateWindow() - GLimp_InitGL failed\n" ); return false; } return ( fullscreen == glConfig.fullScreen ? rserr_ok : rserr_invalid_fullscreen ); }
/** * Set video mode. * @param mode number of the mode to set * @param fullscreen <code>true</code> for a fullscreen mode, * <code>false</code> otherwise */ rserr_t GLimp_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullscreen, bool stereo, bool borderless ) { const char *win_fs[] = {"W", "FS"}; #ifdef __APLE__ if( fullscreen ) { borderless = true; } else { borderless = false; } #endif ri.Com_Printf( "Initializing OpenGL display\n" ); ri.Com_Printf( "...setting mode:" ); ri.Com_Printf( " %d %d %s\n", width, height, win_fs[fullscreen] ); // destroy the existing window if( glw_state.sdl_window ) { GLimp_Shutdown(); } GLimp_CreateWindow( x, y, width, height ); // init all the gl stuff for the window if( !GLimp_InitGL( r_stencilbits->integer, stereo ) ) { ri.Com_Printf( "VID_CreateWindow() - GLimp_InitGL failed\n" ); return rserr_invalid_mode; } glConfig.width = width; glConfig.height = height; glConfig.borderless = borderless; glConfig.fullScreen = fullscreen; if( GLimp_SetFullscreenMode( displayFrequency, fullscreen ) == rserr_ok ) { glConfig.fullScreen = fullscreen; } else { glConfig.fullScreen = !fullscreen; } return glConfig.fullScreen == fullscreen ? rserr_ok : rserr_invalid_fullscreen; }
rserr_t RF_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullScreen, bool stereo, bool borderless ) { rserr_t err; if( glConfig.width == width && glConfig.height == height && glConfig.fullScreen != fullScreen ) { return GLimp_SetFullscreenMode( displayFrequency, fullScreen ); } RF_AdapterShutdown( &rrf.adapter ); err = R_SetMode( x, y, width, height, displayFrequency, fullScreen, stereo, borderless ); if( err != rserr_ok ) { return err; } rrf.frameId = 0; rrf.frameNum = rrf.lastFrameNum = 0; if( !rrf.frame ) { if( glConfig.multithreading ) { int i; for( i = 0; i < 3; i++ ) rrf.frames[i] = RF_CreateCmdBuf( false ); } else { rrf.frame = RF_CreateCmdBuf( true ); } } if( glConfig.multithreading ) { rrf.frame = rrf.frames[0]; } rrf.frame->Clear( rrf.frame ); memset( rrf.customColors, 255, sizeof( rrf.customColors ) ); rrf.adapter.owner = (void *)&rrf; if( RF_AdapterInit( &rrf.adapter ) != true ) { return rserr_unknown; } return rserr_ok; }