$ show android/games-samples
This repository is a collection of sample applications and plugins for Android game development, maintained by Google. It demonstrates integration of the Android Game Development Kit (AGDK), Google Play Games Services, Play Asset Delivery, Adaptive Performance (ADPF), Game Mode, game controllers, and more. The samples span multiple engines: native C++ (NDK), Unity, Unreal Engine, and Godot. Each sample is a self-contained project with its own entry points (e.g., `android_main()` for native apps, `MainActivity` for Java, Unity scenes, Unreal game instances). The architecture varies per sample but commonly follows a scene-based game loop with a `SceneManager` singleton, input handling via cooked events, and rendering through either OpenGL ES or Vulkan via the `simple_renderer` abstraction. External dependencies include the Android SDK/NDK, Google Play Services libraries, and third-party libraries like glm, Bullet Physics, and Dear ImGui. The repo also includes utility tools like a Tuning Fork validation tool and Unity plugins for ANR detection and memory monitoring. While many components are well-crafted and reusable (e.g., `simple_renderer`, `base_game_framework`, `ndk_helper`), there is significant code duplication across samples and some use of deprecated APIs, indicating a moderate level of technical drift.
The LLM identified 5 files worth highlighting for reuse:
Defines a pure virtual `Renderer` interface that abstracts over OpenGL ES and Vulkan implementations. Provides methods for creating buffers, textures, shader programs, render passes, and render states. The concrete implementations (`RendererGLES` and `RendererVk`) are selected at runtime via `SetRendererAPI()`. This component is self-contained, depends only on standard types and platform headers, and can be extracted into a new project to provide a portable graphics backend.
Manages display initialization, swapchain creation, and graphics API selection (GLES/Vulkan). Provides a singleton `DisplayManager` with methods like `InitializeDisplay()`, `SetRendererAPI()`, and `GetDisplayWidth()`. It abstracts platform-specific details (EGL, Vulkan surface) and is used across multiple samples. The interface is clean and could be reused in any Android native game project.
Encapsulates EGL context creation, destruction, and management for OpenGL ES rendering. Provides methods for initializing the display, surface, and context, as well as swapping buffers and handling context loss. This is a standalone utility that can be reused in any Android NDK project requiring OpenGL ES rendering without the full game framework.
Singleton manager for Android Dynamic Performance Framework (ADPF). Provides methods to register thermal status listeners, get thermal headroom, monitor battery current, and create performance hint sessions. Uses JNI to call Java APIs. This component is self-contained and can be extracted to add thermal-aware performance tuning to any Android game.
Manages loading of game assets from Play Asset Delivery packs (install-time, fast-follow, on-demand). Provides an asynchronous interface with callbacks for download progress, completion, and error handling. Uses the Play Asset Delivery native SDK. This component is reusable for any Android game that wants to use Play Asset Delivery for asset management.