]> git.tdb.fi Git - libs/gl.git/blob - source/pixelformat.h
Add some files which got forgotten in earlier commits
[libs/gl.git] / source / pixelformat.h
1 #ifndef MSP_GL_PIXELFORMAT_H_
2 #define MSP_GL_PIXELFORMAT_H_
3
4 #include <msp/core/attributes.h>
5 #include <msp/graphics/image.h>
6 #include <msp/strings/lexicalcast.h>
7 #include "gl.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>
17 #include "datatype.h"
18
19 namespace Msp {
20 namespace GL {
21
22 enum PixelComponents
23 {
24         RED             = GL_RED,
25         RG              = GL_RG,
26         RGB             = GL_RGB,
27         RGBA            = GL_RGBA,
28         BGR             = GL_BGR,
29         BGRA            = GL_BGRA,
30         LUMINANCE       = GL_LUMINANCE,
31         LUMINANCE_ALPHA = GL_LUMINANCE_ALPHA,
32         DEPTH_COMPONENT = GL_DEPTH_COMPONENT,
33         STENCIL_INDEX   = GL_STENCIL_INDEX
34 };
35
36 enum PixelFormat
37 {
38         R8              = GL_R8,
39         R16F            = GL_R16F,
40         R32F            = GL_R32F,
41         RG8             = GL_RG8,
42         RG16F           = GL_RG16F,
43         RG32F           = GL_RG32F,
44         RGB8            = GL_RGB8,
45         RGB16F          = GL_RGB16F,
46         RGB32F          = GL_RGB32F,
47         RGBA8           = GL_RGBA8,
48         RGBA16F         = GL_RGBA16F,
49         RGBA32F         = GL_RGBA32F,
50         SRGB8           = GL_SRGB8,
51         SRGB8_ALPHA8    = GL_SRGB8_ALPHA8,
52         BGR8            = 200000,
53         BGRA8           = 200001,
54         SBGR8           = 200002,
55         SBGR8_ALPHA8    = 200003,
56         LUMINANCE8      = GL_LUMINANCE8,
57         LUMINANCE8_ALPHA8 = GL_LUMINANCE8_ALPHA8,
58         DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16,
59         DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24,
60         DEPTH_COMPONENT32 = GL_DEPTH_COMPONENT32,
61         DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F,
62         STENCIL_INDEX8 = GL_STENCIL_INDEX8
63 };
64
65 void operator>>(const LexicalConverter &, PixelComponents &);
66 void operator>>(const LexicalConverter &, PixelFormat &);
67
68 DEPRECATED PixelComponents pixelformat_from_graphics(Graphics::PixelFormat);
69 DEPRECATED PixelComponents storage_pixelformat_from_graphics(Graphics::PixelFormat, bool);
70 PixelFormat pixelformat_from_image(const Graphics::Image &);
71
72 PixelFormat make_pixelformat(PixelComponents, DataType, bool = false);
73 DEPRECATED PixelFormat get_base_pixelformat(PixelFormat);
74 PixelComponents get_components(PixelFormat);
75 DEPRECATED PixelFormat get_default_sized_pixelformat(PixelComponents);
76 DEPRECATED PixelFormat get_srgb_pixelformat(PixelFormat);
77
78 unsigned get_component_count(PixelComponents);
79 inline unsigned get_component_count(PixelFormat f)
80 { return get_component_count(get_components(f)); }
81
82 DataType get_component_type(PixelFormat);
83 inline unsigned get_component_size(PixelFormat f)
84 { return get_type_size(get_component_type(f)); }
85
86 unsigned get_pixel_size(PixelFormat);
87
88 void require_pixelformat(PixelFormat);
89
90 DEPRECATED inline PixelFormat get_sized_pixelformat(PixelComponents c, unsigned s = 1)
91 { return make_pixelformat(c, (s==2 ? HALF_FLOAT : s==4 ? FLOAT : UNSIGNED_BYTE)); }
92
93 DEPRECATED inline PixelComponents get_unsized_pixelformat(PixelFormat f)
94 { return get_components(f); }
95
96 } // namespace GL
97 } // namespace Msp
98
99 #endif