Skip to content

Add Android support and fix GLES renderer/audio compatibility#40

Closed
Simon358 wants to merge 2 commits into
CTR-tools:masterfrom
Simon358:feature/add-android-support
Closed

Add Android support and fix GLES renderer/audio compatibility#40
Simon358 wants to merge 2 commits into
CTR-tools:masterfrom
Simon358:feature/add-android-support

Conversation

@Simon358

Copy link
Copy Markdown

This PR introduces several critical fixes to enable the Android port to build, launch, and run with stable graphics and audio.

  1. Build System & Dependency Fixes

    Gradle Downgrade: Updated gradle-wrapper.properties to use Gradle 8.7. This resolves a "configuration mutation" error caused by an incompatibility between Gradle 9.x and Android Gradle Plugin 8.2.2.

    Missing Assets: Updated app/build.gradle to include external SDL resource directories in the sourceSets, fixing a resource linking error (ic_launcher not found).

    Library Bundling: Modified CMakeLists.txt to build SDL3 as a shared library (SDL_SHARED ON), ensuring libSDL3.so is correctly bundled into the APK for runtime linking.
  2. Graphics & Renderer Improvements (OpenGL ES Support)

    Mobile-Native Context: Updated NativeRenderer_InitialiseGLContext to request an OpenGL ES 3.0 context on Android instead of the desktop-only OpenGL 3.3 Core profile.

    GLES-Compatible Function Loading: Switched NativeRenderer_InitialiseGLExt to use SDL_GL_GetProcAddress on Android, allowing SDL to handle cross-platform function resolution for mobile drivers.

    Desktop-to-Mobile Readback Fix: Replaced desktop-only glGetTexImage calls with a glReadPixels implementation using framebuffers. This was necessary as glGetTexImage is not available in the OpenGL ES specification.

    Format & Precision:

    Changed internal VRAM format to GL_RG8 on Android to match 8-bit component expectations of mobile GPUs.

    Increased shader integer precision to mediump to prevent indexing artifacts on mobile hardware.

    Feature Gating: Wrapped glPolygonMode (desktop-only) in an #ifndef ANDROID block to prevent crashes.
  3. Audio Fixes

    Driver Selection: Updated NativeAudio_SelectDriverHint to skip Linux-specific sound system hints (alsa, pulseaudio) when running on Android, allowing SDL to correctly initialize the mobile audio driver.

    Logcat Integration: Replaced standard printf/fprintf calls in the audio subsystem with Platform_Log to ensure audio initialization and error messages are visible in Android's Logcat.

@kkv0n

kkv0n commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

hmm with graphics changes i am mostly worried about the render changes since we optimized it recently, having the bottleneck back would be terrible D:

@aalhendi

Copy link
Copy Markdown
Collaborator

Closing as duplicate in favor of #41

@aalhendi aalhendi closed this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants