1 #pragma once
2 
3 #include <cstdint>
4 #include <type_traits>
5 
6 namespace mbgl {
7 namespace gl {
8 
9 // Mapping based on https://www.opengl.org/wiki/OpenGL_Type
10 using ProgramID = uint32_t;
11 using ShaderID = uint32_t;
12 using BufferID = uint32_t;
13 using TextureID = uint32_t;
14 using VertexArrayID = uint32_t;
15 using FramebufferID = uint32_t;
16 using RenderbufferID = uint32_t;
17 
18 // OpenGL does not formally define a type for attribute locations, but most APIs use
19 // GLuint. The exception is glGetAttribLocation, which returns GLint so that -1 can
20 // be used as an error indicator.
21 using AttributeLocation = uint32_t;
22 
23 // OpenGL does not formally define a type for uniform locations, but all APIs use GLint.
24 // The value -1 is special, typically used as a placeholder for an unused uniform and
25 // "silently ignored".
26 using UniformLocation = int32_t;
27 
28 using TextureUnit = uint8_t;
29 
30 enum class ShaderType : uint32_t {
31     Vertex = 0x8B31,
32     Fragment = 0x8B30
33 };
34 
35 enum class DataType : uint16_t {
36     Byte = 0x1400,
37     UnsignedByte = 0x1401,
38     Short = 0x1402,
39     UnsignedShort = 0x1403,
40     Integer = 0x1404,
41     UnsignedInteger = 0x1405,
42     Float = 0x1406
43 };
44 
45 enum class RenderbufferType : uint32_t {
46     RGBA = 0x8058,
47     DepthStencil = 0x88F0,
48 #if not MBGL_USE_GLES2
49     DepthComponent = 0x1902,     // GL_DEPTH_COMPONENT
50 #else
51     DepthComponent = 0x81A5,     // GL_DEPTH_COMPONENT16
52 #endif // MBGL_USE_GLES2
53 };
54 
55 enum class TextureMipMap : bool { No = false, Yes = true };
56 enum class TextureFilter : bool { Nearest = false, Linear = true };
57 enum class TextureWrap : bool { Clamp, Repeat };
58 enum class TextureFormat : uint32_t {
59     RGBA = 0x1908,
60     Alpha = 0x1906,
61 #if not MBGL_USE_GLES2
62     Stencil = 0x1901,
63     Depth = 0x1902,
64 #endif // MBGL_USE_GLES2
65 };
66 
67 enum class TextureType : uint32_t {
68     UnsignedByte = 0x1401,
69 #if MBGL_USE_GLES2
70     HalfFloat = 0x8D61,
71 #else
72     HalfFloat = 0x140B,
73 #endif // MBGL_USE_GLES2
74 };
75 
76 enum class PrimitiveType {
77     Points = 0x0000,
78     Lines = 0x0001,
79     LineLoop = 0x0002,
80     LineStrip = 0x0003,
81     Triangles = 0x0004,
82     TriangleStrip = 0x0005,
83     TriangleFan = 0x0006
84 };
85 
86 struct PixelStorageType {
87     int32_t alignment;
88 };
89 
operator !=(const PixelStorageType & a,const PixelStorageType & b)90 constexpr bool operator!=(const PixelStorageType& a, const PixelStorageType& b) {
91     return a.alignment != b.alignment;
92 }
93 
94 using BinaryProgramFormat = uint32_t;
95 
96 enum class UniformDataType : uint32_t {
97     Float = 0x1406,
98     FloatVec2 = 0x8B50,
99     FloatVec3 = 0x8B51,
100     FloatVec4 = 0x8B52,
101     Int = 0x1404,
102     IntVec2 = 0x8B53,
103     IntVec3 = 0x8B54,
104     IntVec4 = 0x8B55,
105     Bool = 0x8B56,
106     BoolVec2 = 0x8B57,
107     BoolVec3 = 0x8B58,
108     BoolVec4 = 0x8B59,
109     FloatMat2 = 0x8B5A,
110     FloatMat3 = 0x8B5B,
111     FloatMat4 = 0x8B5C,
112     Sampler2D = 0x8B5E,
113     SamplerCube = 0x8B60,
114 };
115 
116 enum class BufferUsage : uint32_t {
117     StreamDraw = 0x88E0,
118     StaticDraw = 0x88E4,
119     DynamicDraw = 0x88E8,
120 };
121 
122 } // namespace gl
123 } // namespace mbgl
124