XGameRuntimeInitialize
Initializes the Gaming Runtime.
Syntax
HRESULT XGameRuntimeInitialize(
)
Parameters
None.
Return value
Type: HRESULT
Returns S_OK if successful; otherwise, returns an error code. For a list of error codes, see Error Codes. If the function fails because the Gaming Runtime library (xgameruntime.dll) wasn't found, the return value is set to E_GAMERUNTIME_DLL_NOT_FOUND.
Remarks
To use the Gaming Runtime features in your game, first initialize the Gaming Runtime by invoking the XGameRuntimeInitialize function. Invoke the XGameRuntimeInitialize function as early as possible, typically within the entry-point function for your game. Similarly, uninitialize the Gaming Runtime as late as possible but before your game exits, by invoking the XGameRuntimeUninitialize function.
The following example demonstrates how to use the XGameRuntimeInitialize and XGameRuntimeUninitialize functions within the entry-point function of a game that is based on the Direct3D 12 Desktop Game template in Visual Studio. The XGameRuntimeInitialize function is invoked before the Game object is instantiated and registered, and the XGameRuntimeUninitialize function is invoked after the Game object is reset but before the entry-point function returns.
// Entry point
int 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;
}
Requirements
Header: XGameRuntimeInit.h
Library: xgameruntime.lib
Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles
See also
XGameRuntimeUninitialize
XGameRuntimeInitializeWithOptions
XGameRuntimeInit
XGameRuntime Structures
XGameRuntime Enumerations
Developing new titles using Gaming Runtime