Sharing is Caring!

Share on facebook
Share on twitter
Share on pinterest
Share on linkedin
Share on vk
Share on email

Overview

With Android x86-based Intel® structure gadgets rising in prominence within the market, the libGDX staff got down to guarantee builders may seamlessly deploy their video games and apps with the usage of a single cross-platform framework. This case research provides a quick introduction to libGDX after which reveals how little effort it takes to port an enormous present code base to x86-based Android gadgets!

What’s libGDX?

libGDX is an open-source, cross-platform sport growth framework for Home windows*, Linux*, Mac OS X*, Android, iOS*, and Blackberry* platforms and WebGL-enabled browsers. You should use libGDX to put in writing their video games in any JVM (Java* Digital Machine) language of their alternative (Java, Scala, Clojure, Kotlin*) and might then deploy the identical code base to all supported platforms. Throughout the varied platforms, libGDX helps all IDEs generally used for JVM growth, like Eclipse*, NetBeans, and Intellij IDEA*. Testing and growth can largely be executed in a desktop atmosphere, thereby rushing up growth and iteration instances as time-consuming gadget deployments are minimized.

Hobbyists, small indie builders, and massive studios alike use libGDX in creating desktop and cellular video games resembling Google‘s Ingress, Robotality’s Midway (Determine 1), or Kiwi Inc.’s lineup of prime grossing social video games. Non-gaming functions additionally use libGDX resembling Esoteric Software program’s Backbone 2D skeletal animation software program.



Determine 1. Screenshot from Robotality’s Midway

Because it’s 1.zero launch in Q2 2014, libGDX has seen round 250,000 month-to-month downloads from Maven Central, making it one of the crucial broadly used, open-source, cross-platform sport growth frameworks at present accessible.



Determine 2. libGDX downloads during the last yr

Intel, Android, and libGDX

With such an enormous person base we shortly realized that libGDX needed to assist Intel® x86-based Android gadgets seamlessly and ship most efficiency. We implement all performance-critical components of libGDX in native C/C++ code, which is then uncovered to builders by way of JNI bindings in order that they will keep inside the consolation of their chosen managed language.

libGDX options a variety of platform-specific native elements that assist builders create high-performance video games:

  • CPU-side graphics: whereas libGDX depends closely on GPU-side rendering by OpenGL ES*, there may be nonetheless a necessity for CPU-side picture composition and manipulation. Subsequently, libGDX implements a full-fledged 2D rendering library and integrates FreeType for font rendering.
  • Guide reminiscence administration: Java functions characteristic a garbage-collected, runtime atmosphere methodology of reminiscence administration. Whereas that is handy in lots of circumstances, native reminiscence sources for textures or meshes have to be managed manually. We allow guide administration by piping all associated operations by native C++ code.
  • Linear algebra: many areas of sport growth depend on matrix, vector, and quaternion arithmetic. Some video games expertise a bottleneck with matrix multiplications. To assist with such points , libGDX implements widespread linear algebra operations in C++ and assembler.
  • Physics: most video games require some degree of simulated physics to generate plausible interactive worlds. libGDX integrates Box2D and Bullet* for 2D and 3D physics. Each 3rd-party libraries are written in native C++ with CPU-specific assembler extensions resembling Intel® Streaming SIMD Extensions Three or NEON*.

Since its inception, libGDX supported x86 and x86 64-bit on Home windows, Linux, and Mac OS X. Subsequently, we have been optimistic that the porting effort for Android on x86 can be minimal. Here’s what wanted to be executed!

Organising Android builds for x86

Every of libGDX’s native elements has its personal subproject with construct recordsdata for each platform. For desktop methods and iOS we depend on GCC/Clang and a customized made Apache Ant*-based construct system. The Android model of libGDX makes use of the Android Native Growth Package. NDK builds are often described by two recordsdata: Android.mk and Software.mk. Generally, it was adequate so as to add x86 as a construct goal within the Software.mk file (as proven beneath). Simple!

APP_ABI := armeabi armeabi-v7a x86

APP_PLATFORM := android-8

APP_STL := stlport_static

A few of our elements have CPU-architecture-specific construct flags, e.g., to allow NEON, to make use of inline meeting, and so forth. To get a primary operational construct, we disabled all of those flags.

Testing

To make sure code stability, libGDX comes with an enormous set of checks that we are able to execute when increasing to new platforms. After the primary NDK construct for x86 Android, we fired up the Bullet physics check assortment. It was an amazing success! Our checks ran flawlessly on the ASUS MeMO Pad* FHD 10 that Intel supplied us for testing (Determine 3).



Determine 3. Instance of Bullet* Physics Check run on an ASUS MeMO Pad* FHD 10

All different checks additionally ran as anticipated on the CPU in addition to the GPU, giving us confidence that the Android construct for x86 was prepared for builders. However may we do higher?

Using Vectoring

Most of libGDX’s native elements cope with math of 1 sort or the opposite, a lot of which may be vectorized by GCC routinely. All at present accessible x86-based Android gadgets assist Intel SSE3, so let’s be certain we get probably the most out of our CPUs!

ifeq ($(TARGET_ARCH),x86)

LOCAL_CFLAGS := $(LOCAL_C_FLAGS) -mfpmath=sse -msse3

LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mfpmath=sse -msse3

endif

With the straightforward tweak above, all our native code now exploits SIMD directions so long as the compiler was in a position to vectorize our math code. Notice that we won’t do the identical for ARM as not all ARM chips assist NEON. A particular win for the x86 Android!

Making builders blissful

Beginning with the 1.zero launch, libGDX tasks routinely assist x86-based Android gadgets as seamlessly as they assist every other platform. The added assist is the ultimate piece of the puzzle to assist make libGDX builders blissful. No guide copying of recordsdata or setting flags, it simply works! If you’re serious about libGDX, we advocate studying our in depth documentation and look at our video tutorials.

Conclusion

Getting libGDX and its enormous native code base to work with x86-based Android was a breeze. We merely needed to tweak 2 recordsdata (5 strains) per subproject. Supporting x86-based gadgets with Android and libGDX is now a actuality. Moreover, builders can now exploit instruments like Intel® {Hardware} Accelerated Execution Supervisor to additional enhance the event cycle and Graphics Efficiency Analyzers for Android to profile and benchmark their video games. It is a massive win for the libGDX group.

In regards to the Writer

Mario Zechner is a technologist with 8+ years {of professional} expertise in a variety of domains, from sport growth to knowledge analytics. He’s the creator of the open-source sport growth framework libGDX, creator of the e book “Beginning Android Games” and is at present engaged on RoboVM, an ahead-of-time compiler for Java Digital Machine bytecode. You could find Mario on Twitter (@badlogicgames) and his weblog (badlogicgames).

For extra such Android sources and instruments from Intel, please go to the Intel® Developer Zone

Supply: https://software program.intel.com/en-us/android/articles/preparing-libgdx-to-natively-support-intel-x86-cpus-running-android

Leave a Reply

Login.

To Comment.

Login to follow creators & categories, to create posts, to comment on posts.

Log In

Forgot password?

Don't have an account? Register

Forgot password?

Enter your account data and we will send you a link to reset your password.

Your password reset link appears to be invalid or expired.

Log in

Privacy Policy

To use social login you have to agree with the storage and handling of your data by this website. %privacy_policy%

Add to Collection

No Collections

Here you'll find all collections you've created before.

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on whatsapp
Share on email