1 #ifndef MSP_GL_PIXELFORMAT_H_
2 #define MSP_GL_PIXELFORMAT_H_
4 #include <msp/core/attributes.h>
5 #include <msp/graphics/image.h>
6 #include <msp/strings/lexicalcast.h>
8 #include <msp/gl/extensions/arb_depth_buffer_float.h>
9 #include <msp/gl/extensions/arb_depth_texture.h>
10 #include <msp/gl/extensions/arb_texture_float.h>
11 #include <msp/gl/extensions/arb_texture_rg.h>
12 #include <msp/gl/extensions/ext_bgra.h>
13 #include <msp/gl/extensions/ext_texture_srgb.h>
14 #include <msp/gl/extensions/oes_required_internalformat.h>
15 #include <msp/gl/extensions/oes_texture_stencil8.h>
16 #include <msp/gl/extensions/msp_luminance_formats.h>
23 Identifies the components of a pixel, without type information. The values
24 are bitfields laid as follows:
27 │││ │ └╴Number of components
30 │└──────╴Reverse order flag
31 └───────╴Grayscale flag
33 This information is presented for internal documentation purposes only; it is
34 inadvisable for programs to rely on it.
42 DEPTH_COMPONENT = 0x09,
47 LUMINANCE_ALPHA = 0x42
51 Identifies a pixel format, with components and type. The values are bitfields
55 ││││ │ └╴Components (see PixelComponents)
56 ││││ └──────────╴Size of one component (bytes)
57 │││└───────────────╴Signed flag
58 ││└────────────────╴Floating-point flag
59 │└─────────────────╴Normalized flag
60 └──────────────────╴sRGB flag
62 This information is presented for internal documentation purposes only; it is
63 inadvisable for programs to rely on it.
77 RGBA16F = 0x3200|RGBA,
78 RGBA32F = 0x3400|RGBA,
80 SRGB8_ALPHA8 = 0xC100|RGBA,
84 SBGR8_ALPHA8 = 0xC100|BGRA,
85 LUMINANCE8 = 0x4100|LUMINANCE,
86 LUMINANCE8_ALPHA8 = 0x4100|LUMINANCE_ALPHA,
87 DEPTH_COMPONENT16 = 0x4200|DEPTH_COMPONENT,
88 DEPTH_COMPONENT24 = 0x4300|DEPTH_COMPONENT,
89 DEPTH_COMPONENT32 = 0x4400|DEPTH_COMPONENT,
90 DEPTH_COMPONENT32F = 0x3400|DEPTH_COMPONENT,
91 STENCIL_INDEX8 = 0x0100|STENCIL_INDEX
94 void operator>>(const LexicalConverter &, PixelComponents &);
95 void operator>>(const LexicalConverter &, PixelFormat &);
97 PixelComponents components_from_graphics(Graphics::PixelFormat);
98 PixelFormat pixelformat_from_image(const Graphics::Image &);
100 PixelFormat make_pixelformat(PixelComponents, DataType, bool = false);
101 inline PixelComponents get_components(PixelFormat f) { return static_cast<PixelComponents>(f&0xFF); }
102 inline unsigned get_component_count(PixelComponents c) { return c&7; }
103 inline unsigned get_component_count(PixelFormat f) { return get_component_count(get_components(f)); }
104 inline DataType get_component_type(PixelFormat f) { return static_cast<DataType>((f&0xF00)>>8 | (f&0x3000)>>4); }
105 inline unsigned get_component_size(PixelFormat f) { return get_type_size(get_component_type(f)); }
106 inline bool is_srgb(PixelFormat f) { return f&0x8000; }
107 inline unsigned get_pixel_size(PixelFormat f) { return get_component_count(f)*get_type_size(get_component_type(f)); }
109 void require_pixelformat(PixelFormat);
111 GLenum get_gl_components(PixelComponents);
112 GLenum get_gl_pixelformat(PixelFormat);