|
| 1 | +# Hawkeye Android |
| 2 | + |
| 3 | +Android port of the Hawkeye 3D renderer, running the desktop C/Raylib scene natively on Android via NativeActivity and OpenGL ES 3.0. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +The app has no Java/Kotlin logic beyond the manifest declaration. `NativeActivity` loads `libhawkeye.so`, which runs a standard C `main()` entry point via Raylib's Android platform backend. |
| 8 | + |
| 9 | +``` |
| 10 | +android/ |
| 11 | +├── app/src/main/ |
| 12 | +│ ├── AndroidManifest.xml — declares NativeActivity, requires OpenGL ES 3.0 |
| 13 | +│ ├── assets/ — all symlinks into the parent Hawkeye project |
| 14 | +│ │ ├── fonts -> ../../../../fonts |
| 15 | +│ │ ├── models -> ../../../../models |
| 16 | +│ │ ├── shaders -> ../../../../shaders |
| 17 | +│ │ └── themes -> ../../../../themes |
| 18 | +│ └── cpp/ |
| 19 | +│ ├── CMakeLists.txt — fetches Raylib 5.5, compiles rendering subset |
| 20 | +│ └── android_main.c — entry point: scene_init + vehicle_init + render loop |
| 21 | +``` |
| 22 | + |
| 23 | +The Hawkeye source files compiled in are: `scene.c`, `vehicle.c`, `asset_path.c`, `theme.c`, `ortho_panel.c`. MAVLink, ULog, HUD, and replay code are excluded. |
| 24 | + |
| 25 | +## Shader Compatibility |
| 26 | + |
| 27 | +The original shaders use `#version 330` (desktop OpenGL). On Android they are patched at load time via Raylib's `SetLoadFileTextCallback`: |
| 28 | + |
| 29 | +- `#version 330` → `#version 300 es` |
| 30 | +- `precision mediump float;` is injected into fragment shaders |
| 31 | + |
| 32 | +No shader copies are kept in the Android project — the `shaders/` asset dir is a symlink to the originals. |
| 33 | + |
| 34 | +## Environment Setup |
| 35 | + |
| 36 | +If you haven't done Android development before, here's what you need: |
| 37 | + |
| 38 | +### 1. Install Android Studio |
| 39 | + |
| 40 | +Download and install [Android Studio](https://developer.android.com/studio) for your platform (macOS, Linux, or Windows). The installer includes the Android SDK and the SDK Manager. |
| 41 | + |
| 42 | +### 2. Install the NDK and CMake |
| 43 | + |
| 44 | +Open Android Studio, go to **Settings → Languages & Frameworks → Android SDK → SDK Tools**, check: |
| 45 | + |
| 46 | +- **NDK (Side by side)** — install version `30.0.14904198` |
| 47 | +- **CMake** — install version `3.22.1` |
| 48 | + |
| 49 | +Click **Apply**. |
| 50 | + |
| 51 | +Alternatively, from the command line (replace `$ANDROID_SDK_ROOT` with your SDK path — typically `~/Library/Android/sdk` on macOS or `~/Android/Sdk` on Linux): |
| 52 | + |
| 53 | +```bash |
| 54 | +$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "ndk;30.0.14904198" "cmake;3.22.1" |
| 55 | +``` |
| 56 | + |
| 57 | +### 3. Open the project |
| 58 | + |
| 59 | +Open the `android/` directory in Android Studio. Gradle will sync automatically and download any remaining dependencies. |
| 60 | + |
| 61 | +### Note on symlinks |
| 62 | + |
| 63 | +The `assets/` directory uses symlinks into the parent repo (fonts, models, shaders, themes). These work on macOS and Linux out of the box. On Windows, either enable [Developer Mode](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) before cloning or use WSL. |
| 64 | + |
| 65 | +## Requirements |
| 66 | + |
| 67 | +- Android SDK (API 29+) |
| 68 | +- NDK 30.0.14904198 |
| 69 | +- CMake 3.22+ |
| 70 | +- A device or emulator with OpenGL ES 3.0 support |
| 71 | + |
| 72 | +## Building |
| 73 | + |
| 74 | +```bash |
| 75 | +./gradlew assembleDebug |
| 76 | +``` |
| 77 | + |
| 78 | +Raylib 5.5 is fetched automatically by CMake on the first build. Built ABIs: `arm64-v8a`, `x86_64`. |
| 79 | + |
| 80 | +## Deploying |
| 81 | + |
| 82 | +```bash |
| 83 | +adb install -r app/build/outputs/apk/debug/app-debug.apk |
| 84 | +adb shell am start -n com.px4.hawkeye.android/android.app.NativeActivity |
| 85 | +``` |
| 86 | + |
0 commit comments