# 原生平台SDK
# Prerequisites
Before you can get started, you’ll need to define your app in the Developer Center. Through this process you will get an App Id to initialize the SDK. You can find more detail from here
Platform SDK is a toolkit to help your content integrating with Pimax Store, you will need to integrate OpenVR to render your game in VR environment.
# Introduction to SDK
This document describes how to use Pimax native platform SDK (hereinafter referred to as SDK) to develop VR applications. The functions provided by this SDK include DRM and some User releated informations. There will be support for achievements, in-app payments, DLC, and more.
# Introduction to SDK Structure
The SDK folder structure is as follows:
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 with the samples under Samples folder.
# Headers
.h file | The main 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
The generalization of SDK process is shown as this flow chart: init → check entitlement → message loop → shutdown.
The SDK implemented an asynchronous message mechanism. You should constantly check message for notifications and messages from the Platform SDK by calling pvr_PollMessage every frame before your game logic. And don't forget to call pvr_checkEntitlement to verify the user's ownship of your 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):
Fill your application's [appSecret] into test.json
{
"appSecret": "TESTSECRET", //app secret id
"Entitlement": 1001, //Result of CheckEntitlement().
"LoggedInUser": {
"username": "json",
"userid": 123456
} //Result of GetLoggedInUser().
}
You can modify test.json under your work directory and restart to test different result.
# PiPlatformService
Start Pimax Store to communicate with your app. If your app is not yet on the shelves, you can use test.json for simulated development. The specific usage process is shown above.
# Instructions for SDK configuration
# Development environment requirements
Windows :
- Visual studio 2015 or above
- Pimax Client 1.3.0.17 or above
64-bit architecture is recommended.
# Sample Apps
Let’s start with a simple example to understand the SDK.
The PvrSamples provided examples of how to initialize the SDK, perform the entitlement check, and perform some of the platform features.
Go to the Samples/PvrSamples
folder:
Now let's start PvrSamples.sln
and explore PvrSamples.cpp
In this example, you can see that the App ID entered by the user is obtained from line 31 (just for testing), and then initialized, including some states initializing, communication with the Pimax Store process, and so on.
If the initialization fails, it will parse the specific failure content, and then exit.
In the initEnv() function. In this example, there is nothing special to initialize, we only make some call to SDK to check entitlement and request some messages.
We called pvr_PollMessage() in the infinite loop to check the message queue(Line 55 above). You can add pvr_PollMessage() to your own game loop.
Message from platform SDK should be handled asynchronously, you can find how to achieve that in the processXXXX function. You can obtained an pvrMessageHandle instance through pvr_PollMessage(), call releated APIs to retrieve the detail info.
Remember to include the Include directory when compiling, and point to the corresponding static library when linking. You can find the libs under Windows/Lib.
Be sure to install the piamx store (version 1.1.0+) before launching your app.
Now let's launch the example:
All the returns in the above figure can find the corresponding content in the corresponding header file, for example: User has an entitlement:1003, because it is an error in the validity of the account detection,
so the corresponding error can be found in PVR_Account.h that the test account does not have an appid This app for 123。
← Unreal平台SDK 原生 PC SDK →