قالب وردپرس درنا توس
Home / Tips and Tricks / What It Is and How It Is Used in Your Apps

What It Is and How It Is Used in Your Apps



  Android Game SDK

The Android Game SDK is a new collection of libraries from Google designed to help improve game development. At least it promises to be in the not too distant future. The Android Game SDK is currently just a library: the Android Frame Pacing Library, apparently also known as "Swappy".

The announcement came in early December 2019 and could be considered an overdue admission. Hopefully, future iterations will help streamline the game development process so that developers can design and publish puzzles, platform games, or even 3D titles faster, without resorting to third-party engines such as Unity and Unreal.

This post will be updated If new items are added to the Android Game SDK frequently, bookmark this page and try again. We are currently taking a look at the frame pacing library.


How the Frame Pacing Library Works

This library is designed to help games maintain a constant frame rate with minimal input latency. For this purpose, the rendering loop of the game is synchronized with the subsystem and the hardware of the operating system. The display subsystem aims to reduce cracks that can sometimes occur when the hardware changes from one frame to another halfway through an update. For this purpose, previous frames are buffered, late transmissions are recognized and the display of the last frames is repeated if a late frame is detected.

  frame pacing library too fast

From Google [19659011DieskannjedochzuSynchronisationsfehlanpassungenführendiezuinkonsistentenFrame-AnzeigezeitenführenWenneinFramebeispielsweiseschnellergerendertwirdkanndiesdieZeitverkürzendiedervorherigeFrameaufdemBildschirmverbringtSolltedasRendernvonFramesjedochzulangedauernwirdesmöglicherweisealszusätzlichesFrameangezeigt

The frame pacing library solves these problems by using the Choreographer API Android to to synchronize the game with the display subsystem. This is achieved by using a timestamp extension for presentations in OpenGL and Vulkan APIs, which ensures that frames are presented at the right time. Synchronization fences are also used to prevent buffer filling. Multiple update rates are also supported, allowing developers to choose different device types – including 90 Hz and 120 Hz displays – and customization options. The frame presentation times are automatically adapted to the device hardware.


How to use the Android Game SDK frame pacing library

If your game uses Vulkan on OpenGL you can use this library. To do this, you must first download the Android Game SDK here.

To see how this works, you can also download the Bouncy Ball sample here to test it with OpenGL. Instructions for volcano can be found here. Open the project and run the app to make sure it works.

Then link the project to the library. Do this for static libraries by adding gamesdk / include to compiler include paths and swappy / swappyGL.h to integrate with OpenGL ES. In most cases, the header file contains all the necessary functions.

Finally add the following path to the paths of your linker library:

  gamesdk / libs /   architecture   _API   apiLevel   _NDK   ndkVersion   _ [19659018] stlVersion   _Release 

Of course you will replace the bold text for the corresponding processor / NDK version etc.

Initialize an instance of Android Frame Pacing with:

  void SwappyGL_init (JNIEnv * env, job object activity); 

And destroy this instance with:

  void SwappyGL_destroy (); 

You can now configure your exchange intervals and update periods with the following functions:

  void SwappyGL_setSwapIntervalNS (uint64_t swap_ns);

void SwappyGL_setFenceTimeoutNS (uint64_t fence_timeout_ns);

void SwappyGL_setUseAffinity (bool tf); 

Call this immediately after the initialization of SwappyGL_init () which should be as close as possible to the start of your engine. Pass the duration of the frame to SwappyGL_setSwapIntervalNS () with the options SWAPPY_SWAP_60FPS SWAPPY_SWAP_30FPS or SWAPPY_65_yp_wap [now] Do swap bwapp with [bp90_1200] (EGLDisplay display, EGLSurface surface) . This includes the method eglSwapBuffers () used by Open GL ES, so you should replace all instances with the new version.

You can use bool to check whether frame stimulation has been activated at any time SwappyGL_isEnabled () .

For more detailed instructions on using the Frame Pacing Library, see the official Android developer page.

  Unity Android Game SDK

Using Android Game SDK in Unity

The Frame Pacing Library is also included in Unity Version 2019.2 and higher. Simply check the box for optimized frame stimulation in the Android settings to automatically activate smoother frame rates for your games.

Once again, Unity makes life a lot easier for game developers!


Looking to the future

I think it's high time that Google gave the game developers some love. I therefore see this as very positive. The frame pacing library itself should also be a welcome addition, especially for more demanding games that want to offer silky smooth frame rates. It's a small start, so I keep my fingers crossed for other useful libraries that will soon make their debut with the Android Game SDK.

More Articles on Android Development


Source link