Move pixel_traits to a separate header
This commit is contained in:
parent
b1afa3dbc1
commit
6709792abf
2 changed files with 85 additions and 75 deletions
84
libs/gfx/include/psemek/gfx/pixel.hpp
Normal file
84
libs/gfx/include/psemek/gfx/pixel.hpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/gfx/color.hpp>
|
||||
#include <psemek/gfx/gl.hpp>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
||||
template <typename Pixel>
|
||||
struct pixel_traits;
|
||||
|
||||
template <>
|
||||
struct pixel_traits<std::uint8_t>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R8;
|
||||
static constexpr GLenum format = gl::RED;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::uint8_t, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG8;
|
||||
static constexpr GLenum format = gl::RG;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::uint8_t, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB8;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::uint8_t, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA8;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<std::int8_t>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R8;
|
||||
static constexpr GLenum format = gl::RED;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::int8_t, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG8;
|
||||
static constexpr GLenum format = gl::RG;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::int8_t, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB8;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::int8_t, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA8;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<float>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R32F;
|
||||
static constexpr GLenum format = gl::RED;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/gfx/gl.hpp>
|
||||
#include <psemek/gfx/pixel.hpp>
|
||||
#include <psemek/gfx/pixmap.hpp>
|
||||
#include <psemek/geom/vector.hpp>
|
||||
|
||||
|
|
@ -9,81 +10,6 @@
|
|||
namespace psemek::gfx
|
||||
{
|
||||
|
||||
template <typename Pixel>
|
||||
struct pixel_traits;
|
||||
|
||||
template <>
|
||||
struct pixel_traits<std::uint8_t>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R8;
|
||||
static constexpr GLenum format = gl::RED;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::uint8_t, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG8;
|
||||
static constexpr GLenum format = gl::RG;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::uint8_t, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB8;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::uint8_t, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA8;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<std::int8_t>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::R8;
|
||||
static constexpr GLenum format = gl::RED;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::int8_t, 2>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RG8;
|
||||
static constexpr GLenum format = gl::RG;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::int8_t, 3>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGB8;
|
||||
static constexpr GLenum format = gl::RGB;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pixel_traits<geom::vector<std::int8_t, 4>>
|
||||
{
|
||||
static constexpr GLenum internal_format = gl::RGBA8;
|
||||
static constexpr GLenum format = gl::RGBA;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
};
|
||||
|
||||
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 <std::size_t D, GLenum Target>
|
||||
struct basic_texture
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue