Power your game using the Play Games PC SDK

With the Play Games PC SDK you can access Google Play services to build and monetize your game on PCs. Sell digital content using Play Billing, seamlessly sign-in using Play Games, and ensure your users have a valid entitlement to your application with Play Integrity.

Ready to get started?

Prerequisites

  • Create an app entry inside of the Play Console and claim a Play package name.

  • Download and install Google Play Games for PC and sign in with your Google Account.

Step 1: Add the SDK to your project

  • Download the Play Games PC C++ SDK.

  • Copy the API headers folder includes/ into your application's codebase.

  • Copy the redistributable files from imports/ into your application's project.

    • Link your project against play_pc_sdk.lib allowing access to the contents of the play_pc_sdk.dll.

Step 2: Add a manifest file

Before you can use the SDK from within your game you will need to associate your game executable with the Play package name that you claimed inside of the Play Console. This done by adding a manifest.xml file in the same directory as your game's executable.

Example manifest.xml contents:

<?xml version="1.0" encoding="utf-8"?>
<Manifest version="1">
    <Application>
        <PackageName>com.example.package</PackageName>
    </Application>
</Manifest>

Example manifest.xml placement:

C:\Program Files
└───Example Game
    ├───Game.exe
    └───manifest.xml

Step 3: Digitally sign your game

Before your game can use the SDK, the game's executable must be digitally signed using an Authenticode Digital Signature. For instructions on how to sign an executable see the documentation on the SignTool .

Step 4: Initialize the SDK

Initialize the SDK during the startup sequence of your game. This should be done automatically without requiring any user interaction and it is recommended to verify a successful initialization before rendering your game window. This provides the best user experience by surfacing and resolving errors as soon as possible and avoids your game window briefly appearing in cases where your game process needs to exit.

Start using the SDK by calling GooglePlayInitialize to initialize the API. This will setup global state, connect with the SDK runtime, and verify the application was started correctly. This MUST be called and have the continuation callback complete with InitializeResult::ok() equal to true before any other API may be used.

// Initialize the SDK as part of the startup sequence of your application.
auto promise = std::make_shared<std::promise<InitializeResult>>();
GooglePlayInitialize(
  [promise](InitializeResult result) {
    promise->set_value(std::move(result));
  });

auto initialize_result = promise->get_future().get();
if (initialize_result.ok()) {
  // The SDK succeeded with initialization. Continue with the startup sequence
  // of the game.
  // ...
} else if (initialize_result.code() == InitializationError::kActionRequiredShutdownClientProcess) {
  // The SDK failed to initialize and has requested that your game process exit
  // as soon as possible.
  exit(1);
} else {
  // The SDK failed to initialize for an alternative reason. It is still
  // generally recommended that you exit the game process as soon as possible,
  // because it won't be possible to access any APIs in the SDK. Critical
  // operations such as verifying the user owns a valid license to your game
  // won't be possible.
  // ...
}

If the initialization fails with the code kActionRequiredShutdownClientProcess exit the game process as soon possible. The SDK's runtime will attempt to assist the user with no additional action required by your game. For example if the user does not own a valid license to the game, Google Play Games will prompt the user to purchase a copy. For other errors it is still recommended to exit the game process as soon as possible as it won't to use the SDK to perform critical operations such as verifying the user owns a valid license to your game.

A non-successful response may indicate one of the following conditions:

  • The SDK runtime is not installed, is not running on the device or is an older version not compatible with the SDK integrated into your game.

  • The SDK runtime was unable to verify the application identity of the game. This could be due to an invalid manifest.xml or using the SDK without enabling developer mode when developing. Without this your game's executable is required to be digitally signed with the digital certificate registered to your Play package name.

  • The game executable was not launched through the Google Play games client.

  • The active user in Google Play Games does not own a license for the application.

Step 5: (Optional) Supporting multiple game-processes

If your game uses multiple processes and plans to use the Play Games PC SDK from a process that is not directly launched by Google Play Games for PC additional integration steps are required:

  1. The process directly launched by Google Play Games for PC must verify a successful initialization of the Play Games PC SDK.

    This provides the best user experience by surfacing errors as soon as possible. Note that child-process using the SDK must also perform initialization in addition to the directly launched process.

  2. To use the Play Games PC SDK in a child-process forward the command line parameters to the spawned child-process.

    Example command line parameter forwarding:

    Processes hierarchy tree:
    
    GooglePlayGames.exe
    └───YourGameLauncher.exe --foo=abc --bar=123
        └───YourGame.exe --foo=abc --bar=123
    

    In this example we see a process hierarchy where Google Play Games for PC (GooglePlayGames.exe) launches the game (YourGameLauncher.exe) with some example parameters (--foo=abc --bar=123). The game then spawns a child-process (YourGame.exe) which uses the Play Games PC SDK. To allow this the game process launched by Google Play Games for PC forwards the command line parameters it was given to the child-process.

  3. Exit all processes when the game stops running.

    When a user closes your game or the game exits due to a SDK initialization failure, such as kActionRequiredShutdownClientProcess, close all processes your game has spawned. This makes certain that the next time your game is launched by the Google Play Games for PC client, new changes such as switching to a different active account will take effect.

Next steps

Use the SDK while developing in your IDE:

Add Google Play PC features to your app: