Share retained app UI GL dispatch
This commit is contained in:
65
src/app.cpp
65
src/app.cpp
@@ -19,6 +19,7 @@
|
||||
#include "legacy_document_open_services.h"
|
||||
#include "legacy_document_session_services.h"
|
||||
#include "legacy_recording_services.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "platform_api/platform_services.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
|
||||
@@ -41,11 +42,6 @@ namespace {
|
||||
return reinterpret_cast<const char*>(glGetString(static_cast<GLenum>(name)));
|
||||
}
|
||||
|
||||
void enable_opengl_state(std::uint32_t state) noexcept
|
||||
{
|
||||
glEnable(static_cast<GLenum>(state));
|
||||
}
|
||||
|
||||
pp::app::CanvasToolMode canvas_tool_mode_from_canvas_mode(kCanvasMode mode) noexcept
|
||||
{
|
||||
switch (mode) {
|
||||
@@ -76,47 +72,12 @@ pp::app::CanvasToolMode canvas_tool_mode_from_canvas_mode(kCanvasMode mode) noex
|
||||
}
|
||||
}
|
||||
|
||||
void disable_opengl_state(std::uint32_t state) noexcept
|
||||
{
|
||||
glDisable(static_cast<GLenum>(state));
|
||||
}
|
||||
|
||||
void set_opengl_blend_func(std::uint32_t source_factor, std::uint32_t destination_factor) noexcept
|
||||
{
|
||||
glBlendFunc(static_cast<GLenum>(source_factor), static_cast<GLenum>(destination_factor));
|
||||
}
|
||||
|
||||
void set_opengl_blend_equation_separate(std::uint32_t color_equation, std::uint32_t alpha_equation) noexcept
|
||||
{
|
||||
glBlendEquationSeparate(static_cast<GLenum>(color_equation), static_cast<GLenum>(alpha_equation));
|
||||
}
|
||||
|
||||
void clear_opengl_color(float r, float g, float b, float a) noexcept
|
||||
{
|
||||
glClearColor(r, g, b, a);
|
||||
}
|
||||
|
||||
void clear_opengl_buffers(std::uint32_t mask) noexcept
|
||||
{
|
||||
glClear(static_cast<GLbitfield>(mask));
|
||||
}
|
||||
|
||||
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 set_opengl_scissor(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept
|
||||
{
|
||||
glScissor(static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
|
||||
}
|
||||
|
||||
void apply_app_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 viewport failed: %s", status.message);
|
||||
@@ -127,9 +88,9 @@ void apply_app_scissor(pp::renderer::gl::OpenGlScissorRect scissor)
|
||||
const auto status = pp::renderer::gl::apply_opengl_scissor_rect(
|
||||
scissor,
|
||||
pp::renderer::gl::OpenGlScissorDispatch {
|
||||
.enable = enable_opengl_state,
|
||||
.disable = disable_opengl_state,
|
||||
.scissor = set_opengl_scissor,
|
||||
.enable = pp::legacy::ui_gl::enable_opengl_state,
|
||||
.disable = pp::legacy::ui_gl::disable_opengl_state,
|
||||
.scissor = pp::legacy::ui_gl::set_opengl_scissor,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL scissor failed: %s", status.message);
|
||||
@@ -140,8 +101,8 @@ void apply_app_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 scissor test failed: %s", status.message);
|
||||
@@ -225,8 +186,8 @@ void App::clear()
|
||||
{
|
||||
const auto status = pp::renderer::gl::clear_panopainter_default_target(
|
||||
pp::renderer::gl::OpenGlClearDispatch {
|
||||
.clear_color = clear_opengl_color,
|
||||
.clear = clear_opengl_buffers,
|
||||
.clear_color = pp::legacy::ui_gl::set_opengl_clear_color,
|
||||
.clear = pp::legacy::ui_gl::clear_opengl_buffer,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL clear failed: %s", status.message);
|
||||
@@ -462,10 +423,10 @@ void App::init()
|
||||
App::I->apply_render_platform_hints();
|
||||
const auto startup_state_status = pp::renderer::gl::apply_panopainter_initial_state(
|
||||
pp::renderer::gl::OpenGlStateDispatch {
|
||||
.enable = enable_opengl_state,
|
||||
.disable = disable_opengl_state,
|
||||
.blend_func = set_opengl_blend_func,
|
||||
.blend_equation_separate = set_opengl_blend_equation_separate,
|
||||
.enable = pp::legacy::ui_gl::enable_opengl_state,
|
||||
.disable = pp::legacy::ui_gl::disable_opengl_state,
|
||||
.blend_func = pp::legacy::ui_gl::set_opengl_blend_func,
|
||||
.blend_equation_separate = pp::legacy::ui_gl::set_opengl_blend_equation_separate,
|
||||
});
|
||||
if (!startup_state_status.ok())
|
||||
LOG("OpenGL startup state failed: %s", startup_state_status.message);
|
||||
|
||||
Reference in New Issue
Block a user