From 6709792abf3f6275c09995ca2d188999f1239bb1 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 4 Oct 2020 12:22:45 +0300 Subject: [PATCH] Move pixel_traits to a separate header --- libs/gfx/include/psemek/gfx/pixel.hpp | 84 +++++++++++++++++++++++++ libs/gfx/include/psemek/gfx/texture.hpp | 76 +--------------------- 2 files changed, 85 insertions(+), 75 deletions(-) create mode 100644 libs/gfx/include/psemek/gfx/pixel.hpp diff --git a/libs/gfx/include/psemek/gfx/pixel.hpp b/libs/gfx/include/psemek/gfx/pixel.hpp new file mode 100644 index 00000000..e6ab0620 --- /dev/null +++ b/libs/gfx/include/psemek/gfx/pixel.hpp @@ -0,0 +1,84 @@ +#pragma once + +#include +#include + +namespace psemek::gfx +{ + + template + struct pixel_traits; + + template <> + struct pixel_traits + { + static constexpr GLenum internal_format = gl::R8; + static constexpr GLenum format = gl::RED; + static constexpr GLenum type = gl::UNSIGNED_BYTE; + }; + + template <> + struct pixel_traits> + { + static constexpr GLenum internal_format = gl::RG8; + static constexpr GLenum format = gl::RG; + static constexpr GLenum type = gl::UNSIGNED_BYTE; + }; + + template <> + struct pixel_traits> + { + static constexpr GLenum internal_format = gl::RGB8; + static constexpr GLenum format = gl::RGB; + static constexpr GLenum type = gl::UNSIGNED_BYTE; + }; + + template <> + struct pixel_traits> + { + static constexpr GLenum internal_format = gl::RGBA8; + static constexpr GLenum format = gl::RGBA; + static constexpr GLenum type = gl::UNSIGNED_BYTE; + }; + + template <> + struct pixel_traits + { + static constexpr GLenum internal_format = gl::R8; + static constexpr GLenum format = gl::RED; + static constexpr GLenum type = gl::BYTE; + }; + + template <> + struct pixel_traits> + { + static constexpr GLenum internal_format = gl::RG8; + static constexpr GLenum format = gl::RG; + static constexpr GLenum type = gl::BYTE; + }; + + template <> + struct pixel_traits> + { + static constexpr GLenum internal_format = gl::RGB8; + static constexpr GLenum format = gl::RGB; + static constexpr GLenum type = gl::BYTE; + }; + + template <> + struct pixel_traits> + { + static constexpr GLenum internal_format = gl::RGBA8; + static constexpr GLenum format = gl::RGBA; + static constexpr GLenum type = gl::BYTE; + }; + + template <> + struct pixel_traits + { + static constexpr GLenum internal_format = gl::R32F; + static constexpr GLenum format = gl::RED; + static constexpr GLenum type = gl::FLOAT; + }; + +} diff --git a/libs/gfx/include/psemek/gfx/texture.hpp b/libs/gfx/include/psemek/gfx/texture.hpp index c2262a1b..9681a713 100644 --- a/libs/gfx/include/psemek/gfx/texture.hpp +++ b/libs/gfx/include/psemek/gfx/texture.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -9,81 +10,6 @@ namespace psemek::gfx { - template - struct pixel_traits; - - template <> - struct pixel_traits - { - static constexpr GLenum internal_format = gl::R8; - static constexpr GLenum format = gl::RED; - static constexpr GLenum type = gl::UNSIGNED_BYTE; - }; - - template <> - struct pixel_traits> - { - static constexpr GLenum internal_format = gl::RG8; - static constexpr GLenum format = gl::RG; - static constexpr GLenum type = gl::UNSIGNED_BYTE; - }; - - template <> - struct pixel_traits> - { - static constexpr GLenum internal_format = gl::RGB8; - static constexpr GLenum format = gl::RGB; - static constexpr GLenum type = gl::UNSIGNED_BYTE; - }; - - template <> - struct pixel_traits> - { - static constexpr GLenum internal_format = gl::RGBA8; - static constexpr GLenum format = gl::RGBA; - static constexpr GLenum type = gl::UNSIGNED_BYTE; - }; - - template <> - struct pixel_traits - { - static constexpr GLenum internal_format = gl::R8; - static constexpr GLenum format = gl::RED; - static constexpr GLenum type = gl::BYTE; - }; - - template <> - struct pixel_traits> - { - static constexpr GLenum internal_format = gl::RG8; - static constexpr GLenum format = gl::RG; - static constexpr GLenum type = gl::BYTE; - }; - - template <> - struct pixel_traits> - { - static constexpr GLenum internal_format = gl::RGB8; - static constexpr GLenum format = gl::RGB; - static constexpr GLenum type = gl::BYTE; - }; - - template <> - struct pixel_traits> - { - static constexpr GLenum internal_format = gl::RGBA8; - static constexpr GLenum format = gl::RGBA; - static constexpr GLenum type = gl::BYTE; - }; - - template <> - struct pixel_traits - { - static constexpr GLenum internal_format = gl::R32F; - static constexpr GLenum format = gl::RED; - static constexpr GLenum type = gl::FLOAT; - }; - template struct basic_texture {