Route VR and startup GL state through backend
This commit is contained in:
@@ -29,6 +29,11 @@ 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));
|
||||
@@ -75,6 +80,20 @@ void apply_vr_render_capability(std::uint32_t state, bool enabled)
|
||||
LOG("OpenGL VR render state failed: %s", status.message);
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
if (!result.ok()) {
|
||||
LOG("OpenGL VR render state query failed: %s", result.status().message);
|
||||
return false;
|
||||
}
|
||||
return result.value();
|
||||
}
|
||||
|
||||
void clear_vr_depth_buffer()
|
||||
{
|
||||
const auto status = pp::renderer::gl::clear_opengl_buffers(
|
||||
@@ -262,8 +281,8 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
||||
glm::vec3 origin = glm::vec3(0, 0, -1) * glm::transpose(glm::mat3(pose));
|
||||
vr_rot = glm::lookAt({ 0, 0, 0 }, origin, { 0, 1, 0 });
|
||||
|
||||
auto blend = glIsEnabled(pp::renderer::gl::blend_state());
|
||||
auto depth = glIsEnabled(pp::renderer::gl::depth_test_state());
|
||||
const bool blend = query_vr_render_capability(pp::renderer::gl::blend_state());
|
||||
const bool depth = query_vr_render_capability(pp::renderer::gl::depth_test_state());
|
||||
|
||||
apply_vr_render_capability(pp::renderer::gl::blend_state(), false);
|
||||
apply_vr_render_capability(pp::renderer::gl::depth_test_state(), false);
|
||||
@@ -556,8 +575,8 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
||||
mode->on_Draw(ortho_proj, proj, camera);
|
||||
*/
|
||||
|
||||
apply_vr_render_capability(pp::renderer::gl::blend_state(), blend != 0U);
|
||||
apply_vr_render_capability(pp::renderer::gl::depth_test_state(), depth != 0U);
|
||||
apply_vr_render_capability(pp::renderer::gl::blend_state(), blend);
|
||||
apply_vr_render_capability(pp::renderer::gl::depth_test_state(), depth);
|
||||
sampler.unbind();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user