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
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 For ndk-build, in
CMakeLists.txt: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
Enable GPU instancing
Frame pacing and synchronization
Control frame rate with Choreographer
From the Java/Kotlin layer:Use EGL sync objects
Debugging graphics
Enable GPU debugging
For Vulkan:Profile with Android GPU Inspector
Android GPU Inspector (AGI) provides frame profiling and shader debugging:- Install AGI from the Android developer website
- Connect your device via USB
- Launch AGI and select your application
- 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
- Vulkan on Android - Official getting started guide
- OpenGL ES Reference - OpenGL ES specifications and documentation
- Android GPU Inspector - Graphics profiling tool