Add integer pixel formats & restructure pixel.hpp
This commit is contained in:
parent
11e9abf414
commit
e7427e1d58
1 changed files with 246 additions and 25 deletions
|
|
@ -25,9 +25,14 @@ namespace psemek::gfx
|
|||
struct uint10;
|
||||
struct uint12;
|
||||
|
||||
template <typename T>
|
||||
struct integer;
|
||||
|
||||
template <typename Pixel>
|
||||
struct pixel_traits;
|
||||
|
||||
// Normalized 8-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<std::uint8_t>
|
||||
{
|
||||
|
|
@ -60,6 +65,36 @@ namespace psemek::gfx
|
|||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
// Normalized 10-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<uint10, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB10;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
// Normalized 12-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<uint12, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB12;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<uint12, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA12;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
// Normalized 16-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<std::uint16_t>
|
||||
{
|
||||
|
|
@ -92,62 +127,212 @@ namespace psemek::gfx
|
|||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
// Unsigned 8-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<uint10, 3>>
|
||||
struct pixel_traits<integer<std::uint8_t>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB10;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum internal_format = gl::R8UI;
|
||||
static constexpr GLenum format = gl::RED_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<uint12, 3>>
|
||||
struct pixel_traits<geom::vector<integer<std::uint8_t>, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB12;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum internal_format = gl::RG8UI;
|
||||
static constexpr GLenum format = gl::RG_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<uint12, 4>>
|
||||
struct pixel_traits<geom::vector<integer<std::uint8_t>, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA12;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum internal_format = gl::RGB8UI;
|
||||
static constexpr GLenum format = gl::RGB_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<float>
|
||||
struct pixel_traits<geom::vector<integer<std::uint8_t>, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R32F;
|
||||
static constexpr GLenum format = gl::RED;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
static constexpr GLenum internal_format = gl::RGBA8UI;
|
||||
static constexpr GLenum format = gl::RGBA_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
// Unsigned 16-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<integer<std::uint16_t>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R16UI;
|
||||
static constexpr GLenum format = gl::RED_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_SHORT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<float, 2>>
|
||||
struct pixel_traits<geom::vector<integer<std::uint16_t>, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG32F;
|
||||
static constexpr GLenum format = gl::RG;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
static constexpr GLenum internal_format = gl::RG16UI;
|
||||
static constexpr GLenum format = gl::RG_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_SHORT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<float, 3>>
|
||||
struct pixel_traits<geom::vector<integer<std::uint16_t>, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB32F;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
static constexpr GLenum internal_format = gl::RGB16UI;
|
||||
static constexpr GLenum format = gl::RGB_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_SHORT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<float, 4>>
|
||||
struct pixel_traits<geom::vector<integer<std::uint16_t>, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA32F;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
static constexpr GLenum internal_format = gl::RGBA16UI;
|
||||
static constexpr GLenum format = gl::RGBA_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_SHORT;
|
||||
};
|
||||
|
||||
// Unsigned 32-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<integer<std::uint32_t>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R32UI;
|
||||
static constexpr GLenum format = gl::RED_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_INT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::uint32_t>, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG32UI;
|
||||
static constexpr GLenum format = gl::RG_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_INT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::uint32_t>, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB32UI;
|
||||
static constexpr GLenum format = gl::RGB_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_INT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::uint32_t>, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA32UI;
|
||||
static constexpr GLenum format = gl::RGBA_INTEGER;
|
||||
static constexpr GLenum type = gl::UNSIGNED_INT;
|
||||
};
|
||||
|
||||
// Signed 8-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<integer<std::int8_t>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R8I;
|
||||
static constexpr GLenum format = gl::RED_INTEGER;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int8_t>, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG8I;
|
||||
static constexpr GLenum format = gl::RG_INTEGER;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int8_t>, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB8I;
|
||||
static constexpr GLenum format = gl::RGB_INTEGER;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int8_t>, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA8I;
|
||||
static constexpr GLenum format = gl::RGBA_INTEGER;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
// Signed 16-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<integer<std::int16_t>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R16I;
|
||||
static constexpr GLenum format = gl::RED_INTEGER;
|
||||
static constexpr GLenum type = gl::SHORT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int16_t>, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG16I;
|
||||
static constexpr GLenum format = gl::RG_INTEGER;
|
||||
static constexpr GLenum type = gl::SHORT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int16_t>, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB16I;
|
||||
static constexpr GLenum format = gl::RGB_INTEGER;
|
||||
static constexpr GLenum type = gl::SHORT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int16_t>, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA16I;
|
||||
static constexpr GLenum format = gl::RGBA_INTEGER;
|
||||
static constexpr GLenum type = gl::SHORT;
|
||||
};
|
||||
|
||||
// Signed 32-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<integer<std::int32_t>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R32I;
|
||||
static constexpr GLenum format = gl::RED_INTEGER;
|
||||
static constexpr GLenum type = gl::INT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int32_t>, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG32I;
|
||||
static constexpr GLenum format = gl::RG_INTEGER;
|
||||
static constexpr GLenum type = gl::INT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int32_t>, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB32I;
|
||||
static constexpr GLenum format = gl::RGB_INTEGER;
|
||||
static constexpr GLenum type = gl::INT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<integer<std::int32_t>, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA32I;
|
||||
static constexpr GLenum format = gl::RGBA_INTEGER;
|
||||
static constexpr GLenum type = gl::INT;
|
||||
};
|
||||
|
||||
// Float 16-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<float16>
|
||||
{
|
||||
|
|
@ -180,6 +365,42 @@ namespace psemek::gfx
|
|||
static constexpr GLenum type = gl::FLOAT;
|
||||
};
|
||||
|
||||
// Float 32-bit
|
||||
|
||||
template <>
|
||||
struct pixel_traits<float>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R32F;
|
||||
static constexpr GLenum format = gl::RED;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<float, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG32F;
|
||||
static constexpr GLenum format = gl::RG;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<float, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB32F;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<float, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA32F;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
};
|
||||
|
||||
// Depth-stencil
|
||||
|
||||
template <>
|
||||
struct pixel_traits<depth24_pixel>
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue