Making Applications Platform Independent#
All platform-specific code is abstracted away from the application. Apart from issues such as different compilers/toolchains and project files, this also means areas such as the file system and the window/surface itself. This platform independence is largely provided by PVRShell.
Supported platforms#
The PowerVR Framework is publicly supported for Windows, Linux, OSX, Android, iOS, and QNX.
Build system#
The SDK creates build systems through CMake on all platforms. Each Framework module and example have their own CMakeLists.txt
and there is additionally a CMakeLists.txt
file at the root of the SDK.
For Android, gradle is used for the Java part and putting the apk together, and CMake (the same CMake as all the other platforms) is used for the native part. CMake is called internally by the Android build system. Each Framework module and example has their gradle build scripts in a build-android
folder.
A number of cross-compilation toolchains are also provided. These are found in the cmake/toolchains folder of the SDK. These are:
iOS cross-compilation toolchain.
Linux cross-compilation with gcc (x86_32, x86_64,armv7, armv7hf, armv8, mips32, mips64).
QNX cross-compilation with qcc (x86_32, x86_64, aarch64le, armlet-v7).
Changing the compiler to something else is achieved by changing/copying the CMake toolchains.
File system (streams)#
The file system is abstracted through the PVRCore and PVRShell.
In PVRCore, the abstract class pvr::Stream
contains several implementations:
pvr::FileStream
provides code for files.pvr::AndroidAssetStream
provides code for Android Assets.pvr::WindowsResourceStream
provides code for Windows Resource files.pvr::BufferStream
provides code for raw memory.
Any Framework functionality requiring raw data will require a pvr::Stream
object, so that files, raw memory, android assets, or windows resources can be used interchangeably.
PVRShell puts everything together. The pvr::Shell
class provides a getAssetStream(…)
method which will try all applicable methods to get a pvr::Stream
to a filename provided. The method initially looks for a file with a specified name and, if it fails, attempts other platform specific streams such as Android Assets or Windows Resources. Linux, by default, only supports files, and iOS accesses its bundles as files. It is important to check the returned smart pointer for NULL
to make sure that a stream was actually created.
Windowing system#
The windowing system is abstracted through PVRShell. No access is required, or given to the windowing system, except for generic OSWindow
and OSDisplay
objects used for context/surface creation by PVRUtils. Window creation parameters such as window size, full screen mode, and frame buffer formats are accessed by several setXXXXXXX
PVRShell functions that can be called in the initialisation phase of the application.