Move initial GL state policy into renderer GL
This commit is contained in:
40
src/app.cpp
40
src/app.cpp
@@ -45,36 +45,11 @@ namespace {
|
||||
return static_cast<GLenum>(pp::renderer::gl::shading_language_version_string_name());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum depth_test_state() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::depth_test_state());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum scissor_test_state() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::scissor_test_state());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum source_alpha_blend_factor() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::source_alpha_blend_factor());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum one_minus_source_alpha_blend_factor() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::one_minus_source_alpha_blend_factor());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum add_blend_equation() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::add_blend_equation());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum max_blend_equation() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::max_blend_equation());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLint rgba8_internal_format() noexcept
|
||||
{
|
||||
return static_cast<GLint>(pp::renderer::gl::rgba8_internal_format());
|
||||
@@ -414,10 +389,19 @@ void App::init()
|
||||
// }
|
||||
//}
|
||||
|
||||
glDisable(depth_test_state());
|
||||
const auto initial_state = pp::renderer::gl::panopainter_initial_state();
|
||||
if (initial_state.depth_test_enabled)
|
||||
glEnable(static_cast<GLenum>(initial_state.depth_test_state));
|
||||
else
|
||||
glDisable(static_cast<GLenum>(initial_state.depth_test_state));
|
||||
|
||||
App::I->apply_render_platform_hints();
|
||||
glBlendFunc(source_alpha_blend_factor(), one_minus_source_alpha_blend_factor());
|
||||
glBlendEquationSeparate(add_blend_equation(), max_blend_equation());
|
||||
glBlendFunc(
|
||||
static_cast<GLenum>(initial_state.source_color_factor),
|
||||
static_cast<GLenum>(initial_state.destination_color_factor));
|
||||
glBlendEquationSeparate(
|
||||
static_cast<GLenum>(initial_state.color_equation),
|
||||
static_cast<GLenum>(initial_state.alpha_equation));
|
||||
});
|
||||
|
||||
int run_counter = Settings::value<Serializer::Integer>("run_counter") + 1;
|
||||
|
||||
@@ -212,6 +212,18 @@ pp::renderer::RenderDeviceFeatures render_device_features(OpenGlCapabilities cap
|
||||
};
|
||||
}
|
||||
|
||||
OpenGlInitialState panopainter_initial_state() noexcept
|
||||
{
|
||||
return OpenGlInitialState {
|
||||
.depth_test_enabled = false,
|
||||
.depth_test_state = depth_test_state(),
|
||||
.source_color_factor = source_alpha_blend_factor(),
|
||||
.destination_color_factor = one_minus_source_alpha_blend_factor(),
|
||||
.color_equation = add_blend_equation(),
|
||||
.alpha_equation = max_blend_equation(),
|
||||
};
|
||||
}
|
||||
|
||||
std::uint32_t extension_count_query() noexcept
|
||||
{
|
||||
return gl_num_extensions;
|
||||
|
||||
@@ -115,11 +115,21 @@ struct OpenGlWindowsWglContextConfig {
|
||||
std::array<std::int32_t, 15> pixel_format_attributes {};
|
||||
};
|
||||
|
||||
struct OpenGlInitialState {
|
||||
bool depth_test_enabled = false;
|
||||
std::uint32_t depth_test_state = 0;
|
||||
std::uint32_t source_color_factor = 0;
|
||||
std::uint32_t destination_color_factor = 0;
|
||||
std::uint32_t color_equation = 0;
|
||||
std::uint32_t alpha_equation = 0;
|
||||
};
|
||||
|
||||
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
||||
std::span<const std::string_view> extensions,
|
||||
OpenGlRuntime runtime) noexcept;
|
||||
[[nodiscard]] pp::renderer::RenderDeviceFeatures render_device_features(
|
||||
OpenGlCapabilities capabilities) noexcept;
|
||||
[[nodiscard]] OpenGlInitialState panopainter_initial_state() noexcept;
|
||||
|
||||
[[nodiscard]] std::uint32_t extension_count_query() noexcept;
|
||||
[[nodiscard]] std::uint32_t extension_string_name() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user