Share retained app UI GL dispatch

This commit is contained in:
2026-06-05 15:19:10 +02:00
parent 96d1903cf2
commit 26470e0fe8
7 changed files with 74 additions and 135 deletions

View File

@@ -3,6 +3,7 @@
#include <cstdint>
#include "app.h"
#include "legacy_ui_gl_dispatch.h"
#include "node_panel_grid.h"
#include "util.h"
#include "shape.h"
@@ -12,55 +13,12 @@ namespace {
void set_active_texture_unit(std::uint32_t unit_index)
{
const auto status = pp::renderer::gl::activate_opengl_texture_unit(
unit_index,
pp::renderer::gl::OpenGlActiveTextureDispatch {
.active_texture = [](std::uint32_t texture_unit) noexcept
{
glActiveTexture(static_cast<GLenum>(texture_unit));
},
});
if (!status.ok())
LOG("OpenGL VR active texture dispatch failed: %s", status.message);
pp::legacy::ui_gl::activate_texture_unit(unit_index, "OpenGL VR");
}
void unbind_texture_2d()
{
const auto status = pp::renderer::gl::bind_opengl_texture_2d(
0U,
pp::renderer::gl::OpenGlTexture2DBindDispatch {
.bind_texture = [](std::uint32_t target, std::uint32_t texture) noexcept
{
glBindTexture(static_cast<GLenum>(target), static_cast<GLuint>(texture));
},
});
if (!status.ok())
LOG("OpenGL VR texture unbind dispatch failed: %s", status.message);
}
void enable_opengl_state(std::uint32_t state) noexcept
{
glEnable(static_cast<GLenum>(state));
}
void disable_opengl_state(std::uint32_t state) noexcept
{
glDisable(static_cast<GLenum>(state));
}
std::uint8_t is_opengl_state_enabled(std::uint32_t state) noexcept
{
return static_cast<std::uint8_t>(glIsEnabled(static_cast<GLenum>(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<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
}
void clear_opengl_mask(std::uint32_t mask) noexcept
{
glClear(static_cast<GLbitfield>(mask));
pp::legacy::ui_gl::unbind_texture_2d("OpenGL VR");
}
void apply_vr_ui_viewport(pp::renderer::gl::OpenGlViewportRect viewport)
@@ -68,7 +26,7 @@ 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,
.viewport = pp::legacy::ui_gl::set_opengl_viewport,
});
if (!status.ok())
LOG("OpenGL VR UI viewport failed: %s", status.message);
@@ -79,8 +37,8 @@ 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,
.enable = pp::legacy::ui_gl::enable_opengl_state,
.disable = pp::legacy::ui_gl::disable_opengl_state,
});
if (!status.ok())
LOG("OpenGL VR UI scissor test failed: %s", status.message);
@@ -92,8 +50,8 @@ void apply_vr_render_capability(std::uint32_t state, bool enabled)
state,
enabled,
pp::renderer::gl::OpenGlCapabilityDispatch {
.enable = enable_opengl_state,
.disable = disable_opengl_state,
.enable = pp::legacy::ui_gl::enable_opengl_state,
.disable = pp::legacy::ui_gl::disable_opengl_state,
});
if (!status.ok())
LOG("OpenGL VR render state failed: %s", status.message);
@@ -104,7 +62,7 @@ bool query_vr_render_capability(std::uint32_t state)
const auto result = pp::renderer::gl::query_opengl_capability_state(
state,
pp::renderer::gl::OpenGlCapabilityStateQueryDispatch {
.is_enabled = is_opengl_state_enabled,
.is_enabled = pp::legacy::ui_gl::is_opengl_state_enabled,
});
if (!result.ok()) {
LOG("OpenGL VR render state query failed: %s", result.status().message);
@@ -118,7 +76,7 @@ void clear_vr_depth_buffer()
const auto status = pp::renderer::gl::clear_opengl_buffers(
pp::renderer::gl::framebuffer_depth_buffer_mask(),
pp::renderer::gl::OpenGlBufferClearDispatch {
.clear = clear_opengl_mask,
.clear = pp::legacy::ui_gl::clear_opengl_buffer,
});
if (!status.ok())
LOG("OpenGL VR depth clear failed: %s", status.message);