Add OpenXR bring-up: render the game as a floating quad in an immersive Quest session
build / build (push) Successful in 2m12s
build / build (push) Successful in 2m12s
- 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.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// Minimal OpenXR bring-up for questshock's immersive Quest build. Keeps the
|
||||
// game's own rendering untouched (see android/engine-patches/
|
||||
// 12-android-openxr-present.patch) - this module only owns the OpenXR
|
||||
// instance/session/swapchain and the final "submit a quad layer instead of
|
||||
// presenting to a window" step. No stereo rendering, no controller input
|
||||
// yet (see the plan's steps B/C/D for those) - the game composite is shown
|
||||
// as a single flat quad floating in front of the viewer.
|
||||
#ifndef QUESTSHOCK_XR_SESSION_H
|
||||
#define QUESTSHOCK_XR_SESSION_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Call once, right after init_opengl() (OpenGL.cc) has created and made
|
||||
// current the GL context SDL/gl4es already use - creates the OpenXR
|
||||
// instance/session sharing that same EGL display/context, plus one
|
||||
// swapchain sized to the game's logical resolution (game_width/height, i.e.
|
||||
// grd_cap->w/h - see Shock.c's InitSDL()). Returns false if OpenXR bring-up
|
||||
// failed (e.g. no runtime installed) - callers should fall back to the
|
||||
// existing window-present path in that case.
|
||||
bool xr_init(int game_width, int game_height);
|
||||
|
||||
// Pumps XR session-state events. Call once per frame, before
|
||||
// xr_frame_begin(). Must still be called even when xr_init() returned
|
||||
// false (no-op in that case).
|
||||
void xr_poll_events(void);
|
||||
|
||||
// True once the session has reached a state where frames are expected
|
||||
// (XR_SESSION_STATE_SYNCHRONIZED or later) - i.e. it's safe/required to
|
||||
// start calling xr_frame_begin()/xr_frame_end() each frame.
|
||||
bool xr_is_session_running(void);
|
||||
|
||||
// Begins the XR frame (xrWaitFrame/xrBeginFrame) and, if the runtime wants
|
||||
// this frame rendered, acquires the next swapchain image and binds its
|
||||
// framebuffer as the current render target - ready for the caller to draw
|
||||
// into exactly as it would have drawn to the default framebuffer. Returns
|
||||
// true if the caller should draw this frame; xr_frame_end() must be called
|
||||
// unconditionally afterward either way (a begun XR frame must always be
|
||||
// ended, rendered or not).
|
||||
bool xr_frame_begin(void);
|
||||
|
||||
// Releases the swapchain image (if one was acquired this frame) and
|
||||
// submits it as a single XrCompositionLayerQuad positioned in front of the
|
||||
// local reference space's origin, then ends the XR frame.
|
||||
void xr_frame_end(void);
|
||||
|
||||
void xr_shutdown(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user