From 7dcf76c3aa299a51d1dcac3a2bb3691217a5992c Mon Sep 17 00:00:00 2001 From: omigamedev Date: Wed, 3 Jun 2026 05:59:36 +0200 Subject: [PATCH] Route VR UI viewport scissor through renderer GL --- docs/modernization/build-inventory.md | 6 ++-- docs/modernization/roadmap.md | 3 ++ src/app_vr.cpp | 47 +++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 16087f4..1b73482 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -463,9 +463,9 @@ Known local toolchain state: policy and dispatch application consumed by `App::init`, tested runtime version/vendor/renderer/GLSL string query dispatch, tested default clear color/buffer dispatch consumed by `App::clear`, tested app UI - viewport/scissor dispatch consumed by `App::draw`, plus renderer API to - OpenGL token mapping and command-planning contracts used by the OpenGL parity - work. + viewport/scissor dispatch consumed by `App::draw` and `App::vr_draw_ui`, + plus renderer API to OpenGL token mapping and command-planning contracts used + by the OpenGL parity work. - `pano_cli plan-cloud-upload` exposes `pp_app_core` cloud upload availability, new-document warning, publish prompt, and save-before-upload planning as JSON; the live cloud upload command consumes the same start contract before diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 5286f36..e5b8b8d 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -528,6 +528,9 @@ Main app UI viewport and scissor execution now dispatch through tested `pp_renderer_gl` viewport/scissor contracts, leaving `App::draw` and UI node clipping to provide rectangles while the backend owns scissor-state tokens and the live OpenGL call sequence. +VR UI framebuffer viewport and scissor-test setup now also consumes those +`pp_renderer_gl` contracts, keeping desktop and VR UI rendering aligned while +the retained OpenVR app path is split incrementally. Windows RenderDoc frame capture hooks now also dispatch through `PlatformServices`, keeping capture integration in the platform service while leaving non-Windows adapters as no-ops. diff --git a/src/app_vr.cpp b/src/app_vr.cpp index 4b22ba7..c966c32 100644 --- a/src/app_vr.cpp +++ b/src/app_vr.cpp @@ -24,6 +24,44 @@ void unbind_texture_2d() glBindTexture(pp::renderer::gl::texture_2d_target(), 0); } +void enable_opengl_state(std::uint32_t state) noexcept +{ + glEnable(static_cast(state)); +} + +void disable_opengl_state(std::uint32_t state) noexcept +{ + glDisable(static_cast(state)); +} + +void set_opengl_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept +{ + glViewport(static_cast(x), static_cast(y), static_cast(width), static_cast(height)); +} + +void apply_vr_ui_viewport(pp::renderer::gl::OpenGlViewportRect viewport) +{ + const auto status = pp::renderer::gl::apply_opengl_viewport( + viewport, + pp::renderer::gl::OpenGlViewportDispatch { + .viewport = set_opengl_viewport, + }); + if (!status.ok()) + LOG("OpenGL VR UI viewport failed: %s", status.message); +} + +void apply_vr_ui_scissor_test(bool enabled) +{ + const auto status = pp::renderer::gl::apply_opengl_scissor_test( + enabled, + pp::renderer::gl::OpenGlScissorTestDispatch { + .enable = enable_opengl_state, + .disable = disable_opengl_state, + }); + if (!status.ok()) + LOG("OpenGL VR UI scissor test failed: %s", status.message); +} + } bool trigger_down = false; @@ -55,13 +93,16 @@ void App::vr_draw_ui() { uirtt.bindFramebuffer(); uirtt.clear(); - glViewport(0, 0, uirtt.getWidth(), uirtt.getHeight()); - glEnable(pp::renderer::gl::scissor_test_state()); + apply_vr_ui_viewport(pp::renderer::gl::OpenGlViewportRect { + .width = static_cast(uirtt.getWidth()), + .height = static_cast(uirtt.getHeight()), + }); + apply_vr_ui_scissor_test(true); auto observer = std::bind(&App::update_ui_observer, this, std::placeholders::_1); for (int i = 1; i < layout[main_id]->m_children.size(); i++) layout[main_id]->m_children[i]->watch(observer); //msgbox->watch(observer); - glDisable(pp::renderer::gl::scissor_test_state()); + apply_vr_ui_scissor_test(false); uirtt.unbindFramebuffer(); }