/** * @brief Windows specific initialization */ void Sys_PlatformInit(void) { g_wv.hInstance = GetModuleHandle(NULL); #ifdef EXCEPTION_HANDLER WinSetExceptionVersion(Q3_VERSION); #endif #ifndef DEDICATED Sys_SetProcessProperties(); //show the splash screen Sys_Splash(qtrue); #endif #ifdef USE_WINDOWS_CONSOLE // done before Com/Sys_Init since we need this for error output Sys_CreateConsole(); #endif #ifdef DEDICATED Sys_ShowConsoleWindow(1, qtrue); #endif // no abort/retry/fail errors SetErrorMode(SEM_FAILCRITICALERRORS); #ifndef DEDICATED const char *SDL_VIDEODRIVER = getenv("SDL_VIDEODRIVER"); if (SDL_VIDEODRIVER) { Com_Printf("SDL_VIDEODRIVER is externally set to \"%s\", " "in_mouse -1 will have no effect\n", SDL_VIDEODRIVER); SDL_VIDEODRIVER_externallySet = qtrue; } else { SDL_VIDEODRIVER_externallySet = qfalse; } #endif }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { char cwd[ MAX_OSPATH ]; int startTime, endTime; // should never get a previous instance in Win32 if ( hPrevInstance ) { return 0; } #ifdef EXCEPTION_HANDLER WinSetExceptionVersion( Q3_VERSION ); #endif g_wv.hInstance = hInstance; Q_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) ); // done before Com/Sys_Init since we need this for error output Sys_CreateConsole(); // no abort/retry/fail errors SetErrorMode( SEM_FAILCRITICALERRORS ); // get the initial time base Sys_Milliseconds(); //Sys_InitStreamThread(); Com_Init( sys_cmdline ); NET_Init(); #if !defined(DEDICATED) && !defined(BUILD_TTY_CLIENT) IN_Init(); // fretn - directinput must be inited after video etc #endif _getcwd( cwd, sizeof( cwd ) ); Com_Printf( "Working directory: %s\n", cwd ); // hide the early console since we've reached the point where we // have a working graphics subsystems if ( !com_dedicated->integer && !com_viewlog->integer ) { Sys_ShowConsole( 0, qfalse ); } SetFocus( g_wv.hWnd ); // main game loop while ( 1 ) { // if not running as a game client, sleep a bit if ( g_wv.isMinimized || ( com_dedicated && com_dedicated->integer ) ) { Sleep( 5 ); } // set low precision every frame, because some system calls // reset it arbitrarily // _controlfp( _PC_24, _MCW_PC ); // _controlfp( -1, _MCW_EM ); // no exceptions, even if some crappy // syscall turns them back on! startTime = Sys_Milliseconds(); // make sure mouse and joystick are only called once a frame IN_Frame(); // Com_FrameExt(); Com_Frame(); endTime = Sys_Milliseconds(); totalMsec += endTime - startTime; countMsec++; } // never gets here }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char commandLine[MAX_STRING_CHARS] = { 0 }; char cwd[MAX_OSPATH]; // should never get a previous instance in Win32 if (hPrevInstance) { return EXIT_FAILURE; } #ifdef EXCEPTION_HANDLER WinSetExceptionVersion(Q3_VERSION); #endif g_wv.hInstance = hInstance; #if 1 commandLine[0] = '\0'; Sys_ParseArgs(__argc, __argv); Sys_BuildCommandLine(__argc, __argv, commandLine, sizeof(commandLine)); #else Q_strncpyz(commandLine, lpCmdLine, sizeof(commandLine)); #endif #ifndef DEDICATED Sys_SetProcessProperties(); //show the splash screen Sys_Splash(qtrue); #endif #ifdef USE_WINDOWS_CONSOLE // done before Com/Sys_Init since we need this for error output Sys_CreateConsole(); #endif #ifdef DEDICATED Sys_ShowConsoleWindow(1, qtrue); #endif // no abort/retry/fail errors SetErrorMode(SEM_FAILCRITICALERRORS); // get the initial time base Sys_Milliseconds(); Com_Init(commandLine); NET_Init(); Sys_Splash(qfalse); _getcwd(cwd, sizeof(cwd)); Com_Printf("Working directory: %s\n", cwd); // hide the early console since we've reached the point where we // have a working graphics subsystems #ifndef LEGACY_DEBUG if (!com_dedicated->integer && !com_viewlog->integer) { Sys_ShowConsoleWindow(0, qfalse); } #endif // main game loop Sys_GameLoop(); // never gets here return EXIT_SUCCESS; }