Move convert GL state into renderer backend

This commit is contained in:
2026-06-04 20:27:43 +02:00
parent 51601adf6d
commit 967a15f15f
8 changed files with 172 additions and 25 deletions

View File

@@ -273,6 +273,47 @@ pp::foundation::Status apply_panopainter_initial_state(OpenGlStateDispatch dispa
return pp::foundation::Status::success();
}
OpenGlConvertCommandState panopainter_convert_command_state() noexcept
{
return OpenGlConvertCommandState {
.depth_test_enabled = false,
.program_point_size_enabled = true,
.depth_test_state = depth_test_state(),
.program_point_size_state = program_point_size_state(),
.source_color_factor = source_alpha_blend_factor(),
.destination_color_factor = one_minus_source_alpha_blend_factor(),
.blend_equation = add_blend_equation(),
};
}
pp::foundation::Status apply_panopainter_convert_command_state(
OpenGlConvertCommandStateDispatch dispatch) noexcept
{
if (dispatch.enable == nullptr
|| dispatch.disable == nullptr
|| dispatch.blend_func == nullptr
|| dispatch.blend_equation == nullptr)
{
return pp::foundation::Status::invalid_argument(
"OpenGL convert command state dispatch callbacks must not be null");
}
const auto state = panopainter_convert_command_state();
if (state.depth_test_enabled)
dispatch.enable(state.depth_test_state);
else
dispatch.disable(state.depth_test_state);
if (state.program_point_size_enabled)
dispatch.enable(state.program_point_size_state);
else
dispatch.disable(state.program_point_size_state);
dispatch.blend_func(state.source_color_factor, state.destination_color_factor);
dispatch.blend_equation(state.blend_equation);
return pp::foundation::Status::success();
}
pp::foundation::Result<OpenGlSavedState> snapshot_opengl_state(OpenGlStateSnapshotDispatch dispatch) noexcept
{
if (dispatch.is_enabled == nullptr