Files
questshock/android/engine-patches/11-android-openxr-cmake.patch
T
ml 2300d081c3
build / build (push) Successful in 2m12s
Add OpenXR bring-up: render the game as a floating quad in an immersive Quest session
- New android/app/src/main/cpp/xr_session.c (+.h): owns the OpenXR
  instance/session/local-space/swapchain and the per-frame
  xrWaitFrame/xrBeginFrame/xrEndFrame loop, submitting the game's
  existing flat render as a single head-tracked XrCompositionLayerQuad.
  No stereo rendering or controller input yet - that's steps B/C/D of
  the plan.
- 11-android-openxr-cmake.patch: links the OpenXR loader as a build
  dependency, staged into jniLibs the same way as gl4es/SDL2.
  build-image/Dockerfile and prepare-android-project.sh build and stage
  it.
- 12-android-openxr-present.patch: redirects OpenGL.cc's final present
  step (opengl_swap_and_restore / SDLDraw's software path) into the XR
  swapchain FBO instead of the window, on Android only. Two real gl4es
  bugs had to be worked around to get pixels on screen at all:
    - gl4es's own glBindFramebuffer errors on an FBO id it didn't create
      itself, even though the real driver-level bind succeeds - fixed by
      creating the swapchain FBO container via gl4es's own
      glGenFramebuffers/glBindFramebuffer, and only using the real
      (dlsym'd) driver call for attaching OpenXR's foreign swapchain
      texture, which gl4es's own attach can't handle.
    - gl4es's glBegin/glVertexAttrib/glVertex3f immediate-mode emulation
      only captures a fresh per-vertex value for attribute 0 (position,
      driven directly by glVertex3f) - custom attributes like this
      shader's texcoords/light are GLES2's *constant*-attribute API and
      applied once for the whole draw, not per vertex, silently
      collapsing the UI-overlay quad to a single sampled texel. Fixed by
      switching that one draw call to real vertex arrays
      (glVertexAttribPointer/glDrawArrays).
  Also flips the V texcoord to match SDL's top-down row order against
  GL's texture convention, and reuses a persistent texture object
  instead of a fresh gen/upload/delete every frame.
- AndroidManifest.xml: declares the immersive-HMD intent category and
  focus-aware metadata, drops the 2D-panel layout hint.
- README: documents the new OpenXR immersive mode.
2026-07-25 07:25:27 +02:00

40 lines
1.2 KiB
Diff

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,6 +64,19 @@
endif(WIN32)
endif(ENABLE_OPENGL)
+# OpenXR loader (Android only for now - see android/app/src/main/cpp/
+# xr_session.c, which submits the game's existing render as a composition
+# layer instead of presenting to a normal window/surface). EGL is linked
+# explicitly too - xr_session.c calls eglGetCurrentDisplay/Context/
+# QueryContext/ChooseConfig directly (to share the GL context gl4es/SDL
+# already made), and unlike GL itself (where gl4es's own libGL.so already
+# provides every symbol the engine or xr_session.c call), there's no other
+# EGL provider in this link.
+if(ANDROID)
+ set(OPENXR_INCLUDE_DIRS ${ANDROID_PREBUILT_DIR}/openxr/include)
+ set(OPENXR_LIBRARIES ${ANDROID_PREBUILT_DIR}/openxr/lib/libopenxr_loader.so EGL)
+endif(ANDROID)
+
if(ENABLE_SDL2 MATCHES "ON")
find_package(SDL2 REQUIRED)
if(SDL2_FOUND)
@@ -109,6 +122,8 @@
${SDL2_MIXER_INCLUDE_DIRS}
${FLUIDSYNTH_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
+ ${OPENXR_INCLUDE_DIRS}
+ ${ANDROID_EXTRA_INCLUDE_DIRS}
)
if(NOT WIN32)
@@ -439,6 +454,7 @@
${SDL2_MIXER_LIBRARIES}
${FLUIDSYNTH_LIBRARIES}
${OPENGL_LIBRARIES}
+ ${OPENXR_LIBRARIES}
${ALSA_LIBRARIES}
$<$<BOOL:${ANDROID}>:log>
)