void deinit() { // Shutdown the SteamAPI SteamController()->Shutdown(); SteamAPI_Shutdown(); // Delete the SteamAchievements object if (g_SteamAchievements) delete g_SteamAchievements; // Shutdown Steam CEG Steamworks_TermCEGLibrary(); }
static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow ) { if ( SteamAPI_RestartAppIfNecessary( k_uAppIdInvalid ) ) { // if Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the // local Steam client and also launches this game again. // Once you get a public Steam AppID assigned for this game, you need to replace k_uAppIdInvalid with it and // removed steam_appid.txt from the game depot. return EXIT_FAILURE; } // Init Steam CEG if ( !Steamworks_InitCEGLibrary() ) { OutputDebugString( "Steamworks_InitCEGLibrary() failed\n" ); Alert( "Fatal Error", "Steam must be running to play this game (InitDrmLibrary() failed).\n" ); return EXIT_FAILURE; } // Initialize SteamAPI, if this fails we bail out since we depend on Steam for lots of stuff. // You don't necessarily have to though if you write your code to check whether all the Steam // interfaces are NULL before using them and provide alternate paths when they are unavailable. // // This will also load the in-game steam overlay dll into your process. That dll is normally // injected by steam when it launches games, but by calling this you cause it to always load, // even when not launched via steam. if ( !SteamAPI_Init() ) { OutputDebugString( "SteamAPI_Init() failed\n" ); Alert( "Fatal Error", "Steam must be running to play this game (SteamAPI_Init() failed).\n" ); return EXIT_FAILURE; } // set our debug handler SteamClient()->SetWarningMessageHook( &SteamAPIDebugTextHook ); // Tell Steam where it's overlay should show notification dialogs, this can be top right, top left, // bottom right, bottom left. The default position is the bottom left if you don't call this. // Generally you should use the default and not call this as users will be most comfortable with // the default position. The API is provided in case the bottom right creates a serious conflict // with important UI in your game. SteamUtils()->SetOverlayNotificationPosition( k_EPositionTopRight ); // Ensure that the user has logged into Steam. This will always return true if the game is launched // from Steam, but if Steam is at the login prompt when you run your game from the debugger, it // will return false. if ( !SteamUser()->BLoggedOn() ) { OutputDebugString( "Steam user is not logged in\n" ); Alert( "Fatal Error", "Steam user must be logged in to play this game (SteamUser()->BLoggedOn() returned false).\n" ); return EXIT_FAILURE; } // We are going to use the controller interface, initialize it, which is a seperate step as it // create a new thread in the game proc and we don't want to force that on games that don't // have native Steam controller implementations char rgchCWD[1024]; _getcwd( rgchCWD, sizeof( rgchCWD ) ); char rgchFullPath[1024]; #if defined(_WIN32) _snprintf( rgchFullPath, sizeof( rgchFullPath ), "%s\\%s", rgchCWD, "controller.vdf" ); #elif defined(OSX) // hack for now, because we do not have utility functions available for finding the resource path // alternatively we could disable the SteamController init on OS X _snprintf( rgchFullPath, sizeof( rgchFullPath ), "%s/steamworksexample.app/Contents/Resources/%s", rgchCWD, "controller.vdf" ); #else _snprintf( rgchFullPath, sizeof( rgchFullPath ), "%s/%s", rgchCWD, "controller.vdf" ); #endif if( !SteamController()->Init( rgchFullPath ) ) { OutputDebugString( "SteamController()->Init() failed\n" ); Alert( "Fatal Error", "Steam Controller Init failed. Is controller.vdf in the current working directory?\n" ); return EXIT_FAILURE; } bool bUseVR = SteamUtils()->IsSteamRunningInVR(); const char *pchServerAddress, *pchLobbyID; ParseCommandLine( pchCmdLine, &pchServerAddress, &pchLobbyID, &bUseVR ); // do a DRM self check Steamworks_SelfCheck(); // init VR before we make the window // Construct a new instance of the game engine // bugbug jmccaskey - make screen resolution dynamic, maybe take it on command line? IGameEngine *pGameEngine = #if defined(_WIN32) new CGameEngineWin32( hInstance, nCmdShow, 1024, 768, bUseVR ); #elif defined(OSX) CreateGameEngineOSX(); #elif defined(SDL) CreateGameEngineSDL( bUseVR ); #else #error Need CreateGameEngine() #endif // This call will block and run until the game exits RunGameLoop( pGameEngine, pchServerAddress, pchLobbyID ); // Shutdown the SteamAPI SteamController()->Shutdown(); SteamAPI_Shutdown(); // Shutdown Steam CEG Steamworks_TermCEGLibrary(); // exit return EXIT_SUCCESS; }