Route GL state snapshot through renderer GL
This commit is contained in:
@@ -124,9 +124,36 @@ struct OpenGlInitialState {
|
||||
std::uint32_t alpha_equation = 0;
|
||||
};
|
||||
|
||||
struct OpenGlSavedState {
|
||||
std::uint8_t blend_enabled = 0;
|
||||
std::uint8_t depth_test_enabled = 0;
|
||||
std::uint8_t scissor_test_enabled = 0;
|
||||
std::array<std::int32_t, 4> viewport {};
|
||||
std::array<float, 4> clear_color {};
|
||||
std::array<std::int32_t, 10> texture_2d_bindings {};
|
||||
std::array<std::int32_t, 10> sampler_bindings {};
|
||||
std::int32_t cube_map_binding = 0;
|
||||
std::int32_t program = 0;
|
||||
std::int32_t draw_framebuffer = 0;
|
||||
std::int32_t read_framebuffer = 0;
|
||||
std::int32_t active_texture = 0;
|
||||
};
|
||||
|
||||
using OpenGlCapabilityFn = void (*)(std::uint32_t state) noexcept;
|
||||
using OpenGlIsEnabledFn = std::uint8_t (*)(std::uint32_t state) noexcept;
|
||||
using OpenGlGetIntegerFn = void (*)(std::uint32_t name, std::int32_t* value) noexcept;
|
||||
using OpenGlGetFloatFn = void (*)(std::uint32_t name, float* value) noexcept;
|
||||
using OpenGlActiveTextureFn = void (*)(std::uint32_t texture_unit) noexcept;
|
||||
using OpenGlClearColorFn = void (*)(float r, float g, float b, float a) noexcept;
|
||||
using OpenGlClearFn = void (*)(std::uint32_t mask) noexcept;
|
||||
using OpenGlViewportFn = void (*)(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept;
|
||||
using OpenGlScissorFn = void (*)(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept;
|
||||
using OpenGlBlendFuncFn = void (*)(std::uint32_t source_factor, std::uint32_t destination_factor) noexcept;
|
||||
using OpenGlBlendEquationSeparateFn = void (*)(std::uint32_t color_equation, std::uint32_t alpha_equation) noexcept;
|
||||
using OpenGlUseProgramFn = void (*)(std::uint32_t program) noexcept;
|
||||
using OpenGlBindFramebufferFn = void (*)(std::uint32_t target, std::uint32_t framebuffer) noexcept;
|
||||
using OpenGlBindTextureFn = void (*)(std::uint32_t target, std::uint32_t texture) noexcept;
|
||||
using OpenGlBindSamplerFn = void (*)(std::uint32_t unit, std::uint32_t sampler) noexcept;
|
||||
|
||||
struct OpenGlStateDispatch {
|
||||
OpenGlCapabilityFn enable = nullptr;
|
||||
@@ -135,6 +162,25 @@ struct OpenGlStateDispatch {
|
||||
OpenGlBlendEquationSeparateFn blend_equation_separate = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlStateSnapshotDispatch {
|
||||
OpenGlIsEnabledFn is_enabled = nullptr;
|
||||
OpenGlGetIntegerFn get_integer = nullptr;
|
||||
OpenGlGetFloatFn get_float = nullptr;
|
||||
OpenGlActiveTextureFn active_texture = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlStateRestoreDispatch {
|
||||
OpenGlCapabilityFn enable = nullptr;
|
||||
OpenGlCapabilityFn disable = nullptr;
|
||||
OpenGlViewportFn viewport = nullptr;
|
||||
OpenGlClearColorFn clear_color = nullptr;
|
||||
OpenGlBindFramebufferFn bind_framebuffer = nullptr;
|
||||
OpenGlUseProgramFn use_program = nullptr;
|
||||
OpenGlActiveTextureFn active_texture = nullptr;
|
||||
OpenGlBindTextureFn bind_texture = nullptr;
|
||||
OpenGlBindSamplerFn bind_sampler = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlRuntimeInfo {
|
||||
const char* version = "";
|
||||
const char* vendor = "";
|
||||
@@ -153,11 +199,6 @@ struct OpenGlDefaultClear {
|
||||
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;
|
||||
using OpenGlViewportFn = void (*)(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept;
|
||||
using OpenGlScissorFn = void (*)(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept;
|
||||
|
||||
struct OpenGlClearDispatch {
|
||||
OpenGlClearColorFn clear_color = nullptr;
|
||||
OpenGlClearFn clear = nullptr;
|
||||
@@ -194,6 +235,11 @@ struct OpenGlBufferClearDispatch {
|
||||
OpenGlCapabilities capabilities) noexcept;
|
||||
[[nodiscard]] OpenGlInitialState panopainter_initial_state() noexcept;
|
||||
[[nodiscard]] pp::foundation::Status apply_panopainter_initial_state(OpenGlStateDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<OpenGlSavedState> snapshot_opengl_state(
|
||||
OpenGlStateSnapshotDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status restore_opengl_state(
|
||||
const OpenGlSavedState& state,
|
||||
OpenGlStateRestoreDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<OpenGlRuntimeInfo> query_opengl_runtime_info(
|
||||
OpenGlRuntimeInfoDispatch dispatch) noexcept;
|
||||
[[nodiscard]] OpenGlDefaultClear panopainter_default_clear() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user