Route Texture2D through renderer GL
This commit is contained in:
@@ -110,6 +110,37 @@ struct OpenGlRendererTextureFormat {
|
||||
std::uint32_t bytes_per_pixel = 0;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DAllocation {
|
||||
std::int32_t width = 0;
|
||||
std::int32_t height = 0;
|
||||
std::int32_t internal_format = 0;
|
||||
std::uint32_t pixel_format = 0;
|
||||
std::uint32_t component_type = 0;
|
||||
const void* data = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DUpdate {
|
||||
std::uint32_t texture_id = 0;
|
||||
std::int32_t width = 0;
|
||||
std::int32_t height = 0;
|
||||
std::uint32_t pixel_format = 0;
|
||||
std::uint32_t component_type = 0;
|
||||
const void* data = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DReadback {
|
||||
std::uint32_t texture_id = 0;
|
||||
std::int32_t width = 0;
|
||||
std::int32_t height = 0;
|
||||
OpenGlReadbackFormat format;
|
||||
void* pixels = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DReadbackResult {
|
||||
std::uint32_t framebuffer_status = 0;
|
||||
bool pixels_read = false;
|
||||
};
|
||||
|
||||
struct OpenGlWindowsWglContextConfig {
|
||||
std::array<std::int32_t, 9> context_attributes {};
|
||||
std::array<std::int32_t, 15> pixel_format_attributes {};
|
||||
@@ -154,6 +185,44 @@ 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;
|
||||
using OpenGlGenObjectsFn = void (*)(std::uint32_t count, std::uint32_t* ids) noexcept;
|
||||
using OpenGlDeleteObjectsFn = void (*)(std::uint32_t count, const std::uint32_t* ids) noexcept;
|
||||
using OpenGlTexImage2DFn = void (*)(
|
||||
std::uint32_t target,
|
||||
std::int32_t level,
|
||||
std::int32_t internal_format,
|
||||
std::int32_t width,
|
||||
std::int32_t height,
|
||||
std::int32_t border,
|
||||
std::uint32_t pixel_format,
|
||||
std::uint32_t component_type,
|
||||
const void* data) noexcept;
|
||||
using OpenGlTexSubImage2DFn = void (*)(
|
||||
std::uint32_t target,
|
||||
std::int32_t level,
|
||||
std::int32_t x,
|
||||
std::int32_t y,
|
||||
std::int32_t width,
|
||||
std::int32_t height,
|
||||
std::uint32_t pixel_format,
|
||||
std::uint32_t component_type,
|
||||
const void* data) noexcept;
|
||||
using OpenGlGenerateMipmapFn = void (*)(std::uint32_t target) noexcept;
|
||||
using OpenGlFramebufferTexture2DFn = void (*)(
|
||||
std::uint32_t target,
|
||||
std::uint32_t attachment,
|
||||
std::uint32_t texture_target,
|
||||
std::uint32_t texture,
|
||||
std::int32_t level) noexcept;
|
||||
using OpenGlCheckFramebufferStatusFn = std::uint32_t (*)(std::uint32_t target) noexcept;
|
||||
using OpenGlReadPixelsFn = void (*)(
|
||||
std::int32_t x,
|
||||
std::int32_t y,
|
||||
std::int32_t width,
|
||||
std::int32_t height,
|
||||
std::uint32_t pixel_format,
|
||||
std::uint32_t component_type,
|
||||
void* pixels) noexcept;
|
||||
|
||||
struct OpenGlStateDispatch {
|
||||
OpenGlCapabilityFn enable = nullptr;
|
||||
@@ -228,6 +297,41 @@ struct OpenGlBufferClearDispatch {
|
||||
OpenGlClearFn clear = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DAllocationDispatch {
|
||||
OpenGlGenObjectsFn gen_textures = nullptr;
|
||||
OpenGlBindTextureFn bind_texture = nullptr;
|
||||
OpenGlTexImage2DFn tex_image_2d = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DDeleteDispatch {
|
||||
OpenGlDeleteObjectsFn delete_textures = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DBindDispatch {
|
||||
OpenGlBindTextureFn bind_texture = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DUpdateDispatch {
|
||||
OpenGlBindTextureFn bind_texture = nullptr;
|
||||
OpenGlTexSubImage2DFn tex_sub_image_2d = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DMipmapDispatch {
|
||||
OpenGlBindTextureFn bind_texture = nullptr;
|
||||
OpenGlGenerateMipmapFn generate_mipmap = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DReadbackDispatch {
|
||||
OpenGlBindTextureFn bind_texture = nullptr;
|
||||
OpenGlGenObjectsFn gen_framebuffers = nullptr;
|
||||
OpenGlGetIntegerFn get_integer = nullptr;
|
||||
OpenGlBindFramebufferFn bind_framebuffer = nullptr;
|
||||
OpenGlFramebufferTexture2DFn framebuffer_texture_2d = nullptr;
|
||||
OpenGlCheckFramebufferStatusFn check_framebuffer_status = nullptr;
|
||||
OpenGlReadPixelsFn read_pixels = nullptr;
|
||||
OpenGlDeleteObjectsFn delete_framebuffers = nullptr;
|
||||
};
|
||||
|
||||
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
||||
std::span<const std::string_view> extensions,
|
||||
OpenGlRuntime runtime) noexcept;
|
||||
@@ -260,6 +364,24 @@ struct OpenGlBufferClearDispatch {
|
||||
[[nodiscard]] pp::foundation::Status clear_opengl_buffers(
|
||||
std::uint32_t mask,
|
||||
OpenGlBufferClearDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<std::uint32_t> allocate_opengl_texture_2d(
|
||||
OpenGlTexture2DAllocation allocation,
|
||||
OpenGlTexture2DAllocationDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status delete_opengl_texture_2d(
|
||||
std::uint32_t texture_id,
|
||||
OpenGlTexture2DDeleteDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status bind_opengl_texture_2d(
|
||||
std::uint32_t texture_id,
|
||||
OpenGlTexture2DBindDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status update_opengl_texture_2d(
|
||||
OpenGlTexture2DUpdate update,
|
||||
OpenGlTexture2DUpdateDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status generate_opengl_texture_2d_mipmaps(
|
||||
std::uint32_t texture_id,
|
||||
OpenGlTexture2DMipmapDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<OpenGlTexture2DReadbackResult> readback_opengl_texture_2d(
|
||||
OpenGlTexture2DReadback readback,
|
||||
OpenGlTexture2DReadbackDispatch 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