Route default clear through renderer GL
This commit is contained in:
24
src/app.cpp
24
src/app.cpp
@@ -55,6 +55,16 @@ void set_opengl_blend_equation_separate(std::uint32_t color_equation, std::uint3
|
||||
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));
|
||||
}
|
||||
|
||||
[[nodiscard]] GLint rgba8_internal_format() noexcept
|
||||
{
|
||||
return static_cast<GLint>(pp::renderer::gl::rgba8_internal_format());
|
||||
@@ -85,11 +95,6 @@ void set_opengl_blend_equation_separate(std::uint32_t color_equation, std::uint3
|
||||
return static_cast<GLuint>(pp::renderer::gl::default_framebuffer_id());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLbitfield framebuffer_color_buffer_mask() noexcept
|
||||
{
|
||||
return static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask());
|
||||
}
|
||||
|
||||
}
|
||||
std::thread App::render_thread;
|
||||
std::thread::id App::render_thread_id;
|
||||
@@ -208,8 +213,13 @@ bool App::request_close()
|
||||
|
||||
void App::clear()
|
||||
{
|
||||
glClearColor(.1f, .1f, .1f, 1.f);
|
||||
glClear(framebuffer_color_buffer_mask());
|
||||
const auto status = pp::renderer::gl::clear_panopainter_default_target(
|
||||
pp::renderer::gl::OpenGlClearDispatch {
|
||||
.clear_color = clear_opengl_color,
|
||||
.clear = clear_opengl_buffers,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL clear failed: %s", status.message);
|
||||
}
|
||||
|
||||
void App::initAssets()
|
||||
|
||||
@@ -261,6 +261,26 @@ pp::foundation::Result<OpenGlRuntimeInfo> query_opengl_runtime_info(
|
||||
});
|
||||
}
|
||||
|
||||
OpenGlDefaultClear panopainter_default_clear() noexcept
|
||||
{
|
||||
return OpenGlDefaultClear {
|
||||
.color = { 0.1F, 0.1F, 0.1F, 1.0F },
|
||||
.mask = framebuffer_color_buffer_mask(),
|
||||
};
|
||||
}
|
||||
|
||||
pp::foundation::Status clear_panopainter_default_target(OpenGlClearDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.clear_color == nullptr || dispatch.clear == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument("OpenGL clear dispatch callbacks must not be null");
|
||||
}
|
||||
|
||||
const auto clear = panopainter_default_clear();
|
||||
dispatch.clear_color(clear.color[0], clear.color[1], clear.color[2], clear.color[3]);
|
||||
dispatch.clear(clear.mask);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
std::uint32_t extension_count_query() noexcept
|
||||
{
|
||||
return gl_num_extensions;
|
||||
|
||||
@@ -148,6 +148,19 @@ struct OpenGlRuntimeInfoDispatch {
|
||||
OpenGlStringQueryFn get_string = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlDefaultClear {
|
||||
std::array<float, 4> color {};
|
||||
std::uint32_t mask = 0;
|
||||
};
|
||||
|
||||
using OpenGlClearColorFn = void (*)(float r, float g, float b, float a) noexcept;
|
||||
using OpenGlClearFn = void (*)(std::uint32_t mask) noexcept;
|
||||
|
||||
struct OpenGlClearDispatch {
|
||||
OpenGlClearColorFn clear_color = nullptr;
|
||||
OpenGlClearFn clear = nullptr;
|
||||
};
|
||||
|
||||
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
||||
std::span<const std::string_view> extensions,
|
||||
OpenGlRuntime runtime) noexcept;
|
||||
@@ -157,6 +170,8 @@ struct OpenGlRuntimeInfoDispatch {
|
||||
[[nodiscard]] pp::foundation::Status apply_panopainter_initial_state(OpenGlStateDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<OpenGlRuntimeInfo> query_opengl_runtime_info(
|
||||
OpenGlRuntimeInfoDispatch dispatch) noexcept;
|
||||
[[nodiscard]] OpenGlDefaultClear panopainter_default_clear() noexcept;
|
||||
[[nodiscard]] pp::foundation::Status clear_panopainter_default_target(OpenGlClearDispatch dispatch) noexcept;
|
||||
|
||||
[[nodiscard]] std::uint32_t extension_count_query() noexcept;
|
||||
[[nodiscard]] std::uint32_t extension_string_name() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user