Route paint render state through GL backend

This commit is contained in:
2026-06-04 22:19:54 +02:00
parent 24197c5f7e
commit d55f26d637
7 changed files with 304 additions and 73 deletions

View File

@@ -1,8 +1,34 @@
#include "pch.h"
#include "hmd.h"
#include "log.h"
#include "renderer_gl/opengl_capabilities.h"
#include <array>
namespace {
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 apply_hmd_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
{
const auto status = pp::renderer::gl::apply_opengl_viewport(
pp::renderer::gl::OpenGlViewportRect {
.x = x,
.y = y,
.width = width,
.height = height,
},
pp::renderer::gl::OpenGlViewportDispatch {
.viewport = set_opengl_viewport,
});
if (!status.ok())
LOG("HMD viewport dispatch failed because: %s", status.message);
}
}
std::map<ViveController::kButton, ViveController::kButtonMask> ViveController::m_mask {
{ ViveController::kButton::Trigger, ViveController::kButtonMask::TriggerBit },
{ ViveController::kButton::Pad, ViveController::kButtonMask::PadBit },
@@ -181,7 +207,7 @@ void Vive::Draw()
{
m_eyes[eye].bindFramebuffer();
m_eyes[eye].clear();
glViewport(0, 0, m_eyes[eye].getWidth(), m_eyes[eye].getHeight());
apply_hmd_viewport(0, 0, m_eyes[eye].getWidth(), m_eyes[eye].getHeight());
if (on_draw)
on_draw(m_proj[eye], m_view[eye], m_pose);