/* ============== VID_LoadRefresh ============== */ qboolean VID_LoadRefresh(void) { // GetRefAPI_t GetRefAPI; if ( reflib_active ) { R_Shutdown(); VID_FreeReflib (); } VID_Printf(PRINT_INFO, "-------- Loading OpenGL Ref --------\n"); #if 0 if ( ( reflib_library = LoadLibrary( name ) ) == 0 ) { VID_Printf(PRINT_ALL, "LoadLibrary(\"%s\") failed\n", name ); return false; } #endif Swap_Init(); #if 0 if ( ( GetRefAPI = (void *) GetProcAddress( reflib_library, "GetRefAPI" ) ) == 0 ) Com_Error( ERR_FATAL, "GetProcAddress failed on %s", name ); re = GetRefAPI( ri ); #endif #if 0 if (re.api_version != API_VERSION) { VID_FreeReflib (); Com_Error (ERR_FATAL, "%s has incompatible api_version", name); } #endif if ( R_Init( global_hInstance, MainWndProc ) == -1 ) { R_Shutdown(); VID_FreeReflib (); return false; } VID_Printf(PRINT_INFO, "------------------------------------\n"); reflib_active = true; return true; }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { MsgDev( D_INFO, "CL_Shutdown()\n" ); if( cls.initialized && !host.crashed ) { Host_WriteOpenGLConfig (); Host_WriteVideoConfig (); } IN_TouchShutdown(); CL_CloseDemoHeader(); IN_Shutdown (); Mobile_Destroy(); SCR_Shutdown (); if( cls.initialized ) { CL_UnloadProgs (); cls.initialized = false; } FS_Delete( "demoheader.tmp" ); // remove tmp file SCR_FreeCinematic (); // release AVI's *after* client.dll because custom renderer may use them S_Shutdown (); R_Shutdown (); }
/* ============ VID_CheckChanges This function gets called once just before drawing each frame, and it's sole purpose in life is to check to see if any of the video mode parameters have changed, and if they have to update the rendering DLL and/or video mode to match. ============ */ void VID_CheckChanges (void) { if ( vid_restart ) { cl.force_refdef = true; // can't use a paused refdef S_StopAllSounds(); /* ** refresh has changed */ vid_fullscreen->modified = true; cl.refresh_prepped = false; cls.disable_screen = true; VID_Shutdown(); Com_Printf( "--------- [Loading Renderer] ---------\n" ); vid_active = true; if ( R_Init( 0, 0 ) == -1 ) { R_Shutdown(); Com_Error (ERR_FATAL, "Couldn't initialize renderer!"); } Com_Printf( "------------------------------------\n"); vid_restart = false; cls.disable_screen = false; IN_Activate(false); IN_Activate(true); } }
/** * @brief Saves configuration file and shuts the client systems down * @todo this is a callback from @c Sys_Quit and @c Com_Error. It would be better * to run quit through here before the final handoff to the sys code. * @sa Sys_Quit * @sa CL_Init */ void CL_Shutdown (void) { if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; /* remove cvar feedback */ for (const cvar_t* var = Cvar_GetFirst(); var; var = var->next) { if (var->flags & CVAR_R_CONTEXT) Cvar_UnRegisterChangeListener(var->name, CL_RContextCvarChange); if (var->flags & CVAR_R_IMAGES) Cvar_UnRegisterChangeListener(var->name, CL_RImagesCvarChange); } GAME_SetMode(nullptr); GAME_UnloadGame(); CL_HTTP_Cleanup(); Irc_Shutdown(); Con_SaveConsoleHistory(); Key_WriteBindings("keys.cfg"); S_Shutdown(); R_Shutdown(); UI_Shutdown(); CIN_Shutdown(); SEQ_Shutdown(); GAME_Shutdown(); CL_LanguageShutdown(); TOTD_Shutdown(); SCR_Shutdown(); }
void VID_Close() { Sys_Thread_LockMutex(display_mutex); #ifndef GLQUAKE VID_SW_FreeBuffers(); #endif Skin_Shutdown(); Mod_ClearAll(); SCR_Shutdown(); Sbar_Shutdown(); M_VidShutdown(); Draw_Shutdown(); CSTC_PictureShutdown(); if (display) { R_Shutdown(); Sys_Video_Close(display); display = 0; } Sys_Thread_UnlockMutex(display_mutex); }
/* ============ VID_Shutdown ============ */ void VID_Shutdown (void) { if ( reflib_active ) { R_Shutdown(); VID_FreeReflib (); } }
/* ============ VID_Shutdown ============ */ void VID_Shutdown (void) { if ( vid_active ) { R_Shutdown (); vid_active = false; } }
// Specifies the model that will be used as the world static void R_BeginRegistrationAndLoadWorld( const char* model ) { char fullname[ MAX_QPATH ]; String::Sprintf( fullname, sizeof ( fullname ), "maps/%s.bsp", model ); R_Shutdown( false ); CL_InitRenderer(); R_LoadWorld( fullname ); }
// // D_Shutdown // // Called to shutdown subsystems when unloading a set of WAD resource files. // Should be called prior to D_Init when loading a new set of WADs. // void STACK_ARGS D_Shutdown() { if (gamestate == GS_LEVEL) G_ExitLevel(0, 0); // [ML] 9/11/10: Reset custom wad level information from MAPINFO et al. for (size_t i = 0; i < wadlevelinfos.size(); i++) { if (wadlevelinfos[i].snapshot) { delete wadlevelinfos[i].snapshot; wadlevelinfos[i].snapshot = NULL; } } wadlevelinfos.clear(); wadclusterinfos.clear(); F_EndFinale(); ST_Shutdown(); R_ShutdownViewBorder(); // stop sound effects and music S_Stop(); // shutdown automap AM_Stop(); DThinker::DestroyAllThinkers(); UndoDehPatch(); GStrings.FreeData(); // close all open WAD files W_Close(); V_UnloadFonts(); R_Shutdown(); HU_Shutdown(); C_ShutdownConsoleBackground(); R_ShutdownTextureManager(); // reset the Zone memory manager Z_Close(); }
/* ============ VID_Shutdown ============ */ void VID_Shutdown (void) { if ( reflib_active ) { if (KBD_Close_fp) KBD_Close_fp(); if (RW_IN_Shutdown_fp) RW_IN_Shutdown_fp(); KBD_Close_fp = NULL; RW_IN_Shutdown_fp = NULL; R_Shutdown (); VID_FreeReflib (); } }
// This function gets called once just before drawing each frame, and it's sole purpose in life // is to check to see if any of the video mode parameters have changed, and if they have to // update the rendering DLL and/or video mode to match. void CLQ2_CheckVidChanges() { if ( vid_restart_requested ) { S_StopAllSounds(); /* ** refresh has changed */ vid_restart_requested = false; cl.q2_refresh_prepped = false; cls.disable_screen = true; R_Shutdown( true ); CL_InitRenderer(); cls.disable_screen = false; } }
/** * @brief Perform a renderer restart */ static void VID_Restart_f (void) { refdef.ready = false; Com_Printf("renderer restart\n"); R_Shutdown(); R_Init(); UI_Reinit(); /** @todo only reload the skins, not all models */ CL_ViewPrecacheModels(); /** @todo going back into the map isn't working as long as GAME_ReloadMode is called */ /*CL_ViewLoadMedia();*/ GAME_ReloadMode(); }
void RF_Shutdown( bool verbose ) { RF_AdapterShutdown( &rrf.adapter ); if( glConfig.multithreading ) { int i; for( i = 0; i < 3; i++ ) RF_DestroyCmdBuf( &rrf.frames[i] ); } else { RF_DestroyCmdBuf( &rrf.frame ); } memset( &rrf, 0, sizeof( rrf ) ); R_Shutdown( verbose ); }
void VID_Shutdown(void) { if (ref_active) { // Shut down the input backend IN_Close(); IN_BackendShutdown(); /* Shut down the renderer */ R_Shutdown(); } // Declare the refresher as inactive ref_active = false; }
int main( int argc, char *argv[] ) { printf( APP_NAME"\n" ); common.running = true; common.path = argv[0]; {//Strip the file name + extension to get the current working directory int i = strlen( common.path )-1; while ( common.path[i] && i > 0 ) { if ( common.path[i] == '/' || common.path[i] == '\\' ) { common.path[i] = '\0'; break; } i--; } } printf( "Path is %s\n\n", common.path ); srand( (unsigned int)time( NULL ) ); R_Initialise(); Game_Initialise(); Input_Initialise(); while ( common.running ) { Input_Poll(); if ( common.running ) {//If the input handler picked up an exit, don't bother with the game R_ClearScreen(); Game_Render(); SDL_GL_SwapBuffers(); } } R_Shutdown(); Game_Shutdown(); printf( "Thanks for playing!\n" ); return 0; }
/* * @brief Restarts the renderer subsystem. The OpenGL context is discarded and * recreated. All media is reloaded. Other subsystems can elect to refresh * their media references by inspecting r_view.update. */ void R_Restart_f(void) { if (cls.loading) return; R_Shutdown(); R_Init(); cls.loading = 1; R_LoadMedia(); r_render_mode->modified = true; r_view.update = true; cls.loading = 0; }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { // already freed if( !cls.initialized ) return; cls.initialized = false; MsgDev( D_INFO, "CL_Shutdown()\n" ); Host_WriteOpenGLConfig (); Host_WriteVideoConfig (); CL_CloseDemoHeader(); IN_Shutdown (); SCR_Shutdown (); CL_UnloadProgs (); SCR_FreeCinematic (); // release AVI's *after* client.dll because custom renderer may use them S_Shutdown (); R_Shutdown (); }
qboolean VID_LoadRefresh( char *name ) { //refimport_t ri; //GetRefAPI_t GetRefAPI; char fn[MAX_OSPATH]; struct stat st; extern uid_t saved_euid; FILE *fp; char message[128]; if ( reflib_active ) { Com_Printf("REFLIB ACTIVE\n"); if (KBD_Close_fp) KBD_Close_fp(); if (RW_IN_Shutdown_fp) RW_IN_Shutdown_fp(); KBD_Close_fp = NULL; RW_IN_Shutdown_fp = NULL; R_Shutdown(); VID_FreeReflib (); } Com_Printf( "------- Loading %s -------\n", name ); if ((reflib_library = dlopen (name, RTLD_LAZY|RTLD_GLOBAL)) == 0) { Com_Printf("LoadLibrary (\"%s\") failed.\n", dlerror()); return false; } // Init IN (Mouse) n_state.IN_CenterView_fp = IN_CenterView; n_state.Key_Event_fp = Do_Key_Event; n_state.viewangles = cl.viewangles; n_state.in_strafe_state = &in_strafe.state; RW_IN_Init_fp=RW_IN_Init; RW_IN_Shutdown_fp=RW_IN_Shutdown; RW_IN_Activate_fp = RW_IN_Activate; RW_IN_Commands_fp = RW_IN_Commands; RW_IN_Move_fp = RW_IN_Move; RW_IN_Frame_fp = RW_IN_Frame; Real_IN_Init(); if ( R_Init( 0, 0,message ) == false ) { Com_Printf("Render Init fail: %s\n",message); //R_Shutdown(); //VID_FreeReflib (); return false; } // Init KBD void KBD_Init(void); void KBD_Update(void); void KBD_Close(void); KBD_Init_fp = KBD_Init; KBD_Update_fp = KBD_Update; KBD_Close_fp = KBD_Close; KBD_Init_fp(Do_Key_Event); // give up root now setreuid(getuid(), getuid()); setegid(getgid()); Com_Printf( "------------------------------------\n"); reflib_active = true; return true; }
static void CLQ1_ParseServerInfo( QMsg& message ) { common->DPrintf( "Serverinfo packet received.\n" ); R_Shutdown( false ); CL_InitRenderer(); clc.qh_signon = 0; // // wipe the clientActive_t struct // CL_ClearState(); SCR_ClearCenterString(); // parse protocol version number int i = message.ReadLong(); if ( i != Q1PROTOCOL_VERSION ) { common->Printf( "Server returned version %i, not %i", i, Q1PROTOCOL_VERSION ); return; } // parse maxclients cl.qh_maxclients = message.ReadByte(); if ( cl.qh_maxclients < 1 || cl.qh_maxclients > MAX_CLIENTS_QH ) { common->Printf( "Bad maxclients (%u) from server\n", cl.qh_maxclients ); return; } // parse gametype cl.qh_gametype = message.ReadByte(); // parse signon message const char* str = message.ReadString2(); String::NCpy( cl.qh_levelname, str, sizeof ( cl.qh_levelname ) - 1 ); // seperate the printfs so the server message can have a color common->Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n" ); common->Printf( S_COLOR_ORANGE "%s" S_COLOR_WHITE "\n", str ); // precache models Com_Memset( cl.model_draw, 0, sizeof ( cl.model_draw ) ); char model_precache[ MAX_MODELS_Q1 ][ MAX_QPATH ]; int nummodels; for ( nummodels = 1;; nummodels++ ) { str = message.ReadString2(); if ( !str[ 0 ] ) { break; } if ( nummodels == MAX_MODELS_Q1 ) { common->Printf( "Server sent too many model precaches\n" ); return; } String::Cpy( model_precache[ nummodels ], str ); } // precache sounds Com_Memset( cl.sound_precache, 0, sizeof ( cl.sound_precache ) ); char sound_precache[ MAX_SOUNDS_Q1 ][ MAX_QPATH ]; int numsounds; for ( numsounds = 1;; numsounds++ ) { str = message.ReadString2(); if ( !str[ 0 ] ) { break; } if ( numsounds == MAX_SOUNDS_Q1 ) { common->Printf( "Server sent too many sound precaches\n" ); return; } String::Cpy( sound_precache[ numsounds ], str ); } // // now we try to load everything else until a cache allocation fails // CM_LoadMap( model_precache[ 1 ], true, NULL ); R_LoadWorld( model_precache[ 1 ] ); CLQH_KeepaliveMessage(); for ( i = 2; i < nummodels; i++ ) { cl.model_draw[ i ] = CLQ1_RegisterModel( model_precache[ i ] ); if ( cl.model_draw[ i ] == 0 ) { common->Printf( "Model %s not found\n", model_precache[ i ] ); return; } CLQH_KeepaliveMessage(); } S_BeginRegistration(); CLQ1_InitTEnts(); for ( i = 1; i < numsounds; i++ ) { cl.sound_precache[ i ] = S_RegisterSound( sound_precache[ i ] ); CLQH_KeepaliveMessage(); } S_EndRegistration(); // local state R_EndRegistration(); }
static void CLQW_ParseServerData( QMsg& message ) { common->DPrintf( "Serverdata packet received.\n" ); Cbuf_Execute(); // make sure any stuffed commands are done R_Shutdown( false ); CL_InitRenderer(); // // wipe the clientActive_t struct // CL_ClearState(); // parse protocol version number // allow 2.2 and 2.29 demos to play int protover = message.ReadLong(); if ( protover != QWPROTOCOL_VERSION && !( clc.demoplaying && ( protover == 26 || protover == 27 || protover == 28 ) ) ) { common->Error( "Server returned version %i, not %i\nYou probably need to upgrade.\nCheck http://www.quakeworld.net/", protover, QWPROTOCOL_VERSION ); } cl.servercount = message.ReadLong(); // game directory const char* str = message.ReadString2(); bool cflag = false; if ( String::ICmp( fsqhw_gamedirfile, str ) ) { // save current config Com_WriteConfiguration(); cflag = true; } FS_SetGamedirQHW( str ); //ZOID--run the autoexec.cfg in the gamedir //if it exists if ( cflag ) { if ( FS_FileExists( "config.cfg" ) ) { Cbuf_AddText( "cl_warncmd 0\n" ); Cbuf_AddText( "exec config.cfg\n" ); Cbuf_AddText( "exec frontend.cfg\n" ); Cbuf_AddText( "cl_warncmd 1\n" ); } } // parse player slot, high bit means spectator cl.playernum = message.ReadByte(); if ( cl.playernum & 128 ) { cl.qh_spectator = true; cl.playernum &= ~128; } cl.viewentity = cl.playernum + 1; // get the full level name str = const_cast<char*>( message.ReadString2() ); String::NCpy( cl.qh_levelname, str, sizeof ( cl.qh_levelname ) - 1 ); // get the movevars movevars.gravity = message.ReadFloat(); movevars.stopspeed = message.ReadFloat(); movevars.maxspeed = message.ReadFloat(); movevars.spectatormaxspeed = message.ReadFloat(); movevars.accelerate = message.ReadFloat(); movevars.airaccelerate = message.ReadFloat(); movevars.wateraccelerate = message.ReadFloat(); movevars.friction = message.ReadFloat(); movevars.waterfriction = message.ReadFloat(); movevars.entgravity = message.ReadFloat(); // seperate the printfs so the server message can have a color common->Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n" ); common->Printf( S_COLOR_ORANGE "%s" S_COLOR_WHITE "\n", str ); // ask for the sound list next Com_Memset( cl.qh_sound_name, 0, sizeof ( cl.qh_sound_name ) ); CL_AddReliableCommand( va( "soundlist %i %i", cl.servercount, 0 ) ); // now waiting for downloads, etc cls.state = CA_LOADING; }
/* ============== UpdateVideoRef ============== */ void UpdateVideoRef (void) { char reason[128]; if ( vid_ref->modified ) { cl.force_refdef = true; // can't use a paused refdef S_StopAllSounds(); // unclip decals if (active_decals) { CL_UnclipDecals(); reclip_decals = true; } } vid_reloading = false; while (vid_ref->modified) { // refresh has changed vid_ref->modified = false; vid_fullscreen->modified = true; cl.refresh_prepped = false; if (cl.cinematictime > 0) // Knightmare added cls.disable_screen = false; else cls.disable_screen = true; vid_reloading = true; // end Knightmare //========================== // compacted code from VID_LoadRefresh //========================== if ( kmgl_active ) { R_Shutdown(); VID_FreeReflib (); } Com_Printf( "\n--------- Renderer Initialization ---------\n"); if ( !R_Init( 0, 0, reason ) == -1 ) { R_Shutdown(); VID_FreeReflib (); Com_Error (ERR_FATAL, "Couldn't initialize OpenGL renderer!\n%s", reason); } Com_Printf( "------------------------------------\n"); kmgl_active = true; //========================== } /* prefer to fall back on X if active */ //if (getenv("DISPLAY")) Cvar_Set( "vid_ref", "kmglx" ); /*else Cvar_Set( "vid_ref", "kmsdlgl" );*/ // added to close loading screen // if (cl.refresh_prepped && vid_reloading) // cls.disable_screen = false; // re-clip decals if (cl.refresh_prepped && reclip_decals) { CL_ReclipDecals(); reclip_decals = false; } vid_reloading = false; }