Skip to main content
The Android NDK provides native APIs for hardware-accelerated graphics rendering, enabling high-performance games and graphics-intensive applications.

Graphics APIs overview

Android supports two primary native graphics APIs:
  • Vulkan - Modern, low-overhead graphics and compute API introduced in Android 7.0 (API level 24)
  • OpenGL ES - Established graphics API available across all Android versions
For new applications requiring maximum performance and control, use Vulkan. For broader device compatibility, use OpenGL ES 3.x.

Vulkan on Android

Vulkan provides explicit control over GPU resources and reduced CPU overhead, making it ideal for demanding graphics applications.

Setting up Vulkan

1

Add Vulkan support to your build

In your CMakeLists.txt:
For ndk-build, in Android.mk:
2

Include Vulkan headers

3

Check for Vulkan support

Creating a Vulkan instance

Validation layers help catch programming errors during development but should be disabled in release builds for better performance.

Creating an Android surface

Selecting a physical device

OpenGL ES rendering

OpenGL ES provides a simpler API and works across all Android devices.

Setting up OpenGL ES

1

Link against OpenGL ES libraries

In CMakeLists.txt:
2

Include OpenGL ES headers

3

Initialize EGL display

4

Create OpenGL ES context

Basic rendering loop

Performance optimization

Reduce draw calls

Batch geometry to minimize state changes:

Use vertex buffer objects efficiently

Optimize texture usage

Use compressed texture formats like ETC2 (required on all OpenGL ES 3.0+ devices) or ASTC for reduced memory bandwidth.

Enable GPU instancing

Frame pacing and synchronization

Control frame rate with Choreographer

From the Java/Kotlin layer:

Use EGL sync objects

Blocking on GPU completion can reduce performance. Use fences only when synchronization is necessary.

Debugging graphics

Enable GPU debugging

For Vulkan:
For OpenGL ES:

Profile with Android GPU Inspector

Android GPU Inspector (AGI) provides frame profiling and shader debugging:
  1. Install AGI from the Android developer website
  2. Connect your device via USB
  3. Launch AGI and select your application
  4. Capture a frame to analyze draw calls and GPU performance

Best practices

  • Target OpenGL ES 3.0+ - Available on 95%+ of devices, provides modern features
  • Use Vulkan selectively - For compute-heavy workloads or when you need explicit control
  • Minimize GPU state changes - Sort draw calls to reduce pipeline switches
  • Compress textures - Use ETC2 or ASTC to reduce memory bandwidth
  • Profile early and often - Use Android GPU Inspector and systrace
  • Test on low-end devices - Performance varies significantly across device tiers

Additional resources