]> git.tdb.fi Git - libs/gl.git/blob - source/core/datatype.h
Rework PixelComponents and PixelFormat to use custom values
[libs/gl.git] / source / core / datatype.h
1 #ifndef MSP_GL_DATATYPE_H_
2 #define MSP_GL_DATATYPE_H_
3
4 #include "gl.h"
5
6 namespace Msp {
7 namespace GL {
8
9 /**
10 Identifies a data type.  The values are bitfields laid as follows:
11
12 __ds addd ccrr _bfg ssss ssss
13   ││ │  │  │ │  │││         └╴Size (bytes)
14   ││ │  │  │ │  ││└──────────╴Signed flag
15   ││ │  │  │ │  │└───────────╴Floating-point flag
16   ││ │  │  │ │  └────────────╴Boolean flag
17   ││ │  │  │ └───────────────╴Vector or matrix rows minus one
18   ││ │  │  └─────────────────╴Matrix columns minus one
19   ││ │  └────────────────────╴Image dimensions (4 = cube)
20   ││ └───────────────────────╴Image array flag
21   │└─────────────────────────╴Sampled image flag
22   └──────────────────────────╴Shadow sampler flag
23
24 This information is presented for internal documentation purposes only; it is
25 inadvisable for programs to rely on it.
26 */
27 enum DataType
28 {
29         VOID = 0,
30         BOOL = 0x401,
31         BYTE = 0x101,
32         UNSIGNED_BYTE = 0x001,
33         SHORT = 0x102,
34         UNSIGNED_SHORT = 0x002,
35         INT = 0x104,
36         UNSIGNED_INT = 0x004,
37         FLOAT = 0x304,
38         HALF_FLOAT = 0x302,
39         DOUBLE = 0x308,
40
41         FLOAT_VEC2 = 0x1308,
42         FLOAT_VEC3 = 0x230C,
43         FLOAT_VEC4 = 0x3310,
44         INT_VEC2 = 0x1108,
45         INT_VEC3 = 0x210C,
46         INT_VEC4 = 0x3110,
47         BOOL_VEC2 = 0x1402,
48         BOOL_VEC3 = 0x2403,
49         BOOL_VEC4 = 0x3404,
50
51         FLOAT_MAT2 = 0x5310,
52         FLOAT_MAT3 = 0xA324,
53         FLOAT_MAT4 = 0xF340,
54         FLOAT_MAT2x3 = 0x6318,
55         FLOAT_MAT3x2 = 0x9318,
56         FLOAT_MAT2x4 = 0x7320,
57         FLOAT_MAT4x2 = 0xD320,
58         FLOAT_MAT3x4 = 0xB330,
59         FLOAT_MAT4x3 = 0xE330,
60
61         DOUBLE_MAT2 = 0x5320,
62         DOUBLE_MAT3 = 0xA348,
63         DOUBLE_MAT4 = 0xF380,
64         DOUBLE_MAT2x3 = 0x6330,
65         DOUBLE_MAT3x2 = 0x7330,
66         DOUBLE_MAT2x4 = 0x7340,
67         DOUBLE_MAT4x2 = 0xD340,
68         DOUBLE_MAT3x4 = 0xB360,
69         DOUBLE_MAT4x3 = 0xE360,
70
71         IMAGE_1D = 0x10304,
72         IMAGE_2D = 0x20304,
73         IMAGE_3D = 0x30304,
74         IMAGE_CUBE = 0x40304,
75         IMAGE_1D_ARRAY = 0x90304,
76         IMAGE_2D_ARRAY = 0xA0304,
77         IMAGE_CUBE_ARRAY = 0xC0304,
78         SAMPLER_1D = 0x110304,
79         SAMPLER_2D = 0x120304,
80         SAMPLER_3D = 0x130304,
81         SAMPLER_CUBE = 0x140304,
82         SAMPLER_1D_ARRAY = 0x190304,
83         SAMPLER_2D_ARRAY = 0x1A0304,
84         SAMPLER_CUBE_ARRAY = 0x1C0304,
85         SAMPLER_1D_SHADOW = 0x310304,
86         SAMPLER_2D_SHADOW = 0x320304,
87         SAMPLER_CUBE_SHADOW = 0x340304,
88         SAMPLER_1D_ARRAY_SHADOW = 0x390304,
89         SAMPLER_2D_ARRAY_SHADOW = 0x3A0304,
90         SAMPLER_CUBE_ARRAY_SHADOW = 0x3C0304
91 };
92
93 inline unsigned get_type_size(DataType t) { return t&0xFF; }
94 inline bool is_float(DataType t) { return t&0x200; }
95 inline bool is_matrix(DataType t) { return t&0xC000; }
96 inline bool is_vector(DataType t) { return !is_matrix(t) && (t&0x3000); }
97 inline bool is_image(DataType t) { return t&0x70000; }
98
99 GLenum get_gl_type(DataType);
100 DataType from_gl_type(GLenum);
101
102 void require_type(DataType);
103
104 } // namespace GL
105 } // namespace Msp
106
107 #endif