# Native Platform SDK

# Preparation

Before the start, you need to define your app in the Developer Center. Through this process you will have an App Id to initialize the SDK. You can find more detail from here

SDK is a toolkit to integrate your content with Pimax Store, you need OpenVR to render your game in VR environment.

# Introduction of SDK

This document describes how to use Pimax native platform SDK to develop VR applications. The functions provided by this SDK include DRM and some User releated information. It will support achievements, in-app payments, DLC, etc.

# Structure of SDK

The SDK folder structure shows as below:

img

Folder Introduction
Android Exclusive Headers/Tools/Libs for Android platform
Docs SDK documentation
Include C++ header files
Samples SDK usage examples
Tools Development tools
Windows Exclusive Headers/Tools/Libs for Windows platform

For detailed instructions of usage, you can refer to the header files or play the samples under Samples folder.

# Headers

img

.h file Function
PVR_Accout.h Account-related APIs
PVR_Define.h Common definitions
PVR_ErrCode.h Error codes
PVR_Message.h Message related APIs
PVR_Message_ErrCode.h Message related error codes
PVR_MessageType.h Message type definitions
PVR_Platform.h Include all the header files you need and some helper functions.
PVR_SdkState.h Initialization related APIs.
PVR_Setting.h Setting related APIs

# Flow chart

img

The SDK process is shown as the flow chart: Init → Check Entitlement → Message Loop → Shutdown.

The SDK has an asynchronous message mechanism. You should constantly check notifications and messages from the Platform SDK by calling pvr_PollMessage every frame before the game logic. And don't forget to call pvr_checkEntitlement to verify the user's ownership of the game.

# Tools

You could find some useful development tools under Tools folder.

# test.json

test.json is here only for debug, you can copy this file to your work directory to mock the entitlement result and other platform features during development, MAKE SURE to remove it while uploading to Pimax Store.

Note: The content of test.json can only be read if appSecret is correct; appSecret can be obtained from the developer center (opens new window):

native_platfom_sdk_doc_appsecret

native_platfom_sdk_doc_appsecret2

Fill your application's [appSecret] into test.json

{  
    "appSecret": "TESTSECRET", //appSecret of your app, Please remove comments when using
    "Entitlement": 1001,  //Result of CheckEntitlement(). Please remove comments when using 
    "LoggedInUser": {
        "username": "json",
        "userid": 123456  
    }    //Result of GetLoggedInUser().  Please remove comments when using
}

You can modify test.json under your work directory and restart it to test different results.

# PiPlatformService

Start Pimax Store to communicate with your app. If your app is not yet published, you can use test.json for simulated development. The general process is shown above.

# Instruction for SDK configuration

# Development environment requirements

Windows :

  1. Visual studio 2015 or above
  2. Pimax Client 1.3.0.17 or above
  3. 64-bit architecture is recommended.

# Sample Apps

Let’s start with a simple to understand the SDK.

The PvrSamples shows examples of how to initialize the SDK, perform the entitlement check and some other platform features.

Go to the Samples/PvrSamples folder:

img

Start PvrSamples.sln and explore PvrSamples.cpp

img

In this example, you can see the App ID entered by the user is obtained from line 31 (just for testing), and then initialized, including some states, communication with the Pimax Store process, and so on.

If the initialization fails, it will parse the specific failure, and then exit.

For the initEnv() function, in this example, there is nothing special to initialize, it only make some call to SDK to check entitlement and request for some messages.

img

We called pvr_PollMessage() in the infinite loop to check the message queue(Line 55 showed above). You can add pvr_PollMessage() to your own game loop.

img

Message from platform SDK should be handled asynchronously, processXXXX function can help you to achieve it. You can obtain a pvrMessageHandle instance through pvr_PollMessage(), call releated APIs to retrieve the detail info.

Remember to include the directory when compiling, and point to the corresponding static library while linking. You can find the libs under Windows/Lib.

img

Be sure to install the Piamx Store (version 1.1.0 or above) before launching your app.

Now let's launch an example:

img

All the returns in the picture above have corresponding content in the related header file, for example: User has an entitlement:1003, it is an error in the validity of the account detection, it can be found in PVR_Account.h where the test account does not have an App ID.

img