Move OpenGL image format mapping
This commit is contained in:
@@ -7,6 +7,14 @@ namespace {
|
||||
constexpr std::uint32_t gl_unsigned_byte = 0x1401U;
|
||||
constexpr std::uint32_t gl_float = 0x1406U;
|
||||
constexpr std::uint32_t gl_half_float = 0x140BU;
|
||||
constexpr std::uint32_t gl_red = 0x1903U;
|
||||
constexpr std::uint32_t gl_rgb = 0x1907U;
|
||||
constexpr std::uint32_t gl_rgba = 0x1908U;
|
||||
constexpr std::uint32_t gl_rg = 0x8227U;
|
||||
constexpr std::uint32_t gl_r8 = 0x8229U;
|
||||
constexpr std::uint32_t gl_rg8 = 0x822BU;
|
||||
constexpr std::uint32_t gl_rgb8 = 0x8051U;
|
||||
constexpr std::uint32_t gl_rgba8 = 0x8058U;
|
||||
constexpr std::uint32_t gl_rgba32f = 0x8814U;
|
||||
constexpr std::uint32_t gl_rgba16f = 0x881AU;
|
||||
|
||||
@@ -68,4 +76,20 @@ std::uint32_t texture_upload_type_for_internal_format(std::uint32_t internal_for
|
||||
}
|
||||
}
|
||||
|
||||
OpenGlPixelFormat texture_format_for_channel_count(std::uint32_t channel_count) noexcept
|
||||
{
|
||||
switch (channel_count) {
|
||||
case 1:
|
||||
return OpenGlPixelFormat { .internal_format = gl_r8, .pixel_format = gl_red, .channel_count = 1 };
|
||||
case 2:
|
||||
return OpenGlPixelFormat { .internal_format = gl_rg8, .pixel_format = gl_rg, .channel_count = 2 };
|
||||
case 3:
|
||||
return OpenGlPixelFormat { .internal_format = gl_rgb8, .pixel_format = gl_rgb, .channel_count = 3 };
|
||||
case 4:
|
||||
return OpenGlPixelFormat { .internal_format = gl_rgba8, .pixel_format = gl_rgba, .channel_count = 4 };
|
||||
default:
|
||||
return OpenGlPixelFormat {};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,17 @@ struct OpenGlCapabilities {
|
||||
bool float16_textures = false;
|
||||
};
|
||||
|
||||
struct OpenGlPixelFormat {
|
||||
std::uint32_t internal_format = 0;
|
||||
std::uint32_t pixel_format = 0;
|
||||
std::uint32_t channel_count = 0;
|
||||
};
|
||||
|
||||
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
||||
std::span<const std::string_view> extensions,
|
||||
OpenGlRuntime runtime) noexcept;
|
||||
|
||||
[[nodiscard]] std::uint32_t texture_upload_type_for_internal_format(std::uint32_t internal_format) noexcept;
|
||||
[[nodiscard]] OpenGlPixelFormat texture_format_for_channel_count(std::uint32_t channel_count) noexcept;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user