Map renderer blend state to OpenGL

This commit is contained in:
2026-06-02 20:26:55 +02:00
parent 36f9e73dd4
commit 728116da8f
5 changed files with 114 additions and 8 deletions

View File

@@ -813,6 +813,33 @@ OpenGlEnumMapping blend_equation_for_renderer_op(pp::renderer::BlendOp op) noexc
}
}
OpenGlBlendState blend_state_for_renderer_blend_state(pp::renderer::BlendState state) noexcept
{
const auto source_color = blend_factor_for_renderer_factor(state.source_color);
const auto destination_color = blend_factor_for_renderer_factor(state.destination_color);
const auto color_op = blend_equation_for_renderer_op(state.color_op);
const auto source_alpha = blend_factor_for_renderer_factor(state.source_alpha);
const auto destination_alpha = blend_factor_for_renderer_factor(state.destination_alpha);
const auto alpha_op = blend_equation_for_renderer_op(state.alpha_op);
return OpenGlBlendState {
.enabled = state.enabled ? gl_boolean_true : gl_boolean_false,
.source_color_factor = source_color.value,
.destination_color_factor = destination_color.value,
.color_equation = color_op.value,
.source_alpha_factor = source_alpha.value,
.destination_alpha_factor = destination_alpha.value,
.alpha_equation = alpha_op.value,
.color_write_mask = color_write_mask_for_renderer_blend_state(state),
.supported = source_color.supported
&& destination_color.supported
&& color_op.supported
&& source_alpha.supported
&& destination_alpha.supported
&& alpha_op.supported,
};
}
std::uint32_t rgba8_internal_format() noexcept
{
return gl_rgba8;