3 #include "../util/half.hpp"
10 enum class TexFormat {
33 format_, size_, components_, type_, glFormat_, glType_, glInternalFormat_) \
34 template <> struct TexFormatTrait<TexFormat::format_> { \
35 static constexpr int size = size_; \
36 static constexpr int components = components_; \
38 static constexpr GLenum glFormat = glFormat_; \
39 static constexpr GLenum glType = glType_; \
40 static constexpr GLint glInternalFormat = glInternalFormat_; \
44 X(R8, 1, 1, uint8_t, GL_RED, GL_UNSIGNED_BYTE, GL_R8)
45 X(RGB8, 3, 3, uint8_t, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8)
46 X(RGBA8, 4, 4, uint8_t, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8)
47 X(R16F, 2, 1,
half, GL_RED, GL_HALF_FLOAT, GL_R16F)
48 X(RGB16F, 6, 3, half, GL_RGB, GL_HALF_FLOAT, GL_RGB16F)
49 X(RGBA16F, 8, 4, half, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F)
50 X(R32F, 4, 1,
float, GL_RED, GL_FLOAT, GL_R32F)
51 X(RGB32F, 12, 3,
float, GL_RGB, GL_FLOAT, GL_RGB32F)
52 X(RGBA32F, 16, 4,
float, GL_RGBA, GL_FLOAT, GL_RGBA32F)
53 X(D16, 2, 1,
void, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT16)
54 X(D32, 4, 1,
void, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32)
55 X(D24S8, 4, 2,
void, GL_DEPTH_STENCIL, GL_FLOAT, GL_DEPTH24_STENCIL8)
60 #define X(format_, prop_)\
61 case TexFormat::format_: return TexFormatTrait<TexFormat::format_>::prop_;
77 inline GLenum texFormatToGLFormat(TexFormat format) {
83 inline GLenum texFormatToGLType(TexFormat format) {
89 inline GLint texFormatToGLInternalFormat(TexFormat format) {
95 inline int texFormatSize(TexFormat format) {