What it is and how to use it in your apps
![]() |
| Android Authority |
The Android Game SDK is a brand new set of libraries from Google designed to assist higher sport growth. Or not less than, that's what it guarantees to be within the not-too-distant future. For proper now, the Android Sport SDK is, in reality, only one library: the Android Frame Pacing Library, apparently also called "Swappy."
The announcement got here firstly of December 2019 and could be thought-about a long-overdue inclusion. Hopefully, future iterations will assist in streamlining the sport growth course of permitting builders to new rapid design and launch puzzle video games, platformers, and even 3D titles without counting on third-party engines like Unity and Unreal.
This put up might be up to date ceaselessly as new parts are added to the Android Sport SDK, so bookmark this web page and verify again. For now, we'll be looking at the Body Pacing Library.
How the Body Pacing Library works
This library is designed to assist video games to preserve a gentle body fee with minimal enter latency. It does this by synchronizing the sport's rendering loop with the OS show subsystem and {hardware}. The show subsystem goals to scale back tearing that may generally happen when {hardware} switches from one body to a different mid-way by a replacement. It does this by buffering earlier frames, detecting late submissions, and repeating the show of these previous frames ought to a new body be exposed.
Find out how to use the Android Sport SDK's Body Pacing Library
In case your sport makes use of both Vulkan on OpenGL, then it is possible for you to make the most of this library. To take action, first, you will have to download the Android Game SDK here. To see how this works, you, too can obtain the Bouncy Ball sample here to check with OpenGL. You may find instructions for Vulkan here. Open the undertaking, then run the app to verify it works. Subsequent, hyperlink the undertaking to the library. For static libraries, do that by including gamesdk/embody to compiler embody paths and swappy/swappyGL.h for integration with OpenGL ES. Generally, the header file will consist of all vital capabilities. Lastly, add the next path to your linker library paths:gamesdk/libs/structure_APIapiLevel_NDKndkVersion_stlVersion_ReleaseAfter all, you'll swap the daring textual content for the related processor/NDK model and so on. Initialize an occasion of Android Body Pacing utilizing:
void SwappyGL_init(JNIEnv *env, jobject jactivity);And destroy stated occasion with:
void SwappyGL_destroy();Now the next capabilities will allow you to configure your swap intervals and refresh durations:
void SwappyGL_setSwapIntervalNS(uint64_t swap_ns); void SwappyGL_setFenceTimeoutNS(uint64_t fence_timeout_ns); void SwappyGL_setUseAffinity(bool tf);Name these instantly after you could have initialized SwappyGL_init(), which must be as near when your engine launches as potential. Go the period of the body into SwappyGL_setSwapIntervalNS() utilizing the SWAPPY_SWAP_60FPS, SWAPPY_SWAP_30FPS, or SWAPPY_SWAP_20FPS constants (the place acceptable). Now carry out the body swap utilizing bool SwappyGL_swap(EGLDisplay show, EGLSurface floor). This wraps the eglSwapBuffers() technique used by Open GL ES, so you must change all situations with the brand new model. You may verify that Body Pacing has been enabled at any level utilizing bool SwappyGL_isEnabled(). For other detailed directions on using the Body Pacing Library, take a look at its official Android developer guide page.
Utilizing Android Sport SDK in Unity
The Body Pacing Library can be included in Unity model 2019.2 and above. Merely choose the optimized Body Pacing checkbox in Android Settings, and also you’ll robotically allow smoother body charges in your video games.
As soon as once more, Unity makes life instead a lot simpler for sport builders!


0 Comments