게임에서 Gaming Runtime 기능을 사용하려면 먼저 XGameRuntimeInitialize 함수를 호출하여 Gaming Runtime을 초기화합니다. 게임이 Gaming Runtime 사용을 완료하고 종료할 준비가 되면 XGameRuntimeUninitialize 함수를 호출하여 Gaming Runtime을 초기화 해제합니다. XGameRuntimeUninitialize 함수는 게임이 종료되기 전에 최대한 늦게, 일반적으로 게임의 진입점 함수 내에서 호출합니다.다음 예제는 Visual Studio의 Direct3D 12 Desktop Game 템플릿을 기반으로 하는 게임의 진입점 함수 내에서 XGameRuntimeInitialize 및 XGameRuntimeUninitialize 함수를 사용하는 방법을 보여 줍니다. XGameRuntimeInitialize 함수는 Game 개체가 인스턴스화되고 등록되기 전에 호출되며, XGameRuntimeUninitialize 함수는 Game 개체가 재설정된 후 진입점 함수가 반환되기 전에 호출됩니다.
// Entry pointint WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow){ UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // Initialize the Gaming Runtime before // performing any other activity. if (FAILED(XGameRuntimeInitialize())) return 1; if (!XMVerifyCPUSupport()) return 1; g_game = std::make_unique<Game>(); // Register class and create window { // Code omitted for brevity. ... } // Main message loop MSG msg = {}; while (WM_QUIT != msg.message) { // Code omitted for brevity. ... } g_game.reset(); // Uninitialize the Gaming Runtime after // all other activity has been completed. XGameRuntimeUninitialize(); return (int) msg.wParam;}