aboutsummaryrefslogtreecommitdiff
path: root/utils/transform_03_URr.txt
diff options
context:
space:
mode:
Diffstat (limited to 'utils/transform_03_URr.txt')
0 files changed, 0 insertions, 0 deletions

Generated with cgit - Back to sebastiano.tronto.net

inesweeper/diff/'>Diffstat
-rw-r--r--.gitignore2
-rw-r--r--LICENSE4
-rw-r--r--Makefile35
-rw-r--r--README.md28
-rw-r--r--TODO-MAYBE5
-rw-r--r--minesweeper.ha318
-rw-r--r--raylib/raylib.ha52
-rw-r--r--raylib/src/CMakeLists.txt132
-rw-r--r--raylib/src/LICENSE16
-rw-r--r--raylib/src/Makefile873
-rw-r--r--raylib/src/config.h303
-rw-r--r--raylib/src/external/RGFW.h9015
-rw-r--r--raylib/src/external/cgltf.h7081
-rw-r--r--raylib/src/external/dirent.h183
-rw-r--r--raylib/src/external/dr_flac.h12536
-rw-r--r--raylib/src/external/dr_mp3.h4837
-rw-r--r--raylib/src/external/dr_wav.h8815
-rw-r--r--raylib/src/external/glad.h8682
-rw-r--r--raylib/src/external/glad_gles2.h4774
-rw-r--r--raylib/src/external/glfw/.mailmap10
-rw-r--r--raylib/src/external/glfw/CMake/GenerateMappings.cmake48
-rw-r--r--raylib/src/external/glfw/CMake/Info.plist.in38
-rw-r--r--raylib/src/external/glfw/CMake/cmake_uninstall.cmake.in29
-rw-r--r--raylib/src/external/glfw/CMake/glfw3.pc.in13
-rw-r--r--raylib/src/external/glfw/CMake/glfw3Config.cmake.in3
-rw-r--r--raylib/src/external/glfw/CMake/i686-w64-mingw32-clang.cmake13
-rw-r--r--raylib/src/external/glfw/CMake/i686-w64-mingw32.cmake13
-rw-r--r--raylib/src/external/glfw/CMake/modules/FindEpollShim.cmake17
-rw-r--r--raylib/src/external/glfw/CMake/modules/FindOSMesa.cmake18
-rw-r--r--raylib/src/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake13
-rw-r--r--raylib/src/external/glfw/CMake/x86_64-w64-mingw32.cmake13
-rw-r--r--raylib/src/external/glfw/CMakeLists.txt165
-rw-r--r--raylib/src/external/glfw/CONTRIBUTORS.md297
-rw-r--r--raylib/src/external/glfw/LICENSE.md23
-rw-r--r--raylib/src/external/glfw/README.md18
-rw-r--r--raylib/src/external/glfw/deps/getopt.c230
-rw-r--r--raylib/src/external/glfw/deps/getopt.h57
-rw-r--r--raylib/src/external/glfw/deps/glad/gl.h5996
-rw-r--r--raylib/src/external/glfw/deps/glad/gles2.h1805
-rw-r--r--raylib/src/external/glfw/deps/glad/vulkan.h6330
-rw-r--r--raylib/src/external/glfw/deps/mingw/_mingw_dxhelper.h117
-rw-r--r--raylib/src/external/glfw/deps/mingw/dinput.h2467
-rw-r--r--raylib/src/external/glfw/deps/mingw/xinput.h239
-rw-r--r--raylib/src/external/glfw/deps/wayland/fractional-scale-v1.xml102
-rw-r--r--raylib/src/external/glfw/deps/wayland/idle-inhibit-unstable-v1.xml83
-rw-r--r--raylib/src/external/glfw/deps/wayland/pointer-constraints-unstable-v1.xml339
-rw-r--r--raylib/src/external/glfw/deps/wayland/relative-pointer-unstable-v1.xml136
-rw-r--r--raylib/src/external/glfw/deps/wayland/viewporter.xml180
-rw-r--r--raylib/src/external/glfw/deps/wayland/wayland.xml3151
-rw-r--r--raylib/src/external/glfw/deps/wayland/xdg-activation-v1.xml200
-rw-r--r--raylib/src/external/glfw/deps/wayland/xdg-decoration-unstable-v1.xml156
-rw-r--r--raylib/src/external/glfw/deps/wayland/xdg-shell.xml1370
-rw-r--r--raylib/src/external/glfw/include/GLFW/glfw3.h6547
-rw-r--r--raylib/src/external/glfw/include/GLFW/glfw3native.h663
-rw-r--r--raylib/src/external/glfw/src/CMakeLists.txt368
-rw-r--r--raylib/src/external/glfw/src/cocoa_init.m696
-rw-r--r--raylib/src/external/glfw/src/cocoa_joystick.h49
-rw-r--r--raylib/src/external/glfw/src/cocoa_joystick.m485
-rw-r--r--raylib/src/external/glfw/src/cocoa_monitor.m644
-rw-r--r--raylib/src/external/glfw/src/cocoa_platform.h302
-rw-r--r--raylib/src/external/glfw/src/cocoa_time.c57
-rw-r--r--raylib/src/external/glfw/src/cocoa_time.h35
-rw-r--r--raylib/src/external/glfw/src/cocoa_window.m2072
-rw-r--r--raylib/src/external/glfw/src/context.c765
-rw-r--r--raylib/src/external/glfw/src/egl_context.c911
-rw-r--r--raylib/src/external/glfw/src/glfw.rc.in30
-rw-r--r--raylib/src/external/glfw/src/glx_context.c719
-rw-r--r--raylib/src/external/glfw/src/init.c528
-rw-r--r--raylib/src/external/glfw/src/input.c1505
-rw-r--r--raylib/src/external/glfw/src/internal.h1009
-rw-r--r--raylib/src/external/glfw/src/linux_joystick.c436
-rw-r--r--raylib/src/external/glfw/src/linux_joystick.h64
-rw-r--r--raylib/src/external/glfw/src/mappings.h1002
-rw-r--r--raylib/src/external/glfw/src/mappings.h.in82
-rw-r--r--raylib/src/external/glfw/src/monitor.c548
-rw-r--r--raylib/src/external/glfw/src/nsgl_context.m384
-rw-r--r--raylib/src/external/glfw/src/null_init.c264
-rw-r--r--raylib/src/external/glfw/src/null_joystick.c56
-rw-r--r--raylib/src/external/glfw/src/null_joystick.h32
-rw-r--r--raylib/src/external/glfw/src/null_monitor.c160
-rw-r--r--raylib/src/external/glfw/src/null_platform.h271
-rw-r--r--raylib/src/external/glfw/src/null_window.c720
-rw-r--r--raylib/src/external/glfw/src/osmesa_context.c383
-rw-r--r--raylib/src/external/glfw/src/platform.c204
-rw-r--r--raylib/src/external/glfw/src/platform.h212
-rw-r--r--raylib/src/external/glfw/src/posix_module.c53
-rw-r--r--raylib/src/external/glfw/src/posix_poll.c83
-rw-r--r--raylib/src/external/glfw/src/posix_poll.h30
-rw-r--r--raylib/src/external/glfw/src/posix_thread.c107
-rw-r--r--raylib/src/external/glfw/src/posix_thread.h49
-rw-r--r--raylib/src/external/glfw/src/posix_time.c65
-rw-r--r--raylib/src/external/glfw/src/posix_time.h41
-rw-r--r--raylib/src/external/glfw/src/vulkan.c328
-rw-r--r--raylib/src/external/glfw/src/wgl_context.c798
-rw-r--r--raylib/src/external/glfw/src/win32_init.c732
-rw-r--r--raylib/src/external/glfw/src/win32_joystick.c767
-rw-r--r--raylib/src/external/glfw/src/win32_joystick.h51
-rw-r--r--raylib/src/external/glfw/src/win32_module.c51
-rw-r--r--raylib/src/external/glfw/src/win32_monitor.c569
-rw-r--r--raylib/src/external/glfw/src/win32_platform.h627
-rw-r--r--raylib/src/external/glfw/src/win32_thread.c100
-rw-r--r--raylib/src/external/glfw/src/win32_thread.h53
-rw-r--r--raylib/src/external/glfw/src/win32_time.c54
-rw-r--r--raylib/src/external/glfw/src/win32_time.h43
-rw-r--r--raylib/src/external/glfw/src/win32_window.c2594
-rw-r--r--raylib/src/external/glfw/src/window.c1172
-rw-r--r--raylib/src/external/glfw/src/wl_init.c1004
-rw-r--r--raylib/src/external/glfw/src/wl_monitor.c274
-rw-r--r--raylib/src/external/glfw/src/wl_platform.h691
-rw-r--r--raylib/src/external/glfw/src/wl_window.c3309
-rw-r--r--raylib/src/external/glfw/src/x11_init.c1657
-rw-r--r--raylib/src/external/glfw/src/x11_monitor.c641
-rw-r--r--raylib/src/external/glfw/src/x11_platform.h1004
-rw-r--r--raylib/src/external/glfw/src/x11_window.c3358
-rw-r--r--raylib/src/external/glfw/src/xkb_unicode.c943
-rw-r--r--raylib/src/external/glfw/src/xkb_unicode.h30
-rw-r--r--raylib/src/external/jar_mod.h1596
-rw-r--r--raylib/src/external/jar_xm.h2471
-rw-r--r--raylib/src/external/m3d.h6547
-rw-r--r--raylib/src/external/miniaudio.h92633
-rw-r--r--raylib/src/external/msf_gif.h717
-rw-r--r--raylib/src/external/par_shapes.h2155
-rw-r--r--raylib/src/external/qoa.h742
-rw-r--r--raylib/src/external/qoaplay.c278
-rw-r--r--raylib/src/external/qoi.h649
-rw-r--r--raylib/src/external/rl_gputex.h826
-rw-r--r--raylib/src/external/rprand.h311
-rw-r--r--raylib/src/external/sdefl.h790
-rw-r--r--raylib/src/external/sinfl.h629
-rw-r--r--raylib/src/external/stb_image.h7988
-rw-r--r--raylib/src/external/stb_image_resize2.h10601
-rw-r--r--raylib/src/external/stb_image_write.h1724
-rw-r--r--raylib/src/external/stb_perlin.h428
-rw-r--r--raylib/src/external/stb_rect_pack.h623
-rw-r--r--raylib/src/external/stb_truetype.h5079
-rw-r--r--raylib/src/external/stb_vorbis.c5584
-rw-r--r--raylib/src/external/tinyobj_loader_c.h1594
-rw-r--r--raylib/src/external/vox_loader.h727
-rw-r--r--raylib/src/external/win32_clipboard.h374
-rw-r--r--raylib/src/minshell.html89
-rw-r--r--raylib/src/platforms/rcore_android.c1339
-rw-r--r--raylib/src/platforms/rcore_desktop_glfw.c1933
-rw-r--r--raylib/src/platforms/rcore_desktop_rgfw.c1387
-rw-r--r--raylib/src/platforms/rcore_desktop_sdl.c1978
-rw-r--r--raylib/src/platforms/rcore_drm.c1942
-rw-r--r--raylib/src/platforms/rcore_template.c597
-rw-r--r--raylib/src/platforms/rcore_web.c1792
-rw-r--r--raylib/src/raudio.c2879
-rw-r--r--raylib/src/raylib.dll.rc27
-rw-r--r--raylib/src/raylib.dll.rc.databin0 -> 11318 bytes
-rw-r--r--raylib/src/raylib.h1708
-rw-r--r--raylib/src/raylib.icobin0 -> 6177 bytes
-rw-r--r--raylib/src/raylib.rc27
-rw-r--r--raylib/src/raylib.rc.databin0 -> 11302 bytes
-rw-r--r--raylib/src/raymath.h2941
-rw-r--r--raylib/src/rcamera.h555
-rw-r--r--raylib/src/rcore.c4070
-rw-r--r--raylib/src/rgestures.h555
-rw-r--r--raylib/src/rglfw.c148
-rw-r--r--raylib/src/rlgl.h5262
-rw-r--r--raylib/src/rmodels.c6796
-rw-r--r--raylib/src/rshapes.c2414
-rw-r--r--raylib/src/rtext.c2573
-rw-r--r--raylib/src/rtextures.c5548
-rw-r--r--raylib/src/shell.html338
-rw-r--r--raylib/src/utils.c510
-rw-r--r--raylib/src/utils.h81
167 files changed, 317416 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..58d5742
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
1minesweeper
2raylib/*.a
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e47b328
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,4 @@
1The licence for [raylib](https://www.raylib.com) can be found in
2`raylib/src/LICENSE` and it applies to the contents of `raylib/src`.
3
4All other files in this repository are public domain.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..635e04e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,35 @@
1SRC = minesweeper.ha
2OBJ = minesweeper
3
4RAYLIB = -Lraylib -lraylib -lm
5
6UNAME = $(shell uname)
7ifeq ($(UNAME), OpenBSD)
8 GNUMAKE = gmake
9 IRAY = EXTRA_INCLUDE_PATHS='-I/usr/X11R6/include'
10 LRAY = CUSTOM_LDFLAGS='-L/usr/X11R6/lib'
11 GRAY = 'GRAPHICS = GRAPHICS_API_OPENGL_21' # My OpenBSD laptop is a potato
12else
13 GNUMAKE = make
14endif
15
16all: raylib/libraylib.a
17 hare build -o ${OBJ} ${RAYLIB} ${SRC}
18
19raylib/libraylib.a:
20 cd raylib/src && $(GNUMAKE) $(GRAY) $(IRAY) $(LRAY) $(RAYP)
21 cp raylib/src/libraylib.a raylib/
22 cd raylib/src && $(GNUMAKE) clean
23
24run: raylib/libraylib.a
25 hare run $(RAYLIB) $(SRC)
26
27test: raylib/libraylib.a
28 hare test $(RAYLIB) $(SRC)
29
30clean:
31 rm -f $(OBJ)
32 rm -f raylib/libraylib.a
33 cd raylib/src && $(GNUMAKE) clean
34
35.PHONY: all run clean
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..53d60fe
--- /dev/null
+++ b/README.md
@@ -0,0 +1,28 @@
1# A minesweeper implementation to play around with Hare and Raylib
2
3Just for fun
4
5## Requirements
6
7* [Hare](https://harelang.org)
8* All that is required to build [raylib](https://www.raylib.com) from source
9 (see the
10 [raylib wiki](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux))
11* GNU make
12
13## Build and run
14
15Just type:
16
17```
18make
19./minesweeper
20```
21
22Alternatively, you can build and run directly with:
23
24```
25make run
26```
27
28Tested on Fedora Linux (x86-64) and OpenBSD (x86-64). May work on other systems too.
diff --git a/TODO-MAYBE b/TODO-MAYBE
new file mode 100644
index 0000000..afefbb0
--- /dev/null
+++ b/TODO-MAYBE
@@ -0,0 +1,5 @@
1- new game screen with board size selection
2- better colors
3- top bar with smiley face
4- timer
5- save scores to file, record view
diff --git a/minesweeper.ha b/minesweeper.ha
new file mode 100644
index 0000000..4567c7b
--- /dev/null
+++ b/minesweeper.ha
@@ -0,0 +1,318 @@
1use fmt;
2use math::random;
3use raylib;
4use strings;
5use time;
6
7// Types
8type cell = struct {
9 is_mine: bool,
10 is_hidden: bool,
11 is_flag: bool,
12 near_mines: int,
13 near_flags: int
14};
15
16type board = struct {
17 cells: []cell,
18 last_clicked: (int | void),
19 width: int,
20 height: int,
21 nmines: int,
22 nfreed: int,
23 finished: bool,
24};
25
26// Gameplay constants
27const BOARD_WIDTH = 8;
28const BOARD_HEIGHT = 8;
29const NMINES = 10;
30
31// Graphics-related constants
32const WINDOW_WIDTH = 1000;
33const WINDOW_HEIGHT = 800;
34const WINDOW_TITLE = "Minesweeper";
35
36const FLAG_SIZE = 40;
37const CELL_SIZE = 80;
38const HALFGAP_SIZE = 4;
39const BOTTOM_BAR_THICKNESS = 40;
40
41const COLOR_BACKGROUND = raylib::color { r = 230, g = 230, b = 230, a = 255 };
42const COLOR_FREE = raylib::color { r = 200, g = 200, b = 200, a = 255 };
43const COLOR_HIDDEN = raylib::color { r = 100, g = 100, b = 100, a = 255 };
44const COLOR_FLAG = raylib::color { r = 30, g = 30, b = 30, a = 255 };
45const COLOR_MINE = raylib::color { r = 255, g = 0, b = 0, a = 255 };
46const COLOR_CLICKED_MINE = raylib::color { r = 255, g = 100, b = 100, a = 255 };
47const COLOR_NR: [9]raylib::color = [
48 // TODO, maybe: different color for each number
49 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 0, unused
50 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 1
51 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 2
52 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 3
53 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 4
54 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 5
55 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 6
56 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 7
57 raylib::color { r = 0, g = 0, b = 0, a = 255 }, // 8
58];
59
60let bottom_left_text = "Playing...";
61
62fn draw_bottom_bar() void = {
63 const color_text = raylib::color { r = 200, g = 0, b = 0, a = 255 };
64 const text_gap = 4;
65 let h = raylib::get_screen_height();
66 let w = raylib::get_screen_width();
67 let tl = raylib::vector2 { x = 0.0, y = (h - BOTTOM_BAR_THICKNESS) : f32 };
68 let sz = raylib::vector2 { x = w: f32, y = h: f32 };
69
70 raylib::draw_rectangle_v(tl, sz, COLOR_BACKGROUND);
71 raylib::draw_text(bottom_left_text, text_gap,
72 (h - BOTTOM_BAR_THICKNESS + text_gap),
73 (BOTTOM_BAR_THICKNESS - 2 * text_gap), color_text);
74};
75
76fn foreach_neighbor(
77 b: *board,
78 ii: int,
79 f: *fn(b: *board, jj: int) void
80) void = {
81 let i = ii / b.width;
82 let j = ii % b.width;
83
84 const neighbors: [8](int, int) = [
85 (i-1, j-1), (i-1, j), (i-1, j+1),
86 (i, j-1), (i, j+1),
87 (i+1, j-1), (i+1, j), (i+1, j+1)
88 ];
89 for (let p .. neighbors)
90 if (p.0 >= 0 && p.0 < b.height &&
91 p.1 >= 0 && p.1 < b.width)
92 f(b, p.0*b.width + p.1);
93};
94
95fn inc_near_mines(b: *board, ii: int) void = b.cells[ii].near_mines += 1;
96fn inc_near_flags(b: *board, ii: int) void = b.cells[ii].near_flags += 1;
97fn dec_near_flags(b: *board, ii: int) void = b.cells[ii].near_flags -= 1;
98
99fn new_board(w: int, h: int, n: int) *board = {
100 let empty_cell = cell {
101 is_mine = false,
102 is_hidden = true,
103 is_flag = false,
104 near_mines = 0,
105 near_flags = 0
106 };
107 let b: *board = alloc(board {
108 cells = alloc([empty_cell ...], (w*h): size)!,
109 last_clicked = void,
110 width = w,
111 height = h,
112 nmines = n,
113 nfreed = 0,
114 finished = false
115 })!;
116
117 const seed: u64 = time::now(time::clock::REALTIME).sec : u64;
118 const rand: math::random::random = math::random::init(seed);
119 for (let i = 0; i < n; i += 1) {
120 let j = math::random::u32n(&rand, (w*h-i): u32): int;
121 for (let k = 0; k <= j; k += 1)
122 if (b.cells[k].is_mine)
123 j += 1;
124 b.cells[j].is_mine = true;
125 foreach_neighbor(b, j, &inc_near_mines);
126 };
127 return b;
128};
129
130fn delete_board(b: *board) void = {
131 free(b.cells);
132 free(b);
133};
134
135fn game_lost(b: *board) void = {
136 for (let c &.. b.cells)
137 c.is_hidden = false;
138 bottom_left_text = "You lost! Press n for a new game";
139 b.finished = true;
140};
141
142fn game_won(b: *board) void = {
143 for (let c &.. b.cells)
144 c.is_hidden = false;
145 bottom_left_text = "You won! Press n for a new game";
146 b.finished = true;
147};
148
149fn leftclick_if_hidden_noflag(b: *board, i: int) void = {
150 if (b.cells[i].is_hidden && ! b.cells[i].is_flag)
151 leftclick_cell(b, i);
152};
153
154fn leftclick_cell(b: *board, i: int) void = {
155 let c = &(b.cells[i]);
156 if (c.is_hidden) {
157 if (c.is_flag)
158 return;
159 b.last_clicked = i;
160 c.is_hidden = false;
161 if (c.is_mine) {
162 game_lost(b);
163 } else {
164 b.nfreed += 1;
165 if (b.nfreed == len(b.cells): int - b.nmines)
166 game_won(b);
167 };
168 if (c.near_mines == 0 && c.near_flags == 0)
169 foreach_neighbor(b, i, &leftclick_if_hidden_noflag);
170 } else {
171 if (c.near_flags == c.near_mines)
172 foreach_neighbor(b, i, &leftclick_if_hidden_noflag);
173 };
174};
175
176fn rightclick_cell(b: *board, i: int) void = {
177 let c = &(b.cells[i]);
178 if (c.is_hidden) {
179 c.is_flag = !c.is_flag;
180 const f = if (c.is_flag) &inc_near_flags else &dec_near_flags;
181 foreach_neighbor(b, i, f);
182 } else {
183 return;
184 };
185};
186
187// Return true if the user started a new game
188fn handle_interaction(b: *board) bool = {
189 const p = raylib::get_mouse_position();
190 if (raylib::is_mouse_button_pressed(raylib::MOUSE_BUTTON_LEFT)) {
191 match (get_cell_index(b, p)) {
192 case void => return false;
193 case let i: int => leftclick_cell(b, i);
194 };
195 };
196 if (raylib::is_mouse_button_pressed(raylib::MOUSE_BUTTON_RIGHT)) {
197 match (get_cell_index(b, p)) {
198 case void => return false;
199 case let i: int => rightclick_cell(b, i);
200 };
201 };
202 if (raylib::is_key_pressed(raylib::KEY_N) && b.finished)
203 return true;
204 return false;
205};
206
207fn top_gap() int = {
208 let h = raylib::get_screen_height();
209 return (h - BOTTOM_BAR_THICKNESS - BOARD_HEIGHT * CELL_SIZE) / 2;
210};
211
212fn side_gap() int = {
213 let w = raylib::get_screen_width();
214 return (w - BOARD_WIDTH * CELL_SIZE) / 2;
215};
216
217fn cell_pos(b: *board, i: int) raylib::vector2 = {
218 return raylib::vector2 {
219 x = ((i % b.width) * CELL_SIZE + HALFGAP_SIZE + side_gap()) : f32,
220 y = ((i / b.width) * CELL_SIZE + HALFGAP_SIZE + top_gap()) : f32
221 };
222};
223
224fn flag_pos(b: *board, i: int) raylib::vector2 = {
225 const shift = (CELL_SIZE - FLAG_SIZE) / 2;
226 return raylib::vector2 {
227 x = ((i % b.width) * CELL_SIZE + shift + side_gap()) : f32,
228 y = ((i / b.width) * CELL_SIZE + shift + top_gap()) : f32
229 };
230};
231
232fn get_cell_index(b: *board, p: raylib::vector2) (int | void) = {
233 const i = (p.y: int - top_gap()) / CELL_SIZE;
234 const j: int = (p.x: int - side_gap()) / CELL_SIZE;
235 if (i < b.height && j < b.width)
236 return i * b.width + j;
237};
238
239fn cell_drawsize() raylib::vector2 = raylib::vector2 {
240 x = (CELL_SIZE - 2*HALFGAP_SIZE) : f32,
241 y = (CELL_SIZE - 2*HALFGAP_SIZE) : f32
242};
243
244fn flag_drawsize() raylib::vector2 = raylib::vector2 {
245 x = FLAG_SIZE : f32,
246 y = FLAG_SIZE : f32
247};
248
249fn draw_flag(b: *board, i: int) void =
250 raylib::draw_rectangle_v(flag_pos(b, i), flag_drawsize(), COLOR_FLAG);
251
252fn draw_cell_hidden(b: *board, i: int) void = {
253 raylib::draw_rectangle_v(cell_pos(b, i), cell_drawsize(), COLOR_HIDDEN);
254 if (b.cells[i].is_flag)
255 draw_flag(b, i);
256};
257
258fn draw_cell_mine(b: *board, i: int) void = {
259 const c = match (b.last_clicked) {
260 case void => yield COLOR_MINE;
261 case let l: int => yield if (l == i) COLOR_CLICKED_MINE else COLOR_MINE;
262 };
263 raylib::draw_rectangle_v(cell_pos(b, i), cell_drawsize(), c);
264};
265
266fn draw_cell_free(b: *board, i: int) void = {
267 let pos = cell_pos(b, i);
268 let sz = cell_drawsize();
269 raylib::draw_rectangle_v(pos, cell_drawsize(), COLOR_FREE);
270
271 const n = b.cells[i].near_mines: u8;
272 const s = strings::fromutf8([n + '0']) as str;
273 const w = raylib::measure_text(s, sz.y: int);
274 const shift_x = (CELL_SIZE: f32 / 2.0) - (w: f32 / 2.0) - (HALFGAP_SIZE: f32);
275 const shift_y = (CELL_SIZE: f32 / 2.0) - (sz.y / 2.0);
276 let text_x = (pos.x + shift_x): int;
277 let text_y = (pos.y + shift_y): int;
278 raylib::draw_text(s, text_x, text_y, sz.y: int, COLOR_NR[n]);
279};
280
281fn draw_cell(b: *board, i: int) void = {
282 const c = b.cells[i];
283 if (c.is_hidden) {
284 draw_cell_hidden(b, i);
285 } else if (c.is_mine) {
286 draw_cell_mine(b, i);
287 } else {
288 draw_cell_free(b, i);
289 };
290};
291
292fn draw_board(b: *board) void = {
293 for (let i = 0; i < b.height; i += 1)
294 for (let j = 0; j < b.width; j += 1)
295 draw_cell(b, i*b.width + j);
296};
297
298export fn main() void = {
299 let game_board = new_board(BOARD_WIDTH, BOARD_HEIGHT, NMINES);
300 defer delete_board(game_board);
301
302 raylib::set_config_flags(raylib::FLAG_WINDOW_RESIZABLE);
303 raylib::init_window(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE);
304 for (!raylib::window_should_close()) {
305 raylib::begin_drawing();
306
307 raylib::clear_background(COLOR_BACKGROUND);
308 draw_board(game_board);
309 draw_bottom_bar();
310 const restart = handle_interaction(game_board);
311 if (restart) {
312 delete_board(game_board);
313 game_board = new_board(BOARD_WIDTH, BOARD_HEIGHT, NMINES);
314 };
315
316 raylib::end_drawing();
317 };
318};
diff --git a/raylib/raylib.ha b/raylib/raylib.ha
new file mode 100644
index 0000000..65c1b51
--- /dev/null
+++ b/raylib/raylib.ha
@@ -0,0 +1,52 @@
1use types::c;
2
3export const MOUSE_BUTTON_LEFT = 0;
4export const MOUSE_BUTTON_RIGHT = 1;
5export const FLAG_WINDOW_RESIZABLE: uint = 4;
6
7export const KEY_N = 78;
8
9export type color = struct {
10 r: u8,
11 g: u8,
12 b: u8,
13 a: u8
14};
15
16export type vector2 = struct {
17 x: f32,
18 y: f32
19};
20
21export @symbol("WindowShouldClose") fn window_should_close() bool;
22export @symbol("BeginDrawing") fn begin_drawing() void;
23export @symbol("EndDrawing") fn end_drawing() void;
24export @symbol("ClearBackground") fn clear_background(color) void;
25export @symbol("DrawRectangleV") fn draw_rectangle_v(vector2, vector2, color) void;
26export @symbol("IsMouseButtonPressed") fn is_mouse_button_pressed(int) bool;
27export @symbol("GetMousePosition") fn get_mouse_position() vector2;
28export @symbol("GetScreenHeight") fn get_screen_height() int;
29export @symbol("GetScreenWidth") fn get_screen_width() int;
30export @symbol("SetConfigFlags") fn set_config_flags(uint) void;
31export @symbol("IsKeyPressed") fn is_key_pressed(int) bool;
32
33@symbol("InitWindow") fn InitWindow(int, int, *c::char) void;
34export fn init_window(width: int, height: int, title: str) void = {
35 let c_title = c::fromstr(title)!;
36 defer free(c_title);
37 InitWindow(width, height, c_title);
38};
39
40@symbol("DrawText") fn DrawText(*c::char, int, int, int, color) void;
41export fn draw_text(text: str, x: int, y: int, sz: int, c: color) void = {
42 let c_str = c::fromstr(text)!;
43 defer free(c_str);
44 DrawText(c_str, x, y, sz, c);
45};
46
47@symbol("MeasureText") fn MeasureText(*c::char, int) int;
48export fn measure_text(text: str, sz: int) int = {
49 let c_str = c::fromstr(text)!;
50 defer free(c_str);
51 return MeasureText(c_str, sz);
52};
diff --git a/raylib/src/CMakeLists.txt b/raylib/src/CMakeLists.txt
new file mode 100644
index 0000000..9735e26
--- /dev/null
+++ b/raylib/src/CMakeLists.txt
@@ -0,0 +1,132 @@
1# Setup the project and settings
2project(raylib C)
3set(PROJECT_VERSION 5.5.0)
4set(API_VERSION 550)
5
6include(GNUInstallDirs)
7include(JoinPaths)
8
9# Sets build type if not set by now
10if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
11 if(RAYLIB_IS_MAIN)
12 set(default_build_type Debug)
13 else()
14 message(WARNING "Default build type is not set (CMAKE_BUILD_TYPE)")
15 endif()
16
17 message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
18
19 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
20 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
21endif()
22
23# Used as public API to be included into other projects
24set(raylib_public_headers
25 raylib.h
26 rlgl.h
27 raymath.h
28 )
29
30# Sources to be compiled
31set(raylib_sources
32 raudio.c
33 rcore.c
34 rmodels.c
35 rshapes.c
36 rtext.c
37 rtextures.c
38 utils.c
39 )
40
41# <root>/cmake/GlfwImport.cmake handles the details around the inclusion of glfw
42if (NOT ${PLATFORM} MATCHES "Web")
43 include(GlfwImport)
44endif ()
45
46# Sets additional platform options and link libraries for each platform
47# also selects the proper graphics API and version for that platform
48# Produces a variable LIBS_PRIVATE that will be used later
49include(LibraryConfigurations)
50
51if (SUPPORT_MODULE_RAUDIO)
52 MESSAGE(STATUS "Audio Backend: miniaudio")
53else ()
54 MESSAGE(STATUS "Audio Backend: None (-DCUSTOMIZE_BUILD=ON -DSUPPORT_MODULE_RAUDIO=OFF)")
55endif ()
56
57add_library(raylib ${raylib_sources} ${raylib_public_headers})
58
59if (NOT BUILD_SHARED_LIBS)
60 MESSAGE(STATUS "Building raylib static library")
61 add_library(raylib_static ALIAS raylib)
62else()
63 MESSAGE(STATUS "Building raylib shared library")
64 target_compile_definitions(raylib
65 PRIVATE $<BUILD_INTERFACE:BUILD_LIBTYPE_SHARED>
66 INTERFACE $<INSTALL_INTERFACE:USE_LIBTYPE_SHARED>
67 )
68endif()
69
70if (${PLATFORM} MATCHES "Web")
71 target_link_options(raylib PUBLIC "-sUSE_GLFW=3")
72 if(${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3")
73 target_link_options(raylib PUBLIC "-sMIN_WEBGL_VERSION=2")
74 target_link_options(raylib PUBLIC "-sMAX_WEBGL_VERSION=2")
75 endif()
76endif()
77
78set_target_properties(raylib PROPERTIES
79 PUBLIC_HEADER "${raylib_public_headers}"
80 VERSION ${PROJECT_VERSION}
81 SOVERSION ${API_VERSION}
82 )
83
84if (WITH_PIC OR BUILD_SHARED_LIBS)
85 set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON)
86endif ()
87
88if (BUILD_SHARED_LIBS)
89 # Hide raylib's symbols by default so RLAPI can expose them
90 set_property(TARGET raylib PROPERTY C_VISIBILITY_PRESET hidden)
91endif ()
92
93target_link_libraries(raylib "${LIBS_PRIVATE}")
94
95# Sets some compile time definitions for the pre-processor
96# If CUSTOMIZE_BUILD option is on you will not use config.h by default
97# and you will be able to select more build options
98include(CompileDefinitions)
99
100# Registering include directories
101target_include_directories(raylib
102 PUBLIC
103 $<INSTALL_INTERFACE:include>
104 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
105 PRIVATE
106 ${CMAKE_CURRENT_SOURCE_DIR}
107 ${OPENGL_INCLUDE_DIR}
108 ${OPENAL_INCLUDE_DIR}
109 )
110
111# Copy the header files to the build directory for convenience
112file(COPY ${raylib_public_headers} DESTINATION "include")
113
114# Includes information on how the library will be installed on the system
115# when cmake --install is run
116include(InstallConfigurations)
117
118# Print the flags for the user
119if (DEFINED CMAKE_BUILD_TYPE)
120 message(STATUS "Generated build type: ${CMAKE_BUILD_TYPE}")
121else ()
122 message(STATUS "Generated config types: ${CMAKE_CONFIGURATION_TYPES}")
123endif ()
124
125message(STATUS "Compiling with the flags:")
126message(STATUS " PLATFORM=" ${PLATFORM_CPP})
127message(STATUS " GRAPHICS=" ${GRAPHICS})
128
129# Options if you want to create an installer using CPack
130include(PackConfigurations)
131
132enable_testing()
diff --git a/raylib/src/LICENSE b/raylib/src/LICENSE
new file mode 100644
index 0000000..e96f876
--- /dev/null
+++ b/raylib/src/LICENSE
@@ -0,0 +1,16 @@
1Copyright (c) 2013-2025 Ramon Santamaria (@raysan5)
2
3This software is provided "as-is", without any express or implied warranty. In no event
4will the authors be held liable for any damages arising from the use of this software.
5
6Permission is granted to anyone to use this software for any purpose, including commercial
7applications, and to alter it and redistribute it freely, subject to the following restrictions:
8
9 1. The origin of this software must not be misrepresented; you must not claim that you
10 wrote the original software. If you use this software in a product, an acknowledgment
11 in the product documentation would be appreciated but is not required.
12
13 2. Altered source versions must be plainly marked as such, and must not be misrepresented
14 as being the original software.
15
16 3. This notice may not be removed or altered from any source distribution.
diff --git a/raylib/src/Makefile b/raylib/src/Makefile
new file mode 100644
index 0000000..7dde52f
--- /dev/null
+++ b/raylib/src/Makefile
@@ -0,0 +1,873 @@
1#******************************************************************************
2#
3# raylib makefile
4#
5# This file supports building raylib library for the following platforms:
6#
7# > PLATFORM_DESKTOP
8# - Defaults to PLATFORM_DESKTOP_GLFW
9# > PLATFORM_DESKTOP_GLFW (GLFW backend):
10# - Windows (Win32, Win64)
11# - Linux (X11/Wayland desktop mode)
12# - macOS/OSX (x64, arm64)
13# - FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
14# > PLATFORM_DESKTOP_SDL (SDL backend):
15# - Windows (Win32, Win64)
16# - Linux (X11/Wayland desktop mode)
17# - Others (not tested)
18# > PLATFORM_DESKTOP_RGFW (RGFW backend):
19# - Windows (Win32, Win64)
20# - Linux (X11 desktop mode)
21# - macOS/OSX (x64, arm64 (not tested))
22# - Others (not tested)
23# > PLATFORM_WEB:
24# - HTML5 (WebAssembly)
25# > PLATFORM_DRM:
26# - Raspberry Pi 0-5 (DRM/KMS)
27# - Linux DRM subsystem (KMS mode)
28# > PLATFORM_ANDROID:
29# - Android (ARM, ARM64)
30#
31# Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
32# Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
33#
34# Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
35#
36# This software is provided "as-is", without any express or implied warranty. In no event
37# will the authors be held liable for any damages arising from the use of this software.
38#
39# Permission is granted to anyone to use this software for any purpose, including commercial
40# applications, and to alter it and redistribute it freely, subject to the following restrictions:
41#
42# 1. The origin of this software must not be misrepresented; you must not claim that you
43# wrote the original software. If you use this software in a product, an acknowledgment
44# in the product documentation would be appreciated but is not required.
45#
46# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
47# as being the original software.
48#
49# 3. This notice may not be removed or altered from any source distribution.
50#
51#**************************************************************************************************
52
53# NOTE: Highly recommended to read the raylib Wiki to know how to compile raylib for different platforms
54# https://github.com/raysan5/raylib/wiki
55
56.PHONY: all clean install uninstall
57
58# Define required environment variables
59#------------------------------------------------------------------------------------------------
60# Define target platform
61PLATFORM ?= PLATFORM_DESKTOP
62
63ifeq ($(PLATFORM), PLATFORM_DESKTOP)
64 TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW
65else
66 TARGET_PLATFORM = $(PLATFORM)
67endif
68
69# Define required raylib variables
70RAYLIB_VERSION = 5.5.0
71RAYLIB_API_VERSION = 550
72
73# Define raylib source code path
74RAYLIB_SRC_PATH ?= ../src
75
76# Define output directory for compiled library, defaults to src directory
77# NOTE: If externally provided, make sure directory exists
78RAYLIB_RELEASE_PATH ?= $(RAYLIB_SRC_PATH)
79
80# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
81RAYLIB_LIBTYPE ?= STATIC
82
83# Build mode for library: DEBUG or RELEASE
84RAYLIB_BUILD_MODE ?= RELEASE
85
86# Build output name for the library
87RAYLIB_LIB_NAME ?= raylib
88
89# Define resource file for DLL properties
90RAYLIB_RES_FILE ?= ./raylib.dll.rc.data
91
92# Define external config flags
93# NOTE: It will override config.h flags with the provided ones,
94# if NONE, default config.h flags are used
95RAYLIB_CONFIG_FLAGS ?= NONE
96
97# To define additional cflags: Use make CUSTOM_CFLAGS=""
98
99# Include raylib modules on compilation
100# NOTE: Some programs like tools could not require those modules
101RAYLIB_MODULE_AUDIO ?= TRUE
102RAYLIB_MODULE_MODELS ?= TRUE
103RAYLIB_MODULE_RAYGUI ?= FALSE
104
105# NOTE: Additional libraries have been moved to their own repos:
106# raygui: https://github.com/raysan5/raygui
107RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src
108
109# Use external GLFW library instead of rglfw module
110USE_EXTERNAL_GLFW ?= FALSE
111
112# Enable support for X11 by default on Linux when using GLFW
113# NOTE: Wayland is disabled by default, only enable if you are sure
114GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
115GLFW_LINUX_ENABLE_X11 ?= TRUE
116
117# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
118# WARNING: Library is not included in raylib, it MUST be configured by users
119SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
120SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
121SDL_LIBRARIES ?= -lSDL2 -lSDL2main
122
123
124# Determine if the file has root access (only required to install raylib)
125# "whoami" prints the name of the user that calls him (so, if it is the root user, "whoami" prints "root")
126ROOT = $(shell whoami)
127
128# By default we suppose we are working on Windows
129HOST_PLATFORM_OS ?= WINDOWS
130PLATFORM_OS ?= WINDOWS
131
132# Determine PLATFORM_OS when required
133ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_ANDROID))
134 # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
135 # ifeq ($(UNAME),Msys) -> Windows
136 ifeq ($(OS),Windows_NT)
137 PLATFORM_OS = WINDOWS
138 ifndef PLATFORM_SHELL
139 PLATFORM_SHELL = cmd
140 endif
141 else
142 UNAMEOS = $(shell uname)
143 ifeq ($(UNAMEOS),Linux)
144 PLATFORM_OS = LINUX
145 endif
146 ifeq ($(UNAMEOS),FreeBSD)
147 PLATFORM_OS = BSD
148 endif
149 ifeq ($(UNAMEOS),OpenBSD)
150 PLATFORM_OS = BSD
151 endif
152 ifeq ($(UNAMEOS),NetBSD)
153 PLATFORM_OS = BSD
154 endif
155 ifeq ($(UNAMEOS),DragonFly)
156 PLATFORM_OS = BSD
157 endif
158 ifeq ($(UNAMEOS),Darwin)
159 PLATFORM_OS = OSX
160 endif
161 ifndef PLATFORM_SHELL
162 PLATFORM_SHELL = sh
163 endif
164 endif
165endif
166ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
167 UNAMEOS = $(shell uname)
168 ifeq ($(UNAMEOS),Linux)
169 PLATFORM_OS = LINUX
170 endif
171 ifndef PLATFORM_SHELL
172 PLATFORM_SHELL = sh
173 endif
174endif
175ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
176 ifeq ($(PLATFORM_OS),LINUX)
177 ifndef PLATFORM_SHELL
178 PLATFORM_SHELL = sh
179 endif
180 endif
181endif
182
183ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
184 ifeq ($(PLATFORM_OS), WINDOWS)
185 # Emscripten required variables
186 EMSDK_PATH ?= C:/raylib/emsdk
187 EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
188 CLANG_PATH := $(EMSDK_PATH)/upstream/bin
189 PYTHON_PATH := $(EMSDK_PATH)/python/3.9.2-nuget_64bit
190 NODE_PATH := $(EMSDK_PATH)/node/20.18.0_64bit/bin
191 export PATH := $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:/raylib/MinGW/bin;$(PATH)
192 endif
193endif
194
195ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
196 # Android architecture
197 # Starting at 2019 using arm64 is mandatory for published apps,
198 # Starting on August 2020, minimum required target API is Android 10 (API level 29)
199 ANDROID_ARCH ?= arm64
200 ANDROID_API_VERSION ?= 29
201
202 # Android required path variables
203 # NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
204 ifeq ($(OS),Windows_NT)
205 ANDROID_NDK ?= C:/android-ndk
206 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
207 else
208 ANDROID_NDK ?= /usr/lib/android/ndk
209 ifeq ($(PLATFORM_OS), OSX)
210 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/darwin-x86_64
211 else
212 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
213 endif
214 endif
215
216 # NOTE: Sysroot can also be reference from $(ANDROID_NDK)/sysroot
217 ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot
218
219 ifeq ($(ANDROID_ARCH),arm)
220 ANDROID_COMPILER_ARCH = armv7a
221 endif
222 ifeq ($(ANDROID_ARCH),arm64)
223 ANDROID_COMPILER_ARCH = aarch64
224 endif
225 ifeq ($(ANDROID_ARCH),x86)
226 ANDROID_COMPILER_ARCH = i686
227 endif
228 ifeq ($(ANDROID_ARCH),x86_64)
229 ANDROID_COMPILER_ARCH = x86_64
230 endif
231
232endif
233
234# Define raylib graphics api depending on selected platform
235# NOTE: By default use OpenGL 3.3 on desktop platforms
236ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
237 GRAPHICS ?= GRAPHICS_API_OPENGL_33
238 #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
239 #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
240 #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
241 #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
242endif
243ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
244 GRAPHICS ?= GRAPHICS_API_OPENGL_33
245endif
246ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
247 GRAPHICS ?= GRAPHICS_API_OPENGL_33
248 #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
249 #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
250 #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
251 #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
252endif
253ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
254 # On DRM OpenGL ES 2.0 must be used
255 GRAPHICS = GRAPHICS_API_OPENGL_ES2
256endif
257ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
258 # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
259 GRAPHICS = GRAPHICS_API_OPENGL_ES2
260 #GRAPHICS = GRAPHICS_API_OPENGL_ES3
261endif
262ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
263 # By default use OpenGL ES 2.0 on Android
264 GRAPHICS = GRAPHICS_API_OPENGL_ES2
265endif
266
267# Define default C compiler and archiver to pack library: CC, AR
268#------------------------------------------------------------------------------------------------
269CC = gcc
270AR = ar
271
272ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
273 ifeq ($(PLATFORM_OS),OSX)
274 # OSX default compiler
275 CC = clang
276 GLFW_OSX = -x objective-c
277 endif
278 ifeq ($(PLATFORM_OS),BSD)
279 # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
280 CC = clang
281 endif
282endif
283ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
284 ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
285 # Define RPI cross-compiler
286 #CC = armv6j-hardfloat-linux-gnueabi-gcc
287 CC = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-gcc
288 AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar
289 endif
290endif
291ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
292 # HTML5 emscripten compiler
293 CC = emcc
294 AR = emar
295endif
296ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
297 # Android toolchain (must be provided for desired architecture and compiler)
298 ifeq ($(ANDROID_ARCH),arm)
299 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-androideabi$(ANDROID_API_VERSION)-clang
300 endif
301 ifeq ($(ANDROID_ARCH),arm64)
302 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
303 endif
304 ifeq ($(ANDROID_ARCH),x86)
305 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
306 endif
307 ifeq ($(ANDROID_ARCH),x86_64)
308 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
309 endif
310 # It seems from Android NDK r22 onwards we need to use llvm-ar
311 AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar
312endif
313
314# Define compiler flags: CFLAGS
315#------------------------------------------------------------------------------------------------
316# -O1 defines optimization level
317# -g include debug information on compilation
318# -s strip unnecessary data from build --> linker
319# -Wall turns on most, but not all, compiler warnings
320# -std=c99 defines C language mode (standard C from 1999 revision)
321# -std=gnu99 defines C language mode (GNU C from 1999 revision)
322# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
323# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
324# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
325# -D_GNU_SOURCE access to lots of nonstandard GNU/Linux extension functions
326# -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers
327# -fno-strict-aliasing jar_xm.h does shady stuff (breaks strict aliasing)
328CFLAGS = -Wall -D_GNU_SOURCE -D$(TARGET_PLATFORM) -D$(GRAPHICS) -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing
329
330ifneq ($(RAYLIB_CONFIG_FLAGS), NONE)
331 CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS)
332endif
333
334ifeq ($(TARGET_PLATFORM), PLATFORM_WEB)
335 # NOTE: When using multi-threading in the user code, it requires -pthread enabled
336 CFLAGS += -std=gnu99
337else
338 CFLAGS += -std=c99
339endif
340
341ifeq ($(PLATFORM_OS), LINUX)
342 CFLAGS += -fPIC
343endif
344
345ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
346 CFLAGS += -g -D_DEBUG
347endif
348
349ifeq ($(RAYLIB_BUILD_MODE),RELEASE)
350 ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
351 CFLAGS += -Os
352 endif
353 ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
354 CFLAGS += -O1
355 endif
356 ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
357 CFLAGS += -O2
358 endif
359endif
360
361# Additional flags for compiler (if desired)
362# -Wextra enables some extra warning flags that are not enabled by -Wall
363# -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration
364# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
365# -Werror=implicit-function-declaration catch function calls without prior declaration
366ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
367 CFLAGS += -Werror=implicit-function-declaration
368endif
369ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
370 # -Os # size optimization
371 # -O2 # optimization level 2, if used, also set --memory-init-file 0
372 # -sUSE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker!
373 # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
374 # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
375 # -sUSE_PTHREADS=1 # multithreading support
376 # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
377 # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
378 # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading
379 # --profiling # include information for code profiling
380 # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
381 # --preload-file resources # specify a resources folder for data compilation
382 ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
383 CFLAGS += -sASSERTIONS=1 --profiling
384 endif
385 #CFLAGS += -sGL_ENABLE_GET_PROC_ADDRESS
386endif
387ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
388 # Compiler flags for arquitecture
389 ifeq ($(ANDROID_ARCH),arm)
390 CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
391 endif
392 ifeq ($(ANDROID_ARCH),arm64)
393 CFLAGS += -target aarch64 -mfix-cortex-a53-835769
394 endif
395 ifeq ($(ANDROID_ARCH),x86)
396 CFLAGS += -march=i686
397 endif
398 ifeq ($(ANDROID_ARCH),x86_64)
399 CFLAGS += -march=x86-64
400 endif
401 # Compilation functions attributes options
402 CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIE -fPIC
403 # Compiler options for the linker
404 # -Werror=format-security
405 CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes
406 # Preprocessor macro definitions
407 CFLAGS += -D__ANDROID__ -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
408endif
409
410# Define required compilation flags for raylib SHARED lib
411ifeq ($(RAYLIB_LIBTYPE),SHARED)
412 # make sure code is compiled as position independent
413 # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC
414 # MinGW32 just doesn't need -fPIC, it shows warnings
415 CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED
416
417 # hide all symbols by default, so RLAPI can expose them
418 ifeq ($(PLATFORM_OS),$(filter $(PLATFORM_OS), LINUX BSD OSX))
419 CFLAGS += -fvisibility=hidden
420 endif
421endif
422
423ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
424 # without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in
425 # which contains a conflicting type Font
426 CFLAGS += -DEGL_NO_X11
427 CFLAGS += -Werror=implicit-function-declaration
428endif
429# Use Wayland display on Linux desktop
430ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
431 ifeq ($(PLATFORM_OS), LINUX)
432 ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
433 CFLAGS += -D_GLFW_X11
434 endif
435 ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
436 CFLAGS += -D_GLFW_WAYLAND
437 LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
438
439 WL_PROTOCOLS_DIR := external/glfw/deps/wayland
440
441 wl_generate = \
442 $(eval protocol=$(1)) \
443 $(eval basename=$(2)) \
444 $(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \
445 $(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.h)
446
447 $(call wl_generate, $(WL_PROTOCOLS_DIR)/wayland.xml, wayland-client-protocol)
448 $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol)
449 $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol)
450 $(call wl_generate, $(WL_PROTOCOLS_DIR)/viewporter.xml, viewporter-client-protocol)
451 $(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol)
452 $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol)
453 $(call wl_generate, $(WL_PROTOCOLS_DIR)/fractional-scale-v1.xml, fractional-scale-v1-client-protocol)
454 $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-activation-v1.xml, xdg-activation-v1-client-protocol)
455 $(call wl_generate, $(WL_PROTOCOLS_DIR)/idle-inhibit-unstable-v1.xml, idle-inhibit-unstable-v1-client-protocol)
456 endif
457 endif
458endif
459
460CFLAGS += $(CUSTOM_CFLAGS)
461
462# Define include paths for required headers: INCLUDE_PATHS
463# NOTE: Several external required libraries (stb and others)
464#------------------------------------------------------------------------------------------------
465INCLUDE_PATHS = -I. $(EXTRA_INCLUDE_PATHS)
466
467# Define additional directories containing required header files
468ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
469 INCLUDE_PATHS += -Iexternal/glfw/include
470 ifeq ($(PLATFORM_OS),BSD)
471 INCLUDE_PATHS += -I/usr/local/include -I/usr/pkg/include -I/usr/X11R7/include
472 endif
473endif
474ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
475 INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH)
476endif
477ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
478 INCLUDE_PATHS += -Iexternal/glfw/include
479endif
480ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
481 INCLUDE_PATHS += -I/usr/include/libdrm
482 ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
483 INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/usr/include
484 INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
485 endif
486endif
487ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
488 NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue
489 # Include android_native_app_glue.h
490 INCLUDE_PATHS += -I$(NATIVE_APP_GLUE)
491
492 # Android required libraries
493 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include
494 ifeq ($(ANDROID_ARCH),arm)
495 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/arm-linux-androideabi
496 endif
497 ifeq ($(ANDROID_ARCH),arm64)
498 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/aarch64-linux-android
499 endif
500 ifeq ($(ANDROID_ARCH),x86)
501 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/i686-linux-android
502 endif
503 ifeq ($(ANDROID_ARCH),x86_64)
504 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/x86_64-linux-android
505 endif
506endif
507
508# Define library paths containing required libs: LDFLAGS
509# NOTE: This is only required for dynamic library generation
510#------------------------------------------------------------------------------------------------
511LDFLAGS = $(CUSTOM_LDFLAGS) -L. -L$(RAYLIB_RELEASE_PATH)
512
513ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
514 ifeq ($(PLATFORM_OS),WINDOWS)
515 ifneq ($(CC), tcc)
516 LDFLAGS += -Wl,--out-implib,$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME)dll.a
517 endif
518 endif
519 ifeq ($(PLATFORM_OS),OSX)
520 LDFLAGS += -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION)
521 endif
522 ifeq ($(PLATFORM_OS),LINUX)
523 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
524 endif
525 ifeq ($(PLATFORM_OS),BSD)
526 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so -Lsrc -L/usr/local/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib
527 endif
528endif
529ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
530 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
531 LDFLAGS += -L$(SDL_LIBRARY_PATH)
532endif
533ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
534 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
535 ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
536 LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib -L$(RPI_TOOLCHAIN_SYSROOT)/usr/lib
537 endif
538endif
539ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
540 LDFLAGS += -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -Wl,--exclude-libs,libatomic.a
541 LDFLAGS += -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
542 # Force linking of library module to define symbol
543 LDFLAGS += -u ANativeActivity_onCreate
544 # Library paths containing required libs
545 LDFLAGS += -Lsrc
546 # Avoid unresolved symbol pointing to external main()
547 LDFLAGS += -Wl,-undefined,dynamic_lookup
548endif
549
550# Define libraries required on linking: LDLIBS
551# NOTE: This is only required for dynamic library generation
552#------------------------------------------------------------------------------------------------
553ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
554 ifeq ($(PLATFORM_OS),WINDOWS)
555 ifeq ($(CC), tcc)
556 LDLIBS = -lopengl32 -lgdi32 -lwinmm -lshell32
557 else
558 LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm
559 endif
560 endif
561 ifeq ($(PLATFORM_OS),LINUX)
562 LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt
563 ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
564 LDLIBS += -lX11
565 endif
566 # TODO: On ARM 32bit arch, miniaudio requires atomics library
567 #LDLIBS += -latomic
568 endif
569 ifeq ($(PLATFORM_OS),OSX)
570 LDLIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
571 endif
572 ifeq ($(PLATFORM_OS),BSD)
573 LDLIBS = -lGL -lpthread
574 endif
575 ifeq ($(USE_EXTERNAL_GLFW),TRUE)
576 # Check the version name. If GLFW3 was built manually, it may have produced
577 # a static library known as libglfw3.a. In that case, the name should be -lglfw3
578 LDLIBS = -lglfw
579 endif
580endif
581ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
582 ifeq ($(PLATFORM_OS),WINDOWS)
583 LDLIBS = -static-libgcc -lopengl32 -lgdi32
584 endif
585 ifeq ($(PLATFORM_OS),LINUX)
586 LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt
587 ifeq ($(USE_WAYLAND_DISPLAY),FALSE)
588 LDLIBS += -lX11
589 endif
590 endif
591 LDLIBS += $(SDL_LIBRARIES)
592endif
593ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
594 ifeq ($(PLATFORM_OS),WINDOWS)
595 # Libraries for Windows desktop compilation
596 LDLIBS = -lgdi32 -lwinmm -lopengl32
597 endif
598 ifeq ($(PLATFORM_OS),LINUX)
599 # Libraries for Debian GNU/Linux desktop compipling
600 # NOTE: Required packages: libegl1-mesa-dev
601 LDLIBS = -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lm -lpthread -ldl -lrt
602
603 # Explicit link to libc
604 ifeq ($(RAYLIB_LIBTYPE),SHARED)
605 LDLIBS += -lc
606 endif
607
608 # NOTE: On ARM 32bit arch, miniaudio requires atomics library
609 LDLIBS += -latomic
610 endif
611 ifeq ($(PLATFORM_OS),OSX)
612 # Libraries for Debian MacOS desktop compiling
613 # NOTE: Required packages: libegl1-mesa-dev
614 LDLIBS += -lm -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
615 endif
616endif
617ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
618 LDLIBS = -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl
619 ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
620 LDLIBS += -latomic
621 endif
622endif
623ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
624 LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm
625endif
626
627# Define source code object files required
628#------------------------------------------------------------------------------------------------
629OBJS = rcore.o \
630 rshapes.o \
631 rtextures.o \
632 rtext.o \
633 utils.o
634
635ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
636 ifeq ($(USE_EXTERNAL_GLFW),FALSE)
637 OBJS += rglfw.o
638 endif
639endif
640ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
641 OBJS += rmodels.o
642endif
643ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
644 OBJS += raudio.o
645endif
646ifeq ($(RAYLIB_MODULE_RAYGUI),TRUE)
647 OBJS += raygui.o
648endif
649
650ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
651 OBJS += android_native_app_glue.o
652endif
653
654# Define processes to execute
655#------------------------------------------------------------------------------------------------
656# Default target entry
657all: raylib
658
659# Compile raylib library
660# NOTE: Release directory is created if not exist
661raylib: $(OBJS)
662ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
663 # Compile raylib libray for web
664 #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc
665 $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
666 @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).a)!"
667else
668 ifeq ($(RAYLIB_LIBTYPE),SHARED)
669 ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))
670 ifeq ($(PLATFORM_OS),WINDOWS)
671 # NOTE: Linking with provided resource file
672 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) $(LDLIBS)
673 @echo "raylib dynamic library ($(RAYLIB_LIB_NAME).dll) and import library (lib$(RAYLIB_LIB_NAME)dll.a) generated!"
674 endif
675 ifeq ($(PLATFORM_OS),LINUX)
676 # Compile raylib shared library version $(RAYLIB_VERSION).
677 # WARNING: you should type "make clean" before doing this target
678 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS)
679 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
680 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
681 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
682 endif
683 ifeq ($(PLATFORM_OS),OSX)
684 $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) $(LDLIBS)
685 install_name_tool -id "@rpath/lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib
686 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!"
687 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib
688 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).dylib
689 endif
690 ifeq ($(PLATFORM_OS),BSD)
691 # WARNING: you should type "gmake clean" before doing this target
692 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS)
693 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
694 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
695 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
696 endif
697 endif
698 ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
699 # Compile raylib shared library version $(RAYLIB_VERSION).
700 # WARNING: you should type "make clean" before doing this target
701 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS)
702 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
703 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
704 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
705 endif
706 ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
707 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS)
708 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
709 # WARNING: symbolic links creation on Windows should be done using mklink command, no ln available
710 ifeq ($(HOST_PLATFORM_OS),LINUX)
711 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
712 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
713 endif
714 endif
715 else
716 # Compile raylib static library version $(RAYLIB_VERSION)
717 # WARNING: You should type "make clean" before doing this target.
718 $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
719 @echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!"
720 endif
721endif
722
723# Compile all modules with their prerequisites
724
725# Prerequisites of core module
726rcore.o : platforms/*.c
727
728# Compile core module
729rcore.o : rcore.c raylib.h rlgl.h utils.h raymath.h rcamera.h rgestures.h
730 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
731
732# Compile rglfw module
733rglfw.o : rglfw.c
734 $(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS)
735
736# Compile shapes module
737rshapes.o : rshapes.c raylib.h rlgl.h
738 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
739
740# Compile textures module
741rtextures.o : rtextures.c raylib.h rlgl.h utils.h
742 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
743
744# Compile text module
745rtext.o : rtext.c raylib.h utils.h
746 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
747
748# Compile utils module
749utils.o : utils.c utils.h
750 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
751
752# Compile models module
753rmodels.o : rmodels.c raylib.h rlgl.h raymath.h
754 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
755
756# Compile audio module
757raudio.o : raudio.c raylib.h
758 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
759
760# Compile raygui module
761# NOTE: raygui header should be distributed with raylib.h
762raygui.o : raygui.c
763 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
764raygui.c:
765ifeq ($(PLATFORM_SHELL), cmd)
766 @echo #define RAYGUI_IMPLEMENTATION > raygui.c
767 @echo #include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h" >> raygui.c
768else
769 @echo "#define RAYGUI_IMPLEMENTATION" > raygui.c
770 @echo "#include \"$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h\"" >> raygui.c
771endif
772
773# Compile android_native_app_glue module
774android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
775 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
776
777# Install generated and needed files to desired directories.
778# On GNU/Linux and BSDs, there are some standard directories that contain extra
779# libraries and header files. These directories (often /usr/local/lib and
780# /usr/local/include) are for libraries that are installed manually
781# (without a package manager). We'll use /usr/local/lib/raysan5 and /usr/local/include/raysan5
782# for our -L and -I specification to simplify management of the raylib source package.
783# Customize these locations if you like but don't forget to pass them to make
784# for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig.
785# HINT: Add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles.
786# See below and ../examples/Makefile for more information.
787
788# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
789DESTDIR ?= /usr/local
790RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
791# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
792RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
793
794install :
795ifeq ($(ROOT),root)
796 ifeq ($(PLATFORM_OS),LINUX)
797 # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH)
798 # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information.
799 # Prepare the environment as needed.
800 mkdir --parents --verbose $(RAYLIB_INSTALL_PATH)
801 mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH)
802 ifeq ($(RAYLIB_LIBTYPE),SHARED)
803 # Installing raylib to $(RAYLIB_INSTALL_PATH).
804 cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)
805 cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
806 cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
807 # Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH.
808 # Not necessary if later embedding RPATH in your executable. See examples/Makefile.
809 ldconfig $(RAYLIB_INSTALL_PATH)
810 else
811 # Installing raylib to $(RAYLIB_INSTALL_PATH).
812 cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a
813 endif
814 # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH).
815 cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
816 cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
817 cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
818 @echo "raylib development files installed/updated!"
819 else
820 @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
821 endif
822else
823 @echo "Error: Root permissions needed for installation. Try sudo make install"
824endif
825
826# Remove raylib dev files installed on the system
827# NOTE: see 'install' target.
828uninstall :
829ifeq ($(ROOT),root)
830 # WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH).
831 # and $(RAYLIB_H_INSTALL_PATH). Please confirm each item.
832 ifeq ($(PLATFORM_OS),LINUX)
833 ifeq ($(RAYLIB_LIBTYPE),SHARED)
834 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
835 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
836 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
837 # Uncomment to clean up the runtime linker cache. See install target.
838 ldconfig
839 else
840 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
841 endif
842 rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
843 rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
844 rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
845 @echo "raylib development files removed!"
846 else
847 @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
848 endif
849else
850 @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall"
851endif
852
853.PHONY: clean_shell_cmd clean_shell_sh
854
855# Clean everything
856clean: clean_shell_$(PLATFORM_SHELL)
857 @echo "removed all generated files!"
858
859clean_shell_sh:
860 rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h
861ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
862 rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
863endif
864
865# Set specific target variable
866clean_shell_cmd: SHELL=cmd
867clean_shell_cmd:
868 del *.o /s
869 cd $(RAYLIB_RELEASE_PATH) & \
870 del lib$(RAYLIB_LIB_NAME).a /s & \
871 del lib$(RAYLIB_LIB_NAME)dll.a /s & \
872 del $(RAYLIB_LIB_NAME).dll /s & \
873 del raygui.c /s & \
diff --git a/raylib/src/config.h b/raylib/src/config.h
new file mode 100644
index 0000000..e3749c5
--- /dev/null
+++ b/raylib/src/config.h
@@ -0,0 +1,303 @@
1/**********************************************************************************************
2*
3* raylib configuration flags
4*
5* This file defines all the configuration flags for the different raylib modules
6*
7* LICENSE: zlib/libpng
8*
9* Copyright (c) 2018-2024 Ahmad Fatoum & Ramon Santamaria (@raysan5)
10*
11* This software is provided "as-is", without any express or implied warranty. In no event
12* will the authors be held liable for any damages arising from the use of this software.
13*
14* Permission is granted to anyone to use this software for any purpose, including commercial
15* applications, and to alter it and redistribute it freely, subject to the following restrictions:
16*
17* 1. The origin of this software must not be misrepresented; you must not claim that you
18* wrote the original software. If you use this software in a product, an acknowledgment
19* in the product documentation would be appreciated but is not required.
20*
21* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
22* as being the original software.
23*
24* 3. This notice may not be removed or altered from any source distribution.
25*
26**********************************************************************************************/
27
28#ifndef CONFIG_H
29#define CONFIG_H
30
31//------------------------------------------------------------------------------------
32// Module selection - Some modules could be avoided
33// Mandatory modules: rcore, rlgl, utils
34//------------------------------------------------------------------------------------
35#define SUPPORT_MODULE_RSHAPES 1
36#define SUPPORT_MODULE_RTEXTURES 1
37#define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures
38#define SUPPORT_MODULE_RMODELS 1
39#define SUPPORT_MODULE_RAUDIO 1
40
41//------------------------------------------------------------------------------------
42// Module: rcore - Configuration Flags
43//------------------------------------------------------------------------------------
44// Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
45#define SUPPORT_CAMERA_SYSTEM 1
46// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
47#define SUPPORT_GESTURES_SYSTEM 1
48// Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64
49#define SUPPORT_RPRAND_GENERATOR 1
50// Mouse gestures are directly mapped like touches and processed by gestures system
51#define SUPPORT_MOUSE_GESTURES 1
52// Reconfigure standard input to receive key inputs, works with SSH connection.
53#define SUPPORT_SSH_KEYBOARD_RPI 1
54// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
55// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
56#define SUPPORT_WINMM_HIGHRES_TIMER 1
57// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
58//#define SUPPORT_BUSY_WAIT_LOOP 1
59// Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy
60#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1
61// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
62#define SUPPORT_SCREEN_CAPTURE 1
63// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
64#define SUPPORT_GIF_RECORDING 1
65// Support CompressData() and DecompressData() functions
66#define SUPPORT_COMPRESSION_API 1
67// Support automatic generated events, loading and recording of those events when required
68#define SUPPORT_AUTOMATION_EVENTS 1
69// Support custom frame control, only for advanced users
70// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()
71// Enabling this flag allows manual control of the frame processes, use at your own risk
72//#define SUPPORT_CUSTOM_FRAME_CONTROL 1
73
74
75// rcore: Configuration values
76//------------------------------------------------------------------------------------
77#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
78#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value)
79
80#define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported
81#define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported
82#define MAX_GAMEPADS 4 // Maximum number of gamepads supported
83#define MAX_GAMEPAD_AXIS 8 // Maximum number of axis supported (per gamepad)
84#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
85#define MAX_GAMEPAD_VIBRATION_TIME 2.0f // Maximum vibration time in seconds
86#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
87#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
88#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
89
90#define MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB
91
92#define MAX_AUTOMATION_EVENTS 16384 // Maximum number of automation events to record
93
94//------------------------------------------------------------------------------------
95// Module: rlgl - Configuration values
96//------------------------------------------------------------------------------------
97
98// Enable OpenGL Debug Context (only available on OpenGL 4.3)
99//#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 1
100
101// Show OpenGL extensions and capabilities detailed logs on init
102//#define RLGL_SHOW_GL_DETAILS_INFO 1
103
104#define RL_SUPPORT_MESH_GPU_SKINNING 1 // GPU skinning, comment if your GPU does not support more than 8 VBOs
105
106//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits
107#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
108#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
109#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
110
111#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
112
113#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
114
115#define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
116#define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
117
118// Default shader vertex attribute locations
119#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0
120#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1
121#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2
122#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3
123#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4
124#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
125#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
126#if defined(RL_SUPPORT_MESH_GPU_SKINNING)
127 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7
128 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
129#endif
130
131// Default shader vertex attribute names to set location points
132// NOTE: When a new shader is loaded, the following locations are tried to be set for convenience
133#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION
134#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD
135#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL
136#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR
137#define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT
138#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2
139
140#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
141#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
142#define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
143#define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
144#define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))
145#define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color)
146#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
147#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
148#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
149
150
151//------------------------------------------------------------------------------------
152// Module: rshapes - Configuration Flags
153//------------------------------------------------------------------------------------
154// Use QUADS instead of TRIANGLES for drawing when possible
155// Some lines-based shapes could still use lines
156#define SUPPORT_QUADS_DRAW_MODE 1
157
158// rshapes: Configuration values
159//------------------------------------------------------------------------------------
160#define SPLINE_SEGMENT_DIVISIONS 24 // Spline segments subdivisions
161
162
163//------------------------------------------------------------------------------------
164// Module: rtextures - Configuration Flags
165//------------------------------------------------------------------------------------
166// Selecte desired fileformats to be supported for image data loading
167#define SUPPORT_FILEFORMAT_PNG 1
168//#define SUPPORT_FILEFORMAT_BMP 1
169//#define SUPPORT_FILEFORMAT_TGA 1
170//#define SUPPORT_FILEFORMAT_JPG 1
171#define SUPPORT_FILEFORMAT_GIF 1
172#define SUPPORT_FILEFORMAT_QOI 1
173//#define SUPPORT_FILEFORMAT_PSD 1
174#define SUPPORT_FILEFORMAT_DDS 1
175//#define SUPPORT_FILEFORMAT_HDR 1
176//#define SUPPORT_FILEFORMAT_PIC 1
177//#define SUPPORT_FILEFORMAT_KTX 1
178//#define SUPPORT_FILEFORMAT_ASTC 1
179//#define SUPPORT_FILEFORMAT_PKM 1
180//#define SUPPORT_FILEFORMAT_PVR 1
181
182// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
183#define SUPPORT_IMAGE_EXPORT 1
184// Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
185#define SUPPORT_IMAGE_GENERATION 1
186// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
187// If not defined, still some functions are supported: ImageFormat(), ImageCrop(), ImageToPOT()
188#define SUPPORT_IMAGE_MANIPULATION 1
189
190
191//------------------------------------------------------------------------------------
192// Module: rtext - Configuration Flags
193//------------------------------------------------------------------------------------
194// Default font is loaded on window initialization to be available for the user to render simple text
195// NOTE: If enabled, uses external module functions to load default raylib font
196#define SUPPORT_DEFAULT_FONT 1
197// Selected desired font fileformats to be supported for loading
198#define SUPPORT_FILEFORMAT_TTF 1
199#define SUPPORT_FILEFORMAT_FNT 1
200//#define SUPPORT_FILEFORMAT_BDF 1
201
202// Support text management functions
203// If not defined, still some functions are supported: TextLength(), TextFormat()
204#define SUPPORT_TEXT_MANIPULATION 1
205
206// On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle
207// at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow
208// drawing text and shapes with a single draw call [SetShapesTexture()].
209#define SUPPORT_FONT_ATLAS_WHITE_REC 1
210
211// rtext: Configuration values
212//------------------------------------------------------------------------------------
213#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
214 // TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit()
215#define MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit()
216
217
218//------------------------------------------------------------------------------------
219// Module: rmodels - Configuration Flags
220//------------------------------------------------------------------------------------
221// Selected desired model fileformats to be supported for loading
222#define SUPPORT_FILEFORMAT_OBJ 1
223#define SUPPORT_FILEFORMAT_MTL 1
224#define SUPPORT_FILEFORMAT_IQM 1
225#define SUPPORT_FILEFORMAT_GLTF 1
226#define SUPPORT_FILEFORMAT_VOX 1
227#define SUPPORT_FILEFORMAT_M3D 1
228// Support procedural mesh generation functions, uses external par_shapes.h library
229// NOTE: Some generated meshes DO NOT include generated texture coordinates
230#define SUPPORT_MESH_GENERATION 1
231
232// rmodels: Configuration values
233//------------------------------------------------------------------------------------
234#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
235
236#ifdef RL_SUPPORT_MESH_GPU_SKINNING
237#define MAX_MESH_VERTEX_BUFFERS 9 // Maximum vertex buffers (VBO) per mesh
238#else
239#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
240#endif
241
242//------------------------------------------------------------------------------------
243// Module: raudio - Configuration Flags
244//------------------------------------------------------------------------------------
245// Desired audio fileformats to be supported for loading
246#define SUPPORT_FILEFORMAT_WAV 1
247#define SUPPORT_FILEFORMAT_OGG 1
248#define SUPPORT_FILEFORMAT_MP3 1
249#define SUPPORT_FILEFORMAT_QOA 1
250//#define SUPPORT_FILEFORMAT_FLAC 1
251#define SUPPORT_FILEFORMAT_XM 1
252#define SUPPORT_FILEFORMAT_MOD 1
253
254// raudio: Configuration values
255//------------------------------------------------------------------------------------
256#define AUDIO_DEVICE_FORMAT ma_format_f32 // Device output format (miniaudio: float-32bit)
257#define AUDIO_DEVICE_CHANNELS 2 // Device output channels: stereo
258#define AUDIO_DEVICE_SAMPLE_RATE 0 // Device sample rate (device default)
259
260#define MAX_AUDIO_BUFFER_POOL_CHANNELS 16 // Maximum number of audio pool channels
261
262//------------------------------------------------------------------------------------
263// Module: utils - Configuration Flags
264//------------------------------------------------------------------------------------
265// Standard file io library (stdio.h) included
266#define SUPPORT_STANDARD_FILEIO 1
267// Show TRACELOG() output messages
268// NOTE: By default LOG_DEBUG traces not shown
269#define SUPPORT_TRACELOG 1
270//#define SUPPORT_TRACELOG_DEBUG 1
271
272// utils: Configuration values
273//------------------------------------------------------------------------------------
274#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
275
276
277// Enable partial support for clipboard image, only working on SDL3 or
278// being on both Windows OS + GLFW or Windows OS + RGFW
279#define SUPPORT_CLIPBOARD_IMAGE 1
280
281#if defined(SUPPORT_CLIPBOARD_IMAGE)
282 #ifndef STBI_REQUIRED
283 #define STBI_REQUIRED
284 #endif
285
286 #ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows
287 #define SUPPORT_FILEFORMAT_BMP 1
288 #endif
289
290 #ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu
291 #define SUPPORT_FILEFORMAT_PNG 1
292 #endif
293
294 #ifndef SUPPORT_FILEFORMAT_JPG
295 #define SUPPORT_FILEFORMAT_JPG 1
296 #endif
297
298 #ifndef SUPPORT_MODULE_RTEXTURES
299 #define SUPPORT_MODULE_RTEXTURES 1
300 #endif
301#endif
302
303#endif // CONFIG_H
diff --git a/raylib/src/external/RGFW.h b/raylib/src/external/RGFW.h
new file mode 100644
index 0000000..978536f
--- /dev/null
+++ b/raylib/src/external/RGFW.h
@@ -0,0 +1,9015 @@
1/*
2* Copyright (C) 2023-24 ColleagueRiley
3*
4* libpng license
5*
6* This software is provided 'as-is', without any express or implied
7* warranty. In no event will the authors be held liable for any damages
8* arising from the use of this software.
9*
10* Permission is granted to anyone to use this software for any purpose,
11* including commercial applications, and to alter it and redistribute it
12* freely, subject to the following restrictions:
13*
14* 1. The origin of this software must not be misrepresented; you must not
15* claim that you wrote the original software. If you use this software
16* in a product, an acknowledgment in the product documentation would be
17* appreciated but is not required.
18* 2. Altered source versions must be plainly marked as such, and must not be
19* misrepresented as being the original software.
20* 3. This notice may not be removed or altered from any source distribution.
21*
22*
23*/
24
25/*
26 (MAKE SURE RGFW_IMPLEMENTATION is in exactly one header or you use -D RGFW_IMPLEMENTATION)
27 #define RGFW_IMPLEMENTATION - makes it so source code is included with header
28*/
29
30/*
31 #define RGFW_IMPLEMENTATION - (required) makes it so the source code is included
32 #define RGFW_PRINT_ERRORS - (optional) makes it so RGFW prints errors when they're found
33 #define RGFW_OSMESA - (optional) use OSmesa as backend (instead of system's opengl api + regular opengl)
34 #define RGFW_BUFFER - (optional) just draw directly to (RGFW) window pixel buffer that is drawn to screen (the buffer is in the RGBA format)
35 #define RGFW_EGL - (optional) use EGL for loading an OpenGL context (instead of the system's opengl api)
36 #define RGFW_OPENGL_ES1 - (optional) use EGL to load and use Opengl ES (version 1) for backend rendering (instead of the system's opengl api)
37 This version doesn't work for desktops (I'm pretty sure)
38 #define RGFW_OPENGL_ES2 - (optional) use OpenGL ES (version 2)
39 #define RGFW_OPENGL_ES3 - (optional) use OpenGL ES (version 3)
40 #define RGFW_DIRECTX - (optional) use directX for the rendering backend (rather than opengl) (windows only, defaults to opengl for unix)
41 #define RGFW_WEBGPU - (optional) use webGPU for rendering (Web ONLY)
42 #define RGFW_NO_API - (optional) don't use any rendering API (no opengl, no vulkan, no directX)
43
44 #define RGFW_LINK_EGL (optional) (windows only) if EGL is being used, if EGL functions should be defined dymanically (using GetProcAddress)
45 #define RGFW_LINK_OSMESA (optional) (windows only) if EGL is being used, if OS Mesa functions should be defined dymanically (using GetProcAddress)
46
47 #define RGFW_X11 (optional) (unix only) if X11 should be used. This option is turned on by default by unix systems except for MacOS
48 #define RGFW_WGL_LOAD (optional) (windows only) if WGL should be loaded dynamically during runtime
49 #define RGFW_NO_X11_CURSOR (optional) (unix only) don't use XCursor
50 #define RGFW_NO_X11_CURSOR_PRELOAD (optional) (unix only) Use XCursor, but don't link it in code, (you'll have to link it with -lXcursor)
51
52 #define RGFW_NO_DPI - Do not include calculate DPI (no XRM nor libShcore included)
53
54 #define RGFW_ALLOC_DROPFILES (optional) if room should be allocating for drop files (by default it's global data)
55 #define RGFW_MALLOC x - choose what function to use to allocate, by default the standard malloc is used
56 #define RGFW_CALLOC x - choose what function to use to allocate (calloc), by default the standard calloc is used
57 #define RGFW_FREE x - choose what function to use to allocated memory, by default the standard free is used
58
59 #define RGFW_EXPORT - Use when building RGFW
60 #define RGFW_IMPORT - Use when linking with RGFW (not as a single-header)
61
62 #define RGFW_STD_INT - force the use stdint.h (for systems that might not have stdint.h (msvc))
63*/
64
65/*
66 Credits :
67 EimaMei/Sacode : Much of the code for creating windows using winapi, Wrote the Silicon library, helped with MacOS Support, siliapp.h -> referencing
68
69 stb - This project is heavily inspired by the stb single header files
70
71 GLFW:
72 certain parts of winapi and X11 are very poorly documented,
73 GLFW's source code was referenced and used throughout the project (used code is marked in some way),
74 this mainly includes, code for drag and drops, code for setting the icon to a bitmap and the code for managing the clipboard for X11 (as these parts are not documented very well)
75
76 GLFW Copyright, https::/github.com/GLFW/GLFW
77
78 Copyright (c) 2002-2006 Marcus Geelnard
79 Copyright (c) 2006-2019 Camilla Löwy
80
81 contributors : (feel free to put yourself here if you contribute)
82 krisvers -> code review
83 EimaMei (SaCode) -> code review
84 Code-Nycticebus -> bug fixes
85 Rob Rohan -> X11 bugs and missing features, MacOS/Cocoa fixing memory issues/bugs
86 AICDG (@THISISAGOODNAME) -> vulkan support (example)
87 @Easymode -> support, testing/debugging, bug fixes and reviews
88 Joshua Rowe (omnisci3nce) - bug fix, review (macOS)
89 @lesleyrs -> bug fix, review (OpenGL)
90 Nick Porcino (meshula) - testing, organization, review (MacOS, examples)
91*/
92
93#if _MSC_VER
94 #pragma comment(lib, "gdi32")
95 #pragma comment(lib, "shell32")
96 #pragma comment(lib, "opengl32")
97 #pragma comment(lib, "winmm")
98 #pragma comment(lib, "user32")
99#endif
100
101#ifndef RGFW_MALLOC
102 #include <stdlib.h>
103
104 #ifndef __USE_POSIX199309
105 #define __USE_POSIX199309
106 #endif
107
108 #include <time.h>
109 #define RGFW_MALLOC malloc
110 #define RGFW_CALLOC calloc
111 #define RGFW_FREE free
112#endif
113
114#if !_MSC_VER
115 #ifndef inline
116 #ifndef __APPLE__
117 #define inline __inline
118 #endif
119 #endif
120#endif
121
122#ifdef RGFW_WIN95 /* for windows 95 testing (not that it really works) */
123 #define RGFW_NO_MONITOR
124 #define RGFW_NO_PASSTHROUGH
125#endif
126
127#if defined(RGFW_EXPORT) || defined(RGFW_IMPORT)
128 #if defined(_WIN32)
129 #if defined(__TINYC__) && (defined(RGFW_EXPORT) || defined(RGFW_IMPORT))
130 #define __declspec(x) __attribute__((x))
131 #endif
132
133 #if defined(RGFW_EXPORT)
134 #define RGFWDEF __declspec(dllexport)
135 #else
136 #define RGFWDEF __declspec(dllimport)
137 #endif
138 #else
139 #if defined(RGFW_EXPORT)
140 #define RGFWDEF __attribute__((visibility("default")))
141 #endif
142 #endif
143#endif
144
145#ifndef RGFWDEF
146 #ifdef __clang__
147 #define RGFWDEF static inline
148 #else
149 #define RGFWDEF inline
150 #endif
151#endif
152
153#ifndef RGFW_ENUM
154 #define RGFW_ENUM(type, name) type name; enum
155#endif
156
157#ifndef RGFW_UNUSED
158 #define RGFW_UNUSED(x) (void)(x);
159#endif
160
161#if defined(__cplusplus) && !defined(__EMSCRIPTEN__)
162 extern "C" {
163#endif
164
165 /* makes sure the header file part is only defined once by default */
166#ifndef RGFW_HEADER
167
168#define RGFW_HEADER
169
170#if !defined(u8)
171 #if ((defined(_MSC_VER) || defined(__SYMBIAN32__)) && !defined(RGFW_STD_INT)) /* MSVC might not have stdint.h */
172 typedef unsigned char u8;
173 typedef signed char i8;
174 typedef unsigned short u16;
175 typedef signed short i16;
176 typedef unsigned int u32;
177 typedef signed int i32;
178 typedef unsigned long u64;
179 typedef signed long i64;
180 #else /* use stdint standard types instead of c ""standard"" types */
181 #include <stdint.h>
182
183 typedef uint8_t u8;
184 typedef int8_t i8;
185 typedef uint16_t u16;
186 typedef int16_t i16;
187 typedef uint32_t u32;
188 typedef int32_t i32;
189 typedef uint64_t u64;
190 typedef int64_t i64;
191 #endif
192#endif
193
194#if !defined(b8) /* RGFW bool type */
195 typedef u8 b8;
196 typedef u32 b32;
197#endif
198
199#define RGFW_TRUE (!(0))
200#define RGFW_FALSE 0
201
202/* thse OS macros looks better & are standardized */
203/* plus it helps with cross-compiling */
204
205#ifdef __EMSCRIPTEN__
206 #define RGFW_WEBASM
207
208 #if !defined(RGFW_NO_API) && !defined(RGFW_WEBGPU)
209 #define RGFW_OPENGL
210 #endif
211
212 #ifdef RGFW_EGL
213 #undef RGFW_EGL
214 #endif
215
216 #include <emscripten/html5.h>
217 #include <emscripten/key_codes.h>
218
219 #ifdef RGFW_WEBGPU
220 #include <emscripten/html5_webgpu.h>
221 #endif
222#endif
223
224#if defined(RGFW_X11) && defined(__APPLE__)
225 #define RGFW_MACOS_X11
226 #undef __APPLE__
227#endif
228
229#if defined(_WIN32) && !defined(RGFW_X11) && !defined(RGFW_WEBASM) /* (if you're using X11 on windows some how) */
230 #define RGFW_WINDOWS
231
232 /* make sure the correct architecture is defined */
233 #if defined(_WIN64)
234 #define _AMD64_
235 #undef _X86_
236 #else
237 #undef _AMD64_
238 #ifndef _X86_
239 #define _X86_
240 #endif
241 #endif
242
243 #ifndef RGFW_NO_XINPUT
244 #ifdef __MINGW32__ /* try to find the right header */
245 #include <xinput.h>
246 #else
247 #include <XInput.h>
248 #endif
249 #endif
250
251 #if defined(RGFW_DIRECTX)
252 #include <d3d11.h>
253 #include <dxgi.h>
254 #include <dxgi.h>
255 #include <d3dcompiler.h>
256
257 #ifndef __cplusplus
258 #define __uuidof(T) IID_##T
259 #endif
260 #endif
261
262#elif defined(RGFW_WAYLAND)
263 #if !defined(RGFW_NO_API) && (!defined(RGFW_BUFFER) || defined(RGFW_OPENGL))
264 #define RGFW_EGL
265 #define RGFW_OPENGL
266 #include <wayland-egl.h>
267 #endif
268
269 #include <wayland-client.h>
270#elif (defined(__unix__) || defined(RGFW_MACOS_X11) || defined(RGFW_X11)) && !defined(RGFW_WEBASM)
271 #define RGFW_MACOS_X11
272 #define RGFW_X11
273 #include <X11/Xlib.h>
274#elif defined(__APPLE__) && !defined(RGFW_MACOS_X11) && !defined(RGFW_X11) && !defined(RGFW_WEBASM)
275 #define RGFW_MACOS
276#endif
277
278#if (defined(RGFW_OPENGL_ES1) || defined(RGFW_OPENGL_ES2) || defined(RGFW_OPENGL_ES3)) && !defined(RGFW_EGL)
279 #define RGFW_EGL
280#endif
281
282#if !defined(RGFW_OSMESA) && !defined(RGFW_EGL) && !defined(RGFW_OPENGL) && !defined(RGFW_DIRECTX) && !defined(RGFW_BUFFER) && !defined(RGFW_NO_API)
283 #define RGFW_OPENGL
284#endif
285
286#ifdef RGFW_EGL
287 #include <EGL/egl.h>
288#elif defined(RGFW_OSMESA)
289 #ifndef __APPLE__
290 #include <GL/osmesa.h>
291 #else
292 #include <OpenGL/osmesa.h>
293 #endif
294#endif
295
296#if defined(RGFW_OPENGL) && defined(RGFW_X11)
297 #ifndef GLX_MESA_swap_control
298 #define GLX_MESA_swap_control
299 #endif
300 #include <GL/glx.h> /* GLX defs, xlib.h, gl.h */
301#endif
302
303#ifndef RGFW_ALPHA
304 #define RGFW_ALPHA 128 /* alpha value for RGFW_TRANSPARENT_WINDOW (WINAPI ONLY, macOS + linux don't need this) */
305#endif
306
307/*! Optional arguments for making a windows */
308#define RGFW_TRANSPARENT_WINDOW (1L<<9) /*!< the window is transparent (only properly works on X11 and MacOS, although it's although for windows) */
309#define RGFW_NO_BORDER (1L<<3) /*!< the window doesn't have border */
310#define RGFW_NO_RESIZE (1L<<4) /*!< the window cannot be resized by the user */
311#define RGFW_ALLOW_DND (1L<<5) /*!< the window supports drag and drop*/
312#define RGFW_HIDE_MOUSE (1L<<6) /*! the window should hide the mouse or not (can be toggled later on) using `RGFW_window_mouseShow*/
313#define RGFW_FULLSCREEN (1L<<8) /* the window is fullscreen by default or not */
314#define RGFW_CENTER (1L<<10) /*! center the window on the screen */
315#define RGFW_OPENGL_SOFTWARE (1L<<11) /*! use OpenGL software rendering */
316#define RGFW_COCOA_MOVE_TO_RESOURCE_DIR (1L << 12) /* (cocoa only), move to resource folder */
317#define RGFW_SCALE_TO_MONITOR (1L << 13) /* scale the window to the screen */
318#define RGFW_NO_INIT_API (1L << 2) /* DO not init an API (mostly for bindings, you should use `#define RGFW_NO_API` in C */
319
320#define RGFW_NO_GPU_RENDER (1L<<14) /* don't render (using the GPU based API)*/
321#define RGFW_NO_CPU_RENDER (1L<<15) /* don't render (using the CPU based buffer rendering)*/
322#define RGFW_WINDOW_HIDE (1L << 16)/* the window is hidden */
323
324typedef RGFW_ENUM(u8, RGFW_event_types) {
325 /*! event codes */
326 RGFW_keyPressed = 1, /* a key has been pressed */
327 RGFW_keyReleased, /*!< a key has been released*/
328 /*! key event note
329 the code of the key pressed is stored in
330 RGFW_Event.keyCode
331 !!Keycodes defined at the bottom of the RGFW_HEADER part of this file!!
332
333 while a string version is stored in
334 RGFW_Event.KeyString
335
336 RGFW_Event.lockState holds the current lockState
337 this means if CapsLock, NumLock are active or not
338 */
339 RGFW_mouseButtonPressed, /*!< a mouse button has been pressed (left,middle,right)*/
340 RGFW_mouseButtonReleased, /*!< a mouse button has been released (left,middle,right)*/
341 RGFW_mousePosChanged, /*!< the position of the mouse has been changed*/
342 /*! mouse event note
343 the x and y of the mouse can be found in the vector, RGFW_Event.point
344
345 RGFW_Event.button holds which mouse button was pressed
346 */
347 RGFW_jsButtonPressed, /*!< a joystick button was pressed */
348 RGFW_jsButtonReleased, /*!< a joystick button was released */
349 RGFW_jsAxisMove, /*!< an axis of a joystick was moved*/
350 /*! joystick event note
351 RGFW_Event.joystick holds which joystick was altered, if any
352 RGFW_Event.button holds which joystick button was pressed
353
354 RGFW_Event.axis holds the data of all the axis
355 RGFW_Event.axisCount says how many axis there are
356 */
357 RGFW_windowMoved, /*!< the window was moved (by the user) */
358 RGFW_windowResized, /*!< the window was resized (by the user), [on webASM this means the browser was resized] */
359 RGFW_focusIn, /*!< window is in focus now */
360 RGFW_focusOut, /*!< window is out of focus now */
361 RGFW_mouseEnter, /* mouse entered the window */
362 RGFW_mouseLeave, /* mouse left the window */
363 RGFW_windowRefresh, /* The window content needs to be refreshed */
364
365 /* attribs change event note
366 The event data is sent straight to the window structure
367 with win->r.x, win->r.y, win->r.w and win->r.h
368 */
369 RGFW_quit, /*!< the user clicked the quit button*/
370 RGFW_dnd, /*!< a file has been dropped into the window*/
371 RGFW_dnd_init /*!< the start of a dnd event, when the place where the file drop is known */
372 /* dnd data note
373 The x and y coords of the drop are stored in the vector RGFW_Event.point
374
375 RGFW_Event.droppedFilesCount holds how many files were dropped
376
377 This is also the size of the array which stores all the dropped file string,
378 RGFW_Event.droppedFiles
379 */
380};
381
382/*! mouse button codes (RGFW_Event.button) */
383#define RGFW_mouseLeft 1 /*!< left mouse button is pressed*/
384#define RGFW_mouseMiddle 2 /*!< mouse-wheel-button is pressed*/
385#define RGFW_mouseRight 3 /*!< right mouse button is pressed*/
386#define RGFW_mouseScrollUp 4 /*!< mouse wheel is scrolling up*/
387#define RGFW_mouseScrollDown 5 /*!< mouse wheel is scrolling down*/
388
389#ifndef RGFW_MAX_PATH
390#define RGFW_MAX_PATH 260 /* max length of a path (for dnd) */
391#endif
392#ifndef RGFW_MAX_DROPS
393#define RGFW_MAX_DROPS 260 /* max items you can drop at once */
394#endif
395
396
397/* for RGFW_Event.lockstate */
398#define RGFW_CAPSLOCK (1L << 1)
399#define RGFW_NUMLOCK (1L << 2)
400
401/*! joystick button codes (based on xbox/playstation), you may need to change these values per controller */
402#ifndef RGFW_joystick_codes
403 typedef RGFW_ENUM(u8, RGFW_joystick_codes) {
404 RGFW_JS_A = 0, /*!< or PS X button */
405 RGFW_JS_B = 1, /*!< or PS circle button */
406 RGFW_JS_Y = 2, /*!< or PS triangle button */
407 RGFW_JS_X = 3, /*!< or PS square button */
408 RGFW_JS_START = 9, /*!< start button */
409 RGFW_JS_SELECT = 8, /*!< select button */
410 RGFW_JS_HOME = 10, /*!< home button */
411 RGFW_JS_UP = 13, /*!< dpad up */
412 RGFW_JS_DOWN = 14, /*!< dpad down*/
413 RGFW_JS_LEFT = 15, /*!< dpad left */
414 RGFW_JS_RIGHT = 16, /*!< dpad right */
415 RGFW_JS_L1 = 4, /*!< left bump */
416 RGFW_JS_L2 = 5, /*!< left trigger*/
417 RGFW_JS_R1 = 6, /*!< right bumper */
418 RGFW_JS_R2 = 7, /*!< right trigger */
419 };
420#endif
421
422/*! basic vector type, if there's not already a point/vector type of choice */
423#ifndef RGFW_point
424 typedef struct { i32 x, y; } RGFW_point;
425#endif
426
427/*! basic rect type, if there's not already a rect type of choice */
428#ifndef RGFW_rect
429 typedef struct { i32 x, y, w, h; } RGFW_rect;
430#endif
431
432/*! basic area type, if there's not already a area type of choice */
433#ifndef RGFW_area
434 typedef struct { u32 w, h; } RGFW_area;
435#endif
436
437#ifndef __cplusplus
438#define RGFW_POINT(x, y) (RGFW_point){(i32)(x), (i32)(y)}
439#define RGFW_RECT(x, y, w, h) (RGFW_rect){(i32)(x), (i32)(y), (i32)(w), (i32)(h)}
440#define RGFW_AREA(w, h) (RGFW_area){(u32)(w), (u32)(h)}
441#else
442#define RGFW_POINT(x, y) {(i32)(x), (i32)(y)}
443#define RGFW_RECT(x, y, w, h) {(i32)(x), (i32)(y), (i32)(w), (i32)(h)}
444#define RGFW_AREA(w, h) {(u32)(w), (u32)(h)}
445#endif
446
447#ifndef RGFW_NO_MONITOR
448 /*! structure for monitor data */
449 typedef struct RGFW_monitor {
450 char name[128]; /*!< monitor name */
451 RGFW_rect rect; /*!< monitor Workarea */
452 float scaleX, scaleY; /*!< monitor content scale*/
453 float physW, physH; /*!< monitor physical size */
454 } RGFW_monitor;
455
456 /*
457 NOTE : Monitor functions should be ran only as many times as needed (not in a loop)
458 */
459
460 /*! get an array of all the monitors (max 6) */
461 RGFWDEF RGFW_monitor* RGFW_getMonitors(void);
462 /*! get the primary monitor */
463 RGFWDEF RGFW_monitor RGFW_getPrimaryMonitor(void);
464#endif
465
466/* NOTE: some parts of the data can represent different things based on the event (read comments in RGFW_Event struct) */
467/*! Event structure for checking/getting events */
468typedef struct RGFW_Event {
469 char keyName[16]; /*!< key name of event*/
470
471 /*! drag and drop data */
472 /* 260 max paths with a max length of 260 */
473#ifdef RGFW_ALLOC_DROPFILES
474 char** droppedFiles;
475#else
476 char droppedFiles[RGFW_MAX_DROPS][RGFW_MAX_PATH]; /*!< dropped files*/
477#endif
478 u32 droppedFilesCount; /*!< house many files were dropped */
479
480 u32 type; /*!< which event has been sent?*/
481 RGFW_point point; /*!< mouse x, y of event (or drop point) */
482
483 u8 keyCode; /*!< keycode of event !!Keycodes defined at the bottom of the RGFW_HEADER part of this file!! */
484
485 b8 repeat; /*!< key press event repeated (the key is being held) */
486 b8 inFocus; /*!< if the window is in focus or not (this is always true for MacOS windows due to the api being weird) */
487
488 u8 lockState;
489
490 u8 button; /* !< which mouse button was pressed */
491 double scroll; /*!< the raw mouse scroll value */
492
493 u16 joystick; /*! which joystick this event applies to (if applicable to any) */
494 u8 axisesCount; /*!< number of axises */
495 RGFW_point axis[2]; /*!< x, y of axises (-100 to 100) */
496
497 u64 frameTime, frameTime2; /*!< this is used for counting the fps */
498} RGFW_Event;
499
500/*! source data for the window (used by the APIs) */
501typedef struct RGFW_window_src {
502#ifdef RGFW_WINDOWS
503 HWND window; /*!< source window */
504 HDC hdc; /*!< source HDC */
505 u32 hOffset; /*!< height offset for window */
506 #if (defined(RGFW_OPENGL)) && !defined(RGFW_OSMESA) && !defined(RGFW_EGL)
507 HGLRC ctx; /*!< source graphics context */
508 #elif defined(RGFW_OSMESA)
509 OSMesaContext ctx;
510 #elif defined(RGFW_DIRECTX)
511 IDXGISwapChain* swapchain;
512 ID3D11RenderTargetView* renderTargetView;
513 ID3D11DepthStencilView* pDepthStencilView;
514 #elif defined(RGFW_EGL)
515 EGLSurface EGL_surface;
516 EGLDisplay EGL_display;
517 EGLContext EGL_context;
518 #endif
519
520 #if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
521 HDC hdcMem;
522 HBITMAP bitmap;
523 #endif
524 RGFW_area maxSize, minSize; /*!< for setting max/min resize (RGFW_WINDOWS) */
525#elif defined(RGFW_X11)
526 Display* display; /*!< source display */
527 Window window; /*!< source window */
528 #if (defined(RGFW_OPENGL)) && !defined(RGFW_OSMESA) && !defined(RGFW_EGL)
529 GLXContext ctx; /*!< source graphics context */
530 #elif defined(RGFW_OSMESA)
531 OSMesaContext ctx;
532 #elif defined(RGFW_EGL)
533 EGLSurface EGL_surface;
534 EGLDisplay EGL_display;
535 EGLContext EGL_context;
536 #endif
537
538#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
539 XImage* bitmap;
540 GC gc;
541#endif
542#elif defined(RGFW_WAYLAND)
543 struct wl_display* display;
544 struct wl_surface* surface;
545 struct wl_buffer* wl_buffer;
546 struct wl_keyboard* keyboard;
547
548 struct xdg_surface* xdg_surface;
549 struct xdg_toplevel* xdg_toplevel;
550 struct zxdg_toplevel_decoration_v1* decoration;
551 RGFW_Event events[20];
552 i32 eventLen;
553 size_t eventIndex;
554 #if defined(RGFW_EGL)
555 struct wl_egl_window* window;
556 EGLSurface EGL_surface;
557 EGLDisplay EGL_display;
558 EGLContext EGL_context;
559 #elif defined(RGFW_OSMESA)
560 OSMesaContext ctx;
561 #endif
562#elif defined(RGFW_MACOS)
563 u32 display;
564 void* displayLink;
565 void* window;
566 b8 dndPassed;
567#if (defined(RGFW_OPENGL)) && !defined(RGFW_OSMESA) && !defined(RGFW_EGL)
568 void* ctx; /*!< source graphics context */
569#elif defined(RGFW_OSMESA)
570 OSMesaContext ctx;
571#elif defined(RGFW_EGL)
572 EGLSurface EGL_surface;
573 EGLDisplay EGL_display;
574 EGLContext EGL_context;
575#endif
576
577 void* view; /*apple viewpoint thingy*/
578
579#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
580 void* bitmap; /*!< API's bitmap for storing or managing */
581 void* image;
582#endif
583#elif defined(RGFW_WEBASM)
584 #ifdef RGFW_WEBGPU
585 WGPUInstance ctx;
586 WGPUDevice device;
587 WGPUQueue queue;
588 #else
589 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx;
590 #endif
591#endif
592} RGFW_window_src;
593
594
595
596typedef struct RGFW_window {
597 RGFW_window_src src; /*!< src window data */
598
599#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
600 u8* buffer; /*!< buffer for non-GPU systems (OSMesa, basic software rendering) */
601 /* when rendering using RGFW_BUFFER, the buffer is in the RGBA format */
602#endif
603 void* userPtr; /* ptr for usr data */
604
605 RGFW_Event event; /*!< current event */
606
607 RGFW_rect r; /*!< the x, y, w and h of the struct */
608
609 RGFW_point _lastMousePoint; /*!< last cusor point (for raw mouse data) */
610
611 u32 _winArgs; /*!< windows args (for RGFW to check) */
612} RGFW_window; /*!< Window structure for managing the window */
613
614#if defined(RGFW_X11) || defined(RGFW_MACOS)
615 typedef u64 RGFW_thread; /*!< thread type unix */
616#else
617 typedef void* RGFW_thread; /*!< thread type for window */
618#endif
619
620/** * @defgroup Window_management
621* @{ */
622
623
624/*!
625 * the class name for X11 and WinAPI. apps with the same class will be grouped by the WM
626 * by default the class name will == the root window's name
627*/
628RGFWDEF void RGFW_setClassName(char* name);
629
630/*! this has to be set before createWindow is called, else the fulscreen size is used */
631RGFWDEF void RGFW_setBufferSize(RGFW_area size); /*!< the buffer cannot be resized (by RGFW) */
632
633RGFWDEF RGFW_window* RGFW_createWindow(
634 const char* name, /* name of the window */
635 RGFW_rect rect, /* rect of window */
636 u16 args /* extra arguments (NULL / (u16)0 means no args used)*/
637); /*!< function to create a window struct */
638
639/*! get the size of the screen to an area struct */
640RGFWDEF RGFW_area RGFW_getScreenSize(void);
641
642/*!
643 this function checks an *individual* event (and updates window structure attributes)
644 this means, using this function without a while loop may cause event lag
645
646 ex.
647
648 while (RGFW_window_checkEvent(win) != NULL) [this keeps checking events until it reaches the last one]
649
650 this function is optional if you choose to use event callbacks,
651 although you still need some way to tell RGFW to process events eg. `RGFW_window_checkEvents`
652*/
653
654RGFWDEF RGFW_Event* RGFW_window_checkEvent(RGFW_window* win); /*!< check current event (returns a pointer to win->event or NULL if there is no event)*/
655
656/*!
657 for RGFW_window_eventWait and RGFW_window_checkEvents
658 waitMS -> Allows th e function to keep checking for events even after `RGFW_window_checkEvent == NULL`
659 if waitMS == 0, the loop will not wait for events
660 if waitMS == a positive integer, the loop will wait that many miliseconds after there are no more events until it returns
661 if waitMS == a negative integer, the loop will not return until it gets another event
662*/
663typedef RGFW_ENUM(i32, RGFW_eventWait) {
664 RGFW_NEXT = -1,
665 RGFW_NO_WAIT = 0
666};
667
668/*! sleep until RGFW gets an event or the timer ends (defined by OS) */
669RGFWDEF void RGFW_window_eventWait(RGFW_window* win, i32 waitMS);
670
671/*!
672 check all the events until there are none left,
673 this should only be used if you're using callbacks only
674*/
675RGFWDEF void RGFW_window_checkEvents(RGFW_window* win, i32 waitMS);
676
677/*!
678 Tell RGFW_window_eventWait to stop waiting, to be ran from another thread
679*/
680RGFWDEF void RGFW_stopCheckEvents(void);
681
682/*! window managment functions*/
683RGFWDEF void RGFW_window_close(RGFW_window* win); /*!< close the window and free leftover data */
684
685/*! moves window to a given point */
686RGFWDEF void RGFW_window_move(RGFW_window* win,
687 RGFW_point v/*!< new pos*/
688);
689
690#ifndef RGFW_NO_MONITOR
691 /*! move to a specific monitor */
692 RGFWDEF void RGFW_window_moveToMonitor(RGFW_window* win, RGFW_monitor m /* monitor */);
693#endif
694
695/*! resize window to a current size/area */
696RGFWDEF void RGFW_window_resize(RGFW_window* win, /*!< source window */
697 RGFW_area a/*!< new size*/
698);
699
700/*! set the minimum size a user can shrink a window to a given size/area */
701RGFWDEF void RGFW_window_setMinSize(RGFW_window* win, RGFW_area a);
702/*! set the minimum size a user can extend a window to a given size/area */
703RGFWDEF void RGFW_window_setMaxSize(RGFW_window* win, RGFW_area a);
704
705RGFWDEF void RGFW_window_maximize(RGFW_window* win); /*!< maximize the window size */
706RGFWDEF void RGFW_window_minimize(RGFW_window* win); /*!< minimize the window (in taskbar (per OS))*/
707RGFWDEF void RGFW_window_restore(RGFW_window* win); /*!< restore the window from minimized (per OS)*/
708
709/*! if the window should have a border or not (borderless) based on bool value of `border` */
710RGFWDEF void RGFW_window_setBorder(RGFW_window* win, b8 border);
711
712/*! turn on / off dnd (RGFW_ALLOW_DND stil must be passed to the window)*/
713RGFWDEF void RGFW_window_setDND(RGFW_window* win, b8 allow);
714
715#ifndef RGFW_NO_PASSTHROUGH
716 /*!! turn on / off mouse passthrough */
717 RGFWDEF void RGFW_window_setMousePassthrough(RGFW_window* win, b8 passthrough);
718#endif
719
720/*! rename window to a given string */
721RGFWDEF void RGFW_window_setName(RGFW_window* win,
722 char* name
723);
724
725RGFWDEF void RGFW_window_setIcon(RGFW_window* win, /*!< source window */
726 u8* icon /*!< icon bitmap */,
727 RGFW_area a /*!< width and height of the bitmap*/,
728 i32 channels /*!< how many channels the bitmap has (rgb : 3, rgba : 4) */
729); /*!< image resized by default */
730
731/*!< sets mouse to bitmap (very simular to RGFW_window_setIcon), image NOT resized by default*/
732RGFWDEF void RGFW_window_setMouse(RGFW_window* win, u8* image, RGFW_area a, i32 channels);
733
734/*!< sets the mouse to a standard API cursor (based on RGFW_MOUSE, as seen at the end of the RGFW_HEADER part of this file) */
735RGFWDEF void RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse);
736
737RGFWDEF void RGFW_window_setMouseDefault(RGFW_window* win); /*!< sets the mouse to the default mouse icon */
738/*
739 Locks cursor at the center of the window
740 win->event.point become raw mouse movement data
741
742 this is useful for a 3D camera
743*/
744RGFWDEF void RGFW_window_mouseHold(RGFW_window* win, RGFW_area area);
745/*! stop holding the mouse and let it move freely */
746RGFWDEF void RGFW_window_mouseUnhold(RGFW_window* win);
747
748/*! hide the window */
749RGFWDEF void RGFW_window_hide(RGFW_window* win);
750/*! show the window */
751RGFWDEF void RGFW_window_show(RGFW_window* win);
752
753/*
754 makes it so `RGFW_window_shouldClose` returns true
755 by setting the window event.type to RGFW_quit
756*/
757RGFWDEF void RGFW_window_setShouldClose(RGFW_window* win);
758
759/*! where the mouse is on the screen */
760RGFWDEF RGFW_point RGFW_getGlobalMousePoint(void);
761
762/*! where the mouse is on the window */
763RGFWDEF RGFW_point RGFW_window_getMousePoint(RGFW_window* win);
764
765/*! show the mouse or hide the mouse*/
766RGFWDEF void RGFW_window_showMouse(RGFW_window* win, i8 show);
767/*! move the mouse to a set x, y pos*/
768RGFWDEF void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v);
769
770/*! if the window should close (RGFW_close was sent or escape was pressed) */
771RGFWDEF b8 RGFW_window_shouldClose(RGFW_window* win);
772/*! if window is fullscreen'd */
773RGFWDEF b8 RGFW_window_isFullscreen(RGFW_window* win);
774/*! if window is hidden */
775RGFWDEF b8 RGFW_window_isHidden(RGFW_window* win);
776/*! if window is minimized */
777RGFWDEF b8 RGFW_window_isMinimized(RGFW_window* win);
778/*! if window is maximized */
779RGFWDEF b8 RGFW_window_isMaximized(RGFW_window* win);
780
781/** @} */
782
783/** * @defgroup Monitor
784* @{ */
785
786#ifndef RGFW_NO_MONITOR
787/*
788scale the window to the monitor,
789this is run by default if the user uses the arg `RGFW_SCALE_TO_MONITOR` during window creation
790*/
791RGFWDEF void RGFW_window_scaleToMonitor(RGFW_window* win);
792/*! get the struct of the window's monitor */
793RGFWDEF RGFW_monitor RGFW_window_getMonitor(RGFW_window* win);
794#endif
795
796/** @} */
797
798/** * @defgroup Input
799* @{ */
800
801/*error handling*/
802RGFWDEF b8 RGFW_Error(void); /*!< returns true if an error has occurred (doesn't print errors itself) */
803
804/*! returns true if the key should be shifted */
805RGFWDEF b8 RGFW_shouldShift(u32 keycode, u8 lockState);
806
807/*! get char from RGFW keycode (using a LUT), uses shift'd version if shift = true */
808RGFWDEF char RGFW_keyCodeToChar(u32 keycode, b8 shift);
809/*! get char from RGFW keycode (using a LUT), uses lockState for shouldShift) */
810RGFWDEF char RGFW_keyCodeToCharAuto(u32 keycode, u8 lockState);
811
812/*! if window == NULL, it checks if the key is pressed globally. Otherwise, it checks only if the key is pressed while the window in focus.*/
813RGFWDEF b8 RGFW_isPressed(RGFW_window* win, u8 key); /*!< if key is pressed (key code)*/
814
815RGFWDEF b8 RGFW_wasPressed(RGFW_window* win, u8 key); /*!< if key was pressed (checks previous state only) (key code)*/
816
817RGFWDEF b8 RGFW_isHeld(RGFW_window* win, u8 key); /*!< if key is held (key code)*/
818RGFWDEF b8 RGFW_isReleased(RGFW_window* win, u8 key); /*!< if key is released (key code)*/
819
820/* if a key is pressed and then released, pretty much the same as RGFW_isReleased */
821RGFWDEF b8 RGFW_isClicked(RGFW_window* win, u8 key /*!< key code*/);
822
823/*! if a mouse button is pressed */
824RGFWDEF b8 RGFW_isMousePressed(RGFW_window* win, u8 button /*!< mouse button code */ );
825/*! if a mouse button is held */
826RGFWDEF b8 RGFW_isMouseHeld(RGFW_window* win, u8 button /*!< mouse button code */ );
827/*! if a mouse button was released */
828RGFWDEF b8 RGFW_isMouseReleased(RGFW_window* win, u8 button /*!< mouse button code */ );
829/*! if a mouse button was pressed (checks previous state only) */
830RGFWDEF b8 RGFW_wasMousePressed(RGFW_window* win, u8 button /*!< mouse button code */ );
831/** @} */
832
833/** * @defgroup Clipboard
834* @{ */
835RGFWDEF char* RGFW_readClipboard(size_t* size); /*!< read clipboard data */
836RGFWDEF void RGFW_clipboardFree(char* str); /*!< the string returned from RGFW_readClipboard must be freed */
837
838RGFWDEF void RGFW_writeClipboard(const char* text, u32 textLen); /*!< write text to the clipboard */
839/** @} */
840
841/**
842
843
844 Event callbacks,
845 these are completely optional, you can use the normal
846 RGFW_checkEvent() method if you prefer that
847
848* @defgroup Callbacks
849* @{
850*/
851
852/*! RGFW_windowMoved, the window and its new rect value */
853typedef void (* RGFW_windowmovefunc)(RGFW_window* win, RGFW_rect r);
854/*! RGFW_windowResized, the window and its new rect value */
855typedef void (* RGFW_windowresizefunc)(RGFW_window* win, RGFW_rect r);
856/*! RGFW_quit, the window that was closed */
857typedef void (* RGFW_windowquitfunc)(RGFW_window* win);
858/*! RGFW_focusIn / RGFW_focusOut, the window who's focus has changed and if its inFocus */
859typedef void (* RGFW_focusfunc)(RGFW_window* win, b8 inFocus);
860/*! RGFW_mouseEnter / RGFW_mouseLeave, the window that changed, the point of the mouse (enter only) and if the mouse has entered */
861typedef void (* RGFW_mouseNotifyfunc)(RGFW_window* win, RGFW_point point, b8 status);
862/*! RGFW_mousePosChanged, the window that the move happened on and the new point of the mouse */
863typedef void (* RGFW_mouseposfunc)(RGFW_window* win, RGFW_point point);
864/*! RGFW_dnd_init, the window, the point of the drop on the windows */
865typedef void (* RGFW_dndInitfunc)(RGFW_window* win, RGFW_point point);
866/*! RGFW_windowRefresh, the window that needs to be refreshed */
867typedef void (* RGFW_windowrefreshfunc)(RGFW_window* win);
868/*! RGFW_keyPressed / RGFW_keyReleased, the window that got the event, the keycode, the string version, the state of mod keys, if it was a press (else it's a release) */
869typedef void (* RGFW_keyfunc)(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed);
870/*! RGFW_mouseButtonPressed / RGFW_mouseButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */
871typedef void (* RGFW_mousebuttonfunc)(RGFW_window* win, u8 button, double scroll, b8 pressed);
872/*! RGFW_jsButtonPressed / RGFW_jsButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */
873typedef void (* RGFW_jsButtonfunc)(RGFW_window* win, u16 joystick, u8 button, b8 pressed);
874/*! RGFW_jsAxisMove, the window that got the event, the joystick in question, the axis values and the amount of axises */
875typedef void (* RGFW_jsAxisfunc)(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount);
876
877
878/*! RGFW_dnd, the window that had the drop, the drop data and the amount files dropped returns previous callback function (if it was set) */
879#ifdef RGFW_ALLOC_DROPFILES
880 typedef void (* RGFW_dndfunc)(RGFW_window* win, char** droppedFiles, u32 droppedFilesCount);
881#else
882 typedef void (* RGFW_dndfunc)(RGFW_window* win, char droppedFiles[RGFW_MAX_DROPS][RGFW_MAX_PATH], u32 droppedFilesCount);
883#endif
884/*! set callback for a window move event returns previous callback function (if it was set) */
885RGFWDEF RGFW_windowmovefunc RGFW_setWindowMoveCallback(RGFW_windowmovefunc func);
886/*! set callback for a window resize event returns previous callback function (if it was set) */
887RGFWDEF RGFW_windowresizefunc RGFW_setWindowResizeCallback(RGFW_windowresizefunc func);
888/*! set callback for a window quit event returns previous callback function (if it was set) */
889RGFWDEF RGFW_windowquitfunc RGFW_setWindowQuitCallback(RGFW_windowquitfunc func);
890/*! set callback for a mouse move event returns previous callback function (if it was set) */
891RGFWDEF RGFW_mouseposfunc RGFW_setMousePosCallback(RGFW_mouseposfunc func);
892/*! set callback for a window refresh event returns previous callback function (if it was set) */
893RGFWDEF RGFW_windowrefreshfunc RGFW_setWindowRefreshCallback(RGFW_windowrefreshfunc func);
894/*! set callback for a window focus change event returns previous callback function (if it was set) */
895RGFWDEF RGFW_focusfunc RGFW_setFocusCallback(RGFW_focusfunc func);
896/*! set callback for a mouse notify event returns previous callback function (if it was set) */
897RGFWDEF RGFW_mouseNotifyfunc RGFW_setMouseNotifyCallBack(RGFW_mouseNotifyfunc func);
898/*! set callback for a drop event event returns previous callback function (if it was set) */
899RGFWDEF RGFW_dndfunc RGFW_setDndCallback(RGFW_dndfunc func);
900/*! set callback for a start of a drop event returns previous callback function (if it was set) */
901RGFWDEF RGFW_dndInitfunc RGFW_setDndInitCallback(RGFW_dndInitfunc func);
902/*! set callback for a key (press / release ) event returns previous callback function (if it was set) */
903RGFWDEF RGFW_keyfunc RGFW_setKeyCallback(RGFW_keyfunc func);
904/*! set callback for a mouse button (press / release ) event returns previous callback function (if it was set) */
905RGFWDEF RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func);
906/*! set callback for a controller button (press / release ) event returns previous callback function (if it was set) */
907RGFWDEF RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func);
908/*! set callback for a joystick axis mov event returns previous callback function (if it was set) */
909RGFWDEF RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func);
910
911/** @} */
912
913/** * @defgroup Threads
914* @{ */
915
916#ifndef RGFW_NO_THREADS
917 /*! threading functions*/
918
919 /*! NOTE! (for X11/linux) : if you define a window in a thread, it must be run after the original thread's window is created or else there will be a memory error */
920 /*
921 I'd suggest you use sili's threading functions instead
922 if you're going to use sili
923 which is a good idea generally
924 */
925
926 #if defined(__unix__) || defined(__APPLE__) || defined(RGFW_WEBASM)
927 typedef void* (* RGFW_threadFunc_ptr)(void*);
928 #else
929 typedef DWORD (__stdcall *RGFW_threadFunc_ptr) (LPVOID lpThreadParameter);
930 #endif
931
932 RGFWDEF RGFW_thread RGFW_createThread(RGFW_threadFunc_ptr ptr, void* args); /*!< create a thread*/
933 RGFWDEF void RGFW_cancelThread(RGFW_thread thread); /*!< cancels a thread*/
934 RGFWDEF void RGFW_joinThread(RGFW_thread thread); /*!< join thread to current thread */
935 RGFWDEF void RGFW_setThreadPriority(RGFW_thread thread, u8 priority); /*!< sets the priority priority */
936#endif
937
938/** @} */
939
940/** * @defgroup joystick
941* @{ */
942
943/*! joystick count starts at 0*/
944/*!< register joystick to window based on a number (the number is based on when it was connected eg. /dev/js0)*/
945RGFWDEF u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber);
946RGFWDEF u16 RGFW_registerJoystickF(RGFW_window* win, char* file);
947
948RGFWDEF u32 RGFW_isPressedJS(RGFW_window* win, u16 controller, u8 button);
949
950/** @} */
951
952/** * @defgroup graphics_API
953* @{ */
954
955/*!< make the window the current opengl drawing context
956
957 NOTE:
958 if you want to switch the graphics context's thread,
959 you have to run RGFW_window_makeCurrent(NULL); on the old thread
960 then RGFW_window_makeCurrent(valid_window) on the new thread
961*/
962RGFWDEF void RGFW_window_makeCurrent(RGFW_window* win);
963
964/*< updates fps / sets fps to cap (must by ran manually by the user at the end of a frame), returns current fps */
965RGFWDEF u32 RGFW_window_checkFPS(RGFW_window* win, u32 fpsCap);
966
967/* supports openGL, directX, OSMesa, EGL and software rendering */
968RGFWDEF void RGFW_window_swapBuffers(RGFW_window* win); /*!< swap the rendering buffer */
969RGFWDEF void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval);
970
971RGFWDEF void RGFW_window_setGPURender(RGFW_window* win, i8 set);
972RGFWDEF void RGFW_window_setCPURender(RGFW_window* win, i8 set);
973
974/*! native API functions */
975#if defined(RGFW_OPENGL) || defined(RGFW_EGL)
976 /*! OpenGL init hints */
977 RGFWDEF void RGFW_setGLStencil(i32 stencil); /*!< set stencil buffer bit size (8 by default) */
978 RGFWDEF void RGFW_setGLSamples(i32 samples); /*!< set number of sampiling buffers (4 by default) */
979 RGFWDEF void RGFW_setGLStereo(i32 stereo); /*!< use GL_STEREO (GL_FALSE by default) */
980 RGFWDEF void RGFW_setGLAuxBuffers(i32 auxBuffers); /*!< number of aux buffers (0 by default) */
981
982 /*! which profile to use for the opengl verion */
983 typedef RGFW_ENUM(u8, RGFW_GL_profile) { RGFW_GL_CORE = 0, RGFW_GL_COMPATIBILITY };
984 /*! Set OpenGL version hint (core or compatibility profile)*/
985 RGFWDEF void RGFW_setGLVersion(RGFW_GL_profile profile, i32 major, i32 minor);
986 RGFWDEF void RGFW_setDoubleBuffer(b8 useDoubleBuffer);
987 RGFWDEF void* RGFW_getProcAddress(const char* procname); /*!< get native opengl proc address */
988 RGFWDEF void RGFW_window_makeCurrent_OpenGL(RGFW_window* win); /*!< to be called by RGFW_window_makeCurrent */
989#elif defined(RGFW_DIRECTX)
990 typedef struct {
991 IDXGIFactory* pFactory;
992 IDXGIAdapter* pAdapter;
993 ID3D11Device* pDevice;
994 ID3D11DeviceContext* pDeviceContext;
995 } RGFW_directXinfo;
996
997 /*
998 RGFW stores a global instance of RGFW_directXinfo,
999 you can use this function to get a pointer the instance
1000 */
1001 RGFWDEF RGFW_directXinfo* RGFW_getDirectXInfo(void);
1002#endif
1003
1004/** @} */
1005
1006/** * @defgroup Supporting
1007* @{ */
1008RGFWDEF u64 RGFW_getTime(void); /*!< get time in seconds */
1009RGFWDEF u64 RGFW_getTimeNS(void); /*!< get time in nanoseconds */
1010RGFWDEF void RGFW_sleep(u64 milisecond); /*!< sleep for a set time */
1011
1012/*!
1013 key codes and mouse icon enums
1014*/
1015
1016typedef RGFW_ENUM(u8, RGFW_Key) {
1017 RGFW_KEY_NULL = 0,
1018 RGFW_Escape,
1019 RGFW_F1,
1020 RGFW_F2,
1021 RGFW_F3,
1022 RGFW_F4,
1023 RGFW_F5,
1024 RGFW_F6,
1025 RGFW_F7,
1026 RGFW_F8,
1027 RGFW_F9,
1028 RGFW_F10,
1029 RGFW_F11,
1030 RGFW_F12,
1031
1032 RGFW_Backtick,
1033
1034 RGFW_0,
1035 RGFW_1,
1036 RGFW_2,
1037 RGFW_3,
1038 RGFW_4,
1039 RGFW_5,
1040 RGFW_6,
1041 RGFW_7,
1042 RGFW_8,
1043 RGFW_9,
1044
1045 RGFW_Minus,
1046 RGFW_Equals,
1047 RGFW_BackSpace,
1048 RGFW_Tab,
1049 RGFW_CapsLock,
1050 RGFW_ShiftL,
1051 RGFW_ControlL,
1052 RGFW_AltL,
1053 RGFW_SuperL,
1054 RGFW_ShiftR,
1055 RGFW_ControlR,
1056 RGFW_AltR,
1057 RGFW_SuperR,
1058 RGFW_Space,
1059
1060 RGFW_a,
1061 RGFW_b,
1062 RGFW_c,
1063 RGFW_d,
1064 RGFW_e,
1065 RGFW_f,
1066 RGFW_g,
1067 RGFW_h,
1068 RGFW_i,
1069 RGFW_j,
1070 RGFW_k,
1071 RGFW_l,
1072 RGFW_m,
1073 RGFW_n,
1074 RGFW_o,
1075 RGFW_p,
1076 RGFW_q,
1077 RGFW_r,
1078 RGFW_s,
1079 RGFW_t,
1080 RGFW_u,
1081 RGFW_v,
1082 RGFW_w,
1083 RGFW_x,
1084 RGFW_y,
1085 RGFW_z,
1086
1087 RGFW_Period,
1088 RGFW_Comma,
1089 RGFW_Slash,
1090 RGFW_Bracket,
1091 RGFW_CloseBracket,
1092 RGFW_Semicolon,
1093 RGFW_Return,
1094 RGFW_Quote,
1095 RGFW_BackSlash,
1096
1097 RGFW_Up,
1098 RGFW_Down,
1099 RGFW_Left,
1100 RGFW_Right,
1101
1102 RGFW_Delete,
1103 RGFW_Insert,
1104 RGFW_End,
1105 RGFW_Home,
1106 RGFW_PageUp,
1107 RGFW_PageDown,
1108
1109 RGFW_Numlock,
1110 RGFW_KP_Slash,
1111 RGFW_Multiply,
1112 RGFW_KP_Minus,
1113 RGFW_KP_1,
1114 RGFW_KP_2,
1115 RGFW_KP_3,
1116 RGFW_KP_4,
1117 RGFW_KP_5,
1118 RGFW_KP_6,
1119 RGFW_KP_7,
1120 RGFW_KP_8,
1121 RGFW_KP_9,
1122 RGFW_KP_0,
1123 RGFW_KP_Period,
1124 RGFW_KP_Return,
1125
1126 final_key,
1127};
1128
1129
1130typedef RGFW_ENUM(u8, RGFW_mouseIcons) {
1131 RGFW_MOUSE_NORMAL = 0,
1132 RGFW_MOUSE_ARROW,
1133 RGFW_MOUSE_IBEAM,
1134 RGFW_MOUSE_CROSSHAIR,
1135 RGFW_MOUSE_POINTING_HAND,
1136 RGFW_MOUSE_RESIZE_EW,
1137 RGFW_MOUSE_RESIZE_NS,
1138 RGFW_MOUSE_RESIZE_NWSE,
1139 RGFW_MOUSE_RESIZE_NESW,
1140 RGFW_MOUSE_RESIZE_ALL,
1141 RGFW_MOUSE_NOT_ALLOWED,
1142};
1143
1144/** @} */
1145
1146#endif /* RGFW_HEADER */
1147
1148/*
1149Example to get you started :
1150
1151linux : gcc main.c -lX11 -lXcursor -lGL
1152windows : gcc main.c -lopengl32 -lshell32 -lgdi32
1153macos : gcc main.c -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
1154
1155#define RGFW_IMPLEMENTATION
1156#include "RGFW.h"
1157
1158u8 icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF};
1159
1160int main() {
1161 RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(500, 500, 500, 500), (u64)0);
1162
1163 RGFW_window_setIcon(win, icon, RGFW_AREA(3, 3), 4);
1164
1165 for (;;) {
1166 RGFW_window_checkEvent(win); // NOTE: checking events outside of a while loop may cause input lag
1167 if (win->event.type == RGFW_quit || RGFW_isPressed(win, RGFW_Escape))
1168 break;
1169
1170 RGFW_window_swapBuffers(win);
1171
1172 glClearColor(0xFF, 0XFF, 0xFF, 0xFF);
1173 glClear(GL_COLOR_BUFFER_BIT);
1174 }
1175
1176 RGFW_window_close(win);
1177}
1178
1179 compiling :
1180
1181 if you wish to compile the library all you have to do is create a new file with this in it
1182
1183 rgfw.c
1184 #define RGFW_IMPLEMENTATION
1185 #include "RGFW.h"
1186
1187 then you can use gcc (or whatever compile you wish to use) to compile the library into object file
1188
1189 ex. gcc -c RGFW.c -fPIC
1190
1191 after you compile the library into an object file, you can also turn the object file into an static or shared library
1192
1193 (commands ar and gcc can be replaced with whatever equivalent your system uses)
1194 static : ar rcs RGFW.a RGFW.o
1195 shared :
1196 windows:
1197 gcc -shared RGFW.o -lwinmm -lopengl32 -lshell32 -lgdi32 -o RGFW.dll
1198 linux:
1199 gcc -shared RGFW.o -lX11 -lXcursor -lGL -lXrandr -o RGFW.so
1200 macos:
1201 gcc -shared RGFW.o -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
1202*/
1203
1204#ifdef RGFW_X11
1205 #define RGFW_OS_BASED_VALUE(l, w, m, h, ww) l
1206#elif defined(RGFW_WINDOWS)
1207 #define RGFW_OS_BASED_VALUE(l, w, m, h, ww) w
1208#elif defined(RGFW_MACOS)
1209 #define RGFW_OS_BASED_VALUE(l, w, m, h, ww) m
1210#elif defined(RGFW_WEBASM)
1211 #define RGFW_OS_BASED_VALUE(l, w, m, h, ww) h
1212#elif defined(RGFW_WAYLAND)
1213 #define RGFW_OS_BASED_VALUE(l, w, m, h, ww) ww
1214#endif
1215
1216
1217#ifdef RGFW_IMPLEMENTATION
1218
1219#include <stdio.h>
1220#include <string.h>
1221#include <math.h>
1222#include <assert.h>
1223
1224/*
1225RGFW_IMPLEMENTATION starts with generic RGFW defines
1226
1227This is the start of keycode data
1228
1229 Why not use macros instead of the numbers itself?
1230 Windows -> Not all virtual keys are macros (VK_0 - VK_1, VK_a - VK_z)
1231 Linux -> Only symcodes are values, (XK_0 - XK_1, XK_a - XK_z) are larger than 0xFF00, I can't find any way to work with them without making the array an unreasonable size
1232 MacOS -> windows and linux already don't have keycodes as macros, so there's no point
1233*/
1234
1235
1236
1237/*
1238 the c++ compiler doesn't support setting up an array like,
1239 we'll have to do it during runtime using a function & this messy setup
1240*/
1241#ifndef __cplusplus
1242#define RGFW_NEXT ,
1243#define RGFW_MAP
1244#else
1245#define RGFW_NEXT ;
1246#define RGFW_MAP RGFW_keycodes
1247#endif
1248
1249#ifdef RGFW_WAYLAND
1250#include <linux/input-event-codes.h>
1251#endif
1252
1253u8 RGFW_keycodes [RGFW_OS_BASED_VALUE(136, 337, 128, DOM_VK_WIN_OEM_CLEAR + 1, 130)] = {
1254#ifdef __cplusplus
1255 0
1256};
1257void RGFW_init_keys(void) {
1258#endif
1259 RGFW_MAP [RGFW_OS_BASED_VALUE(49, 192, 50, DOM_VK_BACK_QUOTE, KEY_GRAVE)] = RGFW_Backtick RGFW_NEXT
1260
1261 RGFW_MAP [RGFW_OS_BASED_VALUE(19, 0x30, 29, DOM_VK_0, KEY_0)] = RGFW_0 RGFW_NEXT
1262 RGFW_MAP [RGFW_OS_BASED_VALUE(10, 0x31, 18, DOM_VK_1, KEY_1)] = RGFW_1 RGFW_NEXT
1263 RGFW_MAP [RGFW_OS_BASED_VALUE(11, 0x32, 19, DOM_VK_2, KEY_2)] = RGFW_2 RGFW_NEXT
1264 RGFW_MAP [RGFW_OS_BASED_VALUE(12, 0x33, 20, DOM_VK_3, KEY_3)] = RGFW_3 RGFW_NEXT
1265 RGFW_MAP [RGFW_OS_BASED_VALUE(13, 0x34, 21, DOM_VK_4, KEY_4)] = RGFW_4 RGFW_NEXT
1266 RGFW_MAP [RGFW_OS_BASED_VALUE(14, 0x35, 23, DOM_VK_5, KEY_5)] = RGFW_5 RGFW_NEXT
1267 RGFW_MAP [RGFW_OS_BASED_VALUE(15, 0x36, 22, DOM_VK_6, KEY_6)] = RGFW_6 RGFW_NEXT
1268 RGFW_MAP [RGFW_OS_BASED_VALUE(16, 0x37, 26, DOM_VK_7, KEY_7)] = RGFW_7 RGFW_NEXT
1269 RGFW_MAP [RGFW_OS_BASED_VALUE(17, 0x38, 28, DOM_VK_8, KEY_8)] = RGFW_8 RGFW_NEXT
1270 RGFW_MAP [RGFW_OS_BASED_VALUE(18, 0x39, 25, DOM_VK_9, KEY_9)] = RGFW_9,
1271
1272 RGFW_MAP [RGFW_OS_BASED_VALUE(65, 0x20, 49, DOM_VK_SPACE, KEY_SPACE)] = RGFW_Space,
1273
1274 RGFW_MAP [RGFW_OS_BASED_VALUE(38, 0x41, 0, DOM_VK_A, KEY_A)] = RGFW_a RGFW_NEXT
1275 RGFW_MAP [RGFW_OS_BASED_VALUE(56, 0x42, 11, DOM_VK_B, KEY_B)] = RGFW_b RGFW_NEXT
1276 RGFW_MAP [RGFW_OS_BASED_VALUE(54, 0x43, 8, DOM_VK_C, KEY_C)] = RGFW_c RGFW_NEXT
1277 RGFW_MAP [RGFW_OS_BASED_VALUE(40, 0x44, 2, DOM_VK_D, KEY_D)] = RGFW_d RGFW_NEXT
1278 RGFW_MAP [RGFW_OS_BASED_VALUE(26, 0x45, 14, DOM_VK_E, KEY_E)] = RGFW_e RGFW_NEXT
1279 RGFW_MAP [RGFW_OS_BASED_VALUE(41, 0x46, 3, DOM_VK_F, KEY_F)] = RGFW_f RGFW_NEXT
1280 RGFW_MAP [RGFW_OS_BASED_VALUE(42, 0x47, 5, DOM_VK_G, KEY_G)] = RGFW_g RGFW_NEXT
1281 RGFW_MAP [RGFW_OS_BASED_VALUE(43, 0x48, 4, DOM_VK_H, KEY_H)] = RGFW_h RGFW_NEXT
1282 RGFW_MAP [RGFW_OS_BASED_VALUE(31, 0x49, 34, DOM_VK_I, KEY_I)] = RGFW_i RGFW_NEXT
1283 RGFW_MAP [RGFW_OS_BASED_VALUE(44, 0x4A, 38, DOM_VK_J, KEY_J)] = RGFW_j RGFW_NEXT
1284 RGFW_MAP [RGFW_OS_BASED_VALUE(45, 0x4B, 40, DOM_VK_K, KEY_K)] = RGFW_k RGFW_NEXT
1285 RGFW_MAP [RGFW_OS_BASED_VALUE(46, 0x4C, 37, DOM_VK_L, KEY_L)] = RGFW_l RGFW_NEXT
1286 RGFW_MAP [RGFW_OS_BASED_VALUE(58, 0x4D, 46, DOM_VK_M, KEY_M)] = RGFW_m RGFW_NEXT
1287 RGFW_MAP [RGFW_OS_BASED_VALUE(57, 0x4E, 45, DOM_VK_N, KEY_N)] = RGFW_n RGFW_NEXT
1288 RGFW_MAP [RGFW_OS_BASED_VALUE(32, 0x4F, 31, DOM_VK_O, KEY_O)] = RGFW_o RGFW_NEXT
1289 RGFW_MAP [RGFW_OS_BASED_VALUE(33, 0x50, 35, DOM_VK_P, KEY_P)] = RGFW_p RGFW_NEXT
1290 RGFW_MAP [RGFW_OS_BASED_VALUE(24, 0x51, 12, DOM_VK_Q, KEY_Q)] = RGFW_q RGFW_NEXT
1291 RGFW_MAP [RGFW_OS_BASED_VALUE(27, 0x52, 15, DOM_VK_R, KEY_R)] = RGFW_r RGFW_NEXT
1292 RGFW_MAP [RGFW_OS_BASED_VALUE(39, 0x53, 1, DOM_VK_S, KEY_S)] = RGFW_s RGFW_NEXT
1293 RGFW_MAP [RGFW_OS_BASED_VALUE(28, 0x54, 17, DOM_VK_T, KEY_T)] = RGFW_t RGFW_NEXT
1294 RGFW_MAP [RGFW_OS_BASED_VALUE(30, 0x55, 32, DOM_VK_U, KEY_U)] = RGFW_u RGFW_NEXT
1295 RGFW_MAP [RGFW_OS_BASED_VALUE(55, 0x56, 9, DOM_VK_V, KEY_V)] = RGFW_v RGFW_NEXT
1296 RGFW_MAP [RGFW_OS_BASED_VALUE(25, 0x57, 13, DOM_VK_W, KEY_W)] = RGFW_w RGFW_NEXT
1297 RGFW_MAP [RGFW_OS_BASED_VALUE(53, 0x58, 7, DOM_VK_X, KEY_X)] = RGFW_x RGFW_NEXT
1298 RGFW_MAP [RGFW_OS_BASED_VALUE(29, 0x59, 16, DOM_VK_Y, KEY_Y)] = RGFW_y RGFW_NEXT
1299 RGFW_MAP [RGFW_OS_BASED_VALUE(52, 0x5A, 6, DOM_VK_Z, KEY_Z)] = RGFW_z,
1300
1301 RGFW_MAP [RGFW_OS_BASED_VALUE(60, 190, 47, DOM_VK_PERIOD, KEY_DOT)] = RGFW_Period RGFW_NEXT
1302 RGFW_MAP [RGFW_OS_BASED_VALUE(59, 188, 43, DOM_VK_COMMA, KEY_COMMA)] = RGFW_Comma RGFW_NEXT
1303 RGFW_MAP [RGFW_OS_BASED_VALUE(61, 191, 44, DOM_VK_SLASH, KEY_SLASH)] = RGFW_Slash RGFW_NEXT
1304 RGFW_MAP [RGFW_OS_BASED_VALUE(34, 219, 33, DOM_VK_OPEN_BRACKET, KEY_LEFTBRACE)] = RGFW_Bracket RGFW_NEXT
1305 RGFW_MAP [RGFW_OS_BASED_VALUE(35, 221, 30, DOM_VK_CLOSE_BRACKET, KEY_RIGHTBRACE)] = RGFW_CloseBracket RGFW_NEXT
1306 RGFW_MAP [RGFW_OS_BASED_VALUE(47, 186, 41, DOM_VK_SEMICOLON, KEY_SEMICOLON)] = RGFW_Semicolon RGFW_NEXT
1307 RGFW_MAP [RGFW_OS_BASED_VALUE(48, 222, 39, DOM_VK_QUOTE, KEY_APOSTROPHE)] = RGFW_Quote RGFW_NEXT
1308 RGFW_MAP [RGFW_OS_BASED_VALUE(51, 322, 42, DOM_VK_BACK_SLASH, KEY_BACKSLASH)] = RGFW_BackSlash,
1309
1310 RGFW_MAP [RGFW_OS_BASED_VALUE(36, 0x0D, 36, DOM_VK_RETURN, KEY_ENTER)] = RGFW_Return RGFW_NEXT
1311 RGFW_MAP [RGFW_OS_BASED_VALUE(119, 0x2E, 118, DOM_VK_DELETE, KEY_DELETE)] = RGFW_Delete RGFW_NEXT
1312 RGFW_MAP [RGFW_OS_BASED_VALUE(77, 0x90, 72, DOM_VK_NUM_LOCK, KEY_NUMLOCK)] = RGFW_Numlock RGFW_NEXT
1313 RGFW_MAP [RGFW_OS_BASED_VALUE(106, 0x6F, 82, DOM_VK_DIVIDE, KEY_KPSLASH)] = RGFW_KP_Slash RGFW_NEXT
1314 RGFW_MAP [RGFW_OS_BASED_VALUE(63, 0x6A, 76, DOM_VK_MULTIPLY, KEY_KPASTERISK)] = RGFW_Multiply RGFW_NEXT
1315 RGFW_MAP [RGFW_OS_BASED_VALUE(82, 0x6D, 67, DOM_VK_SUBTRACT, KEY_KPMINUS)] = RGFW_KP_Minus RGFW_NEXT
1316 RGFW_MAP [RGFW_OS_BASED_VALUE(87, 0x61, 84, DOM_VK_NUMPAD1, KEY_KP1)] = RGFW_KP_1 RGFW_NEXT
1317 RGFW_MAP [RGFW_OS_BASED_VALUE(88, 0x62, 85, DOM_VK_NUMPAD2, KEY_KP2)] = RGFW_KP_2 RGFW_NEXT
1318 RGFW_MAP [RGFW_OS_BASED_VALUE(89, 0x63, 86, DOM_VK_NUMPAD3, KEY_KP3)] = RGFW_KP_3 RGFW_NEXT
1319 RGFW_MAP [RGFW_OS_BASED_VALUE(83, 0x64, 87, DOM_VK_NUMPAD4, KEY_KP4)] = RGFW_KP_4 RGFW_NEXT
1320 RGFW_MAP [RGFW_OS_BASED_VALUE(84, 0x65, 88, DOM_VK_NUMPAD5, KEY_KP5)] = RGFW_KP_5 RGFW_NEXT
1321 RGFW_MAP [RGFW_OS_BASED_VALUE(85, 0x66, 89, DOM_VK_NUMPAD6, KEY_KP6)] = RGFW_KP_6 RGFW_NEXT
1322 RGFW_MAP [RGFW_OS_BASED_VALUE(79, 0x67, 90, DOM_VK_NUMPAD7, KEY_KP7)] = RGFW_KP_7 RGFW_NEXT
1323 RGFW_MAP [RGFW_OS_BASED_VALUE(80, 0x68, 92, DOM_VK_NUMPAD8, KEY_KP8)] = RGFW_KP_8 RGFW_NEXT
1324 RGFW_MAP [RGFW_OS_BASED_VALUE(81, 0x69, 93, DOM_VK_NUMPAD9, KEY_KP9)] = RGFW_KP_9 RGFW_NEXT
1325 RGFW_MAP [RGFW_OS_BASED_VALUE(90, 0x60, 83, DOM_VK_NUMPAD0, KEY_KP0)] = RGFW_KP_0 RGFW_NEXT
1326 RGFW_MAP [RGFW_OS_BASED_VALUE(91, 0x6E, 65, DOM_VK_DECIMAL, KEY_KPDOT)] = RGFW_KP_Period RGFW_NEXT
1327 RGFW_MAP [RGFW_OS_BASED_VALUE(104, 0x92, 77, 0, KEY_KPENTER)] = RGFW_KP_Return,
1328
1329 RGFW_MAP [RGFW_OS_BASED_VALUE(20, 189, 27, DOM_VK_HYPHEN_MINUS, KEY_MINUS)] = RGFW_Minus RGFW_NEXT
1330 RGFW_MAP [RGFW_OS_BASED_VALUE(21, 187, 24, DOM_VK_EQUALS, KEY_EQUAL)] = RGFW_Equals RGFW_NEXT
1331 RGFW_MAP [RGFW_OS_BASED_VALUE(22, 8, 51, DOM_VK_BACK_SPACE, KEY_BACKSPACE)] = RGFW_BackSpace RGFW_NEXT
1332 RGFW_MAP [RGFW_OS_BASED_VALUE(23, 0x09, 48, DOM_VK_TAB, KEY_TAB)] = RGFW_Tab RGFW_NEXT
1333 RGFW_MAP [RGFW_OS_BASED_VALUE(66, 20, 57, DOM_VK_CAPS_LOCK, KEY_CAPSLOCK)] = RGFW_CapsLock RGFW_NEXT
1334 RGFW_MAP [RGFW_OS_BASED_VALUE(50, 0x10, 56, DOM_VK_SHIFT, KEY_LEFTSHIFT)] = RGFW_ShiftL RGFW_NEXT
1335 RGFW_MAP [RGFW_OS_BASED_VALUE(37, 0x11, 59, DOM_VK_CONTROL, KEY_LEFTCTRL)] = RGFW_ControlL RGFW_NEXT
1336 RGFW_MAP [RGFW_OS_BASED_VALUE(64,0x12, 58, DOM_VK_ALT, KEY_LEFTALT)] = RGFW_AltL RGFW_NEXT
1337 RGFW_MAP [RGFW_OS_BASED_VALUE(133, 0x5B, 55, DOM_VK_WIN, KEY_LEFTMETA)] = RGFW_SuperL,
1338
1339 #if !defined(RGFW_WINDOWS) && !defined(RGFW_MACOS) && !defined(RGFW_WEBASM)
1340 RGFW_MAP [RGFW_OS_BASED_VALUE(105, 0x11, 59, 0, KEY_RIGHTCTRL)] = RGFW_ControlR RGFW_NEXT
1341 RGFW_MAP [RGFW_OS_BASED_VALUE(135, 0xA4, 55, 0, KEY_RIGHTMETA)] = RGFW_SuperR,
1342 RGFW_MAP [RGFW_OS_BASED_VALUE(62, 0x5C, 56, 0, KEY_RIGHTSHIFT)] = RGFW_ShiftR RGFW_NEXT
1343 RGFW_MAP [RGFW_OS_BASED_VALUE(108, 165, 58, 0, KEY_RIGHTALT)] = RGFW_AltR,
1344 #endif
1345
1346 RGFW_MAP [RGFW_OS_BASED_VALUE(67, 0x70, 127, DOM_VK_F1, KEY_F1)] = RGFW_F1 RGFW_NEXT
1347 RGFW_MAP [RGFW_OS_BASED_VALUE(68, 0x71, 121, DOM_VK_F2, KEY_F2)] = RGFW_F2 RGFW_NEXT
1348 RGFW_MAP [RGFW_OS_BASED_VALUE(69, 0x72, 100, DOM_VK_F3, KEY_F3)] = RGFW_F3 RGFW_NEXT
1349 RGFW_MAP [RGFW_OS_BASED_VALUE(70, 0x73, 119, DOM_VK_F4, KEY_F4)] = RGFW_F4 RGFW_NEXT
1350 RGFW_MAP [RGFW_OS_BASED_VALUE(71, 0x74, 97, DOM_VK_F5, KEY_F5)] = RGFW_F5 RGFW_NEXT
1351 RGFW_MAP [RGFW_OS_BASED_VALUE(72, 0x75, 98, DOM_VK_F6, KEY_F6)] = RGFW_F6 RGFW_NEXT
1352 RGFW_MAP [RGFW_OS_BASED_VALUE(73, 0x76, 99, DOM_VK_F7, KEY_F7)] = RGFW_F7 RGFW_NEXT
1353 RGFW_MAP [RGFW_OS_BASED_VALUE(74, 0x77, 101, DOM_VK_F8, KEY_F8)] = RGFW_F8 RGFW_NEXT
1354 RGFW_MAP [RGFW_OS_BASED_VALUE(75, 0x78, 102, DOM_VK_F9, KEY_F9)] = RGFW_F9 RGFW_NEXT
1355 RGFW_MAP [RGFW_OS_BASED_VALUE(76, 0x79, 110, DOM_VK_F10, KEY_F10)] = RGFW_F10 RGFW_NEXT
1356 RGFW_MAP [RGFW_OS_BASED_VALUE(95, 0x7A, 104, DOM_VK_F11, KEY_F11)] = RGFW_F11 RGFW_NEXT
1357 RGFW_MAP [RGFW_OS_BASED_VALUE(96, 0x7B, 112, DOM_VK_F12, KEY_F12)] = RGFW_F12 RGFW_NEXT
1358 RGFW_MAP [RGFW_OS_BASED_VALUE(111, 0x26, 126, DOM_VK_UP, KEY_UP)] = RGFW_Up RGFW_NEXT
1359 RGFW_MAP [RGFW_OS_BASED_VALUE(116, 0x28, 125, DOM_VK_DOWN, KEY_DOWN)] = RGFW_Down RGFW_NEXT
1360 RGFW_MAP [RGFW_OS_BASED_VALUE(113, 0x25, 123, DOM_VK_LEFT, KEY_LEFT)] = RGFW_Left RGFW_NEXT
1361 RGFW_MAP [RGFW_OS_BASED_VALUE(114, 0x27, 124, DOM_VK_RIGHT, KEY_RIGHT)] = RGFW_Right RGFW_NEXT
1362 RGFW_MAP [RGFW_OS_BASED_VALUE(118, 0x2D, 115, DOM_VK_INSERT, KEY_INSERT)] = RGFW_Insert RGFW_NEXT
1363 RGFW_MAP [RGFW_OS_BASED_VALUE(115, 0x23, 120, DOM_VK_END, KEY_END)] = RGFW_End RGFW_NEXT
1364 RGFW_MAP [RGFW_OS_BASED_VALUE(112, 336, 117, DOM_VK_PAGE_UP, KEY_PAGEUP)] = RGFW_PageUp RGFW_NEXT
1365 RGFW_MAP [RGFW_OS_BASED_VALUE(117, 325, 122, DOM_VK_PAGE_DOWN, KEY_PAGEDOWN)] = RGFW_PageDown RGFW_NEXT
1366 RGFW_MAP [RGFW_OS_BASED_VALUE(9, 0x1B, 53, DOM_VK_ESCAPE, KEY_ESC)] = RGFW_Escape RGFW_NEXT
1367 RGFW_MAP [RGFW_OS_BASED_VALUE(110, 0x24, 116, DOM_VK_HOME, KEY_HOME)] = RGFW_Home RGFW_NEXT
1368#ifndef __cplusplus
1369};
1370#else
1371}
1372#endif
1373
1374#undef RGFW_NEXT
1375#undef RGFW_MAP
1376
1377typedef struct {
1378 b8 current : 1;
1379 b8 prev : 1;
1380} RGFW_keyState;
1381
1382RGFW_keyState RGFW_keyboard[final_key] = { {0, 0} };
1383
1384RGFWDEF u32 RGFW_apiKeyCodeToRGFW(u32 keycode);
1385
1386u32 RGFW_apiKeyCodeToRGFW(u32 keycode) {
1387 #ifdef __cplusplus
1388 if (RGFW_OS_BASED_VALUE(49, 192, 50, DOM_VK_BACK_QUOTE, KEY_GRAVE) != RGFW_Backtick) {
1389 RGFW_init_keys();
1390 }
1391 #endif
1392
1393 /* make sure the key isn't out of bounds */
1394 if (keycode > sizeof(RGFW_keycodes) / sizeof(u8))
1395 return 0;
1396
1397 return RGFW_keycodes[keycode];
1398}
1399
1400RGFWDEF void RGFW_resetKey(void);
1401void RGFW_resetKey(void) {
1402 size_t len = final_key; /*!< last_key == length */
1403
1404 size_t i; /*!< reset each previous state */
1405 for (i = 0; i < len; i++)
1406 RGFW_keyboard[i].prev = 0;
1407}
1408
1409b8 RGFW_shouldShift(u32 keycode, u8 lockState) {
1410 #define RGFW_xor(x, y) (( (x) && (!(y)) ) || ((y) && (!(x)) ))
1411 b8 caps4caps = (lockState & RGFW_CAPSLOCK) && ((keycode >= RGFW_a) && (keycode <= RGFW_z));
1412 b8 shouldShift = RGFW_xor((RGFW_isPressed(NULL, RGFW_ShiftL) || RGFW_isPressed(NULL, RGFW_ShiftR)), caps4caps);
1413 #undef RGFW_xor
1414
1415 return shouldShift;
1416}
1417
1418char RGFW_keyCodeToChar(u32 keycode, b8 shift) {
1419 static const char map[] = {
1420 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '`', '0', '1', '2', '3', '4', '5', '6', '7', '8',
1421 '9', '-', '=', 0, '\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1422 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', ',', '/', '[', ']', ';', '\n', '\'', '\\',
1423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', '*', '-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\n'
1424 };
1425
1426 static const char mapCaps[] = {
1427 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '~', ')', '!', '@', '#', '$', '%', '^', '&', '*',
1428 '(', '_', '+', 0, '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1429 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1430 'X', 'Y', 'Z', '>', '<', '?', '{', '}', ':', '\n', '"', '|',
1431 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '?', '*', '-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1432 };
1433
1434 if (shift == RGFW_FALSE)
1435 return map[keycode];
1436 return mapCaps[keycode];
1437}
1438
1439char RGFW_keyCodeToCharAuto(u32 keycode, u8 lockState) { return RGFW_keyCodeToChar(keycode, RGFW_shouldShift(keycode, lockState)); }
1440
1441/*
1442 this is the end of keycode data
1443*/
1444
1445/* joystick data */
1446u8 RGFW_jsPressed[4][16]; /*!< if a key is currently pressed or not (per joystick) */
1447
1448i32 RGFW_joysticks[4]; /*!< limit of 4 joysticks at a time */
1449u16 RGFW_joystickCount; /*!< the actual amount of joysticks */
1450
1451/*
1452 event callback defines start here
1453*/
1454
1455
1456/*
1457 These exist to avoid the
1458 if (func == NULL) check
1459 for (allegedly) better performance
1460*/
1461void RGFW_windowmovefuncEMPTY(RGFW_window* win, RGFW_rect r) { RGFW_UNUSED(win); RGFW_UNUSED(r); }
1462void RGFW_windowresizefuncEMPTY(RGFW_window* win, RGFW_rect r) { RGFW_UNUSED(win); RGFW_UNUSED(r); }
1463void RGFW_windowquitfuncEMPTY(RGFW_window* win) { RGFW_UNUSED(win); }
1464void RGFW_focusfuncEMPTY(RGFW_window* win, b8 inFocus) {RGFW_UNUSED(win); RGFW_UNUSED(inFocus);}
1465void RGFW_mouseNotifyfuncEMPTY(RGFW_window* win, RGFW_point point, b8 status) {RGFW_UNUSED(win); RGFW_UNUSED(point); RGFW_UNUSED(status);}
1466void RGFW_mouseposfuncEMPTY(RGFW_window* win, RGFW_point point) {RGFW_UNUSED(win); RGFW_UNUSED(point);}
1467void RGFW_dndInitfuncEMPTY(RGFW_window* win, RGFW_point point) {RGFW_UNUSED(win); RGFW_UNUSED(point);}
1468void RGFW_windowrefreshfuncEMPTY(RGFW_window* win) {RGFW_UNUSED(win); }
1469void RGFW_keyfuncEMPTY(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(keycode); RGFW_UNUSED(keyName); RGFW_UNUSED(lockState); RGFW_UNUSED(pressed);}
1470void RGFW_mousebuttonfuncEMPTY(RGFW_window* win, u8 button, double scroll, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(button); RGFW_UNUSED(scroll); RGFW_UNUSED(pressed);}
1471void RGFW_jsButtonfuncEMPTY(RGFW_window* win, u16 joystick, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(button); RGFW_UNUSED(pressed); }
1472void RGFW_jsAxisfuncEMPTY(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); }
1473
1474#ifdef RGFW_ALLOC_DROPFILES
1475void RGFW_dndfuncEMPTY(RGFW_window* win, char** droppedFiles, u32 droppedFilesCount) {RGFW_UNUSED(win); RGFW_UNUSED(droppedFiles); RGFW_UNUSED(droppedFilesCount);}
1476#else
1477void RGFW_dndfuncEMPTY(RGFW_window* win, char droppedFiles[RGFW_MAX_DROPS][RGFW_MAX_PATH], u32 droppedFilesCount) {RGFW_UNUSED(win); RGFW_UNUSED(droppedFiles); RGFW_UNUSED(droppedFilesCount);}
1478#endif
1479
1480RGFW_windowmovefunc RGFW_windowMoveCallback = RGFW_windowmovefuncEMPTY;
1481RGFW_windowresizefunc RGFW_windowResizeCallback = RGFW_windowresizefuncEMPTY;
1482RGFW_windowquitfunc RGFW_windowQuitCallback = RGFW_windowquitfuncEMPTY;
1483RGFW_mouseposfunc RGFW_mousePosCallback = RGFW_mouseposfuncEMPTY;
1484RGFW_windowrefreshfunc RGFW_windowRefreshCallback = RGFW_windowrefreshfuncEMPTY;
1485RGFW_focusfunc RGFW_focusCallback = RGFW_focusfuncEMPTY;
1486RGFW_mouseNotifyfunc RGFW_mouseNotifyCallBack = RGFW_mouseNotifyfuncEMPTY;
1487RGFW_dndfunc RGFW_dndCallback = RGFW_dndfuncEMPTY;
1488RGFW_dndInitfunc RGFW_dndInitCallback = RGFW_dndInitfuncEMPTY;
1489RGFW_keyfunc RGFW_keyCallback = RGFW_keyfuncEMPTY;
1490RGFW_mousebuttonfunc RGFW_mouseButtonCallback = RGFW_mousebuttonfuncEMPTY;
1491RGFW_jsButtonfunc RGFW_jsButtonCallback = RGFW_jsButtonfuncEMPTY;
1492RGFW_jsAxisfunc RGFW_jsAxisCallback = RGFW_jsAxisfuncEMPTY;
1493
1494void RGFW_window_checkEvents(RGFW_window* win, i32 waitMS) {
1495 RGFW_window_eventWait(win, waitMS);
1496
1497 while (RGFW_window_checkEvent(win) != NULL && RGFW_window_shouldClose(win) == 0) {
1498 if (win->event.type == RGFW_quit) return;
1499 }
1500
1501 #ifdef RGFW_WEBASM /* webasm needs to run the sleep function for asyncify */
1502 RGFW_sleep(0);
1503 #endif
1504}
1505
1506RGFW_windowmovefunc RGFW_setWindowMoveCallback(RGFW_windowmovefunc func) {
1507 RGFW_windowmovefunc prev = (RGFW_windowMoveCallback == RGFW_windowmovefuncEMPTY) ? NULL : RGFW_windowMoveCallback;
1508 RGFW_windowMoveCallback = func;
1509 return prev;
1510}
1511RGFW_windowresizefunc RGFW_setWindowResizeCallback(RGFW_windowresizefunc func) {
1512 RGFW_windowresizefunc prev = (RGFW_windowResizeCallback == RGFW_windowresizefuncEMPTY) ? NULL : RGFW_windowResizeCallback;
1513 RGFW_windowResizeCallback = func;
1514 return prev;
1515}
1516RGFW_windowquitfunc RGFW_setWindowQuitCallback(RGFW_windowquitfunc func) {
1517 RGFW_windowquitfunc prev = (RGFW_windowQuitCallback == RGFW_windowquitfuncEMPTY) ? NULL : RGFW_windowQuitCallback;
1518 RGFW_windowQuitCallback = func;
1519 return prev;
1520}
1521
1522RGFW_mouseposfunc RGFW_setMousePosCallback(RGFW_mouseposfunc func) {
1523 RGFW_mouseposfunc prev = (RGFW_mousePosCallback == RGFW_mouseposfuncEMPTY) ? NULL : RGFW_mousePosCallback;
1524 RGFW_mousePosCallback = func;
1525 return prev;
1526}
1527RGFW_windowrefreshfunc RGFW_setWindowRefreshCallback(RGFW_windowrefreshfunc func) {
1528 RGFW_windowrefreshfunc prev = (RGFW_windowRefreshCallback == RGFW_windowrefreshfuncEMPTY) ? NULL : RGFW_windowRefreshCallback;
1529 RGFW_windowRefreshCallback = func;
1530 return prev;
1531}
1532RGFW_focusfunc RGFW_setFocusCallback(RGFW_focusfunc func) {
1533 RGFW_focusfunc prev = (RGFW_focusCallback == RGFW_focusfuncEMPTY) ? NULL : RGFW_focusCallback;
1534 RGFW_focusCallback = func;
1535 return prev;
1536}
1537
1538RGFW_mouseNotifyfunc RGFW_setMouseNotifyCallBack(RGFW_mouseNotifyfunc func) {
1539 RGFW_mouseNotifyfunc prev = (RGFW_mouseNotifyCallBack == RGFW_mouseNotifyfuncEMPTY) ? NULL : RGFW_mouseNotifyCallBack;
1540 RGFW_mouseNotifyCallBack = func;
1541 return prev;
1542}
1543RGFW_dndfunc RGFW_setDndCallback(RGFW_dndfunc func) {
1544 RGFW_dndfunc prev = (RGFW_dndCallback == RGFW_dndfuncEMPTY) ? NULL : RGFW_dndCallback;
1545 RGFW_dndCallback = func;
1546 return prev;
1547}
1548RGFW_dndInitfunc RGFW_setDndInitCallback(RGFW_dndInitfunc func) {
1549 RGFW_dndInitfunc prev = (RGFW_dndInitCallback == RGFW_dndInitfuncEMPTY) ? NULL : RGFW_dndInitCallback;
1550 RGFW_dndInitCallback = func;
1551 return prev;
1552}
1553RGFW_keyfunc RGFW_setKeyCallback(RGFW_keyfunc func) {
1554 RGFW_keyfunc prev = (RGFW_keyCallback == RGFW_keyfuncEMPTY) ? NULL : RGFW_keyCallback;
1555 RGFW_keyCallback = func;
1556 return prev;
1557}
1558RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func) {
1559 RGFW_mousebuttonfunc prev = (RGFW_mouseButtonCallback == RGFW_mousebuttonfuncEMPTY) ? NULL : RGFW_mouseButtonCallback;
1560 RGFW_mouseButtonCallback = func;
1561 return prev;
1562}
1563RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func) {
1564 RGFW_jsButtonfunc prev = (RGFW_jsButtonCallback == RGFW_jsButtonfuncEMPTY) ? NULL : RGFW_jsButtonCallback;
1565 RGFW_jsButtonCallback = func;
1566 return prev;
1567}
1568RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func) {
1569 RGFW_jsAxisfunc prev = (RGFW_jsAxisCallback == RGFW_jsAxisfuncEMPTY) ? NULL : RGFW_jsAxisCallback;
1570 RGFW_jsAxisCallback = func;
1571 return prev;
1572}
1573/*
1574no more event call back defines
1575*/
1576
1577#define RGFW_ASSERT(check, str) {\
1578 if (!(check)) { \
1579 printf(str); \
1580 assert(check); \
1581 } \
1582}
1583
1584b8 RGFW_error = 0;
1585b8 RGFW_Error(void) { return RGFW_error; }
1586
1587#define SET_ATTRIB(a, v) { \
1588 assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
1589 attribs[index++] = a; \
1590 attribs[index++] = v; \
1591}
1592
1593RGFW_area RGFW_bufferSize = {0, 0};
1594void RGFW_setBufferSize(RGFW_area size) {
1595 RGFW_bufferSize = size;
1596}
1597
1598
1599RGFWDEF RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args);
1600
1601/* do a basic initialization for RGFW_window, this is to standard it for each OS */
1602RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) {
1603 RGFW_window* win = (RGFW_window*) RGFW_MALLOC(sizeof(RGFW_window)); /*!< make a new RGFW struct */
1604
1605 /* clear out dnd info */
1606#ifdef RGFW_ALLOC_DROPFILES
1607 win->event.droppedFiles = (char**) RGFW_MALLOC(sizeof(char*) * RGFW_MAX_DROPS);
1608 u32 i;
1609 for (i = 0; i < RGFW_MAX_DROPS; i++)
1610 win->event.droppedFiles[i] = (char*) RGFW_CALLOC(RGFW_MAX_PATH, sizeof(char));
1611#endif
1612
1613 /* X11 requires us to have a display to get the screen size */
1614 #ifndef RGFW_X11
1615 RGFW_area screenR = RGFW_getScreenSize();
1616 #else
1617 win->src.display = XOpenDisplay(NULL);
1618 assert(win->src.display != NULL);
1619
1620 Screen* scrn = DefaultScreenOfDisplay((Display*)win->src.display);
1621 RGFW_area screenR = RGFW_AREA((u32)scrn->width, (u32)scrn->height);
1622 #endif
1623
1624 /* rect based the requested args */
1625 if (args & RGFW_FULLSCREEN)
1626 rect = RGFW_RECT(0, 0, screenR.w, screenR.h);
1627
1628 /* set and init the new window's data */
1629 win->r = rect;
1630 win->event.inFocus = 1;
1631 win->event.droppedFilesCount = 0;
1632 RGFW_joystickCount = 0;
1633 win->_winArgs = 0;
1634 win->event.lockState = 0;
1635
1636 return win;
1637}
1638
1639#ifndef RGFW_NO_MONITOR
1640void RGFW_window_scaleToMonitor(RGFW_window* win) {
1641 RGFW_monitor monitor = RGFW_window_getMonitor(win);
1642
1643 RGFW_window_resize(win, RGFW_AREA((u32)(monitor.scaleX * (float)win->r.w), (u32)(monitor.scaleX * (float)win->r.h)));
1644}
1645#endif
1646
1647RGFW_window* RGFW_root = NULL;
1648
1649
1650#define RGFW_HOLD_MOUSE (1L<<2) /*!< hold the moues still */
1651#define RGFW_MOUSE_LEFT (1L<<3) /* if mouse left the window */
1652
1653#ifdef RGFW_MACOS
1654RGFWDEF void RGFW_window_cocoaSetLayer(RGFW_window* win, void* layer);
1655RGFWDEF void* RGFW_cocoaGetLayer(void);
1656#endif
1657
1658char* RGFW_className = NULL;
1659void RGFW_setClassName(char* name) {
1660 RGFW_className = name;
1661}
1662
1663void RGFW_clipboardFree(char* str) { RGFW_FREE(str); }
1664
1665RGFW_keyState RGFW_mouseButtons[5] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} };
1666
1667b8 RGFW_isMousePressed(RGFW_window* win, u8 button) {
1668 assert(win != NULL);
1669 return RGFW_mouseButtons[button].current && (win != NULL) && win->event.inFocus;
1670}
1671b8 RGFW_wasMousePressed(RGFW_window* win, u8 button) {
1672 assert(win != NULL);
1673 return RGFW_mouseButtons[button].prev && (win != NULL) && win->event.inFocus;
1674}
1675b8 RGFW_isMouseHeld(RGFW_window* win, u8 button) {
1676 return (RGFW_isMousePressed(win, button) && RGFW_wasMousePressed(win, button));
1677}
1678b8 RGFW_isMouseReleased(RGFW_window* win, u8 button) {
1679 return (!RGFW_isMousePressed(win, button) && RGFW_wasMousePressed(win, button));
1680}
1681
1682b8 RGFW_isPressed(RGFW_window* win, u8 key) {
1683 return RGFW_keyboard[key].current && (win == NULL || win->event.inFocus);
1684}
1685
1686b8 RGFW_wasPressed(RGFW_window* win, u8 key) {
1687 return RGFW_keyboard[key].prev && (win == NULL || win->event.inFocus);
1688}
1689
1690b8 RGFW_isHeld(RGFW_window* win, u8 key) {
1691 return (RGFW_isPressed(win, key) && RGFW_wasPressed(win, key));
1692}
1693
1694b8 RGFW_isClicked(RGFW_window* win, u8 key) {
1695 return (RGFW_wasPressed(win, key) && !RGFW_isPressed(win, key));
1696}
1697
1698b8 RGFW_isReleased(RGFW_window* win, u8 key) {
1699 return (!RGFW_isPressed(win, key) && RGFW_wasPressed(win, key));
1700}
1701
1702#if defined(RGFW_WINDOWS) && defined(RGFW_DIRECTX) /* defines for directX context*/
1703 RGFW_directXinfo RGFW_dxInfo;
1704 RGFW_directXinfo* RGFW_getDirectXInfo(void) { return &RGFW_dxInfo; }
1705#endif
1706
1707void RGFW_window_makeCurrent(RGFW_window* win) {
1708#if defined(RGFW_WINDOWS) && defined(RGFW_DIRECTX)
1709 if (win == NULL)
1710 RGFW_dxInfo.pDeviceContext->lpVtbl->OMSetRenderTargets(RGFW_dxInfo.pDeviceContext, 1, NULL, NULL);
1711 else
1712 RGFW_dxInfo.pDeviceContext->lpVtbl->OMSetRenderTargets(RGFW_dxInfo.pDeviceContext, 1, &win->src.renderTargetView, NULL);
1713#elif defined(RGFW_OPENGL)
1714 RGFW_window_makeCurrent_OpenGL(win);
1715#else
1716 RGFW_UNUSED(win)
1717#endif
1718}
1719
1720void RGFW_window_setGPURender(RGFW_window* win, i8 set) {
1721 if (!set && !(win->_winArgs & RGFW_NO_GPU_RENDER))
1722 win->_winArgs |= RGFW_NO_GPU_RENDER;
1723
1724 else if (set && win->_winArgs & RGFW_NO_GPU_RENDER)
1725 win->_winArgs ^= RGFW_NO_GPU_RENDER;
1726}
1727
1728void RGFW_window_setCPURender(RGFW_window* win, i8 set) {
1729 if (!set && !(win->_winArgs & RGFW_NO_CPU_RENDER))
1730 win->_winArgs |= RGFW_NO_CPU_RENDER;
1731
1732 else if (set && win->_winArgs & RGFW_NO_CPU_RENDER)
1733 win->_winArgs ^= RGFW_NO_CPU_RENDER;
1734}
1735
1736void RGFW_window_maximize(RGFW_window* win) {
1737 assert(win != NULL);
1738
1739 RGFW_area screen = RGFW_getScreenSize();
1740
1741 RGFW_window_move(win, RGFW_POINT(0, 0));
1742 RGFW_window_resize(win, screen);
1743}
1744
1745b8 RGFW_window_shouldClose(RGFW_window* win) {
1746 assert(win != NULL);
1747 return (win->event.type == RGFW_quit || RGFW_isPressed(win, RGFW_Escape));
1748}
1749
1750void RGFW_window_setShouldClose(RGFW_window* win) { win->event.type = RGFW_quit; RGFW_windowQuitCallback(win); }
1751
1752#ifndef RGFW_NO_MONITOR
1753 void RGFW_window_moveToMonitor(RGFW_window* win, RGFW_monitor m) {
1754 RGFW_window_move(win, RGFW_POINT(m.rect.x + win->r.x, m.rect.y + win->r.y));
1755 }
1756#endif
1757
1758RGFWDEF void RGFW_captureCursor(RGFW_window* win, RGFW_rect);
1759RGFWDEF void RGFW_releaseCursor(RGFW_window* win);
1760
1761void RGFW_window_mouseHold(RGFW_window* win, RGFW_area area) {
1762 if ((win->_winArgs & RGFW_HOLD_MOUSE))
1763 return;
1764
1765
1766 if (!area.w && !area.h)
1767 area = RGFW_AREA(win->r.w / 2, win->r.h / 2);
1768
1769 win->_winArgs |= RGFW_HOLD_MOUSE;
1770 RGFW_captureCursor(win, win->r);
1771 RGFW_window_moveMouse(win, RGFW_POINT(win->r.x + (win->r.w / 2), win->r.y + (win->r.h / 2)));
1772}
1773
1774void RGFW_window_mouseUnhold(RGFW_window* win) {
1775 if ((win->_winArgs & RGFW_HOLD_MOUSE)) {
1776 win->_winArgs ^= RGFW_HOLD_MOUSE;
1777
1778 RGFW_releaseCursor(win);
1779 }
1780}
1781
1782u32 RGFW_window_checkFPS(RGFW_window* win, u32 fpsCap) {
1783 u64 deltaTime = RGFW_getTimeNS() - win->event.frameTime;
1784
1785 u32 output_fps = 0;
1786 u64 fps = round(1e+9 / deltaTime);
1787 output_fps= fps;
1788
1789 if (fpsCap && fps > fpsCap) {
1790 u64 frameTimeNS = 1e+9 / fpsCap;
1791 u64 sleepTimeMS = (frameTimeNS - deltaTime) / 1e6;
1792
1793 if (sleepTimeMS > 0) {
1794 RGFW_sleep(sleepTimeMS);
1795 win->event.frameTime = 0;
1796 }
1797 }
1798
1799 win->event.frameTime = RGFW_getTimeNS();
1800
1801 if (fpsCap == 0)
1802 return (u32) output_fps;
1803
1804 deltaTime = RGFW_getTimeNS() - win->event.frameTime2;
1805 output_fps = round(1e+9 / deltaTime);
1806 win->event.frameTime2 = RGFW_getTimeNS();
1807
1808 return output_fps;
1809}
1810
1811u32 RGFW_isPressedJS(RGFW_window* win, u16 c, u8 button) {
1812 RGFW_UNUSED(win);
1813 return RGFW_jsPressed[c][button];
1814}
1815
1816#if defined(RGFW_X11) || defined(RGFW_WINDOWS)
1817 void RGFW_window_showMouse(RGFW_window* win, i8 show) {
1818 static u8 RGFW_blk[] = { 0, 0, 0, 0 };
1819 if (show == 0)
1820 RGFW_window_setMouse(win, RGFW_blk, RGFW_AREA(1, 1), 4);
1821 else
1822 RGFW_window_setMouseDefault(win);
1823 }
1824#endif
1825
1826RGFWDEF void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock);
1827void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) {
1828 if (capital && !(win->event.lockState & RGFW_CAPSLOCK))
1829 win->event.lockState |= RGFW_CAPSLOCK;
1830 else if (!capital && (win->event.lockState & RGFW_CAPSLOCK))
1831 win->event.lockState ^= RGFW_CAPSLOCK;
1832
1833 if (numlock && !(win->event.lockState & RGFW_NUMLOCK))
1834 win->event.lockState |= RGFW_NUMLOCK;
1835 else if (!numlock && (win->event.lockState & RGFW_NUMLOCK))
1836 win->event.lockState ^= RGFW_NUMLOCK;
1837}
1838
1839#if defined(RGFW_X11) || defined(RGFW_MACOS) || defined(RGFW_WEBASM) || defined(RGFW_WAYLAND)
1840 struct timespec;
1841
1842 int nanosleep(const struct timespec* duration, struct timespec* rem);
1843 int clock_gettime(clockid_t clk_id, struct timespec* tp);
1844 int setenv(const char *name, const char *value, int overwrite);
1845
1846 void RGFW_window_setDND(RGFW_window* win, b8 allow) {
1847 if (allow && !(win->_winArgs & RGFW_ALLOW_DND))
1848 win->_winArgs |= RGFW_ALLOW_DND;
1849
1850 else if (!allow && (win->_winArgs & RGFW_ALLOW_DND))
1851 win->_winArgs ^= RGFW_ALLOW_DND;
1852 }
1853#endif
1854
1855/*
1856 graphics API specific code (end of generic code)
1857 starts here
1858*/
1859
1860
1861/*
1862 OpenGL defines start here (Normal, EGL, OSMesa)
1863*/
1864
1865#if defined(RGFW_OPENGL) || defined(RGFW_EGL) || defined(RGFW_OSMESA)
1866 #ifdef RGFW_WINDOWS
1867 #define WIN32_LEAN_AND_MEAN
1868 #define OEMRESOURCE
1869 #include <windows.h>
1870 #endif
1871
1872 #if !defined(__APPLE__) && !defined(RGFW_NO_GL_HEADER)
1873 #include <GL/gl.h>
1874 #elif defined(__APPLE__)
1875 #ifndef GL_SILENCE_DEPRECATION
1876 #define GL_SILENCE_DEPRECATION
1877 #endif
1878 #include <OpenGL/gl.h>
1879 #include <OpenGL/OpenGL.h>
1880 #endif
1881
1882/* EGL, normal OpenGL only */
1883#if !defined(RGFW_OSMESA)
1884 i32 RGFW_majorVersion = 0, RGFW_minorVersion = 0;
1885 b8 RGFW_profile = RGFW_GL_CORE;
1886
1887 #ifndef RGFW_EGL
1888 i32 RGFW_STENCIL = 8, RGFW_SAMPLES = 4, RGFW_STEREO = 0, RGFW_AUX_BUFFERS = 0, RGFW_DOUBLE_BUFFER = 1;
1889 #else
1890 i32 RGFW_STENCIL = 0, RGFW_SAMPLES = 0, RGFW_STEREO = 0, RGFW_AUX_BUFFERS = 0, RGFW_DOUBLE_BUFFER = 1;
1891 #endif
1892
1893
1894 void RGFW_setGLStencil(i32 stencil) { RGFW_STENCIL = stencil; }
1895 void RGFW_setGLSamples(i32 samples) { RGFW_SAMPLES = samples; }
1896 void RGFW_setGLStereo(i32 stereo) { RGFW_STEREO = stereo; }
1897 void RGFW_setGLAuxBuffers(i32 auxBuffers) { RGFW_AUX_BUFFERS = auxBuffers; }
1898 void RGFW_setDoubleBuffer(b8 useDoubleBuffer) { RGFW_DOUBLE_BUFFER = useDoubleBuffer; }
1899
1900 void RGFW_setGLVersion(b8 profile, i32 major, i32 minor) {
1901 RGFW_profile = profile;
1902 RGFW_majorVersion = major;
1903 RGFW_minorVersion = minor;
1904 }
1905
1906/* OPENGL normal only (no EGL / OSMesa) */
1907#ifndef RGFW_EGL
1908
1909#define RGFW_GL_RENDER_TYPE RGFW_OS_BASED_VALUE(GLX_X_VISUAL_TYPE, 0x2003, 73, 0, 0)
1910 #define RGFW_GL_ALPHA_SIZE RGFW_OS_BASED_VALUE(GLX_ALPHA_SIZE, 0x201b, 11, 0, 0)
1911 #define RGFW_GL_DEPTH_SIZE RGFW_OS_BASED_VALUE(GLX_DEPTH_SIZE, 0x2022, 12, 0, 0)
1912 #define RGFW_GL_DOUBLEBUFFER RGFW_OS_BASED_VALUE(GLX_DOUBLEBUFFER, 0x2011, 5, 0, 0)
1913 #define RGFW_GL_STENCIL_SIZE RGFW_OS_BASED_VALUE(GLX_STENCIL_SIZE, 0x2023, 13, 0, 0)
1914 #define RGFW_GL_SAMPLES RGFW_OS_BASED_VALUE(GLX_SAMPLES, 0x2042, 55, 0, 0)
1915 #define RGFW_GL_STEREO RGFW_OS_BASED_VALUE(GLX_STEREO, 0x2012, 6, 0, 0)
1916 #define RGFW_GL_AUX_BUFFERS RGFW_OS_BASED_VALUE(GLX_AUX_BUFFERS, 0x2024, 7, 0, 0)
1917
1918#if defined(RGFW_X11) || defined(RGFW_WINDOWS)
1919 #define RGFW_GL_DRAW RGFW_OS_BASED_VALUE(GLX_X_RENDERABLE, 0x2001, 0, 0, 0)
1920 #define RGFW_GL_DRAW_TYPE RGFW_OS_BASED_VALUE(GLX_RENDER_TYPE, 0x2013, 0, 0, 0)
1921 #define RGFW_GL_FULL_FORMAT RGFW_OS_BASED_VALUE(GLX_TRUE_COLOR, 0x2027, 0, 0, 0)
1922 #define RGFW_GL_RED_SIZE RGFW_OS_BASED_VALUE(GLX_RED_SIZE, 0x2015, 0, 0, 0)
1923 #define RGFW_GL_GREEN_SIZE RGFW_OS_BASED_VALUE(GLX_GREEN_SIZE, 0x2017, 0, 0, 0)
1924 #define RGFW_GL_BLUE_SIZE RGFW_OS_BASED_VALUE(GLX_BLUE_SIZE, 0x2019, 0, 0, 0)
1925 #define RGFW_GL_USE_RGBA RGFW_OS_BASED_VALUE(GLX_RGBA_BIT, 0x202B, 0, 0, 0)
1926#endif
1927
1928#ifdef RGFW_WINDOWS
1929 #define WGL_SUPPORT_OPENGL_ARB 0x2010
1930 #define WGL_COLOR_BITS_ARB 0x2014
1931 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
1932 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
1933 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
1934 #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
1935 #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
1936 #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
1937 #define WGL_SAMPLE_BUFFERS_ARB 0x2041
1938 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
1939 #define WGL_PIXEL_TYPE_ARB 0x2013
1940 #define WGL_TYPE_RGBA_ARB 0x202B
1941
1942 #define WGL_TRANSPARENT_ARB 0x200A
1943#endif
1944
1945/* The window'ing api needs to know how to render the data we (or opengl) give it
1946 MacOS and Windows do this using a structure called a "pixel format"
1947 X11 calls it a "Visual"
1948 This function returns the attributes for the format we want */
1949 static u32* RGFW_initFormatAttribs(u32 useSoftware) {
1950 RGFW_UNUSED(useSoftware);
1951 static u32 attribs[] = {
1952 #if defined(RGFW_X11) || defined(RGFW_WINDOWS)
1953 RGFW_GL_RENDER_TYPE,
1954 RGFW_GL_FULL_FORMAT,
1955 #endif
1956 RGFW_GL_ALPHA_SIZE , 8,
1957 RGFW_GL_DEPTH_SIZE , 24,
1958 #if defined(RGFW_X11) || defined(RGFW_WINDOWS)
1959 RGFW_GL_DRAW, 1,
1960 RGFW_GL_RED_SIZE , 8,
1961 RGFW_GL_GREEN_SIZE , 8,
1962 RGFW_GL_BLUE_SIZE , 8,
1963 RGFW_GL_DRAW_TYPE , RGFW_GL_USE_RGBA,
1964 #endif
1965
1966 #ifdef RGFW_X11
1967 GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT,
1968 #endif
1969
1970 #ifdef RGFW_MACOS
1971 72,
1972 8, 24,
1973 #endif
1974
1975 #ifdef RGFW_WINDOWS
1976 WGL_SUPPORT_OPENGL_ARB, 1,
1977 WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
1978 WGL_COLOR_BITS_ARB, 32,
1979 #endif
1980
1981 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1982 };
1983
1984 size_t index = (sizeof(attribs) / sizeof(attribs[0])) - 13;
1985
1986 #define RGFW_GL_ADD_ATTRIB(attrib, attVal) \
1987 if (attVal) { \
1988 attribs[index] = attrib;\
1989 attribs[index + 1] = attVal;\
1990 index += 2;\
1991 }
1992
1993 RGFW_GL_ADD_ATTRIB(RGFW_GL_DOUBLEBUFFER, 1);
1994
1995 RGFW_GL_ADD_ATTRIB(RGFW_GL_STENCIL_SIZE, RGFW_STENCIL);
1996 RGFW_GL_ADD_ATTRIB(RGFW_GL_STEREO, RGFW_STEREO);
1997 RGFW_GL_ADD_ATTRIB(RGFW_GL_AUX_BUFFERS, RGFW_AUX_BUFFERS);
1998
1999#ifndef RGFW_X11
2000 RGFW_GL_ADD_ATTRIB(RGFW_GL_SAMPLES, RGFW_SAMPLES);
2001#endif
2002
2003#ifdef RGFW_MACOS
2004 if (useSoftware) {
2005 RGFW_GL_ADD_ATTRIB(70, kCGLRendererGenericFloatID);
2006 } else {
2007 attribs[index] = RGFW_GL_RENDER_TYPE;
2008 index += 1;
2009 }
2010#endif
2011
2012#ifdef RGFW_MACOS
2013 /* macOS has the surface attribs and the opengl attribs connected for some reason
2014 maybe this is to give macOS more control to limit openGL/the opengl version? */
2015
2016 attribs[index] = 99;
2017 attribs[index + 1] = 0x1000;
2018
2019 if (RGFW_majorVersion >= 4 || RGFW_majorVersion >= 3) {
2020 attribs[index + 1] = (u32) ((RGFW_majorVersion >= 4) ? 0x4100 : 0x3200);
2021 }
2022#endif
2023
2024 RGFW_GL_ADD_ATTRIB(0, 0);
2025
2026 return attribs;
2027 }
2028
2029/* EGL only (no OSMesa nor normal OPENGL) */
2030#elif defined(RGFW_EGL)
2031
2032#include <EGL/egl.h>
2033
2034#if defined(RGFW_LINK_EGL)
2035 typedef EGLBoolean(EGLAPIENTRY* PFN_eglInitialize)(EGLDisplay, EGLint*, EGLint*);
2036
2037 PFNEGLINITIALIZEPROC eglInitializeSource;
2038 PFNEGLGETCONFIGSPROC eglGetConfigsSource;
2039 PFNEGLCHOOSECONFIGPROC eglChooseConfigSource;
2040 PFNEGLCREATEWINDOWSURFACEPROC eglCreateWindowSurfaceSource;
2041 PFNEGLCREATECONTEXTPROC eglCreateContextSource;
2042 PFNEGLMAKECURRENTPROC eglMakeCurrentSource;
2043 PFNEGLGETDISPLAYPROC eglGetDisplaySource;
2044 PFNEGLSWAPBUFFERSPROC eglSwapBuffersSource;
2045 PFNEGLSWAPINTERVALPROC eglSwapIntervalSource;
2046 PFNEGLBINDAPIPROC eglBindAPISource;
2047 PFNEGLDESTROYCONTEXTPROC eglDestroyContextSource;
2048 PFNEGLTERMINATEPROC eglTerminateSource;
2049 PFNEGLDESTROYSURFACEPROC eglDestroySurfaceSource;
2050
2051#define eglInitialize eglInitializeSource
2052#define eglGetConfigs eglGetConfigsSource
2053#define eglChooseConfig eglChooseConfigSource
2054#define eglCreateWindowSurface eglCreateWindowSurfaceSource
2055#define eglCreateContext eglCreateContextSource
2056#define eglMakeCurrent eglMakeCurrentSource
2057#define eglGetDisplay eglGetDisplaySource
2058#define eglSwapBuffers eglSwapBuffersSource
2059#define eglSwapInterval eglSwapIntervalSource
2060#define eglBindAPI eglBindAPISource
2061#define eglDestroyContext eglDestroyContextSource
2062#define eglTerminate eglTerminateSource
2063#define eglDestroySurface eglDestroySurfaceSource;
2064#endif
2065
2066
2067#define EGL_SURFACE_MAJOR_VERSION_KHR 0x3098
2068#define EGL_SURFACE_MINOR_VERSION_KHR 0x30fb
2069
2070#ifndef RGFW_GL_ADD_ATTRIB
2071#define RGFW_GL_ADD_ATTRIB(attrib, attVal) \
2072 if (attVal) { \
2073 attribs[index] = attrib;\
2074 attribs[index + 1] = attVal;\
2075 index += 2;\
2076 }
2077#endif
2078
2079
2080 void RGFW_createOpenGLContext(RGFW_window* win) {
2081#if defined(RGFW_LINK_EGL)
2082 eglInitializeSource = (PFNEGLINITIALIZEPROC) eglGetProcAddress("eglInitialize");
2083 eglGetConfigsSource = (PFNEGLGETCONFIGSPROC) eglGetProcAddress("eglGetConfigs");
2084 eglChooseConfigSource = (PFNEGLCHOOSECONFIGPROC) eglGetProcAddress("eglChooseConfig");
2085 eglCreateWindowSurfaceSource = (PFNEGLCREATEWINDOWSURFACEPROC) eglGetProcAddress("eglCreateWindowSurface");
2086 eglCreateContextSource = (PFNEGLCREATECONTEXTPROC) eglGetProcAddress("eglCreateContext");
2087 eglMakeCurrentSource = (PFNEGLMAKECURRENTPROC) eglGetProcAddress("eglMakeCurrent");
2088 eglGetDisplaySource = (PFNEGLGETDISPLAYPROC) eglGetProcAddress("eglGetDisplay");
2089 eglSwapBuffersSource = (PFNEGLSWAPBUFFERSPROC) eglGetProcAddress("eglSwapBuffers");
2090 eglSwapIntervalSource = (PFNEGLSWAPINTERVALPROC) eglGetProcAddress("eglSwapInterval");
2091 eglBindAPISource = (PFNEGLBINDAPIPROC) eglGetProcAddress("eglBindAPI");
2092 eglDestroyContextSource = (PFNEGLDESTROYCONTEXTPROC) eglGetProcAddress("eglDestroyContext");
2093 eglTerminateSource = (PFNEGLTERMINATEPROC) eglGetProcAddress("eglTerminate");
2094 eglDestroySurfaceSource = (PFNEGLDESTROYSURFACEPROC) eglGetProcAddress("eglDestroySurface");
2095#endif /* RGFW_LINK_EGL */
2096
2097 #ifdef RGFW_WINDOWS
2098 win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType) win->src.hdc);
2099 #elif defined(RGFW_MACOS)
2100 win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType)0);
2101 #else
2102 win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType) win->src.display);
2103 #endif
2104
2105 EGLint major, minor;
2106
2107 eglInitialize(win->src.EGL_display, &major, &minor);
2108
2109 #ifndef EGL_OPENGL_ES1_BIT
2110 #define EGL_OPENGL_ES1_BIT 0x1
2111 #endif
2112
2113 EGLint egl_config[] = {
2114 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
2115 EGL_RENDERABLE_TYPE,
2116 #ifdef RGFW_OPENGL_ES1
2117 EGL_OPENGL_ES1_BIT,
2118 #elif defined(RGFW_OPENGL_ES3)
2119 EGL_OPENGL_ES3_BIT,
2120 #elif defined(RGFW_OPENGL_ES2)
2121 EGL_OPENGL_ES2_BIT,
2122 #else
2123 EGL_OPENGL_BIT,
2124 #endif
2125 EGL_NONE, EGL_NONE
2126 };
2127
2128 EGLConfig config;
2129 EGLint numConfigs;
2130 eglChooseConfig(win->src.EGL_display, egl_config, &config, 1, &numConfigs);
2131
2132 #if defined(RGFW_MACOS)
2133 void* layer = RGFW_cocoaGetLayer();
2134
2135 RGFW_window_cocoaSetLayer(win, layer);
2136
2137 win->src.EGL_surface = eglCreateWindowSurface(win->src.EGL_display, config, (EGLNativeWindowType) layer, NULL);
2138 #else
2139 win->src.EGL_surface = eglCreateWindowSurface(win->src.EGL_display, config, (EGLNativeWindowType) win->src.window, NULL);
2140 #endif
2141
2142 EGLint attribs[] = {
2143 EGL_CONTEXT_CLIENT_VERSION,
2144 #ifdef RGFW_OPENGL_ES1
2145 1,
2146 #else
2147 2,
2148 #endif
2149 EGL_NONE, EGL_NONE, EGL_NONE, EGL_NONE, EGL_NONE, EGL_NONE, EGL_NONE, EGL_NONE, EGL_NONE
2150 };
2151
2152 size_t index = 4;
2153 RGFW_GL_ADD_ATTRIB(EGL_STENCIL_SIZE, RGFW_STENCIL);
2154 RGFW_GL_ADD_ATTRIB(EGL_SAMPLES, RGFW_SAMPLES);
2155
2156 if (RGFW_DOUBLE_BUFFER)
2157 RGFW_GL_ADD_ATTRIB(EGL_RENDER_BUFFER, EGL_BACK_BUFFER);
2158
2159 if (RGFW_majorVersion) {
2160 attribs[1] = RGFW_majorVersion;
2161
2162 RGFW_GL_ADD_ATTRIB(EGL_CONTEXT_MAJOR_VERSION, RGFW_majorVersion);
2163 RGFW_GL_ADD_ATTRIB(EGL_CONTEXT_MINOR_VERSION, RGFW_minorVersion);
2164
2165 if (RGFW_profile == RGFW_GL_CORE) {
2166 RGFW_GL_ADD_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT);
2167 }
2168 else {
2169 RGFW_GL_ADD_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT);
2170 }
2171
2172 }
2173
2174 #if defined(RGFW_OPENGL_ES1) || defined(RGFW_OPENGL_ES2) || defined(RGFW_OPENGL_ES3)
2175 eglBindAPI(EGL_OPENGL_ES_API);
2176 #else
2177 eglBindAPI(EGL_OPENGL_API);
2178 #endif
2179
2180 win->src.EGL_context = eglCreateContext(win->src.EGL_display, config, EGL_NO_CONTEXT, attribs);
2181
2182 if (win->src.EGL_context == NULL)
2183 fprintf(stderr, "failed to create an EGL opengl context\n");
2184
2185 eglMakeCurrent(win->src.EGL_display, win->src.EGL_surface, win->src.EGL_surface, win->src.EGL_context);
2186 eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface);
2187 }
2188
2189 void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
2190 eglMakeCurrent(win->src.EGL_display, win->src.EGL_surface, win->src.EGL_surface, win->src.EGL_context);
2191 }
2192
2193 #ifdef RGFW_APPLE
2194 void* RGFWnsglFramework = NULL;
2195 #elif defined(RGFW_WINDOWS)
2196 static HMODULE wglinstance = NULL;
2197 #endif
2198
2199 void* RGFW_getProcAddress(const char* procname) {
2200 #if defined(RGFW_WINDOWS)
2201 void* proc = (void*) GetProcAddress(wglinstance, procname);
2202
2203 if (proc)
2204 return proc;
2205 #endif
2206
2207 return (void*) eglGetProcAddress(procname);
2208 }
2209
2210 void RGFW_closeEGL(RGFW_window* win) {
2211 eglDestroySurface(win->src.EGL_display, win->src.EGL_surface);
2212 eglDestroyContext(win->src.EGL_display, win->src.EGL_context);
2213
2214 eglTerminate(win->src.EGL_display);
2215 }
2216
2217 void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) {
2218 assert(win != NULL);
2219
2220 eglSwapInterval(win->src.EGL_display, swapInterval);
2221
2222 }
2223#endif /* RGFW_EGL */
2224
2225/*
2226 end of RGFW_EGL defines
2227*/
2228
2229/* OPENGL Normal / EGL defines only (no OS MESA) Ends here */
2230
2231#elif defined(RGFW_OSMESA) /* OSmesa only */
2232RGFWDEF void RGFW_OSMesa_reorganize(void);
2233
2234/* reorganize buffer for osmesa */
2235void RGFW_OSMesa_reorganize(void) {
2236 u8* row = (u8*) RGFW_MALLOC(win->r.w * 3);
2237
2238 i32 half_height = win->r.h / 2;
2239 i32 stride = win->r.w * 3;
2240
2241 i32 y;
2242 for (y = 0; y < half_height; ++y) {
2243 i32 top_offset = y * stride;
2244 i32 bottom_offset = (win->r.h - y - 1) * stride;
2245 memcpy(row, win->buffer + top_offset, stride);
2246 memcpy(win->buffer + top_offset, win->buffer + bottom_offset, stride);
2247 memcpy(win->buffer + bottom_offset, row, stride);
2248 }
2249
2250 RGFW_FREE(row);
2251}
2252#endif /* RGFW_OSMesa */
2253
2254#endif /* RGFW_GL (OpenGL, EGL, OSMesa )*/
2255
2256/*
2257This is where OS specific stuff starts
2258*/
2259
2260
2261#if defined(RGFW_WAYLAND) || defined(RGFW_X11)
2262 int RGFW_eventWait_forceStop[] = {0, 0, 0}; /* for wait events */
2263
2264 #ifdef __linux__
2265 #include <linux/joystick.h>
2266 #include <fcntl.h>
2267 #include <unistd.h>
2268
2269 RGFW_Event* RGFW_linux_updateJoystick(RGFW_window* win) {
2270 static int xAxis = 0, yAxis = 0;
2271 u8 i;
2272 for (i = 0; i < RGFW_joystickCount; i++) {
2273 struct js_event e;
2274
2275
2276 if (RGFW_joysticks[i] == 0)
2277 continue;
2278
2279 i32 flags = fcntl(RGFW_joysticks[i], F_GETFL, 0);
2280 fcntl(RGFW_joysticks[i], F_SETFL, flags | O_NONBLOCK);
2281
2282 ssize_t bytes;
2283 while ((bytes = read(RGFW_joysticks[i], &e, sizeof(e))) > 0) {
2284 switch (e.type) {
2285 case JS_EVENT_BUTTON:
2286 win->event.type = e.value ? RGFW_jsButtonPressed : RGFW_jsButtonReleased;
2287 win->event.button = e.number;
2288 RGFW_jsPressed[i][e.number] = e.value;
2289 RGFW_jsButtonCallback(win, i, e.number, e.value);
2290 return &win->event;
2291 case JS_EVENT_AXIS:
2292 ioctl(RGFW_joysticks[i], JSIOCGAXES, &win->event.axisesCount);
2293
2294 if ((e.number == 0 || e.number % 2) && e.number != 1)
2295 xAxis = e.value;
2296 else
2297 yAxis = e.value;
2298
2299 win->event.axis[e.number / 2].x = xAxis;
2300 win->event.axis[e.number / 2].y = yAxis;
2301 win->event.type = RGFW_jsAxisMove;
2302 win->event.joystick = i;
2303 RGFW_jsAxisCallback(win, i, win->event.axis, win->event.axisesCount);
2304 return &win->event;
2305
2306 default: break;
2307 }
2308 }
2309 }
2310
2311 return NULL;
2312 }
2313
2314 #endif
2315#endif
2316
2317/*
2318
2319
2320Start of Linux / Unix defines
2321
2322
2323*/
2324
2325#ifdef RGFW_X11
2326#ifndef RGFW_NO_X11_CURSOR
2327#include <X11/Xcursor/Xcursor.h>
2328#endif
2329#include <dlfcn.h>
2330
2331#ifndef RGFW_NO_DPI
2332#include <X11/extensions/Xrandr.h>
2333#include <X11/Xresource.h>
2334#endif
2335
2336#include <X11/Xutil.h>
2337#include <X11/Xatom.h>
2338#include <X11/keysymdef.h>
2339#include <unistd.h>
2340
2341#include <X11/XKBlib.h> /* for converting keycode to string */
2342#include <X11/cursorfont.h> /* for hiding */
2343#include <X11/extensions/shapeconst.h>
2344#include <X11/extensions/shape.h>
2345#include <X11/extensions/XInput2.h>
2346
2347#include <limits.h> /* for data limits (mainly used in drag and drop functions) */
2348#include <poll.h>
2349
2350
2351#ifdef __linux__
2352#include <linux/joystick.h>
2353#endif
2354
2355 u8 RGFW_mouseIconSrc[] = { XC_arrow, XC_left_ptr, XC_xterm, XC_crosshair, XC_hand2, XC_sb_h_double_arrow, XC_sb_v_double_arrow, XC_bottom_left_corner, XC_bottom_right_corner, XC_fleur, XC_X_cursor};
2356 /*atoms needed for drag and drop*/
2357 Atom XdndAware, XdndTypeList, XdndSelection, XdndEnter, XdndPosition, XdndStatus, XdndLeave, XdndDrop, XdndFinished, XdndActionCopy, XtextPlain, XtextUriList;
2358
2359 Atom wm_delete_window = 0;
2360
2361#if !defined(RGFW_NO_X11_CURSOR) && !defined(RGFW_NO_X11_CURSOR_PRELOAD)
2362 typedef XcursorImage* (*PFN_XcursorImageCreate)(int, int);
2363 typedef void (*PFN_XcursorImageDestroy)(XcursorImage*);
2364 typedef Cursor(*PFN_XcursorImageLoadCursor)(Display*, const XcursorImage*);
2365#endif
2366#ifdef RGFW_OPENGL
2367 typedef GLXContext(*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
2368#endif
2369
2370#if !defined(RGFW_NO_X11_XI_PRELOAD)
2371 typedef int (* PFN_XISelectEvents)(Display*,Window,XIEventMask*,int);
2372 PFN_XISelectEvents XISelectEventsSrc = NULL;
2373 #define XISelectEvents XISelectEventsSrc
2374
2375 void* X11Xihandle = NULL;
2376#endif
2377
2378#if !defined(RGFW_NO_X11_CURSOR) && !defined(RGFW_NO_X11_CURSOR_PRELOAD)
2379 PFN_XcursorImageLoadCursor XcursorImageLoadCursorSrc = NULL;
2380 PFN_XcursorImageCreate XcursorImageCreateSrc = NULL;
2381 PFN_XcursorImageDestroy XcursorImageDestroySrc = NULL;
2382
2383#define XcursorImageLoadCursor XcursorImageLoadCursorSrc
2384#define XcursorImageCreate XcursorImageCreateSrc
2385#define XcursorImageDestroy XcursorImageDestroySrc
2386
2387 void* X11Cursorhandle = NULL;
2388#endif
2389
2390 u32 RGFW_windowsOpen = 0;
2391
2392#ifdef RGFW_OPENGL
2393 void* RGFW_getProcAddress(const char* procname) { return (void*) glXGetProcAddress((GLubyte*) procname); }
2394#endif
2395
2396 RGFWDEF void RGFW_init_buffer(RGFW_window* win, XVisualInfo* vi);
2397 void RGFW_init_buffer(RGFW_window* win, XVisualInfo* vi) {
2398#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
2399 if (RGFW_bufferSize.w == 0 && RGFW_bufferSize.h == 0)
2400 RGFW_bufferSize = RGFW_getScreenSize();
2401
2402 win->buffer = (u8*)RGFW_MALLOC(RGFW_bufferSize.w * RGFW_bufferSize.h * 4);
2403
2404 #ifdef RGFW_OSMESA
2405 win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
2406 OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h);
2407 #endif
2408
2409 win->src.bitmap = XCreateImage(
2410 win->src.display, XDefaultVisual(win->src.display, vi->screen),
2411 vi->depth,
2412 ZPixmap, 0, NULL, RGFW_bufferSize.w, RGFW_bufferSize.h,
2413 32, 0
2414 );
2415
2416 win->src.gc = XCreateGC(win->src.display, win->src.window, 0, NULL);
2417
2418 #else
2419 RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
2420 RGFW_UNUSED(vi)
2421 #endif
2422 }
2423
2424
2425
2426 void RGFW_window_setBorder(RGFW_window* win, u8 border) {
2427 static Atom _MOTIF_WM_HINTS = 0;
2428 if (_MOTIF_WM_HINTS == 0 )
2429 _MOTIF_WM_HINTS = XInternAtom(win->src.display, "_MOTIF_WM_HINTS", False);
2430
2431 struct __x11WindowHints {
2432 unsigned long flags, functions, decorations, status;
2433 long input_mode;
2434 } hints;
2435 hints.flags = (1L << 1);
2436 hints.decorations = border;
2437
2438 XChangeProperty(
2439 win->src.display, win->src.window,
2440 _MOTIF_WM_HINTS, _MOTIF_WM_HINTS,
2441 32, PropModeReplace, (u8*)&hints, 5
2442 );
2443 }
2444
2445 void RGFW_releaseCursor(RGFW_window* win) {
2446 XUngrabPointer(win->src.display, CurrentTime);
2447
2448 /* disable raw input */
2449 unsigned char mask[] = { 0 };
2450 XIEventMask em;
2451 em.deviceid = XIAllMasterDevices;
2452 em.mask_len = sizeof(mask);
2453 em.mask = mask;
2454
2455 XISelectEvents(win->src.display, XDefaultRootWindow(win->src.display), &em, 1);
2456 }
2457
2458 void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) {
2459 /* enable raw input */
2460 unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 };
2461 XISetMask(mask, XI_RawMotion);
2462
2463 XIEventMask em;
2464 em.deviceid = XIAllMasterDevices;
2465 em.mask_len = sizeof(mask);
2466 em.mask = mask;
2467
2468 XISelectEvents(win->src.display, XDefaultRootWindow(win->src.display), &em, 1);
2469
2470 XGrabPointer(win->src.display, win->src.window, True, PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
2471
2472 RGFW_window_moveMouse(win, RGFW_POINT(win->r.x + (i32)(r.w / 2), win->r.y + (i32)(r.h / 2)));
2473 }
2474
2475 RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
2476#if !defined(RGFW_NO_X11_CURSOR) && !defined(RGFW_NO_X11_CURSOR_PRELOAD)
2477 if (X11Cursorhandle == NULL) {
2478#if defined(__CYGWIN__)
2479 X11Cursorhandle = dlopen("libXcursor-1.so", RTLD_LAZY | RTLD_LOCAL);
2480#elif defined(__OpenBSD__) || defined(__NetBSD__)
2481 X11Cursorhandle = dlopen("libXcursor.so", RTLD_LAZY | RTLD_LOCAL);
2482#else
2483 X11Cursorhandle = dlopen("libXcursor.so.1", RTLD_LAZY | RTLD_LOCAL);
2484#endif
2485
2486 XcursorImageCreateSrc = (PFN_XcursorImageCreate) dlsym(X11Cursorhandle, "XcursorImageCreate");
2487 XcursorImageDestroySrc = (PFN_XcursorImageDestroy) dlsym(X11Cursorhandle, "XcursorImageDestroy");
2488 XcursorImageLoadCursorSrc = (PFN_XcursorImageLoadCursor) dlsym(X11Cursorhandle, "XcursorImageLoadCursor");
2489 }
2490#endif
2491
2492#if !defined(RGFW_NO_X11_XI_PRELOAD)
2493 if (X11Xihandle == NULL) {
2494#if defined(__CYGWIN__)
2495 X11Xihandle = dlopen("libXi-6.so", RTLD_LAZY | RTLD_LOCAL);
2496#elif defined(__OpenBSD__) || defined(__NetBSD__)
2497 X11Xihandle = dlopen("libXi.so", RTLD_LAZY | RTLD_LOCAL);
2498#else
2499 X11Xihandle = dlopen("libXi.so.6", RTLD_LAZY | RTLD_LOCAL);
2500#endif
2501
2502 XISelectEventsSrc = (PFN_XISelectEvents) dlsym(X11Xihandle, "XISelectEvents");
2503 }
2504#endif
2505
2506 XInitThreads(); /*!< init X11 threading*/
2507
2508 if (args & RGFW_OPENGL_SOFTWARE)
2509 setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);
2510
2511 RGFW_window* win = RGFW_window_basic_init(rect, args);
2512
2513 u64 event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask | FocusChangeMask | LeaveWindowMask | EnterWindowMask | ExposureMask; /*!< X11 events accepted*/
2514
2515#ifdef RGFW_OPENGL
2516 u32* visual_attribs = RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE);
2517 i32 fbcount;
2518 GLXFBConfig* fbc = glXChooseFBConfig((Display*) win->src.display, DefaultScreen(win->src.display), (i32*) visual_attribs, &fbcount);
2519
2520 i32 best_fbc = -1;
2521
2522 if (fbcount == 0) {
2523 printf("Failed to find any valid GLX visual configs\n");
2524 return NULL;
2525 }
2526
2527 u32 i;
2528 for (i = 0; i < (u32)fbcount; i++) {
2529 XVisualInfo* vi = glXGetVisualFromFBConfig((Display*) win->src.display, fbc[i]);
2530 if (vi == NULL)
2531 continue;
2532
2533 XFree(vi);
2534
2535 i32 samp_buf, samples;
2536 glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
2537 glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLES, &samples);
2538
2539 if ((!(args & RGFW_TRANSPARENT_WINDOW) || vi->depth == 32) &&
2540 (best_fbc < 0 || samp_buf) && (samples == RGFW_SAMPLES || best_fbc == -1)) {
2541 best_fbc = i;
2542 }
2543 }
2544
2545 if (best_fbc == -1) {
2546 printf("Failed to get a valid GLX visual\n");
2547 return NULL;
2548 }
2549
2550 GLXFBConfig bestFbc = fbc[best_fbc];
2551
2552 /* Get a visual */
2553 XVisualInfo* vi = glXGetVisualFromFBConfig((Display*) win->src.display, bestFbc);
2554
2555 XFree(fbc);
2556#else
2557 XVisualInfo viNorm;
2558
2559 viNorm.visual = DefaultVisual((Display*) win->src.display, DefaultScreen((Display*) win->src.display));
2560
2561 viNorm.depth = 0;
2562 XVisualInfo* vi = &viNorm;
2563
2564 XMatchVisualInfo((Display*) win->src.display, DefaultScreen((Display*) win->src.display), 32, TrueColor, vi); /*!< for RGBA backgrounds*/
2565#endif
2566 /* make X window attrubutes*/
2567 XSetWindowAttributes swa;
2568 Colormap cmap;
2569
2570 swa.colormap = cmap = XCreateColormap((Display*) win->src.display,
2571 DefaultRootWindow(win->src.display),
2572 vi->visual, AllocNone);
2573
2574 swa.background_pixmap = None;
2575 swa.border_pixel = 0;
2576 swa.event_mask = event_mask;
2577
2578 swa.background_pixel = 0;
2579
2580 /* create the window*/
2581 win->src.window = XCreateWindow((Display*) win->src.display, DefaultRootWindow((Display*) win->src.display), win->r.x, win->r.y, win->r.w, win->r.h,
2582 0, vi->depth, InputOutput, vi->visual,
2583 CWColormap | CWBorderPixel | CWBackPixel | CWEventMask, &swa);
2584
2585 XFreeColors((Display*) win->src.display, cmap, NULL, 0, 0);
2586
2587 #ifdef RGFW_OPENGL
2588 XFree(vi);
2589 #endif
2590
2591 // In your .desktop app, if you set the property
2592 // StartupWMClass=RGFW that will assoicate the launcher icon
2593 // with your application - robrohan
2594
2595 if (RGFW_className == NULL)
2596 RGFW_className = (char*)name;
2597
2598 XClassHint *hint = XAllocClassHint();
2599 assert(hint != NULL);
2600 hint->res_class = (char*)RGFW_className;
2601 hint->res_name = (char*)name; // just use the window name as the app name
2602 XSetClassHint((Display*) win->src.display, win->src.window, hint);
2603 XFree(hint);
2604
2605 if ((args & RGFW_NO_INIT_API) == 0) {
2606#ifdef RGFW_OPENGL /* This is the second part of setting up opengl. This is where we ask OpenGL for a specific version. */
2607 i32 context_attribs[7] = { 0, 0, 0, 0, 0, 0, 0 };
2608 context_attribs[0] = GLX_CONTEXT_PROFILE_MASK_ARB;
2609 if (RGFW_profile == RGFW_GL_CORE)
2610 context_attribs[1] = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
2611 else
2612 context_attribs[1] = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
2613
2614 if (RGFW_majorVersion || RGFW_minorVersion) {
2615 context_attribs[2] = GLX_CONTEXT_MAJOR_VERSION_ARB;
2616 context_attribs[3] = RGFW_majorVersion;
2617 context_attribs[4] = GLX_CONTEXT_MINOR_VERSION_ARB;
2618 context_attribs[5] = RGFW_minorVersion;
2619 }
2620
2621 glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
2622 glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)
2623 glXGetProcAddressARB((GLubyte*) "glXCreateContextAttribsARB");
2624
2625 GLXContext ctx = NULL;
2626
2627 if (RGFW_root != NULL)
2628 ctx = RGFW_root->src.ctx;
2629
2630 win->src.ctx = glXCreateContextAttribsARB((Display*) win->src.display, bestFbc, ctx, True, context_attribs);
2631#endif
2632 if (RGFW_root == NULL)
2633 RGFW_root = win;
2634
2635 RGFW_init_buffer(win, vi);
2636 }
2637
2638
2639 #ifndef RGFW_NO_MONITOR
2640 if (args & RGFW_SCALE_TO_MONITOR)
2641 RGFW_window_scaleToMonitor(win);
2642 #endif
2643
2644 if (args & RGFW_CENTER) {
2645 RGFW_area screenR = RGFW_getScreenSize();
2646 RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
2647 }
2648
2649 if (args & RGFW_NO_RESIZE) { /* make it so the user can't resize the window*/
2650 XSizeHints* sh = XAllocSizeHints();
2651 sh->flags = (1L << 4) | (1L << 5);
2652 sh->min_width = sh->max_width = win->r.w;
2653 sh->min_height = sh->max_height = win->r.h;
2654
2655 XSetWMSizeHints((Display*) win->src.display, (Drawable) win->src.window, sh, XA_WM_NORMAL_HINTS);
2656 XFree(sh);
2657 }
2658
2659 if (args & RGFW_NO_BORDER) {
2660 RGFW_window_setBorder(win, 0);
2661 }
2662
2663 XSelectInput((Display*) win->src.display, (Drawable) win->src.window, event_mask); /*!< tell X11 what events we want*/
2664
2665 /* make it so the user can't close the window until the program does*/
2666 if (wm_delete_window == 0)
2667 wm_delete_window = XInternAtom((Display*) win->src.display, "WM_DELETE_WINDOW", False);
2668
2669 XSetWMProtocols((Display*) win->src.display, (Drawable) win->src.window, &wm_delete_window, 1);
2670
2671 /* connect the context to the window*/
2672#ifdef RGFW_OPENGL
2673 if ((args & RGFW_NO_INIT_API) == 0)
2674 glXMakeCurrent((Display*) win->src.display, (Drawable) win->src.window, (GLXContext) win->src.ctx);
2675#endif
2676
2677 /* set the background*/
2678 XStoreName((Display*) win->src.display, (Drawable) win->src.window, name); /*!< set the name*/
2679
2680 XMapWindow((Display*) win->src.display, (Drawable) win->src.window); /* draw the window*/
2681 XMoveWindow((Display*) win->src.display, (Drawable) win->src.window, win->r.x, win->r.y); /*!< move the window to it's proper cords*/
2682
2683 if (args & RGFW_ALLOW_DND) { /* init drag and drop atoms and turn on drag and drop for this window */
2684 win->_winArgs |= RGFW_ALLOW_DND;
2685
2686 XdndTypeList = XInternAtom((Display*) win->src.display, "XdndTypeList", False);
2687 XdndSelection = XInternAtom((Display*) win->src.display, "XdndSelection", False);
2688
2689 /* client messages */
2690 XdndEnter = XInternAtom((Display*) win->src.display, "XdndEnter", False);
2691 XdndPosition = XInternAtom((Display*) win->src.display, "XdndPosition", False);
2692 XdndStatus = XInternAtom((Display*) win->src.display, "XdndStatus", False);
2693 XdndLeave = XInternAtom((Display*) win->src.display, "XdndLeave", False);
2694 XdndDrop = XInternAtom((Display*) win->src.display, "XdndDrop", False);
2695 XdndFinished = XInternAtom((Display*) win->src.display, "XdndFinished", False);
2696
2697 /* actions */
2698 XdndActionCopy = XInternAtom((Display*) win->src.display, "XdndActionCopy", False);
2699
2700 XtextUriList = XInternAtom((Display*) win->src.display, "text/uri-list", False);
2701 XtextPlain = XInternAtom((Display*) win->src.display, "text/plain", False);
2702
2703 XdndAware = XInternAtom((Display*) win->src.display, "XdndAware", False);
2704 const u8 version = 5;
2705
2706 XChangeProperty((Display*) win->src.display, (Window) win->src.window,
2707 XdndAware, 4, 32,
2708 PropModeReplace, &version, 1); /*!< turns on drag and drop */
2709 }
2710
2711 #ifdef RGFW_EGL
2712 if ((args & RGFW_NO_INIT_API) == 0)
2713 RGFW_createOpenGLContext(win);
2714 #endif
2715
2716 RGFW_window_setMouseDefault(win);
2717
2718 RGFW_windowsOpen++;
2719
2720 return win; /*return newly created window*/
2721 }
2722
2723 RGFW_area RGFW_getScreenSize(void) {
2724 assert(RGFW_root != NULL);
2725
2726 Screen* scrn = DefaultScreenOfDisplay((Display*) RGFW_root->src.display);
2727 return RGFW_AREA(scrn->width, scrn->height);
2728 }
2729
2730 RGFW_point RGFW_getGlobalMousePoint(void) {
2731 assert(RGFW_root != NULL);
2732
2733 RGFW_point RGFWMouse;
2734
2735 i32 x, y;
2736 u32 z;
2737 Window window1, window2;
2738 XQueryPointer((Display*) RGFW_root->src.display, XDefaultRootWindow((Display*) RGFW_root->src.display), &window1, &window2, &RGFWMouse.x, &RGFWMouse.y, &x, &y, &z);
2739
2740 return RGFWMouse;
2741 }
2742
2743 RGFW_point RGFW_window_getMousePoint(RGFW_window* win) {
2744 assert(win != NULL);
2745
2746 RGFW_point RGFWMouse;
2747
2748 i32 x, y;
2749 u32 z;
2750 Window window1, window2;
2751 XQueryPointer((Display*) win->src.display, win->src.window, &window1, &window2, &x, &y, &RGFWMouse.x, &RGFWMouse.y, &z);
2752
2753 return RGFWMouse;
2754 }
2755
2756 int xAxis = 0, yAxis = 0;
2757
2758 RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
2759 assert(win != NULL);
2760
2761 static struct {
2762 long source, version;
2763 i32 format;
2764 } xdnd;
2765
2766 if (win->event.type == 0)
2767 RGFW_resetKey();
2768
2769 if (win->event.type == RGFW_quit) {
2770 return NULL;
2771 }
2772
2773 win->event.type = 0;
2774
2775#ifdef __linux__
2776 RGFW_Event* event = RGFW_linux_updateJoystick(win);
2777 if (event != NULL)
2778 return event;
2779#endif
2780
2781 XPending(win->src.display);
2782
2783 XEvent E; /*!< raw X11 event */
2784
2785 /* if there is no unread qued events, get a new one */
2786 if ((QLength(win->src.display) || XEventsQueued((Display*) win->src.display, QueuedAlready) + XEventsQueued((Display*) win->src.display, QueuedAfterReading))
2787 && win->event.type != RGFW_quit
2788 )
2789 XNextEvent((Display*) win->src.display, &E);
2790 else {
2791 return NULL;
2792 }
2793
2794 u32 i;
2795 win->event.type = 0;
2796
2797
2798 switch (E.type) {
2799 case KeyPress:
2800 case KeyRelease: {
2801 win->event.repeat = RGFW_FALSE;
2802 /* check if it's a real key release */
2803 if (E.type == KeyRelease && XEventsQueued((Display*) win->src.display, QueuedAfterReading)) { /* get next event if there is one*/
2804 XEvent NE;
2805 XPeekEvent((Display*) win->src.display, &NE);
2806
2807 if (E.xkey.time == NE.xkey.time && E.xkey.keycode == NE.xkey.keycode) /* check if the current and next are both the same*/
2808 win->event.repeat = RGFW_TRUE;
2809 }
2810
2811 /* set event key data */
2812 KeySym sym = (KeySym)XkbKeycodeToKeysym((Display*) win->src.display, E.xkey.keycode, 0, E.xkey.state & ShiftMask ? 1 : 0);
2813 win->event.keyCode = RGFW_apiKeyCodeToRGFW(E.xkey.keycode);
2814
2815 char* str = (char*)XKeysymToString(sym);
2816 if (str != NULL)
2817 strncpy(win->event.keyName, str, 16);
2818
2819 win->event.keyName[15] = '\0';
2820
2821 RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode);
2822
2823 /* get keystate data */
2824 win->event.type = (E.type == KeyPress) ? RGFW_keyPressed : RGFW_keyReleased;
2825
2826 XKeyboardState keystate;
2827 XGetKeyboardControl((Display*) win->src.display, &keystate);
2828
2829 RGFW_updateLockState(win, (keystate.led_mask & 1), (keystate.led_mask & 2));
2830 RGFW_keyboard[win->event.keyCode].current = (E.type == KeyPress);
2831 RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, (E.type == KeyPress));
2832 break;
2833 }
2834 case ButtonPress:
2835 case ButtonRelease:
2836 win->event.type = RGFW_mouseButtonPressed + (E.type == ButtonRelease); // the events match
2837
2838 switch(win->event.button) {
2839 case RGFW_mouseScrollUp:
2840 win->event.scroll = 1;
2841 break;
2842 case RGFW_mouseScrollDown:
2843 win->event.scroll = -1;
2844 break;
2845 default: break;
2846 }
2847
2848 win->event.button = E.xbutton.button;
2849 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
2850
2851 if (win->event.repeat == RGFW_FALSE)
2852 win->event.repeat = RGFW_isPressed(win, win->event.keyCode);
2853
2854 RGFW_mouseButtons[win->event.button].current = (E.type == ButtonPress);
2855 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, (E.type == ButtonPress));
2856 break;
2857
2858 case MotionNotify:
2859 win->event.point.x = E.xmotion.x;
2860 win->event.point.y = E.xmotion.y;
2861
2862 if ((win->_winArgs & RGFW_HOLD_MOUSE)) {
2863 win->event.point.y = E.xmotion.y;
2864
2865 win->event.point.x = win->_lastMousePoint.x - abs(win->event.point.x);
2866 win->event.point.y = win->_lastMousePoint.y - abs(win->event.point.y);
2867 }
2868
2869 win->_lastMousePoint = RGFW_POINT(E.xmotion.x, E.xmotion.y);
2870
2871 win->event.type = RGFW_mousePosChanged;
2872 RGFW_mousePosCallback(win, win->event.point);
2873 break;
2874
2875 case GenericEvent: {
2876 /* MotionNotify is used for mouse events if the mouse isn't held */
2877 if (!(win->_winArgs & RGFW_HOLD_MOUSE)) {
2878 XFreeEventData(win->src.display, &E.xcookie);
2879 break;
2880 }
2881
2882 XGetEventData(win->src.display, &E.xcookie);
2883 if (E.xcookie.evtype == XI_RawMotion) {
2884 XIRawEvent *raw = (XIRawEvent *)E.xcookie.data;
2885 if (raw->valuators.mask_len == 0) {
2886 XFreeEventData(win->src.display, &E.xcookie);
2887 break;
2888 }
2889
2890 double deltaX = 0.0f;
2891 double deltaY = 0.0f;
2892
2893 /* check if relative motion data exists where we think it does */
2894 if (XIMaskIsSet(raw->valuators.mask, 0) != 0)
2895 deltaX += raw->raw_values[0];
2896 if (XIMaskIsSet(raw->valuators.mask, 1) != 0)
2897 deltaY += raw->raw_values[1];
2898
2899 win->event.point = RGFW_POINT((i32)deltaX, (i32)deltaY);
2900
2901 RGFW_window_moveMouse(win, RGFW_POINT(win->r.x + (win->r.w / 2), win->r.y + (win->r.h / 2)));
2902
2903 win->event.type = RGFW_mousePosChanged;
2904 RGFW_mousePosCallback(win, win->event.point);
2905 }
2906
2907 XFreeEventData(win->src.display, &E.xcookie);
2908 break;
2909 }
2910
2911 case Expose:
2912 win->event.type = RGFW_windowRefresh;
2913 RGFW_windowRefreshCallback(win);
2914 break;
2915
2916 case ClientMessage:
2917 /* if the client closed the window*/
2918 if (E.xclient.data.l[0] == (i64) wm_delete_window) {
2919 win->event.type = RGFW_quit;
2920 RGFW_windowQuitCallback(win);
2921 break;
2922 }
2923
2924 /* reset DND values */
2925 if (win->event.droppedFilesCount) {
2926 for (i = 0; i < win->event.droppedFilesCount; i++)
2927 win->event.droppedFiles[i][0] = '\0';
2928 }
2929
2930 win->event.droppedFilesCount = 0;
2931
2932 if ((win->_winArgs & RGFW_ALLOW_DND) == 0)
2933 break;
2934
2935 XEvent reply = { ClientMessage };
2936 reply.xclient.window = xdnd.source;
2937 reply.xclient.format = 32;
2938 reply.xclient.data.l[0] = (long) win->src.window;
2939 reply.xclient.data.l[1] = 0;
2940 reply.xclient.data.l[2] = None;
2941
2942 if (E.xclient.message_type == XdndEnter) {
2943 unsigned long count;
2944 Atom* formats;
2945 Atom real_formats[6];
2946
2947 Bool list = E.xclient.data.l[1] & 1;
2948
2949 xdnd.source = E.xclient.data.l[0];
2950 xdnd.version = E.xclient.data.l[1] >> 24;
2951 xdnd.format = None;
2952
2953 if (xdnd.version > 5)
2954 break;
2955
2956 if (list) {
2957 Atom actualType;
2958 i32 actualFormat;
2959 unsigned long bytesAfter;
2960
2961 XGetWindowProperty((Display*) win->src.display,
2962 xdnd.source,
2963 XdndTypeList,
2964 0,
2965 LONG_MAX,
2966 False,
2967 4,
2968 &actualType,
2969 &actualFormat,
2970 &count,
2971 &bytesAfter,
2972 (u8**) &formats);
2973 } else {
2974 count = 0;
2975
2976 if (E.xclient.data.l[2] != None)
2977 real_formats[count++] = E.xclient.data.l[2];
2978 if (E.xclient.data.l[3] != None)
2979 real_formats[count++] = E.xclient.data.l[3];
2980 if (E.xclient.data.l[4] != None)
2981 real_formats[count++] = E.xclient.data.l[4];
2982
2983 formats = real_formats;
2984 }
2985
2986 unsigned long i;
2987 for (i = 0; i < count; i++) {
2988 if (formats[i] == XtextUriList || formats[i] == XtextPlain) {
2989 xdnd.format = formats[i];
2990 break;
2991 }
2992 }
2993
2994 if (list) {
2995 XFree(formats);
2996 }
2997
2998 break;
2999 }
3000 if (E.xclient.message_type == XdndPosition) {
3001 const i32 xabs = (E.xclient.data.l[2] >> 16) & 0xffff;
3002 const i32 yabs = (E.xclient.data.l[2]) & 0xffff;
3003 Window dummy;
3004 i32 xpos, ypos;
3005
3006 if (xdnd.version > 5)
3007 break;
3008
3009 XTranslateCoordinates((Display*) win->src.display,
3010 XDefaultRootWindow((Display*) win->src.display),
3011 (Window) win->src.window,
3012 xabs, yabs,
3013 &xpos, &ypos,
3014 &dummy);
3015
3016 win->event.point.x = xpos;
3017 win->event.point.y = ypos;
3018
3019 reply.xclient.window = xdnd.source;
3020 reply.xclient.message_type = XdndStatus;
3021
3022 if (xdnd.format) {
3023 reply.xclient.data.l[1] = 1;
3024 if (xdnd.version >= 2)
3025 reply.xclient.data.l[4] = XdndActionCopy;
3026 }
3027
3028 XSendEvent((Display*) win->src.display, xdnd.source, False, NoEventMask, &reply);
3029 XFlush((Display*) win->src.display);
3030 break;
3031 }
3032
3033 if (E.xclient.message_type != XdndDrop)
3034 break;
3035
3036 if (xdnd.version > 5)
3037 break;
3038
3039 win->event.type = RGFW_dnd_init;
3040
3041 if (xdnd.format) {
3042 Time time = CurrentTime;
3043
3044 if (xdnd.version >= 1)
3045 time = E.xclient.data.l[2];
3046
3047 XConvertSelection((Display*) win->src.display,
3048 XdndSelection,
3049 xdnd.format,
3050 XdndSelection,
3051 (Window) win->src.window,
3052 time);
3053 } else if (xdnd.version >= 2) {
3054 XEvent reply = { ClientMessage };
3055
3056 XSendEvent((Display*) win->src.display, xdnd.source,
3057 False, NoEventMask, &reply);
3058 XFlush((Display*) win->src.display);
3059 }
3060
3061 RGFW_dndInitCallback(win, win->event.point);
3062 break;
3063 case SelectionNotify: {
3064 /* this is only for checking for xdnd drops */
3065 if (E.xselection.property != XdndSelection || !(win->_winArgs | RGFW_ALLOW_DND))
3066 break;
3067
3068 char* data;
3069 unsigned long result;
3070
3071 Atom actualType;
3072 i32 actualFormat;
3073 unsigned long bytesAfter;
3074
3075 XGetWindowProperty((Display*) win->src.display, E.xselection.requestor, E.xselection.property, 0, LONG_MAX, False, E.xselection.target, &actualType, &actualFormat, &result, &bytesAfter, (u8**) &data);
3076
3077 if (result == 0)
3078 break;
3079
3080 /*
3081 SOURCED FROM GLFW _glfwParseUriList
3082 Copyright (c) 2002-2006 Marcus Geelnard
3083 Copyright (c) 2006-2019 Camilla Löwy
3084 */
3085
3086 const char* prefix = (const char*)"file://";
3087
3088 char* line;
3089
3090 win->event.droppedFilesCount = 0;
3091
3092 win->event.type = RGFW_dnd;
3093
3094 while ((line = strtok(data, "\r\n"))) {
3095 char path[RGFW_MAX_PATH];
3096
3097 data = NULL;
3098
3099 if (line[0] == '#')
3100 continue;
3101
3102 char* l;
3103 for (l = line; 1; l++) {
3104 if ((l - line) > 7)
3105 break;
3106 else if (*l != prefix[(l - line)])
3107 break;
3108 else if (*l == '\0' && prefix[(l - line)] == '\0') {
3109 line += 7;
3110 while (*line != '/')
3111 line++;
3112 break;
3113 } else if (*l == '\0')
3114 break;
3115 }
3116
3117 win->event.droppedFilesCount++;
3118
3119 size_t index = 0;
3120 while (*line) {
3121 if (line[0] == '%' && line[1] && line[2]) {
3122 const char digits[3] = { line[1], line[2], '\0' };
3123 path[index] = (char) strtol(digits, NULL, 16);
3124 line += 2;
3125 } else
3126 path[index] = *line;
3127
3128 index++;
3129 line++;
3130 }
3131 path[index] = '\0';
3132 strncpy(win->event.droppedFiles[win->event.droppedFilesCount - 1], path, index + 1);
3133 }
3134
3135 if (data)
3136 XFree(data);
3137
3138 if (xdnd.version >= 2) {
3139 reply.xclient.message_type = XdndFinished;
3140 reply.xclient.data.l[1] = result;
3141 reply.xclient.data.l[2] = XdndActionCopy;
3142
3143 XSendEvent((Display*) win->src.display, xdnd.source, False, NoEventMask, &reply);
3144 XFlush((Display*) win->src.display);
3145 }
3146
3147 RGFW_dndCallback(win, win->event.droppedFiles, win->event.droppedFilesCount);
3148 break;
3149 }
3150 case FocusIn:
3151 win->event.inFocus = 1;
3152 win->event.type = RGFW_focusIn;
3153 RGFW_focusCallback(win, 1);
3154 break;
3155
3156 break;
3157 case FocusOut:
3158 win->event.inFocus = 0;
3159 win->event.type = RGFW_focusOut;
3160 RGFW_focusCallback(win, 0);
3161 break;
3162
3163 case EnterNotify: {
3164 win->event.type = RGFW_mouseEnter;
3165 win->event.point.x = E.xcrossing.x;
3166 win->event.point.y = E.xcrossing.y;
3167 RGFW_mouseNotifyCallBack(win, win->event.point, 1);
3168 break;
3169 }
3170
3171 case LeaveNotify: {
3172 win->event.type = RGFW_mouseLeave;
3173 RGFW_mouseNotifyCallBack(win, win->event.point, 0);
3174 break;
3175 }
3176
3177 case ConfigureNotify: {
3178 /* detect resize */
3179 if (E.xconfigure.width != win->r.w || E.xconfigure.height != win->r.h) {
3180 win->event.type = RGFW_windowResized;
3181 win->r = RGFW_RECT(win->r.x, win->r.y, E.xconfigure.width, E.xconfigure.height);
3182 RGFW_windowResizeCallback(win, win->r);
3183 break;
3184 }
3185
3186 /* detect move */
3187 if (E.xconfigure.x != win->r.x || E.xconfigure.y != win->r.y) {
3188 win->event.type = RGFW_windowMoved;
3189 win->r = RGFW_RECT(E.xconfigure.x, E.xconfigure.y, win->r.w, win->r.h);
3190 RGFW_windowMoveCallback(win, win->r);
3191 break;
3192 }
3193
3194 break;
3195 }
3196 default: {
3197 break;
3198 }
3199 }
3200
3201 XFlush((Display*) win->src.display);
3202
3203 if (win->event.type)
3204 return &win->event;
3205 else
3206 return NULL;
3207 }
3208
3209 void RGFW_window_move(RGFW_window* win, RGFW_point v) {
3210 assert(win != NULL);
3211 win->r.x = v.x;
3212 win->r.y = v.y;
3213
3214 XMoveWindow((Display*) win->src.display, (Window) win->src.window, v.x, v.y);
3215 }
3216
3217
3218 void RGFW_window_resize(RGFW_window* win, RGFW_area a) {
3219 assert(win != NULL);
3220 win->r.w = a.w;
3221 win->r.h = a.h;
3222
3223 XResizeWindow((Display*) win->src.display, (Window) win->src.window, a.w, a.h);
3224 }
3225
3226 void RGFW_window_setMinSize(RGFW_window* win, RGFW_area a) {
3227 assert(win != NULL);
3228
3229 if (a.w == 0 && a.h == 0)
3230 return;
3231
3232 XSizeHints hints;
3233 long flags;
3234
3235 XGetWMNormalHints(win->src.display, (Window) win->src.window, &hints, &flags);
3236
3237 hints.flags |= PMinSize;
3238
3239 hints.min_width = a.w;
3240 hints.min_height = a.h;
3241
3242 XSetWMNormalHints(win->src.display, (Window) win->src.window, &hints);
3243 }
3244
3245 void RGFW_window_setMaxSize(RGFW_window* win, RGFW_area a) {
3246 assert(win != NULL);
3247
3248 if (a.w == 0 && a.h == 0)
3249 return;
3250
3251 XSizeHints hints;
3252 long flags;
3253
3254 XGetWMNormalHints(win->src.display, (Window) win->src.window, &hints, &flags);
3255
3256 hints.flags |= PMaxSize;
3257
3258 hints.max_width = a.w;
3259 hints.max_height = a.h;
3260
3261 XSetWMNormalHints(win->src.display, (Window) win->src.window, &hints);
3262 }
3263
3264
3265 void RGFW_window_minimize(RGFW_window* win) {
3266 assert(win != NULL);
3267
3268 XIconifyWindow(win->src.display, (Window) win->src.window, DefaultScreen(win->src.display));
3269 XFlush(win->src.display);
3270 }
3271
3272 void RGFW_window_restore(RGFW_window* win) {
3273 assert(win != NULL);
3274
3275 XMapWindow(win->src.display, (Window) win->src.window);
3276 XFlush(win->src.display);
3277 }
3278
3279 void RGFW_window_setName(RGFW_window* win, char* name) {
3280 assert(win != NULL);
3281
3282 XStoreName((Display*) win->src.display, (Window) win->src.window, name);
3283 }
3284
3285 void* RGFW_libxshape = NULL;
3286
3287 #ifndef RGFW_NO_PASSTHROUGH
3288 void RGFW_window_setMousePassthrough(RGFW_window* win, b8 passthrough) {
3289 assert(win != NULL);
3290
3291 #if defined(__CYGWIN__)
3292 RGFW_libxshape = dlopen("libXext-6.so", RTLD_LAZY | RTLD_LOCAL);
3293 #elif defined(__OpenBSD__) || defined(__NetBSD__)
3294 RGFW_libxshape = dlopen("libXext.so", RTLD_LAZY | RTLD_LOCAL);
3295 #else
3296 RGFW_libxshape = dlopen("libXext.so.6", RTLD_LAZY | RTLD_LOCAL);
3297 #endif
3298
3299 typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
3300 static PFN_XShapeCombineMask XShapeCombineMask;
3301
3302 typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,int);
3303 static PFN_XShapeCombineRegion XShapeCombineRegion;
3304
3305 if (XShapeCombineMask != NULL)
3306 XShapeCombineMask = (PFN_XShapeCombineMask) dlsym(RGFW_libxshape, "XShapeCombineMask");
3307
3308 if (XShapeCombineRegion != NULL)
3309 XShapeCombineRegion = (PFN_XShapeCombineRegion) dlsym(RGFW_libxshape, "XShapeCombineMask");
3310
3311 if (passthrough) {
3312 Region region = XCreateRegion();
3313 XShapeCombineRegion(win->src.display, win->src.window, ShapeInput, 0, 0, region, ShapeSet);
3314 XDestroyRegion(region);
3315
3316 return;
3317 }
3318
3319 XShapeCombineMask(win->src.display, win->src.window, ShapeInput, 0, 0, None, ShapeSet);
3320 }
3321 #endif
3322
3323 /*
3324 the majority function is sourced from GLFW
3325 */
3326
3327 void RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) {
3328 assert(win != NULL);
3329
3330 i32 longCount = 2 + a.w * a.h;
3331
3332 u64* X11Icon = (u64*) RGFW_MALLOC(longCount * sizeof(u64));
3333 u64* target = X11Icon;
3334
3335 *target++ = a.w;
3336 *target++ = a.h;
3337
3338 u32 i;
3339
3340 for (i = 0; i < a.w * a.h; i++) {
3341 if (channels == 3)
3342 *target++ = ((icon[i * 3 + 0]) << 16) |
3343 ((icon[i * 3 + 1]) << 8) |
3344 ((icon[i * 3 + 2]) << 0) |
3345 (0xFF << 24);
3346
3347 else if (channels == 4)
3348 *target++ = ((icon[i * 4 + 0]) << 16) |
3349 ((icon[i * 4 + 1]) << 8) |
3350 ((icon[i * 4 + 2]) << 0) |
3351 ((icon[i * 4 + 3]) << 24);
3352 }
3353
3354 static Atom NET_WM_ICON = 0;
3355 if (NET_WM_ICON == 0)
3356 NET_WM_ICON = XInternAtom((Display*) win->src.display, "_NET_WM_ICON", False);
3357
3358 XChangeProperty((Display*) win->src.display, (Window) win->src.window,
3359 NET_WM_ICON,
3360 6, 32,
3361 PropModeReplace,
3362 (u8*) X11Icon,
3363 longCount);
3364
3365 RGFW_FREE(X11Icon);
3366
3367 XFlush((Display*) win->src.display);
3368 }
3369
3370 void RGFW_window_setMouse(RGFW_window* win, u8* image, RGFW_area a, i32 channels) {
3371 assert(win != NULL);
3372
3373#ifndef RGFW_NO_X11_CURSOR
3374 XcursorImage* native = XcursorImageCreate(a.w, a.h);
3375 native->xhot = 0;
3376 native->yhot = 0;
3377
3378 u8* source = (u8*) image;
3379 XcursorPixel* target = native->pixels;
3380
3381 u32 i;
3382 for (i = 0; i < a.w * a.h; i++, target++, source += 4) {
3383 u8 alpha = 0xFF;
3384 if (channels == 4)
3385 alpha = source[3];
3386
3387 *target = (alpha << 24) | (((source[0] * alpha) / 255) << 16) | (((source[1] * alpha) / 255) << 8) | (((source[2] * alpha) / 255) << 0);
3388 }
3389
3390 Cursor cursor = XcursorImageLoadCursor((Display*) win->src.display, native);
3391 XDefineCursor((Display*) win->src.display, (Window) win->src.window, (Cursor) cursor);
3392
3393 XFreeCursor((Display*) win->src.display, (Cursor) cursor);
3394 XcursorImageDestroy(native);
3395#else
3396 RGFW_UNUSED(image) RGFW_UNUSED(a.w) RGFW_UNUSED(channels)
3397#endif
3398 }
3399
3400 void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v) {
3401 assert(win != NULL);
3402
3403 XEvent event;
3404 XQueryPointer(win->src.display, DefaultRootWindow(win->src.display),
3405 &event.xbutton.root, &event.xbutton.window,
3406 &event.xbutton.x_root, &event.xbutton.y_root,
3407 &event.xbutton.x, &event.xbutton.y,
3408 &event.xbutton.state);
3409
3410 if (event.xbutton.x == v.x && event.xbutton.y == v.y)
3411 return;
3412
3413 XWarpPointer(win->src.display, None, win->src.window, 0, 0, 0, 0, (int) v.x - win->r.x, (int) v.y - win->r.y);
3414 }
3415
3416 RGFWDEF void RGFW_window_disableMouse(RGFW_window* win) {
3417 RGFW_UNUSED(win);
3418 }
3419
3420 void RGFW_window_setMouseDefault(RGFW_window* win) {
3421 RGFW_window_setMouseStandard(win, RGFW_MOUSE_ARROW);
3422 }
3423
3424 void RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
3425 assert(win != NULL);
3426
3427 if (mouse > (sizeof(RGFW_mouseIconSrc) / sizeof(u8)))
3428 return;
3429
3430 mouse = RGFW_mouseIconSrc[mouse];
3431
3432 Cursor cursor = XCreateFontCursor((Display*) win->src.display, mouse);
3433 XDefineCursor((Display*) win->src.display, (Window) win->src.window, (Cursor) cursor);
3434
3435 XFreeCursor((Display*) win->src.display, (Cursor) cursor);
3436 }
3437
3438 void RGFW_window_hide(RGFW_window* win) {
3439 XMapWindow(win->src.display, win->src.window);
3440 }
3441
3442 void RGFW_window_show(RGFW_window* win) {
3443 XUnmapWindow(win->src.display, win->src.window);
3444 }
3445
3446 /*
3447 the majority function is sourced from GLFW
3448 */
3449 char* RGFW_readClipboard(size_t* size) {
3450 static Atom UTF8 = 0;
3451 if (UTF8 == 0)
3452 UTF8 = XInternAtom(RGFW_root->src.display, "UTF8_STRING", True);
3453
3454 XEvent event;
3455 int format;
3456 unsigned long N, sizeN;
3457 char* data, * s = NULL;
3458 Atom target;
3459 Atom CLIPBOARD = 0, XSEL_DATA = 0;
3460
3461 if (CLIPBOARD == 0) {
3462 CLIPBOARD = XInternAtom(RGFW_root->src.display, "CLIPBOARD", 0);
3463 XSEL_DATA = XInternAtom(RGFW_root->src.display, "XSEL_DATA", 0);
3464 }
3465
3466 XConvertSelection(RGFW_root->src.display, CLIPBOARD, UTF8, XSEL_DATA, RGFW_root->src.window, CurrentTime);
3467 XSync(RGFW_root->src.display, 0);
3468 XNextEvent(RGFW_root->src.display, &event);
3469
3470 if (event.type != SelectionNotify || event.xselection.selection != CLIPBOARD || event.xselection.property == 0)
3471 return NULL;
3472
3473 XGetWindowProperty(event.xselection.display, event.xselection.requestor,
3474 event.xselection.property, 0L, (~0L), 0, AnyPropertyType, &target,
3475 &format, &sizeN, &N, (unsigned char**) &data);
3476
3477 if (target == UTF8 || target == XA_STRING) {
3478 s = (char*)RGFW_MALLOC(sizeof(char) * sizeN);
3479 strncpy(s, data, sizeN);
3480 s[sizeN] = '\0';
3481 XFree(data);
3482 }
3483
3484 XDeleteProperty(event.xselection.display, event.xselection.requestor, event.xselection.property);
3485
3486 if (s != NULL && size != NULL)
3487 *size = sizeN;
3488
3489 return s;
3490 }
3491
3492 /*
3493 almost all of this function is sourced from GLFW
3494 */
3495 void RGFW_writeClipboard(const char* text, u32 textLen) {
3496 static Atom CLIPBOARD = 0,
3497 UTF8_STRING = 0,
3498 SAVE_TARGETS = 0,
3499 TARGETS = 0,
3500 MULTIPLE = 0,
3501 ATOM_PAIR = 0,
3502 CLIPBOARD_MANAGER = 0;
3503
3504 if (CLIPBOARD == 0) {
3505 CLIPBOARD = XInternAtom((Display*) RGFW_root->src.display, "CLIPBOARD", False);
3506 UTF8_STRING = XInternAtom((Display*) RGFW_root->src.display, "UTF8_STRING", False);
3507 SAVE_TARGETS = XInternAtom((Display*) RGFW_root->src.display, "SAVE_TARGETS", False);
3508 TARGETS = XInternAtom((Display*) RGFW_root->src.display, "TARGETS", False);
3509 MULTIPLE = XInternAtom((Display*) RGFW_root->src.display, "MULTIPLE", False);
3510 ATOM_PAIR = XInternAtom((Display*) RGFW_root->src.display, "ATOM_PAIR", False);
3511 CLIPBOARD_MANAGER = XInternAtom((Display*) RGFW_root->src.display, "CLIPBOARD_MANAGER", False);
3512 }
3513
3514 XSetSelectionOwner((Display*) RGFW_root->src.display, CLIPBOARD, (Window) RGFW_root->src.window, CurrentTime);
3515
3516 XConvertSelection((Display*) RGFW_root->src.display, CLIPBOARD_MANAGER, SAVE_TARGETS, None, (Window) RGFW_root->src.window, CurrentTime);
3517 for (;;) {
3518 XEvent event;
3519
3520 XNextEvent((Display*) RGFW_root->src.display, &event);
3521 if (event.type != SelectionRequest) {
3522 break;
3523 }
3524
3525 const XSelectionRequestEvent* request = &event.xselectionrequest;
3526
3527 XEvent reply = { SelectionNotify };
3528 reply.xselection.property = 0;
3529
3530 if (request->target == TARGETS) {
3531 const Atom targets[] = { TARGETS,
3532 MULTIPLE,
3533 UTF8_STRING,
3534 XA_STRING };
3535
3536 XChangeProperty((Display*) RGFW_root->src.display,
3537 request->requestor,
3538 request->property,
3539 4,
3540 32,
3541 PropModeReplace,
3542 (u8*) targets,
3543 sizeof(targets) / sizeof(targets[0]));
3544
3545 reply.xselection.property = request->property;
3546 }
3547
3548 if (request->target == MULTIPLE) {
3549 Atom* targets = NULL;
3550
3551 Atom actualType = 0;
3552 int actualFormat = 0;
3553 unsigned long count = 0, bytesAfter = 0;
3554
3555 XGetWindowProperty((Display*) RGFW_root->src.display, request->requestor, request->property, 0, LONG_MAX, False, ATOM_PAIR, &actualType, &actualFormat, &count, &bytesAfter, (u8**) &targets);
3556
3557 unsigned long i;
3558 for (i = 0; i < (u32)count; i += 2) {
3559 if (targets[i] == UTF8_STRING || targets[i] == XA_STRING) {
3560 XChangeProperty((Display*) RGFW_root->src.display,
3561 request->requestor,
3562 targets[i + 1],
3563 targets[i],
3564 8,
3565 PropModeReplace,
3566 (u8*) text,
3567 textLen);
3568 XFlush(RGFW_root->src.display);
3569 } else {
3570 targets[i + 1] = None;
3571 }
3572 }
3573
3574 XChangeProperty((Display*) RGFW_root->src.display,
3575 request->requestor,
3576 request->property,
3577 ATOM_PAIR,
3578 32,
3579 PropModeReplace,
3580 (u8*) targets,
3581 count);
3582
3583 XFlush(RGFW_root->src.display);
3584 XFree(targets);
3585
3586 reply.xselection.property = request->property;
3587 }
3588
3589 reply.xselection.display = request->display;
3590 reply.xselection.requestor = request->requestor;
3591 reply.xselection.selection = request->selection;
3592 reply.xselection.target = request->target;
3593 reply.xselection.time = request->time;
3594
3595 XSendEvent((Display*) RGFW_root->src.display, request->requestor, False, 0, &reply);
3596 XFlush(RGFW_root->src.display);
3597 }
3598 }
3599
3600 u8 RGFW_window_isFullscreen(RGFW_window* win) {
3601 assert(win != NULL);
3602
3603 XWindowAttributes windowAttributes;
3604 XGetWindowAttributes(win->src.display, (Window) win->src.window, &windowAttributes);
3605
3606 /* check if the window is visable */
3607 if (windowAttributes.map_state != IsViewable)
3608 return 0;
3609
3610 /* check if the window covers the full screen */
3611 return (windowAttributes.x == 0 && windowAttributes.y == 0 &&
3612 windowAttributes.width == XDisplayWidth(win->src.display, DefaultScreen(win->src.display)) &&
3613 windowAttributes.height == XDisplayHeight(win->src.display, DefaultScreen(win->src.display)));
3614 }
3615
3616 u8 RGFW_window_isHidden(RGFW_window* win) {
3617 assert(win != NULL);
3618
3619 XWindowAttributes windowAttributes;
3620 XGetWindowAttributes(win->src.display, (Window) win->src.window, &windowAttributes);
3621
3622 return (windowAttributes.map_state == IsUnmapped && !RGFW_window_isMinimized(win));
3623 }
3624
3625 u8 RGFW_window_isMinimized(RGFW_window* win) {
3626 assert(win != NULL);
3627
3628 static Atom prop = 0;
3629 if (prop == 0)
3630 prop = XInternAtom(win->src.display, "WM_STATE", False);
3631
3632 Atom actual_type;
3633 i32 actual_format;
3634 unsigned long nitems, bytes_after;
3635 unsigned char* prop_data;
3636
3637 i16 status = XGetWindowProperty(win->src.display, (Window) win->src.window, prop, 0, 2, False,
3638 AnyPropertyType, &actual_type, &actual_format,
3639 &nitems, &bytes_after, &prop_data);
3640
3641 if (status == Success && nitems >= 1 && *((int*) prop_data) == IconicState) {
3642 XFree(prop_data);
3643 return 1;
3644 }
3645
3646 if (prop_data != NULL)
3647 XFree(prop_data);
3648
3649 return 0;
3650 }
3651
3652 u8 RGFW_window_isMaximized(RGFW_window* win) {
3653 assert(win != NULL);
3654
3655 static Atom net_wm_state = 0;
3656 static Atom net_wm_state_maximized_horz = 0;
3657 static Atom net_wm_state_maximized_vert = 0;
3658
3659 if (net_wm_state == 0) {
3660 net_wm_state = XInternAtom(win->src.display, "_NET_WM_STATE", False);
3661 net_wm_state_maximized_vert = XInternAtom(win->src.display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
3662 net_wm_state_maximized_horz = XInternAtom(win->src.display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
3663 }
3664
3665 Atom actual_type;
3666 i32 actual_format;
3667 unsigned long nitems, bytes_after;
3668 unsigned char* prop_data;
3669
3670 i16 status = XGetWindowProperty(win->src.display, (Window) win->src.window, net_wm_state, 0, 1024, False,
3671 XA_ATOM, &actual_type, &actual_format,
3672 &nitems, &bytes_after, &prop_data);
3673
3674 if (status != Success) {
3675 if (prop_data != NULL)
3676 XFree(prop_data);
3677
3678 return 0;
3679 }
3680
3681 Atom* atoms = (Atom*) prop_data;
3682 u64 i;
3683 for (i = 0; i < nitems; ++i) {
3684 if (atoms[i] == net_wm_state_maximized_horz ||
3685 atoms[i] == net_wm_state_maximized_vert) {
3686 XFree(prop_data);
3687 return 1;
3688 }
3689 }
3690
3691 return 0;
3692 }
3693
3694 static void XGetSystemContentScale(Display* display, float* xscale, float* yscale) {
3695 float xdpi = 96.f, ydpi = 96.f;
3696
3697#ifndef RGFW_NO_DPI
3698 char* rms = XResourceManagerString(display);
3699 XrmDatabase db = NULL;
3700
3701 if (rms && db)
3702 db = XrmGetStringDatabase(rms);
3703
3704 if (db == 0) {
3705 *xscale = xdpi / 96.f;
3706 *yscale = ydpi / 96.f;
3707 return;
3708 }
3709
3710 XrmValue value;
3711 char* type = NULL;
3712
3713 if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value) && type && strncmp(type, "String", 7) == 0)
3714 xdpi = ydpi = atof(value.addr);
3715 XrmDestroyDatabase(db);
3716#endif
3717
3718 * xscale = xdpi / 96.f;
3719 *yscale = ydpi / 96.f;
3720 }
3721
3722 RGFW_monitor RGFW_XCreateMonitor(i32 screen) {
3723 RGFW_monitor monitor;
3724
3725 Display* display = XOpenDisplay(NULL);
3726
3727 RGFW_area size = RGFW_getScreenSize();
3728
3729 monitor.rect = RGFW_RECT(0, 0, size.w, size.h);
3730 monitor.physW = DisplayWidthMM(display, screen);
3731 monitor.physH = DisplayHeightMM(display, screen);
3732
3733 XGetSystemContentScale(display, &monitor.scaleX, &monitor.scaleY);
3734 XRRScreenResources* sr = XRRGetScreenResourcesCurrent(display, RootWindow(display, screen));
3735
3736 XRRCrtcInfo* ci = NULL;
3737 int crtc = screen;
3738
3739 if (sr->ncrtc > crtc) {
3740 ci = XRRGetCrtcInfo(display, sr, sr->crtcs[crtc]);
3741 }
3742
3743 if (ci == NULL) {
3744 float dpi_width = round((double)monitor.rect.w/(((double)monitor.physW)/25.4));
3745 float dpi_height = round((double)monitor.rect.h/(((double)monitor.physH)/25.4));
3746
3747 monitor.scaleX = (float) (dpi_width) / (float) 96;
3748 monitor.scaleY = (float) (dpi_height) / (float) 96;
3749 XRRFreeScreenResources(sr);
3750 XCloseDisplay(display);
3751 return monitor;
3752 }
3753
3754 XRROutputInfo* info = XRRGetOutputInfo (display, sr, sr->outputs[screen]);
3755 monitor.physW = info->mm_width;
3756 monitor.physH = info->mm_height;
3757
3758 monitor.rect.x = ci->x;
3759 monitor.rect.y = ci->y;
3760 monitor.rect.w = ci->width;
3761 monitor.rect.h = ci->height;
3762
3763 float dpi_width = round((double)monitor.rect.w/(((double)monitor.physW)/25.4));
3764 float dpi_height = round((double)monitor.rect.h/(((double)monitor.physH)/25.4));
3765
3766 monitor.scaleX = (float) (dpi_width) / (float) 96;
3767 monitor.scaleY = (float) (dpi_height) / (float) 96;
3768
3769 if (monitor.scaleX > 1 && monitor.scaleX < 1.1)
3770 monitor.scaleX = 1;
3771
3772 if (monitor.scaleY > 1 && monitor.scaleY < 1.1)
3773 monitor.scaleY = 1;
3774
3775 XRRFreeCrtcInfo(ci);
3776 XRRFreeScreenResources(sr);
3777
3778 XCloseDisplay(display);
3779
3780 return monitor;
3781 }
3782
3783 RGFW_monitor RGFW_monitors[6];
3784 RGFW_monitor* RGFW_getMonitors(void) {
3785 size_t i;
3786 for (i = 0; i < (size_t)ScreenCount(RGFW_root->src.display) && i < 6; i++)
3787 RGFW_monitors[i] = RGFW_XCreateMonitor(i);
3788
3789 return RGFW_monitors;
3790 }
3791
3792 RGFW_monitor RGFW_getPrimaryMonitor(void) {
3793 assert(RGFW_root != NULL);
3794
3795 i32 primary = -1;
3796 Window root = DefaultRootWindow(RGFW_root->src.display);
3797 XRRScreenResources* res = XRRGetScreenResources(RGFW_root->src.display, root);
3798
3799 for (int i = 0; i < res->noutput; i++) {
3800 XRROutputInfo* output_info = XRRGetOutputInfo(RGFW_root->src.display, res, res->outputs[i]);
3801 if (output_info->connection == RR_Connected && output_info->crtc) {
3802 XRRCrtcInfo* crtc_info = XRRGetCrtcInfo(RGFW_root->src.display, res, output_info->crtc);
3803 if (crtc_info->mode != None && crtc_info->x == 0 && crtc_info->y == 0) {
3804 primary = i;
3805 XRRFreeCrtcInfo(crtc_info);
3806 XRRFreeOutputInfo(output_info);
3807 break;
3808 }
3809 XRRFreeCrtcInfo(crtc_info);
3810 }
3811 XRRFreeOutputInfo(output_info);
3812 }
3813
3814 XRRFreeScreenResources(res);
3815
3816 return RGFW_XCreateMonitor(primary);
3817 }
3818
3819 RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) {
3820 return RGFW_XCreateMonitor(DefaultScreen(win->src.display));
3821 }
3822
3823 #ifdef RGFW_OPENGL
3824 void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
3825 if (win == NULL)
3826 glXMakeCurrent((Display*) NULL, (Drawable)NULL, (GLXContext) NULL);
3827 else
3828 glXMakeCurrent((Display*) win->src.display, (Drawable) win->src.window, (GLXContext) win->src.ctx);
3829 }
3830 #endif
3831
3832
3833 void RGFW_window_swapBuffers(RGFW_window* win) {
3834 assert(win != NULL);
3835
3836 /* clear the window*/
3837 if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) {
3838#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
3839 #ifdef RGFW_OSMESA
3840 RGFW_OSMesa_reorganize();
3841 #endif
3842 RGFW_area area = RGFW_bufferSize;
3843
3844#ifndef RGFW_X11_DONT_CONVERT_BGR
3845 win->src.bitmap->data = (char*) win->buffer;
3846 u32 x, y;
3847 for (y = 0; y < (u32)win->r.h; y++) {
3848 for (x = 0; x < (u32)win->r.w; x++) {
3849 u32 index = (y * 4 * area.w) + x * 4;
3850
3851 u8 red = win->src.bitmap->data[index];
3852 win->src.bitmap->data[index] = win->buffer[index + 2];
3853 win->src.bitmap->data[index + 2] = red;
3854
3855 }
3856 }
3857#endif
3858 XPutImage(win->src.display, (Window) win->src.window, win->src.gc, win->src.bitmap, 0, 0, 0, 0, RGFW_bufferSize.w, RGFW_bufferSize.h);
3859#endif
3860 }
3861
3862 if (!(win->_winArgs & RGFW_NO_GPU_RENDER)) {
3863 #ifdef RGFW_EGL
3864 eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface);
3865 #elif defined(RGFW_OPENGL)
3866 glXSwapBuffers((Display*) win->src.display, (Window) win->src.window);
3867 #endif
3868 }
3869 }
3870
3871 #if !defined(RGFW_EGL)
3872 void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) {
3873 assert(win != NULL);
3874
3875 #if defined(RGFW_OPENGL)
3876 ((PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((GLubyte*) "glXSwapIntervalEXT"))((Display*) win->src.display, (Window) win->src.window, swapInterval);
3877 #else
3878 RGFW_UNUSED(swapInterval);
3879 #endif
3880 }
3881 #endif
3882
3883
3884 void RGFW_window_close(RGFW_window* win) {
3885 /* ungrab pointer if it was grabbed */
3886 if (win->_winArgs & RGFW_HOLD_MOUSE)
3887 XUngrabPointer(win->src.display, CurrentTime);
3888
3889 assert(win != NULL);
3890#ifdef RGFW_EGL
3891 RGFW_closeEGL(win);
3892#endif
3893
3894#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
3895 if (win->buffer != NULL) {
3896 XDestroyImage((XImage*) win->src.bitmap);
3897 XFreeGC(win->src.display, win->src.gc);
3898 }
3899#endif
3900
3901 if ((Display*) win->src.display) {
3902#ifdef RGFW_OPENGL
3903 glXDestroyContext((Display*) win->src.display, win->src.ctx);
3904#endif
3905
3906 if (win == RGFW_root)
3907 RGFW_root = NULL;
3908
3909 if ((Drawable) win->src.window)
3910 XDestroyWindow((Display*) win->src.display, (Drawable) win->src.window); /*!< close the window*/
3911
3912 XCloseDisplay((Display*) win->src.display); /*!< kill the display*/
3913 }
3914
3915#ifdef RGFW_ALLOC_DROPFILES
3916 {
3917 u32 i;
3918 for (i = 0; i < RGFW_MAX_DROPS; i++)
3919 RGFW_FREE(win->event.droppedFiles[i]);
3920
3921
3922 RGFW_FREE(win->event.droppedFiles);
3923 }
3924#endif
3925
3926 RGFW_windowsOpen--;
3927#if !defined(RGFW_NO_X11_CURSOR_PRELOAD) && !defined(RGFW_NO_X11_CURSOR)
3928 if (X11Cursorhandle != NULL && RGFW_windowsOpen <= 0) {
3929 dlclose(X11Cursorhandle);
3930
3931 X11Cursorhandle = NULL;
3932 }
3933#endif
3934#if !defined(RGFW_NO_X11_XI_PRELOAD)
3935 if (X11Xihandle != NULL && RGFW_windowsOpen <= 0) {
3936 dlclose(X11Xihandle);
3937
3938 X11Xihandle = NULL;
3939 }
3940#endif
3941
3942 if (RGFW_libxshape != NULL && RGFW_windowsOpen <= 0) {
3943 dlclose(RGFW_libxshape);
3944 RGFW_libxshape = NULL;
3945 }
3946
3947 if (RGFW_windowsOpen <= 0) {
3948 if (RGFW_eventWait_forceStop[0] || RGFW_eventWait_forceStop[1]){
3949 close(RGFW_eventWait_forceStop[0]);
3950 close(RGFW_eventWait_forceStop[1]);
3951 }
3952
3953 u8 i;
3954 for (i = 0; i < RGFW_joystickCount; i++)
3955 close(RGFW_joysticks[i]);
3956 }
3957
3958 /* set cleared display / window to NULL for error checking */
3959 win->src.display = (Display*) 0;
3960 win->src.window = (Window) 0;
3961
3962 RGFW_FREE(win); /*!< free collected window data */
3963 }
3964
3965
3966/*
3967 End of X11 linux / unix defines
3968*/
3969
3970#endif /* RGFW_X11 */
3971
3972
3973/* wayland or X11 defines*/
3974#if defined(RGFW_WAYLAND) || defined(RGFW_X11)
3975#include <fcntl.h>
3976#include <poll.h>
3977#include <unistd.h>
3978 u16 RGFW_registerJoystickF(RGFW_window* win, char* file) {
3979 assert(win != NULL);
3980
3981#ifdef __linux__
3982
3983 i32 js = open(file, O_RDONLY);
3984
3985 if (js && RGFW_joystickCount < 4) {
3986 RGFW_joystickCount++;
3987
3988 RGFW_joysticks[RGFW_joystickCount - 1] = open(file, O_RDONLY);
3989
3990 u8 i;
3991 for (i = 0; i < 16; i++)
3992 RGFW_jsPressed[RGFW_joystickCount - 1][i] = 0;
3993
3994 }
3995
3996 else {
3997#ifdef RGFW_PRINT_ERRORS
3998 RGFW_error = 1;
3999 fprintf(stderr, "Error RGFW_registerJoystickF : Cannot open file %s\n", file);
4000#endif
4001 }
4002
4003 return RGFW_joystickCount - 1;
4004#endif
4005 }
4006
4007 u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) {
4008 assert(win != NULL);
4009
4010#ifdef __linux__
4011 char file[15];
4012 sprintf(file, "/dev/input/js%i", jsNumber);
4013
4014 return RGFW_registerJoystickF(win, file);
4015#endif
4016 }
4017
4018 void RGFW_stopCheckEvents(void) {
4019 RGFW_eventWait_forceStop[2] = 1;
4020 while (1) {
4021 const char byte = 0;
4022 const ssize_t result = write(RGFW_eventWait_forceStop[1], &byte, 1);
4023 if (result == 1 || result == -1)
4024 break;
4025 }
4026 }
4027
4028 void RGFW_window_eventWait(RGFW_window* win, i32 waitMS) {
4029 if (waitMS == 0)
4030 return;
4031
4032 u8 i;
4033
4034 if (RGFW_eventWait_forceStop[0] == 0 || RGFW_eventWait_forceStop[1] == 0) {
4035 if (pipe(RGFW_eventWait_forceStop) != -1) {
4036 fcntl(RGFW_eventWait_forceStop[0], F_GETFL, 0);
4037 fcntl(RGFW_eventWait_forceStop[0], F_GETFD, 0);
4038 fcntl(RGFW_eventWait_forceStop[1], F_GETFL, 0);
4039 fcntl(RGFW_eventWait_forceStop[1], F_GETFD, 0);
4040 }
4041 }
4042
4043 struct pollfd fds[] = {
4044 #ifdef RGFW_WAYLAND
4045 { wl_display_get_fd(win->src.display), POLLIN, 0 },
4046 #else
4047 { ConnectionNumber(win->src.display), POLLIN, 0 },
4048 #endif
4049 { RGFW_eventWait_forceStop[0], POLLIN, 0 },
4050 #ifdef __linux__ /* blank space for 4 joystick files*/
4051 { -1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0}
4052 #endif
4053 };
4054
4055 u8 index = 2;
4056
4057 #if defined(__linux__)
4058 for (i = 0; i < RGFW_joystickCount; i++) {
4059 if (RGFW_joysticks[i] == 0)
4060 continue;
4061
4062 fds[index].fd = RGFW_joysticks[i];
4063 index++;
4064 }
4065 #endif
4066
4067
4068 u64 start = RGFW_getTimeNS();
4069
4070 #ifdef RGFW_WAYLAND
4071 while (wl_display_dispatch(win->src.display) <= 0 && waitMS >= -1) {
4072 #else
4073 while (XPending(win->src.display) == 0 && waitMS >= -1) {
4074 #endif
4075 if (poll(fds, index, waitMS) <= 0)
4076 break;
4077
4078 if (waitMS > 0) {
4079 waitMS -= (RGFW_getTimeNS() - start) / 1e+6;
4080 }
4081 }
4082
4083 /* drain any data in the stop request */
4084 if (RGFW_eventWait_forceStop[2]) {
4085 char data[64];
4086 (void)!read(RGFW_eventWait_forceStop[0], data, sizeof(data));
4087
4088 RGFW_eventWait_forceStop[2] = 0;
4089 }
4090 }
4091
4092 u64 RGFW_getTimeNS(void) {
4093 struct timespec ts = { 0 };
4094 clock_gettime(1, &ts);
4095 unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
4096
4097 return nanoSeconds;
4098 }
4099
4100 u64 RGFW_getTime(void) {
4101 struct timespec ts = { 0 };
4102 clock_gettime(1, &ts);
4103 unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
4104
4105 return (double)(nanoSeconds) * 1e-9;
4106 }
4107#endif /* end of wayland or X11 time defines*/
4108
4109
4110/*
4111
4112 Start of Wayland defines
4113
4114
4115*/
4116
4117#ifdef RGFW_WAYLAND
4118/*
4119Wayland TODO:
4120- fix RGFW_keyPressed lock state
4121
4122 RGFW_windowMoved, the window was moved (by the user)
4123 RGFW_windowResized the window was resized (by the user), [on webASM this means the browser was resized]
4124 RGFW_windowRefresh The window content needs to be refreshed
4125
4126 RGFW_dnd a file has been dropped into the window
4127 RGFW_dnd_init
4128
4129- window args:
4130 #define RGFW_NO_RESIZE the window cannot be resized by the user
4131 #define RGFW_ALLOW_DND the window supports drag and drop
4132 #define RGFW_SCALE_TO_MONITOR scale the window to the screen
4133
4134- other missing functions functions ("TODO wayland") (~30 functions)
4135- fix buffer rendering weird behavior
4136*/
4137 #include <errno.h>
4138 #include <unistd.h>
4139 #include <sys/mman.h>
4140 #include <xkbcommon/xkbcommon.h>
4141 #include <xkbcommon/xkbcommon-keysyms.h>
4142 #include <dirent.h>
4143 #include <linux/kd.h>
4144 #include <wayland-cursor.h>
4145
4146RGFW_window* RGFW_key_win = NULL;
4147
4148void RGFW_eventPipe_push(RGFW_window* win, RGFW_Event event) {
4149 if (win == NULL) {
4150 win = RGFW_key_win;
4151
4152 if (win == NULL) return;
4153 }
4154
4155 if (win->src.eventLen >= (i32)(sizeof(win->src.events) / sizeof(win->src.events[0])))
4156 return;
4157
4158 win->src.events[win->src.eventLen] = event;
4159 win->src.eventLen += 1;
4160}
4161
4162RGFW_Event RGFW_eventPipe_pop(RGFW_window* win) {
4163 RGFW_Event ev;
4164 ev.type = 0;
4165
4166 if (win->src.eventLen > -1)
4167 win->src.eventLen -= 1;
4168
4169 if (win->src.eventLen >= 0)
4170 ev = win->src.events[win->src.eventLen];
4171
4172 return ev;
4173}
4174
4175/* wayland global garbage (wayland bad, X11 is fine (ish) (not really)) */
4176#include "xdg-shell.h"
4177#include "xdg-decoration-unstable-v1.h"
4178
4179struct xdg_wm_base *xdg_wm_base;
4180struct wl_compositor* RGFW_compositor = NULL;
4181struct wl_shm* shm = NULL;
4182struct wl_shell* RGFW_shell = NULL;
4183static struct wl_seat *seat = NULL;
4184static struct xkb_context *xkb_context;
4185static struct xkb_keymap *keymap = NULL;
4186static struct xkb_state *xkb_state = NULL;
4187enum zxdg_toplevel_decoration_v1_mode client_preferred_mode, RGFW_current_mode;
4188static struct zxdg_decoration_manager_v1 *decoration_manager = NULL;
4189
4190struct wl_cursor_theme* RGFW_wl_cursor_theme = NULL;
4191struct wl_surface* RGFW_cursor_surface = NULL;
4192struct wl_cursor_image* RGFW_cursor_image = NULL;
4193
4194static void xdg_wm_base_ping_handler(void *data,
4195 struct xdg_wm_base *wm_base, uint32_t serial)
4196{
4197 RGFW_UNUSED(data);
4198 xdg_wm_base_pong(wm_base, serial);
4199}
4200
4201static const struct xdg_wm_base_listener xdg_wm_base_listener = {
4202 .ping = xdg_wm_base_ping_handler,
4203};
4204
4205b8 RGFW_wl_configured = 0;
4206
4207static void xdg_surface_configure_handler(void *data,
4208 struct xdg_surface *xdg_surface, uint32_t serial)
4209{
4210 RGFW_UNUSED(data);
4211 xdg_surface_ack_configure(xdg_surface, serial);
4212 #ifdef RGFW_DEBUG
4213 printf("Surface configured\n");
4214 #endif
4215 RGFW_wl_configured = 1;
4216}
4217
4218static const struct xdg_surface_listener xdg_surface_listener = {
4219 .configure = xdg_surface_configure_handler,
4220};
4221
4222static void xdg_toplevel_configure_handler(void *data,
4223 struct xdg_toplevel *toplevel, int32_t width, int32_t height,
4224 struct wl_array *states)
4225{
4226 RGFW_UNUSED(data); RGFW_UNUSED(toplevel); RGFW_UNUSED(states)
4227 fprintf(stderr, "XDG toplevel configure: %dx%d\n", width, height);
4228}
4229
4230static void xdg_toplevel_close_handler(void *data,
4231 struct xdg_toplevel *toplevel)
4232{
4233 RGFW_UNUSED(data);
4234 RGFW_window* win = (RGFW_window*)xdg_toplevel_get_user_data(toplevel);
4235 if (win == NULL)
4236 win = RGFW_key_win;
4237
4238 RGFW_Event ev;
4239 ev.type = RGFW_quit;
4240
4241 RGFW_eventPipe_push(win, ev);
4242
4243 RGFW_windowQuitCallback(win);
4244}
4245
4246static void shm_format_handler(void *data,
4247 struct wl_shm *shm, uint32_t format)
4248{
4249 RGFW_UNUSED(data); RGFW_UNUSED(shm);
4250 fprintf(stderr, "Format %d\n", format);
4251}
4252
4253static const struct wl_shm_listener shm_listener = {
4254 .format = shm_format_handler,
4255};
4256
4257static const struct xdg_toplevel_listener xdg_toplevel_listener = {
4258 .configure = xdg_toplevel_configure_handler,
4259 .close = xdg_toplevel_close_handler,
4260};
4261
4262RGFW_window* RGFW_mouse_win = NULL;
4263
4264static void pointer_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) {
4265 RGFW_UNUSED(data); RGFW_UNUSED(pointer); RGFW_UNUSED(serial); RGFW_UNUSED(surface_x); RGFW_UNUSED(surface_y);
4266 RGFW_window* win = (RGFW_window*)wl_surface_get_user_data(surface);
4267 RGFW_mouse_win = win;
4268
4269 RGFW_Event ev;
4270 ev.type = RGFW_mouseEnter;
4271 ev.point = win->event.point;
4272
4273 RGFW_eventPipe_push(win, ev);
4274
4275 RGFW_mouseNotifyCallBack(win, win->event.point, RGFW_TRUE);
4276}
4277static void pointer_leave(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface) {
4278 RGFW_UNUSED(data); RGFW_UNUSED(pointer); RGFW_UNUSED(serial); RGFW_UNUSED(surface);
4279 RGFW_window* win = (RGFW_window*)wl_surface_get_user_data(surface);
4280 if (RGFW_mouse_win == win)
4281 RGFW_mouse_win = NULL;
4282
4283 RGFW_Event ev;
4284 ev.type = RGFW_mouseLeave;
4285 ev.point = win->event.point;
4286 RGFW_eventPipe_push(win, ev);
4287
4288 RGFW_mouseNotifyCallBack(win, win->event.point, RGFW_FALSE);
4289}
4290static void pointer_motion(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y) {
4291 RGFW_UNUSED(data); RGFW_UNUSED(pointer); RGFW_UNUSED(time); RGFW_UNUSED(x); RGFW_UNUSED(y);
4292
4293 assert(RGFW_mouse_win != NULL);
4294
4295 RGFW_Event ev;
4296 ev.type = RGFW_mousePosChanged;
4297 ev.point = RGFW_POINT(wl_fixed_to_double(x), wl_fixed_to_double(y));
4298 RGFW_eventPipe_push(RGFW_mouse_win, ev);
4299
4300 RGFW_mousePosCallback(RGFW_mouse_win, RGFW_POINT(wl_fixed_to_double(x), wl_fixed_to_double(y)));
4301}
4302static void pointer_button(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) {
4303 RGFW_UNUSED(data); RGFW_UNUSED(pointer); RGFW_UNUSED(time); RGFW_UNUSED(serial);
4304 assert(RGFW_mouse_win != NULL);
4305
4306 u32 b = (button - 0x110) + 1;
4307
4308 /* flip right and middle button codes */
4309 if (b == 2) b = 3;
4310 else if (b == 3) b = 2;
4311
4312 RGFW_mouseButtons[b].prev = RGFW_mouseButtons[b].current;
4313 RGFW_mouseButtons[b].current = state;
4314
4315 RGFW_Event ev;
4316 ev.type = RGFW_mouseButtonPressed + state;
4317 ev.button = b;
4318 RGFW_eventPipe_push(RGFW_mouse_win, ev);
4319
4320 RGFW_mouseButtonCallback(RGFW_mouse_win, b, 0, state);
4321}
4322static void pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) {
4323 RGFW_UNUSED(data); RGFW_UNUSED(pointer); RGFW_UNUSED(time); RGFW_UNUSED(axis);
4324 assert(RGFW_mouse_win != NULL);
4325
4326 double scroll = wl_fixed_to_double(value);
4327
4328 RGFW_Event ev;
4329 ev.type = RGFW_mouseButtonPressed;
4330 ev.button = RGFW_mouseScrollUp + (scroll < 0);
4331 RGFW_eventPipe_push(RGFW_mouse_win, ev);
4332
4333 RGFW_mouseButtonCallback(RGFW_mouse_win, RGFW_mouseScrollUp + (scroll < 0), scroll, 1);
4334}
4335
4336void RGFW_doNothing(void) { }
4337static struct wl_pointer_listener pointer_listener = (struct wl_pointer_listener){&pointer_enter, &pointer_leave, &pointer_motion, &pointer_button, &pointer_axis, (void*)&RGFW_doNothing, (void*)&RGFW_doNothing, (void*)&RGFW_doNothing, (void*)&RGFW_doNothing, (void*)&RGFW_doNothing, (void*)&RGFW_doNothing};
4338
4339static void keyboard_keymap (void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size) {
4340 RGFW_UNUSED(data); RGFW_UNUSED(keyboard); RGFW_UNUSED(format);
4341
4342 char *keymap_string = mmap (NULL, size, PROT_READ, MAP_SHARED, fd, 0);
4343 xkb_keymap_unref (keymap);
4344 keymap = xkb_keymap_new_from_string (xkb_context, keymap_string, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
4345
4346 munmap (keymap_string, size);
4347 close (fd);
4348 xkb_state_unref (xkb_state);
4349 xkb_state = xkb_state_new (keymap);
4350}
4351static void keyboard_enter (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys) {
4352 RGFW_UNUSED(data); RGFW_UNUSED(keyboard); RGFW_UNUSED(serial); RGFW_UNUSED(keys);
4353
4354 RGFW_key_win = (RGFW_window*)wl_surface_get_user_data(surface);
4355
4356 RGFW_Event ev;
4357 ev.type = RGFW_focusIn;
4358 ev.inFocus = RGFW_TRUE;
4359 RGFW_key_win->event.inFocus = RGFW_TRUE;
4360
4361 RGFW_eventPipe_push((RGFW_window*)RGFW_mouse_win, ev);
4362
4363 RGFW_focusCallback(RGFW_key_win, RGFW_TRUE);
4364}
4365static void keyboard_leave (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface) {
4366 RGFW_UNUSED(data); RGFW_UNUSED(keyboard); RGFW_UNUSED(serial);
4367
4368 RGFW_window* win = (RGFW_window*)wl_surface_get_user_data(surface);
4369 if (RGFW_key_win == win)
4370 RGFW_key_win = NULL;
4371
4372 RGFW_Event ev;
4373 ev.type = RGFW_focusOut;
4374 ev.inFocus = RGFW_FALSE;
4375 win->event.inFocus = RGFW_FALSE;
4376 RGFW_eventPipe_push(win, ev);
4377
4378 RGFW_focusCallback(win, RGFW_FALSE);
4379}
4380static void keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) {
4381 RGFW_UNUSED(data); RGFW_UNUSED(keyboard); RGFW_UNUSED(serial); RGFW_UNUSED(time);
4382
4383 assert(RGFW_key_win != NULL);
4384
4385 xkb_keysym_t keysym = xkb_state_key_get_one_sym (xkb_state, key+8);
4386 char name[16];
4387 xkb_keysym_get_name(keysym, name, 16);
4388
4389 u32 RGFW_key = RGFW_apiKeyCodeToRGFW(key);
4390 RGFW_keyboard[RGFW_key].prev = RGFW_keyboard[RGFW_key].current;
4391 RGFW_keyboard[RGFW_key].current = state;
4392 RGFW_Event ev;
4393 ev.type = RGFW_keyPressed + state;
4394 ev.keyCode = RGFW_key;
4395 strcpy(ev.keyName, name);
4396 ev.repeat = RGFW_isHeld(RGFW_key_win, RGFW_key);
4397 RGFW_eventPipe_push(RGFW_key_win, ev);
4398
4399 RGFW_updateLockState(RGFW_key_win, xkb_keymap_mod_get_index(keymap, "Lock"), xkb_keymap_mod_get_index(keymap, "Mod2"));
4400
4401 RGFW_keyCallback(RGFW_key_win, RGFW_key, name, RGFW_key_win->event.lockState, state);
4402}
4403static void keyboard_modifiers (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) {
4404 RGFW_UNUSED(data); RGFW_UNUSED(keyboard); RGFW_UNUSED(serial); RGFW_UNUSED(time);
4405 xkb_state_update_mask (xkb_state, mods_depressed, mods_latched, mods_locked, 0, 0, group);
4406}
4407static struct wl_keyboard_listener keyboard_listener = {&keyboard_keymap, &keyboard_enter, &keyboard_leave, &keyboard_key, &keyboard_modifiers, (void*)&RGFW_doNothing};
4408
4409static void seat_capabilities (void *data, struct wl_seat *seat, uint32_t capabilities) {
4410 RGFW_UNUSED(data);
4411
4412 if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
4413 struct wl_pointer *pointer = wl_seat_get_pointer (seat);
4414 wl_pointer_add_listener (pointer, &pointer_listener, NULL);
4415 }
4416 if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) {
4417 struct wl_keyboard *keyboard = wl_seat_get_keyboard (seat);
4418 wl_keyboard_add_listener (keyboard, &keyboard_listener, NULL);
4419 }
4420}
4421static struct wl_seat_listener seat_listener = {&seat_capabilities, (void*)&RGFW_doNothing};
4422
4423static void wl_global_registry_handler(void *data,
4424 struct wl_registry *registry, uint32_t id, const char *interface,
4425 uint32_t version)
4426{
4427 RGFW_UNUSED(data); RGFW_UNUSED(version);
4428
4429 if (strcmp(interface, "wl_compositor") == 0) {
4430 RGFW_compositor = wl_registry_bind(registry,
4431 id, &wl_compositor_interface, 4);
4432 } else if (strcmp(interface, "xdg_wm_base") == 0) {
4433 xdg_wm_base = wl_registry_bind(registry,
4434 id, &xdg_wm_base_interface, 1);
4435 } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
4436 decoration_manager = wl_registry_bind(registry, id, &zxdg_decoration_manager_v1_interface, 1);
4437 } else if (strcmp(interface, "wl_shm") == 0) {
4438 shm = wl_registry_bind(registry,
4439 id, &wl_shm_interface, 1);
4440 wl_shm_add_listener(shm, &shm_listener, NULL);
4441 } else if (strcmp(interface,"wl_seat") == 0) {
4442 seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
4443 wl_seat_add_listener(seat, &seat_listener, NULL);
4444 }
4445
4446 else {
4447 #ifdef RGFW_DEBUG
4448 printf("did not register %s\n", interface);
4449 return;
4450 #endif
4451 }
4452
4453 #ifdef RGFW_DEBUG
4454 printf("registered %s\n", interface);
4455 #endif
4456}
4457
4458static void wl_global_registry_remove(void *data, struct wl_registry *registry, uint32_t name) { RGFW_UNUSED(data); RGFW_UNUSED(registry); RGFW_UNUSED(name); }
4459static const struct wl_registry_listener registry_listener = {
4460 .global = wl_global_registry_handler,
4461 .global_remove = wl_global_registry_remove,
4462};
4463
4464static const char *get_mode_name(enum zxdg_toplevel_decoration_v1_mode mode) {
4465 switch (mode) {
4466 case ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE:
4467 return "client-side decorations";
4468 case ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE:
4469 return "server-side decorations";
4470 }
4471 abort();
4472}
4473
4474
4475static void decoration_handle_configure(void *data,
4476 struct zxdg_toplevel_decoration_v1 *decoration,
4477 enum zxdg_toplevel_decoration_v1_mode mode) {
4478 RGFW_UNUSED(data); RGFW_UNUSED(decoration);
4479 printf("Using %s\n", get_mode_name(mode));
4480 RGFW_current_mode = mode;
4481}
4482
4483static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = {
4484 .configure = decoration_handle_configure,
4485};
4486
4487static void randname(char *buf) {
4488 struct timespec ts;
4489 clock_gettime(CLOCK_REALTIME, &ts);
4490 long r = ts.tv_nsec;
4491 for (int i = 0; i < 6; ++i) {
4492 buf[i] = 'A'+(r&15)+(r&16)*2;
4493 r >>= 5;
4494 }
4495}
4496
4497static int anonymous_shm_open(void) {
4498 char name[] = "/RGFW-wayland-XXXXXX";
4499 int retries = 100;
4500
4501 do {
4502 randname(name + strlen(name) - 6);
4503
4504 --retries;
4505 // shm_open guarantees that O_CLOEXEC is set
4506 int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
4507 if (fd >= 0) {
4508 shm_unlink(name);
4509 return fd;
4510 }
4511 } while (retries > 0 && errno == EEXIST);
4512
4513 return -1;
4514}
4515
4516int create_shm_file(off_t size) {
4517 int fd = anonymous_shm_open();
4518 if (fd < 0) {
4519 return fd;
4520 }
4521
4522 if (ftruncate(fd, size) < 0) {
4523 close(fd);
4524 return -1;
4525 }
4526
4527 return fd;
4528}
4529
4530static void wl_surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) {
4531 #ifdef RGFW_BUFFER
4532 RGFW_window* win = (RGFW_window*)data;
4533 if ((win->_winArgs & RGFW_NO_CPU_RENDER))
4534 return;
4535
4536 #ifndef RGFW_X11_DONT_CONVERT_BGR
4537 u32 x, y;
4538 for (y = 0; y < (u32)win->r.h; y++) {
4539 for (x = 0; x < (u32)win->r.w; x++) {
4540 u32 index = (y * 4 * win->r.w) + x * 4;
4541
4542 u8 red = win->buffer[index];
4543 win->buffer[index] = win->buffer[index + 2];
4544 win->buffer[index + 2] = red;
4545
4546 }
4547 }
4548 #endif
4549
4550 wl_surface_attach(win->src.surface, win->src.wl_buffer, 0, 0);
4551 wl_surface_damage_buffer(win->src.surface, 0, 0, win->r.w, win->r.h);
4552 wl_surface_commit(win->src.surface);
4553 #endif
4554}
4555
4556static const struct wl_callback_listener wl_surface_frame_listener = {
4557 .done = wl_surface_frame_done,
4558};
4559
4560
4561 /* normal wayland RGFW stuff */
4562
4563 RGFW_area RGFW_getScreenSize(void) {
4564 RGFW_area area = {};
4565
4566 if (RGFW_root != NULL)
4567 /* this isn't right but it's here for buffers */
4568 area = RGFW_AREA(RGFW_root->r.w, RGFW_root->r.h);
4569
4570 /* TODO wayland */
4571 return area;
4572 }
4573
4574 void RGFW_releaseCursor(RGFW_window* win) {
4575 RGFW_UNUSED(win);
4576 }
4577
4578 void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) {
4579 RGFW_UNUSED(win); RGFW_UNUSED(r);
4580
4581 /* TODO wayland */
4582 }
4583
4584
4585 RGFWDEF void RGFW_init_buffer(RGFW_window* win);
4586 void RGFW_init_buffer(RGFW_window* win) {
4587 #if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
4588 size_t size = win->r.w * win->r.h * 4;
4589 int fd = create_shm_file(size);
4590 if (fd < 0) {
4591 fprintf(stderr, "Failed to create a buffer. size: %ld\n", size);
4592 exit(1);
4593 }
4594
4595 win->buffer = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
4596 if (win->buffer == MAP_FAILED) {
4597 fprintf(stderr, "mmap failed!\n");
4598 close(fd);
4599 exit(1);
4600 }
4601
4602 struct wl_shm_pool* pool = wl_shm_create_pool(shm, fd, size);
4603 win->src.wl_buffer = wl_shm_pool_create_buffer(pool, 0, win->r.w, win->r.h, win->r.w * 4,
4604 WL_SHM_FORMAT_ARGB8888);
4605 wl_shm_pool_destroy(pool);
4606
4607 close(fd);
4608
4609 wl_surface_attach(win->src.surface, win->src.wl_buffer, 0, 0);
4610 wl_surface_commit(win->src.surface);
4611
4612 u8 color[] = {0x00, 0x00, 0x00, 0xFF};
4613
4614 size_t i;
4615 for (i = 0; i < size; i += 4) {
4616 memcpy(&win->buffer[i], color, 4);
4617 }
4618
4619 #if defined(RGFW_OSMESA)
4620 win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
4621 OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h);
4622 #endif
4623 #else
4624 RGFW_UNUSED(win);
4625 #endif
4626 }
4627
4628
4629 RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
4630 RGFW_window* win = RGFW_window_basic_init(rect, args);
4631
4632 fprintf(stderr, "Warning: RGFW Wayland support is experimental\n");
4633
4634 win->src.display = wl_display_connect(NULL);
4635 if (win->src.display == NULL) {
4636 #ifdef RGFW_DEBUG
4637 fprintf(stderr, "Failed to load Wayland display\n");
4638 #endif
4639 return NULL;
4640 }
4641
4642 struct wl_registry *registry = wl_display_get_registry(win->src.display);
4643 wl_registry_add_listener(registry, &registry_listener, NULL);
4644
4645 wl_display_dispatch(win->src.display);
4646 wl_display_roundtrip(win->src.display);
4647
4648 if (RGFW_compositor == NULL) {
4649 #ifdef RGFW_DEBUG
4650 fprintf(stderr, "Can't find compositor.\n");
4651 #endif
4652
4653 return NULL;
4654 }
4655
4656 if (RGFW_wl_cursor_theme == NULL) {
4657 RGFW_wl_cursor_theme = wl_cursor_theme_load(NULL, 24, shm);
4658 RGFW_cursor_surface = wl_compositor_create_surface(RGFW_compositor);
4659
4660 struct wl_cursor* cursor = wl_cursor_theme_get_cursor(RGFW_wl_cursor_theme, "left_ptr");
4661 RGFW_cursor_image = cursor->images[0];
4662 struct wl_buffer* cursor_buffer = wl_cursor_image_get_buffer(RGFW_cursor_image);
4663
4664 wl_surface_attach(RGFW_cursor_surface, cursor_buffer, 0, 0);
4665 wl_surface_commit(RGFW_cursor_surface);
4666 }
4667
4668 if (RGFW_root == NULL)
4669 xdg_wm_base_add_listener(xdg_wm_base, &xdg_wm_base_listener, NULL);
4670
4671 xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
4672
4673 win->src.surface = wl_compositor_create_surface(RGFW_compositor);
4674 wl_surface_set_user_data(win->src.surface, win);
4675
4676 win->src.xdg_surface = xdg_wm_base_get_xdg_surface(xdg_wm_base, win->src.surface);
4677 xdg_surface_add_listener(win->src.xdg_surface, &xdg_surface_listener, NULL);
4678
4679 xdg_wm_base_set_user_data(xdg_wm_base, win);
4680
4681 win->src.xdg_toplevel = xdg_surface_get_toplevel(win->src.xdg_surface);
4682 xdg_toplevel_set_user_data(win->src.xdg_toplevel, win);
4683 xdg_toplevel_set_title(win->src.xdg_toplevel, name);
4684 xdg_toplevel_add_listener(win->src.xdg_toplevel, &xdg_toplevel_listener, NULL);
4685
4686 xdg_surface_set_window_geometry(win->src.xdg_surface, 0, 0, win->r.w, win->r.h);
4687
4688 if (!(args & RGFW_NO_BORDER)) {
4689 win->src.decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
4690 decoration_manager, win->src.xdg_toplevel);
4691 }
4692
4693 if (args & RGFW_CENTER) {
4694 RGFW_area screenR = RGFW_getScreenSize();
4695 RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
4696 }
4697
4698 if (args & RGFW_OPENGL_SOFTWARE)
4699 setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);
4700
4701 wl_display_roundtrip(win->src.display);
4702
4703 wl_surface_commit(win->src.surface);
4704
4705 /* wait for the surface to be configured */
4706 while (wl_display_dispatch(win->src.display) != -1 && !RGFW_wl_configured) { }
4707
4708
4709 #ifdef RGFW_OPENGL
4710 if ((args & RGFW_NO_INIT_API) == 0) {
4711 win->src.window = wl_egl_window_create(win->src.surface, win->r.w, win->r.h);
4712 RGFW_createOpenGLContext(win);
4713 }
4714 #endif
4715
4716 RGFW_init_buffer(win);
4717
4718 struct wl_callback* callback = wl_surface_frame(win->src.surface);
4719 wl_callback_add_listener(callback, &wl_surface_frame_listener, win);
4720 wl_surface_commit(win->src.surface);
4721
4722 if (args & RGFW_HIDE_MOUSE) {
4723 RGFW_window_showMouse(win, 0);
4724 }
4725
4726 if (RGFW_root == NULL) {
4727 RGFW_root = win;
4728 }
4729
4730 win->src.eventIndex = 0;
4731 win->src.eventLen = 0;
4732
4733 return win;
4734 }
4735
4736 RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
4737 if (win->_winArgs & RGFW_WINDOW_HIDE)
4738 return NULL;
4739
4740 if (win->src.eventIndex == 0) {
4741 if (wl_display_roundtrip(win->src.display) == -1) {
4742 return NULL;
4743 }
4744 RGFW_resetKey();
4745 }
4746
4747 #ifdef __linux__
4748 RGFW_Event* event = RGFW_linux_updateJoystick(win);
4749 if (event != NULL)
4750 return event;
4751 #endif
4752
4753 if (win->src.eventLen == 0) {
4754 return NULL;
4755 }
4756
4757 RGFW_Event ev = RGFW_eventPipe_pop(win);
4758
4759 if (ev.type == 0 || win->event.type == RGFW_quit) {
4760 return NULL;
4761 }
4762
4763 ev.frameTime = win->event.frameTime;
4764 ev.frameTime2 = win->event.frameTime2;
4765 ev.inFocus = win->event.inFocus;
4766 win->event = ev;
4767
4768 return &win->event;
4769 }
4770
4771
4772 void RGFW_window_resize(RGFW_window* win, RGFW_area a) {
4773 RGFW_UNUSED(win); RGFW_UNUSED(a);
4774
4775 /* TODO wayland */
4776 }
4777
4778 void RGFW_window_move(RGFW_window* win, RGFW_point v) {
4779 RGFW_UNUSED(win); RGFW_UNUSED(v);
4780
4781 /* TODO wayland */
4782 }
4783
4784 void RGFW_window_setIcon(RGFW_window* win, u8* src, RGFW_area a, i32 channels) {
4785 RGFW_UNUSED(win); RGFW_UNUSED(src); RGFW_UNUSED(a); RGFW_UNUSED(channels)
4786 /* TODO wayland */
4787 }
4788
4789 void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v) {
4790 RGFW_UNUSED(win); RGFW_UNUSED(v);
4791
4792 /* TODO wayland */
4793 }
4794
4795 void RGFW_window_showMouse(RGFW_window* win, i8 show) {
4796 RGFW_UNUSED(win);
4797
4798 if (show) {
4799
4800 }
4801 else {
4802
4803 }
4804
4805 /* TODO wayland */
4806 }
4807
4808 b8 RGFW_window_isMaximized(RGFW_window* win) {
4809 RGFW_UNUSED(win);
4810 /* TODO wayland */
4811 return 0;
4812 }
4813
4814 b8 RGFW_window_isMinimized(RGFW_window* win) {
4815 RGFW_UNUSED(win);
4816 /* TODO wayland */
4817 return 0;
4818 }
4819
4820 b8 RGFW_window_isHidden(RGFW_window* win) {
4821 RGFW_UNUSED(win);
4822 /* TODO wayland */
4823 return 0;
4824 }
4825
4826 b8 RGFW_window_isFullscreen(RGFW_window* win) {
4827 RGFW_UNUSED(win);
4828 /* TODO wayland */
4829 return 0;
4830 }
4831
4832 RGFW_point RGFW_window_getMousePoint(RGFW_window* win) {
4833 RGFW_UNUSED(win);
4834 /* TODO wayland */
4835 return RGFW_POINT(0, 0);
4836 }
4837
4838 RGFW_point RGFW_getGlobalMousePoint(void) {
4839 /* TODO wayland */
4840 return RGFW_POINT(0, 0);
4841 }
4842
4843 void RGFW_window_show(RGFW_window* win) {
4844 //wl_surface_attach(win->src.surface, win->rc., 0, 0);
4845 wl_surface_commit(win->src.surface);
4846
4847 if (win->_winArgs & RGFW_WINDOW_HIDE)
4848 win->_winArgs ^= RGFW_WINDOW_HIDE;
4849 }
4850
4851 void RGFW_window_hide(RGFW_window* win) {
4852 wl_surface_attach(win->src.surface, NULL, 0, 0);
4853 wl_surface_commit(win->src.surface);
4854 win->_winArgs |= RGFW_WINDOW_HIDE;
4855 }
4856
4857 void RGFW_window_setMouseDefault(RGFW_window* win) {
4858 RGFW_UNUSED(win);
4859
4860 RGFW_window_setMouseStandard(win, RGFW_MOUSE_NORMAL);
4861 }
4862
4863 void RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
4864 RGFW_UNUSED(win);
4865
4866 static const char* iconStrings[] = { "left_ptr", "left_ptr", "text", "cross", "pointer", "e-resize", "n-resize", "nw-resize", "ne-resize", "all-resize", "not-allowed" };
4867
4868 struct wl_cursor* cursor = wl_cursor_theme_get_cursor(RGFW_wl_cursor_theme, iconStrings[mouse]);
4869 RGFW_cursor_image = cursor->images[0];
4870 struct wl_buffer* cursor_buffer = wl_cursor_image_get_buffer(RGFW_cursor_image);
4871
4872 wl_surface_attach(RGFW_cursor_surface, cursor_buffer, 0, 0);
4873 wl_surface_commit(RGFW_cursor_surface);
4874 }
4875
4876 void RGFW_window_setMouse(RGFW_window* win, u8* image, RGFW_area a, i32 channels) {
4877 RGFW_UNUSED(win); RGFW_UNUSED(image); RGFW_UNUSED(a); RGFW_UNUSED(channels)
4878 //struct wl_cursor* cursor = wl_cursor_theme_get_cursor(RGFW_wl_cursor_theme, iconStrings[mouse]);
4879 //RGFW_cursor_image = image;
4880 struct wl_buffer* cursor_buffer = wl_cursor_image_get_buffer(RGFW_cursor_image);
4881
4882 wl_surface_attach(RGFW_cursor_surface, cursor_buffer, 0, 0);
4883 wl_surface_commit(RGFW_cursor_surface);
4884 }
4885
4886 void RGFW_window_setName(RGFW_window* win, char* name) {
4887 xdg_toplevel_set_title(win->src.xdg_toplevel, name);
4888 }
4889
4890 void RGFW_window_setMousePassthrough(RGFW_window* win, b8 passthrough) {
4891 RGFW_UNUSED(win); RGFW_UNUSED(passthrough);
4892
4893 /* TODO wayland */
4894 }
4895
4896 void RGFW_window_setBorder(RGFW_window* win, b8 border) {
4897 RGFW_UNUSED(win); RGFW_UNUSED(border);
4898
4899 /* TODO wayland */
4900 }
4901
4902 void RGFW_window_restore(RGFW_window* win) {
4903 RGFW_UNUSED(win);
4904
4905 /* TODO wayland */
4906 }
4907
4908 void RGFW_window_minimize(RGFW_window* win) {
4909 RGFW_UNUSED(win);
4910
4911 /* TODO wayland */
4912 }
4913
4914 void RGFW_window_setMaxSize(RGFW_window* win, RGFW_area a) {
4915 RGFW_UNUSED(win); RGFW_UNUSED(a);
4916
4917 /* TODO wayland */
4918 }
4919
4920 void RGFW_window_setMinSize(RGFW_window* win, RGFW_area a) {
4921 RGFW_UNUSED(win); RGFW_UNUSED(a);
4922
4923 /* TODO wayland */
4924 }
4925
4926 RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) {
4927 RGFW_monitor m = {};
4928 RGFW_UNUSED(win);
4929 RGFW_UNUSED(m);
4930 /* TODO wayland */
4931
4932 return m;
4933 }
4934
4935
4936 #ifndef RGFW_EGL
4937 void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) { RGFW_UNUSED(win); RGFW_UNUSED(swapInterval); }
4938 #endif
4939
4940 void RGFW_window_swapBuffers(RGFW_window* win) {
4941 assert(win != NULL);
4942
4943 /* clear the window*/
4944 #ifdef RGFW_BUFFER
4945 wl_surface_frame_done(win, NULL, 0);
4946 if (!(win->_winArgs & RGFW_NO_GPU_RENDER))
4947 #endif
4948 {
4949 #ifdef RGFW_OPENGL
4950 eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface);
4951 #endif
4952 }
4953
4954 wl_display_flush(win->src.display);
4955 }
4956
4957 void RGFW_window_close(RGFW_window* win) {
4958 #ifdef RGFW_EGL
4959 RGFW_closeEGL(win);
4960 #endif
4961
4962 if (RGFW_root == win) {
4963 RGFW_root = NULL;
4964 }
4965
4966 xdg_toplevel_destroy(win->src.xdg_toplevel);
4967 xdg_surface_destroy(win->src.xdg_surface);
4968 wl_surface_destroy(win->src.surface);
4969
4970 #ifdef RGFW_BUFFER
4971 wl_buffer_destroy(win->src.wl_buffer);
4972 #endif
4973
4974 wl_display_disconnect(win->src.display);
4975 RGFW_FREE(win);
4976 }
4977
4978 RGFW_monitor RGFW_getPrimaryMonitor(void) {
4979 /* TODO wayland */
4980
4981 return (RGFW_monitor){};
4982 }
4983
4984 RGFW_monitor* RGFW_getMonitors(void) {
4985 /* TODO wayland */
4986
4987 return NULL;
4988 }
4989
4990 void RGFW_writeClipboard(const char* text, u32 textLen) {
4991 RGFW_UNUSED(text); RGFW_UNUSED(textLen);
4992
4993 /* TODO wayland */
4994 }
4995
4996 char* RGFW_readClipboard(size_t* size) {
4997 RGFW_UNUSED(size);
4998
4999 /* TODO wayland */
5000
5001 return NULL;
5002 }
5003#endif /* RGFW_WAYLAND */
5004
5005/*
5006 End of Wayland defines
5007*/
5008
5009
5010/*
5011
5012 Start of Windows defines
5013
5014
5015*/
5016
5017#ifdef RGFW_WINDOWS
5018 #define WIN32_LEAN_AND_MEAN
5019 #define OEMRESOURCE
5020 #include <windows.h>
5021
5022 #include <processthreadsapi.h>
5023 #include <wchar.h>
5024 #include <locale.h>
5025 #include <windowsx.h>
5026 #include <shellapi.h>
5027 #include <shellscalingapi.h>
5028
5029 #include <winuser.h>
5030
5031 __declspec(dllimport) int __stdcall WideCharToMultiByte( UINT CodePage, DWORD dwFlags, const WCHAR* lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar);
5032
5033 #ifndef RGFW_NO_XINPUT
5034 typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
5035 PFN_XInputGetState XInputGetStateSRC = NULL;
5036 #define XInputGetState XInputGetStateSRC
5037
5038 typedef DWORD (WINAPI * PFN_XInputGetKeystroke)(DWORD, DWORD, PXINPUT_KEYSTROKE);
5039 PFN_XInputGetKeystroke XInputGetKeystrokeSRC = NULL;
5040 #define XInputGetKeystroke XInputGetKeystrokeSRC
5041
5042 static HMODULE RGFW_XInput_dll = NULL;
5043 #endif
5044
5045 u32 RGFW_mouseIconSrc[] = {OCR_NORMAL, OCR_NORMAL, OCR_IBEAM, OCR_CROSS, OCR_HAND, OCR_SIZEWE, OCR_SIZENS, OCR_SIZENWSE, OCR_SIZENESW, OCR_SIZEALL, OCR_NO};
5046
5047 char* createUTF8FromWideStringWin32(const WCHAR* source);
5048
5049#define GL_FRONT 0x0404
5050#define GL_BACK 0x0405
5051#define GL_LEFT 0x0406
5052#define GL_RIGHT 0x0407
5053
5054#if defined(RGFW_OSMESA) && defined(RGFW_LINK_OSMESA)
5055
5056 typedef void (GLAPIENTRY* PFN_OSMesaDestroyContext)(OSMesaContext);
5057 typedef i32(GLAPIENTRY* PFN_OSMesaMakeCurrent)(OSMesaContext, void*, int, int, int);
5058 typedef OSMesaContext(GLAPIENTRY* PFN_OSMesaCreateContext)(GLenum, OSMesaContext);
5059
5060 PFN_OSMesaMakeCurrent OSMesaMakeCurrentSource;
5061 PFN_OSMesaCreateContext OSMesaCreateContextSource;
5062 PFN_OSMesaDestroyContext OSMesaDestroyContextSource;
5063
5064#define OSMesaCreateContext OSMesaCreateContextSource
5065#define OSMesaMakeCurrent OSMesaMakeCurrentSource
5066#define OSMesaDestroyContext OSMesaDestroyContextSource
5067#endif
5068
5069 typedef int (*PFN_wglGetSwapIntervalEXT)(void);
5070 PFN_wglGetSwapIntervalEXT wglGetSwapIntervalEXTSrc = NULL;
5071#define wglGetSwapIntervalEXT wglGetSwapIntervalEXTSrc
5072
5073
5074 void* RGFWjoystickApi = NULL;
5075
5076 /* these two wgl functions need to be preloaded */
5077 typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hdc, HGLRC hglrc, const int *attribList);
5078 PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL;
5079
5080 /* defines for creating ARB attributes */
5081#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
5082#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
5083#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
5084#define WGL_DRAW_TO_WINDOW_ARB 0x2001
5085#define WGL_ACCELERATION_ARB 0x2003
5086#define WGL_NO_ACCELERATION_ARB 0x2025
5087#define WGL_DOUBLE_BUFFER_ARB 0x2011
5088#define WGL_COLOR_BITS_ARB 0x2014
5089#define WGL_RED_BITS_ARB 0x2015
5090#define WGL_RED_SHIFT_ARB 0x2016
5091#define WGL_GREEN_BITS_ARB 0x2017
5092#define WGL_GREEN_SHIFT_ARB 0x2018
5093#define WGL_BLUE_BITS_ARB 0x2019
5094#define WGL_BLUE_SHIFT_ARB 0x201a
5095#define WGL_ALPHA_BITS_ARB 0x201b
5096#define WGL_ALPHA_SHIFT_ARB 0x201c
5097#define WGL_ACCUM_BITS_ARB 0x201d
5098#define WGL_ACCUM_RED_BITS_ARB 0x201e
5099#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
5100#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
5101#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
5102#define WGL_DEPTH_BITS_ARB 0x2022
5103#define WGL_AUX_BUFFERS_ARB 0x2024
5104#define WGL_STEREO_ARB 0x2012
5105#define WGL_DEPTH_BITS_ARB 0x2022
5106#define WGL_STENCIL_BITS_ARB 0x2023
5107#define WGL_FULL_ACCELERATION_ARB 0x2027
5108#define WGL_CONTEXT_FLAGS_ARB 0x2094
5109#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
5110#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
5111#define WGL_SAMPLE_BUFFERS_ARB 0x2041
5112#define WGL_SAMPLES_ARB 0x2042
5113#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
5114
5115#ifndef RGFW_EGL
5116static HMODULE wglinstance = NULL;
5117#endif
5118
5119#ifdef RGFW_WGL_LOAD
5120 typedef HGLRC(WINAPI* PFN_wglCreateContext)(HDC);
5121 typedef BOOL(WINAPI* PFN_wglDeleteContext)(HGLRC);
5122 typedef PROC(WINAPI* PFN_wglGetProcAddress)(LPCSTR);
5123 typedef BOOL(WINAPI* PFN_wglMakeCurrent)(HDC, HGLRC);
5124 typedef HDC(WINAPI* PFN_wglGetCurrentDC)();
5125 typedef HGLRC(WINAPI* PFN_wglGetCurrentContext)();
5126
5127 PFN_wglCreateContext wglCreateContextSRC;
5128 PFN_wglDeleteContext wglDeleteContextSRC;
5129 PFN_wglGetProcAddress wglGetProcAddressSRC;
5130 PFN_wglMakeCurrent wglMakeCurrentSRC;
5131 PFN_wglGetCurrentDC wglGetCurrentDCSRC;
5132 PFN_wglGetCurrentContext wglGetCurrentContextSRC;
5133
5134 #define wglCreateContext wglCreateContextSRC
5135 #define wglDeleteContext wglDeleteContextSRC
5136 #define wglGetProcAddress wglGetProcAddressSRC
5137 #define wglMakeCurrent wglMakeCurrentSRC
5138
5139 #define wglGetCurrentDC wglGetCurrentDCSRC
5140 #define wglGetCurrentContext wglGetCurrentContextSRC
5141#endif
5142
5143#ifdef RGFW_OPENGL
5144 void* RGFW_getProcAddress(const char* procname) {
5145 void* proc = (void*) wglGetProcAddress(procname);
5146 if (proc)
5147 return proc;
5148
5149 return (void*) GetProcAddress(wglinstance, procname);
5150 }
5151
5152 typedef HRESULT (APIENTRY* PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int* piAttribIList, const FLOAT* pfAttribFList, UINT nMaxFormats, int* piFormats, UINT* nNumFormats);
5153 static PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = NULL;
5154#endif
5155
5156 RGFW_window RGFW_eventWindow;
5157
5158 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
5159 switch (message) {
5160 case WM_MOVE:
5161 RGFW_eventWindow.r.x = LOWORD(lParam);
5162 RGFW_eventWindow.r.y = HIWORD(lParam);
5163 RGFW_eventWindow.src.window = hWnd;
5164 return DefWindowProcA(hWnd, message, wParam, lParam);
5165 case WM_SIZE:
5166 RGFW_eventWindow.r.w = LOWORD(lParam);
5167 RGFW_eventWindow.r.h = HIWORD(lParam);
5168 RGFW_eventWindow.src.window = hWnd;
5169 return DefWindowProcA(hWnd, message, wParam, lParam); // Call DefWindowProc after handling
5170 default:
5171 return DefWindowProcA(hWnd, message, wParam, lParam);
5172 }
5173 }
5174
5175 #ifndef RGFW_NO_DPI
5176 static HMODULE RGFW_Shcore_dll = NULL;
5177 typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
5178 PFN_GetDpiForMonitor GetDpiForMonitorSRC = NULL;
5179 #define GetDpiForMonitor GetDpiForMonitorSRC
5180 #endif
5181
5182 __declspec(dllimport) u32 __stdcall timeBeginPeriod(u32 uPeriod);
5183
5184 #ifndef RGFW_NO_XINPUT
5185 void RGFW_loadXInput(void) {
5186 u32 i;
5187 static const char* names[] = {
5188 "xinput1_4.dll",
5189 "xinput1_3.dll",
5190 "xinput9_1_0.dll",
5191 "xinput1_2.dll",
5192 "xinput1_1.dll"
5193 };
5194
5195 for (i = 0; i < sizeof(names) / sizeof(const char*); i++) {
5196 RGFW_XInput_dll = LoadLibraryA(names[i]);
5197
5198 if (RGFW_XInput_dll) {
5199 XInputGetStateSRC = (PFN_XInputGetState)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetState");
5200
5201 if (XInputGetStateSRC == NULL)
5202 printf("Failed to load XInputGetState");
5203 }
5204 }
5205 }
5206 #endif
5207
5208 RGFWDEF void RGFW_init_buffer(RGFW_window* win);
5209 void RGFW_init_buffer(RGFW_window* win) {
5210#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
5211 if (RGFW_bufferSize.w == 0 && RGFW_bufferSize.h == 0)
5212 RGFW_bufferSize = RGFW_getScreenSize();
5213
5214 BITMAPV5HEADER bi = { 0 };
5215 ZeroMemory(&bi, sizeof(bi));
5216 bi.bV5Size = sizeof(bi);
5217 bi.bV5Width = RGFW_bufferSize.w;
5218 bi.bV5Height = -((LONG) RGFW_bufferSize.h);
5219 bi.bV5Planes = 1;
5220 bi.bV5BitCount = 32;
5221 bi.bV5Compression = BI_BITFIELDS;
5222 bi.bV5BlueMask = 0x00ff0000;
5223 bi.bV5GreenMask = 0x0000ff00;
5224 bi.bV5RedMask = 0x000000ff;
5225 bi.bV5AlphaMask = 0xff000000;
5226
5227 win->src.bitmap = CreateDIBSection(win->src.hdc,
5228 (BITMAPINFO*) &bi,
5229 DIB_RGB_COLORS,
5230 (void**) &win->buffer,
5231 NULL,
5232 (DWORD) 0);
5233
5234 win->src.hdcMem = CreateCompatibleDC(win->src.hdc);
5235
5236 #if defined(RGFW_OSMESA)
5237 win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
5238 OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h);
5239 #endif
5240#else
5241RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
5242#endif
5243 }
5244
5245 void RGFW_window_setDND(RGFW_window* win, b8 allow) {
5246 DragAcceptFiles(win->src.window, allow);
5247 }
5248
5249 void RGFW_releaseCursor(RGFW_window* win) {
5250 RGFW_UNUSED(win);
5251 ClipCursor(NULL);
5252 const RAWINPUTDEVICE id = { 0x01, 0x02, RIDEV_REMOVE, NULL };
5253 RegisterRawInputDevices(&id, 1, sizeof(id));
5254 }
5255
5256 void RGFW_captureCursor(RGFW_window* win, RGFW_rect rect) {
5257 RGFW_UNUSED(win); RGFW_UNUSED(rect);
5258
5259 RECT clipRect;
5260 GetClientRect(win->src.window, &clipRect);
5261 ClientToScreen(win->src.window, (POINT*) &clipRect.left);
5262 ClientToScreen(win->src.window, (POINT*) &clipRect.right);
5263 ClipCursor(&clipRect);
5264
5265 const RAWINPUTDEVICE id = { 0x01, 0x02, 0, win->src.window };
5266 RegisterRawInputDevices(&id, 1, sizeof(id));
5267 }
5268
5269 RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
5270 #ifndef RGFW_NO_XINPUT
5271 if (RGFW_XInput_dll == NULL)
5272 RGFW_loadXInput();
5273 #endif
5274
5275 #ifndef RGFW_NO_DPI
5276 if (RGFW_Shcore_dll == NULL) {
5277 RGFW_Shcore_dll = LoadLibraryA("shcore.dll");
5278 GetDpiForMonitorSRC = (PFN_GetDpiForMonitor)(void*)GetProcAddress(RGFW_Shcore_dll, "GetDpiForMonitor");
5279 SetProcessDPIAware();
5280 }
5281 #endif
5282
5283 if (wglinstance == NULL) {
5284 wglinstance = LoadLibraryA("opengl32.dll");
5285#ifdef RGFW_WGL_LOAD
5286 wglCreateContextSRC = (PFN_wglCreateContext) GetProcAddress(wglinstance, "wglCreateContext");
5287 wglDeleteContextSRC = (PFN_wglDeleteContext) GetProcAddress(wglinstance, "wglDeleteContext");
5288 wglGetProcAddressSRC = (PFN_wglGetProcAddress) GetProcAddress(wglinstance, "wglGetProcAddress");
5289 wglMakeCurrentSRC = (PFN_wglMakeCurrent) GetProcAddress(wglinstance, "wglMakeCurrent");
5290 wglGetCurrentDCSRC = (PFN_wglGetCurrentDC) GetProcAddress(wglinstance, "wglGetCurrentDC");
5291 wglGetCurrentContextSRC = (PFN_wglGetCurrentContext) GetProcAddress(wglinstance, "wglGetCurrentContext");
5292#endif
5293 }
5294
5295 if (name[0] == 0) name = (char*) " ";
5296
5297 RGFW_eventWindow.r = RGFW_RECT(-1, -1, -1, -1);
5298 RGFW_eventWindow.src.window = NULL;
5299
5300 RGFW_window* win = RGFW_window_basic_init(rect, args);
5301
5302 win->src.maxSize = RGFW_AREA(0, 0);
5303 win->src.minSize = RGFW_AREA(0, 0);
5304
5305
5306 HINSTANCE inh = GetModuleHandleA(NULL);
5307
5308 #ifndef __cplusplus
5309 WNDCLASSA Class = { 0 }; /*!< Setup the Window class. */
5310 #else
5311 WNDCLASSA Class = { };
5312 #endif
5313
5314 if (RGFW_className == NULL)
5315 RGFW_className = (char*)name;
5316
5317 Class.lpszClassName = RGFW_className;
5318 Class.hInstance = inh;
5319 Class.hCursor = LoadCursor(NULL, IDC_ARROW);
5320 Class.lpfnWndProc = WndProc;
5321
5322 RegisterClassA(&Class);
5323
5324 DWORD window_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
5325
5326 RECT windowRect, clientRect;
5327
5328 if (!(args & RGFW_NO_BORDER)) {
5329 window_style |= WS_CAPTION | WS_SYSMENU | WS_BORDER | WS_MINIMIZEBOX;
5330
5331 if (!(args & RGFW_NO_RESIZE))
5332 window_style |= WS_SIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME;
5333 } else
5334 window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX;
5335
5336 HWND dummyWin = CreateWindowA(Class.lpszClassName, name, window_style, win->r.x, win->r.y, win->r.w, win->r.h, 0, 0, inh, 0);
5337
5338 GetWindowRect(dummyWin, &windowRect);
5339 GetClientRect(dummyWin, &clientRect);
5340
5341 win->src.hOffset = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top);
5342 win->src.window = CreateWindowA(Class.lpszClassName, name, window_style, win->r.x, win->r.y, win->r.w, win->r.h + win->src.hOffset, 0, 0, inh, 0);
5343
5344 if (args & RGFW_ALLOW_DND) {
5345 win->_winArgs |= RGFW_ALLOW_DND;
5346 RGFW_window_setDND(win, 1);
5347 }
5348 win->src.hdc = GetDC(win->src.window);
5349
5350 if ((args & RGFW_NO_INIT_API) == 0) {
5351#ifdef RGFW_DIRECTX
5352 assert(FAILED(CreateDXGIFactory(&__uuidof(IDXGIFactory), (void**) &RGFW_dxInfo.pFactory)) == 0);
5353
5354 if (FAILED(RGFW_dxInfo.pFactory->lpVtbl->EnumAdapters(RGFW_dxInfo.pFactory, 0, &RGFW_dxInfo.pAdapter))) {
5355 fprintf(stderr, "Failed to enumerate DXGI adapters\n");
5356 RGFW_dxInfo.pFactory->lpVtbl->Release(RGFW_dxInfo.pFactory);
5357 return NULL;
5358 }
5359
5360 D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0 };
5361
5362 if (FAILED(D3D11CreateDevice(RGFW_dxInfo.pAdapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, 0, featureLevels, 1, D3D11_SDK_VERSION, &RGFW_dxInfo.pDevice, NULL, &RGFW_dxInfo.pDeviceContext))) {
5363 fprintf(stderr, "Failed to create Direct3D device\n");
5364 RGFW_dxInfo.pAdapter->lpVtbl->Release(RGFW_dxInfo.pAdapter);
5365 RGFW_dxInfo.pFactory->lpVtbl->Release(RGFW_dxInfo.pFactory);
5366 return NULL;
5367 }
5368
5369 DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 };
5370 swapChainDesc.BufferCount = 1;
5371 swapChainDesc.BufferDesc.Width = win->r.w;
5372 swapChainDesc.BufferDesc.Height = win->r.h;
5373 swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
5374 swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
5375 swapChainDesc.OutputWindow = win->src.window;
5376 swapChainDesc.SampleDesc.Count = 1;
5377 swapChainDesc.SampleDesc.Quality = 0;
5378 swapChainDesc.Windowed = TRUE;
5379 RGFW_dxInfo.pFactory->lpVtbl->CreateSwapChain(RGFW_dxInfo.pFactory, (IUnknown*) RGFW_dxInfo.pDevice, &swapChainDesc, &win->src.swapchain);
5380
5381 ID3D11Texture2D* pBackBuffer;
5382 win->src.swapchain->lpVtbl->GetBuffer(win->src.swapchain, 0, &__uuidof(ID3D11Texture2D), (LPVOID*) &pBackBuffer);
5383 RGFW_dxInfo.pDevice->lpVtbl->CreateRenderTargetView(RGFW_dxInfo.pDevice, (ID3D11Resource*) pBackBuffer, NULL, &win->src.renderTargetView);
5384 pBackBuffer->lpVtbl->Release(pBackBuffer);
5385
5386 D3D11_TEXTURE2D_DESC depthStencilDesc = { 0 };
5387 depthStencilDesc.Width = win->r.w;
5388 depthStencilDesc.Height = win->r.h;
5389 depthStencilDesc.MipLevels = 1;
5390 depthStencilDesc.ArraySize = 1;
5391 depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
5392 depthStencilDesc.SampleDesc.Count = 1;
5393 depthStencilDesc.SampleDesc.Quality = 0;
5394 depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
5395 depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
5396
5397 ID3D11Texture2D* pDepthStencilTexture = NULL;
5398 RGFW_dxInfo.pDevice->lpVtbl->CreateTexture2D(RGFW_dxInfo.pDevice, &depthStencilDesc, NULL, &pDepthStencilTexture);
5399
5400 D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc = { 0 };
5401 depthStencilViewDesc.Format = depthStencilDesc.Format;
5402 depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
5403 depthStencilViewDesc.Texture2D.MipSlice = 0;
5404
5405 RGFW_dxInfo.pDevice->lpVtbl->CreateDepthStencilView(RGFW_dxInfo.pDevice, (ID3D11Resource*) pDepthStencilTexture, &depthStencilViewDesc, &win->src.pDepthStencilView);
5406
5407 pDepthStencilTexture->lpVtbl->Release(pDepthStencilTexture);
5408
5409 RGFW_dxInfo.pDeviceContext->lpVtbl->OMSetRenderTargets(RGFW_dxInfo.pDeviceContext, 1, &win->src.renderTargetView, win->src.pDepthStencilView);
5410#endif
5411
5412#ifdef RGFW_OPENGL
5413 HDC dummy_dc = GetDC(dummyWin);
5414
5415 u32 pfd_flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
5416
5417 //if (RGFW_DOUBLE_BUFFER)
5418 pfd_flags |= PFD_DOUBLEBUFFER;
5419
5420 PIXELFORMATDESCRIPTOR pfd = {
5421 sizeof(pfd),
5422 1, /* version */
5423 pfd_flags,
5424 PFD_TYPE_RGBA, /* ipixel type */
5425 24, /* color bits */
5426 0, 0, 0, 0, 0, 0,
5427 8, /* alpha bits */
5428 0, 0, 0, 0, 0, 0,
5429 32, /* depth bits */
5430 8, /* stencil bits */
5431 0,
5432 PFD_MAIN_PLANE, /* Layer type */
5433 0, 0, 0, 0
5434 };
5435
5436 int pixel_format = ChoosePixelFormat(dummy_dc, &pfd);
5437 SetPixelFormat(dummy_dc, pixel_format, &pfd);
5438
5439 HGLRC dummy_context = wglCreateContext(dummy_dc);
5440 wglMakeCurrent(dummy_dc, dummy_context);
5441
5442 if (wglChoosePixelFormatARB == NULL) {
5443 wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) (void*) wglGetProcAddress("wglCreateContextAttribsARB");
5444 wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) (void*)wglGetProcAddress("wglChoosePixelFormatARB");
5445 }
5446
5447 wglMakeCurrent(dummy_dc, 0);
5448 wglDeleteContext(dummy_context);
5449 ReleaseDC(dummyWin, dummy_dc);
5450
5451 /* try to create the pixel format we want for opengl and then try to create an opengl context for the specified version */
5452 if (wglCreateContextAttribsARB != NULL) {
5453 PIXELFORMATDESCRIPTOR pfd = {sizeof(pfd), 1, pfd_flags, PFD_TYPE_RGBA, 32, 8, PFD_MAIN_PLANE, 24, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
5454
5455 if (args & RGFW_OPENGL_SOFTWARE)
5456 pfd.dwFlags |= PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED;
5457
5458 if (wglChoosePixelFormatARB != NULL) {
5459 i32* pixel_format_attribs = (i32*)RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE);
5460
5461 int pixel_format;
5462 UINT num_formats;
5463 wglChoosePixelFormatARB(win->src.hdc, pixel_format_attribs, 0, 1, &pixel_format, &num_formats);
5464 if (!num_formats) {
5465 printf("Failed to create a pixel format for WGL.\n");
5466 }
5467
5468 DescribePixelFormat(win->src.hdc, pixel_format, sizeof(pfd), &pfd);
5469 if (!SetPixelFormat(win->src.hdc, pixel_format, &pfd)) {
5470 printf("Failed to set the WGL pixel format.\n");
5471 }
5472 }
5473
5474 /* create opengl/WGL context for the specified version */
5475 u32 index = 0;
5476 i32 attribs[40];
5477
5478 if (RGFW_profile == RGFW_GL_CORE) {
5479 SET_ATTRIB(WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB);
5480 }
5481 else {
5482 SET_ATTRIB(WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
5483 }
5484
5485 if (RGFW_majorVersion || RGFW_minorVersion) {
5486 SET_ATTRIB(WGL_CONTEXT_MAJOR_VERSION_ARB, RGFW_majorVersion);
5487 SET_ATTRIB(WGL_CONTEXT_MINOR_VERSION_ARB, RGFW_minorVersion);
5488 }
5489
5490 SET_ATTRIB(0, 0);
5491
5492 win->src.ctx = (HGLRC)wglCreateContextAttribsARB(win->src.hdc, NULL, attribs);
5493 } else { /* fall back to a default context (probably opengl 2 or something) */
5494 fprintf(stderr, "Failed to create an accelerated OpenGL Context\n");
5495
5496 int pixel_format = ChoosePixelFormat(win->src.hdc, &pfd);
5497 SetPixelFormat(win->src.hdc, pixel_format, &pfd);
5498
5499 win->src.ctx = wglCreateContext(win->src.hdc);
5500 }
5501
5502 wglMakeCurrent(win->src.hdc, win->src.ctx);
5503#endif
5504 }
5505
5506#ifdef RGFW_OSMESA
5507#ifdef RGFW_LINK_OSM ESA
5508 OSMesaMakeCurrentSource = (PFN_OSMesaMakeCurrent) GetProcAddress(win->src.hdc, "OSMesaMakeCurrent");
5509 OSMesaCreateContextSource = (PFN_OSMesaCreateContext) GetProcAddress(win->src.hdc, "OSMesaCreateContext");
5510 OSMesaDestroyContextSource = (PFN_OSMesaDestroyContext) GetProcAddress(win->src.hdc, "OSMesaDestroyContext");
5511#endif
5512#endif
5513
5514#ifdef RGFW_OPENGL
5515 if ((args & RGFW_NO_INIT_API) == 0) {
5516 ReleaseDC(win->src.window, win->src.hdc);
5517 win->src.hdc = GetDC(win->src.window);
5518 wglMakeCurrent(win->src.hdc, win->src.ctx);
5519 }
5520#endif
5521
5522 DestroyWindow(dummyWin);
5523 RGFW_init_buffer(win);
5524
5525
5526 #ifndef RGFW_NO_MONITOR
5527 if (args & RGFW_SCALE_TO_MONITOR)
5528 RGFW_window_scaleToMonitor(win);
5529 #endif
5530
5531 if (args & RGFW_CENTER) {
5532 RGFW_area screenR = RGFW_getScreenSize();
5533 RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
5534 }
5535
5536#ifdef RGFW_EGL
5537 if ((args & RGFW_NO_INIT_API) == 0)
5538 RGFW_createOpenGLContext(win);
5539#endif
5540
5541 if (args & RGFW_HIDE_MOUSE)
5542 RGFW_window_showMouse(win, 0);
5543
5544 if (args & RGFW_TRANSPARENT_WINDOW) {
5545 SetWindowLong(win->src.window, GWL_EXSTYLE, GetWindowLong(win->src.window, GWL_EXSTYLE) | WS_EX_LAYERED);
5546 SetLayeredWindowAttributes(win->src.window, RGB(255, 255, 255), RGFW_ALPHA, LWA_ALPHA);
5547 }
5548
5549 ShowWindow(win->src.window, SW_SHOWNORMAL);
5550
5551 if (RGFW_root == NULL)
5552 RGFW_root = win;
5553
5554 #ifdef RGFW_OPENGL
5555 else
5556 wglShareLists(RGFW_root->src.ctx, win->src.ctx);
5557 #endif
5558
5559 return win;
5560 }
5561
5562 void RGFW_window_setBorder(RGFW_window* win, u8 border) {
5563 DWORD style = GetWindowLong(win->src.window, GWL_STYLE);
5564
5565 if (border == 0) {
5566 SetWindowLong(win->src.window, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW);
5567 SetWindowPos(
5568 win->src.window, HWND_TOP, 0, 0, 0, 0,
5569 SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE
5570 );
5571 }
5572 else {
5573 SetWindowLong(win->src.window, GWL_STYLE, style | WS_OVERLAPPEDWINDOW);
5574 SetWindowPos(
5575 win->src.window, HWND_TOP, 0, 0, 0, 0,
5576 SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE
5577 );
5578 }
5579 }
5580
5581
5582 RGFW_area RGFW_getScreenSize(void) {
5583 return RGFW_AREA(GetDeviceCaps(GetDC(NULL), HORZRES), GetDeviceCaps(GetDC(NULL), VERTRES));
5584 }
5585
5586 RGFW_point RGFW_getGlobalMousePoint(void) {
5587 POINT p;
5588 GetCursorPos(&p);
5589
5590 return RGFW_POINT(p.x, p.y);
5591 }
5592
5593 RGFW_point RGFW_window_getMousePoint(RGFW_window* win) {
5594 POINT p;
5595 GetCursorPos(&p);
5596 ScreenToClient(win->src.window, &p);
5597
5598 return RGFW_POINT(p.x, p.y);
5599 }
5600
5601 void RGFW_window_setMinSize(RGFW_window* win, RGFW_area a) {
5602 assert(win != NULL);
5603 win->src.minSize = a;
5604 }
5605
5606 void RGFW_window_setMaxSize(RGFW_window* win, RGFW_area a) {
5607 assert(win != NULL);
5608 win->src.maxSize = a;
5609 }
5610
5611
5612 void RGFW_window_minimize(RGFW_window* win) {
5613 assert(win != NULL);
5614
5615 ShowWindow(win->src.window, SW_MINIMIZE);
5616 }
5617
5618 void RGFW_window_restore(RGFW_window* win) {
5619 assert(win != NULL);
5620
5621 ShowWindow(win->src.window, SW_RESTORE);
5622 }
5623
5624
5625 u8 RGFW_xinput2RGFW[] = {
5626 RGFW_JS_A, /* or PS X button */
5627 RGFW_JS_B, /* or PS circle button */
5628 RGFW_JS_X, /* or PS square button */
5629 RGFW_JS_Y, /* or PS triangle button */
5630 RGFW_JS_R1, /* right bumper */
5631 RGFW_JS_L1, /* left bump */
5632 RGFW_JS_L2, /* left trigger*/
5633 RGFW_JS_R2, /* right trigger */
5634 0, 0, 0, 0, 0, 0, 0, 0,
5635 RGFW_JS_UP, /* dpad up */
5636 RGFW_JS_DOWN, /* dpad down*/
5637 RGFW_JS_LEFT, /* dpad left */
5638 RGFW_JS_RIGHT, /* dpad right */
5639 RGFW_JS_START, /* start button */
5640 RGFW_JS_SELECT/* select button */
5641 };
5642
5643 static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) {
5644 RGFW_UNUSED(win)
5645
5646 size_t i;
5647 for (i = 0; i < 4; i++) {
5648 XINPUT_KEYSTROKE keystroke;
5649
5650 if (XInputGetKeystroke == NULL)
5651 return 0;
5652
5653 DWORD result = XInputGetKeystroke((DWORD)i, 0, &keystroke);
5654
5655 if ((keystroke.Flags & XINPUT_KEYSTROKE_REPEAT) == 0 && result != ERROR_EMPTY) {
5656 if (result != ERROR_SUCCESS)
5657 return 0;
5658
5659 if (keystroke.VirtualKey > VK_PAD_BACK)
5660 continue;
5661
5662 // RGFW_jsButtonPressed + 1 = RGFW_jsButtonReleased
5663 e->type = RGFW_jsButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
5664 e->button = RGFW_xinput2RGFW[keystroke.VirtualKey - 0x5800];
5665 RGFW_jsPressed[i][e->button] = !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
5666
5667 return 1;
5668 }
5669
5670 XINPUT_STATE state;
5671 if (XInputGetState == NULL ||
5672 XInputGetState((DWORD) i, &state) == ERROR_DEVICE_NOT_CONNECTED
5673 )
5674 return 0;
5675#define INPUT_DEADZONE ( 0.24f * (float)(0x7FFF) ) // Default to 24% of the +/- 32767 range. This is a reasonable default value but can be altered if needed.
5676
5677 if ((state.Gamepad.sThumbLX < INPUT_DEADZONE &&
5678 state.Gamepad.sThumbLX > -INPUT_DEADZONE) &&
5679 (state.Gamepad.sThumbLY < INPUT_DEADZONE &&
5680 state.Gamepad.sThumbLY > -INPUT_DEADZONE))
5681 {
5682 state.Gamepad.sThumbLX = 0;
5683 state.Gamepad.sThumbLY = 0;
5684 }
5685
5686 if ((state.Gamepad.sThumbRX < INPUT_DEADZONE &&
5687 state.Gamepad.sThumbRX > -INPUT_DEADZONE) &&
5688 (state.Gamepad.sThumbRY < INPUT_DEADZONE &&
5689 state.Gamepad.sThumbRY > -INPUT_DEADZONE))
5690 {
5691 state.Gamepad.sThumbRX = 0;
5692 state.Gamepad.sThumbRY = 0;
5693 }
5694
5695 e->axisesCount = 2;
5696 RGFW_point axis1 = RGFW_POINT(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY);
5697 RGFW_point axis2 = RGFW_POINT(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY);
5698
5699 if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y || axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) {
5700 e->type = RGFW_jsAxisMove;
5701
5702 e->axis[0] = axis1;
5703 e->axis[1] = axis2;
5704
5705 return 1;
5706 }
5707
5708 e->axis[0] = axis1;
5709 e->axis[1] = axis2;
5710 }
5711
5712 return 0;
5713 }
5714
5715 void RGFW_stopCheckEvents(void) {
5716 PostMessageW(RGFW_root->src.window, WM_NULL, 0, 0);
5717 }
5718
5719 void RGFW_window_eventWait(RGFW_window* win, i32 waitMS) {
5720 RGFW_UNUSED(win);
5721
5722 MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (waitMS * 1e3), QS_ALLINPUT);
5723 }
5724
5725 RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
5726 assert(win != NULL);
5727
5728 if (win->event.type == RGFW_quit) {
5729 return NULL;
5730 }
5731
5732 MSG msg;
5733
5734 if (RGFW_eventWindow.src.window == win->src.window) {
5735 if (RGFW_eventWindow.r.x != -1) {
5736 win->r.x = RGFW_eventWindow.r.x;
5737 win->r.y = RGFW_eventWindow.r.y;
5738 win->event.type = RGFW_windowMoved;
5739 RGFW_windowMoveCallback(win, win->r);
5740 }
5741
5742 if (RGFW_eventWindow.r.w != -1) {
5743 win->r.w = RGFW_eventWindow.r.w;
5744 win->r.h = RGFW_eventWindow.r.h;
5745 win->event.type = RGFW_windowResized;
5746 RGFW_windowResizeCallback(win, win->r);
5747 }
5748
5749 RGFW_eventWindow.src.window = NULL;
5750 RGFW_eventWindow.r = RGFW_RECT(-1, -1, -1, -1);
5751
5752 return &win->event;
5753 }
5754
5755
5756 static HDROP drop;
5757
5758 if (win->event.type == RGFW_dnd_init) {
5759 if (win->event.droppedFilesCount) {
5760 u32 i;
5761 for (i = 0; i < win->event.droppedFilesCount; i++)
5762 win->event.droppedFiles[i][0] = '\0';
5763 }
5764
5765 win->event.droppedFilesCount = 0;
5766 win->event.droppedFilesCount = DragQueryFileW(drop, 0xffffffff, NULL, 0);
5767 //win->event.droppedFiles = (char**)RGFW_CALLOC(win->event.droppedFilesCount, sizeof(char*));
5768
5769 u32 i;
5770 for (i = 0; i < win->event.droppedFilesCount; i++) {
5771 const UINT length = DragQueryFileW(drop, i, NULL, 0);
5772 WCHAR* buffer = (WCHAR*) RGFW_CALLOC((size_t) length + 1, sizeof(WCHAR));
5773
5774 DragQueryFileW(drop, i, buffer, length + 1);
5775 strncpy(win->event.droppedFiles[i], createUTF8FromWideStringWin32(buffer), RGFW_MAX_PATH);
5776 win->event.droppedFiles[i][RGFW_MAX_PATH - 1] = '\0';
5777 RGFW_FREE(buffer);
5778 }
5779
5780 DragFinish(drop);
5781 RGFW_dndCallback(win, win->event.droppedFiles, win->event.droppedFilesCount);
5782
5783 win->event.type = RGFW_dnd;
5784 return &win->event;
5785 }
5786
5787 win->event.inFocus = (GetForegroundWindow() == win->src.window);
5788
5789 if (RGFW_checkXInput(win, &win->event))
5790 return &win->event;
5791
5792 static BYTE keyboardState[256];
5793
5794 if (PeekMessageA(&msg, win->src.window, 0u, 0u, PM_REMOVE)) {
5795 switch (msg.message) {
5796 case WM_CLOSE:
5797 case WM_QUIT:
5798 RGFW_windowQuitCallback(win);
5799 win->event.type = RGFW_quit;
5800 break;
5801
5802 case WM_ACTIVATE:
5803 win->event.inFocus = (LOWORD(msg.wParam) == WA_INACTIVE);
5804
5805 if (win->event.inFocus) {
5806 win->event.type = RGFW_focusIn;
5807 RGFW_focusCallback(win, 1);
5808 }
5809 else {
5810 win->event.type = RGFW_focusOut;
5811 RGFW_focusCallback(win, 0);
5812 }
5813
5814 break;
5815
5816 case WM_PAINT:
5817 win->event.type = RGFW_windowRefresh;
5818 RGFW_windowRefreshCallback(win);
5819 break;
5820
5821 case WM_MOUSELEAVE:
5822 win->event.type = RGFW_mouseLeave;
5823 win->_winArgs |= RGFW_MOUSE_LEFT;
5824 RGFW_mouseNotifyCallBack(win, win->event.point, 0);
5825 break;
5826
5827 case WM_KEYUP: {
5828 win->event.keyCode = RGFW_apiKeyCodeToRGFW((u32) msg.wParam);
5829
5830 RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode);
5831
5832 static char keyName[16];
5833
5834 {
5835 GetKeyNameTextA((LONG) msg.lParam, keyName, 16);
5836
5837 if ((!(GetKeyState(VK_CAPITAL) & 0x0001) && !(GetKeyState(VK_SHIFT) & 0x8000)) ||
5838 ((GetKeyState(VK_CAPITAL) & 0x0001) && (GetKeyState(VK_SHIFT) & 0x8000))) {
5839 CharLowerBuffA(keyName, 16);
5840 }
5841 }
5842
5843 RGFW_updateLockState(win, (GetKeyState(VK_CAPITAL) & 0x0001), (GetKeyState(VK_NUMLOCK) & 0x0001));
5844
5845 strncpy(win->event.keyName, keyName, 16);
5846
5847 if (RGFW_isPressed(win, RGFW_ShiftL)) {
5848 ToAscii((UINT) msg.wParam, MapVirtualKey((UINT) msg.wParam, MAPVK_VK_TO_CHAR),
5849 keyboardState, (LPWORD) win->event.keyName, 0);
5850 }
5851
5852 win->event.type = RGFW_keyReleased;
5853 RGFW_keyboard[win->event.keyCode].current = 0;
5854 RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 0);
5855 break;
5856 }
5857 case WM_KEYDOWN: {
5858 win->event.keyCode = RGFW_apiKeyCodeToRGFW((u32) msg.wParam);
5859
5860 RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode);
5861
5862 static char keyName[16];
5863
5864 {
5865 GetKeyNameTextA((LONG) msg.lParam, keyName, 16);
5866
5867 if ((!(GetKeyState(VK_CAPITAL) & 0x0001) && !(GetKeyState(VK_SHIFT) & 0x8000)) ||
5868 ((GetKeyState(VK_CAPITAL) & 0x0001) && (GetKeyState(VK_SHIFT) & 0x8000))) {
5869 CharLowerBuffA(keyName, 16);
5870 }
5871 }
5872
5873 RGFW_updateLockState(win, (GetKeyState(VK_CAPITAL) & 0x0001), (GetKeyState(VK_NUMLOCK) & 0x0001));
5874
5875 strncpy(win->event.keyName, keyName, 16);
5876
5877 if (RGFW_isPressed(win, RGFW_ShiftL) & 0x8000) {
5878 ToAscii((UINT) msg.wParam, MapVirtualKey((UINT) msg.wParam, MAPVK_VK_TO_CHAR),
5879 keyboardState, (LPWORD) win->event.keyName, 0);
5880 }
5881
5882 win->event.type = RGFW_keyPressed;
5883 win->event.repeat = RGFW_isPressed(win, win->event.keyCode);
5884 RGFW_keyboard[win->event.keyCode].current = 1;
5885 RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 1);
5886 break;
5887 }
5888
5889 case WM_MOUSEMOVE:
5890 if ((win->_winArgs & RGFW_HOLD_MOUSE))
5891 break;
5892
5893 win->event.type = RGFW_mousePosChanged;
5894
5895 win->event.point.x = GET_X_LPARAM(msg.lParam);
5896 win->event.point.y = GET_Y_LPARAM(msg.lParam);
5897
5898 RGFW_mousePosCallback(win, win->event.point);
5899
5900 if (win->_winArgs & RGFW_MOUSE_LEFT) {
5901 win->_winArgs ^= RGFW_MOUSE_LEFT;
5902 win->event.type = RGFW_mouseEnter;
5903 RGFW_mouseNotifyCallBack(win, win->event.point, 1);
5904 }
5905
5906 break;
5907
5908 case WM_INPUT: {
5909 if (!(win->_winArgs & RGFW_HOLD_MOUSE))
5910 break;
5911
5912 unsigned size = sizeof(RAWINPUT);
5913 static RAWINPUT raw[sizeof(RAWINPUT)];
5914 GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, raw, &size, sizeof(RAWINPUTHEADER));
5915
5916 if (raw->header.dwType != RIM_TYPEMOUSE || (raw->data.mouse.lLastX == 0 && raw->data.mouse.lLastY == 0) )
5917 break;
5918
5919 win->event.type = RGFW_mousePosChanged;
5920 win->event.point.x = raw->data.mouse.lLastX;
5921 win->event.point.y = raw->data.mouse.lLastY;
5922 break;
5923 }
5924
5925 case WM_LBUTTONDOWN:
5926 win->event.button = RGFW_mouseLeft;
5927 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
5928 RGFW_mouseButtons[win->event.button].current = 1;
5929 win->event.type = RGFW_mouseButtonPressed;
5930 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
5931 break;
5932 case WM_RBUTTONDOWN:
5933 win->event.button = RGFW_mouseRight;
5934 win->event.type = RGFW_mouseButtonPressed;
5935 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
5936 RGFW_mouseButtons[win->event.button].current = 1;
5937 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
5938 break;
5939 case WM_MBUTTONDOWN:
5940 win->event.button = RGFW_mouseMiddle;
5941 win->event.type = RGFW_mouseButtonPressed;
5942 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
5943 RGFW_mouseButtons[win->event.button].current = 1;
5944 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
5945 break;
5946
5947 case WM_MOUSEWHEEL:
5948 if (msg.wParam > 0)
5949 win->event.button = RGFW_mouseScrollUp;
5950 else
5951 win->event.button = RGFW_mouseScrollDown;
5952
5953 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
5954 RGFW_mouseButtons[win->event.button].current = 1;
5955
5956 win->event.scroll = (SHORT) HIWORD(msg.wParam) / (double) WHEEL_DELTA;
5957
5958 win->event.type = RGFW_mouseButtonPressed;
5959 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
5960 break;
5961
5962 case WM_LBUTTONUP:
5963
5964 win->event.button = RGFW_mouseLeft;
5965 win->event.type = RGFW_mouseButtonReleased;
5966
5967 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
5968 RGFW_mouseButtons[win->event.button].current = 0;
5969 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 0);
5970 break;
5971 case WM_RBUTTONUP:
5972 win->event.button = RGFW_mouseRight;
5973 win->event.type = RGFW_mouseButtonReleased;
5974
5975 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
5976 RGFW_mouseButtons[win->event.button].current = 0;
5977 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 0);
5978 break;
5979 case WM_MBUTTONUP:
5980 win->event.button = RGFW_mouseMiddle;
5981 win->event.type = RGFW_mouseButtonReleased;
5982
5983 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
5984 RGFW_mouseButtons[win->event.button].current = 0;
5985 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 0);
5986 break;
5987
5988 /*
5989 much of this event is source from glfw
5990 */
5991 case WM_DROPFILES: {
5992 win->event.type = RGFW_dnd_init;
5993
5994 drop = (HDROP) msg.wParam;
5995 POINT pt;
5996
5997 /* Move the mouse to the position of the drop */
5998 DragQueryPoint(drop, &pt);
5999
6000 win->event.point.x = pt.x;
6001 win->event.point.y = pt.y;
6002
6003 RGFW_dndInitCallback(win, win->event.point);
6004 }
6005 break;
6006 case WM_GETMINMAXINFO:
6007 {
6008 if (win->src.maxSize.w == 0 && win->src.maxSize.h == 0)
6009 break;
6010
6011 MINMAXINFO* mmi = (MINMAXINFO*) msg.lParam;
6012 mmi->ptMinTrackSize.x = win->src.minSize.w;
6013 mmi->ptMinTrackSize.y = win->src.minSize.h;
6014 mmi->ptMaxTrackSize.x = win->src.maxSize.w;
6015 mmi->ptMaxTrackSize.y = win->src.maxSize.h;
6016 return 0;
6017 }
6018 default:
6019 win->event.type = 0;
6020 break;
6021 }
6022
6023 TranslateMessage(&msg);
6024 DispatchMessageA(&msg);
6025 }
6026
6027 else
6028 win->event.type = 0;
6029
6030 if (!IsWindow(win->src.window)) {
6031 win->event.type = RGFW_quit;
6032 RGFW_windowQuitCallback(win);
6033 }
6034
6035 if (win->event.type)
6036 return &win->event;
6037 else
6038 return NULL;
6039 }
6040
6041 u8 RGFW_window_isFullscreen(RGFW_window* win) {
6042 assert(win != NULL);
6043
6044 #ifndef __cplusplus
6045 WINDOWPLACEMENT placement = { 0 };
6046 #else
6047 WINDOWPLACEMENT placement = { };
6048 #endif
6049 GetWindowPlacement(win->src.window, &placement);
6050 return placement.showCmd == SW_SHOWMAXIMIZED;
6051 }
6052
6053 u8 RGFW_window_isHidden(RGFW_window* win) {
6054 assert(win != NULL);
6055
6056 return IsWindowVisible(win->src.window) == 0 && !RGFW_window_isMinimized(win);
6057 }
6058
6059 u8 RGFW_window_isMinimized(RGFW_window* win) {
6060 assert(win != NULL);
6061
6062 #ifndef __cplusplus
6063 WINDOWPLACEMENT placement = { 0 };
6064 #else
6065 WINDOWPLACEMENT placement = { };
6066 #endif
6067 GetWindowPlacement(win->src.window, &placement);
6068 return placement.showCmd == SW_SHOWMINIMIZED;
6069 }
6070
6071 u8 RGFW_window_isMaximized(RGFW_window* win) {
6072 assert(win != NULL);
6073
6074 #ifndef __cplusplus
6075 WINDOWPLACEMENT placement = { 0 };
6076 #else
6077 WINDOWPLACEMENT placement = { };
6078 #endif
6079 GetWindowPlacement(win->src.window, &placement);
6080 return placement.showCmd == SW_SHOWMAXIMIZED;
6081 }
6082
6083 typedef struct { int iIndex; HMONITOR hMonitor; } RGFW_mInfo;
6084 BOOL CALLBACK GetMonitorByHandle(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
6085 RGFW_UNUSED(hdcMonitor)
6086 RGFW_UNUSED(lprcMonitor)
6087
6088 RGFW_mInfo* info = (RGFW_mInfo*) dwData;
6089 if (info->hMonitor == hMonitor)
6090 return FALSE;
6091
6092 info->iIndex++;
6093 return TRUE;
6094 }
6095
6096 #ifndef RGFW_NO_MONITOR
6097 RGFW_monitor win32CreateMonitor(HMONITOR src) {
6098 RGFW_monitor monitor;
6099 MONITORINFO monitorInfo;
6100
6101 monitorInfo.cbSize = sizeof(MONITORINFO);
6102 GetMonitorInfoA(src, &monitorInfo);
6103
6104 RGFW_mInfo info;
6105 info.iIndex = 0;
6106 info.hMonitor = src;
6107
6108 /* get the monitor's index */
6109 if (EnumDisplayMonitors(NULL, NULL, GetMonitorByHandle, (LPARAM) &info)) {
6110 DISPLAY_DEVICEA dd;
6111 dd.cb = sizeof(dd);
6112
6113 /* loop through the devices until you find a device with the monitor's index */
6114 size_t deviceIndex;
6115 for (deviceIndex = 0; EnumDisplayDevicesA(0, (DWORD) deviceIndex, &dd, 0); deviceIndex++) {
6116 char* deviceName = dd.DeviceName;
6117 if (EnumDisplayDevicesA(deviceName, info.iIndex, &dd, 0)) {
6118 strncpy(monitor.name, dd.DeviceString, 128); /*!< copy the monitor's name */
6119 break;
6120 }
6121 }
6122 }
6123
6124 monitor.rect.x = monitorInfo.rcWork.left;
6125 monitor.rect.y = monitorInfo.rcWork.top;
6126 monitor.rect.w = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
6127 monitor.rect.h = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
6128
6129#ifndef RGFW_NO_DPI
6130 #ifndef USER_DEFAULT_SCREEN_DPI
6131 #define USER_DEFAULT_SCREEN_DPI 96
6132 #endif
6133
6134 if (GetDpiForMonitor != NULL) {
6135 u32 x, y;
6136 GetDpiForMonitor(src, MDT_EFFECTIVE_DPI, &x, &y);
6137
6138 monitor.scaleX = (float) (x) / (float) USER_DEFAULT_SCREEN_DPI;
6139 monitor.scaleY = (float) (y) / (float) USER_DEFAULT_SCREEN_DPI;
6140 }
6141#endif
6142
6143 HDC hdc = GetDC(NULL);
6144 /* get pixels per inch */
6145 i32 ppiX = GetDeviceCaps(hdc, LOGPIXELSX);
6146 i32 ppiY = GetDeviceCaps(hdc, LOGPIXELSY);
6147 ReleaseDC(NULL, hdc);
6148
6149 /* Calculate physical height in inches */
6150 monitor.physW = GetSystemMetrics(SM_CYSCREEN) / (float) ppiX;
6151 monitor.physH = GetSystemMetrics(SM_CXSCREEN) / (float) ppiY;
6152
6153 return monitor;
6154 }
6155 #endif /* RGFW_NO_MONITOR */
6156
6157
6158 #ifndef RGFW_NO_MONITOR
6159 RGFW_monitor RGFW_monitors[6];
6160 BOOL CALLBACK GetMonitorHandle(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
6161 RGFW_UNUSED(hdcMonitor)
6162 RGFW_UNUSED(lprcMonitor)
6163
6164 RGFW_mInfo* info = (RGFW_mInfo*) dwData;
6165
6166 if (info->iIndex >= 6)
6167 return FALSE;
6168
6169 RGFW_monitors[info->iIndex] = win32CreateMonitor(hMonitor);
6170 info->iIndex++;
6171
6172 return TRUE;
6173 }
6174
6175 RGFW_monitor RGFW_getPrimaryMonitor(void) {
6176 #ifdef __cplusplus
6177 return win32CreateMonitor(MonitorFromPoint({ 0, 0 }, MONITOR_DEFAULTTOPRIMARY));
6178 #else
6179 return win32CreateMonitor(MonitorFromPoint((POINT) { 0, 0 }, MONITOR_DEFAULTTOPRIMARY));
6180 #endif
6181 }
6182
6183 RGFW_monitor* RGFW_getMonitors(void) {
6184 RGFW_mInfo info;
6185 info.iIndex = 0;
6186 while (EnumDisplayMonitors(NULL, NULL, GetMonitorHandle, (LPARAM) &info));
6187
6188 return RGFW_monitors;
6189 }
6190
6191 RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) {
6192 HMONITOR src = MonitorFromWindow(win->src.window, MONITOR_DEFAULTTOPRIMARY);
6193 return win32CreateMonitor(src);
6194 }
6195 #endif
6196
6197 HICON RGFW_loadHandleImage(RGFW_window* win, u8* src, RGFW_area a, BOOL icon) {
6198 assert(win != NULL);
6199
6200 u32 i;
6201 HDC dc;
6202 HICON handle;
6203 HBITMAP color, mask;
6204 BITMAPV5HEADER bi;
6205 ICONINFO ii;
6206 u8* target = NULL;
6207 u8* source = src;
6208
6209 ZeroMemory(&bi, sizeof(bi));
6210 bi.bV5Size = sizeof(bi);
6211 bi.bV5Width = a.w;
6212 bi.bV5Height = -((LONG) a.h);
6213 bi.bV5Planes = 1;
6214 bi.bV5BitCount = 32;
6215 bi.bV5Compression = BI_BITFIELDS;
6216 bi.bV5RedMask = 0x00ff0000;
6217 bi.bV5GreenMask = 0x0000ff00;
6218 bi.bV5BlueMask = 0x000000ff;
6219 bi.bV5AlphaMask = 0xff000000;
6220
6221 dc = GetDC(NULL);
6222 color = CreateDIBSection(dc,
6223 (BITMAPINFO*) &bi,
6224 DIB_RGB_COLORS,
6225 (void**) &target,
6226 NULL,
6227 (DWORD) 0);
6228 ReleaseDC(NULL, dc);
6229
6230 mask = CreateBitmap(a.w, a.h, 1, 1, NULL);
6231
6232 for (i = 0; i < a.w * a.h; i++) {
6233 target[0] = source[2];
6234 target[1] = source[1];
6235 target[2] = source[0];
6236 target[3] = source[3];
6237 target += 4;
6238 source += 4;
6239 }
6240
6241 ZeroMemory(&ii, sizeof(ii));
6242 ii.fIcon = icon;
6243 ii.xHotspot = 0;
6244 ii.yHotspot = 0;
6245 ii.hbmMask = mask;
6246 ii.hbmColor = color;
6247
6248 handle = CreateIconIndirect(&ii);
6249
6250 DeleteObject(color);
6251 DeleteObject(mask);
6252
6253 return handle;
6254 }
6255
6256 void RGFW_window_setMouse(RGFW_window* win, u8* image, RGFW_area a, i32 channels) {
6257 assert(win != NULL);
6258 RGFW_UNUSED(channels)
6259
6260 HCURSOR cursor = (HCURSOR) RGFW_loadHandleImage(win, image, a, FALSE);
6261 SetClassLongPtrA(win->src.window, GCLP_HCURSOR, (LPARAM) cursor);
6262 SetCursor(cursor);
6263 DestroyCursor(cursor);
6264 }
6265
6266 void RGFW_window_setMouseDefault(RGFW_window* win) {
6267 RGFW_window_setMouseStandard(win, RGFW_MOUSE_ARROW);
6268 }
6269
6270 void RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
6271 assert(win != NULL);
6272
6273 if (mouse > (sizeof(RGFW_mouseIconSrc) / sizeof(u32)))
6274 return;
6275
6276 char* icon = MAKEINTRESOURCEA(RGFW_mouseIconSrc[mouse]);
6277
6278 SetClassLongPtrA(win->src.window, GCLP_HCURSOR, (LPARAM) LoadCursorA(NULL, icon));
6279 SetCursor(LoadCursorA(NULL, icon));
6280 }
6281
6282 void RGFW_window_hide(RGFW_window* win) {
6283 ShowWindow(win->src.window, SW_HIDE);
6284 }
6285
6286 void RGFW_window_show(RGFW_window* win) {
6287 ShowWindow(win->src.window, SW_RESTORE);
6288 }
6289
6290 void RGFW_window_close(RGFW_window* win) {
6291 assert(win != NULL);
6292
6293#ifdef RGFW_EGL
6294 RGFW_closeEGL(win);
6295#endif
6296
6297 if (win == RGFW_root) {
6298#ifdef RGFW_DIRECTX
6299 RGFW_dxInfo.pDeviceContext->lpVtbl->Release(RGFW_dxInfo.pDeviceContext);
6300 RGFW_dxInfo.pDevice->lpVtbl->Release(RGFW_dxInfo.pDevice);
6301 RGFW_dxInfo.pAdapter->lpVtbl->Release(RGFW_dxInfo.pAdapter);
6302 RGFW_dxInfo.pFactory->lpVtbl->Release(RGFW_dxInfo.pFactory);
6303#endif
6304
6305 if (RGFW_XInput_dll != NULL) {
6306 FreeLibrary(RGFW_XInput_dll);
6307 RGFW_XInput_dll = NULL;
6308 }
6309
6310 #ifndef RGFW_NO_DPI
6311 if (RGFW_Shcore_dll != NULL) {
6312 FreeLibrary(RGFW_Shcore_dll);
6313 RGFW_Shcore_dll = NULL;
6314 }
6315 #endif
6316
6317 if (wglinstance != NULL) {
6318 FreeLibrary(wglinstance);
6319 wglinstance = NULL;
6320 }
6321
6322 RGFW_root = NULL;
6323 }
6324
6325#ifdef RGFW_DIRECTX
6326 win->src.swapchain->lpVtbl->Release(win->src.swapchain);
6327 win->src.renderTargetView->lpVtbl->Release(win->src.renderTargetView);
6328 win->src.pDepthStencilView->lpVtbl->Release(win->src.pDepthStencilView);
6329#endif
6330
6331#ifdef RGFW_BUFFER
6332 DeleteDC(win->src.hdcMem);
6333 DeleteObject(win->src.bitmap);
6334#endif
6335
6336#ifdef RGFW_OPENGL
6337 wglDeleteContext((HGLRC) win->src.ctx); /*!< delete opengl context */
6338#endif
6339 DeleteDC(win->src.hdc); /*!< delete device context */
6340 DestroyWindow(win->src.window); /*!< delete window */
6341
6342#if defined(RGFW_OSMESA)
6343 if (win->buffer != NULL)
6344 RGFW_FREE(win->buffer);
6345#endif
6346
6347#ifdef RGFW_ALLOC_DROPFILES
6348 {
6349 u32 i;
6350 for (i = 0; i < RGFW_MAX_DROPS; i++)
6351 RGFW_FREE(win->event.droppedFiles[i]);
6352
6353
6354 RGFW_FREE(win->event.droppedFiles);
6355 }
6356#endif
6357
6358 RGFW_FREE(win);
6359 }
6360
6361 void RGFW_window_move(RGFW_window* win, RGFW_point v) {
6362 assert(win != NULL);
6363
6364 win->r.x = v.x;
6365 win->r.y = v.y;
6366 SetWindowPos(win->src.window, HWND_TOP, win->r.x, win->r.y, 0, 0, SWP_NOSIZE);
6367 }
6368
6369 void RGFW_window_resize(RGFW_window* win, RGFW_area a) {
6370 assert(win != NULL);
6371
6372 win->r.w = a.w;
6373 win->r.h = a.h;
6374 SetWindowPos(win->src.window, HWND_TOP, 0, 0, win->r.w, win->r.h + win->src.hOffset, SWP_NOMOVE);
6375 }
6376
6377
6378 void RGFW_window_setName(RGFW_window* win, char* name) {
6379 assert(win != NULL);
6380
6381 SetWindowTextA(win->src.window, name);
6382 }
6383
6384 /* sourced from GLFW */
6385 #ifndef RGFW_NO_PASSTHROUGH
6386 void RGFW_window_setMousePassthrough(RGFW_window* win, b8 passthrough) {
6387 assert(win != NULL);
6388
6389 COLORREF key = 0;
6390 BYTE alpha = 0;
6391 DWORD flags = 0;
6392 DWORD exStyle = GetWindowLongW(win->src.window, GWL_EXSTYLE);
6393
6394 if (exStyle & WS_EX_LAYERED)
6395 GetLayeredWindowAttributes(win->src.window, &key, &alpha, &flags);
6396
6397 if (passthrough)
6398 exStyle |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
6399 else
6400 {
6401 exStyle &= ~WS_EX_TRANSPARENT;
6402 // NOTE: Window opacity also needs the layered window style so do not
6403 // remove it if the window is alpha blended
6404 if (exStyle & WS_EX_LAYERED)
6405 {
6406 if (!(flags & LWA_ALPHA))
6407 exStyle &= ~WS_EX_LAYERED;
6408 }
6409 }
6410
6411 SetWindowLongW(win->src.window, GWL_EXSTYLE, exStyle);
6412
6413 if (passthrough) {
6414 SetLayeredWindowAttributes(win->src.window, key, alpha, flags);
6415 }
6416 }
6417 #endif
6418
6419 /* much of this function is sourced from GLFW */
6420 void RGFW_window_setIcon(RGFW_window* win, u8* src, RGFW_area a, i32 channels) {
6421 assert(win != NULL);
6422 #ifndef RGFW_WIN95
6423 RGFW_UNUSED(channels)
6424
6425 HICON handle = RGFW_loadHandleImage(win, src, a, TRUE);
6426
6427 SetClassLongPtrA(win->src.window, GCLP_HICON, (LPARAM) handle);
6428
6429 DestroyIcon(handle);
6430 #else
6431 RGFW_UNUSED(src)
6432 RGFW_UNUSED(a)
6433 RGFW_UNUSED(channels)
6434 #endif
6435 }
6436
6437 char* RGFW_readClipboard(size_t* size) {
6438 /* Open the clipboard */
6439 if (OpenClipboard(NULL) == 0)
6440 return (char*) "";
6441
6442 /* Get the clipboard data as a Unicode string */
6443 HANDLE hData = GetClipboardData(CF_UNICODETEXT);
6444 if (hData == NULL) {
6445 CloseClipboard();
6446 return (char*) "";
6447 }
6448
6449 wchar_t* wstr = (wchar_t*) GlobalLock(hData);
6450
6451 char* text;
6452
6453 {
6454 setlocale(LC_ALL, "en_US.UTF-8");
6455
6456 size_t textLen = wcstombs(NULL, wstr, 0);
6457 if (textLen == 0)
6458 return (char*) "";
6459
6460 text = (char*) RGFW_MALLOC((textLen * sizeof(char)) + 1);
6461
6462 wcstombs(text, wstr, (textLen) +1);
6463
6464 if (size != NULL)
6465 *size = textLen + 1;
6466
6467 text[textLen] = '\0';
6468 }
6469
6470 /* Release the clipboard data */
6471 GlobalUnlock(hData);
6472 CloseClipboard();
6473
6474 return text;
6475 }
6476
6477 void RGFW_writeClipboard(const char* text, u32 textLen) {
6478 HANDLE object;
6479 WCHAR* buffer;
6480
6481 object = GlobalAlloc(GMEM_MOVEABLE, (1 + textLen) * sizeof(WCHAR));
6482 if (!object)
6483 return;
6484
6485 buffer = (WCHAR*) GlobalLock(object);
6486 if (!buffer) {
6487 GlobalFree(object);
6488 return;
6489 }
6490
6491 MultiByteToWideChar(CP_UTF8, 0, text, -1, buffer, textLen);
6492 GlobalUnlock(object);
6493
6494 if (!OpenClipboard(RGFW_root->src.window)) {
6495 GlobalFree(object);
6496 return;
6497 }
6498
6499 EmptyClipboard();
6500 SetClipboardData(CF_UNICODETEXT, object);
6501 CloseClipboard();
6502 }
6503
6504 u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) {
6505 assert(win != NULL);
6506
6507 RGFW_UNUSED(jsNumber)
6508
6509 return RGFW_registerJoystickF(win, (char*) "");
6510 }
6511
6512 u16 RGFW_registerJoystickF(RGFW_window* win, char* file) {
6513 assert(win != NULL);
6514 RGFW_UNUSED(file)
6515
6516 return RGFW_joystickCount - 1;
6517 }
6518
6519 void RGFW_window_moveMouse(RGFW_window* win, RGFW_point p) {
6520 assert(win != NULL);
6521
6522 SetCursorPos(p.x, p.y);
6523 }
6524
6525 #ifdef RGFW_OPENGL
6526 void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
6527 if (win == NULL)
6528 wglMakeCurrent(NULL, NULL);
6529 else
6530 wglMakeCurrent(win->src.hdc, (HGLRC) win->src.ctx);
6531 }
6532 #endif
6533
6534 #ifndef RGFW_EGL
6535 void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) {
6536 assert(win != NULL);
6537
6538 #if defined(RGFW_OPENGL)
6539 typedef BOOL(APIENTRY* PFNWGLSWAPINTERVALEXTPROC)(int interval);
6540 static PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
6541 static void* loadSwapFunc = (void*) 1;
6542
6543 if (loadSwapFunc == NULL) {
6544 fprintf(stderr, "wglSwapIntervalEXT not supported\n");
6545 return;
6546 }
6547
6548 if (wglSwapIntervalEXT == NULL) {
6549 loadSwapFunc = (void*) wglGetProcAddress("wglSwapIntervalEXT");
6550 wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) loadSwapFunc;
6551 }
6552
6553 if (wglSwapIntervalEXT(swapInterval) == FALSE)
6554 fprintf(stderr, "Failed to set swap interval\n");
6555 #else
6556 RGFW_UNUSED(swapInterval);
6557 #endif
6558
6559 }
6560 #endif
6561
6562 void RGFW_window_swapBuffers(RGFW_window* win) {
6563 //assert(win != NULL);
6564 /* clear the window*/
6565
6566 if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) {
6567#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
6568 #ifdef RGFW_OSMESA
6569 RGFW_OSMesa_reorganize();
6570 #endif
6571
6572 HGDIOBJ oldbmp = SelectObject(win->src.hdcMem, win->src.bitmap);
6573 BitBlt(win->src.hdc, 0, 0, win->r.w, win->r.h, win->src.hdcMem, 0, 0, SRCCOPY);
6574 SelectObject(win->src.hdcMem, oldbmp);
6575#endif
6576 }
6577
6578 if (!(win->_winArgs & RGFW_NO_GPU_RENDER)) {
6579 #ifdef RGFW_EGL
6580 eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface);
6581 #elif defined(RGFW_OPENGL)
6582 SwapBuffers(win->src.hdc);
6583 #endif
6584
6585 #if defined(RGFW_WINDOWS) && defined(RGFW_DIRECTX)
6586 win->src.swapchain->lpVtbl->Present(win->src.swapchain, 0, 0);
6587 #endif
6588 }
6589 }
6590
6591 char* createUTF8FromWideStringWin32(const WCHAR* source) {
6592 char* target;
6593 i32 size;
6594
6595 size = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);
6596 if (!size) {
6597 return NULL;
6598 }
6599
6600 target = (char*) RGFW_CALLOC(size, 1);
6601
6602 if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL)) {
6603 RGFW_FREE(target);
6604 return NULL;
6605 }
6606
6607 return target;
6608 }
6609
6610 static inline LARGE_INTEGER RGFW_win32_initTimer(void) {
6611 static LARGE_INTEGER frequency = {{0, 0}};
6612 if (frequency.QuadPart == 0) {
6613 timeBeginPeriod(1);
6614 QueryPerformanceFrequency(&frequency);
6615 }
6616
6617 return frequency;
6618 }
6619
6620 u64 RGFW_getTimeNS(void) {
6621 LARGE_INTEGER frequency = RGFW_win32_initTimer();
6622
6623 LARGE_INTEGER counter;
6624 QueryPerformanceCounter(&counter);
6625
6626 return (u64) ((counter.QuadPart * 1e9) / frequency.QuadPart);
6627 }
6628
6629 u64 RGFW_getTime(void) {
6630 LARGE_INTEGER frequency = RGFW_win32_initTimer();
6631
6632 LARGE_INTEGER counter;
6633 QueryPerformanceCounter(&counter);
6634 return (u64) (counter.QuadPart / (double) frequency.QuadPart);
6635 }
6636
6637 void RGFW_sleep(u64 ms) {
6638 Sleep(ms);
6639 }
6640
6641#ifndef RGFW_NO_THREADS
6642 RGFW_thread RGFW_createThread(RGFW_threadFunc_ptr ptr, void* args) { return CreateThread(NULL, 0, ptr, args, 0, NULL); }
6643 void RGFW_cancelThread(RGFW_thread thread) { CloseHandle((HANDLE) thread); }
6644 void RGFW_joinThread(RGFW_thread thread) { WaitForSingleObject((HANDLE) thread, INFINITE); }
6645 void RGFW_setThreadPriority(RGFW_thread thread, u8 priority) { SetThreadPriority((HANDLE) thread, priority); }
6646#endif
6647#endif /* RGFW_WINDOWS */
6648
6649/*
6650 End of Windows defines
6651*/
6652
6653
6654
6655/*
6656
6657 Start of MacOS defines
6658
6659
6660*/
6661
6662#if defined(RGFW_MACOS)
6663 /*
6664 based on silicon.h
6665 start of cocoa wrapper
6666 */
6667
6668#include <CoreVideo/CVDisplayLink.h>
6669#include <ApplicationServices/ApplicationServices.h>
6670#include <objc/runtime.h>
6671#include <objc/message.h>
6672#include <mach/mach_time.h>
6673
6674 typedef CGRect NSRect;
6675 typedef CGPoint NSPoint;
6676 typedef CGSize NSSize;
6677
6678 typedef void NSBitmapImageRep;
6679 typedef void NSCursor;
6680 typedef void NSDraggingInfo;
6681 typedef void NSWindow;
6682 typedef void NSApplication;
6683 typedef void NSScreen;
6684 typedef void NSEvent;
6685 typedef void NSString;
6686 typedef void NSOpenGLContext;
6687 typedef void NSPasteboard;
6688 typedef void NSColor;
6689 typedef void NSArray;
6690 typedef void NSImageRep;
6691 typedef void NSImage;
6692 typedef void NSOpenGLView;
6693
6694
6695 typedef const char* NSPasteboardType;
6696 typedef unsigned long NSUInteger;
6697 typedef long NSInteger;
6698 typedef NSInteger NSModalResponse;
6699
6700#ifdef __arm64__
6701 /* ARM just uses objc_msgSend */
6702#define abi_objc_msgSend_stret objc_msgSend
6703#define abi_objc_msgSend_fpret objc_msgSend
6704#else /* __i386__ */
6705 /* x86 just uses abi_objc_msgSend_fpret and (NSColor *)objc_msgSend_id respectively */
6706#define abi_objc_msgSend_stret objc_msgSend_stret
6707#define abi_objc_msgSend_fpret objc_msgSend_fpret
6708#endif
6709
6710#define NSAlloc(nsclass) objc_msgSend_id((id)nsclass, sel_registerName("alloc"))
6711#define objc_msgSend_bool ((BOOL (*)(id, SEL))objc_msgSend)
6712#define objc_msgSend_void ((void (*)(id, SEL))objc_msgSend)
6713#define objc_msgSend_void_id ((void (*)(id, SEL, id))objc_msgSend)
6714#define objc_msgSend_uint ((NSUInteger (*)(id, SEL))objc_msgSend)
6715#define objc_msgSend_void_bool ((void (*)(id, SEL, BOOL))objc_msgSend)
6716#define objc_msgSend_bool_void ((BOOL (*)(id, SEL))objc_msgSend)
6717#define objc_msgSend_void_SEL ((void (*)(id, SEL, SEL))objc_msgSend)
6718#define objc_msgSend_id ((id (*)(id, SEL))objc_msgSend)
6719#define objc_msgSend_id_id ((id (*)(id, SEL, id))objc_msgSend)
6720#define objc_msgSend_id_bool ((BOOL (*)(id, SEL, id))objc_msgSend)
6721#define objc_msgSend_int ((id (*)(id, SEL, int))objc_msgSend)
6722#define objc_msgSend_arr ((id (*)(id, SEL, int))objc_msgSend)
6723#define objc_msgSend_ptr ((id (*)(id, SEL, void*))objc_msgSend)
6724#define objc_msgSend_class ((id (*)(Class, SEL))objc_msgSend)
6725#define objc_msgSend_class_char ((id (*)(Class, SEL, char*))objc_msgSend)
6726
6727 NSApplication* NSApp = NULL;
6728
6729 void NSRelease(id obj) {
6730 objc_msgSend_void(obj, sel_registerName("release"));
6731 }
6732
6733 #define release NSRelease
6734
6735 NSString* NSString_stringWithUTF8String(const char* str) {
6736 return ((id(*)(id, SEL, const char*))objc_msgSend)
6737 ((id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), str);
6738 }
6739
6740 const char* NSString_to_char(NSString* str) {
6741 return ((const char* (*)(id, SEL)) objc_msgSend) (str, sel_registerName("UTF8String"));
6742 }
6743
6744 void si_impl_func_to_SEL_with_name(const char* class_name, const char* register_name, void* function) {
6745 Class selected_class;
6746
6747 if (strcmp(class_name, "NSView") == 0) {
6748 selected_class = objc_getClass("ViewClass");
6749 } else if (strcmp(class_name, "NSWindow") == 0) {
6750 selected_class = objc_getClass("WindowClass");
6751 } else {
6752 selected_class = objc_getClass(class_name);
6753 }
6754
6755 class_addMethod(selected_class, sel_registerName(register_name), (IMP) function, 0);
6756 }
6757
6758 /* Header for the array. */
6759 typedef struct siArrayHeader {
6760 size_t count;
6761 /* TODO(EimaMei): Add a `type_width` later on. */
6762 } siArrayHeader;
6763
6764 /* Gets the header of the siArray. */
6765#define SI_ARRAY_HEADER(s) ((siArrayHeader*)s - 1)
6766
6767 void* si_array_init_reserve(size_t sizeof_element, size_t count) {
6768 siArrayHeader* ptr = malloc(sizeof(siArrayHeader) + (sizeof_element * count));
6769 void* array = ptr + sizeof(siArrayHeader);
6770
6771 siArrayHeader* header = SI_ARRAY_HEADER(array);
6772 header->count = count;
6773
6774 return array;
6775 }
6776
6777#define si_array_len(array) (SI_ARRAY_HEADER(array)->count)
6778#define si_func_to_SEL(class_name, function) si_impl_func_to_SEL_with_name(class_name, #function":", function)
6779 /* Creates an Objective-C method (SEL) from a regular C function with the option to set the register name.*/
6780#define si_func_to_SEL_with_name(class_name, register_name, function) si_impl_func_to_SEL_with_name(class_name, register_name":", function)
6781
6782 unsigned char* NSBitmapImageRep_bitmapData(NSBitmapImageRep* imageRep) {
6783 return ((unsigned char* (*)(id, SEL))objc_msgSend)
6784 (imageRep, sel_registerName("bitmapData"));
6785 }
6786
6787#define NS_ENUM(type, name) type name; enum
6788
6789 typedef NS_ENUM(NSUInteger, NSBitmapFormat) {
6790 NSBitmapFormatAlphaFirst = 1 << 0, // 0 means is alpha last (RGBA, CMYKA, etc.)
6791 NSBitmapFormatAlphaNonpremultiplied = 1 << 1, // 0 means is premultiplied
6792 NSBitmapFormatFloatingPointSamples = 1 << 2, // 0 is integer
6793
6794 NSBitmapFormatSixteenBitLittleEndian API_AVAILABLE(macos(10.10)) = (1 << 8),
6795 NSBitmapFormatThirtyTwoBitLittleEndian API_AVAILABLE(macos(10.10)) = (1 << 9),
6796 NSBitmapFormatSixteenBitBigEndian API_AVAILABLE(macos(10.10)) = (1 << 10),
6797 NSBitmapFormatThirtyTwoBitBigEndian API_AVAILABLE(macos(10.10)) = (1 << 11)
6798 };
6799
6800 NSBitmapImageRep* NSBitmapImageRep_initWithBitmapData(unsigned char** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, const char* colorSpaceName, NSBitmapFormat bitmapFormat, NSInteger rowBytes, NSInteger pixelBits) {
6801 void* func = sel_registerName("initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:");
6802
6803 return (NSBitmapImageRep*) ((id(*)(id, SEL, unsigned char**, NSInteger, NSInteger, NSInteger, NSInteger, bool, bool, const char*, NSBitmapFormat, NSInteger, NSInteger))objc_msgSend)
6804 (NSAlloc((id)objc_getClass("NSBitmapImageRep")), func, planes, width, height, bps, spp, alpha, isPlanar, NSString_stringWithUTF8String(colorSpaceName), bitmapFormat, rowBytes, pixelBits);
6805 }
6806
6807 NSColor* NSColor_colorWithSRGB(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha) {
6808 void* nsclass = objc_getClass("NSColor");
6809 void* func = sel_registerName("colorWithSRGBRed:green:blue:alpha:");
6810 return ((id(*)(id, SEL, CGFloat, CGFloat, CGFloat, CGFloat))objc_msgSend)
6811 (nsclass, func, red, green, blue, alpha);
6812 }
6813
6814 NSCursor* NSCursor_initWithImage(NSImage* newImage, NSPoint aPoint) {
6815 void* func = sel_registerName("initWithImage:hotSpot:");
6816 void* nsclass = objc_getClass("NSCursor");
6817
6818 return (NSCursor*) ((id(*)(id, SEL, id, NSPoint))objc_msgSend)
6819 (NSAlloc(nsclass), func, newImage, aPoint);
6820 }
6821
6822 void NSImage_addRepresentation(NSImage* image, NSImageRep* imageRep) {
6823 void* func = sel_registerName("addRepresentation:");
6824 objc_msgSend_void_id(image, func, imageRep);
6825 }
6826
6827 NSImage* NSImage_initWithSize(NSSize size) {
6828 void* func = sel_registerName("initWithSize:");
6829 return ((id(*)(id, SEL, NSSize))objc_msgSend)
6830 (NSAlloc((id)objc_getClass("NSImage")), func, size);
6831 }
6832#define NS_OPENGL_ENUM_DEPRECATED(minVers, maxVers) API_AVAILABLE(macos(minVers))
6833 typedef NS_ENUM(NSInteger, NSOpenGLContextParameter) {
6834 NSOpenGLContextParameterSwapInterval NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 222, /* 1 param. 0 -> Don't sync, 1 -> Sync to vertical retrace */
6835 NSOpenGLContextParametectxaceOrder NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 235, /* 1 param. 1 -> Above Window (default), -1 -> Below Window */
6836 NSOpenGLContextParametectxaceOpacity NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 236, /* 1 param. 1-> Surface is opaque (default), 0 -> non-opaque */
6837 NSOpenGLContextParametectxaceBackingSize NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 304, /* 2 params. Width/height of surface backing size */
6838 NSOpenGLContextParameterReclaimResources NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 308, /* 0 params. */
6839 NSOpenGLContextParameterCurrentRendererID NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 309, /* 1 param. Retrieves the current renderer ID */
6840 NSOpenGLContextParameterGPUVertexProcessing NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 310, /* 1 param. Currently processing vertices with GPU (get) */
6841 NSOpenGLContextParameterGPUFragmentProcessing NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 311, /* 1 param. Currently processing fragments with GPU (get) */
6842 NSOpenGLContextParameterHasDrawable NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 314, /* 1 param. Boolean returned if drawable is attached */
6843 NSOpenGLContextParameterMPSwapsInFlight NS_OPENGL_ENUM_DEPRECATED(10.0, 10.14) = 315, /* 1 param. Max number of swaps queued by the MP GL engine */
6844
6845 NSOpenGLContextParameterSwapRectangle API_DEPRECATED("", macos(10.0, 10.14)) = 200, /* 4 params. Set or get the swap rectangle {x, y, w, h} */
6846 NSOpenGLContextParameterSwapRectangleEnable API_DEPRECATED("", macos(10.0, 10.14)) = 201, /* Enable or disable the swap rectangle */
6847 NSOpenGLContextParameterRasterizationEnable API_DEPRECATED("", macos(10.0, 10.14)) = 221, /* Enable or disable all rasterization */
6848 NSOpenGLContextParameterStateValidation API_DEPRECATED("", macos(10.0, 10.14)) = 301, /* Validate state for multi-screen functionality */
6849 NSOpenGLContextParametectxaceSurfaceVolatile API_DEPRECATED("", macos(10.0, 10.14)) = 306, /* 1 param. Surface volatile state */
6850 };
6851
6852
6853 void NSOpenGLContext_setValues(NSOpenGLContext* context, const int* vals, NSOpenGLContextParameter param) {
6854 void* func = sel_registerName("setValues:forParameter:");
6855 ((void (*)(id, SEL, const int*, NSOpenGLContextParameter))objc_msgSend)
6856 (context, func, vals, param);
6857 }
6858
6859 void* NSOpenGLPixelFormat_initWithAttributes(const uint32_t* attribs) {
6860 void* func = sel_registerName("initWithAttributes:");
6861 return (void*) ((id(*)(id, SEL, const uint32_t*))objc_msgSend)
6862 (NSAlloc((id)objc_getClass("NSOpenGLPixelFormat")), func, attribs);
6863 }
6864
6865 NSOpenGLView* NSOpenGLView_initWithFrame(NSRect frameRect, uint32_t* format) {
6866 void* func = sel_registerName("initWithFrame:pixelFormat:");
6867 return (NSOpenGLView*) ((id(*)(id, SEL, NSRect, uint32_t*))objc_msgSend)
6868 (NSAlloc((id)objc_getClass("NSOpenGLView")), func, frameRect, format);
6869 }
6870
6871 void NSCursor_performSelector(NSCursor* cursor, void* selector) {
6872 void* func = sel_registerName("performSelector:");
6873 objc_msgSend_void_SEL(cursor, func, selector);
6874 }
6875
6876 NSPasteboard* NSPasteboard_generalPasteboard(void) {
6877 return (NSPasteboard*) objc_msgSend_id((id)objc_getClass("NSPasteboard"), sel_registerName("generalPasteboard"));
6878 }
6879
6880 NSString** cstrToNSStringArray(char** strs, size_t len) {
6881 static NSString* nstrs[6];
6882 size_t i;
6883 for (i = 0; i < len; i++)
6884 nstrs[i] = NSString_stringWithUTF8String(strs[i]);
6885
6886 return nstrs;
6887 }
6888
6889 const char* NSPasteboard_stringForType(NSPasteboard* pasteboard, NSPasteboardType dataType) {
6890 void* func = sel_registerName("stringForType:");
6891 return (const char*) NSString_to_char(((id(*)(id, SEL, const char*))objc_msgSend)(pasteboard, func, NSString_stringWithUTF8String(dataType)));
6892 }
6893
6894 NSArray* c_array_to_NSArray(void* array, size_t len) {
6895 SEL func = sel_registerName("initWithObjects:count:");
6896 void* nsclass = objc_getClass("NSArray");
6897 return ((id (*)(id, SEL, void*, NSUInteger))objc_msgSend)
6898 (NSAlloc(nsclass), func, array, len);
6899 }
6900
6901 void NSregisterForDraggedTypes(void* view, NSPasteboardType* newTypes, size_t len) {
6902 NSString** ntypes = cstrToNSStringArray((char**)newTypes, len);
6903
6904 NSArray* array = c_array_to_NSArray(ntypes, len);
6905 objc_msgSend_void_id(view, sel_registerName("registerForDraggedTypes:"), array);
6906 NSRelease(array);
6907 }
6908
6909 NSInteger NSPasteBoard_declareTypes(NSPasteboard* pasteboard, NSPasteboardType* newTypes, size_t len, void* owner) {
6910 NSString** ntypes = cstrToNSStringArray((char**)newTypes, len);
6911
6912 void* func = sel_registerName("declareTypes:owner:");
6913
6914 NSArray* array = c_array_to_NSArray(ntypes, len);
6915
6916 NSInteger output = ((NSInteger(*)(id, SEL, id, void*))objc_msgSend)
6917 (pasteboard, func, array, owner);
6918 NSRelease(array);
6919
6920 return output;
6921 }
6922
6923 bool NSPasteBoard_setString(NSPasteboard* pasteboard, const char* stringToWrite, NSPasteboardType dataType) {
6924 void* func = sel_registerName("setString:forType:");
6925 return ((bool (*)(id, SEL, id, NSPasteboardType))objc_msgSend)
6926 (pasteboard, func, NSString_stringWithUTF8String(stringToWrite), NSString_stringWithUTF8String(dataType));
6927 }
6928
6929 void NSRetain(id obj) { objc_msgSend_void(obj, sel_registerName("retain")); }
6930
6931 typedef enum NSApplicationActivationPolicy {
6932 NSApplicationActivationPolicyRegular,
6933 NSApplicationActivationPolicyAccessory,
6934 NSApplicationActivationPolicyProhibited
6935 } NSApplicationActivationPolicy;
6936
6937 typedef NS_ENUM(u32, NSBackingStoreType) {
6938 NSBackingStoreRetained = 0,
6939 NSBackingStoreNonretained = 1,
6940 NSBackingStoreBuffered = 2
6941 };
6942
6943 typedef NS_ENUM(u32, NSWindowStyleMask) {
6944 NSWindowStyleMaskBorderless = 0,
6945 NSWindowStyleMaskTitled = 1 << 0,
6946 NSWindowStyleMaskClosable = 1 << 1,
6947 NSWindowStyleMaskMiniaturizable = 1 << 2,
6948 NSWindowStyleMaskResizable = 1 << 3,
6949 NSWindowStyleMaskTexturedBackground = 1 << 8, /* deprecated */
6950 NSWindowStyleMaskUnifiedTitleAndToolbar = 1 << 12,
6951 NSWindowStyleMaskFullScreen = 1 << 14,
6952 NSWindowStyleMaskFullSizeContentView = 1 << 15,
6953 NSWindowStyleMaskUtilityWindow = 1 << 4,
6954 NSWindowStyleMaskDocModalWindow = 1 << 6,
6955 NSWindowStyleMaskNonactivatingPanel = 1 << 7,
6956 NSWindowStyleMaskHUDWindow = 1 << 13
6957 };
6958
6959 NSPasteboardType const NSPasteboardTypeString = "public.utf8-plain-text"; // Replaces NSStringPboardType
6960
6961
6962 typedef NS_ENUM(i32, NSDragOperation) {
6963 NSDragOperationNone = 0,
6964 NSDragOperationCopy = 1,
6965 NSDragOperationLink = 2,
6966 NSDragOperationGeneric = 4,
6967 NSDragOperationPrivate = 8,
6968 NSDragOperationMove = 16,
6969 NSDragOperationDelete = 32,
6970 NSDragOperationEvery = ULONG_MAX,
6971
6972 //NSDragOperationAll_Obsolete API_DEPRECATED("", macos(10.0,10.10)) = 15, // Use NSDragOperationEvery
6973 //NSDragOperationAll API_DEPRECATED("", macos(10.0,10.10)) = NSDragOperationAll_Obsolete, // Use NSDragOperationEvery
6974 };
6975
6976 void* NSArray_objectAtIndex(NSArray* array, NSUInteger index) {
6977 void* func = sel_registerName("objectAtIndex:");
6978 return ((id(*)(id, SEL, NSUInteger))objc_msgSend)(array, func, index);
6979 }
6980
6981 const char** NSPasteboard_readObjectsForClasses(NSPasteboard* pasteboard, Class* classArray, size_t len, void* options) {
6982 void* func = sel_registerName("readObjectsForClasses:options:");
6983
6984 NSArray* array = c_array_to_NSArray(classArray, len);
6985
6986 NSArray* output = (NSArray*) ((id(*)(id, SEL, id, void*))objc_msgSend)
6987 (pasteboard, func, array, options);
6988
6989 NSRelease(array);
6990 NSUInteger count = ((NSUInteger(*)(id, SEL))objc_msgSend)(output, sel_registerName("count"));
6991
6992 const char** res = si_array_init_reserve(sizeof(const char*), count);
6993
6994 void* path_func = sel_registerName("path");
6995
6996 for (NSUInteger i = 0; i < count; i++) {
6997 void* url = NSArray_objectAtIndex(output, i);
6998 NSString* url_str = ((id(*)(id, SEL))objc_msgSend)(url, path_func);
6999 res[i] = NSString_to_char(url_str);
7000 }
7001
7002 return res;
7003 }
7004
7005 void* NSWindow_contentView(NSWindow* window) {
7006 void* func = sel_registerName("contentView");
7007 return objc_msgSend_id(window, func);
7008 }
7009
7010 /*
7011 End of cocoa wrapper
7012 */
7013
7014 char* RGFW_mouseIconSrc[] = {"arrowCursor", "arrowCursor", "IBeamCursor", "crosshairCursor", "pointingHandCursor", "resizeLeftRightCursor", "resizeUpDownCursor", "_windowResizeNorthWestSouthEastCursor", "_windowResizeNorthEastSouthWestCursor", "closedHandCursor", "operationNotAllowedCursor"};
7015
7016 void* RGFWnsglFramework = NULL;
7017
7018#ifdef RGFW_OPENGL
7019 void* RGFW_getProcAddress(const char* procname) {
7020 if (RGFWnsglFramework == NULL)
7021 RGFWnsglFramework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
7022
7023 CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault, procname, kCFStringEncodingASCII);
7024
7025 void* symbol = CFBundleGetFunctionPointerForName(RGFWnsglFramework, symbolName);
7026
7027 CFRelease(symbolName);
7028
7029 return symbol;
7030 }
7031#endif
7032
7033 CVReturn displayCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* inNow, const CVTimeStamp* inOutputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext) {
7034 RGFW_UNUSED(displayLink) RGFW_UNUSED(inNow) RGFW_UNUSED(inOutputTime) RGFW_UNUSED(flagsIn) RGFW_UNUSED(flagsOut) RGFW_UNUSED(displayLinkContext)
7035 return kCVReturnSuccess;
7036 }
7037
7038 id NSWindow_delegate(RGFW_window* win) {
7039 return (id) objc_msgSend_id(win->src.window, sel_registerName("delegate"));
7040 }
7041
7042 u32 RGFW_OnClose(void* self) {
7043 RGFW_window* win = NULL;
7044 object_getInstanceVariable(self, "RGFW_window", (void*)&win);
7045 if (win == NULL)
7046 return true;
7047
7048 win->event.type = RGFW_quit;
7049 RGFW_windowQuitCallback(win);
7050
7051 return true;
7052 }
7053
7054 /* NOTE(EimaMei): Fixes the constant clicking when the app is running under a terminal. */
7055 bool acceptsFirstResponder(void) { return true; }
7056 bool performKeyEquivalent(NSEvent* event) { RGFW_UNUSED(event); return true; }
7057
7058 NSDragOperation draggingEntered(id self, SEL sel, id sender) {
7059 RGFW_UNUSED(sender); RGFW_UNUSED(self); RGFW_UNUSED(sel);
7060
7061 return NSDragOperationCopy;
7062 }
7063 NSDragOperation draggingUpdated(id self, SEL sel, id sender) {
7064 RGFW_UNUSED(sel);
7065
7066 RGFW_window* win = NULL;
7067 object_getInstanceVariable(self, "RGFW_window", (void*)&win);
7068 if (win == NULL)
7069 return 0;
7070
7071 if (!(win->_winArgs & RGFW_ALLOW_DND)) {
7072 return 0;
7073 }
7074
7075 win->event.type = RGFW_dnd_init;
7076 win->src.dndPassed = 0;
7077
7078 NSPoint p = ((NSPoint(*)(id, SEL)) objc_msgSend)(sender, sel_registerName("draggingLocation"));
7079
7080 win->event.point = RGFW_POINT((u32) p.x, (u32) (win->r.h - p.y));
7081 RGFW_dndInitCallback(win, win->event.point);
7082
7083 return NSDragOperationCopy;
7084 }
7085 bool prepareForDragOperation(id self) {
7086 RGFW_window* win = NULL;
7087 object_getInstanceVariable(self, "RGFW_window", (void*)&win);
7088 if (win == NULL)
7089 return true;
7090
7091 if (!(win->_winArgs & RGFW_ALLOW_DND)) {
7092 return false;
7093 }
7094
7095 return true;
7096 }
7097
7098 void RGFW__osxDraggingEnded(id self, SEL sel, id sender) { RGFW_UNUSED(sender); RGFW_UNUSED(self); RGFW_UNUSED(sel); return; }
7099
7100 /* NOTE(EimaMei): Usually, you never need 'id self, SEL cmd' for C -> Obj-C methods. This isn't the case. */
7101 bool performDragOperation(id self, SEL sel, id sender) {
7102 RGFW_UNUSED(sender); RGFW_UNUSED(self); RGFW_UNUSED(sel);
7103
7104 RGFW_window* win = NULL;
7105 object_getInstanceVariable(self, "RGFW_window", (void*)&win);
7106
7107 if (win == NULL)
7108 return false;
7109
7110 // NSPasteboard* pasteBoard = objc_msgSend_id(sender, sel_registerName("draggingPasteboard"));
7111
7112 /////////////////////////////
7113 id pasteBoard = objc_msgSend_id(sender, sel_registerName("draggingPasteboard"));
7114
7115 // Get the types of data available on the pasteboard
7116 id types = objc_msgSend_id(pasteBoard, sel_registerName("types"));
7117
7118 // Get the string type for file URLs
7119 id fileURLsType = objc_msgSend_class_char(objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), "NSFilenamesPboardType");
7120
7121 // Check if the pasteboard contains file URLs
7122 if (objc_msgSend_id_bool(types, sel_registerName("containsObject:"), fileURLsType) == 0) {
7123 #ifdef RGFW_DEBUG
7124 printf("No files found on the pasteboard.\n");
7125 #endif
7126
7127 return 0;
7128 }
7129
7130 id fileURLs = objc_msgSend_id_id(pasteBoard, sel_registerName("propertyListForType:"), fileURLsType);
7131 int count = ((int (*)(id, SEL))objc_msgSend)(fileURLs, sel_registerName("count"));
7132
7133 if (count == 0)
7134 return 0;
7135
7136 for (int i = 0; i < count; i++) {
7137 id fileURL = objc_msgSend_arr(fileURLs, sel_registerName("objectAtIndex:"), i);
7138 const char *filePath = ((const char* (*)(id, SEL))objc_msgSend)(fileURL, sel_registerName("UTF8String"));
7139 strncpy(win->event.droppedFiles[i], filePath, RGFW_MAX_PATH);
7140 win->event.droppedFiles[i][RGFW_MAX_PATH - 1] = '\0';
7141 }
7142 win->event.droppedFilesCount = count;
7143
7144 win->event.type = RGFW_dnd;
7145 win->src.dndPassed = 0;
7146
7147 NSPoint p = ((NSPoint(*)(id, SEL)) objc_msgSend)(sender, sel_registerName("draggingLocation"));
7148 win->event.point = RGFW_POINT((u32) p.x, (u32) (win->r.h - p.y));
7149
7150 RGFW_dndCallback(win, win->event.droppedFiles, win->event.droppedFilesCount);
7151
7152 return false;
7153 }
7154
7155 static void NSMoveToResourceDir(void) {
7156 /* sourced from glfw */
7157 char resourcesPath[255];
7158
7159 CFBundleRef bundle = CFBundleGetMainBundle();
7160 if (!bundle)
7161 return;
7162
7163 CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
7164 CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
7165
7166 if (
7167 CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo ||
7168 CFURLGetFileSystemRepresentation(resourcesURL, true, (u8*) resourcesPath, 255) == 0
7169 ) {
7170 CFRelease(last);
7171 CFRelease(resourcesURL);
7172 return;
7173 }
7174
7175 CFRelease(last);
7176 CFRelease(resourcesURL);
7177
7178 chdir(resourcesPath);
7179 }
7180
7181
7182 NSSize RGFW__osxWindowResize(void* self, SEL sel, NSSize frameSize) {
7183 RGFW_UNUSED(sel);
7184
7185 RGFW_window* win = NULL;
7186 object_getInstanceVariable(self, "RGFW_window", (void*)&win);
7187 if (win == NULL)
7188 return frameSize;
7189
7190 win->r.w = frameSize.width;
7191 win->r.h = frameSize.height;
7192 win->event.type = RGFW_windowResized;
7193 RGFW_windowResizeCallback(win, win->r);
7194 return frameSize;
7195 }
7196
7197 void RGFW__osxWindowMove(void* self, SEL sel) {
7198 RGFW_UNUSED(sel);
7199
7200 RGFW_window* win = NULL;
7201 object_getInstanceVariable(self, "RGFW_window", (void*)&win);
7202 if (win == NULL)
7203 return;
7204
7205 NSRect frame = ((NSRect(*)(id, SEL))abi_objc_msgSend_stret)(win->src.window, sel_registerName("frame"));
7206 win->r.x = (i32) frame.origin.x;
7207 win->r.y = (i32) frame.origin.y;
7208
7209 win->event.type = RGFW_windowMoved;
7210 RGFW_windowMoveCallback(win, win->r);
7211 }
7212
7213 void RGFW__osxUpdateLayer(void* self, SEL sel) {
7214 RGFW_UNUSED(sel);
7215
7216 RGFW_window* win = NULL;
7217 object_getInstanceVariable(self, "RGFW_window", (void*)&win);
7218 if (win == NULL)
7219 return;
7220
7221 win->event.type = RGFW_windowRefresh;
7222 RGFW_windowRefreshCallback(win);
7223 }
7224
7225 RGFWDEF void RGFW_init_buffer(RGFW_window* win);
7226 void RGFW_init_buffer(RGFW_window* win) {
7227 #if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
7228 if (RGFW_bufferSize.w == 0 && RGFW_bufferSize.h == 0)
7229 RGFW_bufferSize = RGFW_getScreenSize();
7230
7231 win->buffer = RGFW_MALLOC(RGFW_bufferSize.w * RGFW_bufferSize.h * 4);
7232
7233 #ifdef RGFW_OSMESA
7234 win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
7235 OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h);
7236 #endif
7237 #else
7238 RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
7239 #endif
7240 }
7241
7242
7243 void RGFW_window_cocoaSetLayer(RGFW_window* win, void* layer) {
7244 objc_msgSend_void_id(win->src.view, sel_registerName("setLayer"), layer);
7245 }
7246
7247 void* RGFW_cocoaGetLayer(void) {
7248 return objc_msgSend_class(objc_getClass("CAMetalLayer"), sel_registerName("layer"));
7249 }
7250
7251
7252 NSPasteboardType const NSPasteboardTypeURL = "public.url";
7253 NSPasteboardType const NSPasteboardTypeFileURL = "public.file-url";
7254
7255 RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
7256 static u8 RGFW_loaded = 0;
7257
7258 /* NOTE(EimaMei): Why does Apple hate good code? Like wtf, who thought of methods being a great idea???
7259 Imagine a universe, where MacOS had a proper system API (we would probably have like 20% better performance).
7260 */
7261 si_func_to_SEL_with_name("NSObject", "windowShouldClose", RGFW_OnClose);
7262
7263 /* NOTE(EimaMei): Fixes the 'Boop' sfx from constantly playing each time you click a key. Only a problem when running in the terminal. */
7264 si_func_to_SEL("NSWindow", acceptsFirstResponder);
7265 si_func_to_SEL("NSWindow", performKeyEquivalent);
7266
7267 // RR Create an autorelease pool
7268 id pool = objc_msgSend_class(objc_getClass("NSAutoreleasePool"), sel_registerName("alloc"));
7269 pool = objc_msgSend_id(pool, sel_registerName("init"));
7270
7271 if (NSApp == NULL) {
7272 NSApp = objc_msgSend_id((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
7273
7274 ((void (*)(id, SEL, NSUInteger))objc_msgSend)
7275 (NSApp, sel_registerName("setActivationPolicy:"), NSApplicationActivationPolicyRegular);
7276 }
7277
7278 RGFW_window* win = RGFW_window_basic_init(rect, args);
7279
7280 RGFW_window_setMouseDefault(win);
7281
7282 NSRect windowRect;
7283 windowRect.origin.x = win->r.x;
7284 windowRect.origin.y = win->r.y;
7285 windowRect.size.width = win->r.w;
7286 windowRect.size.height = win->r.h;
7287
7288 NSBackingStoreType macArgs = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSBackingStoreBuffered | NSWindowStyleMaskTitled;
7289
7290 if (!(args & RGFW_NO_RESIZE))
7291 macArgs |= NSWindowStyleMaskResizable;
7292 if (!(args & RGFW_NO_BORDER))
7293 macArgs |= NSWindowStyleMaskTitled;
7294 else
7295 macArgs = NSWindowStyleMaskBorderless;
7296 {
7297 void* nsclass = objc_getClass("NSWindow");
7298 void* func = sel_registerName("initWithContentRect:styleMask:backing:defer:");
7299
7300 win->src.window = ((id(*)(id, SEL, NSRect, NSWindowStyleMask, NSBackingStoreType, bool))objc_msgSend)
7301 (NSAlloc(nsclass), func, windowRect, macArgs, macArgs, false);
7302 }
7303
7304 NSString* str = NSString_stringWithUTF8String(name);
7305 objc_msgSend_void_id(win->src.window, sel_registerName("setTitle:"), str);
7306
7307#ifdef RGFW_EGL
7308 if ((args & RGFW_NO_INIT_API) == 0)
7309 RGFW_createOpenGLContext(win);
7310#endif
7311
7312#ifdef RGFW_OPENGL
7313 if ((args & RGFW_NO_INIT_API) == 0) {
7314 void* attrs = RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE);
7315 void* format = NSOpenGLPixelFormat_initWithAttributes(attrs);
7316
7317 if (format == NULL) {
7318 printf("Failed to load pixel format for OpenGL\n");
7319
7320 void* attrs = RGFW_initFormatAttribs(1);
7321 format = NSOpenGLPixelFormat_initWithAttributes(attrs);
7322 if (format == NULL)
7323 printf("and loading software rendering OpenGL failed\n");
7324 else
7325 printf("Switching to software rendering\n");
7326 }
7327
7328 /* the pixel format can be passed directly to opengl context creation to create a context
7329 this is because the format also includes information about the opengl version (which may be a bad thing) */
7330 win->src.view = NSOpenGLView_initWithFrame((NSRect){{0, 0}, {win->r.w, win->r.h}}, format);
7331 objc_msgSend_void(win->src.view, sel_registerName("prepareOpenGL"));
7332 win->src.ctx = objc_msgSend_id(win->src.view, sel_registerName("openGLContext"));
7333 } else
7334#endif
7335 {
7336 NSRect contentRect = (NSRect){{0, 0}, {win->r.w, win->r.h}};
7337 win->src.view = ((id(*)(id, SEL, NSRect))objc_msgSend)
7338 (NSAlloc((id)objc_getClass("NSView")), sel_registerName("initWithFrame:"),
7339 contentRect);
7340 }
7341
7342 void* contentView = NSWindow_contentView(win->src.window);
7343 objc_msgSend_void_bool(contentView, sel_registerName("setWantsLayer:"), true);
7344
7345 objc_msgSend_void_id(win->src.window, sel_registerName("setContentView:"), win->src.view);
7346
7347#ifdef RGFW_OPENGL
7348 if ((args & RGFW_NO_INIT_API) == 0)
7349 objc_msgSend_void(win->src.ctx, sel_registerName("makeCurrentContext"));
7350#endif
7351 if (args & RGFW_TRANSPARENT_WINDOW) {
7352#ifdef RGFW_OPENGL
7353 if ((args & RGFW_NO_INIT_API) == 0) {
7354 i32 opacity = 0;
7355 #define NSOpenGLCPSurfaceOpacity 236
7356 NSOpenGLContext_setValues(win->src.ctx, &opacity, NSOpenGLCPSurfaceOpacity);
7357 }
7358#endif
7359
7360 objc_msgSend_void_bool(win->src.window, sel_registerName("setOpaque:"), false);
7361
7362 objc_msgSend_void_id(win->src.window, sel_registerName("setBackgroundColor:"),
7363 NSColor_colorWithSRGB(0, 0, 0, 0));
7364 }
7365
7366 win->src.display = CGMainDisplayID();
7367 CVDisplayLinkCreateWithCGDisplay(win->src.display, (CVDisplayLinkRef*)&win->src.displayLink);
7368 CVDisplayLinkSetOutputCallback(win->src.displayLink, displayCallback, win);
7369 CVDisplayLinkStart(win->src.displayLink);
7370
7371 RGFW_init_buffer(win);
7372
7373 #ifndef RGFW_NO_MONITOR
7374 if (args & RGFW_SCALE_TO_MONITOR)
7375 RGFW_window_scaleToMonitor(win);
7376 #endif
7377
7378 if (args & RGFW_CENTER) {
7379 RGFW_area screenR = RGFW_getScreenSize();
7380 RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
7381 }
7382
7383 if (args & RGFW_HIDE_MOUSE)
7384 RGFW_window_showMouse(win, 0);
7385
7386 if (args & RGFW_COCOA_MOVE_TO_RESOURCE_DIR)
7387 NSMoveToResourceDir();
7388
7389 Class delegateClass = objc_allocateClassPair(objc_getClass("NSObject"), "WindowDelegate", 0);
7390
7391 class_addIvar(
7392 delegateClass, "RGFW_window",
7393 sizeof(RGFW_window*), rint(log2(sizeof(RGFW_window*))),
7394 "L"
7395 );
7396
7397 class_addMethod(delegateClass, sel_registerName("windowWillResize:toSize:"), (IMP) RGFW__osxWindowResize, "{NSSize=ff}@:{NSSize=ff}");
7398 class_addMethod(delegateClass, sel_registerName("updateLayer:"), (IMP) RGFW__osxUpdateLayer, "");
7399 class_addMethod(delegateClass, sel_registerName("windowWillMove:"), (IMP) RGFW__osxWindowMove, "");
7400 class_addMethod(delegateClass, sel_registerName("windowDidMove:"), (IMP) RGFW__osxWindowMove, "");
7401 class_addMethod(delegateClass, sel_registerName("draggingEntered:"), (IMP)draggingEntered, "l@:@");
7402 class_addMethod(delegateClass, sel_registerName("draggingUpdated:"), (IMP)draggingUpdated, "l@:@");
7403 class_addMethod(delegateClass, sel_registerName("draggingExited:"), (IMP)RGFW__osxDraggingEnded, "v@:@");
7404 class_addMethod(delegateClass, sel_registerName("draggingEnded:"), (IMP)RGFW__osxDraggingEnded, "v@:@");
7405 class_addMethod(delegateClass, sel_registerName("prepareForDragOperation:"), (IMP)prepareForDragOperation, "B@:@");
7406 class_addMethod(delegateClass, sel_registerName("performDragOperation:"), (IMP)performDragOperation, "B@:@");
7407
7408 id delegate = objc_msgSend_id(NSAlloc(delegateClass), sel_registerName("init"));
7409
7410 object_setInstanceVariable(delegate, "RGFW_window", win);
7411
7412 objc_msgSend_void_id(win->src.window, sel_registerName("setDelegate:"), delegate);
7413
7414 if (args & RGFW_ALLOW_DND) {
7415 win->_winArgs |= RGFW_ALLOW_DND;
7416
7417 NSPasteboardType types[] = {NSPasteboardTypeURL, NSPasteboardTypeFileURL, NSPasteboardTypeString};
7418 NSregisterForDraggedTypes(win->src.window, types, 3);
7419 }
7420
7421 // Show the window
7422 objc_msgSend_void_bool(NSApp, sel_registerName("activateIgnoringOtherApps:"), true);
7423 ((id(*)(id, SEL, SEL))objc_msgSend)(win->src.window, sel_registerName("makeKeyAndOrderFront:"), NULL);
7424 objc_msgSend_void_bool(win->src.window, sel_registerName("setIsVisible:"), true);
7425
7426 if (!RGFW_loaded) {
7427 objc_msgSend_void(win->src.window, sel_registerName("makeMainWindow"));
7428
7429 RGFW_loaded = 1;
7430 }
7431
7432 objc_msgSend_void(win->src.window, sel_registerName("makeKeyWindow"));
7433
7434 objc_msgSend_void(NSApp, sel_registerName("finishLaunching"));
7435
7436 if (RGFW_root == NULL)
7437 RGFW_root = win;
7438
7439 NSRetain(win->src.window);
7440 NSRetain(NSApp);
7441
7442 return win;
7443 }
7444
7445 void RGFW_window_setBorder(RGFW_window* win, u8 border) {
7446 NSBackingStoreType storeType = NSWindowStyleMaskBorderless;
7447 if (!border) {
7448 storeType = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable;
7449 }
7450 if (!(win->_winArgs & RGFW_NO_RESIZE)) {
7451 storeType |= NSWindowStyleMaskResizable;
7452 }
7453
7454 ((void (*)(id, SEL, NSBackingStoreType))objc_msgSend)(win->src.window, sel_registerName("setStyleMask:"), storeType);
7455
7456 objc_msgSend_void_bool(win->src.window, sel_registerName("setHasShadow:"), border);
7457 }
7458
7459 RGFW_area RGFW_getScreenSize(void) {
7460 static CGDirectDisplayID display = 0;
7461
7462 if (display == 0)
7463 display = CGMainDisplayID();
7464
7465 return RGFW_AREA(CGDisplayPixelsWide(display), CGDisplayPixelsHigh(display));
7466 }
7467
7468 RGFW_point RGFW_getGlobalMousePoint(void) {
7469 assert(RGFW_root != NULL);
7470
7471 CGEventRef e = CGEventCreate(NULL);
7472 CGPoint point = CGEventGetLocation(e);
7473 CFRelease(e);
7474
7475 return RGFW_POINT((u32) point.x, (u32) point.y); /*!< the point is loaded during event checks */
7476 }
7477
7478 RGFW_point RGFW_window_getMousePoint(RGFW_window* win) {
7479 NSPoint p = ((NSPoint(*)(id, SEL)) objc_msgSend)(win->src.window, sel_registerName("mouseLocationOutsideOfEventStream"));
7480
7481 return RGFW_POINT((u32) p.x, (u32) (win->r.h - p.y));
7482 }
7483
7484 u32 RGFW_keysPressed[10]; /*10 keys at a time*/
7485 typedef NS_ENUM(u32, NSEventType) { /* various types of events */
7486 NSEventTypeLeftMouseDown = 1,
7487 NSEventTypeLeftMouseUp = 2,
7488 NSEventTypeRightMouseDown = 3,
7489 NSEventTypeRightMouseUp = 4,
7490 NSEventTypeMouseMoved = 5,
7491 NSEventTypeLeftMouseDragged = 6,
7492 NSEventTypeRightMouseDragged = 7,
7493 NSEventTypeMouseEntered = 8,
7494 NSEventTypeMouseExited = 9,
7495 NSEventTypeKeyDown = 10,
7496 NSEventTypeKeyUp = 11,
7497 NSEventTypeFlagsChanged = 12,
7498 NSEventTypeAppKitDefined = 13,
7499 NSEventTypeSystemDefined = 14,
7500 NSEventTypeApplicationDefined = 15,
7501 NSEventTypePeriodic = 16,
7502 NSEventTypeCursorUpdate = 17,
7503 NSEventTypeScrollWheel = 22,
7504 NSEventTypeTabletPoint = 23,
7505 NSEventTypeTabletProximity = 24,
7506 NSEventTypeOtherMouseDown = 25,
7507 NSEventTypeOtherMouseUp = 26,
7508 NSEventTypeOtherMouseDragged = 27,
7509 /* The following event types are available on some hardware on 10.5.2 and later */
7510 NSEventTypeGesture API_AVAILABLE(macos(10.5)) = 29,
7511 NSEventTypeMagnify API_AVAILABLE(macos(10.5)) = 30,
7512 NSEventTypeSwipe API_AVAILABLE(macos(10.5)) = 31,
7513 NSEventTypeRotate API_AVAILABLE(macos(10.5)) = 18,
7514 NSEventTypeBeginGesture API_AVAILABLE(macos(10.5)) = 19,
7515 NSEventTypeEndGesture API_AVAILABLE(macos(10.5)) = 20,
7516
7517 NSEventTypeSmartMagnify API_AVAILABLE(macos(10.8)) = 32,
7518 NSEventTypeQuickLook API_AVAILABLE(macos(10.8)) = 33,
7519
7520 NSEventTypePressure API_AVAILABLE(macos(10.10.3)) = 34,
7521 NSEventTypeDirectTouch API_AVAILABLE(macos(10.10)) = 37,
7522
7523 NSEventTypeChangeMode API_AVAILABLE(macos(10.15)) = 38,
7524 };
7525
7526 typedef NS_ENUM(unsigned long long, NSEventMask) { /* masks for the types of events */
7527 NSEventMaskLeftMouseDown = 1ULL << NSEventTypeLeftMouseDown,
7528 NSEventMaskLeftMouseUp = 1ULL << NSEventTypeLeftMouseUp,
7529 NSEventMaskRightMouseDown = 1ULL << NSEventTypeRightMouseDown,
7530 NSEventMaskRightMouseUp = 1ULL << NSEventTypeRightMouseUp,
7531 NSEventMaskMouseMoved = 1ULL << NSEventTypeMouseMoved,
7532 NSEventMaskLeftMouseDragged = 1ULL << NSEventTypeLeftMouseDragged,
7533 NSEventMaskRightMouseDragged = 1ULL << NSEventTypeRightMouseDragged,
7534 NSEventMaskMouseEntered = 1ULL << NSEventTypeMouseEntered,
7535 NSEventMaskMouseExited = 1ULL << NSEventTypeMouseExited,
7536 NSEventMaskKeyDown = 1ULL << NSEventTypeKeyDown,
7537 NSEventMaskKeyUp = 1ULL << NSEventTypeKeyUp,
7538 NSEventMaskFlagsChanged = 1ULL << NSEventTypeFlagsChanged,
7539 NSEventMaskAppKitDefined = 1ULL << NSEventTypeAppKitDefined,
7540 NSEventMaskSystemDefined = 1ULL << NSEventTypeSystemDefined,
7541 NSEventMaskApplicationDefined = 1ULL << NSEventTypeApplicationDefined,
7542 NSEventMaskPeriodic = 1ULL << NSEventTypePeriodic,
7543 NSEventMaskCursorUpdate = 1ULL << NSEventTypeCursorUpdate,
7544 NSEventMaskScrollWheel = 1ULL << NSEventTypeScrollWheel,
7545 NSEventMaskTabletPoint = 1ULL << NSEventTypeTabletPoint,
7546 NSEventMaskTabletProximity = 1ULL << NSEventTypeTabletProximity,
7547 NSEventMaskOtherMouseDown = 1ULL << NSEventTypeOtherMouseDown,
7548 NSEventMaskOtherMouseUp = 1ULL << NSEventTypeOtherMouseUp,
7549 NSEventMaskOtherMouseDragged = 1ULL << NSEventTypeOtherMouseDragged,
7550 /* The following event masks are available on some hardware on 10.5.2 and later */
7551 NSEventMaskGesture API_AVAILABLE(macos(10.5)) = 1ULL << NSEventTypeGesture,
7552 NSEventMaskMagnify API_AVAILABLE(macos(10.5)) = 1ULL << NSEventTypeMagnify,
7553 NSEventMaskSwipe API_AVAILABLE(macos(10.5)) = 1ULL << NSEventTypeSwipe,
7554 NSEventMaskRotate API_AVAILABLE(macos(10.5)) = 1ULL << NSEventTypeRotate,
7555 NSEventMaskBeginGesture API_AVAILABLE(macos(10.5)) = 1ULL << NSEventTypeBeginGesture,
7556 NSEventMaskEndGesture API_AVAILABLE(macos(10.5)) = 1ULL << NSEventTypeEndGesture,
7557
7558 /* Note: You can only use these event masks on 64 bit. In other words, you cannot setup a local, nor global, event monitor for these event types on 32 bit. Also, you cannot search the event queue for them (nextEventMatchingMask:...) on 32 bit.
7559 */
7560 NSEventMaskSmartMagnify API_AVAILABLE(macos(10.8)) = 1ULL << NSEventTypeSmartMagnify,
7561 NSEventMaskPressure API_AVAILABLE(macos(10.10.3)) = 1ULL << NSEventTypePressure,
7562 NSEventMaskDirectTouch API_AVAILABLE(macos(10.12.2)) = 1ULL << NSEventTypeDirectTouch,
7563
7564 NSEventMaskChangeMode API_AVAILABLE(macos(10.15)) = 1ULL << NSEventTypeChangeMode,
7565
7566 NSEventMaskAny = ULONG_MAX,
7567
7568 };
7569
7570 typedef enum NSEventModifierFlags {
7571 NSEventModifierFlagCapsLock = 1 << 16,
7572 NSEventModifierFlagShift = 1 << 17,
7573 NSEventModifierFlagControl = 1 << 18,
7574 NSEventModifierFlagOption = 1 << 19,
7575 NSEventModifierFlagCommand = 1 << 20,
7576 NSEventModifierFlagNumericPad = 1 << 21
7577 } NSEventModifierFlags;
7578
7579 void RGFW_stopCheckEvents(void) {
7580 id eventPool = objc_msgSend_class(objc_getClass("NSAutoreleasePool"), sel_registerName("alloc"));
7581 eventPool = objc_msgSend_id(eventPool, sel_registerName("init"));
7582
7583 NSEvent* e = (NSEvent*) ((id(*)(id, SEL, NSEventType, NSPoint, NSEventModifierFlags, void*, NSInteger, void**, short, NSInteger, NSInteger))objc_msgSend)
7584 (NSApp, sel_registerName("otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:"),
7585 NSEventTypeApplicationDefined, (NSPoint){0, 0}, 0, 0, 0, NULL, 0, 0, 0);
7586
7587 ((void (*)(id, SEL, id, bool))objc_msgSend)
7588 (NSApp, sel_registerName("postEvent:atStart:"), e, 1);
7589
7590 objc_msgSend_bool_void(eventPool, sel_registerName("drain"));
7591 }
7592
7593 void RGFW_window_eventWait(RGFW_window* win, i32 waitMS) {
7594 RGFW_UNUSED(win);
7595
7596 id eventPool = objc_msgSend_class(objc_getClass("NSAutoreleasePool"), sel_registerName("alloc"));
7597 eventPool = objc_msgSend_id(eventPool, sel_registerName("init"));
7598
7599 void* date = (void*) ((id(*)(Class, SEL, double))objc_msgSend)
7600 (objc_getClass("NSDate"), sel_registerName("dateWithTimeIntervalSinceNow:"), waitMS);
7601
7602 NSEvent* e = (NSEvent*) ((id(*)(id, SEL, NSEventMask, void*, NSString*, bool))objc_msgSend)
7603 (NSApp, sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:"),
7604 ULONG_MAX, date, NSString_stringWithUTF8String("kCFRunLoopDefaultMode"), true);
7605
7606
7607 if (e) {
7608 objc_msgSend_void_id(NSApp, sel_registerName("sendEvent:"), e);
7609 }
7610
7611 objc_msgSend_bool_void(eventPool, sel_registerName("drain"));
7612 }
7613
7614 RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
7615 assert(win != NULL);
7616
7617 if (win->event.type == RGFW_quit)
7618 return NULL;
7619
7620 if ((win->event.type == RGFW_dnd || win->event.type == RGFW_dnd_init) && win->src.dndPassed == 0) {
7621 win->src.dndPassed = 1;
7622 return &win->event;
7623 }
7624
7625 id eventPool = objc_msgSend_class(objc_getClass("NSAutoreleasePool"), sel_registerName("alloc"));
7626 eventPool = objc_msgSend_id(eventPool, sel_registerName("init"));
7627
7628 static void* eventFunc = NULL;
7629 if (eventFunc == NULL)
7630 eventFunc = sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:");
7631
7632 if ((win->event.type == RGFW_windowMoved || win->event.type == RGFW_windowResized || win->event.type == RGFW_windowRefresh) && win->event.keyCode != 120) {
7633 win->event.keyCode = 120;
7634 objc_msgSend_bool_void(eventPool, sel_registerName("drain"));
7635 return &win->event;
7636 }
7637
7638 void* date = NULL;
7639
7640 NSEvent* e = (NSEvent*) ((id(*)(id, SEL, NSEventMask, void*, NSString*, bool))objc_msgSend)
7641 (NSApp, eventFunc, ULONG_MAX, date, NSString_stringWithUTF8String("kCFRunLoopDefaultMode"), true);
7642
7643 if (e == NULL) {
7644 objc_msgSend_bool_void(eventPool, sel_registerName("drain"));
7645 return NULL;
7646 }
7647
7648 if (objc_msgSend_id(e, sel_registerName("window")) != win->src.window) {
7649 ((void (*)(id, SEL, id, bool))objc_msgSend)
7650 (NSApp, sel_registerName("postEvent:atStart:"), e, 0);
7651
7652 objc_msgSend_bool_void(eventPool, sel_registerName("drain"));
7653 return NULL;
7654 }
7655
7656 if (win->event.droppedFilesCount) {
7657 u32 i;
7658 for (i = 0; i < win->event.droppedFilesCount; i++)
7659 win->event.droppedFiles[i][0] = '\0';
7660 }
7661
7662 win->event.droppedFilesCount = 0;
7663 win->event.type = 0;
7664
7665 switch (objc_msgSend_uint(e, sel_registerName("type"))) {
7666 case NSEventTypeMouseEntered: {
7667 win->event.type = RGFW_mouseEnter;
7668 NSPoint p = ((NSPoint(*)(id, SEL)) objc_msgSend)(e, sel_registerName("locationInWindow"));
7669
7670 win->event.point = RGFW_POINT((i32) p.x, (i32) (win->r.h - p.y));
7671 RGFW_mouseNotifyCallBack(win, win->event.point, 1);
7672 break;
7673 }
7674
7675 case NSEventTypeMouseExited:
7676 win->event.type = RGFW_mouseLeave;
7677 RGFW_mouseNotifyCallBack(win, win->event.point, 0);
7678 break;
7679
7680 case NSEventTypeKeyDown: {
7681 u32 key = (u16) objc_msgSend_uint(e, sel_registerName("keyCode"));
7682 win->event.keyCode = RGFW_apiKeyCodeToRGFW(key);
7683 RGFW_keyboard[win->event.keyCode].prev = RGFW_keyboard[win->event.keyCode].current;
7684
7685 win->event.type = RGFW_keyPressed;
7686 char* str = (char*)(const char*) NSString_to_char(objc_msgSend_id(e, sel_registerName("characters")));
7687 strncpy(win->event.keyName, str, 16);
7688 win->event.repeat = RGFW_isPressed(win, win->event.keyCode);
7689 RGFW_keyboard[win->event.keyCode].current = 1;
7690
7691 RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 1);
7692 break;
7693 }
7694
7695 case NSEventTypeKeyUp: {
7696 u32 key = (u16) objc_msgSend_uint(e, sel_registerName("keyCode"));
7697 win->event.keyCode = RGFW_apiKeyCodeToRGFW(key);;
7698
7699 RGFW_keyboard[win->event.keyCode].prev = RGFW_keyboard[win->event.keyCode].current;
7700
7701 win->event.type = RGFW_keyReleased;
7702 char* str = (char*)(const char*) NSString_to_char(objc_msgSend_id(e, sel_registerName("characters")));
7703 strncpy(win->event.keyName, str, 16);
7704
7705 RGFW_keyboard[win->event.keyCode].current = 0;
7706 RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 0);
7707 break;
7708 }
7709
7710 case NSEventTypeFlagsChanged: {
7711 u32 flags = objc_msgSend_uint(e, sel_registerName("modifierFlags"));
7712 RGFW_updateLockState(win, ((u32)(flags & NSEventModifierFlagCapsLock) % 255), ((flags & NSEventModifierFlagNumericPad) % 255));
7713
7714 u8 i;
7715 for (i = 0; i < 9; i++)
7716 RGFW_keyboard[i + RGFW_CapsLock].prev = 0;
7717
7718 for (i = 0; i < 5; i++) {
7719 u32 shift = (1 << (i + 16));
7720 u32 key = i + RGFW_CapsLock;
7721
7722 if ((flags & shift) && !RGFW_wasPressed(win, key)) {
7723 RGFW_keyboard[key].current = 1;
7724
7725 if (key != RGFW_CapsLock)
7726 RGFW_keyboard[key+ 4].current = 1;
7727
7728 win->event.type = RGFW_keyPressed;
7729 win->event.keyCode = key;
7730 break;
7731 }
7732
7733 if (!(flags & shift) && RGFW_wasPressed(win, key)) {
7734 RGFW_keyboard[key].current = 0;
7735
7736 if (key != RGFW_CapsLock)
7737 RGFW_keyboard[key + 4].current = 0;
7738
7739 win->event.type = RGFW_keyReleased;
7740 win->event.keyCode = key;
7741 break;
7742 }
7743 }
7744
7745 RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, win->event.type == RGFW_keyPressed);
7746
7747 break;
7748 }
7749 case NSEventTypeLeftMouseDragged:
7750 case NSEventTypeOtherMouseDragged:
7751 case NSEventTypeRightMouseDragged:
7752 case NSEventTypeMouseMoved:
7753 win->event.type = RGFW_mousePosChanged;
7754 NSPoint p = ((NSPoint(*)(id, SEL)) objc_msgSend)(e, sel_registerName("locationInWindow"));
7755 win->event.point = RGFW_POINT((u32) p.x, (u32) (win->r.h - p.y));
7756
7757 if ((win->_winArgs & RGFW_HOLD_MOUSE)) {
7758 p.x = ((CGFloat(*)(id, SEL))abi_objc_msgSend_fpret)(e, sel_registerName("deltaX"));
7759 p.y = ((CGFloat(*)(id, SEL))abi_objc_msgSend_fpret)(e, sel_registerName("deltaY"));
7760
7761 win->event.point = RGFW_POINT((i32)p.x, (i32)p.y);
7762 }
7763
7764 RGFW_mousePosCallback(win, win->event.point);
7765 break;
7766
7767 case NSEventTypeLeftMouseDown:
7768 win->event.button = RGFW_mouseLeft;
7769 win->event.type = RGFW_mouseButtonPressed;
7770 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
7771 RGFW_mouseButtons[win->event.button].current = 1;
7772 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
7773 break;
7774
7775 case NSEventTypeOtherMouseDown:
7776 win->event.button = RGFW_mouseMiddle;
7777 win->event.type = RGFW_mouseButtonPressed;
7778 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
7779 RGFW_mouseButtons[win->event.button].current = 1;
7780 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
7781 break;
7782
7783 case NSEventTypeRightMouseDown:
7784 win->event.button = RGFW_mouseRight;
7785 win->event.type = RGFW_mouseButtonPressed;
7786 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
7787 RGFW_mouseButtons[win->event.button].current = 1;
7788 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
7789 break;
7790
7791 case NSEventTypeLeftMouseUp:
7792 win->event.button = RGFW_mouseLeft;
7793 win->event.type = RGFW_mouseButtonReleased;
7794 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
7795 RGFW_mouseButtons[win->event.button].current = 0;
7796 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 0);
7797 break;
7798
7799 case NSEventTypeOtherMouseUp:
7800 win->event.button = RGFW_mouseMiddle;
7801 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
7802 RGFW_mouseButtons[win->event.button].current = 0;
7803 win->event.type = RGFW_mouseButtonReleased;
7804 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 0);
7805 break;
7806
7807 case NSEventTypeRightMouseUp:
7808 win->event.button = RGFW_mouseRight;
7809 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
7810 RGFW_mouseButtons[win->event.button].current = 0;
7811 win->event.type = RGFW_mouseButtonReleased;
7812 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 0);
7813 break;
7814
7815 case NSEventTypeScrollWheel: {
7816 double deltaY = ((CGFloat(*)(id, SEL))abi_objc_msgSend_fpret)(e, sel_registerName("deltaY"));
7817
7818 if (deltaY > 0) {
7819 win->event.button = RGFW_mouseScrollUp;
7820 }
7821 else if (deltaY < 0) {
7822 win->event.button = RGFW_mouseScrollDown;
7823 }
7824
7825 RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current;
7826 RGFW_mouseButtons[win->event.button].current = 1;
7827
7828 win->event.scroll = deltaY;
7829
7830 win->event.type = RGFW_mouseButtonPressed;
7831 RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, 1);
7832 break;
7833 }
7834
7835 default:
7836 break;
7837 }
7838
7839 objc_msgSend_void_id(NSApp, sel_registerName("sendEvent:"), e);
7840 ((void(*)(id, SEL))objc_msgSend)(NSApp, sel_registerName("updateWindows"));
7841
7842 objc_msgSend_bool_void(eventPool, sel_registerName("drain"));
7843 return &win->event;
7844 }
7845
7846
7847 void RGFW_window_move(RGFW_window* win, RGFW_point v) {
7848 assert(win != NULL);
7849
7850 win->r.x = v.x;
7851 win->r.y = v.y;
7852 ((void(*)(id, SEL, NSRect, bool, bool))objc_msgSend)
7853 (win->src.window, sel_registerName("setFrame:display:animate:"), (NSRect){{win->r.x, win->r.y}, {win->r.w, win->r.h}}, true, true);
7854 }
7855
7856 void RGFW_window_resize(RGFW_window* win, RGFW_area a) {
7857 assert(win != NULL);
7858
7859 win->r.w = a.w;
7860 win->r.h = a.h;
7861 ((void(*)(id, SEL, NSRect, bool, bool))objc_msgSend)
7862 (win->src.window, sel_registerName("setFrame:display:animate:"), (NSRect){{win->r.x, win->r.y}, {win->r.w, win->r.h}}, true, true);
7863 }
7864
7865 void RGFW_window_minimize(RGFW_window* win) {
7866 assert(win != NULL);
7867
7868 objc_msgSend_void_SEL(win->src.window, sel_registerName("performMiniaturize:"), NULL);
7869 }
7870
7871 void RGFW_window_restore(RGFW_window* win) {
7872 assert(win != NULL);
7873
7874 objc_msgSend_void_SEL(win->src.window, sel_registerName("deminiaturize:"), NULL);
7875 }
7876
7877 void RGFW_window_setName(RGFW_window* win, char* name) {
7878 assert(win != NULL);
7879
7880 NSString* str = NSString_stringWithUTF8String(name);
7881 objc_msgSend_void_id(win->src.window, sel_registerName("setTitle:"), str);
7882 }
7883
7884 #ifndef RGFW_NO_PASSTHROUGH
7885 void RGFW_window_setMousePassthrough(RGFW_window* win, b8 passthrough) {
7886 objc_msgSend_void_bool(win->src.window, sel_registerName("setIgnoresMouseEvents:"), passthrough);
7887 }
7888 #endif
7889
7890 void RGFW_window_setMinSize(RGFW_window* win, RGFW_area a) {
7891 if (a.w == 0 && a.h == 0)
7892 return;
7893
7894 ((void (*)(id, SEL, NSSize))objc_msgSend)
7895 (win->src.window, sel_registerName("setMinSize:"), (NSSize){a.w, a.h});
7896 }
7897
7898 void RGFW_window_setMaxSize(RGFW_window* win, RGFW_area a) {
7899 if (a.w == 0 && a.h == 0)
7900 return;
7901
7902 ((void (*)(id, SEL, NSSize))objc_msgSend)
7903 (win->src.window, sel_registerName("setMaxSize:"), (NSSize){a.w, a.h});
7904 }
7905
7906 void RGFW_window_setIcon(RGFW_window* win, u8* data, RGFW_area area, i32 channels) {
7907 assert(win != NULL);
7908
7909 /* code by EimaMei */
7910 // Make a bitmap representation, then copy the loaded image into it.
7911 void* representation = NSBitmapImageRep_initWithBitmapData(NULL, area.w, area.h, 8, channels, (channels == 4), false, "NSCalibratedRGBColorSpace", 1 << 1, area.w * channels, 8 * channels);
7912 memcpy(NSBitmapImageRep_bitmapData(representation), data, area.w * area.h * channels);
7913
7914 // Add ze representation.
7915 void* dock_image = NSImage_initWithSize((NSSize){area.w, area.h});
7916 NSImage_addRepresentation(dock_image, (void*) representation);
7917
7918 // Finally, set the dock image to it.
7919 objc_msgSend_void_id(NSApp, sel_registerName("setApplicationIconImage:"), dock_image);
7920 // Free the garbage.
7921 release(dock_image);
7922 release(representation);
7923 }
7924
7925 NSCursor* NSCursor_arrowStr(char* str) {
7926 void* nclass = objc_getClass("NSCursor");
7927 void* func = sel_registerName(str);
7928 return (NSCursor*) objc_msgSend_id(nclass, func);
7929 }
7930
7931 void RGFW_window_setMouse(RGFW_window* win, u8* image, RGFW_area a, i32 channels) {
7932 assert(win != NULL);
7933
7934 if (image == NULL) {
7935 objc_msgSend_void(NSCursor_arrowStr("arrowCursor"), sel_registerName("set"));
7936 return;
7937 }
7938
7939 /* NOTE(EimaMei): Code by yours truly. */
7940 // Make a bitmap representation, then copy the loaded image into it.
7941 void* representation = NSBitmapImageRep_initWithBitmapData(NULL, a.w, a.h, 8, channels, (channels == 4), false, "NSCalibratedRGBColorSpace", 1 << 1, a.w * channels, 8 * channels);
7942 memcpy(NSBitmapImageRep_bitmapData(representation), image, a.w * a.h * channels);
7943
7944 // Add ze representation.
7945 void* cursor_image = NSImage_initWithSize((NSSize){a.w, a.h});
7946 NSImage_addRepresentation(cursor_image, representation);
7947
7948 // Finally, set the cursor image.
7949 void* cursor = NSCursor_initWithImage(cursor_image, (NSPoint){0.0, 0.0});
7950
7951 objc_msgSend_void(cursor, sel_registerName("set"));
7952
7953 // Free the garbage.
7954 release(cursor_image);
7955 release(representation);
7956 }
7957
7958 void RGFW_window_setMouseDefault(RGFW_window* win) {
7959 RGFW_window_setMouseStandard(win, RGFW_MOUSE_ARROW);
7960 }
7961
7962 void RGFW_window_showMouse(RGFW_window* win, i8 show) {
7963 RGFW_UNUSED(win);
7964
7965 if (show) {
7966 CGDisplayShowCursor(kCGDirectMainDisplay);
7967 }
7968 else {
7969 CGDisplayHideCursor(kCGDirectMainDisplay);
7970 }
7971 }
7972
7973 void RGFW_window_setMouseStandard(RGFW_window* win, u8 stdMouses) {
7974 if (stdMouses > ((sizeof(RGFW_mouseIconSrc)) / (sizeof(char*))))
7975 return;
7976
7977 char* mouseStr = RGFW_mouseIconSrc[stdMouses];
7978 void* mouse = NSCursor_arrowStr(mouseStr);
7979
7980 if (mouse == NULL)
7981 return;
7982
7983 RGFW_UNUSED(win);
7984 CGDisplayShowCursor(kCGDirectMainDisplay);
7985 objc_msgSend_void(mouse, sel_registerName("set"));
7986 }
7987
7988 void RGFW_releaseCursor(RGFW_window* win) {
7989 RGFW_UNUSED(win);
7990 CGAssociateMouseAndMouseCursorPosition(1);
7991 }
7992
7993 void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) {
7994 RGFW_UNUSED(win)
7995
7996 CGWarpMouseCursorPosition(CGPointMake(r.x + (r.w / 2), r.y + (r.h / 2)));
7997 CGAssociateMouseAndMouseCursorPosition(0);
7998 }
7999
8000 void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v) {
8001 RGFW_UNUSED(win);
8002
8003 CGWarpMouseCursorPosition(CGPointMake(v.x, v.y));
8004 }
8005
8006
8007 void RGFW_window_hide(RGFW_window* win) {
8008 objc_msgSend_void_bool(win->src.window, sel_registerName("setIsVisible:"), false);
8009 }
8010
8011 void RGFW_window_show(RGFW_window* win) {
8012 ((id(*)(id, SEL, SEL))objc_msgSend)(win->src.window, sel_registerName("makeKeyAndOrderFront:"), NULL);
8013 objc_msgSend_void_bool(win->src.window, sel_registerName("setIsVisible:"), true);
8014 }
8015
8016 u8 RGFW_window_isFullscreen(RGFW_window* win) {
8017 assert(win != NULL);
8018
8019 NSWindowStyleMask mask = (NSWindowStyleMask) objc_msgSend_uint(win->src.window, sel_registerName("styleMask"));
8020 return (mask & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen;
8021 }
8022
8023 u8 RGFW_window_isHidden(RGFW_window* win) {
8024 assert(win != NULL);
8025
8026 bool visible = objc_msgSend_bool(win->src.window, sel_registerName("isVisible"));
8027 return visible == NO && !RGFW_window_isMinimized(win);
8028 }
8029
8030 u8 RGFW_window_isMinimized(RGFW_window* win) {
8031 assert(win != NULL);
8032
8033 return objc_msgSend_bool(win->src.window, sel_registerName("isMiniaturized")) == YES;
8034 }
8035
8036 u8 RGFW_window_isMaximized(RGFW_window* win) {
8037 assert(win != NULL);
8038
8039 return objc_msgSend_bool(win->src.window, sel_registerName("isZoomed"));
8040 }
8041
8042 static RGFW_monitor RGFW_NSCreateMonitor(CGDirectDisplayID display) {
8043 RGFW_monitor monitor;
8044
8045 CGRect bounds = CGDisplayBounds(display);
8046 monitor.rect = RGFW_RECT((int) bounds.origin.x, (int) bounds.origin.y, (int) bounds.size.width, (int) bounds.size.height);
8047
8048 CGSize screenSizeMM = CGDisplayScreenSize(display);
8049 monitor.physW = screenSizeMM.width;
8050 monitor.physH = screenSizeMM.height;
8051
8052 monitor.scaleX = ((monitor.rect.w / (screenSizeMM.width / 25.4)) / 96) + 0.25;
8053 monitor.scaleY = ((monitor.rect.h / (screenSizeMM.height / 25.4)) / 96) + 0.25;
8054
8055 return monitor;
8056 }
8057
8058
8059 static RGFW_monitor RGFW_monitors[7];
8060
8061 RGFW_monitor* RGFW_getMonitors(void) {
8062 static CGDirectDisplayID displays[7];
8063 u32 count;
8064
8065 if (CGGetActiveDisplayList(6, displays, &count) != kCGErrorSuccess)
8066 return NULL;
8067
8068 for (u32 i = 0; i < count; i++)
8069 RGFW_monitors[i] = RGFW_NSCreateMonitor(displays[i]);
8070
8071 return RGFW_monitors;
8072 }
8073
8074 RGFW_monitor RGFW_getPrimaryMonitor(void) {
8075 CGDirectDisplayID primary = CGMainDisplayID();
8076 return RGFW_NSCreateMonitor(primary);
8077 }
8078
8079 RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) {
8080 return RGFW_NSCreateMonitor(win->src.display);
8081 }
8082
8083 char* RGFW_readClipboard(size_t* size) {
8084 char* clip = (char*)NSPasteboard_stringForType(NSPasteboard_generalPasteboard(), NSPasteboardTypeString);
8085
8086 size_t clip_len = 1;
8087
8088 if (clip != NULL) {
8089 clip_len = strlen(clip) + 1;
8090 }
8091
8092 char* str = (char*)RGFW_MALLOC(sizeof(char) * clip_len);
8093
8094 if (clip != NULL) {
8095 strncpy(str, clip, clip_len);
8096 }
8097
8098 str[clip_len] = '\0';
8099
8100 if (size != NULL)
8101 *size = clip_len;
8102 return str;
8103 }
8104
8105 void RGFW_writeClipboard(const char* text, u32 textLen) {
8106 RGFW_UNUSED(textLen);
8107
8108 NSPasteboardType array[] = { NSPasteboardTypeString, NULL };
8109 NSPasteBoard_declareTypes(NSPasteboard_generalPasteboard(), array, 1, NULL);
8110
8111 NSPasteBoard_setString(NSPasteboard_generalPasteboard(), text, NSPasteboardTypeString);
8112 }
8113
8114 u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) {
8115 RGFW_UNUSED(jsNumber);
8116
8117 assert(win != NULL);
8118
8119 return RGFW_registerJoystickF(win, (char*) "");
8120 }
8121
8122 u16 RGFW_registerJoystickF(RGFW_window* win, char* file) {
8123 RGFW_UNUSED(file);
8124
8125 assert(win != NULL);
8126
8127 return RGFW_joystickCount - 1;
8128 }
8129
8130 #ifdef RGFW_OPENGL
8131 void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
8132 assert(win != NULL);
8133 objc_msgSend_void(win->src.ctx, sel_registerName("makeCurrentContext"));
8134 }
8135 #endif
8136
8137 #if !defined(RGFW_EGL)
8138 void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) {
8139 assert(win != NULL);
8140 #if defined(RGFW_OPENGL)
8141
8142 NSOpenGLContext_setValues(win->src.ctx, &swapInterval, 222);
8143 #else
8144 RGFW_UNUSED(swapInterval);
8145 #endif
8146 }
8147 #endif
8148
8149 // Function to create a CGImageRef from an array of bytes
8150 CGImageRef createImageFromBytes(unsigned char *buffer, int width, int height)
8151 {
8152 // Define color space
8153 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
8154 // Create bitmap context
8155 CGContextRef context = CGBitmapContextCreate(
8156 buffer,
8157 width, height,
8158 8,
8159 RGFW_bufferSize.w * 4,
8160 colorSpace,
8161 kCGImageAlphaPremultipliedLast);
8162 // Create image from bitmap context
8163 CGImageRef image = CGBitmapContextCreateImage(context);
8164 // Release the color space and context
8165 CGColorSpaceRelease(colorSpace);
8166 CGContextRelease(context);
8167
8168 return image;
8169 }
8170
8171 void RGFW_window_swapBuffers(RGFW_window* win) {
8172 assert(win != NULL);
8173 /* clear the window*/
8174
8175 if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) {
8176#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
8177 #ifdef RGFW_OSMESA
8178 RGFW_OSMesa_reorganize();
8179 #endif
8180
8181 void* view = NSWindow_contentView(win->src.window);
8182 void* layer = objc_msgSend_id(view, sel_registerName("layer"));
8183
8184 ((void(*)(id, SEL, NSRect))objc_msgSend)(layer,
8185 sel_registerName("setFrame:"),
8186 (NSRect){{0, 0}, {win->r.w, win->r.h}});
8187
8188 CGImageRef image = createImageFromBytes(win->buffer, win->r.w, win->r.h);
8189 // Get the current graphics context
8190 id graphicsContext = objc_msgSend_class(objc_getClass("NSGraphicsContext"), sel_registerName("currentContext"));
8191 // Get the CGContext from the current NSGraphicsContext
8192 id cgContext = objc_msgSend_id(graphicsContext, sel_registerName("graphicsPort"));
8193 // Draw the image in the context
8194 NSRect bounds = (NSRect){{0,0}, {win->r.w, win->r.h}};
8195 CGContextDrawImage((void*)cgContext, *(CGRect*)&bounds, image);
8196 // Flush the graphics context to ensure the drawing is displayed
8197 objc_msgSend_id(graphicsContext, sel_registerName("flushGraphics"));
8198
8199 objc_msgSend_void_id(layer, sel_registerName("setContents:"), (id)image);
8200 objc_msgSend_id(layer, sel_registerName("setNeedsDisplay"));
8201
8202 CGImageRelease(image);
8203#endif
8204 }
8205
8206 if (!(win->_winArgs & RGFW_NO_GPU_RENDER)) {
8207 #ifdef RGFW_EGL
8208 eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface);
8209 #elif defined(RGFW_OPENGL)
8210 objc_msgSend_void(win->src.ctx, sel_registerName("flushBuffer"));
8211 #endif
8212 }
8213 }
8214
8215 void RGFW_window_close(RGFW_window* win) {
8216 assert(win != NULL);
8217 release(win->src.view);
8218
8219#ifdef RGFW_ALLOC_DROPFILES
8220 {
8221 u32 i;
8222 for (i = 0; i < RGFW_MAX_DROPS; i++)
8223 RGFW_FREE(win->event.droppedFiles[i]);
8224
8225
8226 RGFW_FREE(win->event.droppedFiles);
8227 }
8228#endif
8229
8230#ifdef RGFW_BUFFER
8231 release(win->src.bitmap);
8232 release(win->src.image);
8233#endif
8234
8235 CVDisplayLinkStop(win->src.displayLink);
8236 CVDisplayLinkRelease(win->src.displayLink);
8237
8238 RGFW_FREE(win);
8239 }
8240
8241 u64 RGFW_getTimeNS(void) {
8242 static mach_timebase_info_data_t timebase_info;
8243 if (timebase_info.denom == 0) {
8244 mach_timebase_info(&timebase_info);
8245 }
8246 return mach_absolute_time() * timebase_info.numer / timebase_info.denom;
8247 }
8248
8249 u64 RGFW_getTime(void) {
8250 static mach_timebase_info_data_t timebase_info;
8251 if (timebase_info.denom == 0) {
8252 mach_timebase_info(&timebase_info);
8253 }
8254 return (double) mach_absolute_time() * (double) timebase_info.numer / ((double) timebase_info.denom * 1e9);
8255 }
8256#endif /* RGFW_MACOS */
8257
8258/*
8259 End of MaOS defines
8260*/
8261
8262/*
8263 WEBASM defines
8264*/
8265
8266#ifdef RGFW_WEBASM
8267RGFW_Event RGFW_events[20];
8268size_t RGFW_eventLen = 0;
8269
8270EM_BOOL Emscripten_on_keydown(int eventType, const EmscriptenKeyboardEvent* e, void* userData) {
8271 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8272
8273 RGFW_events[RGFW_eventLen].type = RGFW_keyPressed;
8274 memcpy(RGFW_events[RGFW_eventLen].keyName, e->key, 16);
8275 RGFW_events[RGFW_eventLen].keyCode = RGFW_apiKeyCodeToRGFW(e->keyCode);
8276 RGFW_events[RGFW_eventLen].lockState = 0;
8277 RGFW_eventLen++;
8278
8279 RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].prev = RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current;
8280 RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current = 1;
8281 RGFW_keyCallback(RGFW_root, RGFW_apiKeyCodeToRGFW(e->keyCode), RGFW_events[RGFW_eventLen].keyName, 0, 1);
8282
8283 return EM_TRUE;
8284}
8285
8286EM_BOOL Emscripten_on_keyup(int eventType, const EmscriptenKeyboardEvent* e, void* userData) {
8287 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8288
8289 RGFW_events[RGFW_eventLen].type = RGFW_keyReleased;
8290 memcpy(RGFW_events[RGFW_eventLen].keyName, e->key, 16);
8291 RGFW_events[RGFW_eventLen].keyCode = RGFW_apiKeyCodeToRGFW(e->keyCode);
8292 RGFW_events[RGFW_eventLen].lockState = 0;
8293 RGFW_eventLen++;
8294
8295 RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].prev = RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current;
8296 RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current = 0;
8297
8298 RGFW_keyCallback(RGFW_root, RGFW_apiKeyCodeToRGFW(e->keyCode), RGFW_events[RGFW_eventLen].keyName, 0, 0);
8299
8300 return EM_TRUE;
8301}
8302
8303EM_BOOL Emscripten_on_resize(int eventType, const EmscriptenUiEvent* e, void* userData) {
8304 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8305
8306 RGFW_events[RGFW_eventLen].type = RGFW_windowResized;
8307 RGFW_eventLen++;
8308
8309 RGFW_windowResizeCallback(RGFW_root, RGFW_RECT(0, 0, e->windowInnerWidth, e->windowInnerHeight));
8310 return EM_TRUE;
8311}
8312
8313EM_BOOL Emscripten_on_fullscreenchange(int eventType, const EmscriptenFullscreenChangeEvent* e, void* userData) {
8314 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8315
8316 RGFW_events[RGFW_eventLen].type = RGFW_windowResized;
8317 RGFW_eventLen++;
8318
8319 RGFW_root->r = RGFW_RECT(0, 0, e->elementWidth, e->elementHeight);
8320 RGFW_windowResizeCallback(RGFW_root, RGFW_root->r);
8321 return EM_TRUE;
8322}
8323
8324EM_BOOL Emscripten_on_focusin(int eventType, const EmscriptenFocusEvent* e, void* userData) {
8325 RGFW_UNUSED(eventType); RGFW_UNUSED(userData); RGFW_UNUSED(e);
8326
8327 RGFW_events[RGFW_eventLen].type = RGFW_focusIn;
8328 RGFW_eventLen++;
8329
8330 RGFW_root->event.inFocus = 1;
8331 RGFW_focusCallback(RGFW_root, 1);
8332 return EM_TRUE;
8333}
8334
8335EM_BOOL Emscripten_on_focusout(int eventType, const EmscriptenFocusEvent* e, void* userData) {
8336 RGFW_UNUSED(eventType); RGFW_UNUSED(userData); RGFW_UNUSED(e);
8337
8338 RGFW_events[RGFW_eventLen].type = RGFW_focusOut;
8339 RGFW_eventLen++;
8340
8341 RGFW_root->event.inFocus = 0;
8342 RGFW_focusCallback(RGFW_root, 0);
8343 return EM_TRUE;
8344}
8345
8346EM_BOOL Emscripten_on_mousemove(int eventType, const EmscriptenMouseEvent* e, void* userData) {
8347 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8348
8349 RGFW_events[RGFW_eventLen].type = RGFW_mousePosChanged;
8350
8351 if ((RGFW_root->_winArgs & RGFW_HOLD_MOUSE)) {
8352 RGFW_point p = RGFW_POINT(e->movementX, e->movementY);
8353 RGFW_events[RGFW_eventLen].point = p;
8354 }
8355 else
8356 RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->targetX, e->targetY);
8357 RGFW_eventLen++;
8358
8359 RGFW_mousePosCallback(RGFW_root, RGFW_events[RGFW_eventLen].point);
8360 return EM_TRUE;
8361}
8362
8363EM_BOOL Emscripten_on_mousedown(int eventType, const EmscriptenMouseEvent* e, void* userData) {
8364 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8365
8366 RGFW_events[RGFW_eventLen].type = RGFW_mouseButtonPressed;
8367 RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->targetX, e->targetY);
8368 RGFW_events[RGFW_eventLen].button = e->button + 1;
8369 RGFW_events[RGFW_eventLen].scroll = 0;
8370
8371 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].prev = RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current;
8372 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current = 1;
8373
8374 RGFW_mouseButtonCallback(RGFW_root, RGFW_events[RGFW_eventLen].button, RGFW_events[RGFW_eventLen].scroll, 1);
8375 RGFW_eventLen++;
8376
8377 return EM_TRUE;
8378}
8379
8380EM_BOOL Emscripten_on_mouseup(int eventType, const EmscriptenMouseEvent* e, void* userData) {
8381 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8382
8383 RGFW_events[RGFW_eventLen].type = RGFW_mouseButtonReleased;
8384 RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->targetX, e->targetY);
8385 RGFW_events[RGFW_eventLen].button = e->button + 1;
8386 RGFW_events[RGFW_eventLen].scroll = 0;
8387
8388 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].prev = RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current;
8389 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current = 0;
8390
8391 RGFW_mouseButtonCallback(RGFW_root, RGFW_events[RGFW_eventLen].button, RGFW_events[RGFW_eventLen].scroll, 0);
8392 RGFW_eventLen++;
8393 return EM_TRUE;
8394}
8395
8396EM_BOOL Emscripten_on_wheel(int eventType, const EmscriptenWheelEvent* e, void* userData) {
8397 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8398
8399 RGFW_events[RGFW_eventLen].type = RGFW_mouseButtonPressed;
8400 RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->mouse.targetX, e->mouse.targetY);
8401 RGFW_events[RGFW_eventLen].button = RGFW_mouseScrollUp + (e->deltaY < 0);
8402 RGFW_events[RGFW_eventLen].scroll = e->deltaY;
8403
8404 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].prev = RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current;
8405 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current = 1;
8406
8407 RGFW_mouseButtonCallback(RGFW_root, RGFW_events[RGFW_eventLen].button, RGFW_events[RGFW_eventLen].scroll, 1);
8408 RGFW_eventLen++;
8409
8410 return EM_TRUE;
8411}
8412
8413EM_BOOL Emscripten_on_touchstart(int eventType, const EmscriptenTouchEvent* e, void* userData) {
8414 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8415
8416 size_t i;
8417 for (i = 0; i < (size_t)e->numTouches; i++) {
8418 RGFW_events[RGFW_eventLen].type = RGFW_mouseButtonPressed;
8419 RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->touches[i].targetX, e->touches[i].targetY);
8420 RGFW_events[RGFW_eventLen].button = 1;
8421 RGFW_events[RGFW_eventLen].scroll = 0;
8422
8423
8424 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].prev = RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current;
8425 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current = 1;
8426
8427 RGFW_mousePosCallback(RGFW_root, RGFW_events[RGFW_eventLen].point);
8428
8429 RGFW_mouseButtonCallback(RGFW_root, RGFW_events[RGFW_eventLen].button, RGFW_events[RGFW_eventLen].scroll, 1);
8430 RGFW_eventLen++;
8431 }
8432
8433 return EM_TRUE;
8434}
8435EM_BOOL Emscripten_on_touchmove(int eventType, const EmscriptenTouchEvent* e, void* userData) {
8436 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8437
8438 size_t i;
8439 for (i = 0; i < (size_t)e->numTouches; i++) {
8440 RGFW_events[RGFW_eventLen].type = RGFW_mousePosChanged;
8441 RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->touches[i].targetX, e->touches[i].targetY);
8442
8443 RGFW_mousePosCallback(RGFW_root, RGFW_events[RGFW_eventLen].point);
8444 RGFW_eventLen++;
8445 }
8446 return EM_TRUE;
8447}
8448
8449EM_BOOL Emscripten_on_touchend(int eventType, const EmscriptenTouchEvent* e, void* userData) {
8450 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8451
8452 size_t i;
8453 for (i = 0; i < (size_t)e->numTouches; i++) {
8454 RGFW_events[RGFW_eventLen].type = RGFW_mouseButtonReleased;
8455 RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->touches[i].targetX, e->touches[i].targetY);
8456 RGFW_events[RGFW_eventLen].button = 1;
8457 RGFW_events[RGFW_eventLen].scroll = 0;
8458
8459 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].prev = RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current;
8460 RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current = 0;
8461
8462 RGFW_mouseButtonCallback(RGFW_root, RGFW_events[RGFW_eventLen].button, RGFW_events[RGFW_eventLen].scroll, 0);
8463 RGFW_eventLen++;
8464 }
8465 return EM_TRUE;
8466}
8467
8468EM_BOOL Emscripten_on_touchcancel(int eventType, const EmscriptenTouchEvent* e, void* userData) { RGFW_UNUSED(eventType); RGFW_UNUSED(userData); RGFW_UNUSED(e); return EM_TRUE; }
8469
8470EM_BOOL Emscripten_on_gamepad(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) {
8471 RGFW_UNUSED(eventType); RGFW_UNUSED(userData);
8472
8473 if (gamepadEvent->index >= 4)
8474 return 0;
8475
8476 RGFW_joysticks[gamepadEvent->index] = gamepadEvent->connected;
8477
8478 return 1; // The event was consumed by the callback handler
8479}
8480
8481void EMSCRIPTEN_KEEPALIVE Emscripten_onDrop(size_t count) {
8482 if (!(RGFW_root->_winArgs & RGFW_ALLOW_DND))
8483 return;
8484
8485 RGFW_events[RGFW_eventLen].droppedFilesCount = count;
8486 RGFW_dndCallback(RGFW_root, RGFW_events[RGFW_eventLen].droppedFiles, count);
8487 RGFW_eventLen++;
8488}
8489
8490b8 RGFW_stopCheckEvents_bool = RGFW_FALSE;
8491void RGFW_stopCheckEvents(void) {
8492 RGFW_stopCheckEvents_bool = RGFW_TRUE;
8493}
8494
8495void RGFW_window_eventWait(RGFW_window* win, i32 waitMS) {
8496 RGFW_UNUSED(win);
8497
8498 if (waitMS == 0)
8499 return;
8500
8501 u32 start = (u32)(((u64)RGFW_getTimeNS()) / 1e+6);
8502
8503 while ((RGFW_eventLen == 0) && RGFW_stopCheckEvents_bool == RGFW_FALSE &&
8504 (waitMS < 0 || (RGFW_getTimeNS() / 1e+6) - start < waitMS)
8505 ) {
8506 emscripten_sleep(0);
8507 }
8508
8509 RGFW_stopCheckEvents_bool = RGFW_FALSE;
8510}
8511
8512RGFWDEF void RGFW_init_buffer(RGFW_window* win);
8513void RGFW_init_buffer(RGFW_window* win) {
8514 #if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
8515 if (RGFW_bufferSize.w == 0 && RGFW_bufferSize.h == 0)
8516 RGFW_bufferSize = RGFW_getScreenSize();
8517
8518 win->buffer = RGFW_MALLOC(RGFW_bufferSize.w * RGFW_bufferSize.h * 4);
8519 #ifdef RGFW_OSMESA
8520 win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
8521 OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h);
8522 #endif
8523 #else
8524 RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
8525 #endif
8526}
8527
8528void EMSCRIPTEN_KEEPALIVE RGFW_makeSetValue(size_t index, char* file) {
8529 /* This seems like a terrible idea, don't replicate this unless you hate yourself or the OS */
8530 /* TODO: find a better way to do this,
8531 strcpy doesn't seem to work, maybe because of asyncio
8532 */
8533
8534 RGFW_events[RGFW_eventLen].type = RGFW_dnd;
8535 char** arr = (char**)&RGFW_events[RGFW_eventLen].droppedFiles[index];
8536 *arr = file;
8537}
8538
8539#include <sys/stat.h>
8540#include <sys/types.h>
8541#include <errno.h>
8542
8543void EMSCRIPTEN_KEEPALIVE RGFW_mkdir(char* name) { mkdir(name, 0755); }
8544
8545void EMSCRIPTEN_KEEPALIVE RGFW_writeFile(const char *path, const char *data, size_t len) {
8546 FILE* file = fopen(path, "w+");
8547 if (file == NULL)
8548 return;
8549
8550 fwrite(data, sizeof(char), len, file);
8551 fclose(file);
8552}
8553
8554RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
8555 RGFW_UNUSED(name)
8556
8557 RGFW_UNUSED(RGFW_initFormatAttribs);
8558
8559 RGFW_window* win = RGFW_window_basic_init(rect, args);
8560
8561#ifndef RGFW_WEBGPU
8562 EmscriptenWebGLContextAttributes attrs;
8563 attrs.alpha = EM_TRUE;
8564 attrs.depth = EM_TRUE;
8565 attrs.alpha = EM_TRUE;
8566 attrs.stencil = RGFW_STENCIL;
8567 attrs.antialias = RGFW_SAMPLES;
8568 attrs.premultipliedAlpha = EM_TRUE;
8569 attrs.preserveDrawingBuffer = EM_FALSE;
8570
8571 if (RGFW_DOUBLE_BUFFER == 0)
8572 attrs.renderViaOffscreenBackBuffer = 0;
8573 else
8574 attrs.renderViaOffscreenBackBuffer = RGFW_AUX_BUFFERS;
8575
8576 attrs.failIfMajorPerformanceCaveat = EM_FALSE;
8577 attrs.majorVersion = (RGFW_majorVersion == 0) ? 1 : RGFW_majorVersion;
8578 attrs.minorVersion = RGFW_minorVersion;
8579
8580 attrs.enableExtensionsByDefault = EM_TRUE;
8581 attrs.explicitSwapControl = EM_TRUE;
8582
8583 emscripten_webgl_init_context_attributes(&attrs);
8584 win->src.ctx = emscripten_webgl_create_context("#canvas", &attrs);
8585 emscripten_webgl_make_context_current(win->src.ctx);
8586
8587 #ifdef LEGACY_GL_EMULATION
8588 EM_ASM("Module.useWebGL = true; GLImmediate.init();");
8589 #endif
8590#else
8591 win->src.ctx = wgpuCreateInstance(NULL);
8592 win->src.device = emscripten_webgpu_get_device();
8593 win->src.queue = wgpuDeviceGetQueue(win->src.device);
8594#endif
8595
8596 emscripten_set_canvas_element_size("#canvas", rect.w, rect.h);
8597 emscripten_set_window_title(name);
8598
8599 /* load callbacks */
8600 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_keydown);
8601 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_keyup);
8602 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_resize);
8603 emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, EM_FALSE, Emscripten_on_fullscreenchange);
8604 emscripten_set_mousemove_callback("#canvas", NULL, EM_FALSE, Emscripten_on_mousemove);
8605 emscripten_set_touchstart_callback("#canvas", NULL, EM_FALSE, Emscripten_on_touchstart);
8606 emscripten_set_touchend_callback("#canvas", NULL, EM_FALSE, Emscripten_on_touchend);
8607 emscripten_set_touchmove_callback("#canvas", NULL, EM_FALSE, Emscripten_on_touchmove);
8608 emscripten_set_touchcancel_callback("#canvas", NULL, EM_FALSE, Emscripten_on_touchcancel);
8609 emscripten_set_mousedown_callback("#canvas", NULL, EM_FALSE, Emscripten_on_mousedown);
8610 emscripten_set_mouseup_callback("#canvas", NULL, EM_FALSE, Emscripten_on_mouseup);
8611 emscripten_set_wheel_callback("#canvas", NULL, EM_FALSE, Emscripten_on_wheel);
8612 emscripten_set_focusin_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_focusin);
8613 emscripten_set_focusout_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_focusout);
8614 emscripten_set_gamepadconnected_callback(NULL, 1, Emscripten_on_gamepad);
8615 emscripten_set_gamepaddisconnected_callback(NULL, 1, Emscripten_on_gamepad);
8616
8617 if (args & RGFW_ALLOW_DND) {
8618 win->_winArgs |= RGFW_ALLOW_DND;
8619 }
8620
8621 EM_ASM({
8622 var canvas = document.getElementById('canvas');
8623 canvas.addEventListener('drop', function(e) {
8624 e.preventDefault();
8625 if (e.dataTransfer.file < 0)
8626 return;
8627
8628 var filenamesArray = [];
8629 var count = e.dataTransfer.files.length;
8630
8631 /* Read and save the files to emscripten's files */
8632 var drop_dir = '.rgfw_dropped_files';
8633 Module._RGFW_mkdir(drop_dir);
8634
8635 for (var i = 0; i < count; i++) {
8636 var file = e.dataTransfer.files[i];
8637
8638 var path = '/' + drop_dir + '/' + file.name.replace("//", '_');
8639 var reader = new FileReader();
8640
8641 reader.onloadend = (e) => {
8642 if (reader.readyState != 2) {
8643 out('failed to read dropped file: '+file.name+': '+reader.error);
8644 }
8645 else {
8646 var data = e.target.result;
8647
8648 _RGFW_writeFile(path, new Uint8Array(data), file.size);
8649 }
8650 };
8651
8652 reader.readAsArrayBuffer(file);
8653 // This works weird on modern opengl
8654 var filename = stringToNewUTF8(path);
8655
8656 filenamesArray.push(filename);
8657
8658 Module._RGFW_makeSetValue(i, filename);
8659 }
8660
8661 Module._Emscripten_onDrop(count);
8662
8663 for (var i = 0; i < count; ++i) {
8664 _free(filenamesArray[i]);
8665 }
8666 }, true);
8667
8668 canvas.addEventListener('dragover', function(e) { e.preventDefault(); return false; }, true);
8669 });
8670
8671 RGFW_init_buffer(win);
8672 glViewport(0, 0, rect.w, rect.h);
8673
8674 RGFW_root = win;
8675
8676 if (args & RGFW_HIDE_MOUSE) {
8677 RGFW_window_showMouse(win, 0);
8678 }
8679
8680 if (args & RGFW_FULLSCREEN) {
8681 RGFW_window_resize(win, RGFW_getScreenSize());
8682 }
8683
8684 return win;
8685}
8686
8687RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
8688 static u8 index = 0;
8689
8690 if (index == 0)
8691 RGFW_resetKey();
8692
8693 /* check gamepads */
8694 for (int i = 0; (i < emscripten_get_num_gamepads()) && (i < 4); i++) {
8695 if (RGFW_joysticks[i] == 0)
8696 continue;;
8697
8698 EmscriptenGamepadEvent gamepadState;
8699
8700 if (emscripten_get_gamepad_status(i, &gamepadState) != EMSCRIPTEN_RESULT_SUCCESS)
8701 break;
8702
8703 // Register buttons data for every connected gamepad
8704 for (int j = 0; (j < gamepadState.numButtons) && (j < 16); j++) {
8705 u32 map[] = {
8706 RGFW_JS_A, RGFW_JS_X, RGFW_JS_B, RGFW_JS_Y,
8707 RGFW_JS_L1, RGFW_JS_R1, RGFW_JS_L2, RGFW_JS_R2,
8708 RGFW_JS_SELECT, RGFW_JS_START,
8709 0, 0,
8710 RGFW_JS_UP, RGFW_JS_DOWN, RGFW_JS_LEFT, RGFW_JS_RIGHT
8711 };
8712
8713 u32 button = map[j];
8714 if (RGFW_jsPressed[i][button] != gamepadState.digitalButton[j]) {
8715 win->event.type = RGFW_jsButtonPressed;
8716 win->event.joystick = i;
8717 win->event.button = map[j];
8718 return &win->event;
8719 }
8720
8721 RGFW_jsPressed[i][button] = gamepadState.digitalButton[j];
8722 }
8723
8724 for (int j = 0; (j < gamepadState.numAxes) && (j < 4); j += 2) {
8725 win->event.axisesCount = gamepadState.numAxes;
8726 if (win->event.axis[j].x != gamepadState.axis[j] ||
8727 win->event.axis[j].y != gamepadState.axis[j + 1]
8728 ) {
8729 win->event.axis[j].x = gamepadState.axis[j];
8730 win->event.axis[j].y = gamepadState.axis[j + 1];
8731 win->event.type = RGFW_jsAxisMove;
8732 win->event.joystick = i;
8733 return &win->event;
8734 }
8735 }
8736 }
8737
8738 /* check queued events */
8739 if (RGFW_eventLen == 0)
8740 return NULL;
8741
8742 RGFW_events[index].frameTime = win->event.frameTime;
8743 RGFW_events[index].frameTime2 = win->event.frameTime2;
8744 RGFW_events[index].inFocus = win->event.inFocus;
8745
8746 win->event = RGFW_events[index];
8747
8748 RGFW_eventLen--;
8749
8750 if (RGFW_eventLen)
8751 index++;
8752 else
8753 index = 0;
8754
8755 return &win->event;
8756}
8757
8758void RGFW_window_resize(RGFW_window* win, RGFW_area a) {
8759 RGFW_UNUSED(win)
8760 emscripten_set_canvas_element_size("#canvas", a.w, a.h);
8761}
8762
8763/* NOTE: I don't know if this is possible */
8764void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v) { RGFW_UNUSED(win); RGFW_UNUSED(v); }
8765/* this one might be possible but it looks iffy */
8766void RGFW_window_setMouse(RGFW_window* win, u8* image, RGFW_area a, i32 channels) { RGFW_UNUSED(win); RGFW_UNUSED(channels) RGFW_UNUSED(a) RGFW_UNUSED(image) }
8767
8768const char RGFW_CURSORS[11][12] = {
8769 "default",
8770 "default",
8771 "text",
8772 "crosshair",
8773 "pointer",
8774 "ew-resize",
8775 "ns-resize",
8776 "nwse-resize",
8777 "nesw-resize",
8778 "move",
8779 "not-allowed"
8780};
8781
8782void RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
8783 RGFW_UNUSED(win)
8784 EM_ASM( { document.getElementById("canvas").style.cursor = UTF8ToString($0); }, RGFW_CURSORS[mouse]);
8785}
8786
8787void RGFW_window_setMouseDefault(RGFW_window* win) {
8788 RGFW_window_setMouseStandard(win, RGFW_MOUSE_NORMAL);
8789}
8790
8791void RGFW_window_showMouse(RGFW_window* win, i8 show) {
8792 if (show)
8793 RGFW_window_setMouseDefault(win);
8794 else
8795 EM_ASM(document.getElementById('canvas').style.cursor = 'none';);
8796}
8797
8798RGFW_point RGFW_getGlobalMousePoint(void) {
8799 RGFW_point point;
8800 point.x = EM_ASM_INT({
8801 return window.mouseX || 0;
8802 });
8803 point.y = EM_ASM_INT({
8804 return window.mouseY || 0;
8805 });
8806 return point;
8807}
8808
8809RGFW_point RGFW_window_getMousePoint(RGFW_window* win) {
8810 RGFW_UNUSED(win);
8811
8812 EmscriptenMouseEvent mouseEvent;
8813 emscripten_get_mouse_status(&mouseEvent);
8814 return RGFW_POINT( mouseEvent.targetX, mouseEvent.targetY);
8815}
8816
8817void RGFW_window_setMousePassthrough(RGFW_window* win, b8 passthrough) {
8818 RGFW_UNUSED(win);
8819
8820 EM_ASM_({
8821 var canvas = document.getElementById('canvas');
8822 if ($0) {
8823 canvas.style.pointerEvents = 'none';
8824 } else {
8825 canvas.style.pointerEvents = 'auto';
8826 }
8827 }, passthrough);
8828}
8829
8830void RGFW_writeClipboard(const char* text, u32 textLen) {
8831 RGFW_UNUSED(textLen)
8832 EM_ASM({ navigator.clipboard.writeText(UTF8ToString($0)); }, text);
8833}
8834
8835
8836char* RGFW_readClipboard(size_t* size) {
8837 /*
8838 placeholder code for later
8839 I'm not sure if this is possible do the the async stuff
8840 */
8841
8842 if (size != NULL)
8843 *size = 0;
8844
8845 char* str = (char*)malloc(1);
8846 str[0] = '\0';
8847
8848 return str;
8849}
8850
8851void RGFW_window_swapBuffers(RGFW_window* win) {
8852 RGFW_UNUSED(win);
8853
8854 #ifdef RGFW_BUFFER
8855 if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) {
8856 glEnable(GL_TEXTURE_2D);
8857
8858 GLuint texture;
8859 glGenTextures(1,&texture);
8860
8861 glBindTexture(GL_TEXTURE_2D,texture);
8862
8863 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
8864 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
8865 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
8866 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
8867
8868 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RGFW_bufferSize.w, RGFW_bufferSize.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, win->buffer);
8869
8870 float ratioX = ((float)win->r.w / (float)RGFW_bufferSize.w);
8871 float ratioY = ((float)win->r.h / (float)RGFW_bufferSize.h);
8872
8873 // Set up the viewport
8874 glClear(GL_COLOR_BUFFER_BIT);
8875
8876 glBegin(GL_TRIANGLES);
8877 glTexCoord2f(0, ratioY); glColor3f(1, 1, 1); glVertex2f(-1, -1);
8878 glTexCoord2f(0, 0); glColor3f(1, 1, 1); glVertex2f(-1, 1);
8879 glTexCoord2f(ratioX, ratioY); glColor3f(1, 1, 1); glVertex2f(1, -1);
8880
8881 glTexCoord2f(ratioX, 0); glColor3f(1, 1, 1); glVertex2f(1, 1);
8882 glTexCoord2f(ratioX, ratioY); glColor3f(1, 1, 1); glVertex2f(1, -1);
8883 glTexCoord2f(0, 0); glColor3f(1, 1, 1); glVertex2f(-1, 1);
8884 glEnd();
8885
8886 glDeleteTextures(1, &texture);
8887 }
8888 #endif
8889
8890#ifndef RGFW_WEBGPU
8891 emscripten_webgl_commit_frame();
8892#endif
8893 emscripten_sleep(0);
8894}
8895
8896
8897void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
8898#ifndef RGFW_WEBGPU
8899 if (win == NULL)
8900 emscripten_webgl_make_context_current(0);
8901 else
8902 emscripten_webgl_make_context_current(win->src.ctx);
8903#endif
8904}
8905
8906#ifndef RGFW_EGL
8907void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) { RGFW_UNUSED(win); RGFW_UNUSED(swapInterval); }
8908#endif
8909
8910void RGFW_window_close(RGFW_window* win) {
8911#ifndef RGFW_WEBGPU
8912 emscripten_webgl_destroy_context(win->src.ctx);
8913#endif
8914
8915 free(win);
8916}
8917
8918int RGFW_innerWidth(void) { return EM_ASM_INT({ return window.innerWidth; }); }
8919int RGFW_innerHeight(void) { return EM_ASM_INT({ return window.innerHeight; }); }
8920
8921RGFW_area RGFW_getScreenSize(void) {
8922 return RGFW_AREA(RGFW_innerWidth(), RGFW_innerHeight());
8923}
8924
8925void* RGFW_getProcAddress(const char* procname) {
8926 return emscripten_webgl_get_proc_address(procname);
8927}
8928
8929void RGFW_sleep(u64 milisecond) {
8930 emscripten_sleep(milisecond);
8931}
8932
8933u64 RGFW_getTimeNS(void) {
8934 return emscripten_get_now() * 1e+6;
8935}
8936
8937u64 RGFW_getTime(void) {
8938 return emscripten_get_now() * 1000;
8939}
8940
8941void RGFW_releaseCursor(RGFW_window* win) {
8942 RGFW_UNUSED(win);
8943 emscripten_exit_pointerlock();
8944}
8945
8946void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) {
8947 RGFW_UNUSED(win); RGFW_UNUSED(r);
8948
8949 emscripten_request_pointerlock("#canvas", 1);
8950}
8951
8952
8953void RGFW_window_setName(RGFW_window* win, char* name) {
8954 RGFW_UNUSED(win);
8955 emscripten_set_window_title(name);
8956}
8957
8958/* unsupported functions */
8959RGFW_monitor* RGFW_getMonitors(void) { return NULL; }
8960RGFW_monitor RGFW_getPrimaryMonitor(void) { return (RGFW_monitor){}; }
8961void RGFW_window_move(RGFW_window* win, RGFW_point v) { RGFW_UNUSED(win) RGFW_UNUSED(v) }
8962void RGFW_window_setMinSize(RGFW_window* win, RGFW_area a) { RGFW_UNUSED(win) RGFW_UNUSED(a) }
8963void RGFW_window_setMaxSize(RGFW_window* win, RGFW_area a) { RGFW_UNUSED(win) RGFW_UNUSED(a) }
8964void RGFW_window_minimize(RGFW_window* win) { RGFW_UNUSED(win)}
8965void RGFW_window_restore(RGFW_window* win) { RGFW_UNUSED(win) }
8966void RGFW_window_setBorder(RGFW_window* win, b8 border) { RGFW_UNUSED(win) RGFW_UNUSED(border) }
8967void RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) { RGFW_UNUSED(win) RGFW_UNUSED(icon) RGFW_UNUSED(a) RGFW_UNUSED(channels) }
8968void RGFW_window_hide(RGFW_window* win) { RGFW_UNUSED(win) }
8969void RGFW_window_show(RGFW_window* win) {RGFW_UNUSED(win) }
8970b8 RGFW_window_isHidden(RGFW_window* win) { RGFW_UNUSED(win) return 0; }
8971b8 RGFW_window_isMinimized(RGFW_window* win) { RGFW_UNUSED(win) return 0; }
8972b8 RGFW_window_isMaximized(RGFW_window* win) { RGFW_UNUSED(win) return 0; }
8973RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) { RGFW_UNUSED(win) return (RGFW_monitor){}; }
8974
8975#endif
8976
8977/* end of web asm defines */
8978
8979/* unix (macOS, linux, web asm) only stuff */
8980#if defined(RGFW_X11) || defined(RGFW_MACOS) || defined(RGFW_WEBASM) || defined(RGFW_WAYLAND)
8981/* unix threading */
8982#ifndef RGFW_NO_THREADS
8983#include <pthread.h>
8984
8985 RGFW_thread RGFW_createThread(RGFW_threadFunc_ptr ptr, void* args) {
8986 RGFW_UNUSED(args);
8987
8988 RGFW_thread t;
8989 pthread_create((pthread_t*) &t, NULL, *ptr, NULL);
8990 return t;
8991 }
8992 void RGFW_cancelThread(RGFW_thread thread) { pthread_cancel((pthread_t) thread); }
8993 void RGFW_joinThread(RGFW_thread thread) { pthread_join((pthread_t) thread, NULL); }
8994#ifdef __linux__
8995 void RGFW_setThreadPriority(RGFW_thread thread, u8 priority) { pthread_setschedprio((pthread_t)thread, priority); }
8996#endif
8997#endif
8998
8999#ifndef RGFW_WEBASM
9000/* unix sleep */
9001 void RGFW_sleep(u64 ms) {
9002 struct timespec time;
9003 time.tv_sec = 0;
9004 time.tv_nsec = ms * 1e+6;
9005
9006 nanosleep(&time, NULL);
9007 }
9008#endif
9009
9010#endif /* end of unix / mac stuff*/
9011#endif /*RGFW_IMPLEMENTATION*/
9012
9013#if defined(__cplusplus) && !defined(__EMSCRIPTEN__)
9014}
9015#endif
diff --git a/raylib/src/external/cgltf.h b/raylib/src/external/cgltf.h
new file mode 100644
index 0000000..36fd644
--- /dev/null
+++ b/raylib/src/external/cgltf.h
@@ -0,0 +1,7081 @@
1/**
2 * cgltf - a single-file glTF 2.0 parser written in C99.
3 *
4 * Version: 1.14
5 *
6 * Website: https://github.com/jkuhlmann/cgltf
7 *
8 * Distributed under the MIT License, see notice at the end of this file.
9 *
10 * Building:
11 * Include this file where you need the struct and function
12 * declarations. Have exactly one source file where you define
13 * `CGLTF_IMPLEMENTATION` before including this file to get the
14 * function definitions.
15 *
16 * Reference:
17 * `cgltf_result cgltf_parse(const cgltf_options*, const void*,
18 * cgltf_size, cgltf_data**)` parses both glTF and GLB data. If
19 * this function returns `cgltf_result_success`, you have to call
20 * `cgltf_free()` on the created `cgltf_data*` variable.
21 * Note that contents of external files for buffers and images are not
22 * automatically loaded. You'll need to read these files yourself using
23 * URIs in the `cgltf_data` structure.
24 *
25 * `cgltf_options` is the struct passed to `cgltf_parse()` to control
26 * parts of the parsing process. You can use it to force the file type
27 * and provide memory allocation as well as file operation callbacks.
28 * Should be zero-initialized to trigger default behavior.
29 *
30 * `cgltf_data` is the struct allocated and filled by `cgltf_parse()`.
31 * It generally mirrors the glTF format as described by the spec (see
32 * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0).
33 *
34 * `void cgltf_free(cgltf_data*)` frees the allocated `cgltf_data`
35 * variable.
36 *
37 * `cgltf_result cgltf_load_buffers(const cgltf_options*, cgltf_data*,
38 * const char* gltf_path)` can be optionally called to open and read buffer
39 * files using the `FILE*` APIs. The `gltf_path` argument is the path to
40 * the original glTF file, which allows the parser to resolve the path to
41 * buffer files.
42 *
43 * `cgltf_result cgltf_load_buffer_base64(const cgltf_options* options,
44 * cgltf_size size, const char* base64, void** out_data)` decodes
45 * base64-encoded data content. Used internally by `cgltf_load_buffers()`.
46 * This is useful when decoding data URIs in images.
47 *
48 * `cgltf_result cgltf_parse_file(const cgltf_options* options, const
49 * char* path, cgltf_data** out_data)` can be used to open the given
50 * file using `FILE*` APIs and parse the data using `cgltf_parse()`.
51 *
52 * `cgltf_result cgltf_validate(cgltf_data*)` can be used to do additional
53 * checks to make sure the parsed glTF data is valid.
54 *
55 * `cgltf_node_transform_local` converts the translation / rotation / scale properties of a node
56 * into a mat4.
57 *
58 * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every ancestor in order
59 * to compute the root-to-node transformation.
60 *
61 * `cgltf_accessor_unpack_floats` reads in the data from an accessor, applies sparse data (if any),
62 * and converts them to floating point. Assumes that `cgltf_load_buffers` has already been called.
63 * By passing null for the output pointer, users can find out how many floats are required in the
64 * output buffer.
65 *
66 * `cgltf_accessor_unpack_indices` reads in the index data from an accessor. Assumes that
67 * `cgltf_load_buffers` has already been called. By passing null for the output pointer, users can
68 * find out how many indices are required in the output buffer. Returns 0 if the accessor is
69 * sparse or if the output component size is less than the accessor's component size.
70 *
71 * `cgltf_num_components` is a tiny utility that tells you the dimensionality of
72 * a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate
73 * the necessary amount of memory. `cgltf_component_size` and `cgltf_calc_size` exist for
74 * similar purposes.
75 *
76 * `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to
77 * floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element
78 * size is the number of floats in the output buffer, which should be in the range [1, 16]. Returns
79 * false if the passed-in element_size is too small, or if the accessor is sparse.
80 *
81 * `cgltf_accessor_read_uint` is similar to its floating-point counterpart, but limited to reading
82 * vector types and does not support matrix types. The passed-in element size is the number of uints
83 * in the output buffer, which should be in the range [1, 4]. Returns false if the passed-in
84 * element_size is too small, or if the accessor is sparse.
85 *
86 * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t
87 * and only works with single-component data types.
88 *
89 * `cgltf_copy_extras_json` allows users to retrieve the "extras" data that can be attached to many
90 * glTF objects (which can be arbitrary JSON data). This is a legacy function, consider using
91 * cgltf_extras::data directly instead. You can parse this data using your own JSON parser
92 * or, if you've included the cgltf implementation using the integrated JSMN JSON parser.
93 */
94#ifndef CGLTF_H_INCLUDED__
95#define CGLTF_H_INCLUDED__
96
97#include <stddef.h>
98#include <stdint.h> /* For uint8_t, uint32_t */
99
100#ifdef __cplusplus
101extern "C" {
102#endif
103
104typedef size_t cgltf_size;
105typedef long long int cgltf_ssize;
106typedef float cgltf_float;
107typedef int cgltf_int;
108typedef unsigned int cgltf_uint;
109typedef int cgltf_bool;
110
111typedef enum cgltf_file_type
112{
113 cgltf_file_type_invalid,
114 cgltf_file_type_gltf,
115 cgltf_file_type_glb,
116 cgltf_file_type_max_enum
117} cgltf_file_type;
118
119typedef enum cgltf_result
120{
121 cgltf_result_success,
122 cgltf_result_data_too_short,
123 cgltf_result_unknown_format,
124 cgltf_result_invalid_json,
125 cgltf_result_invalid_gltf,
126 cgltf_result_invalid_options,
127 cgltf_result_file_not_found,
128 cgltf_result_io_error,
129 cgltf_result_out_of_memory,
130 cgltf_result_legacy_gltf,
131 cgltf_result_max_enum
132} cgltf_result;
133
134typedef struct cgltf_memory_options
135{
136 void* (*alloc_func)(void* user, cgltf_size size);
137 void (*free_func) (void* user, void* ptr);
138 void* user_data;
139} cgltf_memory_options;
140
141typedef struct cgltf_file_options
142{
143 cgltf_result(*read)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data);
144 void (*release)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data);
145 void* user_data;
146} cgltf_file_options;
147
148typedef struct cgltf_options
149{
150 cgltf_file_type type; /* invalid == auto detect */
151 cgltf_size json_token_count; /* 0 == auto */
152 cgltf_memory_options memory;
153 cgltf_file_options file;
154} cgltf_options;
155
156typedef enum cgltf_buffer_view_type
157{
158 cgltf_buffer_view_type_invalid,
159 cgltf_buffer_view_type_indices,
160 cgltf_buffer_view_type_vertices,
161 cgltf_buffer_view_type_max_enum
162} cgltf_buffer_view_type;
163
164typedef enum cgltf_attribute_type
165{
166 cgltf_attribute_type_invalid,
167 cgltf_attribute_type_position,
168 cgltf_attribute_type_normal,
169 cgltf_attribute_type_tangent,
170 cgltf_attribute_type_texcoord,
171 cgltf_attribute_type_color,
172 cgltf_attribute_type_joints,
173 cgltf_attribute_type_weights,
174 cgltf_attribute_type_custom,
175 cgltf_attribute_type_max_enum
176} cgltf_attribute_type;
177
178typedef enum cgltf_component_type
179{
180 cgltf_component_type_invalid,
181 cgltf_component_type_r_8, /* BYTE */
182 cgltf_component_type_r_8u, /* UNSIGNED_BYTE */
183 cgltf_component_type_r_16, /* SHORT */
184 cgltf_component_type_r_16u, /* UNSIGNED_SHORT */
185 cgltf_component_type_r_32u, /* UNSIGNED_INT */
186 cgltf_component_type_r_32f, /* FLOAT */
187 cgltf_component_type_max_enum
188} cgltf_component_type;
189
190typedef enum cgltf_type
191{
192 cgltf_type_invalid,
193 cgltf_type_scalar,
194 cgltf_type_vec2,
195 cgltf_type_vec3,
196 cgltf_type_vec4,
197 cgltf_type_mat2,
198 cgltf_type_mat3,
199 cgltf_type_mat4,
200 cgltf_type_max_enum
201} cgltf_type;
202
203typedef enum cgltf_primitive_type
204{
205 cgltf_primitive_type_invalid,
206 cgltf_primitive_type_points,
207 cgltf_primitive_type_lines,
208 cgltf_primitive_type_line_loop,
209 cgltf_primitive_type_line_strip,
210 cgltf_primitive_type_triangles,
211 cgltf_primitive_type_triangle_strip,
212 cgltf_primitive_type_triangle_fan,
213 cgltf_primitive_type_max_enum
214} cgltf_primitive_type;
215
216typedef enum cgltf_alpha_mode
217{
218 cgltf_alpha_mode_opaque,
219 cgltf_alpha_mode_mask,
220 cgltf_alpha_mode_blend,
221 cgltf_alpha_mode_max_enum
222} cgltf_alpha_mode;
223
224typedef enum cgltf_animation_path_type {
225 cgltf_animation_path_type_invalid,
226 cgltf_animation_path_type_translation,
227 cgltf_animation_path_type_rotation,
228 cgltf_animation_path_type_scale,
229 cgltf_animation_path_type_weights,
230 cgltf_animation_path_type_max_enum
231} cgltf_animation_path_type;
232
233typedef enum cgltf_interpolation_type {
234 cgltf_interpolation_type_linear,
235 cgltf_interpolation_type_step,
236 cgltf_interpolation_type_cubic_spline,
237 cgltf_interpolation_type_max_enum
238} cgltf_interpolation_type;
239
240typedef enum cgltf_camera_type {
241 cgltf_camera_type_invalid,
242 cgltf_camera_type_perspective,
243 cgltf_camera_type_orthographic,
244 cgltf_camera_type_max_enum
245} cgltf_camera_type;
246
247typedef enum cgltf_light_type {
248 cgltf_light_type_invalid,
249 cgltf_light_type_directional,
250 cgltf_light_type_point,
251 cgltf_light_type_spot,
252 cgltf_light_type_max_enum
253} cgltf_light_type;
254
255typedef enum cgltf_data_free_method {
256 cgltf_data_free_method_none,
257 cgltf_data_free_method_file_release,
258 cgltf_data_free_method_memory_free,
259 cgltf_data_free_method_max_enum
260} cgltf_data_free_method;
261
262typedef struct cgltf_extras {
263 cgltf_size start_offset; /* this field is deprecated and will be removed in the future; use data instead */
264 cgltf_size end_offset; /* this field is deprecated and will be removed in the future; use data instead */
265
266 char* data;
267} cgltf_extras;
268
269typedef struct cgltf_extension {
270 char* name;
271 char* data;
272} cgltf_extension;
273
274typedef struct cgltf_buffer
275{
276 char* name;
277 cgltf_size size;
278 char* uri;
279 void* data; /* loaded by cgltf_load_buffers */
280 cgltf_data_free_method data_free_method;
281 cgltf_extras extras;
282 cgltf_size extensions_count;
283 cgltf_extension* extensions;
284} cgltf_buffer;
285
286typedef enum cgltf_meshopt_compression_mode {
287 cgltf_meshopt_compression_mode_invalid,
288 cgltf_meshopt_compression_mode_attributes,
289 cgltf_meshopt_compression_mode_triangles,
290 cgltf_meshopt_compression_mode_indices,
291 cgltf_meshopt_compression_mode_max_enum
292} cgltf_meshopt_compression_mode;
293
294typedef enum cgltf_meshopt_compression_filter {
295 cgltf_meshopt_compression_filter_none,
296 cgltf_meshopt_compression_filter_octahedral,
297 cgltf_meshopt_compression_filter_quaternion,
298 cgltf_meshopt_compression_filter_exponential,
299 cgltf_meshopt_compression_filter_max_enum
300} cgltf_meshopt_compression_filter;
301
302typedef struct cgltf_meshopt_compression
303{
304 cgltf_buffer* buffer;
305 cgltf_size offset;
306 cgltf_size size;
307 cgltf_size stride;
308 cgltf_size count;
309 cgltf_meshopt_compression_mode mode;
310 cgltf_meshopt_compression_filter filter;
311} cgltf_meshopt_compression;
312
313typedef struct cgltf_buffer_view
314{
315 char *name;
316 cgltf_buffer* buffer;
317 cgltf_size offset;
318 cgltf_size size;
319 cgltf_size stride; /* 0 == automatically determined by accessor */
320 cgltf_buffer_view_type type;
321 void* data; /* overrides buffer->data if present, filled by extensions */
322 cgltf_bool has_meshopt_compression;
323 cgltf_meshopt_compression meshopt_compression;
324 cgltf_extras extras;
325 cgltf_size extensions_count;
326 cgltf_extension* extensions;
327} cgltf_buffer_view;
328
329typedef struct cgltf_accessor_sparse
330{
331 cgltf_size count;
332 cgltf_buffer_view* indices_buffer_view;
333 cgltf_size indices_byte_offset;
334 cgltf_component_type indices_component_type;
335 cgltf_buffer_view* values_buffer_view;
336 cgltf_size values_byte_offset;
337} cgltf_accessor_sparse;
338
339typedef struct cgltf_accessor
340{
341 char* name;
342 cgltf_component_type component_type;
343 cgltf_bool normalized;
344 cgltf_type type;
345 cgltf_size offset;
346 cgltf_size count;
347 cgltf_size stride;
348 cgltf_buffer_view* buffer_view;
349 cgltf_bool has_min;
350 cgltf_float min[16];
351 cgltf_bool has_max;
352 cgltf_float max[16];
353 cgltf_bool is_sparse;
354 cgltf_accessor_sparse sparse;
355 cgltf_extras extras;
356 cgltf_size extensions_count;
357 cgltf_extension* extensions;
358} cgltf_accessor;
359
360typedef struct cgltf_attribute
361{
362 char* name;
363 cgltf_attribute_type type;
364 cgltf_int index;
365 cgltf_accessor* data;
366} cgltf_attribute;
367
368typedef struct cgltf_image
369{
370 char* name;
371 char* uri;
372 cgltf_buffer_view* buffer_view;
373 char* mime_type;
374 cgltf_extras extras;
375 cgltf_size extensions_count;
376 cgltf_extension* extensions;
377} cgltf_image;
378
379typedef struct cgltf_sampler
380{
381 char* name;
382 cgltf_int mag_filter;
383 cgltf_int min_filter;
384 cgltf_int wrap_s;
385 cgltf_int wrap_t;
386 cgltf_extras extras;
387 cgltf_size extensions_count;
388 cgltf_extension* extensions;
389} cgltf_sampler;
390
391typedef struct cgltf_texture
392{
393 char* name;
394 cgltf_image* image;
395 cgltf_sampler* sampler;
396 cgltf_bool has_basisu;
397 cgltf_image* basisu_image;
398 cgltf_bool has_webp;
399 cgltf_image* webp_image;
400 cgltf_extras extras;
401 cgltf_size extensions_count;
402 cgltf_extension* extensions;
403} cgltf_texture;
404
405typedef struct cgltf_texture_transform
406{
407 cgltf_float offset[2];
408 cgltf_float rotation;
409 cgltf_float scale[2];
410 cgltf_bool has_texcoord;
411 cgltf_int texcoord;
412} cgltf_texture_transform;
413
414typedef struct cgltf_texture_view
415{
416 cgltf_texture* texture;
417 cgltf_int texcoord;
418 cgltf_float scale; /* equivalent to strength for occlusion_texture */
419 cgltf_bool has_transform;
420 cgltf_texture_transform transform;
421} cgltf_texture_view;
422
423typedef struct cgltf_pbr_metallic_roughness
424{
425 cgltf_texture_view base_color_texture;
426 cgltf_texture_view metallic_roughness_texture;
427
428 cgltf_float base_color_factor[4];
429 cgltf_float metallic_factor;
430 cgltf_float roughness_factor;
431} cgltf_pbr_metallic_roughness;
432
433typedef struct cgltf_pbr_specular_glossiness
434{
435 cgltf_texture_view diffuse_texture;
436 cgltf_texture_view specular_glossiness_texture;
437
438 cgltf_float diffuse_factor[4];
439 cgltf_float specular_factor[3];
440 cgltf_float glossiness_factor;
441} cgltf_pbr_specular_glossiness;
442
443typedef struct cgltf_clearcoat
444{
445 cgltf_texture_view clearcoat_texture;
446 cgltf_texture_view clearcoat_roughness_texture;
447 cgltf_texture_view clearcoat_normal_texture;
448
449 cgltf_float clearcoat_factor;
450 cgltf_float clearcoat_roughness_factor;
451} cgltf_clearcoat;
452
453typedef struct cgltf_transmission
454{
455 cgltf_texture_view transmission_texture;
456 cgltf_float transmission_factor;
457} cgltf_transmission;
458
459typedef struct cgltf_ior
460{
461 cgltf_float ior;
462} cgltf_ior;
463
464typedef struct cgltf_specular
465{
466 cgltf_texture_view specular_texture;
467 cgltf_texture_view specular_color_texture;
468 cgltf_float specular_color_factor[3];
469 cgltf_float specular_factor;
470} cgltf_specular;
471
472typedef struct cgltf_volume
473{
474 cgltf_texture_view thickness_texture;
475 cgltf_float thickness_factor;
476 cgltf_float attenuation_color[3];
477 cgltf_float attenuation_distance;
478} cgltf_volume;
479
480typedef struct cgltf_sheen
481{
482 cgltf_texture_view sheen_color_texture;
483 cgltf_float sheen_color_factor[3];
484 cgltf_texture_view sheen_roughness_texture;
485 cgltf_float sheen_roughness_factor;
486} cgltf_sheen;
487
488typedef struct cgltf_emissive_strength
489{
490 cgltf_float emissive_strength;
491} cgltf_emissive_strength;
492
493typedef struct cgltf_iridescence
494{
495 cgltf_float iridescence_factor;
496 cgltf_texture_view iridescence_texture;
497 cgltf_float iridescence_ior;
498 cgltf_float iridescence_thickness_min;
499 cgltf_float iridescence_thickness_max;
500 cgltf_texture_view iridescence_thickness_texture;
501} cgltf_iridescence;
502
503typedef struct cgltf_anisotropy
504{
505 cgltf_float anisotropy_strength;
506 cgltf_float anisotropy_rotation;
507 cgltf_texture_view anisotropy_texture;
508} cgltf_anisotropy;
509
510typedef struct cgltf_dispersion
511{
512 cgltf_float dispersion;
513} cgltf_dispersion;
514
515typedef struct cgltf_material
516{
517 char* name;
518 cgltf_bool has_pbr_metallic_roughness;
519 cgltf_bool has_pbr_specular_glossiness;
520 cgltf_bool has_clearcoat;
521 cgltf_bool has_transmission;
522 cgltf_bool has_volume;
523 cgltf_bool has_ior;
524 cgltf_bool has_specular;
525 cgltf_bool has_sheen;
526 cgltf_bool has_emissive_strength;
527 cgltf_bool has_iridescence;
528 cgltf_bool has_anisotropy;
529 cgltf_bool has_dispersion;
530 cgltf_pbr_metallic_roughness pbr_metallic_roughness;
531 cgltf_pbr_specular_glossiness pbr_specular_glossiness;
532 cgltf_clearcoat clearcoat;
533 cgltf_ior ior;
534 cgltf_specular specular;
535 cgltf_sheen sheen;
536 cgltf_transmission transmission;
537 cgltf_volume volume;
538 cgltf_emissive_strength emissive_strength;
539 cgltf_iridescence iridescence;
540 cgltf_anisotropy anisotropy;
541 cgltf_dispersion dispersion;
542 cgltf_texture_view normal_texture;
543 cgltf_texture_view occlusion_texture;
544 cgltf_texture_view emissive_texture;
545 cgltf_float emissive_factor[3];
546 cgltf_alpha_mode alpha_mode;
547 cgltf_float alpha_cutoff;
548 cgltf_bool double_sided;
549 cgltf_bool unlit;
550 cgltf_extras extras;
551 cgltf_size extensions_count;
552 cgltf_extension* extensions;
553} cgltf_material;
554
555typedef struct cgltf_material_mapping
556{
557 cgltf_size variant;
558 cgltf_material* material;
559 cgltf_extras extras;
560} cgltf_material_mapping;
561
562typedef struct cgltf_morph_target {
563 cgltf_attribute* attributes;
564 cgltf_size attributes_count;
565} cgltf_morph_target;
566
567typedef struct cgltf_draco_mesh_compression {
568 cgltf_buffer_view* buffer_view;
569 cgltf_attribute* attributes;
570 cgltf_size attributes_count;
571} cgltf_draco_mesh_compression;
572
573typedef struct cgltf_mesh_gpu_instancing {
574 cgltf_attribute* attributes;
575 cgltf_size attributes_count;
576} cgltf_mesh_gpu_instancing;
577
578typedef struct cgltf_primitive {
579 cgltf_primitive_type type;
580 cgltf_accessor* indices;
581 cgltf_material* material;
582 cgltf_attribute* attributes;
583 cgltf_size attributes_count;
584 cgltf_morph_target* targets;
585 cgltf_size targets_count;
586 cgltf_extras extras;
587 cgltf_bool has_draco_mesh_compression;
588 cgltf_draco_mesh_compression draco_mesh_compression;
589 cgltf_material_mapping* mappings;
590 cgltf_size mappings_count;
591 cgltf_size extensions_count;
592 cgltf_extension* extensions;
593} cgltf_primitive;
594
595typedef struct cgltf_mesh {
596 char* name;
597 cgltf_primitive* primitives;
598 cgltf_size primitives_count;
599 cgltf_float* weights;
600 cgltf_size weights_count;
601 char** target_names;
602 cgltf_size target_names_count;
603 cgltf_extras extras;
604 cgltf_size extensions_count;
605 cgltf_extension* extensions;
606} cgltf_mesh;
607
608typedef struct cgltf_node cgltf_node;
609
610typedef struct cgltf_skin {
611 char* name;
612 cgltf_node** joints;
613 cgltf_size joints_count;
614 cgltf_node* skeleton;
615 cgltf_accessor* inverse_bind_matrices;
616 cgltf_extras extras;
617 cgltf_size extensions_count;
618 cgltf_extension* extensions;
619} cgltf_skin;
620
621typedef struct cgltf_camera_perspective {
622 cgltf_bool has_aspect_ratio;
623 cgltf_float aspect_ratio;
624 cgltf_float yfov;
625 cgltf_bool has_zfar;
626 cgltf_float zfar;
627 cgltf_float znear;
628 cgltf_extras extras;
629} cgltf_camera_perspective;
630
631typedef struct cgltf_camera_orthographic {
632 cgltf_float xmag;
633 cgltf_float ymag;
634 cgltf_float zfar;
635 cgltf_float znear;
636 cgltf_extras extras;
637} cgltf_camera_orthographic;
638
639typedef struct cgltf_camera {
640 char* name;
641 cgltf_camera_type type;
642 union {
643 cgltf_camera_perspective perspective;
644 cgltf_camera_orthographic orthographic;
645 } data;
646 cgltf_extras extras;
647 cgltf_size extensions_count;
648 cgltf_extension* extensions;
649} cgltf_camera;
650
651typedef struct cgltf_light {
652 char* name;
653 cgltf_float color[3];
654 cgltf_float intensity;
655 cgltf_light_type type;
656 cgltf_float range;
657 cgltf_float spot_inner_cone_angle;
658 cgltf_float spot_outer_cone_angle;
659 cgltf_extras extras;
660} cgltf_light;
661
662struct cgltf_node {
663 char* name;
664 cgltf_node* parent;
665 cgltf_node** children;
666 cgltf_size children_count;
667 cgltf_skin* skin;
668 cgltf_mesh* mesh;
669 cgltf_camera* camera;
670 cgltf_light* light;
671 cgltf_float* weights;
672 cgltf_size weights_count;
673 cgltf_bool has_translation;
674 cgltf_bool has_rotation;
675 cgltf_bool has_scale;
676 cgltf_bool has_matrix;
677 cgltf_float translation[3];
678 cgltf_float rotation[4];
679 cgltf_float scale[3];
680 cgltf_float matrix[16];
681 cgltf_extras extras;
682 cgltf_bool has_mesh_gpu_instancing;
683 cgltf_mesh_gpu_instancing mesh_gpu_instancing;
684 cgltf_size extensions_count;
685 cgltf_extension* extensions;
686};
687
688typedef struct cgltf_scene {
689 char* name;
690 cgltf_node** nodes;
691 cgltf_size nodes_count;
692 cgltf_extras extras;
693 cgltf_size extensions_count;
694 cgltf_extension* extensions;
695} cgltf_scene;
696
697typedef struct cgltf_animation_sampler {
698 cgltf_accessor* input;
699 cgltf_accessor* output;
700 cgltf_interpolation_type interpolation;
701 cgltf_extras extras;
702 cgltf_size extensions_count;
703 cgltf_extension* extensions;
704} cgltf_animation_sampler;
705
706typedef struct cgltf_animation_channel {
707 cgltf_animation_sampler* sampler;
708 cgltf_node* target_node;
709 cgltf_animation_path_type target_path;
710 cgltf_extras extras;
711 cgltf_size extensions_count;
712 cgltf_extension* extensions;
713} cgltf_animation_channel;
714
715typedef struct cgltf_animation {
716 char* name;
717 cgltf_animation_sampler* samplers;
718 cgltf_size samplers_count;
719 cgltf_animation_channel* channels;
720 cgltf_size channels_count;
721 cgltf_extras extras;
722 cgltf_size extensions_count;
723 cgltf_extension* extensions;
724} cgltf_animation;
725
726typedef struct cgltf_material_variant
727{
728 char* name;
729 cgltf_extras extras;
730} cgltf_material_variant;
731
732typedef struct cgltf_asset {
733 char* copyright;
734 char* generator;
735 char* version;
736 char* min_version;
737 cgltf_extras extras;
738 cgltf_size extensions_count;
739 cgltf_extension* extensions;
740} cgltf_asset;
741
742typedef struct cgltf_data
743{
744 cgltf_file_type file_type;
745 void* file_data;
746
747 cgltf_asset asset;
748
749 cgltf_mesh* meshes;
750 cgltf_size meshes_count;
751
752 cgltf_material* materials;
753 cgltf_size materials_count;
754
755 cgltf_accessor* accessors;
756 cgltf_size accessors_count;
757
758 cgltf_buffer_view* buffer_views;
759 cgltf_size buffer_views_count;
760
761 cgltf_buffer* buffers;
762 cgltf_size buffers_count;
763
764 cgltf_image* images;
765 cgltf_size images_count;
766
767 cgltf_texture* textures;
768 cgltf_size textures_count;
769
770 cgltf_sampler* samplers;
771 cgltf_size samplers_count;
772
773 cgltf_skin* skins;
774 cgltf_size skins_count;
775
776 cgltf_camera* cameras;
777 cgltf_size cameras_count;
778
779 cgltf_light* lights;
780 cgltf_size lights_count;
781
782 cgltf_node* nodes;
783 cgltf_size nodes_count;
784
785 cgltf_scene* scenes;
786 cgltf_size scenes_count;
787
788 cgltf_scene* scene;
789
790 cgltf_animation* animations;
791 cgltf_size animations_count;
792
793 cgltf_material_variant* variants;
794 cgltf_size variants_count;
795
796 cgltf_extras extras;
797
798 cgltf_size data_extensions_count;
799 cgltf_extension* data_extensions;
800
801 char** extensions_used;
802 cgltf_size extensions_used_count;
803
804 char** extensions_required;
805 cgltf_size extensions_required_count;
806
807 const char* json;
808 cgltf_size json_size;
809
810 const void* bin;
811 cgltf_size bin_size;
812
813 cgltf_memory_options memory;
814 cgltf_file_options file;
815} cgltf_data;
816
817cgltf_result cgltf_parse(
818 const cgltf_options* options,
819 const void* data,
820 cgltf_size size,
821 cgltf_data** out_data);
822
823cgltf_result cgltf_parse_file(
824 const cgltf_options* options,
825 const char* path,
826 cgltf_data** out_data);
827
828cgltf_result cgltf_load_buffers(
829 const cgltf_options* options,
830 cgltf_data* data,
831 const char* gltf_path);
832
833cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data);
834
835cgltf_size cgltf_decode_string(char* string);
836cgltf_size cgltf_decode_uri(char* uri);
837
838cgltf_result cgltf_validate(cgltf_data* data);
839
840void cgltf_free(cgltf_data* data);
841
842void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix);
843void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix);
844
845const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view);
846
847cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size);
848cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size);
849cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
850
851cgltf_size cgltf_num_components(cgltf_type type);
852cgltf_size cgltf_component_size(cgltf_component_type component_type);
853cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
854
855cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count);
856cgltf_size cgltf_accessor_unpack_indices(const cgltf_accessor* accessor, void* out, cgltf_size out_component_size, cgltf_size index_count);
857
858/* this function is deprecated and will be removed in the future; use cgltf_extras::data instead */
859cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size);
860
861cgltf_size cgltf_mesh_index(const cgltf_data* data, const cgltf_mesh* object);
862cgltf_size cgltf_material_index(const cgltf_data* data, const cgltf_material* object);
863cgltf_size cgltf_accessor_index(const cgltf_data* data, const cgltf_accessor* object);
864cgltf_size cgltf_buffer_view_index(const cgltf_data* data, const cgltf_buffer_view* object);
865cgltf_size cgltf_buffer_index(const cgltf_data* data, const cgltf_buffer* object);
866cgltf_size cgltf_image_index(const cgltf_data* data, const cgltf_image* object);
867cgltf_size cgltf_texture_index(const cgltf_data* data, const cgltf_texture* object);
868cgltf_size cgltf_sampler_index(const cgltf_data* data, const cgltf_sampler* object);
869cgltf_size cgltf_skin_index(const cgltf_data* data, const cgltf_skin* object);
870cgltf_size cgltf_camera_index(const cgltf_data* data, const cgltf_camera* object);
871cgltf_size cgltf_light_index(const cgltf_data* data, const cgltf_light* object);
872cgltf_size cgltf_node_index(const cgltf_data* data, const cgltf_node* object);
873cgltf_size cgltf_scene_index(const cgltf_data* data, const cgltf_scene* object);
874cgltf_size cgltf_animation_index(const cgltf_data* data, const cgltf_animation* object);
875cgltf_size cgltf_animation_sampler_index(const cgltf_animation* animation, const cgltf_animation_sampler* object);
876cgltf_size cgltf_animation_channel_index(const cgltf_animation* animation, const cgltf_animation_channel* object);
877
878#ifdef __cplusplus
879}
880#endif
881
882#endif /* #ifndef CGLTF_H_INCLUDED__ */
883
884/*
885 *
886 * Stop now, if you are only interested in the API.
887 * Below, you find the implementation.
888 *
889 */
890
891#if defined(__INTELLISENSE__) || defined(__JETBRAINS_IDE__)
892/* This makes MSVC/CLion intellisense work. */
893#define CGLTF_IMPLEMENTATION
894#endif
895
896#ifdef CGLTF_IMPLEMENTATION
897
898#include <assert.h> /* For assert */
899#include <string.h> /* For strncpy */
900#include <stdio.h> /* For fopen */
901#include <limits.h> /* For UINT_MAX etc */
902#include <float.h> /* For FLT_MAX */
903
904#if !defined(CGLTF_MALLOC) || !defined(CGLTF_FREE) || !defined(CGLTF_ATOI) || !defined(CGLTF_ATOF) || !defined(CGLTF_ATOLL)
905#include <stdlib.h> /* For malloc, free, atoi, atof */
906#endif
907
908/* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in input size */
909#define JSMN_PARENT_LINKS
910
911/* JSMN_STRICT is necessary to reject invalid JSON documents */
912#define JSMN_STRICT
913
914/*
915 * -- jsmn.h start --
916 * Source: https://github.com/zserge/jsmn
917 * License: MIT
918 */
919typedef enum {
920 JSMN_UNDEFINED = 0,
921 JSMN_OBJECT = 1,
922 JSMN_ARRAY = 2,
923 JSMN_STRING = 3,
924 JSMN_PRIMITIVE = 4
925} jsmntype_t;
926enum jsmnerr {
927 /* Not enough tokens were provided */
928 JSMN_ERROR_NOMEM = -1,
929 /* Invalid character inside JSON string */
930 JSMN_ERROR_INVAL = -2,
931 /* The string is not a full JSON packet, more bytes expected */
932 JSMN_ERROR_PART = -3
933};
934typedef struct {
935 jsmntype_t type;
936 ptrdiff_t start;
937 ptrdiff_t end;
938 int size;
939#ifdef JSMN_PARENT_LINKS
940 int parent;
941#endif
942} jsmntok_t;
943typedef struct {
944 size_t pos; /* offset in the JSON string */
945 unsigned int toknext; /* next token to allocate */
946 int toksuper; /* superior token node, e.g parent object or array */
947} jsmn_parser;
948static void jsmn_init(jsmn_parser *parser);
949static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens);
950/*
951 * -- jsmn.h end --
952 */
953
954
955#ifndef CGLTF_CONSTS
956#define GlbHeaderSize 12
957#define GlbChunkHeaderSize 8
958static const uint32_t GlbVersion = 2;
959static const uint32_t GlbMagic = 0x46546C67;
960static const uint32_t GlbMagicJsonChunk = 0x4E4F534A;
961static const uint32_t GlbMagicBinChunk = 0x004E4942;
962#define CGLTF_CONSTS
963#endif
964
965#ifndef CGLTF_MALLOC
966#define CGLTF_MALLOC(size) malloc(size)
967#endif
968#ifndef CGLTF_FREE
969#define CGLTF_FREE(ptr) free(ptr)
970#endif
971#ifndef CGLTF_ATOI
972#define CGLTF_ATOI(str) atoi(str)
973#endif
974#ifndef CGLTF_ATOF
975#define CGLTF_ATOF(str) atof(str)
976#endif
977#ifndef CGLTF_ATOLL
978#define CGLTF_ATOLL(str) atoll(str)
979#endif
980#ifndef CGLTF_VALIDATE_ENABLE_ASSERTS
981#define CGLTF_VALIDATE_ENABLE_ASSERTS 0
982#endif
983
984static void* cgltf_default_alloc(void* user, cgltf_size size)
985{
986 (void)user;
987 return CGLTF_MALLOC(size);
988}
989
990static void cgltf_default_free(void* user, void* ptr)
991{
992 (void)user;
993 CGLTF_FREE(ptr);
994}
995
996static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_size count)
997{
998 if (SIZE_MAX / element_size < count)
999 {
1000 return NULL;
1001 }
1002 void* result = options->memory.alloc_func(options->memory.user_data, element_size * count);
1003 if (!result)
1004 {
1005 return NULL;
1006 }
1007 memset(result, 0, element_size * count);
1008 return result;
1009}
1010
1011static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data)
1012{
1013 (void)file_options;
1014 void* (*memory_alloc)(void*, cgltf_size) = memory_options->alloc_func ? memory_options->alloc_func : &cgltf_default_alloc;
1015 void (*memory_free)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free;
1016
1017 FILE* file = fopen(path, "rb");
1018 if (!file)
1019 {
1020 return cgltf_result_file_not_found;
1021 }
1022
1023 cgltf_size file_size = size ? *size : 0;
1024
1025 if (file_size == 0)
1026 {
1027 fseek(file, 0, SEEK_END);
1028
1029#ifdef _MSC_VER
1030 __int64 length = _ftelli64(file);
1031#else
1032 long length = ftell(file);
1033#endif
1034
1035 if (length < 0)
1036 {
1037 fclose(file);
1038 return cgltf_result_io_error;
1039 }
1040
1041 fseek(file, 0, SEEK_SET);
1042 file_size = (cgltf_size)length;
1043 }
1044
1045 char* file_data = (char*)memory_alloc(memory_options->user_data, file_size);
1046 if (!file_data)
1047 {
1048 fclose(file);
1049 return cgltf_result_out_of_memory;
1050 }
1051
1052 cgltf_size read_size = fread(file_data, 1, file_size, file);
1053
1054 fclose(file);
1055
1056 if (read_size != file_size)
1057 {
1058 memory_free(memory_options->user_data, file_data);
1059 return cgltf_result_io_error;
1060 }
1061
1062 if (size)
1063 {
1064 *size = file_size;
1065 }
1066 if (data)
1067 {
1068 *data = file_data;
1069 }
1070
1071 return cgltf_result_success;
1072}
1073
1074static void cgltf_default_file_release(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data)
1075{
1076 (void)file_options;
1077 void (*memfree)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free;
1078 memfree(memory_options->user_data, data);
1079}
1080
1081static cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data);
1082
1083cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data)
1084{
1085 if (size < GlbHeaderSize)
1086 {
1087 return cgltf_result_data_too_short;
1088 }
1089
1090 if (options == NULL)
1091 {
1092 return cgltf_result_invalid_options;
1093 }
1094
1095 cgltf_options fixed_options = *options;
1096 if (fixed_options.memory.alloc_func == NULL)
1097 {
1098 fixed_options.memory.alloc_func = &cgltf_default_alloc;
1099 }
1100 if (fixed_options.memory.free_func == NULL)
1101 {
1102 fixed_options.memory.free_func = &cgltf_default_free;
1103 }
1104
1105 uint32_t tmp;
1106 // Magic
1107 memcpy(&tmp, data, 4);
1108 if (tmp != GlbMagic)
1109 {
1110 if (fixed_options.type == cgltf_file_type_invalid)
1111 {
1112 fixed_options.type = cgltf_file_type_gltf;
1113 }
1114 else if (fixed_options.type == cgltf_file_type_glb)
1115 {
1116 return cgltf_result_unknown_format;
1117 }
1118 }
1119
1120 if (fixed_options.type == cgltf_file_type_gltf)
1121 {
1122 cgltf_result json_result = cgltf_parse_json(&fixed_options, (const uint8_t*)data, size, out_data);
1123 if (json_result != cgltf_result_success)
1124 {
1125 return json_result;
1126 }
1127
1128 (*out_data)->file_type = cgltf_file_type_gltf;
1129
1130 return cgltf_result_success;
1131 }
1132
1133 const uint8_t* ptr = (const uint8_t*)data;
1134 // Version
1135 memcpy(&tmp, ptr + 4, 4);
1136 uint32_t version = tmp;
1137 if (version != GlbVersion)
1138 {
1139 return version < GlbVersion ? cgltf_result_legacy_gltf : cgltf_result_unknown_format;
1140 }
1141
1142 // Total length
1143 memcpy(&tmp, ptr + 8, 4);
1144 if (tmp > size)
1145 {
1146 return cgltf_result_data_too_short;
1147 }
1148
1149 const uint8_t* json_chunk = ptr + GlbHeaderSize;
1150
1151 if (GlbHeaderSize + GlbChunkHeaderSize > size)
1152 {
1153 return cgltf_result_data_too_short;
1154 }
1155
1156 // JSON chunk: length
1157 uint32_t json_length;
1158 memcpy(&json_length, json_chunk, 4);
1159 if (json_length > size - GlbHeaderSize - GlbChunkHeaderSize)
1160 {
1161 return cgltf_result_data_too_short;
1162 }
1163
1164 // JSON chunk: magic
1165 memcpy(&tmp, json_chunk + 4, 4);
1166 if (tmp != GlbMagicJsonChunk)
1167 {
1168 return cgltf_result_unknown_format;
1169 }
1170
1171 json_chunk += GlbChunkHeaderSize;
1172
1173 const void* bin = NULL;
1174 cgltf_size bin_size = 0;
1175
1176 if (GlbChunkHeaderSize <= size - GlbHeaderSize - GlbChunkHeaderSize - json_length)
1177 {
1178 // We can read another chunk
1179 const uint8_t* bin_chunk = json_chunk + json_length;
1180
1181 // Bin chunk: length
1182 uint32_t bin_length;
1183 memcpy(&bin_length, bin_chunk, 4);
1184 if (bin_length > size - GlbHeaderSize - GlbChunkHeaderSize - json_length - GlbChunkHeaderSize)
1185 {
1186 return cgltf_result_data_too_short;
1187 }
1188
1189 // Bin chunk: magic
1190 memcpy(&tmp, bin_chunk + 4, 4);
1191 if (tmp != GlbMagicBinChunk)
1192 {
1193 return cgltf_result_unknown_format;
1194 }
1195
1196 bin_chunk += GlbChunkHeaderSize;
1197
1198 bin = bin_chunk;
1199 bin_size = bin_length;
1200 }
1201
1202 cgltf_result json_result = cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data);
1203 if (json_result != cgltf_result_success)
1204 {
1205 return json_result;
1206 }
1207
1208 (*out_data)->file_type = cgltf_file_type_glb;
1209 (*out_data)->bin = bin;
1210 (*out_data)->bin_size = bin_size;
1211
1212 return cgltf_result_success;
1213}
1214
1215cgltf_result cgltf_parse_file(const cgltf_options* options, const char* path, cgltf_data** out_data)
1216{
1217 if (options == NULL)
1218 {
1219 return cgltf_result_invalid_options;
1220 }
1221
1222 cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
1223 void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = options->file.release ? options->file.release : cgltf_default_file_release;
1224
1225 void* file_data = NULL;
1226 cgltf_size file_size = 0;
1227 cgltf_result result = file_read(&options->memory, &options->file, path, &file_size, &file_data);
1228 if (result != cgltf_result_success)
1229 {
1230 return result;
1231 }
1232
1233 result = cgltf_parse(options, file_data, file_size, out_data);
1234
1235 if (result != cgltf_result_success)
1236 {
1237 file_release(&options->memory, &options->file, file_data);
1238 return result;
1239 }
1240
1241 (*out_data)->file_data = file_data;
1242
1243 return cgltf_result_success;
1244}
1245
1246static void cgltf_combine_paths(char* path, const char* base, const char* uri)
1247{
1248 const char* s0 = strrchr(base, '/');
1249 const char* s1 = strrchr(base, '\\');
1250 const char* slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1;
1251
1252 if (slash)
1253 {
1254 size_t prefix = slash - base + 1;
1255
1256 strncpy(path, base, prefix);
1257 strcpy(path + prefix, uri);
1258 }
1259 else
1260 {
1261 strcpy(path, uri);
1262 }
1263}
1264
1265static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* gltf_path, void** out_data)
1266{
1267 void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc;
1268 void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free;
1269 cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
1270
1271 char* path = (char*)memory_alloc(options->memory.user_data, strlen(uri) + strlen(gltf_path) + 1);
1272 if (!path)
1273 {
1274 return cgltf_result_out_of_memory;
1275 }
1276
1277 cgltf_combine_paths(path, gltf_path, uri);
1278
1279 // after combining, the tail of the resulting path is a uri; decode_uri converts it into path
1280 cgltf_decode_uri(path + strlen(path) - strlen(uri));
1281
1282 void* file_data = NULL;
1283 cgltf_result result = file_read(&options->memory, &options->file, path, &size, &file_data);
1284
1285 memory_free(options->memory.user_data, path);
1286
1287 *out_data = (result == cgltf_result_success) ? file_data : NULL;
1288
1289 return result;
1290}
1291
1292cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data)
1293{
1294 void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc;
1295 void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free;
1296
1297 unsigned char* data = (unsigned char*)memory_alloc(options->memory.user_data, size);
1298 if (!data)
1299 {
1300 return cgltf_result_out_of_memory;
1301 }
1302
1303 unsigned int buffer = 0;
1304 unsigned int buffer_bits = 0;
1305
1306 for (cgltf_size i = 0; i < size; ++i)
1307 {
1308 while (buffer_bits < 8)
1309 {
1310 char ch = *base64++;
1311
1312 int index =
1313 (unsigned)(ch - 'A') < 26 ? (ch - 'A') :
1314 (unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 :
1315 (unsigned)(ch - '0') < 10 ? (ch - '0') + 52 :
1316 ch == '+' ? 62 :
1317 ch == '/' ? 63 :
1318 -1;
1319
1320 if (index < 0)
1321 {
1322 memory_free(options->memory.user_data, data);
1323 return cgltf_result_io_error;
1324 }
1325
1326 buffer = (buffer << 6) | index;
1327 buffer_bits += 6;
1328 }
1329
1330 data[i] = (unsigned char)(buffer >> (buffer_bits - 8));
1331 buffer_bits -= 8;
1332 }
1333
1334 *out_data = data;
1335
1336 return cgltf_result_success;
1337}
1338
1339static int cgltf_unhex(char ch)
1340{
1341 return
1342 (unsigned)(ch - '0') < 10 ? (ch - '0') :
1343 (unsigned)(ch - 'A') < 6 ? (ch - 'A') + 10 :
1344 (unsigned)(ch - 'a') < 6 ? (ch - 'a') + 10 :
1345 -1;
1346}
1347
1348cgltf_size cgltf_decode_string(char* string)
1349{
1350 char* read = string + strcspn(string, "\\");
1351 if (*read == 0)
1352 {
1353 return read - string;
1354 }
1355 char* write = string;
1356 char* last = string;
1357
1358 for (;;)
1359 {
1360 // Copy characters since last escaped sequence
1361 cgltf_size written = read - last;
1362 memmove(write, last, written);
1363 write += written;
1364
1365 if (*read++ == 0)
1366 {
1367 break;
1368 }
1369
1370 // jsmn already checked that all escape sequences are valid
1371 switch (*read++)
1372 {
1373 case '\"': *write++ = '\"'; break;
1374 case '/': *write++ = '/'; break;
1375 case '\\': *write++ = '\\'; break;
1376 case 'b': *write++ = '\b'; break;
1377 case 'f': *write++ = '\f'; break;
1378 case 'r': *write++ = '\r'; break;
1379 case 'n': *write++ = '\n'; break;
1380 case 't': *write++ = '\t'; break;
1381 case 'u':
1382 {
1383 // UCS-2 codepoint \uXXXX to UTF-8
1384 int character = 0;
1385 for (cgltf_size i = 0; i < 4; ++i)
1386 {
1387 character = (character << 4) + cgltf_unhex(*read++);
1388 }
1389
1390 if (character <= 0x7F)
1391 {
1392 *write++ = character & 0xFF;
1393 }
1394 else if (character <= 0x7FF)
1395 {
1396 *write++ = 0xC0 | ((character >> 6) & 0xFF);
1397 *write++ = 0x80 | (character & 0x3F);
1398 }
1399 else
1400 {
1401 *write++ = 0xE0 | ((character >> 12) & 0xFF);
1402 *write++ = 0x80 | ((character >> 6) & 0x3F);
1403 *write++ = 0x80 | (character & 0x3F);
1404 }
1405 break;
1406 }
1407 default:
1408 break;
1409 }
1410
1411 last = read;
1412 read += strcspn(read, "\\");
1413 }
1414
1415 *write = 0;
1416 return write - string;
1417}
1418
1419cgltf_size cgltf_decode_uri(char* uri)
1420{
1421 char* write = uri;
1422 char* i = uri;
1423
1424 while (*i)
1425 {
1426 if (*i == '%')
1427 {
1428 int ch1 = cgltf_unhex(i[1]);
1429
1430 if (ch1 >= 0)
1431 {
1432 int ch2 = cgltf_unhex(i[2]);
1433
1434 if (ch2 >= 0)
1435 {
1436 *write++ = (char)(ch1 * 16 + ch2);
1437 i += 3;
1438 continue;
1439 }
1440 }
1441 }
1442
1443 *write++ = *i++;
1444 }
1445
1446 *write = 0;
1447 return write - uri;
1448}
1449
1450cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* gltf_path)
1451{
1452 if (options == NULL)
1453 {
1454 return cgltf_result_invalid_options;
1455 }
1456
1457 if (data->buffers_count && data->buffers[0].data == NULL && data->buffers[0].uri == NULL && data->bin)
1458 {
1459 if (data->bin_size < data->buffers[0].size)
1460 {
1461 return cgltf_result_data_too_short;
1462 }
1463
1464 data->buffers[0].data = (void*)data->bin;
1465 data->buffers[0].data_free_method = cgltf_data_free_method_none;
1466 }
1467
1468 for (cgltf_size i = 0; i < data->buffers_count; ++i)
1469 {
1470 if (data->buffers[i].data)
1471 {
1472 continue;
1473 }
1474
1475 const char* uri = data->buffers[i].uri;
1476
1477 if (uri == NULL)
1478 {
1479 continue;
1480 }
1481
1482 if (strncmp(uri, "data:", 5) == 0)
1483 {
1484 const char* comma = strchr(uri, ',');
1485
1486 if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0)
1487 {
1488 cgltf_result res = cgltf_load_buffer_base64(options, data->buffers[i].size, comma + 1, &data->buffers[i].data);
1489 data->buffers[i].data_free_method = cgltf_data_free_method_memory_free;
1490
1491 if (res != cgltf_result_success)
1492 {
1493 return res;
1494 }
1495 }
1496 else
1497 {
1498 return cgltf_result_unknown_format;
1499 }
1500 }
1501 else if (strstr(uri, "://") == NULL && gltf_path)
1502 {
1503 cgltf_result res = cgltf_load_buffer_file(options, data->buffers[i].size, uri, gltf_path, &data->buffers[i].data);
1504 data->buffers[i].data_free_method = cgltf_data_free_method_file_release;
1505
1506 if (res != cgltf_result_success)
1507 {
1508 return res;
1509 }
1510 }
1511 else
1512 {
1513 return cgltf_result_unknown_format;
1514 }
1515 }
1516
1517 return cgltf_result_success;
1518}
1519
1520static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count)
1521{
1522 char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset;
1523 cgltf_size bound = 0;
1524
1525 switch (component_type)
1526 {
1527 case cgltf_component_type_r_8u:
1528 for (size_t i = 0; i < count; ++i)
1529 {
1530 cgltf_size v = ((unsigned char*)data)[i];
1531 bound = bound > v ? bound : v;
1532 }
1533 break;
1534
1535 case cgltf_component_type_r_16u:
1536 for (size_t i = 0; i < count; ++i)
1537 {
1538 cgltf_size v = ((unsigned short*)data)[i];
1539 bound = bound > v ? bound : v;
1540 }
1541 break;
1542
1543 case cgltf_component_type_r_32u:
1544 for (size_t i = 0; i < count; ++i)
1545 {
1546 cgltf_size v = ((unsigned int*)data)[i];
1547 bound = bound > v ? bound : v;
1548 }
1549 break;
1550
1551 default:
1552 ;
1553 }
1554
1555 return bound;
1556}
1557
1558#if CGLTF_VALIDATE_ENABLE_ASSERTS
1559#define CGLTF_ASSERT_IF(cond, result) assert(!(cond)); if (cond) return result;
1560#else
1561#define CGLTF_ASSERT_IF(cond, result) if (cond) return result;
1562#endif
1563
1564cgltf_result cgltf_validate(cgltf_data* data)
1565{
1566 for (cgltf_size i = 0; i < data->accessors_count; ++i)
1567 {
1568 cgltf_accessor* accessor = &data->accessors[i];
1569
1570 CGLTF_ASSERT_IF(data->accessors[i].component_type == cgltf_component_type_invalid, cgltf_result_invalid_gltf);
1571 CGLTF_ASSERT_IF(data->accessors[i].type == cgltf_type_invalid, cgltf_result_invalid_gltf);
1572
1573 cgltf_size element_size = cgltf_calc_size(accessor->type, accessor->component_type);
1574
1575 if (accessor->buffer_view)
1576 {
1577 cgltf_size req_size = accessor->offset + accessor->stride * (accessor->count - 1) + element_size;
1578
1579 CGLTF_ASSERT_IF(accessor->buffer_view->size < req_size, cgltf_result_data_too_short);
1580 }
1581
1582 if (accessor->is_sparse)
1583 {
1584 cgltf_accessor_sparse* sparse = &accessor->sparse;
1585
1586 cgltf_size indices_component_size = cgltf_component_size(sparse->indices_component_type);
1587 cgltf_size indices_req_size = sparse->indices_byte_offset + indices_component_size * sparse->count;
1588 cgltf_size values_req_size = sparse->values_byte_offset + element_size * sparse->count;
1589
1590 CGLTF_ASSERT_IF(sparse->indices_buffer_view->size < indices_req_size ||
1591 sparse->values_buffer_view->size < values_req_size, cgltf_result_data_too_short);
1592
1593 CGLTF_ASSERT_IF(sparse->indices_component_type != cgltf_component_type_r_8u &&
1594 sparse->indices_component_type != cgltf_component_type_r_16u &&
1595 sparse->indices_component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
1596
1597 if (sparse->indices_buffer_view->buffer->data)
1598 {
1599 cgltf_size index_bound = cgltf_calc_index_bound(sparse->indices_buffer_view, sparse->indices_byte_offset, sparse->indices_component_type, sparse->count);
1600
1601 CGLTF_ASSERT_IF(index_bound >= accessor->count, cgltf_result_data_too_short);
1602 }
1603 }
1604 }
1605
1606 for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
1607 {
1608 cgltf_size req_size = data->buffer_views[i].offset + data->buffer_views[i].size;
1609
1610 CGLTF_ASSERT_IF(data->buffer_views[i].buffer && data->buffer_views[i].buffer->size < req_size, cgltf_result_data_too_short);
1611
1612 if (data->buffer_views[i].has_meshopt_compression)
1613 {
1614 cgltf_meshopt_compression* mc = &data->buffer_views[i].meshopt_compression;
1615
1616 CGLTF_ASSERT_IF(mc->buffer == NULL || mc->buffer->size < mc->offset + mc->size, cgltf_result_data_too_short);
1617
1618 CGLTF_ASSERT_IF(data->buffer_views[i].stride && mc->stride != data->buffer_views[i].stride, cgltf_result_invalid_gltf);
1619
1620 CGLTF_ASSERT_IF(data->buffer_views[i].size != mc->stride * mc->count, cgltf_result_invalid_gltf);
1621
1622 CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_invalid, cgltf_result_invalid_gltf);
1623
1624 CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_attributes && !(mc->stride % 4 == 0 && mc->stride <= 256), cgltf_result_invalid_gltf);
1625
1626 CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0, cgltf_result_invalid_gltf);
1627
1628 CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->stride != 2 && mc->stride != 4, cgltf_result_invalid_gltf);
1629
1630 CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->filter != cgltf_meshopt_compression_filter_none, cgltf_result_invalid_gltf);
1631
1632 CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_octahedral && mc->stride != 4 && mc->stride != 8, cgltf_result_invalid_gltf);
1633
1634 CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_quaternion && mc->stride != 8, cgltf_result_invalid_gltf);
1635 }
1636 }
1637
1638 for (cgltf_size i = 0; i < data->meshes_count; ++i)
1639 {
1640 if (data->meshes[i].weights)
1641 {
1642 CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].weights_count, cgltf_result_invalid_gltf);
1643 }
1644
1645 if (data->meshes[i].target_names)
1646 {
1647 CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].target_names_count, cgltf_result_invalid_gltf);
1648 }
1649
1650 for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
1651 {
1652 CGLTF_ASSERT_IF(data->meshes[i].primitives[j].type == cgltf_primitive_type_invalid, cgltf_result_invalid_gltf);
1653 CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets_count != data->meshes[i].primitives[0].targets_count, cgltf_result_invalid_gltf);
1654
1655 CGLTF_ASSERT_IF(data->meshes[i].primitives[j].attributes_count == 0, cgltf_result_invalid_gltf);
1656
1657 cgltf_accessor* first = data->meshes[i].primitives[j].attributes[0].data;
1658
1659 CGLTF_ASSERT_IF(first->count == 0, cgltf_result_invalid_gltf);
1660
1661 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
1662 {
1663 CGLTF_ASSERT_IF(data->meshes[i].primitives[j].attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
1664 }
1665
1666 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
1667 {
1668 for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
1669 {
1670 CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets[k].attributes[m].data->count != first->count, cgltf_result_invalid_gltf);
1671 }
1672 }
1673
1674 cgltf_accessor* indices = data->meshes[i].primitives[j].indices;
1675
1676 CGLTF_ASSERT_IF(indices &&
1677 indices->component_type != cgltf_component_type_r_8u &&
1678 indices->component_type != cgltf_component_type_r_16u &&
1679 indices->component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
1680
1681 CGLTF_ASSERT_IF(indices && indices->type != cgltf_type_scalar, cgltf_result_invalid_gltf);
1682 CGLTF_ASSERT_IF(indices && indices->stride != cgltf_component_size(indices->component_type), cgltf_result_invalid_gltf);
1683
1684 if (indices && indices->buffer_view && indices->buffer_view->buffer->data)
1685 {
1686 cgltf_size index_bound = cgltf_calc_index_bound(indices->buffer_view, indices->offset, indices->component_type, indices->count);
1687
1688 CGLTF_ASSERT_IF(index_bound >= first->count, cgltf_result_data_too_short);
1689 }
1690
1691 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
1692 {
1693 CGLTF_ASSERT_IF(data->meshes[i].primitives[j].mappings[k].variant >= data->variants_count, cgltf_result_invalid_gltf);
1694 }
1695 }
1696 }
1697
1698 for (cgltf_size i = 0; i < data->nodes_count; ++i)
1699 {
1700 if (data->nodes[i].weights && data->nodes[i].mesh)
1701 {
1702 CGLTF_ASSERT_IF(data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
1703 }
1704
1705 if (data->nodes[i].has_mesh_gpu_instancing)
1706 {
1707 CGLTF_ASSERT_IF(data->nodes[i].mesh == NULL, cgltf_result_invalid_gltf);
1708 CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes_count == 0, cgltf_result_invalid_gltf);
1709
1710 cgltf_accessor* first = data->nodes[i].mesh_gpu_instancing.attributes[0].data;
1711
1712 for (cgltf_size k = 0; k < data->nodes[i].mesh_gpu_instancing.attributes_count; ++k)
1713 {
1714 CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
1715 }
1716 }
1717 }
1718
1719 for (cgltf_size i = 0; i < data->nodes_count; ++i)
1720 {
1721 cgltf_node* p1 = data->nodes[i].parent;
1722 cgltf_node* p2 = p1 ? p1->parent : NULL;
1723
1724 while (p1 && p2)
1725 {
1726 CGLTF_ASSERT_IF(p1 == p2, cgltf_result_invalid_gltf);
1727
1728 p1 = p1->parent;
1729 p2 = p2->parent ? p2->parent->parent : NULL;
1730 }
1731 }
1732
1733 for (cgltf_size i = 0; i < data->scenes_count; ++i)
1734 {
1735 for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
1736 {
1737 CGLTF_ASSERT_IF(data->scenes[i].nodes[j]->parent, cgltf_result_invalid_gltf);
1738 }
1739 }
1740
1741 for (cgltf_size i = 0; i < data->animations_count; ++i)
1742 {
1743 for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
1744 {
1745 cgltf_animation_channel* channel = &data->animations[i].channels[j];
1746
1747 if (!channel->target_node)
1748 {
1749 continue;
1750 }
1751
1752 cgltf_size components = 1;
1753
1754 if (channel->target_path == cgltf_animation_path_type_weights)
1755 {
1756 CGLTF_ASSERT_IF(!channel->target_node->mesh || !channel->target_node->mesh->primitives_count, cgltf_result_invalid_gltf);
1757
1758 components = channel->target_node->mesh->primitives[0].targets_count;
1759 }
1760
1761 cgltf_size values = channel->sampler->interpolation == cgltf_interpolation_type_cubic_spline ? 3 : 1;
1762
1763 CGLTF_ASSERT_IF(channel->sampler->input->count * components * values != channel->sampler->output->count, cgltf_result_invalid_gltf);
1764 }
1765 }
1766
1767 for (cgltf_size i = 0; i < data->variants_count; ++i)
1768 {
1769 CGLTF_ASSERT_IF(!data->variants[i].name, cgltf_result_invalid_gltf);
1770 }
1771
1772 return cgltf_result_success;
1773}
1774
1775cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size)
1776{
1777 cgltf_size json_size = extras->end_offset - extras->start_offset;
1778
1779 if (!dest)
1780 {
1781 if (dest_size)
1782 {
1783 *dest_size = json_size + 1;
1784 return cgltf_result_success;
1785 }
1786 return cgltf_result_invalid_options;
1787 }
1788
1789 if (*dest_size + 1 < json_size)
1790 {
1791 strncpy(dest, data->json + extras->start_offset, *dest_size - 1);
1792 dest[*dest_size - 1] = 0;
1793 }
1794 else
1795 {
1796 strncpy(dest, data->json + extras->start_offset, json_size);
1797 dest[json_size] = 0;
1798 }
1799
1800 return cgltf_result_success;
1801}
1802
1803static void cgltf_free_extras(cgltf_data* data, cgltf_extras* extras)
1804{
1805 data->memory.free_func(data->memory.user_data, extras->data);
1806}
1807
1808static void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
1809{
1810 for (cgltf_size i = 0; i < extensions_count; ++i)
1811 {
1812 data->memory.free_func(data->memory.user_data, extensions[i].name);
1813 data->memory.free_func(data->memory.user_data, extensions[i].data);
1814 }
1815 data->memory.free_func(data->memory.user_data, extensions);
1816}
1817
1818void cgltf_free(cgltf_data* data)
1819{
1820 if (!data)
1821 {
1822 return;
1823 }
1824
1825 void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = data->file.release ? data->file.release : cgltf_default_file_release;
1826
1827 data->memory.free_func(data->memory.user_data, data->asset.copyright);
1828 data->memory.free_func(data->memory.user_data, data->asset.generator);
1829 data->memory.free_func(data->memory.user_data, data->asset.version);
1830 data->memory.free_func(data->memory.user_data, data->asset.min_version);
1831
1832 cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count);
1833 cgltf_free_extras(data, &data->asset.extras);
1834
1835 for (cgltf_size i = 0; i < data->accessors_count; ++i)
1836 {
1837 data->memory.free_func(data->memory.user_data, data->accessors[i].name);
1838
1839 cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count);
1840 cgltf_free_extras(data, &data->accessors[i].extras);
1841 }
1842 data->memory.free_func(data->memory.user_data, data->accessors);
1843
1844 for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
1845 {
1846 data->memory.free_func(data->memory.user_data, data->buffer_views[i].name);
1847 data->memory.free_func(data->memory.user_data, data->buffer_views[i].data);
1848
1849 cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count);
1850 cgltf_free_extras(data, &data->buffer_views[i].extras);
1851 }
1852 data->memory.free_func(data->memory.user_data, data->buffer_views);
1853
1854 for (cgltf_size i = 0; i < data->buffers_count; ++i)
1855 {
1856 data->memory.free_func(data->memory.user_data, data->buffers[i].name);
1857
1858 if (data->buffers[i].data_free_method == cgltf_data_free_method_file_release)
1859 {
1860 file_release(&data->memory, &data->file, data->buffers[i].data);
1861 }
1862 else if (data->buffers[i].data_free_method == cgltf_data_free_method_memory_free)
1863 {
1864 data->memory.free_func(data->memory.user_data, data->buffers[i].data);
1865 }
1866
1867 data->memory.free_func(data->memory.user_data, data->buffers[i].uri);
1868
1869 cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count);
1870 cgltf_free_extras(data, &data->buffers[i].extras);
1871 }
1872 data->memory.free_func(data->memory.user_data, data->buffers);
1873
1874 for (cgltf_size i = 0; i < data->meshes_count; ++i)
1875 {
1876 data->memory.free_func(data->memory.user_data, data->meshes[i].name);
1877
1878 for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
1879 {
1880 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
1881 {
1882 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes[k].name);
1883 }
1884
1885 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes);
1886
1887 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
1888 {
1889 for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
1890 {
1891 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name);
1892 }
1893
1894 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes);
1895 }
1896
1897 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets);
1898
1899 if (data->meshes[i].primitives[j].has_draco_mesh_compression)
1900 {
1901 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++k)
1902 {
1903 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes[k].name);
1904 }
1905
1906 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes);
1907 }
1908
1909 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
1910 {
1911 cgltf_free_extras(data, &data->meshes[i].primitives[j].mappings[k].extras);
1912 }
1913
1914 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].mappings);
1915
1916 cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count);
1917 cgltf_free_extras(data, &data->meshes[i].primitives[j].extras);
1918 }
1919
1920 data->memory.free_func(data->memory.user_data, data->meshes[i].primitives);
1921 data->memory.free_func(data->memory.user_data, data->meshes[i].weights);
1922
1923 for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j)
1924 {
1925 data->memory.free_func(data->memory.user_data, data->meshes[i].target_names[j]);
1926 }
1927
1928 cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count);
1929 cgltf_free_extras(data, &data->meshes[i].extras);
1930
1931 data->memory.free_func(data->memory.user_data, data->meshes[i].target_names);
1932 }
1933
1934 data->memory.free_func(data->memory.user_data, data->meshes);
1935
1936 for (cgltf_size i = 0; i < data->materials_count; ++i)
1937 {
1938 data->memory.free_func(data->memory.user_data, data->materials[i].name);
1939
1940 cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count);
1941 cgltf_free_extras(data, &data->materials[i].extras);
1942 }
1943
1944 data->memory.free_func(data->memory.user_data, data->materials);
1945
1946 for (cgltf_size i = 0; i < data->images_count; ++i)
1947 {
1948 data->memory.free_func(data->memory.user_data, data->images[i].name);
1949 data->memory.free_func(data->memory.user_data, data->images[i].uri);
1950 data->memory.free_func(data->memory.user_data, data->images[i].mime_type);
1951
1952 cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count);
1953 cgltf_free_extras(data, &data->images[i].extras);
1954 }
1955
1956 data->memory.free_func(data->memory.user_data, data->images);
1957
1958 for (cgltf_size i = 0; i < data->textures_count; ++i)
1959 {
1960 data->memory.free_func(data->memory.user_data, data->textures[i].name);
1961
1962 cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count);
1963 cgltf_free_extras(data, &data->textures[i].extras);
1964 }
1965
1966 data->memory.free_func(data->memory.user_data, data->textures);
1967
1968 for (cgltf_size i = 0; i < data->samplers_count; ++i)
1969 {
1970 data->memory.free_func(data->memory.user_data, data->samplers[i].name);
1971
1972 cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count);
1973 cgltf_free_extras(data, &data->samplers[i].extras);
1974 }
1975
1976 data->memory.free_func(data->memory.user_data, data->samplers);
1977
1978 for (cgltf_size i = 0; i < data->skins_count; ++i)
1979 {
1980 data->memory.free_func(data->memory.user_data, data->skins[i].name);
1981 data->memory.free_func(data->memory.user_data, data->skins[i].joints);
1982
1983 cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count);
1984 cgltf_free_extras(data, &data->skins[i].extras);
1985 }
1986
1987 data->memory.free_func(data->memory.user_data, data->skins);
1988
1989 for (cgltf_size i = 0; i < data->cameras_count; ++i)
1990 {
1991 data->memory.free_func(data->memory.user_data, data->cameras[i].name);
1992
1993 if (data->cameras[i].type == cgltf_camera_type_perspective)
1994 {
1995 cgltf_free_extras(data, &data->cameras[i].data.perspective.extras);
1996 }
1997 else if (data->cameras[i].type == cgltf_camera_type_orthographic)
1998 {
1999 cgltf_free_extras(data, &data->cameras[i].data.orthographic.extras);
2000 }
2001
2002 cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count);
2003 cgltf_free_extras(data, &data->cameras[i].extras);
2004 }
2005
2006 data->memory.free_func(data->memory.user_data, data->cameras);
2007
2008 for (cgltf_size i = 0; i < data->lights_count; ++i)
2009 {
2010 data->memory.free_func(data->memory.user_data, data->lights[i].name);
2011
2012 cgltf_free_extras(data, &data->lights[i].extras);
2013 }
2014
2015 data->memory.free_func(data->memory.user_data, data->lights);
2016
2017 for (cgltf_size i = 0; i < data->nodes_count; ++i)
2018 {
2019 data->memory.free_func(data->memory.user_data, data->nodes[i].name);
2020 data->memory.free_func(data->memory.user_data, data->nodes[i].children);
2021 data->memory.free_func(data->memory.user_data, data->nodes[i].weights);
2022
2023 if (data->nodes[i].has_mesh_gpu_instancing)
2024 {
2025 for (cgltf_size j = 0; j < data->nodes[i].mesh_gpu_instancing.attributes_count; ++j)
2026 {
2027 data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes[j].name);
2028 }
2029
2030 data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes);
2031 }
2032
2033 cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count);
2034 cgltf_free_extras(data, &data->nodes[i].extras);
2035 }
2036
2037 data->memory.free_func(data->memory.user_data, data->nodes);
2038
2039 for (cgltf_size i = 0; i < data->scenes_count; ++i)
2040 {
2041 data->memory.free_func(data->memory.user_data, data->scenes[i].name);
2042 data->memory.free_func(data->memory.user_data, data->scenes[i].nodes);
2043
2044 cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count);
2045 cgltf_free_extras(data, &data->scenes[i].extras);
2046 }
2047
2048 data->memory.free_func(data->memory.user_data, data->scenes);
2049
2050 for (cgltf_size i = 0; i < data->animations_count; ++i)
2051 {
2052 data->memory.free_func(data->memory.user_data, data->animations[i].name);
2053 for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
2054 {
2055 cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count);
2056 cgltf_free_extras(data, &data->animations[i].samplers[j].extras);
2057 }
2058 data->memory.free_func(data->memory.user_data, data->animations[i].samplers);
2059
2060 for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
2061 {
2062 cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count);
2063 cgltf_free_extras(data, &data->animations[i].channels[j].extras);
2064 }
2065 data->memory.free_func(data->memory.user_data, data->animations[i].channels);
2066
2067 cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count);
2068 cgltf_free_extras(data, &data->animations[i].extras);
2069 }
2070
2071 data->memory.free_func(data->memory.user_data, data->animations);
2072
2073 for (cgltf_size i = 0; i < data->variants_count; ++i)
2074 {
2075 data->memory.free_func(data->memory.user_data, data->variants[i].name);
2076
2077 cgltf_free_extras(data, &data->variants[i].extras);
2078 }
2079
2080 data->memory.free_func(data->memory.user_data, data->variants);
2081
2082 cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count);
2083 cgltf_free_extras(data, &data->extras);
2084
2085 for (cgltf_size i = 0; i < data->extensions_used_count; ++i)
2086 {
2087 data->memory.free_func(data->memory.user_data, data->extensions_used[i]);
2088 }
2089
2090 data->memory.free_func(data->memory.user_data, data->extensions_used);
2091
2092 for (cgltf_size i = 0; i < data->extensions_required_count; ++i)
2093 {
2094 data->memory.free_func(data->memory.user_data, data->extensions_required[i]);
2095 }
2096
2097 data->memory.free_func(data->memory.user_data, data->extensions_required);
2098
2099 file_release(&data->memory, &data->file, data->file_data);
2100
2101 data->memory.free_func(data->memory.user_data, data);
2102}
2103
2104void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix)
2105{
2106 cgltf_float* lm = out_matrix;
2107
2108 if (node->has_matrix)
2109 {
2110 memcpy(lm, node->matrix, sizeof(float) * 16);
2111 }
2112 else
2113 {
2114 float tx = node->translation[0];
2115 float ty = node->translation[1];
2116 float tz = node->translation[2];
2117
2118 float qx = node->rotation[0];
2119 float qy = node->rotation[1];
2120 float qz = node->rotation[2];
2121 float qw = node->rotation[3];
2122
2123 float sx = node->scale[0];
2124 float sy = node->scale[1];
2125 float sz = node->scale[2];
2126
2127 lm[0] = (1 - 2 * qy*qy - 2 * qz*qz) * sx;
2128 lm[1] = (2 * qx*qy + 2 * qz*qw) * sx;
2129 lm[2] = (2 * qx*qz - 2 * qy*qw) * sx;
2130 lm[3] = 0.f;
2131
2132 lm[4] = (2 * qx*qy - 2 * qz*qw) * sy;
2133 lm[5] = (1 - 2 * qx*qx - 2 * qz*qz) * sy;
2134 lm[6] = (2 * qy*qz + 2 * qx*qw) * sy;
2135 lm[7] = 0.f;
2136
2137 lm[8] = (2 * qx*qz + 2 * qy*qw) * sz;
2138 lm[9] = (2 * qy*qz - 2 * qx*qw) * sz;
2139 lm[10] = (1 - 2 * qx*qx - 2 * qy*qy) * sz;
2140 lm[11] = 0.f;
2141
2142 lm[12] = tx;
2143 lm[13] = ty;
2144 lm[14] = tz;
2145 lm[15] = 1.f;
2146 }
2147}
2148
2149void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)
2150{
2151 cgltf_float* lm = out_matrix;
2152 cgltf_node_transform_local(node, lm);
2153
2154 const cgltf_node* parent = node->parent;
2155
2156 while (parent)
2157 {
2158 float pm[16];
2159 cgltf_node_transform_local(parent, pm);
2160
2161 for (int i = 0; i < 4; ++i)
2162 {
2163 float l0 = lm[i * 4 + 0];
2164 float l1 = lm[i * 4 + 1];
2165 float l2 = lm[i * 4 + 2];
2166
2167 float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8];
2168 float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9];
2169 float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10];
2170
2171 lm[i * 4 + 0] = r0;
2172 lm[i * 4 + 1] = r1;
2173 lm[i * 4 + 2] = r2;
2174 }
2175
2176 lm[12] += pm[12];
2177 lm[13] += pm[13];
2178 lm[14] += pm[14];
2179
2180 parent = parent->parent;
2181 }
2182}
2183
2184static cgltf_ssize cgltf_component_read_integer(const void* in, cgltf_component_type component_type)
2185{
2186 switch (component_type)
2187 {
2188 case cgltf_component_type_r_16:
2189 return *((const int16_t*) in);
2190 case cgltf_component_type_r_16u:
2191 return *((const uint16_t*) in);
2192 case cgltf_component_type_r_32u:
2193 return *((const uint32_t*) in);
2194 case cgltf_component_type_r_8:
2195 return *((const int8_t*) in);
2196 case cgltf_component_type_r_8u:
2197 return *((const uint8_t*) in);
2198 default:
2199 return 0;
2200 }
2201}
2202
2203static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type)
2204{
2205 switch (component_type)
2206 {
2207 case cgltf_component_type_r_16u:
2208 return *((const uint16_t*) in);
2209 case cgltf_component_type_r_32u:
2210 return *((const uint32_t*) in);
2211 case cgltf_component_type_r_8u:
2212 return *((const uint8_t*) in);
2213 default:
2214 return 0;
2215 }
2216}
2217
2218static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized)
2219{
2220 if (component_type == cgltf_component_type_r_32f)
2221 {
2222 return *((const float*) in);
2223 }
2224
2225 if (normalized)
2226 {
2227 switch (component_type)
2228 {
2229 // note: glTF spec doesn't currently define normalized conversions for 32-bit integers
2230 case cgltf_component_type_r_16:
2231 return *((const int16_t*) in) / (cgltf_float)32767;
2232 case cgltf_component_type_r_16u:
2233 return *((const uint16_t*) in) / (cgltf_float)65535;
2234 case cgltf_component_type_r_8:
2235 return *((const int8_t*) in) / (cgltf_float)127;
2236 case cgltf_component_type_r_8u:
2237 return *((const uint8_t*) in) / (cgltf_float)255;
2238 default:
2239 return 0;
2240 }
2241 }
2242
2243 return (cgltf_float)cgltf_component_read_integer(in, component_type);
2244}
2245
2246static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size)
2247{
2248 cgltf_size num_components = cgltf_num_components(type);
2249
2250 if (element_size < num_components) {
2251 return 0;
2252 }
2253
2254 // There are three special cases for component extraction, see #data-alignment in the 2.0 spec.
2255
2256 cgltf_size component_size = cgltf_component_size(component_type);
2257
2258 if (type == cgltf_type_mat2 && component_size == 1)
2259 {
2260 out[0] = cgltf_component_read_float(element, component_type, normalized);
2261 out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
2262 out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
2263 out[3] = cgltf_component_read_float(element + 5, component_type, normalized);
2264 return 1;
2265 }
2266
2267 if (type == cgltf_type_mat3 && component_size == 1)
2268 {
2269 out[0] = cgltf_component_read_float(element, component_type, normalized);
2270 out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
2271 out[2] = cgltf_component_read_float(element + 2, component_type, normalized);
2272 out[3] = cgltf_component_read_float(element + 4, component_type, normalized);
2273 out[4] = cgltf_component_read_float(element + 5, component_type, normalized);
2274 out[5] = cgltf_component_read_float(element + 6, component_type, normalized);
2275 out[6] = cgltf_component_read_float(element + 8, component_type, normalized);
2276 out[7] = cgltf_component_read_float(element + 9, component_type, normalized);
2277 out[8] = cgltf_component_read_float(element + 10, component_type, normalized);
2278 return 1;
2279 }
2280
2281 if (type == cgltf_type_mat3 && component_size == 2)
2282 {
2283 out[0] = cgltf_component_read_float(element, component_type, normalized);
2284 out[1] = cgltf_component_read_float(element + 2, component_type, normalized);
2285 out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
2286 out[3] = cgltf_component_read_float(element + 8, component_type, normalized);
2287 out[4] = cgltf_component_read_float(element + 10, component_type, normalized);
2288 out[5] = cgltf_component_read_float(element + 12, component_type, normalized);
2289 out[6] = cgltf_component_read_float(element + 16, component_type, normalized);
2290 out[7] = cgltf_component_read_float(element + 18, component_type, normalized);
2291 out[8] = cgltf_component_read_float(element + 20, component_type, normalized);
2292 return 1;
2293 }
2294
2295 for (cgltf_size i = 0; i < num_components; ++i)
2296 {
2297 out[i] = cgltf_component_read_float(element + component_size * i, component_type, normalized);
2298 }
2299 return 1;
2300}
2301
2302const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view)
2303{
2304 if (view->data)
2305 return (const uint8_t*)view->data;
2306
2307 if (!view->buffer->data)
2308 return NULL;
2309
2310 const uint8_t* result = (const uint8_t*)view->buffer->data;
2311 result += view->offset;
2312 return result;
2313}
2314
2315cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size)
2316{
2317 if (accessor->is_sparse)
2318 {
2319 return 0;
2320 }
2321 if (accessor->buffer_view == NULL)
2322 {
2323 memset(out, 0, element_size * sizeof(cgltf_float));
2324 return 1;
2325 }
2326 const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
2327 if (element == NULL)
2328 {
2329 return 0;
2330 }
2331 element += accessor->offset + accessor->stride * index;
2332 return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size);
2333}
2334
2335cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count)
2336{
2337 cgltf_size floats_per_element = cgltf_num_components(accessor->type);
2338 cgltf_size available_floats = accessor->count * floats_per_element;
2339 if (out == NULL)
2340 {
2341 return available_floats;
2342 }
2343
2344 float_count = available_floats < float_count ? available_floats : float_count;
2345 cgltf_size element_count = float_count / floats_per_element;
2346
2347 // First pass: convert each element in the base accessor.
2348 if (accessor->buffer_view == NULL)
2349 {
2350 memset(out, 0, element_count * floats_per_element * sizeof(cgltf_float));
2351 }
2352 else
2353 {
2354 const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
2355 if (element == NULL)
2356 {
2357 return 0;
2358 }
2359 element += accessor->offset;
2360
2361 if (accessor->component_type == cgltf_component_type_r_32f && accessor->stride == floats_per_element * sizeof(cgltf_float))
2362 {
2363 memcpy(out, element, element_count * floats_per_element * sizeof(cgltf_float));
2364 }
2365 else
2366 {
2367 cgltf_float* dest = out;
2368
2369 for (cgltf_size index = 0; index < element_count; index++, dest += floats_per_element, element += accessor->stride)
2370 {
2371 if (!cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, dest, floats_per_element))
2372 {
2373 return 0;
2374 }
2375 }
2376 }
2377 }
2378
2379 // Second pass: write out each element in the sparse accessor.
2380 if (accessor->is_sparse)
2381 {
2382 const cgltf_accessor_sparse* sparse = &accessor->sparse;
2383
2384 const uint8_t* index_data = cgltf_buffer_view_data(sparse->indices_buffer_view);
2385 const uint8_t* reader_head = cgltf_buffer_view_data(sparse->values_buffer_view);
2386
2387 if (index_data == NULL || reader_head == NULL)
2388 {
2389 return 0;
2390 }
2391
2392 index_data += sparse->indices_byte_offset;
2393 reader_head += sparse->values_byte_offset;
2394
2395 cgltf_size index_stride = cgltf_component_size(sparse->indices_component_type);
2396 for (cgltf_size reader_index = 0; reader_index < sparse->count; reader_index++, index_data += index_stride, reader_head += accessor->stride)
2397 {
2398 size_t writer_index = cgltf_component_read_index(index_data, sparse->indices_component_type);
2399 float* writer_head = out + writer_index * floats_per_element;
2400
2401 if (!cgltf_element_read_float(reader_head, accessor->type, accessor->component_type, accessor->normalized, writer_head, floats_per_element))
2402 {
2403 return 0;
2404 }
2405 }
2406 }
2407
2408 return element_count * floats_per_element;
2409}
2410
2411static cgltf_uint cgltf_component_read_uint(const void* in, cgltf_component_type component_type)
2412{
2413 switch (component_type)
2414 {
2415 case cgltf_component_type_r_8:
2416 return *((const int8_t*) in);
2417
2418 case cgltf_component_type_r_8u:
2419 return *((const uint8_t*) in);
2420
2421 case cgltf_component_type_r_16:
2422 return *((const int16_t*) in);
2423
2424 case cgltf_component_type_r_16u:
2425 return *((const uint16_t*) in);
2426
2427 case cgltf_component_type_r_32u:
2428 return *((const uint32_t*) in);
2429
2430 default:
2431 return 0;
2432 }
2433}
2434
2435static cgltf_bool cgltf_element_read_uint(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_uint* out, cgltf_size element_size)
2436{
2437 cgltf_size num_components = cgltf_num_components(type);
2438
2439 if (element_size < num_components)
2440 {
2441 return 0;
2442 }
2443
2444 // Reading integer matrices is not a valid use case
2445 if (type == cgltf_type_mat2 || type == cgltf_type_mat3 || type == cgltf_type_mat4)
2446 {
2447 return 0;
2448 }
2449
2450 cgltf_size component_size = cgltf_component_size(component_type);
2451
2452 for (cgltf_size i = 0; i < num_components; ++i)
2453 {
2454 out[i] = cgltf_component_read_uint(element + component_size * i, component_type);
2455 }
2456 return 1;
2457}
2458
2459cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size)
2460{
2461 if (accessor->is_sparse)
2462 {
2463 return 0;
2464 }
2465 if (accessor->buffer_view == NULL)
2466 {
2467 memset(out, 0, element_size * sizeof( cgltf_uint ));
2468 return 1;
2469 }
2470 const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
2471 if (element == NULL)
2472 {
2473 return 0;
2474 }
2475 element += accessor->offset + accessor->stride * index;
2476 return cgltf_element_read_uint(element, accessor->type, accessor->component_type, out, element_size);
2477}
2478
2479cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index)
2480{
2481 if (accessor->is_sparse)
2482 {
2483 return 0; // This is an error case, but we can't communicate the error with existing interface.
2484 }
2485 if (accessor->buffer_view == NULL)
2486 {
2487 return 0;
2488 }
2489 const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
2490 if (element == NULL)
2491 {
2492 return 0; // This is an error case, but we can't communicate the error with existing interface.
2493 }
2494 element += accessor->offset + accessor->stride * index;
2495 return cgltf_component_read_index(element, accessor->component_type);
2496}
2497
2498cgltf_size cgltf_mesh_index(const cgltf_data* data, const cgltf_mesh* object)
2499{
2500 assert(object && (cgltf_size)(object - data->meshes) < data->meshes_count);
2501 return (cgltf_size)(object - data->meshes);
2502}
2503
2504cgltf_size cgltf_material_index(const cgltf_data* data, const cgltf_material* object)
2505{
2506 assert(object && (cgltf_size)(object - data->materials) < data->materials_count);
2507 return (cgltf_size)(object - data->materials);
2508}
2509
2510cgltf_size cgltf_accessor_index(const cgltf_data* data, const cgltf_accessor* object)
2511{
2512 assert(object && (cgltf_size)(object - data->accessors) < data->accessors_count);
2513 return (cgltf_size)(object - data->accessors);
2514}
2515
2516cgltf_size cgltf_buffer_view_index(const cgltf_data* data, const cgltf_buffer_view* object)
2517{
2518 assert(object && (cgltf_size)(object - data->buffer_views) < data->buffer_views_count);
2519 return (cgltf_size)(object - data->buffer_views);
2520}
2521
2522cgltf_size cgltf_buffer_index(const cgltf_data* data, const cgltf_buffer* object)
2523{
2524 assert(object && (cgltf_size)(object - data->buffers) < data->buffers_count);
2525 return (cgltf_size)(object - data->buffers);
2526}
2527
2528cgltf_size cgltf_image_index(const cgltf_data* data, const cgltf_image* object)
2529{
2530 assert(object && (cgltf_size)(object - data->images) < data->images_count);
2531 return (cgltf_size)(object - data->images);
2532}
2533
2534cgltf_size cgltf_texture_index(const cgltf_data* data, const cgltf_texture* object)
2535{
2536 assert(object && (cgltf_size)(object - data->textures) < data->textures_count);
2537 return (cgltf_size)(object - data->textures);
2538}
2539
2540cgltf_size cgltf_sampler_index(const cgltf_data* data, const cgltf_sampler* object)
2541{
2542 assert(object && (cgltf_size)(object - data->samplers) < data->samplers_count);
2543 return (cgltf_size)(object - data->samplers);
2544}
2545
2546cgltf_size cgltf_skin_index(const cgltf_data* data, const cgltf_skin* object)
2547{
2548 assert(object && (cgltf_size)(object - data->skins) < data->skins_count);
2549 return (cgltf_size)(object - data->skins);
2550}
2551
2552cgltf_size cgltf_camera_index(const cgltf_data* data, const cgltf_camera* object)
2553{
2554 assert(object && (cgltf_size)(object - data->cameras) < data->cameras_count);
2555 return (cgltf_size)(object - data->cameras);
2556}
2557
2558cgltf_size cgltf_light_index(const cgltf_data* data, const cgltf_light* object)
2559{
2560 assert(object && (cgltf_size)(object - data->lights) < data->lights_count);
2561 return (cgltf_size)(object - data->lights);
2562}
2563
2564cgltf_size cgltf_node_index(const cgltf_data* data, const cgltf_node* object)
2565{
2566 assert(object && (cgltf_size)(object - data->nodes) < data->nodes_count);
2567 return (cgltf_size)(object - data->nodes);
2568}
2569
2570cgltf_size cgltf_scene_index(const cgltf_data* data, const cgltf_scene* object)
2571{
2572 assert(object && (cgltf_size)(object - data->scenes) < data->scenes_count);
2573 return (cgltf_size)(object - data->scenes);
2574}
2575
2576cgltf_size cgltf_animation_index(const cgltf_data* data, const cgltf_animation* object)
2577{
2578 assert(object && (cgltf_size)(object - data->animations) < data->animations_count);
2579 return (cgltf_size)(object - data->animations);
2580}
2581
2582cgltf_size cgltf_animation_sampler_index(const cgltf_animation* animation, const cgltf_animation_sampler* object)
2583{
2584 assert(object && (cgltf_size)(object - animation->samplers) < animation->samplers_count);
2585 return (cgltf_size)(object - animation->samplers);
2586}
2587
2588cgltf_size cgltf_animation_channel_index(const cgltf_animation* animation, const cgltf_animation_channel* object)
2589{
2590 assert(object && (cgltf_size)(object - animation->channels) < animation->channels_count);
2591 return (cgltf_size)(object - animation->channels);
2592}
2593
2594cgltf_size cgltf_accessor_unpack_indices(const cgltf_accessor* accessor, void* out, cgltf_size out_component_size, cgltf_size index_count)
2595{
2596 if (out == NULL)
2597 {
2598 return accessor->count;
2599 }
2600
2601 index_count = accessor->count < index_count ? accessor->count : index_count;
2602 cgltf_size index_component_size = cgltf_component_size(accessor->component_type);
2603
2604 if (accessor->is_sparse)
2605 {
2606 return 0;
2607 }
2608 if (accessor->buffer_view == NULL)
2609 {
2610 return 0;
2611 }
2612 if (index_component_size > out_component_size)
2613 {
2614 return 0;
2615 }
2616 const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
2617 if (element == NULL)
2618 {
2619 return 0;
2620 }
2621 element += accessor->offset;
2622
2623 if (index_component_size == out_component_size && accessor->stride == out_component_size)
2624 {
2625 memcpy(out, element, index_count * index_component_size);
2626 return index_count;
2627 }
2628
2629 // The component size of the output array is larger than the component size of the index data, so index data will be padded.
2630 switch (out_component_size)
2631 {
2632 case 2:
2633 for (cgltf_size index = 0; index < index_count; index++, element += accessor->stride)
2634 {
2635 ((uint16_t*)out)[index] = (uint16_t)cgltf_component_read_index(element, accessor->component_type);
2636 }
2637 break;
2638 case 4:
2639 for (cgltf_size index = 0; index < index_count; index++, element += accessor->stride)
2640 {
2641 ((uint32_t*)out)[index] = (uint32_t)cgltf_component_read_index(element, accessor->component_type);
2642 }
2643 break;
2644 default:
2645 break;
2646 }
2647
2648 return index_count;
2649}
2650
2651#define CGLTF_ERROR_JSON -1
2652#define CGLTF_ERROR_NOMEM -2
2653#define CGLTF_ERROR_LEGACY -3
2654
2655#define CGLTF_CHECK_TOKTYPE(tok_, type_) if ((tok_).type != (type_)) { return CGLTF_ERROR_JSON; }
2656#define CGLTF_CHECK_TOKTYPE_RET(tok_, type_, ret_) if ((tok_).type != (type_)) { return ret_; }
2657#define CGLTF_CHECK_KEY(tok_) if ((tok_).type != JSMN_STRING || (tok_).size == 0) { return CGLTF_ERROR_JSON; } /* checking size for 0 verifies that a value follows the key */
2658
2659#define CGLTF_PTRINDEX(type, idx) (type*)((cgltf_size)idx + 1)
2660#define CGLTF_PTRFIXUP(var, data, size) if (var) { if ((cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; }
2661#define CGLTF_PTRFIXUP_REQ(var, data, size) if (!var || (cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1];
2662
2663static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, const char* str)
2664{
2665 CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING);
2666 size_t const str_len = strlen(str);
2667 size_t const name_length = (size_t)(tok->end - tok->start);
2668 return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128;
2669}
2670
2671static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk)
2672{
2673 CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
2674 char tmp[128];
2675 int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
2676 strncpy(tmp, (const char*)json_chunk + tok->start, size);
2677 tmp[size] = 0;
2678 return CGLTF_ATOI(tmp);
2679}
2680
2681static cgltf_size cgltf_json_to_size(jsmntok_t const* tok, const uint8_t* json_chunk)
2682{
2683 CGLTF_CHECK_TOKTYPE_RET(*tok, JSMN_PRIMITIVE, 0);
2684 char tmp[128];
2685 int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
2686 strncpy(tmp, (const char*)json_chunk + tok->start, size);
2687 tmp[size] = 0;
2688 long long res = CGLTF_ATOLL(tmp);
2689 return res < 0 ? 0 : (cgltf_size)res;
2690}
2691
2692static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json_chunk)
2693{
2694 CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
2695 char tmp[128];
2696 int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
2697 strncpy(tmp, (const char*)json_chunk + tok->start, size);
2698 tmp[size] = 0;
2699 return (cgltf_float)CGLTF_ATOF(tmp);
2700}
2701
2702static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk)
2703{
2704 int size = (int)(tok->end - tok->start);
2705 return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0;
2706}
2707
2708static int cgltf_skip_json(jsmntok_t const* tokens, int i)
2709{
2710 int end = i + 1;
2711
2712 while (i < end)
2713 {
2714 switch (tokens[i].type)
2715 {
2716 case JSMN_OBJECT:
2717 end += tokens[i].size * 2;
2718 break;
2719
2720 case JSMN_ARRAY:
2721 end += tokens[i].size;
2722 break;
2723
2724 case JSMN_PRIMITIVE:
2725 case JSMN_STRING:
2726 break;
2727
2728 default:
2729 return -1;
2730 }
2731
2732 i++;
2733 }
2734
2735 return i;
2736}
2737
2738static void cgltf_fill_float_array(float* out_array, int size, float value)
2739{
2740 for (int j = 0; j < size; ++j)
2741 {
2742 out_array[j] = value;
2743 }
2744}
2745
2746static int cgltf_parse_json_float_array(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, float* out_array, int size)
2747{
2748 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
2749 if (tokens[i].size != size)
2750 {
2751 return CGLTF_ERROR_JSON;
2752 }
2753 ++i;
2754 for (int j = 0; j < size; ++j)
2755 {
2756 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
2757 out_array[j] = cgltf_json_to_float(tokens + i, json_chunk);
2758 ++i;
2759 }
2760 return i;
2761}
2762
2763static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char** out_string)
2764{
2765 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
2766 if (*out_string)
2767 {
2768 return CGLTF_ERROR_JSON;
2769 }
2770 int size = (int)(tokens[i].end - tokens[i].start);
2771 char* result = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
2772 if (!result)
2773 {
2774 return CGLTF_ERROR_NOMEM;
2775 }
2776 strncpy(result, (const char*)json_chunk + tokens[i].start, size);
2777 result[size] = 0;
2778 *out_string = result;
2779 return i + 1;
2780}
2781
2782static int cgltf_parse_json_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, size_t element_size, void** out_array, cgltf_size* out_size)
2783{
2784 (void)json_chunk;
2785 if (tokens[i].type != JSMN_ARRAY)
2786 {
2787 return tokens[i].type == JSMN_OBJECT ? CGLTF_ERROR_LEGACY : CGLTF_ERROR_JSON;
2788 }
2789 if (*out_array)
2790 {
2791 return CGLTF_ERROR_JSON;
2792 }
2793 int size = tokens[i].size;
2794 void* result = cgltf_calloc(options, element_size, size);
2795 if (!result)
2796 {
2797 return CGLTF_ERROR_NOMEM;
2798 }
2799 *out_array = result;
2800 *out_size = size;
2801 return i + 1;
2802}
2803
2804static int cgltf_parse_json_string_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char*** out_array, cgltf_size* out_size)
2805{
2806 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
2807 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(char*), (void**)out_array, out_size);
2808 if (i < 0)
2809 {
2810 return i;
2811 }
2812
2813 for (cgltf_size j = 0; j < *out_size; ++j)
2814 {
2815 i = cgltf_parse_json_string(options, tokens, i, json_chunk, j + (*out_array));
2816 if (i < 0)
2817 {
2818 return i;
2819 }
2820 }
2821 return i;
2822}
2823
2824static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index)
2825{
2826 if (*name == '_')
2827 {
2828 *out_type = cgltf_attribute_type_custom;
2829 return;
2830 }
2831
2832 const char* us = strchr(name, '_');
2833 size_t len = us ? (size_t)(us - name) : strlen(name);
2834
2835 if (len == 8 && strncmp(name, "POSITION", 8) == 0)
2836 {
2837 *out_type = cgltf_attribute_type_position;
2838 }
2839 else if (len == 6 && strncmp(name, "NORMAL", 6) == 0)
2840 {
2841 *out_type = cgltf_attribute_type_normal;
2842 }
2843 else if (len == 7 && strncmp(name, "TANGENT", 7) == 0)
2844 {
2845 *out_type = cgltf_attribute_type_tangent;
2846 }
2847 else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0)
2848 {
2849 *out_type = cgltf_attribute_type_texcoord;
2850 }
2851 else if (len == 5 && strncmp(name, "COLOR", 5) == 0)
2852 {
2853 *out_type = cgltf_attribute_type_color;
2854 }
2855 else if (len == 6 && strncmp(name, "JOINTS", 6) == 0)
2856 {
2857 *out_type = cgltf_attribute_type_joints;
2858 }
2859 else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0)
2860 {
2861 *out_type = cgltf_attribute_type_weights;
2862 }
2863 else
2864 {
2865 *out_type = cgltf_attribute_type_invalid;
2866 }
2867
2868 if (us && *out_type != cgltf_attribute_type_invalid)
2869 {
2870 *out_index = CGLTF_ATOI(us + 1);
2871 if (*out_index < 0)
2872 {
2873 *out_type = cgltf_attribute_type_invalid;
2874 *out_index = 0;
2875 }
2876 }
2877}
2878
2879static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_attribute** out_attributes, cgltf_size* out_attributes_count)
2880{
2881 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
2882
2883 if (*out_attributes)
2884 {
2885 return CGLTF_ERROR_JSON;
2886 }
2887
2888 *out_attributes_count = tokens[i].size;
2889 *out_attributes = (cgltf_attribute*)cgltf_calloc(options, sizeof(cgltf_attribute), *out_attributes_count);
2890 ++i;
2891
2892 if (!*out_attributes)
2893 {
2894 return CGLTF_ERROR_NOMEM;
2895 }
2896
2897 for (cgltf_size j = 0; j < *out_attributes_count; ++j)
2898 {
2899 CGLTF_CHECK_KEY(tokens[i]);
2900
2901 i = cgltf_parse_json_string(options, tokens, i, json_chunk, &(*out_attributes)[j].name);
2902 if (i < 0)
2903 {
2904 return CGLTF_ERROR_JSON;
2905 }
2906
2907 cgltf_parse_attribute_type((*out_attributes)[j].name, &(*out_attributes)[j].type, &(*out_attributes)[j].index);
2908
2909 (*out_attributes)[j].data = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
2910 ++i;
2911 }
2912
2913 return i;
2914}
2915
2916static int cgltf_parse_json_extras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
2917{
2918 if (out_extras->data)
2919 {
2920 return CGLTF_ERROR_JSON;
2921 }
2922
2923 /* fill deprecated fields for now, this will be removed in the future */
2924 out_extras->start_offset = tokens[i].start;
2925 out_extras->end_offset = tokens[i].end;
2926
2927 size_t start = tokens[i].start;
2928 size_t size = tokens[i].end - start;
2929 out_extras->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
2930 if (!out_extras->data)
2931 {
2932 return CGLTF_ERROR_NOMEM;
2933 }
2934 strncpy(out_extras->data, (const char*)json_chunk + start, size);
2935 out_extras->data[size] = '\0';
2936
2937 i = cgltf_skip_json(tokens, i);
2938 return i;
2939}
2940
2941static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extension* out_extension)
2942{
2943 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
2944 CGLTF_CHECK_TOKTYPE(tokens[i+1], JSMN_OBJECT);
2945 if (out_extension->name)
2946 {
2947 return CGLTF_ERROR_JSON;
2948 }
2949
2950 cgltf_size name_length = tokens[i].end - tokens[i].start;
2951 out_extension->name = (char*)options->memory.alloc_func(options->memory.user_data, name_length + 1);
2952 if (!out_extension->name)
2953 {
2954 return CGLTF_ERROR_NOMEM;
2955 }
2956 strncpy(out_extension->name, (const char*)json_chunk + tokens[i].start, name_length);
2957 out_extension->name[name_length] = 0;
2958 i++;
2959
2960 size_t start = tokens[i].start;
2961 size_t size = tokens[i].end - start;
2962 out_extension->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
2963 if (!out_extension->data)
2964 {
2965 return CGLTF_ERROR_NOMEM;
2966 }
2967 strncpy(out_extension->data, (const char*)json_chunk + start, size);
2968 out_extension->data[size] = '\0';
2969
2970 i = cgltf_skip_json(tokens, i);
2971
2972 return i;
2973}
2974
2975static int cgltf_parse_json_unprocessed_extensions(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_size* out_extensions_count, cgltf_extension** out_extensions)
2976{
2977 ++i;
2978
2979 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
2980 if(*out_extensions)
2981 {
2982 return CGLTF_ERROR_JSON;
2983 }
2984
2985 int extensions_size = tokens[i].size;
2986 *out_extensions_count = 0;
2987 *out_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
2988
2989 if (!*out_extensions)
2990 {
2991 return CGLTF_ERROR_NOMEM;
2992 }
2993
2994 ++i;
2995
2996 for (int j = 0; j < extensions_size; ++j)
2997 {
2998 CGLTF_CHECK_KEY(tokens[i]);
2999
3000 cgltf_size extension_index = (*out_extensions_count)++;
3001 cgltf_extension* extension = &((*out_extensions)[extension_index]);
3002 i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, extension);
3003
3004 if (i < 0)
3005 {
3006 return i;
3007 }
3008 }
3009 return i;
3010}
3011
3012static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_draco_mesh_compression* out_draco_mesh_compression)
3013{
3014 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3015
3016 int size = tokens[i].size;
3017 ++i;
3018
3019 for (int j = 0; j < size; ++j)
3020 {
3021 CGLTF_CHECK_KEY(tokens[i]);
3022
3023 if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0)
3024 {
3025 i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_draco_mesh_compression->attributes, &out_draco_mesh_compression->attributes_count);
3026 }
3027 else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0)
3028 {
3029 ++i;
3030 out_draco_mesh_compression->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
3031 ++i;
3032 }
3033 else
3034 {
3035 i = cgltf_skip_json(tokens, i+1);
3036 }
3037
3038 if (i < 0)
3039 {
3040 return i;
3041 }
3042 }
3043
3044 return i;
3045}
3046
3047static int cgltf_parse_json_mesh_gpu_instancing(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh_gpu_instancing* out_mesh_gpu_instancing)
3048{
3049 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3050
3051 int size = tokens[i].size;
3052 ++i;
3053
3054 for (int j = 0; j < size; ++j)
3055 {
3056 CGLTF_CHECK_KEY(tokens[i]);
3057
3058 if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0)
3059 {
3060 i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_mesh_gpu_instancing->attributes, &out_mesh_gpu_instancing->attributes_count);
3061 }
3062 else
3063 {
3064 i = cgltf_skip_json(tokens, i+1);
3065 }
3066
3067 if (i < 0)
3068 {
3069 return i;
3070 }
3071 }
3072
3073 return i;
3074}
3075
3076static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_mapping* out_mappings, cgltf_size* offset)
3077{
3078 (void)options;
3079 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
3080
3081 int size = tokens[i].size;
3082 ++i;
3083
3084 for (int j = 0; j < size; ++j)
3085 {
3086 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3087
3088 int obj_size = tokens[i].size;
3089 ++i;
3090
3091 int material = -1;
3092 int variants_tok = -1;
3093 int extras_tok = -1;
3094
3095 for (int k = 0; k < obj_size; ++k)
3096 {
3097 CGLTF_CHECK_KEY(tokens[i]);
3098
3099 if (cgltf_json_strcmp(tokens + i, json_chunk, "material") == 0)
3100 {
3101 ++i;
3102 material = cgltf_json_to_int(tokens + i, json_chunk);
3103 ++i;
3104 }
3105 else if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
3106 {
3107 variants_tok = i+1;
3108 CGLTF_CHECK_TOKTYPE(tokens[variants_tok], JSMN_ARRAY);
3109
3110 i = cgltf_skip_json(tokens, i+1);
3111 }
3112 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
3113 {
3114 extras_tok = i + 1;
3115 i = cgltf_skip_json(tokens, extras_tok);
3116 }
3117 else
3118 {
3119 i = cgltf_skip_json(tokens, i+1);
3120 }
3121
3122 if (i < 0)
3123 {
3124 return i;
3125 }
3126 }
3127
3128 if (material < 0 || variants_tok < 0)
3129 {
3130 return CGLTF_ERROR_JSON;
3131 }
3132
3133 if (out_mappings)
3134 {
3135 for (int k = 0; k < tokens[variants_tok].size; ++k)
3136 {
3137 int variant = cgltf_json_to_int(&tokens[variants_tok + 1 + k], json_chunk);
3138 if (variant < 0)
3139 return variant;
3140
3141 out_mappings[*offset].material = CGLTF_PTRINDEX(cgltf_material, material);
3142 out_mappings[*offset].variant = variant;
3143
3144 if (extras_tok >= 0)
3145 {
3146 int e = cgltf_parse_json_extras(options, tokens, extras_tok, json_chunk, &out_mappings[*offset].extras);
3147 if (e < 0)
3148 return e;
3149 }
3150
3151 (*offset)++;
3152 }
3153 }
3154 else
3155 {
3156 (*offset) += tokens[variants_tok].size;
3157 }
3158 }
3159
3160 return i;
3161}
3162
3163static int cgltf_parse_json_material_mappings(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
3164{
3165 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3166
3167 int size = tokens[i].size;
3168 ++i;
3169
3170 for (int j = 0; j < size; ++j)
3171 {
3172 CGLTF_CHECK_KEY(tokens[i]);
3173
3174 if (cgltf_json_strcmp(tokens + i, json_chunk, "mappings") == 0)
3175 {
3176 if (out_prim->mappings)
3177 {
3178 return CGLTF_ERROR_JSON;
3179 }
3180
3181 cgltf_size mappings_offset = 0;
3182 int k = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, NULL, &mappings_offset);
3183 if (k < 0)
3184 {
3185 return k;
3186 }
3187
3188 out_prim->mappings_count = mappings_offset;
3189 out_prim->mappings = (cgltf_material_mapping*)cgltf_calloc(options, sizeof(cgltf_material_mapping), out_prim->mappings_count);
3190
3191 mappings_offset = 0;
3192 i = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, out_prim->mappings, &mappings_offset);
3193 }
3194 else
3195 {
3196 i = cgltf_skip_json(tokens, i+1);
3197 }
3198
3199 if (i < 0)
3200 {
3201 return i;
3202 }
3203 }
3204
3205 return i;
3206}
3207
3208static cgltf_primitive_type cgltf_json_to_primitive_type(jsmntok_t const* tok, const uint8_t* json_chunk)
3209{
3210 int type = cgltf_json_to_int(tok, json_chunk);
3211
3212 switch (type)
3213 {
3214 case 0:
3215 return cgltf_primitive_type_points;
3216 case 1:
3217 return cgltf_primitive_type_lines;
3218 case 2:
3219 return cgltf_primitive_type_line_loop;
3220 case 3:
3221 return cgltf_primitive_type_line_strip;
3222 case 4:
3223 return cgltf_primitive_type_triangles;
3224 case 5:
3225 return cgltf_primitive_type_triangle_strip;
3226 case 6:
3227 return cgltf_primitive_type_triangle_fan;
3228 default:
3229 return cgltf_primitive_type_invalid;
3230 }
3231}
3232
3233static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
3234{
3235 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3236
3237 out_prim->type = cgltf_primitive_type_triangles;
3238
3239 int size = tokens[i].size;
3240 ++i;
3241
3242 for (int j = 0; j < size; ++j)
3243 {
3244 CGLTF_CHECK_KEY(tokens[i]);
3245
3246 if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
3247 {
3248 ++i;
3249 out_prim->type = cgltf_json_to_primitive_type(tokens+i, json_chunk);
3250 ++i;
3251 }
3252 else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
3253 {
3254 ++i;
3255 out_prim->indices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
3256 ++i;
3257 }
3258 else if (cgltf_json_strcmp(tokens+i, json_chunk, "material") == 0)
3259 {
3260 ++i;
3261 out_prim->material = CGLTF_PTRINDEX(cgltf_material, cgltf_json_to_int(tokens + i, json_chunk));
3262 ++i;
3263 }
3264 else if (cgltf_json_strcmp(tokens+i, json_chunk, "attributes") == 0)
3265 {
3266 i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_prim->attributes, &out_prim->attributes_count);
3267 }
3268 else if (cgltf_json_strcmp(tokens+i, json_chunk, "targets") == 0)
3269 {
3270 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), (void**)&out_prim->targets, &out_prim->targets_count);
3271 if (i < 0)
3272 {
3273 return i;
3274 }
3275
3276 for (cgltf_size k = 0; k < out_prim->targets_count; ++k)
3277 {
3278 i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim->targets[k].attributes, &out_prim->targets[k].attributes_count);
3279 if (i < 0)
3280 {
3281 return i;
3282 }
3283 }
3284 }
3285 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
3286 {
3287 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_prim->extras);
3288 }
3289 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
3290 {
3291 ++i;
3292
3293 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3294 if(out_prim->extensions)
3295 {
3296 return CGLTF_ERROR_JSON;
3297 }
3298
3299 int extensions_size = tokens[i].size;
3300 out_prim->extensions_count = 0;
3301 out_prim->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
3302
3303 if (!out_prim->extensions)
3304 {
3305 return CGLTF_ERROR_NOMEM;
3306 }
3307
3308 ++i;
3309 for (int k = 0; k < extensions_size; ++k)
3310 {
3311 CGLTF_CHECK_KEY(tokens[i]);
3312
3313 if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_draco_mesh_compression") == 0)
3314 {
3315 out_prim->has_draco_mesh_compression = 1;
3316 i = cgltf_parse_json_draco_mesh_compression(options, tokens, i + 1, json_chunk, &out_prim->draco_mesh_compression);
3317 }
3318 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
3319 {
3320 i = cgltf_parse_json_material_mappings(options, tokens, i + 1, json_chunk, out_prim);
3321 }
3322 else
3323 {
3324 i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_prim->extensions[out_prim->extensions_count++]));
3325 }
3326
3327 if (i < 0)
3328 {
3329 return i;
3330 }
3331 }
3332 }
3333 else
3334 {
3335 i = cgltf_skip_json(tokens, i+1);
3336 }
3337
3338 if (i < 0)
3339 {
3340 return i;
3341 }
3342 }
3343
3344 return i;
3345}
3346
3347static int cgltf_parse_json_mesh(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh* out_mesh)
3348{
3349 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3350
3351 int size = tokens[i].size;
3352 ++i;
3353
3354 for (int j = 0; j < size; ++j)
3355 {
3356 CGLTF_CHECK_KEY(tokens[i]);
3357
3358 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
3359 {
3360 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_mesh->name);
3361 }
3362 else if (cgltf_json_strcmp(tokens+i, json_chunk, "primitives") == 0)
3363 {
3364 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), (void**)&out_mesh->primitives, &out_mesh->primitives_count);
3365 if (i < 0)
3366 {
3367 return i;
3368 }
3369
3370 for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; ++prim_index)
3371 {
3372 i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh->primitives[prim_index]);
3373 if (i < 0)
3374 {
3375 return i;
3376 }
3377 }
3378 }
3379 else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
3380 {
3381 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_mesh->weights, &out_mesh->weights_count);
3382 if (i < 0)
3383 {
3384 return i;
3385 }
3386
3387 i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_mesh->weights, (int)out_mesh->weights_count);
3388 }
3389 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
3390 {
3391 ++i;
3392
3393 out_mesh->extras.start_offset = tokens[i].start;
3394 out_mesh->extras.end_offset = tokens[i].end;
3395
3396 if (tokens[i].type == JSMN_OBJECT)
3397 {
3398 int extras_size = tokens[i].size;
3399 ++i;
3400
3401 for (int k = 0; k < extras_size; ++k)
3402 {
3403 CGLTF_CHECK_KEY(tokens[i]);
3404
3405 if (cgltf_json_strcmp(tokens+i, json_chunk, "targetNames") == 0 && tokens[i+1].type == JSMN_ARRAY)
3406 {
3407 i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_mesh->target_names, &out_mesh->target_names_count);
3408 }
3409 else
3410 {
3411 i = cgltf_skip_json(tokens, i+1);
3412 }
3413
3414 if (i < 0)
3415 {
3416 return i;
3417 }
3418 }
3419 }
3420 else
3421 {
3422 i = cgltf_skip_json(tokens, i);
3423 }
3424 }
3425 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
3426 {
3427 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_mesh->extensions_count, &out_mesh->extensions);
3428 }
3429 else
3430 {
3431 i = cgltf_skip_json(tokens, i+1);
3432 }
3433
3434 if (i < 0)
3435 {
3436 return i;
3437 }
3438 }
3439
3440 return i;
3441}
3442
3443static int cgltf_parse_json_meshes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
3444{
3445 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), (void**)&out_data->meshes, &out_data->meshes_count);
3446 if (i < 0)
3447 {
3448 return i;
3449 }
3450
3451 for (cgltf_size j = 0; j < out_data->meshes_count; ++j)
3452 {
3453 i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data->meshes[j]);
3454 if (i < 0)
3455 {
3456 return i;
3457 }
3458 }
3459 return i;
3460}
3461
3462static cgltf_component_type cgltf_json_to_component_type(jsmntok_t const* tok, const uint8_t* json_chunk)
3463{
3464 int type = cgltf_json_to_int(tok, json_chunk);
3465
3466 switch (type)
3467 {
3468 case 5120:
3469 return cgltf_component_type_r_8;
3470 case 5121:
3471 return cgltf_component_type_r_8u;
3472 case 5122:
3473 return cgltf_component_type_r_16;
3474 case 5123:
3475 return cgltf_component_type_r_16u;
3476 case 5125:
3477 return cgltf_component_type_r_32u;
3478 case 5126:
3479 return cgltf_component_type_r_32f;
3480 default:
3481 return cgltf_component_type_invalid;
3482 }
3483}
3484
3485static int cgltf_parse_json_accessor_sparse(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor_sparse* out_sparse)
3486{
3487 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3488
3489 int size = tokens[i].size;
3490 ++i;
3491
3492 for (int j = 0; j < size; ++j)
3493 {
3494 CGLTF_CHECK_KEY(tokens[i]);
3495
3496 if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
3497 {
3498 ++i;
3499 out_sparse->count = cgltf_json_to_size(tokens + i, json_chunk);
3500 ++i;
3501 }
3502 else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
3503 {
3504 ++i;
3505 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3506
3507 int indices_size = tokens[i].size;
3508 ++i;
3509
3510 for (int k = 0; k < indices_size; ++k)
3511 {
3512 CGLTF_CHECK_KEY(tokens[i]);
3513
3514 if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
3515 {
3516 ++i;
3517 out_sparse->indices_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
3518 ++i;
3519 }
3520 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
3521 {
3522 ++i;
3523 out_sparse->indices_byte_offset = cgltf_json_to_size(tokens + i, json_chunk);
3524 ++i;
3525 }
3526 else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
3527 {
3528 ++i;
3529 out_sparse->indices_component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
3530 ++i;
3531 }
3532 else
3533 {
3534 i = cgltf_skip_json(tokens, i+1);
3535 }
3536
3537 if (i < 0)
3538 {
3539 return i;
3540 }
3541 }
3542 }
3543 else if (cgltf_json_strcmp(tokens+i, json_chunk, "values") == 0)
3544 {
3545 ++i;
3546 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3547
3548 int values_size = tokens[i].size;
3549 ++i;
3550
3551 for (int k = 0; k < values_size; ++k)
3552 {
3553 CGLTF_CHECK_KEY(tokens[i]);
3554
3555 if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
3556 {
3557 ++i;
3558 out_sparse->values_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
3559 ++i;
3560 }
3561 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
3562 {
3563 ++i;
3564 out_sparse->values_byte_offset = cgltf_json_to_size(tokens + i, json_chunk);
3565 ++i;
3566 }
3567 else
3568 {
3569 i = cgltf_skip_json(tokens, i+1);
3570 }
3571
3572 if (i < 0)
3573 {
3574 return i;
3575 }
3576 }
3577 }
3578 else
3579 {
3580 i = cgltf_skip_json(tokens, i+1);
3581 }
3582
3583 if (i < 0)
3584 {
3585 return i;
3586 }
3587 }
3588
3589 return i;
3590}
3591
3592static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor* out_accessor)
3593{
3594 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3595
3596 int size = tokens[i].size;
3597 ++i;
3598
3599 for (int j = 0; j < size; ++j)
3600 {
3601 CGLTF_CHECK_KEY(tokens[i]);
3602
3603 if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
3604 {
3605 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_accessor->name);
3606 }
3607 else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
3608 {
3609 ++i;
3610 out_accessor->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
3611 ++i;
3612 }
3613 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
3614 {
3615 ++i;
3616 out_accessor->offset =
3617 cgltf_json_to_size(tokens+i, json_chunk);
3618 ++i;
3619 }
3620 else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
3621 {
3622 ++i;
3623 out_accessor->component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
3624 ++i;
3625 }
3626 else if (cgltf_json_strcmp(tokens+i, json_chunk, "normalized") == 0)
3627 {
3628 ++i;
3629 out_accessor->normalized = cgltf_json_to_bool(tokens+i, json_chunk);
3630 ++i;
3631 }
3632 else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
3633 {
3634 ++i;
3635 out_accessor->count = cgltf_json_to_size(tokens+i, json_chunk);
3636 ++i;
3637 }
3638 else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
3639 {
3640 ++i;
3641 if (cgltf_json_strcmp(tokens+i, json_chunk, "SCALAR") == 0)
3642 {
3643 out_accessor->type = cgltf_type_scalar;
3644 }
3645 else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC2") == 0)
3646 {
3647 out_accessor->type = cgltf_type_vec2;
3648 }
3649 else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC3") == 0)
3650 {
3651 out_accessor->type = cgltf_type_vec3;
3652 }
3653 else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC4") == 0)
3654 {
3655 out_accessor->type = cgltf_type_vec4;
3656 }
3657 else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT2") == 0)
3658 {
3659 out_accessor->type = cgltf_type_mat2;
3660 }
3661 else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT3") == 0)
3662 {
3663 out_accessor->type = cgltf_type_mat3;
3664 }
3665 else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT4") == 0)
3666 {
3667 out_accessor->type = cgltf_type_mat4;
3668 }
3669 ++i;
3670 }
3671 else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0)
3672 {
3673 ++i;
3674 out_accessor->has_min = 1;
3675 // note: we can't parse the precise number of elements since type may not have been computed yet
3676 int min_size = tokens[i].size > 16 ? 16 : tokens[i].size;
3677 i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, min_size);
3678 }
3679 else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0)
3680 {
3681 ++i;
3682 out_accessor->has_max = 1;
3683 // note: we can't parse the precise number of elements since type may not have been computed yet
3684 int max_size = tokens[i].size > 16 ? 16 : tokens[i].size;
3685 i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, max_size);
3686 }
3687 else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0)
3688 {
3689 out_accessor->is_sparse = 1;
3690 i = cgltf_parse_json_accessor_sparse(tokens, i + 1, json_chunk, &out_accessor->sparse);
3691 }
3692 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
3693 {
3694 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_accessor->extras);
3695 }
3696 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
3697 {
3698 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_accessor->extensions_count, &out_accessor->extensions);
3699 }
3700 else
3701 {
3702 i = cgltf_skip_json(tokens, i+1);
3703 }
3704
3705 if (i < 0)
3706 {
3707 return i;
3708 }
3709 }
3710
3711 return i;
3712}
3713
3714static int cgltf_parse_json_texture_transform(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_transform* out_texture_transform)
3715{
3716 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3717
3718 int size = tokens[i].size;
3719 ++i;
3720
3721 for (int j = 0; j < size; ++j)
3722 {
3723 CGLTF_CHECK_KEY(tokens[i]);
3724
3725 if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0)
3726 {
3727 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->offset, 2);
3728 }
3729 else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0)
3730 {
3731 ++i;
3732 out_texture_transform->rotation = cgltf_json_to_float(tokens + i, json_chunk);
3733 ++i;
3734 }
3735 else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0)
3736 {
3737 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->scale, 2);
3738 }
3739 else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
3740 {
3741 ++i;
3742 out_texture_transform->has_texcoord = 1;
3743 out_texture_transform->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
3744 ++i;
3745 }
3746 else
3747 {
3748 i = cgltf_skip_json(tokens, i + 1);
3749 }
3750
3751 if (i < 0)
3752 {
3753 return i;
3754 }
3755 }
3756
3757 return i;
3758}
3759
3760static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_view* out_texture_view)
3761{
3762 (void)options;
3763
3764 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3765
3766 out_texture_view->scale = 1.0f;
3767 cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f);
3768
3769 int size = tokens[i].size;
3770 ++i;
3771
3772 for (int j = 0; j < size; ++j)
3773 {
3774 CGLTF_CHECK_KEY(tokens[i]);
3775
3776 if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0)
3777 {
3778 ++i;
3779 out_texture_view->texture = CGLTF_PTRINDEX(cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk));
3780 ++i;
3781 }
3782 else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
3783 {
3784 ++i;
3785 out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
3786 ++i;
3787 }
3788 else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0)
3789 {
3790 ++i;
3791 out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
3792 ++i;
3793 }
3794 else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0)
3795 {
3796 ++i;
3797 out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
3798 ++i;
3799 }
3800 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
3801 {
3802 ++i;
3803
3804 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3805 int extensions_size = tokens[i].size;
3806
3807 ++i;
3808
3809 for (int k = 0; k < extensions_size; ++k)
3810 {
3811 CGLTF_CHECK_KEY(tokens[i]);
3812
3813 if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_texture_transform") == 0)
3814 {
3815 out_texture_view->has_transform = 1;
3816 i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, &out_texture_view->transform);
3817 }
3818 else
3819 {
3820 i = cgltf_skip_json(tokens, i + 1);
3821 }
3822
3823 if (i < 0)
3824 {
3825 return i;
3826 }
3827 }
3828 }
3829 else
3830 {
3831 i = cgltf_skip_json(tokens, i + 1);
3832 }
3833
3834 if (i < 0)
3835 {
3836 return i;
3837 }
3838 }
3839
3840 return i;
3841}
3842
3843static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_metallic_roughness* out_pbr)
3844{
3845 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3846
3847 int size = tokens[i].size;
3848 ++i;
3849
3850 for (int j = 0; j < size; ++j)
3851 {
3852 CGLTF_CHECK_KEY(tokens[i]);
3853
3854 if (cgltf_json_strcmp(tokens+i, json_chunk, "metallicFactor") == 0)
3855 {
3856 ++i;
3857 out_pbr->metallic_factor =
3858 cgltf_json_to_float(tokens + i, json_chunk);
3859 ++i;
3860 }
3861 else if (cgltf_json_strcmp(tokens+i, json_chunk, "roughnessFactor") == 0)
3862 {
3863 ++i;
3864 out_pbr->roughness_factor =
3865 cgltf_json_to_float(tokens+i, json_chunk);
3866 ++i;
3867 }
3868 else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorFactor") == 0)
3869 {
3870 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->base_color_factor, 4);
3871 }
3872 else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorTexture") == 0)
3873 {
3874 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->base_color_texture);
3875 }
3876 else if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicRoughnessTexture") == 0)
3877 {
3878 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->metallic_roughness_texture);
3879 }
3880 else
3881 {
3882 i = cgltf_skip_json(tokens, i+1);
3883 }
3884
3885 if (i < 0)
3886 {
3887 return i;
3888 }
3889 }
3890
3891 return i;
3892}
3893
3894static int cgltf_parse_json_pbr_specular_glossiness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_specular_glossiness* out_pbr)
3895{
3896 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3897 int size = tokens[i].size;
3898 ++i;
3899
3900 for (int j = 0; j < size; ++j)
3901 {
3902 CGLTF_CHECK_KEY(tokens[i]);
3903
3904 if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseFactor") == 0)
3905 {
3906 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->diffuse_factor, 4);
3907 }
3908 else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
3909 {
3910 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->specular_factor, 3);
3911 }
3912 else if (cgltf_json_strcmp(tokens+i, json_chunk, "glossinessFactor") == 0)
3913 {
3914 ++i;
3915 out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk);
3916 ++i;
3917 }
3918 else if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseTexture") == 0)
3919 {
3920 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->diffuse_texture);
3921 }
3922 else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularGlossinessTexture") == 0)
3923 {
3924 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->specular_glossiness_texture);
3925 }
3926 else
3927 {
3928 i = cgltf_skip_json(tokens, i+1);
3929 }
3930
3931 if (i < 0)
3932 {
3933 return i;
3934 }
3935 }
3936
3937 return i;
3938}
3939
3940static int cgltf_parse_json_clearcoat(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_clearcoat* out_clearcoat)
3941{
3942 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3943 int size = tokens[i].size;
3944 ++i;
3945
3946 for (int j = 0; j < size; ++j)
3947 {
3948 CGLTF_CHECK_KEY(tokens[i]);
3949
3950 if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatFactor") == 0)
3951 {
3952 ++i;
3953 out_clearcoat->clearcoat_factor = cgltf_json_to_float(tokens + i, json_chunk);
3954 ++i;
3955 }
3956 else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessFactor") == 0)
3957 {
3958 ++i;
3959 out_clearcoat->clearcoat_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
3960 ++i;
3961 }
3962 else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatTexture") == 0)
3963 {
3964 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_texture);
3965 }
3966 else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessTexture") == 0)
3967 {
3968 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_roughness_texture);
3969 }
3970 else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatNormalTexture") == 0)
3971 {
3972 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_normal_texture);
3973 }
3974 else
3975 {
3976 i = cgltf_skip_json(tokens, i+1);
3977 }
3978
3979 if (i < 0)
3980 {
3981 return i;
3982 }
3983 }
3984
3985 return i;
3986}
3987
3988static int cgltf_parse_json_ior(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_ior* out_ior)
3989{
3990 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
3991 int size = tokens[i].size;
3992 ++i;
3993
3994 // Default values
3995 out_ior->ior = 1.5f;
3996
3997 for (int j = 0; j < size; ++j)
3998 {
3999 CGLTF_CHECK_KEY(tokens[i]);
4000
4001 if (cgltf_json_strcmp(tokens+i, json_chunk, "ior") == 0)
4002 {
4003 ++i;
4004 out_ior->ior = cgltf_json_to_float(tokens + i, json_chunk);
4005 ++i;
4006 }
4007 else
4008 {
4009 i = cgltf_skip_json(tokens, i+1);
4010 }
4011
4012 if (i < 0)
4013 {
4014 return i;
4015 }
4016 }
4017
4018 return i;
4019}
4020
4021static int cgltf_parse_json_specular(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_specular* out_specular)
4022{
4023 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4024 int size = tokens[i].size;
4025 ++i;
4026
4027 // Default values
4028 out_specular->specular_factor = 1.0f;
4029 cgltf_fill_float_array(out_specular->specular_color_factor, 3, 1.0f);
4030
4031 for (int j = 0; j < size; ++j)
4032 {
4033 CGLTF_CHECK_KEY(tokens[i]);
4034
4035 if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
4036 {
4037 ++i;
4038 out_specular->specular_factor = cgltf_json_to_float(tokens + i, json_chunk);
4039 ++i;
4040 }
4041 else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularColorFactor") == 0)
4042 {
4043 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_specular->specular_color_factor, 3);
4044 }
4045 else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularTexture") == 0)
4046 {
4047 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_texture);
4048 }
4049 else if (cgltf_json_strcmp(tokens + i, json_chunk, "specularColorTexture") == 0)
4050 {
4051 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_color_texture);
4052 }
4053 else
4054 {
4055 i = cgltf_skip_json(tokens, i+1);
4056 }
4057
4058 if (i < 0)
4059 {
4060 return i;
4061 }
4062 }
4063
4064 return i;
4065}
4066
4067static int cgltf_parse_json_transmission(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_transmission* out_transmission)
4068{
4069 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4070 int size = tokens[i].size;
4071 ++i;
4072
4073 for (int j = 0; j < size; ++j)
4074 {
4075 CGLTF_CHECK_KEY(tokens[i]);
4076
4077 if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionFactor") == 0)
4078 {
4079 ++i;
4080 out_transmission->transmission_factor = cgltf_json_to_float(tokens + i, json_chunk);
4081 ++i;
4082 }
4083 else if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionTexture") == 0)
4084 {
4085 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_transmission->transmission_texture);
4086 }
4087 else
4088 {
4089 i = cgltf_skip_json(tokens, i+1);
4090 }
4091
4092 if (i < 0)
4093 {
4094 return i;
4095 }
4096 }
4097
4098 return i;
4099}
4100
4101static int cgltf_parse_json_volume(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_volume* out_volume)
4102{
4103 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4104 int size = tokens[i].size;
4105 ++i;
4106
4107 for (int j = 0; j < size; ++j)
4108 {
4109 CGLTF_CHECK_KEY(tokens[i]);
4110
4111 if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessFactor") == 0)
4112 {
4113 ++i;
4114 out_volume->thickness_factor = cgltf_json_to_float(tokens + i, json_chunk);
4115 ++i;
4116 }
4117 else if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessTexture") == 0)
4118 {
4119 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_volume->thickness_texture);
4120 }
4121 else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationColor") == 0)
4122 {
4123 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_volume->attenuation_color, 3);
4124 }
4125 else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationDistance") == 0)
4126 {
4127 ++i;
4128 out_volume->attenuation_distance = cgltf_json_to_float(tokens + i, json_chunk);
4129 ++i;
4130 }
4131 else
4132 {
4133 i = cgltf_skip_json(tokens, i + 1);
4134 }
4135
4136 if (i < 0)
4137 {
4138 return i;
4139 }
4140 }
4141
4142 return i;
4143}
4144
4145static int cgltf_parse_json_sheen(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sheen* out_sheen)
4146{
4147 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4148 int size = tokens[i].size;
4149 ++i;
4150
4151 for (int j = 0; j < size; ++j)
4152 {
4153 CGLTF_CHECK_KEY(tokens[i]);
4154
4155 if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorFactor") == 0)
4156 {
4157 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_sheen->sheen_color_factor, 3);
4158 }
4159 else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorTexture") == 0)
4160 {
4161 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_color_texture);
4162 }
4163 else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessFactor") == 0)
4164 {
4165 ++i;
4166 out_sheen->sheen_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
4167 ++i;
4168 }
4169 else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessTexture") == 0)
4170 {
4171 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_roughness_texture);
4172 }
4173 else
4174 {
4175 i = cgltf_skip_json(tokens, i+1);
4176 }
4177
4178 if (i < 0)
4179 {
4180 return i;
4181 }
4182 }
4183
4184 return i;
4185}
4186
4187static int cgltf_parse_json_emissive_strength(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_emissive_strength* out_emissive_strength)
4188{
4189 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4190 int size = tokens[i].size;
4191 ++i;
4192
4193 // Default
4194 out_emissive_strength->emissive_strength = 1.f;
4195
4196 for (int j = 0; j < size; ++j)
4197 {
4198 CGLTF_CHECK_KEY(tokens[i]);
4199
4200 if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveStrength") == 0)
4201 {
4202 ++i;
4203 out_emissive_strength->emissive_strength = cgltf_json_to_float(tokens + i, json_chunk);
4204 ++i;
4205 }
4206 else
4207 {
4208 i = cgltf_skip_json(tokens, i + 1);
4209 }
4210
4211 if (i < 0)
4212 {
4213 return i;
4214 }
4215 }
4216
4217 return i;
4218}
4219
4220static int cgltf_parse_json_iridescence(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_iridescence* out_iridescence)
4221{
4222 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4223 int size = tokens[i].size;
4224 ++i;
4225
4226 // Default
4227 out_iridescence->iridescence_ior = 1.3f;
4228 out_iridescence->iridescence_thickness_min = 100.f;
4229 out_iridescence->iridescence_thickness_max = 400.f;
4230
4231 for (int j = 0; j < size; ++j)
4232 {
4233 CGLTF_CHECK_KEY(tokens[i]);
4234
4235 if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceFactor") == 0)
4236 {
4237 ++i;
4238 out_iridescence->iridescence_factor = cgltf_json_to_float(tokens + i, json_chunk);
4239 ++i;
4240 }
4241 else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceTexture") == 0)
4242 {
4243 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_texture);
4244 }
4245 else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceIor") == 0)
4246 {
4247 ++i;
4248 out_iridescence->iridescence_ior = cgltf_json_to_float(tokens + i, json_chunk);
4249 ++i;
4250 }
4251 else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMinimum") == 0)
4252 {
4253 ++i;
4254 out_iridescence->iridescence_thickness_min = cgltf_json_to_float(tokens + i, json_chunk);
4255 ++i;
4256 }
4257 else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMaximum") == 0)
4258 {
4259 ++i;
4260 out_iridescence->iridescence_thickness_max = cgltf_json_to_float(tokens + i, json_chunk);
4261 ++i;
4262 }
4263 else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessTexture") == 0)
4264 {
4265 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_thickness_texture);
4266 }
4267 else
4268 {
4269 i = cgltf_skip_json(tokens, i + 1);
4270 }
4271
4272 if (i < 0)
4273 {
4274 return i;
4275 }
4276 }
4277
4278 return i;
4279}
4280
4281static int cgltf_parse_json_anisotropy(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_anisotropy* out_anisotropy)
4282{
4283 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4284 int size = tokens[i].size;
4285 ++i;
4286
4287
4288 for (int j = 0; j < size; ++j)
4289 {
4290 CGLTF_CHECK_KEY(tokens[i]);
4291
4292 if (cgltf_json_strcmp(tokens + i, json_chunk, "anisotropyStrength") == 0)
4293 {
4294 ++i;
4295 out_anisotropy->anisotropy_strength = cgltf_json_to_float(tokens + i, json_chunk);
4296 ++i;
4297 }
4298 else if (cgltf_json_strcmp(tokens + i, json_chunk, "anisotropyRotation") == 0)
4299 {
4300 ++i;
4301 out_anisotropy->anisotropy_rotation = cgltf_json_to_float(tokens + i, json_chunk);
4302 ++i;
4303 }
4304 else if (cgltf_json_strcmp(tokens + i, json_chunk, "anisotropyTexture") == 0)
4305 {
4306 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_anisotropy->anisotropy_texture);
4307 }
4308 else
4309 {
4310 i = cgltf_skip_json(tokens, i + 1);
4311 }
4312
4313 if (i < 0)
4314 {
4315 return i;
4316 }
4317 }
4318
4319 return i;
4320}
4321
4322static int cgltf_parse_json_dispersion(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_dispersion* out_dispersion)
4323{
4324 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4325 int size = tokens[i].size;
4326 ++i;
4327
4328
4329 for (int j = 0; j < size; ++j)
4330 {
4331 CGLTF_CHECK_KEY(tokens[i]);
4332
4333 if (cgltf_json_strcmp(tokens + i, json_chunk, "dispersion") == 0)
4334 {
4335 ++i;
4336 out_dispersion->dispersion = cgltf_json_to_float(tokens + i, json_chunk);
4337 ++i;
4338 }
4339 else
4340 {
4341 i = cgltf_skip_json(tokens, i + 1);
4342 }
4343
4344 if (i < 0)
4345 {
4346 return i;
4347 }
4348 }
4349
4350 return i;
4351}
4352
4353static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image)
4354{
4355 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4356
4357 int size = tokens[i].size;
4358 ++i;
4359
4360 for (int j = 0; j < size; ++j)
4361 {
4362 CGLTF_CHECK_KEY(tokens[i]);
4363
4364 if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0)
4365 {
4366 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->uri);
4367 }
4368 else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
4369 {
4370 ++i;
4371 out_image->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
4372 ++i;
4373 }
4374 else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0)
4375 {
4376 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->mime_type);
4377 }
4378 else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
4379 {
4380 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->name);
4381 }
4382 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
4383 {
4384 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_image->extras);
4385 }
4386 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
4387 {
4388 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_image->extensions_count, &out_image->extensions);
4389 }
4390 else
4391 {
4392 i = cgltf_skip_json(tokens, i + 1);
4393 }
4394
4395 if (i < 0)
4396 {
4397 return i;
4398 }
4399 }
4400
4401 return i;
4402}
4403
4404static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sampler* out_sampler)
4405{
4406 (void)options;
4407 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4408
4409 out_sampler->wrap_s = 10497;
4410 out_sampler->wrap_t = 10497;
4411
4412 int size = tokens[i].size;
4413 ++i;
4414
4415 for (int j = 0; j < size; ++j)
4416 {
4417 CGLTF_CHECK_KEY(tokens[i]);
4418
4419 if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
4420 {
4421 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_sampler->name);
4422 }
4423 else if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0)
4424 {
4425 ++i;
4426 out_sampler->mag_filter
4427 = cgltf_json_to_int(tokens + i, json_chunk);
4428 ++i;
4429 }
4430 else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0)
4431 {
4432 ++i;
4433 out_sampler->min_filter
4434 = cgltf_json_to_int(tokens + i, json_chunk);
4435 ++i;
4436 }
4437 else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0)
4438 {
4439 ++i;
4440 out_sampler->wrap_s
4441 = cgltf_json_to_int(tokens + i, json_chunk);
4442 ++i;
4443 }
4444 else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0)
4445 {
4446 ++i;
4447 out_sampler->wrap_t
4448 = cgltf_json_to_int(tokens + i, json_chunk);
4449 ++i;
4450 }
4451 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
4452 {
4453 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
4454 }
4455 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
4456 {
4457 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
4458 }
4459 else
4460 {
4461 i = cgltf_skip_json(tokens, i + 1);
4462 }
4463
4464 if (i < 0)
4465 {
4466 return i;
4467 }
4468 }
4469
4470 return i;
4471}
4472
4473static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture* out_texture)
4474{
4475 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4476
4477 int size = tokens[i].size;
4478 ++i;
4479
4480 for (int j = 0; j < size; ++j)
4481 {
4482 CGLTF_CHECK_KEY(tokens[i]);
4483
4484 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
4485 {
4486 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_texture->name);
4487 }
4488 else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0)
4489 {
4490 ++i;
4491 out_texture->sampler = CGLTF_PTRINDEX(cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk));
4492 ++i;
4493 }
4494 else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0)
4495 {
4496 ++i;
4497 out_texture->image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
4498 ++i;
4499 }
4500 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
4501 {
4502 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_texture->extras);
4503 }
4504 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
4505 {
4506 ++i;
4507
4508 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4509 if (out_texture->extensions)
4510 {
4511 return CGLTF_ERROR_JSON;
4512 }
4513
4514 int extensions_size = tokens[i].size;
4515 ++i;
4516 out_texture->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
4517 out_texture->extensions_count = 0;
4518
4519 if (!out_texture->extensions)
4520 {
4521 return CGLTF_ERROR_NOMEM;
4522 }
4523
4524 for (int k = 0; k < extensions_size; ++k)
4525 {
4526 CGLTF_CHECK_KEY(tokens[i]);
4527
4528 if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_texture_basisu") == 0)
4529 {
4530 out_texture->has_basisu = 1;
4531 ++i;
4532 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4533 int num_properties = tokens[i].size;
4534 ++i;
4535
4536 for (int t = 0; t < num_properties; ++t)
4537 {
4538 CGLTF_CHECK_KEY(tokens[i]);
4539
4540 if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0)
4541 {
4542 ++i;
4543 out_texture->basisu_image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
4544 ++i;
4545 }
4546 else
4547 {
4548 i = cgltf_skip_json(tokens, i + 1);
4549 }
4550 if (i < 0)
4551 {
4552 return i;
4553 }
4554 }
4555 }
4556 else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXT_texture_webp") == 0)
4557 {
4558 out_texture->has_webp = 1;
4559 ++i;
4560 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4561 int num_properties = tokens[i].size;
4562 ++i;
4563
4564 for (int t = 0; t < num_properties; ++t)
4565 {
4566 CGLTF_CHECK_KEY(tokens[i]);
4567
4568 if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0)
4569 {
4570 ++i;
4571 out_texture->webp_image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
4572 ++i;
4573 }
4574 else
4575 {
4576 i = cgltf_skip_json(tokens, i + 1);
4577 }
4578 if (i < 0)
4579 {
4580 return i;
4581 }
4582 }
4583 }
4584 else
4585 {
4586 i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture->extensions[out_texture->extensions_count++]));
4587 }
4588
4589 if (i < 0)
4590 {
4591 return i;
4592 }
4593 }
4594 }
4595 else
4596 {
4597 i = cgltf_skip_json(tokens, i + 1);
4598 }
4599
4600 if (i < 0)
4601 {
4602 return i;
4603 }
4604 }
4605
4606 return i;
4607}
4608
4609static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material* out_material)
4610{
4611 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4612
4613 cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, 4, 1.0f);
4614 out_material->pbr_metallic_roughness.metallic_factor = 1.0f;
4615 out_material->pbr_metallic_roughness.roughness_factor = 1.0f;
4616
4617 cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, 4, 1.0f);
4618 cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, 3, 1.0f);
4619 out_material->pbr_specular_glossiness.glossiness_factor = 1.0f;
4620
4621 cgltf_fill_float_array(out_material->volume.attenuation_color, 3, 1.0f);
4622 out_material->volume.attenuation_distance = FLT_MAX;
4623
4624 out_material->alpha_cutoff = 0.5f;
4625
4626 int size = tokens[i].size;
4627 ++i;
4628
4629 for (int j = 0; j < size; ++j)
4630 {
4631 CGLTF_CHECK_KEY(tokens[i]);
4632
4633 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
4634 {
4635 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_material->name);
4636 }
4637 else if (cgltf_json_strcmp(tokens+i, json_chunk, "pbrMetallicRoughness") == 0)
4638 {
4639 out_material->has_pbr_metallic_roughness = 1;
4640 i = cgltf_parse_json_pbr_metallic_roughness(options, tokens, i + 1, json_chunk, &out_material->pbr_metallic_roughness);
4641 }
4642 else if (cgltf_json_strcmp(tokens+i, json_chunk, "emissiveFactor") == 0)
4643 {
4644 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_material->emissive_factor, 3);
4645 }
4646 else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == 0)
4647 {
4648 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
4649 &out_material->normal_texture);
4650 }
4651 else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == 0)
4652 {
4653 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
4654 &out_material->occlusion_texture);
4655 }
4656 else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == 0)
4657 {
4658 i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
4659 &out_material->emissive_texture);
4660 }
4661 else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0)
4662 {
4663 ++i;
4664 if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0)
4665 {
4666 out_material->alpha_mode = cgltf_alpha_mode_opaque;
4667 }
4668 else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0)
4669 {
4670 out_material->alpha_mode = cgltf_alpha_mode_mask;
4671 }
4672 else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0)
4673 {
4674 out_material->alpha_mode = cgltf_alpha_mode_blend;
4675 }
4676 ++i;
4677 }
4678 else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0)
4679 {
4680 ++i;
4681 out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk);
4682 ++i;
4683 }
4684 else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0)
4685 {
4686 ++i;
4687 out_material->double_sided =
4688 cgltf_json_to_bool(tokens + i, json_chunk);
4689 ++i;
4690 }
4691 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
4692 {
4693 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_material->extras);
4694 }
4695 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
4696 {
4697 ++i;
4698
4699 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4700 if(out_material->extensions)
4701 {
4702 return CGLTF_ERROR_JSON;
4703 }
4704
4705 int extensions_size = tokens[i].size;
4706 ++i;
4707 out_material->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
4708 out_material->extensions_count= 0;
4709
4710 if (!out_material->extensions)
4711 {
4712 return CGLTF_ERROR_NOMEM;
4713 }
4714
4715 for (int k = 0; k < extensions_size; ++k)
4716 {
4717 CGLTF_CHECK_KEY(tokens[i]);
4718
4719 if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_pbrSpecularGlossiness") == 0)
4720 {
4721 out_material->has_pbr_specular_glossiness = 1;
4722 i = cgltf_parse_json_pbr_specular_glossiness(options, tokens, i + 1, json_chunk, &out_material->pbr_specular_glossiness);
4723 }
4724 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_unlit") == 0)
4725 {
4726 out_material->unlit = 1;
4727 i = cgltf_skip_json(tokens, i+1);
4728 }
4729 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_clearcoat") == 0)
4730 {
4731 out_material->has_clearcoat = 1;
4732 i = cgltf_parse_json_clearcoat(options, tokens, i + 1, json_chunk, &out_material->clearcoat);
4733 }
4734 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_ior") == 0)
4735 {
4736 out_material->has_ior = 1;
4737 i = cgltf_parse_json_ior(tokens, i + 1, json_chunk, &out_material->ior);
4738 }
4739 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_specular") == 0)
4740 {
4741 out_material->has_specular = 1;
4742 i = cgltf_parse_json_specular(options, tokens, i + 1, json_chunk, &out_material->specular);
4743 }
4744 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_transmission") == 0)
4745 {
4746 out_material->has_transmission = 1;
4747 i = cgltf_parse_json_transmission(options, tokens, i + 1, json_chunk, &out_material->transmission);
4748 }
4749 else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_volume") == 0)
4750 {
4751 out_material->has_volume = 1;
4752 i = cgltf_parse_json_volume(options, tokens, i + 1, json_chunk, &out_material->volume);
4753 }
4754 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_sheen") == 0)
4755 {
4756 out_material->has_sheen = 1;
4757 i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, &out_material->sheen);
4758 }
4759 else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_emissive_strength") == 0)
4760 {
4761 out_material->has_emissive_strength = 1;
4762 i = cgltf_parse_json_emissive_strength(tokens, i + 1, json_chunk, &out_material->emissive_strength);
4763 }
4764 else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_iridescence") == 0)
4765 {
4766 out_material->has_iridescence = 1;
4767 i = cgltf_parse_json_iridescence(options, tokens, i + 1, json_chunk, &out_material->iridescence);
4768 }
4769 else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_anisotropy") == 0)
4770 {
4771 out_material->has_anisotropy = 1;
4772 i = cgltf_parse_json_anisotropy(options, tokens, i + 1, json_chunk, &out_material->anisotropy);
4773 }
4774 else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_dispersion") == 0)
4775 {
4776 out_material->has_dispersion = 1;
4777 i = cgltf_parse_json_dispersion(tokens, i + 1, json_chunk, &out_material->dispersion);
4778 }
4779 else
4780 {
4781 i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++]));
4782 }
4783
4784 if (i < 0)
4785 {
4786 return i;
4787 }
4788 }
4789 }
4790 else
4791 {
4792 i = cgltf_skip_json(tokens, i+1);
4793 }
4794
4795 if (i < 0)
4796 {
4797 return i;
4798 }
4799 }
4800
4801 return i;
4802}
4803
4804static int cgltf_parse_json_accessors(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
4805{
4806 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_accessor), (void**)&out_data->accessors, &out_data->accessors_count);
4807 if (i < 0)
4808 {
4809 return i;
4810 }
4811
4812 for (cgltf_size j = 0; j < out_data->accessors_count; ++j)
4813 {
4814 i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, &out_data->accessors[j]);
4815 if (i < 0)
4816 {
4817 return i;
4818 }
4819 }
4820 return i;
4821}
4822
4823static int cgltf_parse_json_materials(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
4824{
4825 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material), (void**)&out_data->materials, &out_data->materials_count);
4826 if (i < 0)
4827 {
4828 return i;
4829 }
4830
4831 for (cgltf_size j = 0; j < out_data->materials_count; ++j)
4832 {
4833 i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data->materials[j]);
4834 if (i < 0)
4835 {
4836 return i;
4837 }
4838 }
4839 return i;
4840}
4841
4842static int cgltf_parse_json_images(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
4843{
4844 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_image), (void**)&out_data->images, &out_data->images_count);
4845 if (i < 0)
4846 {
4847 return i;
4848 }
4849
4850 for (cgltf_size j = 0; j < out_data->images_count; ++j)
4851 {
4852 i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data->images[j]);
4853 if (i < 0)
4854 {
4855 return i;
4856 }
4857 }
4858 return i;
4859}
4860
4861static int cgltf_parse_json_textures(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
4862{
4863 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_texture), (void**)&out_data->textures, &out_data->textures_count);
4864 if (i < 0)
4865 {
4866 return i;
4867 }
4868
4869 for (cgltf_size j = 0; j < out_data->textures_count; ++j)
4870 {
4871 i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data->textures[j]);
4872 if (i < 0)
4873 {
4874 return i;
4875 }
4876 }
4877 return i;
4878}
4879
4880static int cgltf_parse_json_samplers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
4881{
4882 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_sampler), (void**)&out_data->samplers, &out_data->samplers_count);
4883 if (i < 0)
4884 {
4885 return i;
4886 }
4887
4888 for (cgltf_size j = 0; j < out_data->samplers_count; ++j)
4889 {
4890 i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data->samplers[j]);
4891 if (i < 0)
4892 {
4893 return i;
4894 }
4895 }
4896 return i;
4897}
4898
4899static int cgltf_parse_json_meshopt_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_meshopt_compression* out_meshopt_compression)
4900{
4901 (void)options;
4902 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4903
4904 int size = tokens[i].size;
4905 ++i;
4906
4907 for (int j = 0; j < size; ++j)
4908 {
4909 CGLTF_CHECK_KEY(tokens[i]);
4910
4911 if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
4912 {
4913 ++i;
4914 out_meshopt_compression->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
4915 ++i;
4916 }
4917 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
4918 {
4919 ++i;
4920 out_meshopt_compression->offset = cgltf_json_to_size(tokens+i, json_chunk);
4921 ++i;
4922 }
4923 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
4924 {
4925 ++i;
4926 out_meshopt_compression->size = cgltf_json_to_size(tokens+i, json_chunk);
4927 ++i;
4928 }
4929 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
4930 {
4931 ++i;
4932 out_meshopt_compression->stride = cgltf_json_to_size(tokens+i, json_chunk);
4933 ++i;
4934 }
4935 else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
4936 {
4937 ++i;
4938 out_meshopt_compression->count = cgltf_json_to_size(tokens+i, json_chunk);
4939 ++i;
4940 }
4941 else if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
4942 {
4943 ++i;
4944 if (cgltf_json_strcmp(tokens+i, json_chunk, "ATTRIBUTES") == 0)
4945 {
4946 out_meshopt_compression->mode = cgltf_meshopt_compression_mode_attributes;
4947 }
4948 else if (cgltf_json_strcmp(tokens+i, json_chunk, "TRIANGLES") == 0)
4949 {
4950 out_meshopt_compression->mode = cgltf_meshopt_compression_mode_triangles;
4951 }
4952 else if (cgltf_json_strcmp(tokens+i, json_chunk, "INDICES") == 0)
4953 {
4954 out_meshopt_compression->mode = cgltf_meshopt_compression_mode_indices;
4955 }
4956 ++i;
4957 }
4958 else if (cgltf_json_strcmp(tokens+i, json_chunk, "filter") == 0)
4959 {
4960 ++i;
4961 if (cgltf_json_strcmp(tokens+i, json_chunk, "NONE") == 0)
4962 {
4963 out_meshopt_compression->filter = cgltf_meshopt_compression_filter_none;
4964 }
4965 else if (cgltf_json_strcmp(tokens+i, json_chunk, "OCTAHEDRAL") == 0)
4966 {
4967 out_meshopt_compression->filter = cgltf_meshopt_compression_filter_octahedral;
4968 }
4969 else if (cgltf_json_strcmp(tokens+i, json_chunk, "QUATERNION") == 0)
4970 {
4971 out_meshopt_compression->filter = cgltf_meshopt_compression_filter_quaternion;
4972 }
4973 else if (cgltf_json_strcmp(tokens+i, json_chunk, "EXPONENTIAL") == 0)
4974 {
4975 out_meshopt_compression->filter = cgltf_meshopt_compression_filter_exponential;
4976 }
4977 ++i;
4978 }
4979 else
4980 {
4981 i = cgltf_skip_json(tokens, i+1);
4982 }
4983
4984 if (i < 0)
4985 {
4986 return i;
4987 }
4988 }
4989
4990 return i;
4991}
4992
4993static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer_view* out_buffer_view)
4994{
4995 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
4996
4997 int size = tokens[i].size;
4998 ++i;
4999
5000 for (int j = 0; j < size; ++j)
5001 {
5002 CGLTF_CHECK_KEY(tokens[i]);
5003
5004 if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
5005 {
5006 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer_view->name);
5007 }
5008 else if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
5009 {
5010 ++i;
5011 out_buffer_view->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
5012 ++i;
5013 }
5014 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
5015 {
5016 ++i;
5017 out_buffer_view->offset =
5018 cgltf_json_to_size(tokens+i, json_chunk);
5019 ++i;
5020 }
5021 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
5022 {
5023 ++i;
5024 out_buffer_view->size =
5025 cgltf_json_to_size(tokens+i, json_chunk);
5026 ++i;
5027 }
5028 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
5029 {
5030 ++i;
5031 out_buffer_view->stride =
5032 cgltf_json_to_size(tokens+i, json_chunk);
5033 ++i;
5034 }
5035 else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
5036 {
5037 ++i;
5038 int type = cgltf_json_to_int(tokens+i, json_chunk);
5039 switch (type)
5040 {
5041 case 34962:
5042 type = cgltf_buffer_view_type_vertices;
5043 break;
5044 case 34963:
5045 type = cgltf_buffer_view_type_indices;
5046 break;
5047 default:
5048 type = cgltf_buffer_view_type_invalid;
5049 break;
5050 }
5051 out_buffer_view->type = (cgltf_buffer_view_type)type;
5052 ++i;
5053 }
5054 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5055 {
5056 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer_view->extras);
5057 }
5058 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5059 {
5060 ++i;
5061
5062 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5063 if(out_buffer_view->extensions)
5064 {
5065 return CGLTF_ERROR_JSON;
5066 }
5067
5068 int extensions_size = tokens[i].size;
5069 out_buffer_view->extensions_count = 0;
5070 out_buffer_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
5071
5072 if (!out_buffer_view->extensions)
5073 {
5074 return CGLTF_ERROR_NOMEM;
5075 }
5076
5077 ++i;
5078 for (int k = 0; k < extensions_size; ++k)
5079 {
5080 CGLTF_CHECK_KEY(tokens[i]);
5081
5082 if (cgltf_json_strcmp(tokens+i, json_chunk, "EXT_meshopt_compression") == 0)
5083 {
5084 out_buffer_view->has_meshopt_compression = 1;
5085 i = cgltf_parse_json_meshopt_compression(options, tokens, i + 1, json_chunk, &out_buffer_view->meshopt_compression);
5086 }
5087 else
5088 {
5089 i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_buffer_view->extensions[out_buffer_view->extensions_count++]));
5090 }
5091
5092 if (i < 0)
5093 {
5094 return i;
5095 }
5096 }
5097 }
5098 else
5099 {
5100 i = cgltf_skip_json(tokens, i+1);
5101 }
5102
5103 if (i < 0)
5104 {
5105 return i;
5106 }
5107 }
5108
5109 return i;
5110}
5111
5112static int cgltf_parse_json_buffer_views(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
5113{
5114 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), (void**)&out_data->buffer_views, &out_data->buffer_views_count);
5115 if (i < 0)
5116 {
5117 return i;
5118 }
5119
5120 for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j)
5121 {
5122 i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, &out_data->buffer_views[j]);
5123 if (i < 0)
5124 {
5125 return i;
5126 }
5127 }
5128 return i;
5129}
5130
5131static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer* out_buffer)
5132{
5133 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5134
5135 int size = tokens[i].size;
5136 ++i;
5137
5138 for (int j = 0; j < size; ++j)
5139 {
5140 CGLTF_CHECK_KEY(tokens[i]);
5141
5142 if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
5143 {
5144 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->name);
5145 }
5146 else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
5147 {
5148 ++i;
5149 out_buffer->size =
5150 cgltf_json_to_size(tokens+i, json_chunk);
5151 ++i;
5152 }
5153 else if (cgltf_json_strcmp(tokens+i, json_chunk, "uri") == 0)
5154 {
5155 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->uri);
5156 }
5157 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5158 {
5159 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer->extras);
5160 }
5161 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5162 {
5163 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_buffer->extensions_count, &out_buffer->extensions);
5164 }
5165 else
5166 {
5167 i = cgltf_skip_json(tokens, i+1);
5168 }
5169
5170 if (i < 0)
5171 {
5172 return i;
5173 }
5174 }
5175
5176 return i;
5177}
5178
5179static int cgltf_parse_json_buffers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
5180{
5181 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer), (void**)&out_data->buffers, &out_data->buffers_count);
5182 if (i < 0)
5183 {
5184 return i;
5185 }
5186
5187 for (cgltf_size j = 0; j < out_data->buffers_count; ++j)
5188 {
5189 i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data->buffers[j]);
5190 if (i < 0)
5191 {
5192 return i;
5193 }
5194 }
5195 return i;
5196}
5197
5198static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_skin* out_skin)
5199{
5200 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5201
5202 int size = tokens[i].size;
5203 ++i;
5204
5205 for (int j = 0; j < size; ++j)
5206 {
5207 CGLTF_CHECK_KEY(tokens[i]);
5208
5209 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
5210 {
5211 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_skin->name);
5212 }
5213 else if (cgltf_json_strcmp(tokens+i, json_chunk, "joints") == 0)
5214 {
5215 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_skin->joints, &out_skin->joints_count);
5216 if (i < 0)
5217 {
5218 return i;
5219 }
5220
5221 for (cgltf_size k = 0; k < out_skin->joints_count; ++k)
5222 {
5223 out_skin->joints[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
5224 ++i;
5225 }
5226 }
5227 else if (cgltf_json_strcmp(tokens+i, json_chunk, "skeleton") == 0)
5228 {
5229 ++i;
5230 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
5231 out_skin->skeleton = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
5232 ++i;
5233 }
5234 else if (cgltf_json_strcmp(tokens+i, json_chunk, "inverseBindMatrices") == 0)
5235 {
5236 ++i;
5237 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
5238 out_skin->inverse_bind_matrices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
5239 ++i;
5240 }
5241 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5242 {
5243 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_skin->extras);
5244 }
5245 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5246 {
5247 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_skin->extensions_count, &out_skin->extensions);
5248 }
5249 else
5250 {
5251 i = cgltf_skip_json(tokens, i+1);
5252 }
5253
5254 if (i < 0)
5255 {
5256 return i;
5257 }
5258 }
5259
5260 return i;
5261}
5262
5263static int cgltf_parse_json_skins(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
5264{
5265 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), (void**)&out_data->skins, &out_data->skins_count);
5266 if (i < 0)
5267 {
5268 return i;
5269 }
5270
5271 for (cgltf_size j = 0; j < out_data->skins_count; ++j)
5272 {
5273 i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data->skins[j]);
5274 if (i < 0)
5275 {
5276 return i;
5277 }
5278 }
5279 return i;
5280}
5281
5282static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_camera* out_camera)
5283{
5284 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5285
5286 int size = tokens[i].size;
5287 ++i;
5288
5289 for (int j = 0; j < size; ++j)
5290 {
5291 CGLTF_CHECK_KEY(tokens[i]);
5292
5293 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
5294 {
5295 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name);
5296 }
5297 else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0)
5298 {
5299 ++i;
5300
5301 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5302
5303 int data_size = tokens[i].size;
5304 ++i;
5305
5306 if (out_camera->type != cgltf_camera_type_invalid)
5307 {
5308 return CGLTF_ERROR_JSON;
5309 }
5310
5311 out_camera->type = cgltf_camera_type_perspective;
5312
5313 for (int k = 0; k < data_size; ++k)
5314 {
5315 CGLTF_CHECK_KEY(tokens[i]);
5316
5317 if (cgltf_json_strcmp(tokens+i, json_chunk, "aspectRatio") == 0)
5318 {
5319 ++i;
5320 out_camera->data.perspective.has_aspect_ratio = 1;
5321 out_camera->data.perspective.aspect_ratio = cgltf_json_to_float(tokens + i, json_chunk);
5322 ++i;
5323 }
5324 else if (cgltf_json_strcmp(tokens+i, json_chunk, "yfov") == 0)
5325 {
5326 ++i;
5327 out_camera->data.perspective.yfov = cgltf_json_to_float(tokens + i, json_chunk);
5328 ++i;
5329 }
5330 else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
5331 {
5332 ++i;
5333 out_camera->data.perspective.has_zfar = 1;
5334 out_camera->data.perspective.zfar = cgltf_json_to_float(tokens + i, json_chunk);
5335 ++i;
5336 }
5337 else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
5338 {
5339 ++i;
5340 out_camera->data.perspective.znear = cgltf_json_to_float(tokens + i, json_chunk);
5341 ++i;
5342 }
5343 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5344 {
5345 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
5346 }
5347 else
5348 {
5349 i = cgltf_skip_json(tokens, i+1);
5350 }
5351
5352 if (i < 0)
5353 {
5354 return i;
5355 }
5356 }
5357 }
5358 else if (cgltf_json_strcmp(tokens+i, json_chunk, "orthographic") == 0)
5359 {
5360 ++i;
5361
5362 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5363
5364 int data_size = tokens[i].size;
5365 ++i;
5366
5367 if (out_camera->type != cgltf_camera_type_invalid)
5368 {
5369 return CGLTF_ERROR_JSON;
5370 }
5371
5372 out_camera->type = cgltf_camera_type_orthographic;
5373
5374 for (int k = 0; k < data_size; ++k)
5375 {
5376 CGLTF_CHECK_KEY(tokens[i]);
5377
5378 if (cgltf_json_strcmp(tokens+i, json_chunk, "xmag") == 0)
5379 {
5380 ++i;
5381 out_camera->data.orthographic.xmag = cgltf_json_to_float(tokens + i, json_chunk);
5382 ++i;
5383 }
5384 else if (cgltf_json_strcmp(tokens+i, json_chunk, "ymag") == 0)
5385 {
5386 ++i;
5387 out_camera->data.orthographic.ymag = cgltf_json_to_float(tokens + i, json_chunk);
5388 ++i;
5389 }
5390 else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
5391 {
5392 ++i;
5393 out_camera->data.orthographic.zfar = cgltf_json_to_float(tokens + i, json_chunk);
5394 ++i;
5395 }
5396 else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
5397 {
5398 ++i;
5399 out_camera->data.orthographic.znear = cgltf_json_to_float(tokens + i, json_chunk);
5400 ++i;
5401 }
5402 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5403 {
5404 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
5405 }
5406 else
5407 {
5408 i = cgltf_skip_json(tokens, i+1);
5409 }
5410
5411 if (i < 0)
5412 {
5413 return i;
5414 }
5415 }
5416 }
5417 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5418 {
5419 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->extras);
5420 }
5421 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5422 {
5423 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_camera->extensions_count, &out_camera->extensions);
5424 }
5425 else
5426 {
5427 i = cgltf_skip_json(tokens, i+1);
5428 }
5429
5430 if (i < 0)
5431 {
5432 return i;
5433 }
5434 }
5435
5436 return i;
5437}
5438
5439static int cgltf_parse_json_cameras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
5440{
5441 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_camera), (void**)&out_data->cameras, &out_data->cameras_count);
5442 if (i < 0)
5443 {
5444 return i;
5445 }
5446
5447 for (cgltf_size j = 0; j < out_data->cameras_count; ++j)
5448 {
5449 i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data->cameras[j]);
5450 if (i < 0)
5451 {
5452 return i;
5453 }
5454 }
5455 return i;
5456}
5457
5458static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_light* out_light)
5459{
5460 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5461
5462 out_light->color[0] = 1.f;
5463 out_light->color[1] = 1.f;
5464 out_light->color[2] = 1.f;
5465 out_light->intensity = 1.f;
5466
5467 out_light->spot_inner_cone_angle = 0.f;
5468 out_light->spot_outer_cone_angle = 3.1415926535f / 4.0f;
5469
5470 int size = tokens[i].size;
5471 ++i;
5472
5473 for (int j = 0; j < size; ++j)
5474 {
5475 CGLTF_CHECK_KEY(tokens[i]);
5476
5477 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
5478 {
5479 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_light->name);
5480 }
5481 else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0)
5482 {
5483 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_light->color, 3);
5484 }
5485 else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0)
5486 {
5487 ++i;
5488 out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk);
5489 ++i;
5490 }
5491 else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
5492 {
5493 ++i;
5494 if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0)
5495 {
5496 out_light->type = cgltf_light_type_directional;
5497 }
5498 else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0)
5499 {
5500 out_light->type = cgltf_light_type_point;
5501 }
5502 else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0)
5503 {
5504 out_light->type = cgltf_light_type_spot;
5505 }
5506 ++i;
5507 }
5508 else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0)
5509 {
5510 ++i;
5511 out_light->range = cgltf_json_to_float(tokens + i, json_chunk);
5512 ++i;
5513 }
5514 else if (cgltf_json_strcmp(tokens+i, json_chunk, "spot") == 0)
5515 {
5516 ++i;
5517
5518 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5519
5520 int data_size = tokens[i].size;
5521 ++i;
5522
5523 for (int k = 0; k < data_size; ++k)
5524 {
5525 CGLTF_CHECK_KEY(tokens[i]);
5526
5527 if (cgltf_json_strcmp(tokens+i, json_chunk, "innerConeAngle") == 0)
5528 {
5529 ++i;
5530 out_light->spot_inner_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
5531 ++i;
5532 }
5533 else if (cgltf_json_strcmp(tokens+i, json_chunk, "outerConeAngle") == 0)
5534 {
5535 ++i;
5536 out_light->spot_outer_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
5537 ++i;
5538 }
5539 else
5540 {
5541 i = cgltf_skip_json(tokens, i+1);
5542 }
5543
5544 if (i < 0)
5545 {
5546 return i;
5547 }
5548 }
5549 }
5550 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5551 {
5552 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_light->extras);
5553 }
5554 else
5555 {
5556 i = cgltf_skip_json(tokens, i+1);
5557 }
5558
5559 if (i < 0)
5560 {
5561 return i;
5562 }
5563 }
5564
5565 return i;
5566}
5567
5568static int cgltf_parse_json_lights(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
5569{
5570 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_light), (void**)&out_data->lights, &out_data->lights_count);
5571 if (i < 0)
5572 {
5573 return i;
5574 }
5575
5576 for (cgltf_size j = 0; j < out_data->lights_count; ++j)
5577 {
5578 i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data->lights[j]);
5579 if (i < 0)
5580 {
5581 return i;
5582 }
5583 }
5584 return i;
5585}
5586
5587static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_node* out_node)
5588{
5589 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5590
5591 out_node->rotation[3] = 1.0f;
5592 out_node->scale[0] = 1.0f;
5593 out_node->scale[1] = 1.0f;
5594 out_node->scale[2] = 1.0f;
5595 out_node->matrix[0] = 1.0f;
5596 out_node->matrix[5] = 1.0f;
5597 out_node->matrix[10] = 1.0f;
5598 out_node->matrix[15] = 1.0f;
5599
5600 int size = tokens[i].size;
5601 ++i;
5602
5603 for (int j = 0; j < size; ++j)
5604 {
5605 CGLTF_CHECK_KEY(tokens[i]);
5606
5607 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
5608 {
5609 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_node->name);
5610 }
5611 else if (cgltf_json_strcmp(tokens+i, json_chunk, "children") == 0)
5612 {
5613 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_node->children, &out_node->children_count);
5614 if (i < 0)
5615 {
5616 return i;
5617 }
5618
5619 for (cgltf_size k = 0; k < out_node->children_count; ++k)
5620 {
5621 out_node->children[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
5622 ++i;
5623 }
5624 }
5625 else if (cgltf_json_strcmp(tokens+i, json_chunk, "mesh") == 0)
5626 {
5627 ++i;
5628 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
5629 out_node->mesh = CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk));
5630 ++i;
5631 }
5632 else if (cgltf_json_strcmp(tokens+i, json_chunk, "skin") == 0)
5633 {
5634 ++i;
5635 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
5636 out_node->skin = CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk));
5637 ++i;
5638 }
5639 else if (cgltf_json_strcmp(tokens+i, json_chunk, "camera") == 0)
5640 {
5641 ++i;
5642 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
5643 out_node->camera = CGLTF_PTRINDEX(cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk));
5644 ++i;
5645 }
5646 else if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
5647 {
5648 out_node->has_translation = 1;
5649 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->translation, 3);
5650 }
5651 else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
5652 {
5653 out_node->has_rotation = 1;
5654 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->rotation, 4);
5655 }
5656 else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
5657 {
5658 out_node->has_scale = 1;
5659 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->scale, 3);
5660 }
5661 else if (cgltf_json_strcmp(tokens+i, json_chunk, "matrix") == 0)
5662 {
5663 out_node->has_matrix = 1;
5664 i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->matrix, 16);
5665 }
5666 else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
5667 {
5668 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_node->weights, &out_node->weights_count);
5669 if (i < 0)
5670 {
5671 return i;
5672 }
5673
5674 i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_node->weights, (int)out_node->weights_count);
5675 }
5676 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5677 {
5678 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_node->extras);
5679 }
5680 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5681 {
5682 ++i;
5683
5684 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5685 if(out_node->extensions)
5686 {
5687 return CGLTF_ERROR_JSON;
5688 }
5689
5690 int extensions_size = tokens[i].size;
5691 out_node->extensions_count= 0;
5692 out_node->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
5693
5694 if (!out_node->extensions)
5695 {
5696 return CGLTF_ERROR_NOMEM;
5697 }
5698
5699 ++i;
5700
5701 for (int k = 0; k < extensions_size; ++k)
5702 {
5703 CGLTF_CHECK_KEY(tokens[i]);
5704
5705 if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
5706 {
5707 ++i;
5708
5709 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5710
5711 int data_size = tokens[i].size;
5712 ++i;
5713
5714 for (int m = 0; m < data_size; ++m)
5715 {
5716 CGLTF_CHECK_KEY(tokens[i]);
5717
5718 if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0)
5719 {
5720 ++i;
5721 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
5722 out_node->light = CGLTF_PTRINDEX(cgltf_light, cgltf_json_to_int(tokens + i, json_chunk));
5723 ++i;
5724 }
5725 else
5726 {
5727 i = cgltf_skip_json(tokens, i + 1);
5728 }
5729
5730 if (i < 0)
5731 {
5732 return i;
5733 }
5734 }
5735 }
5736 else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXT_mesh_gpu_instancing") == 0)
5737 {
5738 out_node->has_mesh_gpu_instancing = 1;
5739 i = cgltf_parse_json_mesh_gpu_instancing(options, tokens, i + 1, json_chunk, &out_node->mesh_gpu_instancing);
5740 }
5741 else
5742 {
5743 i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_node->extensions[out_node->extensions_count++]));
5744 }
5745
5746 if (i < 0)
5747 {
5748 return i;
5749 }
5750 }
5751 }
5752 else
5753 {
5754 i = cgltf_skip_json(tokens, i+1);
5755 }
5756
5757 if (i < 0)
5758 {
5759 return i;
5760 }
5761 }
5762
5763 return i;
5764}
5765
5766static int cgltf_parse_json_nodes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
5767{
5768 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), (void**)&out_data->nodes, &out_data->nodes_count);
5769 if (i < 0)
5770 {
5771 return i;
5772 }
5773
5774 for (cgltf_size j = 0; j < out_data->nodes_count; ++j)
5775 {
5776 i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data->nodes[j]);
5777 if (i < 0)
5778 {
5779 return i;
5780 }
5781 }
5782 return i;
5783}
5784
5785static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_scene* out_scene)
5786{
5787 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5788
5789 int size = tokens[i].size;
5790 ++i;
5791
5792 for (int j = 0; j < size; ++j)
5793 {
5794 CGLTF_CHECK_KEY(tokens[i]);
5795
5796 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
5797 {
5798 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_scene->name);
5799 }
5800 else if (cgltf_json_strcmp(tokens+i, json_chunk, "nodes") == 0)
5801 {
5802 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_scene->nodes, &out_scene->nodes_count);
5803 if (i < 0)
5804 {
5805 return i;
5806 }
5807
5808 for (cgltf_size k = 0; k < out_scene->nodes_count; ++k)
5809 {
5810 out_scene->nodes[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
5811 ++i;
5812 }
5813 }
5814 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5815 {
5816 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_scene->extras);
5817 }
5818 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5819 {
5820 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_scene->extensions_count, &out_scene->extensions);
5821 }
5822 else
5823 {
5824 i = cgltf_skip_json(tokens, i+1);
5825 }
5826
5827 if (i < 0)
5828 {
5829 return i;
5830 }
5831 }
5832
5833 return i;
5834}
5835
5836static int cgltf_parse_json_scenes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
5837{
5838 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_scene), (void**)&out_data->scenes, &out_data->scenes_count);
5839 if (i < 0)
5840 {
5841 return i;
5842 }
5843
5844 for (cgltf_size j = 0; j < out_data->scenes_count; ++j)
5845 {
5846 i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data->scenes[j]);
5847 if (i < 0)
5848 {
5849 return i;
5850 }
5851 }
5852 return i;
5853}
5854
5855static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_sampler* out_sampler)
5856{
5857 (void)options;
5858 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5859
5860 int size = tokens[i].size;
5861 ++i;
5862
5863 for (int j = 0; j < size; ++j)
5864 {
5865 CGLTF_CHECK_KEY(tokens[i]);
5866
5867 if (cgltf_json_strcmp(tokens+i, json_chunk, "input") == 0)
5868 {
5869 ++i;
5870 out_sampler->input = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
5871 ++i;
5872 }
5873 else if (cgltf_json_strcmp(tokens+i, json_chunk, "output") == 0)
5874 {
5875 ++i;
5876 out_sampler->output = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
5877 ++i;
5878 }
5879 else if (cgltf_json_strcmp(tokens+i, json_chunk, "interpolation") == 0)
5880 {
5881 ++i;
5882 if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0)
5883 {
5884 out_sampler->interpolation = cgltf_interpolation_type_linear;
5885 }
5886 else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0)
5887 {
5888 out_sampler->interpolation = cgltf_interpolation_type_step;
5889 }
5890 else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == 0)
5891 {
5892 out_sampler->interpolation = cgltf_interpolation_type_cubic_spline;
5893 }
5894 ++i;
5895 }
5896 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5897 {
5898 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
5899 }
5900 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5901 {
5902 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
5903 }
5904 else
5905 {
5906 i = cgltf_skip_json(tokens, i+1);
5907 }
5908
5909 if (i < 0)
5910 {
5911 return i;
5912 }
5913 }
5914
5915 return i;
5916}
5917
5918static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_channel* out_channel)
5919{
5920 (void)options;
5921 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5922
5923 int size = tokens[i].size;
5924 ++i;
5925
5926 for (int j = 0; j < size; ++j)
5927 {
5928 CGLTF_CHECK_KEY(tokens[i]);
5929
5930 if (cgltf_json_strcmp(tokens+i, json_chunk, "sampler") == 0)
5931 {
5932 ++i;
5933 out_channel->sampler = CGLTF_PTRINDEX(cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk));
5934 ++i;
5935 }
5936 else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
5937 {
5938 ++i;
5939
5940 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
5941
5942 int target_size = tokens[i].size;
5943 ++i;
5944
5945 for (int k = 0; k < target_size; ++k)
5946 {
5947 CGLTF_CHECK_KEY(tokens[i]);
5948
5949 if (cgltf_json_strcmp(tokens+i, json_chunk, "node") == 0)
5950 {
5951 ++i;
5952 out_channel->target_node = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
5953 ++i;
5954 }
5955 else if (cgltf_json_strcmp(tokens+i, json_chunk, "path") == 0)
5956 {
5957 ++i;
5958 if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
5959 {
5960 out_channel->target_path = cgltf_animation_path_type_translation;
5961 }
5962 else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
5963 {
5964 out_channel->target_path = cgltf_animation_path_type_rotation;
5965 }
5966 else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
5967 {
5968 out_channel->target_path = cgltf_animation_path_type_scale;
5969 }
5970 else if (cgltf_json_strcmp(tokens+i, json_chunk, "weights") == 0)
5971 {
5972 out_channel->target_path = cgltf_animation_path_type_weights;
5973 }
5974 ++i;
5975 }
5976 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
5977 {
5978 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_channel->extras);
5979 }
5980 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
5981 {
5982 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_channel->extensions_count, &out_channel->extensions);
5983 }
5984 else
5985 {
5986 i = cgltf_skip_json(tokens, i+1);
5987 }
5988
5989 if (i < 0)
5990 {
5991 return i;
5992 }
5993 }
5994 }
5995 else
5996 {
5997 i = cgltf_skip_json(tokens, i+1);
5998 }
5999
6000 if (i < 0)
6001 {
6002 return i;
6003 }
6004 }
6005
6006 return i;
6007}
6008
6009static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation* out_animation)
6010{
6011 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
6012
6013 int size = tokens[i].size;
6014 ++i;
6015
6016 for (int j = 0; j < size; ++j)
6017 {
6018 CGLTF_CHECK_KEY(tokens[i]);
6019
6020 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
6021 {
6022 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_animation->name);
6023 }
6024 else if (cgltf_json_strcmp(tokens+i, json_chunk, "samplers") == 0)
6025 {
6026 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), (void**)&out_animation->samplers, &out_animation->samplers_count);
6027 if (i < 0)
6028 {
6029 return i;
6030 }
6031
6032 for (cgltf_size k = 0; k < out_animation->samplers_count; ++k)
6033 {
6034 i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation->samplers[k]);
6035 if (i < 0)
6036 {
6037 return i;
6038 }
6039 }
6040 }
6041 else if (cgltf_json_strcmp(tokens+i, json_chunk, "channels") == 0)
6042 {
6043 i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), (void**)&out_animation->channels, &out_animation->channels_count);
6044 if (i < 0)
6045 {
6046 return i;
6047 }
6048
6049 for (cgltf_size k = 0; k < out_animation->channels_count; ++k)
6050 {
6051 i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation->channels[k]);
6052 if (i < 0)
6053 {
6054 return i;
6055 }
6056 }
6057 }
6058 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
6059 {
6060 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_animation->extras);
6061 }
6062 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
6063 {
6064 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_animation->extensions_count, &out_animation->extensions);
6065 }
6066 else
6067 {
6068 i = cgltf_skip_json(tokens, i+1);
6069 }
6070
6071 if (i < 0)
6072 {
6073 return i;
6074 }
6075 }
6076
6077 return i;
6078}
6079
6080static int cgltf_parse_json_animations(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
6081{
6082 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_animation), (void**)&out_data->animations, &out_data->animations_count);
6083 if (i < 0)
6084 {
6085 return i;
6086 }
6087
6088 for (cgltf_size j = 0; j < out_data->animations_count; ++j)
6089 {
6090 i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data->animations[j]);
6091 if (i < 0)
6092 {
6093 return i;
6094 }
6095 }
6096 return i;
6097}
6098
6099static int cgltf_parse_json_variant(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_variant* out_variant)
6100{
6101 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
6102
6103 int size = tokens[i].size;
6104 ++i;
6105
6106 for (int j = 0; j < size; ++j)
6107 {
6108 CGLTF_CHECK_KEY(tokens[i]);
6109
6110 if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
6111 {
6112 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_variant->name);
6113 }
6114 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
6115 {
6116 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_variant->extras);
6117 }
6118 else
6119 {
6120 i = cgltf_skip_json(tokens, i+1);
6121 }
6122
6123 if (i < 0)
6124 {
6125 return i;
6126 }
6127 }
6128
6129 return i;
6130}
6131
6132static int cgltf_parse_json_variants(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
6133{
6134 i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material_variant), (void**)&out_data->variants, &out_data->variants_count);
6135 if (i < 0)
6136 {
6137 return i;
6138 }
6139
6140 for (cgltf_size j = 0; j < out_data->variants_count; ++j)
6141 {
6142 i = cgltf_parse_json_variant(options, tokens, i, json_chunk, &out_data->variants[j]);
6143 if (i < 0)
6144 {
6145 return i;
6146 }
6147 }
6148 return i;
6149}
6150
6151static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_asset* out_asset)
6152{
6153 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
6154
6155 int size = tokens[i].size;
6156 ++i;
6157
6158 for (int j = 0; j < size; ++j)
6159 {
6160 CGLTF_CHECK_KEY(tokens[i]);
6161
6162 if (cgltf_json_strcmp(tokens+i, json_chunk, "copyright") == 0)
6163 {
6164 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->copyright);
6165 }
6166 else if (cgltf_json_strcmp(tokens+i, json_chunk, "generator") == 0)
6167 {
6168 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->generator);
6169 }
6170 else if (cgltf_json_strcmp(tokens+i, json_chunk, "version") == 0)
6171 {
6172 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->version);
6173 }
6174 else if (cgltf_json_strcmp(tokens+i, json_chunk, "minVersion") == 0)
6175 {
6176 i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->min_version);
6177 }
6178 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
6179 {
6180 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_asset->extras);
6181 }
6182 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
6183 {
6184 i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_asset->extensions_count, &out_asset->extensions);
6185 }
6186 else
6187 {
6188 i = cgltf_skip_json(tokens, i+1);
6189 }
6190
6191 if (i < 0)
6192 {
6193 return i;
6194 }
6195 }
6196
6197 if (out_asset->version && CGLTF_ATOF(out_asset->version) < 2)
6198 {
6199 return CGLTF_ERROR_LEGACY;
6200 }
6201
6202 return i;
6203}
6204
6205cgltf_size cgltf_num_components(cgltf_type type) {
6206 switch (type)
6207 {
6208 case cgltf_type_vec2:
6209 return 2;
6210 case cgltf_type_vec3:
6211 return 3;
6212 case cgltf_type_vec4:
6213 return 4;
6214 case cgltf_type_mat2:
6215 return 4;
6216 case cgltf_type_mat3:
6217 return 9;
6218 case cgltf_type_mat4:
6219 return 16;
6220 case cgltf_type_invalid:
6221 case cgltf_type_scalar:
6222 default:
6223 return 1;
6224 }
6225}
6226
6227cgltf_size cgltf_component_size(cgltf_component_type component_type) {
6228 switch (component_type)
6229 {
6230 case cgltf_component_type_r_8:
6231 case cgltf_component_type_r_8u:
6232 return 1;
6233 case cgltf_component_type_r_16:
6234 case cgltf_component_type_r_16u:
6235 return 2;
6236 case cgltf_component_type_r_32u:
6237 case cgltf_component_type_r_32f:
6238 return 4;
6239 case cgltf_component_type_invalid:
6240 default:
6241 return 0;
6242 }
6243}
6244
6245cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
6246{
6247 cgltf_size component_size = cgltf_component_size(component_type);
6248 if (type == cgltf_type_mat2 && component_size == 1)
6249 {
6250 return 8 * component_size;
6251 }
6252 else if (type == cgltf_type_mat3 && (component_size == 1 || component_size == 2))
6253 {
6254 return 12 * component_size;
6255 }
6256 return component_size * cgltf_num_components(type);
6257}
6258
6259static int cgltf_fixup_pointers(cgltf_data* out_data);
6260
6261static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
6262{
6263 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
6264
6265 int size = tokens[i].size;
6266 ++i;
6267
6268 for (int j = 0; j < size; ++j)
6269 {
6270 CGLTF_CHECK_KEY(tokens[i]);
6271
6272 if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0)
6273 {
6274 i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, &out_data->asset);
6275 }
6276 else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0)
6277 {
6278 i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data);
6279 }
6280 else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0)
6281 {
6282 i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, out_data);
6283 }
6284 else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0)
6285 {
6286 i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, out_data);
6287 }
6288 else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0)
6289 {
6290 i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, out_data);
6291 }
6292 else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0)
6293 {
6294 i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, out_data);
6295 }
6296 else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0)
6297 {
6298 i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data);
6299 }
6300 else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0)
6301 {
6302 i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, out_data);
6303 }
6304 else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0)
6305 {
6306 i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, out_data);
6307 }
6308 else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0)
6309 {
6310 i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data);
6311 }
6312 else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0)
6313 {
6314 i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, out_data);
6315 }
6316 else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0)
6317 {
6318 i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data);
6319 }
6320 else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0)
6321 {
6322 i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data);
6323 }
6324 else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0)
6325 {
6326 ++i;
6327 out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk));
6328 ++i;
6329 }
6330 else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0)
6331 {
6332 i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, out_data);
6333 }
6334 else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0)
6335 {
6336 i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_data->extras);
6337 }
6338 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
6339 {
6340 ++i;
6341
6342 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
6343 if(out_data->data_extensions)
6344 {
6345 return CGLTF_ERROR_JSON;
6346 }
6347
6348 int extensions_size = tokens[i].size;
6349 out_data->data_extensions_count = 0;
6350 out_data->data_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
6351
6352 if (!out_data->data_extensions)
6353 {
6354 return CGLTF_ERROR_NOMEM;
6355 }
6356
6357 ++i;
6358
6359 for (int k = 0; k < extensions_size; ++k)
6360 {
6361 CGLTF_CHECK_KEY(tokens[i]);
6362
6363 if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
6364 {
6365 ++i;
6366
6367 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
6368
6369 int data_size = tokens[i].size;
6370 ++i;
6371
6372 for (int m = 0; m < data_size; ++m)
6373 {
6374 CGLTF_CHECK_KEY(tokens[i]);
6375
6376 if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0)
6377 {
6378 i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, out_data);
6379 }
6380 else
6381 {
6382 i = cgltf_skip_json(tokens, i + 1);
6383 }
6384
6385 if (i < 0)
6386 {
6387 return i;
6388 }
6389 }
6390 }
6391 else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
6392 {
6393 ++i;
6394
6395 CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
6396
6397 int data_size = tokens[i].size;
6398 ++i;
6399
6400 for (int m = 0; m < data_size; ++m)
6401 {
6402 CGLTF_CHECK_KEY(tokens[i]);
6403
6404 if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
6405 {
6406 i = cgltf_parse_json_variants(options, tokens, i + 1, json_chunk, out_data);
6407 }
6408 else
6409 {
6410 i = cgltf_skip_json(tokens, i + 1);
6411 }
6412
6413 if (i < 0)
6414 {
6415 return i;
6416 }
6417 }
6418 }
6419 else
6420 {
6421 i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_data->data_extensions[out_data->data_extensions_count++]));
6422 }
6423
6424 if (i < 0)
6425 {
6426 return i;
6427 }
6428 }
6429 }
6430 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsUsed") == 0)
6431 {
6432 i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_used, &out_data->extensions_used_count);
6433 }
6434 else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsRequired") == 0)
6435 {
6436 i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_required, &out_data->extensions_required_count);
6437 }
6438 else
6439 {
6440 i = cgltf_skip_json(tokens, i + 1);
6441 }
6442
6443 if (i < 0)
6444 {
6445 return i;
6446 }
6447 }
6448
6449 return i;
6450}
6451
6452cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data)
6453{
6454 jsmn_parser parser = { 0, 0, 0 };
6455
6456 if (options->json_token_count == 0)
6457 {
6458 int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, NULL, 0);
6459
6460 if (token_count <= 0)
6461 {
6462 return cgltf_result_invalid_json;
6463 }
6464
6465 options->json_token_count = token_count;
6466 }
6467
6468 jsmntok_t* tokens = (jsmntok_t*)options->memory.alloc_func(options->memory.user_data, sizeof(jsmntok_t) * (options->json_token_count + 1));
6469
6470 if (!tokens)
6471 {
6472 return cgltf_result_out_of_memory;
6473 }
6474
6475 jsmn_init(&parser);
6476
6477 int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, tokens, options->json_token_count);
6478
6479 if (token_count <= 0)
6480 {
6481 options->memory.free_func(options->memory.user_data, tokens);
6482 return cgltf_result_invalid_json;
6483 }
6484
6485 // this makes sure that we always have an UNDEFINED token at the end of the stream
6486 // for invalid JSON inputs this makes sure we don't perform out of bound reads of token data
6487 tokens[token_count].type = JSMN_UNDEFINED;
6488
6489 cgltf_data* data = (cgltf_data*)options->memory.alloc_func(options->memory.user_data, sizeof(cgltf_data));
6490
6491 if (!data)
6492 {
6493 options->memory.free_func(options->memory.user_data, tokens);
6494 return cgltf_result_out_of_memory;
6495 }
6496
6497 memset(data, 0, sizeof(cgltf_data));
6498 data->memory = options->memory;
6499 data->file = options->file;
6500
6501 int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data);
6502
6503 options->memory.free_func(options->memory.user_data, tokens);
6504
6505 if (i < 0)
6506 {
6507 cgltf_free(data);
6508
6509 switch (i)
6510 {
6511 case CGLTF_ERROR_NOMEM: return cgltf_result_out_of_memory;
6512 case CGLTF_ERROR_LEGACY: return cgltf_result_legacy_gltf;
6513 default: return cgltf_result_invalid_gltf;
6514 }
6515 }
6516
6517 if (cgltf_fixup_pointers(data) < 0)
6518 {
6519 cgltf_free(data);
6520 return cgltf_result_invalid_gltf;
6521 }
6522
6523 data->json = (const char*)json_chunk;
6524 data->json_size = size;
6525
6526 *out_data = data;
6527
6528 return cgltf_result_success;
6529}
6530
6531static int cgltf_fixup_pointers(cgltf_data* data)
6532{
6533 for (cgltf_size i = 0; i < data->meshes_count; ++i)
6534 {
6535 for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
6536 {
6537 CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, data->accessors_count);
6538 CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, data->materials_count);
6539
6540 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
6541 {
6542 CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, data->accessors, data->accessors_count);
6543 }
6544
6545 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
6546 {
6547 for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
6548 {
6549 CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].targets[k].attributes[m].data, data->accessors, data->accessors_count);
6550 }
6551 }
6552
6553 if (data->meshes[i].primitives[j].has_draco_mesh_compression)
6554 {
6555 CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.buffer_view, data->buffer_views, data->buffer_views_count);
6556 for (cgltf_size m = 0; m < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++m)
6557 {
6558 CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.attributes[m].data, data->accessors, data->accessors_count);
6559 }
6560 }
6561
6562 for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
6563 {
6564 CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].mappings[k].material, data->materials, data->materials_count);
6565 }
6566 }
6567 }
6568
6569 for (cgltf_size i = 0; i < data->accessors_count; ++i)
6570 {
6571 CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, data->buffer_views_count);
6572
6573 if (data->accessors[i].is_sparse)
6574 {
6575 CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, data->buffer_views, data->buffer_views_count);
6576 CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, data->buffer_views, data->buffer_views_count);
6577 }
6578
6579 if (data->accessors[i].buffer_view)
6580 {
6581 data->accessors[i].stride = data->accessors[i].buffer_view->stride;
6582 }
6583
6584 if (data->accessors[i].stride == 0)
6585 {
6586 data->accessors[i].stride = cgltf_calc_size(data->accessors[i].type, data->accessors[i].component_type);
6587 }
6588 }
6589
6590 for (cgltf_size i = 0; i < data->textures_count; ++i)
6591 {
6592 CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count);
6593 CGLTF_PTRFIXUP(data->textures[i].basisu_image, data->images, data->images_count);
6594 CGLTF_PTRFIXUP(data->textures[i].webp_image, data->images, data->images_count);
6595 CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count);
6596 }
6597
6598 for (cgltf_size i = 0; i < data->images_count; ++i)
6599 {
6600 CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, data->buffer_views_count);
6601 }
6602
6603 for (cgltf_size i = 0; i < data->materials_count; ++i)
6604 {
6605 CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, data->textures_count);
6606 CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, data->textures_count);
6607 CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, data->textures_count);
6608
6609 CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.base_color_texture.texture, data->textures, data->textures_count);
6610 CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture, data->textures, data->textures_count);
6611
6612 CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, data->textures, data->textures_count);
6613 CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture, data->textures, data->textures_count);
6614
6615 CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_texture.texture, data->textures, data->textures_count);
6616 CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_roughness_texture.texture, data->textures, data->textures_count);
6617 CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_normal_texture.texture, data->textures, data->textures_count);
6618
6619 CGLTF_PTRFIXUP(data->materials[i].specular.specular_texture.texture, data->textures, data->textures_count);
6620 CGLTF_PTRFIXUP(data->materials[i].specular.specular_color_texture.texture, data->textures, data->textures_count);
6621
6622 CGLTF_PTRFIXUP(data->materials[i].transmission.transmission_texture.texture, data->textures, data->textures_count);
6623
6624 CGLTF_PTRFIXUP(data->materials[i].volume.thickness_texture.texture, data->textures, data->textures_count);
6625
6626 CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, data->textures, data->textures_count);
6627 CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, data->textures, data->textures_count);
6628
6629 CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_texture.texture, data->textures, data->textures_count);
6630 CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_thickness_texture.texture, data->textures, data->textures_count);
6631
6632 CGLTF_PTRFIXUP(data->materials[i].anisotropy.anisotropy_texture.texture, data->textures, data->textures_count);
6633 }
6634
6635 for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
6636 {
6637 CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, data->buffers_count);
6638
6639 if (data->buffer_views[i].has_meshopt_compression)
6640 {
6641 CGLTF_PTRFIXUP_REQ(data->buffer_views[i].meshopt_compression.buffer, data->buffers, data->buffers_count);
6642 }
6643 }
6644
6645 for (cgltf_size i = 0; i < data->skins_count; ++i)
6646 {
6647 for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j)
6648 {
6649 CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, data->nodes_count);
6650 }
6651
6652 CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count);
6653 CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, data->accessors_count);
6654 }
6655
6656 for (cgltf_size i = 0; i < data->nodes_count; ++i)
6657 {
6658 for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j)
6659 {
6660 CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, data->nodes_count);
6661
6662 if (data->nodes[i].children[j]->parent)
6663 {
6664 return CGLTF_ERROR_JSON;
6665 }
6666
6667 data->nodes[i].children[j]->parent = &data->nodes[i];
6668 }
6669
6670 CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count);
6671 CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count);
6672 CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count);
6673 CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count);
6674
6675 if (data->nodes[i].has_mesh_gpu_instancing)
6676 {
6677 for (cgltf_size m = 0; m < data->nodes[i].mesh_gpu_instancing.attributes_count; ++m)
6678 {
6679 CGLTF_PTRFIXUP_REQ(data->nodes[i].mesh_gpu_instancing.attributes[m].data, data->accessors, data->accessors_count);
6680 }
6681 }
6682 }
6683
6684 for (cgltf_size i = 0; i < data->scenes_count; ++i)
6685 {
6686 for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
6687 {
6688 CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, data->nodes_count);
6689
6690 if (data->scenes[i].nodes[j]->parent)
6691 {
6692 return CGLTF_ERROR_JSON;
6693 }
6694 }
6695 }
6696
6697 CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count);
6698
6699 for (cgltf_size i = 0; i < data->animations_count; ++i)
6700 {
6701 for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
6702 {
6703 CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, data->accessors_count);
6704 CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, data->accessors, data->accessors_count);
6705 }
6706
6707 for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
6708 {
6709 CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, data->animations[i].samplers, data->animations[i].samplers_count);
6710 CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, data->nodes_count);
6711 }
6712 }
6713
6714 return 0;
6715}
6716
6717/*
6718 * -- jsmn.c start --
6719 * Source: https://github.com/zserge/jsmn
6720 * License: MIT
6721 *
6722 * Copyright (c) 2010 Serge A. Zaitsev
6723
6724 * Permission is hereby granted, free of charge, to any person obtaining a copy
6725 * of this software and associated documentation files (the "Software"), to deal
6726 * in the Software without restriction, including without limitation the rights
6727 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6728 * copies of the Software, and to permit persons to whom the Software is
6729 * furnished to do so, subject to the following conditions:
6730
6731 * The above copyright notice and this permission notice shall be included in
6732 * all copies or substantial portions of the Software.
6733
6734 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6735 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6736 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6737 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6738 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6739 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6740 * THE SOFTWARE.
6741 */
6742
6743/**
6744 * Allocates a fresh unused token from the token pull.
6745 */
6746static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
6747 jsmntok_t *tokens, size_t num_tokens) {
6748 jsmntok_t *tok;
6749 if (parser->toknext >= num_tokens) {
6750 return NULL;
6751 }
6752 tok = &tokens[parser->toknext++];
6753 tok->start = tok->end = -1;
6754 tok->size = 0;
6755#ifdef JSMN_PARENT_LINKS
6756 tok->parent = -1;
6757#endif
6758 return tok;
6759}
6760
6761/**
6762 * Fills token type and boundaries.
6763 */
6764static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
6765 ptrdiff_t start, ptrdiff_t end) {
6766 token->type = type;
6767 token->start = start;
6768 token->end = end;
6769 token->size = 0;
6770}
6771
6772/**
6773 * Fills next available token with JSON primitive.
6774 */
6775static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
6776 size_t len, jsmntok_t *tokens, size_t num_tokens) {
6777 jsmntok_t *token;
6778 ptrdiff_t start;
6779
6780 start = parser->pos;
6781
6782 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
6783 switch (js[parser->pos]) {
6784#ifndef JSMN_STRICT
6785 /* In strict mode primitive must be followed by "," or "}" or "]" */
6786 case ':':
6787#endif
6788 case '\t' : case '\r' : case '\n' : case ' ' :
6789 case ',' : case ']' : case '}' :
6790 goto found;
6791 }
6792 if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
6793 parser->pos = start;
6794 return JSMN_ERROR_INVAL;
6795 }
6796 }
6797#ifdef JSMN_STRICT
6798 /* In strict mode primitive must be followed by a comma/object/array */
6799 parser->pos = start;
6800 return JSMN_ERROR_PART;
6801#endif
6802
6803found:
6804 if (tokens == NULL) {
6805 parser->pos--;
6806 return 0;
6807 }
6808 token = jsmn_alloc_token(parser, tokens, num_tokens);
6809 if (token == NULL) {
6810 parser->pos = start;
6811 return JSMN_ERROR_NOMEM;
6812 }
6813 jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
6814#ifdef JSMN_PARENT_LINKS
6815 token->parent = parser->toksuper;
6816#endif
6817 parser->pos--;
6818 return 0;
6819}
6820
6821/**
6822 * Fills next token with JSON string.
6823 */
6824static int jsmn_parse_string(jsmn_parser *parser, const char *js,
6825 size_t len, jsmntok_t *tokens, size_t num_tokens) {
6826 jsmntok_t *token;
6827
6828 ptrdiff_t start = parser->pos;
6829
6830 parser->pos++;
6831
6832 /* Skip starting quote */
6833 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
6834 char c = js[parser->pos];
6835
6836 /* Quote: end of string */
6837 if (c == '\"') {
6838 if (tokens == NULL) {
6839 return 0;
6840 }
6841 token = jsmn_alloc_token(parser, tokens, num_tokens);
6842 if (token == NULL) {
6843 parser->pos = start;
6844 return JSMN_ERROR_NOMEM;
6845 }
6846 jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
6847#ifdef JSMN_PARENT_LINKS
6848 token->parent = parser->toksuper;
6849#endif
6850 return 0;
6851 }
6852
6853 /* Backslash: Quoted symbol expected */
6854 if (c == '\\' && parser->pos + 1 < len) {
6855 int i;
6856 parser->pos++;
6857 switch (js[parser->pos]) {
6858 /* Allowed escaped symbols */
6859 case '\"': case '/' : case '\\' : case 'b' :
6860 case 'f' : case 'r' : case 'n' : case 't' :
6861 break;
6862 /* Allows escaped symbol \uXXXX */
6863 case 'u':
6864 parser->pos++;
6865 for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
6866 /* If it isn't a hex character we have an error */
6867 if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
6868 (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
6869 (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
6870 parser->pos = start;
6871 return JSMN_ERROR_INVAL;
6872 }
6873 parser->pos++;
6874 }
6875 parser->pos--;
6876 break;
6877 /* Unexpected symbol */
6878 default:
6879 parser->pos = start;
6880 return JSMN_ERROR_INVAL;
6881 }
6882 }
6883 }
6884 parser->pos = start;
6885 return JSMN_ERROR_PART;
6886}
6887
6888/**
6889 * Parse JSON string and fill tokens.
6890 */
6891static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
6892 jsmntok_t *tokens, size_t num_tokens) {
6893 int r;
6894 int i;
6895 jsmntok_t *token;
6896 int count = parser->toknext;
6897
6898 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
6899 char c;
6900 jsmntype_t type;
6901
6902 c = js[parser->pos];
6903 switch (c) {
6904 case '{': case '[':
6905 count++;
6906 if (tokens == NULL) {
6907 break;
6908 }
6909 token = jsmn_alloc_token(parser, tokens, num_tokens);
6910 if (token == NULL)
6911 return JSMN_ERROR_NOMEM;
6912 if (parser->toksuper != -1) {
6913 tokens[parser->toksuper].size++;
6914#ifdef JSMN_PARENT_LINKS
6915 token->parent = parser->toksuper;
6916#endif
6917 }
6918 token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
6919 token->start = parser->pos;
6920 parser->toksuper = parser->toknext - 1;
6921 break;
6922 case '}': case ']':
6923 if (tokens == NULL)
6924 break;
6925 type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
6926#ifdef JSMN_PARENT_LINKS
6927 if (parser->toknext < 1) {
6928 return JSMN_ERROR_INVAL;
6929 }
6930 token = &tokens[parser->toknext - 1];
6931 for (;;) {
6932 if (token->start != -1 && token->end == -1) {
6933 if (token->type != type) {
6934 return JSMN_ERROR_INVAL;
6935 }
6936 token->end = parser->pos + 1;
6937 parser->toksuper = token->parent;
6938 break;
6939 }
6940 if (token->parent == -1) {
6941 if(token->type != type || parser->toksuper == -1) {
6942 return JSMN_ERROR_INVAL;
6943 }
6944 break;
6945 }
6946 token = &tokens[token->parent];
6947 }
6948#else
6949 for (i = parser->toknext - 1; i >= 0; i--) {
6950 token = &tokens[i];
6951 if (token->start != -1 && token->end == -1) {
6952 if (token->type != type) {
6953 return JSMN_ERROR_INVAL;
6954 }
6955 parser->toksuper = -1;
6956 token->end = parser->pos + 1;
6957 break;
6958 }
6959 }
6960 /* Error if unmatched closing bracket */
6961 if (i == -1) return JSMN_ERROR_INVAL;
6962 for (; i >= 0; i--) {
6963 token = &tokens[i];
6964 if (token->start != -1 && token->end == -1) {
6965 parser->toksuper = i;
6966 break;
6967 }
6968 }
6969#endif
6970 break;
6971 case '\"':
6972 r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
6973 if (r < 0) return r;
6974 count++;
6975 if (parser->toksuper != -1 && tokens != NULL)
6976 tokens[parser->toksuper].size++;
6977 break;
6978 case '\t' : case '\r' : case '\n' : case ' ':
6979 break;
6980 case ':':
6981 parser->toksuper = parser->toknext - 1;
6982 break;
6983 case ',':
6984 if (tokens != NULL && parser->toksuper != -1 &&
6985 tokens[parser->toksuper].type != JSMN_ARRAY &&
6986 tokens[parser->toksuper].type != JSMN_OBJECT) {
6987#ifdef JSMN_PARENT_LINKS
6988 parser->toksuper = tokens[parser->toksuper].parent;
6989#else
6990 for (i = parser->toknext - 1; i >= 0; i--) {
6991 if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
6992 if (tokens[i].start != -1 && tokens[i].end == -1) {
6993 parser->toksuper = i;
6994 break;
6995 }
6996 }
6997 }
6998#endif
6999 }
7000 break;
7001#ifdef JSMN_STRICT
7002 /* In strict mode primitives are: numbers and booleans */
7003 case '-': case '0': case '1' : case '2': case '3' : case '4':
7004 case '5': case '6': case '7' : case '8': case '9':
7005 case 't': case 'f': case 'n' :
7006 /* And they must not be keys of the object */
7007 if (tokens != NULL && parser->toksuper != -1) {
7008 jsmntok_t *t = &tokens[parser->toksuper];
7009 if (t->type == JSMN_OBJECT ||
7010 (t->type == JSMN_STRING && t->size != 0)) {
7011 return JSMN_ERROR_INVAL;
7012 }
7013 }
7014#else
7015 /* In non-strict mode every unquoted value is a primitive */
7016 default:
7017#endif
7018 r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
7019 if (r < 0) return r;
7020 count++;
7021 if (parser->toksuper != -1 && tokens != NULL)
7022 tokens[parser->toksuper].size++;
7023 break;
7024
7025#ifdef JSMN_STRICT
7026 /* Unexpected char in strict mode */
7027 default:
7028 return JSMN_ERROR_INVAL;
7029#endif
7030 }
7031 }
7032
7033 if (tokens != NULL) {
7034 for (i = parser->toknext - 1; i >= 0; i--) {
7035 /* Unmatched opened object or array */
7036 if (tokens[i].start != -1 && tokens[i].end == -1) {
7037 return JSMN_ERROR_PART;
7038 }
7039 }
7040 }
7041
7042 return count;
7043}
7044
7045/**
7046 * Creates a new parser based over a given buffer with an array of tokens
7047 * available.
7048 */
7049static void jsmn_init(jsmn_parser *parser) {
7050 parser->pos = 0;
7051 parser->toknext = 0;
7052 parser->toksuper = -1;
7053}
7054/*
7055 * -- jsmn.c end --
7056 */
7057
7058#endif /* #ifdef CGLTF_IMPLEMENTATION */
7059
7060/* cgltf is distributed under MIT license:
7061 *
7062 * Copyright (c) 2018-2021 Johannes Kuhlmann
7063
7064 * Permission is hereby granted, free of charge, to any person obtaining a copy
7065 * of this software and associated documentation files (the "Software"), to deal
7066 * in the Software without restriction, including without limitation the rights
7067 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7068 * copies of the Software, and to permit persons to whom the Software is
7069 * furnished to do so, subject to the following conditions:
7070
7071 * The above copyright notice and this permission notice shall be included in all
7072 * copies or substantial portions of the Software.
7073
7074 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7075 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7076 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7077 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7078 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7079 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7080 * SOFTWARE.
7081 */
diff --git a/raylib/src/external/dirent.h b/raylib/src/external/dirent.h
new file mode 100644
index 0000000..c611376
--- /dev/null
+++ b/raylib/src/external/dirent.h
@@ -0,0 +1,183 @@
1/****************************************************************************
2
3 Declaration of POSIX directory browsing functions and types for Win32.
4
5 Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
6 History: Created March 1997. Updated June 2003.
7 Reviewed by Ramon Santamaria for raylib on January 2020.
8
9 Copyright Kevlin Henney, 1997, 2003. All rights reserved.
10
11 Permission to use, copy, modify, and distribute this software and its
12 documentation for any purpose is hereby granted without fee, provided
13 that this copyright and permissions notice appear in all copies and
14 derivatives.
15
16 This software is supplied "as is" without express or implied warranty.
17
18 But that said, if there are any problems please get in touch.
19
20****************************************************************************/
21
22#ifndef DIRENT_H
23#define DIRENT_H
24
25// Allow custom memory allocators
26#ifndef DIRENT_MALLOC
27 #define DIRENT_MALLOC(sz) malloc(sz)
28#endif
29#ifndef DIRENT_FREE
30 #define DIRENT_FREE(p) free(p)
31#endif
32
33//----------------------------------------------------------------------------------
34// Types and Structures Definition
35//----------------------------------------------------------------------------------
36
37// Fordward declaration of DIR, implementation below
38typedef struct DIR DIR;
39
40struct dirent {
41 char *d_name;
42};
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48//------------------------------------------------------------------------------------
49// Functions Declaration
50//------------------------------------------------------------------------------------
51DIR *opendir(const char *name);
52int closedir(DIR *dir);
53struct dirent *readdir(DIR *dir);
54void rewinddir(DIR *dir);
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif // DIRENT_H
61
62/****************************************************************************
63
64 Implementation of POSIX directory browsing functions and types for Win32.
65
66 Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
67 History: Created March 1997. Updated June 2003.
68 Reviewed by Ramon Santamaria for raylib on January 2020.
69
70 Copyright Kevlin Henney, 1997, 2003. All rights reserved.
71
72 Permission to use, copy, modify, and distribute this software and its
73 documentation for any purpose is hereby granted without fee, provided
74 that this copyright and permissions notice appear in all copies and
75 derivatives.
76
77 This software is supplied "as is" without express or implied warranty.
78
79 But that said, if there are any problems please get in touch.
80
81****************************************************************************/
82
83#include <io.h> // _findfirst and _findnext set errno iff they return -1
84#include <stdlib.h>
85#include <string.h>
86#include <errno.h>
87
88//----------------------------------------------------------------------------------
89// Types and Structures Definition
90//----------------------------------------------------------------------------------
91typedef ptrdiff_t handle_type; // C99's intptr_t not sufficiently portable
92
93struct DIR {
94 handle_type handle; // -1 for failed rewind
95 struct _finddata_t info;
96 struct dirent result; // d_name null iff first time
97 char *name; // null-terminated char string
98};
99
100DIR *opendir(const char *name)
101{
102 DIR *dir = 0;
103
104 if (name && name[0])
105 {
106 size_t base_length = strlen(name);
107
108 // Search pattern must end with suitable wildcard
109 const char *all = strchr("/\\", name[base_length - 1]) ? "*" : "/*";
110
111 if ((dir = (DIR *)DIRENT_MALLOC(sizeof *dir)) != 0 &&
112 (dir->name = (char *)DIRENT_MALLOC(base_length + strlen(all) + 1)) != 0)
113 {
114 strcat(strcpy(dir->name, name), all);
115
116 if ((dir->handle = (handle_type) _findfirst(dir->name, &dir->info)) != -1)
117 {
118 dir->result.d_name = 0;
119 }
120 else // rollback
121 {
122 DIRENT_FREE(dir->name);
123 DIRENT_FREE(dir);
124 dir = 0;
125 }
126 }
127 else // rollback
128 {
129 DIRENT_FREE(dir);
130 dir = 0;
131 errno = ENOMEM;
132 }
133 }
134 else errno = EINVAL;
135
136 return dir;
137}
138
139int closedir(DIR *dir)
140{
141 int result = -1;
142
143 if (dir)
144 {
145 if (dir->handle != -1) result = _findclose(dir->handle);
146
147 DIRENT_FREE(dir->name);
148 DIRENT_FREE(dir);
149 }
150
151 // NOTE: All errors ampped to EBADF
152 if (result == -1) errno = EBADF;
153
154 return result;
155}
156
157struct dirent *readdir(DIR *dir)
158{
159 struct dirent *result = 0;
160
161 if (dir && dir->handle != -1)
162 {
163 if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
164 {
165 result = &dir->result;
166 result->d_name = dir->info.name;
167 }
168 }
169 else errno = EBADF;
170
171 return result;
172}
173
174void rewinddir(DIR *dir)
175{
176 if (dir && dir->handle != -1)
177 {
178 _findclose(dir->handle);
179 dir->handle = (handle_type) _findfirst(dir->name, &dir->info);
180 dir->result.d_name = 0;
181 }
182 else errno = EBADF;
183}
diff --git a/raylib/src/external/dr_flac.h b/raylib/src/external/dr_flac.h
new file mode 100644
index 0000000..14324cf
--- /dev/null
+++ b/raylib/src/external/dr_flac.h
@@ -0,0 +1,12536 @@
1/*
2FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
3dr_flac - v0.12.42 - 2023-11-02
4
5David Reid - mackron@gmail.com
6
7GitHub: https://github.com/mackron/dr_libs
8*/
9
10/*
11RELEASE NOTES - v0.12.0
12=======================
13Version 0.12.0 has breaking API changes including changes to the existing API and the removal of deprecated APIs.
14
15
16Improved Client-Defined Memory Allocation
17-----------------------------------------
18The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
19existing system of DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE are still in place and will be used by default when no custom
20allocation callbacks are specified.
21
22To use the new system, you pass in a pointer to a drflac_allocation_callbacks object to drflac_open() and family, like this:
23
24 void* my_malloc(size_t sz, void* pUserData)
25 {
26 return malloc(sz);
27 }
28 void* my_realloc(void* p, size_t sz, void* pUserData)
29 {
30 return realloc(p, sz);
31 }
32 void my_free(void* p, void* pUserData)
33 {
34 free(p);
35 }
36
37 ...
38
39 drflac_allocation_callbacks allocationCallbacks;
40 allocationCallbacks.pUserData = &myData;
41 allocationCallbacks.onMalloc = my_malloc;
42 allocationCallbacks.onRealloc = my_realloc;
43 allocationCallbacks.onFree = my_free;
44 drflac* pFlac = drflac_open_file("my_file.flac", &allocationCallbacks);
45
46The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
47
48Passing in null for the allocation callbacks object will cause dr_flac to use defaults which is the same as DRFLAC_MALLOC,
49DRFLAC_REALLOC and DRFLAC_FREE and the equivalent of how it worked in previous versions.
50
51Every API that opens a drflac object now takes this extra parameter. These include the following:
52
53 drflac_open()
54 drflac_open_relaxed()
55 drflac_open_with_metadata()
56 drflac_open_with_metadata_relaxed()
57 drflac_open_file()
58 drflac_open_file_with_metadata()
59 drflac_open_memory()
60 drflac_open_memory_with_metadata()
61 drflac_open_and_read_pcm_frames_s32()
62 drflac_open_and_read_pcm_frames_s16()
63 drflac_open_and_read_pcm_frames_f32()
64 drflac_open_file_and_read_pcm_frames_s32()
65 drflac_open_file_and_read_pcm_frames_s16()
66 drflac_open_file_and_read_pcm_frames_f32()
67 drflac_open_memory_and_read_pcm_frames_s32()
68 drflac_open_memory_and_read_pcm_frames_s16()
69 drflac_open_memory_and_read_pcm_frames_f32()
70
71
72
73Optimizations
74-------------
75Seeking performance has been greatly improved. A new binary search based seeking algorithm has been introduced which significantly
76improves performance over the brute force method which was used when no seek table was present. Seek table based seeking also takes
77advantage of the new binary search seeking system to further improve performance there as well. Note that this depends on CRC which
78means it will be disabled when DR_FLAC_NO_CRC is used.
79
80The SSE4.1 pipeline has been cleaned up and optimized. You should see some improvements with decoding speed of 24-bit files in
81particular. 16-bit streams should also see some improvement.
82
83drflac_read_pcm_frames_s16() has been optimized. Previously this sat on top of drflac_read_pcm_frames_s32() and performed it's s32
84to s16 conversion in a second pass. This is now all done in a single pass. This includes SSE2 and ARM NEON optimized paths.
85
86A minor optimization has been implemented for drflac_read_pcm_frames_s32(). This will now use an SSE2 optimized pipeline for stereo
87channel reconstruction which is the last part of the decoding process.
88
89The ARM build has seen a few improvements. The CLZ (count leading zeroes) and REV (byte swap) instructions are now used when
90compiling with GCC and Clang which is achieved using inline assembly. The CLZ instruction requires ARM architecture version 5 at
91compile time and the REV instruction requires ARM architecture version 6.
92
93An ARM NEON optimized pipeline has been implemented. To enable this you'll need to add -mfpu=neon to the command line when compiling.
94
95
96Removed APIs
97------------
98The following APIs were deprecated in version 0.11.0 and have been completely removed in version 0.12.0:
99
100 drflac_read_s32() -> drflac_read_pcm_frames_s32()
101 drflac_read_s16() -> drflac_read_pcm_frames_s16()
102 drflac_read_f32() -> drflac_read_pcm_frames_f32()
103 drflac_seek_to_sample() -> drflac_seek_to_pcm_frame()
104 drflac_open_and_decode_s32() -> drflac_open_and_read_pcm_frames_s32()
105 drflac_open_and_decode_s16() -> drflac_open_and_read_pcm_frames_s16()
106 drflac_open_and_decode_f32() -> drflac_open_and_read_pcm_frames_f32()
107 drflac_open_and_decode_file_s32() -> drflac_open_file_and_read_pcm_frames_s32()
108 drflac_open_and_decode_file_s16() -> drflac_open_file_and_read_pcm_frames_s16()
109 drflac_open_and_decode_file_f32() -> drflac_open_file_and_read_pcm_frames_f32()
110 drflac_open_and_decode_memory_s32() -> drflac_open_memory_and_read_pcm_frames_s32()
111 drflac_open_and_decode_memory_s16() -> drflac_open_memory_and_read_pcm_frames_s16()
112 drflac_open_and_decode_memory_f32() -> drflac_open_memroy_and_read_pcm_frames_f32()
113
114Prior versions of dr_flac operated on a per-sample basis whereas now it operates on PCM frames. The removed APIs all relate
115to the old per-sample APIs. You now need to use the "pcm_frame" versions.
116*/
117
118
119/*
120Introduction
121============
122dr_flac is a single file library. To use it, do something like the following in one .c file.
123
124 ```c
125 #define DR_FLAC_IMPLEMENTATION
126 #include "dr_flac.h"
127 ```
128
129You can then #include this file in other parts of the program as you would with any other header file. To decode audio data, do something like the following:
130
131 ```c
132 drflac* pFlac = drflac_open_file("MySong.flac", NULL);
133 if (pFlac == NULL) {
134 // Failed to open FLAC file
135 }
136
137 drflac_int32* pSamples = malloc(pFlac->totalPCMFrameCount * pFlac->channels * sizeof(drflac_int32));
138 drflac_uint64 numberOfInterleavedSamplesActuallyRead = drflac_read_pcm_frames_s32(pFlac, pFlac->totalPCMFrameCount, pSamples);
139 ```
140
141The drflac object represents the decoder. It is a transparent type so all the information you need, such as the number of channels and the bits per sample,
142should be directly accessible - just make sure you don't change their values. Samples are always output as interleaved signed 32-bit PCM. In the example above
143a native FLAC stream was opened, however dr_flac has seamless support for Ogg encapsulated FLAC streams as well.
144
145You do not need to decode the entire stream in one go - you just specify how many samples you'd like at any given time and the decoder will give you as many
146samples as it can, up to the amount requested. Later on when you need the next batch of samples, just call it again. Example:
147
148 ```c
149 while (drflac_read_pcm_frames_s32(pFlac, chunkSizeInPCMFrames, pChunkSamples) > 0) {
150 do_something();
151 }
152 ```
153
154You can seek to a specific PCM frame with `drflac_seek_to_pcm_frame()`.
155
156If you just want to quickly decode an entire FLAC file in one go you can do something like this:
157
158 ```c
159 unsigned int channels;
160 unsigned int sampleRate;
161 drflac_uint64 totalPCMFrameCount;
162 drflac_int32* pSampleData = drflac_open_file_and_read_pcm_frames_s32("MySong.flac", &channels, &sampleRate, &totalPCMFrameCount, NULL);
163 if (pSampleData == NULL) {
164 // Failed to open and decode FLAC file.
165 }
166
167 ...
168
169 drflac_free(pSampleData, NULL);
170 ```
171
172You can read samples as signed 16-bit integer and 32-bit floating-point PCM with the *_s16() and *_f32() family of APIs respectively, but note that these
173should be considered lossy.
174
175
176If you need access to metadata (album art, etc.), use `drflac_open_with_metadata()`, `drflac_open_file_with_metdata()` or `drflac_open_memory_with_metadata()`.
177The rationale for keeping these APIs separate is that they're slightly slower than the normal versions and also just a little bit harder to use. dr_flac
178reports metadata to the application through the use of a callback, and every metadata block is reported before `drflac_open_with_metdata()` returns.
179
180The main opening APIs (`drflac_open()`, etc.) will fail if the header is not present. The presents a problem in certain scenarios such as broadcast style
181streams or internet radio where the header may not be present because the user has started playback mid-stream. To handle this, use the relaxed APIs:
182
183 `drflac_open_relaxed()`
184 `drflac_open_with_metadata_relaxed()`
185
186It is not recommended to use these APIs for file based streams because a missing header would usually indicate a corrupt or perverse file. In addition, these
187APIs can take a long time to initialize because they may need to spend a lot of time finding the first frame.
188
189
190
191Build Options
192=============
193#define these options before including this file.
194
195#define DR_FLAC_NO_STDIO
196 Disable `drflac_open_file()` and family.
197
198#define DR_FLAC_NO_OGG
199 Disables support for Ogg/FLAC streams.
200
201#define DR_FLAC_BUFFER_SIZE <number>
202 Defines the size of the internal buffer to store data from onRead(). This buffer is used to reduce the number of calls back to the client for more data.
203 Larger values means more memory, but better performance. My tests show diminishing returns after about 4KB (which is the default). Consider reducing this if
204 you have a very efficient implementation of onRead(), or increase it if it's very inefficient. Must be a multiple of 8.
205
206#define DR_FLAC_NO_CRC
207 Disables CRC checks. This will offer a performance boost when CRC is unnecessary. This will disable binary search seeking. When seeking, the seek table will
208 be used if available. Otherwise the seek will be performed using brute force.
209
210#define DR_FLAC_NO_SIMD
211 Disables SIMD optimizations (SSE on x86/x64 architectures, NEON on ARM architectures). Use this if you are having compatibility issues with your compiler.
212
213#define DR_FLAC_NO_WCHAR
214 Disables all functions ending with `_w`. Use this if your compiler does not provide wchar.h. Not required if DR_FLAC_NO_STDIO is also defined.
215
216
217
218Notes
219=====
220- dr_flac does not support changing the sample rate nor channel count mid stream.
221- dr_flac is not thread-safe, but its APIs can be called from any thread so long as you do your own synchronization.
222- When using Ogg encapsulation, a corrupted metadata block will result in `drflac_open_with_metadata()` and `drflac_open()` returning inconsistent samples due
223 to differences in corrupted stream recorvery logic between the two APIs.
224*/
225
226#ifndef dr_flac_h
227#define dr_flac_h
228
229#ifdef __cplusplus
230extern "C" {
231#endif
232
233#define DRFLAC_STRINGIFY(x) #x
234#define DRFLAC_XSTRINGIFY(x) DRFLAC_STRINGIFY(x)
235
236#define DRFLAC_VERSION_MAJOR 0
237#define DRFLAC_VERSION_MINOR 12
238#define DRFLAC_VERSION_REVISION 42
239#define DRFLAC_VERSION_STRING DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
240
241#include <stddef.h> /* For size_t. */
242
243/* Sized Types */
244typedef signed char drflac_int8;
245typedef unsigned char drflac_uint8;
246typedef signed short drflac_int16;
247typedef unsigned short drflac_uint16;
248typedef signed int drflac_int32;
249typedef unsigned int drflac_uint32;
250#if defined(_MSC_VER) && !defined(__clang__)
251 typedef signed __int64 drflac_int64;
252 typedef unsigned __int64 drflac_uint64;
253#else
254 #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
255 #pragma GCC diagnostic push
256 #pragma GCC diagnostic ignored "-Wlong-long"
257 #if defined(__clang__)
258 #pragma GCC diagnostic ignored "-Wc++11-long-long"
259 #endif
260 #endif
261 typedef signed long long drflac_int64;
262 typedef unsigned long long drflac_uint64;
263 #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
264 #pragma GCC diagnostic pop
265 #endif
266#endif
267#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__)
268 typedef drflac_uint64 drflac_uintptr;
269#else
270 typedef drflac_uint32 drflac_uintptr;
271#endif
272typedef drflac_uint8 drflac_bool8;
273typedef drflac_uint32 drflac_bool32;
274#define DRFLAC_TRUE 1
275#define DRFLAC_FALSE 0
276/* End Sized Types */
277
278/* Decorations */
279#if !defined(DRFLAC_API)
280 #if defined(DRFLAC_DLL)
281 #if defined(_WIN32)
282 #define DRFLAC_DLL_IMPORT __declspec(dllimport)
283 #define DRFLAC_DLL_EXPORT __declspec(dllexport)
284 #define DRFLAC_DLL_PRIVATE static
285 #else
286 #if defined(__GNUC__) && __GNUC__ >= 4
287 #define DRFLAC_DLL_IMPORT __attribute__((visibility("default")))
288 #define DRFLAC_DLL_EXPORT __attribute__((visibility("default")))
289 #define DRFLAC_DLL_PRIVATE __attribute__((visibility("hidden")))
290 #else
291 #define DRFLAC_DLL_IMPORT
292 #define DRFLAC_DLL_EXPORT
293 #define DRFLAC_DLL_PRIVATE static
294 #endif
295 #endif
296
297 #if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
298 #define DRFLAC_API DRFLAC_DLL_EXPORT
299 #else
300 #define DRFLAC_API DRFLAC_DLL_IMPORT
301 #endif
302 #define DRFLAC_PRIVATE DRFLAC_DLL_PRIVATE
303 #else
304 #define DRFLAC_API extern
305 #define DRFLAC_PRIVATE static
306 #endif
307#endif
308/* End Decorations */
309
310#if defined(_MSC_VER) && _MSC_VER >= 1700 /* Visual Studio 2012 */
311 #define DRFLAC_DEPRECATED __declspec(deprecated)
312#elif (defined(__GNUC__) && __GNUC__ >= 4) /* GCC 4 */
313 #define DRFLAC_DEPRECATED __attribute__((deprecated))
314#elif defined(__has_feature) /* Clang */
315 #if __has_feature(attribute_deprecated)
316 #define DRFLAC_DEPRECATED __attribute__((deprecated))
317 #else
318 #define DRFLAC_DEPRECATED
319 #endif
320#else
321 #define DRFLAC_DEPRECATED
322#endif
323
324DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision);
325DRFLAC_API const char* drflac_version_string(void);
326
327/* Allocation Callbacks */
328typedef struct
329{
330 void* pUserData;
331 void* (* onMalloc)(size_t sz, void* pUserData);
332 void* (* onRealloc)(void* p, size_t sz, void* pUserData);
333 void (* onFree)(void* p, void* pUserData);
334} drflac_allocation_callbacks;
335/* End Allocation Callbacks */
336
337/*
338As data is read from the client it is placed into an internal buffer for fast access. This controls the size of that buffer. Larger values means more speed,
339but also more memory. In my testing there is diminishing returns after about 4KB, but you can fiddle with this to suit your own needs. Must be a multiple of 8.
340*/
341#ifndef DR_FLAC_BUFFER_SIZE
342#define DR_FLAC_BUFFER_SIZE 4096
343#endif
344
345
346/* Architecture Detection */
347#if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
348#define DRFLAC_64BIT
349#endif
350
351#if defined(__x86_64__) || defined(_M_X64)
352 #define DRFLAC_X64
353#elif defined(__i386) || defined(_M_IX86)
354 #define DRFLAC_X86
355#elif defined(__arm__) || defined(_M_ARM) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
356 #define DRFLAC_ARM
357#endif
358/* End Architecture Detection */
359
360
361#ifdef DRFLAC_64BIT
362typedef drflac_uint64 drflac_cache_t;
363#else
364typedef drflac_uint32 drflac_cache_t;
365#endif
366
367/* The various metadata block types. */
368#define DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO 0
369#define DRFLAC_METADATA_BLOCK_TYPE_PADDING 1
370#define DRFLAC_METADATA_BLOCK_TYPE_APPLICATION 2
371#define DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE 3
372#define DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT 4
373#define DRFLAC_METADATA_BLOCK_TYPE_CUESHEET 5
374#define DRFLAC_METADATA_BLOCK_TYPE_PICTURE 6
375#define DRFLAC_METADATA_BLOCK_TYPE_INVALID 127
376
377/* The various picture types specified in the PICTURE block. */
378#define DRFLAC_PICTURE_TYPE_OTHER 0
379#define DRFLAC_PICTURE_TYPE_FILE_ICON 1
380#define DRFLAC_PICTURE_TYPE_OTHER_FILE_ICON 2
381#define DRFLAC_PICTURE_TYPE_COVER_FRONT 3
382#define DRFLAC_PICTURE_TYPE_COVER_BACK 4
383#define DRFLAC_PICTURE_TYPE_LEAFLET_PAGE 5
384#define DRFLAC_PICTURE_TYPE_MEDIA 6
385#define DRFLAC_PICTURE_TYPE_LEAD_ARTIST 7
386#define DRFLAC_PICTURE_TYPE_ARTIST 8
387#define DRFLAC_PICTURE_TYPE_CONDUCTOR 9
388#define DRFLAC_PICTURE_TYPE_BAND 10
389#define DRFLAC_PICTURE_TYPE_COMPOSER 11
390#define DRFLAC_PICTURE_TYPE_LYRICIST 12
391#define DRFLAC_PICTURE_TYPE_RECORDING_LOCATION 13
392#define DRFLAC_PICTURE_TYPE_DURING_RECORDING 14
393#define DRFLAC_PICTURE_TYPE_DURING_PERFORMANCE 15
394#define DRFLAC_PICTURE_TYPE_SCREEN_CAPTURE 16
395#define DRFLAC_PICTURE_TYPE_BRIGHT_COLORED_FISH 17
396#define DRFLAC_PICTURE_TYPE_ILLUSTRATION 18
397#define DRFLAC_PICTURE_TYPE_BAND_LOGOTYPE 19
398#define DRFLAC_PICTURE_TYPE_PUBLISHER_LOGOTYPE 20
399
400typedef enum
401{
402 drflac_container_native,
403 drflac_container_ogg,
404 drflac_container_unknown
405} drflac_container;
406
407typedef enum
408{
409 drflac_seek_origin_start,
410 drflac_seek_origin_current
411} drflac_seek_origin;
412
413/* The order of members in this structure is important because we map this directly to the raw data within the SEEKTABLE metadata block. */
414typedef struct
415{
416 drflac_uint64 firstPCMFrame;
417 drflac_uint64 flacFrameOffset; /* The offset from the first byte of the header of the first frame. */
418 drflac_uint16 pcmFrameCount;
419} drflac_seekpoint;
420
421typedef struct
422{
423 drflac_uint16 minBlockSizeInPCMFrames;
424 drflac_uint16 maxBlockSizeInPCMFrames;
425 drflac_uint32 minFrameSizeInPCMFrames;
426 drflac_uint32 maxFrameSizeInPCMFrames;
427 drflac_uint32 sampleRate;
428 drflac_uint8 channels;
429 drflac_uint8 bitsPerSample;
430 drflac_uint64 totalPCMFrameCount;
431 drflac_uint8 md5[16];
432} drflac_streaminfo;
433
434typedef struct
435{
436 /*
437 The metadata type. Use this to know how to interpret the data below. Will be set to one of the
438 DRFLAC_METADATA_BLOCK_TYPE_* tokens.
439 */
440 drflac_uint32 type;
441
442 /*
443 A pointer to the raw data. This points to a temporary buffer so don't hold on to it. It's best to
444 not modify the contents of this buffer. Use the structures below for more meaningful and structured
445 information about the metadata. It's possible for this to be null.
446 */
447 const void* pRawData;
448
449 /* The size in bytes of the block and the buffer pointed to by pRawData if it's non-NULL. */
450 drflac_uint32 rawDataSize;
451
452 union
453 {
454 drflac_streaminfo streaminfo;
455
456 struct
457 {
458 int unused;
459 } padding;
460
461 struct
462 {
463 drflac_uint32 id;
464 const void* pData;
465 drflac_uint32 dataSize;
466 } application;
467
468 struct
469 {
470 drflac_uint32 seekpointCount;
471 const drflac_seekpoint* pSeekpoints;
472 } seektable;
473
474 struct
475 {
476 drflac_uint32 vendorLength;
477 const char* vendor;
478 drflac_uint32 commentCount;
479 const void* pComments;
480 } vorbis_comment;
481
482 struct
483 {
484 char catalog[128];
485 drflac_uint64 leadInSampleCount;
486 drflac_bool32 isCD;
487 drflac_uint8 trackCount;
488 const void* pTrackData;
489 } cuesheet;
490
491 struct
492 {
493 drflac_uint32 type;
494 drflac_uint32 mimeLength;
495 const char* mime;
496 drflac_uint32 descriptionLength;
497 const char* description;
498 drflac_uint32 width;
499 drflac_uint32 height;
500 drflac_uint32 colorDepth;
501 drflac_uint32 indexColorCount;
502 drflac_uint32 pictureDataSize;
503 const drflac_uint8* pPictureData;
504 } picture;
505 } data;
506} drflac_metadata;
507
508
509/*
510Callback for when data needs to be read from the client.
511
512
513Parameters
514----------
515pUserData (in)
516 The user data that was passed to drflac_open() and family.
517
518pBufferOut (out)
519 The output buffer.
520
521bytesToRead (in)
522 The number of bytes to read.
523
524
525Return Value
526------------
527The number of bytes actually read.
528
529
530Remarks
531-------
532A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until either the entire bytesToRead is filled or
533you have reached the end of the stream.
534*/
535typedef size_t (* drflac_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
536
537/*
538Callback for when data needs to be seeked.
539
540
541Parameters
542----------
543pUserData (in)
544 The user data that was passed to drflac_open() and family.
545
546offset (in)
547 The number of bytes to move, relative to the origin. Will never be negative.
548
549origin (in)
550 The origin of the seek - the current position or the start of the stream.
551
552
553Return Value
554------------
555Whether or not the seek was successful.
556
557
558Remarks
559-------
560The offset will never be negative. Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which will be
561either drflac_seek_origin_start or drflac_seek_origin_current.
562
563When seeking to a PCM frame using drflac_seek_to_pcm_frame(), dr_flac may call this with an offset beyond the end of the FLAC stream. This needs to be detected
564and handled by returning DRFLAC_FALSE.
565*/
566typedef drflac_bool32 (* drflac_seek_proc)(void* pUserData, int offset, drflac_seek_origin origin);
567
568/*
569Callback for when a metadata block is read.
570
571
572Parameters
573----------
574pUserData (in)
575 The user data that was passed to drflac_open() and family.
576
577pMetadata (in)
578 A pointer to a structure containing the data of the metadata block.
579
580
581Remarks
582-------
583Use pMetadata->type to determine which metadata block is being handled and how to read the data. This
584will be set to one of the DRFLAC_METADATA_BLOCK_TYPE_* tokens.
585*/
586typedef void (* drflac_meta_proc)(void* pUserData, drflac_metadata* pMetadata);
587
588
589/* Structure for internal use. Only used for decoders opened with drflac_open_memory. */
590typedef struct
591{
592 const drflac_uint8* data;
593 size_t dataSize;
594 size_t currentReadPos;
595} drflac__memory_stream;
596
597/* Structure for internal use. Used for bit streaming. */
598typedef struct
599{
600 /* The function to call when more data needs to be read. */
601 drflac_read_proc onRead;
602
603 /* The function to call when the current read position needs to be moved. */
604 drflac_seek_proc onSeek;
605
606 /* The user data to pass around to onRead and onSeek. */
607 void* pUserData;
608
609
610 /*
611 The number of unaligned bytes in the L2 cache. This will always be 0 until the end of the stream is hit. At the end of the
612 stream there will be a number of bytes that don't cleanly fit in an L1 cache line, so we use this variable to know whether
613 or not the bistreamer needs to run on a slower path to read those last bytes. This will never be more than sizeof(drflac_cache_t).
614 */
615 size_t unalignedByteCount;
616
617 /* The content of the unaligned bytes. */
618 drflac_cache_t unalignedCache;
619
620 /* The index of the next valid cache line in the "L2" cache. */
621 drflac_uint32 nextL2Line;
622
623 /* The number of bits that have been consumed by the cache. This is used to determine how many valid bits are remaining. */
624 drflac_uint32 consumedBits;
625
626 /*
627 The cached data which was most recently read from the client. There are two levels of cache. Data flows as such:
628 Client -> L2 -> L1. The L2 -> L1 movement is aligned and runs on a fast path in just a few instructions.
629 */
630 drflac_cache_t cacheL2[DR_FLAC_BUFFER_SIZE/sizeof(drflac_cache_t)];
631 drflac_cache_t cache;
632
633 /*
634 CRC-16. This is updated whenever bits are read from the bit stream. Manually set this to 0 to reset the CRC. For FLAC, this
635 is reset to 0 at the beginning of each frame.
636 */
637 drflac_uint16 crc16;
638 drflac_cache_t crc16Cache; /* A cache for optimizing CRC calculations. This is filled when when the L1 cache is reloaded. */
639 drflac_uint32 crc16CacheIgnoredBytes; /* The number of bytes to ignore when updating the CRC-16 from the CRC-16 cache. */
640} drflac_bs;
641
642typedef struct
643{
644 /* The type of the subframe: SUBFRAME_CONSTANT, SUBFRAME_VERBATIM, SUBFRAME_FIXED or SUBFRAME_LPC. */
645 drflac_uint8 subframeType;
646
647 /* The number of wasted bits per sample as specified by the sub-frame header. */
648 drflac_uint8 wastedBitsPerSample;
649
650 /* The order to use for the prediction stage for SUBFRAME_FIXED and SUBFRAME_LPC. */
651 drflac_uint8 lpcOrder;
652
653 /* A pointer to the buffer containing the decoded samples in the subframe. This pointer is an offset from drflac::pExtraData. */
654 drflac_int32* pSamplesS32;
655} drflac_subframe;
656
657typedef struct
658{
659 /*
660 If the stream uses variable block sizes, this will be set to the index of the first PCM frame. If fixed block sizes are used, this will
661 always be set to 0. This is 64-bit because the decoded PCM frame number will be 36 bits.
662 */
663 drflac_uint64 pcmFrameNumber;
664
665 /*
666 If the stream uses fixed block sizes, this will be set to the frame number. If variable block sizes are used, this will always be 0. This
667 is 32-bit because in fixed block sizes, the maximum frame number will be 31 bits.
668 */
669 drflac_uint32 flacFrameNumber;
670
671 /* The sample rate of this frame. */
672 drflac_uint32 sampleRate;
673
674 /* The number of PCM frames in each sub-frame within this frame. */
675 drflac_uint16 blockSizeInPCMFrames;
676
677 /*
678 The channel assignment of this frame. This is not always set to the channel count. If interchannel decorrelation is being used this
679 will be set to DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE, DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE or DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE.
680 */
681 drflac_uint8 channelAssignment;
682
683 /* The number of bits per sample within this frame. */
684 drflac_uint8 bitsPerSample;
685
686 /* The frame's CRC. */
687 drflac_uint8 crc8;
688} drflac_frame_header;
689
690typedef struct
691{
692 /* The header. */
693 drflac_frame_header header;
694
695 /*
696 The number of PCM frames left to be read in this FLAC frame. This is initially set to the block size. As PCM frames are read,
697 this will be decremented. When it reaches 0, the decoder will see this frame as fully consumed and load the next frame.
698 */
699 drflac_uint32 pcmFramesRemaining;
700
701 /* The list of sub-frames within the frame. There is one sub-frame for each channel, and there's a maximum of 8 channels. */
702 drflac_subframe subframes[8];
703} drflac_frame;
704
705typedef struct
706{
707 /* The function to call when a metadata block is read. */
708 drflac_meta_proc onMeta;
709
710 /* The user data posted to the metadata callback function. */
711 void* pUserDataMD;
712
713 /* Memory allocation callbacks. */
714 drflac_allocation_callbacks allocationCallbacks;
715
716
717 /* The sample rate. Will be set to something like 44100. */
718 drflac_uint32 sampleRate;
719
720 /*
721 The number of channels. This will be set to 1 for monaural streams, 2 for stereo, etc. Maximum 8. This is set based on the
722 value specified in the STREAMINFO block.
723 */
724 drflac_uint8 channels;
725
726 /* The bits per sample. Will be set to something like 16, 24, etc. */
727 drflac_uint8 bitsPerSample;
728
729 /* The maximum block size, in samples. This number represents the number of samples in each channel (not combined). */
730 drflac_uint16 maxBlockSizeInPCMFrames;
731
732 /*
733 The total number of PCM Frames making up the stream. Can be 0 in which case it's still a valid stream, but just means
734 the total PCM frame count is unknown. Likely the case with streams like internet radio.
735 */
736 drflac_uint64 totalPCMFrameCount;
737
738
739 /* The container type. This is set based on whether or not the decoder was opened from a native or Ogg stream. */
740 drflac_container container;
741
742 /* The number of seekpoints in the seektable. */
743 drflac_uint32 seekpointCount;
744
745
746 /* Information about the frame the decoder is currently sitting on. */
747 drflac_frame currentFLACFrame;
748
749
750 /* The index of the PCM frame the decoder is currently sitting on. This is only used for seeking. */
751 drflac_uint64 currentPCMFrame;
752
753 /* The position of the first FLAC frame in the stream. This is only ever used for seeking. */
754 drflac_uint64 firstFLACFramePosInBytes;
755
756
757 /* A hack to avoid a malloc() when opening a decoder with drflac_open_memory(). */
758 drflac__memory_stream memoryStream;
759
760
761 /* A pointer to the decoded sample data. This is an offset of pExtraData. */
762 drflac_int32* pDecodedSamples;
763
764 /* A pointer to the seek table. This is an offset of pExtraData, or NULL if there is no seek table. */
765 drflac_seekpoint* pSeekpoints;
766
767 /* Internal use only. Only used with Ogg containers. Points to a drflac_oggbs object. This is an offset of pExtraData. */
768 void* _oggbs;
769
770 /* Internal use only. Used for profiling and testing different seeking modes. */
771 drflac_bool32 _noSeekTableSeek : 1;
772 drflac_bool32 _noBinarySearchSeek : 1;
773 drflac_bool32 _noBruteForceSeek : 1;
774
775 /* The bit streamer. The raw FLAC data is fed through this object. */
776 drflac_bs bs;
777
778 /* Variable length extra data. We attach this to the end of the object so we can avoid unnecessary mallocs. */
779 drflac_uint8 pExtraData[1];
780} drflac;
781
782
783/*
784Opens a FLAC decoder.
785
786
787Parameters
788----------
789onRead (in)
790 The function to call when data needs to be read from the client.
791
792onSeek (in)
793 The function to call when the read position of the client data needs to move.
794
795pUserData (in, optional)
796 A pointer to application defined data that will be passed to onRead and onSeek.
797
798pAllocationCallbacks (in, optional)
799 A pointer to application defined callbacks for managing memory allocations.
800
801
802Return Value
803------------
804Returns a pointer to an object representing the decoder.
805
806
807Remarks
808-------
809Close the decoder with `drflac_close()`.
810
811`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
812
813This function will automatically detect whether or not you are attempting to open a native or Ogg encapsulated FLAC, both of which should work seamlessly
814without any manual intervention. Ogg encapsulation also works with multiplexed streams which basically means it can play FLAC encoded audio tracks in videos.
815
816This is the lowest level function for opening a FLAC stream. You can also use `drflac_open_file()` and `drflac_open_memory()` to open the stream from a file or
817from a block of memory respectively.
818
819The STREAMINFO block must be present for this to succeed. Use `drflac_open_relaxed()` to open a FLAC stream where the header may not be present.
820
821Use `drflac_open_with_metadata()` if you need access to metadata.
822
823
824Seek Also
825---------
826drflac_open_file()
827drflac_open_memory()
828drflac_open_with_metadata()
829drflac_close()
830*/
831DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
832
833/*
834Opens a FLAC stream with relaxed validation of the header block.
835
836
837Parameters
838----------
839onRead (in)
840 The function to call when data needs to be read from the client.
841
842onSeek (in)
843 The function to call when the read position of the client data needs to move.
844
845container (in)
846 Whether or not the FLAC stream is encapsulated using standard FLAC encapsulation or Ogg encapsulation.
847
848pUserData (in, optional)
849 A pointer to application defined data that will be passed to onRead and onSeek.
850
851pAllocationCallbacks (in, optional)
852 A pointer to application defined callbacks for managing memory allocations.
853
854
855Return Value
856------------
857A pointer to an object representing the decoder.
858
859
860Remarks
861-------
862The same as drflac_open(), except attempts to open the stream even when a header block is not present.
863
864Because the header is not necessarily available, the caller must explicitly define the container (Native or Ogg). Do not set this to `drflac_container_unknown`
865as that is for internal use only.
866
867Opening in relaxed mode will continue reading data from onRead until it finds a valid frame. If a frame is never found it will continue forever. To abort,
868force your `onRead` callback to return 0, which dr_flac will use as an indicator that the end of the stream was found.
869
870Use `drflac_open_with_metadata_relaxed()` if you need access to metadata.
871*/
872DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
873
874/*
875Opens a FLAC decoder and notifies the caller of the metadata chunks (album art, etc.).
876
877
878Parameters
879----------
880onRead (in)
881 The function to call when data needs to be read from the client.
882
883onSeek (in)
884 The function to call when the read position of the client data needs to move.
885
886onMeta (in)
887 The function to call for every metadata block.
888
889pUserData (in, optional)
890 A pointer to application defined data that will be passed to onRead, onSeek and onMeta.
891
892pAllocationCallbacks (in, optional)
893 A pointer to application defined callbacks for managing memory allocations.
894
895
896Return Value
897------------
898A pointer to an object representing the decoder.
899
900
901Remarks
902-------
903Close the decoder with `drflac_close()`.
904
905`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
906
907This is slower than `drflac_open()`, so avoid this one if you don't need metadata. Internally, this will allocate and free memory on the heap for every
908metadata block except for STREAMINFO and PADDING blocks.
909
910The caller is notified of the metadata via the `onMeta` callback. All metadata blocks will be handled before the function returns. This callback takes a
911pointer to a `drflac_metadata` object which is a union containing the data of all relevant metadata blocks. Use the `type` member to discriminate against
912the different metadata types.
913
914The STREAMINFO block must be present for this to succeed. Use `drflac_open_with_metadata_relaxed()` to open a FLAC stream where the header may not be present.
915
916Note that this will behave inconsistently with `drflac_open()` if the stream is an Ogg encapsulated stream and a metadata block is corrupted. This is due to
917the way the Ogg stream recovers from corrupted pages. When `drflac_open_with_metadata()` is being used, the open routine will try to read the contents of the
918metadata block, whereas `drflac_open()` will simply seek past it (for the sake of efficiency). This inconsistency can result in different samples being
919returned depending on whether or not the stream is being opened with metadata.
920
921
922Seek Also
923---------
924drflac_open_file_with_metadata()
925drflac_open_memory_with_metadata()
926drflac_open()
927drflac_close()
928*/
929DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
930
931/*
932The same as drflac_open_with_metadata(), except attempts to open the stream even when a header block is not present.
933
934See Also
935--------
936drflac_open_with_metadata()
937drflac_open_relaxed()
938*/
939DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
940
941/*
942Closes the given FLAC decoder.
943
944
945Parameters
946----------
947pFlac (in)
948 The decoder to close.
949
950
951Remarks
952-------
953This will destroy the decoder object.
954
955
956See Also
957--------
958drflac_open()
959drflac_open_with_metadata()
960drflac_open_file()
961drflac_open_file_w()
962drflac_open_file_with_metadata()
963drflac_open_file_with_metadata_w()
964drflac_open_memory()
965drflac_open_memory_with_metadata()
966*/
967DRFLAC_API void drflac_close(drflac* pFlac);
968
969
970/*
971Reads sample data from the given FLAC decoder, output as interleaved signed 32-bit PCM.
972
973
974Parameters
975----------
976pFlac (in)
977 The decoder.
978
979framesToRead (in)
980 The number of PCM frames to read.
981
982pBufferOut (out, optional)
983 A pointer to the buffer that will receive the decoded samples.
984
985
986Return Value
987------------
988Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
989
990
991Remarks
992-------
993pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
994*/
995DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut);
996
997
998/*
999Reads sample data from the given FLAC decoder, output as interleaved signed 16-bit PCM.
1000
1001
1002Parameters
1003----------
1004pFlac (in)
1005 The decoder.
1006
1007framesToRead (in)
1008 The number of PCM frames to read.
1009
1010pBufferOut (out, optional)
1011 A pointer to the buffer that will receive the decoded samples.
1012
1013
1014Return Value
1015------------
1016Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
1017
1018
1019Remarks
1020-------
1021pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
1022
1023Note that this is lossy for streams where the bits per sample is larger than 16.
1024*/
1025DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut);
1026
1027/*
1028Reads sample data from the given FLAC decoder, output as interleaved 32-bit floating point PCM.
1029
1030
1031Parameters
1032----------
1033pFlac (in)
1034 The decoder.
1035
1036framesToRead (in)
1037 The number of PCM frames to read.
1038
1039pBufferOut (out, optional)
1040 A pointer to the buffer that will receive the decoded samples.
1041
1042
1043Return Value
1044------------
1045Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
1046
1047
1048Remarks
1049-------
1050pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
1051
1052Note that this should be considered lossy due to the nature of floating point numbers not being able to exactly represent every possible number.
1053*/
1054DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut);
1055
1056/*
1057Seeks to the PCM frame at the given index.
1058
1059
1060Parameters
1061----------
1062pFlac (in)
1063 The decoder.
1064
1065pcmFrameIndex (in)
1066 The index of the PCM frame to seek to. See notes below.
1067
1068
1069Return Value
1070-------------
1071`DRFLAC_TRUE` if successful; `DRFLAC_FALSE` otherwise.
1072*/
1073DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex);
1074
1075
1076
1077#ifndef DR_FLAC_NO_STDIO
1078/*
1079Opens a FLAC decoder from the file at the given path.
1080
1081
1082Parameters
1083----------
1084pFileName (in)
1085 The path of the file to open, either absolute or relative to the current directory.
1086
1087pAllocationCallbacks (in, optional)
1088 A pointer to application defined callbacks for managing memory allocations.
1089
1090
1091Return Value
1092------------
1093A pointer to an object representing the decoder.
1094
1095
1096Remarks
1097-------
1098Close the decoder with drflac_close().
1099
1100
1101Remarks
1102-------
1103This will hold a handle to the file until the decoder is closed with drflac_close(). Some platforms will restrict the number of files a process can have open
1104at any given time, so keep this mind if you have many decoders open at the same time.
1105
1106
1107See Also
1108--------
1109drflac_open_file_with_metadata()
1110drflac_open()
1111drflac_close()
1112*/
1113DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
1114DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
1115
1116/*
1117Opens a FLAC decoder from the file at the given path and notifies the caller of the metadata chunks (album art, etc.)
1118
1119
1120Parameters
1121----------
1122pFileName (in)
1123 The path of the file to open, either absolute or relative to the current directory.
1124
1125pAllocationCallbacks (in, optional)
1126 A pointer to application defined callbacks for managing memory allocations.
1127
1128onMeta (in)
1129 The callback to fire for each metadata block.
1130
1131pUserData (in)
1132 A pointer to the user data to pass to the metadata callback.
1133
1134pAllocationCallbacks (in)
1135 A pointer to application defined callbacks for managing memory allocations.
1136
1137
1138Remarks
1139-------
1140Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
1141
1142
1143See Also
1144--------
1145drflac_open_with_metadata()
1146drflac_open()
1147drflac_close()
1148*/
1149DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
1150DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
1151#endif
1152
1153/*
1154Opens a FLAC decoder from a pre-allocated block of memory
1155
1156
1157Parameters
1158----------
1159pData (in)
1160 A pointer to the raw encoded FLAC data.
1161
1162dataSize (in)
1163 The size in bytes of `data`.
1164
1165pAllocationCallbacks (in)
1166 A pointer to application defined callbacks for managing memory allocations.
1167
1168
1169Return Value
1170------------
1171A pointer to an object representing the decoder.
1172
1173
1174Remarks
1175-------
1176This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for the lifetime of the decoder.
1177
1178
1179See Also
1180--------
1181drflac_open()
1182drflac_close()
1183*/
1184DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks);
1185
1186/*
1187Opens a FLAC decoder from a pre-allocated block of memory and notifies the caller of the metadata chunks (album art, etc.)
1188
1189
1190Parameters
1191----------
1192pData (in)
1193 A pointer to the raw encoded FLAC data.
1194
1195dataSize (in)
1196 The size in bytes of `data`.
1197
1198onMeta (in)
1199 The callback to fire for each metadata block.
1200
1201pUserData (in)
1202 A pointer to the user data to pass to the metadata callback.
1203
1204pAllocationCallbacks (in)
1205 A pointer to application defined callbacks for managing memory allocations.
1206
1207
1208Remarks
1209-------
1210Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
1211
1212
1213See Also
1214-------
1215drflac_open_with_metadata()
1216drflac_open()
1217drflac_close()
1218*/
1219DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
1220
1221
1222
1223/* High Level APIs */
1224
1225/*
1226Opens a FLAC stream from the given callbacks and fully decodes it in a single operation. The return value is a
1227pointer to the sample data as interleaved signed 32-bit PCM. The returned data must be freed with drflac_free().
1228
1229You can pass in custom memory allocation callbacks via the pAllocationCallbacks parameter. This can be NULL in which
1230case it will use DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
1231
1232Sometimes a FLAC file won't keep track of the total sample count. In this situation the function will continuously
1233read samples into a dynamically sized buffer on the heap until no samples are left.
1234
1235Do not call this function on a broadcast type of stream (like internet radio streams and whatnot).
1236*/
1237DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1238
1239/* Same as drflac_open_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
1240DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1241
1242/* Same as drflac_open_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
1243DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1244
1245#ifndef DR_FLAC_NO_STDIO
1246/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a file. */
1247DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1248
1249/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
1250DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1251
1252/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
1253DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1254#endif
1255
1256/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a block of memory. */
1257DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1258
1259/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
1260DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1261
1262/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
1263DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
1264
1265/*
1266Frees memory that was allocated internally by dr_flac.
1267
1268Set pAllocationCallbacks to the same object that was passed to drflac_open_*_and_read_pcm_frames_*(). If you originally passed in NULL, pass in NULL for this.
1269*/
1270DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks);
1271
1272
1273/* Structure representing an iterator for vorbis comments in a VORBIS_COMMENT metadata block. */
1274typedef struct
1275{
1276 drflac_uint32 countRemaining;
1277 const char* pRunningData;
1278} drflac_vorbis_comment_iterator;
1279
1280/*
1281Initializes a vorbis comment iterator. This can be used for iterating over the vorbis comments in a VORBIS_COMMENT
1282metadata block.
1283*/
1284DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments);
1285
1286/*
1287Goes to the next vorbis comment in the given iterator. If null is returned it means there are no more comments. The
1288returned string is NOT null terminated.
1289*/
1290DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut);
1291
1292
1293/* Structure representing an iterator for cuesheet tracks in a CUESHEET metadata block. */
1294typedef struct
1295{
1296 drflac_uint32 countRemaining;
1297 const char* pRunningData;
1298} drflac_cuesheet_track_iterator;
1299
1300/* The order of members here is important because we map this directly to the raw data within the CUESHEET metadata block. */
1301typedef struct
1302{
1303 drflac_uint64 offset;
1304 drflac_uint8 index;
1305 drflac_uint8 reserved[3];
1306} drflac_cuesheet_track_index;
1307
1308typedef struct
1309{
1310 drflac_uint64 offset;
1311 drflac_uint8 trackNumber;
1312 char ISRC[12];
1313 drflac_bool8 isAudio;
1314 drflac_bool8 preEmphasis;
1315 drflac_uint8 indexCount;
1316 const drflac_cuesheet_track_index* pIndexPoints;
1317} drflac_cuesheet_track;
1318
1319/*
1320Initializes a cuesheet track iterator. This can be used for iterating over the cuesheet tracks in a CUESHEET metadata
1321block.
1322*/
1323DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData);
1324
1325/* Goes to the next cuesheet track in the given iterator. If DRFLAC_FALSE is returned it means there are no more comments. */
1326DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack);
1327
1328
1329#ifdef __cplusplus
1330}
1331#endif
1332#endif /* dr_flac_h */
1333
1334
1335/************************************************************************************************************************************************************
1336 ************************************************************************************************************************************************************
1337
1338 IMPLEMENTATION
1339
1340 ************************************************************************************************************************************************************
1341 ************************************************************************************************************************************************************/
1342#if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
1343#ifndef dr_flac_c
1344#define dr_flac_c
1345
1346/* Disable some annoying warnings. */
1347#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
1348 #pragma GCC diagnostic push
1349 #if __GNUC__ >= 7
1350 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
1351 #endif
1352#endif
1353
1354#ifdef __linux__
1355 #ifndef _BSD_SOURCE
1356 #define _BSD_SOURCE
1357 #endif
1358 #ifndef _DEFAULT_SOURCE
1359 #define _DEFAULT_SOURCE
1360 #endif
1361 #ifndef __USE_BSD
1362 #define __USE_BSD
1363 #endif
1364 #include <endian.h>
1365#endif
1366
1367#include <stdlib.h>
1368#include <string.h>
1369
1370/* Inline */
1371#ifdef _MSC_VER
1372 #define DRFLAC_INLINE __forceinline
1373#elif defined(__GNUC__)
1374 /*
1375 I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
1376 the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
1377 case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
1378 command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
1379 I am using "__inline__" only when we're compiling in strict ANSI mode.
1380 */
1381 #if defined(__STRICT_ANSI__)
1382 #define DRFLAC_GNUC_INLINE_HINT __inline__
1383 #else
1384 #define DRFLAC_GNUC_INLINE_HINT inline
1385 #endif
1386
1387 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
1388 #define DRFLAC_INLINE DRFLAC_GNUC_INLINE_HINT __attribute__((always_inline))
1389 #else
1390 #define DRFLAC_INLINE DRFLAC_GNUC_INLINE_HINT
1391 #endif
1392#elif defined(__WATCOMC__)
1393 #define DRFLAC_INLINE __inline
1394#else
1395 #define DRFLAC_INLINE
1396#endif
1397/* End Inline */
1398
1399/*
1400Intrinsics Support
1401
1402There's a bug in GCC 4.2.x which results in an incorrect compilation error when using _mm_slli_epi32() where it complains with
1403
1404 "error: shift must be an immediate"
1405
1406Unfortuantely dr_flac depends on this for a few things so we're just going to disable SSE on GCC 4.2 and below.
1407*/
1408#if !defined(DR_FLAC_NO_SIMD)
1409 #if defined(DRFLAC_X64) || defined(DRFLAC_X86)
1410 #if defined(_MSC_VER) && !defined(__clang__)
1411 /* MSVC. */
1412 #if _MSC_VER >= 1400 && !defined(DRFLAC_NO_SSE2) /* 2005 */
1413 #define DRFLAC_SUPPORT_SSE2
1414 #endif
1415 #if _MSC_VER >= 1600 && !defined(DRFLAC_NO_SSE41) /* 2010 */
1416 #define DRFLAC_SUPPORT_SSE41
1417 #endif
1418 #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
1419 /* Assume GNUC-style. */
1420 #if defined(__SSE2__) && !defined(DRFLAC_NO_SSE2)
1421 #define DRFLAC_SUPPORT_SSE2
1422 #endif
1423 #if defined(__SSE4_1__) && !defined(DRFLAC_NO_SSE41)
1424 #define DRFLAC_SUPPORT_SSE41
1425 #endif
1426 #endif
1427
1428 /* If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. */
1429 #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
1430 #if !defined(DRFLAC_SUPPORT_SSE2) && !defined(DRFLAC_NO_SSE2) && __has_include(<emmintrin.h>)
1431 #define DRFLAC_SUPPORT_SSE2
1432 #endif
1433 #if !defined(DRFLAC_SUPPORT_SSE41) && !defined(DRFLAC_NO_SSE41) && __has_include(<smmintrin.h>)
1434 #define DRFLAC_SUPPORT_SSE41
1435 #endif
1436 #endif
1437
1438 #if defined(DRFLAC_SUPPORT_SSE41)
1439 #include <smmintrin.h>
1440 #elif defined(DRFLAC_SUPPORT_SSE2)
1441 #include <emmintrin.h>
1442 #endif
1443 #endif
1444
1445 #if defined(DRFLAC_ARM)
1446 #if !defined(DRFLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
1447 #define DRFLAC_SUPPORT_NEON
1448 #include <arm_neon.h>
1449 #endif
1450 #endif
1451#endif
1452
1453/* Compile-time CPU feature support. */
1454#if !defined(DR_FLAC_NO_SIMD) && (defined(DRFLAC_X86) || defined(DRFLAC_X64))
1455 #if defined(_MSC_VER) && !defined(__clang__)
1456 #if _MSC_VER >= 1400
1457 #include <intrin.h>
1458 static void drflac__cpuid(int info[4], int fid)
1459 {
1460 __cpuid(info, fid);
1461 }
1462 #else
1463 #define DRFLAC_NO_CPUID
1464 #endif
1465 #else
1466 #if defined(__GNUC__) || defined(__clang__)
1467 static void drflac__cpuid(int info[4], int fid)
1468 {
1469 /*
1470 It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the
1471 specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for
1472 supporting different assembly dialects.
1473
1474 What's basically happening is that we're saving and restoring the ebx register manually.
1475 */
1476 #if defined(DRFLAC_X86) && defined(__PIC__)
1477 __asm__ __volatile__ (
1478 "xchg{l} {%%}ebx, %k1;"
1479 "cpuid;"
1480 "xchg{l} {%%}ebx, %k1;"
1481 : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
1482 );
1483 #else
1484 __asm__ __volatile__ (
1485 "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
1486 );
1487 #endif
1488 }
1489 #else
1490 #define DRFLAC_NO_CPUID
1491 #endif
1492 #endif
1493#else
1494 #define DRFLAC_NO_CPUID
1495#endif
1496
1497static DRFLAC_INLINE drflac_bool32 drflac_has_sse2(void)
1498{
1499#if defined(DRFLAC_SUPPORT_SSE2)
1500 #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE2)
1501 #if defined(DRFLAC_X64)
1502 return DRFLAC_TRUE; /* 64-bit targets always support SSE2. */
1503 #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
1504 return DRFLAC_TRUE; /* If the compiler is allowed to freely generate SSE2 code we can assume support. */
1505 #else
1506 #if defined(DRFLAC_NO_CPUID)
1507 return DRFLAC_FALSE;
1508 #else
1509 int info[4];
1510 drflac__cpuid(info, 1);
1511 return (info[3] & (1 << 26)) != 0;
1512 #endif
1513 #endif
1514 #else
1515 return DRFLAC_FALSE; /* SSE2 is only supported on x86 and x64 architectures. */
1516 #endif
1517#else
1518 return DRFLAC_FALSE; /* No compiler support. */
1519#endif
1520}
1521
1522static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
1523{
1524#if defined(DRFLAC_SUPPORT_SSE41)
1525 #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
1526 #if defined(__SSE4_1__) || defined(__AVX__)
1527 return DRFLAC_TRUE; /* If the compiler is allowed to freely generate SSE41 code we can assume support. */
1528 #else
1529 #if defined(DRFLAC_NO_CPUID)
1530 return DRFLAC_FALSE;
1531 #else
1532 int info[4];
1533 drflac__cpuid(info, 1);
1534 return (info[2] & (1 << 19)) != 0;
1535 #endif
1536 #endif
1537 #else
1538 return DRFLAC_FALSE; /* SSE41 is only supported on x86 and x64 architectures. */
1539 #endif
1540#else
1541 return DRFLAC_FALSE; /* No compiler support. */
1542#endif
1543}
1544
1545
1546#if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(DRFLAC_X86) || defined(DRFLAC_X64)) && !defined(__clang__)
1547 #define DRFLAC_HAS_LZCNT_INTRINSIC
1548#elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
1549 #define DRFLAC_HAS_LZCNT_INTRINSIC
1550#elif defined(__clang__)
1551 #if defined(__has_builtin)
1552 #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl)
1553 #define DRFLAC_HAS_LZCNT_INTRINSIC
1554 #endif
1555 #endif
1556#endif
1557
1558#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__clang__)
1559 #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
1560 #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
1561 #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
1562#elif defined(__clang__)
1563 #if defined(__has_builtin)
1564 #if __has_builtin(__builtin_bswap16)
1565 #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
1566 #endif
1567 #if __has_builtin(__builtin_bswap32)
1568 #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
1569 #endif
1570 #if __has_builtin(__builtin_bswap64)
1571 #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
1572 #endif
1573 #endif
1574#elif defined(__GNUC__)
1575 #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1576 #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
1577 #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
1578 #endif
1579 #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
1580 #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
1581 #endif
1582#elif defined(__WATCOMC__) && defined(__386__)
1583 #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
1584 #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
1585 #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
1586 extern __inline drflac_uint16 _watcom_bswap16(drflac_uint16);
1587 extern __inline drflac_uint32 _watcom_bswap32(drflac_uint32);
1588 extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
1589#pragma aux _watcom_bswap16 = \
1590 "xchg al, ah" \
1591 parm [ax] \
1592 value [ax] \
1593 modify nomemory;
1594#pragma aux _watcom_bswap32 = \
1595 "bswap eax" \
1596 parm [eax] \
1597 value [eax] \
1598 modify nomemory;
1599#pragma aux _watcom_bswap64 = \
1600 "bswap eax" \
1601 "bswap edx" \
1602 "xchg eax,edx" \
1603 parm [eax edx] \
1604 value [eax edx] \
1605 modify nomemory;
1606#endif
1607
1608
1609/* Standard library stuff. */
1610#ifndef DRFLAC_ASSERT
1611#include <assert.h>
1612#define DRFLAC_ASSERT(expression) assert(expression)
1613#endif
1614#ifndef DRFLAC_MALLOC
1615#define DRFLAC_MALLOC(sz) malloc((sz))
1616#endif
1617#ifndef DRFLAC_REALLOC
1618#define DRFLAC_REALLOC(p, sz) realloc((p), (sz))
1619#endif
1620#ifndef DRFLAC_FREE
1621#define DRFLAC_FREE(p) free((p))
1622#endif
1623#ifndef DRFLAC_COPY_MEMORY
1624#define DRFLAC_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
1625#endif
1626#ifndef DRFLAC_ZERO_MEMORY
1627#define DRFLAC_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
1628#endif
1629#ifndef DRFLAC_ZERO_OBJECT
1630#define DRFLAC_ZERO_OBJECT(p) DRFLAC_ZERO_MEMORY((p), sizeof(*(p)))
1631#endif
1632
1633#define DRFLAC_MAX_SIMD_VECTOR_SIZE 64 /* 64 for AVX-512 in the future. */
1634
1635/* Result Codes */
1636typedef drflac_int32 drflac_result;
1637#define DRFLAC_SUCCESS 0
1638#define DRFLAC_ERROR -1 /* A generic error. */
1639#define DRFLAC_INVALID_ARGS -2
1640#define DRFLAC_INVALID_OPERATION -3
1641#define DRFLAC_OUT_OF_MEMORY -4
1642#define DRFLAC_OUT_OF_RANGE -5
1643#define DRFLAC_ACCESS_DENIED -6
1644#define DRFLAC_DOES_NOT_EXIST -7
1645#define DRFLAC_ALREADY_EXISTS -8
1646#define DRFLAC_TOO_MANY_OPEN_FILES -9
1647#define DRFLAC_INVALID_FILE -10
1648#define DRFLAC_TOO_BIG -11
1649#define DRFLAC_PATH_TOO_LONG -12
1650#define DRFLAC_NAME_TOO_LONG -13
1651#define DRFLAC_NOT_DIRECTORY -14
1652#define DRFLAC_IS_DIRECTORY -15
1653#define DRFLAC_DIRECTORY_NOT_EMPTY -16
1654#define DRFLAC_END_OF_FILE -17
1655#define DRFLAC_NO_SPACE -18
1656#define DRFLAC_BUSY -19
1657#define DRFLAC_IO_ERROR -20
1658#define DRFLAC_INTERRUPT -21
1659#define DRFLAC_UNAVAILABLE -22
1660#define DRFLAC_ALREADY_IN_USE -23
1661#define DRFLAC_BAD_ADDRESS -24
1662#define DRFLAC_BAD_SEEK -25
1663#define DRFLAC_BAD_PIPE -26
1664#define DRFLAC_DEADLOCK -27
1665#define DRFLAC_TOO_MANY_LINKS -28
1666#define DRFLAC_NOT_IMPLEMENTED -29
1667#define DRFLAC_NO_MESSAGE -30
1668#define DRFLAC_BAD_MESSAGE -31
1669#define DRFLAC_NO_DATA_AVAILABLE -32
1670#define DRFLAC_INVALID_DATA -33
1671#define DRFLAC_TIMEOUT -34
1672#define DRFLAC_NO_NETWORK -35
1673#define DRFLAC_NOT_UNIQUE -36
1674#define DRFLAC_NOT_SOCKET -37
1675#define DRFLAC_NO_ADDRESS -38
1676#define DRFLAC_BAD_PROTOCOL -39
1677#define DRFLAC_PROTOCOL_UNAVAILABLE -40
1678#define DRFLAC_PROTOCOL_NOT_SUPPORTED -41
1679#define DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED -42
1680#define DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED -43
1681#define DRFLAC_SOCKET_NOT_SUPPORTED -44
1682#define DRFLAC_CONNECTION_RESET -45
1683#define DRFLAC_ALREADY_CONNECTED -46
1684#define DRFLAC_NOT_CONNECTED -47
1685#define DRFLAC_CONNECTION_REFUSED -48
1686#define DRFLAC_NO_HOST -49
1687#define DRFLAC_IN_PROGRESS -50
1688#define DRFLAC_CANCELLED -51
1689#define DRFLAC_MEMORY_ALREADY_MAPPED -52
1690#define DRFLAC_AT_END -53
1691
1692#define DRFLAC_CRC_MISMATCH -100
1693/* End Result Codes */
1694
1695
1696#define DRFLAC_SUBFRAME_CONSTANT 0
1697#define DRFLAC_SUBFRAME_VERBATIM 1
1698#define DRFLAC_SUBFRAME_FIXED 8
1699#define DRFLAC_SUBFRAME_LPC 32
1700#define DRFLAC_SUBFRAME_RESERVED 255
1701
1702#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE 0
1703#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 1
1704
1705#define DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT 0
1706#define DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE 8
1707#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE 9
1708#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE 10
1709
1710#define DRFLAC_SEEKPOINT_SIZE_IN_BYTES 18
1711#define DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES 36
1712#define DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES 12
1713
1714#define drflac_align(x, a) ((((x) + (a) - 1) / (a)) * (a))
1715
1716
1717DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision)
1718{
1719 if (pMajor) {
1720 *pMajor = DRFLAC_VERSION_MAJOR;
1721 }
1722
1723 if (pMinor) {
1724 *pMinor = DRFLAC_VERSION_MINOR;
1725 }
1726
1727 if (pRevision) {
1728 *pRevision = DRFLAC_VERSION_REVISION;
1729 }
1730}
1731
1732DRFLAC_API const char* drflac_version_string(void)
1733{
1734 return DRFLAC_VERSION_STRING;
1735}
1736
1737
1738/* CPU caps. */
1739#if defined(__has_feature)
1740 #if __has_feature(thread_sanitizer)
1741 #define DRFLAC_NO_THREAD_SANITIZE __attribute__((no_sanitize("thread")))
1742 #else
1743 #define DRFLAC_NO_THREAD_SANITIZE
1744 #endif
1745#else
1746 #define DRFLAC_NO_THREAD_SANITIZE
1747#endif
1748
1749#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
1750static drflac_bool32 drflac__gIsLZCNTSupported = DRFLAC_FALSE;
1751#endif
1752
1753#ifndef DRFLAC_NO_CPUID
1754static drflac_bool32 drflac__gIsSSE2Supported = DRFLAC_FALSE;
1755static drflac_bool32 drflac__gIsSSE41Supported = DRFLAC_FALSE;
1756
1757/*
1758I've had a bug report that Clang's ThreadSanitizer presents a warning in this function. Having reviewed this, this does
1759actually make sense. However, since CPU caps should never differ for a running process, I don't think the trade off of
1760complicating internal API's by passing around CPU caps versus just disabling the warnings is worthwhile. I'm therefore
1761just going to disable these warnings. This is disabled via the DRFLAC_NO_THREAD_SANITIZE attribute.
1762*/
1763DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
1764{
1765 static drflac_bool32 isCPUCapsInitialized = DRFLAC_FALSE;
1766
1767 if (!isCPUCapsInitialized) {
1768 /* LZCNT */
1769#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
1770 int info[4] = {0};
1771 drflac__cpuid(info, 0x80000001);
1772 drflac__gIsLZCNTSupported = (info[2] & (1 << 5)) != 0;
1773#endif
1774
1775 /* SSE2 */
1776 drflac__gIsSSE2Supported = drflac_has_sse2();
1777
1778 /* SSE4.1 */
1779 drflac__gIsSSE41Supported = drflac_has_sse41();
1780
1781 /* Initialized. */
1782 isCPUCapsInitialized = DRFLAC_TRUE;
1783 }
1784}
1785#else
1786static drflac_bool32 drflac__gIsNEONSupported = DRFLAC_FALSE;
1787
1788static DRFLAC_INLINE drflac_bool32 drflac__has_neon(void)
1789{
1790#if defined(DRFLAC_SUPPORT_NEON)
1791 #if defined(DRFLAC_ARM) && !defined(DRFLAC_NO_NEON)
1792 #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
1793 return DRFLAC_TRUE; /* If the compiler is allowed to freely generate NEON code we can assume support. */
1794 #else
1795 /* TODO: Runtime check. */
1796 return DRFLAC_FALSE;
1797 #endif
1798 #else
1799 return DRFLAC_FALSE; /* NEON is only supported on ARM architectures. */
1800 #endif
1801#else
1802 return DRFLAC_FALSE; /* No compiler support. */
1803#endif
1804}
1805
1806DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
1807{
1808 drflac__gIsNEONSupported = drflac__has_neon();
1809
1810#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
1811 drflac__gIsLZCNTSupported = DRFLAC_TRUE;
1812#endif
1813}
1814#endif
1815
1816
1817/* Endian Management */
1818static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian(void)
1819{
1820#if defined(DRFLAC_X86) || defined(DRFLAC_X64)
1821 return DRFLAC_TRUE;
1822#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
1823 return DRFLAC_TRUE;
1824#else
1825 int n = 1;
1826 return (*(char*)&n) == 1;
1827#endif
1828}
1829
1830static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
1831{
1832#ifdef DRFLAC_HAS_BYTESWAP16_INTRINSIC
1833 #if defined(_MSC_VER) && !defined(__clang__)
1834 return _byteswap_ushort(n);
1835 #elif defined(__GNUC__) || defined(__clang__)
1836 return __builtin_bswap16(n);
1837 #elif defined(__WATCOMC__) && defined(__386__)
1838 return _watcom_bswap16(n);
1839 #else
1840 #error "This compiler does not support the byte swap intrinsic."
1841 #endif
1842#else
1843 return ((n & 0xFF00) >> 8) |
1844 ((n & 0x00FF) << 8);
1845#endif
1846}
1847
1848static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
1849{
1850#ifdef DRFLAC_HAS_BYTESWAP32_INTRINSIC
1851 #if defined(_MSC_VER) && !defined(__clang__)
1852 return _byteswap_ulong(n);
1853 #elif defined(__GNUC__) || defined(__clang__)
1854 #if defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(__ARM_ARCH_6M__) && !defined(DRFLAC_64BIT) /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
1855 /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
1856 drflac_uint32 r;
1857 __asm__ __volatile__ (
1858 #if defined(DRFLAC_64BIT)
1859 "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n) /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
1860 #else
1861 "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
1862 #endif
1863 );
1864 return r;
1865 #else
1866 return __builtin_bswap32(n);
1867 #endif
1868 #elif defined(__WATCOMC__) && defined(__386__)
1869 return _watcom_bswap32(n);
1870 #else
1871 #error "This compiler does not support the byte swap intrinsic."
1872 #endif
1873#else
1874 return ((n & 0xFF000000) >> 24) |
1875 ((n & 0x00FF0000) >> 8) |
1876 ((n & 0x0000FF00) << 8) |
1877 ((n & 0x000000FF) << 24);
1878#endif
1879}
1880
1881static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
1882{
1883#ifdef DRFLAC_HAS_BYTESWAP64_INTRINSIC
1884 #if defined(_MSC_VER) && !defined(__clang__)
1885 return _byteswap_uint64(n);
1886 #elif defined(__GNUC__) || defined(__clang__)
1887 return __builtin_bswap64(n);
1888 #elif defined(__WATCOMC__) && defined(__386__)
1889 return _watcom_bswap64(n);
1890 #else
1891 #error "This compiler does not support the byte swap intrinsic."
1892 #endif
1893#else
1894 /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
1895 return ((n & ((drflac_uint64)0xFF000000 << 32)) >> 56) |
1896 ((n & ((drflac_uint64)0x00FF0000 << 32)) >> 40) |
1897 ((n & ((drflac_uint64)0x0000FF00 << 32)) >> 24) |
1898 ((n & ((drflac_uint64)0x000000FF << 32)) >> 8) |
1899 ((n & ((drflac_uint64)0xFF000000 )) << 8) |
1900 ((n & ((drflac_uint64)0x00FF0000 )) << 24) |
1901 ((n & ((drflac_uint64)0x0000FF00 )) << 40) |
1902 ((n & ((drflac_uint64)0x000000FF )) << 56);
1903#endif
1904}
1905
1906
1907static DRFLAC_INLINE drflac_uint16 drflac__be2host_16(drflac_uint16 n)
1908{
1909 if (drflac__is_little_endian()) {
1910 return drflac__swap_endian_uint16(n);
1911 }
1912
1913 return n;
1914}
1915
1916static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
1917{
1918 if (drflac__is_little_endian()) {
1919 return drflac__swap_endian_uint32(n);
1920 }
1921
1922 return n;
1923}
1924
1925static DRFLAC_INLINE drflac_uint32 drflac__be2host_32_ptr_unaligned(const void* pData)
1926{
1927 const drflac_uint8* pNum = (drflac_uint8*)pData;
1928 return *(pNum) << 24 | *(pNum+1) << 16 | *(pNum+2) << 8 | *(pNum+3);
1929}
1930
1931static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
1932{
1933 if (drflac__is_little_endian()) {
1934 return drflac__swap_endian_uint64(n);
1935 }
1936
1937 return n;
1938}
1939
1940
1941static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
1942{
1943 if (!drflac__is_little_endian()) {
1944 return drflac__swap_endian_uint32(n);
1945 }
1946
1947 return n;
1948}
1949
1950static DRFLAC_INLINE drflac_uint32 drflac__le2host_32_ptr_unaligned(const void* pData)
1951{
1952 const drflac_uint8* pNum = (drflac_uint8*)pData;
1953 return *pNum | *(pNum+1) << 8 | *(pNum+2) << 16 | *(pNum+3) << 24;
1954}
1955
1956
1957static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
1958{
1959 drflac_uint32 result = 0;
1960 result |= (n & 0x7F000000) >> 3;
1961 result |= (n & 0x007F0000) >> 2;
1962 result |= (n & 0x00007F00) >> 1;
1963 result |= (n & 0x0000007F) >> 0;
1964
1965 return result;
1966}
1967
1968
1969
1970/* The CRC code below is based on this document: http://zlib.net/crc_v3.txt */
1971static drflac_uint8 drflac__crc8_table[] = {
1972 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
1973 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
1974 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
1975 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
1976 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
1977 0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
1978 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
1979 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
1980 0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
1981 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
1982 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
1983 0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
1984 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
1985 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
1986 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
1987 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
1988};
1989
1990static drflac_uint16 drflac__crc16_table[] = {
1991 0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011,
1992 0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
1993 0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072,
1994 0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041,
1995 0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2,
1996 0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1,
1997 0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1,
1998 0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082,
1999 0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192,
2000 0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1,
2001 0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1,
2002 0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2,
2003 0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151,
2004 0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162,
2005 0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132,
2006 0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101,
2007 0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312,
2008 0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321,
2009 0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371,
2010 0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342,
2011 0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1,
2012 0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2,
2013 0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2,
2014 0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381,
2015 0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291,
2016 0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2,
2017 0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2,
2018 0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1,
2019 0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252,
2020 0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261,
2021 0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231,
2022 0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202
2023};
2024
2025static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
2026{
2027 return drflac__crc8_table[crc ^ data];
2028}
2029
2030static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 data, drflac_uint32 count)
2031{
2032#ifdef DR_FLAC_NO_CRC
2033 (void)crc;
2034 (void)data;
2035 (void)count;
2036 return 0;
2037#else
2038#if 0
2039 /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc8(crc, 0, 8);") */
2040 drflac_uint8 p = 0x07;
2041 for (int i = count-1; i >= 0; --i) {
2042 drflac_uint8 bit = (data & (1 << i)) >> i;
2043 if (crc & 0x80) {
2044 crc = ((crc << 1) | bit) ^ p;
2045 } else {
2046 crc = ((crc << 1) | bit);
2047 }
2048 }
2049 return crc;
2050#else
2051 drflac_uint32 wholeBytes;
2052 drflac_uint32 leftoverBits;
2053 drflac_uint64 leftoverDataMask;
2054
2055 static drflac_uint64 leftoverDataMaskTable[8] = {
2056 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
2057 };
2058
2059 DRFLAC_ASSERT(count <= 32);
2060
2061 wholeBytes = count >> 3;
2062 leftoverBits = count - (wholeBytes*8);
2063 leftoverDataMask = leftoverDataMaskTable[leftoverBits];
2064
2065 switch (wholeBytes) {
2066 case 4: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
2067 case 3: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
2068 case 2: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
2069 case 1: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
2070 case 0: if (leftoverBits > 0) crc = (drflac_uint8)((crc << leftoverBits) ^ drflac__crc8_table[(crc >> (8 - leftoverBits)) ^ (data & leftoverDataMask)]);
2071 }
2072 return crc;
2073#endif
2074#endif
2075}
2076
2077static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
2078{
2079 return (crc << 8) ^ drflac__crc16_table[(drflac_uint8)(crc >> 8) ^ data];
2080}
2081
2082static DRFLAC_INLINE drflac_uint16 drflac_crc16_cache(drflac_uint16 crc, drflac_cache_t data)
2083{
2084#ifdef DRFLAC_64BIT
2085 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
2086 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
2087 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
2088 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
2089#endif
2090 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
2091 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
2092 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 8) & 0xFF));
2093 crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 0) & 0xFF));
2094
2095 return crc;
2096}
2097
2098static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
2099{
2100 switch (byteCount)
2101 {
2102#ifdef DRFLAC_64BIT
2103 case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
2104 case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
2105 case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
2106 case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
2107#endif
2108 case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
2109 case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
2110 case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 8) & 0xFF));
2111 case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 0) & 0xFF));
2112 }
2113
2114 return crc;
2115}
2116
2117#if 0
2118static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
2119{
2120#ifdef DR_FLAC_NO_CRC
2121 (void)crc;
2122 (void)data;
2123 (void)count;
2124 return 0;
2125#else
2126#if 0
2127 /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc16(crc, 0, 16);") */
2128 drflac_uint16 p = 0x8005;
2129 for (int i = count-1; i >= 0; --i) {
2130 drflac_uint16 bit = (data & (1ULL << i)) >> i;
2131 if (r & 0x8000) {
2132 r = ((r << 1) | bit) ^ p;
2133 } else {
2134 r = ((r << 1) | bit);
2135 }
2136 }
2137
2138 return crc;
2139#else
2140 drflac_uint32 wholeBytes;
2141 drflac_uint32 leftoverBits;
2142 drflac_uint64 leftoverDataMask;
2143
2144 static drflac_uint64 leftoverDataMaskTable[8] = {
2145 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
2146 };
2147
2148 DRFLAC_ASSERT(count <= 64);
2149
2150 wholeBytes = count >> 3;
2151 leftoverBits = count & 7;
2152 leftoverDataMask = leftoverDataMaskTable[leftoverBits];
2153
2154 switch (wholeBytes) {
2155 default:
2156 case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
2157 case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
2158 case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
2159 case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
2160 case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
2161 }
2162 return crc;
2163#endif
2164#endif
2165}
2166
2167static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
2168{
2169#ifdef DR_FLAC_NO_CRC
2170 (void)crc;
2171 (void)data;
2172 (void)count;
2173 return 0;
2174#else
2175 drflac_uint32 wholeBytes;
2176 drflac_uint32 leftoverBits;
2177 drflac_uint64 leftoverDataMask;
2178
2179 static drflac_uint64 leftoverDataMaskTable[8] = {
2180 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
2181 };
2182
2183 DRFLAC_ASSERT(count <= 64);
2184
2185 wholeBytes = count >> 3;
2186 leftoverBits = count & 7;
2187 leftoverDataMask = leftoverDataMaskTable[leftoverBits];
2188
2189 switch (wholeBytes) {
2190 default:
2191 case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits))); /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
2192 case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits)));
2193 case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits)));
2194 case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits)));
2195 case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 ) << leftoverBits)) >> (24 + leftoverBits)));
2196 case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 ) << leftoverBits)) >> (16 + leftoverBits)));
2197 case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 ) << leftoverBits)) >> ( 8 + leftoverBits)));
2198 case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF ) << leftoverBits)) >> ( 0 + leftoverBits)));
2199 case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
2200 }
2201 return crc;
2202#endif
2203}
2204
2205
2206static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
2207{
2208#ifdef DRFLAC_64BIT
2209 return drflac_crc16__64bit(crc, data, count);
2210#else
2211 return drflac_crc16__32bit(crc, data, count);
2212#endif
2213}
2214#endif
2215
2216
2217#ifdef DRFLAC_64BIT
2218#define drflac__be2host__cache_line drflac__be2host_64
2219#else
2220#define drflac__be2host__cache_line drflac__be2host_32
2221#endif
2222
2223/*
2224BIT READING ATTEMPT #2
2225
2226This uses a 32- or 64-bit bit-shifted cache - as bits are read, the cache is shifted such that the first valid bit is sitting
2227on the most significant bit. It uses the notion of an L1 and L2 cache (borrowed from CPU architecture), where the L1 cache
2228is a 32- or 64-bit unsigned integer (depending on whether or not a 32- or 64-bit build is being compiled) and the L2 is an
2229array of "cache lines", with each cache line being the same size as the L1. The L2 is a buffer of about 4KB and is where data
2230from onRead() is read into.
2231*/
2232#define DRFLAC_CACHE_L1_SIZE_BYTES(bs) (sizeof((bs)->cache))
2233#define DRFLAC_CACHE_L1_SIZE_BITS(bs) (sizeof((bs)->cache)*8)
2234#define DRFLAC_CACHE_L1_BITS_REMAINING(bs) (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (bs)->consumedBits)
2235#define DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount) (~((~(drflac_cache_t)0) >> (_bitCount)))
2236#define DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, _bitCount) (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (_bitCount))
2237#define DRFLAC_CACHE_L1_SELECT(bs, _bitCount) (((bs)->cache) & DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount))
2238#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, _bitCount) (DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)))
2239#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, _bitCount)(DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> (DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)) & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1)))
2240#define DRFLAC_CACHE_L2_SIZE_BYTES(bs) (sizeof((bs)->cacheL2))
2241#define DRFLAC_CACHE_L2_LINE_COUNT(bs) (DRFLAC_CACHE_L2_SIZE_BYTES(bs) / sizeof((bs)->cacheL2[0]))
2242#define DRFLAC_CACHE_L2_LINES_REMAINING(bs) (DRFLAC_CACHE_L2_LINE_COUNT(bs) - (bs)->nextL2Line)
2243
2244
2245#ifndef DR_FLAC_NO_CRC
2246static DRFLAC_INLINE void drflac__reset_crc16(drflac_bs* bs)
2247{
2248 bs->crc16 = 0;
2249 bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
2250}
2251
2252static DRFLAC_INLINE void drflac__update_crc16(drflac_bs* bs)
2253{
2254 if (bs->crc16CacheIgnoredBytes == 0) {
2255 bs->crc16 = drflac_crc16_cache(bs->crc16, bs->crc16Cache);
2256 } else {
2257 bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache, DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bs->crc16CacheIgnoredBytes);
2258 bs->crc16CacheIgnoredBytes = 0;
2259 }
2260}
2261
2262static DRFLAC_INLINE drflac_uint16 drflac__flush_crc16(drflac_bs* bs)
2263{
2264 /* We should never be flushing in a situation where we are not aligned on a byte boundary. */
2265 DRFLAC_ASSERT((DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7) == 0);
2266
2267 /*
2268 The bits that were read from the L1 cache need to be accumulated. The number of bytes needing to be accumulated is determined
2269 by the number of bits that have been consumed.
2270 */
2271 if (DRFLAC_CACHE_L1_BITS_REMAINING(bs) == 0) {
2272 drflac__update_crc16(bs);
2273 } else {
2274 /* We only accumulate the consumed bits. */
2275 bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache >> DRFLAC_CACHE_L1_BITS_REMAINING(bs), (bs->consumedBits >> 3) - bs->crc16CacheIgnoredBytes);
2276
2277 /*
2278 The bits that we just accumulated should never be accumulated again. We need to keep track of how many bytes were accumulated
2279 so we can handle that later.
2280 */
2281 bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
2282 }
2283
2284 return bs->crc16;
2285}
2286#endif
2287
2288static DRFLAC_INLINE drflac_bool32 drflac__reload_l1_cache_from_l2(drflac_bs* bs)
2289{
2290 size_t bytesRead;
2291 size_t alignedL1LineCount;
2292
2293 /* Fast path. Try loading straight from L2. */
2294 if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
2295 bs->cache = bs->cacheL2[bs->nextL2Line++];
2296 return DRFLAC_TRUE;
2297 }
2298
2299 /*
2300 If we get here it means we've run out of data in the L2 cache. We'll need to fetch more from the client, if there's
2301 any left.
2302 */
2303 if (bs->unalignedByteCount > 0) {
2304 return DRFLAC_FALSE; /* If we have any unaligned bytes it means there's no more aligned bytes left in the client. */
2305 }
2306
2307 bytesRead = bs->onRead(bs->pUserData, bs->cacheL2, DRFLAC_CACHE_L2_SIZE_BYTES(bs));
2308
2309 bs->nextL2Line = 0;
2310 if (bytesRead == DRFLAC_CACHE_L2_SIZE_BYTES(bs)) {
2311 bs->cache = bs->cacheL2[bs->nextL2Line++];
2312 return DRFLAC_TRUE;
2313 }
2314
2315
2316 /*
2317 If we get here it means we were unable to retrieve enough data to fill the entire L2 cache. It probably
2318 means we've just reached the end of the file. We need to move the valid data down to the end of the buffer
2319 and adjust the index of the next line accordingly. Also keep in mind that the L2 cache must be aligned to
2320 the size of the L1 so we'll need to seek backwards by any misaligned bytes.
2321 */
2322 alignedL1LineCount = bytesRead / DRFLAC_CACHE_L1_SIZE_BYTES(bs);
2323
2324 /* We need to keep track of any unaligned bytes for later use. */
2325 bs->unalignedByteCount = bytesRead - (alignedL1LineCount * DRFLAC_CACHE_L1_SIZE_BYTES(bs));
2326 if (bs->unalignedByteCount > 0) {
2327 bs->unalignedCache = bs->cacheL2[alignedL1LineCount];
2328 }
2329
2330 if (alignedL1LineCount > 0) {
2331 size_t offset = DRFLAC_CACHE_L2_LINE_COUNT(bs) - alignedL1LineCount;
2332 size_t i;
2333 for (i = alignedL1LineCount; i > 0; --i) {
2334 bs->cacheL2[i-1 + offset] = bs->cacheL2[i-1];
2335 }
2336
2337 bs->nextL2Line = (drflac_uint32)offset;
2338 bs->cache = bs->cacheL2[bs->nextL2Line++];
2339 return DRFLAC_TRUE;
2340 } else {
2341 /* If we get into this branch it means we weren't able to load any L1-aligned data. */
2342 bs->nextL2Line = DRFLAC_CACHE_L2_LINE_COUNT(bs);
2343 return DRFLAC_FALSE;
2344 }
2345}
2346
2347static drflac_bool32 drflac__reload_cache(drflac_bs* bs)
2348{
2349 size_t bytesRead;
2350
2351#ifndef DR_FLAC_NO_CRC
2352 drflac__update_crc16(bs);
2353#endif
2354
2355 /* Fast path. Try just moving the next value in the L2 cache to the L1 cache. */
2356 if (drflac__reload_l1_cache_from_l2(bs)) {
2357 bs->cache = drflac__be2host__cache_line(bs->cache);
2358 bs->consumedBits = 0;
2359#ifndef DR_FLAC_NO_CRC
2360 bs->crc16Cache = bs->cache;
2361#endif
2362 return DRFLAC_TRUE;
2363 }
2364
2365 /* Slow path. */
2366
2367 /*
2368 If we get here it means we have failed to load the L1 cache from the L2. Likely we've just reached the end of the stream and the last
2369 few bytes did not meet the alignment requirements for the L2 cache. In this case we need to fall back to a slower path and read the
2370 data from the unaligned cache.
2371 */
2372 bytesRead = bs->unalignedByteCount;
2373 if (bytesRead == 0) {
2374 bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs); /* <-- The stream has been exhausted, so marked the bits as consumed. */
2375 return DRFLAC_FALSE;
2376 }
2377
2378 DRFLAC_ASSERT(bytesRead < DRFLAC_CACHE_L1_SIZE_BYTES(bs));
2379 bs->consumedBits = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bytesRead) * 8;
2380
2381 bs->cache = drflac__be2host__cache_line(bs->unalignedCache);
2382 bs->cache &= DRFLAC_CACHE_L1_SELECTION_MASK(DRFLAC_CACHE_L1_BITS_REMAINING(bs)); /* <-- Make sure the consumed bits are always set to zero. Other parts of the library depend on this property. */
2383 bs->unalignedByteCount = 0; /* <-- At this point the unaligned bytes have been moved into the cache and we thus have no more unaligned bytes. */
2384
2385#ifndef DR_FLAC_NO_CRC
2386 bs->crc16Cache = bs->cache >> bs->consumedBits;
2387 bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
2388#endif
2389 return DRFLAC_TRUE;
2390}
2391
2392static void drflac__reset_cache(drflac_bs* bs)
2393{
2394 bs->nextL2Line = DRFLAC_CACHE_L2_LINE_COUNT(bs); /* <-- This clears the L2 cache. */
2395 bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs); /* <-- This clears the L1 cache. */
2396 bs->cache = 0;
2397 bs->unalignedByteCount = 0; /* <-- This clears the trailing unaligned bytes. */
2398 bs->unalignedCache = 0;
2399
2400#ifndef DR_FLAC_NO_CRC
2401 bs->crc16Cache = 0;
2402 bs->crc16CacheIgnoredBytes = 0;
2403#endif
2404}
2405
2406
2407static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned int bitCount, drflac_uint32* pResultOut)
2408{
2409 DRFLAC_ASSERT(bs != NULL);
2410 DRFLAC_ASSERT(pResultOut != NULL);
2411 DRFLAC_ASSERT(bitCount > 0);
2412 DRFLAC_ASSERT(bitCount <= 32);
2413
2414 if (bs->consumedBits == DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
2415 if (!drflac__reload_cache(bs)) {
2416 return DRFLAC_FALSE;
2417 }
2418 }
2419
2420 if (bitCount <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
2421 /*
2422 If we want to load all 32-bits from a 32-bit cache we need to do it slightly differently because we can't do
2423 a 32-bit shift on a 32-bit integer. This will never be the case on 64-bit caches, so we can have a slightly
2424 more optimal solution for this.
2425 */
2426#ifdef DRFLAC_64BIT
2427 *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
2428 bs->consumedBits += bitCount;
2429 bs->cache <<= bitCount;
2430#else
2431 if (bitCount < DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
2432 *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
2433 bs->consumedBits += bitCount;
2434 bs->cache <<= bitCount;
2435 } else {
2436 /* Cannot shift by 32-bits, so need to do it differently. */
2437 *pResultOut = (drflac_uint32)bs->cache;
2438 bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
2439 bs->cache = 0;
2440 }
2441#endif
2442
2443 return DRFLAC_TRUE;
2444 } else {
2445 /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
2446 drflac_uint32 bitCountHi = DRFLAC_CACHE_L1_BITS_REMAINING(bs);
2447 drflac_uint32 bitCountLo = bitCount - bitCountHi;
2448 drflac_uint32 resultHi;
2449
2450 DRFLAC_ASSERT(bitCountHi > 0);
2451 DRFLAC_ASSERT(bitCountHi < 32);
2452 resultHi = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi);
2453
2454 if (!drflac__reload_cache(bs)) {
2455 return DRFLAC_FALSE;
2456 }
2457 if (bitCountLo > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
2458 /* This happens when we get to end of stream */
2459 return DRFLAC_FALSE;
2460 }
2461
2462 *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
2463 bs->consumedBits += bitCountLo;
2464 bs->cache <<= bitCountLo;
2465 return DRFLAC_TRUE;
2466 }
2467}
2468
2469static drflac_bool32 drflac__read_int32(drflac_bs* bs, unsigned int bitCount, drflac_int32* pResult)
2470{
2471 drflac_uint32 result;
2472
2473 DRFLAC_ASSERT(bs != NULL);
2474 DRFLAC_ASSERT(pResult != NULL);
2475 DRFLAC_ASSERT(bitCount > 0);
2476 DRFLAC_ASSERT(bitCount <= 32);
2477
2478 if (!drflac__read_uint32(bs, bitCount, &result)) {
2479 return DRFLAC_FALSE;
2480 }
2481
2482 /* Do not attempt to shift by 32 as it's undefined. */
2483 if (bitCount < 32) {
2484 drflac_uint32 signbit;
2485 signbit = ((result >> (bitCount-1)) & 0x01);
2486 result |= (~signbit + 1) << bitCount;
2487 }
2488
2489 *pResult = (drflac_int32)result;
2490 return DRFLAC_TRUE;
2491}
2492
2493#ifdef DRFLAC_64BIT
2494static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, drflac_uint64* pResultOut)
2495{
2496 drflac_uint32 resultHi;
2497 drflac_uint32 resultLo;
2498
2499 DRFLAC_ASSERT(bitCount <= 64);
2500 DRFLAC_ASSERT(bitCount > 32);
2501
2502 if (!drflac__read_uint32(bs, bitCount - 32, &resultHi)) {
2503 return DRFLAC_FALSE;
2504 }
2505
2506 if (!drflac__read_uint32(bs, 32, &resultLo)) {
2507 return DRFLAC_FALSE;
2508 }
2509
2510 *pResultOut = (((drflac_uint64)resultHi) << 32) | ((drflac_uint64)resultLo);
2511 return DRFLAC_TRUE;
2512}
2513#endif
2514
2515/* Function below is unused, but leaving it here in case I need to quickly add it again. */
2516#if 0
2517static drflac_bool32 drflac__read_int64(drflac_bs* bs, unsigned int bitCount, drflac_int64* pResultOut)
2518{
2519 drflac_uint64 result;
2520 drflac_uint64 signbit;
2521
2522 DRFLAC_ASSERT(bitCount <= 64);
2523
2524 if (!drflac__read_uint64(bs, bitCount, &result)) {
2525 return DRFLAC_FALSE;
2526 }
2527
2528 signbit = ((result >> (bitCount-1)) & 0x01);
2529 result |= (~signbit + 1) << bitCount;
2530
2531 *pResultOut = (drflac_int64)result;
2532 return DRFLAC_TRUE;
2533}
2534#endif
2535
2536static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, drflac_uint16* pResult)
2537{
2538 drflac_uint32 result;
2539
2540 DRFLAC_ASSERT(bs != NULL);
2541 DRFLAC_ASSERT(pResult != NULL);
2542 DRFLAC_ASSERT(bitCount > 0);
2543 DRFLAC_ASSERT(bitCount <= 16);
2544
2545 if (!drflac__read_uint32(bs, bitCount, &result)) {
2546 return DRFLAC_FALSE;
2547 }
2548
2549 *pResult = (drflac_uint16)result;
2550 return DRFLAC_TRUE;
2551}
2552
2553#if 0
2554static drflac_bool32 drflac__read_int16(drflac_bs* bs, unsigned int bitCount, drflac_int16* pResult)
2555{
2556 drflac_int32 result;
2557
2558 DRFLAC_ASSERT(bs != NULL);
2559 DRFLAC_ASSERT(pResult != NULL);
2560 DRFLAC_ASSERT(bitCount > 0);
2561 DRFLAC_ASSERT(bitCount <= 16);
2562
2563 if (!drflac__read_int32(bs, bitCount, &result)) {
2564 return DRFLAC_FALSE;
2565 }
2566
2567 *pResult = (drflac_int16)result;
2568 return DRFLAC_TRUE;
2569}
2570#endif
2571
2572static drflac_bool32 drflac__read_uint8(drflac_bs* bs, unsigned int bitCount, drflac_uint8* pResult)
2573{
2574 drflac_uint32 result;
2575
2576 DRFLAC_ASSERT(bs != NULL);
2577 DRFLAC_ASSERT(pResult != NULL);
2578 DRFLAC_ASSERT(bitCount > 0);
2579 DRFLAC_ASSERT(bitCount <= 8);
2580
2581 if (!drflac__read_uint32(bs, bitCount, &result)) {
2582 return DRFLAC_FALSE;
2583 }
2584
2585 *pResult = (drflac_uint8)result;
2586 return DRFLAC_TRUE;
2587}
2588
2589static drflac_bool32 drflac__read_int8(drflac_bs* bs, unsigned int bitCount, drflac_int8* pResult)
2590{
2591 drflac_int32 result;
2592
2593 DRFLAC_ASSERT(bs != NULL);
2594 DRFLAC_ASSERT(pResult != NULL);
2595 DRFLAC_ASSERT(bitCount > 0);
2596 DRFLAC_ASSERT(bitCount <= 8);
2597
2598 if (!drflac__read_int32(bs, bitCount, &result)) {
2599 return DRFLAC_FALSE;
2600 }
2601
2602 *pResult = (drflac_int8)result;
2603 return DRFLAC_TRUE;
2604}
2605
2606
2607static drflac_bool32 drflac__seek_bits(drflac_bs* bs, size_t bitsToSeek)
2608{
2609 if (bitsToSeek <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
2610 bs->consumedBits += (drflac_uint32)bitsToSeek;
2611 bs->cache <<= bitsToSeek;
2612 return DRFLAC_TRUE;
2613 } else {
2614 /* It straddles the cached data. This function isn't called too frequently so I'm favouring simplicity here. */
2615 bitsToSeek -= DRFLAC_CACHE_L1_BITS_REMAINING(bs);
2616 bs->consumedBits += DRFLAC_CACHE_L1_BITS_REMAINING(bs);
2617 bs->cache = 0;
2618
2619 /* Simple case. Seek in groups of the same number as bits that fit within a cache line. */
2620#ifdef DRFLAC_64BIT
2621 while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
2622 drflac_uint64 bin;
2623 if (!drflac__read_uint64(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
2624 return DRFLAC_FALSE;
2625 }
2626 bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
2627 }
2628#else
2629 while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
2630 drflac_uint32 bin;
2631 if (!drflac__read_uint32(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
2632 return DRFLAC_FALSE;
2633 }
2634 bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
2635 }
2636#endif
2637
2638 /* Whole leftover bytes. */
2639 while (bitsToSeek >= 8) {
2640 drflac_uint8 bin;
2641 if (!drflac__read_uint8(bs, 8, &bin)) {
2642 return DRFLAC_FALSE;
2643 }
2644 bitsToSeek -= 8;
2645 }
2646
2647 /* Leftover bits. */
2648 if (bitsToSeek > 0) {
2649 drflac_uint8 bin;
2650 if (!drflac__read_uint8(bs, (drflac_uint32)bitsToSeek, &bin)) {
2651 return DRFLAC_FALSE;
2652 }
2653 bitsToSeek = 0; /* <-- Necessary for the assert below. */
2654 }
2655
2656 DRFLAC_ASSERT(bitsToSeek == 0);
2657 return DRFLAC_TRUE;
2658 }
2659}
2660
2661
2662/* This function moves the bit streamer to the first bit after the sync code (bit 15 of the of the frame header). It will also update the CRC-16. */
2663static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
2664{
2665 DRFLAC_ASSERT(bs != NULL);
2666
2667 /*
2668 The sync code is always aligned to 8 bits. This is convenient for us because it means we can do byte-aligned movements. The first
2669 thing to do is align to the next byte.
2670 */
2671 if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
2672 return DRFLAC_FALSE;
2673 }
2674
2675 for (;;) {
2676 drflac_uint8 hi;
2677
2678#ifndef DR_FLAC_NO_CRC
2679 drflac__reset_crc16(bs);
2680#endif
2681
2682 if (!drflac__read_uint8(bs, 8, &hi)) {
2683 return DRFLAC_FALSE;
2684 }
2685
2686 if (hi == 0xFF) {
2687 drflac_uint8 lo;
2688 if (!drflac__read_uint8(bs, 6, &lo)) {
2689 return DRFLAC_FALSE;
2690 }
2691
2692 if (lo == 0x3E) {
2693 return DRFLAC_TRUE;
2694 } else {
2695 if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
2696 return DRFLAC_FALSE;
2697 }
2698 }
2699 }
2700 }
2701
2702 /* Should never get here. */
2703 /*return DRFLAC_FALSE;*/
2704}
2705
2706
2707#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
2708#define DRFLAC_IMPLEMENT_CLZ_LZCNT
2709#endif
2710#if defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(__clang__)
2711#define DRFLAC_IMPLEMENT_CLZ_MSVC
2712#endif
2713#if defined(__WATCOMC__) && defined(__386__)
2714#define DRFLAC_IMPLEMENT_CLZ_WATCOM
2715#endif
2716#ifdef __MRC__
2717#include <intrinsics.h>
2718#define DRFLAC_IMPLEMENT_CLZ_MRC
2719#endif
2720
2721static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
2722{
2723 drflac_uint32 n;
2724 static drflac_uint32 clz_table_4[] = {
2725 0,
2726 4,
2727 3, 3,
2728 2, 2, 2, 2,
2729 1, 1, 1, 1, 1, 1, 1, 1
2730 };
2731
2732 if (x == 0) {
2733 return sizeof(x)*8;
2734 }
2735
2736 n = clz_table_4[x >> (sizeof(x)*8 - 4)];
2737 if (n == 0) {
2738#ifdef DRFLAC_64BIT
2739 if ((x & ((drflac_uint64)0xFFFFFFFF << 32)) == 0) { n = 32; x <<= 32; }
2740 if ((x & ((drflac_uint64)0xFFFF0000 << 32)) == 0) { n += 16; x <<= 16; }
2741 if ((x & ((drflac_uint64)0xFF000000 << 32)) == 0) { n += 8; x <<= 8; }
2742 if ((x & ((drflac_uint64)0xF0000000 << 32)) == 0) { n += 4; x <<= 4; }
2743#else
2744 if ((x & 0xFFFF0000) == 0) { n = 16; x <<= 16; }
2745 if ((x & 0xFF000000) == 0) { n += 8; x <<= 8; }
2746 if ((x & 0xF0000000) == 0) { n += 4; x <<= 4; }
2747#endif
2748 n += clz_table_4[x >> (sizeof(x)*8 - 4)];
2749 }
2750
2751 return n - 1;
2752}
2753
2754#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
2755static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
2756{
2757 /* Fast compile time check for ARM. */
2758#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
2759 return DRFLAC_TRUE;
2760#elif defined(__MRC__)
2761 return DRFLAC_TRUE;
2762#else
2763 /* If the compiler itself does not support the intrinsic then we'll need to return false. */
2764 #ifdef DRFLAC_HAS_LZCNT_INTRINSIC
2765 return drflac__gIsLZCNTSupported;
2766 #else
2767 return DRFLAC_FALSE;
2768 #endif
2769#endif
2770}
2771
2772static DRFLAC_INLINE drflac_uint32 drflac__clz_lzcnt(drflac_cache_t x)
2773{
2774 /*
2775 It's critical for competitive decoding performance that this function be highly optimal. With MSVC we can use the __lzcnt64() and __lzcnt() intrinsics
2776 to achieve good performance, however on GCC and Clang it's a little bit more annoying. The __builtin_clzl() and __builtin_clzll() intrinsics leave
2777 it undefined as to the return value when `x` is 0. We need this to be well defined as returning 32 or 64, depending on whether or not it's a 32- or
2778 64-bit build. To work around this we would need to add a conditional to check for the x = 0 case, but this creates unnecessary inefficiency. To work
2779 around this problem I have written some inline assembly to emit the LZCNT (x86) or CLZ (ARM) instruction directly which removes the need to include
2780 the conditional. This has worked well in the past, but for some reason Clang's MSVC compatible driver, clang-cl, does not seem to be handling this
2781 in the same way as the normal Clang driver. It seems that `clang-cl` is just outputting the wrong results sometimes, maybe due to some register
2782 getting clobbered?
2783
2784 I'm not sure if this is a bug with dr_flac's inlined assembly (most likely), a bug in `clang-cl` or just a misunderstanding on my part with inline
2785 assembly rules for `clang-cl`. If somebody can identify an error in dr_flac's inlined assembly I'm happy to get that fixed.
2786
2787 Fortunately there is an easy workaround for this. Clang implements MSVC-specific intrinsics for compatibility. It also defines _MSC_VER for extra
2788 compatibility. We can therefore just check for _MSC_VER and use the MSVC intrinsic which, fortunately for us, Clang supports. It would still be nice
2789 to know how to fix the inlined assembly for correctness sake, however.
2790 */
2791
2792#if defined(_MSC_VER) /*&& !defined(__clang__)*/ /* <-- Intentionally wanting Clang to use the MSVC __lzcnt64/__lzcnt intrinsics due to above ^. */
2793 #ifdef DRFLAC_64BIT
2794 return (drflac_uint32)__lzcnt64(x);
2795 #else
2796 return (drflac_uint32)__lzcnt(x);
2797 #endif
2798#else
2799 #if defined(__GNUC__) || defined(__clang__)
2800 #if defined(DRFLAC_X64)
2801 {
2802 drflac_uint64 r;
2803 __asm__ __volatile__ (
2804 "lzcnt{ %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
2805 );
2806
2807 return (drflac_uint32)r;
2808 }
2809 #elif defined(DRFLAC_X86)
2810 {
2811 drflac_uint32 r;
2812 __asm__ __volatile__ (
2813 "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
2814 );
2815
2816 return r;
2817 }
2818 #elif defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(__ARM_ARCH_6M__) && !defined(DRFLAC_64BIT) /* <-- I haven't tested 64-bit inline assembly, so only enabling this for the 32-bit build for now. */
2819 {
2820 unsigned int r;
2821 __asm__ __volatile__ (
2822 #if defined(DRFLAC_64BIT)
2823 "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x) /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
2824 #else
2825 "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x)
2826 #endif
2827 );
2828
2829 return r;
2830 }
2831 #else
2832 if (x == 0) {
2833 return sizeof(x)*8;
2834 }
2835 #ifdef DRFLAC_64BIT
2836 return (drflac_uint32)__builtin_clzll((drflac_uint64)x);
2837 #else
2838 return (drflac_uint32)__builtin_clzl((drflac_uint32)x);
2839 #endif
2840 #endif
2841 #else
2842 /* Unsupported compiler. */
2843 #error "This compiler does not support the lzcnt intrinsic."
2844 #endif
2845#endif
2846}
2847#endif
2848
2849#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
2850#include <intrin.h> /* For BitScanReverse(). */
2851
2852static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
2853{
2854 drflac_uint32 n;
2855
2856 if (x == 0) {
2857 return sizeof(x)*8;
2858 }
2859
2860#ifdef DRFLAC_64BIT
2861 _BitScanReverse64((unsigned long*)&n, x);
2862#else
2863 _BitScanReverse((unsigned long*)&n, x);
2864#endif
2865 return sizeof(x)*8 - n - 1;
2866}
2867#endif
2868
2869#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
2870static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
2871#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM_LZCNT
2872/* Use the LZCNT instruction (only available on some processors since the 2010s). */
2873#pragma aux drflac__clz_watcom_lzcnt = \
2874 "db 0F3h, 0Fh, 0BDh, 0C0h" /* lzcnt eax, eax */ \
2875 parm [eax] \
2876 value [eax] \
2877 modify nomemory;
2878#else
2879/* Use the 386+-compatible implementation. */
2880#pragma aux drflac__clz_watcom = \
2881 "bsr eax, eax" \
2882 "xor eax, 31" \
2883 parm [eax] nomemory \
2884 value [eax] \
2885 modify exact [eax] nomemory;
2886#endif
2887#endif
2888
2889static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
2890{
2891#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
2892 if (drflac__is_lzcnt_supported()) {
2893 return drflac__clz_lzcnt(x);
2894 } else
2895#endif
2896 {
2897#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
2898 return drflac__clz_msvc(x);
2899#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM_LZCNT)
2900 return drflac__clz_watcom_lzcnt(x);
2901#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
2902 return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
2903#elif defined(__MRC__)
2904 return __cntlzw(x);
2905#else
2906 return drflac__clz_software(x);
2907#endif
2908 }
2909}
2910
2911
2912static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, unsigned int* pOffsetOut)
2913{
2914 drflac_uint32 zeroCounter = 0;
2915 drflac_uint32 setBitOffsetPlus1;
2916
2917 while (bs->cache == 0) {
2918 zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
2919 if (!drflac__reload_cache(bs)) {
2920 return DRFLAC_FALSE;
2921 }
2922 }
2923
2924 if (bs->cache == 1) {
2925 /* Not catching this would lead to undefined behaviour: a shift of a 32-bit number by 32 or more is undefined */
2926 *pOffsetOut = zeroCounter + (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs) - 1;
2927 if (!drflac__reload_cache(bs)) {
2928 return DRFLAC_FALSE;
2929 }
2930
2931 return DRFLAC_TRUE;
2932 }
2933
2934 setBitOffsetPlus1 = drflac__clz(bs->cache);
2935 setBitOffsetPlus1 += 1;
2936
2937 if (setBitOffsetPlus1 > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
2938 /* This happens when we get to end of stream */
2939 return DRFLAC_FALSE;
2940 }
2941
2942 bs->consumedBits += setBitOffsetPlus1;
2943 bs->cache <<= setBitOffsetPlus1;
2944
2945 *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1;
2946 return DRFLAC_TRUE;
2947}
2948
2949
2950
2951static drflac_bool32 drflac__seek_to_byte(drflac_bs* bs, drflac_uint64 offsetFromStart)
2952{
2953 DRFLAC_ASSERT(bs != NULL);
2954 DRFLAC_ASSERT(offsetFromStart > 0);
2955
2956 /*
2957 Seeking from the start is not quite as trivial as it sounds because the onSeek callback takes a signed 32-bit integer (which
2958 is intentional because it simplifies the implementation of the onSeek callbacks), however offsetFromStart is unsigned 64-bit.
2959 To resolve we just need to do an initial seek from the start, and then a series of offset seeks to make up the remainder.
2960 */
2961 if (offsetFromStart > 0x7FFFFFFF) {
2962 drflac_uint64 bytesRemaining = offsetFromStart;
2963 if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
2964 return DRFLAC_FALSE;
2965 }
2966 bytesRemaining -= 0x7FFFFFFF;
2967
2968 while (bytesRemaining > 0x7FFFFFFF) {
2969 if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
2970 return DRFLAC_FALSE;
2971 }
2972 bytesRemaining -= 0x7FFFFFFF;
2973 }
2974
2975 if (bytesRemaining > 0) {
2976 if (!bs->onSeek(bs->pUserData, (int)bytesRemaining, drflac_seek_origin_current)) {
2977 return DRFLAC_FALSE;
2978 }
2979 }
2980 } else {
2981 if (!bs->onSeek(bs->pUserData, (int)offsetFromStart, drflac_seek_origin_start)) {
2982 return DRFLAC_FALSE;
2983 }
2984 }
2985
2986 /* The cache should be reset to force a reload of fresh data from the client. */
2987 drflac__reset_cache(bs);
2988 return DRFLAC_TRUE;
2989}
2990
2991
2992static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64* pNumberOut, drflac_uint8* pCRCOut)
2993{
2994 drflac_uint8 crc;
2995 drflac_uint64 result;
2996 drflac_uint8 utf8[7] = {0};
2997 int byteCount;
2998 int i;
2999
3000 DRFLAC_ASSERT(bs != NULL);
3001 DRFLAC_ASSERT(pNumberOut != NULL);
3002 DRFLAC_ASSERT(pCRCOut != NULL);
3003
3004 crc = *pCRCOut;
3005
3006 if (!drflac__read_uint8(bs, 8, utf8)) {
3007 *pNumberOut = 0;
3008 return DRFLAC_AT_END;
3009 }
3010 crc = drflac_crc8(crc, utf8[0], 8);
3011
3012 if ((utf8[0] & 0x80) == 0) {
3013 *pNumberOut = utf8[0];
3014 *pCRCOut = crc;
3015 return DRFLAC_SUCCESS;
3016 }
3017
3018 /*byteCount = 1;*/
3019 if ((utf8[0] & 0xE0) == 0xC0) {
3020 byteCount = 2;
3021 } else if ((utf8[0] & 0xF0) == 0xE0) {
3022 byteCount = 3;
3023 } else if ((utf8[0] & 0xF8) == 0xF0) {
3024 byteCount = 4;
3025 } else if ((utf8[0] & 0xFC) == 0xF8) {
3026 byteCount = 5;
3027 } else if ((utf8[0] & 0xFE) == 0xFC) {
3028 byteCount = 6;
3029 } else if ((utf8[0] & 0xFF) == 0xFE) {
3030 byteCount = 7;
3031 } else {
3032 *pNumberOut = 0;
3033 return DRFLAC_CRC_MISMATCH; /* Bad UTF-8 encoding. */
3034 }
3035
3036 /* Read extra bytes. */
3037 DRFLAC_ASSERT(byteCount > 1);
3038
3039 result = (drflac_uint64)(utf8[0] & (0xFF >> (byteCount + 1)));
3040 for (i = 1; i < byteCount; ++i) {
3041 if (!drflac__read_uint8(bs, 8, utf8 + i)) {
3042 *pNumberOut = 0;
3043 return DRFLAC_AT_END;
3044 }
3045 crc = drflac_crc8(crc, utf8[i], 8);
3046
3047 result = (result << 6) | (utf8[i] & 0x3F);
3048 }
3049
3050 *pNumberOut = result;
3051 *pCRCOut = crc;
3052 return DRFLAC_SUCCESS;
3053}
3054
3055
3056static DRFLAC_INLINE drflac_uint32 drflac__ilog2_u32(drflac_uint32 x)
3057{
3058#if 1 /* Needs optimizing. */
3059 drflac_uint32 result = 0;
3060 while (x > 0) {
3061 result += 1;
3062 x >>= 1;
3063 }
3064
3065 return result;
3066#endif
3067}
3068
3069static DRFLAC_INLINE drflac_bool32 drflac__use_64_bit_prediction(drflac_uint32 bitsPerSample, drflac_uint32 order, drflac_uint32 precision)
3070{
3071 /* https://web.archive.org/web/20220205005724/https://github.com/ietf-wg-cellar/flac-specification/blob/37a49aa48ba4ba12e8757badfc59c0df35435fec/rfc_backmatter.md */
3072 return bitsPerSample + precision + drflac__ilog2_u32(order) > 32;
3073}
3074
3075
3076/*
3077The next two functions are responsible for calculating the prediction.
3078
3079When the bits per sample is >16 we need to use 64-bit integer arithmetic because otherwise we'll run out of precision. It's
3080safe to assume this will be slower on 32-bit platforms so we use a more optimal solution when the bits per sample is <=16.
3081*/
3082#if defined(__clang__)
3083__attribute__((no_sanitize("signed-integer-overflow")))
3084#endif
3085static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
3086{
3087 drflac_int32 prediction = 0;
3088
3089 DRFLAC_ASSERT(order <= 32);
3090
3091 /* 32-bit version. */
3092
3093 /* VC++ optimizes this to a single jmp. I've not yet verified this for other compilers. */
3094 switch (order)
3095 {
3096 case 32: prediction += coefficients[31] * pDecodedSamples[-32];
3097 case 31: prediction += coefficients[30] * pDecodedSamples[-31];
3098 case 30: prediction += coefficients[29] * pDecodedSamples[-30];
3099 case 29: prediction += coefficients[28] * pDecodedSamples[-29];
3100 case 28: prediction += coefficients[27] * pDecodedSamples[-28];
3101 case 27: prediction += coefficients[26] * pDecodedSamples[-27];
3102 case 26: prediction += coefficients[25] * pDecodedSamples[-26];
3103 case 25: prediction += coefficients[24] * pDecodedSamples[-25];
3104 case 24: prediction += coefficients[23] * pDecodedSamples[-24];
3105 case 23: prediction += coefficients[22] * pDecodedSamples[-23];
3106 case 22: prediction += coefficients[21] * pDecodedSamples[-22];
3107 case 21: prediction += coefficients[20] * pDecodedSamples[-21];
3108 case 20: prediction += coefficients[19] * pDecodedSamples[-20];
3109 case 19: prediction += coefficients[18] * pDecodedSamples[-19];
3110 case 18: prediction += coefficients[17] * pDecodedSamples[-18];
3111 case 17: prediction += coefficients[16] * pDecodedSamples[-17];
3112 case 16: prediction += coefficients[15] * pDecodedSamples[-16];
3113 case 15: prediction += coefficients[14] * pDecodedSamples[-15];
3114 case 14: prediction += coefficients[13] * pDecodedSamples[-14];
3115 case 13: prediction += coefficients[12] * pDecodedSamples[-13];
3116 case 12: prediction += coefficients[11] * pDecodedSamples[-12];
3117 case 11: prediction += coefficients[10] * pDecodedSamples[-11];
3118 case 10: prediction += coefficients[ 9] * pDecodedSamples[-10];
3119 case 9: prediction += coefficients[ 8] * pDecodedSamples[- 9];
3120 case 8: prediction += coefficients[ 7] * pDecodedSamples[- 8];
3121 case 7: prediction += coefficients[ 6] * pDecodedSamples[- 7];
3122 case 6: prediction += coefficients[ 5] * pDecodedSamples[- 6];
3123 case 5: prediction += coefficients[ 4] * pDecodedSamples[- 5];
3124 case 4: prediction += coefficients[ 3] * pDecodedSamples[- 4];
3125 case 3: prediction += coefficients[ 2] * pDecodedSamples[- 3];
3126 case 2: prediction += coefficients[ 1] * pDecodedSamples[- 2];
3127 case 1: prediction += coefficients[ 0] * pDecodedSamples[- 1];
3128 }
3129
3130 return (drflac_int32)(prediction >> shift);
3131}
3132
3133static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
3134{
3135 drflac_int64 prediction;
3136
3137 DRFLAC_ASSERT(order <= 32);
3138
3139 /* 64-bit version. */
3140
3141 /* This method is faster on the 32-bit build when compiling with VC++. See note below. */
3142#ifndef DRFLAC_64BIT
3143 if (order == 8)
3144 {
3145 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3146 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3147 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3148 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3149 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3150 prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
3151 prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
3152 prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
3153 }
3154 else if (order == 7)
3155 {
3156 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3157 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3158 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3159 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3160 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3161 prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
3162 prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
3163 }
3164 else if (order == 3)
3165 {
3166 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3167 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3168 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3169 }
3170 else if (order == 6)
3171 {
3172 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3173 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3174 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3175 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3176 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3177 prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
3178 }
3179 else if (order == 5)
3180 {
3181 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3182 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3183 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3184 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3185 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3186 }
3187 else if (order == 4)
3188 {
3189 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3190 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3191 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3192 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3193 }
3194 else if (order == 12)
3195 {
3196 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3197 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3198 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3199 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3200 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3201 prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
3202 prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
3203 prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
3204 prediction += coefficients[8] * (drflac_int64)pDecodedSamples[-9];
3205 prediction += coefficients[9] * (drflac_int64)pDecodedSamples[-10];
3206 prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
3207 prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
3208 }
3209 else if (order == 2)
3210 {
3211 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3212 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3213 }
3214 else if (order == 1)
3215 {
3216 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3217 }
3218 else if (order == 10)
3219 {
3220 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3221 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3222 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3223 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3224 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3225 prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
3226 prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
3227 prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
3228 prediction += coefficients[8] * (drflac_int64)pDecodedSamples[-9];
3229 prediction += coefficients[9] * (drflac_int64)pDecodedSamples[-10];
3230 }
3231 else if (order == 9)
3232 {
3233 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3234 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3235 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3236 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3237 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3238 prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
3239 prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
3240 prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
3241 prediction += coefficients[8] * (drflac_int64)pDecodedSamples[-9];
3242 }
3243 else if (order == 11)
3244 {
3245 prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
3246 prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
3247 prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
3248 prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
3249 prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
3250 prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
3251 prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
3252 prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
3253 prediction += coefficients[8] * (drflac_int64)pDecodedSamples[-9];
3254 prediction += coefficients[9] * (drflac_int64)pDecodedSamples[-10];
3255 prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
3256 }
3257 else
3258 {
3259 int j;
3260
3261 prediction = 0;
3262 for (j = 0; j < (int)order; ++j) {
3263 prediction += coefficients[j] * (drflac_int64)pDecodedSamples[-j-1];
3264 }
3265 }
3266#endif
3267
3268 /*
3269 VC++ optimizes this to a single jmp instruction, but only the 64-bit build. The 32-bit build generates less efficient code for some
3270 reason. The ugly version above is faster so we'll just switch between the two depending on the target platform.
3271 */
3272#ifdef DRFLAC_64BIT
3273 prediction = 0;
3274 switch (order)
3275 {
3276 case 32: prediction += coefficients[31] * (drflac_int64)pDecodedSamples[-32];
3277 case 31: prediction += coefficients[30] * (drflac_int64)pDecodedSamples[-31];
3278 case 30: prediction += coefficients[29] * (drflac_int64)pDecodedSamples[-30];
3279 case 29: prediction += coefficients[28] * (drflac_int64)pDecodedSamples[-29];
3280 case 28: prediction += coefficients[27] * (drflac_int64)pDecodedSamples[-28];
3281 case 27: prediction += coefficients[26] * (drflac_int64)pDecodedSamples[-27];
3282 case 26: prediction += coefficients[25] * (drflac_int64)pDecodedSamples[-26];
3283 case 25: prediction += coefficients[24] * (drflac_int64)pDecodedSamples[-25];
3284 case 24: prediction += coefficients[23] * (drflac_int64)pDecodedSamples[-24];
3285 case 23: prediction += coefficients[22] * (drflac_int64)pDecodedSamples[-23];
3286 case 22: prediction += coefficients[21] * (drflac_int64)pDecodedSamples[-22];
3287 case 21: prediction += coefficients[20] * (drflac_int64)pDecodedSamples[-21];
3288 case 20: prediction += coefficients[19] * (drflac_int64)pDecodedSamples[-20];
3289 case 19: prediction += coefficients[18] * (drflac_int64)pDecodedSamples[-19];
3290 case 18: prediction += coefficients[17] * (drflac_int64)pDecodedSamples[-18];
3291 case 17: prediction += coefficients[16] * (drflac_int64)pDecodedSamples[-17];
3292 case 16: prediction += coefficients[15] * (drflac_int64)pDecodedSamples[-16];
3293 case 15: prediction += coefficients[14] * (drflac_int64)pDecodedSamples[-15];
3294 case 14: prediction += coefficients[13] * (drflac_int64)pDecodedSamples[-14];
3295 case 13: prediction += coefficients[12] * (drflac_int64)pDecodedSamples[-13];
3296 case 12: prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
3297 case 11: prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
3298 case 10: prediction += coefficients[ 9] * (drflac_int64)pDecodedSamples[-10];
3299 case 9: prediction += coefficients[ 8] * (drflac_int64)pDecodedSamples[- 9];
3300 case 8: prediction += coefficients[ 7] * (drflac_int64)pDecodedSamples[- 8];
3301 case 7: prediction += coefficients[ 6] * (drflac_int64)pDecodedSamples[- 7];
3302 case 6: prediction += coefficients[ 5] * (drflac_int64)pDecodedSamples[- 6];
3303 case 5: prediction += coefficients[ 4] * (drflac_int64)pDecodedSamples[- 5];
3304 case 4: prediction += coefficients[ 3] * (drflac_int64)pDecodedSamples[- 4];
3305 case 3: prediction += coefficients[ 2] * (drflac_int64)pDecodedSamples[- 3];
3306 case 2: prediction += coefficients[ 1] * (drflac_int64)pDecodedSamples[- 2];
3307 case 1: prediction += coefficients[ 0] * (drflac_int64)pDecodedSamples[- 1];
3308 }
3309#endif
3310
3311 return (drflac_int32)(prediction >> shift);
3312}
3313
3314
3315#if 0
3316/*
3317Reference implementation for reading and decoding samples with residual. This is intentionally left unoptimized for the
3318sake of readability and should only be used as a reference.
3319*/
3320static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
3321{
3322 drflac_uint32 i;
3323
3324 DRFLAC_ASSERT(bs != NULL);
3325 DRFLAC_ASSERT(pSamplesOut != NULL);
3326
3327 for (i = 0; i < count; ++i) {
3328 drflac_uint32 zeroCounter = 0;
3329 for (;;) {
3330 drflac_uint8 bit;
3331 if (!drflac__read_uint8(bs, 1, &bit)) {
3332 return DRFLAC_FALSE;
3333 }
3334
3335 if (bit == 0) {
3336 zeroCounter += 1;
3337 } else {
3338 break;
3339 }
3340 }
3341
3342 drflac_uint32 decodedRice;
3343 if (riceParam > 0) {
3344 if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
3345 return DRFLAC_FALSE;
3346 }
3347 } else {
3348 decodedRice = 0;
3349 }
3350
3351 decodedRice |= (zeroCounter << riceParam);
3352 if ((decodedRice & 0x01)) {
3353 decodedRice = ~(decodedRice >> 1);
3354 } else {
3355 decodedRice = (decodedRice >> 1);
3356 }
3357
3358
3359 if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
3360 pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
3361 } else {
3362 pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
3363 }
3364 }
3365
3366 return DRFLAC_TRUE;
3367}
3368#endif
3369
3370#if 0
3371static drflac_bool32 drflac__read_rice_parts__reference(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
3372{
3373 drflac_uint32 zeroCounter = 0;
3374 drflac_uint32 decodedRice;
3375
3376 for (;;) {
3377 drflac_uint8 bit;
3378 if (!drflac__read_uint8(bs, 1, &bit)) {
3379 return DRFLAC_FALSE;
3380 }
3381
3382 if (bit == 0) {
3383 zeroCounter += 1;
3384 } else {
3385 break;
3386 }
3387 }
3388
3389 if (riceParam > 0) {
3390 if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
3391 return DRFLAC_FALSE;
3392 }
3393 } else {
3394 decodedRice = 0;
3395 }
3396
3397 *pZeroCounterOut = zeroCounter;
3398 *pRiceParamPartOut = decodedRice;
3399 return DRFLAC_TRUE;
3400}
3401#endif
3402
3403#if 0
3404static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
3405{
3406 drflac_cache_t riceParamMask;
3407 drflac_uint32 zeroCounter;
3408 drflac_uint32 setBitOffsetPlus1;
3409 drflac_uint32 riceParamPart;
3410 drflac_uint32 riceLength;
3411
3412 DRFLAC_ASSERT(riceParam > 0); /* <-- riceParam should never be 0. drflac__read_rice_parts__param_equals_zero() should be used instead for this case. */
3413
3414 riceParamMask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParam);
3415
3416 zeroCounter = 0;
3417 while (bs->cache == 0) {
3418 zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
3419 if (!drflac__reload_cache(bs)) {
3420 return DRFLAC_FALSE;
3421 }
3422 }
3423
3424 setBitOffsetPlus1 = drflac__clz(bs->cache);
3425 zeroCounter += setBitOffsetPlus1;
3426 setBitOffsetPlus1 += 1;
3427
3428 riceLength = setBitOffsetPlus1 + riceParam;
3429 if (riceLength < DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
3430 riceParamPart = (drflac_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength));
3431
3432 bs->consumedBits += riceLength;
3433 bs->cache <<= riceLength;
3434 } else {
3435 drflac_uint32 bitCountLo;
3436 drflac_cache_t resultHi;
3437
3438 bs->consumedBits += riceLength;
3439 bs->cache <<= setBitOffsetPlus1 & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1); /* <-- Equivalent to "if (setBitOffsetPlus1 < DRFLAC_CACHE_L1_SIZE_BITS(bs)) { bs->cache <<= setBitOffsetPlus1; }" */
3440
3441 /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
3442 bitCountLo = bs->consumedBits - DRFLAC_CACHE_L1_SIZE_BITS(bs);
3443 resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam); /* <-- Use DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE() if ever this function allows riceParam=0. */
3444
3445 if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
3446#ifndef DR_FLAC_NO_CRC
3447 drflac__update_crc16(bs);
3448#endif
3449 bs->cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
3450 bs->consumedBits = 0;
3451#ifndef DR_FLAC_NO_CRC
3452 bs->crc16Cache = bs->cache;
3453#endif
3454 } else {
3455 /* Slow path. We need to fetch more data from the client. */
3456 if (!drflac__reload_cache(bs)) {
3457 return DRFLAC_FALSE;
3458 }
3459 if (bitCountLo > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
3460 /* This happens when we get to end of stream */
3461 return DRFLAC_FALSE;
3462 }
3463 }
3464
3465 riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
3466
3467 bs->consumedBits += bitCountLo;
3468 bs->cache <<= bitCountLo;
3469 }
3470
3471 pZeroCounterOut[0] = zeroCounter;
3472 pRiceParamPartOut[0] = riceParamPart;
3473
3474 return DRFLAC_TRUE;
3475}
3476#endif
3477
3478static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
3479{
3480 drflac_uint32 riceParamPlus1 = riceParam + 1;
3481 /*drflac_cache_t riceParamPlus1Mask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParamPlus1);*/
3482 drflac_uint32 riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
3483 drflac_uint32 riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
3484
3485 /*
3486 The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
3487 no idea how this will work in practice...
3488 */
3489 drflac_cache_t bs_cache = bs->cache;
3490 drflac_uint32 bs_consumedBits = bs->consumedBits;
3491
3492 /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
3493 drflac_uint32 lzcount = drflac__clz(bs_cache);
3494 if (lzcount < sizeof(bs_cache)*8) {
3495 pZeroCounterOut[0] = lzcount;
3496
3497 /*
3498 It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
3499 this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
3500 outside of this function at a higher level.
3501 */
3502 extract_rice_param_part:
3503 bs_cache <<= lzcount;
3504 bs_consumedBits += lzcount;
3505
3506 if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
3507 /* Getting here means the rice parameter part is wholly contained within the current cache line. */
3508 pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
3509 bs_cache <<= riceParamPlus1;
3510 bs_consumedBits += riceParamPlus1;
3511 } else {
3512 drflac_uint32 riceParamPartHi;
3513 drflac_uint32 riceParamPartLo;
3514 drflac_uint32 riceParamPartLoBitCount;
3515
3516 /*
3517 Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
3518 line, reload the cache, and then combine it with the head of the next cache line.
3519 */
3520
3521 /* Grab the high part of the rice parameter part. */
3522 riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
3523
3524 /* Before reloading the cache we need to grab the size in bits of the low part. */
3525 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
3526 DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
3527
3528 /* Now reload the cache. */
3529 if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
3530 #ifndef DR_FLAC_NO_CRC
3531 drflac__update_crc16(bs);
3532 #endif
3533 bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
3534 bs_consumedBits = riceParamPartLoBitCount;
3535 #ifndef DR_FLAC_NO_CRC
3536 bs->crc16Cache = bs_cache;
3537 #endif
3538 } else {
3539 /* Slow path. We need to fetch more data from the client. */
3540 if (!drflac__reload_cache(bs)) {
3541 return DRFLAC_FALSE;
3542 }
3543 if (riceParamPartLoBitCount > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
3544 /* This happens when we get to end of stream */
3545 return DRFLAC_FALSE;
3546 }
3547
3548 bs_cache = bs->cache;
3549 bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
3550 }
3551
3552 /* We should now have enough information to construct the rice parameter part. */
3553 riceParamPartLo = (drflac_uint32)(bs_cache >> (DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount)));
3554 pRiceParamPartOut[0] = riceParamPartHi | riceParamPartLo;
3555
3556 bs_cache <<= riceParamPartLoBitCount;
3557 }
3558 } else {
3559 /*
3560 Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
3561 to drflac__clz() and we need to reload the cache.
3562 */
3563 drflac_uint32 zeroCounter = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
3564 for (;;) {
3565 if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
3566 #ifndef DR_FLAC_NO_CRC
3567 drflac__update_crc16(bs);
3568 #endif
3569 bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
3570 bs_consumedBits = 0;
3571 #ifndef DR_FLAC_NO_CRC
3572 bs->crc16Cache = bs_cache;
3573 #endif
3574 } else {
3575 /* Slow path. We need to fetch more data from the client. */
3576 if (!drflac__reload_cache(bs)) {
3577 return DRFLAC_FALSE;
3578 }
3579
3580 bs_cache = bs->cache;
3581 bs_consumedBits = bs->consumedBits;
3582 }
3583
3584 lzcount = drflac__clz(bs_cache);
3585 zeroCounter += lzcount;
3586
3587 if (lzcount < sizeof(bs_cache)*8) {
3588 break;
3589 }
3590 }
3591
3592 pZeroCounterOut[0] = zeroCounter;
3593 goto extract_rice_param_part;
3594 }
3595
3596 /* Make sure the cache is restored at the end of it all. */
3597 bs->cache = bs_cache;
3598 bs->consumedBits = bs_consumedBits;
3599
3600 return DRFLAC_TRUE;
3601}
3602
3603static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac_uint8 riceParam)
3604{
3605 drflac_uint32 riceParamPlus1 = riceParam + 1;
3606 drflac_uint32 riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
3607
3608 /*
3609 The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
3610 no idea how this will work in practice...
3611 */
3612 drflac_cache_t bs_cache = bs->cache;
3613 drflac_uint32 bs_consumedBits = bs->consumedBits;
3614
3615 /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
3616 drflac_uint32 lzcount = drflac__clz(bs_cache);
3617 if (lzcount < sizeof(bs_cache)*8) {
3618 /*
3619 It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
3620 this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
3621 outside of this function at a higher level.
3622 */
3623 extract_rice_param_part:
3624 bs_cache <<= lzcount;
3625 bs_consumedBits += lzcount;
3626
3627 if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
3628 /* Getting here means the rice parameter part is wholly contained within the current cache line. */
3629 bs_cache <<= riceParamPlus1;
3630 bs_consumedBits += riceParamPlus1;
3631 } else {
3632 /*
3633 Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
3634 line, reload the cache, and then combine it with the head of the next cache line.
3635 */
3636
3637 /* Before reloading the cache we need to grab the size in bits of the low part. */
3638 drflac_uint32 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
3639 DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
3640
3641 /* Now reload the cache. */
3642 if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
3643 #ifndef DR_FLAC_NO_CRC
3644 drflac__update_crc16(bs);
3645 #endif
3646 bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
3647 bs_consumedBits = riceParamPartLoBitCount;
3648 #ifndef DR_FLAC_NO_CRC
3649 bs->crc16Cache = bs_cache;
3650 #endif
3651 } else {
3652 /* Slow path. We need to fetch more data from the client. */
3653 if (!drflac__reload_cache(bs)) {
3654 return DRFLAC_FALSE;
3655 }
3656
3657 if (riceParamPartLoBitCount > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
3658 /* This happens when we get to end of stream */
3659 return DRFLAC_FALSE;
3660 }
3661
3662 bs_cache = bs->cache;
3663 bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
3664 }
3665
3666 bs_cache <<= riceParamPartLoBitCount;
3667 }
3668 } else {
3669 /*
3670 Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
3671 to drflac__clz() and we need to reload the cache.
3672 */
3673 for (;;) {
3674 if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
3675 #ifndef DR_FLAC_NO_CRC
3676 drflac__update_crc16(bs);
3677 #endif
3678 bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
3679 bs_consumedBits = 0;
3680 #ifndef DR_FLAC_NO_CRC
3681 bs->crc16Cache = bs_cache;
3682 #endif
3683 } else {
3684 /* Slow path. We need to fetch more data from the client. */
3685 if (!drflac__reload_cache(bs)) {
3686 return DRFLAC_FALSE;
3687 }
3688
3689 bs_cache = bs->cache;
3690 bs_consumedBits = bs->consumedBits;
3691 }
3692
3693 lzcount = drflac__clz(bs_cache);
3694 if (lzcount < sizeof(bs_cache)*8) {
3695 break;
3696 }
3697 }
3698
3699 goto extract_rice_param_part;
3700 }
3701
3702 /* Make sure the cache is restored at the end of it all. */
3703 bs->cache = bs_cache;
3704 bs->consumedBits = bs_consumedBits;
3705
3706 return DRFLAC_TRUE;
3707}
3708
3709
3710static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorder(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
3711{
3712 drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
3713 drflac_uint32 zeroCountPart0;
3714 drflac_uint32 riceParamPart0;
3715 drflac_uint32 riceParamMask;
3716 drflac_uint32 i;
3717
3718 DRFLAC_ASSERT(bs != NULL);
3719 DRFLAC_ASSERT(pSamplesOut != NULL);
3720
3721 (void)bitsPerSample;
3722 (void)order;
3723 (void)shift;
3724 (void)coefficients;
3725
3726 riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
3727
3728 i = 0;
3729 while (i < count) {
3730 /* Rice extraction. */
3731 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
3732 return DRFLAC_FALSE;
3733 }
3734
3735 /* Rice reconstruction. */
3736 riceParamPart0 &= riceParamMask;
3737 riceParamPart0 |= (zeroCountPart0 << riceParam);
3738 riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
3739
3740 pSamplesOut[i] = riceParamPart0;
3741
3742 i += 1;
3743 }
3744
3745 return DRFLAC_TRUE;
3746}
3747
3748static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
3749{
3750 drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
3751 drflac_uint32 zeroCountPart0 = 0;
3752 drflac_uint32 zeroCountPart1 = 0;
3753 drflac_uint32 zeroCountPart2 = 0;
3754 drflac_uint32 zeroCountPart3 = 0;
3755 drflac_uint32 riceParamPart0 = 0;
3756 drflac_uint32 riceParamPart1 = 0;
3757 drflac_uint32 riceParamPart2 = 0;
3758 drflac_uint32 riceParamPart3 = 0;
3759 drflac_uint32 riceParamMask;
3760 const drflac_int32* pSamplesOutEnd;
3761 drflac_uint32 i;
3762
3763 DRFLAC_ASSERT(bs != NULL);
3764 DRFLAC_ASSERT(pSamplesOut != NULL);
3765
3766 if (lpcOrder == 0) {
3767 return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
3768 }
3769
3770 riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
3771 pSamplesOutEnd = pSamplesOut + (count & ~3);
3772
3773 if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
3774 while (pSamplesOut < pSamplesOutEnd) {
3775 /*
3776 Rice extraction. It's faster to do this one at a time against local variables than it is to use the x4 version
3777 against an array. Not sure why, but perhaps it's making more efficient use of registers?
3778 */
3779 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
3780 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
3781 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
3782 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
3783 return DRFLAC_FALSE;
3784 }
3785
3786 riceParamPart0 &= riceParamMask;
3787 riceParamPart1 &= riceParamMask;
3788 riceParamPart2 &= riceParamMask;
3789 riceParamPart3 &= riceParamMask;
3790
3791 riceParamPart0 |= (zeroCountPart0 << riceParam);
3792 riceParamPart1 |= (zeroCountPart1 << riceParam);
3793 riceParamPart2 |= (zeroCountPart2 << riceParam);
3794 riceParamPart3 |= (zeroCountPart3 << riceParam);
3795
3796 riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
3797 riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
3798 riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
3799 riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
3800
3801 pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
3802 pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 1);
3803 pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 2);
3804 pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 3);
3805
3806 pSamplesOut += 4;
3807 }
3808 } else {
3809 while (pSamplesOut < pSamplesOutEnd) {
3810 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
3811 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
3812 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
3813 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
3814 return DRFLAC_FALSE;
3815 }
3816
3817 riceParamPart0 &= riceParamMask;
3818 riceParamPart1 &= riceParamMask;
3819 riceParamPart2 &= riceParamMask;
3820 riceParamPart3 &= riceParamMask;
3821
3822 riceParamPart0 |= (zeroCountPart0 << riceParam);
3823 riceParamPart1 |= (zeroCountPart1 << riceParam);
3824 riceParamPart2 |= (zeroCountPart2 << riceParam);
3825 riceParamPart3 |= (zeroCountPart3 << riceParam);
3826
3827 riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
3828 riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
3829 riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
3830 riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
3831
3832 pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
3833 pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 1);
3834 pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 2);
3835 pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 3);
3836
3837 pSamplesOut += 4;
3838 }
3839 }
3840
3841 i = (count & ~3);
3842 while (i < count) {
3843 /* Rice extraction. */
3844 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
3845 return DRFLAC_FALSE;
3846 }
3847
3848 /* Rice reconstruction. */
3849 riceParamPart0 &= riceParamMask;
3850 riceParamPart0 |= (zeroCountPart0 << riceParam);
3851 riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
3852 /*riceParamPart0 = (riceParamPart0 >> 1) ^ (~(riceParamPart0 & 0x01) + 1);*/
3853
3854 /* Sample reconstruction. */
3855 if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
3856 pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
3857 } else {
3858 pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
3859 }
3860
3861 i += 1;
3862 pSamplesOut += 1;
3863 }
3864
3865 return DRFLAC_TRUE;
3866}
3867
3868#if defined(DRFLAC_SUPPORT_SSE2)
3869static DRFLAC_INLINE __m128i drflac__mm_packs_interleaved_epi32(__m128i a, __m128i b)
3870{
3871 __m128i r;
3872
3873 /* Pack. */
3874 r = _mm_packs_epi32(a, b);
3875
3876 /* a3a2 a1a0 b3b2 b1b0 -> a3a2 b3b2 a1a0 b1b0 */
3877 r = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 1, 2, 0));
3878
3879 /* a3a2 b3b2 a1a0 b1b0 -> a3b3 a2b2 a1b1 a0b0 */
3880 r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
3881 r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
3882
3883 return r;
3884}
3885#endif
3886
3887#if defined(DRFLAC_SUPPORT_SSE41)
3888static DRFLAC_INLINE __m128i drflac__mm_not_si128(__m128i a)
3889{
3890 return _mm_xor_si128(a, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
3891}
3892
3893static DRFLAC_INLINE __m128i drflac__mm_hadd_epi32(__m128i x)
3894{
3895 __m128i x64 = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
3896 __m128i x32 = _mm_shufflelo_epi16(x64, _MM_SHUFFLE(1, 0, 3, 2));
3897 return _mm_add_epi32(x64, x32);
3898}
3899
3900static DRFLAC_INLINE __m128i drflac__mm_hadd_epi64(__m128i x)
3901{
3902 return _mm_add_epi64(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
3903}
3904
3905static DRFLAC_INLINE __m128i drflac__mm_srai_epi64(__m128i x, int count)
3906{
3907 /*
3908 To simplify this we are assuming count < 32. This restriction allows us to work on a low side and a high side. The low side
3909 is shifted with zero bits, whereas the right side is shifted with sign bits.
3910 */
3911 __m128i lo = _mm_srli_epi64(x, count);
3912 __m128i hi = _mm_srai_epi32(x, count);
3913
3914 hi = _mm_and_si128(hi, _mm_set_epi32(0xFFFFFFFF, 0, 0xFFFFFFFF, 0)); /* The high part needs to have the low part cleared. */
3915
3916 return _mm_or_si128(lo, hi);
3917}
3918
3919static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
3920{
3921 int i;
3922 drflac_uint32 riceParamMask;
3923 drflac_int32* pDecodedSamples = pSamplesOut;
3924 drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
3925 drflac_uint32 zeroCountParts0 = 0;
3926 drflac_uint32 zeroCountParts1 = 0;
3927 drflac_uint32 zeroCountParts2 = 0;
3928 drflac_uint32 zeroCountParts3 = 0;
3929 drflac_uint32 riceParamParts0 = 0;
3930 drflac_uint32 riceParamParts1 = 0;
3931 drflac_uint32 riceParamParts2 = 0;
3932 drflac_uint32 riceParamParts3 = 0;
3933 __m128i coefficients128_0;
3934 __m128i coefficients128_4;
3935 __m128i coefficients128_8;
3936 __m128i samples128_0;
3937 __m128i samples128_4;
3938 __m128i samples128_8;
3939 __m128i riceParamMask128;
3940
3941 const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
3942
3943 riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
3944 riceParamMask128 = _mm_set1_epi32(riceParamMask);
3945
3946 /* Pre-load. */
3947 coefficients128_0 = _mm_setzero_si128();
3948 coefficients128_4 = _mm_setzero_si128();
3949 coefficients128_8 = _mm_setzero_si128();
3950
3951 samples128_0 = _mm_setzero_si128();
3952 samples128_4 = _mm_setzero_si128();
3953 samples128_8 = _mm_setzero_si128();
3954
3955 /*
3956 Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
3957 what's available in the input buffers. It would be convenient to use a fall-through switch to do this, but this results
3958 in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
3959 so I think there's opportunity for this to be simplified.
3960 */
3961#if 1
3962 {
3963 int runningOrder = order;
3964
3965 /* 0 - 3. */
3966 if (runningOrder >= 4) {
3967 coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
3968 samples128_0 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 4));
3969 runningOrder -= 4;
3970 } else {
3971 switch (runningOrder) {
3972 case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
3973 case 2: coefficients128_0 = _mm_set_epi32(0, 0, coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0, 0); break;
3974 case 1: coefficients128_0 = _mm_set_epi32(0, 0, 0, coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0, 0, 0); break;
3975 }
3976 runningOrder = 0;
3977 }
3978
3979 /* 4 - 7 */
3980 if (runningOrder >= 4) {
3981 coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
3982 samples128_4 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 8));
3983 runningOrder -= 4;
3984 } else {
3985 switch (runningOrder) {
3986 case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
3987 case 2: coefficients128_4 = _mm_set_epi32(0, 0, coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0, 0); break;
3988 case 1: coefficients128_4 = _mm_set_epi32(0, 0, 0, coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0, 0, 0); break;
3989 }
3990 runningOrder = 0;
3991 }
3992
3993 /* 8 - 11 */
3994 if (runningOrder == 4) {
3995 coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
3996 samples128_8 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 12));
3997 runningOrder -= 4;
3998 } else {
3999 switch (runningOrder) {
4000 case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
4001 case 2: coefficients128_8 = _mm_set_epi32(0, 0, coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0, 0); break;
4002 case 1: coefficients128_8 = _mm_set_epi32(0, 0, 0, coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0, 0, 0); break;
4003 }
4004 runningOrder = 0;
4005 }
4006
4007 /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
4008 coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
4009 coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
4010 coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
4011 }
4012#else
4013 /* This causes strict-aliasing warnings with GCC. */
4014 switch (order)
4015 {
4016 case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
4017 case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
4018 case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
4019 case 9: ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
4020 case 8: ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
4021 case 7: ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
4022 case 6: ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
4023 case 5: ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
4024 case 4: ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
4025 case 3: ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
4026 case 2: ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
4027 case 1: ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
4028 }
4029#endif
4030
4031 /* For this version we are doing one sample at a time. */
4032 while (pDecodedSamples < pDecodedSamplesEnd) {
4033 __m128i prediction128;
4034 __m128i zeroCountPart128;
4035 __m128i riceParamPart128;
4036
4037 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
4038 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
4039 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
4040 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
4041 return DRFLAC_FALSE;
4042 }
4043
4044 zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
4045 riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
4046
4047 riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
4048 riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
4049 riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01))), _mm_set1_epi32(0x01))); /* <-- SSE2 compatible */
4050 /*riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_mullo_epi32(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01)), _mm_set1_epi32(0xFFFFFFFF)));*/ /* <-- Only supported from SSE4.1 and is slower in my testing... */
4051
4052 if (order <= 4) {
4053 for (i = 0; i < 4; i += 1) {
4054 prediction128 = _mm_mullo_epi32(coefficients128_0, samples128_0);
4055
4056 /* Horizontal add and shift. */
4057 prediction128 = drflac__mm_hadd_epi32(prediction128);
4058 prediction128 = _mm_srai_epi32(prediction128, shift);
4059 prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
4060
4061 samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
4062 riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
4063 }
4064 } else if (order <= 8) {
4065 for (i = 0; i < 4; i += 1) {
4066 prediction128 = _mm_mullo_epi32(coefficients128_4, samples128_4);
4067 prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
4068
4069 /* Horizontal add and shift. */
4070 prediction128 = drflac__mm_hadd_epi32(prediction128);
4071 prediction128 = _mm_srai_epi32(prediction128, shift);
4072 prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
4073
4074 samples128_4 = _mm_alignr_epi8(samples128_0, samples128_4, 4);
4075 samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
4076 riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
4077 }
4078 } else {
4079 for (i = 0; i < 4; i += 1) {
4080 prediction128 = _mm_mullo_epi32(coefficients128_8, samples128_8);
4081 prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_4, samples128_4));
4082 prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
4083
4084 /* Horizontal add and shift. */
4085 prediction128 = drflac__mm_hadd_epi32(prediction128);
4086 prediction128 = _mm_srai_epi32(prediction128, shift);
4087 prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
4088
4089 samples128_8 = _mm_alignr_epi8(samples128_4, samples128_8, 4);
4090 samples128_4 = _mm_alignr_epi8(samples128_0, samples128_4, 4);
4091 samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
4092 riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
4093 }
4094 }
4095
4096 /* We store samples in groups of 4. */
4097 _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
4098 pDecodedSamples += 4;
4099 }
4100
4101 /* Make sure we process the last few samples. */
4102 i = (count & ~3);
4103 while (i < (int)count) {
4104 /* Rice extraction. */
4105 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
4106 return DRFLAC_FALSE;
4107 }
4108
4109 /* Rice reconstruction. */
4110 riceParamParts0 &= riceParamMask;
4111 riceParamParts0 |= (zeroCountParts0 << riceParam);
4112 riceParamParts0 = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
4113
4114 /* Sample reconstruction. */
4115 pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
4116
4117 i += 1;
4118 pDecodedSamples += 1;
4119 }
4120
4121 return DRFLAC_TRUE;
4122}
4123
4124static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
4125{
4126 int i;
4127 drflac_uint32 riceParamMask;
4128 drflac_int32* pDecodedSamples = pSamplesOut;
4129 drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
4130 drflac_uint32 zeroCountParts0 = 0;
4131 drflac_uint32 zeroCountParts1 = 0;
4132 drflac_uint32 zeroCountParts2 = 0;
4133 drflac_uint32 zeroCountParts3 = 0;
4134 drflac_uint32 riceParamParts0 = 0;
4135 drflac_uint32 riceParamParts1 = 0;
4136 drflac_uint32 riceParamParts2 = 0;
4137 drflac_uint32 riceParamParts3 = 0;
4138 __m128i coefficients128_0;
4139 __m128i coefficients128_4;
4140 __m128i coefficients128_8;
4141 __m128i samples128_0;
4142 __m128i samples128_4;
4143 __m128i samples128_8;
4144 __m128i prediction128;
4145 __m128i riceParamMask128;
4146
4147 const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
4148
4149 DRFLAC_ASSERT(order <= 12);
4150
4151 riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
4152 riceParamMask128 = _mm_set1_epi32(riceParamMask);
4153
4154 prediction128 = _mm_setzero_si128();
4155
4156 /* Pre-load. */
4157 coefficients128_0 = _mm_setzero_si128();
4158 coefficients128_4 = _mm_setzero_si128();
4159 coefficients128_8 = _mm_setzero_si128();
4160
4161 samples128_0 = _mm_setzero_si128();
4162 samples128_4 = _mm_setzero_si128();
4163 samples128_8 = _mm_setzero_si128();
4164
4165#if 1
4166 {
4167 int runningOrder = order;
4168
4169 /* 0 - 3. */
4170 if (runningOrder >= 4) {
4171 coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
4172 samples128_0 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 4));
4173 runningOrder -= 4;
4174 } else {
4175 switch (runningOrder) {
4176 case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
4177 case 2: coefficients128_0 = _mm_set_epi32(0, 0, coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0, 0); break;
4178 case 1: coefficients128_0 = _mm_set_epi32(0, 0, 0, coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0, 0, 0); break;
4179 }
4180 runningOrder = 0;
4181 }
4182
4183 /* 4 - 7 */
4184 if (runningOrder >= 4) {
4185 coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
4186 samples128_4 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 8));
4187 runningOrder -= 4;
4188 } else {
4189 switch (runningOrder) {
4190 case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
4191 case 2: coefficients128_4 = _mm_set_epi32(0, 0, coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0, 0); break;
4192 case 1: coefficients128_4 = _mm_set_epi32(0, 0, 0, coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0, 0, 0); break;
4193 }
4194 runningOrder = 0;
4195 }
4196
4197 /* 8 - 11 */
4198 if (runningOrder == 4) {
4199 coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
4200 samples128_8 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 12));
4201 runningOrder -= 4;
4202 } else {
4203 switch (runningOrder) {
4204 case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
4205 case 2: coefficients128_8 = _mm_set_epi32(0, 0, coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0, 0); break;
4206 case 1: coefficients128_8 = _mm_set_epi32(0, 0, 0, coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0, 0, 0); break;
4207 }
4208 runningOrder = 0;
4209 }
4210
4211 /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
4212 coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
4213 coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
4214 coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
4215 }
4216#else
4217 switch (order)
4218 {
4219 case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
4220 case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
4221 case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
4222 case 9: ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
4223 case 8: ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
4224 case 7: ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
4225 case 6: ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
4226 case 5: ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
4227 case 4: ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
4228 case 3: ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
4229 case 2: ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
4230 case 1: ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
4231 }
4232#endif
4233
4234 /* For this version we are doing one sample at a time. */
4235 while (pDecodedSamples < pDecodedSamplesEnd) {
4236 __m128i zeroCountPart128;
4237 __m128i riceParamPart128;
4238
4239 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
4240 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
4241 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
4242 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
4243 return DRFLAC_FALSE;
4244 }
4245
4246 zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
4247 riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
4248
4249 riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
4250 riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
4251 riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(1))), _mm_set1_epi32(1)));
4252
4253 for (i = 0; i < 4; i += 1) {
4254 prediction128 = _mm_xor_si128(prediction128, prediction128); /* Reset to 0. */
4255
4256 switch (order)
4257 {
4258 case 12:
4259 case 11: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(1, 1, 0, 0))));
4260 case 10:
4261 case 9: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(3, 3, 2, 2))));
4262 case 8:
4263 case 7: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(1, 1, 0, 0))));
4264 case 6:
4265 case 5: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(3, 3, 2, 2))));
4266 case 4:
4267 case 3: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(1, 1, 0, 0))));
4268 case 2:
4269 case 1: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(3, 3, 2, 2))));
4270 }
4271
4272 /* Horizontal add and shift. */
4273 prediction128 = drflac__mm_hadd_epi64(prediction128);
4274 prediction128 = drflac__mm_srai_epi64(prediction128, shift);
4275 prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
4276
4277 /* Our value should be sitting in prediction128[0]. We need to combine this with our SSE samples. */
4278 samples128_8 = _mm_alignr_epi8(samples128_4, samples128_8, 4);
4279 samples128_4 = _mm_alignr_epi8(samples128_0, samples128_4, 4);
4280 samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
4281
4282 /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
4283 riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
4284 }
4285
4286 /* We store samples in groups of 4. */
4287 _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
4288 pDecodedSamples += 4;
4289 }
4290
4291 /* Make sure we process the last few samples. */
4292 i = (count & ~3);
4293 while (i < (int)count) {
4294 /* Rice extraction. */
4295 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
4296 return DRFLAC_FALSE;
4297 }
4298
4299 /* Rice reconstruction. */
4300 riceParamParts0 &= riceParamMask;
4301 riceParamParts0 |= (zeroCountParts0 << riceParam);
4302 riceParamParts0 = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
4303
4304 /* Sample reconstruction. */
4305 pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
4306
4307 i += 1;
4308 pDecodedSamples += 1;
4309 }
4310
4311 return DRFLAC_TRUE;
4312}
4313
4314static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
4315{
4316 DRFLAC_ASSERT(bs != NULL);
4317 DRFLAC_ASSERT(pSamplesOut != NULL);
4318
4319 /* In my testing the order is rarely > 12, so in this case I'm going to simplify the SSE implementation by only handling order <= 12. */
4320 if (lpcOrder > 0 && lpcOrder <= 12) {
4321 if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
4322 return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
4323 } else {
4324 return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
4325 }
4326 } else {
4327 return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
4328 }
4329}
4330#endif
4331
4332#if defined(DRFLAC_SUPPORT_NEON)
4333static DRFLAC_INLINE void drflac__vst2q_s32(drflac_int32* p, int32x4x2_t x)
4334{
4335 vst1q_s32(p+0, x.val[0]);
4336 vst1q_s32(p+4, x.val[1]);
4337}
4338
4339static DRFLAC_INLINE void drflac__vst2q_u32(drflac_uint32* p, uint32x4x2_t x)
4340{
4341 vst1q_u32(p+0, x.val[0]);
4342 vst1q_u32(p+4, x.val[1]);
4343}
4344
4345static DRFLAC_INLINE void drflac__vst2q_f32(float* p, float32x4x2_t x)
4346{
4347 vst1q_f32(p+0, x.val[0]);
4348 vst1q_f32(p+4, x.val[1]);
4349}
4350
4351static DRFLAC_INLINE void drflac__vst2q_s16(drflac_int16* p, int16x4x2_t x)
4352{
4353 vst1q_s16(p, vcombine_s16(x.val[0], x.val[1]));
4354}
4355
4356static DRFLAC_INLINE void drflac__vst2q_u16(drflac_uint16* p, uint16x4x2_t x)
4357{
4358 vst1q_u16(p, vcombine_u16(x.val[0], x.val[1]));
4359}
4360
4361static DRFLAC_INLINE int32x4_t drflac__vdupq_n_s32x4(drflac_int32 x3, drflac_int32 x2, drflac_int32 x1, drflac_int32 x0)
4362{
4363 drflac_int32 x[4];
4364 x[3] = x3;
4365 x[2] = x2;
4366 x[1] = x1;
4367 x[0] = x0;
4368 return vld1q_s32(x);
4369}
4370
4371static DRFLAC_INLINE int32x4_t drflac__valignrq_s32_1(int32x4_t a, int32x4_t b)
4372{
4373 /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
4374
4375 /* Reference */
4376 /*return drflac__vdupq_n_s32x4(
4377 vgetq_lane_s32(a, 0),
4378 vgetq_lane_s32(b, 3),
4379 vgetq_lane_s32(b, 2),
4380 vgetq_lane_s32(b, 1)
4381 );*/
4382
4383 return vextq_s32(b, a, 1);
4384}
4385
4386static DRFLAC_INLINE uint32x4_t drflac__valignrq_u32_1(uint32x4_t a, uint32x4_t b)
4387{
4388 /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
4389
4390 /* Reference */
4391 /*return drflac__vdupq_n_s32x4(
4392 vgetq_lane_s32(a, 0),
4393 vgetq_lane_s32(b, 3),
4394 vgetq_lane_s32(b, 2),
4395 vgetq_lane_s32(b, 1)
4396 );*/
4397
4398 return vextq_u32(b, a, 1);
4399}
4400
4401static DRFLAC_INLINE int32x2_t drflac__vhaddq_s32(int32x4_t x)
4402{
4403 /* The sum must end up in position 0. */
4404
4405 /* Reference */
4406 /*return vdupq_n_s32(
4407 vgetq_lane_s32(x, 3) +
4408 vgetq_lane_s32(x, 2) +
4409 vgetq_lane_s32(x, 1) +
4410 vgetq_lane_s32(x, 0)
4411 );*/
4412
4413 int32x2_t r = vadd_s32(vget_high_s32(x), vget_low_s32(x));
4414 return vpadd_s32(r, r);
4415}
4416
4417static DRFLAC_INLINE int64x1_t drflac__vhaddq_s64(int64x2_t x)
4418{
4419 return vadd_s64(vget_high_s64(x), vget_low_s64(x));
4420}
4421
4422static DRFLAC_INLINE int32x4_t drflac__vrevq_s32(int32x4_t x)
4423{
4424 /* Reference */
4425 /*return drflac__vdupq_n_s32x4(
4426 vgetq_lane_s32(x, 0),
4427 vgetq_lane_s32(x, 1),
4428 vgetq_lane_s32(x, 2),
4429 vgetq_lane_s32(x, 3)
4430 );*/
4431
4432 return vrev64q_s32(vcombine_s32(vget_high_s32(x), vget_low_s32(x)));
4433}
4434
4435static DRFLAC_INLINE int32x4_t drflac__vnotq_s32(int32x4_t x)
4436{
4437 return veorq_s32(x, vdupq_n_s32(0xFFFFFFFF));
4438}
4439
4440static DRFLAC_INLINE uint32x4_t drflac__vnotq_u32(uint32x4_t x)
4441{
4442 return veorq_u32(x, vdupq_n_u32(0xFFFFFFFF));
4443}
4444
4445static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
4446{
4447 int i;
4448 drflac_uint32 riceParamMask;
4449 drflac_int32* pDecodedSamples = pSamplesOut;
4450 drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
4451 drflac_uint32 zeroCountParts[4];
4452 drflac_uint32 riceParamParts[4];
4453 int32x4_t coefficients128_0;
4454 int32x4_t coefficients128_4;
4455 int32x4_t coefficients128_8;
4456 int32x4_t samples128_0;
4457 int32x4_t samples128_4;
4458 int32x4_t samples128_8;
4459 uint32x4_t riceParamMask128;
4460 int32x4_t riceParam128;
4461 int32x2_t shift64;
4462 uint32x4_t one128;
4463
4464 const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
4465
4466 riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
4467 riceParamMask128 = vdupq_n_u32(riceParamMask);
4468
4469 riceParam128 = vdupq_n_s32(riceParam);
4470 shift64 = vdup_n_s32(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
4471 one128 = vdupq_n_u32(1);
4472
4473 /*
4474 Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
4475 what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
4476 in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
4477 so I think there's opportunity for this to be simplified.
4478 */
4479 {
4480 int runningOrder = order;
4481 drflac_int32 tempC[4] = {0, 0, 0, 0};
4482 drflac_int32 tempS[4] = {0, 0, 0, 0};
4483
4484 /* 0 - 3. */
4485 if (runningOrder >= 4) {
4486 coefficients128_0 = vld1q_s32(coefficients + 0);
4487 samples128_0 = vld1q_s32(pSamplesOut - 4);
4488 runningOrder -= 4;
4489 } else {
4490 switch (runningOrder) {
4491 case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
4492 case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
4493 case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
4494 }
4495
4496 coefficients128_0 = vld1q_s32(tempC);
4497 samples128_0 = vld1q_s32(tempS);
4498 runningOrder = 0;
4499 }
4500
4501 /* 4 - 7 */
4502 if (runningOrder >= 4) {
4503 coefficients128_4 = vld1q_s32(coefficients + 4);
4504 samples128_4 = vld1q_s32(pSamplesOut - 8);
4505 runningOrder -= 4;
4506 } else {
4507 switch (runningOrder) {
4508 case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
4509 case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
4510 case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
4511 }
4512
4513 coefficients128_4 = vld1q_s32(tempC);
4514 samples128_4 = vld1q_s32(tempS);
4515 runningOrder = 0;
4516 }
4517
4518 /* 8 - 11 */
4519 if (runningOrder == 4) {
4520 coefficients128_8 = vld1q_s32(coefficients + 8);
4521 samples128_8 = vld1q_s32(pSamplesOut - 12);
4522 runningOrder -= 4;
4523 } else {
4524 switch (runningOrder) {
4525 case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
4526 case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
4527 case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
4528 }
4529
4530 coefficients128_8 = vld1q_s32(tempC);
4531 samples128_8 = vld1q_s32(tempS);
4532 runningOrder = 0;
4533 }
4534
4535 /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
4536 coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
4537 coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
4538 coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
4539 }
4540
4541 /* For this version we are doing one sample at a time. */
4542 while (pDecodedSamples < pDecodedSamplesEnd) {
4543 int32x4_t prediction128;
4544 int32x2_t prediction64;
4545 uint32x4_t zeroCountPart128;
4546 uint32x4_t riceParamPart128;
4547
4548 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
4549 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
4550 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
4551 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
4552 return DRFLAC_FALSE;
4553 }
4554
4555 zeroCountPart128 = vld1q_u32(zeroCountParts);
4556 riceParamPart128 = vld1q_u32(riceParamParts);
4557
4558 riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
4559 riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
4560 riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
4561
4562 if (order <= 4) {
4563 for (i = 0; i < 4; i += 1) {
4564 prediction128 = vmulq_s32(coefficients128_0, samples128_0);
4565
4566 /* Horizontal add and shift. */
4567 prediction64 = drflac__vhaddq_s32(prediction128);
4568 prediction64 = vshl_s32(prediction64, shift64);
4569 prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
4570
4571 samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
4572 riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
4573 }
4574 } else if (order <= 8) {
4575 for (i = 0; i < 4; i += 1) {
4576 prediction128 = vmulq_s32(coefficients128_4, samples128_4);
4577 prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
4578
4579 /* Horizontal add and shift. */
4580 prediction64 = drflac__vhaddq_s32(prediction128);
4581 prediction64 = vshl_s32(prediction64, shift64);
4582 prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
4583
4584 samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
4585 samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
4586 riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
4587 }
4588 } else {
4589 for (i = 0; i < 4; i += 1) {
4590 prediction128 = vmulq_s32(coefficients128_8, samples128_8);
4591 prediction128 = vmlaq_s32(prediction128, coefficients128_4, samples128_4);
4592 prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
4593
4594 /* Horizontal add and shift. */
4595 prediction64 = drflac__vhaddq_s32(prediction128);
4596 prediction64 = vshl_s32(prediction64, shift64);
4597 prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
4598
4599 samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
4600 samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
4601 samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
4602 riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
4603 }
4604 }
4605
4606 /* We store samples in groups of 4. */
4607 vst1q_s32(pDecodedSamples, samples128_0);
4608 pDecodedSamples += 4;
4609 }
4610
4611 /* Make sure we process the last few samples. */
4612 i = (count & ~3);
4613 while (i < (int)count) {
4614 /* Rice extraction. */
4615 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
4616 return DRFLAC_FALSE;
4617 }
4618
4619 /* Rice reconstruction. */
4620 riceParamParts[0] &= riceParamMask;
4621 riceParamParts[0] |= (zeroCountParts[0] << riceParam);
4622 riceParamParts[0] = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
4623
4624 /* Sample reconstruction. */
4625 pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
4626
4627 i += 1;
4628 pDecodedSamples += 1;
4629 }
4630
4631 return DRFLAC_TRUE;
4632}
4633
4634static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
4635{
4636 int i;
4637 drflac_uint32 riceParamMask;
4638 drflac_int32* pDecodedSamples = pSamplesOut;
4639 drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
4640 drflac_uint32 zeroCountParts[4];
4641 drflac_uint32 riceParamParts[4];
4642 int32x4_t coefficients128_0;
4643 int32x4_t coefficients128_4;
4644 int32x4_t coefficients128_8;
4645 int32x4_t samples128_0;
4646 int32x4_t samples128_4;
4647 int32x4_t samples128_8;
4648 uint32x4_t riceParamMask128;
4649 int32x4_t riceParam128;
4650 int64x1_t shift64;
4651 uint32x4_t one128;
4652 int64x2_t prediction128 = { 0 };
4653 uint32x4_t zeroCountPart128;
4654 uint32x4_t riceParamPart128;
4655
4656 const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
4657
4658 riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
4659 riceParamMask128 = vdupq_n_u32(riceParamMask);
4660
4661 riceParam128 = vdupq_n_s32(riceParam);
4662 shift64 = vdup_n_s64(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
4663 one128 = vdupq_n_u32(1);
4664
4665 /*
4666 Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
4667 what's available in the input buffers. It would be convenient to use a fall-through switch to do this, but this results
4668 in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
4669 so I think there's opportunity for this to be simplified.
4670 */
4671 {
4672 int runningOrder = order;
4673 drflac_int32 tempC[4] = {0, 0, 0, 0};
4674 drflac_int32 tempS[4] = {0, 0, 0, 0};
4675
4676 /* 0 - 3. */
4677 if (runningOrder >= 4) {
4678 coefficients128_0 = vld1q_s32(coefficients + 0);
4679 samples128_0 = vld1q_s32(pSamplesOut - 4);
4680 runningOrder -= 4;
4681 } else {
4682 switch (runningOrder) {
4683 case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
4684 case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
4685 case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
4686 }
4687
4688 coefficients128_0 = vld1q_s32(tempC);
4689 samples128_0 = vld1q_s32(tempS);
4690 runningOrder = 0;
4691 }
4692
4693 /* 4 - 7 */
4694 if (runningOrder >= 4) {
4695 coefficients128_4 = vld1q_s32(coefficients + 4);
4696 samples128_4 = vld1q_s32(pSamplesOut - 8);
4697 runningOrder -= 4;
4698 } else {
4699 switch (runningOrder) {
4700 case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
4701 case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
4702 case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
4703 }
4704
4705 coefficients128_4 = vld1q_s32(tempC);
4706 samples128_4 = vld1q_s32(tempS);
4707 runningOrder = 0;
4708 }
4709
4710 /* 8 - 11 */
4711 if (runningOrder == 4) {
4712 coefficients128_8 = vld1q_s32(coefficients + 8);
4713 samples128_8 = vld1q_s32(pSamplesOut - 12);
4714 runningOrder -= 4;
4715 } else {
4716 switch (runningOrder) {
4717 case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
4718 case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
4719 case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
4720 }
4721
4722 coefficients128_8 = vld1q_s32(tempC);
4723 samples128_8 = vld1q_s32(tempS);
4724 runningOrder = 0;
4725 }
4726
4727 /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
4728 coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
4729 coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
4730 coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
4731 }
4732
4733 /* For this version we are doing one sample at a time. */
4734 while (pDecodedSamples < pDecodedSamplesEnd) {
4735 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
4736 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
4737 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
4738 !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
4739 return DRFLAC_FALSE;
4740 }
4741
4742 zeroCountPart128 = vld1q_u32(zeroCountParts);
4743 riceParamPart128 = vld1q_u32(riceParamParts);
4744
4745 riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
4746 riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
4747 riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
4748
4749 for (i = 0; i < 4; i += 1) {
4750 int64x1_t prediction64;
4751
4752 prediction128 = veorq_s64(prediction128, prediction128); /* Reset to 0. */
4753 switch (order)
4754 {
4755 case 12:
4756 case 11: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_8), vget_low_s32(samples128_8)));
4757 case 10:
4758 case 9: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_8), vget_high_s32(samples128_8)));
4759 case 8:
4760 case 7: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_4), vget_low_s32(samples128_4)));
4761 case 6:
4762 case 5: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_4), vget_high_s32(samples128_4)));
4763 case 4:
4764 case 3: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_0), vget_low_s32(samples128_0)));
4765 case 2:
4766 case 1: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_0), vget_high_s32(samples128_0)));
4767 }
4768
4769 /* Horizontal add and shift. */
4770 prediction64 = drflac__vhaddq_s64(prediction128);
4771 prediction64 = vshl_s64(prediction64, shift64);
4772 prediction64 = vadd_s64(prediction64, vdup_n_s64(vgetq_lane_u32(riceParamPart128, 0)));
4773
4774 /* Our value should be sitting in prediction64[0]. We need to combine this with our SSE samples. */
4775 samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
4776 samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
4777 samples128_0 = drflac__valignrq_s32_1(vcombine_s32(vreinterpret_s32_s64(prediction64), vdup_n_s32(0)), samples128_0);
4778
4779 /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
4780 riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
4781 }
4782
4783 /* We store samples in groups of 4. */
4784 vst1q_s32(pDecodedSamples, samples128_0);
4785 pDecodedSamples += 4;
4786 }
4787
4788 /* Make sure we process the last few samples. */
4789 i = (count & ~3);
4790 while (i < (int)count) {
4791 /* Rice extraction. */
4792 if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
4793 return DRFLAC_FALSE;
4794 }
4795
4796 /* Rice reconstruction. */
4797 riceParamParts[0] &= riceParamMask;
4798 riceParamParts[0] |= (zeroCountParts[0] << riceParam);
4799 riceParamParts[0] = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
4800
4801 /* Sample reconstruction. */
4802 pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
4803
4804 i += 1;
4805 pDecodedSamples += 1;
4806 }
4807
4808 return DRFLAC_TRUE;
4809}
4810
4811static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
4812{
4813 DRFLAC_ASSERT(bs != NULL);
4814 DRFLAC_ASSERT(pSamplesOut != NULL);
4815
4816 /* In my testing the order is rarely > 12, so in this case I'm going to simplify the NEON implementation by only handling order <= 12. */
4817 if (lpcOrder > 0 && lpcOrder <= 12) {
4818 if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
4819 return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
4820 } else {
4821 return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
4822 }
4823 } else {
4824 return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
4825 }
4826}
4827#endif
4828
4829static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
4830{
4831#if defined(DRFLAC_SUPPORT_SSE41)
4832 if (drflac__gIsSSE41Supported) {
4833 return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
4834 } else
4835#elif defined(DRFLAC_SUPPORT_NEON)
4836 if (drflac__gIsNEONSupported) {
4837 return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
4838 } else
4839#endif
4840 {
4841 /* Scalar fallback. */
4842 #if 0
4843 return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
4844 #else
4845 return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
4846 #endif
4847 }
4848}
4849
4850/* Reads and seeks past a string of residual values as Rice codes. The decoder should be sitting on the first bit of the Rice codes. */
4851static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam)
4852{
4853 drflac_uint32 i;
4854
4855 DRFLAC_ASSERT(bs != NULL);
4856
4857 for (i = 0; i < count; ++i) {
4858 if (!drflac__seek_rice_parts(bs, riceParam)) {
4859 return DRFLAC_FALSE;
4860 }
4861 }
4862
4863 return DRFLAC_TRUE;
4864}
4865
4866#if defined(__clang__)
4867__attribute__((no_sanitize("signed-integer-overflow")))
4868#endif
4869static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
4870{
4871 drflac_uint32 i;
4872
4873 DRFLAC_ASSERT(bs != NULL);
4874 DRFLAC_ASSERT(unencodedBitsPerSample <= 31); /* <-- unencodedBitsPerSample is a 5 bit number, so cannot exceed 31. */
4875 DRFLAC_ASSERT(pSamplesOut != NULL);
4876
4877 for (i = 0; i < count; ++i) {
4878 if (unencodedBitsPerSample > 0) {
4879 if (!drflac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) {
4880 return DRFLAC_FALSE;
4881 }
4882 } else {
4883 pSamplesOut[i] = 0;
4884 }
4885
4886 if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
4887 pSamplesOut[i] += drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
4888 } else {
4889 pSamplesOut[i] += drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
4890 }
4891 }
4892
4893 return DRFLAC_TRUE;
4894}
4895
4896
4897/*
4898Reads and decodes the residual for the sub-frame the decoder is currently sitting on. This function should be called
4899when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be ignored. The
4900<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
4901*/
4902static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
4903{
4904 drflac_uint8 residualMethod;
4905 drflac_uint8 partitionOrder;
4906 drflac_uint32 samplesInPartition;
4907 drflac_uint32 partitionsRemaining;
4908
4909 DRFLAC_ASSERT(bs != NULL);
4910 DRFLAC_ASSERT(blockSize != 0);
4911 DRFLAC_ASSERT(pDecodedSamples != NULL); /* <-- Should we allow NULL, in which case we just seek past the residual rather than do a full decode? */
4912
4913 if (!drflac__read_uint8(bs, 2, &residualMethod)) {
4914 return DRFLAC_FALSE;
4915 }
4916
4917 if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
4918 return DRFLAC_FALSE; /* Unknown or unsupported residual coding method. */
4919 }
4920
4921 /* Ignore the first <order> values. */
4922 pDecodedSamples += lpcOrder;
4923
4924 if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
4925 return DRFLAC_FALSE;
4926 }
4927
4928 /*
4929 From the FLAC spec:
4930 The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
4931 */
4932 if (partitionOrder > 8) {
4933 return DRFLAC_FALSE;
4934 }
4935
4936 /* Validation check. */
4937 if ((blockSize / (1 << partitionOrder)) < lpcOrder) {
4938 return DRFLAC_FALSE;
4939 }
4940
4941 samplesInPartition = (blockSize / (1 << partitionOrder)) - lpcOrder;
4942 partitionsRemaining = (1 << partitionOrder);
4943 for (;;) {
4944 drflac_uint8 riceParam = 0;
4945 if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
4946 if (!drflac__read_uint8(bs, 4, &riceParam)) {
4947 return DRFLAC_FALSE;
4948 }
4949 if (riceParam == 15) {
4950 riceParam = 0xFF;
4951 }
4952 } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
4953 if (!drflac__read_uint8(bs, 5, &riceParam)) {
4954 return DRFLAC_FALSE;
4955 }
4956 if (riceParam == 31) {
4957 riceParam = 0xFF;
4958 }
4959 }
4960
4961 if (riceParam != 0xFF) {
4962 if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
4963 return DRFLAC_FALSE;
4964 }
4965 } else {
4966 drflac_uint8 unencodedBitsPerSample = 0;
4967 if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
4968 return DRFLAC_FALSE;
4969 }
4970
4971 if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
4972 return DRFLAC_FALSE;
4973 }
4974 }
4975
4976 pDecodedSamples += samplesInPartition;
4977
4978 if (partitionsRemaining == 1) {
4979 break;
4980 }
4981
4982 partitionsRemaining -= 1;
4983
4984 if (partitionOrder != 0) {
4985 samplesInPartition = blockSize / (1 << partitionOrder);
4986 }
4987 }
4988
4989 return DRFLAC_TRUE;
4990}
4991
4992/*
4993Reads and seeks past the residual for the sub-frame the decoder is currently sitting on. This function should be called
4994when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be set to 0. The
4995<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
4996*/
4997static drflac_bool32 drflac__read_and_seek_residual(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 order)
4998{
4999 drflac_uint8 residualMethod;
5000 drflac_uint8 partitionOrder;
5001 drflac_uint32 samplesInPartition;
5002 drflac_uint32 partitionsRemaining;
5003
5004 DRFLAC_ASSERT(bs != NULL);
5005 DRFLAC_ASSERT(blockSize != 0);
5006
5007 if (!drflac__read_uint8(bs, 2, &residualMethod)) {
5008 return DRFLAC_FALSE;
5009 }
5010
5011 if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
5012 return DRFLAC_FALSE; /* Unknown or unsupported residual coding method. */
5013 }
5014
5015 if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
5016 return DRFLAC_FALSE;
5017 }
5018
5019 /*
5020 From the FLAC spec:
5021 The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
5022 */
5023 if (partitionOrder > 8) {
5024 return DRFLAC_FALSE;
5025 }
5026
5027 /* Validation check. */
5028 if ((blockSize / (1 << partitionOrder)) <= order) {
5029 return DRFLAC_FALSE;
5030 }
5031
5032 samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
5033 partitionsRemaining = (1 << partitionOrder);
5034 for (;;)
5035 {
5036 drflac_uint8 riceParam = 0;
5037 if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
5038 if (!drflac__read_uint8(bs, 4, &riceParam)) {
5039 return DRFLAC_FALSE;
5040 }
5041 if (riceParam == 15) {
5042 riceParam = 0xFF;
5043 }
5044 } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
5045 if (!drflac__read_uint8(bs, 5, &riceParam)) {
5046 return DRFLAC_FALSE;
5047 }
5048 if (riceParam == 31) {
5049 riceParam = 0xFF;
5050 }
5051 }
5052
5053 if (riceParam != 0xFF) {
5054 if (!drflac__read_and_seek_residual__rice(bs, samplesInPartition, riceParam)) {
5055 return DRFLAC_FALSE;
5056 }
5057 } else {
5058 drflac_uint8 unencodedBitsPerSample = 0;
5059 if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
5060 return DRFLAC_FALSE;
5061 }
5062
5063 if (!drflac__seek_bits(bs, unencodedBitsPerSample * samplesInPartition)) {
5064 return DRFLAC_FALSE;
5065 }
5066 }
5067
5068
5069 if (partitionsRemaining == 1) {
5070 break;
5071 }
5072
5073 partitionsRemaining -= 1;
5074 samplesInPartition = blockSize / (1 << partitionOrder);
5075 }
5076
5077 return DRFLAC_TRUE;
5078}
5079
5080
5081static drflac_bool32 drflac__decode_samples__constant(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
5082{
5083 drflac_uint32 i;
5084
5085 /* Only a single sample needs to be decoded here. */
5086 drflac_int32 sample;
5087 if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
5088 return DRFLAC_FALSE;
5089 }
5090
5091 /*
5092 We don't really need to expand this, but it does simplify the process of reading samples. If this becomes a performance issue (unlikely)
5093 we'll want to look at a more efficient way.
5094 */
5095 for (i = 0; i < blockSize; ++i) {
5096 pDecodedSamples[i] = sample;
5097 }
5098
5099 return DRFLAC_TRUE;
5100}
5101
5102static drflac_bool32 drflac__decode_samples__verbatim(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
5103{
5104 drflac_uint32 i;
5105
5106 for (i = 0; i < blockSize; ++i) {
5107 drflac_int32 sample;
5108 if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
5109 return DRFLAC_FALSE;
5110 }
5111
5112 pDecodedSamples[i] = sample;
5113 }
5114
5115 return DRFLAC_TRUE;
5116}
5117
5118static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
5119{
5120 drflac_uint32 i;
5121
5122 static drflac_int32 lpcCoefficientsTable[5][4] = {
5123 {0, 0, 0, 0},
5124 {1, 0, 0, 0},
5125 {2, -1, 0, 0},
5126 {3, -3, 1, 0},
5127 {4, -6, 4, -1}
5128 };
5129
5130 /* Warm up samples and coefficients. */
5131 for (i = 0; i < lpcOrder; ++i) {
5132 drflac_int32 sample;
5133 if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
5134 return DRFLAC_FALSE;
5135 }
5136
5137 pDecodedSamples[i] = sample;
5138 }
5139
5140 if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, 4, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
5141 return DRFLAC_FALSE;
5142 }
5143
5144 return DRFLAC_TRUE;
5145}
5146
5147static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 bitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
5148{
5149 drflac_uint8 i;
5150 drflac_uint8 lpcPrecision;
5151 drflac_int8 lpcShift;
5152 drflac_int32 coefficients[32];
5153
5154 /* Warm up samples. */
5155 for (i = 0; i < lpcOrder; ++i) {
5156 drflac_int32 sample;
5157 if (!drflac__read_int32(bs, bitsPerSample, &sample)) {
5158 return DRFLAC_FALSE;
5159 }
5160
5161 pDecodedSamples[i] = sample;
5162 }
5163
5164 if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
5165 return DRFLAC_FALSE;
5166 }
5167 if (lpcPrecision == 15) {
5168 return DRFLAC_FALSE; /* Invalid. */
5169 }
5170 lpcPrecision += 1;
5171
5172 if (!drflac__read_int8(bs, 5, &lpcShift)) {
5173 return DRFLAC_FALSE;
5174 }
5175
5176 /*
5177 From the FLAC specification:
5178
5179 Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement)
5180
5181 Emphasis on the "signed two's-complement". In practice there does not seem to be any encoders nor decoders supporting negative shifts. For now dr_flac is
5182 not going to support negative shifts as I don't have any reference files. However, when a reference file comes through I will consider adding support.
5183 */
5184 if (lpcShift < 0) {
5185 return DRFLAC_FALSE;
5186 }
5187
5188 DRFLAC_ZERO_MEMORY(coefficients, sizeof(coefficients));
5189 for (i = 0; i < lpcOrder; ++i) {
5190 if (!drflac__read_int32(bs, lpcPrecision, coefficients + i)) {
5191 return DRFLAC_FALSE;
5192 }
5193 }
5194
5195 if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
5196 return DRFLAC_FALSE;
5197 }
5198
5199 return DRFLAC_TRUE;
5200}
5201
5202
5203static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_uint8 streaminfoBitsPerSample, drflac_frame_header* header)
5204{
5205 const drflac_uint32 sampleRateTable[12] = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
5206 const drflac_uint8 bitsPerSampleTable[8] = {0, 8, 12, (drflac_uint8)-1, 16, 20, 24, (drflac_uint8)-1}; /* -1 = reserved. */
5207
5208 DRFLAC_ASSERT(bs != NULL);
5209 DRFLAC_ASSERT(header != NULL);
5210
5211 /* Keep looping until we find a valid sync code. */
5212 for (;;) {
5213 drflac_uint8 crc8 = 0xCE; /* 0xCE = drflac_crc8(0, 0x3FFE, 14); */
5214 drflac_uint8 reserved = 0;
5215 drflac_uint8 blockingStrategy = 0;
5216 drflac_uint8 blockSize = 0;
5217 drflac_uint8 sampleRate = 0;
5218 drflac_uint8 channelAssignment = 0;
5219 drflac_uint8 bitsPerSample = 0;
5220 drflac_bool32 isVariableBlockSize;
5221
5222 if (!drflac__find_and_seek_to_next_sync_code(bs)) {
5223 return DRFLAC_FALSE;
5224 }
5225
5226 if (!drflac__read_uint8(bs, 1, &reserved)) {
5227 return DRFLAC_FALSE;
5228 }
5229 if (reserved == 1) {
5230 continue;
5231 }
5232 crc8 = drflac_crc8(crc8, reserved, 1);
5233
5234 if (!drflac__read_uint8(bs, 1, &blockingStrategy)) {
5235 return DRFLAC_FALSE;
5236 }
5237 crc8 = drflac_crc8(crc8, blockingStrategy, 1);
5238
5239 if (!drflac__read_uint8(bs, 4, &blockSize)) {
5240 return DRFLAC_FALSE;
5241 }
5242 if (blockSize == 0) {
5243 continue;
5244 }
5245 crc8 = drflac_crc8(crc8, blockSize, 4);
5246
5247 if (!drflac__read_uint8(bs, 4, &sampleRate)) {
5248 return DRFLAC_FALSE;
5249 }
5250 crc8 = drflac_crc8(crc8, sampleRate, 4);
5251
5252 if (!drflac__read_uint8(bs, 4, &channelAssignment)) {
5253 return DRFLAC_FALSE;
5254 }
5255 if (channelAssignment > 10) {
5256 continue;
5257 }
5258 crc8 = drflac_crc8(crc8, channelAssignment, 4);
5259
5260 if (!drflac__read_uint8(bs, 3, &bitsPerSample)) {
5261 return DRFLAC_FALSE;
5262 }
5263 if (bitsPerSample == 3 || bitsPerSample == 7) {
5264 continue;
5265 }
5266 crc8 = drflac_crc8(crc8, bitsPerSample, 3);
5267
5268
5269 if (!drflac__read_uint8(bs, 1, &reserved)) {
5270 return DRFLAC_FALSE;
5271 }
5272 if (reserved == 1) {
5273 continue;
5274 }
5275 crc8 = drflac_crc8(crc8, reserved, 1);
5276
5277
5278 isVariableBlockSize = blockingStrategy == 1;
5279 if (isVariableBlockSize) {
5280 drflac_uint64 pcmFrameNumber;
5281 drflac_result result = drflac__read_utf8_coded_number(bs, &pcmFrameNumber, &crc8);
5282 if (result != DRFLAC_SUCCESS) {
5283 if (result == DRFLAC_AT_END) {
5284 return DRFLAC_FALSE;
5285 } else {
5286 continue;
5287 }
5288 }
5289 header->flacFrameNumber = 0;
5290 header->pcmFrameNumber = pcmFrameNumber;
5291 } else {
5292 drflac_uint64 flacFrameNumber = 0;
5293 drflac_result result = drflac__read_utf8_coded_number(bs, &flacFrameNumber, &crc8);
5294 if (result != DRFLAC_SUCCESS) {
5295 if (result == DRFLAC_AT_END) {
5296 return DRFLAC_FALSE;
5297 } else {
5298 continue;
5299 }
5300 }
5301 header->flacFrameNumber = (drflac_uint32)flacFrameNumber; /* <-- Safe cast. */
5302 header->pcmFrameNumber = 0;
5303 }
5304
5305
5306 DRFLAC_ASSERT(blockSize > 0);
5307 if (blockSize == 1) {
5308 header->blockSizeInPCMFrames = 192;
5309 } else if (blockSize <= 5) {
5310 DRFLAC_ASSERT(blockSize >= 2);
5311 header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2));
5312 } else if (blockSize == 6) {
5313 if (!drflac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) {
5314 return DRFLAC_FALSE;
5315 }
5316 crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 8);
5317 header->blockSizeInPCMFrames += 1;
5318 } else if (blockSize == 7) {
5319 if (!drflac__read_uint16(bs, 16, &header->blockSizeInPCMFrames)) {
5320 return DRFLAC_FALSE;
5321 }
5322 crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
5323 if (header->blockSizeInPCMFrames == 0xFFFF) {
5324 return DRFLAC_FALSE; /* Frame is too big. This is the size of the frame minus 1. The STREAMINFO block defines the max block size which is 16-bits. Adding one will make it 17 bits and therefore too big. */
5325 }
5326 header->blockSizeInPCMFrames += 1;
5327 } else {
5328 DRFLAC_ASSERT(blockSize >= 8);
5329 header->blockSizeInPCMFrames = 256 * (1 << (blockSize - 8));
5330 }
5331
5332
5333 if (sampleRate <= 11) {
5334 header->sampleRate = sampleRateTable[sampleRate];
5335 } else if (sampleRate == 12) {
5336 if (!drflac__read_uint32(bs, 8, &header->sampleRate)) {
5337 return DRFLAC_FALSE;
5338 }
5339 crc8 = drflac_crc8(crc8, header->sampleRate, 8);
5340 header->sampleRate *= 1000;
5341 } else if (sampleRate == 13) {
5342 if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
5343 return DRFLAC_FALSE;
5344 }
5345 crc8 = drflac_crc8(crc8, header->sampleRate, 16);
5346 } else if (sampleRate == 14) {
5347 if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
5348 return DRFLAC_FALSE;
5349 }
5350 crc8 = drflac_crc8(crc8, header->sampleRate, 16);
5351 header->sampleRate *= 10;
5352 } else {
5353 continue; /* Invalid. Assume an invalid block. */
5354 }
5355
5356
5357 header->channelAssignment = channelAssignment;
5358
5359 header->bitsPerSample = bitsPerSampleTable[bitsPerSample];
5360 if (header->bitsPerSample == 0) {
5361 header->bitsPerSample = streaminfoBitsPerSample;
5362 }
5363
5364 if (header->bitsPerSample != streaminfoBitsPerSample) {
5365 /* If this subframe has a different bitsPerSample then streaminfo or the first frame, reject it */
5366 return DRFLAC_FALSE;
5367 }
5368
5369 if (!drflac__read_uint8(bs, 8, &header->crc8)) {
5370 return DRFLAC_FALSE;
5371 }
5372
5373#ifndef DR_FLAC_NO_CRC
5374 if (header->crc8 != crc8) {
5375 continue; /* CRC mismatch. Loop back to the top and find the next sync code. */
5376 }
5377#endif
5378 return DRFLAC_TRUE;
5379 }
5380}
5381
5382static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe* pSubframe)
5383{
5384 drflac_uint8 header;
5385 int type;
5386
5387 if (!drflac__read_uint8(bs, 8, &header)) {
5388 return DRFLAC_FALSE;
5389 }
5390
5391 /* First bit should always be 0. */
5392 if ((header & 0x80) != 0) {
5393 return DRFLAC_FALSE;
5394 }
5395
5396 type = (header & 0x7E) >> 1;
5397 if (type == 0) {
5398 pSubframe->subframeType = DRFLAC_SUBFRAME_CONSTANT;
5399 } else if (type == 1) {
5400 pSubframe->subframeType = DRFLAC_SUBFRAME_VERBATIM;
5401 } else {
5402 if ((type & 0x20) != 0) {
5403 pSubframe->subframeType = DRFLAC_SUBFRAME_LPC;
5404 pSubframe->lpcOrder = (drflac_uint8)(type & 0x1F) + 1;
5405 } else if ((type & 0x08) != 0) {
5406 pSubframe->subframeType = DRFLAC_SUBFRAME_FIXED;
5407 pSubframe->lpcOrder = (drflac_uint8)(type & 0x07);
5408 if (pSubframe->lpcOrder > 4) {
5409 pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
5410 pSubframe->lpcOrder = 0;
5411 }
5412 } else {
5413 pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
5414 }
5415 }
5416
5417 if (pSubframe->subframeType == DRFLAC_SUBFRAME_RESERVED) {
5418 return DRFLAC_FALSE;
5419 }
5420
5421 /* Wasted bits per sample. */
5422 pSubframe->wastedBitsPerSample = 0;
5423 if ((header & 0x01) == 1) {
5424 unsigned int wastedBitsPerSample;
5425 if (!drflac__seek_past_next_set_bit(bs, &wastedBitsPerSample)) {
5426 return DRFLAC_FALSE;
5427 }
5428 pSubframe->wastedBitsPerSample = (drflac_uint8)wastedBitsPerSample + 1;
5429 }
5430
5431 return DRFLAC_TRUE;
5432}
5433
5434static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex, drflac_int32* pDecodedSamplesOut)
5435{
5436 drflac_subframe* pSubframe;
5437 drflac_uint32 subframeBitsPerSample;
5438
5439 DRFLAC_ASSERT(bs != NULL);
5440 DRFLAC_ASSERT(frame != NULL);
5441
5442 pSubframe = frame->subframes + subframeIndex;
5443 if (!drflac__read_subframe_header(bs, pSubframe)) {
5444 return DRFLAC_FALSE;
5445 }
5446
5447 /* Side channels require an extra bit per sample. Took a while to figure that one out... */
5448 subframeBitsPerSample = frame->header.bitsPerSample;
5449 if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
5450 subframeBitsPerSample += 1;
5451 } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
5452 subframeBitsPerSample += 1;
5453 }
5454
5455 if (subframeBitsPerSample > 32) {
5456 /* libFLAC and ffmpeg reject 33-bit subframes as well */
5457 return DRFLAC_FALSE;
5458 }
5459
5460 /* Need to handle wasted bits per sample. */
5461 if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
5462 return DRFLAC_FALSE;
5463 }
5464 subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
5465
5466 pSubframe->pSamplesS32 = pDecodedSamplesOut;
5467
5468 switch (pSubframe->subframeType)
5469 {
5470 case DRFLAC_SUBFRAME_CONSTANT:
5471 {
5472 drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
5473 } break;
5474
5475 case DRFLAC_SUBFRAME_VERBATIM:
5476 {
5477 drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
5478 } break;
5479
5480 case DRFLAC_SUBFRAME_FIXED:
5481 {
5482 drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
5483 } break;
5484
5485 case DRFLAC_SUBFRAME_LPC:
5486 {
5487 drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
5488 } break;
5489
5490 default: return DRFLAC_FALSE;
5491 }
5492
5493 return DRFLAC_TRUE;
5494}
5495
5496static drflac_bool32 drflac__seek_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex)
5497{
5498 drflac_subframe* pSubframe;
5499 drflac_uint32 subframeBitsPerSample;
5500
5501 DRFLAC_ASSERT(bs != NULL);
5502 DRFLAC_ASSERT(frame != NULL);
5503
5504 pSubframe = frame->subframes + subframeIndex;
5505 if (!drflac__read_subframe_header(bs, pSubframe)) {
5506 return DRFLAC_FALSE;
5507 }
5508
5509 /* Side channels require an extra bit per sample. Took a while to figure that one out... */
5510 subframeBitsPerSample = frame->header.bitsPerSample;
5511 if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
5512 subframeBitsPerSample += 1;
5513 } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
5514 subframeBitsPerSample += 1;
5515 }
5516
5517 /* Need to handle wasted bits per sample. */
5518 if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
5519 return DRFLAC_FALSE;
5520 }
5521 subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
5522
5523 pSubframe->pSamplesS32 = NULL;
5524
5525 switch (pSubframe->subframeType)
5526 {
5527 case DRFLAC_SUBFRAME_CONSTANT:
5528 {
5529 if (!drflac__seek_bits(bs, subframeBitsPerSample)) {
5530 return DRFLAC_FALSE;
5531 }
5532 } break;
5533
5534 case DRFLAC_SUBFRAME_VERBATIM:
5535 {
5536 unsigned int bitsToSeek = frame->header.blockSizeInPCMFrames * subframeBitsPerSample;
5537 if (!drflac__seek_bits(bs, bitsToSeek)) {
5538 return DRFLAC_FALSE;
5539 }
5540 } break;
5541
5542 case DRFLAC_SUBFRAME_FIXED:
5543 {
5544 unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
5545 if (!drflac__seek_bits(bs, bitsToSeek)) {
5546 return DRFLAC_FALSE;
5547 }
5548
5549 if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
5550 return DRFLAC_FALSE;
5551 }
5552 } break;
5553
5554 case DRFLAC_SUBFRAME_LPC:
5555 {
5556 drflac_uint8 lpcPrecision;
5557
5558 unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
5559 if (!drflac__seek_bits(bs, bitsToSeek)) {
5560 return DRFLAC_FALSE;
5561 }
5562
5563 if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
5564 return DRFLAC_FALSE;
5565 }
5566 if (lpcPrecision == 15) {
5567 return DRFLAC_FALSE; /* Invalid. */
5568 }
5569 lpcPrecision += 1;
5570
5571
5572 bitsToSeek = (pSubframe->lpcOrder * lpcPrecision) + 5; /* +5 for shift. */
5573 if (!drflac__seek_bits(bs, bitsToSeek)) {
5574 return DRFLAC_FALSE;
5575 }
5576
5577 if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
5578 return DRFLAC_FALSE;
5579 }
5580 } break;
5581
5582 default: return DRFLAC_FALSE;
5583 }
5584
5585 return DRFLAC_TRUE;
5586}
5587
5588
5589static DRFLAC_INLINE drflac_uint8 drflac__get_channel_count_from_channel_assignment(drflac_int8 channelAssignment)
5590{
5591 drflac_uint8 lookup[] = {1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 2};
5592
5593 DRFLAC_ASSERT(channelAssignment <= 10);
5594 return lookup[channelAssignment];
5595}
5596
5597static drflac_result drflac__decode_flac_frame(drflac* pFlac)
5598{
5599 int channelCount;
5600 int i;
5601 drflac_uint8 paddingSizeInBits;
5602 drflac_uint16 desiredCRC16;
5603#ifndef DR_FLAC_NO_CRC
5604 drflac_uint16 actualCRC16;
5605#endif
5606
5607 /* This function should be called while the stream is sitting on the first byte after the frame header. */
5608 DRFLAC_ZERO_MEMORY(pFlac->currentFLACFrame.subframes, sizeof(pFlac->currentFLACFrame.subframes));
5609
5610 /* The frame block size must never be larger than the maximum block size defined by the FLAC stream. */
5611 if (pFlac->currentFLACFrame.header.blockSizeInPCMFrames > pFlac->maxBlockSizeInPCMFrames) {
5612 return DRFLAC_ERROR;
5613 }
5614
5615 /* The number of channels in the frame must match the channel count from the STREAMINFO block. */
5616 channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
5617 if (channelCount != (int)pFlac->channels) {
5618 return DRFLAC_ERROR;
5619 }
5620
5621 for (i = 0; i < channelCount; ++i) {
5622 if (!drflac__decode_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i, pFlac->pDecodedSamples + (pFlac->currentFLACFrame.header.blockSizeInPCMFrames * i))) {
5623 return DRFLAC_ERROR;
5624 }
5625 }
5626
5627 paddingSizeInBits = (drflac_uint8)(DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7);
5628 if (paddingSizeInBits > 0) {
5629 drflac_uint8 padding = 0;
5630 if (!drflac__read_uint8(&pFlac->bs, paddingSizeInBits, &padding)) {
5631 return DRFLAC_AT_END;
5632 }
5633 }
5634
5635#ifndef DR_FLAC_NO_CRC
5636 actualCRC16 = drflac__flush_crc16(&pFlac->bs);
5637#endif
5638 if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
5639 return DRFLAC_AT_END;
5640 }
5641
5642#ifndef DR_FLAC_NO_CRC
5643 if (actualCRC16 != desiredCRC16) {
5644 return DRFLAC_CRC_MISMATCH; /* CRC mismatch. */
5645 }
5646#endif
5647
5648 pFlac->currentFLACFrame.pcmFramesRemaining = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
5649
5650 return DRFLAC_SUCCESS;
5651}
5652
5653static drflac_result drflac__seek_flac_frame(drflac* pFlac)
5654{
5655 int channelCount;
5656 int i;
5657 drflac_uint16 desiredCRC16;
5658#ifndef DR_FLAC_NO_CRC
5659 drflac_uint16 actualCRC16;
5660#endif
5661
5662 channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
5663 for (i = 0; i < channelCount; ++i) {
5664 if (!drflac__seek_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i)) {
5665 return DRFLAC_ERROR;
5666 }
5667 }
5668
5669 /* Padding. */
5670 if (!drflac__seek_bits(&pFlac->bs, DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7)) {
5671 return DRFLAC_ERROR;
5672 }
5673
5674 /* CRC. */
5675#ifndef DR_FLAC_NO_CRC
5676 actualCRC16 = drflac__flush_crc16(&pFlac->bs);
5677#endif
5678 if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
5679 return DRFLAC_AT_END;
5680 }
5681
5682#ifndef DR_FLAC_NO_CRC
5683 if (actualCRC16 != desiredCRC16) {
5684 return DRFLAC_CRC_MISMATCH; /* CRC mismatch. */
5685 }
5686#endif
5687
5688 return DRFLAC_SUCCESS;
5689}
5690
5691static drflac_bool32 drflac__read_and_decode_next_flac_frame(drflac* pFlac)
5692{
5693 DRFLAC_ASSERT(pFlac != NULL);
5694
5695 for (;;) {
5696 drflac_result result;
5697
5698 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
5699 return DRFLAC_FALSE;
5700 }
5701
5702 result = drflac__decode_flac_frame(pFlac);
5703 if (result != DRFLAC_SUCCESS) {
5704 if (result == DRFLAC_CRC_MISMATCH) {
5705 continue; /* CRC mismatch. Skip to the next frame. */
5706 } else {
5707 return DRFLAC_FALSE;
5708 }
5709 }
5710
5711 return DRFLAC_TRUE;
5712 }
5713}
5714
5715static void drflac__get_pcm_frame_range_of_current_flac_frame(drflac* pFlac, drflac_uint64* pFirstPCMFrame, drflac_uint64* pLastPCMFrame)
5716{
5717 drflac_uint64 firstPCMFrame;
5718 drflac_uint64 lastPCMFrame;
5719
5720 DRFLAC_ASSERT(pFlac != NULL);
5721
5722 firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber;
5723 if (firstPCMFrame == 0) {
5724 firstPCMFrame = ((drflac_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames;
5725 }
5726
5727 lastPCMFrame = firstPCMFrame + pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
5728 if (lastPCMFrame > 0) {
5729 lastPCMFrame -= 1; /* Needs to be zero based. */
5730 }
5731
5732 if (pFirstPCMFrame) {
5733 *pFirstPCMFrame = firstPCMFrame;
5734 }
5735 if (pLastPCMFrame) {
5736 *pLastPCMFrame = lastPCMFrame;
5737 }
5738}
5739
5740static drflac_bool32 drflac__seek_to_first_frame(drflac* pFlac)
5741{
5742 drflac_bool32 result;
5743
5744 DRFLAC_ASSERT(pFlac != NULL);
5745
5746 result = drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes);
5747
5748 DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
5749 pFlac->currentPCMFrame = 0;
5750
5751 return result;
5752}
5753
5754static DRFLAC_INLINE drflac_result drflac__seek_to_next_flac_frame(drflac* pFlac)
5755{
5756 /* This function should only ever be called while the decoder is sitting on the first byte past the FRAME_HEADER section. */
5757 DRFLAC_ASSERT(pFlac != NULL);
5758 return drflac__seek_flac_frame(pFlac);
5759}
5760
5761
5762static drflac_uint64 drflac__seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 pcmFramesToSeek)
5763{
5764 drflac_uint64 pcmFramesRead = 0;
5765 while (pcmFramesToSeek > 0) {
5766 if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
5767 if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
5768 break; /* Couldn't read the next frame, so just break from the loop and return. */
5769 }
5770 } else {
5771 if (pFlac->currentFLACFrame.pcmFramesRemaining > pcmFramesToSeek) {
5772 pcmFramesRead += pcmFramesToSeek;
5773 pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)pcmFramesToSeek; /* <-- Safe cast. Will always be < currentFrame.pcmFramesRemaining < 65536. */
5774 pcmFramesToSeek = 0;
5775 } else {
5776 pcmFramesRead += pFlac->currentFLACFrame.pcmFramesRemaining;
5777 pcmFramesToSeek -= pFlac->currentFLACFrame.pcmFramesRemaining;
5778 pFlac->currentFLACFrame.pcmFramesRemaining = 0;
5779 }
5780 }
5781 }
5782
5783 pFlac->currentPCMFrame += pcmFramesRead;
5784 return pcmFramesRead;
5785}
5786
5787
5788static drflac_bool32 drflac__seek_to_pcm_frame__brute_force(drflac* pFlac, drflac_uint64 pcmFrameIndex)
5789{
5790 drflac_bool32 isMidFrame = DRFLAC_FALSE;
5791 drflac_uint64 runningPCMFrameCount;
5792
5793 DRFLAC_ASSERT(pFlac != NULL);
5794
5795 /* If we are seeking forward we start from the current position. Otherwise we need to start all the way from the start of the file. */
5796 if (pcmFrameIndex >= pFlac->currentPCMFrame) {
5797 /* Seeking forward. Need to seek from the current position. */
5798 runningPCMFrameCount = pFlac->currentPCMFrame;
5799
5800 /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
5801 if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
5802 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
5803 return DRFLAC_FALSE;
5804 }
5805 } else {
5806 isMidFrame = DRFLAC_TRUE;
5807 }
5808 } else {
5809 /* Seeking backwards. Need to seek from the start of the file. */
5810 runningPCMFrameCount = 0;
5811
5812 /* Move back to the start. */
5813 if (!drflac__seek_to_first_frame(pFlac)) {
5814 return DRFLAC_FALSE;
5815 }
5816
5817 /* Decode the first frame in preparation for sample-exact seeking below. */
5818 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
5819 return DRFLAC_FALSE;
5820 }
5821 }
5822
5823 /*
5824 We need to as quickly as possible find the frame that contains the target sample. To do this, we iterate over each frame and inspect its
5825 header. If based on the header we can determine that the frame contains the sample, we do a full decode of that frame.
5826 */
5827 for (;;) {
5828 drflac_uint64 pcmFrameCountInThisFLACFrame;
5829 drflac_uint64 firstPCMFrameInFLACFrame = 0;
5830 drflac_uint64 lastPCMFrameInFLACFrame = 0;
5831
5832 drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
5833
5834 pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
5835 if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
5836 /*
5837 The sample should be in this frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
5838 it never existed and keep iterating.
5839 */
5840 drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
5841
5842 if (!isMidFrame) {
5843 drflac_result result = drflac__decode_flac_frame(pFlac);
5844 if (result == DRFLAC_SUCCESS) {
5845 /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
5846 return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; /* <-- If this fails, something bad has happened (it should never fail). */
5847 } else {
5848 if (result == DRFLAC_CRC_MISMATCH) {
5849 goto next_iteration; /* CRC mismatch. Pretend this frame never existed. */
5850 } else {
5851 return DRFLAC_FALSE;
5852 }
5853 }
5854 } else {
5855 /* We started seeking mid-frame which means we need to skip the frame decoding part. */
5856 return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
5857 }
5858 } else {
5859 /*
5860 It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
5861 frame never existed and leave the running sample count untouched.
5862 */
5863 if (!isMidFrame) {
5864 drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
5865 if (result == DRFLAC_SUCCESS) {
5866 runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
5867 } else {
5868 if (result == DRFLAC_CRC_MISMATCH) {
5869 goto next_iteration; /* CRC mismatch. Pretend this frame never existed. */
5870 } else {
5871 return DRFLAC_FALSE;
5872 }
5873 }
5874 } else {
5875 /*
5876 We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
5877 drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
5878 */
5879 runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
5880 pFlac->currentFLACFrame.pcmFramesRemaining = 0;
5881 isMidFrame = DRFLAC_FALSE;
5882 }
5883
5884 /* If we are seeking to the end of the file and we've just hit it, we're done. */
5885 if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
5886 return DRFLAC_TRUE;
5887 }
5888 }
5889
5890 next_iteration:
5891 /* Grab the next frame in preparation for the next iteration. */
5892 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
5893 return DRFLAC_FALSE;
5894 }
5895 }
5896}
5897
5898
5899#if !defined(DR_FLAC_NO_CRC)
5900/*
5901We use an average compression ratio to determine our approximate start location. FLAC files are generally about 50%-70% the size of their
5902uncompressed counterparts so we'll use this as a basis. I'm going to split the middle and use a factor of 0.6 to determine the starting
5903location.
5904*/
5905#define DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f
5906
5907static drflac_bool32 drflac__seek_to_approximate_flac_frame_to_byte(drflac* pFlac, drflac_uint64 targetByte, drflac_uint64 rangeLo, drflac_uint64 rangeHi, drflac_uint64* pLastSuccessfulSeekOffset)
5908{
5909 DRFLAC_ASSERT(pFlac != NULL);
5910 DRFLAC_ASSERT(pLastSuccessfulSeekOffset != NULL);
5911 DRFLAC_ASSERT(targetByte >= rangeLo);
5912 DRFLAC_ASSERT(targetByte <= rangeHi);
5913
5914 *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
5915
5916 for (;;) {
5917 /* After rangeLo == rangeHi == targetByte fails, we need to break out. */
5918 drflac_uint64 lastTargetByte = targetByte;
5919
5920 /* When seeking to a byte, failure probably means we've attempted to seek beyond the end of the stream. To counter this we just halve it each attempt. */
5921 if (!drflac__seek_to_byte(&pFlac->bs, targetByte)) {
5922 /* If we couldn't even seek to the first byte in the stream we have a problem. Just abandon the whole thing. */
5923 if (targetByte == 0) {
5924 drflac__seek_to_first_frame(pFlac); /* Try to recover. */
5925 return DRFLAC_FALSE;
5926 }
5927
5928 /* Halve the byte location and continue. */
5929 targetByte = rangeLo + ((rangeHi - rangeLo)/2);
5930 rangeHi = targetByte;
5931 } else {
5932 /* Getting here should mean that we have seeked to an appropriate byte. */
5933
5934 /* Clear the details of the FLAC frame so we don't misreport data. */
5935 DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
5936
5937 /*
5938 Now seek to the next FLAC frame. We need to decode the entire frame (not just the header) because it's possible for the header to incorrectly pass the
5939 CRC check and return bad data. We need to decode the entire frame to be more certain. Although this seems unlikely, this has happened to me in testing
5940 so it needs to stay this way for now.
5941 */
5942#if 1
5943 if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
5944 /* Halve the byte location and continue. */
5945 targetByte = rangeLo + ((rangeHi - rangeLo)/2);
5946 rangeHi = targetByte;
5947 } else {
5948 break;
5949 }
5950#else
5951 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
5952 /* Halve the byte location and continue. */
5953 targetByte = rangeLo + ((rangeHi - rangeLo)/2);
5954 rangeHi = targetByte;
5955 } else {
5956 break;
5957 }
5958#endif
5959 }
5960
5961 /* We already tried this byte and there are no more to try, break out. */
5962 if(targetByte == lastTargetByte) {
5963 return DRFLAC_FALSE;
5964 }
5965 }
5966
5967 /* The current PCM frame needs to be updated based on the frame we just seeked to. */
5968 drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
5969
5970 DRFLAC_ASSERT(targetByte <= rangeHi);
5971
5972 *pLastSuccessfulSeekOffset = targetByte;
5973 return DRFLAC_TRUE;
5974}
5975
5976static drflac_bool32 drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 offset)
5977{
5978 /* This section of code would be used if we were only decoding the FLAC frame header when calling drflac__seek_to_approximate_flac_frame_to_byte(). */
5979#if 0
5980 if (drflac__decode_flac_frame(pFlac) != DRFLAC_SUCCESS) {
5981 /* We failed to decode this frame which may be due to it being corrupt. We'll just use the next valid FLAC frame. */
5982 if (drflac__read_and_decode_next_flac_frame(pFlac) == DRFLAC_FALSE) {
5983 return DRFLAC_FALSE;
5984 }
5985 }
5986#endif
5987
5988 return drflac__seek_forward_by_pcm_frames(pFlac, offset) == offset;
5989}
5990
5991
5992static drflac_bool32 drflac__seek_to_pcm_frame__binary_search_internal(drflac* pFlac, drflac_uint64 pcmFrameIndex, drflac_uint64 byteRangeLo, drflac_uint64 byteRangeHi)
5993{
5994 /* This assumes pFlac->currentPCMFrame is sitting on byteRangeLo upon entry. */
5995
5996 drflac_uint64 targetByte;
5997 drflac_uint64 pcmRangeLo = pFlac->totalPCMFrameCount;
5998 drflac_uint64 pcmRangeHi = 0;
5999 drflac_uint64 lastSuccessfulSeekOffset = (drflac_uint64)-1;
6000 drflac_uint64 closestSeekOffsetBeforeTargetPCMFrame = byteRangeLo;
6001 drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
6002
6003 targetByte = byteRangeLo + (drflac_uint64)(((drflac_int64)((pcmFrameIndex - pFlac->currentPCMFrame) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO);
6004 if (targetByte > byteRangeHi) {
6005 targetByte = byteRangeHi;
6006 }
6007
6008 for (;;) {
6009 if (drflac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
6010 /* We found a FLAC frame. We need to check if it contains the sample we're looking for. */
6011 drflac_uint64 newPCMRangeLo;
6012 drflac_uint64 newPCMRangeHi;
6013 drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &newPCMRangeLo, &newPCMRangeHi);
6014
6015 /* If we selected the same frame, it means we should be pretty close. Just decode the rest. */
6016 if (pcmRangeLo == newPCMRangeLo) {
6017 if (!drflac__seek_to_approximate_flac_frame_to_byte(pFlac, closestSeekOffsetBeforeTargetPCMFrame, closestSeekOffsetBeforeTargetPCMFrame, byteRangeHi, &lastSuccessfulSeekOffset)) {
6018 break; /* Failed to seek to closest frame. */
6019 }
6020
6021 if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
6022 return DRFLAC_TRUE;
6023 } else {
6024 break; /* Failed to seek forward. */
6025 }
6026 }
6027
6028 pcmRangeLo = newPCMRangeLo;
6029 pcmRangeHi = newPCMRangeHi;
6030
6031 if (pcmRangeLo <= pcmFrameIndex && pcmRangeHi >= pcmFrameIndex) {
6032 /* The target PCM frame is in this FLAC frame. */
6033 if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame) ) {
6034 return DRFLAC_TRUE;
6035 } else {
6036 break; /* Failed to seek to FLAC frame. */
6037 }
6038 } else {
6039 const float approxCompressionRatio = (drflac_int64)(lastSuccessfulSeekOffset - pFlac->firstFLACFramePosInBytes) / ((drflac_int64)(pcmRangeLo * pFlac->channels * pFlac->bitsPerSample)/8.0f);
6040
6041 if (pcmRangeLo > pcmFrameIndex) {
6042 /* We seeked too far forward. We need to move our target byte backward and try again. */
6043 byteRangeHi = lastSuccessfulSeekOffset;
6044 if (byteRangeLo > byteRangeHi) {
6045 byteRangeLo = byteRangeHi;
6046 }
6047
6048 targetByte = byteRangeLo + ((byteRangeHi - byteRangeLo) / 2);
6049 if (targetByte < byteRangeLo) {
6050 targetByte = byteRangeLo;
6051 }
6052 } else /*if (pcmRangeHi < pcmFrameIndex)*/ {
6053 /* We didn't seek far enough. We need to move our target byte forward and try again. */
6054
6055 /* If we're close enough we can just seek forward. */
6056 if ((pcmFrameIndex - pcmRangeLo) < seekForwardThreshold) {
6057 if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
6058 return DRFLAC_TRUE;
6059 } else {
6060 break; /* Failed to seek to FLAC frame. */
6061 }
6062 } else {
6063 byteRangeLo = lastSuccessfulSeekOffset;
6064 if (byteRangeHi < byteRangeLo) {
6065 byteRangeHi = byteRangeLo;
6066 }
6067
6068 targetByte = lastSuccessfulSeekOffset + (drflac_uint64)(((drflac_int64)((pcmFrameIndex-pcmRangeLo) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * approxCompressionRatio);
6069 if (targetByte > byteRangeHi) {
6070 targetByte = byteRangeHi;
6071 }
6072
6073 if (closestSeekOffsetBeforeTargetPCMFrame < lastSuccessfulSeekOffset) {
6074 closestSeekOffsetBeforeTargetPCMFrame = lastSuccessfulSeekOffset;
6075 }
6076 }
6077 }
6078 }
6079 } else {
6080 /* Getting here is really bad. We just recover as best we can, but moving to the first frame in the stream, and then abort. */
6081 break;
6082 }
6083 }
6084
6085 drflac__seek_to_first_frame(pFlac); /* <-- Try to recover. */
6086 return DRFLAC_FALSE;
6087}
6088
6089static drflac_bool32 drflac__seek_to_pcm_frame__binary_search(drflac* pFlac, drflac_uint64 pcmFrameIndex)
6090{
6091 drflac_uint64 byteRangeLo;
6092 drflac_uint64 byteRangeHi;
6093 drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
6094
6095 /* Our algorithm currently assumes the FLAC stream is currently sitting at the start. */
6096 if (drflac__seek_to_first_frame(pFlac) == DRFLAC_FALSE) {
6097 return DRFLAC_FALSE;
6098 }
6099
6100 /* If we're close enough to the start, just move to the start and seek forward. */
6101 if (pcmFrameIndex < seekForwardThreshold) {
6102 return drflac__seek_forward_by_pcm_frames(pFlac, pcmFrameIndex) == pcmFrameIndex;
6103 }
6104
6105 /*
6106 Our starting byte range is the byte position of the first FLAC frame and the approximate end of the file as if it were completely uncompressed. This ensures
6107 the entire file is included, even though most of the time it'll exceed the end of the actual stream. This is OK as the frame searching logic will handle it.
6108 */
6109 byteRangeLo = pFlac->firstFLACFramePosInBytes;
6110 byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
6111
6112 return drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi);
6113}
6114#endif /* !DR_FLAC_NO_CRC */
6115
6116static drflac_bool32 drflac__seek_to_pcm_frame__seek_table(drflac* pFlac, drflac_uint64 pcmFrameIndex)
6117{
6118 drflac_uint32 iClosestSeekpoint = 0;
6119 drflac_bool32 isMidFrame = DRFLAC_FALSE;
6120 drflac_uint64 runningPCMFrameCount;
6121 drflac_uint32 iSeekpoint;
6122
6123
6124 DRFLAC_ASSERT(pFlac != NULL);
6125
6126 if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) {
6127 return DRFLAC_FALSE;
6128 }
6129
6130 /* Do not use the seektable if pcmFramIndex is not coverd by it. */
6131 if (pFlac->pSeekpoints[0].firstPCMFrame > pcmFrameIndex) {
6132 return DRFLAC_FALSE;
6133 }
6134
6135 for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
6136 if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) {
6137 break;
6138 }
6139
6140 iClosestSeekpoint = iSeekpoint;
6141 }
6142
6143 /* There's been cases where the seek table contains only zeros. We need to do some basic validation on the closest seekpoint. */
6144 if (pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount == 0 || pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount > pFlac->maxBlockSizeInPCMFrames) {
6145 return DRFLAC_FALSE;
6146 }
6147 if (pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame > pFlac->totalPCMFrameCount && pFlac->totalPCMFrameCount > 0) {
6148 return DRFLAC_FALSE;
6149 }
6150
6151#if !defined(DR_FLAC_NO_CRC)
6152 /* At this point we should know the closest seek point. We can use a binary search for this. We need to know the total sample count for this. */
6153 if (pFlac->totalPCMFrameCount > 0) {
6154 drflac_uint64 byteRangeLo;
6155 drflac_uint64 byteRangeHi;
6156
6157 byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
6158 byteRangeLo = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset;
6159
6160 /*
6161 If our closest seek point is not the last one, we only need to search between it and the next one. The section below calculates an appropriate starting
6162 value for byteRangeHi which will clamp it appropriately.
6163
6164 Note that the next seekpoint must have an offset greater than the closest seekpoint because otherwise our binary search algorithm will break down. There
6165 have been cases where a seektable consists of seek points where every byte offset is set to 0 which causes problems. If this happens we need to abort.
6166 */
6167 if (iClosestSeekpoint < pFlac->seekpointCount-1) {
6168 drflac_uint32 iNextSeekpoint = iClosestSeekpoint + 1;
6169
6170 /* Basic validation on the seekpoints to ensure they're usable. */
6171 if (pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset >= pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset || pFlac->pSeekpoints[iNextSeekpoint].pcmFrameCount == 0) {
6172 return DRFLAC_FALSE; /* The next seekpoint doesn't look right. The seek table cannot be trusted from here. Abort. */
6173 }
6174
6175 if (pFlac->pSeekpoints[iNextSeekpoint].firstPCMFrame != (((drflac_uint64)0xFFFFFFFF << 32) | 0xFFFFFFFF)) { /* Make sure it's not a placeholder seekpoint. */
6176 byteRangeHi = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset - 1; /* byteRangeHi must be zero based. */
6177 }
6178 }
6179
6180 if (drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
6181 if (drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
6182 drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
6183
6184 if (drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) {
6185 return DRFLAC_TRUE;
6186 }
6187 }
6188 }
6189 }
6190#endif /* !DR_FLAC_NO_CRC */
6191
6192 /* Getting here means we need to use a slower algorithm because the binary search method failed or cannot be used. */
6193
6194 /*
6195 If we are seeking forward and the closest seekpoint is _before_ the current sample, we just seek forward from where we are. Otherwise we start seeking
6196 from the seekpoint's first sample.
6197 */
6198 if (pcmFrameIndex >= pFlac->currentPCMFrame && pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame <= pFlac->currentPCMFrame) {
6199 /* Optimized case. Just seek forward from where we are. */
6200 runningPCMFrameCount = pFlac->currentPCMFrame;
6201
6202 /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
6203 if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
6204 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
6205 return DRFLAC_FALSE;
6206 }
6207 } else {
6208 isMidFrame = DRFLAC_TRUE;
6209 }
6210 } else {
6211 /* Slower case. Seek to the start of the seekpoint and then seek forward from there. */
6212 runningPCMFrameCount = pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame;
6213
6214 if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
6215 return DRFLAC_FALSE;
6216 }
6217
6218 /* Grab the frame the seekpoint is sitting on in preparation for the sample-exact seeking below. */
6219 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
6220 return DRFLAC_FALSE;
6221 }
6222 }
6223
6224 for (;;) {
6225 drflac_uint64 pcmFrameCountInThisFLACFrame;
6226 drflac_uint64 firstPCMFrameInFLACFrame = 0;
6227 drflac_uint64 lastPCMFrameInFLACFrame = 0;
6228
6229 drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
6230
6231 pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
6232 if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
6233 /*
6234 The sample should be in this frame. We need to fully decode it, but if it's an invalid frame (a CRC mismatch) we need to pretend
6235 it never existed and keep iterating.
6236 */
6237 drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
6238
6239 if (!isMidFrame) {
6240 drflac_result result = drflac__decode_flac_frame(pFlac);
6241 if (result == DRFLAC_SUCCESS) {
6242 /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
6243 return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; /* <-- If this fails, something bad has happened (it should never fail). */
6244 } else {
6245 if (result == DRFLAC_CRC_MISMATCH) {
6246 goto next_iteration; /* CRC mismatch. Pretend this frame never existed. */
6247 } else {
6248 return DRFLAC_FALSE;
6249 }
6250 }
6251 } else {
6252 /* We started seeking mid-frame which means we need to skip the frame decoding part. */
6253 return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
6254 }
6255 } else {
6256 /*
6257 It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
6258 frame never existed and leave the running sample count untouched.
6259 */
6260 if (!isMidFrame) {
6261 drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
6262 if (result == DRFLAC_SUCCESS) {
6263 runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
6264 } else {
6265 if (result == DRFLAC_CRC_MISMATCH) {
6266 goto next_iteration; /* CRC mismatch. Pretend this frame never existed. */
6267 } else {
6268 return DRFLAC_FALSE;
6269 }
6270 }
6271 } else {
6272 /*
6273 We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
6274 drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
6275 */
6276 runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
6277 pFlac->currentFLACFrame.pcmFramesRemaining = 0;
6278 isMidFrame = DRFLAC_FALSE;
6279 }
6280
6281 /* If we are seeking to the end of the file and we've just hit it, we're done. */
6282 if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
6283 return DRFLAC_TRUE;
6284 }
6285 }
6286
6287 next_iteration:
6288 /* Grab the next frame in preparation for the next iteration. */
6289 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
6290 return DRFLAC_FALSE;
6291 }
6292 }
6293}
6294
6295
6296#ifndef DR_FLAC_NO_OGG
6297typedef struct
6298{
6299 drflac_uint8 capturePattern[4]; /* Should be "OggS" */
6300 drflac_uint8 structureVersion; /* Always 0. */
6301 drflac_uint8 headerType;
6302 drflac_uint64 granulePosition;
6303 drflac_uint32 serialNumber;
6304 drflac_uint32 sequenceNumber;
6305 drflac_uint32 checksum;
6306 drflac_uint8 segmentCount;
6307 drflac_uint8 segmentTable[255];
6308} drflac_ogg_page_header;
6309#endif
6310
6311typedef struct
6312{
6313 drflac_read_proc onRead;
6314 drflac_seek_proc onSeek;
6315 drflac_meta_proc onMeta;
6316 drflac_container container;
6317 void* pUserData;
6318 void* pUserDataMD;
6319 drflac_uint32 sampleRate;
6320 drflac_uint8 channels;
6321 drflac_uint8 bitsPerSample;
6322 drflac_uint64 totalPCMFrameCount;
6323 drflac_uint16 maxBlockSizeInPCMFrames;
6324 drflac_uint64 runningFilePos;
6325 drflac_bool32 hasStreamInfoBlock;
6326 drflac_bool32 hasMetadataBlocks;
6327 drflac_bs bs; /* <-- A bit streamer is required for loading data during initialization. */
6328 drflac_frame_header firstFrameHeader; /* <-- The header of the first frame that was read during relaxed initalization. Only set if there is no STREAMINFO block. */
6329
6330#ifndef DR_FLAC_NO_OGG
6331 drflac_uint32 oggSerial;
6332 drflac_uint64 oggFirstBytePos;
6333 drflac_ogg_page_header oggBosHeader;
6334#endif
6335} drflac_init_info;
6336
6337static DRFLAC_INLINE void drflac__decode_block_header(drflac_uint32 blockHeader, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
6338{
6339 blockHeader = drflac__be2host_32(blockHeader);
6340 *isLastBlock = (drflac_uint8)((blockHeader & 0x80000000UL) >> 31);
6341 *blockType = (drflac_uint8)((blockHeader & 0x7F000000UL) >> 24);
6342 *blockSize = (blockHeader & 0x00FFFFFFUL);
6343}
6344
6345static DRFLAC_INLINE drflac_bool32 drflac__read_and_decode_block_header(drflac_read_proc onRead, void* pUserData, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
6346{
6347 drflac_uint32 blockHeader;
6348
6349 *blockSize = 0;
6350 if (onRead(pUserData, &blockHeader, 4) != 4) {
6351 return DRFLAC_FALSE;
6352 }
6353
6354 drflac__decode_block_header(blockHeader, isLastBlock, blockType, blockSize);
6355 return DRFLAC_TRUE;
6356}
6357
6358static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUserData, drflac_streaminfo* pStreamInfo)
6359{
6360 drflac_uint32 blockSizes;
6361 drflac_uint64 frameSizes = 0;
6362 drflac_uint64 importantProps;
6363 drflac_uint8 md5[16];
6364
6365 /* min/max block size. */
6366 if (onRead(pUserData, &blockSizes, 4) != 4) {
6367 return DRFLAC_FALSE;
6368 }
6369
6370 /* min/max frame size. */
6371 if (onRead(pUserData, &frameSizes, 6) != 6) {
6372 return DRFLAC_FALSE;
6373 }
6374
6375 /* Sample rate, channels, bits per sample and total sample count. */
6376 if (onRead(pUserData, &importantProps, 8) != 8) {
6377 return DRFLAC_FALSE;
6378 }
6379
6380 /* MD5 */
6381 if (onRead(pUserData, md5, sizeof(md5)) != sizeof(md5)) {
6382 return DRFLAC_FALSE;
6383 }
6384
6385 blockSizes = drflac__be2host_32(blockSizes);
6386 frameSizes = drflac__be2host_64(frameSizes);
6387 importantProps = drflac__be2host_64(importantProps);
6388
6389 pStreamInfo->minBlockSizeInPCMFrames = (drflac_uint16)((blockSizes & 0xFFFF0000) >> 16);
6390 pStreamInfo->maxBlockSizeInPCMFrames = (drflac_uint16) (blockSizes & 0x0000FFFF);
6391 pStreamInfo->minFrameSizeInPCMFrames = (drflac_uint32)((frameSizes & (((drflac_uint64)0x00FFFFFF << 16) << 24)) >> 40);
6392 pStreamInfo->maxFrameSizeInPCMFrames = (drflac_uint32)((frameSizes & (((drflac_uint64)0x00FFFFFF << 16) << 0)) >> 16);
6393 pStreamInfo->sampleRate = (drflac_uint32)((importantProps & (((drflac_uint64)0x000FFFFF << 16) << 28)) >> 44);
6394 pStreamInfo->channels = (drflac_uint8 )((importantProps & (((drflac_uint64)0x0000000E << 16) << 24)) >> 41) + 1;
6395 pStreamInfo->bitsPerSample = (drflac_uint8 )((importantProps & (((drflac_uint64)0x0000001F << 16) << 20)) >> 36) + 1;
6396 pStreamInfo->totalPCMFrameCount = ((importantProps & ((((drflac_uint64)0x0000000F << 16) << 16) | 0xFFFFFFFF)));
6397 DRFLAC_COPY_MEMORY(pStreamInfo->md5, md5, sizeof(md5));
6398
6399 return DRFLAC_TRUE;
6400}
6401
6402
6403static void* drflac__malloc_default(size_t sz, void* pUserData)
6404{
6405 (void)pUserData;
6406 return DRFLAC_MALLOC(sz);
6407}
6408
6409static void* drflac__realloc_default(void* p, size_t sz, void* pUserData)
6410{
6411 (void)pUserData;
6412 return DRFLAC_REALLOC(p, sz);
6413}
6414
6415static void drflac__free_default(void* p, void* pUserData)
6416{
6417 (void)pUserData;
6418 DRFLAC_FREE(p);
6419}
6420
6421
6422static void* drflac__malloc_from_callbacks(size_t sz, const drflac_allocation_callbacks* pAllocationCallbacks)
6423{
6424 if (pAllocationCallbacks == NULL) {
6425 return NULL;
6426 }
6427
6428 if (pAllocationCallbacks->onMalloc != NULL) {
6429 return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
6430 }
6431
6432 /* Try using realloc(). */
6433 if (pAllocationCallbacks->onRealloc != NULL) {
6434 return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
6435 }
6436
6437 return NULL;
6438}
6439
6440static void* drflac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drflac_allocation_callbacks* pAllocationCallbacks)
6441{
6442 if (pAllocationCallbacks == NULL) {
6443 return NULL;
6444 }
6445
6446 if (pAllocationCallbacks->onRealloc != NULL) {
6447 return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
6448 }
6449
6450 /* Try emulating realloc() in terms of malloc()/free(). */
6451 if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
6452 void* p2;
6453
6454 p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
6455 if (p2 == NULL) {
6456 return NULL;
6457 }
6458
6459 if (p != NULL) {
6460 DRFLAC_COPY_MEMORY(p2, p, szOld);
6461 pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
6462 }
6463
6464 return p2;
6465 }
6466
6467 return NULL;
6468}
6469
6470static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
6471{
6472 if (p == NULL || pAllocationCallbacks == NULL) {
6473 return;
6474 }
6475
6476 if (pAllocationCallbacks->onFree != NULL) {
6477 pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
6478 }
6479}
6480
6481
6482static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeekpointCount, drflac_allocation_callbacks* pAllocationCallbacks)
6483{
6484 /*
6485 We want to keep track of the byte position in the stream of the seektable. At the time of calling this function we know that
6486 we'll be sitting on byte 42.
6487 */
6488 drflac_uint64 runningFilePos = 42;
6489 drflac_uint64 seektablePos = 0;
6490 drflac_uint32 seektableSize = 0;
6491
6492 for (;;) {
6493 drflac_metadata metadata;
6494 drflac_uint8 isLastBlock = 0;
6495 drflac_uint8 blockType = 0;
6496 drflac_uint32 blockSize;
6497 if (drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize) == DRFLAC_FALSE) {
6498 return DRFLAC_FALSE;
6499 }
6500 runningFilePos += 4;
6501
6502 metadata.type = blockType;
6503 metadata.pRawData = NULL;
6504 metadata.rawDataSize = 0;
6505
6506 switch (blockType)
6507 {
6508 case DRFLAC_METADATA_BLOCK_TYPE_APPLICATION:
6509 {
6510 if (blockSize < 4) {
6511 return DRFLAC_FALSE;
6512 }
6513
6514 if (onMeta) {
6515 void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
6516 if (pRawData == NULL) {
6517 return DRFLAC_FALSE;
6518 }
6519
6520 if (onRead(pUserData, pRawData, blockSize) != blockSize) {
6521 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6522 return DRFLAC_FALSE;
6523 }
6524
6525 metadata.pRawData = pRawData;
6526 metadata.rawDataSize = blockSize;
6527 metadata.data.application.id = drflac__be2host_32(*(drflac_uint32*)pRawData);
6528 metadata.data.application.pData = (const void*)((drflac_uint8*)pRawData + sizeof(drflac_uint32));
6529 metadata.data.application.dataSize = blockSize - sizeof(drflac_uint32);
6530 onMeta(pUserDataMD, &metadata);
6531
6532 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6533 }
6534 } break;
6535
6536 case DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE:
6537 {
6538 seektablePos = runningFilePos;
6539 seektableSize = blockSize;
6540
6541 if (onMeta) {
6542 drflac_uint32 seekpointCount;
6543 drflac_uint32 iSeekpoint;
6544 void* pRawData;
6545
6546 seekpointCount = blockSize/DRFLAC_SEEKPOINT_SIZE_IN_BYTES;
6547
6548 pRawData = drflac__malloc_from_callbacks(seekpointCount * sizeof(drflac_seekpoint), pAllocationCallbacks);
6549 if (pRawData == NULL) {
6550 return DRFLAC_FALSE;
6551 }
6552
6553 /* We need to read seekpoint by seekpoint and do some processing. */
6554 for (iSeekpoint = 0; iSeekpoint < seekpointCount; ++iSeekpoint) {
6555 drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
6556
6557 if (onRead(pUserData, pSeekpoint, DRFLAC_SEEKPOINT_SIZE_IN_BYTES) != DRFLAC_SEEKPOINT_SIZE_IN_BYTES) {
6558 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6559 return DRFLAC_FALSE;
6560 }
6561
6562 /* Endian swap. */
6563 pSeekpoint->firstPCMFrame = drflac__be2host_64(pSeekpoint->firstPCMFrame);
6564 pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
6565 pSeekpoint->pcmFrameCount = drflac__be2host_16(pSeekpoint->pcmFrameCount);
6566 }
6567
6568 metadata.pRawData = pRawData;
6569 metadata.rawDataSize = blockSize;
6570 metadata.data.seektable.seekpointCount = seekpointCount;
6571 metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
6572
6573 onMeta(pUserDataMD, &metadata);
6574
6575 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6576 }
6577 } break;
6578
6579 case DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT:
6580 {
6581 if (blockSize < 8) {
6582 return DRFLAC_FALSE;
6583 }
6584
6585 if (onMeta) {
6586 void* pRawData;
6587 const char* pRunningData;
6588 const char* pRunningDataEnd;
6589 drflac_uint32 i;
6590
6591 pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
6592 if (pRawData == NULL) {
6593 return DRFLAC_FALSE;
6594 }
6595
6596 if (onRead(pUserData, pRawData, blockSize) != blockSize) {
6597 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6598 return DRFLAC_FALSE;
6599 }
6600
6601 metadata.pRawData = pRawData;
6602 metadata.rawDataSize = blockSize;
6603
6604 pRunningData = (const char*)pRawData;
6605 pRunningDataEnd = (const char*)pRawData + blockSize;
6606
6607 metadata.data.vorbis_comment.vendorLength = drflac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6608
6609 /* Need space for the rest of the block */
6610 if ((pRunningDataEnd - pRunningData) - 4 < (drflac_int64)metadata.data.vorbis_comment.vendorLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
6611 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6612 return DRFLAC_FALSE;
6613 }
6614 metadata.data.vorbis_comment.vendor = pRunningData; pRunningData += metadata.data.vorbis_comment.vendorLength;
6615 metadata.data.vorbis_comment.commentCount = drflac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6616
6617 /* Need space for 'commentCount' comments after the block, which at minimum is a drflac_uint32 per comment */
6618 if ((pRunningDataEnd - pRunningData) / sizeof(drflac_uint32) < metadata.data.vorbis_comment.commentCount) { /* <-- Note the order of operations to avoid overflow to a valid value */
6619 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6620 return DRFLAC_FALSE;
6621 }
6622 metadata.data.vorbis_comment.pComments = pRunningData;
6623
6624 /* Check that the comments section is valid before passing it to the callback */
6625 for (i = 0; i < metadata.data.vorbis_comment.commentCount; ++i) {
6626 drflac_uint32 commentLength;
6627
6628 if (pRunningDataEnd - pRunningData < 4) {
6629 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6630 return DRFLAC_FALSE;
6631 }
6632
6633 commentLength = drflac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6634 if (pRunningDataEnd - pRunningData < (drflac_int64)commentLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
6635 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6636 return DRFLAC_FALSE;
6637 }
6638 pRunningData += commentLength;
6639 }
6640
6641 onMeta(pUserDataMD, &metadata);
6642
6643 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6644 }
6645 } break;
6646
6647 case DRFLAC_METADATA_BLOCK_TYPE_CUESHEET:
6648 {
6649 if (blockSize < 396) {
6650 return DRFLAC_FALSE;
6651 }
6652
6653 if (onMeta) {
6654 void* pRawData;
6655 const char* pRunningData;
6656 const char* pRunningDataEnd;
6657 size_t bufferSize;
6658 drflac_uint8 iTrack;
6659 drflac_uint8 iIndex;
6660 void* pTrackData;
6661
6662 /*
6663 This needs to be loaded in two passes. The first pass is used to calculate the size of the memory allocation
6664 we need for storing the necessary data. The second pass will fill that buffer with usable data.
6665 */
6666 pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
6667 if (pRawData == NULL) {
6668 return DRFLAC_FALSE;
6669 }
6670
6671 if (onRead(pUserData, pRawData, blockSize) != blockSize) {
6672 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6673 return DRFLAC_FALSE;
6674 }
6675
6676 metadata.pRawData = pRawData;
6677 metadata.rawDataSize = blockSize;
6678
6679 pRunningData = (const char*)pRawData;
6680 pRunningDataEnd = (const char*)pRawData + blockSize;
6681
6682 DRFLAC_COPY_MEMORY(metadata.data.cuesheet.catalog, pRunningData, 128); pRunningData += 128;
6683 metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
6684 metadata.data.cuesheet.isCD = (pRunningData[0] & 0x80) != 0; pRunningData += 259;
6685 metadata.data.cuesheet.trackCount = pRunningData[0]; pRunningData += 1;
6686 metadata.data.cuesheet.pTrackData = NULL; /* Will be filled later. */
6687
6688 /* Pass 1: Calculate the size of the buffer for the track data. */
6689 {
6690 const char* pRunningDataSaved = pRunningData; /* Will be restored at the end in preparation for the second pass. */
6691
6692 bufferSize = metadata.data.cuesheet.trackCount * DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES;
6693
6694 for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
6695 drflac_uint8 indexCount;
6696 drflac_uint32 indexPointSize;
6697
6698 if (pRunningDataEnd - pRunningData < DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES) {
6699 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6700 return DRFLAC_FALSE;
6701 }
6702
6703 /* Skip to the index point count */
6704 pRunningData += 35;
6705
6706 indexCount = pRunningData[0];
6707 pRunningData += 1;
6708
6709 bufferSize += indexCount * sizeof(drflac_cuesheet_track_index);
6710
6711 /* Quick validation check. */
6712 indexPointSize = indexCount * DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES;
6713 if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
6714 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6715 return DRFLAC_FALSE;
6716 }
6717
6718 pRunningData += indexPointSize;
6719 }
6720
6721 pRunningData = pRunningDataSaved;
6722 }
6723
6724 /* Pass 2: Allocate a buffer and fill the data. Validation was done in the step above so can be skipped. */
6725 {
6726 char* pRunningTrackData;
6727
6728 pTrackData = drflac__malloc_from_callbacks(bufferSize, pAllocationCallbacks);
6729 if (pTrackData == NULL) {
6730 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6731 return DRFLAC_FALSE;
6732 }
6733
6734 pRunningTrackData = (char*)pTrackData;
6735
6736 for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
6737 drflac_uint8 indexCount;
6738
6739 DRFLAC_COPY_MEMORY(pRunningTrackData, pRunningData, DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES);
6740 pRunningData += DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1; /* Skip forward, but not beyond the last byte in the CUESHEET_TRACK block which is the index count. */
6741 pRunningTrackData += DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1;
6742
6743 /* Grab the index count for the next part. */
6744 indexCount = pRunningData[0];
6745 pRunningData += 1;
6746 pRunningTrackData += 1;
6747
6748 /* Extract each track index. */
6749 for (iIndex = 0; iIndex < indexCount; ++iIndex) {
6750 drflac_cuesheet_track_index* pTrackIndex = (drflac_cuesheet_track_index*)pRunningTrackData;
6751
6752 DRFLAC_COPY_MEMORY(pRunningTrackData, pRunningData, DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES);
6753 pRunningData += DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES;
6754 pRunningTrackData += sizeof(drflac_cuesheet_track_index);
6755
6756 pTrackIndex->offset = drflac__be2host_64(pTrackIndex->offset);
6757 }
6758 }
6759
6760 metadata.data.cuesheet.pTrackData = pTrackData;
6761 }
6762
6763 /* The original data is no longer needed. */
6764 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6765 pRawData = NULL;
6766
6767 onMeta(pUserDataMD, &metadata);
6768
6769 drflac__free_from_callbacks(pTrackData, pAllocationCallbacks);
6770 pTrackData = NULL;
6771 }
6772 } break;
6773
6774 case DRFLAC_METADATA_BLOCK_TYPE_PICTURE:
6775 {
6776 if (blockSize < 32) {
6777 return DRFLAC_FALSE;
6778 }
6779
6780 if (onMeta) {
6781 void* pRawData;
6782 const char* pRunningData;
6783 const char* pRunningDataEnd;
6784
6785 pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
6786 if (pRawData == NULL) {
6787 return DRFLAC_FALSE;
6788 }
6789
6790 if (onRead(pUserData, pRawData, blockSize) != blockSize) {
6791 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6792 return DRFLAC_FALSE;
6793 }
6794
6795 metadata.pRawData = pRawData;
6796 metadata.rawDataSize = blockSize;
6797
6798 pRunningData = (const char*)pRawData;
6799 pRunningDataEnd = (const char*)pRawData + blockSize;
6800
6801 metadata.data.picture.type = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6802 metadata.data.picture.mimeLength = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6803
6804 /* Need space for the rest of the block */
6805 if ((pRunningDataEnd - pRunningData) - 24 < (drflac_int64)metadata.data.picture.mimeLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
6806 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6807 return DRFLAC_FALSE;
6808 }
6809 metadata.data.picture.mime = pRunningData; pRunningData += metadata.data.picture.mimeLength;
6810 metadata.data.picture.descriptionLength = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6811
6812 /* Need space for the rest of the block */
6813 if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
6814 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6815 return DRFLAC_FALSE;
6816 }
6817 metadata.data.picture.description = pRunningData; pRunningData += metadata.data.picture.descriptionLength;
6818 metadata.data.picture.width = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6819 metadata.data.picture.height = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6820 metadata.data.picture.colorDepth = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6821 metadata.data.picture.indexColorCount = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6822 metadata.data.picture.pictureDataSize = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
6823 metadata.data.picture.pPictureData = (const drflac_uint8*)pRunningData;
6824
6825 /* Need space for the picture after the block */
6826 if (pRunningDataEnd - pRunningData < (drflac_int64)metadata.data.picture.pictureDataSize) { /* <-- Note the order of operations to avoid overflow to a valid value */
6827 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6828 return DRFLAC_FALSE;
6829 }
6830
6831 onMeta(pUserDataMD, &metadata);
6832
6833 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6834 }
6835 } break;
6836
6837 case DRFLAC_METADATA_BLOCK_TYPE_PADDING:
6838 {
6839 if (onMeta) {
6840 metadata.data.padding.unused = 0;
6841
6842 /* Padding doesn't have anything meaningful in it, so just skip over it, but make sure the caller is aware of it by firing the callback. */
6843 if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
6844 isLastBlock = DRFLAC_TRUE; /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
6845 } else {
6846 onMeta(pUserDataMD, &metadata);
6847 }
6848 }
6849 } break;
6850
6851 case DRFLAC_METADATA_BLOCK_TYPE_INVALID:
6852 {
6853 /* Invalid chunk. Just skip over this one. */
6854 if (onMeta) {
6855 if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
6856 isLastBlock = DRFLAC_TRUE; /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
6857 }
6858 }
6859 } break;
6860
6861 default:
6862 {
6863 /*
6864 It's an unknown chunk, but not necessarily invalid. There's a chance more metadata blocks might be defined later on, so we
6865 can at the very least report the chunk to the application and let it look at the raw data.
6866 */
6867 if (onMeta) {
6868 void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
6869 if (pRawData == NULL) {
6870 return DRFLAC_FALSE;
6871 }
6872
6873 if (onRead(pUserData, pRawData, blockSize) != blockSize) {
6874 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6875 return DRFLAC_FALSE;
6876 }
6877
6878 metadata.pRawData = pRawData;
6879 metadata.rawDataSize = blockSize;
6880 onMeta(pUserDataMD, &metadata);
6881
6882 drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
6883 }
6884 } break;
6885 }
6886
6887 /* If we're not handling metadata, just skip over the block. If we are, it will have been handled earlier in the switch statement above. */
6888 if (onMeta == NULL && blockSize > 0) {
6889 if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
6890 isLastBlock = DRFLAC_TRUE;
6891 }
6892 }
6893
6894 runningFilePos += blockSize;
6895 if (isLastBlock) {
6896 break;
6897 }
6898 }
6899
6900 *pSeektablePos = seektablePos;
6901 *pSeekpointCount = seektableSize / DRFLAC_SEEKPOINT_SIZE_IN_BYTES;
6902 *pFirstFramePos = runningFilePos;
6903
6904 return DRFLAC_TRUE;
6905}
6906
6907static drflac_bool32 drflac__init_private__native(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
6908{
6909 /* Pre Condition: The bit stream should be sitting just past the 4-byte id header. */
6910
6911 drflac_uint8 isLastBlock;
6912 drflac_uint8 blockType;
6913 drflac_uint32 blockSize;
6914
6915 (void)onSeek;
6916
6917 pInit->container = drflac_container_native;
6918
6919 /* The first metadata block should be the STREAMINFO block. */
6920 if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
6921 return DRFLAC_FALSE;
6922 }
6923
6924 if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
6925 if (!relaxed) {
6926 /* We're opening in strict mode and the first block is not the STREAMINFO block. Error. */
6927 return DRFLAC_FALSE;
6928 } else {
6929 /*
6930 Relaxed mode. To open from here we need to just find the first frame and set the sample rate, etc. to whatever is defined
6931 for that frame.
6932 */
6933 pInit->hasStreamInfoBlock = DRFLAC_FALSE;
6934 pInit->hasMetadataBlocks = DRFLAC_FALSE;
6935
6936 if (!drflac__read_next_flac_frame_header(&pInit->bs, 0, &pInit->firstFrameHeader)) {
6937 return DRFLAC_FALSE; /* Couldn't find a frame. */
6938 }
6939
6940 if (pInit->firstFrameHeader.bitsPerSample == 0) {
6941 return DRFLAC_FALSE; /* Failed to initialize because the first frame depends on the STREAMINFO block, which does not exist. */
6942 }
6943
6944 pInit->sampleRate = pInit->firstFrameHeader.sampleRate;
6945 pInit->channels = drflac__get_channel_count_from_channel_assignment(pInit->firstFrameHeader.channelAssignment);
6946 pInit->bitsPerSample = pInit->firstFrameHeader.bitsPerSample;
6947 pInit->maxBlockSizeInPCMFrames = 65535; /* <-- See notes here: https://xiph.org/flac/format.html#metadata_block_streaminfo */
6948 return DRFLAC_TRUE;
6949 }
6950 } else {
6951 drflac_streaminfo streaminfo;
6952 if (!drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
6953 return DRFLAC_FALSE;
6954 }
6955
6956 pInit->hasStreamInfoBlock = DRFLAC_TRUE;
6957 pInit->sampleRate = streaminfo.sampleRate;
6958 pInit->channels = streaminfo.channels;
6959 pInit->bitsPerSample = streaminfo.bitsPerSample;
6960 pInit->totalPCMFrameCount = streaminfo.totalPCMFrameCount;
6961 pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames; /* Don't care about the min block size - only the max (used for determining the size of the memory allocation). */
6962 pInit->hasMetadataBlocks = !isLastBlock;
6963
6964 if (onMeta) {
6965 drflac_metadata metadata;
6966 metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
6967 metadata.pRawData = NULL;
6968 metadata.rawDataSize = 0;
6969 metadata.data.streaminfo = streaminfo;
6970 onMeta(pUserDataMD, &metadata);
6971 }
6972
6973 return DRFLAC_TRUE;
6974 }
6975}
6976
6977#ifndef DR_FLAC_NO_OGG
6978#define DRFLAC_OGG_MAX_PAGE_SIZE 65307
6979#define DRFLAC_OGG_CAPTURE_PATTERN_CRC32 1605413199 /* CRC-32 of "OggS". */
6980
6981typedef enum
6982{
6983 drflac_ogg_recover_on_crc_mismatch,
6984 drflac_ogg_fail_on_crc_mismatch
6985} drflac_ogg_crc_mismatch_recovery;
6986
6987#ifndef DR_FLAC_NO_CRC
6988static drflac_uint32 drflac__crc32_table[] = {
6989 0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L,
6990 0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
6991 0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L,
6992 0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
6993 0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L,
6994 0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
6995 0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L,
6996 0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
6997 0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L,
6998 0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
6999 0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L,
7000 0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
7001 0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L,
7002 0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
7003 0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L,
7004 0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
7005 0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL,
7006 0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
7007 0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L,
7008 0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL,
7009 0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL,
7010 0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
7011 0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L,
7012 0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
7013 0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL,
7014 0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
7015 0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L,
7016 0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
7017 0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL,
7018 0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
7019 0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L,
7020 0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
7021 0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L,
7022 0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
7023 0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL,
7024 0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
7025 0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L,
7026 0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
7027 0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL,
7028 0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
7029 0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L,
7030 0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
7031 0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL,
7032 0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
7033 0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L,
7034 0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
7035 0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL,
7036 0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
7037 0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L,
7038 0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
7039 0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L,
7040 0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
7041 0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L,
7042 0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL,
7043 0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L,
7044 0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
7045 0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L,
7046 0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
7047 0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L,
7048 0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
7049 0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L,
7050 0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
7051 0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L,
7052 0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
7053};
7054#endif
7055
7056static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac_uint8 data)
7057{
7058#ifndef DR_FLAC_NO_CRC
7059 return (crc32 << 8) ^ drflac__crc32_table[(drflac_uint8)((crc32 >> 24) & 0xFF) ^ data];
7060#else
7061 (void)data;
7062 return crc32;
7063#endif
7064}
7065
7066#if 0
7067static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint32(drflac_uint32 crc32, drflac_uint32 data)
7068{
7069 crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 24) & 0xFF));
7070 crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 16) & 0xFF));
7071 crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 8) & 0xFF));
7072 crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 0) & 0xFF));
7073 return crc32;
7074}
7075
7076static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint64(drflac_uint32 crc32, drflac_uint64 data)
7077{
7078 crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >> 32) & 0xFFFFFFFF));
7079 crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >> 0) & 0xFFFFFFFF));
7080 return crc32;
7081}
7082#endif
7083
7084static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
7085{
7086 /* This can be optimized. */
7087 drflac_uint32 i;
7088 for (i = 0; i < dataSize; ++i) {
7089 crc32 = drflac_crc32_byte(crc32, pData[i]);
7090 }
7091 return crc32;
7092}
7093
7094
7095static DRFLAC_INLINE drflac_bool32 drflac_ogg__is_capture_pattern(drflac_uint8 pattern[4])
7096{
7097 return pattern[0] == 'O' && pattern[1] == 'g' && pattern[2] == 'g' && pattern[3] == 'S';
7098}
7099
7100static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_header_size(drflac_ogg_page_header* pHeader)
7101{
7102 return 27 + pHeader->segmentCount;
7103}
7104
7105static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_body_size(drflac_ogg_page_header* pHeader)
7106{
7107 drflac_uint32 pageBodySize = 0;
7108 int i;
7109
7110 for (i = 0; i < pHeader->segmentCount; ++i) {
7111 pageBodySize += pHeader->segmentTable[i];
7112 }
7113
7114 return pageBodySize;
7115}
7116
7117static drflac_result drflac_ogg__read_page_header_after_capture_pattern(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
7118{
7119 drflac_uint8 data[23];
7120 drflac_uint32 i;
7121
7122 DRFLAC_ASSERT(*pCRC32 == DRFLAC_OGG_CAPTURE_PATTERN_CRC32);
7123
7124 if (onRead(pUserData, data, 23) != 23) {
7125 return DRFLAC_AT_END;
7126 }
7127 *pBytesRead += 23;
7128
7129 /*
7130 It's not actually used, but set the capture pattern to 'OggS' for completeness. Not doing this will cause static analysers to complain about
7131 us trying to access uninitialized data. We could alternatively just comment out this member of the drflac_ogg_page_header structure, but I
7132 like to have it map to the structure of the underlying data.
7133 */
7134 pHeader->capturePattern[0] = 'O';
7135 pHeader->capturePattern[1] = 'g';
7136 pHeader->capturePattern[2] = 'g';
7137 pHeader->capturePattern[3] = 'S';
7138
7139 pHeader->structureVersion = data[0];
7140 pHeader->headerType = data[1];
7141 DRFLAC_COPY_MEMORY(&pHeader->granulePosition, &data[ 2], 8);
7142 DRFLAC_COPY_MEMORY(&pHeader->serialNumber, &data[10], 4);
7143 DRFLAC_COPY_MEMORY(&pHeader->sequenceNumber, &data[14], 4);
7144 DRFLAC_COPY_MEMORY(&pHeader->checksum, &data[18], 4);
7145 pHeader->segmentCount = data[22];
7146
7147 /* Calculate the CRC. Note that for the calculation the checksum part of the page needs to be set to 0. */
7148 data[18] = 0;
7149 data[19] = 0;
7150 data[20] = 0;
7151 data[21] = 0;
7152
7153 for (i = 0; i < 23; ++i) {
7154 *pCRC32 = drflac_crc32_byte(*pCRC32, data[i]);
7155 }
7156
7157
7158 if (onRead(pUserData, pHeader->segmentTable, pHeader->segmentCount) != pHeader->segmentCount) {
7159 return DRFLAC_AT_END;
7160 }
7161 *pBytesRead += pHeader->segmentCount;
7162
7163 for (i = 0; i < pHeader->segmentCount; ++i) {
7164 *pCRC32 = drflac_crc32_byte(*pCRC32, pHeader->segmentTable[i]);
7165 }
7166
7167 return DRFLAC_SUCCESS;
7168}
7169
7170static drflac_result drflac_ogg__read_page_header(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
7171{
7172 drflac_uint8 id[4];
7173
7174 *pBytesRead = 0;
7175
7176 if (onRead(pUserData, id, 4) != 4) {
7177 return DRFLAC_AT_END;
7178 }
7179 *pBytesRead += 4;
7180
7181 /* We need to read byte-by-byte until we find the OggS capture pattern. */
7182 for (;;) {
7183 if (drflac_ogg__is_capture_pattern(id)) {
7184 drflac_result result;
7185
7186 *pCRC32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
7187
7188 result = drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, pHeader, pBytesRead, pCRC32);
7189 if (result == DRFLAC_SUCCESS) {
7190 return DRFLAC_SUCCESS;
7191 } else {
7192 if (result == DRFLAC_CRC_MISMATCH) {
7193 continue;
7194 } else {
7195 return result;
7196 }
7197 }
7198 } else {
7199 /* The first 4 bytes did not equal the capture pattern. Read the next byte and try again. */
7200 id[0] = id[1];
7201 id[1] = id[2];
7202 id[2] = id[3];
7203 if (onRead(pUserData, &id[3], 1) != 1) {
7204 return DRFLAC_AT_END;
7205 }
7206 *pBytesRead += 1;
7207 }
7208 }
7209}
7210
7211
7212/*
7213The main part of the Ogg encapsulation is the conversion from the physical Ogg bitstream to the native FLAC bitstream. It works
7214in three general stages: Ogg Physical Bitstream -> Ogg/FLAC Logical Bitstream -> FLAC Native Bitstream. dr_flac is designed
7215in such a way that the core sections assume everything is delivered in native format. Therefore, for each encapsulation type
7216dr_flac is supporting there needs to be a layer sitting on top of the onRead and onSeek callbacks that ensures the bits read from
7217the physical Ogg bitstream are converted and delivered in native FLAC format.
7218*/
7219typedef struct
7220{
7221 drflac_read_proc onRead; /* The original onRead callback from drflac_open() and family. */
7222 drflac_seek_proc onSeek; /* The original onSeek callback from drflac_open() and family. */
7223 void* pUserData; /* The user data passed on onRead and onSeek. This is the user data that was passed on drflac_open() and family. */
7224 drflac_uint64 currentBytePos; /* The position of the byte we are sitting on in the physical byte stream. Used for efficient seeking. */
7225 drflac_uint64 firstBytePos; /* The position of the first byte in the physical bitstream. Points to the start of the "OggS" identifier of the FLAC bos page. */
7226 drflac_uint32 serialNumber; /* The serial number of the FLAC audio pages. This is determined by the initial header page that was read during initialization. */
7227 drflac_ogg_page_header bosPageHeader; /* Used for seeking. */
7228 drflac_ogg_page_header currentPageHeader;
7229 drflac_uint32 bytesRemainingInPage;
7230 drflac_uint32 pageDataSize;
7231 drflac_uint8 pageData[DRFLAC_OGG_MAX_PAGE_SIZE];
7232} drflac_oggbs; /* oggbs = Ogg Bitstream */
7233
7234static size_t drflac_oggbs__read_physical(drflac_oggbs* oggbs, void* bufferOut, size_t bytesToRead)
7235{
7236 size_t bytesActuallyRead = oggbs->onRead(oggbs->pUserData, bufferOut, bytesToRead);
7237 oggbs->currentBytePos += bytesActuallyRead;
7238
7239 return bytesActuallyRead;
7240}
7241
7242static drflac_bool32 drflac_oggbs__seek_physical(drflac_oggbs* oggbs, drflac_uint64 offset, drflac_seek_origin origin)
7243{
7244 if (origin == drflac_seek_origin_start) {
7245 if (offset <= 0x7FFFFFFF) {
7246 if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_start)) {
7247 return DRFLAC_FALSE;
7248 }
7249 oggbs->currentBytePos = offset;
7250
7251 return DRFLAC_TRUE;
7252 } else {
7253 if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
7254 return DRFLAC_FALSE;
7255 }
7256 oggbs->currentBytePos = offset;
7257
7258 return drflac_oggbs__seek_physical(oggbs, offset - 0x7FFFFFFF, drflac_seek_origin_current);
7259 }
7260 } else {
7261 while (offset > 0x7FFFFFFF) {
7262 if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
7263 return DRFLAC_FALSE;
7264 }
7265 oggbs->currentBytePos += 0x7FFFFFFF;
7266 offset -= 0x7FFFFFFF;
7267 }
7268
7269 if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_current)) { /* <-- Safe cast thanks to the loop above. */
7270 return DRFLAC_FALSE;
7271 }
7272 oggbs->currentBytePos += offset;
7273
7274 return DRFLAC_TRUE;
7275 }
7276}
7277
7278static drflac_bool32 drflac_oggbs__goto_next_page(drflac_oggbs* oggbs, drflac_ogg_crc_mismatch_recovery recoveryMethod)
7279{
7280 drflac_ogg_page_header header;
7281 for (;;) {
7282 drflac_uint32 crc32 = 0;
7283 drflac_uint32 bytesRead;
7284 drflac_uint32 pageBodySize;
7285#ifndef DR_FLAC_NO_CRC
7286 drflac_uint32 actualCRC32;
7287#endif
7288
7289 if (drflac_ogg__read_page_header(oggbs->onRead, oggbs->pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
7290 return DRFLAC_FALSE;
7291 }
7292 oggbs->currentBytePos += bytesRead;
7293
7294 pageBodySize = drflac_ogg__get_page_body_size(&header);
7295 if (pageBodySize > DRFLAC_OGG_MAX_PAGE_SIZE) {
7296 continue; /* Invalid page size. Assume it's corrupted and just move to the next page. */
7297 }
7298
7299 if (header.serialNumber != oggbs->serialNumber) {
7300 /* It's not a FLAC page. Skip it. */
7301 if (pageBodySize > 0 && !drflac_oggbs__seek_physical(oggbs, pageBodySize, drflac_seek_origin_current)) {
7302 return DRFLAC_FALSE;
7303 }
7304 continue;
7305 }
7306
7307
7308 /* We need to read the entire page and then do a CRC check on it. If there's a CRC mismatch we need to skip this page. */
7309 if (drflac_oggbs__read_physical(oggbs, oggbs->pageData, pageBodySize) != pageBodySize) {
7310 return DRFLAC_FALSE;
7311 }
7312 oggbs->pageDataSize = pageBodySize;
7313
7314#ifndef DR_FLAC_NO_CRC
7315 actualCRC32 = drflac_crc32_buffer(crc32, oggbs->pageData, oggbs->pageDataSize);
7316 if (actualCRC32 != header.checksum) {
7317 if (recoveryMethod == drflac_ogg_recover_on_crc_mismatch) {
7318 continue; /* CRC mismatch. Skip this page. */
7319 } else {
7320 /*
7321 Even though we are failing on a CRC mismatch, we still want our stream to be in a good state. Therefore we
7322 go to the next valid page to ensure we're in a good state, but return false to let the caller know that the
7323 seek did not fully complete.
7324 */
7325 drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch);
7326 return DRFLAC_FALSE;
7327 }
7328 }
7329#else
7330 (void)recoveryMethod; /* <-- Silence a warning. */
7331#endif
7332
7333 oggbs->currentPageHeader = header;
7334 oggbs->bytesRemainingInPage = pageBodySize;
7335 return DRFLAC_TRUE;
7336 }
7337}
7338
7339/* Function below is unused at the moment, but I might be re-adding it later. */
7340#if 0
7341static drflac_uint8 drflac_oggbs__get_current_segment_index(drflac_oggbs* oggbs, drflac_uint8* pBytesRemainingInSeg)
7342{
7343 drflac_uint32 bytesConsumedInPage = drflac_ogg__get_page_body_size(&oggbs->currentPageHeader) - oggbs->bytesRemainingInPage;
7344 drflac_uint8 iSeg = 0;
7345 drflac_uint32 iByte = 0;
7346 while (iByte < bytesConsumedInPage) {
7347 drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
7348 if (iByte + segmentSize > bytesConsumedInPage) {
7349 break;
7350 } else {
7351 iSeg += 1;
7352 iByte += segmentSize;
7353 }
7354 }
7355
7356 *pBytesRemainingInSeg = oggbs->currentPageHeader.segmentTable[iSeg] - (drflac_uint8)(bytesConsumedInPage - iByte);
7357 return iSeg;
7358}
7359
7360static drflac_bool32 drflac_oggbs__seek_to_next_packet(drflac_oggbs* oggbs)
7361{
7362 /* The current packet ends when we get to the segment with a lacing value of < 255 which is not at the end of a page. */
7363 for (;;) {
7364 drflac_bool32 atEndOfPage = DRFLAC_FALSE;
7365
7366 drflac_uint8 bytesRemainingInSeg;
7367 drflac_uint8 iFirstSeg = drflac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
7368
7369 drflac_uint32 bytesToEndOfPacketOrPage = bytesRemainingInSeg;
7370 for (drflac_uint8 iSeg = iFirstSeg; iSeg < oggbs->currentPageHeader.segmentCount; ++iSeg) {
7371 drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
7372 if (segmentSize < 255) {
7373 if (iSeg == oggbs->currentPageHeader.segmentCount-1) {
7374 atEndOfPage = DRFLAC_TRUE;
7375 }
7376
7377 break;
7378 }
7379
7380 bytesToEndOfPacketOrPage += segmentSize;
7381 }
7382
7383 /*
7384 At this point we will have found either the packet or the end of the page. If were at the end of the page we'll
7385 want to load the next page and keep searching for the end of the packet.
7386 */
7387 drflac_oggbs__seek_physical(oggbs, bytesToEndOfPacketOrPage, drflac_seek_origin_current);
7388 oggbs->bytesRemainingInPage -= bytesToEndOfPacketOrPage;
7389
7390 if (atEndOfPage) {
7391 /*
7392 We're potentially at the next packet, but we need to check the next page first to be sure because the packet may
7393 straddle pages.
7394 */
7395 if (!drflac_oggbs__goto_next_page(oggbs)) {
7396 return DRFLAC_FALSE;
7397 }
7398
7399 /* If it's a fresh packet it most likely means we're at the next packet. */
7400 if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
7401 return DRFLAC_TRUE;
7402 }
7403 } else {
7404 /* We're at the next packet. */
7405 return DRFLAC_TRUE;
7406 }
7407 }
7408}
7409
7410static drflac_bool32 drflac_oggbs__seek_to_next_frame(drflac_oggbs* oggbs)
7411{
7412 /* The bitstream should be sitting on the first byte just after the header of the frame. */
7413
7414 /* What we're actually doing here is seeking to the start of the next packet. */
7415 return drflac_oggbs__seek_to_next_packet(oggbs);
7416}
7417#endif
7418
7419static size_t drflac__on_read_ogg(void* pUserData, void* bufferOut, size_t bytesToRead)
7420{
7421 drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
7422 drflac_uint8* pRunningBufferOut = (drflac_uint8*)bufferOut;
7423 size_t bytesRead = 0;
7424
7425 DRFLAC_ASSERT(oggbs != NULL);
7426 DRFLAC_ASSERT(pRunningBufferOut != NULL);
7427
7428 /* Reading is done page-by-page. If we've run out of bytes in the page we need to move to the next one. */
7429 while (bytesRead < bytesToRead) {
7430 size_t bytesRemainingToRead = bytesToRead - bytesRead;
7431
7432 if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) {
7433 DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), bytesRemainingToRead);
7434 bytesRead += bytesRemainingToRead;
7435 oggbs->bytesRemainingInPage -= (drflac_uint32)bytesRemainingToRead;
7436 break;
7437 }
7438
7439 /* If we get here it means some of the requested data is contained in the next pages. */
7440 if (oggbs->bytesRemainingInPage > 0) {
7441 DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), oggbs->bytesRemainingInPage);
7442 bytesRead += oggbs->bytesRemainingInPage;
7443 pRunningBufferOut += oggbs->bytesRemainingInPage;
7444 oggbs->bytesRemainingInPage = 0;
7445 }
7446
7447 DRFLAC_ASSERT(bytesRemainingToRead > 0);
7448 if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
7449 break; /* Failed to go to the next page. Might have simply hit the end of the stream. */
7450 }
7451 }
7452
7453 return bytesRead;
7454}
7455
7456static drflac_bool32 drflac__on_seek_ogg(void* pUserData, int offset, drflac_seek_origin origin)
7457{
7458 drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
7459 int bytesSeeked = 0;
7460
7461 DRFLAC_ASSERT(oggbs != NULL);
7462 DRFLAC_ASSERT(offset >= 0); /* <-- Never seek backwards. */
7463
7464 /* Seeking is always forward which makes things a lot simpler. */
7465 if (origin == drflac_seek_origin_start) {
7466 if (!drflac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, drflac_seek_origin_start)) {
7467 return DRFLAC_FALSE;
7468 }
7469
7470 if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
7471 return DRFLAC_FALSE;
7472 }
7473
7474 return drflac__on_seek_ogg(pUserData, offset, drflac_seek_origin_current);
7475 }
7476
7477 DRFLAC_ASSERT(origin == drflac_seek_origin_current);
7478
7479 while (bytesSeeked < offset) {
7480 int bytesRemainingToSeek = offset - bytesSeeked;
7481 DRFLAC_ASSERT(bytesRemainingToSeek >= 0);
7482
7483 if (oggbs->bytesRemainingInPage >= (size_t)bytesRemainingToSeek) {
7484 bytesSeeked += bytesRemainingToSeek;
7485 (void)bytesSeeked; /* <-- Silence a dead store warning emitted by Clang Static Analyzer. */
7486 oggbs->bytesRemainingInPage -= bytesRemainingToSeek;
7487 break;
7488 }
7489
7490 /* If we get here it means some of the requested data is contained in the next pages. */
7491 if (oggbs->bytesRemainingInPage > 0) {
7492 bytesSeeked += (int)oggbs->bytesRemainingInPage;
7493 oggbs->bytesRemainingInPage = 0;
7494 }
7495
7496 DRFLAC_ASSERT(bytesRemainingToSeek > 0);
7497 if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
7498 /* Failed to go to the next page. We either hit the end of the stream or had a CRC mismatch. */
7499 return DRFLAC_FALSE;
7500 }
7501 }
7502
7503 return DRFLAC_TRUE;
7504}
7505
7506
7507static drflac_bool32 drflac_ogg__seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
7508{
7509 drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
7510 drflac_uint64 originalBytePos;
7511 drflac_uint64 runningGranulePosition;
7512 drflac_uint64 runningFrameBytePos;
7513 drflac_uint64 runningPCMFrameCount;
7514
7515 DRFLAC_ASSERT(oggbs != NULL);
7516
7517 originalBytePos = oggbs->currentBytePos; /* For recovery. Points to the OggS identifier. */
7518
7519 /* First seek to the first frame. */
7520 if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) {
7521 return DRFLAC_FALSE;
7522 }
7523 oggbs->bytesRemainingInPage = 0;
7524
7525 runningGranulePosition = 0;
7526 for (;;) {
7527 if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
7528 drflac_oggbs__seek_physical(oggbs, originalBytePos, drflac_seek_origin_start);
7529 return DRFLAC_FALSE; /* Never did find that sample... */
7530 }
7531
7532 runningFrameBytePos = oggbs->currentBytePos - drflac_ogg__get_page_header_size(&oggbs->currentPageHeader) - oggbs->pageDataSize;
7533 if (oggbs->currentPageHeader.granulePosition >= pcmFrameIndex) {
7534 break; /* The sample is somewhere in the previous page. */
7535 }
7536
7537 /*
7538 At this point we know the sample is not in the previous page. It could possibly be in this page. For simplicity we
7539 disregard any pages that do not begin a fresh packet.
7540 */
7541 if ((oggbs->currentPageHeader.headerType & 0x01) == 0) { /* <-- Is it a fresh page? */
7542 if (oggbs->currentPageHeader.segmentTable[0] >= 2) {
7543 drflac_uint8 firstBytesInPage[2];
7544 firstBytesInPage[0] = oggbs->pageData[0];
7545 firstBytesInPage[1] = oggbs->pageData[1];
7546
7547 if ((firstBytesInPage[0] == 0xFF) && (firstBytesInPage[1] & 0xFC) == 0xF8) { /* <-- Does the page begin with a frame's sync code? */
7548 runningGranulePosition = oggbs->currentPageHeader.granulePosition;
7549 }
7550
7551 continue;
7552 }
7553 }
7554 }
7555
7556 /*
7557 We found the page that that is closest to the sample, so now we need to find it. The first thing to do is seek to the
7558 start of that page. In the loop above we checked that it was a fresh page which means this page is also the start of
7559 a new frame. This property means that after we've seeked to the page we can immediately start looping over frames until
7560 we find the one containing the target sample.
7561 */
7562 if (!drflac_oggbs__seek_physical(oggbs, runningFrameBytePos, drflac_seek_origin_start)) {
7563 return DRFLAC_FALSE;
7564 }
7565 if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
7566 return DRFLAC_FALSE;
7567 }
7568
7569 /*
7570 At this point we'll be sitting on the first byte of the frame header of the first frame in the page. We just keep
7571 looping over these frames until we find the one containing the sample we're after.
7572 */
7573 runningPCMFrameCount = runningGranulePosition;
7574 for (;;) {
7575 /*
7576 There are two ways to find the sample and seek past irrelevant frames:
7577 1) Use the native FLAC decoder.
7578 2) Use Ogg's framing system.
7579
7580 Both of these options have their own pros and cons. Using the native FLAC decoder is slower because it needs to
7581 do a full decode of the frame. Using Ogg's framing system is faster, but more complicated and involves some code
7582 duplication for the decoding of frame headers.
7583
7584 Another thing to consider is that using the Ogg framing system will perform direct seeking of the physical Ogg
7585 bitstream. This is important to consider because it means we cannot read data from the drflac_bs object using the
7586 standard drflac__*() APIs because that will read in extra data for its own internal caching which in turn breaks
7587 the positioning of the read pointer of the physical Ogg bitstream. Therefore, anything that would normally be read
7588 using the native FLAC decoding APIs, such as drflac__read_next_flac_frame_header(), need to be re-implemented so as to
7589 avoid the use of the drflac_bs object.
7590
7591 Considering these issues, I have decided to use the slower native FLAC decoding method for the following reasons:
7592 1) Seeking is already partially accelerated using Ogg's paging system in the code block above.
7593 2) Seeking in an Ogg encapsulated FLAC stream is probably quite uncommon.
7594 3) Simplicity.
7595 */
7596 drflac_uint64 firstPCMFrameInFLACFrame = 0;
7597 drflac_uint64 lastPCMFrameInFLACFrame = 0;
7598 drflac_uint64 pcmFrameCountInThisFrame;
7599
7600 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
7601 return DRFLAC_FALSE;
7602 }
7603
7604 drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
7605
7606 pcmFrameCountInThisFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
7607
7608 /* If we are seeking to the end of the file and we've just hit it, we're done. */
7609 if (pcmFrameIndex == pFlac->totalPCMFrameCount && (runningPCMFrameCount + pcmFrameCountInThisFrame) == pFlac->totalPCMFrameCount) {
7610 drflac_result result = drflac__decode_flac_frame(pFlac);
7611 if (result == DRFLAC_SUCCESS) {
7612 pFlac->currentPCMFrame = pcmFrameIndex;
7613 pFlac->currentFLACFrame.pcmFramesRemaining = 0;
7614 return DRFLAC_TRUE;
7615 } else {
7616 return DRFLAC_FALSE;
7617 }
7618 }
7619
7620 if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFrame)) {
7621 /*
7622 The sample should be in this FLAC frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
7623 it never existed and keep iterating.
7624 */
7625 drflac_result result = drflac__decode_flac_frame(pFlac);
7626 if (result == DRFLAC_SUCCESS) {
7627 /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
7628 drflac_uint64 pcmFramesToDecode = (size_t)(pcmFrameIndex - runningPCMFrameCount); /* <-- Safe cast because the maximum number of samples in a frame is 65535. */
7629 if (pcmFramesToDecode == 0) {
7630 return DRFLAC_TRUE;
7631 }
7632
7633 pFlac->currentPCMFrame = runningPCMFrameCount;
7634
7635 return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; /* <-- If this fails, something bad has happened (it should never fail). */
7636 } else {
7637 if (result == DRFLAC_CRC_MISMATCH) {
7638 continue; /* CRC mismatch. Pretend this frame never existed. */
7639 } else {
7640 return DRFLAC_FALSE;
7641 }
7642 }
7643 } else {
7644 /*
7645 It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
7646 frame never existed and leave the running sample count untouched.
7647 */
7648 drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
7649 if (result == DRFLAC_SUCCESS) {
7650 runningPCMFrameCount += pcmFrameCountInThisFrame;
7651 } else {
7652 if (result == DRFLAC_CRC_MISMATCH) {
7653 continue; /* CRC mismatch. Pretend this frame never existed. */
7654 } else {
7655 return DRFLAC_FALSE;
7656 }
7657 }
7658 }
7659 }
7660}
7661
7662
7663
7664static drflac_bool32 drflac__init_private__ogg(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
7665{
7666 drflac_ogg_page_header header;
7667 drflac_uint32 crc32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
7668 drflac_uint32 bytesRead = 0;
7669
7670 /* Pre Condition: The bit stream should be sitting just past the 4-byte OggS capture pattern. */
7671 (void)relaxed;
7672
7673 pInit->container = drflac_container_ogg;
7674 pInit->oggFirstBytePos = 0;
7675
7676 /*
7677 We'll get here if the first 4 bytes of the stream were the OggS capture pattern, however it doesn't necessarily mean the
7678 stream includes FLAC encoded audio. To check for this we need to scan the beginning-of-stream page markers and check if
7679 any match the FLAC specification. Important to keep in mind that the stream may be multiplexed.
7680 */
7681 if (drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
7682 return DRFLAC_FALSE;
7683 }
7684 pInit->runningFilePos += bytesRead;
7685
7686 for (;;) {
7687 int pageBodySize;
7688
7689 /* Break if we're past the beginning of stream page. */
7690 if ((header.headerType & 0x02) == 0) {
7691 return DRFLAC_FALSE;
7692 }
7693
7694 /* Check if it's a FLAC header. */
7695 pageBodySize = drflac_ogg__get_page_body_size(&header);
7696 if (pageBodySize == 51) { /* 51 = the lacing value of the FLAC header packet. */
7697 /* It could be a FLAC page... */
7698 drflac_uint32 bytesRemainingInPage = pageBodySize;
7699 drflac_uint8 packetType;
7700
7701 if (onRead(pUserData, &packetType, 1) != 1) {
7702 return DRFLAC_FALSE;
7703 }
7704
7705 bytesRemainingInPage -= 1;
7706 if (packetType == 0x7F) {
7707 /* Increasingly more likely to be a FLAC page... */
7708 drflac_uint8 sig[4];
7709 if (onRead(pUserData, sig, 4) != 4) {
7710 return DRFLAC_FALSE;
7711 }
7712
7713 bytesRemainingInPage -= 4;
7714 if (sig[0] == 'F' && sig[1] == 'L' && sig[2] == 'A' && sig[3] == 'C') {
7715 /* Almost certainly a FLAC page... */
7716 drflac_uint8 mappingVersion[2];
7717 if (onRead(pUserData, mappingVersion, 2) != 2) {
7718 return DRFLAC_FALSE;
7719 }
7720
7721 if (mappingVersion[0] != 1) {
7722 return DRFLAC_FALSE; /* Only supporting version 1.x of the Ogg mapping. */
7723 }
7724
7725 /*
7726 The next 2 bytes are the non-audio packets, not including this one. We don't care about this because we're going to
7727 be handling it in a generic way based on the serial number and packet types.
7728 */
7729 if (!onSeek(pUserData, 2, drflac_seek_origin_current)) {
7730 return DRFLAC_FALSE;
7731 }
7732
7733 /* Expecting the native FLAC signature "fLaC". */
7734 if (onRead(pUserData, sig, 4) != 4) {
7735 return DRFLAC_FALSE;
7736 }
7737
7738 if (sig[0] == 'f' && sig[1] == 'L' && sig[2] == 'a' && sig[3] == 'C') {
7739 /* The remaining data in the page should be the STREAMINFO block. */
7740 drflac_streaminfo streaminfo;
7741 drflac_uint8 isLastBlock;
7742 drflac_uint8 blockType;
7743 drflac_uint32 blockSize;
7744 if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
7745 return DRFLAC_FALSE;
7746 }
7747
7748 if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
7749 return DRFLAC_FALSE; /* Invalid block type. First block must be the STREAMINFO block. */
7750 }
7751
7752 if (drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
7753 /* Success! */
7754 pInit->hasStreamInfoBlock = DRFLAC_TRUE;
7755 pInit->sampleRate = streaminfo.sampleRate;
7756 pInit->channels = streaminfo.channels;
7757 pInit->bitsPerSample = streaminfo.bitsPerSample;
7758 pInit->totalPCMFrameCount = streaminfo.totalPCMFrameCount;
7759 pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
7760 pInit->hasMetadataBlocks = !isLastBlock;
7761
7762 if (onMeta) {
7763 drflac_metadata metadata;
7764 metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
7765 metadata.pRawData = NULL;
7766 metadata.rawDataSize = 0;
7767 metadata.data.streaminfo = streaminfo;
7768 onMeta(pUserDataMD, &metadata);
7769 }
7770
7771 pInit->runningFilePos += pageBodySize;
7772 pInit->oggFirstBytePos = pInit->runningFilePos - 79; /* Subtracting 79 will place us right on top of the "OggS" identifier of the FLAC bos page. */
7773 pInit->oggSerial = header.serialNumber;
7774 pInit->oggBosHeader = header;
7775 break;
7776 } else {
7777 /* Failed to read STREAMINFO block. Aww, so close... */
7778 return DRFLAC_FALSE;
7779 }
7780 } else {
7781 /* Invalid file. */
7782 return DRFLAC_FALSE;
7783 }
7784 } else {
7785 /* Not a FLAC header. Skip it. */
7786 if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
7787 return DRFLAC_FALSE;
7788 }
7789 }
7790 } else {
7791 /* Not a FLAC header. Seek past the entire page and move on to the next. */
7792 if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
7793 return DRFLAC_FALSE;
7794 }
7795 }
7796 } else {
7797 if (!onSeek(pUserData, pageBodySize, drflac_seek_origin_current)) {
7798 return DRFLAC_FALSE;
7799 }
7800 }
7801
7802 pInit->runningFilePos += pageBodySize;
7803
7804
7805 /* Read the header of the next page. */
7806 if (drflac_ogg__read_page_header(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
7807 return DRFLAC_FALSE;
7808 }
7809 pInit->runningFilePos += bytesRead;
7810 }
7811
7812 /*
7813 If we get here it means we found a FLAC audio stream. We should be sitting on the first byte of the header of the next page. The next
7814 packets in the FLAC logical stream contain the metadata. The only thing left to do in the initialization phase for Ogg is to create the
7815 Ogg bistream object.
7816 */
7817 pInit->hasMetadataBlocks = DRFLAC_TRUE; /* <-- Always have at least VORBIS_COMMENT metadata block. */
7818 return DRFLAC_TRUE;
7819}
7820#endif
7821
7822static drflac_bool32 drflac__init_private(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD)
7823{
7824 drflac_bool32 relaxed;
7825 drflac_uint8 id[4];
7826
7827 if (pInit == NULL || onRead == NULL || onSeek == NULL) {
7828 return DRFLAC_FALSE;
7829 }
7830
7831 DRFLAC_ZERO_MEMORY(pInit, sizeof(*pInit));
7832 pInit->onRead = onRead;
7833 pInit->onSeek = onSeek;
7834 pInit->onMeta = onMeta;
7835 pInit->container = container;
7836 pInit->pUserData = pUserData;
7837 pInit->pUserDataMD = pUserDataMD;
7838
7839 pInit->bs.onRead = onRead;
7840 pInit->bs.onSeek = onSeek;
7841 pInit->bs.pUserData = pUserData;
7842 drflac__reset_cache(&pInit->bs);
7843
7844
7845 /* If the container is explicitly defined then we can try opening in relaxed mode. */
7846 relaxed = container != drflac_container_unknown;
7847
7848 /* Skip over any ID3 tags. */
7849 for (;;) {
7850 if (onRead(pUserData, id, 4) != 4) {
7851 return DRFLAC_FALSE; /* Ran out of data. */
7852 }
7853 pInit->runningFilePos += 4;
7854
7855 if (id[0] == 'I' && id[1] == 'D' && id[2] == '3') {
7856 drflac_uint8 header[6];
7857 drflac_uint8 flags;
7858 drflac_uint32 headerSize;
7859
7860 if (onRead(pUserData, header, 6) != 6) {
7861 return DRFLAC_FALSE; /* Ran out of data. */
7862 }
7863 pInit->runningFilePos += 6;
7864
7865 flags = header[1];
7866
7867 DRFLAC_COPY_MEMORY(&headerSize, header+2, 4);
7868 headerSize = drflac__unsynchsafe_32(drflac__be2host_32(headerSize));
7869 if (flags & 0x10) {
7870 headerSize += 10;
7871 }
7872
7873 if (!onSeek(pUserData, headerSize, drflac_seek_origin_current)) {
7874 return DRFLAC_FALSE; /* Failed to seek past the tag. */
7875 }
7876 pInit->runningFilePos += headerSize;
7877 } else {
7878 break;
7879 }
7880 }
7881
7882 if (id[0] == 'f' && id[1] == 'L' && id[2] == 'a' && id[3] == 'C') {
7883 return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
7884 }
7885#ifndef DR_FLAC_NO_OGG
7886 if (id[0] == 'O' && id[1] == 'g' && id[2] == 'g' && id[3] == 'S') {
7887 return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
7888 }
7889#endif
7890
7891 /* If we get here it means we likely don't have a header. Try opening in relaxed mode, if applicable. */
7892 if (relaxed) {
7893 if (container == drflac_container_native) {
7894 return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
7895 }
7896#ifndef DR_FLAC_NO_OGG
7897 if (container == drflac_container_ogg) {
7898 return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
7899 }
7900#endif
7901 }
7902
7903 /* Unsupported container. */
7904 return DRFLAC_FALSE;
7905}
7906
7907static void drflac__init_from_info(drflac* pFlac, const drflac_init_info* pInit)
7908{
7909 DRFLAC_ASSERT(pFlac != NULL);
7910 DRFLAC_ASSERT(pInit != NULL);
7911
7912 DRFLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac));
7913 pFlac->bs = pInit->bs;
7914 pFlac->onMeta = pInit->onMeta;
7915 pFlac->pUserDataMD = pInit->pUserDataMD;
7916 pFlac->maxBlockSizeInPCMFrames = pInit->maxBlockSizeInPCMFrames;
7917 pFlac->sampleRate = pInit->sampleRate;
7918 pFlac->channels = (drflac_uint8)pInit->channels;
7919 pFlac->bitsPerSample = (drflac_uint8)pInit->bitsPerSample;
7920 pFlac->totalPCMFrameCount = pInit->totalPCMFrameCount;
7921 pFlac->container = pInit->container;
7922}
7923
7924
7925static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD, const drflac_allocation_callbacks* pAllocationCallbacks)
7926{
7927 drflac_init_info init;
7928 drflac_uint32 allocationSize;
7929 drflac_uint32 wholeSIMDVectorCountPerChannel;
7930 drflac_uint32 decodedSamplesAllocationSize;
7931#ifndef DR_FLAC_NO_OGG
7932 drflac_oggbs* pOggbs = NULL;
7933#endif
7934 drflac_uint64 firstFramePos;
7935 drflac_uint64 seektablePos;
7936 drflac_uint32 seekpointCount;
7937 drflac_allocation_callbacks allocationCallbacks;
7938 drflac* pFlac;
7939
7940 /* CPU support first. */
7941 drflac__init_cpu_caps();
7942
7943 if (!drflac__init_private(&init, onRead, onSeek, onMeta, container, pUserData, pUserDataMD)) {
7944 return NULL;
7945 }
7946
7947 if (pAllocationCallbacks != NULL) {
7948 allocationCallbacks = *pAllocationCallbacks;
7949 if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) {
7950 return NULL; /* Invalid allocation callbacks. */
7951 }
7952 } else {
7953 allocationCallbacks.pUserData = NULL;
7954 allocationCallbacks.onMalloc = drflac__malloc_default;
7955 allocationCallbacks.onRealloc = drflac__realloc_default;
7956 allocationCallbacks.onFree = drflac__free_default;
7957 }
7958
7959
7960 /*
7961 The size of the allocation for the drflac object needs to be large enough to fit the following:
7962 1) The main members of the drflac structure
7963 2) A block of memory large enough to store the decoded samples of the largest frame in the stream
7964 3) If the container is Ogg, a drflac_oggbs object
7965
7966 The complicated part of the allocation is making sure there's enough room the decoded samples, taking into consideration
7967 the different SIMD instruction sets.
7968 */
7969 allocationSize = sizeof(drflac);
7970
7971 /*
7972 The allocation size for decoded frames depends on the number of 32-bit integers that fit inside the largest SIMD vector
7973 we are supporting.
7974 */
7975 if ((init.maxBlockSizeInPCMFrames % (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) == 0) {
7976 wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32)));
7977 } else {
7978 wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) + 1;
7979 }
7980
7981 decodedSamplesAllocationSize = wholeSIMDVectorCountPerChannel * DRFLAC_MAX_SIMD_VECTOR_SIZE * init.channels;
7982
7983 allocationSize += decodedSamplesAllocationSize;
7984 allocationSize += DRFLAC_MAX_SIMD_VECTOR_SIZE; /* Allocate extra bytes to ensure we have enough for alignment. */
7985
7986#ifndef DR_FLAC_NO_OGG
7987 /* There's additional data required for Ogg streams. */
7988 if (init.container == drflac_container_ogg) {
7989 allocationSize += sizeof(drflac_oggbs);
7990
7991 pOggbs = (drflac_oggbs*)drflac__malloc_from_callbacks(sizeof(*pOggbs), &allocationCallbacks);
7992 if (pOggbs == NULL) {
7993 return NULL; /*DRFLAC_OUT_OF_MEMORY;*/
7994 }
7995
7996 DRFLAC_ZERO_MEMORY(pOggbs, sizeof(*pOggbs));
7997 pOggbs->onRead = onRead;
7998 pOggbs->onSeek = onSeek;
7999 pOggbs->pUserData = pUserData;
8000 pOggbs->currentBytePos = init.oggFirstBytePos;
8001 pOggbs->firstBytePos = init.oggFirstBytePos;
8002 pOggbs->serialNumber = init.oggSerial;
8003 pOggbs->bosPageHeader = init.oggBosHeader;
8004 pOggbs->bytesRemainingInPage = 0;
8005 }
8006#endif
8007
8008 /*
8009 This part is a bit awkward. We need to load the seektable so that it can be referenced in-memory, but I want the drflac object to
8010 consist of only a single heap allocation. To this, the size of the seek table needs to be known, which we determine when reading
8011 and decoding the metadata.
8012 */
8013 firstFramePos = 42; /* <-- We know we are at byte 42 at this point. */
8014 seektablePos = 0;
8015 seekpointCount = 0;
8016 if (init.hasMetadataBlocks) {
8017 drflac_read_proc onReadOverride = onRead;
8018 drflac_seek_proc onSeekOverride = onSeek;
8019 void* pUserDataOverride = pUserData;
8020
8021#ifndef DR_FLAC_NO_OGG
8022 if (init.container == drflac_container_ogg) {
8023 onReadOverride = drflac__on_read_ogg;
8024 onSeekOverride = drflac__on_seek_ogg;
8025 pUserDataOverride = (void*)pOggbs;
8026 }
8027#endif
8028
8029 if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seekpointCount, &allocationCallbacks)) {
8030 #ifndef DR_FLAC_NO_OGG
8031 drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
8032 #endif
8033 return NULL;
8034 }
8035
8036 allocationSize += seekpointCount * sizeof(drflac_seekpoint);
8037 }
8038
8039
8040 pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
8041 if (pFlac == NULL) {
8042 #ifndef DR_FLAC_NO_OGG
8043 drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
8044 #endif
8045 return NULL;
8046 }
8047
8048 drflac__init_from_info(pFlac, &init);
8049 pFlac->allocationCallbacks = allocationCallbacks;
8050 pFlac->pDecodedSamples = (drflac_int32*)drflac_align((size_t)pFlac->pExtraData, DRFLAC_MAX_SIMD_VECTOR_SIZE);
8051
8052#ifndef DR_FLAC_NO_OGG
8053 if (init.container == drflac_container_ogg) {
8054 drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + (seekpointCount * sizeof(drflac_seekpoint)));
8055 DRFLAC_COPY_MEMORY(pInternalOggbs, pOggbs, sizeof(*pOggbs));
8056
8057 /* At this point the pOggbs object has been handed over to pInternalOggbs and can be freed. */
8058 drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
8059 pOggbs = NULL;
8060
8061 /* The Ogg bistream needs to be layered on top of the original bitstream. */
8062 pFlac->bs.onRead = drflac__on_read_ogg;
8063 pFlac->bs.onSeek = drflac__on_seek_ogg;
8064 pFlac->bs.pUserData = (void*)pInternalOggbs;
8065 pFlac->_oggbs = (void*)pInternalOggbs;
8066 }
8067#endif
8068
8069 pFlac->firstFLACFramePosInBytes = firstFramePos;
8070
8071 /* NOTE: Seektables are not currently compatible with Ogg encapsulation (Ogg has its own accelerated seeking system). I may change this later, so I'm leaving this here for now. */
8072#ifndef DR_FLAC_NO_OGG
8073 if (init.container == drflac_container_ogg)
8074 {
8075 pFlac->pSeekpoints = NULL;
8076 pFlac->seekpointCount = 0;
8077 }
8078 else
8079#endif
8080 {
8081 /* If we have a seektable we need to load it now, making sure we move back to where we were previously. */
8082 if (seektablePos != 0) {
8083 pFlac->seekpointCount = seekpointCount;
8084 pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
8085
8086 DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
8087 DRFLAC_ASSERT(pFlac->bs.onRead != NULL);
8088
8089 /* Seek to the seektable, then just read directly into our seektable buffer. */
8090 if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
8091 drflac_uint32 iSeekpoint;
8092
8093 for (iSeekpoint = 0; iSeekpoint < seekpointCount; iSeekpoint += 1) {
8094 if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints + iSeekpoint, DRFLAC_SEEKPOINT_SIZE_IN_BYTES) == DRFLAC_SEEKPOINT_SIZE_IN_BYTES) {
8095 /* Endian swap. */
8096 pFlac->pSeekpoints[iSeekpoint].firstPCMFrame = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
8097 pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
8098 pFlac->pSeekpoints[iSeekpoint].pcmFrameCount = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
8099 } else {
8100 /* Failed to read the seektable. Pretend we don't have one. */
8101 pFlac->pSeekpoints = NULL;
8102 pFlac->seekpointCount = 0;
8103 break;
8104 }
8105 }
8106
8107 /* We need to seek back to where we were. If this fails it's a critical error. */
8108 if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, drflac_seek_origin_start)) {
8109 drflac__free_from_callbacks(pFlac, &allocationCallbacks);
8110 return NULL;
8111 }
8112 } else {
8113 /* Failed to seek to the seektable. Ominous sign, but for now we can just pretend we don't have one. */
8114 pFlac->pSeekpoints = NULL;
8115 pFlac->seekpointCount = 0;
8116 }
8117 }
8118 }
8119
8120
8121 /*
8122 If we get here, but don't have a STREAMINFO block, it means we've opened the stream in relaxed mode and need to decode
8123 the first frame.
8124 */
8125 if (!init.hasStreamInfoBlock) {
8126 pFlac->currentFLACFrame.header = init.firstFrameHeader;
8127 for (;;) {
8128 drflac_result result = drflac__decode_flac_frame(pFlac);
8129 if (result == DRFLAC_SUCCESS) {
8130 break;
8131 } else {
8132 if (result == DRFLAC_CRC_MISMATCH) {
8133 if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
8134 drflac__free_from_callbacks(pFlac, &allocationCallbacks);
8135 return NULL;
8136 }
8137 continue;
8138 } else {
8139 drflac__free_from_callbacks(pFlac, &allocationCallbacks);
8140 return NULL;
8141 }
8142 }
8143 }
8144 }
8145
8146 return pFlac;
8147}
8148
8149
8150
8151#ifndef DR_FLAC_NO_STDIO
8152#include <stdio.h>
8153#ifndef DR_FLAC_NO_WCHAR
8154#include <wchar.h> /* For wcslen(), wcsrtombs() */
8155#endif
8156
8157/* Errno */
8158/* drflac_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
8159#include <errno.h>
8160static drflac_result drflac_result_from_errno(int e)
8161{
8162 switch (e)
8163 {
8164 case 0: return DRFLAC_SUCCESS;
8165 #ifdef EPERM
8166 case EPERM: return DRFLAC_INVALID_OPERATION;
8167 #endif
8168 #ifdef ENOENT
8169 case ENOENT: return DRFLAC_DOES_NOT_EXIST;
8170 #endif
8171 #ifdef ESRCH
8172 case ESRCH: return DRFLAC_DOES_NOT_EXIST;
8173 #endif
8174 #ifdef EINTR
8175 case EINTR: return DRFLAC_INTERRUPT;
8176 #endif
8177 #ifdef EIO
8178 case EIO: return DRFLAC_IO_ERROR;
8179 #endif
8180 #ifdef ENXIO
8181 case ENXIO: return DRFLAC_DOES_NOT_EXIST;
8182 #endif
8183 #ifdef E2BIG
8184 case E2BIG: return DRFLAC_INVALID_ARGS;
8185 #endif
8186 #ifdef ENOEXEC
8187 case ENOEXEC: return DRFLAC_INVALID_FILE;
8188 #endif
8189 #ifdef EBADF
8190 case EBADF: return DRFLAC_INVALID_FILE;
8191 #endif
8192 #ifdef ECHILD
8193 case ECHILD: return DRFLAC_ERROR;
8194 #endif
8195 #ifdef EAGAIN
8196 case EAGAIN: return DRFLAC_UNAVAILABLE;
8197 #endif
8198 #ifdef ENOMEM
8199 case ENOMEM: return DRFLAC_OUT_OF_MEMORY;
8200 #endif
8201 #ifdef EACCES
8202 case EACCES: return DRFLAC_ACCESS_DENIED;
8203 #endif
8204 #ifdef EFAULT
8205 case EFAULT: return DRFLAC_BAD_ADDRESS;
8206 #endif
8207 #ifdef ENOTBLK
8208 case ENOTBLK: return DRFLAC_ERROR;
8209 #endif
8210 #ifdef EBUSY
8211 case EBUSY: return DRFLAC_BUSY;
8212 #endif
8213 #ifdef EEXIST
8214 case EEXIST: return DRFLAC_ALREADY_EXISTS;
8215 #endif
8216 #ifdef EXDEV
8217 case EXDEV: return DRFLAC_ERROR;
8218 #endif
8219 #ifdef ENODEV
8220 case ENODEV: return DRFLAC_DOES_NOT_EXIST;
8221 #endif
8222 #ifdef ENOTDIR
8223 case ENOTDIR: return DRFLAC_NOT_DIRECTORY;
8224 #endif
8225 #ifdef EISDIR
8226 case EISDIR: return DRFLAC_IS_DIRECTORY;
8227 #endif
8228 #ifdef EINVAL
8229 case EINVAL: return DRFLAC_INVALID_ARGS;
8230 #endif
8231 #ifdef ENFILE
8232 case ENFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
8233 #endif
8234 #ifdef EMFILE
8235 case EMFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
8236 #endif
8237 #ifdef ENOTTY
8238 case ENOTTY: return DRFLAC_INVALID_OPERATION;
8239 #endif
8240 #ifdef ETXTBSY
8241 case ETXTBSY: return DRFLAC_BUSY;
8242 #endif
8243 #ifdef EFBIG
8244 case EFBIG: return DRFLAC_TOO_BIG;
8245 #endif
8246 #ifdef ENOSPC
8247 case ENOSPC: return DRFLAC_NO_SPACE;
8248 #endif
8249 #ifdef ESPIPE
8250 case ESPIPE: return DRFLAC_BAD_SEEK;
8251 #endif
8252 #ifdef EROFS
8253 case EROFS: return DRFLAC_ACCESS_DENIED;
8254 #endif
8255 #ifdef EMLINK
8256 case EMLINK: return DRFLAC_TOO_MANY_LINKS;
8257 #endif
8258 #ifdef EPIPE
8259 case EPIPE: return DRFLAC_BAD_PIPE;
8260 #endif
8261 #ifdef EDOM
8262 case EDOM: return DRFLAC_OUT_OF_RANGE;
8263 #endif
8264 #ifdef ERANGE
8265 case ERANGE: return DRFLAC_OUT_OF_RANGE;
8266 #endif
8267 #ifdef EDEADLK
8268 case EDEADLK: return DRFLAC_DEADLOCK;
8269 #endif
8270 #ifdef ENAMETOOLONG
8271 case ENAMETOOLONG: return DRFLAC_PATH_TOO_LONG;
8272 #endif
8273 #ifdef ENOLCK
8274 case ENOLCK: return DRFLAC_ERROR;
8275 #endif
8276 #ifdef ENOSYS
8277 case ENOSYS: return DRFLAC_NOT_IMPLEMENTED;
8278 #endif
8279 #ifdef ENOTEMPTY
8280 case ENOTEMPTY: return DRFLAC_DIRECTORY_NOT_EMPTY;
8281 #endif
8282 #ifdef ELOOP
8283 case ELOOP: return DRFLAC_TOO_MANY_LINKS;
8284 #endif
8285 #ifdef ENOMSG
8286 case ENOMSG: return DRFLAC_NO_MESSAGE;
8287 #endif
8288 #ifdef EIDRM
8289 case EIDRM: return DRFLAC_ERROR;
8290 #endif
8291 #ifdef ECHRNG
8292 case ECHRNG: return DRFLAC_ERROR;
8293 #endif
8294 #ifdef EL2NSYNC
8295 case EL2NSYNC: return DRFLAC_ERROR;
8296 #endif
8297 #ifdef EL3HLT
8298 case EL3HLT: return DRFLAC_ERROR;
8299 #endif
8300 #ifdef EL3RST
8301 case EL3RST: return DRFLAC_ERROR;
8302 #endif
8303 #ifdef ELNRNG
8304 case ELNRNG: return DRFLAC_OUT_OF_RANGE;
8305 #endif
8306 #ifdef EUNATCH
8307 case EUNATCH: return DRFLAC_ERROR;
8308 #endif
8309 #ifdef ENOCSI
8310 case ENOCSI: return DRFLAC_ERROR;
8311 #endif
8312 #ifdef EL2HLT
8313 case EL2HLT: return DRFLAC_ERROR;
8314 #endif
8315 #ifdef EBADE
8316 case EBADE: return DRFLAC_ERROR;
8317 #endif
8318 #ifdef EBADR
8319 case EBADR: return DRFLAC_ERROR;
8320 #endif
8321 #ifdef EXFULL
8322 case EXFULL: return DRFLAC_ERROR;
8323 #endif
8324 #ifdef ENOANO
8325 case ENOANO: return DRFLAC_ERROR;
8326 #endif
8327 #ifdef EBADRQC
8328 case EBADRQC: return DRFLAC_ERROR;
8329 #endif
8330 #ifdef EBADSLT
8331 case EBADSLT: return DRFLAC_ERROR;
8332 #endif
8333 #ifdef EBFONT
8334 case EBFONT: return DRFLAC_INVALID_FILE;
8335 #endif
8336 #ifdef ENOSTR
8337 case ENOSTR: return DRFLAC_ERROR;
8338 #endif
8339 #ifdef ENODATA
8340 case ENODATA: return DRFLAC_NO_DATA_AVAILABLE;
8341 #endif
8342 #ifdef ETIME
8343 case ETIME: return DRFLAC_TIMEOUT;
8344 #endif
8345 #ifdef ENOSR
8346 case ENOSR: return DRFLAC_NO_DATA_AVAILABLE;
8347 #endif
8348 #ifdef ENONET
8349 case ENONET: return DRFLAC_NO_NETWORK;
8350 #endif
8351 #ifdef ENOPKG
8352 case ENOPKG: return DRFLAC_ERROR;
8353 #endif
8354 #ifdef EREMOTE
8355 case EREMOTE: return DRFLAC_ERROR;
8356 #endif
8357 #ifdef ENOLINK
8358 case ENOLINK: return DRFLAC_ERROR;
8359 #endif
8360 #ifdef EADV
8361 case EADV: return DRFLAC_ERROR;
8362 #endif
8363 #ifdef ESRMNT
8364 case ESRMNT: return DRFLAC_ERROR;
8365 #endif
8366 #ifdef ECOMM
8367 case ECOMM: return DRFLAC_ERROR;
8368 #endif
8369 #ifdef EPROTO
8370 case EPROTO: return DRFLAC_ERROR;
8371 #endif
8372 #ifdef EMULTIHOP
8373 case EMULTIHOP: return DRFLAC_ERROR;
8374 #endif
8375 #ifdef EDOTDOT
8376 case EDOTDOT: return DRFLAC_ERROR;
8377 #endif
8378 #ifdef EBADMSG
8379 case EBADMSG: return DRFLAC_BAD_MESSAGE;
8380 #endif
8381 #ifdef EOVERFLOW
8382 case EOVERFLOW: return DRFLAC_TOO_BIG;
8383 #endif
8384 #ifdef ENOTUNIQ
8385 case ENOTUNIQ: return DRFLAC_NOT_UNIQUE;
8386 #endif
8387 #ifdef EBADFD
8388 case EBADFD: return DRFLAC_ERROR;
8389 #endif
8390 #ifdef EREMCHG
8391 case EREMCHG: return DRFLAC_ERROR;
8392 #endif
8393 #ifdef ELIBACC
8394 case ELIBACC: return DRFLAC_ACCESS_DENIED;
8395 #endif
8396 #ifdef ELIBBAD
8397 case ELIBBAD: return DRFLAC_INVALID_FILE;
8398 #endif
8399 #ifdef ELIBSCN
8400 case ELIBSCN: return DRFLAC_INVALID_FILE;
8401 #endif
8402 #ifdef ELIBMAX
8403 case ELIBMAX: return DRFLAC_ERROR;
8404 #endif
8405 #ifdef ELIBEXEC
8406 case ELIBEXEC: return DRFLAC_ERROR;
8407 #endif
8408 #ifdef EILSEQ
8409 case EILSEQ: return DRFLAC_INVALID_DATA;
8410 #endif
8411 #ifdef ERESTART
8412 case ERESTART: return DRFLAC_ERROR;
8413 #endif
8414 #ifdef ESTRPIPE
8415 case ESTRPIPE: return DRFLAC_ERROR;
8416 #endif
8417 #ifdef EUSERS
8418 case EUSERS: return DRFLAC_ERROR;
8419 #endif
8420 #ifdef ENOTSOCK
8421 case ENOTSOCK: return DRFLAC_NOT_SOCKET;
8422 #endif
8423 #ifdef EDESTADDRREQ
8424 case EDESTADDRREQ: return DRFLAC_NO_ADDRESS;
8425 #endif
8426 #ifdef EMSGSIZE
8427 case EMSGSIZE: return DRFLAC_TOO_BIG;
8428 #endif
8429 #ifdef EPROTOTYPE
8430 case EPROTOTYPE: return DRFLAC_BAD_PROTOCOL;
8431 #endif
8432 #ifdef ENOPROTOOPT
8433 case ENOPROTOOPT: return DRFLAC_PROTOCOL_UNAVAILABLE;
8434 #endif
8435 #ifdef EPROTONOSUPPORT
8436 case EPROTONOSUPPORT: return DRFLAC_PROTOCOL_NOT_SUPPORTED;
8437 #endif
8438 #ifdef ESOCKTNOSUPPORT
8439 case ESOCKTNOSUPPORT: return DRFLAC_SOCKET_NOT_SUPPORTED;
8440 #endif
8441 #ifdef EOPNOTSUPP
8442 case EOPNOTSUPP: return DRFLAC_INVALID_OPERATION;
8443 #endif
8444 #ifdef EPFNOSUPPORT
8445 case EPFNOSUPPORT: return DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED;
8446 #endif
8447 #ifdef EAFNOSUPPORT
8448 case EAFNOSUPPORT: return DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED;
8449 #endif
8450 #ifdef EADDRINUSE
8451 case EADDRINUSE: return DRFLAC_ALREADY_IN_USE;
8452 #endif
8453 #ifdef EADDRNOTAVAIL
8454 case EADDRNOTAVAIL: return DRFLAC_ERROR;
8455 #endif
8456 #ifdef ENETDOWN
8457 case ENETDOWN: return DRFLAC_NO_NETWORK;
8458 #endif
8459 #ifdef ENETUNREACH
8460 case ENETUNREACH: return DRFLAC_NO_NETWORK;
8461 #endif
8462 #ifdef ENETRESET
8463 case ENETRESET: return DRFLAC_NO_NETWORK;
8464 #endif
8465 #ifdef ECONNABORTED
8466 case ECONNABORTED: return DRFLAC_NO_NETWORK;
8467 #endif
8468 #ifdef ECONNRESET
8469 case ECONNRESET: return DRFLAC_CONNECTION_RESET;
8470 #endif
8471 #ifdef ENOBUFS
8472 case ENOBUFS: return DRFLAC_NO_SPACE;
8473 #endif
8474 #ifdef EISCONN
8475 case EISCONN: return DRFLAC_ALREADY_CONNECTED;
8476 #endif
8477 #ifdef ENOTCONN
8478 case ENOTCONN: return DRFLAC_NOT_CONNECTED;
8479 #endif
8480 #ifdef ESHUTDOWN
8481 case ESHUTDOWN: return DRFLAC_ERROR;
8482 #endif
8483 #ifdef ETOOMANYREFS
8484 case ETOOMANYREFS: return DRFLAC_ERROR;
8485 #endif
8486 #ifdef ETIMEDOUT
8487 case ETIMEDOUT: return DRFLAC_TIMEOUT;
8488 #endif
8489 #ifdef ECONNREFUSED
8490 case ECONNREFUSED: return DRFLAC_CONNECTION_REFUSED;
8491 #endif
8492 #ifdef EHOSTDOWN
8493 case EHOSTDOWN: return DRFLAC_NO_HOST;
8494 #endif
8495 #ifdef EHOSTUNREACH
8496 case EHOSTUNREACH: return DRFLAC_NO_HOST;
8497 #endif
8498 #ifdef EALREADY
8499 case EALREADY: return DRFLAC_IN_PROGRESS;
8500 #endif
8501 #ifdef EINPROGRESS
8502 case EINPROGRESS: return DRFLAC_IN_PROGRESS;
8503 #endif
8504 #ifdef ESTALE
8505 case ESTALE: return DRFLAC_INVALID_FILE;
8506 #endif
8507 #ifdef EUCLEAN
8508 case EUCLEAN: return DRFLAC_ERROR;
8509 #endif
8510 #ifdef ENOTNAM
8511 case ENOTNAM: return DRFLAC_ERROR;
8512 #endif
8513 #ifdef ENAVAIL
8514 case ENAVAIL: return DRFLAC_ERROR;
8515 #endif
8516 #ifdef EISNAM
8517 case EISNAM: return DRFLAC_ERROR;
8518 #endif
8519 #ifdef EREMOTEIO
8520 case EREMOTEIO: return DRFLAC_IO_ERROR;
8521 #endif
8522 #ifdef EDQUOT
8523 case EDQUOT: return DRFLAC_NO_SPACE;
8524 #endif
8525 #ifdef ENOMEDIUM
8526 case ENOMEDIUM: return DRFLAC_DOES_NOT_EXIST;
8527 #endif
8528 #ifdef EMEDIUMTYPE
8529 case EMEDIUMTYPE: return DRFLAC_ERROR;
8530 #endif
8531 #ifdef ECANCELED
8532 case ECANCELED: return DRFLAC_CANCELLED;
8533 #endif
8534 #ifdef ENOKEY
8535 case ENOKEY: return DRFLAC_ERROR;
8536 #endif
8537 #ifdef EKEYEXPIRED
8538 case EKEYEXPIRED: return DRFLAC_ERROR;
8539 #endif
8540 #ifdef EKEYREVOKED
8541 case EKEYREVOKED: return DRFLAC_ERROR;
8542 #endif
8543 #ifdef EKEYREJECTED
8544 case EKEYREJECTED: return DRFLAC_ERROR;
8545 #endif
8546 #ifdef EOWNERDEAD
8547 case EOWNERDEAD: return DRFLAC_ERROR;
8548 #endif
8549 #ifdef ENOTRECOVERABLE
8550 case ENOTRECOVERABLE: return DRFLAC_ERROR;
8551 #endif
8552 #ifdef ERFKILL
8553 case ERFKILL: return DRFLAC_ERROR;
8554 #endif
8555 #ifdef EHWPOISON
8556 case EHWPOISON: return DRFLAC_ERROR;
8557 #endif
8558 default: return DRFLAC_ERROR;
8559 }
8560}
8561/* End Errno */
8562
8563/* fopen */
8564static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
8565{
8566#if defined(_MSC_VER) && _MSC_VER >= 1400
8567 errno_t err;
8568#endif
8569
8570 if (ppFile != NULL) {
8571 *ppFile = NULL; /* Safety. */
8572 }
8573
8574 if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
8575 return DRFLAC_INVALID_ARGS;
8576 }
8577
8578#if defined(_MSC_VER) && _MSC_VER >= 1400
8579 err = fopen_s(ppFile, pFilePath, pOpenMode);
8580 if (err != 0) {
8581 return drflac_result_from_errno(err);
8582 }
8583#else
8584#if defined(_WIN32) || defined(__APPLE__)
8585 *ppFile = fopen(pFilePath, pOpenMode);
8586#else
8587 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
8588 *ppFile = fopen64(pFilePath, pOpenMode);
8589 #else
8590 *ppFile = fopen(pFilePath, pOpenMode);
8591 #endif
8592#endif
8593 if (*ppFile == NULL) {
8594 drflac_result result = drflac_result_from_errno(errno);
8595 if (result == DRFLAC_SUCCESS) {
8596 result = DRFLAC_ERROR; /* Just a safety check to make sure we never ever return success when pFile == NULL. */
8597 }
8598
8599 return result;
8600 }
8601#endif
8602
8603 return DRFLAC_SUCCESS;
8604}
8605
8606/*
8607_wfopen() isn't always available in all compilation environments.
8608
8609 * Windows only.
8610 * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
8611 * MinGW-64 (both 32- and 64-bit) seems to support it.
8612 * MinGW wraps it in !defined(__STRICT_ANSI__).
8613 * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
8614
8615This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
8616fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
8617*/
8618#if defined(_WIN32)
8619 #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
8620 #define DRFLAC_HAS_WFOPEN
8621 #endif
8622#endif
8623
8624#ifndef DR_FLAC_NO_WCHAR
8625static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
8626{
8627 if (ppFile != NULL) {
8628 *ppFile = NULL; /* Safety. */
8629 }
8630
8631 if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
8632 return DRFLAC_INVALID_ARGS;
8633 }
8634
8635#if defined(DRFLAC_HAS_WFOPEN)
8636 {
8637 /* Use _wfopen() on Windows. */
8638 #if defined(_MSC_VER) && _MSC_VER >= 1400
8639 errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
8640 if (err != 0) {
8641 return drflac_result_from_errno(err);
8642 }
8643 #else
8644 *ppFile = _wfopen(pFilePath, pOpenMode);
8645 if (*ppFile == NULL) {
8646 return drflac_result_from_errno(errno);
8647 }
8648 #endif
8649 (void)pAllocationCallbacks;
8650 }
8651#else
8652 /*
8653 Use fopen() on anything other than Windows. Requires a conversion. This is annoying because
8654 fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note
8655 that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
8656 maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler
8657 error I'll look into improving compatibility.
8658 */
8659
8660 /*
8661 Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just
8662 need to abort with an error. If you encounter a compiler lacking such support, add it to this list
8663 and submit a bug report and it'll be added to the library upstream.
8664 */
8665 #if defined(__DJGPP__)
8666 {
8667 /* Nothing to do here. This will fall through to the error check below. */
8668 }
8669 #else
8670 {
8671 mbstate_t mbs;
8672 size_t lenMB;
8673 const wchar_t* pFilePathTemp = pFilePath;
8674 char* pFilePathMB = NULL;
8675 char pOpenModeMB[32] = {0};
8676
8677 /* Get the length first. */
8678 DRFLAC_ZERO_OBJECT(&mbs);
8679 lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
8680 if (lenMB == (size_t)-1) {
8681 return drflac_result_from_errno(errno);
8682 }
8683
8684 pFilePathMB = (char*)drflac__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
8685 if (pFilePathMB == NULL) {
8686 return DRFLAC_OUT_OF_MEMORY;
8687 }
8688
8689 pFilePathTemp = pFilePath;
8690 DRFLAC_ZERO_OBJECT(&mbs);
8691 wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
8692
8693 /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
8694 {
8695 size_t i = 0;
8696 for (;;) {
8697 if (pOpenMode[i] == 0) {
8698 pOpenModeMB[i] = '\0';
8699 break;
8700 }
8701
8702 pOpenModeMB[i] = (char)pOpenMode[i];
8703 i += 1;
8704 }
8705 }
8706
8707 *ppFile = fopen(pFilePathMB, pOpenModeMB);
8708
8709 drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
8710 }
8711 #endif
8712
8713 if (*ppFile == NULL) {
8714 return DRFLAC_ERROR;
8715 }
8716#endif
8717
8718 return DRFLAC_SUCCESS;
8719}
8720#endif
8721/* End fopen */
8722
8723static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
8724{
8725 return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData);
8726}
8727
8728static drflac_bool32 drflac__on_seek_stdio(void* pUserData, int offset, drflac_seek_origin origin)
8729{
8730 DRFLAC_ASSERT(offset >= 0); /* <-- Never seek backwards. */
8731
8732 return fseek((FILE*)pUserData, offset, (origin == drflac_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
8733}
8734
8735
8736DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
8737{
8738 drflac* pFlac;
8739 FILE* pFile;
8740
8741 if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
8742 return NULL;
8743 }
8744
8745 pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
8746 if (pFlac == NULL) {
8747 fclose(pFile);
8748 return NULL;
8749 }
8750
8751 return pFlac;
8752}
8753
8754#ifndef DR_FLAC_NO_WCHAR
8755DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
8756{
8757 drflac* pFlac;
8758 FILE* pFile;
8759
8760 if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
8761 return NULL;
8762 }
8763
8764 pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
8765 if (pFlac == NULL) {
8766 fclose(pFile);
8767 return NULL;
8768 }
8769
8770 return pFlac;
8771}
8772#endif
8773
8774DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
8775{
8776 drflac* pFlac;
8777 FILE* pFile;
8778
8779 if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
8780 return NULL;
8781 }
8782
8783 pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
8784 if (pFlac == NULL) {
8785 fclose(pFile);
8786 return pFlac;
8787 }
8788
8789 return pFlac;
8790}
8791
8792#ifndef DR_FLAC_NO_WCHAR
8793DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
8794{
8795 drflac* pFlac;
8796 FILE* pFile;
8797
8798 if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
8799 return NULL;
8800 }
8801
8802 pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
8803 if (pFlac == NULL) {
8804 fclose(pFile);
8805 return pFlac;
8806 }
8807
8808 return pFlac;
8809}
8810#endif
8811#endif /* DR_FLAC_NO_STDIO */
8812
8813static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
8814{
8815 drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
8816 size_t bytesRemaining;
8817
8818 DRFLAC_ASSERT(memoryStream != NULL);
8819 DRFLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos);
8820
8821 bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos;
8822 if (bytesToRead > bytesRemaining) {
8823 bytesToRead = bytesRemaining;
8824 }
8825
8826 if (bytesToRead > 0) {
8827 DRFLAC_COPY_MEMORY(bufferOut, memoryStream->data + memoryStream->currentReadPos, bytesToRead);
8828 memoryStream->currentReadPos += bytesToRead;
8829 }
8830
8831 return bytesToRead;
8832}
8833
8834static drflac_bool32 drflac__on_seek_memory(void* pUserData, int offset, drflac_seek_origin origin)
8835{
8836 drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
8837
8838 DRFLAC_ASSERT(memoryStream != NULL);
8839 DRFLAC_ASSERT(offset >= 0); /* <-- Never seek backwards. */
8840
8841 if (offset > (drflac_int64)memoryStream->dataSize) {
8842 return DRFLAC_FALSE;
8843 }
8844
8845 if (origin == drflac_seek_origin_current) {
8846 if (memoryStream->currentReadPos + offset <= memoryStream->dataSize) {
8847 memoryStream->currentReadPos += offset;
8848 } else {
8849 return DRFLAC_FALSE; /* Trying to seek too far forward. */
8850 }
8851 } else {
8852 if ((drflac_uint32)offset <= memoryStream->dataSize) {
8853 memoryStream->currentReadPos = offset;
8854 } else {
8855 return DRFLAC_FALSE; /* Trying to seek too far forward. */
8856 }
8857 }
8858
8859 return DRFLAC_TRUE;
8860}
8861
8862DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks)
8863{
8864 drflac__memory_stream memoryStream;
8865 drflac* pFlac;
8866
8867 memoryStream.data = (const drflac_uint8*)pData;
8868 memoryStream.dataSize = dataSize;
8869 memoryStream.currentReadPos = 0;
8870 pFlac = drflac_open(drflac__on_read_memory, drflac__on_seek_memory, &memoryStream, pAllocationCallbacks);
8871 if (pFlac == NULL) {
8872 return NULL;
8873 }
8874
8875 pFlac->memoryStream = memoryStream;
8876
8877 /* This is an awful hack... */
8878#ifndef DR_FLAC_NO_OGG
8879 if (pFlac->container == drflac_container_ogg)
8880 {
8881 drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
8882 oggbs->pUserData = &pFlac->memoryStream;
8883 }
8884 else
8885#endif
8886 {
8887 pFlac->bs.pUserData = &pFlac->memoryStream;
8888 }
8889
8890 return pFlac;
8891}
8892
8893DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
8894{
8895 drflac__memory_stream memoryStream;
8896 drflac* pFlac;
8897
8898 memoryStream.data = (const drflac_uint8*)pData;
8899 memoryStream.dataSize = dataSize;
8900 memoryStream.currentReadPos = 0;
8901 pFlac = drflac_open_with_metadata_private(drflac__on_read_memory, drflac__on_seek_memory, onMeta, drflac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks);
8902 if (pFlac == NULL) {
8903 return NULL;
8904 }
8905
8906 pFlac->memoryStream = memoryStream;
8907
8908 /* This is an awful hack... */
8909#ifndef DR_FLAC_NO_OGG
8910 if (pFlac->container == drflac_container_ogg)
8911 {
8912 drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
8913 oggbs->pUserData = &pFlac->memoryStream;
8914 }
8915 else
8916#endif
8917 {
8918 pFlac->bs.pUserData = &pFlac->memoryStream;
8919 }
8920
8921 return pFlac;
8922}
8923
8924
8925
8926DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
8927{
8928 return drflac_open_with_metadata_private(onRead, onSeek, NULL, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
8929}
8930DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
8931{
8932 return drflac_open_with_metadata_private(onRead, onSeek, NULL, container, pUserData, pUserData, pAllocationCallbacks);
8933}
8934
8935DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
8936{
8937 return drflac_open_with_metadata_private(onRead, onSeek, onMeta, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
8938}
8939DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
8940{
8941 return drflac_open_with_metadata_private(onRead, onSeek, onMeta, container, pUserData, pUserData, pAllocationCallbacks);
8942}
8943
8944DRFLAC_API void drflac_close(drflac* pFlac)
8945{
8946 if (pFlac == NULL) {
8947 return;
8948 }
8949
8950#ifndef DR_FLAC_NO_STDIO
8951 /*
8952 If we opened the file with drflac_open_file() we will want to close the file handle. We can know whether or not drflac_open_file()
8953 was used by looking at the callbacks.
8954 */
8955 if (pFlac->bs.onRead == drflac__on_read_stdio) {
8956 fclose((FILE*)pFlac->bs.pUserData);
8957 }
8958
8959#ifndef DR_FLAC_NO_OGG
8960 /* Need to clean up Ogg streams a bit differently due to the way the bit streaming is chained. */
8961 if (pFlac->container == drflac_container_ogg) {
8962 drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
8963 DRFLAC_ASSERT(pFlac->bs.onRead == drflac__on_read_ogg);
8964
8965 if (oggbs->onRead == drflac__on_read_stdio) {
8966 fclose((FILE*)oggbs->pUserData);
8967 }
8968 }
8969#endif
8970#endif
8971
8972 drflac__free_from_callbacks(pFlac, &pFlac->allocationCallbacks);
8973}
8974
8975
8976#if 0
8977static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
8978{
8979 drflac_uint64 i;
8980 for (i = 0; i < frameCount; ++i) {
8981 drflac_uint32 left = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
8982 drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
8983 drflac_uint32 right = left - side;
8984
8985 pOutputSamples[i*2+0] = (drflac_int32)left;
8986 pOutputSamples[i*2+1] = (drflac_int32)right;
8987 }
8988}
8989#endif
8990
8991static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
8992{
8993 drflac_uint64 i;
8994 drflac_uint64 frameCount4 = frameCount >> 2;
8995 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
8996 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
8997 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
8998 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
8999
9000 for (i = 0; i < frameCount4; ++i) {
9001 drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
9002 drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
9003 drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
9004 drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
9005
9006 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
9007 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
9008 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
9009 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
9010
9011 drflac_uint32 right0 = left0 - side0;
9012 drflac_uint32 right1 = left1 - side1;
9013 drflac_uint32 right2 = left2 - side2;
9014 drflac_uint32 right3 = left3 - side3;
9015
9016 pOutputSamples[i*8+0] = (drflac_int32)left0;
9017 pOutputSamples[i*8+1] = (drflac_int32)right0;
9018 pOutputSamples[i*8+2] = (drflac_int32)left1;
9019 pOutputSamples[i*8+3] = (drflac_int32)right1;
9020 pOutputSamples[i*8+4] = (drflac_int32)left2;
9021 pOutputSamples[i*8+5] = (drflac_int32)right2;
9022 pOutputSamples[i*8+6] = (drflac_int32)left3;
9023 pOutputSamples[i*8+7] = (drflac_int32)right3;
9024 }
9025
9026 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9027 drflac_uint32 left = pInputSamples0U32[i] << shift0;
9028 drflac_uint32 side = pInputSamples1U32[i] << shift1;
9029 drflac_uint32 right = left - side;
9030
9031 pOutputSamples[i*2+0] = (drflac_int32)left;
9032 pOutputSamples[i*2+1] = (drflac_int32)right;
9033 }
9034}
9035
9036#if defined(DRFLAC_SUPPORT_SSE2)
9037static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9038{
9039 drflac_uint64 i;
9040 drflac_uint64 frameCount4 = frameCount >> 2;
9041 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9042 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9043 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9044 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9045
9046 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9047
9048 for (i = 0; i < frameCount4; ++i) {
9049 __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
9050 __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
9051 __m128i right = _mm_sub_epi32(left, side);
9052
9053 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
9054 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
9055 }
9056
9057 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9058 drflac_uint32 left = pInputSamples0U32[i] << shift0;
9059 drflac_uint32 side = pInputSamples1U32[i] << shift1;
9060 drflac_uint32 right = left - side;
9061
9062 pOutputSamples[i*2+0] = (drflac_int32)left;
9063 pOutputSamples[i*2+1] = (drflac_int32)right;
9064 }
9065}
9066#endif
9067
9068#if defined(DRFLAC_SUPPORT_NEON)
9069static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9070{
9071 drflac_uint64 i;
9072 drflac_uint64 frameCount4 = frameCount >> 2;
9073 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9074 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9075 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9076 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9077 int32x4_t shift0_4;
9078 int32x4_t shift1_4;
9079
9080 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9081
9082 shift0_4 = vdupq_n_s32(shift0);
9083 shift1_4 = vdupq_n_s32(shift1);
9084
9085 for (i = 0; i < frameCount4; ++i) {
9086 uint32x4_t left;
9087 uint32x4_t side;
9088 uint32x4_t right;
9089
9090 left = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
9091 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
9092 right = vsubq_u32(left, side);
9093
9094 drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
9095 }
9096
9097 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9098 drflac_uint32 left = pInputSamples0U32[i] << shift0;
9099 drflac_uint32 side = pInputSamples1U32[i] << shift1;
9100 drflac_uint32 right = left - side;
9101
9102 pOutputSamples[i*2+0] = (drflac_int32)left;
9103 pOutputSamples[i*2+1] = (drflac_int32)right;
9104 }
9105}
9106#endif
9107
9108static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9109{
9110#if defined(DRFLAC_SUPPORT_SSE2)
9111 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
9112 drflac_read_pcm_frames_s32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9113 } else
9114#elif defined(DRFLAC_SUPPORT_NEON)
9115 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
9116 drflac_read_pcm_frames_s32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9117 } else
9118#endif
9119 {
9120 /* Scalar fallback. */
9121#if 0
9122 drflac_read_pcm_frames_s32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9123#else
9124 drflac_read_pcm_frames_s32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9125#endif
9126 }
9127}
9128
9129
9130#if 0
9131static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9132{
9133 drflac_uint64 i;
9134 for (i = 0; i < frameCount; ++i) {
9135 drflac_uint32 side = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
9136 drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
9137 drflac_uint32 left = right + side;
9138
9139 pOutputSamples[i*2+0] = (drflac_int32)left;
9140 pOutputSamples[i*2+1] = (drflac_int32)right;
9141 }
9142}
9143#endif
9144
9145static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9146{
9147 drflac_uint64 i;
9148 drflac_uint64 frameCount4 = frameCount >> 2;
9149 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9150 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9151 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9152 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9153
9154 for (i = 0; i < frameCount4; ++i) {
9155 drflac_uint32 side0 = pInputSamples0U32[i*4+0] << shift0;
9156 drflac_uint32 side1 = pInputSamples0U32[i*4+1] << shift0;
9157 drflac_uint32 side2 = pInputSamples0U32[i*4+2] << shift0;
9158 drflac_uint32 side3 = pInputSamples0U32[i*4+3] << shift0;
9159
9160 drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
9161 drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
9162 drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
9163 drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
9164
9165 drflac_uint32 left0 = right0 + side0;
9166 drflac_uint32 left1 = right1 + side1;
9167 drflac_uint32 left2 = right2 + side2;
9168 drflac_uint32 left3 = right3 + side3;
9169
9170 pOutputSamples[i*8+0] = (drflac_int32)left0;
9171 pOutputSamples[i*8+1] = (drflac_int32)right0;
9172 pOutputSamples[i*8+2] = (drflac_int32)left1;
9173 pOutputSamples[i*8+3] = (drflac_int32)right1;
9174 pOutputSamples[i*8+4] = (drflac_int32)left2;
9175 pOutputSamples[i*8+5] = (drflac_int32)right2;
9176 pOutputSamples[i*8+6] = (drflac_int32)left3;
9177 pOutputSamples[i*8+7] = (drflac_int32)right3;
9178 }
9179
9180 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9181 drflac_uint32 side = pInputSamples0U32[i] << shift0;
9182 drflac_uint32 right = pInputSamples1U32[i] << shift1;
9183 drflac_uint32 left = right + side;
9184
9185 pOutputSamples[i*2+0] = (drflac_int32)left;
9186 pOutputSamples[i*2+1] = (drflac_int32)right;
9187 }
9188}
9189
9190#if defined(DRFLAC_SUPPORT_SSE2)
9191static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9192{
9193 drflac_uint64 i;
9194 drflac_uint64 frameCount4 = frameCount >> 2;
9195 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9196 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9197 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9198 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9199
9200 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9201
9202 for (i = 0; i < frameCount4; ++i) {
9203 __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
9204 __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
9205 __m128i left = _mm_add_epi32(right, side);
9206
9207 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
9208 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
9209 }
9210
9211 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9212 drflac_uint32 side = pInputSamples0U32[i] << shift0;
9213 drflac_uint32 right = pInputSamples1U32[i] << shift1;
9214 drflac_uint32 left = right + side;
9215
9216 pOutputSamples[i*2+0] = (drflac_int32)left;
9217 pOutputSamples[i*2+1] = (drflac_int32)right;
9218 }
9219}
9220#endif
9221
9222#if defined(DRFLAC_SUPPORT_NEON)
9223static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9224{
9225 drflac_uint64 i;
9226 drflac_uint64 frameCount4 = frameCount >> 2;
9227 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9228 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9229 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9230 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9231 int32x4_t shift0_4;
9232 int32x4_t shift1_4;
9233
9234 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9235
9236 shift0_4 = vdupq_n_s32(shift0);
9237 shift1_4 = vdupq_n_s32(shift1);
9238
9239 for (i = 0; i < frameCount4; ++i) {
9240 uint32x4_t side;
9241 uint32x4_t right;
9242 uint32x4_t left;
9243
9244 side = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
9245 right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
9246 left = vaddq_u32(right, side);
9247
9248 drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
9249 }
9250
9251 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9252 drflac_uint32 side = pInputSamples0U32[i] << shift0;
9253 drflac_uint32 right = pInputSamples1U32[i] << shift1;
9254 drflac_uint32 left = right + side;
9255
9256 pOutputSamples[i*2+0] = (drflac_int32)left;
9257 pOutputSamples[i*2+1] = (drflac_int32)right;
9258 }
9259}
9260#endif
9261
9262static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9263{
9264#if defined(DRFLAC_SUPPORT_SSE2)
9265 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
9266 drflac_read_pcm_frames_s32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9267 } else
9268#elif defined(DRFLAC_SUPPORT_NEON)
9269 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
9270 drflac_read_pcm_frames_s32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9271 } else
9272#endif
9273 {
9274 /* Scalar fallback. */
9275#if 0
9276 drflac_read_pcm_frames_s32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9277#else
9278 drflac_read_pcm_frames_s32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9279#endif
9280 }
9281}
9282
9283
9284#if 0
9285static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9286{
9287 for (drflac_uint64 i = 0; i < frameCount; ++i) {
9288 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9289 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9290
9291 mid = (mid << 1) | (side & 0x01);
9292
9293 pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
9294 pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
9295 }
9296}
9297#endif
9298
9299static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9300{
9301 drflac_uint64 i;
9302 drflac_uint64 frameCount4 = frameCount >> 2;
9303 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9304 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9305 drflac_int32 shift = unusedBitsPerSample;
9306
9307 if (shift > 0) {
9308 shift -= 1;
9309 for (i = 0; i < frameCount4; ++i) {
9310 drflac_uint32 temp0L;
9311 drflac_uint32 temp1L;
9312 drflac_uint32 temp2L;
9313 drflac_uint32 temp3L;
9314 drflac_uint32 temp0R;
9315 drflac_uint32 temp1R;
9316 drflac_uint32 temp2R;
9317 drflac_uint32 temp3R;
9318
9319 drflac_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9320 drflac_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9321 drflac_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9322 drflac_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9323
9324 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9325 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9326 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9327 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9328
9329 mid0 = (mid0 << 1) | (side0 & 0x01);
9330 mid1 = (mid1 << 1) | (side1 & 0x01);
9331 mid2 = (mid2 << 1) | (side2 & 0x01);
9332 mid3 = (mid3 << 1) | (side3 & 0x01);
9333
9334 temp0L = (mid0 + side0) << shift;
9335 temp1L = (mid1 + side1) << shift;
9336 temp2L = (mid2 + side2) << shift;
9337 temp3L = (mid3 + side3) << shift;
9338
9339 temp0R = (mid0 - side0) << shift;
9340 temp1R = (mid1 - side1) << shift;
9341 temp2R = (mid2 - side2) << shift;
9342 temp3R = (mid3 - side3) << shift;
9343
9344 pOutputSamples[i*8+0] = (drflac_int32)temp0L;
9345 pOutputSamples[i*8+1] = (drflac_int32)temp0R;
9346 pOutputSamples[i*8+2] = (drflac_int32)temp1L;
9347 pOutputSamples[i*8+3] = (drflac_int32)temp1R;
9348 pOutputSamples[i*8+4] = (drflac_int32)temp2L;
9349 pOutputSamples[i*8+5] = (drflac_int32)temp2R;
9350 pOutputSamples[i*8+6] = (drflac_int32)temp3L;
9351 pOutputSamples[i*8+7] = (drflac_int32)temp3R;
9352 }
9353 } else {
9354 for (i = 0; i < frameCount4; ++i) {
9355 drflac_uint32 temp0L;
9356 drflac_uint32 temp1L;
9357 drflac_uint32 temp2L;
9358 drflac_uint32 temp3L;
9359 drflac_uint32 temp0R;
9360 drflac_uint32 temp1R;
9361 drflac_uint32 temp2R;
9362 drflac_uint32 temp3R;
9363
9364 drflac_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9365 drflac_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9366 drflac_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9367 drflac_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9368
9369 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9370 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9371 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9372 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9373
9374 mid0 = (mid0 << 1) | (side0 & 0x01);
9375 mid1 = (mid1 << 1) | (side1 & 0x01);
9376 mid2 = (mid2 << 1) | (side2 & 0x01);
9377 mid3 = (mid3 << 1) | (side3 & 0x01);
9378
9379 temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
9380 temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
9381 temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
9382 temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
9383
9384 temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
9385 temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
9386 temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
9387 temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
9388
9389 pOutputSamples[i*8+0] = (drflac_int32)temp0L;
9390 pOutputSamples[i*8+1] = (drflac_int32)temp0R;
9391 pOutputSamples[i*8+2] = (drflac_int32)temp1L;
9392 pOutputSamples[i*8+3] = (drflac_int32)temp1R;
9393 pOutputSamples[i*8+4] = (drflac_int32)temp2L;
9394 pOutputSamples[i*8+5] = (drflac_int32)temp2R;
9395 pOutputSamples[i*8+6] = (drflac_int32)temp3L;
9396 pOutputSamples[i*8+7] = (drflac_int32)temp3R;
9397 }
9398 }
9399
9400 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9401 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9402 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9403
9404 mid = (mid << 1) | (side & 0x01);
9405
9406 pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
9407 pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
9408 }
9409}
9410
9411#if defined(DRFLAC_SUPPORT_SSE2)
9412static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9413{
9414 drflac_uint64 i;
9415 drflac_uint64 frameCount4 = frameCount >> 2;
9416 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9417 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9418 drflac_int32 shift = unusedBitsPerSample;
9419
9420 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9421
9422 if (shift == 0) {
9423 for (i = 0; i < frameCount4; ++i) {
9424 __m128i mid;
9425 __m128i side;
9426 __m128i left;
9427 __m128i right;
9428
9429 mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
9430 side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
9431
9432 mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
9433
9434 left = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
9435 right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
9436
9437 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
9438 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
9439 }
9440
9441 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9442 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9443 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9444
9445 mid = (mid << 1) | (side & 0x01);
9446
9447 pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
9448 pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
9449 }
9450 } else {
9451 shift -= 1;
9452 for (i = 0; i < frameCount4; ++i) {
9453 __m128i mid;
9454 __m128i side;
9455 __m128i left;
9456 __m128i right;
9457
9458 mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
9459 side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
9460
9461 mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
9462
9463 left = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
9464 right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
9465
9466 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
9467 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
9468 }
9469
9470 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9471 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9472 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9473
9474 mid = (mid << 1) | (side & 0x01);
9475
9476 pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
9477 pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
9478 }
9479 }
9480}
9481#endif
9482
9483#if defined(DRFLAC_SUPPORT_NEON)
9484static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9485{
9486 drflac_uint64 i;
9487 drflac_uint64 frameCount4 = frameCount >> 2;
9488 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9489 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9490 drflac_int32 shift = unusedBitsPerSample;
9491 int32x4_t wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
9492 int32x4_t wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
9493 uint32x4_t one4;
9494
9495 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9496
9497 wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
9498 wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
9499 one4 = vdupq_n_u32(1);
9500
9501 if (shift == 0) {
9502 for (i = 0; i < frameCount4; ++i) {
9503 uint32x4_t mid;
9504 uint32x4_t side;
9505 int32x4_t left;
9506 int32x4_t right;
9507
9508 mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
9509 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
9510
9511 mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
9512
9513 left = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
9514 right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
9515
9516 drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
9517 }
9518
9519 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9520 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9521 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9522
9523 mid = (mid << 1) | (side & 0x01);
9524
9525 pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
9526 pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
9527 }
9528 } else {
9529 int32x4_t shift4;
9530
9531 shift -= 1;
9532 shift4 = vdupq_n_s32(shift);
9533
9534 for (i = 0; i < frameCount4; ++i) {
9535 uint32x4_t mid;
9536 uint32x4_t side;
9537 int32x4_t left;
9538 int32x4_t right;
9539
9540 mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
9541 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
9542
9543 mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
9544
9545 left = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
9546 right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
9547
9548 drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
9549 }
9550
9551 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9552 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9553 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9554
9555 mid = (mid << 1) | (side & 0x01);
9556
9557 pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
9558 pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
9559 }
9560 }
9561}
9562#endif
9563
9564static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9565{
9566#if defined(DRFLAC_SUPPORT_SSE2)
9567 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
9568 drflac_read_pcm_frames_s32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9569 } else
9570#elif defined(DRFLAC_SUPPORT_NEON)
9571 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
9572 drflac_read_pcm_frames_s32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9573 } else
9574#endif
9575 {
9576 /* Scalar fallback. */
9577#if 0
9578 drflac_read_pcm_frames_s32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9579#else
9580 drflac_read_pcm_frames_s32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9581#endif
9582 }
9583}
9584
9585
9586#if 0
9587static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9588{
9589 for (drflac_uint64 i = 0; i < frameCount; ++i) {
9590 pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample));
9591 pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample));
9592 }
9593}
9594#endif
9595
9596static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9597{
9598 drflac_uint64 i;
9599 drflac_uint64 frameCount4 = frameCount >> 2;
9600 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9601 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9602 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9603 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9604
9605 for (i = 0; i < frameCount4; ++i) {
9606 drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
9607 drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
9608 drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
9609 drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
9610
9611 drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
9612 drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
9613 drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
9614 drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
9615
9616 pOutputSamples[i*8+0] = (drflac_int32)tempL0;
9617 pOutputSamples[i*8+1] = (drflac_int32)tempR0;
9618 pOutputSamples[i*8+2] = (drflac_int32)tempL1;
9619 pOutputSamples[i*8+3] = (drflac_int32)tempR1;
9620 pOutputSamples[i*8+4] = (drflac_int32)tempL2;
9621 pOutputSamples[i*8+5] = (drflac_int32)tempR2;
9622 pOutputSamples[i*8+6] = (drflac_int32)tempL3;
9623 pOutputSamples[i*8+7] = (drflac_int32)tempR3;
9624 }
9625
9626 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9627 pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
9628 pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
9629 }
9630}
9631
9632#if defined(DRFLAC_SUPPORT_SSE2)
9633static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9634{
9635 drflac_uint64 i;
9636 drflac_uint64 frameCount4 = frameCount >> 2;
9637 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9638 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9639 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9640 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9641
9642 for (i = 0; i < frameCount4; ++i) {
9643 __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
9644 __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
9645
9646 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
9647 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
9648 }
9649
9650 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9651 pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
9652 pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
9653 }
9654}
9655#endif
9656
9657#if defined(DRFLAC_SUPPORT_NEON)
9658static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9659{
9660 drflac_uint64 i;
9661 drflac_uint64 frameCount4 = frameCount >> 2;
9662 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9663 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9664 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9665 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9666
9667 int32x4_t shift4_0 = vdupq_n_s32(shift0);
9668 int32x4_t shift4_1 = vdupq_n_s32(shift1);
9669
9670 for (i = 0; i < frameCount4; ++i) {
9671 int32x4_t left;
9672 int32x4_t right;
9673
9674 left = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift4_0));
9675 right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift4_1));
9676
9677 drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
9678 }
9679
9680 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9681 pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
9682 pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
9683 }
9684}
9685#endif
9686
9687static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
9688{
9689#if defined(DRFLAC_SUPPORT_SSE2)
9690 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
9691 drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9692 } else
9693#elif defined(DRFLAC_SUPPORT_NEON)
9694 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
9695 drflac_read_pcm_frames_s32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9696 } else
9697#endif
9698 {
9699 /* Scalar fallback. */
9700#if 0
9701 drflac_read_pcm_frames_s32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9702#else
9703 drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9704#endif
9705 }
9706}
9707
9708
9709DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut)
9710{
9711 drflac_uint64 framesRead;
9712 drflac_uint32 unusedBitsPerSample;
9713
9714 if (pFlac == NULL || framesToRead == 0) {
9715 return 0;
9716 }
9717
9718 if (pBufferOut == NULL) {
9719 return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
9720 }
9721
9722 DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
9723 unusedBitsPerSample = 32 - pFlac->bitsPerSample;
9724
9725 framesRead = 0;
9726 while (framesToRead > 0) {
9727 /* If we've run out of samples in this frame, go to the next. */
9728 if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
9729 if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
9730 break; /* Couldn't read the next frame, so just break from the loop and return. */
9731 }
9732 } else {
9733 unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
9734 drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
9735 drflac_uint64 frameCountThisIteration = framesToRead;
9736
9737 if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
9738 frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
9739 }
9740
9741 if (channelCount == 2) {
9742 const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
9743 const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
9744
9745 switch (pFlac->currentFLACFrame.header.channelAssignment)
9746 {
9747 case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
9748 {
9749 drflac_read_pcm_frames_s32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
9750 } break;
9751
9752 case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
9753 {
9754 drflac_read_pcm_frames_s32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
9755 } break;
9756
9757 case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
9758 {
9759 drflac_read_pcm_frames_s32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
9760 } break;
9761
9762 case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
9763 default:
9764 {
9765 drflac_read_pcm_frames_s32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
9766 } break;
9767 }
9768 } else {
9769 /* Generic interleaving. */
9770 drflac_uint64 i;
9771 for (i = 0; i < frameCountThisIteration; ++i) {
9772 unsigned int j;
9773 for (j = 0; j < channelCount; ++j) {
9774 pBufferOut[(i*channelCount)+j] = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
9775 }
9776 }
9777 }
9778
9779 framesRead += frameCountThisIteration;
9780 pBufferOut += frameCountThisIteration * channelCount;
9781 framesToRead -= frameCountThisIteration;
9782 pFlac->currentPCMFrame += frameCountThisIteration;
9783 pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
9784 }
9785 }
9786
9787 return framesRead;
9788}
9789
9790
9791#if 0
9792static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
9793{
9794 drflac_uint64 i;
9795 for (i = 0; i < frameCount; ++i) {
9796 drflac_uint32 left = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
9797 drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
9798 drflac_uint32 right = left - side;
9799
9800 left >>= 16;
9801 right >>= 16;
9802
9803 pOutputSamples[i*2+0] = (drflac_int16)left;
9804 pOutputSamples[i*2+1] = (drflac_int16)right;
9805 }
9806}
9807#endif
9808
9809static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
9810{
9811 drflac_uint64 i;
9812 drflac_uint64 frameCount4 = frameCount >> 2;
9813 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9814 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9815 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9816 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9817
9818 for (i = 0; i < frameCount4; ++i) {
9819 drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
9820 drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
9821 drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
9822 drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
9823
9824 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
9825 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
9826 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
9827 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
9828
9829 drflac_uint32 right0 = left0 - side0;
9830 drflac_uint32 right1 = left1 - side1;
9831 drflac_uint32 right2 = left2 - side2;
9832 drflac_uint32 right3 = left3 - side3;
9833
9834 left0 >>= 16;
9835 left1 >>= 16;
9836 left2 >>= 16;
9837 left3 >>= 16;
9838
9839 right0 >>= 16;
9840 right1 >>= 16;
9841 right2 >>= 16;
9842 right3 >>= 16;
9843
9844 pOutputSamples[i*8+0] = (drflac_int16)left0;
9845 pOutputSamples[i*8+1] = (drflac_int16)right0;
9846 pOutputSamples[i*8+2] = (drflac_int16)left1;
9847 pOutputSamples[i*8+3] = (drflac_int16)right1;
9848 pOutputSamples[i*8+4] = (drflac_int16)left2;
9849 pOutputSamples[i*8+5] = (drflac_int16)right2;
9850 pOutputSamples[i*8+6] = (drflac_int16)left3;
9851 pOutputSamples[i*8+7] = (drflac_int16)right3;
9852 }
9853
9854 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9855 drflac_uint32 left = pInputSamples0U32[i] << shift0;
9856 drflac_uint32 side = pInputSamples1U32[i] << shift1;
9857 drflac_uint32 right = left - side;
9858
9859 left >>= 16;
9860 right >>= 16;
9861
9862 pOutputSamples[i*2+0] = (drflac_int16)left;
9863 pOutputSamples[i*2+1] = (drflac_int16)right;
9864 }
9865}
9866
9867#if defined(DRFLAC_SUPPORT_SSE2)
9868static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
9869{
9870 drflac_uint64 i;
9871 drflac_uint64 frameCount4 = frameCount >> 2;
9872 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9873 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9874 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9875 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9876
9877 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9878
9879 for (i = 0; i < frameCount4; ++i) {
9880 __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
9881 __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
9882 __m128i right = _mm_sub_epi32(left, side);
9883
9884 left = _mm_srai_epi32(left, 16);
9885 right = _mm_srai_epi32(right, 16);
9886
9887 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
9888 }
9889
9890 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9891 drflac_uint32 left = pInputSamples0U32[i] << shift0;
9892 drflac_uint32 side = pInputSamples1U32[i] << shift1;
9893 drflac_uint32 right = left - side;
9894
9895 left >>= 16;
9896 right >>= 16;
9897
9898 pOutputSamples[i*2+0] = (drflac_int16)left;
9899 pOutputSamples[i*2+1] = (drflac_int16)right;
9900 }
9901}
9902#endif
9903
9904#if defined(DRFLAC_SUPPORT_NEON)
9905static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
9906{
9907 drflac_uint64 i;
9908 drflac_uint64 frameCount4 = frameCount >> 2;
9909 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9910 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9911 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9912 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9913 int32x4_t shift0_4;
9914 int32x4_t shift1_4;
9915
9916 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
9917
9918 shift0_4 = vdupq_n_s32(shift0);
9919 shift1_4 = vdupq_n_s32(shift1);
9920
9921 for (i = 0; i < frameCount4; ++i) {
9922 uint32x4_t left;
9923 uint32x4_t side;
9924 uint32x4_t right;
9925
9926 left = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
9927 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
9928 right = vsubq_u32(left, side);
9929
9930 left = vshrq_n_u32(left, 16);
9931 right = vshrq_n_u32(right, 16);
9932
9933 drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
9934 }
9935
9936 for (i = (frameCount4 << 2); i < frameCount; ++i) {
9937 drflac_uint32 left = pInputSamples0U32[i] << shift0;
9938 drflac_uint32 side = pInputSamples1U32[i] << shift1;
9939 drflac_uint32 right = left - side;
9940
9941 left >>= 16;
9942 right >>= 16;
9943
9944 pOutputSamples[i*2+0] = (drflac_int16)left;
9945 pOutputSamples[i*2+1] = (drflac_int16)right;
9946 }
9947}
9948#endif
9949
9950static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
9951{
9952#if defined(DRFLAC_SUPPORT_SSE2)
9953 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
9954 drflac_read_pcm_frames_s16__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9955 } else
9956#elif defined(DRFLAC_SUPPORT_NEON)
9957 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
9958 drflac_read_pcm_frames_s16__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9959 } else
9960#endif
9961 {
9962 /* Scalar fallback. */
9963#if 0
9964 drflac_read_pcm_frames_s16__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9965#else
9966 drflac_read_pcm_frames_s16__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
9967#endif
9968 }
9969}
9970
9971
9972#if 0
9973static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
9974{
9975 drflac_uint64 i;
9976 for (i = 0; i < frameCount; ++i) {
9977 drflac_uint32 side = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
9978 drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
9979 drflac_uint32 left = right + side;
9980
9981 left >>= 16;
9982 right >>= 16;
9983
9984 pOutputSamples[i*2+0] = (drflac_int16)left;
9985 pOutputSamples[i*2+1] = (drflac_int16)right;
9986 }
9987}
9988#endif
9989
9990static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
9991{
9992 drflac_uint64 i;
9993 drflac_uint64 frameCount4 = frameCount >> 2;
9994 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
9995 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
9996 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
9997 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
9998
9999 for (i = 0; i < frameCount4; ++i) {
10000 drflac_uint32 side0 = pInputSamples0U32[i*4+0] << shift0;
10001 drflac_uint32 side1 = pInputSamples0U32[i*4+1] << shift0;
10002 drflac_uint32 side2 = pInputSamples0U32[i*4+2] << shift0;
10003 drflac_uint32 side3 = pInputSamples0U32[i*4+3] << shift0;
10004
10005 drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
10006 drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
10007 drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
10008 drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
10009
10010 drflac_uint32 left0 = right0 + side0;
10011 drflac_uint32 left1 = right1 + side1;
10012 drflac_uint32 left2 = right2 + side2;
10013 drflac_uint32 left3 = right3 + side3;
10014
10015 left0 >>= 16;
10016 left1 >>= 16;
10017 left2 >>= 16;
10018 left3 >>= 16;
10019
10020 right0 >>= 16;
10021 right1 >>= 16;
10022 right2 >>= 16;
10023 right3 >>= 16;
10024
10025 pOutputSamples[i*8+0] = (drflac_int16)left0;
10026 pOutputSamples[i*8+1] = (drflac_int16)right0;
10027 pOutputSamples[i*8+2] = (drflac_int16)left1;
10028 pOutputSamples[i*8+3] = (drflac_int16)right1;
10029 pOutputSamples[i*8+4] = (drflac_int16)left2;
10030 pOutputSamples[i*8+5] = (drflac_int16)right2;
10031 pOutputSamples[i*8+6] = (drflac_int16)left3;
10032 pOutputSamples[i*8+7] = (drflac_int16)right3;
10033 }
10034
10035 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10036 drflac_uint32 side = pInputSamples0U32[i] << shift0;
10037 drflac_uint32 right = pInputSamples1U32[i] << shift1;
10038 drflac_uint32 left = right + side;
10039
10040 left >>= 16;
10041 right >>= 16;
10042
10043 pOutputSamples[i*2+0] = (drflac_int16)left;
10044 pOutputSamples[i*2+1] = (drflac_int16)right;
10045 }
10046}
10047
10048#if defined(DRFLAC_SUPPORT_SSE2)
10049static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10050{
10051 drflac_uint64 i;
10052 drflac_uint64 frameCount4 = frameCount >> 2;
10053 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10054 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10055 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10056 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10057
10058 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10059
10060 for (i = 0; i < frameCount4; ++i) {
10061 __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
10062 __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
10063 __m128i left = _mm_add_epi32(right, side);
10064
10065 left = _mm_srai_epi32(left, 16);
10066 right = _mm_srai_epi32(right, 16);
10067
10068 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
10069 }
10070
10071 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10072 drflac_uint32 side = pInputSamples0U32[i] << shift0;
10073 drflac_uint32 right = pInputSamples1U32[i] << shift1;
10074 drflac_uint32 left = right + side;
10075
10076 left >>= 16;
10077 right >>= 16;
10078
10079 pOutputSamples[i*2+0] = (drflac_int16)left;
10080 pOutputSamples[i*2+1] = (drflac_int16)right;
10081 }
10082}
10083#endif
10084
10085#if defined(DRFLAC_SUPPORT_NEON)
10086static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10087{
10088 drflac_uint64 i;
10089 drflac_uint64 frameCount4 = frameCount >> 2;
10090 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10091 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10092 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10093 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10094 int32x4_t shift0_4;
10095 int32x4_t shift1_4;
10096
10097 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10098
10099 shift0_4 = vdupq_n_s32(shift0);
10100 shift1_4 = vdupq_n_s32(shift1);
10101
10102 for (i = 0; i < frameCount4; ++i) {
10103 uint32x4_t side;
10104 uint32x4_t right;
10105 uint32x4_t left;
10106
10107 side = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
10108 right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
10109 left = vaddq_u32(right, side);
10110
10111 left = vshrq_n_u32(left, 16);
10112 right = vshrq_n_u32(right, 16);
10113
10114 drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
10115 }
10116
10117 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10118 drflac_uint32 side = pInputSamples0U32[i] << shift0;
10119 drflac_uint32 right = pInputSamples1U32[i] << shift1;
10120 drflac_uint32 left = right + side;
10121
10122 left >>= 16;
10123 right >>= 16;
10124
10125 pOutputSamples[i*2+0] = (drflac_int16)left;
10126 pOutputSamples[i*2+1] = (drflac_int16)right;
10127 }
10128}
10129#endif
10130
10131static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10132{
10133#if defined(DRFLAC_SUPPORT_SSE2)
10134 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
10135 drflac_read_pcm_frames_s16__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10136 } else
10137#elif defined(DRFLAC_SUPPORT_NEON)
10138 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
10139 drflac_read_pcm_frames_s16__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10140 } else
10141#endif
10142 {
10143 /* Scalar fallback. */
10144#if 0
10145 drflac_read_pcm_frames_s16__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10146#else
10147 drflac_read_pcm_frames_s16__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10148#endif
10149 }
10150}
10151
10152
10153#if 0
10154static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10155{
10156 for (drflac_uint64 i = 0; i < frameCount; ++i) {
10157 drflac_uint32 mid = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10158 drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10159
10160 mid = (mid << 1) | (side & 0x01);
10161
10162 pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
10163 pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
10164 }
10165}
10166#endif
10167
10168static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10169{
10170 drflac_uint64 i;
10171 drflac_uint64 frameCount4 = frameCount >> 2;
10172 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10173 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10174 drflac_uint32 shift = unusedBitsPerSample;
10175
10176 if (shift > 0) {
10177 shift -= 1;
10178 for (i = 0; i < frameCount4; ++i) {
10179 drflac_uint32 temp0L;
10180 drflac_uint32 temp1L;
10181 drflac_uint32 temp2L;
10182 drflac_uint32 temp3L;
10183 drflac_uint32 temp0R;
10184 drflac_uint32 temp1R;
10185 drflac_uint32 temp2R;
10186 drflac_uint32 temp3R;
10187
10188 drflac_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10189 drflac_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10190 drflac_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10191 drflac_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10192
10193 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10194 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10195 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10196 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10197
10198 mid0 = (mid0 << 1) | (side0 & 0x01);
10199 mid1 = (mid1 << 1) | (side1 & 0x01);
10200 mid2 = (mid2 << 1) | (side2 & 0x01);
10201 mid3 = (mid3 << 1) | (side3 & 0x01);
10202
10203 temp0L = (mid0 + side0) << shift;
10204 temp1L = (mid1 + side1) << shift;
10205 temp2L = (mid2 + side2) << shift;
10206 temp3L = (mid3 + side3) << shift;
10207
10208 temp0R = (mid0 - side0) << shift;
10209 temp1R = (mid1 - side1) << shift;
10210 temp2R = (mid2 - side2) << shift;
10211 temp3R = (mid3 - side3) << shift;
10212
10213 temp0L >>= 16;
10214 temp1L >>= 16;
10215 temp2L >>= 16;
10216 temp3L >>= 16;
10217
10218 temp0R >>= 16;
10219 temp1R >>= 16;
10220 temp2R >>= 16;
10221 temp3R >>= 16;
10222
10223 pOutputSamples[i*8+0] = (drflac_int16)temp0L;
10224 pOutputSamples[i*8+1] = (drflac_int16)temp0R;
10225 pOutputSamples[i*8+2] = (drflac_int16)temp1L;
10226 pOutputSamples[i*8+3] = (drflac_int16)temp1R;
10227 pOutputSamples[i*8+4] = (drflac_int16)temp2L;
10228 pOutputSamples[i*8+5] = (drflac_int16)temp2R;
10229 pOutputSamples[i*8+6] = (drflac_int16)temp3L;
10230 pOutputSamples[i*8+7] = (drflac_int16)temp3R;
10231 }
10232 } else {
10233 for (i = 0; i < frameCount4; ++i) {
10234 drflac_uint32 temp0L;
10235 drflac_uint32 temp1L;
10236 drflac_uint32 temp2L;
10237 drflac_uint32 temp3L;
10238 drflac_uint32 temp0R;
10239 drflac_uint32 temp1R;
10240 drflac_uint32 temp2R;
10241 drflac_uint32 temp3R;
10242
10243 drflac_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10244 drflac_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10245 drflac_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10246 drflac_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10247
10248 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10249 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10250 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10251 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10252
10253 mid0 = (mid0 << 1) | (side0 & 0x01);
10254 mid1 = (mid1 << 1) | (side1 & 0x01);
10255 mid2 = (mid2 << 1) | (side2 & 0x01);
10256 mid3 = (mid3 << 1) | (side3 & 0x01);
10257
10258 temp0L = ((drflac_int32)(mid0 + side0) >> 1);
10259 temp1L = ((drflac_int32)(mid1 + side1) >> 1);
10260 temp2L = ((drflac_int32)(mid2 + side2) >> 1);
10261 temp3L = ((drflac_int32)(mid3 + side3) >> 1);
10262
10263 temp0R = ((drflac_int32)(mid0 - side0) >> 1);
10264 temp1R = ((drflac_int32)(mid1 - side1) >> 1);
10265 temp2R = ((drflac_int32)(mid2 - side2) >> 1);
10266 temp3R = ((drflac_int32)(mid3 - side3) >> 1);
10267
10268 temp0L >>= 16;
10269 temp1L >>= 16;
10270 temp2L >>= 16;
10271 temp3L >>= 16;
10272
10273 temp0R >>= 16;
10274 temp1R >>= 16;
10275 temp2R >>= 16;
10276 temp3R >>= 16;
10277
10278 pOutputSamples[i*8+0] = (drflac_int16)temp0L;
10279 pOutputSamples[i*8+1] = (drflac_int16)temp0R;
10280 pOutputSamples[i*8+2] = (drflac_int16)temp1L;
10281 pOutputSamples[i*8+3] = (drflac_int16)temp1R;
10282 pOutputSamples[i*8+4] = (drflac_int16)temp2L;
10283 pOutputSamples[i*8+5] = (drflac_int16)temp2R;
10284 pOutputSamples[i*8+6] = (drflac_int16)temp3L;
10285 pOutputSamples[i*8+7] = (drflac_int16)temp3R;
10286 }
10287 }
10288
10289 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10290 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10291 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10292
10293 mid = (mid << 1) | (side & 0x01);
10294
10295 pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
10296 pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
10297 }
10298}
10299
10300#if defined(DRFLAC_SUPPORT_SSE2)
10301static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10302{
10303 drflac_uint64 i;
10304 drflac_uint64 frameCount4 = frameCount >> 2;
10305 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10306 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10307 drflac_uint32 shift = unusedBitsPerSample;
10308
10309 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10310
10311 if (shift == 0) {
10312 for (i = 0; i < frameCount4; ++i) {
10313 __m128i mid;
10314 __m128i side;
10315 __m128i left;
10316 __m128i right;
10317
10318 mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
10319 side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
10320
10321 mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
10322
10323 left = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
10324 right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
10325
10326 left = _mm_srai_epi32(left, 16);
10327 right = _mm_srai_epi32(right, 16);
10328
10329 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
10330 }
10331
10332 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10333 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10334 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10335
10336 mid = (mid << 1) | (side & 0x01);
10337
10338 pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
10339 pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
10340 }
10341 } else {
10342 shift -= 1;
10343 for (i = 0; i < frameCount4; ++i) {
10344 __m128i mid;
10345 __m128i side;
10346 __m128i left;
10347 __m128i right;
10348
10349 mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
10350 side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
10351
10352 mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
10353
10354 left = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
10355 right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
10356
10357 left = _mm_srai_epi32(left, 16);
10358 right = _mm_srai_epi32(right, 16);
10359
10360 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
10361 }
10362
10363 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10364 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10365 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10366
10367 mid = (mid << 1) | (side & 0x01);
10368
10369 pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
10370 pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
10371 }
10372 }
10373}
10374#endif
10375
10376#if defined(DRFLAC_SUPPORT_NEON)
10377static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10378{
10379 drflac_uint64 i;
10380 drflac_uint64 frameCount4 = frameCount >> 2;
10381 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10382 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10383 drflac_uint32 shift = unusedBitsPerSample;
10384 int32x4_t wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
10385 int32x4_t wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
10386
10387 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10388
10389 wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
10390 wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
10391
10392 if (shift == 0) {
10393 for (i = 0; i < frameCount4; ++i) {
10394 uint32x4_t mid;
10395 uint32x4_t side;
10396 int32x4_t left;
10397 int32x4_t right;
10398
10399 mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
10400 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
10401
10402 mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
10403
10404 left = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
10405 right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
10406
10407 left = vshrq_n_s32(left, 16);
10408 right = vshrq_n_s32(right, 16);
10409
10410 drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
10411 }
10412
10413 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10414 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10415 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10416
10417 mid = (mid << 1) | (side & 0x01);
10418
10419 pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
10420 pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
10421 }
10422 } else {
10423 int32x4_t shift4;
10424
10425 shift -= 1;
10426 shift4 = vdupq_n_s32(shift);
10427
10428 for (i = 0; i < frameCount4; ++i) {
10429 uint32x4_t mid;
10430 uint32x4_t side;
10431 int32x4_t left;
10432 int32x4_t right;
10433
10434 mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
10435 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
10436
10437 mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
10438
10439 left = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
10440 right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
10441
10442 left = vshrq_n_s32(left, 16);
10443 right = vshrq_n_s32(right, 16);
10444
10445 drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
10446 }
10447
10448 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10449 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10450 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10451
10452 mid = (mid << 1) | (side & 0x01);
10453
10454 pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
10455 pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
10456 }
10457 }
10458}
10459#endif
10460
10461static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10462{
10463#if defined(DRFLAC_SUPPORT_SSE2)
10464 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
10465 drflac_read_pcm_frames_s16__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10466 } else
10467#elif defined(DRFLAC_SUPPORT_NEON)
10468 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
10469 drflac_read_pcm_frames_s16__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10470 } else
10471#endif
10472 {
10473 /* Scalar fallback. */
10474#if 0
10475 drflac_read_pcm_frames_s16__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10476#else
10477 drflac_read_pcm_frames_s16__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10478#endif
10479 }
10480}
10481
10482
10483#if 0
10484static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10485{
10486 for (drflac_uint64 i = 0; i < frameCount; ++i) {
10487 pOutputSamples[i*2+0] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) >> 16);
10488 pOutputSamples[i*2+1] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) >> 16);
10489 }
10490}
10491#endif
10492
10493static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10494{
10495 drflac_uint64 i;
10496 drflac_uint64 frameCount4 = frameCount >> 2;
10497 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10498 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10499 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10500 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10501
10502 for (i = 0; i < frameCount4; ++i) {
10503 drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
10504 drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
10505 drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
10506 drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
10507
10508 drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
10509 drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
10510 drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
10511 drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
10512
10513 tempL0 >>= 16;
10514 tempL1 >>= 16;
10515 tempL2 >>= 16;
10516 tempL3 >>= 16;
10517
10518 tempR0 >>= 16;
10519 tempR1 >>= 16;
10520 tempR2 >>= 16;
10521 tempR3 >>= 16;
10522
10523 pOutputSamples[i*8+0] = (drflac_int16)tempL0;
10524 pOutputSamples[i*8+1] = (drflac_int16)tempR0;
10525 pOutputSamples[i*8+2] = (drflac_int16)tempL1;
10526 pOutputSamples[i*8+3] = (drflac_int16)tempR1;
10527 pOutputSamples[i*8+4] = (drflac_int16)tempL2;
10528 pOutputSamples[i*8+5] = (drflac_int16)tempR2;
10529 pOutputSamples[i*8+6] = (drflac_int16)tempL3;
10530 pOutputSamples[i*8+7] = (drflac_int16)tempR3;
10531 }
10532
10533 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10534 pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
10535 pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
10536 }
10537}
10538
10539#if defined(DRFLAC_SUPPORT_SSE2)
10540static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10541{
10542 drflac_uint64 i;
10543 drflac_uint64 frameCount4 = frameCount >> 2;
10544 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10545 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10546 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10547 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10548
10549 for (i = 0; i < frameCount4; ++i) {
10550 __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
10551 __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
10552
10553 left = _mm_srai_epi32(left, 16);
10554 right = _mm_srai_epi32(right, 16);
10555
10556 /* At this point we have results. We can now pack and interleave these into a single __m128i object and then store the in the output buffer. */
10557 _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
10558 }
10559
10560 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10561 pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
10562 pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
10563 }
10564}
10565#endif
10566
10567#if defined(DRFLAC_SUPPORT_NEON)
10568static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10569{
10570 drflac_uint64 i;
10571 drflac_uint64 frameCount4 = frameCount >> 2;
10572 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10573 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10574 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10575 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10576
10577 int32x4_t shift0_4 = vdupq_n_s32(shift0);
10578 int32x4_t shift1_4 = vdupq_n_s32(shift1);
10579
10580 for (i = 0; i < frameCount4; ++i) {
10581 int32x4_t left;
10582 int32x4_t right;
10583
10584 left = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
10585 right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
10586
10587 left = vshrq_n_s32(left, 16);
10588 right = vshrq_n_s32(right, 16);
10589
10590 drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
10591 }
10592
10593 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10594 pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
10595 pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
10596 }
10597}
10598#endif
10599
10600static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
10601{
10602#if defined(DRFLAC_SUPPORT_SSE2)
10603 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
10604 drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10605 } else
10606#elif defined(DRFLAC_SUPPORT_NEON)
10607 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
10608 drflac_read_pcm_frames_s16__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10609 } else
10610#endif
10611 {
10612 /* Scalar fallback. */
10613#if 0
10614 drflac_read_pcm_frames_s16__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10615#else
10616 drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10617#endif
10618 }
10619}
10620
10621DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut)
10622{
10623 drflac_uint64 framesRead;
10624 drflac_uint32 unusedBitsPerSample;
10625
10626 if (pFlac == NULL || framesToRead == 0) {
10627 return 0;
10628 }
10629
10630 if (pBufferOut == NULL) {
10631 return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
10632 }
10633
10634 DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
10635 unusedBitsPerSample = 32 - pFlac->bitsPerSample;
10636
10637 framesRead = 0;
10638 while (framesToRead > 0) {
10639 /* If we've run out of samples in this frame, go to the next. */
10640 if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
10641 if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
10642 break; /* Couldn't read the next frame, so just break from the loop and return. */
10643 }
10644 } else {
10645 unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
10646 drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
10647 drflac_uint64 frameCountThisIteration = framesToRead;
10648
10649 if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
10650 frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
10651 }
10652
10653 if (channelCount == 2) {
10654 const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
10655 const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
10656
10657 switch (pFlac->currentFLACFrame.header.channelAssignment)
10658 {
10659 case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
10660 {
10661 drflac_read_pcm_frames_s16__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
10662 } break;
10663
10664 case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
10665 {
10666 drflac_read_pcm_frames_s16__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
10667 } break;
10668
10669 case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
10670 {
10671 drflac_read_pcm_frames_s16__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
10672 } break;
10673
10674 case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
10675 default:
10676 {
10677 drflac_read_pcm_frames_s16__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
10678 } break;
10679 }
10680 } else {
10681 /* Generic interleaving. */
10682 drflac_uint64 i;
10683 for (i = 0; i < frameCountThisIteration; ++i) {
10684 unsigned int j;
10685 for (j = 0; j < channelCount; ++j) {
10686 drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
10687 pBufferOut[(i*channelCount)+j] = (drflac_int16)(sampleS32 >> 16);
10688 }
10689 }
10690 }
10691
10692 framesRead += frameCountThisIteration;
10693 pBufferOut += frameCountThisIteration * channelCount;
10694 framesToRead -= frameCountThisIteration;
10695 pFlac->currentPCMFrame += frameCountThisIteration;
10696 pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
10697 }
10698 }
10699
10700 return framesRead;
10701}
10702
10703
10704#if 0
10705static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10706{
10707 drflac_uint64 i;
10708 for (i = 0; i < frameCount; ++i) {
10709 drflac_uint32 left = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
10710 drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
10711 drflac_uint32 right = left - side;
10712
10713 pOutputSamples[i*2+0] = (float)((drflac_int32)left / 2147483648.0);
10714 pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
10715 }
10716}
10717#endif
10718
10719static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10720{
10721 drflac_uint64 i;
10722 drflac_uint64 frameCount4 = frameCount >> 2;
10723 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10724 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10725 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10726 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10727
10728 float factor = 1 / 2147483648.0;
10729
10730 for (i = 0; i < frameCount4; ++i) {
10731 drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
10732 drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
10733 drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
10734 drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
10735
10736 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
10737 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
10738 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
10739 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
10740
10741 drflac_uint32 right0 = left0 - side0;
10742 drflac_uint32 right1 = left1 - side1;
10743 drflac_uint32 right2 = left2 - side2;
10744 drflac_uint32 right3 = left3 - side3;
10745
10746 pOutputSamples[i*8+0] = (drflac_int32)left0 * factor;
10747 pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
10748 pOutputSamples[i*8+2] = (drflac_int32)left1 * factor;
10749 pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
10750 pOutputSamples[i*8+4] = (drflac_int32)left2 * factor;
10751 pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
10752 pOutputSamples[i*8+6] = (drflac_int32)left3 * factor;
10753 pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
10754 }
10755
10756 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10757 drflac_uint32 left = pInputSamples0U32[i] << shift0;
10758 drflac_uint32 side = pInputSamples1U32[i] << shift1;
10759 drflac_uint32 right = left - side;
10760
10761 pOutputSamples[i*2+0] = (drflac_int32)left * factor;
10762 pOutputSamples[i*2+1] = (drflac_int32)right * factor;
10763 }
10764}
10765
10766#if defined(DRFLAC_SUPPORT_SSE2)
10767static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10768{
10769 drflac_uint64 i;
10770 drflac_uint64 frameCount4 = frameCount >> 2;
10771 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10772 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10773 drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
10774 drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
10775 __m128 factor;
10776
10777 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10778
10779 factor = _mm_set1_ps(1.0f / 8388608.0f);
10780
10781 for (i = 0; i < frameCount4; ++i) {
10782 __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
10783 __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
10784 __m128i right = _mm_sub_epi32(left, side);
10785 __m128 leftf = _mm_mul_ps(_mm_cvtepi32_ps(left), factor);
10786 __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
10787
10788 _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
10789 _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
10790 }
10791
10792 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10793 drflac_uint32 left = pInputSamples0U32[i] << shift0;
10794 drflac_uint32 side = pInputSamples1U32[i] << shift1;
10795 drflac_uint32 right = left - side;
10796
10797 pOutputSamples[i*2+0] = (drflac_int32)left / 8388608.0f;
10798 pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
10799 }
10800}
10801#endif
10802
10803#if defined(DRFLAC_SUPPORT_NEON)
10804static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10805{
10806 drflac_uint64 i;
10807 drflac_uint64 frameCount4 = frameCount >> 2;
10808 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10809 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10810 drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
10811 drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
10812 float32x4_t factor4;
10813 int32x4_t shift0_4;
10814 int32x4_t shift1_4;
10815
10816 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10817
10818 factor4 = vdupq_n_f32(1.0f / 8388608.0f);
10819 shift0_4 = vdupq_n_s32(shift0);
10820 shift1_4 = vdupq_n_s32(shift1);
10821
10822 for (i = 0; i < frameCount4; ++i) {
10823 uint32x4_t left;
10824 uint32x4_t side;
10825 uint32x4_t right;
10826 float32x4_t leftf;
10827 float32x4_t rightf;
10828
10829 left = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
10830 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
10831 right = vsubq_u32(left, side);
10832 leftf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)), factor4);
10833 rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
10834
10835 drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
10836 }
10837
10838 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10839 drflac_uint32 left = pInputSamples0U32[i] << shift0;
10840 drflac_uint32 side = pInputSamples1U32[i] << shift1;
10841 drflac_uint32 right = left - side;
10842
10843 pOutputSamples[i*2+0] = (drflac_int32)left / 8388608.0f;
10844 pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
10845 }
10846}
10847#endif
10848
10849static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10850{
10851#if defined(DRFLAC_SUPPORT_SSE2)
10852 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
10853 drflac_read_pcm_frames_f32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10854 } else
10855#elif defined(DRFLAC_SUPPORT_NEON)
10856 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
10857 drflac_read_pcm_frames_f32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10858 } else
10859#endif
10860 {
10861 /* Scalar fallback. */
10862#if 0
10863 drflac_read_pcm_frames_f32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10864#else
10865 drflac_read_pcm_frames_f32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
10866#endif
10867 }
10868}
10869
10870
10871#if 0
10872static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10873{
10874 drflac_uint64 i;
10875 for (i = 0; i < frameCount; ++i) {
10876 drflac_uint32 side = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
10877 drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
10878 drflac_uint32 left = right + side;
10879
10880 pOutputSamples[i*2+0] = (float)((drflac_int32)left / 2147483648.0);
10881 pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
10882 }
10883}
10884#endif
10885
10886static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10887{
10888 drflac_uint64 i;
10889 drflac_uint64 frameCount4 = frameCount >> 2;
10890 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10891 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10892 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
10893 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
10894 float factor = 1 / 2147483648.0;
10895
10896 for (i = 0; i < frameCount4; ++i) {
10897 drflac_uint32 side0 = pInputSamples0U32[i*4+0] << shift0;
10898 drflac_uint32 side1 = pInputSamples0U32[i*4+1] << shift0;
10899 drflac_uint32 side2 = pInputSamples0U32[i*4+2] << shift0;
10900 drflac_uint32 side3 = pInputSamples0U32[i*4+3] << shift0;
10901
10902 drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
10903 drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
10904 drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
10905 drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
10906
10907 drflac_uint32 left0 = right0 + side0;
10908 drflac_uint32 left1 = right1 + side1;
10909 drflac_uint32 left2 = right2 + side2;
10910 drflac_uint32 left3 = right3 + side3;
10911
10912 pOutputSamples[i*8+0] = (drflac_int32)left0 * factor;
10913 pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
10914 pOutputSamples[i*8+2] = (drflac_int32)left1 * factor;
10915 pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
10916 pOutputSamples[i*8+4] = (drflac_int32)left2 * factor;
10917 pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
10918 pOutputSamples[i*8+6] = (drflac_int32)left3 * factor;
10919 pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
10920 }
10921
10922 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10923 drflac_uint32 side = pInputSamples0U32[i] << shift0;
10924 drflac_uint32 right = pInputSamples1U32[i] << shift1;
10925 drflac_uint32 left = right + side;
10926
10927 pOutputSamples[i*2+0] = (drflac_int32)left * factor;
10928 pOutputSamples[i*2+1] = (drflac_int32)right * factor;
10929 }
10930}
10931
10932#if defined(DRFLAC_SUPPORT_SSE2)
10933static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10934{
10935 drflac_uint64 i;
10936 drflac_uint64 frameCount4 = frameCount >> 2;
10937 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10938 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10939 drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
10940 drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
10941 __m128 factor;
10942
10943 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10944
10945 factor = _mm_set1_ps(1.0f / 8388608.0f);
10946
10947 for (i = 0; i < frameCount4; ++i) {
10948 __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
10949 __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
10950 __m128i left = _mm_add_epi32(right, side);
10951 __m128 leftf = _mm_mul_ps(_mm_cvtepi32_ps(left), factor);
10952 __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
10953
10954 _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
10955 _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
10956 }
10957
10958 for (i = (frameCount4 << 2); i < frameCount; ++i) {
10959 drflac_uint32 side = pInputSamples0U32[i] << shift0;
10960 drflac_uint32 right = pInputSamples1U32[i] << shift1;
10961 drflac_uint32 left = right + side;
10962
10963 pOutputSamples[i*2+0] = (drflac_int32)left / 8388608.0f;
10964 pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
10965 }
10966}
10967#endif
10968
10969#if defined(DRFLAC_SUPPORT_NEON)
10970static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
10971{
10972 drflac_uint64 i;
10973 drflac_uint64 frameCount4 = frameCount >> 2;
10974 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
10975 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
10976 drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
10977 drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
10978 float32x4_t factor4;
10979 int32x4_t shift0_4;
10980 int32x4_t shift1_4;
10981
10982 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
10983
10984 factor4 = vdupq_n_f32(1.0f / 8388608.0f);
10985 shift0_4 = vdupq_n_s32(shift0);
10986 shift1_4 = vdupq_n_s32(shift1);
10987
10988 for (i = 0; i < frameCount4; ++i) {
10989 uint32x4_t side;
10990 uint32x4_t right;
10991 uint32x4_t left;
10992 float32x4_t leftf;
10993 float32x4_t rightf;
10994
10995 side = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
10996 right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
10997 left = vaddq_u32(right, side);
10998 leftf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)), factor4);
10999 rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
11000
11001 drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
11002 }
11003
11004 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11005 drflac_uint32 side = pInputSamples0U32[i] << shift0;
11006 drflac_uint32 right = pInputSamples1U32[i] << shift1;
11007 drflac_uint32 left = right + side;
11008
11009 pOutputSamples[i*2+0] = (drflac_int32)left / 8388608.0f;
11010 pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
11011 }
11012}
11013#endif
11014
11015static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11016{
11017#if defined(DRFLAC_SUPPORT_SSE2)
11018 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
11019 drflac_read_pcm_frames_f32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11020 } else
11021#elif defined(DRFLAC_SUPPORT_NEON)
11022 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
11023 drflac_read_pcm_frames_f32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11024 } else
11025#endif
11026 {
11027 /* Scalar fallback. */
11028#if 0
11029 drflac_read_pcm_frames_f32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11030#else
11031 drflac_read_pcm_frames_f32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11032#endif
11033 }
11034}
11035
11036
11037#if 0
11038static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11039{
11040 for (drflac_uint64 i = 0; i < frameCount; ++i) {
11041 drflac_uint32 mid = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11042 drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11043
11044 mid = (mid << 1) | (side & 0x01);
11045
11046 pOutputSamples[i*2+0] = (float)((((drflac_int32)(mid + side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
11047 pOutputSamples[i*2+1] = (float)((((drflac_int32)(mid - side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
11048 }
11049}
11050#endif
11051
11052static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11053{
11054 drflac_uint64 i;
11055 drflac_uint64 frameCount4 = frameCount >> 2;
11056 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
11057 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
11058 drflac_uint32 shift = unusedBitsPerSample;
11059 float factor = 1 / 2147483648.0;
11060
11061 if (shift > 0) {
11062 shift -= 1;
11063 for (i = 0; i < frameCount4; ++i) {
11064 drflac_uint32 temp0L;
11065 drflac_uint32 temp1L;
11066 drflac_uint32 temp2L;
11067 drflac_uint32 temp3L;
11068 drflac_uint32 temp0R;
11069 drflac_uint32 temp1R;
11070 drflac_uint32 temp2R;
11071 drflac_uint32 temp3R;
11072
11073 drflac_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11074 drflac_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11075 drflac_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11076 drflac_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11077
11078 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11079 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11080 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11081 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11082
11083 mid0 = (mid0 << 1) | (side0 & 0x01);
11084 mid1 = (mid1 << 1) | (side1 & 0x01);
11085 mid2 = (mid2 << 1) | (side2 & 0x01);
11086 mid3 = (mid3 << 1) | (side3 & 0x01);
11087
11088 temp0L = (mid0 + side0) << shift;
11089 temp1L = (mid1 + side1) << shift;
11090 temp2L = (mid2 + side2) << shift;
11091 temp3L = (mid3 + side3) << shift;
11092
11093 temp0R = (mid0 - side0) << shift;
11094 temp1R = (mid1 - side1) << shift;
11095 temp2R = (mid2 - side2) << shift;
11096 temp3R = (mid3 - side3) << shift;
11097
11098 pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
11099 pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
11100 pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
11101 pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
11102 pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
11103 pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
11104 pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
11105 pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
11106 }
11107 } else {
11108 for (i = 0; i < frameCount4; ++i) {
11109 drflac_uint32 temp0L;
11110 drflac_uint32 temp1L;
11111 drflac_uint32 temp2L;
11112 drflac_uint32 temp3L;
11113 drflac_uint32 temp0R;
11114 drflac_uint32 temp1R;
11115 drflac_uint32 temp2R;
11116 drflac_uint32 temp3R;
11117
11118 drflac_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11119 drflac_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11120 drflac_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11121 drflac_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11122
11123 drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11124 drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11125 drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11126 drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11127
11128 mid0 = (mid0 << 1) | (side0 & 0x01);
11129 mid1 = (mid1 << 1) | (side1 & 0x01);
11130 mid2 = (mid2 << 1) | (side2 & 0x01);
11131 mid3 = (mid3 << 1) | (side3 & 0x01);
11132
11133 temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
11134 temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
11135 temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
11136 temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
11137
11138 temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
11139 temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
11140 temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
11141 temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
11142
11143 pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
11144 pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
11145 pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
11146 pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
11147 pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
11148 pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
11149 pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
11150 pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
11151 }
11152 }
11153
11154 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11155 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11156 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11157
11158 mid = (mid << 1) | (side & 0x01);
11159
11160 pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) * factor;
11161 pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) * factor;
11162 }
11163}
11164
11165#if defined(DRFLAC_SUPPORT_SSE2)
11166static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11167{
11168 drflac_uint64 i;
11169 drflac_uint64 frameCount4 = frameCount >> 2;
11170 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
11171 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
11172 drflac_uint32 shift = unusedBitsPerSample - 8;
11173 float factor;
11174 __m128 factor128;
11175
11176 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
11177
11178 factor = 1.0f / 8388608.0f;
11179 factor128 = _mm_set1_ps(factor);
11180
11181 if (shift == 0) {
11182 for (i = 0; i < frameCount4; ++i) {
11183 __m128i mid;
11184 __m128i side;
11185 __m128i tempL;
11186 __m128i tempR;
11187 __m128 leftf;
11188 __m128 rightf;
11189
11190 mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
11191 side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
11192
11193 mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
11194
11195 tempL = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
11196 tempR = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
11197
11198 leftf = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
11199 rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
11200
11201 _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
11202 _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
11203 }
11204
11205 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11206 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11207 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11208
11209 mid = (mid << 1) | (side & 0x01);
11210
11211 pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
11212 pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
11213 }
11214 } else {
11215 shift -= 1;
11216 for (i = 0; i < frameCount4; ++i) {
11217 __m128i mid;
11218 __m128i side;
11219 __m128i tempL;
11220 __m128i tempR;
11221 __m128 leftf;
11222 __m128 rightf;
11223
11224 mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
11225 side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
11226
11227 mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
11228
11229 tempL = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
11230 tempR = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
11231
11232 leftf = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
11233 rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
11234
11235 _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
11236 _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
11237 }
11238
11239 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11240 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11241 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11242
11243 mid = (mid << 1) | (side & 0x01);
11244
11245 pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
11246 pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
11247 }
11248 }
11249}
11250#endif
11251
11252#if defined(DRFLAC_SUPPORT_NEON)
11253static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11254{
11255 drflac_uint64 i;
11256 drflac_uint64 frameCount4 = frameCount >> 2;
11257 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
11258 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
11259 drflac_uint32 shift = unusedBitsPerSample - 8;
11260 float factor;
11261 float32x4_t factor4;
11262 int32x4_t shift4;
11263 int32x4_t wbps0_4; /* Wasted Bits Per Sample */
11264 int32x4_t wbps1_4; /* Wasted Bits Per Sample */
11265
11266 DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
11267
11268 factor = 1.0f / 8388608.0f;
11269 factor4 = vdupq_n_f32(factor);
11270 wbps0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
11271 wbps1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
11272
11273 if (shift == 0) {
11274 for (i = 0; i < frameCount4; ++i) {
11275 int32x4_t lefti;
11276 int32x4_t righti;
11277 float32x4_t leftf;
11278 float32x4_t rightf;
11279
11280 uint32x4_t mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
11281 uint32x4_t side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
11282
11283 mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
11284
11285 lefti = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
11286 righti = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
11287
11288 leftf = vmulq_f32(vcvtq_f32_s32(lefti), factor4);
11289 rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
11290
11291 drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
11292 }
11293
11294 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11295 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11296 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11297
11298 mid = (mid << 1) | (side & 0x01);
11299
11300 pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
11301 pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
11302 }
11303 } else {
11304 shift -= 1;
11305 shift4 = vdupq_n_s32(shift);
11306 for (i = 0; i < frameCount4; ++i) {
11307 uint32x4_t mid;
11308 uint32x4_t side;
11309 int32x4_t lefti;
11310 int32x4_t righti;
11311 float32x4_t leftf;
11312 float32x4_t rightf;
11313
11314 mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
11315 side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
11316
11317 mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
11318
11319 lefti = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
11320 righti = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
11321
11322 leftf = vmulq_f32(vcvtq_f32_s32(lefti), factor4);
11323 rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
11324
11325 drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
11326 }
11327
11328 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11329 drflac_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11330 drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11331
11332 mid = (mid << 1) | (side & 0x01);
11333
11334 pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
11335 pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
11336 }
11337 }
11338}
11339#endif
11340
11341static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11342{
11343#if defined(DRFLAC_SUPPORT_SSE2)
11344 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
11345 drflac_read_pcm_frames_f32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11346 } else
11347#elif defined(DRFLAC_SUPPORT_NEON)
11348 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
11349 drflac_read_pcm_frames_f32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11350 } else
11351#endif
11352 {
11353 /* Scalar fallback. */
11354#if 0
11355 drflac_read_pcm_frames_f32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11356#else
11357 drflac_read_pcm_frames_f32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11358#endif
11359 }
11360}
11361
11362#if 0
11363static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11364{
11365 for (drflac_uint64 i = 0; i < frameCount; ++i) {
11366 pOutputSamples[i*2+0] = (float)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) / 2147483648.0);
11367 pOutputSamples[i*2+1] = (float)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) / 2147483648.0);
11368 }
11369}
11370#endif
11371
11372static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11373{
11374 drflac_uint64 i;
11375 drflac_uint64 frameCount4 = frameCount >> 2;
11376 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
11377 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
11378 drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
11379 drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
11380 float factor = 1 / 2147483648.0;
11381
11382 for (i = 0; i < frameCount4; ++i) {
11383 drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
11384 drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
11385 drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
11386 drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
11387
11388 drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
11389 drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
11390 drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
11391 drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
11392
11393 pOutputSamples[i*8+0] = (drflac_int32)tempL0 * factor;
11394 pOutputSamples[i*8+1] = (drflac_int32)tempR0 * factor;
11395 pOutputSamples[i*8+2] = (drflac_int32)tempL1 * factor;
11396 pOutputSamples[i*8+3] = (drflac_int32)tempR1 * factor;
11397 pOutputSamples[i*8+4] = (drflac_int32)tempL2 * factor;
11398 pOutputSamples[i*8+5] = (drflac_int32)tempR2 * factor;
11399 pOutputSamples[i*8+6] = (drflac_int32)tempL3 * factor;
11400 pOutputSamples[i*8+7] = (drflac_int32)tempR3 * factor;
11401 }
11402
11403 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11404 pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
11405 pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
11406 }
11407}
11408
11409#if defined(DRFLAC_SUPPORT_SSE2)
11410static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11411{
11412 drflac_uint64 i;
11413 drflac_uint64 frameCount4 = frameCount >> 2;
11414 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
11415 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
11416 drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
11417 drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
11418
11419 float factor = 1.0f / 8388608.0f;
11420 __m128 factor128 = _mm_set1_ps(factor);
11421
11422 for (i = 0; i < frameCount4; ++i) {
11423 __m128i lefti;
11424 __m128i righti;
11425 __m128 leftf;
11426 __m128 rightf;
11427
11428 lefti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
11429 righti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
11430
11431 leftf = _mm_mul_ps(_mm_cvtepi32_ps(lefti), factor128);
11432 rightf = _mm_mul_ps(_mm_cvtepi32_ps(righti), factor128);
11433
11434 _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
11435 _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
11436 }
11437
11438 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11439 pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
11440 pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
11441 }
11442}
11443#endif
11444
11445#if defined(DRFLAC_SUPPORT_NEON)
11446static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11447{
11448 drflac_uint64 i;
11449 drflac_uint64 frameCount4 = frameCount >> 2;
11450 const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
11451 const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
11452 drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
11453 drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
11454
11455 float factor = 1.0f / 8388608.0f;
11456 float32x4_t factor4 = vdupq_n_f32(factor);
11457 int32x4_t shift0_4 = vdupq_n_s32(shift0);
11458 int32x4_t shift1_4 = vdupq_n_s32(shift1);
11459
11460 for (i = 0; i < frameCount4; ++i) {
11461 int32x4_t lefti;
11462 int32x4_t righti;
11463 float32x4_t leftf;
11464 float32x4_t rightf;
11465
11466 lefti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
11467 righti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
11468
11469 leftf = vmulq_f32(vcvtq_f32_s32(lefti), factor4);
11470 rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
11471
11472 drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
11473 }
11474
11475 for (i = (frameCount4 << 2); i < frameCount; ++i) {
11476 pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
11477 pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
11478 }
11479}
11480#endif
11481
11482static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
11483{
11484#if defined(DRFLAC_SUPPORT_SSE2)
11485 if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
11486 drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11487 } else
11488#elif defined(DRFLAC_SUPPORT_NEON)
11489 if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
11490 drflac_read_pcm_frames_f32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11491 } else
11492#endif
11493 {
11494 /* Scalar fallback. */
11495#if 0
11496 drflac_read_pcm_frames_f32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11497#else
11498 drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
11499#endif
11500 }
11501}
11502
11503DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut)
11504{
11505 drflac_uint64 framesRead;
11506 drflac_uint32 unusedBitsPerSample;
11507
11508 if (pFlac == NULL || framesToRead == 0) {
11509 return 0;
11510 }
11511
11512 if (pBufferOut == NULL) {
11513 return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
11514 }
11515
11516 DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
11517 unusedBitsPerSample = 32 - pFlac->bitsPerSample;
11518
11519 framesRead = 0;
11520 while (framesToRead > 0) {
11521 /* If we've run out of samples in this frame, go to the next. */
11522 if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
11523 if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
11524 break; /* Couldn't read the next frame, so just break from the loop and return. */
11525 }
11526 } else {
11527 unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
11528 drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
11529 drflac_uint64 frameCountThisIteration = framesToRead;
11530
11531 if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
11532 frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
11533 }
11534
11535 if (channelCount == 2) {
11536 const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
11537 const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
11538
11539 switch (pFlac->currentFLACFrame.header.channelAssignment)
11540 {
11541 case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
11542 {
11543 drflac_read_pcm_frames_f32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
11544 } break;
11545
11546 case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
11547 {
11548 drflac_read_pcm_frames_f32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
11549 } break;
11550
11551 case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
11552 {
11553 drflac_read_pcm_frames_f32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
11554 } break;
11555
11556 case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
11557 default:
11558 {
11559 drflac_read_pcm_frames_f32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
11560 } break;
11561 }
11562 } else {
11563 /* Generic interleaving. */
11564 drflac_uint64 i;
11565 for (i = 0; i < frameCountThisIteration; ++i) {
11566 unsigned int j;
11567 for (j = 0; j < channelCount; ++j) {
11568 drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
11569 pBufferOut[(i*channelCount)+j] = (float)(sampleS32 / 2147483648.0);
11570 }
11571 }
11572 }
11573
11574 framesRead += frameCountThisIteration;
11575 pBufferOut += frameCountThisIteration * channelCount;
11576 framesToRead -= frameCountThisIteration;
11577 pFlac->currentPCMFrame += frameCountThisIteration;
11578 pFlac->currentFLACFrame.pcmFramesRemaining -= (unsigned int)frameCountThisIteration;
11579 }
11580 }
11581
11582 return framesRead;
11583}
11584
11585
11586DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
11587{
11588 if (pFlac == NULL) {
11589 return DRFLAC_FALSE;
11590 }
11591
11592 /* Don't do anything if we're already on the seek point. */
11593 if (pFlac->currentPCMFrame == pcmFrameIndex) {
11594 return DRFLAC_TRUE;
11595 }
11596
11597 /*
11598 If we don't know where the first frame begins then we can't seek. This will happen when the STREAMINFO block was not present
11599 when the decoder was opened.
11600 */
11601 if (pFlac->firstFLACFramePosInBytes == 0) {
11602 return DRFLAC_FALSE;
11603 }
11604
11605 if (pcmFrameIndex == 0) {
11606 pFlac->currentPCMFrame = 0;
11607 return drflac__seek_to_first_frame(pFlac);
11608 } else {
11609 drflac_bool32 wasSuccessful = DRFLAC_FALSE;
11610 drflac_uint64 originalPCMFrame = pFlac->currentPCMFrame;
11611
11612 /* Clamp the sample to the end. */
11613 if (pcmFrameIndex > pFlac->totalPCMFrameCount) {
11614 pcmFrameIndex = pFlac->totalPCMFrameCount;
11615 }
11616
11617 /* If the target sample and the current sample are in the same frame we just move the position forward. */
11618 if (pcmFrameIndex > pFlac->currentPCMFrame) {
11619 /* Forward. */
11620 drflac_uint32 offset = (drflac_uint32)(pcmFrameIndex - pFlac->currentPCMFrame);
11621 if (pFlac->currentFLACFrame.pcmFramesRemaining > offset) {
11622 pFlac->currentFLACFrame.pcmFramesRemaining -= offset;
11623 pFlac->currentPCMFrame = pcmFrameIndex;
11624 return DRFLAC_TRUE;
11625 }
11626 } else {
11627 /* Backward. */
11628 drflac_uint32 offsetAbs = (drflac_uint32)(pFlac->currentPCMFrame - pcmFrameIndex);
11629 drflac_uint32 currentFLACFramePCMFrameCount = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
11630 drflac_uint32 currentFLACFramePCMFramesConsumed = currentFLACFramePCMFrameCount - pFlac->currentFLACFrame.pcmFramesRemaining;
11631 if (currentFLACFramePCMFramesConsumed > offsetAbs) {
11632 pFlac->currentFLACFrame.pcmFramesRemaining += offsetAbs;
11633 pFlac->currentPCMFrame = pcmFrameIndex;
11634 return DRFLAC_TRUE;
11635 }
11636 }
11637
11638 /*
11639 Different techniques depending on encapsulation. Using the native FLAC seektable with Ogg encapsulation is a bit awkward so
11640 we'll instead use Ogg's natural seeking facility.
11641 */
11642#ifndef DR_FLAC_NO_OGG
11643 if (pFlac->container == drflac_container_ogg)
11644 {
11645 wasSuccessful = drflac_ogg__seek_to_pcm_frame(pFlac, pcmFrameIndex);
11646 }
11647 else
11648#endif
11649 {
11650 /* First try seeking via the seek table. If this fails, fall back to a brute force seek which is much slower. */
11651 if (/*!wasSuccessful && */!pFlac->_noSeekTableSeek) {
11652 wasSuccessful = drflac__seek_to_pcm_frame__seek_table(pFlac, pcmFrameIndex);
11653 }
11654
11655#if !defined(DR_FLAC_NO_CRC)
11656 /* Fall back to binary search if seek table seeking fails. This requires the length of the stream to be known. */
11657 if (!wasSuccessful && !pFlac->_noBinarySearchSeek && pFlac->totalPCMFrameCount > 0) {
11658 wasSuccessful = drflac__seek_to_pcm_frame__binary_search(pFlac, pcmFrameIndex);
11659 }
11660#endif
11661
11662 /* Fall back to brute force if all else fails. */
11663 if (!wasSuccessful && !pFlac->_noBruteForceSeek) {
11664 wasSuccessful = drflac__seek_to_pcm_frame__brute_force(pFlac, pcmFrameIndex);
11665 }
11666 }
11667
11668 if (wasSuccessful) {
11669 pFlac->currentPCMFrame = pcmFrameIndex;
11670 } else {
11671 /* Seek failed. Try putting the decoder back to it's original state. */
11672 if (drflac_seek_to_pcm_frame(pFlac, originalPCMFrame) == DRFLAC_FALSE) {
11673 /* Failed to seek back to the original PCM frame. Fall back to 0. */
11674 drflac_seek_to_pcm_frame(pFlac, 0);
11675 }
11676 }
11677
11678 return wasSuccessful;
11679 }
11680}
11681
11682
11683
11684/* High Level APIs */
11685
11686/* SIZE_MAX */
11687#if defined(SIZE_MAX)
11688 #define DRFLAC_SIZE_MAX SIZE_MAX
11689#else
11690 #if defined(DRFLAC_64BIT)
11691 #define DRFLAC_SIZE_MAX ((drflac_uint64)0xFFFFFFFFFFFFFFFF)
11692 #else
11693 #define DRFLAC_SIZE_MAX 0xFFFFFFFF
11694 #endif
11695#endif
11696/* End SIZE_MAX */
11697
11698
11699/* Using a macro as the definition of the drflac__full_decode_and_close_*() API family. Sue me. */
11700#define DRFLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \
11701static type* drflac__full_read_and_close_ ## extension (drflac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut)\
11702{ \
11703 type* pSampleData = NULL; \
11704 drflac_uint64 totalPCMFrameCount; \
11705 \
11706 DRFLAC_ASSERT(pFlac != NULL); \
11707 \
11708 totalPCMFrameCount = pFlac->totalPCMFrameCount; \
11709 \
11710 if (totalPCMFrameCount == 0) { \
11711 type buffer[4096]; \
11712 drflac_uint64 pcmFramesRead; \
11713 size_t sampleDataBufferSize = sizeof(buffer); \
11714 \
11715 pSampleData = (type*)drflac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks); \
11716 if (pSampleData == NULL) { \
11717 goto on_error; \
11718 } \
11719 \
11720 while ((pcmFramesRead = (drflac_uint64)drflac_read_pcm_frames_##extension(pFlac, sizeof(buffer)/sizeof(buffer[0])/pFlac->channels, buffer)) > 0) { \
11721 if (((totalPCMFrameCount + pcmFramesRead) * pFlac->channels * sizeof(type)) > sampleDataBufferSize) { \
11722 type* pNewSampleData; \
11723 size_t newSampleDataBufferSize; \
11724 \
11725 newSampleDataBufferSize = sampleDataBufferSize * 2; \
11726 pNewSampleData = (type*)drflac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks); \
11727 if (pNewSampleData == NULL) { \
11728 drflac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks); \
11729 goto on_error; \
11730 } \
11731 \
11732 sampleDataBufferSize = newSampleDataBufferSize; \
11733 pSampleData = pNewSampleData; \
11734 } \
11735 \
11736 DRFLAC_COPY_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), buffer, (size_t)(pcmFramesRead*pFlac->channels*sizeof(type))); \
11737 totalPCMFrameCount += pcmFramesRead; \
11738 } \
11739 \
11740 /* At this point everything should be decoded, but we just want to fill the unused part buffer with silence - need to \
11741 protect those ears from random noise! */ \
11742 DRFLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type))); \
11743 } else { \
11744 drflac_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type); \
11745 if (dataSize > (drflac_uint64)DRFLAC_SIZE_MAX) { \
11746 goto on_error; /* The decoded data is too big. */ \
11747 } \
11748 \
11749 pSampleData = (type*)drflac__malloc_from_callbacks((size_t)dataSize, &pFlac->allocationCallbacks); /* <-- Safe cast as per the check above. */ \
11750 if (pSampleData == NULL) { \
11751 goto on_error; \
11752 } \
11753 \
11754 totalPCMFrameCount = drflac_read_pcm_frames_##extension(pFlac, pFlac->totalPCMFrameCount, pSampleData); \
11755 } \
11756 \
11757 if (sampleRateOut) *sampleRateOut = pFlac->sampleRate; \
11758 if (channelsOut) *channelsOut = pFlac->channels; \
11759 if (totalPCMFrameCountOut) *totalPCMFrameCountOut = totalPCMFrameCount; \
11760 \
11761 drflac_close(pFlac); \
11762 return pSampleData; \
11763 \
11764on_error: \
11765 drflac_close(pFlac); \
11766 return NULL; \
11767}
11768
11769DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s32, drflac_int32)
11770DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s16, drflac_int16)
11771DRFLAC_DEFINE_FULL_READ_AND_CLOSE(f32, float)
11772
11773DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
11774{
11775 drflac* pFlac;
11776
11777 if (channelsOut) {
11778 *channelsOut = 0;
11779 }
11780 if (sampleRateOut) {
11781 *sampleRateOut = 0;
11782 }
11783 if (totalPCMFrameCountOut) {
11784 *totalPCMFrameCountOut = 0;
11785 }
11786
11787 pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
11788 if (pFlac == NULL) {
11789 return NULL;
11790 }
11791
11792 return drflac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
11793}
11794
11795DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
11796{
11797 drflac* pFlac;
11798
11799 if (channelsOut) {
11800 *channelsOut = 0;
11801 }
11802 if (sampleRateOut) {
11803 *sampleRateOut = 0;
11804 }
11805 if (totalPCMFrameCountOut) {
11806 *totalPCMFrameCountOut = 0;
11807 }
11808
11809 pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
11810 if (pFlac == NULL) {
11811 return NULL;
11812 }
11813
11814 return drflac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
11815}
11816
11817DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
11818{
11819 drflac* pFlac;
11820
11821 if (channelsOut) {
11822 *channelsOut = 0;
11823 }
11824 if (sampleRateOut) {
11825 *sampleRateOut = 0;
11826 }
11827 if (totalPCMFrameCountOut) {
11828 *totalPCMFrameCountOut = 0;
11829 }
11830
11831 pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
11832 if (pFlac == NULL) {
11833 return NULL;
11834 }
11835
11836 return drflac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
11837}
11838
11839#ifndef DR_FLAC_NO_STDIO
11840DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
11841{
11842 drflac* pFlac;
11843
11844 if (sampleRate) {
11845 *sampleRate = 0;
11846 }
11847 if (channels) {
11848 *channels = 0;
11849 }
11850 if (totalPCMFrameCount) {
11851 *totalPCMFrameCount = 0;
11852 }
11853
11854 pFlac = drflac_open_file(filename, pAllocationCallbacks);
11855 if (pFlac == NULL) {
11856 return NULL;
11857 }
11858
11859 return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
11860}
11861
11862DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
11863{
11864 drflac* pFlac;
11865
11866 if (sampleRate) {
11867 *sampleRate = 0;
11868 }
11869 if (channels) {
11870 *channels = 0;
11871 }
11872 if (totalPCMFrameCount) {
11873 *totalPCMFrameCount = 0;
11874 }
11875
11876 pFlac = drflac_open_file(filename, pAllocationCallbacks);
11877 if (pFlac == NULL) {
11878 return NULL;
11879 }
11880
11881 return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
11882}
11883
11884DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
11885{
11886 drflac* pFlac;
11887
11888 if (sampleRate) {
11889 *sampleRate = 0;
11890 }
11891 if (channels) {
11892 *channels = 0;
11893 }
11894 if (totalPCMFrameCount) {
11895 *totalPCMFrameCount = 0;
11896 }
11897
11898 pFlac = drflac_open_file(filename, pAllocationCallbacks);
11899 if (pFlac == NULL) {
11900 return NULL;
11901 }
11902
11903 return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
11904}
11905#endif
11906
11907DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
11908{
11909 drflac* pFlac;
11910
11911 if (sampleRate) {
11912 *sampleRate = 0;
11913 }
11914 if (channels) {
11915 *channels = 0;
11916 }
11917 if (totalPCMFrameCount) {
11918 *totalPCMFrameCount = 0;
11919 }
11920
11921 pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
11922 if (pFlac == NULL) {
11923 return NULL;
11924 }
11925
11926 return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
11927}
11928
11929DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
11930{
11931 drflac* pFlac;
11932
11933 if (sampleRate) {
11934 *sampleRate = 0;
11935 }
11936 if (channels) {
11937 *channels = 0;
11938 }
11939 if (totalPCMFrameCount) {
11940 *totalPCMFrameCount = 0;
11941 }
11942
11943 pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
11944 if (pFlac == NULL) {
11945 return NULL;
11946 }
11947
11948 return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
11949}
11950
11951DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
11952{
11953 drflac* pFlac;
11954
11955 if (sampleRate) {
11956 *sampleRate = 0;
11957 }
11958 if (channels) {
11959 *channels = 0;
11960 }
11961 if (totalPCMFrameCount) {
11962 *totalPCMFrameCount = 0;
11963 }
11964
11965 pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
11966 if (pFlac == NULL) {
11967 return NULL;
11968 }
11969
11970 return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
11971}
11972
11973
11974DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
11975{
11976 if (pAllocationCallbacks != NULL) {
11977 drflac__free_from_callbacks(p, pAllocationCallbacks);
11978 } else {
11979 drflac__free_default(p, NULL);
11980 }
11981}
11982
11983
11984
11985
11986DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments)
11987{
11988 if (pIter == NULL) {
11989 return;
11990 }
11991
11992 pIter->countRemaining = commentCount;
11993 pIter->pRunningData = (const char*)pComments;
11994}
11995
11996DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut)
11997{
11998 drflac_int32 length;
11999 const char* pComment;
12000
12001 /* Safety. */
12002 if (pCommentLengthOut) {
12003 *pCommentLengthOut = 0;
12004 }
12005
12006 if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
12007 return NULL;
12008 }
12009
12010 length = drflac__le2host_32_ptr_unaligned(pIter->pRunningData);
12011 pIter->pRunningData += 4;
12012
12013 pComment = pIter->pRunningData;
12014 pIter->pRunningData += length;
12015 pIter->countRemaining -= 1;
12016
12017 if (pCommentLengthOut) {
12018 *pCommentLengthOut = length;
12019 }
12020
12021 return pComment;
12022}
12023
12024
12025
12026
12027DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData)
12028{
12029 if (pIter == NULL) {
12030 return;
12031 }
12032
12033 pIter->countRemaining = trackCount;
12034 pIter->pRunningData = (const char*)pTrackData;
12035}
12036
12037DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack)
12038{
12039 drflac_cuesheet_track cuesheetTrack;
12040 const char* pRunningData;
12041 drflac_uint64 offsetHi;
12042 drflac_uint64 offsetLo;
12043
12044 if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
12045 return DRFLAC_FALSE;
12046 }
12047
12048 pRunningData = pIter->pRunningData;
12049
12050 offsetHi = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
12051 offsetLo = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
12052 cuesheetTrack.offset = offsetLo | (offsetHi << 32);
12053 cuesheetTrack.trackNumber = pRunningData[0]; pRunningData += 1;
12054 DRFLAC_COPY_MEMORY(cuesheetTrack.ISRC, pRunningData, sizeof(cuesheetTrack.ISRC)); pRunningData += 12;
12055 cuesheetTrack.isAudio = (pRunningData[0] & 0x80) != 0;
12056 cuesheetTrack.preEmphasis = (pRunningData[0] & 0x40) != 0; pRunningData += 14;
12057 cuesheetTrack.indexCount = pRunningData[0]; pRunningData += 1;
12058 cuesheetTrack.pIndexPoints = (const drflac_cuesheet_track_index*)pRunningData; pRunningData += cuesheetTrack.indexCount * sizeof(drflac_cuesheet_track_index);
12059
12060 pIter->pRunningData = pRunningData;
12061 pIter->countRemaining -= 1;
12062
12063 if (pCuesheetTrack) {
12064 *pCuesheetTrack = cuesheetTrack;
12065 }
12066
12067 return DRFLAC_TRUE;
12068}
12069
12070#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
12071 #pragma GCC diagnostic pop
12072#endif
12073#endif /* dr_flac_c */
12074#endif /* DR_FLAC_IMPLEMENTATION */
12075
12076
12077/*
12078REVISION HISTORY
12079================
12080v0.12.42 - 2023-11-02
12081 - Fix build for ARMv6-M.
12082 - Fix a compilation warning with GCC.
12083
12084v0.12.41 - 2023-06-17
12085 - Fix an incorrect date in revision history. No functional change.
12086
12087v0.12.40 - 2023-05-22
12088 - Minor code restructure. No functional change.
12089
12090v0.12.39 - 2022-09-17
12091 - Fix compilation with DJGPP.
12092 - Fix compilation error with Visual Studio 2019 and the ARM build.
12093 - Fix an error with SSE 4.1 detection.
12094 - Add support for disabling wchar_t with DR_WAV_NO_WCHAR.
12095 - Improve compatibility with compilers which lack support for explicit struct packing.
12096 - Improve compatibility with low-end and embedded hardware by reducing the amount of stack
12097 allocation when loading an Ogg encapsulated file.
12098
12099v0.12.38 - 2022-04-10
12100 - Fix compilation error on older versions of GCC.
12101
12102v0.12.37 - 2022-02-12
12103 - Improve ARM detection.
12104
12105v0.12.36 - 2022-02-07
12106 - Fix a compilation error with the ARM build.
12107
12108v0.12.35 - 2022-02-06
12109 - Fix a bug due to underestimating the amount of precision required for the prediction stage.
12110 - Fix some bugs found from fuzz testing.
12111
12112v0.12.34 - 2022-01-07
12113 - Fix some misalignment bugs when reading metadata.
12114
12115v0.12.33 - 2021-12-22
12116 - Fix a bug with seeking when the seek table does not start at PCM frame 0.
12117
12118v0.12.32 - 2021-12-11
12119 - Fix a warning with Clang.
12120
12121v0.12.31 - 2021-08-16
12122 - Silence some warnings.
12123
12124v0.12.30 - 2021-07-31
12125 - Fix platform detection for ARM64.
12126
12127v0.12.29 - 2021-04-02
12128 - Fix a bug where the running PCM frame index is set to an invalid value when over-seeking.
12129 - Fix a decoding error due to an incorrect validation check.
12130
12131v0.12.28 - 2021-02-21
12132 - Fix a warning due to referencing _MSC_VER when it is undefined.
12133
12134v0.12.27 - 2021-01-31
12135 - Fix a static analysis warning.
12136
12137v0.12.26 - 2021-01-17
12138 - Fix a compilation warning due to _BSD_SOURCE being deprecated.
12139
12140v0.12.25 - 2020-12-26
12141 - Update documentation.
12142
12143v0.12.24 - 2020-11-29
12144 - Fix ARM64/NEON detection when compiling with MSVC.
12145
12146v0.12.23 - 2020-11-21
12147 - Fix compilation with OpenWatcom.
12148
12149v0.12.22 - 2020-11-01
12150 - Fix an error with the previous release.
12151
12152v0.12.21 - 2020-11-01
12153 - Fix a possible deadlock when seeking.
12154 - Improve compiler support for older versions of GCC.
12155
12156v0.12.20 - 2020-09-08
12157 - Fix a compilation error on older compilers.
12158
12159v0.12.19 - 2020-08-30
12160 - Fix a bug due to an undefined 32-bit shift.
12161
12162v0.12.18 - 2020-08-14
12163 - Fix a crash when compiling with clang-cl.
12164
12165v0.12.17 - 2020-08-02
12166 - Simplify sized types.
12167
12168v0.12.16 - 2020-07-25
12169 - Fix a compilation warning.
12170
12171v0.12.15 - 2020-07-06
12172 - Check for negative LPC shifts and return an error.
12173
12174v0.12.14 - 2020-06-23
12175 - Add include guard for the implementation section.
12176
12177v0.12.13 - 2020-05-16
12178 - Add compile-time and run-time version querying.
12179 - DRFLAC_VERSION_MINOR
12180 - DRFLAC_VERSION_MAJOR
12181 - DRFLAC_VERSION_REVISION
12182 - DRFLAC_VERSION_STRING
12183 - drflac_version()
12184 - drflac_version_string()
12185
12186v0.12.12 - 2020-04-30
12187 - Fix compilation errors with VC6.
12188
12189v0.12.11 - 2020-04-19
12190 - Fix some pedantic warnings.
12191 - Fix some undefined behaviour warnings.
12192
12193v0.12.10 - 2020-04-10
12194 - Fix some bugs when trying to seek with an invalid seek table.
12195
12196v0.12.9 - 2020-04-05
12197 - Fix warnings.
12198
12199v0.12.8 - 2020-04-04
12200 - Add drflac_open_file_w() and drflac_open_file_with_metadata_w().
12201 - Fix some static analysis warnings.
12202 - Minor documentation updates.
12203
12204v0.12.7 - 2020-03-14
12205 - Fix compilation errors with VC6.
12206
12207v0.12.6 - 2020-03-07
12208 - Fix compilation error with Visual Studio .NET 2003.
12209
12210v0.12.5 - 2020-01-30
12211 - Silence some static analysis warnings.
12212
12213v0.12.4 - 2020-01-29
12214 - Silence some static analysis warnings.
12215
12216v0.12.3 - 2019-12-02
12217 - Fix some warnings when compiling with GCC and the -Og flag.
12218 - Fix a crash in out-of-memory situations.
12219 - Fix potential integer overflow bug.
12220 - Fix some static analysis warnings.
12221 - Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
12222 - Fix a bug with binary search seeking where the bits per sample is not a multiple of 8.
12223
12224v0.12.2 - 2019-10-07
12225 - Internal code clean up.
12226
12227v0.12.1 - 2019-09-29
12228 - Fix some Clang Static Analyzer warnings.
12229 - Fix an unused variable warning.
12230
12231v0.12.0 - 2019-09-23
12232 - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
12233 routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
12234 - drflac_open()
12235 - drflac_open_relaxed()
12236 - drflac_open_with_metadata()
12237 - drflac_open_with_metadata_relaxed()
12238 - drflac_open_file()
12239 - drflac_open_file_with_metadata()
12240 - drflac_open_memory()
12241 - drflac_open_memory_with_metadata()
12242 - drflac_open_and_read_pcm_frames_s32()
12243 - drflac_open_and_read_pcm_frames_s16()
12244 - drflac_open_and_read_pcm_frames_f32()
12245 - drflac_open_file_and_read_pcm_frames_s32()
12246 - drflac_open_file_and_read_pcm_frames_s16()
12247 - drflac_open_file_and_read_pcm_frames_f32()
12248 - drflac_open_memory_and_read_pcm_frames_s32()
12249 - drflac_open_memory_and_read_pcm_frames_s16()
12250 - drflac_open_memory_and_read_pcm_frames_f32()
12251 Set this extra parameter to NULL to use defaults which is the same as the previous behaviour. Setting this NULL will use
12252 DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
12253 - Remove deprecated APIs:
12254 - drflac_read_s32()
12255 - drflac_read_s16()
12256 - drflac_read_f32()
12257 - drflac_seek_to_sample()
12258 - drflac_open_and_decode_s32()
12259 - drflac_open_and_decode_s16()
12260 - drflac_open_and_decode_f32()
12261 - drflac_open_and_decode_file_s32()
12262 - drflac_open_and_decode_file_s16()
12263 - drflac_open_and_decode_file_f32()
12264 - drflac_open_and_decode_memory_s32()
12265 - drflac_open_and_decode_memory_s16()
12266 - drflac_open_and_decode_memory_f32()
12267 - Remove drflac.totalSampleCount which is now replaced with drflac.totalPCMFrameCount. You can emulate drflac.totalSampleCount
12268 by doing pFlac->totalPCMFrameCount*pFlac->channels.
12269 - Rename drflac.currentFrame to drflac.currentFLACFrame to remove ambiguity with PCM frames.
12270 - Fix errors when seeking to the end of a stream.
12271 - Optimizations to seeking.
12272 - SSE improvements and optimizations.
12273 - ARM NEON optimizations.
12274 - Optimizations to drflac_read_pcm_frames_s16().
12275 - Optimizations to drflac_read_pcm_frames_s32().
12276
12277v0.11.10 - 2019-06-26
12278 - Fix a compiler error.
12279
12280v0.11.9 - 2019-06-16
12281 - Silence some ThreadSanitizer warnings.
12282
12283v0.11.8 - 2019-05-21
12284 - Fix warnings.
12285
12286v0.11.7 - 2019-05-06
12287 - C89 fixes.
12288
12289v0.11.6 - 2019-05-05
12290 - Add support for C89.
12291 - Fix a compiler warning when CRC is disabled.
12292 - Change license to choice of public domain or MIT-0.
12293
12294v0.11.5 - 2019-04-19
12295 - Fix a compiler error with GCC.
12296
12297v0.11.4 - 2019-04-17
12298 - Fix some warnings with GCC when compiling with -std=c99.
12299
12300v0.11.3 - 2019-04-07
12301 - Silence warnings with GCC.
12302
12303v0.11.2 - 2019-03-10
12304 - Fix a warning.
12305
12306v0.11.1 - 2019-02-17
12307 - Fix a potential bug with seeking.
12308
12309v0.11.0 - 2018-12-16
12310 - API CHANGE: Deprecated drflac_read_s32(), drflac_read_s16() and drflac_read_f32() and replaced them with
12311 drflac_read_pcm_frames_s32(), drflac_read_pcm_frames_s16() and drflac_read_pcm_frames_f32(). The new APIs take
12312 and return PCM frame counts instead of sample counts. To upgrade you will need to change the input count by
12313 dividing it by the channel count, and then do the same with the return value.
12314 - API_CHANGE: Deprecated drflac_seek_to_sample() and replaced with drflac_seek_to_pcm_frame(). Same rules as
12315 the changes to drflac_read_*() apply.
12316 - API CHANGE: Deprecated drflac_open_and_decode_*() and replaced with drflac_open_*_and_read_*(). Same rules as
12317 the changes to drflac_read_*() apply.
12318 - Optimizations.
12319
12320v0.10.0 - 2018-09-11
12321 - Remove the DR_FLAC_NO_WIN32_IO option and the Win32 file IO functionality. If you need to use Win32 file IO you
12322 need to do it yourself via the callback API.
12323 - Fix the clang build.
12324 - Fix undefined behavior.
12325 - Fix errors with CUESHEET metdata blocks.
12326 - Add an API for iterating over each cuesheet track in the CUESHEET metadata block. This works the same way as the
12327 Vorbis comment API.
12328 - Other miscellaneous bug fixes, mostly relating to invalid FLAC streams.
12329 - Minor optimizations.
12330
12331v0.9.11 - 2018-08-29
12332 - Fix a bug with sample reconstruction.
12333
12334v0.9.10 - 2018-08-07
12335 - Improve 64-bit detection.
12336
12337v0.9.9 - 2018-08-05
12338 - Fix C++ build on older versions of GCC.
12339
12340v0.9.8 - 2018-07-24
12341 - Fix compilation errors.
12342
12343v0.9.7 - 2018-07-05
12344 - Fix a warning.
12345
12346v0.9.6 - 2018-06-29
12347 - Fix some typos.
12348
12349v0.9.5 - 2018-06-23
12350 - Fix some warnings.
12351
12352v0.9.4 - 2018-06-14
12353 - Optimizations to seeking.
12354 - Clean up.
12355
12356v0.9.3 - 2018-05-22
12357 - Bug fix.
12358
12359v0.9.2 - 2018-05-12
12360 - Fix a compilation error due to a missing break statement.
12361
12362v0.9.1 - 2018-04-29
12363 - Fix compilation error with Clang.
12364
12365v0.9 - 2018-04-24
12366 - Fix Clang build.
12367 - Start using major.minor.revision versioning.
12368
12369v0.8g - 2018-04-19
12370 - Fix build on non-x86/x64 architectures.
12371
12372v0.8f - 2018-02-02
12373 - Stop pretending to support changing rate/channels mid stream.
12374
12375v0.8e - 2018-02-01
12376 - Fix a crash when the block size of a frame is larger than the maximum block size defined by the FLAC stream.
12377 - Fix a crash the the Rice partition order is invalid.
12378
12379v0.8d - 2017-09-22
12380 - Add support for decoding streams with ID3 tags. ID3 tags are just skipped.
12381
12382v0.8c - 2017-09-07
12383 - Fix warning on non-x86/x64 architectures.
12384
12385v0.8b - 2017-08-19
12386 - Fix build on non-x86/x64 architectures.
12387
12388v0.8a - 2017-08-13
12389 - A small optimization for the Clang build.
12390
12391v0.8 - 2017-08-12
12392 - API CHANGE: Rename dr_* types to drflac_*.
12393 - Optimizations. This brings dr_flac back to about the same class of efficiency as the reference implementation.
12394 - Add support for custom implementations of malloc(), realloc(), etc.
12395 - Add CRC checking to Ogg encapsulated streams.
12396 - Fix VC++ 6 build. This is only for the C++ compiler. The C compiler is not currently supported.
12397 - Bug fixes.
12398
12399v0.7 - 2017-07-23
12400 - Add support for opening a stream without a header block. To do this, use drflac_open_relaxed() / drflac_open_with_metadata_relaxed().
12401
12402v0.6 - 2017-07-22
12403 - Add support for recovering from invalid frames. With this change, dr_flac will simply skip over invalid frames as if they
12404 never existed. Frames are checked against their sync code, the CRC-8 of the frame header and the CRC-16 of the whole frame.
12405
12406v0.5 - 2017-07-16
12407 - Fix typos.
12408 - Change drflac_bool* types to unsigned.
12409 - Add CRC checking. This makes dr_flac slower, but can be disabled with #define DR_FLAC_NO_CRC.
12410
12411v0.4f - 2017-03-10
12412 - Fix a couple of bugs with the bitstreaming code.
12413
12414v0.4e - 2017-02-17
12415 - Fix some warnings.
12416
12417v0.4d - 2016-12-26
12418 - Add support for 32-bit floating-point PCM decoding.
12419 - Use drflac_int* and drflac_uint* sized types to improve compiler support.
12420 - Minor improvements to documentation.
12421
12422v0.4c - 2016-12-26
12423 - Add support for signed 16-bit integer PCM decoding.
12424
12425v0.4b - 2016-10-23
12426 - A minor change to drflac_bool8 and drflac_bool32 types.
12427
12428v0.4a - 2016-10-11
12429 - Rename drBool32 to drflac_bool32 for styling consistency.
12430
12431v0.4 - 2016-09-29
12432 - API/ABI CHANGE: Use fixed size 32-bit booleans instead of the built-in bool type.
12433 - API CHANGE: Rename drflac_open_and_decode*() to drflac_open_and_decode*_s32().
12434 - API CHANGE: Swap the order of "channels" and "sampleRate" parameters in drflac_open_and_decode*(). Rationale for this is to
12435 keep it consistent with drflac_audio.
12436
12437v0.3f - 2016-09-21
12438 - Fix a warning with GCC.
12439
12440v0.3e - 2016-09-18
12441 - Fixed a bug where GCC 4.3+ was not getting properly identified.
12442 - Fixed a few typos.
12443 - Changed date formats to ISO 8601 (YYYY-MM-DD).
12444
12445v0.3d - 2016-06-11
12446 - Minor clean up.
12447
12448v0.3c - 2016-05-28
12449 - Fixed compilation error.
12450
12451v0.3b - 2016-05-16
12452 - Fixed Linux/GCC build.
12453 - Updated documentation.
12454
12455v0.3a - 2016-05-15
12456 - Minor fixes to documentation.
12457
12458v0.3 - 2016-05-11
12459 - Optimizations. Now at about parity with the reference implementation on 32-bit builds.
12460 - Lots of clean up.
12461
12462v0.2b - 2016-05-10
12463 - Bug fixes.
12464
12465v0.2a - 2016-05-10
12466 - Made drflac_open_and_decode() more robust.
12467 - Removed an unused debugging variable
12468
12469v0.2 - 2016-05-09
12470 - Added support for Ogg encapsulation.
12471 - API CHANGE. Have the onSeek callback take a third argument which specifies whether or not the seek
12472 should be relative to the start or the current position. Also changes the seeking rules such that
12473 seeking offsets will never be negative.
12474 - Have drflac_open_and_decode() fail gracefully if the stream has an unknown total sample count.
12475
12476v0.1b - 2016-05-07
12477 - Properly close the file handle in drflac_open_file() and family when the decoder fails to initialize.
12478 - Removed a stale comment.
12479
12480v0.1a - 2016-05-05
12481 - Minor formatting changes.
12482 - Fixed a warning on the GCC build.
12483
12484v0.1 - 2016-05-03
12485 - Initial versioned release.
12486*/
12487
12488/*
12489This software is available as a choice of the following licenses. Choose
12490whichever you prefer.
12491
12492===============================================================================
12493ALTERNATIVE 1 - Public Domain (www.unlicense.org)
12494===============================================================================
12495This is free and unencumbered software released into the public domain.
12496
12497Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12498software, either in source code form or as a compiled binary, for any purpose,
12499commercial or non-commercial, and by any means.
12500
12501In jurisdictions that recognize copyright laws, the author or authors of this
12502software dedicate any and all copyright interest in the software to the public
12503domain. We make this dedication for the benefit of the public at large and to
12504the detriment of our heirs and successors. We intend this dedication to be an
12505overt act of relinquishment in perpetuity of all present and future rights to
12506this software under copyright law.
12507
12508THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12509IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12510FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
12511AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
12512ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
12513WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12514
12515For more information, please refer to <http://unlicense.org/>
12516
12517===============================================================================
12518ALTERNATIVE 2 - MIT No Attribution
12519===============================================================================
12520Copyright 2023 David Reid
12521
12522Permission is hereby granted, free of charge, to any person obtaining a copy of
12523this software and associated documentation files (the "Software"), to deal in
12524the Software without restriction, including without limitation the rights to
12525use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12526of the Software, and to permit persons to whom the Software is furnished to do
12527so.
12528
12529THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12530IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12531FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
12532AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
12533LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12534OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
12535SOFTWARE.
12536*/
diff --git a/raylib/src/external/dr_mp3.h b/raylib/src/external/dr_mp3.h
new file mode 100644
index 0000000..e1a66d9
--- /dev/null
+++ b/raylib/src/external/dr_mp3.h
@@ -0,0 +1,4837 @@
1/*
2MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
3dr_mp3 - v0.6.39 - 2024-02-27
4
5David Reid - mackron@gmail.com
6
7GitHub: https://github.com/mackron/dr_libs
8
9Based on minimp3 (https://github.com/lieff/minimp3) which is where the real work was done. See the bottom of this file for differences between minimp3 and dr_mp3.
10*/
11
12/*
13RELEASE NOTES - VERSION 0.6
14===========================
15Version 0.6 includes breaking changes with the configuration of decoders. The ability to customize the number of output channels and the sample rate has been
16removed. You must now use the channel count and sample rate reported by the MP3 stream itself, and all channel and sample rate conversion must be done
17yourself.
18
19
20Changes to Initialization
21-------------------------
22Previously, `drmp3_init()`, etc. took a pointer to a `drmp3_config` object that allowed you to customize the output channels and sample rate. This has been
23removed. If you need the old behaviour you will need to convert the data yourself or just not upgrade. The following APIs have changed.
24
25 `drmp3_init()`
26 `drmp3_init_memory()`
27 `drmp3_init_file()`
28
29
30Miscellaneous Changes
31---------------------
32Support for loading a file from a `wchar_t` string has been added via the `drmp3_init_file_w()` API.
33*/
34
35/*
36Introducation
37=============
38dr_mp3 is a single file library. To use it, do something like the following in one .c file.
39
40 ```c
41 #define DR_MP3_IMPLEMENTATION
42 #include "dr_mp3.h"
43 ```
44
45You can then #include this file in other parts of the program as you would with any other header file. To decode audio data, do something like the following:
46
47 ```c
48 drmp3 mp3;
49 if (!drmp3_init_file(&mp3, "MySong.mp3", NULL)) {
50 // Failed to open file
51 }
52
53 ...
54
55 drmp3_uint64 framesRead = drmp3_read_pcm_frames_f32(pMP3, framesToRead, pFrames);
56 ```
57
58The drmp3 object is transparent so you can get access to the channel count and sample rate like so:
59
60 ```
61 drmp3_uint32 channels = mp3.channels;
62 drmp3_uint32 sampleRate = mp3.sampleRate;
63 ```
64
65The example above initializes a decoder from a file, but you can also initialize it from a block of memory and read and seek callbacks with
66`drmp3_init_memory()` and `drmp3_init()` respectively.
67
68You do not need to do any annoying memory management when reading PCM frames - this is all managed internally. You can request any number of PCM frames in each
69call to `drmp3_read_pcm_frames_f32()` and it will return as many PCM frames as it can, up to the requested amount.
70
71You can also decode an entire file in one go with `drmp3_open_and_read_pcm_frames_f32()`, `drmp3_open_memory_and_read_pcm_frames_f32()` and
72`drmp3_open_file_and_read_pcm_frames_f32()`.
73
74
75Build Options
76=============
77#define these options before including this file.
78
79#define DR_MP3_NO_STDIO
80 Disable drmp3_init_file(), etc.
81
82#define DR_MP3_NO_SIMD
83 Disable SIMD optimizations.
84*/
85
86#ifndef dr_mp3_h
87#define dr_mp3_h
88
89#ifdef __cplusplus
90extern "C" {
91#endif
92
93#define DRMP3_STRINGIFY(x) #x
94#define DRMP3_XSTRINGIFY(x) DRMP3_STRINGIFY(x)
95
96#define DRMP3_VERSION_MAJOR 0
97#define DRMP3_VERSION_MINOR 6
98#define DRMP3_VERSION_REVISION 39
99#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
100
101#include <stddef.h> /* For size_t. */
102
103/* Sized Types */
104typedef signed char drmp3_int8;
105typedef unsigned char drmp3_uint8;
106typedef signed short drmp3_int16;
107typedef unsigned short drmp3_uint16;
108typedef signed int drmp3_int32;
109typedef unsigned int drmp3_uint32;
110#if defined(_MSC_VER) && !defined(__clang__)
111 typedef signed __int64 drmp3_int64;
112 typedef unsigned __int64 drmp3_uint64;
113#else
114 #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
115 #pragma GCC diagnostic push
116 #pragma GCC diagnostic ignored "-Wlong-long"
117 #if defined(__clang__)
118 #pragma GCC diagnostic ignored "-Wc++11-long-long"
119 #endif
120 #endif
121 typedef signed long long drmp3_int64;
122 typedef unsigned long long drmp3_uint64;
123 #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
124 #pragma GCC diagnostic pop
125 #endif
126#endif
127#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__)
128 typedef drmp3_uint64 drmp3_uintptr;
129#else
130 typedef drmp3_uint32 drmp3_uintptr;
131#endif
132typedef drmp3_uint8 drmp3_bool8;
133typedef drmp3_uint32 drmp3_bool32;
134#define DRMP3_TRUE 1
135#define DRMP3_FALSE 0
136/* End Sized Types */
137
138/* Decorations */
139#if !defined(DRMP3_API)
140 #if defined(DRMP3_DLL)
141 #if defined(_WIN32)
142 #define DRMP3_DLL_IMPORT __declspec(dllimport)
143 #define DRMP3_DLL_EXPORT __declspec(dllexport)
144 #define DRMP3_DLL_PRIVATE static
145 #else
146 #if defined(__GNUC__) && __GNUC__ >= 4
147 #define DRMP3_DLL_IMPORT __attribute__((visibility("default")))
148 #define DRMP3_DLL_EXPORT __attribute__((visibility("default")))
149 #define DRMP3_DLL_PRIVATE __attribute__((visibility("hidden")))
150 #else
151 #define DRMP3_DLL_IMPORT
152 #define DRMP3_DLL_EXPORT
153 #define DRMP3_DLL_PRIVATE static
154 #endif
155 #endif
156
157 #if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
158 #define DRMP3_API DRMP3_DLL_EXPORT
159 #else
160 #define DRMP3_API DRMP3_DLL_IMPORT
161 #endif
162 #define DRMP3_PRIVATE DRMP3_DLL_PRIVATE
163 #else
164 #define DRMP3_API extern
165 #define DRMP3_PRIVATE static
166 #endif
167#endif
168/* End Decorations */
169
170/* Result Codes */
171typedef drmp3_int32 drmp3_result;
172#define DRMP3_SUCCESS 0
173#define DRMP3_ERROR -1 /* A generic error. */
174#define DRMP3_INVALID_ARGS -2
175#define DRMP3_INVALID_OPERATION -3
176#define DRMP3_OUT_OF_MEMORY -4
177#define DRMP3_OUT_OF_RANGE -5
178#define DRMP3_ACCESS_DENIED -6
179#define DRMP3_DOES_NOT_EXIST -7
180#define DRMP3_ALREADY_EXISTS -8
181#define DRMP3_TOO_MANY_OPEN_FILES -9
182#define DRMP3_INVALID_FILE -10
183#define DRMP3_TOO_BIG -11
184#define DRMP3_PATH_TOO_LONG -12
185#define DRMP3_NAME_TOO_LONG -13
186#define DRMP3_NOT_DIRECTORY -14
187#define DRMP3_IS_DIRECTORY -15
188#define DRMP3_DIRECTORY_NOT_EMPTY -16
189#define DRMP3_END_OF_FILE -17
190#define DRMP3_NO_SPACE -18
191#define DRMP3_BUSY -19
192#define DRMP3_IO_ERROR -20
193#define DRMP3_INTERRUPT -21
194#define DRMP3_UNAVAILABLE -22
195#define DRMP3_ALREADY_IN_USE -23
196#define DRMP3_BAD_ADDRESS -24
197#define DRMP3_BAD_SEEK -25
198#define DRMP3_BAD_PIPE -26
199#define DRMP3_DEADLOCK -27
200#define DRMP3_TOO_MANY_LINKS -28
201#define DRMP3_NOT_IMPLEMENTED -29
202#define DRMP3_NO_MESSAGE -30
203#define DRMP3_BAD_MESSAGE -31
204#define DRMP3_NO_DATA_AVAILABLE -32
205#define DRMP3_INVALID_DATA -33
206#define DRMP3_TIMEOUT -34
207#define DRMP3_NO_NETWORK -35
208#define DRMP3_NOT_UNIQUE -36
209#define DRMP3_NOT_SOCKET -37
210#define DRMP3_NO_ADDRESS -38
211#define DRMP3_BAD_PROTOCOL -39
212#define DRMP3_PROTOCOL_UNAVAILABLE -40
213#define DRMP3_PROTOCOL_NOT_SUPPORTED -41
214#define DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED -42
215#define DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED -43
216#define DRMP3_SOCKET_NOT_SUPPORTED -44
217#define DRMP3_CONNECTION_RESET -45
218#define DRMP3_ALREADY_CONNECTED -46
219#define DRMP3_NOT_CONNECTED -47
220#define DRMP3_CONNECTION_REFUSED -48
221#define DRMP3_NO_HOST -49
222#define DRMP3_IN_PROGRESS -50
223#define DRMP3_CANCELLED -51
224#define DRMP3_MEMORY_ALREADY_MAPPED -52
225#define DRMP3_AT_END -53
226/* End Result Codes */
227
228#define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME 1152
229#define DRMP3_MAX_SAMPLES_PER_FRAME (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2)
230
231/* Inline */
232#ifdef _MSC_VER
233 #define DRMP3_INLINE __forceinline
234#elif defined(__GNUC__)
235 /*
236 I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
237 the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
238 case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
239 command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
240 I am using "__inline__" only when we're compiling in strict ANSI mode.
241 */
242 #if defined(__STRICT_ANSI__)
243 #define DRMP3_GNUC_INLINE_HINT __inline__
244 #else
245 #define DRMP3_GNUC_INLINE_HINT inline
246 #endif
247
248 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
249 #define DRMP3_INLINE DRMP3_GNUC_INLINE_HINT __attribute__((always_inline))
250 #else
251 #define DRMP3_INLINE DRMP3_GNUC_INLINE_HINT
252 #endif
253#elif defined(__WATCOMC__)
254 #define DRMP3_INLINE __inline
255#else
256 #define DRMP3_INLINE
257#endif
258/* End Inline */
259
260
261DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision);
262DRMP3_API const char* drmp3_version_string(void);
263
264
265/* Allocation Callbacks */
266typedef struct
267{
268 void* pUserData;
269 void* (* onMalloc)(size_t sz, void* pUserData);
270 void* (* onRealloc)(void* p, size_t sz, void* pUserData);
271 void (* onFree)(void* p, void* pUserData);
272} drmp3_allocation_callbacks;
273/* End Allocation Callbacks */
274
275
276/*
277Low Level Push API
278==================
279*/
280typedef struct
281{
282 int frame_bytes, channels, hz, layer, bitrate_kbps;
283} drmp3dec_frame_info;
284
285typedef struct
286{
287 float mdct_overlap[2][9*32], qmf_state[15*2*32];
288 int reserv, free_format_bytes;
289 drmp3_uint8 header[4], reserv_buf[511];
290} drmp3dec;
291
292/* Initializes a low level decoder. */
293DRMP3_API void drmp3dec_init(drmp3dec *dec);
294
295/* Reads a frame from a low level decoder. */
296DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info);
297
298/* Helper for converting between f32 and s16. */
299DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples);
300
301
302
303/*
304Main API (Pull API)
305===================
306*/
307typedef enum
308{
309 drmp3_seek_origin_start,
310 drmp3_seek_origin_current
311} drmp3_seek_origin;
312
313typedef struct
314{
315 drmp3_uint64 seekPosInBytes; /* Points to the first byte of an MP3 frame. */
316 drmp3_uint64 pcmFrameIndex; /* The index of the PCM frame this seek point targets. */
317 drmp3_uint16 mp3FramesToDiscard; /* The number of whole MP3 frames to be discarded before pcmFramesToDiscard. */
318 drmp3_uint16 pcmFramesToDiscard; /* The number of leading samples to read and discard. These are discarded after mp3FramesToDiscard. */
319} drmp3_seek_point;
320
321/*
322Callback for when data is read. Return value is the number of bytes actually read.
323
324pUserData [in] The user data that was passed to drmp3_init(), drmp3_open() and family.
325pBufferOut [out] The output buffer.
326bytesToRead [in] The number of bytes to read.
327
328Returns the number of bytes actually read.
329
330A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until
331either the entire bytesToRead is filled or you have reached the end of the stream.
332*/
333typedef size_t (* drmp3_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
334
335/*
336Callback for when data needs to be seeked.
337
338pUserData [in] The user data that was passed to drmp3_init(), drmp3_open() and family.
339offset [in] The number of bytes to move, relative to the origin. Will never be negative.
340origin [in] The origin of the seek - the current position or the start of the stream.
341
342Returns whether or not the seek was successful.
343
344Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which
345will be either drmp3_seek_origin_start or drmp3_seek_origin_current.
346*/
347typedef drmp3_bool32 (* drmp3_seek_proc)(void* pUserData, int offset, drmp3_seek_origin origin);
348
349typedef struct
350{
351 drmp3_uint32 channels;
352 drmp3_uint32 sampleRate;
353} drmp3_config;
354
355typedef struct
356{
357 drmp3dec decoder;
358 drmp3_uint32 channels;
359 drmp3_uint32 sampleRate;
360 drmp3_read_proc onRead;
361 drmp3_seek_proc onSeek;
362 void* pUserData;
363 drmp3_allocation_callbacks allocationCallbacks;
364 drmp3_uint32 mp3FrameChannels; /* The number of channels in the currently loaded MP3 frame. Internal use only. */
365 drmp3_uint32 mp3FrameSampleRate; /* The sample rate of the currently loaded MP3 frame. Internal use only. */
366 drmp3_uint32 pcmFramesConsumedInMP3Frame;
367 drmp3_uint32 pcmFramesRemainingInMP3Frame;
368 drmp3_uint8 pcmFrames[sizeof(float)*DRMP3_MAX_SAMPLES_PER_FRAME]; /* <-- Multipled by sizeof(float) to ensure there's enough room for DR_MP3_FLOAT_OUTPUT. */
369 drmp3_uint64 currentPCMFrame; /* The current PCM frame, globally, based on the output sample rate. Mainly used for seeking. */
370 drmp3_uint64 streamCursor; /* The current byte the decoder is sitting on in the raw stream. */
371 drmp3_seek_point* pSeekPoints; /* NULL by default. Set with drmp3_bind_seek_table(). Memory is owned by the client. dr_mp3 will never attempt to free this pointer. */
372 drmp3_uint32 seekPointCount; /* The number of items in pSeekPoints. When set to 0 assumes to no seek table. Defaults to zero. */
373 size_t dataSize;
374 size_t dataCapacity;
375 size_t dataConsumed;
376 drmp3_uint8* pData;
377 drmp3_bool32 atEnd : 1;
378 struct
379 {
380 const drmp3_uint8* pData;
381 size_t dataSize;
382 size_t currentReadPos;
383 } memory; /* Only used for decoders that were opened against a block of memory. */
384} drmp3;
385
386/*
387Initializes an MP3 decoder.
388
389onRead [in] The function to call when data needs to be read from the client.
390onSeek [in] The function to call when the read position of the client data needs to move.
391pUserData [in, optional] A pointer to application defined data that will be passed to onRead and onSeek.
392
393Returns true if successful; false otherwise.
394
395Close the loader with drmp3_uninit().
396
397See also: drmp3_init_file(), drmp3_init_memory(), drmp3_uninit()
398*/
399DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks);
400
401/*
402Initializes an MP3 decoder from a block of memory.
403
404This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for
405the lifetime of the drmp3 object.
406
407The buffer should contain the contents of the entire MP3 file.
408*/
409DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks);
410
411#ifndef DR_MP3_NO_STDIO
412/*
413Initializes an MP3 decoder from a file.
414
415This holds the internal FILE object until drmp3_uninit() is called. Keep this in mind if you're caching drmp3
416objects because the operating system may restrict the number of file handles an application can have open at
417any given time.
418*/
419DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
420DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
421#endif
422
423/*
424Uninitializes an MP3 decoder.
425*/
426DRMP3_API void drmp3_uninit(drmp3* pMP3);
427
428/*
429Reads PCM frames as interleaved 32-bit IEEE floating point PCM.
430
431Note that framesToRead specifies the number of PCM frames to read, _not_ the number of MP3 frames.
432*/
433DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut);
434
435/*
436Reads PCM frames as interleaved signed 16-bit integer PCM.
437
438Note that framesToRead specifies the number of PCM frames to read, _not_ the number of MP3 frames.
439*/
440DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut);
441
442/*
443Seeks to a specific frame.
444
445Note that this is _not_ an MP3 frame, but rather a PCM frame.
446*/
447DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex);
448
449/*
450Calculates the total number of PCM frames in the MP3 stream. Cannot be used for infinite streams such as internet
451radio. Runs in linear time. Returns 0 on error.
452*/
453DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3);
454
455/*
456Calculates the total number of MP3 frames in the MP3 stream. Cannot be used for infinite streams such as internet
457radio. Runs in linear time. Returns 0 on error.
458*/
459DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3);
460
461/*
462Calculates the total number of MP3 and PCM frames in the MP3 stream. Cannot be used for infinite streams such as internet
463radio. Runs in linear time. Returns 0 on error.
464
465This is equivalent to calling drmp3_get_mp3_frame_count() and drmp3_get_pcm_frame_count() except that it's more efficient.
466*/
467DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount);
468
469/*
470Calculates the seekpoints based on PCM frames. This is slow.
471
472pSeekpoint count is a pointer to a uint32 containing the seekpoint count. On input it contains the desired count.
473On output it contains the actual count. The reason for this design is that the client may request too many
474seekpoints, in which case dr_mp3 will return a corrected count.
475
476Note that seektable seeking is not quite sample exact when the MP3 stream contains inconsistent sample rates.
477*/
478DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints);
479
480/*
481Binds a seek table to the decoder.
482
483This does _not_ make a copy of pSeekPoints - it only references it. It is up to the application to ensure this
484remains valid while it is bound to the decoder.
485
486Use drmp3_calculate_seek_points() to calculate the seek points.
487*/
488DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints);
489
490
491/*
492Opens an decodes an entire MP3 stream as a single operation.
493
494On output pConfig will receive the channel count and sample rate of the stream.
495
496Free the returned pointer with drmp3_free().
497*/
498DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
499DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
500
501DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
502DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
503
504#ifndef DR_MP3_NO_STDIO
505DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
506DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
507#endif
508
509/*
510Allocates a block of memory on the heap.
511*/
512DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks);
513
514/*
515Frees any memory that was allocated by a public drmp3 API.
516*/
517DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks);
518
519#ifdef __cplusplus
520}
521#endif
522#endif /* dr_mp3_h */
523
524
525/************************************************************************************************************************************************************
526 ************************************************************************************************************************************************************
527
528 IMPLEMENTATION
529
530 ************************************************************************************************************************************************************
531 ************************************************************************************************************************************************************/
532#if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
533#ifndef dr_mp3_c
534#define dr_mp3_c
535
536#include <stdlib.h>
537#include <string.h>
538#include <limits.h> /* For INT_MAX */
539
540DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision)
541{
542 if (pMajor) {
543 *pMajor = DRMP3_VERSION_MAJOR;
544 }
545
546 if (pMinor) {
547 *pMinor = DRMP3_VERSION_MINOR;
548 }
549
550 if (pRevision) {
551 *pRevision = DRMP3_VERSION_REVISION;
552 }
553}
554
555DRMP3_API const char* drmp3_version_string(void)
556{
557 return DRMP3_VERSION_STRING;
558}
559
560/* Disable SIMD when compiling with TCC for now. */
561#if defined(__TINYC__)
562#define DR_MP3_NO_SIMD
563#endif
564
565#define DRMP3_OFFSET_PTR(p, offset) ((void*)((drmp3_uint8*)(p) + (offset)))
566
567#define DRMP3_MAX_FREE_FORMAT_FRAME_SIZE 2304 /* more than ISO spec's */
568#ifndef DRMP3_MAX_FRAME_SYNC_MATCHES
569#define DRMP3_MAX_FRAME_SYNC_MATCHES 10
570#endif
571
572#define DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES DRMP3_MAX_FREE_FORMAT_FRAME_SIZE /* MUST be >= 320000/8/32000*1152 = 1440 */
573
574#define DRMP3_MAX_BITRESERVOIR_BYTES 511
575#define DRMP3_SHORT_BLOCK_TYPE 2
576#define DRMP3_STOP_BLOCK_TYPE 3
577#define DRMP3_MODE_MONO 3
578#define DRMP3_MODE_JOINT_STEREO 1
579#define DRMP3_HDR_SIZE 4
580#define DRMP3_HDR_IS_MONO(h) (((h[3]) & 0xC0) == 0xC0)
581#define DRMP3_HDR_IS_MS_STEREO(h) (((h[3]) & 0xE0) == 0x60)
582#define DRMP3_HDR_IS_FREE_FORMAT(h) (((h[2]) & 0xF0) == 0)
583#define DRMP3_HDR_IS_CRC(h) (!((h[1]) & 1))
584#define DRMP3_HDR_TEST_PADDING(h) ((h[2]) & 0x2)
585#define DRMP3_HDR_TEST_MPEG1(h) ((h[1]) & 0x8)
586#define DRMP3_HDR_TEST_NOT_MPEG25(h) ((h[1]) & 0x10)
587#define DRMP3_HDR_TEST_I_STEREO(h) ((h[3]) & 0x10)
588#define DRMP3_HDR_TEST_MS_STEREO(h) ((h[3]) & 0x20)
589#define DRMP3_HDR_GET_STEREO_MODE(h) (((h[3]) >> 6) & 3)
590#define DRMP3_HDR_GET_STEREO_MODE_EXT(h) (((h[3]) >> 4) & 3)
591#define DRMP3_HDR_GET_LAYER(h) (((h[1]) >> 1) & 3)
592#define DRMP3_HDR_GET_BITRATE(h) ((h[2]) >> 4)
593#define DRMP3_HDR_GET_SAMPLE_RATE(h) (((h[2]) >> 2) & 3)
594#define DRMP3_HDR_GET_MY_SAMPLE_RATE(h) (DRMP3_HDR_GET_SAMPLE_RATE(h) + (((h[1] >> 3) & 1) + ((h[1] >> 4) & 1))*3)
595#define DRMP3_HDR_IS_FRAME_576(h) ((h[1] & 14) == 2)
596#define DRMP3_HDR_IS_LAYER_1(h) ((h[1] & 6) == 6)
597
598#define DRMP3_BITS_DEQUANTIZER_OUT -1
599#define DRMP3_MAX_SCF (255 + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210)
600#define DRMP3_MAX_SCFI ((DRMP3_MAX_SCF + 3) & ~3)
601
602#define DRMP3_MIN(a, b) ((a) > (b) ? (b) : (a))
603#define DRMP3_MAX(a, b) ((a) < (b) ? (b) : (a))
604
605#if !defined(DR_MP3_NO_SIMD)
606
607#if !defined(DR_MP3_ONLY_SIMD) && (defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64))
608/* x64 always have SSE2, arm64 always have neon, no need for generic code */
609#define DR_MP3_ONLY_SIMD
610#endif
611
612#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && defined(_M_X64)) || ((defined(__i386) || defined(_M_IX86) || defined(__i386__) || defined(__x86_64__)) && ((defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)))
613#if defined(_MSC_VER)
614#include <intrin.h>
615#endif
616#include <emmintrin.h>
617#define DRMP3_HAVE_SSE 1
618#define DRMP3_HAVE_SIMD 1
619#define DRMP3_VSTORE _mm_storeu_ps
620#define DRMP3_VLD _mm_loadu_ps
621#define DRMP3_VSET _mm_set1_ps
622#define DRMP3_VADD _mm_add_ps
623#define DRMP3_VSUB _mm_sub_ps
624#define DRMP3_VMUL _mm_mul_ps
625#define DRMP3_VMAC(a, x, y) _mm_add_ps(a, _mm_mul_ps(x, y))
626#define DRMP3_VMSB(a, x, y) _mm_sub_ps(a, _mm_mul_ps(x, y))
627#define DRMP3_VMUL_S(x, s) _mm_mul_ps(x, _mm_set1_ps(s))
628#define DRMP3_VREV(x) _mm_shuffle_ps(x, x, _MM_SHUFFLE(0, 1, 2, 3))
629typedef __m128 drmp3_f4;
630#if defined(_MSC_VER) || defined(DR_MP3_ONLY_SIMD)
631#define drmp3_cpuid __cpuid
632#else
633static __inline__ __attribute__((always_inline)) void drmp3_cpuid(int CPUInfo[], const int InfoType)
634{
635#if defined(__PIC__)
636 __asm__ __volatile__(
637#if defined(__x86_64__)
638 "push %%rbx\n"
639 "cpuid\n"
640 "xchgl %%ebx, %1\n"
641 "pop %%rbx\n"
642#else
643 "xchgl %%ebx, %1\n"
644 "cpuid\n"
645 "xchgl %%ebx, %1\n"
646#endif
647 : "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
648 : "a" (InfoType));
649#else
650 __asm__ __volatile__(
651 "cpuid"
652 : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
653 : "a" (InfoType));
654#endif
655}
656#endif
657static int drmp3_have_simd(void)
658{
659#ifdef DR_MP3_ONLY_SIMD
660 return 1;
661#else
662 static int g_have_simd;
663 int CPUInfo[4];
664#ifdef MINIMP3_TEST
665 static int g_counter;
666 if (g_counter++ > 100)
667 return 0;
668#endif
669 if (g_have_simd)
670 goto end;
671 drmp3_cpuid(CPUInfo, 0);
672 if (CPUInfo[0] > 0)
673 {
674 drmp3_cpuid(CPUInfo, 1);
675 g_have_simd = (CPUInfo[3] & (1 << 26)) + 1; /* SSE2 */
676 return g_have_simd - 1;
677 }
678
679end:
680 return g_have_simd - 1;
681#endif
682}
683#elif defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)
684#include <arm_neon.h>
685#define DRMP3_HAVE_SSE 0
686#define DRMP3_HAVE_SIMD 1
687#define DRMP3_VSTORE vst1q_f32
688#define DRMP3_VLD vld1q_f32
689#define DRMP3_VSET vmovq_n_f32
690#define DRMP3_VADD vaddq_f32
691#define DRMP3_VSUB vsubq_f32
692#define DRMP3_VMUL vmulq_f32
693#define DRMP3_VMAC(a, x, y) vmlaq_f32(a, x, y)
694#define DRMP3_VMSB(a, x, y) vmlsq_f32(a, x, y)
695#define DRMP3_VMUL_S(x, s) vmulq_f32(x, vmovq_n_f32(s))
696#define DRMP3_VREV(x) vcombine_f32(vget_high_f32(vrev64q_f32(x)), vget_low_f32(vrev64q_f32(x)))
697typedef float32x4_t drmp3_f4;
698static int drmp3_have_simd(void)
699{ /* TODO: detect neon for !DR_MP3_ONLY_SIMD */
700 return 1;
701}
702#else
703#define DRMP3_HAVE_SSE 0
704#define DRMP3_HAVE_SIMD 0
705#ifdef DR_MP3_ONLY_SIMD
706#error DR_MP3_ONLY_SIMD used, but SSE/NEON not enabled
707#endif
708#endif
709
710#else
711
712#define DRMP3_HAVE_SIMD 0
713
714#endif
715
716#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__aarch64__) && !defined(_M_ARM64) && !defined(__ARM_ARCH_6M__)
717#define DRMP3_HAVE_ARMV6 1
718static __inline__ __attribute__((always_inline)) drmp3_int32 drmp3_clip_int16_arm(drmp3_int32 a)
719{
720 drmp3_int32 x = 0;
721 __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
722 return x;
723}
724#else
725#define DRMP3_HAVE_ARMV6 0
726#endif
727
728
729/* Standard library stuff. */
730#ifndef DRMP3_ASSERT
731#include <assert.h>
732#define DRMP3_ASSERT(expression) assert(expression)
733#endif
734#ifndef DRMP3_COPY_MEMORY
735#define DRMP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
736#endif
737#ifndef DRMP3_MOVE_MEMORY
738#define DRMP3_MOVE_MEMORY(dst, src, sz) memmove((dst), (src), (sz))
739#endif
740#ifndef DRMP3_ZERO_MEMORY
741#define DRMP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
742#endif
743#define DRMP3_ZERO_OBJECT(p) DRMP3_ZERO_MEMORY((p), sizeof(*(p)))
744#ifndef DRMP3_MALLOC
745#define DRMP3_MALLOC(sz) malloc((sz))
746#endif
747#ifndef DRMP3_REALLOC
748#define DRMP3_REALLOC(p, sz) realloc((p), (sz))
749#endif
750#ifndef DRMP3_FREE
751#define DRMP3_FREE(p) free((p))
752#endif
753
754typedef struct
755{
756 const drmp3_uint8 *buf;
757 int pos, limit;
758} drmp3_bs;
759
760typedef struct
761{
762 float scf[3*64];
763 drmp3_uint8 total_bands, stereo_bands, bitalloc[64], scfcod[64];
764} drmp3_L12_scale_info;
765
766typedef struct
767{
768 drmp3_uint8 tab_offset, code_tab_width, band_count;
769} drmp3_L12_subband_alloc;
770
771typedef struct
772{
773 const drmp3_uint8 *sfbtab;
774 drmp3_uint16 part_23_length, big_values, scalefac_compress;
775 drmp3_uint8 global_gain, block_type, mixed_block_flag, n_long_sfb, n_short_sfb;
776 drmp3_uint8 table_select[3], region_count[3], subblock_gain[3];
777 drmp3_uint8 preflag, scalefac_scale, count1_table, scfsi;
778} drmp3_L3_gr_info;
779
780typedef struct
781{
782 drmp3_bs bs;
783 drmp3_uint8 maindata[DRMP3_MAX_BITRESERVOIR_BYTES + DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES];
784 drmp3_L3_gr_info gr_info[4];
785 float grbuf[2][576], scf[40], syn[18 + 15][2*32];
786 drmp3_uint8 ist_pos[2][39];
787} drmp3dec_scratch;
788
789static void drmp3_bs_init(drmp3_bs *bs, const drmp3_uint8 *data, int bytes)
790{
791 bs->buf = data;
792 bs->pos = 0;
793 bs->limit = bytes*8;
794}
795
796static drmp3_uint32 drmp3_bs_get_bits(drmp3_bs *bs, int n)
797{
798 drmp3_uint32 next, cache = 0, s = bs->pos & 7;
799 int shl = n + s;
800 const drmp3_uint8 *p = bs->buf + (bs->pos >> 3);
801 if ((bs->pos += n) > bs->limit)
802 return 0;
803 next = *p++ & (255 >> s);
804 while ((shl -= 8) > 0)
805 {
806 cache |= next << shl;
807 next = *p++;
808 }
809 return cache | (next >> -shl);
810}
811
812static int drmp3_hdr_valid(const drmp3_uint8 *h)
813{
814 return h[0] == 0xff &&
815 ((h[1] & 0xF0) == 0xf0 || (h[1] & 0xFE) == 0xe2) &&
816 (DRMP3_HDR_GET_LAYER(h) != 0) &&
817 (DRMP3_HDR_GET_BITRATE(h) != 15) &&
818 (DRMP3_HDR_GET_SAMPLE_RATE(h) != 3);
819}
820
821static int drmp3_hdr_compare(const drmp3_uint8 *h1, const drmp3_uint8 *h2)
822{
823 return drmp3_hdr_valid(h2) &&
824 ((h1[1] ^ h2[1]) & 0xFE) == 0 &&
825 ((h1[2] ^ h2[2]) & 0x0C) == 0 &&
826 !(DRMP3_HDR_IS_FREE_FORMAT(h1) ^ DRMP3_HDR_IS_FREE_FORMAT(h2));
827}
828
829static unsigned drmp3_hdr_bitrate_kbps(const drmp3_uint8 *h)
830{
831 static const drmp3_uint8 halfrate[2][3][15] = {
832 { { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,16,24,28,32,40,48,56,64,72,80,88,96,112,128 } },
833 { { 0,16,20,24,28,32,40,48,56,64,80,96,112,128,160 }, { 0,16,24,28,32,40,48,56,64,80,96,112,128,160,192 }, { 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224 } },
834 };
835 return 2*halfrate[!!DRMP3_HDR_TEST_MPEG1(h)][DRMP3_HDR_GET_LAYER(h) - 1][DRMP3_HDR_GET_BITRATE(h)];
836}
837
838static unsigned drmp3_hdr_sample_rate_hz(const drmp3_uint8 *h)
839{
840 static const unsigned g_hz[3] = { 44100, 48000, 32000 };
841 return g_hz[DRMP3_HDR_GET_SAMPLE_RATE(h)] >> (int)!DRMP3_HDR_TEST_MPEG1(h) >> (int)!DRMP3_HDR_TEST_NOT_MPEG25(h);
842}
843
844static unsigned drmp3_hdr_frame_samples(const drmp3_uint8 *h)
845{
846 return DRMP3_HDR_IS_LAYER_1(h) ? 384 : (1152 >> (int)DRMP3_HDR_IS_FRAME_576(h));
847}
848
849static int drmp3_hdr_frame_bytes(const drmp3_uint8 *h, int free_format_size)
850{
851 int frame_bytes = drmp3_hdr_frame_samples(h)*drmp3_hdr_bitrate_kbps(h)*125/drmp3_hdr_sample_rate_hz(h);
852 if (DRMP3_HDR_IS_LAYER_1(h))
853 {
854 frame_bytes &= ~3; /* slot align */
855 }
856 return frame_bytes ? frame_bytes : free_format_size;
857}
858
859static int drmp3_hdr_padding(const drmp3_uint8 *h)
860{
861 return DRMP3_HDR_TEST_PADDING(h) ? (DRMP3_HDR_IS_LAYER_1(h) ? 4 : 1) : 0;
862}
863
864#ifndef DR_MP3_ONLY_MP3
865static const drmp3_L12_subband_alloc *drmp3_L12_subband_alloc_table(const drmp3_uint8 *hdr, drmp3_L12_scale_info *sci)
866{
867 const drmp3_L12_subband_alloc *alloc;
868 int mode = DRMP3_HDR_GET_STEREO_MODE(hdr);
869 int nbands, stereo_bands = (mode == DRMP3_MODE_MONO) ? 0 : (mode == DRMP3_MODE_JOINT_STEREO) ? (DRMP3_HDR_GET_STEREO_MODE_EXT(hdr) << 2) + 4 : 32;
870
871 if (DRMP3_HDR_IS_LAYER_1(hdr))
872 {
873 static const drmp3_L12_subband_alloc g_alloc_L1[] = { { 76, 4, 32 } };
874 alloc = g_alloc_L1;
875 nbands = 32;
876 } else if (!DRMP3_HDR_TEST_MPEG1(hdr))
877 {
878 static const drmp3_L12_subband_alloc g_alloc_L2M2[] = { { 60, 4, 4 }, { 44, 3, 7 }, { 44, 2, 19 } };
879 alloc = g_alloc_L2M2;
880 nbands = 30;
881 } else
882 {
883 static const drmp3_L12_subband_alloc g_alloc_L2M1[] = { { 0, 4, 3 }, { 16, 4, 8 }, { 32, 3, 12 }, { 40, 2, 7 } };
884 int sample_rate_idx = DRMP3_HDR_GET_SAMPLE_RATE(hdr);
885 unsigned kbps = drmp3_hdr_bitrate_kbps(hdr) >> (int)(mode != DRMP3_MODE_MONO);
886 if (!kbps) /* free-format */
887 {
888 kbps = 192;
889 }
890
891 alloc = g_alloc_L2M1;
892 nbands = 27;
893 if (kbps < 56)
894 {
895 static const drmp3_L12_subband_alloc g_alloc_L2M1_lowrate[] = { { 44, 4, 2 }, { 44, 3, 10 } };
896 alloc = g_alloc_L2M1_lowrate;
897 nbands = sample_rate_idx == 2 ? 12 : 8;
898 } else if (kbps >= 96 && sample_rate_idx != 1)
899 {
900 nbands = 30;
901 }
902 }
903
904 sci->total_bands = (drmp3_uint8)nbands;
905 sci->stereo_bands = (drmp3_uint8)DRMP3_MIN(stereo_bands, nbands);
906
907 return alloc;
908}
909
910static void drmp3_L12_read_scalefactors(drmp3_bs *bs, drmp3_uint8 *pba, drmp3_uint8 *scfcod, int bands, float *scf)
911{
912 static const float g_deq_L12[18*3] = {
913#define DRMP3_DQ(x) 9.53674316e-07f/x, 7.56931807e-07f/x, 6.00777173e-07f/x
914 DRMP3_DQ(3),DRMP3_DQ(7),DRMP3_DQ(15),DRMP3_DQ(31),DRMP3_DQ(63),DRMP3_DQ(127),DRMP3_DQ(255),DRMP3_DQ(511),DRMP3_DQ(1023),DRMP3_DQ(2047),DRMP3_DQ(4095),DRMP3_DQ(8191),DRMP3_DQ(16383),DRMP3_DQ(32767),DRMP3_DQ(65535),DRMP3_DQ(3),DRMP3_DQ(5),DRMP3_DQ(9)
915 };
916 int i, m;
917 for (i = 0; i < bands; i++)
918 {
919 float s = 0;
920 int ba = *pba++;
921 int mask = ba ? 4 + ((19 >> scfcod[i]) & 3) : 0;
922 for (m = 4; m; m >>= 1)
923 {
924 if (mask & m)
925 {
926 int b = drmp3_bs_get_bits(bs, 6);
927 s = g_deq_L12[ba*3 - 6 + b % 3]*(int)(1 << 21 >> b/3);
928 }
929 *scf++ = s;
930 }
931 }
932}
933
934static void drmp3_L12_read_scale_info(const drmp3_uint8 *hdr, drmp3_bs *bs, drmp3_L12_scale_info *sci)
935{
936 static const drmp3_uint8 g_bitalloc_code_tab[] = {
937 0,17, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16,
938 0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,16,
939 0,17,18, 3,19,4,5,16,
940 0,17,18,16,
941 0,17,18,19, 4,5,6, 7,8, 9,10,11,12,13,14,15,
942 0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,14,
943 0, 2, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16
944 };
945 const drmp3_L12_subband_alloc *subband_alloc = drmp3_L12_subband_alloc_table(hdr, sci);
946
947 int i, k = 0, ba_bits = 0;
948 const drmp3_uint8 *ba_code_tab = g_bitalloc_code_tab;
949
950 for (i = 0; i < sci->total_bands; i++)
951 {
952 drmp3_uint8 ba;
953 if (i == k)
954 {
955 k += subband_alloc->band_count;
956 ba_bits = subband_alloc->code_tab_width;
957 ba_code_tab = g_bitalloc_code_tab + subband_alloc->tab_offset;
958 subband_alloc++;
959 }
960 ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
961 sci->bitalloc[2*i] = ba;
962 if (i < sci->stereo_bands)
963 {
964 ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
965 }
966 sci->bitalloc[2*i + 1] = sci->stereo_bands ? ba : 0;
967 }
968
969 for (i = 0; i < 2*sci->total_bands; i++)
970 {
971 sci->scfcod[i] = (drmp3_uint8)(sci->bitalloc[i] ? DRMP3_HDR_IS_LAYER_1(hdr) ? 2 : drmp3_bs_get_bits(bs, 2) : 6);
972 }
973
974 drmp3_L12_read_scalefactors(bs, sci->bitalloc, sci->scfcod, sci->total_bands*2, sci->scf);
975
976 for (i = sci->stereo_bands; i < sci->total_bands; i++)
977 {
978 sci->bitalloc[2*i + 1] = 0;
979 }
980}
981
982static int drmp3_L12_dequantize_granule(float *grbuf, drmp3_bs *bs, drmp3_L12_scale_info *sci, int group_size)
983{
984 int i, j, k, choff = 576;
985 for (j = 0; j < 4; j++)
986 {
987 float *dst = grbuf + group_size*j;
988 for (i = 0; i < 2*sci->total_bands; i++)
989 {
990 int ba = sci->bitalloc[i];
991 if (ba != 0)
992 {
993 if (ba < 17)
994 {
995 int half = (1 << (ba - 1)) - 1;
996 for (k = 0; k < group_size; k++)
997 {
998 dst[k] = (float)((int)drmp3_bs_get_bits(bs, ba) - half);
999 }
1000 } else
1001 {
1002 unsigned mod = (2 << (ba - 17)) + 1; /* 3, 5, 9 */
1003 unsigned code = drmp3_bs_get_bits(bs, mod + 2 - (mod >> 3)); /* 5, 7, 10 */
1004 for (k = 0; k < group_size; k++, code /= mod)
1005 {
1006 dst[k] = (float)((int)(code % mod - mod/2));
1007 }
1008 }
1009 }
1010 dst += choff;
1011 choff = 18 - choff;
1012 }
1013 }
1014 return group_size*4;
1015}
1016
1017static void drmp3_L12_apply_scf_384(drmp3_L12_scale_info *sci, const float *scf, float *dst)
1018{
1019 int i, k;
1020 DRMP3_COPY_MEMORY(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float));
1021 for (i = 0; i < sci->total_bands; i++, dst += 18, scf += 6)
1022 {
1023 for (k = 0; k < 12; k++)
1024 {
1025 dst[k + 0] *= scf[0];
1026 dst[k + 576] *= scf[3];
1027 }
1028 }
1029}
1030#endif
1031
1032static int drmp3_L3_read_side_info(drmp3_bs *bs, drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
1033{
1034 static const drmp3_uint8 g_scf_long[8][23] = {
1035 { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
1036 { 12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2,0 },
1037 { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
1038 { 6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,54,62,70,76,36,0 },
1039 { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
1040 { 4,4,4,4,4,4,6,6,8,8,10,12,16,20,24,28,34,42,50,54,76,158,0 },
1041 { 4,4,4,4,4,4,6,6,6,8,10,12,16,18,22,28,34,40,46,54,54,192,0 },
1042 { 4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102,26,0 }
1043 };
1044 static const drmp3_uint8 g_scf_short[8][40] = {
1045 { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
1046 { 8,8,8,8,8,8,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
1047 { 4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
1048 { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
1049 { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
1050 { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
1051 { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
1052 { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
1053 };
1054 static const drmp3_uint8 g_scf_mixed[8][40] = {
1055 { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
1056 { 12,12,12,4,4,4,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
1057 { 6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
1058 { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
1059 { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
1060 { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
1061 { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
1062 { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
1063 };
1064
1065 unsigned tables, scfsi = 0;
1066 int main_data_begin, part_23_sum = 0;
1067 int gr_count = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
1068 int sr_idx = DRMP3_HDR_GET_MY_SAMPLE_RATE(hdr); sr_idx -= (sr_idx != 0);
1069
1070 if (DRMP3_HDR_TEST_MPEG1(hdr))
1071 {
1072 gr_count *= 2;
1073 main_data_begin = drmp3_bs_get_bits(bs, 9);
1074 scfsi = drmp3_bs_get_bits(bs, 7 + gr_count);
1075 } else
1076 {
1077 main_data_begin = drmp3_bs_get_bits(bs, 8 + gr_count) >> gr_count;
1078 }
1079
1080 do
1081 {
1082 if (DRMP3_HDR_IS_MONO(hdr))
1083 {
1084 scfsi <<= 4;
1085 }
1086 gr->part_23_length = (drmp3_uint16)drmp3_bs_get_bits(bs, 12);
1087 part_23_sum += gr->part_23_length;
1088 gr->big_values = (drmp3_uint16)drmp3_bs_get_bits(bs, 9);
1089 if (gr->big_values > 288)
1090 {
1091 return -1;
1092 }
1093 gr->global_gain = (drmp3_uint8)drmp3_bs_get_bits(bs, 8);
1094 gr->scalefac_compress = (drmp3_uint16)drmp3_bs_get_bits(bs, DRMP3_HDR_TEST_MPEG1(hdr) ? 4 : 9);
1095 gr->sfbtab = g_scf_long[sr_idx];
1096 gr->n_long_sfb = 22;
1097 gr->n_short_sfb = 0;
1098 if (drmp3_bs_get_bits(bs, 1))
1099 {
1100 gr->block_type = (drmp3_uint8)drmp3_bs_get_bits(bs, 2);
1101 if (!gr->block_type)
1102 {
1103 return -1;
1104 }
1105 gr->mixed_block_flag = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
1106 gr->region_count[0] = 7;
1107 gr->region_count[1] = 255;
1108 if (gr->block_type == DRMP3_SHORT_BLOCK_TYPE)
1109 {
1110 scfsi &= 0x0F0F;
1111 if (!gr->mixed_block_flag)
1112 {
1113 gr->region_count[0] = 8;
1114 gr->sfbtab = g_scf_short[sr_idx];
1115 gr->n_long_sfb = 0;
1116 gr->n_short_sfb = 39;
1117 } else
1118 {
1119 gr->sfbtab = g_scf_mixed[sr_idx];
1120 gr->n_long_sfb = DRMP3_HDR_TEST_MPEG1(hdr) ? 8 : 6;
1121 gr->n_short_sfb = 30;
1122 }
1123 }
1124 tables = drmp3_bs_get_bits(bs, 10);
1125 tables <<= 5;
1126 gr->subblock_gain[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
1127 gr->subblock_gain[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
1128 gr->subblock_gain[2] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
1129 } else
1130 {
1131 gr->block_type = 0;
1132 gr->mixed_block_flag = 0;
1133 tables = drmp3_bs_get_bits(bs, 15);
1134 gr->region_count[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 4);
1135 gr->region_count[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
1136 gr->region_count[2] = 255;
1137 }
1138 gr->table_select[0] = (drmp3_uint8)(tables >> 10);
1139 gr->table_select[1] = (drmp3_uint8)((tables >> 5) & 31);
1140 gr->table_select[2] = (drmp3_uint8)((tables) & 31);
1141 gr->preflag = (drmp3_uint8)(DRMP3_HDR_TEST_MPEG1(hdr) ? drmp3_bs_get_bits(bs, 1) : (gr->scalefac_compress >= 500));
1142 gr->scalefac_scale = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
1143 gr->count1_table = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
1144 gr->scfsi = (drmp3_uint8)((scfsi >> 12) & 15);
1145 scfsi <<= 4;
1146 gr++;
1147 } while(--gr_count);
1148
1149 if (part_23_sum + bs->pos > bs->limit + main_data_begin*8)
1150 {
1151 return -1;
1152 }
1153
1154 return main_data_begin;
1155}
1156
1157static void drmp3_L3_read_scalefactors(drmp3_uint8 *scf, drmp3_uint8 *ist_pos, const drmp3_uint8 *scf_size, const drmp3_uint8 *scf_count, drmp3_bs *bitbuf, int scfsi)
1158{
1159 int i, k;
1160 for (i = 0; i < 4 && scf_count[i]; i++, scfsi *= 2)
1161 {
1162 int cnt = scf_count[i];
1163 if (scfsi & 8)
1164 {
1165 DRMP3_COPY_MEMORY(scf, ist_pos, cnt);
1166 } else
1167 {
1168 int bits = scf_size[i];
1169 if (!bits)
1170 {
1171 DRMP3_ZERO_MEMORY(scf, cnt);
1172 DRMP3_ZERO_MEMORY(ist_pos, cnt);
1173 } else
1174 {
1175 int max_scf = (scfsi < 0) ? (1 << bits) - 1 : -1;
1176 for (k = 0; k < cnt; k++)
1177 {
1178 int s = drmp3_bs_get_bits(bitbuf, bits);
1179 ist_pos[k] = (drmp3_uint8)(s == max_scf ? -1 : s);
1180 scf[k] = (drmp3_uint8)s;
1181 }
1182 }
1183 }
1184 ist_pos += cnt;
1185 scf += cnt;
1186 }
1187 scf[0] = scf[1] = scf[2] = 0;
1188}
1189
1190static float drmp3_L3_ldexp_q2(float y, int exp_q2)
1191{
1192 static const float g_expfrac[4] = { 9.31322575e-10f,7.83145814e-10f,6.58544508e-10f,5.53767716e-10f };
1193 int e;
1194 do
1195 {
1196 e = DRMP3_MIN(30*4, exp_q2);
1197 y *= g_expfrac[e & 3]*(1 << 30 >> (e >> 2));
1198 } while ((exp_q2 -= e) > 0);
1199 return y;
1200}
1201
1202static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *ist_pos, drmp3_bs *bs, const drmp3_L3_gr_info *gr, float *scf, int ch)
1203{
1204 static const drmp3_uint8 g_scf_partitions[3][28] = {
1205 { 6,5,5, 5,6,5,5,5,6,5, 7,3,11,10,0,0, 7, 7, 7,0, 6, 6,6,3, 8, 8,5,0 },
1206 { 8,9,6,12,6,9,9,9,6,9,12,6,15,18,0,0, 6,15,12,0, 6,12,9,6, 6,18,9,0 },
1207 { 9,9,6,12,9,9,9,9,9,9,12,6,18,18,0,0,12,12,12,0,12, 9,9,6,15,12,9,0 }
1208 };
1209 const drmp3_uint8 *scf_partition = g_scf_partitions[!!gr->n_short_sfb + !gr->n_long_sfb];
1210 drmp3_uint8 scf_size[4], iscf[40];
1211 int i, scf_shift = gr->scalefac_scale + 1, gain_exp, scfsi = gr->scfsi;
1212 float gain;
1213
1214 if (DRMP3_HDR_TEST_MPEG1(hdr))
1215 {
1216 static const drmp3_uint8 g_scfc_decode[16] = { 0,1,2,3, 12,5,6,7, 9,10,11,13, 14,15,18,19 };
1217 int part = g_scfc_decode[gr->scalefac_compress];
1218 scf_size[1] = scf_size[0] = (drmp3_uint8)(part >> 2);
1219 scf_size[3] = scf_size[2] = (drmp3_uint8)(part & 3);
1220 } else
1221 {
1222 static const drmp3_uint8 g_mod[6*4] = { 5,5,4,4,5,5,4,1,4,3,1,1,5,6,6,1,4,4,4,1,4,3,1,1 };
1223 int k, modprod, sfc, ist = DRMP3_HDR_TEST_I_STEREO(hdr) && ch;
1224 sfc = gr->scalefac_compress >> ist;
1225 for (k = ist*3*4; sfc >= 0; sfc -= modprod, k += 4)
1226 {
1227 for (modprod = 1, i = 3; i >= 0; i--)
1228 {
1229 scf_size[i] = (drmp3_uint8)(sfc / modprod % g_mod[k + i]);
1230 modprod *= g_mod[k + i];
1231 }
1232 }
1233 scf_partition += k;
1234 scfsi = -16;
1235 }
1236 drmp3_L3_read_scalefactors(iscf, ist_pos, scf_size, scf_partition, bs, scfsi);
1237
1238 if (gr->n_short_sfb)
1239 {
1240 int sh = 3 - scf_shift;
1241 for (i = 0; i < gr->n_short_sfb; i += 3)
1242 {
1243 iscf[gr->n_long_sfb + i + 0] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 0] + (gr->subblock_gain[0] << sh));
1244 iscf[gr->n_long_sfb + i + 1] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 1] + (gr->subblock_gain[1] << sh));
1245 iscf[gr->n_long_sfb + i + 2] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 2] + (gr->subblock_gain[2] << sh));
1246 }
1247 } else if (gr->preflag)
1248 {
1249 static const drmp3_uint8 g_preamp[10] = { 1,1,1,1,2,2,3,3,3,2 };
1250 for (i = 0; i < 10; i++)
1251 {
1252 iscf[11 + i] = (drmp3_uint8)(iscf[11 + i] + g_preamp[i]);
1253 }
1254 }
1255
1256 gain_exp = gr->global_gain + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210 - (DRMP3_HDR_IS_MS_STEREO(hdr) ? 2 : 0);
1257 gain = drmp3_L3_ldexp_q2(1 << (DRMP3_MAX_SCFI/4), DRMP3_MAX_SCFI - gain_exp);
1258 for (i = 0; i < (int)(gr->n_long_sfb + gr->n_short_sfb); i++)
1259 {
1260 scf[i] = drmp3_L3_ldexp_q2(gain, iscf[i] << scf_shift);
1261 }
1262}
1263
1264static const float g_drmp3_pow43[129 + 16] = {
1265 0,-1,-2.519842f,-4.326749f,-6.349604f,-8.549880f,-10.902724f,-13.390518f,-16.000000f,-18.720754f,-21.544347f,-24.463781f,-27.473142f,-30.567351f,-33.741992f,-36.993181f,
1266 0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f
1267};
1268
1269static float drmp3_L3_pow_43(int x)
1270{
1271 float frac;
1272 int sign, mult = 256;
1273
1274 if (x < 129)
1275 {
1276 return g_drmp3_pow43[16 + x];
1277 }
1278
1279 if (x < 1024)
1280 {
1281 mult = 16;
1282 x <<= 3;
1283 }
1284
1285 sign = 2*x & 64;
1286 frac = (float)((x & 63) - sign) / ((x & ~63) + sign);
1287 return g_drmp3_pow43[16 + ((x + sign) >> 6)]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult;
1288}
1289
1290static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *gr_info, const float *scf, int layer3gr_limit)
1291{
1292 static const drmp3_int16 tabs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1293 785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,
1294 -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288,
1295 -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288,
1296 -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258,
1297 -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259,
1298 -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258,
1299 -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258,
1300 -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259,
1301 -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258,
1302 -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290,
1303 -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259,
1304 -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258,
1305 -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259,
1306 -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258,
1307 -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 };
1308 static const drmp3_uint8 tab32[] = { 130,162,193,209,44,28,76,140,9,9,9,9,9,9,9,9,190,254,222,238,126,94,157,157,109,61,173,205};
1309 static const drmp3_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 };
1310 static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 };
1311 static const drmp3_uint8 g_linbits[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 };
1312
1313#define DRMP3_PEEK_BITS(n) (bs_cache >> (32 - (n)))
1314#define DRMP3_FLUSH_BITS(n) { bs_cache <<= (n); bs_sh += (n); }
1315#define DRMP3_CHECK_BITS while (bs_sh >= 0) { bs_cache |= (drmp3_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
1316#define DRMP3_BSPOS ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
1317
1318 float one = 0.0f;
1319 int ireg = 0, big_val_cnt = gr_info->big_values;
1320 const drmp3_uint8 *sfb = gr_info->sfbtab;
1321 const drmp3_uint8 *bs_next_ptr = bs->buf + bs->pos/8;
1322 drmp3_uint32 bs_cache = (((bs_next_ptr[0]*256u + bs_next_ptr[1])*256u + bs_next_ptr[2])*256u + bs_next_ptr[3]) << (bs->pos & 7);
1323 int pairs_to_decode, np, bs_sh = (bs->pos & 7) - 8;
1324 bs_next_ptr += 4;
1325
1326 while (big_val_cnt > 0)
1327 {
1328 int tab_num = gr_info->table_select[ireg];
1329 int sfb_cnt = gr_info->region_count[ireg++];
1330 const drmp3_int16 *codebook = tabs + tabindex[tab_num];
1331 int linbits = g_linbits[tab_num];
1332 if (linbits)
1333 {
1334 do
1335 {
1336 np = *sfb++ / 2;
1337 pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
1338 one = *scf++;
1339 do
1340 {
1341 int j, w = 5;
1342 int leaf = codebook[DRMP3_PEEK_BITS(w)];
1343 while (leaf < 0)
1344 {
1345 DRMP3_FLUSH_BITS(w);
1346 w = leaf & 7;
1347 leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
1348 }
1349 DRMP3_FLUSH_BITS(leaf >> 8);
1350
1351 for (j = 0; j < 2; j++, dst++, leaf >>= 4)
1352 {
1353 int lsb = leaf & 0x0F;
1354 if (lsb == 15)
1355 {
1356 lsb += DRMP3_PEEK_BITS(linbits);
1357 DRMP3_FLUSH_BITS(linbits);
1358 DRMP3_CHECK_BITS;
1359 *dst = one*drmp3_L3_pow_43(lsb)*((drmp3_int32)bs_cache < 0 ? -1: 1);
1360 } else
1361 {
1362 *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
1363 }
1364 DRMP3_FLUSH_BITS(lsb ? 1 : 0);
1365 }
1366 DRMP3_CHECK_BITS;
1367 } while (--pairs_to_decode);
1368 } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
1369 } else
1370 {
1371 do
1372 {
1373 np = *sfb++ / 2;
1374 pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
1375 one = *scf++;
1376 do
1377 {
1378 int j, w = 5;
1379 int leaf = codebook[DRMP3_PEEK_BITS(w)];
1380 while (leaf < 0)
1381 {
1382 DRMP3_FLUSH_BITS(w);
1383 w = leaf & 7;
1384 leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
1385 }
1386 DRMP3_FLUSH_BITS(leaf >> 8);
1387
1388 for (j = 0; j < 2; j++, dst++, leaf >>= 4)
1389 {
1390 int lsb = leaf & 0x0F;
1391 *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
1392 DRMP3_FLUSH_BITS(lsb ? 1 : 0);
1393 }
1394 DRMP3_CHECK_BITS;
1395 } while (--pairs_to_decode);
1396 } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
1397 }
1398 }
1399
1400 for (np = 1 - big_val_cnt;; dst += 4)
1401 {
1402 const drmp3_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32;
1403 int leaf = codebook_count1[DRMP3_PEEK_BITS(4)];
1404 if (!(leaf & 8))
1405 {
1406 leaf = codebook_count1[(leaf >> 3) + (bs_cache << 4 >> (32 - (leaf & 3)))];
1407 }
1408 DRMP3_FLUSH_BITS(leaf & 7);
1409 if (DRMP3_BSPOS > layer3gr_limit)
1410 {
1411 break;
1412 }
1413#define DRMP3_RELOAD_SCALEFACTOR if (!--np) { np = *sfb++/2; if (!np) break; one = *scf++; }
1414#define DRMP3_DEQ_COUNT1(s) if (leaf & (128 >> s)) { dst[s] = ((drmp3_int32)bs_cache < 0) ? -one : one; DRMP3_FLUSH_BITS(1) }
1415 DRMP3_RELOAD_SCALEFACTOR;
1416 DRMP3_DEQ_COUNT1(0);
1417 DRMP3_DEQ_COUNT1(1);
1418 DRMP3_RELOAD_SCALEFACTOR;
1419 DRMP3_DEQ_COUNT1(2);
1420 DRMP3_DEQ_COUNT1(3);
1421 DRMP3_CHECK_BITS;
1422 }
1423
1424 bs->pos = layer3gr_limit;
1425}
1426
1427static void drmp3_L3_midside_stereo(float *left, int n)
1428{
1429 int i = 0;
1430 float *right = left + 576;
1431#if DRMP3_HAVE_SIMD
1432 if (drmp3_have_simd())
1433 {
1434 for (; i < n - 3; i += 4)
1435 {
1436 drmp3_f4 vl = DRMP3_VLD(left + i);
1437 drmp3_f4 vr = DRMP3_VLD(right + i);
1438 DRMP3_VSTORE(left + i, DRMP3_VADD(vl, vr));
1439 DRMP3_VSTORE(right + i, DRMP3_VSUB(vl, vr));
1440 }
1441#ifdef __GNUC__
1442 /* Workaround for spurious -Waggressive-loop-optimizations warning from gcc.
1443 * For more info see: https://github.com/lieff/minimp3/issues/88
1444 */
1445 if (__builtin_constant_p(n % 4 == 0) && n % 4 == 0)
1446 return;
1447#endif
1448 }
1449#endif
1450 for (; i < n; i++)
1451 {
1452 float a = left[i];
1453 float b = right[i];
1454 left[i] = a + b;
1455 right[i] = a - b;
1456 }
1457}
1458
1459static void drmp3_L3_intensity_stereo_band(float *left, int n, float kl, float kr)
1460{
1461 int i;
1462 for (i = 0; i < n; i++)
1463 {
1464 left[i + 576] = left[i]*kr;
1465 left[i] = left[i]*kl;
1466 }
1467}
1468
1469static void drmp3_L3_stereo_top_band(const float *right, const drmp3_uint8 *sfb, int nbands, int max_band[3])
1470{
1471 int i, k;
1472
1473 max_band[0] = max_band[1] = max_band[2] = -1;
1474
1475 for (i = 0; i < nbands; i++)
1476 {
1477 for (k = 0; k < sfb[i]; k += 2)
1478 {
1479 if (right[k] != 0 || right[k + 1] != 0)
1480 {
1481 max_band[i % 3] = i;
1482 break;
1483 }
1484 }
1485 right += sfb[i];
1486 }
1487}
1488
1489static void drmp3_L3_stereo_process(float *left, const drmp3_uint8 *ist_pos, const drmp3_uint8 *sfb, const drmp3_uint8 *hdr, int max_band[3], int mpeg2_sh)
1490{
1491 static const float g_pan[7*2] = { 0,1,0.21132487f,0.78867513f,0.36602540f,0.63397460f,0.5f,0.5f,0.63397460f,0.36602540f,0.78867513f,0.21132487f,1,0 };
1492 unsigned i, max_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 7 : 64;
1493
1494 for (i = 0; sfb[i]; i++)
1495 {
1496 unsigned ipos = ist_pos[i];
1497 if ((int)i > max_band[i % 3] && ipos < max_pos)
1498 {
1499 float kl, kr, s = DRMP3_HDR_TEST_MS_STEREO(hdr) ? 1.41421356f : 1;
1500 if (DRMP3_HDR_TEST_MPEG1(hdr))
1501 {
1502 kl = g_pan[2*ipos];
1503 kr = g_pan[2*ipos + 1];
1504 } else
1505 {
1506 kl = 1;
1507 kr = drmp3_L3_ldexp_q2(1, (ipos + 1) >> 1 << mpeg2_sh);
1508 if (ipos & 1)
1509 {
1510 kl = kr;
1511 kr = 1;
1512 }
1513 }
1514 drmp3_L3_intensity_stereo_band(left, sfb[i], kl*s, kr*s);
1515 } else if (DRMP3_HDR_TEST_MS_STEREO(hdr))
1516 {
1517 drmp3_L3_midside_stereo(left, sfb[i]);
1518 }
1519 left += sfb[i];
1520 }
1521}
1522
1523static void drmp3_L3_intensity_stereo(float *left, drmp3_uint8 *ist_pos, const drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
1524{
1525 int max_band[3], n_sfb = gr->n_long_sfb + gr->n_short_sfb;
1526 int i, max_blocks = gr->n_short_sfb ? 3 : 1;
1527
1528 drmp3_L3_stereo_top_band(left + 576, gr->sfbtab, n_sfb, max_band);
1529 if (gr->n_long_sfb)
1530 {
1531 max_band[0] = max_band[1] = max_band[2] = DRMP3_MAX(DRMP3_MAX(max_band[0], max_band[1]), max_band[2]);
1532 }
1533 for (i = 0; i < max_blocks; i++)
1534 {
1535 int default_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 3 : 0;
1536 int itop = n_sfb - max_blocks + i;
1537 int prev = itop - max_blocks;
1538 ist_pos[itop] = (drmp3_uint8)(max_band[i] >= prev ? default_pos : ist_pos[prev]);
1539 }
1540 drmp3_L3_stereo_process(left, ist_pos, gr->sfbtab, hdr, max_band, gr[1].scalefac_compress & 1);
1541}
1542
1543static void drmp3_L3_reorder(float *grbuf, float *scratch, const drmp3_uint8 *sfb)
1544{
1545 int i, len;
1546 float *src = grbuf, *dst = scratch;
1547
1548 for (;0 != (len = *sfb); sfb += 3, src += 2*len)
1549 {
1550 for (i = 0; i < len; i++, src++)
1551 {
1552 *dst++ = src[0*len];
1553 *dst++ = src[1*len];
1554 *dst++ = src[2*len];
1555 }
1556 }
1557 DRMP3_COPY_MEMORY(grbuf, scratch, (dst - scratch)*sizeof(float));
1558}
1559
1560static void drmp3_L3_antialias(float *grbuf, int nbands)
1561{
1562 static const float g_aa[2][8] = {
1563 {0.85749293f,0.88174200f,0.94962865f,0.98331459f,0.99551782f,0.99916056f,0.99989920f,0.99999316f},
1564 {0.51449576f,0.47173197f,0.31337745f,0.18191320f,0.09457419f,0.04096558f,0.01419856f,0.00369997f}
1565 };
1566
1567 for (; nbands > 0; nbands--, grbuf += 18)
1568 {
1569 int i = 0;
1570#if DRMP3_HAVE_SIMD
1571 if (drmp3_have_simd()) for (; i < 8; i += 4)
1572 {
1573 drmp3_f4 vu = DRMP3_VLD(grbuf + 18 + i);
1574 drmp3_f4 vd = DRMP3_VLD(grbuf + 14 - i);
1575 drmp3_f4 vc0 = DRMP3_VLD(g_aa[0] + i);
1576 drmp3_f4 vc1 = DRMP3_VLD(g_aa[1] + i);
1577 vd = DRMP3_VREV(vd);
1578 DRMP3_VSTORE(grbuf + 18 + i, DRMP3_VSUB(DRMP3_VMUL(vu, vc0), DRMP3_VMUL(vd, vc1)));
1579 vd = DRMP3_VADD(DRMP3_VMUL(vu, vc1), DRMP3_VMUL(vd, vc0));
1580 DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vd));
1581 }
1582#endif
1583#ifndef DR_MP3_ONLY_SIMD
1584 for(; i < 8; i++)
1585 {
1586 float u = grbuf[18 + i];
1587 float d = grbuf[17 - i];
1588 grbuf[18 + i] = u*g_aa[0][i] - d*g_aa[1][i];
1589 grbuf[17 - i] = u*g_aa[1][i] + d*g_aa[0][i];
1590 }
1591#endif
1592 }
1593}
1594
1595static void drmp3_L3_dct3_9(float *y)
1596{
1597 float s0, s1, s2, s3, s4, s5, s6, s7, s8, t0, t2, t4;
1598
1599 s0 = y[0]; s2 = y[2]; s4 = y[4]; s6 = y[6]; s8 = y[8];
1600 t0 = s0 + s6*0.5f;
1601 s0 -= s6;
1602 t4 = (s4 + s2)*0.93969262f;
1603 t2 = (s8 + s2)*0.76604444f;
1604 s6 = (s4 - s8)*0.17364818f;
1605 s4 += s8 - s2;
1606
1607 s2 = s0 - s4*0.5f;
1608 y[4] = s4 + s0;
1609 s8 = t0 - t2 + s6;
1610 s0 = t0 - t4 + t2;
1611 s4 = t0 + t4 - s6;
1612
1613 s1 = y[1]; s3 = y[3]; s5 = y[5]; s7 = y[7];
1614
1615 s3 *= 0.86602540f;
1616 t0 = (s5 + s1)*0.98480775f;
1617 t4 = (s5 - s7)*0.34202014f;
1618 t2 = (s1 + s7)*0.64278761f;
1619 s1 = (s1 - s5 - s7)*0.86602540f;
1620
1621 s5 = t0 - s3 - t2;
1622 s7 = t4 - s3 - t0;
1623 s3 = t4 + s3 - t2;
1624
1625 y[0] = s4 - s7;
1626 y[1] = s2 + s1;
1627 y[2] = s0 - s3;
1628 y[3] = s8 + s5;
1629 y[5] = s8 - s5;
1630 y[6] = s0 + s3;
1631 y[7] = s2 - s1;
1632 y[8] = s4 + s7;
1633}
1634
1635static void drmp3_L3_imdct36(float *grbuf, float *overlap, const float *window, int nbands)
1636{
1637 int i, j;
1638 static const float g_twid9[18] = {
1639 0.73727734f,0.79335334f,0.84339145f,0.88701083f,0.92387953f,0.95371695f,0.97629601f,0.99144486f,0.99904822f,0.67559021f,0.60876143f,0.53729961f,0.46174861f,0.38268343f,0.30070580f,0.21643961f,0.13052619f,0.04361938f
1640 };
1641
1642 for (j = 0; j < nbands; j++, grbuf += 18, overlap += 9)
1643 {
1644 float co[9], si[9];
1645 co[0] = -grbuf[0];
1646 si[0] = grbuf[17];
1647 for (i = 0; i < 4; i++)
1648 {
1649 si[8 - 2*i] = grbuf[4*i + 1] - grbuf[4*i + 2];
1650 co[1 + 2*i] = grbuf[4*i + 1] + grbuf[4*i + 2];
1651 si[7 - 2*i] = grbuf[4*i + 4] - grbuf[4*i + 3];
1652 co[2 + 2*i] = -(grbuf[4*i + 3] + grbuf[4*i + 4]);
1653 }
1654 drmp3_L3_dct3_9(co);
1655 drmp3_L3_dct3_9(si);
1656
1657 si[1] = -si[1];
1658 si[3] = -si[3];
1659 si[5] = -si[5];
1660 si[7] = -si[7];
1661
1662 i = 0;
1663
1664#if DRMP3_HAVE_SIMD
1665 if (drmp3_have_simd()) for (; i < 8; i += 4)
1666 {
1667 drmp3_f4 vovl = DRMP3_VLD(overlap + i);
1668 drmp3_f4 vc = DRMP3_VLD(co + i);
1669 drmp3_f4 vs = DRMP3_VLD(si + i);
1670 drmp3_f4 vr0 = DRMP3_VLD(g_twid9 + i);
1671 drmp3_f4 vr1 = DRMP3_VLD(g_twid9 + 9 + i);
1672 drmp3_f4 vw0 = DRMP3_VLD(window + i);
1673 drmp3_f4 vw1 = DRMP3_VLD(window + 9 + i);
1674 drmp3_f4 vsum = DRMP3_VADD(DRMP3_VMUL(vc, vr1), DRMP3_VMUL(vs, vr0));
1675 DRMP3_VSTORE(overlap + i, DRMP3_VSUB(DRMP3_VMUL(vc, vr0), DRMP3_VMUL(vs, vr1)));
1676 DRMP3_VSTORE(grbuf + i, DRMP3_VSUB(DRMP3_VMUL(vovl, vw0), DRMP3_VMUL(vsum, vw1)));
1677 vsum = DRMP3_VADD(DRMP3_VMUL(vovl, vw1), DRMP3_VMUL(vsum, vw0));
1678 DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vsum));
1679 }
1680#endif
1681 for (; i < 9; i++)
1682 {
1683 float ovl = overlap[i];
1684 float sum = co[i]*g_twid9[9 + i] + si[i]*g_twid9[0 + i];
1685 overlap[i] = co[i]*g_twid9[0 + i] - si[i]*g_twid9[9 + i];
1686 grbuf[i] = ovl*window[0 + i] - sum*window[9 + i];
1687 grbuf[17 - i] = ovl*window[9 + i] + sum*window[0 + i];
1688 }
1689 }
1690}
1691
1692static void drmp3_L3_idct3(float x0, float x1, float x2, float *dst)
1693{
1694 float m1 = x1*0.86602540f;
1695 float a1 = x0 - x2*0.5f;
1696 dst[1] = x0 + x2;
1697 dst[0] = a1 + m1;
1698 dst[2] = a1 - m1;
1699}
1700
1701static void drmp3_L3_imdct12(float *x, float *dst, float *overlap)
1702{
1703 static const float g_twid3[6] = { 0.79335334f,0.92387953f,0.99144486f, 0.60876143f,0.38268343f,0.13052619f };
1704 float co[3], si[3];
1705 int i;
1706
1707 drmp3_L3_idct3(-x[0], x[6] + x[3], x[12] + x[9], co);
1708 drmp3_L3_idct3(x[15], x[12] - x[9], x[6] - x[3], si);
1709 si[1] = -si[1];
1710
1711 for (i = 0; i < 3; i++)
1712 {
1713 float ovl = overlap[i];
1714 float sum = co[i]*g_twid3[3 + i] + si[i]*g_twid3[0 + i];
1715 overlap[i] = co[i]*g_twid3[0 + i] - si[i]*g_twid3[3 + i];
1716 dst[i] = ovl*g_twid3[2 - i] - sum*g_twid3[5 - i];
1717 dst[5 - i] = ovl*g_twid3[5 - i] + sum*g_twid3[2 - i];
1718 }
1719}
1720
1721static void drmp3_L3_imdct_short(float *grbuf, float *overlap, int nbands)
1722{
1723 for (;nbands > 0; nbands--, overlap += 9, grbuf += 18)
1724 {
1725 float tmp[18];
1726 DRMP3_COPY_MEMORY(tmp, grbuf, sizeof(tmp));
1727 DRMP3_COPY_MEMORY(grbuf, overlap, 6*sizeof(float));
1728 drmp3_L3_imdct12(tmp, grbuf + 6, overlap + 6);
1729 drmp3_L3_imdct12(tmp + 1, grbuf + 12, overlap + 6);
1730 drmp3_L3_imdct12(tmp + 2, overlap, overlap + 6);
1731 }
1732}
1733
1734static void drmp3_L3_change_sign(float *grbuf)
1735{
1736 int b, i;
1737 for (b = 0, grbuf += 18; b < 32; b += 2, grbuf += 36)
1738 for (i = 1; i < 18; i += 2)
1739 grbuf[i] = -grbuf[i];
1740}
1741
1742static void drmp3_L3_imdct_gr(float *grbuf, float *overlap, unsigned block_type, unsigned n_long_bands)
1743{
1744 static const float g_mdct_window[2][18] = {
1745 { 0.99904822f,0.99144486f,0.97629601f,0.95371695f,0.92387953f,0.88701083f,0.84339145f,0.79335334f,0.73727734f,0.04361938f,0.13052619f,0.21643961f,0.30070580f,0.38268343f,0.46174861f,0.53729961f,0.60876143f,0.67559021f },
1746 { 1,1,1,1,1,1,0.99144486f,0.92387953f,0.79335334f,0,0,0,0,0,0,0.13052619f,0.38268343f,0.60876143f }
1747 };
1748 if (n_long_bands)
1749 {
1750 drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[0], n_long_bands);
1751 grbuf += 18*n_long_bands;
1752 overlap += 9*n_long_bands;
1753 }
1754 if (block_type == DRMP3_SHORT_BLOCK_TYPE)
1755 drmp3_L3_imdct_short(grbuf, overlap, 32 - n_long_bands);
1756 else
1757 drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[block_type == DRMP3_STOP_BLOCK_TYPE], 32 - n_long_bands);
1758}
1759
1760static void drmp3_L3_save_reservoir(drmp3dec *h, drmp3dec_scratch *s)
1761{
1762 int pos = (s->bs.pos + 7)/8u;
1763 int remains = s->bs.limit/8u - pos;
1764 if (remains > DRMP3_MAX_BITRESERVOIR_BYTES)
1765 {
1766 pos += remains - DRMP3_MAX_BITRESERVOIR_BYTES;
1767 remains = DRMP3_MAX_BITRESERVOIR_BYTES;
1768 }
1769 if (remains > 0)
1770 {
1771 DRMP3_MOVE_MEMORY(h->reserv_buf, s->maindata + pos, remains);
1772 }
1773 h->reserv = remains;
1774}
1775
1776static int drmp3_L3_restore_reservoir(drmp3dec *h, drmp3_bs *bs, drmp3dec_scratch *s, int main_data_begin)
1777{
1778 int frame_bytes = (bs->limit - bs->pos)/8;
1779 int bytes_have = DRMP3_MIN(h->reserv, main_data_begin);
1780 DRMP3_COPY_MEMORY(s->maindata, h->reserv_buf + DRMP3_MAX(0, h->reserv - main_data_begin), DRMP3_MIN(h->reserv, main_data_begin));
1781 DRMP3_COPY_MEMORY(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes);
1782 drmp3_bs_init(&s->bs, s->maindata, bytes_have + frame_bytes);
1783 return h->reserv >= main_data_begin;
1784}
1785
1786static void drmp3_L3_decode(drmp3dec *h, drmp3dec_scratch *s, drmp3_L3_gr_info *gr_info, int nch)
1787{
1788 int ch;
1789
1790 for (ch = 0; ch < nch; ch++)
1791 {
1792 int layer3gr_limit = s->bs.pos + gr_info[ch].part_23_length;
1793 drmp3_L3_decode_scalefactors(h->header, s->ist_pos[ch], &s->bs, gr_info + ch, s->scf, ch);
1794 drmp3_L3_huffman(s->grbuf[ch], &s->bs, gr_info + ch, s->scf, layer3gr_limit);
1795 }
1796
1797 if (DRMP3_HDR_TEST_I_STEREO(h->header))
1798 {
1799 drmp3_L3_intensity_stereo(s->grbuf[0], s->ist_pos[1], gr_info, h->header);
1800 } else if (DRMP3_HDR_IS_MS_STEREO(h->header))
1801 {
1802 drmp3_L3_midside_stereo(s->grbuf[0], 576);
1803 }
1804
1805 for (ch = 0; ch < nch; ch++, gr_info++)
1806 {
1807 int aa_bands = 31;
1808 int n_long_bands = (gr_info->mixed_block_flag ? 2 : 0) << (int)(DRMP3_HDR_GET_MY_SAMPLE_RATE(h->header) == 2);
1809
1810 if (gr_info->n_short_sfb)
1811 {
1812 aa_bands = n_long_bands - 1;
1813 drmp3_L3_reorder(s->grbuf[ch] + n_long_bands*18, s->syn[0], gr_info->sfbtab + gr_info->n_long_sfb);
1814 }
1815
1816 drmp3_L3_antialias(s->grbuf[ch], aa_bands);
1817 drmp3_L3_imdct_gr(s->grbuf[ch], h->mdct_overlap[ch], gr_info->block_type, n_long_bands);
1818 drmp3_L3_change_sign(s->grbuf[ch]);
1819 }
1820}
1821
1822static void drmp3d_DCT_II(float *grbuf, int n)
1823{
1824 static const float g_sec[24] = {
1825 10.19000816f,0.50060302f,0.50241929f,3.40760851f,0.50547093f,0.52249861f,2.05778098f,0.51544732f,0.56694406f,1.48416460f,0.53104258f,0.64682180f,1.16943991f,0.55310392f,0.78815460f,0.97256821f,0.58293498f,1.06067765f,0.83934963f,0.62250412f,1.72244716f,0.74453628f,0.67480832f,5.10114861f
1826 };
1827 int i, k = 0;
1828#if DRMP3_HAVE_SIMD
1829 if (drmp3_have_simd()) for (; k < n; k += 4)
1830 {
1831 drmp3_f4 t[4][8], *x;
1832 float *y = grbuf + k;
1833
1834 for (x = t[0], i = 0; i < 8; i++, x++)
1835 {
1836 drmp3_f4 x0 = DRMP3_VLD(&y[i*18]);
1837 drmp3_f4 x1 = DRMP3_VLD(&y[(15 - i)*18]);
1838 drmp3_f4 x2 = DRMP3_VLD(&y[(16 + i)*18]);
1839 drmp3_f4 x3 = DRMP3_VLD(&y[(31 - i)*18]);
1840 drmp3_f4 t0 = DRMP3_VADD(x0, x3);
1841 drmp3_f4 t1 = DRMP3_VADD(x1, x2);
1842 drmp3_f4 t2 = DRMP3_VMUL_S(DRMP3_VSUB(x1, x2), g_sec[3*i + 0]);
1843 drmp3_f4 t3 = DRMP3_VMUL_S(DRMP3_VSUB(x0, x3), g_sec[3*i + 1]);
1844 x[0] = DRMP3_VADD(t0, t1);
1845 x[8] = DRMP3_VMUL_S(DRMP3_VSUB(t0, t1), g_sec[3*i + 2]);
1846 x[16] = DRMP3_VADD(t3, t2);
1847 x[24] = DRMP3_VMUL_S(DRMP3_VSUB(t3, t2), g_sec[3*i + 2]);
1848 }
1849 for (x = t[0], i = 0; i < 4; i++, x += 8)
1850 {
1851 drmp3_f4 x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
1852 xt = DRMP3_VSUB(x0, x7); x0 = DRMP3_VADD(x0, x7);
1853 x7 = DRMP3_VSUB(x1, x6); x1 = DRMP3_VADD(x1, x6);
1854 x6 = DRMP3_VSUB(x2, x5); x2 = DRMP3_VADD(x2, x5);
1855 x5 = DRMP3_VSUB(x3, x4); x3 = DRMP3_VADD(x3, x4);
1856 x4 = DRMP3_VSUB(x0, x3); x0 = DRMP3_VADD(x0, x3);
1857 x3 = DRMP3_VSUB(x1, x2); x1 = DRMP3_VADD(x1, x2);
1858 x[0] = DRMP3_VADD(x0, x1);
1859 x[4] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x1), 0.70710677f);
1860 x5 = DRMP3_VADD(x5, x6);
1861 x6 = DRMP3_VMUL_S(DRMP3_VADD(x6, x7), 0.70710677f);
1862 x7 = DRMP3_VADD(x7, xt);
1863 x3 = DRMP3_VMUL_S(DRMP3_VADD(x3, x4), 0.70710677f);
1864 x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f)); /* rotate by PI/8 */
1865 x7 = DRMP3_VADD(x7, DRMP3_VMUL_S(x5, 0.382683432f));
1866 x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f));
1867 x0 = DRMP3_VSUB(xt, x6); xt = DRMP3_VADD(xt, x6);
1868 x[1] = DRMP3_VMUL_S(DRMP3_VADD(xt, x7), 0.50979561f);
1869 x[2] = DRMP3_VMUL_S(DRMP3_VADD(x4, x3), 0.54119611f);
1870 x[3] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x5), 0.60134488f);
1871 x[5] = DRMP3_VMUL_S(DRMP3_VADD(x0, x5), 0.89997619f);
1872 x[6] = DRMP3_VMUL_S(DRMP3_VSUB(x4, x3), 1.30656302f);
1873 x[7] = DRMP3_VMUL_S(DRMP3_VSUB(xt, x7), 2.56291556f);
1874 }
1875
1876 if (k > n - 3)
1877 {
1878#if DRMP3_HAVE_SSE
1879#define DRMP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v)
1880#else
1881#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[(i)*18], vget_low_f32(v))
1882#endif
1883 for (i = 0; i < 7; i++, y += 4*18)
1884 {
1885 drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
1886 DRMP3_VSAVE2(0, t[0][i]);
1887 DRMP3_VSAVE2(1, DRMP3_VADD(t[2][i], s));
1888 DRMP3_VSAVE2(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
1889 DRMP3_VSAVE2(3, DRMP3_VADD(t[2][1 + i], s));
1890 }
1891 DRMP3_VSAVE2(0, t[0][7]);
1892 DRMP3_VSAVE2(1, DRMP3_VADD(t[2][7], t[3][7]));
1893 DRMP3_VSAVE2(2, t[1][7]);
1894 DRMP3_VSAVE2(3, t[3][7]);
1895 } else
1896 {
1897#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[(i)*18], v)
1898 for (i = 0; i < 7; i++, y += 4*18)
1899 {
1900 drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
1901 DRMP3_VSAVE4(0, t[0][i]);
1902 DRMP3_VSAVE4(1, DRMP3_VADD(t[2][i], s));
1903 DRMP3_VSAVE4(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
1904 DRMP3_VSAVE4(3, DRMP3_VADD(t[2][1 + i], s));
1905 }
1906 DRMP3_VSAVE4(0, t[0][7]);
1907 DRMP3_VSAVE4(1, DRMP3_VADD(t[2][7], t[3][7]));
1908 DRMP3_VSAVE4(2, t[1][7]);
1909 DRMP3_VSAVE4(3, t[3][7]);
1910 }
1911 } else
1912#endif
1913#ifdef DR_MP3_ONLY_SIMD
1914 {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
1915#else
1916 for (; k < n; k++)
1917 {
1918 float t[4][8], *x, *y = grbuf + k;
1919
1920 for (x = t[0], i = 0; i < 8; i++, x++)
1921 {
1922 float x0 = y[i*18];
1923 float x1 = y[(15 - i)*18];
1924 float x2 = y[(16 + i)*18];
1925 float x3 = y[(31 - i)*18];
1926 float t0 = x0 + x3;
1927 float t1 = x1 + x2;
1928 float t2 = (x1 - x2)*g_sec[3*i + 0];
1929 float t3 = (x0 - x3)*g_sec[3*i + 1];
1930 x[0] = t0 + t1;
1931 x[8] = (t0 - t1)*g_sec[3*i + 2];
1932 x[16] = t3 + t2;
1933 x[24] = (t3 - t2)*g_sec[3*i + 2];
1934 }
1935 for (x = t[0], i = 0; i < 4; i++, x += 8)
1936 {
1937 float x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
1938 xt = x0 - x7; x0 += x7;
1939 x7 = x1 - x6; x1 += x6;
1940 x6 = x2 - x5; x2 += x5;
1941 x5 = x3 - x4; x3 += x4;
1942 x4 = x0 - x3; x0 += x3;
1943 x3 = x1 - x2; x1 += x2;
1944 x[0] = x0 + x1;
1945 x[4] = (x0 - x1)*0.70710677f;
1946 x5 = x5 + x6;
1947 x6 = (x6 + x7)*0.70710677f;
1948 x7 = x7 + xt;
1949 x3 = (x3 + x4)*0.70710677f;
1950 x5 -= x7*0.198912367f; /* rotate by PI/8 */
1951 x7 += x5*0.382683432f;
1952 x5 -= x7*0.198912367f;
1953 x0 = xt - x6; xt += x6;
1954 x[1] = (xt + x7)*0.50979561f;
1955 x[2] = (x4 + x3)*0.54119611f;
1956 x[3] = (x0 - x5)*0.60134488f;
1957 x[5] = (x0 + x5)*0.89997619f;
1958 x[6] = (x4 - x3)*1.30656302f;
1959 x[7] = (xt - x7)*2.56291556f;
1960
1961 }
1962 for (i = 0; i < 7; i++, y += 4*18)
1963 {
1964 y[0*18] = t[0][i];
1965 y[1*18] = t[2][i] + t[3][i] + t[3][i + 1];
1966 y[2*18] = t[1][i] + t[1][i + 1];
1967 y[3*18] = t[2][i + 1] + t[3][i] + t[3][i + 1];
1968 }
1969 y[0*18] = t[0][7];
1970 y[1*18] = t[2][7] + t[3][7];
1971 y[2*18] = t[1][7];
1972 y[3*18] = t[3][7];
1973 }
1974#endif
1975}
1976
1977#ifndef DR_MP3_FLOAT_OUTPUT
1978typedef drmp3_int16 drmp3d_sample_t;
1979
1980static drmp3_int16 drmp3d_scale_pcm(float sample)
1981{
1982 drmp3_int16 s;
1983#if DRMP3_HAVE_ARMV6
1984 drmp3_int32 s32 = (drmp3_int32)(sample + .5f);
1985 s32 -= (s32 < 0);
1986 s = (drmp3_int16)drmp3_clip_int16_arm(s32);
1987#else
1988 if (sample >= 32766.5f) return (drmp3_int16) 32767;
1989 if (sample <= -32767.5f) return (drmp3_int16)-32768;
1990 s = (drmp3_int16)(sample + .5f);
1991 s -= (s < 0); /* away from zero, to be compliant */
1992#endif
1993 return s;
1994}
1995#else
1996typedef float drmp3d_sample_t;
1997
1998static float drmp3d_scale_pcm(float sample)
1999{
2000 return sample*(1.f/32768.f);
2001}
2002#endif
2003
2004static void drmp3d_synth_pair(drmp3d_sample_t *pcm, int nch, const float *z)
2005{
2006 float a;
2007 a = (z[14*64] - z[ 0]) * 29;
2008 a += (z[ 1*64] + z[13*64]) * 213;
2009 a += (z[12*64] - z[ 2*64]) * 459;
2010 a += (z[ 3*64] + z[11*64]) * 2037;
2011 a += (z[10*64] - z[ 4*64]) * 5153;
2012 a += (z[ 5*64] + z[ 9*64]) * 6574;
2013 a += (z[ 8*64] - z[ 6*64]) * 37489;
2014 a += z[ 7*64] * 75038;
2015 pcm[0] = drmp3d_scale_pcm(a);
2016
2017 z += 2;
2018 a = z[14*64] * 104;
2019 a += z[12*64] * 1567;
2020 a += z[10*64] * 9727;
2021 a += z[ 8*64] * 64019;
2022 a += z[ 6*64] * -9975;
2023 a += z[ 4*64] * -45;
2024 a += z[ 2*64] * 146;
2025 a += z[ 0*64] * -5;
2026 pcm[16*nch] = drmp3d_scale_pcm(a);
2027}
2028
2029static void drmp3d_synth(float *xl, drmp3d_sample_t *dstl, int nch, float *lins)
2030{
2031 int i;
2032 float *xr = xl + 576*(nch - 1);
2033 drmp3d_sample_t *dstr = dstl + (nch - 1);
2034
2035 static const float g_win[] = {
2036 -1,26,-31,208,218,401,-519,2063,2000,4788,-5517,7134,5959,35640,-39336,74992,
2037 -1,24,-35,202,222,347,-581,2080,1952,4425,-5879,7640,5288,33791,-41176,74856,
2038 -1,21,-38,196,225,294,-645,2087,1893,4063,-6237,8092,4561,31947,-43006,74630,
2039 -1,19,-41,190,227,244,-711,2085,1822,3705,-6589,8492,3776,30112,-44821,74313,
2040 -1,17,-45,183,228,197,-779,2075,1739,3351,-6935,8840,2935,28289,-46617,73908,
2041 -1,16,-49,176,228,153,-848,2057,1644,3004,-7271,9139,2037,26482,-48390,73415,
2042 -2,14,-53,169,227,111,-919,2032,1535,2663,-7597,9389,1082,24694,-50137,72835,
2043 -2,13,-58,161,224,72,-991,2001,1414,2330,-7910,9592,70,22929,-51853,72169,
2044 -2,11,-63,154,221,36,-1064,1962,1280,2006,-8209,9750,-998,21189,-53534,71420,
2045 -2,10,-68,147,215,2,-1137,1919,1131,1692,-8491,9863,-2122,19478,-55178,70590,
2046 -3,9,-73,139,208,-29,-1210,1870,970,1388,-8755,9935,-3300,17799,-56778,69679,
2047 -3,8,-79,132,200,-57,-1283,1817,794,1095,-8998,9966,-4533,16155,-58333,68692,
2048 -4,7,-85,125,189,-83,-1356,1759,605,814,-9219,9959,-5818,14548,-59838,67629,
2049 -4,7,-91,117,177,-106,-1428,1698,402,545,-9416,9916,-7154,12980,-61289,66494,
2050 -5,6,-97,111,163,-127,-1498,1634,185,288,-9585,9838,-8540,11455,-62684,65290
2051 };
2052 float *zlin = lins + 15*64;
2053 const float *w = g_win;
2054
2055 zlin[4*15] = xl[18*16];
2056 zlin[4*15 + 1] = xr[18*16];
2057 zlin[4*15 + 2] = xl[0];
2058 zlin[4*15 + 3] = xr[0];
2059
2060 zlin[4*31] = xl[1 + 18*16];
2061 zlin[4*31 + 1] = xr[1 + 18*16];
2062 zlin[4*31 + 2] = xl[1];
2063 zlin[4*31 + 3] = xr[1];
2064
2065 drmp3d_synth_pair(dstr, nch, lins + 4*15 + 1);
2066 drmp3d_synth_pair(dstr + 32*nch, nch, lins + 4*15 + 64 + 1);
2067 drmp3d_synth_pair(dstl, nch, lins + 4*15);
2068 drmp3d_synth_pair(dstl + 32*nch, nch, lins + 4*15 + 64);
2069
2070#if DRMP3_HAVE_SIMD
2071 if (drmp3_have_simd()) for (i = 14; i >= 0; i--)
2072 {
2073#define DRMP3_VLOAD(k) drmp3_f4 w0 = DRMP3_VSET(*w++); drmp3_f4 w1 = DRMP3_VSET(*w++); drmp3_f4 vz = DRMP3_VLD(&zlin[4*i - 64*k]); drmp3_f4 vy = DRMP3_VLD(&zlin[4*i - 64*(15 - k)]);
2074#define DRMP3_V0(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0)) ; a = DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1)); }
2075#define DRMP3_V1(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1))); }
2076#define DRMP3_V2(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vy, w1), DRMP3_VMUL(vz, w0))); }
2077 drmp3_f4 a, b;
2078 zlin[4*i] = xl[18*(31 - i)];
2079 zlin[4*i + 1] = xr[18*(31 - i)];
2080 zlin[4*i + 2] = xl[1 + 18*(31 - i)];
2081 zlin[4*i + 3] = xr[1 + 18*(31 - i)];
2082 zlin[4*i + 64] = xl[1 + 18*(1 + i)];
2083 zlin[4*i + 64 + 1] = xr[1 + 18*(1 + i)];
2084 zlin[4*i - 64 + 2] = xl[18*(1 + i)];
2085 zlin[4*i - 64 + 3] = xr[18*(1 + i)];
2086
2087 DRMP3_V0(0) DRMP3_V2(1) DRMP3_V1(2) DRMP3_V2(3) DRMP3_V1(4) DRMP3_V2(5) DRMP3_V1(6) DRMP3_V2(7)
2088
2089 {
2090#ifndef DR_MP3_FLOAT_OUTPUT
2091#if DRMP3_HAVE_SSE
2092 static const drmp3_f4 g_max = { 32767.0f, 32767.0f, 32767.0f, 32767.0f };
2093 static const drmp3_f4 g_min = { -32768.0f, -32768.0f, -32768.0f, -32768.0f };
2094 __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, g_max), g_min)),
2095 _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, g_max), g_min)));
2096 dstr[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
2097 dstr[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
2098 dstl[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
2099 dstl[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
2100 dstr[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
2101 dstr[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
2102 dstl[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
2103 dstl[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
2104#else
2105 int16x4_t pcma, pcmb;
2106 a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
2107 b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
2108 pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
2109 pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
2110 vst1_lane_s16(dstr + (15 - i)*nch, pcma, 1);
2111 vst1_lane_s16(dstr + (17 + i)*nch, pcmb, 1);
2112 vst1_lane_s16(dstl + (15 - i)*nch, pcma, 0);
2113 vst1_lane_s16(dstl + (17 + i)*nch, pcmb, 0);
2114 vst1_lane_s16(dstr + (47 - i)*nch, pcma, 3);
2115 vst1_lane_s16(dstr + (49 + i)*nch, pcmb, 3);
2116 vst1_lane_s16(dstl + (47 - i)*nch, pcma, 2);
2117 vst1_lane_s16(dstl + (49 + i)*nch, pcmb, 2);
2118#endif
2119#else
2120 #if DRMP3_HAVE_SSE
2121 static const drmp3_f4 g_scale = { 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f };
2122 #else
2123 const drmp3_f4 g_scale = vdupq_n_f32(1.0f/32768.0f);
2124 #endif
2125 a = DRMP3_VMUL(a, g_scale);
2126 b = DRMP3_VMUL(b, g_scale);
2127#if DRMP3_HAVE_SSE
2128 _mm_store_ss(dstr + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(1, 1, 1, 1)));
2129 _mm_store_ss(dstr + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(1, 1, 1, 1)));
2130 _mm_store_ss(dstl + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(0, 0, 0, 0)));
2131 _mm_store_ss(dstl + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(0, 0, 0, 0)));
2132 _mm_store_ss(dstr + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 3, 3, 3)));
2133 _mm_store_ss(dstr + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 3, 3, 3)));
2134 _mm_store_ss(dstl + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 2, 2, 2)));
2135 _mm_store_ss(dstl + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 2, 2, 2)));
2136#else
2137 vst1q_lane_f32(dstr + (15 - i)*nch, a, 1);
2138 vst1q_lane_f32(dstr + (17 + i)*nch, b, 1);
2139 vst1q_lane_f32(dstl + (15 - i)*nch, a, 0);
2140 vst1q_lane_f32(dstl + (17 + i)*nch, b, 0);
2141 vst1q_lane_f32(dstr + (47 - i)*nch, a, 3);
2142 vst1q_lane_f32(dstr + (49 + i)*nch, b, 3);
2143 vst1q_lane_f32(dstl + (47 - i)*nch, a, 2);
2144 vst1q_lane_f32(dstl + (49 + i)*nch, b, 2);
2145#endif
2146#endif /* DR_MP3_FLOAT_OUTPUT */
2147 }
2148 } else
2149#endif
2150#ifdef DR_MP3_ONLY_SIMD
2151 {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
2152#else
2153 for (i = 14; i >= 0; i--)
2154 {
2155#define DRMP3_LOAD(k) float w0 = *w++; float w1 = *w++; float *vz = &zlin[4*i - k*64]; float *vy = &zlin[4*i - (15 - k)*64];
2156#define DRMP3_S0(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] = vz[j]*w1 + vy[j]*w0, a[j] = vz[j]*w0 - vy[j]*w1; }
2157#define DRMP3_S1(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vz[j]*w0 - vy[j]*w1; }
2158#define DRMP3_S2(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vy[j]*w1 - vz[j]*w0; }
2159 float a[4], b[4];
2160
2161 zlin[4*i] = xl[18*(31 - i)];
2162 zlin[4*i + 1] = xr[18*(31 - i)];
2163 zlin[4*i + 2] = xl[1 + 18*(31 - i)];
2164 zlin[4*i + 3] = xr[1 + 18*(31 - i)];
2165 zlin[4*(i + 16)] = xl[1 + 18*(1 + i)];
2166 zlin[4*(i + 16) + 1] = xr[1 + 18*(1 + i)];
2167 zlin[4*(i - 16) + 2] = xl[18*(1 + i)];
2168 zlin[4*(i - 16) + 3] = xr[18*(1 + i)];
2169
2170 DRMP3_S0(0) DRMP3_S2(1) DRMP3_S1(2) DRMP3_S2(3) DRMP3_S1(4) DRMP3_S2(5) DRMP3_S1(6) DRMP3_S2(7)
2171
2172 dstr[(15 - i)*nch] = drmp3d_scale_pcm(a[1]);
2173 dstr[(17 + i)*nch] = drmp3d_scale_pcm(b[1]);
2174 dstl[(15 - i)*nch] = drmp3d_scale_pcm(a[0]);
2175 dstl[(17 + i)*nch] = drmp3d_scale_pcm(b[0]);
2176 dstr[(47 - i)*nch] = drmp3d_scale_pcm(a[3]);
2177 dstr[(49 + i)*nch] = drmp3d_scale_pcm(b[3]);
2178 dstl[(47 - i)*nch] = drmp3d_scale_pcm(a[2]);
2179 dstl[(49 + i)*nch] = drmp3d_scale_pcm(b[2]);
2180 }
2181#endif
2182}
2183
2184static void drmp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int nch, drmp3d_sample_t *pcm, float *lins)
2185{
2186 int i;
2187 for (i = 0; i < nch; i++)
2188 {
2189 drmp3d_DCT_II(grbuf + 576*i, nbands);
2190 }
2191
2192 DRMP3_COPY_MEMORY(lins, qmf_state, sizeof(float)*15*64);
2193
2194 for (i = 0; i < nbands; i += 2)
2195 {
2196 drmp3d_synth(grbuf + i, pcm + 32*nch*i, nch, lins + i*64);
2197 }
2198#ifndef DR_MP3_NONSTANDARD_BUT_LOGICAL
2199 if (nch == 1)
2200 {
2201 for (i = 0; i < 15*64; i += 2)
2202 {
2203 qmf_state[i] = lins[nbands*64 + i];
2204 }
2205 } else
2206#endif
2207 {
2208 DRMP3_COPY_MEMORY(qmf_state, lins + nbands*64, sizeof(float)*15*64);
2209 }
2210}
2211
2212static int drmp3d_match_frame(const drmp3_uint8 *hdr, int mp3_bytes, int frame_bytes)
2213{
2214 int i, nmatch;
2215 for (i = 0, nmatch = 0; nmatch < DRMP3_MAX_FRAME_SYNC_MATCHES; nmatch++)
2216 {
2217 i += drmp3_hdr_frame_bytes(hdr + i, frame_bytes) + drmp3_hdr_padding(hdr + i);
2218 if (i + DRMP3_HDR_SIZE > mp3_bytes)
2219 return nmatch > 0;
2220 if (!drmp3_hdr_compare(hdr, hdr + i))
2221 return 0;
2222 }
2223 return 1;
2224}
2225
2226static int drmp3d_find_frame(const drmp3_uint8 *mp3, int mp3_bytes, int *free_format_bytes, int *ptr_frame_bytes)
2227{
2228 int i, k;
2229 for (i = 0; i < mp3_bytes - DRMP3_HDR_SIZE; i++, mp3++)
2230 {
2231 if (drmp3_hdr_valid(mp3))
2232 {
2233 int frame_bytes = drmp3_hdr_frame_bytes(mp3, *free_format_bytes);
2234 int frame_and_padding = frame_bytes + drmp3_hdr_padding(mp3);
2235
2236 for (k = DRMP3_HDR_SIZE; !frame_bytes && k < DRMP3_MAX_FREE_FORMAT_FRAME_SIZE && i + 2*k < mp3_bytes - DRMP3_HDR_SIZE; k++)
2237 {
2238 if (drmp3_hdr_compare(mp3, mp3 + k))
2239 {
2240 int fb = k - drmp3_hdr_padding(mp3);
2241 int nextfb = fb + drmp3_hdr_padding(mp3 + k);
2242 if (i + k + nextfb + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + k + nextfb))
2243 continue;
2244 frame_and_padding = k;
2245 frame_bytes = fb;
2246 *free_format_bytes = fb;
2247 }
2248 }
2249
2250 if ((frame_bytes && i + frame_and_padding <= mp3_bytes &&
2251 drmp3d_match_frame(mp3, mp3_bytes - i, frame_bytes)) ||
2252 (!i && frame_and_padding == mp3_bytes))
2253 {
2254 *ptr_frame_bytes = frame_and_padding;
2255 return i;
2256 }
2257 *free_format_bytes = 0;
2258 }
2259 }
2260 *ptr_frame_bytes = 0;
2261 return mp3_bytes;
2262}
2263
2264DRMP3_API void drmp3dec_init(drmp3dec *dec)
2265{
2266 dec->header[0] = 0;
2267}
2268
2269DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info)
2270{
2271 int i = 0, igr, frame_size = 0, success = 1;
2272 const drmp3_uint8 *hdr;
2273 drmp3_bs bs_frame[1];
2274 drmp3dec_scratch scratch;
2275
2276 if (mp3_bytes > 4 && dec->header[0] == 0xff && drmp3_hdr_compare(dec->header, mp3))
2277 {
2278 frame_size = drmp3_hdr_frame_bytes(mp3, dec->free_format_bytes) + drmp3_hdr_padding(mp3);
2279 if (frame_size != mp3_bytes && (frame_size + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + frame_size)))
2280 {
2281 frame_size = 0;
2282 }
2283 }
2284 if (!frame_size)
2285 {
2286 DRMP3_ZERO_MEMORY(dec, sizeof(drmp3dec));
2287 i = drmp3d_find_frame(mp3, mp3_bytes, &dec->free_format_bytes, &frame_size);
2288 if (!frame_size || i + frame_size > mp3_bytes)
2289 {
2290 info->frame_bytes = i;
2291 return 0;
2292 }
2293 }
2294
2295 hdr = mp3 + i;
2296 DRMP3_COPY_MEMORY(dec->header, hdr, DRMP3_HDR_SIZE);
2297 info->frame_bytes = i + frame_size;
2298 info->channels = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
2299 info->hz = drmp3_hdr_sample_rate_hz(hdr);
2300 info->layer = 4 - DRMP3_HDR_GET_LAYER(hdr);
2301 info->bitrate_kbps = drmp3_hdr_bitrate_kbps(hdr);
2302
2303 drmp3_bs_init(bs_frame, hdr + DRMP3_HDR_SIZE, frame_size - DRMP3_HDR_SIZE);
2304 if (DRMP3_HDR_IS_CRC(hdr))
2305 {
2306 drmp3_bs_get_bits(bs_frame, 16);
2307 }
2308
2309 if (info->layer == 3)
2310 {
2311 int main_data_begin = drmp3_L3_read_side_info(bs_frame, scratch.gr_info, hdr);
2312 if (main_data_begin < 0 || bs_frame->pos > bs_frame->limit)
2313 {
2314 drmp3dec_init(dec);
2315 return 0;
2316 }
2317 success = drmp3_L3_restore_reservoir(dec, bs_frame, &scratch, main_data_begin);
2318 if (success && pcm != NULL)
2319 {
2320 for (igr = 0; igr < (DRMP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*576*info->channels))
2321 {
2322 DRMP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float));
2323 drmp3_L3_decode(dec, &scratch, scratch.gr_info + igr*info->channels, info->channels);
2324 drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 18, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
2325 }
2326 }
2327 drmp3_L3_save_reservoir(dec, &scratch);
2328 } else
2329 {
2330#ifdef DR_MP3_ONLY_MP3
2331 return 0;
2332#else
2333 drmp3_L12_scale_info sci[1];
2334
2335 if (pcm == NULL) {
2336 return drmp3_hdr_frame_samples(hdr);
2337 }
2338
2339 drmp3_L12_read_scale_info(hdr, bs_frame, sci);
2340
2341 DRMP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float));
2342 for (i = 0, igr = 0; igr < 3; igr++)
2343 {
2344 if (12 == (i += drmp3_L12_dequantize_granule(scratch.grbuf[0] + i, bs_frame, sci, info->layer | 1)))
2345 {
2346 i = 0;
2347 drmp3_L12_apply_scf_384(sci, sci->scf + igr, scratch.grbuf[0]);
2348 drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 12, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
2349 DRMP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float));
2350 pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*384*info->channels);
2351 }
2352 if (bs_frame->pos > bs_frame->limit)
2353 {
2354 drmp3dec_init(dec);
2355 return 0;
2356 }
2357 }
2358#endif
2359 }
2360
2361 return success*drmp3_hdr_frame_samples(dec->header);
2362}
2363
2364DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples)
2365{
2366 size_t i = 0;
2367#if DRMP3_HAVE_SIMD
2368 size_t aligned_count = num_samples & ~7;
2369 for(; i < aligned_count; i+=8)
2370 {
2371 drmp3_f4 scale = DRMP3_VSET(32768.0f);
2372 drmp3_f4 a = DRMP3_VMUL(DRMP3_VLD(&in[i ]), scale);
2373 drmp3_f4 b = DRMP3_VMUL(DRMP3_VLD(&in[i+4]), scale);
2374#if DRMP3_HAVE_SSE
2375 drmp3_f4 s16max = DRMP3_VSET( 32767.0f);
2376 drmp3_f4 s16min = DRMP3_VSET(-32768.0f);
2377 __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, s16max), s16min)),
2378 _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, s16max), s16min)));
2379 out[i ] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
2380 out[i+1] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
2381 out[i+2] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
2382 out[i+3] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
2383 out[i+4] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
2384 out[i+5] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
2385 out[i+6] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
2386 out[i+7] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
2387#else
2388 int16x4_t pcma, pcmb;
2389 a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
2390 b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
2391 pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
2392 pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
2393 vst1_lane_s16(out+i , pcma, 0);
2394 vst1_lane_s16(out+i+1, pcma, 1);
2395 vst1_lane_s16(out+i+2, pcma, 2);
2396 vst1_lane_s16(out+i+3, pcma, 3);
2397 vst1_lane_s16(out+i+4, pcmb, 0);
2398 vst1_lane_s16(out+i+5, pcmb, 1);
2399 vst1_lane_s16(out+i+6, pcmb, 2);
2400 vst1_lane_s16(out+i+7, pcmb, 3);
2401#endif
2402 }
2403#endif
2404 for(; i < num_samples; i++)
2405 {
2406 float sample = in[i] * 32768.0f;
2407 if (sample >= 32766.5f)
2408 out[i] = (drmp3_int16) 32767;
2409 else if (sample <= -32767.5f)
2410 out[i] = (drmp3_int16)-32768;
2411 else
2412 {
2413 short s = (drmp3_int16)(sample + .5f);
2414 s -= (s < 0); /* away from zero, to be compliant */
2415 out[i] = s;
2416 }
2417 }
2418}
2419
2420
2421
2422/************************************************************************************************************************************************************
2423
2424 Main Public API
2425
2426 ************************************************************************************************************************************************************/
2427/* SIZE_MAX */
2428#if defined(SIZE_MAX)
2429 #define DRMP3_SIZE_MAX SIZE_MAX
2430#else
2431 #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
2432 #define DRMP3_SIZE_MAX ((drmp3_uint64)0xFFFFFFFFFFFFFFFF)
2433 #else
2434 #define DRMP3_SIZE_MAX 0xFFFFFFFF
2435 #endif
2436#endif
2437/* End SIZE_MAX */
2438
2439/* Options. */
2440#ifndef DRMP3_SEEK_LEADING_MP3_FRAMES
2441#define DRMP3_SEEK_LEADING_MP3_FRAMES 2
2442#endif
2443
2444#define DRMP3_MIN_DATA_CHUNK_SIZE 16384
2445
2446/* The size in bytes of each chunk of data to read from the MP3 stream. minimp3 recommends at least 16K, but in an attempt to reduce data movement I'm making this slightly larger. */
2447#ifndef DRMP3_DATA_CHUNK_SIZE
2448#define DRMP3_DATA_CHUNK_SIZE (DRMP3_MIN_DATA_CHUNK_SIZE*4)
2449#endif
2450
2451
2452#define DRMP3_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
2453#define DRMP3_CLAMP(x, lo, hi) (DRMP3_MAX(lo, DRMP3_MIN(x, hi)))
2454
2455#ifndef DRMP3_PI_D
2456#define DRMP3_PI_D 3.14159265358979323846264
2457#endif
2458
2459#define DRMP3_DEFAULT_RESAMPLER_LPF_ORDER 2
2460
2461static DRMP3_INLINE float drmp3_mix_f32(float x, float y, float a)
2462{
2463 return x*(1-a) + y*a;
2464}
2465static DRMP3_INLINE float drmp3_mix_f32_fast(float x, float y, float a)
2466{
2467 float r0 = (y - x);
2468 float r1 = r0*a;
2469 return x + r1;
2470 /*return x + (y - x)*a;*/
2471}
2472
2473
2474/*
2475Greatest common factor using Euclid's algorithm iteratively.
2476*/
2477static DRMP3_INLINE drmp3_uint32 drmp3_gcf_u32(drmp3_uint32 a, drmp3_uint32 b)
2478{
2479 for (;;) {
2480 if (b == 0) {
2481 break;
2482 } else {
2483 drmp3_uint32 t = a;
2484 a = b;
2485 b = t % a;
2486 }
2487 }
2488
2489 return a;
2490}
2491
2492
2493static void* drmp3__malloc_default(size_t sz, void* pUserData)
2494{
2495 (void)pUserData;
2496 return DRMP3_MALLOC(sz);
2497}
2498
2499static void* drmp3__realloc_default(void* p, size_t sz, void* pUserData)
2500{
2501 (void)pUserData;
2502 return DRMP3_REALLOC(p, sz);
2503}
2504
2505static void drmp3__free_default(void* p, void* pUserData)
2506{
2507 (void)pUserData;
2508 DRMP3_FREE(p);
2509}
2510
2511
2512static void* drmp3__malloc_from_callbacks(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
2513{
2514 if (pAllocationCallbacks == NULL) {
2515 return NULL;
2516 }
2517
2518 if (pAllocationCallbacks->onMalloc != NULL) {
2519 return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
2520 }
2521
2522 /* Try using realloc(). */
2523 if (pAllocationCallbacks->onRealloc != NULL) {
2524 return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
2525 }
2526
2527 return NULL;
2528}
2529
2530static void* drmp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drmp3_allocation_callbacks* pAllocationCallbacks)
2531{
2532 if (pAllocationCallbacks == NULL) {
2533 return NULL;
2534 }
2535
2536 if (pAllocationCallbacks->onRealloc != NULL) {
2537 return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
2538 }
2539
2540 /* Try emulating realloc() in terms of malloc()/free(). */
2541 if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
2542 void* p2;
2543
2544 p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
2545 if (p2 == NULL) {
2546 return NULL;
2547 }
2548
2549 if (p != NULL) {
2550 DRMP3_COPY_MEMORY(p2, p, szOld);
2551 pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
2552 }
2553
2554 return p2;
2555 }
2556
2557 return NULL;
2558}
2559
2560static void drmp3__free_from_callbacks(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
2561{
2562 if (p == NULL || pAllocationCallbacks == NULL) {
2563 return;
2564 }
2565
2566 if (pAllocationCallbacks->onFree != NULL) {
2567 pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
2568 }
2569}
2570
2571
2572static drmp3_allocation_callbacks drmp3_copy_allocation_callbacks_or_defaults(const drmp3_allocation_callbacks* pAllocationCallbacks)
2573{
2574 if (pAllocationCallbacks != NULL) {
2575 /* Copy. */
2576 return *pAllocationCallbacks;
2577 } else {
2578 /* Defaults. */
2579 drmp3_allocation_callbacks allocationCallbacks;
2580 allocationCallbacks.pUserData = NULL;
2581 allocationCallbacks.onMalloc = drmp3__malloc_default;
2582 allocationCallbacks.onRealloc = drmp3__realloc_default;
2583 allocationCallbacks.onFree = drmp3__free_default;
2584 return allocationCallbacks;
2585 }
2586}
2587
2588
2589
2590static size_t drmp3__on_read(drmp3* pMP3, void* pBufferOut, size_t bytesToRead)
2591{
2592 size_t bytesRead = pMP3->onRead(pMP3->pUserData, pBufferOut, bytesToRead);
2593 pMP3->streamCursor += bytesRead;
2594 return bytesRead;
2595}
2596
2597static drmp3_bool32 drmp3__on_seek(drmp3* pMP3, int offset, drmp3_seek_origin origin)
2598{
2599 DRMP3_ASSERT(offset >= 0);
2600
2601 if (!pMP3->onSeek(pMP3->pUserData, offset, origin)) {
2602 return DRMP3_FALSE;
2603 }
2604
2605 if (origin == drmp3_seek_origin_start) {
2606 pMP3->streamCursor = (drmp3_uint64)offset;
2607 } else {
2608 pMP3->streamCursor += offset;
2609 }
2610
2611 return DRMP3_TRUE;
2612}
2613
2614static drmp3_bool32 drmp3__on_seek_64(drmp3* pMP3, drmp3_uint64 offset, drmp3_seek_origin origin)
2615{
2616 if (offset <= 0x7FFFFFFF) {
2617 return drmp3__on_seek(pMP3, (int)offset, origin);
2618 }
2619
2620
2621 /* Getting here "offset" is too large for a 32-bit integer. We just keep seeking forward until we hit the offset. */
2622 if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_start)) {
2623 return DRMP3_FALSE;
2624 }
2625
2626 offset -= 0x7FFFFFFF;
2627 while (offset > 0) {
2628 if (offset <= 0x7FFFFFFF) {
2629 if (!drmp3__on_seek(pMP3, (int)offset, drmp3_seek_origin_current)) {
2630 return DRMP3_FALSE;
2631 }
2632 offset = 0;
2633 } else {
2634 if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_current)) {
2635 return DRMP3_FALSE;
2636 }
2637 offset -= 0x7FFFFFFF;
2638 }
2639 }
2640
2641 return DRMP3_TRUE;
2642}
2643
2644
2645static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
2646{
2647 drmp3_uint32 pcmFramesRead = 0;
2648
2649 DRMP3_ASSERT(pMP3 != NULL);
2650 DRMP3_ASSERT(pMP3->onRead != NULL);
2651
2652 if (pMP3->atEnd) {
2653 return 0;
2654 }
2655
2656 for (;;) {
2657 drmp3dec_frame_info info;
2658
2659 /* minimp3 recommends doing data submission in chunks of at least 16K. If we don't have at least 16K bytes available, get more. */
2660 if (pMP3->dataSize < DRMP3_MIN_DATA_CHUNK_SIZE) {
2661 size_t bytesRead;
2662
2663 /* First we need to move the data down. */
2664 if (pMP3->pData != NULL) {
2665 DRMP3_MOVE_MEMORY(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
2666 }
2667
2668 pMP3->dataConsumed = 0;
2669
2670 if (pMP3->dataCapacity < DRMP3_DATA_CHUNK_SIZE) {
2671 drmp3_uint8* pNewData;
2672 size_t newDataCap;
2673
2674 newDataCap = DRMP3_DATA_CHUNK_SIZE;
2675
2676 pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
2677 if (pNewData == NULL) {
2678 return 0; /* Out of memory. */
2679 }
2680
2681 pMP3->pData = pNewData;
2682 pMP3->dataCapacity = newDataCap;
2683 }
2684
2685 bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
2686 if (bytesRead == 0) {
2687 if (pMP3->dataSize == 0) {
2688 pMP3->atEnd = DRMP3_TRUE;
2689 return 0; /* No data. */
2690 }
2691 }
2692
2693 pMP3->dataSize += bytesRead;
2694 }
2695
2696 if (pMP3->dataSize > INT_MAX) {
2697 pMP3->atEnd = DRMP3_TRUE;
2698 return 0; /* File too big. */
2699 }
2700
2701 DRMP3_ASSERT(pMP3->pData != NULL);
2702 DRMP3_ASSERT(pMP3->dataCapacity > 0);
2703
2704 /* Do a runtime check here to try silencing a false-positive from clang-analyzer. */
2705 if (pMP3->pData == NULL) {
2706 return 0;
2707 }
2708
2709 pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info); /* <-- Safe size_t -> int conversion thanks to the check above. */
2710
2711 /* Consume the data. */
2712 if (info.frame_bytes > 0) {
2713 pMP3->dataConsumed += (size_t)info.frame_bytes;
2714 pMP3->dataSize -= (size_t)info.frame_bytes;
2715 }
2716
2717 /* pcmFramesRead will be equal to 0 if decoding failed. If it is zero and info.frame_bytes > 0 then we have successfully decoded the frame. */
2718 if (pcmFramesRead > 0) {
2719 pcmFramesRead = drmp3_hdr_frame_samples(pMP3->decoder.header);
2720 pMP3->pcmFramesConsumedInMP3Frame = 0;
2721 pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
2722 pMP3->mp3FrameChannels = info.channels;
2723 pMP3->mp3FrameSampleRate = info.hz;
2724 break;
2725 } else if (info.frame_bytes == 0) {
2726 /* Need more data. minimp3 recommends doing data submission in 16K chunks. */
2727 size_t bytesRead;
2728
2729 /* First we need to move the data down. */
2730 DRMP3_MOVE_MEMORY(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
2731 pMP3->dataConsumed = 0;
2732
2733 if (pMP3->dataCapacity == pMP3->dataSize) {
2734 /* No room. Expand. */
2735 drmp3_uint8* pNewData;
2736 size_t newDataCap;
2737
2738 newDataCap = pMP3->dataCapacity + DRMP3_DATA_CHUNK_SIZE;
2739
2740 pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
2741 if (pNewData == NULL) {
2742 return 0; /* Out of memory. */
2743 }
2744
2745 pMP3->pData = pNewData;
2746 pMP3->dataCapacity = newDataCap;
2747 }
2748
2749 /* Fill in a chunk. */
2750 bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
2751 if (bytesRead == 0) {
2752 pMP3->atEnd = DRMP3_TRUE;
2753 return 0; /* Error reading more data. */
2754 }
2755
2756 pMP3->dataSize += bytesRead;
2757 }
2758 };
2759
2760 return pcmFramesRead;
2761}
2762
2763static drmp3_uint32 drmp3_decode_next_frame_ex__memory(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
2764{
2765 drmp3_uint32 pcmFramesRead = 0;
2766 drmp3dec_frame_info info;
2767
2768 DRMP3_ASSERT(pMP3 != NULL);
2769 DRMP3_ASSERT(pMP3->memory.pData != NULL);
2770
2771 if (pMP3->atEnd) {
2772 return 0;
2773 }
2774
2775 for (;;) {
2776 pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
2777 if (pcmFramesRead > 0) {
2778 pcmFramesRead = drmp3_hdr_frame_samples(pMP3->decoder.header);
2779 pMP3->pcmFramesConsumedInMP3Frame = 0;
2780 pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
2781 pMP3->mp3FrameChannels = info.channels;
2782 pMP3->mp3FrameSampleRate = info.hz;
2783 break;
2784 } else if (info.frame_bytes > 0) {
2785 /* No frames were read, but it looks like we skipped past one. Read the next MP3 frame. */
2786 pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
2787 } else {
2788 /* Nothing at all was read. Abort. */
2789 break;
2790 }
2791 }
2792
2793 /* Consume the data. */
2794 pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
2795
2796 return pcmFramesRead;
2797}
2798
2799static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
2800{
2801 if (pMP3->memory.pData != NULL && pMP3->memory.dataSize > 0) {
2802 return drmp3_decode_next_frame_ex__memory(pMP3, pPCMFrames);
2803 } else {
2804 return drmp3_decode_next_frame_ex__callbacks(pMP3, pPCMFrames);
2805 }
2806}
2807
2808static drmp3_uint32 drmp3_decode_next_frame(drmp3* pMP3)
2809{
2810 DRMP3_ASSERT(pMP3 != NULL);
2811 return drmp3_decode_next_frame_ex(pMP3, (drmp3d_sample_t*)pMP3->pcmFrames);
2812}
2813
2814#if 0
2815static drmp3_uint32 drmp3_seek_next_frame(drmp3* pMP3)
2816{
2817 drmp3_uint32 pcmFrameCount;
2818
2819 DRMP3_ASSERT(pMP3 != NULL);
2820
2821 pcmFrameCount = drmp3_decode_next_frame_ex(pMP3, NULL);
2822 if (pcmFrameCount == 0) {
2823 return 0;
2824 }
2825
2826 /* We have essentially just skipped past the frame, so just set the remaining samples to 0. */
2827 pMP3->currentPCMFrame += pcmFrameCount;
2828 pMP3->pcmFramesConsumedInMP3Frame = pcmFrameCount;
2829 pMP3->pcmFramesRemainingInMP3Frame = 0;
2830
2831 return pcmFrameCount;
2832}
2833#endif
2834
2835static drmp3_bool32 drmp3_init_internal(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
2836{
2837 DRMP3_ASSERT(pMP3 != NULL);
2838 DRMP3_ASSERT(onRead != NULL);
2839
2840 /* This function assumes the output object has already been reset to 0. Do not do that here, otherwise things will break. */
2841 drmp3dec_init(&pMP3->decoder);
2842
2843 pMP3->onRead = onRead;
2844 pMP3->onSeek = onSeek;
2845 pMP3->pUserData = pUserData;
2846 pMP3->allocationCallbacks = drmp3_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
2847
2848 if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) {
2849 return DRMP3_FALSE; /* Invalid allocation callbacks. */
2850 }
2851
2852 /* Decode the first frame to confirm that it is indeed a valid MP3 stream. */
2853 if (drmp3_decode_next_frame(pMP3) == 0) {
2854 drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks); /* The call above may have allocated memory. Need to make sure it's freed before aborting. */
2855 return DRMP3_FALSE; /* Not a valid MP3 stream. */
2856 }
2857
2858 pMP3->channels = pMP3->mp3FrameChannels;
2859 pMP3->sampleRate = pMP3->mp3FrameSampleRate;
2860
2861 return DRMP3_TRUE;
2862}
2863
2864DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
2865{
2866 if (pMP3 == NULL || onRead == NULL) {
2867 return DRMP3_FALSE;
2868 }
2869
2870 DRMP3_ZERO_OBJECT(pMP3);
2871 return drmp3_init_internal(pMP3, onRead, onSeek, pUserData, pAllocationCallbacks);
2872}
2873
2874
2875static size_t drmp3__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
2876{
2877 drmp3* pMP3 = (drmp3*)pUserData;
2878 size_t bytesRemaining;
2879
2880 DRMP3_ASSERT(pMP3 != NULL);
2881 DRMP3_ASSERT(pMP3->memory.dataSize >= pMP3->memory.currentReadPos);
2882
2883 bytesRemaining = pMP3->memory.dataSize - pMP3->memory.currentReadPos;
2884 if (bytesToRead > bytesRemaining) {
2885 bytesToRead = bytesRemaining;
2886 }
2887
2888 if (bytesToRead > 0) {
2889 DRMP3_COPY_MEMORY(pBufferOut, pMP3->memory.pData + pMP3->memory.currentReadPos, bytesToRead);
2890 pMP3->memory.currentReadPos += bytesToRead;
2891 }
2892
2893 return bytesToRead;
2894}
2895
2896static drmp3_bool32 drmp3__on_seek_memory(void* pUserData, int byteOffset, drmp3_seek_origin origin)
2897{
2898 drmp3* pMP3 = (drmp3*)pUserData;
2899
2900 DRMP3_ASSERT(pMP3 != NULL);
2901
2902 if (origin == drmp3_seek_origin_current) {
2903 if (byteOffset > 0) {
2904 if (pMP3->memory.currentReadPos + byteOffset > pMP3->memory.dataSize) {
2905 byteOffset = (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos); /* Trying to seek too far forward. */
2906 }
2907 } else {
2908 if (pMP3->memory.currentReadPos < (size_t)-byteOffset) {
2909 byteOffset = -(int)pMP3->memory.currentReadPos; /* Trying to seek too far backwards. */
2910 }
2911 }
2912
2913 /* This will never underflow thanks to the clamps above. */
2914 pMP3->memory.currentReadPos += byteOffset;
2915 } else {
2916 if ((drmp3_uint32)byteOffset <= pMP3->memory.dataSize) {
2917 pMP3->memory.currentReadPos = byteOffset;
2918 } else {
2919 pMP3->memory.currentReadPos = pMP3->memory.dataSize; /* Trying to seek too far forward. */
2920 }
2921 }
2922
2923 return DRMP3_TRUE;
2924}
2925
2926DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks)
2927{
2928 if (pMP3 == NULL) {
2929 return DRMP3_FALSE;
2930 }
2931
2932 DRMP3_ZERO_OBJECT(pMP3);
2933
2934 if (pData == NULL || dataSize == 0) {
2935 return DRMP3_FALSE;
2936 }
2937
2938 pMP3->memory.pData = (const drmp3_uint8*)pData;
2939 pMP3->memory.dataSize = dataSize;
2940 pMP3->memory.currentReadPos = 0;
2941
2942 return drmp3_init_internal(pMP3, drmp3__on_read_memory, drmp3__on_seek_memory, pMP3, pAllocationCallbacks);
2943}
2944
2945
2946#ifndef DR_MP3_NO_STDIO
2947#include <stdio.h>
2948#include <wchar.h> /* For wcslen(), wcsrtombs() */
2949
2950/* Errno */
2951/* drmp3_result_from_errno() is only used inside DR_MP3_NO_STDIO for now. Move this out if it's ever used elsewhere. */
2952#include <errno.h>
2953static drmp3_result drmp3_result_from_errno(int e)
2954{
2955 switch (e)
2956 {
2957 case 0: return DRMP3_SUCCESS;
2958 #ifdef EPERM
2959 case EPERM: return DRMP3_INVALID_OPERATION;
2960 #endif
2961 #ifdef ENOENT
2962 case ENOENT: return DRMP3_DOES_NOT_EXIST;
2963 #endif
2964 #ifdef ESRCH
2965 case ESRCH: return DRMP3_DOES_NOT_EXIST;
2966 #endif
2967 #ifdef EINTR
2968 case EINTR: return DRMP3_INTERRUPT;
2969 #endif
2970 #ifdef EIO
2971 case EIO: return DRMP3_IO_ERROR;
2972 #endif
2973 #ifdef ENXIO
2974 case ENXIO: return DRMP3_DOES_NOT_EXIST;
2975 #endif
2976 #ifdef E2BIG
2977 case E2BIG: return DRMP3_INVALID_ARGS;
2978 #endif
2979 #ifdef ENOEXEC
2980 case ENOEXEC: return DRMP3_INVALID_FILE;
2981 #endif
2982 #ifdef EBADF
2983 case EBADF: return DRMP3_INVALID_FILE;
2984 #endif
2985 #ifdef ECHILD
2986 case ECHILD: return DRMP3_ERROR;
2987 #endif
2988 #ifdef EAGAIN
2989 case EAGAIN: return DRMP3_UNAVAILABLE;
2990 #endif
2991 #ifdef ENOMEM
2992 case ENOMEM: return DRMP3_OUT_OF_MEMORY;
2993 #endif
2994 #ifdef EACCES
2995 case EACCES: return DRMP3_ACCESS_DENIED;
2996 #endif
2997 #ifdef EFAULT
2998 case EFAULT: return DRMP3_BAD_ADDRESS;
2999 #endif
3000 #ifdef ENOTBLK
3001 case ENOTBLK: return DRMP3_ERROR;
3002 #endif
3003 #ifdef EBUSY
3004 case EBUSY: return DRMP3_BUSY;
3005 #endif
3006 #ifdef EEXIST
3007 case EEXIST: return DRMP3_ALREADY_EXISTS;
3008 #endif
3009 #ifdef EXDEV
3010 case EXDEV: return DRMP3_ERROR;
3011 #endif
3012 #ifdef ENODEV
3013 case ENODEV: return DRMP3_DOES_NOT_EXIST;
3014 #endif
3015 #ifdef ENOTDIR
3016 case ENOTDIR: return DRMP3_NOT_DIRECTORY;
3017 #endif
3018 #ifdef EISDIR
3019 case EISDIR: return DRMP3_IS_DIRECTORY;
3020 #endif
3021 #ifdef EINVAL
3022 case EINVAL: return DRMP3_INVALID_ARGS;
3023 #endif
3024 #ifdef ENFILE
3025 case ENFILE: return DRMP3_TOO_MANY_OPEN_FILES;
3026 #endif
3027 #ifdef EMFILE
3028 case EMFILE: return DRMP3_TOO_MANY_OPEN_FILES;
3029 #endif
3030 #ifdef ENOTTY
3031 case ENOTTY: return DRMP3_INVALID_OPERATION;
3032 #endif
3033 #ifdef ETXTBSY
3034 case ETXTBSY: return DRMP3_BUSY;
3035 #endif
3036 #ifdef EFBIG
3037 case EFBIG: return DRMP3_TOO_BIG;
3038 #endif
3039 #ifdef ENOSPC
3040 case ENOSPC: return DRMP3_NO_SPACE;
3041 #endif
3042 #ifdef ESPIPE
3043 case ESPIPE: return DRMP3_BAD_SEEK;
3044 #endif
3045 #ifdef EROFS
3046 case EROFS: return DRMP3_ACCESS_DENIED;
3047 #endif
3048 #ifdef EMLINK
3049 case EMLINK: return DRMP3_TOO_MANY_LINKS;
3050 #endif
3051 #ifdef EPIPE
3052 case EPIPE: return DRMP3_BAD_PIPE;
3053 #endif
3054 #ifdef EDOM
3055 case EDOM: return DRMP3_OUT_OF_RANGE;
3056 #endif
3057 #ifdef ERANGE
3058 case ERANGE: return DRMP3_OUT_OF_RANGE;
3059 #endif
3060 #ifdef EDEADLK
3061 case EDEADLK: return DRMP3_DEADLOCK;
3062 #endif
3063 #ifdef ENAMETOOLONG
3064 case ENAMETOOLONG: return DRMP3_PATH_TOO_LONG;
3065 #endif
3066 #ifdef ENOLCK
3067 case ENOLCK: return DRMP3_ERROR;
3068 #endif
3069 #ifdef ENOSYS
3070 case ENOSYS: return DRMP3_NOT_IMPLEMENTED;
3071 #endif
3072 #ifdef ENOTEMPTY
3073 case ENOTEMPTY: return DRMP3_DIRECTORY_NOT_EMPTY;
3074 #endif
3075 #ifdef ELOOP
3076 case ELOOP: return DRMP3_TOO_MANY_LINKS;
3077 #endif
3078 #ifdef ENOMSG
3079 case ENOMSG: return DRMP3_NO_MESSAGE;
3080 #endif
3081 #ifdef EIDRM
3082 case EIDRM: return DRMP3_ERROR;
3083 #endif
3084 #ifdef ECHRNG
3085 case ECHRNG: return DRMP3_ERROR;
3086 #endif
3087 #ifdef EL2NSYNC
3088 case EL2NSYNC: return DRMP3_ERROR;
3089 #endif
3090 #ifdef EL3HLT
3091 case EL3HLT: return DRMP3_ERROR;
3092 #endif
3093 #ifdef EL3RST
3094 case EL3RST: return DRMP3_ERROR;
3095 #endif
3096 #ifdef ELNRNG
3097 case ELNRNG: return DRMP3_OUT_OF_RANGE;
3098 #endif
3099 #ifdef EUNATCH
3100 case EUNATCH: return DRMP3_ERROR;
3101 #endif
3102 #ifdef ENOCSI
3103 case ENOCSI: return DRMP3_ERROR;
3104 #endif
3105 #ifdef EL2HLT
3106 case EL2HLT: return DRMP3_ERROR;
3107 #endif
3108 #ifdef EBADE
3109 case EBADE: return DRMP3_ERROR;
3110 #endif
3111 #ifdef EBADR
3112 case EBADR: return DRMP3_ERROR;
3113 #endif
3114 #ifdef EXFULL
3115 case EXFULL: return DRMP3_ERROR;
3116 #endif
3117 #ifdef ENOANO
3118 case ENOANO: return DRMP3_ERROR;
3119 #endif
3120 #ifdef EBADRQC
3121 case EBADRQC: return DRMP3_ERROR;
3122 #endif
3123 #ifdef EBADSLT
3124 case EBADSLT: return DRMP3_ERROR;
3125 #endif
3126 #ifdef EBFONT
3127 case EBFONT: return DRMP3_INVALID_FILE;
3128 #endif
3129 #ifdef ENOSTR
3130 case ENOSTR: return DRMP3_ERROR;
3131 #endif
3132 #ifdef ENODATA
3133 case ENODATA: return DRMP3_NO_DATA_AVAILABLE;
3134 #endif
3135 #ifdef ETIME
3136 case ETIME: return DRMP3_TIMEOUT;
3137 #endif
3138 #ifdef ENOSR
3139 case ENOSR: return DRMP3_NO_DATA_AVAILABLE;
3140 #endif
3141 #ifdef ENONET
3142 case ENONET: return DRMP3_NO_NETWORK;
3143 #endif
3144 #ifdef ENOPKG
3145 case ENOPKG: return DRMP3_ERROR;
3146 #endif
3147 #ifdef EREMOTE
3148 case EREMOTE: return DRMP3_ERROR;
3149 #endif
3150 #ifdef ENOLINK
3151 case ENOLINK: return DRMP3_ERROR;
3152 #endif
3153 #ifdef EADV
3154 case EADV: return DRMP3_ERROR;
3155 #endif
3156 #ifdef ESRMNT
3157 case ESRMNT: return DRMP3_ERROR;
3158 #endif
3159 #ifdef ECOMM
3160 case ECOMM: return DRMP3_ERROR;
3161 #endif
3162 #ifdef EPROTO
3163 case EPROTO: return DRMP3_ERROR;
3164 #endif
3165 #ifdef EMULTIHOP
3166 case EMULTIHOP: return DRMP3_ERROR;
3167 #endif
3168 #ifdef EDOTDOT
3169 case EDOTDOT: return DRMP3_ERROR;
3170 #endif
3171 #ifdef EBADMSG
3172 case EBADMSG: return DRMP3_BAD_MESSAGE;
3173 #endif
3174 #ifdef EOVERFLOW
3175 case EOVERFLOW: return DRMP3_TOO_BIG;
3176 #endif
3177 #ifdef ENOTUNIQ
3178 case ENOTUNIQ: return DRMP3_NOT_UNIQUE;
3179 #endif
3180 #ifdef EBADFD
3181 case EBADFD: return DRMP3_ERROR;
3182 #endif
3183 #ifdef EREMCHG
3184 case EREMCHG: return DRMP3_ERROR;
3185 #endif
3186 #ifdef ELIBACC
3187 case ELIBACC: return DRMP3_ACCESS_DENIED;
3188 #endif
3189 #ifdef ELIBBAD
3190 case ELIBBAD: return DRMP3_INVALID_FILE;
3191 #endif
3192 #ifdef ELIBSCN
3193 case ELIBSCN: return DRMP3_INVALID_FILE;
3194 #endif
3195 #ifdef ELIBMAX
3196 case ELIBMAX: return DRMP3_ERROR;
3197 #endif
3198 #ifdef ELIBEXEC
3199 case ELIBEXEC: return DRMP3_ERROR;
3200 #endif
3201 #ifdef EILSEQ
3202 case EILSEQ: return DRMP3_INVALID_DATA;
3203 #endif
3204 #ifdef ERESTART
3205 case ERESTART: return DRMP3_ERROR;
3206 #endif
3207 #ifdef ESTRPIPE
3208 case ESTRPIPE: return DRMP3_ERROR;
3209 #endif
3210 #ifdef EUSERS
3211 case EUSERS: return DRMP3_ERROR;
3212 #endif
3213 #ifdef ENOTSOCK
3214 case ENOTSOCK: return DRMP3_NOT_SOCKET;
3215 #endif
3216 #ifdef EDESTADDRREQ
3217 case EDESTADDRREQ: return DRMP3_NO_ADDRESS;
3218 #endif
3219 #ifdef EMSGSIZE
3220 case EMSGSIZE: return DRMP3_TOO_BIG;
3221 #endif
3222 #ifdef EPROTOTYPE
3223 case EPROTOTYPE: return DRMP3_BAD_PROTOCOL;
3224 #endif
3225 #ifdef ENOPROTOOPT
3226 case ENOPROTOOPT: return DRMP3_PROTOCOL_UNAVAILABLE;
3227 #endif
3228 #ifdef EPROTONOSUPPORT
3229 case EPROTONOSUPPORT: return DRMP3_PROTOCOL_NOT_SUPPORTED;
3230 #endif
3231 #ifdef ESOCKTNOSUPPORT
3232 case ESOCKTNOSUPPORT: return DRMP3_SOCKET_NOT_SUPPORTED;
3233 #endif
3234 #ifdef EOPNOTSUPP
3235 case EOPNOTSUPP: return DRMP3_INVALID_OPERATION;
3236 #endif
3237 #ifdef EPFNOSUPPORT
3238 case EPFNOSUPPORT: return DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED;
3239 #endif
3240 #ifdef EAFNOSUPPORT
3241 case EAFNOSUPPORT: return DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED;
3242 #endif
3243 #ifdef EADDRINUSE
3244 case EADDRINUSE: return DRMP3_ALREADY_IN_USE;
3245 #endif
3246 #ifdef EADDRNOTAVAIL
3247 case EADDRNOTAVAIL: return DRMP3_ERROR;
3248 #endif
3249 #ifdef ENETDOWN
3250 case ENETDOWN: return DRMP3_NO_NETWORK;
3251 #endif
3252 #ifdef ENETUNREACH
3253 case ENETUNREACH: return DRMP3_NO_NETWORK;
3254 #endif
3255 #ifdef ENETRESET
3256 case ENETRESET: return DRMP3_NO_NETWORK;
3257 #endif
3258 #ifdef ECONNABORTED
3259 case ECONNABORTED: return DRMP3_NO_NETWORK;
3260 #endif
3261 #ifdef ECONNRESET
3262 case ECONNRESET: return DRMP3_CONNECTION_RESET;
3263 #endif
3264 #ifdef ENOBUFS
3265 case ENOBUFS: return DRMP3_NO_SPACE;
3266 #endif
3267 #ifdef EISCONN
3268 case EISCONN: return DRMP3_ALREADY_CONNECTED;
3269 #endif
3270 #ifdef ENOTCONN
3271 case ENOTCONN: return DRMP3_NOT_CONNECTED;
3272 #endif
3273 #ifdef ESHUTDOWN
3274 case ESHUTDOWN: return DRMP3_ERROR;
3275 #endif
3276 #ifdef ETOOMANYREFS
3277 case ETOOMANYREFS: return DRMP3_ERROR;
3278 #endif
3279 #ifdef ETIMEDOUT
3280 case ETIMEDOUT: return DRMP3_TIMEOUT;
3281 #endif
3282 #ifdef ECONNREFUSED
3283 case ECONNREFUSED: return DRMP3_CONNECTION_REFUSED;
3284 #endif
3285 #ifdef EHOSTDOWN
3286 case EHOSTDOWN: return DRMP3_NO_HOST;
3287 #endif
3288 #ifdef EHOSTUNREACH
3289 case EHOSTUNREACH: return DRMP3_NO_HOST;
3290 #endif
3291 #ifdef EALREADY
3292 case EALREADY: return DRMP3_IN_PROGRESS;
3293 #endif
3294 #ifdef EINPROGRESS
3295 case EINPROGRESS: return DRMP3_IN_PROGRESS;
3296 #endif
3297 #ifdef ESTALE
3298 case ESTALE: return DRMP3_INVALID_FILE;
3299 #endif
3300 #ifdef EUCLEAN
3301 case EUCLEAN: return DRMP3_ERROR;
3302 #endif
3303 #ifdef ENOTNAM
3304 case ENOTNAM: return DRMP3_ERROR;
3305 #endif
3306 #ifdef ENAVAIL
3307 case ENAVAIL: return DRMP3_ERROR;
3308 #endif
3309 #ifdef EISNAM
3310 case EISNAM: return DRMP3_ERROR;
3311 #endif
3312 #ifdef EREMOTEIO
3313 case EREMOTEIO: return DRMP3_IO_ERROR;
3314 #endif
3315 #ifdef EDQUOT
3316 case EDQUOT: return DRMP3_NO_SPACE;
3317 #endif
3318 #ifdef ENOMEDIUM
3319 case ENOMEDIUM: return DRMP3_DOES_NOT_EXIST;
3320 #endif
3321 #ifdef EMEDIUMTYPE
3322 case EMEDIUMTYPE: return DRMP3_ERROR;
3323 #endif
3324 #ifdef ECANCELED
3325 case ECANCELED: return DRMP3_CANCELLED;
3326 #endif
3327 #ifdef ENOKEY
3328 case ENOKEY: return DRMP3_ERROR;
3329 #endif
3330 #ifdef EKEYEXPIRED
3331 case EKEYEXPIRED: return DRMP3_ERROR;
3332 #endif
3333 #ifdef EKEYREVOKED
3334 case EKEYREVOKED: return DRMP3_ERROR;
3335 #endif
3336 #ifdef EKEYREJECTED
3337 case EKEYREJECTED: return DRMP3_ERROR;
3338 #endif
3339 #ifdef EOWNERDEAD
3340 case EOWNERDEAD: return DRMP3_ERROR;
3341 #endif
3342 #ifdef ENOTRECOVERABLE
3343 case ENOTRECOVERABLE: return DRMP3_ERROR;
3344 #endif
3345 #ifdef ERFKILL
3346 case ERFKILL: return DRMP3_ERROR;
3347 #endif
3348 #ifdef EHWPOISON
3349 case EHWPOISON: return DRMP3_ERROR;
3350 #endif
3351 default: return DRMP3_ERROR;
3352 }
3353}
3354/* End Errno */
3355
3356/* fopen */
3357static drmp3_result drmp3_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
3358{
3359#if defined(_MSC_VER) && _MSC_VER >= 1400
3360 errno_t err;
3361#endif
3362
3363 if (ppFile != NULL) {
3364 *ppFile = NULL; /* Safety. */
3365 }
3366
3367 if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
3368 return DRMP3_INVALID_ARGS;
3369 }
3370
3371#if defined(_MSC_VER) && _MSC_VER >= 1400
3372 err = fopen_s(ppFile, pFilePath, pOpenMode);
3373 if (err != 0) {
3374 return drmp3_result_from_errno(err);
3375 }
3376#else
3377#if defined(_WIN32) || defined(__APPLE__)
3378 *ppFile = fopen(pFilePath, pOpenMode);
3379#else
3380 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
3381 *ppFile = fopen64(pFilePath, pOpenMode);
3382 #else
3383 *ppFile = fopen(pFilePath, pOpenMode);
3384 #endif
3385#endif
3386 if (*ppFile == NULL) {
3387 drmp3_result result = drmp3_result_from_errno(errno);
3388 if (result == DRMP3_SUCCESS) {
3389 result = DRMP3_ERROR; /* Just a safety check to make sure we never ever return success when pFile == NULL. */
3390 }
3391
3392 return result;
3393 }
3394#endif
3395
3396 return DRMP3_SUCCESS;
3397}
3398
3399/*
3400_wfopen() isn't always available in all compilation environments.
3401
3402 * Windows only.
3403 * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
3404 * MinGW-64 (both 32- and 64-bit) seems to support it.
3405 * MinGW wraps it in !defined(__STRICT_ANSI__).
3406 * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
3407
3408This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
3409fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
3410*/
3411#if defined(_WIN32)
3412 #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
3413 #define DRMP3_HAS_WFOPEN
3414 #endif
3415#endif
3416
3417static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drmp3_allocation_callbacks* pAllocationCallbacks)
3418{
3419 if (ppFile != NULL) {
3420 *ppFile = NULL; /* Safety. */
3421 }
3422
3423 if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
3424 return DRMP3_INVALID_ARGS;
3425 }
3426
3427#if defined(DRMP3_HAS_WFOPEN)
3428 {
3429 /* Use _wfopen() on Windows. */
3430 #if defined(_MSC_VER) && _MSC_VER >= 1400
3431 errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
3432 if (err != 0) {
3433 return drmp3_result_from_errno(err);
3434 }
3435 #else
3436 *ppFile = _wfopen(pFilePath, pOpenMode);
3437 if (*ppFile == NULL) {
3438 return drmp3_result_from_errno(errno);
3439 }
3440 #endif
3441 (void)pAllocationCallbacks;
3442 }
3443#else
3444 /*
3445 Use fopen() on anything other than Windows. Requires a conversion. This is annoying because
3446 fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note
3447 that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
3448 maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler
3449 error I'll look into improving compatibility.
3450 */
3451
3452 /*
3453 Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just
3454 need to abort with an error. If you encounter a compiler lacking such support, add it to this list
3455 and submit a bug report and it'll be added to the library upstream.
3456 */
3457 #if defined(__DJGPP__)
3458 {
3459 /* Nothing to do here. This will fall through to the error check below. */
3460 }
3461 #else
3462 {
3463 mbstate_t mbs;
3464 size_t lenMB;
3465 const wchar_t* pFilePathTemp = pFilePath;
3466 char* pFilePathMB = NULL;
3467 char pOpenModeMB[32] = {0};
3468
3469 /* Get the length first. */
3470 DRMP3_ZERO_OBJECT(&mbs);
3471 lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
3472 if (lenMB == (size_t)-1) {
3473 return drmp3_result_from_errno(errno);
3474 }
3475
3476 pFilePathMB = (char*)drmp3__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
3477 if (pFilePathMB == NULL) {
3478 return DRMP3_OUT_OF_MEMORY;
3479 }
3480
3481 pFilePathTemp = pFilePath;
3482 DRMP3_ZERO_OBJECT(&mbs);
3483 wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
3484
3485 /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
3486 {
3487 size_t i = 0;
3488 for (;;) {
3489 if (pOpenMode[i] == 0) {
3490 pOpenModeMB[i] = '\0';
3491 break;
3492 }
3493
3494 pOpenModeMB[i] = (char)pOpenMode[i];
3495 i += 1;
3496 }
3497 }
3498
3499 *ppFile = fopen(pFilePathMB, pOpenModeMB);
3500
3501 drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
3502 }
3503 #endif
3504
3505 if (*ppFile == NULL) {
3506 return DRMP3_ERROR;
3507 }
3508#endif
3509
3510 return DRMP3_SUCCESS;
3511}
3512/* End fopen */
3513
3514
3515static size_t drmp3__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
3516{
3517 return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
3518}
3519
3520static drmp3_bool32 drmp3__on_seek_stdio(void* pUserData, int offset, drmp3_seek_origin origin)
3521{
3522 return fseek((FILE*)pUserData, offset, (origin == drmp3_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
3523}
3524
3525DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
3526{
3527 drmp3_bool32 result;
3528 FILE* pFile;
3529
3530 if (drmp3_fopen(&pFile, pFilePath, "rb") != DRMP3_SUCCESS) {
3531 return DRMP3_FALSE;
3532 }
3533
3534 result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
3535 if (result != DRMP3_TRUE) {
3536 fclose(pFile);
3537 return result;
3538 }
3539
3540 return DRMP3_TRUE;
3541}
3542
3543DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
3544{
3545 drmp3_bool32 result;
3546 FILE* pFile;
3547
3548 if (drmp3_wfopen(&pFile, pFilePath, L"rb", pAllocationCallbacks) != DRMP3_SUCCESS) {
3549 return DRMP3_FALSE;
3550 }
3551
3552 result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
3553 if (result != DRMP3_TRUE) {
3554 fclose(pFile);
3555 return result;
3556 }
3557
3558 return DRMP3_TRUE;
3559}
3560#endif
3561
3562DRMP3_API void drmp3_uninit(drmp3* pMP3)
3563{
3564 if (pMP3 == NULL) {
3565 return;
3566 }
3567
3568#ifndef DR_MP3_NO_STDIO
3569 if (pMP3->onRead == drmp3__on_read_stdio) {
3570 FILE* pFile = (FILE*)pMP3->pUserData;
3571 if (pFile != NULL) {
3572 fclose(pFile);
3573 pMP3->pUserData = NULL; /* Make sure the file handle is cleared to NULL to we don't attempt to close it a second time. */
3574 }
3575 }
3576#endif
3577
3578 drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
3579}
3580
3581#if defined(DR_MP3_FLOAT_OUTPUT)
3582static void drmp3_f32_to_s16(drmp3_int16* dst, const float* src, drmp3_uint64 sampleCount)
3583{
3584 drmp3_uint64 i;
3585 drmp3_uint64 i4;
3586 drmp3_uint64 sampleCount4;
3587
3588 /* Unrolled. */
3589 i = 0;
3590 sampleCount4 = sampleCount >> 2;
3591 for (i4 = 0; i4 < sampleCount4; i4 += 1) {
3592 float x0 = src[i+0];
3593 float x1 = src[i+1];
3594 float x2 = src[i+2];
3595 float x3 = src[i+3];
3596
3597 x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0));
3598 x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1));
3599 x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2));
3600 x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3));
3601
3602 x0 = x0 * 32767.0f;
3603 x1 = x1 * 32767.0f;
3604 x2 = x2 * 32767.0f;
3605 x3 = x3 * 32767.0f;
3606
3607 dst[i+0] = (drmp3_int16)x0;
3608 dst[i+1] = (drmp3_int16)x1;
3609 dst[i+2] = (drmp3_int16)x2;
3610 dst[i+3] = (drmp3_int16)x3;
3611
3612 i += 4;
3613 }
3614
3615 /* Leftover. */
3616 for (; i < sampleCount; i += 1) {
3617 float x = src[i];
3618 x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */
3619 x = x * 32767.0f; /* -1..1 to -32767..32767 */
3620
3621 dst[i] = (drmp3_int16)x;
3622 }
3623}
3624#endif
3625
3626#if !defined(DR_MP3_FLOAT_OUTPUT)
3627static void drmp3_s16_to_f32(float* dst, const drmp3_int16* src, drmp3_uint64 sampleCount)
3628{
3629 drmp3_uint64 i;
3630 for (i = 0; i < sampleCount; i += 1) {
3631 float x = (float)src[i];
3632 x = x * 0.000030517578125f; /* -32768..32767 to -1..0.999969482421875 */
3633 dst[i] = x;
3634 }
3635}
3636#endif
3637
3638
3639static drmp3_uint64 drmp3_read_pcm_frames_raw(drmp3* pMP3, drmp3_uint64 framesToRead, void* pBufferOut)
3640{
3641 drmp3_uint64 totalFramesRead = 0;
3642
3643 DRMP3_ASSERT(pMP3 != NULL);
3644 DRMP3_ASSERT(pMP3->onRead != NULL);
3645
3646 while (framesToRead > 0) {
3647 drmp3_uint32 framesToConsume = (drmp3_uint32)DRMP3_MIN(pMP3->pcmFramesRemainingInMP3Frame, framesToRead);
3648 if (pBufferOut != NULL) {
3649 #if defined(DR_MP3_FLOAT_OUTPUT)
3650 /* f32 */
3651 float* pFramesOutF32 = (float*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalFramesRead * pMP3->channels);
3652 float* pFramesInF32 = (float*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(float) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
3653 DRMP3_COPY_MEMORY(pFramesOutF32, pFramesInF32, sizeof(float) * framesToConsume * pMP3->channels);
3654 #else
3655 /* s16 */
3656 drmp3_int16* pFramesOutS16 = (drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(drmp3_int16) * totalFramesRead * pMP3->channels);
3657 drmp3_int16* pFramesInS16 = (drmp3_int16*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(drmp3_int16) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
3658 DRMP3_COPY_MEMORY(pFramesOutS16, pFramesInS16, sizeof(drmp3_int16) * framesToConsume * pMP3->channels);
3659 #endif
3660 }
3661
3662 pMP3->currentPCMFrame += framesToConsume;
3663 pMP3->pcmFramesConsumedInMP3Frame += framesToConsume;
3664 pMP3->pcmFramesRemainingInMP3Frame -= framesToConsume;
3665 totalFramesRead += framesToConsume;
3666 framesToRead -= framesToConsume;
3667
3668 if (framesToRead == 0) {
3669 break;
3670 }
3671
3672 DRMP3_ASSERT(pMP3->pcmFramesRemainingInMP3Frame == 0);
3673
3674 /*
3675 At this point we have exhausted our in-memory buffer so we need to re-fill. Note that the sample rate may have changed
3676 at this point which means we'll also need to update our sample rate conversion pipeline.
3677 */
3678 if (drmp3_decode_next_frame(pMP3) == 0) {
3679 break;
3680 }
3681 }
3682
3683 return totalFramesRead;
3684}
3685
3686
3687DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut)
3688{
3689 if (pMP3 == NULL || pMP3->onRead == NULL) {
3690 return 0;
3691 }
3692
3693#if defined(DR_MP3_FLOAT_OUTPUT)
3694 /* Fast path. No conversion required. */
3695 return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
3696#else
3697 /* Slow path. Convert from s16 to f32. */
3698 {
3699 drmp3_int16 pTempS16[8192];
3700 drmp3_uint64 totalPCMFramesRead = 0;
3701
3702 while (totalPCMFramesRead < framesToRead) {
3703 drmp3_uint64 framesJustRead;
3704 drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
3705 drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempS16) / pMP3->channels;
3706 if (framesToReadNow > framesRemaining) {
3707 framesToReadNow = framesRemaining;
3708 }
3709
3710 framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempS16);
3711 if (framesJustRead == 0) {
3712 break;
3713 }
3714
3715 drmp3_s16_to_f32((float*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalPCMFramesRead * pMP3->channels), pTempS16, framesJustRead * pMP3->channels);
3716 totalPCMFramesRead += framesJustRead;
3717 }
3718
3719 return totalPCMFramesRead;
3720 }
3721#endif
3722}
3723
3724DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut)
3725{
3726 if (pMP3 == NULL || pMP3->onRead == NULL) {
3727 return 0;
3728 }
3729
3730#if !defined(DR_MP3_FLOAT_OUTPUT)
3731 /* Fast path. No conversion required. */
3732 return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
3733#else
3734 /* Slow path. Convert from f32 to s16. */
3735 {
3736 float pTempF32[4096];
3737 drmp3_uint64 totalPCMFramesRead = 0;
3738
3739 while (totalPCMFramesRead < framesToRead) {
3740 drmp3_uint64 framesJustRead;
3741 drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
3742 drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempF32) / pMP3->channels;
3743 if (framesToReadNow > framesRemaining) {
3744 framesToReadNow = framesRemaining;
3745 }
3746
3747 framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempF32);
3748 if (framesJustRead == 0) {
3749 break;
3750 }
3751
3752 drmp3_f32_to_s16((drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(drmp3_int16) * totalPCMFramesRead * pMP3->channels), pTempF32, framesJustRead * pMP3->channels);
3753 totalPCMFramesRead += framesJustRead;
3754 }
3755
3756 return totalPCMFramesRead;
3757 }
3758#endif
3759}
3760
3761static void drmp3_reset(drmp3* pMP3)
3762{
3763 DRMP3_ASSERT(pMP3 != NULL);
3764
3765 pMP3->pcmFramesConsumedInMP3Frame = 0;
3766 pMP3->pcmFramesRemainingInMP3Frame = 0;
3767 pMP3->currentPCMFrame = 0;
3768 pMP3->dataSize = 0;
3769 pMP3->atEnd = DRMP3_FALSE;
3770 drmp3dec_init(&pMP3->decoder);
3771}
3772
3773static drmp3_bool32 drmp3_seek_to_start_of_stream(drmp3* pMP3)
3774{
3775 DRMP3_ASSERT(pMP3 != NULL);
3776 DRMP3_ASSERT(pMP3->onSeek != NULL);
3777
3778 /* Seek to the start of the stream to begin with. */
3779 if (!drmp3__on_seek(pMP3, 0, drmp3_seek_origin_start)) {
3780 return DRMP3_FALSE;
3781 }
3782
3783 /* Clear any cached data. */
3784 drmp3_reset(pMP3);
3785 return DRMP3_TRUE;
3786}
3787
3788
3789static drmp3_bool32 drmp3_seek_forward_by_pcm_frames__brute_force(drmp3* pMP3, drmp3_uint64 frameOffset)
3790{
3791 drmp3_uint64 framesRead;
3792
3793 /*
3794 Just using a dumb read-and-discard for now. What would be nice is to parse only the header of the MP3 frame, and then skip over leading
3795 frames without spending the time doing a full decode. I cannot see an easy way to do this in minimp3, however, so it may involve some
3796 kind of manual processing.
3797 */
3798#if defined(DR_MP3_FLOAT_OUTPUT)
3799 framesRead = drmp3_read_pcm_frames_f32(pMP3, frameOffset, NULL);
3800#else
3801 framesRead = drmp3_read_pcm_frames_s16(pMP3, frameOffset, NULL);
3802#endif
3803 if (framesRead != frameOffset) {
3804 return DRMP3_FALSE;
3805 }
3806
3807 return DRMP3_TRUE;
3808}
3809
3810static drmp3_bool32 drmp3_seek_to_pcm_frame__brute_force(drmp3* pMP3, drmp3_uint64 frameIndex)
3811{
3812 DRMP3_ASSERT(pMP3 != NULL);
3813
3814 if (frameIndex == pMP3->currentPCMFrame) {
3815 return DRMP3_TRUE;
3816 }
3817
3818 /*
3819 If we're moving foward we just read from where we're at. Otherwise we need to move back to the start of
3820 the stream and read from the beginning.
3821 */
3822 if (frameIndex < pMP3->currentPCMFrame) {
3823 /* Moving backward. Move to the start of the stream and then move forward. */
3824 if (!drmp3_seek_to_start_of_stream(pMP3)) {
3825 return DRMP3_FALSE;
3826 }
3827 }
3828
3829 DRMP3_ASSERT(frameIndex >= pMP3->currentPCMFrame);
3830 return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, (frameIndex - pMP3->currentPCMFrame));
3831}
3832
3833static drmp3_bool32 drmp3_find_closest_seek_point(drmp3* pMP3, drmp3_uint64 frameIndex, drmp3_uint32* pSeekPointIndex)
3834{
3835 drmp3_uint32 iSeekPoint;
3836
3837 DRMP3_ASSERT(pSeekPointIndex != NULL);
3838
3839 *pSeekPointIndex = 0;
3840
3841 if (frameIndex < pMP3->pSeekPoints[0].pcmFrameIndex) {
3842 return DRMP3_FALSE;
3843 }
3844
3845 /* Linear search for simplicity to begin with while I'm getting this thing working. Once it's all working change this to a binary search. */
3846 for (iSeekPoint = 0; iSeekPoint < pMP3->seekPointCount; ++iSeekPoint) {
3847 if (pMP3->pSeekPoints[iSeekPoint].pcmFrameIndex > frameIndex) {
3848 break; /* Found it. */
3849 }
3850
3851 *pSeekPointIndex = iSeekPoint;
3852 }
3853
3854 return DRMP3_TRUE;
3855}
3856
3857static drmp3_bool32 drmp3_seek_to_pcm_frame__seek_table(drmp3* pMP3, drmp3_uint64 frameIndex)
3858{
3859 drmp3_seek_point seekPoint;
3860 drmp3_uint32 priorSeekPointIndex;
3861 drmp3_uint16 iMP3Frame;
3862 drmp3_uint64 leftoverFrames;
3863
3864 DRMP3_ASSERT(pMP3 != NULL);
3865 DRMP3_ASSERT(pMP3->pSeekPoints != NULL);
3866 DRMP3_ASSERT(pMP3->seekPointCount > 0);
3867
3868 /* If there is no prior seekpoint it means the target PCM frame comes before the first seek point. Just assume a seekpoint at the start of the file in this case. */
3869 if (drmp3_find_closest_seek_point(pMP3, frameIndex, &priorSeekPointIndex)) {
3870 seekPoint = pMP3->pSeekPoints[priorSeekPointIndex];
3871 } else {
3872 seekPoint.seekPosInBytes = 0;
3873 seekPoint.pcmFrameIndex = 0;
3874 seekPoint.mp3FramesToDiscard = 0;
3875 seekPoint.pcmFramesToDiscard = 0;
3876 }
3877
3878 /* First thing to do is seek to the first byte of the relevant MP3 frame. */
3879 if (!drmp3__on_seek_64(pMP3, seekPoint.seekPosInBytes, drmp3_seek_origin_start)) {
3880 return DRMP3_FALSE; /* Failed to seek. */
3881 }
3882
3883 /* Clear any cached data. */
3884 drmp3_reset(pMP3);
3885
3886 /* Whole MP3 frames need to be discarded first. */
3887 for (iMP3Frame = 0; iMP3Frame < seekPoint.mp3FramesToDiscard; ++iMP3Frame) {
3888 drmp3_uint32 pcmFramesRead;
3889 drmp3d_sample_t* pPCMFrames;
3890
3891 /* Pass in non-null for the last frame because we want to ensure the sample rate converter is preloaded correctly. */
3892 pPCMFrames = NULL;
3893 if (iMP3Frame == seekPoint.mp3FramesToDiscard-1) {
3894 pPCMFrames = (drmp3d_sample_t*)pMP3->pcmFrames;
3895 }
3896
3897 /* We first need to decode the next frame. */
3898 pcmFramesRead = drmp3_decode_next_frame_ex(pMP3, pPCMFrames);
3899 if (pcmFramesRead == 0) {
3900 return DRMP3_FALSE;
3901 }
3902 }
3903
3904 /* We seeked to an MP3 frame in the raw stream so we need to make sure the current PCM frame is set correctly. */
3905 pMP3->currentPCMFrame = seekPoint.pcmFrameIndex - seekPoint.pcmFramesToDiscard;
3906
3907 /*
3908 Now at this point we can follow the same process as the brute force technique where we just skip over unnecessary MP3 frames and then
3909 read-and-discard at least 2 whole MP3 frames.
3910 */
3911 leftoverFrames = frameIndex - pMP3->currentPCMFrame;
3912 return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, leftoverFrames);
3913}
3914
3915DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex)
3916{
3917 if (pMP3 == NULL || pMP3->onSeek == NULL) {
3918 return DRMP3_FALSE;
3919 }
3920
3921 if (frameIndex == 0) {
3922 return drmp3_seek_to_start_of_stream(pMP3);
3923 }
3924
3925 /* Use the seek table if we have one. */
3926 if (pMP3->pSeekPoints != NULL && pMP3->seekPointCount > 0) {
3927 return drmp3_seek_to_pcm_frame__seek_table(pMP3, frameIndex);
3928 } else {
3929 return drmp3_seek_to_pcm_frame__brute_force(pMP3, frameIndex);
3930 }
3931}
3932
3933DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount)
3934{
3935 drmp3_uint64 currentPCMFrame;
3936 drmp3_uint64 totalPCMFrameCount;
3937 drmp3_uint64 totalMP3FrameCount;
3938
3939 if (pMP3 == NULL) {
3940 return DRMP3_FALSE;
3941 }
3942
3943 /*
3944 The way this works is we move back to the start of the stream, iterate over each MP3 frame and calculate the frame count based
3945 on our output sample rate, the seek back to the PCM frame we were sitting on before calling this function.
3946 */
3947
3948 /* The stream must support seeking for this to work. */
3949 if (pMP3->onSeek == NULL) {
3950 return DRMP3_FALSE;
3951 }
3952
3953 /* We'll need to seek back to where we were, so grab the PCM frame we're currently sitting on so we can restore later. */
3954 currentPCMFrame = pMP3->currentPCMFrame;
3955
3956 if (!drmp3_seek_to_start_of_stream(pMP3)) {
3957 return DRMP3_FALSE;
3958 }
3959
3960 totalPCMFrameCount = 0;
3961 totalMP3FrameCount = 0;
3962
3963 for (;;) {
3964 drmp3_uint32 pcmFramesInCurrentMP3Frame;
3965
3966 pcmFramesInCurrentMP3Frame = drmp3_decode_next_frame_ex(pMP3, NULL);
3967 if (pcmFramesInCurrentMP3Frame == 0) {
3968 break;
3969 }
3970
3971 totalPCMFrameCount += pcmFramesInCurrentMP3Frame;
3972 totalMP3FrameCount += 1;
3973 }
3974
3975 /* Finally, we need to seek back to where we were. */
3976 if (!drmp3_seek_to_start_of_stream(pMP3)) {
3977 return DRMP3_FALSE;
3978 }
3979
3980 if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
3981 return DRMP3_FALSE;
3982 }
3983
3984 if (pMP3FrameCount != NULL) {
3985 *pMP3FrameCount = totalMP3FrameCount;
3986 }
3987 if (pPCMFrameCount != NULL) {
3988 *pPCMFrameCount = totalPCMFrameCount;
3989 }
3990
3991 return DRMP3_TRUE;
3992}
3993
3994DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3)
3995{
3996 drmp3_uint64 totalPCMFrameCount;
3997 if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, NULL, &totalPCMFrameCount)) {
3998 return 0;
3999 }
4000
4001 return totalPCMFrameCount;
4002}
4003
4004DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3)
4005{
4006 drmp3_uint64 totalMP3FrameCount;
4007 if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, NULL)) {
4008 return 0;
4009 }
4010
4011 return totalMP3FrameCount;
4012}
4013
4014static void drmp3__accumulate_running_pcm_frame_count(drmp3* pMP3, drmp3_uint32 pcmFrameCountIn, drmp3_uint64* pRunningPCMFrameCount, float* pRunningPCMFrameCountFractionalPart)
4015{
4016 float srcRatio;
4017 float pcmFrameCountOutF;
4018 drmp3_uint32 pcmFrameCountOut;
4019
4020 srcRatio = (float)pMP3->mp3FrameSampleRate / (float)pMP3->sampleRate;
4021 DRMP3_ASSERT(srcRatio > 0);
4022
4023 pcmFrameCountOutF = *pRunningPCMFrameCountFractionalPart + (pcmFrameCountIn / srcRatio);
4024 pcmFrameCountOut = (drmp3_uint32)pcmFrameCountOutF;
4025 *pRunningPCMFrameCountFractionalPart = pcmFrameCountOutF - pcmFrameCountOut;
4026 *pRunningPCMFrameCount += pcmFrameCountOut;
4027}
4028
4029typedef struct
4030{
4031 drmp3_uint64 bytePos;
4032 drmp3_uint64 pcmFrameIndex; /* <-- After sample rate conversion. */
4033} drmp3__seeking_mp3_frame_info;
4034
4035DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints)
4036{
4037 drmp3_uint32 seekPointCount;
4038 drmp3_uint64 currentPCMFrame;
4039 drmp3_uint64 totalMP3FrameCount;
4040 drmp3_uint64 totalPCMFrameCount;
4041
4042 if (pMP3 == NULL || pSeekPointCount == NULL || pSeekPoints == NULL) {
4043 return DRMP3_FALSE; /* Invalid args. */
4044 }
4045
4046 seekPointCount = *pSeekPointCount;
4047 if (seekPointCount == 0) {
4048 return DRMP3_FALSE; /* The client has requested no seek points. Consider this to be invalid arguments since the client has probably not intended this. */
4049 }
4050
4051 /* We'll need to seek back to the current sample after calculating the seekpoints so we need to go ahead and grab the current location at the top. */
4052 currentPCMFrame = pMP3->currentPCMFrame;
4053
4054 /* We never do more than the total number of MP3 frames and we limit it to 32-bits. */
4055 if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, &totalPCMFrameCount)) {
4056 return DRMP3_FALSE;
4057 }
4058
4059 /* If there's less than DRMP3_SEEK_LEADING_MP3_FRAMES+1 frames we just report 1 seek point which will be the very start of the stream. */
4060 if (totalMP3FrameCount < DRMP3_SEEK_LEADING_MP3_FRAMES+1) {
4061 seekPointCount = 1;
4062 pSeekPoints[0].seekPosInBytes = 0;
4063 pSeekPoints[0].pcmFrameIndex = 0;
4064 pSeekPoints[0].mp3FramesToDiscard = 0;
4065 pSeekPoints[0].pcmFramesToDiscard = 0;
4066 } else {
4067 drmp3_uint64 pcmFramesBetweenSeekPoints;
4068 drmp3__seeking_mp3_frame_info mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES+1];
4069 drmp3_uint64 runningPCMFrameCount = 0;
4070 float runningPCMFrameCountFractionalPart = 0;
4071 drmp3_uint64 nextTargetPCMFrame;
4072 drmp3_uint32 iMP3Frame;
4073 drmp3_uint32 iSeekPoint;
4074
4075 if (seekPointCount > totalMP3FrameCount-1) {
4076 seekPointCount = (drmp3_uint32)totalMP3FrameCount-1;
4077 }
4078
4079 pcmFramesBetweenSeekPoints = totalPCMFrameCount / (seekPointCount+1);
4080
4081 /*
4082 Here is where we actually calculate the seek points. We need to start by moving the start of the stream. We then enumerate over each
4083 MP3 frame.
4084 */
4085 if (!drmp3_seek_to_start_of_stream(pMP3)) {
4086 return DRMP3_FALSE;
4087 }
4088
4089 /*
4090 We need to cache the byte positions of the previous MP3 frames. As a new MP3 frame is iterated, we cycle the byte positions in this
4091 array. The value in the first item in this array is the byte position that will be reported in the next seek point.
4092 */
4093
4094 /* We need to initialize the array of MP3 byte positions for the leading MP3 frames. */
4095 for (iMP3Frame = 0; iMP3Frame < DRMP3_SEEK_LEADING_MP3_FRAMES+1; ++iMP3Frame) {
4096 drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
4097
4098 /* The byte position of the next frame will be the stream's cursor position, minus whatever is sitting in the buffer. */
4099 DRMP3_ASSERT(pMP3->streamCursor >= pMP3->dataSize);
4100 mp3FrameInfo[iMP3Frame].bytePos = pMP3->streamCursor - pMP3->dataSize;
4101 mp3FrameInfo[iMP3Frame].pcmFrameIndex = runningPCMFrameCount;
4102
4103 /* We need to get information about this frame so we can know how many samples it contained. */
4104 pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
4105 if (pcmFramesInCurrentMP3FrameIn == 0) {
4106 return DRMP3_FALSE; /* This should never happen. */
4107 }
4108
4109 drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
4110 }
4111
4112 /*
4113 At this point we will have extracted the byte positions of the leading MP3 frames. We can now start iterating over each seek point and
4114 calculate them.
4115 */
4116 nextTargetPCMFrame = 0;
4117 for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) {
4118 nextTargetPCMFrame += pcmFramesBetweenSeekPoints;
4119
4120 for (;;) {
4121 if (nextTargetPCMFrame < runningPCMFrameCount) {
4122 /* The next seek point is in the current MP3 frame. */
4123 pSeekPoints[iSeekPoint].seekPosInBytes = mp3FrameInfo[0].bytePos;
4124 pSeekPoints[iSeekPoint].pcmFrameIndex = nextTargetPCMFrame;
4125 pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
4126 pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
4127 break;
4128 } else {
4129 size_t i;
4130 drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
4131
4132 /*
4133 The next seek point is not in the current MP3 frame, so continue on to the next one. The first thing to do is cycle the cached
4134 MP3 frame info.
4135 */
4136 for (i = 0; i < DRMP3_COUNTOF(mp3FrameInfo)-1; ++i) {
4137 mp3FrameInfo[i] = mp3FrameInfo[i+1];
4138 }
4139
4140 /* Cache previous MP3 frame info. */
4141 mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].bytePos = pMP3->streamCursor - pMP3->dataSize;
4142 mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].pcmFrameIndex = runningPCMFrameCount;
4143
4144 /*
4145 Go to the next MP3 frame. This shouldn't ever fail, but just in case it does we just set the seek point and break. If it happens, it
4146 should only ever do it for the last seek point.
4147 */
4148 pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
4149 if (pcmFramesInCurrentMP3FrameIn == 0) {
4150 pSeekPoints[iSeekPoint].seekPosInBytes = mp3FrameInfo[0].bytePos;
4151 pSeekPoints[iSeekPoint].pcmFrameIndex = nextTargetPCMFrame;
4152 pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
4153 pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
4154 break;
4155 }
4156
4157 drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
4158 }
4159 }
4160 }
4161
4162 /* Finally, we need to seek back to where we were. */
4163 if (!drmp3_seek_to_start_of_stream(pMP3)) {
4164 return DRMP3_FALSE;
4165 }
4166 if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
4167 return DRMP3_FALSE;
4168 }
4169 }
4170
4171 *pSeekPointCount = seekPointCount;
4172 return DRMP3_TRUE;
4173}
4174
4175DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints)
4176{
4177 if (pMP3 == NULL) {
4178 return DRMP3_FALSE;
4179 }
4180
4181 if (seekPointCount == 0 || pSeekPoints == NULL) {
4182 /* Unbinding. */
4183 pMP3->seekPointCount = 0;
4184 pMP3->pSeekPoints = NULL;
4185 } else {
4186 /* Binding. */
4187 pMP3->seekPointCount = seekPointCount;
4188 pMP3->pSeekPoints = pSeekPoints;
4189 }
4190
4191 return DRMP3_TRUE;
4192}
4193
4194
4195static float* drmp3__full_read_and_close_f32(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
4196{
4197 drmp3_uint64 totalFramesRead = 0;
4198 drmp3_uint64 framesCapacity = 0;
4199 float* pFrames = NULL;
4200 float temp[4096];
4201
4202 DRMP3_ASSERT(pMP3 != NULL);
4203
4204 for (;;) {
4205 drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
4206 drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp);
4207 if (framesJustRead == 0) {
4208 break;
4209 }
4210
4211 /* Reallocate the output buffer if there's not enough room. */
4212 if (framesCapacity < totalFramesRead + framesJustRead) {
4213 drmp3_uint64 oldFramesBufferSize;
4214 drmp3_uint64 newFramesBufferSize;
4215 drmp3_uint64 newFramesCap;
4216 float* pNewFrames;
4217
4218 newFramesCap = framesCapacity * 2;
4219 if (newFramesCap < totalFramesRead + framesJustRead) {
4220 newFramesCap = totalFramesRead + framesJustRead;
4221 }
4222
4223 oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(float);
4224 newFramesBufferSize = newFramesCap * pMP3->channels * sizeof(float);
4225 if (newFramesBufferSize > (drmp3_uint64)DRMP3_SIZE_MAX) {
4226 break;
4227 }
4228
4229 pNewFrames = (float*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
4230 if (pNewFrames == NULL) {
4231 drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
4232 break;
4233 }
4234
4235 pFrames = pNewFrames;
4236 framesCapacity = newFramesCap;
4237 }
4238
4239 DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(float)));
4240 totalFramesRead += framesJustRead;
4241
4242 /* If the number of frames we asked for is less that what we actually read it means we've reached the end. */
4243 if (framesJustRead != framesToReadRightNow) {
4244 break;
4245 }
4246 }
4247
4248 if (pConfig != NULL) {
4249 pConfig->channels = pMP3->channels;
4250 pConfig->sampleRate = pMP3->sampleRate;
4251 }
4252
4253 drmp3_uninit(pMP3);
4254
4255 if (pTotalFrameCount) {
4256 *pTotalFrameCount = totalFramesRead;
4257 }
4258
4259 return pFrames;
4260}
4261
4262static drmp3_int16* drmp3__full_read_and_close_s16(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
4263{
4264 drmp3_uint64 totalFramesRead = 0;
4265 drmp3_uint64 framesCapacity = 0;
4266 drmp3_int16* pFrames = NULL;
4267 drmp3_int16 temp[4096];
4268
4269 DRMP3_ASSERT(pMP3 != NULL);
4270
4271 for (;;) {
4272 drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
4273 drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp);
4274 if (framesJustRead == 0) {
4275 break;
4276 }
4277
4278 /* Reallocate the output buffer if there's not enough room. */
4279 if (framesCapacity < totalFramesRead + framesJustRead) {
4280 drmp3_uint64 newFramesBufferSize;
4281 drmp3_uint64 oldFramesBufferSize;
4282 drmp3_uint64 newFramesCap;
4283 drmp3_int16* pNewFrames;
4284
4285 newFramesCap = framesCapacity * 2;
4286 if (newFramesCap < totalFramesRead + framesJustRead) {
4287 newFramesCap = totalFramesRead + framesJustRead;
4288 }
4289
4290 oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(drmp3_int16);
4291 newFramesBufferSize = newFramesCap * pMP3->channels * sizeof(drmp3_int16);
4292 if (newFramesBufferSize > (drmp3_uint64)DRMP3_SIZE_MAX) {
4293 break;
4294 }
4295
4296 pNewFrames = (drmp3_int16*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
4297 if (pNewFrames == NULL) {
4298 drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
4299 break;
4300 }
4301
4302 pFrames = pNewFrames;
4303 framesCapacity = newFramesCap;
4304 }
4305
4306 DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(drmp3_int16)));
4307 totalFramesRead += framesJustRead;
4308
4309 /* If the number of frames we asked for is less that what we actually read it means we've reached the end. */
4310 if (framesJustRead != framesToReadRightNow) {
4311 break;
4312 }
4313 }
4314
4315 if (pConfig != NULL) {
4316 pConfig->channels = pMP3->channels;
4317 pConfig->sampleRate = pMP3->sampleRate;
4318 }
4319
4320 drmp3_uninit(pMP3);
4321
4322 if (pTotalFrameCount) {
4323 *pTotalFrameCount = totalFramesRead;
4324 }
4325
4326 return pFrames;
4327}
4328
4329
4330DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
4331{
4332 drmp3 mp3;
4333 if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
4334 return NULL;
4335 }
4336
4337 return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
4338}
4339
4340DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
4341{
4342 drmp3 mp3;
4343 if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
4344 return NULL;
4345 }
4346
4347 return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
4348}
4349
4350
4351DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
4352{
4353 drmp3 mp3;
4354 if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
4355 return NULL;
4356 }
4357
4358 return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
4359}
4360
4361DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
4362{
4363 drmp3 mp3;
4364 if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
4365 return NULL;
4366 }
4367
4368 return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
4369}
4370
4371
4372#ifndef DR_MP3_NO_STDIO
4373DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
4374{
4375 drmp3 mp3;
4376 if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
4377 return NULL;
4378 }
4379
4380 return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
4381}
4382
4383DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
4384{
4385 drmp3 mp3;
4386 if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
4387 return NULL;
4388 }
4389
4390 return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
4391}
4392#endif
4393
4394DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
4395{
4396 if (pAllocationCallbacks != NULL) {
4397 return drmp3__malloc_from_callbacks(sz, pAllocationCallbacks);
4398 } else {
4399 return drmp3__malloc_default(sz, NULL);
4400 }
4401}
4402
4403DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
4404{
4405 if (pAllocationCallbacks != NULL) {
4406 drmp3__free_from_callbacks(p, pAllocationCallbacks);
4407 } else {
4408 drmp3__free_default(p, NULL);
4409 }
4410}
4411
4412#endif /* dr_mp3_c */
4413#endif /*DR_MP3_IMPLEMENTATION*/
4414
4415/*
4416DIFFERENCES BETWEEN minimp3 AND dr_mp3
4417======================================
4418- First, keep in mind that minimp3 (https://github.com/lieff/minimp3) is where all the real work was done. All of the
4419 code relating to the actual decoding remains mostly unmodified, apart from some namespacing changes.
4420- dr_mp3 adds a pulling style API which allows you to deliver raw data via callbacks. So, rather than pushing data
4421 to the decoder, the decoder _pulls_ data from your callbacks.
4422- In addition to callbacks, a decoder can be initialized from a block of memory and a file.
4423- The dr_mp3 pull API reads PCM frames rather than whole MP3 frames.
4424- dr_mp3 adds convenience APIs for opening and decoding entire files in one go.
4425- dr_mp3 is fully namespaced, including the implementation section, which is more suitable when compiling projects
4426 as a single translation unit (aka unity builds). At the time of writing this, a unity build is not possible when
4427 using minimp3 in conjunction with stb_vorbis. dr_mp3 addresses this.
4428*/
4429
4430/*
4431RELEASE NOTES - v0.5.0
4432=======================
4433Version 0.5.0 has breaking API changes.
4434
4435Improved Client-Defined Memory Allocation
4436-----------------------------------------
4437The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
4438existing system of DRMP3_MALLOC, DRMP3_REALLOC and DRMP3_FREE are still in place and will be used by default when no custom
4439allocation callbacks are specified.
4440
4441To use the new system, you pass in a pointer to a drmp3_allocation_callbacks object to drmp3_init() and family, like this:
4442
4443 void* my_malloc(size_t sz, void* pUserData)
4444 {
4445 return malloc(sz);
4446 }
4447 void* my_realloc(void* p, size_t sz, void* pUserData)
4448 {
4449 return realloc(p, sz);
4450 }
4451 void my_free(void* p, void* pUserData)
4452 {
4453 free(p);
4454 }
4455
4456 ...
4457
4458 drmp3_allocation_callbacks allocationCallbacks;
4459 allocationCallbacks.pUserData = &myData;
4460 allocationCallbacks.onMalloc = my_malloc;
4461 allocationCallbacks.onRealloc = my_realloc;
4462 allocationCallbacks.onFree = my_free;
4463 drmp3_init_file(&mp3, "my_file.mp3", NULL, &allocationCallbacks);
4464
4465The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
4466
4467Passing in null for the allocation callbacks object will cause dr_mp3 to use defaults which is the same as DRMP3_MALLOC,
4468DRMP3_REALLOC and DRMP3_FREE and the equivalent of how it worked in previous versions.
4469
4470Every API that opens a drmp3 object now takes this extra parameter. These include the following:
4471
4472 drmp3_init()
4473 drmp3_init_file()
4474 drmp3_init_memory()
4475 drmp3_open_and_read_pcm_frames_f32()
4476 drmp3_open_and_read_pcm_frames_s16()
4477 drmp3_open_memory_and_read_pcm_frames_f32()
4478 drmp3_open_memory_and_read_pcm_frames_s16()
4479 drmp3_open_file_and_read_pcm_frames_f32()
4480 drmp3_open_file_and_read_pcm_frames_s16()
4481
4482Renamed APIs
4483------------
4484The following APIs have been renamed for consistency with other dr_* libraries and to make it clear that they return PCM frame
4485counts rather than sample counts.
4486
4487 drmp3_open_and_read_f32() -> drmp3_open_and_read_pcm_frames_f32()
4488 drmp3_open_and_read_s16() -> drmp3_open_and_read_pcm_frames_s16()
4489 drmp3_open_memory_and_read_f32() -> drmp3_open_memory_and_read_pcm_frames_f32()
4490 drmp3_open_memory_and_read_s16() -> drmp3_open_memory_and_read_pcm_frames_s16()
4491 drmp3_open_file_and_read_f32() -> drmp3_open_file_and_read_pcm_frames_f32()
4492 drmp3_open_file_and_read_s16() -> drmp3_open_file_and_read_pcm_frames_s16()
4493*/
4494
4495/*
4496REVISION HISTORY
4497================
4498v0.6.39 - 2024-02-27
4499 - Fix a Wdouble-promotion warning.
4500
4501v0.6.38 - 2023-11-02
4502 - Fix build for ARMv6-M.
4503
4504v0.6.37 - 2023-07-07
4505 - Silence a static analysis warning.
4506
4507v0.6.36 - 2023-06-17
4508 - Fix an incorrect date in revision history. No functional change.
4509
4510v0.6.35 - 2023-05-22
4511 - Minor code restructure. No functional change.
4512
4513v0.6.34 - 2022-09-17
4514 - Fix compilation with DJGPP.
4515 - Fix compilation when compiling with x86 with no SSE2.
4516 - Remove an unnecessary variable from the drmp3 structure.
4517
4518v0.6.33 - 2022-04-10
4519 - Fix compilation error with the MSVC ARM64 build.
4520 - Fix compilation error on older versions of GCC.
4521 - Remove some unused functions.
4522
4523v0.6.32 - 2021-12-11
4524 - Fix a warning with Clang.
4525
4526v0.6.31 - 2021-08-22
4527 - Fix a bug when loading from memory.
4528
4529v0.6.30 - 2021-08-16
4530 - Silence some warnings.
4531 - Replace memory operations with DRMP3_* macros.
4532
4533v0.6.29 - 2021-08-08
4534 - Bring up to date with minimp3.
4535
4536v0.6.28 - 2021-07-31
4537 - Fix platform detection for ARM64.
4538 - Fix a compilation error with C89.
4539
4540v0.6.27 - 2021-02-21
4541 - Fix a warning due to referencing _MSC_VER when it is undefined.
4542
4543v0.6.26 - 2021-01-31
4544 - Bring up to date with minimp3.
4545
4546v0.6.25 - 2020-12-26
4547 - Remove DRMP3_DEFAULT_CHANNELS and DRMP3_DEFAULT_SAMPLE_RATE which are leftovers from some removed APIs.
4548
4549v0.6.24 - 2020-12-07
4550 - Fix a typo in version date for 0.6.23.
4551
4552v0.6.23 - 2020-12-03
4553 - Fix an error where a file can be closed twice when initialization of the decoder fails.
4554
4555v0.6.22 - 2020-12-02
4556 - Fix an error where it's possible for a file handle to be left open when initialization of the decoder fails.
4557
4558v0.6.21 - 2020-11-28
4559 - Bring up to date with minimp3.
4560
4561v0.6.20 - 2020-11-21
4562 - Fix compilation with OpenWatcom.
4563
4564v0.6.19 - 2020-11-13
4565 - Minor code clean up.
4566
4567v0.6.18 - 2020-11-01
4568 - Improve compiler support for older versions of GCC.
4569
4570v0.6.17 - 2020-09-28
4571 - Bring up to date with minimp3.
4572
4573v0.6.16 - 2020-08-02
4574 - Simplify sized types.
4575
4576v0.6.15 - 2020-07-25
4577 - Fix a compilation warning.
4578
4579v0.6.14 - 2020-07-23
4580 - Fix undefined behaviour with memmove().
4581
4582v0.6.13 - 2020-07-06
4583 - Fix a bug when converting from s16 to f32 in drmp3_read_pcm_frames_f32().
4584
4585v0.6.12 - 2020-06-23
4586 - Add include guard for the implementation section.
4587
4588v0.6.11 - 2020-05-26
4589 - Fix use of uninitialized variable error.
4590
4591v0.6.10 - 2020-05-16
4592 - Add compile-time and run-time version querying.
4593 - DRMP3_VERSION_MINOR
4594 - DRMP3_VERSION_MAJOR
4595 - DRMP3_VERSION_REVISION
4596 - DRMP3_VERSION_STRING
4597 - drmp3_version()
4598 - drmp3_version_string()
4599
4600v0.6.9 - 2020-04-30
4601 - Change the `pcm` parameter of drmp3dec_decode_frame() to a `const drmp3_uint8*` for consistency with internal APIs.
4602
4603v0.6.8 - 2020-04-26
4604 - Optimizations to decoding when initializing from memory.
4605
4606v0.6.7 - 2020-04-25
4607 - Fix a compilation error with DR_MP3_NO_STDIO
4608 - Optimization to decoding by reducing some data movement.
4609
4610v0.6.6 - 2020-04-23
4611 - Fix a minor bug with the running PCM frame counter.
4612
4613v0.6.5 - 2020-04-19
4614 - Fix compilation error on ARM builds.
4615
4616v0.6.4 - 2020-04-19
4617 - Bring up to date with changes to minimp3.
4618
4619v0.6.3 - 2020-04-13
4620 - Fix some pedantic warnings.
4621
4622v0.6.2 - 2020-04-10
4623 - Fix a crash in drmp3_open_*_and_read_pcm_frames_*() if the output config object is NULL.
4624
4625v0.6.1 - 2020-04-05
4626 - Fix warnings.
4627
4628v0.6.0 - 2020-04-04
4629 - API CHANGE: Remove the pConfig parameter from the following APIs:
4630 - drmp3_init()
4631 - drmp3_init_memory()
4632 - drmp3_init_file()
4633 - Add drmp3_init_file_w() for opening a file from a wchar_t encoded path.
4634
4635v0.5.6 - 2020-02-12
4636 - Bring up to date with minimp3.
4637
4638v0.5.5 - 2020-01-29
4639 - Fix a memory allocation bug in high level s16 decoding APIs.
4640
4641v0.5.4 - 2019-12-02
4642 - Fix a possible null pointer dereference when using custom memory allocators for realloc().
4643
4644v0.5.3 - 2019-11-14
4645 - Fix typos in documentation.
4646
4647v0.5.2 - 2019-11-02
4648 - Bring up to date with minimp3.
4649
4650v0.5.1 - 2019-10-08
4651 - Fix a warning with GCC.
4652
4653v0.5.0 - 2019-10-07
4654 - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
4655 routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
4656 - drmp3_init()
4657 - drmp3_init_file()
4658 - drmp3_init_memory()
4659 - drmp3_open_and_read_pcm_frames_f32()
4660 - drmp3_open_and_read_pcm_frames_s16()
4661 - drmp3_open_memory_and_read_pcm_frames_f32()
4662 - drmp3_open_memory_and_read_pcm_frames_s16()
4663 - drmp3_open_file_and_read_pcm_frames_f32()
4664 - drmp3_open_file_and_read_pcm_frames_s16()
4665 - API CHANGE: Renamed the following APIs:
4666 - drmp3_open_and_read_f32() -> drmp3_open_and_read_pcm_frames_f32()
4667 - drmp3_open_and_read_s16() -> drmp3_open_and_read_pcm_frames_s16()
4668 - drmp3_open_memory_and_read_f32() -> drmp3_open_memory_and_read_pcm_frames_f32()
4669 - drmp3_open_memory_and_read_s16() -> drmp3_open_memory_and_read_pcm_frames_s16()
4670 - drmp3_open_file_and_read_f32() -> drmp3_open_file_and_read_pcm_frames_f32()
4671 - drmp3_open_file_and_read_s16() -> drmp3_open_file_and_read_pcm_frames_s16()
4672
4673v0.4.7 - 2019-07-28
4674 - Fix a compiler error.
4675
4676v0.4.6 - 2019-06-14
4677 - Fix a compiler error.
4678
4679v0.4.5 - 2019-06-06
4680 - Bring up to date with minimp3.
4681
4682v0.4.4 - 2019-05-06
4683 - Fixes to the VC6 build.
4684
4685v0.4.3 - 2019-05-05
4686 - Use the channel count and/or sample rate of the first MP3 frame instead of DRMP3_DEFAULT_CHANNELS and
4687 DRMP3_DEFAULT_SAMPLE_RATE when they are set to 0. To use the old behaviour, just set the relevant property to
4688 DRMP3_DEFAULT_CHANNELS or DRMP3_DEFAULT_SAMPLE_RATE.
4689 - Add s16 reading APIs
4690 - drmp3_read_pcm_frames_s16
4691 - drmp3_open_memory_and_read_pcm_frames_s16
4692 - drmp3_open_and_read_pcm_frames_s16
4693 - drmp3_open_file_and_read_pcm_frames_s16
4694 - Add drmp3_get_mp3_and_pcm_frame_count() to the public header section.
4695 - Add support for C89.
4696 - Change license to choice of public domain or MIT-0.
4697
4698v0.4.2 - 2019-02-21
4699 - Fix a warning.
4700
4701v0.4.1 - 2018-12-30
4702 - Fix a warning.
4703
4704v0.4.0 - 2018-12-16
4705 - API CHANGE: Rename some APIs:
4706 - drmp3_read_f32 -> to drmp3_read_pcm_frames_f32
4707 - drmp3_seek_to_frame -> drmp3_seek_to_pcm_frame
4708 - drmp3_open_and_decode_f32 -> drmp3_open_and_read_pcm_frames_f32
4709 - drmp3_open_and_decode_memory_f32 -> drmp3_open_memory_and_read_pcm_frames_f32
4710 - drmp3_open_and_decode_file_f32 -> drmp3_open_file_and_read_pcm_frames_f32
4711 - Add drmp3_get_pcm_frame_count().
4712 - Add drmp3_get_mp3_frame_count().
4713 - Improve seeking performance.
4714
4715v0.3.2 - 2018-09-11
4716 - Fix a couple of memory leaks.
4717 - Bring up to date with minimp3.
4718
4719v0.3.1 - 2018-08-25
4720 - Fix C++ build.
4721
4722v0.3.0 - 2018-08-25
4723 - Bring up to date with minimp3. This has a minor API change: the "pcm" parameter of drmp3dec_decode_frame() has
4724 been changed from short* to void* because it can now output both s16 and f32 samples, depending on whether or
4725 not the DR_MP3_FLOAT_OUTPUT option is set.
4726
4727v0.2.11 - 2018-08-08
4728 - Fix a bug where the last part of a file is not read.
4729
4730v0.2.10 - 2018-08-07
4731 - Improve 64-bit detection.
4732
4733v0.2.9 - 2018-08-05
4734 - Fix C++ build on older versions of GCC.
4735 - Bring up to date with minimp3.
4736
4737v0.2.8 - 2018-08-02
4738 - Fix compilation errors with older versions of GCC.
4739
4740v0.2.7 - 2018-07-13
4741 - Bring up to date with minimp3.
4742
4743v0.2.6 - 2018-07-12
4744 - Bring up to date with minimp3.
4745
4746v0.2.5 - 2018-06-22
4747 - Bring up to date with minimp3.
4748
4749v0.2.4 - 2018-05-12
4750 - Bring up to date with minimp3.
4751
4752v0.2.3 - 2018-04-29
4753 - Fix TCC build.
4754
4755v0.2.2 - 2018-04-28
4756 - Fix bug when opening a decoder from memory.
4757
4758v0.2.1 - 2018-04-27
4759 - Efficiency improvements when the decoder reaches the end of the stream.
4760
4761v0.2 - 2018-04-21
4762 - Bring up to date with minimp3.
4763 - Start using major.minor.revision versioning.
4764
4765v0.1d - 2018-03-30
4766 - Bring up to date with minimp3.
4767
4768v0.1c - 2018-03-11
4769 - Fix C++ build error.
4770
4771v0.1b - 2018-03-07
4772 - Bring up to date with minimp3.
4773
4774v0.1a - 2018-02-28
4775 - Fix compilation error on GCC/Clang.
4776 - Fix some warnings.
4777
4778v0.1 - 2018-02-xx
4779 - Initial versioned release.
4780*/
4781
4782/*
4783This software is available as a choice of the following licenses. Choose
4784whichever you prefer.
4785
4786===============================================================================
4787ALTERNATIVE 1 - Public Domain (www.unlicense.org)
4788===============================================================================
4789This is free and unencumbered software released into the public domain.
4790
4791Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
4792software, either in source code form or as a compiled binary, for any purpose,
4793commercial or non-commercial, and by any means.
4794
4795In jurisdictions that recognize copyright laws, the author or authors of this
4796software dedicate any and all copyright interest in the software to the public
4797domain. We make this dedication for the benefit of the public at large and to
4798the detriment of our heirs and successors. We intend this dedication to be an
4799overt act of relinquishment in perpetuity of all present and future rights to
4800this software under copyright law.
4801
4802THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4803IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4804FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4805AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
4806ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
4807WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4808
4809For more information, please refer to <http://unlicense.org/>
4810
4811===============================================================================
4812ALTERNATIVE 2 - MIT No Attribution
4813===============================================================================
4814Copyright 2023 David Reid
4815
4816Permission is hereby granted, free of charge, to any person obtaining a copy of
4817this software and associated documentation files (the "Software"), to deal in
4818the Software without restriction, including without limitation the rights to
4819use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
4820of the Software, and to permit persons to whom the Software is furnished to do
4821so.
4822
4823THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4824IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4825FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4826AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4827LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4828OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4829SOFTWARE.
4830*/
4831
4832/*
4833 https://github.com/lieff/minimp3
4834 To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide.
4835 This software is distributed without any warranty.
4836 See <http://creativecommons.org/publicdomain/zero/1.0/>.
4837*/
diff --git a/raylib/src/external/dr_wav.h b/raylib/src/external/dr_wav.h
new file mode 100644
index 0000000..a8207ab
--- /dev/null
+++ b/raylib/src/external/dr_wav.h
@@ -0,0 +1,8815 @@
1/*
2WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
3dr_wav - v0.13.16 - 2024-02-27
4
5David Reid - mackron@gmail.com
6
7GitHub: https://github.com/mackron/dr_libs
8*/
9
10/*
11Introduction
12============
13This is a single file library. To use it, do something like the following in one .c file.
14
15 ```c
16 #define DR_WAV_IMPLEMENTATION
17 #include "dr_wav.h"
18 ```
19
20You can then #include this file in other parts of the program as you would with any other header file. Do something like the following to read audio data:
21
22 ```c
23 drwav wav;
24 if (!drwav_init_file(&wav, "my_song.wav", NULL)) {
25 // Error opening WAV file.
26 }
27
28 drwav_int32* pDecodedInterleavedPCMFrames = malloc(wav.totalPCMFrameCount * wav.channels * sizeof(drwav_int32));
29 size_t numberOfSamplesActuallyDecoded = drwav_read_pcm_frames_s32(&wav, wav.totalPCMFrameCount, pDecodedInterleavedPCMFrames);
30
31 ...
32
33 drwav_uninit(&wav);
34 ```
35
36If you just want to quickly open and read the audio data in a single operation you can do something like this:
37
38 ```c
39 unsigned int channels;
40 unsigned int sampleRate;
41 drwav_uint64 totalPCMFrameCount;
42 float* pSampleData = drwav_open_file_and_read_pcm_frames_f32("my_song.wav", &channels, &sampleRate, &totalPCMFrameCount, NULL);
43 if (pSampleData == NULL) {
44 // Error opening and reading WAV file.
45 }
46
47 ...
48
49 drwav_free(pSampleData, NULL);
50 ```
51
52The examples above use versions of the API that convert the audio data to a consistent format (32-bit signed PCM, in this case), but you can still output the
53audio data in its internal format (see notes below for supported formats):
54
55 ```c
56 size_t framesRead = drwav_read_pcm_frames(&wav, wav.totalPCMFrameCount, pDecodedInterleavedPCMFrames);
57 ```
58
59You can also read the raw bytes of audio data, which could be useful if dr_wav does not have native support for a particular data format:
60
61 ```c
62 size_t bytesRead = drwav_read_raw(&wav, bytesToRead, pRawDataBuffer);
63 ```
64
65dr_wav can also be used to output WAV files. This does not currently support compressed formats. To use this, look at `drwav_init_write()`,
66`drwav_init_file_write()`, etc. Use `drwav_write_pcm_frames()` to write samples, or `drwav_write_raw()` to write raw data in the "data" chunk.
67
68 ```c
69 drwav_data_format format;
70 format.container = drwav_container_riff; // <-- drwav_container_riff = normal WAV files, drwav_container_w64 = Sony Wave64.
71 format.format = DR_WAVE_FORMAT_PCM; // <-- Any of the DR_WAVE_FORMAT_* codes.
72 format.channels = 2;
73 format.sampleRate = 44100;
74 format.bitsPerSample = 16;
75 drwav_init_file_write(&wav, "data/recording.wav", &format, NULL);
76
77 ...
78
79 drwav_uint64 framesWritten = drwav_write_pcm_frames(pWav, frameCount, pSamples);
80 ```
81
82Note that writing to AIFF or RIFX is not supported.
83
84dr_wav has support for decoding from a number of different encapsulation formats. See below for details.
85
86
87Build Options
88=============
89#define these options before including this file.
90
91#define DR_WAV_NO_CONVERSION_API
92 Disables conversion APIs such as `drwav_read_pcm_frames_f32()` and `drwav_s16_to_f32()`.
93
94#define DR_WAV_NO_STDIO
95 Disables APIs that initialize a decoder from a file such as `drwav_init_file()`, `drwav_init_file_write()`, etc.
96
97#define DR_WAV_NO_WCHAR
98 Disables all functions ending with `_w`. Use this if your compiler does not provide wchar.h. Not required if DR_WAV_NO_STDIO is also defined.
99
100
101Supported Encapsulations
102========================
103- RIFF (Regular WAV)
104- RIFX (Big-Endian)
105- AIFF (Does not currently support ADPCM)
106- RF64
107- W64
108
109Note that AIFF and RIFX do not support write mode, nor do they support reading of metadata.
110
111
112Supported Encodings
113===================
114- Unsigned 8-bit PCM
115- Signed 12-bit PCM
116- Signed 16-bit PCM
117- Signed 24-bit PCM
118- Signed 32-bit PCM
119- IEEE 32-bit floating point
120- IEEE 64-bit floating point
121- A-law and u-law
122- Microsoft ADPCM
123- IMA ADPCM (DVI, format code 0x11)
124
1258-bit PCM encodings are always assumed to be unsigned. Signed 8-bit encoding can only be read with `drwav_read_raw()`.
126
127Note that ADPCM is not currently supported with AIFF. Contributions welcome.
128
129
130Notes
131=====
132- Samples are always interleaved.
133- The default read function does not do any data conversion. Use `drwav_read_pcm_frames_f32()`, `drwav_read_pcm_frames_s32()` and `drwav_read_pcm_frames_s16()`
134 to read and convert audio data to 32-bit floating point, signed 32-bit integer and signed 16-bit integer samples respectively.
135- dr_wav will try to read the WAV file as best it can, even if it's not strictly conformant to the WAV format.
136*/
137
138#ifndef dr_wav_h
139#define dr_wav_h
140
141#ifdef __cplusplus
142extern "C" {
143#endif
144
145#define DRWAV_STRINGIFY(x) #x
146#define DRWAV_XSTRINGIFY(x) DRWAV_STRINGIFY(x)
147
148#define DRWAV_VERSION_MAJOR 0
149#define DRWAV_VERSION_MINOR 13
150#define DRWAV_VERSION_REVISION 16
151#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
152
153#include <stddef.h> /* For size_t. */
154
155/* Sized Types */
156typedef signed char drwav_int8;
157typedef unsigned char drwav_uint8;
158typedef signed short drwav_int16;
159typedef unsigned short drwav_uint16;
160typedef signed int drwav_int32;
161typedef unsigned int drwav_uint32;
162#if defined(_MSC_VER) && !defined(__clang__)
163 typedef signed __int64 drwav_int64;
164 typedef unsigned __int64 drwav_uint64;
165#else
166 #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
167 #pragma GCC diagnostic push
168 #pragma GCC diagnostic ignored "-Wlong-long"
169 #if defined(__clang__)
170 #pragma GCC diagnostic ignored "-Wc++11-long-long"
171 #endif
172 #endif
173 typedef signed long long drwav_int64;
174 typedef unsigned long long drwav_uint64;
175 #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
176 #pragma GCC diagnostic pop
177 #endif
178#endif
179#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__)
180 typedef drwav_uint64 drwav_uintptr;
181#else
182 typedef drwav_uint32 drwav_uintptr;
183#endif
184typedef drwav_uint8 drwav_bool8;
185typedef drwav_uint32 drwav_bool32;
186#define DRWAV_TRUE 1
187#define DRWAV_FALSE 0
188/* End Sized Types */
189
190/* Decorations */
191#if !defined(DRWAV_API)
192 #if defined(DRWAV_DLL)
193 #if defined(_WIN32)
194 #define DRWAV_DLL_IMPORT __declspec(dllimport)
195 #define DRWAV_DLL_EXPORT __declspec(dllexport)
196 #define DRWAV_DLL_PRIVATE static
197 #else
198 #if defined(__GNUC__) && __GNUC__ >= 4
199 #define DRWAV_DLL_IMPORT __attribute__((visibility("default")))
200 #define DRWAV_DLL_EXPORT __attribute__((visibility("default")))
201 #define DRWAV_DLL_PRIVATE __attribute__((visibility("hidden")))
202 #else
203 #define DRWAV_DLL_IMPORT
204 #define DRWAV_DLL_EXPORT
205 #define DRWAV_DLL_PRIVATE static
206 #endif
207 #endif
208
209 #if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
210 #define DRWAV_API DRWAV_DLL_EXPORT
211 #else
212 #define DRWAV_API DRWAV_DLL_IMPORT
213 #endif
214 #define DRWAV_PRIVATE DRWAV_DLL_PRIVATE
215 #else
216 #define DRWAV_API extern
217 #define DRWAV_PRIVATE static
218 #endif
219#endif
220/* End Decorations */
221
222/* Result Codes */
223typedef drwav_int32 drwav_result;
224#define DRWAV_SUCCESS 0
225#define DRWAV_ERROR -1 /* A generic error. */
226#define DRWAV_INVALID_ARGS -2
227#define DRWAV_INVALID_OPERATION -3
228#define DRWAV_OUT_OF_MEMORY -4
229#define DRWAV_OUT_OF_RANGE -5
230#define DRWAV_ACCESS_DENIED -6
231#define DRWAV_DOES_NOT_EXIST -7
232#define DRWAV_ALREADY_EXISTS -8
233#define DRWAV_TOO_MANY_OPEN_FILES -9
234#define DRWAV_INVALID_FILE -10
235#define DRWAV_TOO_BIG -11
236#define DRWAV_PATH_TOO_LONG -12
237#define DRWAV_NAME_TOO_LONG -13
238#define DRWAV_NOT_DIRECTORY -14
239#define DRWAV_IS_DIRECTORY -15
240#define DRWAV_DIRECTORY_NOT_EMPTY -16
241#define DRWAV_END_OF_FILE -17
242#define DRWAV_NO_SPACE -18
243#define DRWAV_BUSY -19
244#define DRWAV_IO_ERROR -20
245#define DRWAV_INTERRUPT -21
246#define DRWAV_UNAVAILABLE -22
247#define DRWAV_ALREADY_IN_USE -23
248#define DRWAV_BAD_ADDRESS -24
249#define DRWAV_BAD_SEEK -25
250#define DRWAV_BAD_PIPE -26
251#define DRWAV_DEADLOCK -27
252#define DRWAV_TOO_MANY_LINKS -28
253#define DRWAV_NOT_IMPLEMENTED -29
254#define DRWAV_NO_MESSAGE -30
255#define DRWAV_BAD_MESSAGE -31
256#define DRWAV_NO_DATA_AVAILABLE -32
257#define DRWAV_INVALID_DATA -33
258#define DRWAV_TIMEOUT -34
259#define DRWAV_NO_NETWORK -35
260#define DRWAV_NOT_UNIQUE -36
261#define DRWAV_NOT_SOCKET -37
262#define DRWAV_NO_ADDRESS -38
263#define DRWAV_BAD_PROTOCOL -39
264#define DRWAV_PROTOCOL_UNAVAILABLE -40
265#define DRWAV_PROTOCOL_NOT_SUPPORTED -41
266#define DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED -42
267#define DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED -43
268#define DRWAV_SOCKET_NOT_SUPPORTED -44
269#define DRWAV_CONNECTION_RESET -45
270#define DRWAV_ALREADY_CONNECTED -46
271#define DRWAV_NOT_CONNECTED -47
272#define DRWAV_CONNECTION_REFUSED -48
273#define DRWAV_NO_HOST -49
274#define DRWAV_IN_PROGRESS -50
275#define DRWAV_CANCELLED -51
276#define DRWAV_MEMORY_ALREADY_MAPPED -52
277#define DRWAV_AT_END -53
278/* End Result Codes */
279
280/* Common data formats. */
281#define DR_WAVE_FORMAT_PCM 0x1
282#define DR_WAVE_FORMAT_ADPCM 0x2
283#define DR_WAVE_FORMAT_IEEE_FLOAT 0x3
284#define DR_WAVE_FORMAT_ALAW 0x6
285#define DR_WAVE_FORMAT_MULAW 0x7
286#define DR_WAVE_FORMAT_DVI_ADPCM 0x11
287#define DR_WAVE_FORMAT_EXTENSIBLE 0xFFFE
288
289/* Flags to pass into drwav_init_ex(), etc. */
290#define DRWAV_SEQUENTIAL 0x00000001
291#define DRWAV_WITH_METADATA 0x00000002
292
293DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision);
294DRWAV_API const char* drwav_version_string(void);
295
296/* Allocation Callbacks */
297typedef struct
298{
299 void* pUserData;
300 void* (* onMalloc)(size_t sz, void* pUserData);
301 void* (* onRealloc)(void* p, size_t sz, void* pUserData);
302 void (* onFree)(void* p, void* pUserData);
303} drwav_allocation_callbacks;
304/* End Allocation Callbacks */
305
306typedef enum
307{
308 drwav_seek_origin_start,
309 drwav_seek_origin_current
310} drwav_seek_origin;
311
312typedef enum
313{
314 drwav_container_riff,
315 drwav_container_rifx,
316 drwav_container_w64,
317 drwav_container_rf64,
318 drwav_container_aiff
319} drwav_container;
320
321typedef struct
322{
323 union
324 {
325 drwav_uint8 fourcc[4];
326 drwav_uint8 guid[16];
327 } id;
328
329 /* The size in bytes of the chunk. */
330 drwav_uint64 sizeInBytes;
331
332 /*
333 RIFF = 2 byte alignment.
334 W64 = 8 byte alignment.
335 */
336 unsigned int paddingSize;
337} drwav_chunk_header;
338
339typedef struct
340{
341 /*
342 The format tag exactly as specified in the wave file's "fmt" chunk. This can be used by applications
343 that require support for data formats not natively supported by dr_wav.
344 */
345 drwav_uint16 formatTag;
346
347 /* The number of channels making up the audio data. When this is set to 1 it is mono, 2 is stereo, etc. */
348 drwav_uint16 channels;
349
350 /* The sample rate. Usually set to something like 44100. */
351 drwav_uint32 sampleRate;
352
353 /* Average bytes per second. You probably don't need this, but it's left here for informational purposes. */
354 drwav_uint32 avgBytesPerSec;
355
356 /* Block align. This is equal to the number of channels * bytes per sample. */
357 drwav_uint16 blockAlign;
358
359 /* Bits per sample. */
360 drwav_uint16 bitsPerSample;
361
362 /* The size of the extended data. Only used internally for validation, but left here for informational purposes. */
363 drwav_uint16 extendedSize;
364
365 /*
366 The number of valid bits per sample. When <formatTag> is equal to WAVE_FORMAT_EXTENSIBLE, <bitsPerSample>
367 is always rounded up to the nearest multiple of 8. This variable contains information about exactly how
368 many bits are valid per sample. Mainly used for informational purposes.
369 */
370 drwav_uint16 validBitsPerSample;
371
372 /* The channel mask. Not used at the moment. */
373 drwav_uint32 channelMask;
374
375 /* The sub-format, exactly as specified by the wave file. */
376 drwav_uint8 subFormat[16];
377} drwav_fmt;
378
379DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT);
380
381
382/*
383Callback for when data is read. Return value is the number of bytes actually read.
384
385pUserData [in] The user data that was passed to drwav_init() and family.
386pBufferOut [out] The output buffer.
387bytesToRead [in] The number of bytes to read.
388
389Returns the number of bytes actually read.
390
391A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until
392either the entire bytesToRead is filled or you have reached the end of the stream.
393*/
394typedef size_t (* drwav_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
395
396/*
397Callback for when data is written. Returns value is the number of bytes actually written.
398
399pUserData [in] The user data that was passed to drwav_init_write() and family.
400pData [out] A pointer to the data to write.
401bytesToWrite [in] The number of bytes to write.
402
403Returns the number of bytes actually written.
404
405If the return value differs from bytesToWrite, it indicates an error.
406*/
407typedef size_t (* drwav_write_proc)(void* pUserData, const void* pData, size_t bytesToWrite);
408
409/*
410Callback for when data needs to be seeked.
411
412pUserData [in] The user data that was passed to drwav_init() and family.
413offset [in] The number of bytes to move, relative to the origin. Will never be negative.
414origin [in] The origin of the seek - the current position or the start of the stream.
415
416Returns whether or not the seek was successful.
417
418Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which will be either drwav_seek_origin_start or
419drwav_seek_origin_current.
420*/
421typedef drwav_bool32 (* drwav_seek_proc)(void* pUserData, int offset, drwav_seek_origin origin);
422
423/*
424Callback for when drwav_init_ex() finds a chunk.
425
426pChunkUserData [in] The user data that was passed to the pChunkUserData parameter of drwav_init_ex() and family.
427onRead [in] A pointer to the function to call when reading.
428onSeek [in] A pointer to the function to call when seeking.
429pReadSeekUserData [in] The user data that was passed to the pReadSeekUserData parameter of drwav_init_ex() and family.
430pChunkHeader [in] A pointer to an object containing basic header information about the chunk. Use this to identify the chunk.
431container [in] Whether or not the WAV file is a RIFF or Wave64 container. If you're unsure of the difference, assume RIFF.
432pFMT [in] A pointer to the object containing the contents of the "fmt" chunk.
433
434Returns the number of bytes read + seeked.
435
436To read data from the chunk, call onRead(), passing in pReadSeekUserData as the first parameter. Do the same for seeking with onSeek(). The return value must
437be the total number of bytes you have read _plus_ seeked.
438
439Use the `container` argument to discriminate the fields in `pChunkHeader->id`. If the container is `drwav_container_riff` or `drwav_container_rf64` you should
440use `id.fourcc`, otherwise you should use `id.guid`.
441
442The `pFMT` parameter can be used to determine the data format of the wave file. Use `drwav_fmt_get_format()` to get the sample format, which will be one of the
443`DR_WAVE_FORMAT_*` identifiers.
444
445The read pointer will be sitting on the first byte after the chunk's header. You must not attempt to read beyond the boundary of the chunk.
446*/
447typedef drwav_uint64 (* drwav_chunk_proc)(void* pChunkUserData, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_chunk_header* pChunkHeader, drwav_container container, const drwav_fmt* pFMT);
448
449
450/* Structure for internal use. Only used for loaders opened with drwav_init_memory(). */
451typedef struct
452{
453 const drwav_uint8* data;
454 size_t dataSize;
455 size_t currentReadPos;
456} drwav__memory_stream;
457
458/* Structure for internal use. Only used for writers opened with drwav_init_memory_write(). */
459typedef struct
460{
461 void** ppData;
462 size_t* pDataSize;
463 size_t dataSize;
464 size_t dataCapacity;
465 size_t currentWritePos;
466} drwav__memory_stream_write;
467
468typedef struct
469{
470 drwav_container container; /* RIFF, W64. */
471 drwav_uint32 format; /* DR_WAVE_FORMAT_* */
472 drwav_uint32 channels;
473 drwav_uint32 sampleRate;
474 drwav_uint32 bitsPerSample;
475} drwav_data_format;
476
477typedef enum
478{
479 drwav_metadata_type_none = 0,
480
481 /*
482 Unknown simply means a chunk that drwav does not handle specifically. You can still ask to
483 receive these chunks as metadata objects. It is then up to you to interpret the chunk's data.
484 You can also write unknown metadata to a wav file. Be careful writing unknown chunks if you
485 have also edited the audio data. The unknown chunks could represent offsets/sizes that no
486 longer correctly correspond to the audio data.
487 */
488 drwav_metadata_type_unknown = 1 << 0,
489
490 /* Only 1 of each of these metadata items are allowed in a wav file. */
491 drwav_metadata_type_smpl = 1 << 1,
492 drwav_metadata_type_inst = 1 << 2,
493 drwav_metadata_type_cue = 1 << 3,
494 drwav_metadata_type_acid = 1 << 4,
495 drwav_metadata_type_bext = 1 << 5,
496
497 /*
498 Wav files often have a LIST chunk. This is a chunk that contains a set of subchunks. For this
499 higher-level metadata API, we don't make a distinction between a regular chunk and a LIST
500 subchunk. Instead, they are all just 'metadata' items.
501
502 There can be multiple of these metadata items in a wav file.
503 */
504 drwav_metadata_type_list_label = 1 << 6,
505 drwav_metadata_type_list_note = 1 << 7,
506 drwav_metadata_type_list_labelled_cue_region = 1 << 8,
507
508 drwav_metadata_type_list_info_software = 1 << 9,
509 drwav_metadata_type_list_info_copyright = 1 << 10,
510 drwav_metadata_type_list_info_title = 1 << 11,
511 drwav_metadata_type_list_info_artist = 1 << 12,
512 drwav_metadata_type_list_info_comment = 1 << 13,
513 drwav_metadata_type_list_info_date = 1 << 14,
514 drwav_metadata_type_list_info_genre = 1 << 15,
515 drwav_metadata_type_list_info_album = 1 << 16,
516 drwav_metadata_type_list_info_tracknumber = 1 << 17,
517
518 /* Other type constants for convenience. */
519 drwav_metadata_type_list_all_info_strings = drwav_metadata_type_list_info_software
520 | drwav_metadata_type_list_info_copyright
521 | drwav_metadata_type_list_info_title
522 | drwav_metadata_type_list_info_artist
523 | drwav_metadata_type_list_info_comment
524 | drwav_metadata_type_list_info_date
525 | drwav_metadata_type_list_info_genre
526 | drwav_metadata_type_list_info_album
527 | drwav_metadata_type_list_info_tracknumber,
528
529 drwav_metadata_type_list_all_adtl = drwav_metadata_type_list_label
530 | drwav_metadata_type_list_note
531 | drwav_metadata_type_list_labelled_cue_region,
532
533 drwav_metadata_type_all = -2, /*0xFFFFFFFF & ~drwav_metadata_type_unknown,*/
534 drwav_metadata_type_all_including_unknown = -1 /*0xFFFFFFFF,*/
535} drwav_metadata_type;
536
537/*
538Sampler Metadata
539
540The sampler chunk contains information about how a sound should be played in the context of a whole
541audio production, and when used in a sampler. See https://en.wikipedia.org/wiki/Sample-based_synthesis.
542*/
543typedef enum
544{
545 drwav_smpl_loop_type_forward = 0,
546 drwav_smpl_loop_type_pingpong = 1,
547 drwav_smpl_loop_type_backward = 2
548} drwav_smpl_loop_type;
549
550typedef struct
551{
552 /* The ID of the associated cue point, see drwav_cue and drwav_cue_point. As with all cue point IDs, this can correspond to a label chunk to give this loop a name, see drwav_list_label_or_note. */
553 drwav_uint32 cuePointId;
554
555 /* See drwav_smpl_loop_type. */
556 drwav_uint32 type;
557
558 /* The byte offset of the first sample to be played in the loop. */
559 drwav_uint32 firstSampleByteOffset;
560
561 /* The byte offset into the audio data of the last sample to be played in the loop. */
562 drwav_uint32 lastSampleByteOffset;
563
564 /* A value to represent that playback should occur at a point between samples. This value ranges from 0 to UINT32_MAX. Where a value of 0 means no fraction, and a value of (UINT32_MAX / 2) would mean half a sample. */
565 drwav_uint32 sampleFraction;
566
567 /* Number of times to play the loop. 0 means loop infinitely. */
568 drwav_uint32 playCount;
569} drwav_smpl_loop;
570
571typedef struct
572{
573 /* IDs for a particular MIDI manufacturer. 0 if not used. */
574 drwav_uint32 manufacturerId;
575 drwav_uint32 productId;
576
577 /* The period of 1 sample in nanoseconds. */
578 drwav_uint32 samplePeriodNanoseconds;
579
580 /* The MIDI root note of this file. 0 to 127. */
581 drwav_uint32 midiUnityNote;
582
583 /* The fraction of a semitone up from the given MIDI note. This is a value from 0 to UINT32_MAX, where 0 means no change and (UINT32_MAX / 2) is half a semitone (AKA 50 cents). */
584 drwav_uint32 midiPitchFraction;
585
586 /* Data relating to SMPTE standards which are used for syncing audio and video. 0 if not used. */
587 drwav_uint32 smpteFormat;
588 drwav_uint32 smpteOffset;
589
590 /* drwav_smpl_loop loops. */
591 drwav_uint32 sampleLoopCount;
592
593 /* Optional sampler-specific data. */
594 drwav_uint32 samplerSpecificDataSizeInBytes;
595
596 drwav_smpl_loop* pLoops;
597 drwav_uint8* pSamplerSpecificData;
598} drwav_smpl;
599
600/*
601Instrument Metadata
602
603The inst metadata contains data about how a sound should be played as part of an instrument. This
604commonly read by samplers. See https://en.wikipedia.org/wiki/Sample-based_synthesis.
605*/
606typedef struct
607{
608 drwav_int8 midiUnityNote; /* The root note of the audio as a MIDI note number. 0 to 127. */
609 drwav_int8 fineTuneCents; /* -50 to +50 */
610 drwav_int8 gainDecibels; /* -64 to +64 */
611 drwav_int8 lowNote; /* 0 to 127 */
612 drwav_int8 highNote; /* 0 to 127 */
613 drwav_int8 lowVelocity; /* 1 to 127 */
614 drwav_int8 highVelocity; /* 1 to 127 */
615} drwav_inst;
616
617/*
618Cue Metadata
619
620Cue points are markers at specific points in the audio. They often come with an associated piece of
621drwav_list_label_or_note metadata which contains the text for the marker.
622*/
623typedef struct
624{
625 /* Unique identification value. */
626 drwav_uint32 id;
627
628 /* Set to 0. This is only relevant if there is a 'playlist' chunk - which is not supported by dr_wav. */
629 drwav_uint32 playOrderPosition;
630
631 /* Should always be "data". This represents the fourcc value of the chunk that this cue point corresponds to. dr_wav only supports a single data chunk so this should always be "data". */
632 drwav_uint8 dataChunkId[4];
633
634 /* Set to 0. This is only relevant if there is a wave list chunk. dr_wav, like lots of readers/writers, do not support this. */
635 drwav_uint32 chunkStart;
636
637 /* Set to 0 for uncompressed formats. Else the last byte in compressed wave data where decompression can begin to find the value of the corresponding sample value. */
638 drwav_uint32 blockStart;
639
640 /* For uncompressed formats this is the byte offset of the cue point into the audio data. For compressed formats this is relative to the block specified with blockStart. */
641 drwav_uint32 sampleByteOffset;
642} drwav_cue_point;
643
644typedef struct
645{
646 drwav_uint32 cuePointCount;
647 drwav_cue_point *pCuePoints;
648} drwav_cue;
649
650/*
651Acid Metadata
652
653This chunk contains some information about the time signature and the tempo of the audio.
654*/
655typedef enum
656{
657 drwav_acid_flag_one_shot = 1, /* If this is not set, then it is a loop instead of a one-shot. */
658 drwav_acid_flag_root_note_set = 2,
659 drwav_acid_flag_stretch = 4,
660 drwav_acid_flag_disk_based = 8,
661 drwav_acid_flag_acidizer = 16 /* Not sure what this means. */
662} drwav_acid_flag;
663
664typedef struct
665{
666 /* A bit-field, see drwav_acid_flag. */
667 drwav_uint32 flags;
668
669 /* Valid if flags contains drwav_acid_flag_root_note_set. It represents the MIDI root note the file - a value from 0 to 127. */
670 drwav_uint16 midiUnityNote;
671
672 /* Reserved values that should probably be ignored. reserved1 seems to often be 128 and reserved2 is 0. */
673 drwav_uint16 reserved1;
674 float reserved2;
675
676 /* Number of beats. */
677 drwav_uint32 numBeats;
678
679 /* The time signature of the audio. */
680 drwav_uint16 meterDenominator;
681 drwav_uint16 meterNumerator;
682
683 /* Beats per minute of the track. Setting a value of 0 suggests that there is no tempo. */
684 float tempo;
685} drwav_acid;
686
687/*
688Cue Label or Note metadata
689
690These are 2 different types of metadata, but they have the exact same format. Labels tend to be the
691more common and represent a short name for a cue point. Notes might be used to represent a longer
692comment.
693*/
694typedef struct
695{
696 /* The ID of a cue point that this label or note corresponds to. */
697 drwav_uint32 cuePointId;
698
699 /* Size of the string not including any null terminator. */
700 drwav_uint32 stringLength;
701
702 /* The string. The *init_with_metadata functions null terminate this for convenience. */
703 char* pString;
704} drwav_list_label_or_note;
705
706/*
707BEXT metadata, also known as Broadcast Wave Format (BWF)
708
709This metadata adds some extra description to an audio file. You must check the version field to
710determine if the UMID or the loudness fields are valid.
711*/
712typedef struct
713{
714 /*
715 These top 3 fields, and the umid field are actually defined in the standard as a statically
716 sized buffers. In order to reduce the size of this struct (and therefore the union in the
717 metadata struct), we instead store these as pointers.
718 */
719 char* pDescription; /* Can be NULL or a null-terminated string, must be <= 256 characters. */
720 char* pOriginatorName; /* Can be NULL or a null-terminated string, must be <= 32 characters. */
721 char* pOriginatorReference; /* Can be NULL or a null-terminated string, must be <= 32 characters. */
722 char pOriginationDate[10]; /* ASCII "yyyy:mm:dd". */
723 char pOriginationTime[8]; /* ASCII "hh:mm:ss". */
724 drwav_uint64 timeReference; /* First sample count since midnight. */
725 drwav_uint16 version; /* Version of the BWF, check this to see if the fields below are valid. */
726
727 /*
728 Unrestricted ASCII characters containing a collection of strings terminated by CR/LF. Each
729 string shall contain a description of a coding process applied to the audio data.
730 */
731 char* pCodingHistory;
732 drwav_uint32 codingHistorySize;
733
734 /* Fields below this point are only valid if the version is 1 or above. */
735 drwav_uint8* pUMID; /* Exactly 64 bytes of SMPTE UMID */
736
737 /* Fields below this point are only valid if the version is 2 or above. */
738 drwav_uint16 loudnessValue; /* Integrated Loudness Value of the file in LUFS (multiplied by 100). */
739 drwav_uint16 loudnessRange; /* Loudness Range of the file in LU (multiplied by 100). */
740 drwav_uint16 maxTruePeakLevel; /* Maximum True Peak Level of the file expressed as dBTP (multiplied by 100). */
741 drwav_uint16 maxMomentaryLoudness; /* Highest value of the Momentary Loudness Level of the file in LUFS (multiplied by 100). */
742 drwav_uint16 maxShortTermLoudness; /* Highest value of the Short-Term Loudness Level of the file in LUFS (multiplied by 100). */
743} drwav_bext;
744
745/*
746Info Text Metadata
747
748There a many different types of information text that can be saved in this format. This is where
749things like the album name, the artists, the year it was produced, etc are saved. See
750drwav_metadata_type for the full list of types that dr_wav supports.
751*/
752typedef struct
753{
754 /* Size of the string not including any null terminator. */
755 drwav_uint32 stringLength;
756
757 /* The string. The *init_with_metadata functions null terminate this for convenience. */
758 char* pString;
759} drwav_list_info_text;
760
761/*
762Labelled Cue Region Metadata
763
764The labelled cue region metadata is used to associate some region of audio with text. The region
765starts at a cue point, and extends for the given number of samples.
766*/
767typedef struct
768{
769 /* The ID of a cue point that this object corresponds to. */
770 drwav_uint32 cuePointId;
771
772 /* The number of samples from the cue point forwards that should be considered this region */
773 drwav_uint32 sampleLength;
774
775 /* Four characters used to say what the purpose of this region is. */
776 drwav_uint8 purposeId[4];
777
778 /* Unsure of the exact meanings of these. It appears to be acceptable to set them all to 0. */
779 drwav_uint16 country;
780 drwav_uint16 language;
781 drwav_uint16 dialect;
782 drwav_uint16 codePage;
783
784 /* Size of the string not including any null terminator. */
785 drwav_uint32 stringLength;
786
787 /* The string. The *init_with_metadata functions null terminate this for convenience. */
788 char* pString;
789} drwav_list_labelled_cue_region;
790
791/*
792Unknown Metadata
793
794This chunk just represents a type of chunk that dr_wav does not understand.
795
796Unknown metadata has a location attached to it. This is because wav files can have a LIST chunk
797that contains subchunks. These LIST chunks can be one of two types. An adtl list, or an INFO
798list. This enum is used to specify the location of a chunk that dr_wav currently doesn't support.
799*/
800typedef enum
801{
802 drwav_metadata_location_invalid,
803 drwav_metadata_location_top_level,
804 drwav_metadata_location_inside_info_list,
805 drwav_metadata_location_inside_adtl_list
806} drwav_metadata_location;
807
808typedef struct
809{
810 drwav_uint8 id[4];
811 drwav_metadata_location chunkLocation;
812 drwav_uint32 dataSizeInBytes;
813 drwav_uint8* pData;
814} drwav_unknown_metadata;
815
816/*
817Metadata is saved as a union of all the supported types.
818*/
819typedef struct
820{
821 /* Determines which item in the union is valid. */
822 drwav_metadata_type type;
823
824 union
825 {
826 drwav_cue cue;
827 drwav_smpl smpl;
828 drwav_acid acid;
829 drwav_inst inst;
830 drwav_bext bext;
831 drwav_list_label_or_note labelOrNote; /* List label or list note. */
832 drwav_list_labelled_cue_region labelledCueRegion;
833 drwav_list_info_text infoText; /* Any of the list info types. */
834 drwav_unknown_metadata unknown;
835 } data;
836} drwav_metadata;
837
838typedef struct
839{
840 /* A pointer to the function to call when more data is needed. */
841 drwav_read_proc onRead;
842
843 /* A pointer to the function to call when data needs to be written. Only used when the drwav object is opened in write mode. */
844 drwav_write_proc onWrite;
845
846 /* A pointer to the function to call when the wav file needs to be seeked. */
847 drwav_seek_proc onSeek;
848
849 /* The user data to pass to callbacks. */
850 void* pUserData;
851
852 /* Allocation callbacks. */
853 drwav_allocation_callbacks allocationCallbacks;
854
855
856 /* Whether or not the WAV file is formatted as a standard RIFF file or W64. */
857 drwav_container container;
858
859
860 /* Structure containing format information exactly as specified by the wav file. */
861 drwav_fmt fmt;
862
863 /* The sample rate. Will be set to something like 44100. */
864 drwav_uint32 sampleRate;
865
866 /* The number of channels. This will be set to 1 for monaural streams, 2 for stereo, etc. */
867 drwav_uint16 channels;
868
869 /* The bits per sample. Will be set to something like 16, 24, etc. */
870 drwav_uint16 bitsPerSample;
871
872 /* Equal to fmt.formatTag, or the value specified by fmt.subFormat if fmt.formatTag is equal to 65534 (WAVE_FORMAT_EXTENSIBLE). */
873 drwav_uint16 translatedFormatTag;
874
875 /* The total number of PCM frames making up the audio data. */
876 drwav_uint64 totalPCMFrameCount;
877
878
879 /* The size in bytes of the data chunk. */
880 drwav_uint64 dataChunkDataSize;
881
882 /* The position in the stream of the first data byte of the data chunk. This is used for seeking. */
883 drwav_uint64 dataChunkDataPos;
884
885 /* The number of bytes remaining in the data chunk. */
886 drwav_uint64 bytesRemaining;
887
888 /* The current read position in PCM frames. */
889 drwav_uint64 readCursorInPCMFrames;
890
891
892 /*
893 Only used in sequential write mode. Keeps track of the desired size of the "data" chunk at the point of initialization time. Always
894 set to 0 for non-sequential writes and when the drwav object is opened in read mode. Used for validation.
895 */
896 drwav_uint64 dataChunkDataSizeTargetWrite;
897
898 /* Keeps track of whether or not the wav writer was initialized in sequential mode. */
899 drwav_bool32 isSequentialWrite;
900
901
902 /* A array of metadata. This is valid after the *init_with_metadata call returns. It will be valid until drwav_uninit() is called. You can take ownership of this data with drwav_take_ownership_of_metadata(). */
903 drwav_metadata* pMetadata;
904 drwav_uint32 metadataCount;
905
906
907 /* A hack to avoid a DRWAV_MALLOC() when opening a decoder with drwav_init_memory(). */
908 drwav__memory_stream memoryStream;
909 drwav__memory_stream_write memoryStreamWrite;
910
911
912 /* Microsoft ADPCM specific data. */
913 struct
914 {
915 drwav_uint32 bytesRemainingInBlock;
916 drwav_uint16 predictor[2];
917 drwav_int32 delta[2];
918 drwav_int32 cachedFrames[4]; /* Samples are stored in this cache during decoding. */
919 drwav_uint32 cachedFrameCount;
920 drwav_int32 prevFrames[2][2]; /* The previous 2 samples for each channel (2 channels at most). */
921 } msadpcm;
922
923 /* IMA ADPCM specific data. */
924 struct
925 {
926 drwav_uint32 bytesRemainingInBlock;
927 drwav_int32 predictor[2];
928 drwav_int32 stepIndex[2];
929 drwav_int32 cachedFrames[16]; /* Samples are stored in this cache during decoding. */
930 drwav_uint32 cachedFrameCount;
931 } ima;
932
933 /* AIFF specific data. */
934 struct
935 {
936 drwav_bool8 isLE; /* Will be set to true if the audio data is little-endian encoded. */
937 drwav_bool8 isUnsigned; /* Only used for 8-bit samples. When set to true, will be treated as unsigned. */
938 } aiff;
939} drwav;
940
941
942/*
943Initializes a pre-allocated drwav object for reading.
944
945pWav [out] A pointer to the drwav object being initialized.
946onRead [in] The function to call when data needs to be read from the client.
947onSeek [in] The function to call when the read position of the client data needs to move.
948onChunk [in, optional] The function to call when a chunk is enumerated at initialized time.
949pUserData, pReadSeekUserData [in, optional] A pointer to application defined data that will be passed to onRead and onSeek.
950pChunkUserData [in, optional] A pointer to application defined data that will be passed to onChunk.
951flags [in, optional] A set of flags for controlling how things are loaded.
952
953Returns true if successful; false otherwise.
954
955Close the loader with drwav_uninit().
956
957This is the lowest level function for initializing a WAV file. You can also use drwav_init_file() and drwav_init_memory()
958to open the stream from a file or from a block of memory respectively.
959
960Possible values for flags:
961 DRWAV_SEQUENTIAL: Never perform a backwards seek while loading. This disables the chunk callback and will cause this function
962 to return as soon as the data chunk is found. Any chunks after the data chunk will be ignored.
963
964drwav_init() is equivalent to "drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0);".
965
966The onChunk callback is not called for the WAVE or FMT chunks. The contents of the FMT chunk can be read from pWav->fmt
967after the function returns.
968
969See also: drwav_init_file(), drwav_init_memory(), drwav_uninit()
970*/
971DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
972DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
973DRWAV_API drwav_bool32 drwav_init_with_metadata(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
974
975/*
976Initializes a pre-allocated drwav object for writing.
977
978onWrite [in] The function to call when data needs to be written.
979onSeek [in] The function to call when the write position needs to move.
980pUserData [in, optional] A pointer to application defined data that will be passed to onWrite and onSeek.
981metadata, numMetadata [in, optional] An array of metadata objects that should be written to the file. The array is not edited. You are responsible for this metadata memory and it must maintain valid until drwav_uninit() is called.
982
983Returns true if successful; false otherwise.
984
985Close the writer with drwav_uninit().
986
987This is the lowest level function for initializing a WAV file. You can also use drwav_init_file_write() and drwav_init_memory_write()
988to open the stream from a file or from a block of memory respectively.
989
990If the total sample count is known, you can use drwav_init_write_sequential(). This avoids the need for dr_wav to perform
991a post-processing step for storing the total sample count and the size of the data chunk which requires a backwards seek.
992
993See also: drwav_init_file_write(), drwav_init_memory_write(), drwav_uninit()
994*/
995DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
996DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
997DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
998DRWAV_API drwav_bool32 drwav_init_write_with_metadata(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks, drwav_metadata* pMetadata, drwav_uint32 metadataCount);
999
1000/*
1001Utility function to determine the target size of the entire data to be written (including all headers and chunks).
1002
1003Returns the target size in bytes.
1004
1005The metadata argument can be NULL meaning no metadata exists.
1006
1007Useful if the application needs to know the size to allocate.
1008
1009Only writing to the RIFF chunk and one data chunk is currently supported.
1010
1011See also: drwav_init_write(), drwav_init_file_write(), drwav_init_memory_write()
1012*/
1013DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalFrameCount, drwav_metadata* pMetadata, drwav_uint32 metadataCount);
1014
1015/*
1016Take ownership of the metadata objects that were allocated via one of the init_with_metadata() function calls. The init_with_metdata functions perform a single heap allocation for this metadata.
1017
1018Useful if you want the data to persist beyond the lifetime of the drwav object.
1019
1020You must free the data returned from this function using drwav_free().
1021*/
1022DRWAV_API drwav_metadata* drwav_take_ownership_of_metadata(drwav* pWav);
1023
1024/*
1025Uninitializes the given drwav object.
1026
1027Use this only for objects initialized with drwav_init*() functions (drwav_init(), drwav_init_ex(), drwav_init_write(), drwav_init_write_sequential()).
1028*/
1029DRWAV_API drwav_result drwav_uninit(drwav* pWav);
1030
1031
1032/*
1033Reads raw audio data.
1034
1035This is the lowest level function for reading audio data. It simply reads the given number of
1036bytes of the raw internal sample data.
1037
1038Consider using drwav_read_pcm_frames_s16(), drwav_read_pcm_frames_s32() or drwav_read_pcm_frames_f32() for
1039reading sample data in a consistent format.
1040
1041pBufferOut can be NULL in which case a seek will be performed.
1042
1043Returns the number of bytes actually read.
1044*/
1045DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut);
1046
1047/*
1048Reads up to the specified number of PCM frames from the WAV file.
1049
1050The output data will be in the file's internal format, converted to native-endian byte order. Use
1051drwav_read_pcm_frames_s16/f32/s32() to read data in a specific format.
1052
1053If the return value is less than <framesToRead> it means the end of the file has been reached or
1054you have requested more PCM frames than can possibly fit in the output buffer.
1055
1056This function will only work when sample data is of a fixed size and uncompressed. If you are
1057using a compressed format consider using drwav_read_raw() or drwav_read_pcm_frames_s16/s32/f32().
1058
1059pBufferOut can be NULL in which case a seek will be performed.
1060*/
1061DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
1062DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
1063DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
1064
1065/*
1066Seeks to the given PCM frame.
1067
1068Returns true if successful; false otherwise.
1069*/
1070DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex);
1071
1072/*
1073Retrieves the current read position in pcm frames.
1074*/
1075DRWAV_API drwav_result drwav_get_cursor_in_pcm_frames(drwav* pWav, drwav_uint64* pCursor);
1076
1077/*
1078Retrieves the length of the file.
1079*/
1080DRWAV_API drwav_result drwav_get_length_in_pcm_frames(drwav* pWav, drwav_uint64* pLength);
1081
1082
1083/*
1084Writes raw audio data.
1085
1086Returns the number of bytes actually written. If this differs from bytesToWrite, it indicates an error.
1087*/
1088DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData);
1089
1090/*
1091Writes PCM frames.
1092
1093Returns the number of PCM frames written.
1094
1095Input samples need to be in native-endian byte order. On big-endian architectures the input data will be converted to
1096little-endian. Use drwav_write_raw() to write raw audio data without performing any conversion.
1097*/
1098DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
1099DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
1100DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
1101
1102/* Conversion Utilities */
1103#ifndef DR_WAV_NO_CONVERSION_API
1104
1105/*
1106Reads a chunk of audio data and converts it to signed 16-bit PCM samples.
1107
1108pBufferOut can be NULL in which case a seek will be performed.
1109
1110Returns the number of PCM frames actually read.
1111
1112If the return value is less than <framesToRead> it means the end of the file has been reached.
1113*/
1114DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
1115DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
1116DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
1117
1118/* Low-level function for converting unsigned 8-bit PCM samples to signed 16-bit PCM samples. */
1119DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
1120
1121/* Low-level function for converting signed 24-bit PCM samples to signed 16-bit PCM samples. */
1122DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
1123
1124/* Low-level function for converting signed 32-bit PCM samples to signed 16-bit PCM samples. */
1125DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount);
1126
1127/* Low-level function for converting IEEE 32-bit floating point samples to signed 16-bit PCM samples. */
1128DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount);
1129
1130/* Low-level function for converting IEEE 64-bit floating point samples to signed 16-bit PCM samples. */
1131DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount);
1132
1133/* Low-level function for converting A-law samples to signed 16-bit PCM samples. */
1134DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
1135
1136/* Low-level function for converting u-law samples to signed 16-bit PCM samples. */
1137DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
1138
1139
1140/*
1141Reads a chunk of audio data and converts it to IEEE 32-bit floating point samples.
1142
1143pBufferOut can be NULL in which case a seek will be performed.
1144
1145Returns the number of PCM frames actually read.
1146
1147If the return value is less than <framesToRead> it means the end of the file has been reached.
1148*/
1149DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
1150DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
1151DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
1152
1153/* Low-level function for converting unsigned 8-bit PCM samples to IEEE 32-bit floating point samples. */
1154DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
1155
1156/* Low-level function for converting signed 16-bit PCM samples to IEEE 32-bit floating point samples. */
1157DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount);
1158
1159/* Low-level function for converting signed 24-bit PCM samples to IEEE 32-bit floating point samples. */
1160DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
1161
1162/* Low-level function for converting signed 32-bit PCM samples to IEEE 32-bit floating point samples. */
1163DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount);
1164
1165/* Low-level function for converting IEEE 64-bit floating point samples to IEEE 32-bit floating point samples. */
1166DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount);
1167
1168/* Low-level function for converting A-law samples to IEEE 32-bit floating point samples. */
1169DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
1170
1171/* Low-level function for converting u-law samples to IEEE 32-bit floating point samples. */
1172DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
1173
1174
1175/*
1176Reads a chunk of audio data and converts it to signed 32-bit PCM samples.
1177
1178pBufferOut can be NULL in which case a seek will be performed.
1179
1180Returns the number of PCM frames actually read.
1181
1182If the return value is less than <framesToRead> it means the end of the file has been reached.
1183*/
1184DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
1185DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
1186DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
1187
1188/* Low-level function for converting unsigned 8-bit PCM samples to signed 32-bit PCM samples. */
1189DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
1190
1191/* Low-level function for converting signed 16-bit PCM samples to signed 32-bit PCM samples. */
1192DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount);
1193
1194/* Low-level function for converting signed 24-bit PCM samples to signed 32-bit PCM samples. */
1195DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
1196
1197/* Low-level function for converting IEEE 32-bit floating point samples to signed 32-bit PCM samples. */
1198DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount);
1199
1200/* Low-level function for converting IEEE 64-bit floating point samples to signed 32-bit PCM samples. */
1201DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount);
1202
1203/* Low-level function for converting A-law samples to signed 32-bit PCM samples. */
1204DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
1205
1206/* Low-level function for converting u-law samples to signed 32-bit PCM samples. */
1207DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
1208
1209#endif /* DR_WAV_NO_CONVERSION_API */
1210
1211
1212/* High-Level Convenience Helpers */
1213
1214#ifndef DR_WAV_NO_STDIO
1215/*
1216Helper for initializing a wave file for reading using stdio.
1217
1218This holds the internal FILE object until drwav_uninit() is called. Keep this in mind if you're caching drwav
1219objects because the operating system may restrict the number of file handles an application can have open at
1220any given time.
1221*/
1222DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
1223DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
1224DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
1225DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
1226DRWAV_API drwav_bool32 drwav_init_file_with_metadata(drwav* pWav, const char* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
1227DRWAV_API drwav_bool32 drwav_init_file_with_metadata_w(drwav* pWav, const wchar_t* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
1228
1229
1230/*
1231Helper for initializing a wave file for writing using stdio.
1232
1233This holds the internal FILE object until drwav_uninit() is called. Keep this in mind if you're caching drwav
1234objects because the operating system may restrict the number of file handles an application can have open at
1235any given time.
1236*/
1237DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
1238DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
1239DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
1240DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
1241DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
1242DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
1243#endif /* DR_WAV_NO_STDIO */
1244
1245/*
1246Helper for initializing a loader from a pre-allocated memory buffer.
1247
1248This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for
1249the lifetime of the drwav object.
1250
1251The buffer should contain the contents of the entire wave file, not just the sample data.
1252*/
1253DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks);
1254DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
1255DRWAV_API drwav_bool32 drwav_init_memory_with_metadata(drwav* pWav, const void* data, size_t dataSize, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
1256
1257/*
1258Helper for initializing a writer which outputs data to a memory buffer.
1259
1260dr_wav will manage the memory allocations, however it is up to the caller to free the data with drwav_free().
1261
1262The buffer will remain allocated even after drwav_uninit() is called. The buffer should not be considered valid
1263until after drwav_uninit() has been called.
1264*/
1265DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
1266DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
1267DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
1268
1269
1270#ifndef DR_WAV_NO_CONVERSION_API
1271/*
1272Opens and reads an entire wav file in a single operation.
1273
1274The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
1275*/
1276DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1277DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1278DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1279#ifndef DR_WAV_NO_STDIO
1280/*
1281Opens and decodes an entire wav file in a single operation.
1282
1283The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
1284*/
1285DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1286DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1287DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1288DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1289DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1290DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1291#endif
1292/*
1293Opens and decodes an entire wav file from a block of memory in a single operation.
1294
1295The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
1296*/
1297DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1298DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1299DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
1300#endif
1301
1302/* Frees data that was allocated internally by dr_wav. */
1303DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks);
1304
1305/* Converts bytes from a wav stream to a sized type of native endian. */
1306DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data);
1307DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data);
1308DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data);
1309DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data);
1310DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data);
1311DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data);
1312DRWAV_API float drwav_bytes_to_f32(const drwav_uint8* data);
1313
1314/* Compares a GUID for the purpose of checking the type of a Wave64 chunk. */
1315DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16]);
1316
1317/* Compares a four-character-code for the purpose of checking the type of a RIFF chunk. */
1318DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b);
1319
1320#ifdef __cplusplus
1321}
1322#endif
1323#endif /* dr_wav_h */
1324
1325
1326/************************************************************************************************************************************************************
1327 ************************************************************************************************************************************************************
1328
1329 IMPLEMENTATION
1330
1331 ************************************************************************************************************************************************************
1332 ************************************************************************************************************************************************************/
1333#if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
1334#ifndef dr_wav_c
1335#define dr_wav_c
1336
1337#ifdef __MRC__
1338/* MrC currently doesn't compile dr_wav correctly with any optimizations enabled. */
1339#pragma options opt off
1340#endif
1341
1342#include <stdlib.h>
1343#include <string.h>
1344#include <limits.h> /* For INT_MAX */
1345
1346#ifndef DR_WAV_NO_STDIO
1347#include <stdio.h>
1348#ifndef DR_WAV_NO_WCHAR
1349#include <wchar.h>
1350#endif
1351#endif
1352
1353/* Standard library stuff. */
1354#ifndef DRWAV_ASSERT
1355#include <assert.h>
1356#define DRWAV_ASSERT(expression) assert(expression)
1357#endif
1358#ifndef DRWAV_MALLOC
1359#define DRWAV_MALLOC(sz) malloc((sz))
1360#endif
1361#ifndef DRWAV_REALLOC
1362#define DRWAV_REALLOC(p, sz) realloc((p), (sz))
1363#endif
1364#ifndef DRWAV_FREE
1365#define DRWAV_FREE(p) free((p))
1366#endif
1367#ifndef DRWAV_COPY_MEMORY
1368#define DRWAV_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
1369#endif
1370#ifndef DRWAV_ZERO_MEMORY
1371#define DRWAV_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
1372#endif
1373#ifndef DRWAV_ZERO_OBJECT
1374#define DRWAV_ZERO_OBJECT(p) DRWAV_ZERO_MEMORY((p), sizeof(*p))
1375#endif
1376
1377#define drwav_countof(x) (sizeof(x) / sizeof(x[0]))
1378#define drwav_align(x, a) ((((x) + (a) - 1) / (a)) * (a))
1379#define drwav_min(a, b) (((a) < (b)) ? (a) : (b))
1380#define drwav_max(a, b) (((a) > (b)) ? (a) : (b))
1381#define drwav_clamp(x, lo, hi) (drwav_max((lo), drwav_min((hi), (x))))
1382#define drwav_offset_ptr(p, offset) (((drwav_uint8*)(p)) + (offset))
1383
1384#define DRWAV_MAX_SIMD_VECTOR_SIZE 32
1385
1386/* Architecture Detection */
1387#if defined(__x86_64__) || defined(_M_X64)
1388 #define DRWAV_X64
1389#elif defined(__i386) || defined(_M_IX86)
1390 #define DRWAV_X86
1391#elif defined(__arm__) || defined(_M_ARM)
1392 #define DRWAV_ARM
1393#endif
1394/* End Architecture Detection */
1395
1396/* Inline */
1397#ifdef _MSC_VER
1398 #define DRWAV_INLINE __forceinline
1399#elif defined(__GNUC__)
1400 /*
1401 I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
1402 the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
1403 case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
1404 command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
1405 I am using "__inline__" only when we're compiling in strict ANSI mode.
1406 */
1407 #if defined(__STRICT_ANSI__)
1408 #define DRWAV_GNUC_INLINE_HINT __inline__
1409 #else
1410 #define DRWAV_GNUC_INLINE_HINT inline
1411 #endif
1412
1413 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
1414 #define DRWAV_INLINE DRWAV_GNUC_INLINE_HINT __attribute__((always_inline))
1415 #else
1416 #define DRWAV_INLINE DRWAV_GNUC_INLINE_HINT
1417 #endif
1418#elif defined(__WATCOMC__)
1419 #define DRWAV_INLINE __inline
1420#else
1421 #define DRWAV_INLINE
1422#endif
1423/* End Inline */
1424
1425/* SIZE_MAX */
1426#if defined(SIZE_MAX)
1427 #define DRWAV_SIZE_MAX SIZE_MAX
1428#else
1429 #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
1430 #define DRWAV_SIZE_MAX ((drwav_uint64)0xFFFFFFFFFFFFFFFF)
1431 #else
1432 #define DRWAV_SIZE_MAX 0xFFFFFFFF
1433 #endif
1434#endif
1435/* End SIZE_MAX */
1436
1437/* Weird bit manipulation is for C89 compatibility (no direct support for 64-bit integers). */
1438#define DRWAV_INT64_MIN ((drwav_int64) ((drwav_uint64)0x80000000 << 32))
1439#define DRWAV_INT64_MAX ((drwav_int64)(((drwav_uint64)0x7FFFFFFF << 32) | 0xFFFFFFFF))
1440
1441#if defined(_MSC_VER) && _MSC_VER >= 1400
1442 #define DRWAV_HAS_BYTESWAP16_INTRINSIC
1443 #define DRWAV_HAS_BYTESWAP32_INTRINSIC
1444 #define DRWAV_HAS_BYTESWAP64_INTRINSIC
1445#elif defined(__clang__)
1446 #if defined(__has_builtin)
1447 #if __has_builtin(__builtin_bswap16)
1448 #define DRWAV_HAS_BYTESWAP16_INTRINSIC
1449 #endif
1450 #if __has_builtin(__builtin_bswap32)
1451 #define DRWAV_HAS_BYTESWAP32_INTRINSIC
1452 #endif
1453 #if __has_builtin(__builtin_bswap64)
1454 #define DRWAV_HAS_BYTESWAP64_INTRINSIC
1455 #endif
1456 #endif
1457#elif defined(__GNUC__)
1458 #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1459 #define DRWAV_HAS_BYTESWAP32_INTRINSIC
1460 #define DRWAV_HAS_BYTESWAP64_INTRINSIC
1461 #endif
1462 #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
1463 #define DRWAV_HAS_BYTESWAP16_INTRINSIC
1464 #endif
1465#endif
1466
1467DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision)
1468{
1469 if (pMajor) {
1470 *pMajor = DRWAV_VERSION_MAJOR;
1471 }
1472
1473 if (pMinor) {
1474 *pMinor = DRWAV_VERSION_MINOR;
1475 }
1476
1477 if (pRevision) {
1478 *pRevision = DRWAV_VERSION_REVISION;
1479 }
1480}
1481
1482DRWAV_API const char* drwav_version_string(void)
1483{
1484 return DRWAV_VERSION_STRING;
1485}
1486
1487/*
1488These limits are used for basic validation when initializing the decoder. If you exceed these limits, first of all: what on Earth are
1489you doing?! (Let me know, I'd be curious!) Second, you can adjust these by #define-ing them before the dr_wav implementation.
1490*/
1491#ifndef DRWAV_MAX_SAMPLE_RATE
1492#define DRWAV_MAX_SAMPLE_RATE 384000
1493#endif
1494#ifndef DRWAV_MAX_CHANNELS
1495#define DRWAV_MAX_CHANNELS 256
1496#endif
1497#ifndef DRWAV_MAX_BITS_PER_SAMPLE
1498#define DRWAV_MAX_BITS_PER_SAMPLE 64
1499#endif
1500
1501static const drwav_uint8 drwavGUID_W64_RIFF[16] = {0x72,0x69,0x66,0x66, 0x2E,0x91, 0xCF,0x11, 0xA5,0xD6, 0x28,0xDB,0x04,0xC1,0x00,0x00}; /* 66666972-912E-11CF-A5D6-28DB04C10000 */
1502static const drwav_uint8 drwavGUID_W64_WAVE[16] = {0x77,0x61,0x76,0x65, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; /* 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
1503/*static const drwav_uint8 drwavGUID_W64_JUNK[16] = {0x6A,0x75,0x6E,0x6B, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};*/ /* 6B6E756A-ACF3-11D3-8CD1-00C04F8EDB8A */
1504static const drwav_uint8 drwavGUID_W64_FMT [16] = {0x66,0x6D,0x74,0x20, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; /* 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */
1505static const drwav_uint8 drwavGUID_W64_FACT[16] = {0x66,0x61,0x63,0x74, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; /* 74636166-ACF3-11D3-8CD1-00C04F8EDB8A */
1506static const drwav_uint8 drwavGUID_W64_DATA[16] = {0x64,0x61,0x74,0x61, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; /* 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */
1507/*static const drwav_uint8 drwavGUID_W64_SMPL[16] = {0x73,0x6D,0x70,0x6C, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};*/ /* 6C706D73-ACF3-11D3-8CD1-00C04F8EDB8A */
1508
1509
1510static DRWAV_INLINE int drwav__is_little_endian(void)
1511{
1512#if defined(DRWAV_X86) || defined(DRWAV_X64)
1513 return DRWAV_TRUE;
1514#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
1515 return DRWAV_TRUE;
1516#else
1517 int n = 1;
1518 return (*(char*)&n) == 1;
1519#endif
1520}
1521
1522
1523static DRWAV_INLINE void drwav_bytes_to_guid(const drwav_uint8* data, drwav_uint8* guid)
1524{
1525 int i;
1526 for (i = 0; i < 16; ++i) {
1527 guid[i] = data[i];
1528 }
1529}
1530
1531
1532static DRWAV_INLINE drwav_uint16 drwav__bswap16(drwav_uint16 n)
1533{
1534#ifdef DRWAV_HAS_BYTESWAP16_INTRINSIC
1535 #if defined(_MSC_VER)
1536 return _byteswap_ushort(n);
1537 #elif defined(__GNUC__) || defined(__clang__)
1538 return __builtin_bswap16(n);
1539 #else
1540 #error "This compiler does not support the byte swap intrinsic."
1541 #endif
1542#else
1543 return ((n & 0xFF00) >> 8) |
1544 ((n & 0x00FF) << 8);
1545#endif
1546}
1547
1548static DRWAV_INLINE drwav_uint32 drwav__bswap32(drwav_uint32 n)
1549{
1550#ifdef DRWAV_HAS_BYTESWAP32_INTRINSIC
1551 #if defined(_MSC_VER)
1552 return _byteswap_ulong(n);
1553 #elif defined(__GNUC__) || defined(__clang__)
1554 #if defined(DRWAV_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRWAV_64BIT) /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
1555 /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
1556 drwav_uint32 r;
1557 __asm__ __volatile__ (
1558 #if defined(DRWAV_64BIT)
1559 "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n) /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
1560 #else
1561 "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
1562 #endif
1563 );
1564 return r;
1565 #else
1566 return __builtin_bswap32(n);
1567 #endif
1568 #else
1569 #error "This compiler does not support the byte swap intrinsic."
1570 #endif
1571#else
1572 return ((n & 0xFF000000) >> 24) |
1573 ((n & 0x00FF0000) >> 8) |
1574 ((n & 0x0000FF00) << 8) |
1575 ((n & 0x000000FF) << 24);
1576#endif
1577}
1578
1579static DRWAV_INLINE drwav_uint64 drwav__bswap64(drwav_uint64 n)
1580{
1581#ifdef DRWAV_HAS_BYTESWAP64_INTRINSIC
1582 #if defined(_MSC_VER)
1583 return _byteswap_uint64(n);
1584 #elif defined(__GNUC__) || defined(__clang__)
1585 return __builtin_bswap64(n);
1586 #else
1587 #error "This compiler does not support the byte swap intrinsic."
1588 #endif
1589#else
1590 /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
1591 return ((n & ((drwav_uint64)0xFF000000 << 32)) >> 56) |
1592 ((n & ((drwav_uint64)0x00FF0000 << 32)) >> 40) |
1593 ((n & ((drwav_uint64)0x0000FF00 << 32)) >> 24) |
1594 ((n & ((drwav_uint64)0x000000FF << 32)) >> 8) |
1595 ((n & ((drwav_uint64)0xFF000000 )) << 8) |
1596 ((n & ((drwav_uint64)0x00FF0000 )) << 24) |
1597 ((n & ((drwav_uint64)0x0000FF00 )) << 40) |
1598 ((n & ((drwav_uint64)0x000000FF )) << 56);
1599#endif
1600}
1601
1602
1603static DRWAV_INLINE drwav_int16 drwav__bswap_s16(drwav_int16 n)
1604{
1605 return (drwav_int16)drwav__bswap16((drwav_uint16)n);
1606}
1607
1608static DRWAV_INLINE void drwav__bswap_samples_s16(drwav_int16* pSamples, drwav_uint64 sampleCount)
1609{
1610 drwav_uint64 iSample;
1611 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1612 pSamples[iSample] = drwav__bswap_s16(pSamples[iSample]);
1613 }
1614}
1615
1616
1617static DRWAV_INLINE void drwav__bswap_s24(drwav_uint8* p)
1618{
1619 drwav_uint8 t;
1620 t = p[0];
1621 p[0] = p[2];
1622 p[2] = t;
1623}
1624
1625static DRWAV_INLINE void drwav__bswap_samples_s24(drwav_uint8* pSamples, drwav_uint64 sampleCount)
1626{
1627 drwav_uint64 iSample;
1628 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1629 drwav_uint8* pSample = pSamples + (iSample*3);
1630 drwav__bswap_s24(pSample);
1631 }
1632}
1633
1634
1635static DRWAV_INLINE drwav_int32 drwav__bswap_s32(drwav_int32 n)
1636{
1637 return (drwav_int32)drwav__bswap32((drwav_uint32)n);
1638}
1639
1640static DRWAV_INLINE void drwav__bswap_samples_s32(drwav_int32* pSamples, drwav_uint64 sampleCount)
1641{
1642 drwav_uint64 iSample;
1643 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1644 pSamples[iSample] = drwav__bswap_s32(pSamples[iSample]);
1645 }
1646}
1647
1648
1649static DRWAV_INLINE drwav_int64 drwav__bswap_s64(drwav_int64 n)
1650{
1651 return (drwav_int64)drwav__bswap64((drwav_uint64)n);
1652}
1653
1654static DRWAV_INLINE void drwav__bswap_samples_s64(drwav_int64* pSamples, drwav_uint64 sampleCount)
1655{
1656 drwav_uint64 iSample;
1657 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1658 pSamples[iSample] = drwav__bswap_s64(pSamples[iSample]);
1659 }
1660}
1661
1662
1663static DRWAV_INLINE float drwav__bswap_f32(float n)
1664{
1665 union {
1666 drwav_uint32 i;
1667 float f;
1668 } x;
1669 x.f = n;
1670 x.i = drwav__bswap32(x.i);
1671
1672 return x.f;
1673}
1674
1675static DRWAV_INLINE void drwav__bswap_samples_f32(float* pSamples, drwav_uint64 sampleCount)
1676{
1677 drwav_uint64 iSample;
1678 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1679 pSamples[iSample] = drwav__bswap_f32(pSamples[iSample]);
1680 }
1681}
1682
1683
1684static DRWAV_INLINE void drwav__bswap_samples(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
1685{
1686 switch (bytesPerSample)
1687 {
1688 case 1:
1689 {
1690 /* No-op. */
1691 } break;
1692 case 2:
1693 {
1694 drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
1695 } break;
1696 case 3:
1697 {
1698 drwav__bswap_samples_s24((drwav_uint8*)pSamples, sampleCount);
1699 } break;
1700 case 4:
1701 {
1702 drwav__bswap_samples_s32((drwav_int32*)pSamples, sampleCount);
1703 } break;
1704 case 8:
1705 {
1706 drwav__bswap_samples_s64((drwav_int64*)pSamples, sampleCount);
1707 } break;
1708 default:
1709 {
1710 /* Unsupported format. */
1711 DRWAV_ASSERT(DRWAV_FALSE);
1712 } break;
1713 }
1714}
1715
1716
1717
1718DRWAV_PRIVATE DRWAV_INLINE drwav_bool32 drwav_is_container_be(drwav_container container)
1719{
1720 if (container == drwav_container_rifx || container == drwav_container_aiff) {
1721 return DRWAV_TRUE;
1722 } else {
1723 return DRWAV_FALSE;
1724 }
1725}
1726
1727
1728DRWAV_PRIVATE DRWAV_INLINE drwav_uint16 drwav_bytes_to_u16_le(const drwav_uint8* data)
1729{
1730 return ((drwav_uint16)data[0] << 0) | ((drwav_uint16)data[1] << 8);
1731}
1732
1733DRWAV_PRIVATE DRWAV_INLINE drwav_uint16 drwav_bytes_to_u16_be(const drwav_uint8* data)
1734{
1735 return ((drwav_uint16)data[1] << 0) | ((drwav_uint16)data[0] << 8);
1736}
1737
1738DRWAV_PRIVATE DRWAV_INLINE drwav_uint16 drwav_bytes_to_u16_ex(const drwav_uint8* data, drwav_container container)
1739{
1740 if (drwav_is_container_be(container)) {
1741 return drwav_bytes_to_u16_be(data);
1742 } else {
1743 return drwav_bytes_to_u16_le(data);
1744 }
1745}
1746
1747
1748DRWAV_PRIVATE DRWAV_INLINE drwav_uint32 drwav_bytes_to_u32_le(const drwav_uint8* data)
1749{
1750 return ((drwav_uint32)data[0] << 0) | ((drwav_uint32)data[1] << 8) | ((drwav_uint32)data[2] << 16) | ((drwav_uint32)data[3] << 24);
1751}
1752
1753DRWAV_PRIVATE DRWAV_INLINE drwav_uint32 drwav_bytes_to_u32_be(const drwav_uint8* data)
1754{
1755 return ((drwav_uint32)data[3] << 0) | ((drwav_uint32)data[2] << 8) | ((drwav_uint32)data[1] << 16) | ((drwav_uint32)data[0] << 24);
1756}
1757
1758DRWAV_PRIVATE DRWAV_INLINE drwav_uint32 drwav_bytes_to_u32_ex(const drwav_uint8* data, drwav_container container)
1759{
1760 if (drwav_is_container_be(container)) {
1761 return drwav_bytes_to_u32_be(data);
1762 } else {
1763 return drwav_bytes_to_u32_le(data);
1764 }
1765}
1766
1767
1768
1769DRWAV_PRIVATE drwav_int64 drwav_aiff_extented_to_s64(const drwav_uint8* data)
1770{
1771 drwav_uint32 exponent = ((drwav_uint32)data[0] << 8) | data[1];
1772 drwav_uint64 hi = ((drwav_uint64)data[2] << 24) | ((drwav_uint64)data[3] << 16) | ((drwav_uint64)data[4] << 8) | ((drwav_uint64)data[5] << 0);
1773 drwav_uint64 lo = ((drwav_uint64)data[6] << 24) | ((drwav_uint64)data[7] << 16) | ((drwav_uint64)data[8] << 8) | ((drwav_uint64)data[9] << 0);
1774 drwav_uint64 significand = (hi << 32) | lo;
1775 int sign = exponent >> 15;
1776
1777 /* Remove sign bit. */
1778 exponent &= 0x7FFF;
1779
1780 /* Special cases. */
1781 if (exponent == 0 && significand == 0) {
1782 return 0;
1783 } else if (exponent == 0x7FFF) {
1784 return sign ? DRWAV_INT64_MIN : DRWAV_INT64_MAX; /* Infinite. */
1785 }
1786
1787 exponent -= 16383;
1788
1789 if (exponent > 63) {
1790 return sign ? DRWAV_INT64_MIN : DRWAV_INT64_MAX; /* Too big for a 64-bit integer. */
1791 } else if (exponent < 1) {
1792 return 0; /* Number is less than 1, so rounds down to 0. */
1793 }
1794
1795 significand >>= (63 - exponent);
1796
1797 if (sign) {
1798 return -(drwav_int64)significand;
1799 } else {
1800 return (drwav_int64)significand;
1801 }
1802}
1803
1804
1805DRWAV_PRIVATE void* drwav__malloc_default(size_t sz, void* pUserData)
1806{
1807 (void)pUserData;
1808 return DRWAV_MALLOC(sz);
1809}
1810
1811DRWAV_PRIVATE void* drwav__realloc_default(void* p, size_t sz, void* pUserData)
1812{
1813 (void)pUserData;
1814 return DRWAV_REALLOC(p, sz);
1815}
1816
1817DRWAV_PRIVATE void drwav__free_default(void* p, void* pUserData)
1818{
1819 (void)pUserData;
1820 DRWAV_FREE(p);
1821}
1822
1823
1824DRWAV_PRIVATE void* drwav__malloc_from_callbacks(size_t sz, const drwav_allocation_callbacks* pAllocationCallbacks)
1825{
1826 if (pAllocationCallbacks == NULL) {
1827 return NULL;
1828 }
1829
1830 if (pAllocationCallbacks->onMalloc != NULL) {
1831 return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
1832 }
1833
1834 /* Try using realloc(). */
1835 if (pAllocationCallbacks->onRealloc != NULL) {
1836 return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
1837 }
1838
1839 return NULL;
1840}
1841
1842DRWAV_PRIVATE void* drwav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drwav_allocation_callbacks* pAllocationCallbacks)
1843{
1844 if (pAllocationCallbacks == NULL) {
1845 return NULL;
1846 }
1847
1848 if (pAllocationCallbacks->onRealloc != NULL) {
1849 return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
1850 }
1851
1852 /* Try emulating realloc() in terms of malloc()/free(). */
1853 if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
1854 void* p2;
1855
1856 p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
1857 if (p2 == NULL) {
1858 return NULL;
1859 }
1860
1861 if (p != NULL) {
1862 DRWAV_COPY_MEMORY(p2, p, szOld);
1863 pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
1864 }
1865
1866 return p2;
1867 }
1868
1869 return NULL;
1870}
1871
1872DRWAV_PRIVATE void drwav__free_from_callbacks(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
1873{
1874 if (p == NULL || pAllocationCallbacks == NULL) {
1875 return;
1876 }
1877
1878 if (pAllocationCallbacks->onFree != NULL) {
1879 pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
1880 }
1881}
1882
1883
1884DRWAV_PRIVATE drwav_allocation_callbacks drwav_copy_allocation_callbacks_or_defaults(const drwav_allocation_callbacks* pAllocationCallbacks)
1885{
1886 if (pAllocationCallbacks != NULL) {
1887 /* Copy. */
1888 return *pAllocationCallbacks;
1889 } else {
1890 /* Defaults. */
1891 drwav_allocation_callbacks allocationCallbacks;
1892 allocationCallbacks.pUserData = NULL;
1893 allocationCallbacks.onMalloc = drwav__malloc_default;
1894 allocationCallbacks.onRealloc = drwav__realloc_default;
1895 allocationCallbacks.onFree = drwav__free_default;
1896 return allocationCallbacks;
1897 }
1898}
1899
1900
1901static DRWAV_INLINE drwav_bool32 drwav__is_compressed_format_tag(drwav_uint16 formatTag)
1902{
1903 return
1904 formatTag == DR_WAVE_FORMAT_ADPCM ||
1905 formatTag == DR_WAVE_FORMAT_DVI_ADPCM;
1906}
1907
1908DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_riff(drwav_uint64 chunkSize)
1909{
1910 return (unsigned int)(chunkSize % 2);
1911}
1912
1913DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_w64(drwav_uint64 chunkSize)
1914{
1915 return (unsigned int)(chunkSize % 8);
1916}
1917
1918DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
1919DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
1920DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
1921
1922DRWAV_PRIVATE drwav_result drwav__read_chunk_header(drwav_read_proc onRead, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_chunk_header* pHeaderOut)
1923{
1924 if (container == drwav_container_riff || container == drwav_container_rifx || container == drwav_container_rf64 || container == drwav_container_aiff) {
1925 drwav_uint8 sizeInBytes[4];
1926
1927 if (onRead(pUserData, pHeaderOut->id.fourcc, 4) != 4) {
1928 return DRWAV_AT_END;
1929 }
1930
1931 if (onRead(pUserData, sizeInBytes, 4) != 4) {
1932 return DRWAV_INVALID_FILE;
1933 }
1934
1935 pHeaderOut->sizeInBytes = drwav_bytes_to_u32_ex(sizeInBytes, container);
1936 pHeaderOut->paddingSize = drwav__chunk_padding_size_riff(pHeaderOut->sizeInBytes);
1937
1938 *pRunningBytesReadOut += 8;
1939 } else if (container == drwav_container_w64) {
1940 drwav_uint8 sizeInBytes[8];
1941
1942 if (onRead(pUserData, pHeaderOut->id.guid, 16) != 16) {
1943 return DRWAV_AT_END;
1944 }
1945
1946 if (onRead(pUserData, sizeInBytes, 8) != 8) {
1947 return DRWAV_INVALID_FILE;
1948 }
1949
1950 pHeaderOut->sizeInBytes = drwav_bytes_to_u64(sizeInBytes) - 24; /* <-- Subtract 24 because w64 includes the size of the header. */
1951 pHeaderOut->paddingSize = drwav__chunk_padding_size_w64(pHeaderOut->sizeInBytes);
1952 *pRunningBytesReadOut += 24;
1953 } else {
1954 return DRWAV_INVALID_FILE;
1955 }
1956
1957 return DRWAV_SUCCESS;
1958}
1959
1960DRWAV_PRIVATE drwav_bool32 drwav__seek_forward(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
1961{
1962 drwav_uint64 bytesRemainingToSeek = offset;
1963 while (bytesRemainingToSeek > 0) {
1964 if (bytesRemainingToSeek > 0x7FFFFFFF) {
1965 if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
1966 return DRWAV_FALSE;
1967 }
1968 bytesRemainingToSeek -= 0x7FFFFFFF;
1969 } else {
1970 if (!onSeek(pUserData, (int)bytesRemainingToSeek, drwav_seek_origin_current)) {
1971 return DRWAV_FALSE;
1972 }
1973 bytesRemainingToSeek = 0;
1974 }
1975 }
1976
1977 return DRWAV_TRUE;
1978}
1979
1980DRWAV_PRIVATE drwav_bool32 drwav__seek_from_start(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
1981{
1982 if (offset <= 0x7FFFFFFF) {
1983 return onSeek(pUserData, (int)offset, drwav_seek_origin_start);
1984 }
1985
1986 /* Larger than 32-bit seek. */
1987 if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_start)) {
1988 return DRWAV_FALSE;
1989 }
1990 offset -= 0x7FFFFFFF;
1991
1992 for (;;) {
1993 if (offset <= 0x7FFFFFFF) {
1994 return onSeek(pUserData, (int)offset, drwav_seek_origin_current);
1995 }
1996
1997 if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
1998 return DRWAV_FALSE;
1999 }
2000 offset -= 0x7FFFFFFF;
2001 }
2002
2003 /* Should never get here. */
2004 /*return DRWAV_TRUE; */
2005}
2006
2007
2008
2009DRWAV_PRIVATE size_t drwav__on_read(drwav_read_proc onRead, void* pUserData, void* pBufferOut, size_t bytesToRead, drwav_uint64* pCursor)
2010{
2011 size_t bytesRead;
2012
2013 DRWAV_ASSERT(onRead != NULL);
2014 DRWAV_ASSERT(pCursor != NULL);
2015
2016 bytesRead = onRead(pUserData, pBufferOut, bytesToRead);
2017 *pCursor += bytesRead;
2018 return bytesRead;
2019}
2020
2021#if 0
2022DRWAV_PRIVATE drwav_bool32 drwav__on_seek(drwav_seek_proc onSeek, void* pUserData, int offset, drwav_seek_origin origin, drwav_uint64* pCursor)
2023{
2024 DRWAV_ASSERT(onSeek != NULL);
2025 DRWAV_ASSERT(pCursor != NULL);
2026
2027 if (!onSeek(pUserData, offset, origin)) {
2028 return DRWAV_FALSE;
2029 }
2030
2031 if (origin == drwav_seek_origin_start) {
2032 *pCursor = offset;
2033 } else {
2034 *pCursor += offset;
2035 }
2036
2037 return DRWAV_TRUE;
2038}
2039#endif
2040
2041
2042#define DRWAV_SMPL_BYTES 36
2043#define DRWAV_SMPL_LOOP_BYTES 24
2044#define DRWAV_INST_BYTES 7
2045#define DRWAV_ACID_BYTES 24
2046#define DRWAV_CUE_BYTES 4
2047#define DRWAV_BEXT_BYTES 602
2048#define DRWAV_BEXT_DESCRIPTION_BYTES 256
2049#define DRWAV_BEXT_ORIGINATOR_NAME_BYTES 32
2050#define DRWAV_BEXT_ORIGINATOR_REF_BYTES 32
2051#define DRWAV_BEXT_RESERVED_BYTES 180
2052#define DRWAV_BEXT_UMID_BYTES 64
2053#define DRWAV_CUE_POINT_BYTES 24
2054#define DRWAV_LIST_LABEL_OR_NOTE_BYTES 4
2055#define DRWAV_LIST_LABELLED_TEXT_BYTES 20
2056
2057#define DRWAV_METADATA_ALIGNMENT 8
2058
2059typedef enum
2060{
2061 drwav__metadata_parser_stage_count,
2062 drwav__metadata_parser_stage_read
2063} drwav__metadata_parser_stage;
2064
2065typedef struct
2066{
2067 drwav_read_proc onRead;
2068 drwav_seek_proc onSeek;
2069 void *pReadSeekUserData;
2070 drwav__metadata_parser_stage stage;
2071 drwav_metadata *pMetadata;
2072 drwav_uint32 metadataCount;
2073 drwav_uint8 *pData;
2074 drwav_uint8 *pDataCursor;
2075 drwav_uint64 metadataCursor;
2076 drwav_uint64 extraCapacity;
2077} drwav__metadata_parser;
2078
2079DRWAV_PRIVATE size_t drwav__metadata_memory_capacity(drwav__metadata_parser* pParser)
2080{
2081 drwav_uint64 cap = sizeof(drwav_metadata) * (drwav_uint64)pParser->metadataCount + pParser->extraCapacity;
2082 if (cap > DRWAV_SIZE_MAX) {
2083 return 0; /* Too big. */
2084 }
2085
2086 return (size_t)cap; /* Safe cast thanks to the check above. */
2087}
2088
2089DRWAV_PRIVATE drwav_uint8* drwav__metadata_get_memory(drwav__metadata_parser* pParser, size_t size, size_t align)
2090{
2091 drwav_uint8* pResult;
2092
2093 if (align) {
2094 drwav_uintptr modulo = (drwav_uintptr)pParser->pDataCursor % align;
2095 if (modulo != 0) {
2096 pParser->pDataCursor += align - modulo;
2097 }
2098 }
2099
2100 pResult = pParser->pDataCursor;
2101
2102 /*
2103 Getting to the point where this function is called means there should always be memory
2104 available. Out of memory checks should have been done at an earlier stage.
2105 */
2106 DRWAV_ASSERT((pResult + size) <= (pParser->pData + drwav__metadata_memory_capacity(pParser)));
2107
2108 pParser->pDataCursor += size;
2109 return pResult;
2110}
2111
2112DRWAV_PRIVATE void drwav__metadata_request_extra_memory_for_stage_2(drwav__metadata_parser* pParser, size_t bytes, size_t align)
2113{
2114 size_t extra = bytes + (align ? (align - 1) : 0);
2115 pParser->extraCapacity += extra;
2116}
2117
2118DRWAV_PRIVATE drwav_result drwav__metadata_alloc(drwav__metadata_parser* pParser, drwav_allocation_callbacks* pAllocationCallbacks)
2119{
2120 if (pParser->extraCapacity != 0 || pParser->metadataCount != 0) {
2121 pAllocationCallbacks->onFree(pParser->pData, pAllocationCallbacks->pUserData);
2122
2123 pParser->pData = (drwav_uint8*)pAllocationCallbacks->onMalloc(drwav__metadata_memory_capacity(pParser), pAllocationCallbacks->pUserData);
2124 pParser->pDataCursor = pParser->pData;
2125
2126 if (pParser->pData == NULL) {
2127 return DRWAV_OUT_OF_MEMORY;
2128 }
2129
2130 /*
2131 We don't need to worry about specifying an alignment here because malloc always returns something
2132 of suitable alignment. This also means pParser->pMetadata is all that we need to store in order
2133 for us to free when we are done.
2134 */
2135 pParser->pMetadata = (drwav_metadata*)drwav__metadata_get_memory(pParser, sizeof(drwav_metadata) * pParser->metadataCount, 1);
2136 pParser->metadataCursor = 0;
2137 }
2138
2139 return DRWAV_SUCCESS;
2140}
2141
2142DRWAV_PRIVATE size_t drwav__metadata_parser_read(drwav__metadata_parser* pParser, void* pBufferOut, size_t bytesToRead, drwav_uint64* pCursor)
2143{
2144 if (pCursor != NULL) {
2145 return drwav__on_read(pParser->onRead, pParser->pReadSeekUserData, pBufferOut, bytesToRead, pCursor);
2146 } else {
2147 return pParser->onRead(pParser->pReadSeekUserData, pBufferOut, bytesToRead);
2148 }
2149}
2150
2151DRWAV_PRIVATE drwav_uint64 drwav__read_smpl_to_metadata_obj(drwav__metadata_parser* pParser, const drwav_chunk_header* pChunkHeader, drwav_metadata* pMetadata)
2152{
2153 drwav_uint8 smplHeaderData[DRWAV_SMPL_BYTES];
2154 drwav_uint64 totalBytesRead = 0;
2155 size_t bytesJustRead;
2156
2157 if (pMetadata == NULL) {
2158 return 0;
2159 }
2160
2161 bytesJustRead = drwav__metadata_parser_read(pParser, smplHeaderData, sizeof(smplHeaderData), &totalBytesRead);
2162
2163 DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
2164 DRWAV_ASSERT(pChunkHeader != NULL);
2165
2166 if (pMetadata != NULL && bytesJustRead == sizeof(smplHeaderData)) {
2167 drwav_uint32 iSampleLoop;
2168
2169 pMetadata->type = drwav_metadata_type_smpl;
2170 pMetadata->data.smpl.manufacturerId = drwav_bytes_to_u32(smplHeaderData + 0);
2171 pMetadata->data.smpl.productId = drwav_bytes_to_u32(smplHeaderData + 4);
2172 pMetadata->data.smpl.samplePeriodNanoseconds = drwav_bytes_to_u32(smplHeaderData + 8);
2173 pMetadata->data.smpl.midiUnityNote = drwav_bytes_to_u32(smplHeaderData + 12);
2174 pMetadata->data.smpl.midiPitchFraction = drwav_bytes_to_u32(smplHeaderData + 16);
2175 pMetadata->data.smpl.smpteFormat = drwav_bytes_to_u32(smplHeaderData + 20);
2176 pMetadata->data.smpl.smpteOffset = drwav_bytes_to_u32(smplHeaderData + 24);
2177 pMetadata->data.smpl.sampleLoopCount = drwav_bytes_to_u32(smplHeaderData + 28);
2178 pMetadata->data.smpl.samplerSpecificDataSizeInBytes = drwav_bytes_to_u32(smplHeaderData + 32);
2179
2180 /*
2181 The loop count needs to be validated against the size of the chunk for safety so we don't
2182 attempt to read over the boundary of the chunk.
2183 */
2184 if (pMetadata->data.smpl.sampleLoopCount == (pChunkHeader->sizeInBytes - DRWAV_SMPL_BYTES) / DRWAV_SMPL_LOOP_BYTES) {
2185 pMetadata->data.smpl.pLoops = (drwav_smpl_loop*)drwav__metadata_get_memory(pParser, sizeof(drwav_smpl_loop) * pMetadata->data.smpl.sampleLoopCount, DRWAV_METADATA_ALIGNMENT);
2186
2187 for (iSampleLoop = 0; iSampleLoop < pMetadata->data.smpl.sampleLoopCount; ++iSampleLoop) {
2188 drwav_uint8 smplLoopData[DRWAV_SMPL_LOOP_BYTES];
2189 bytesJustRead = drwav__metadata_parser_read(pParser, smplLoopData, sizeof(smplLoopData), &totalBytesRead);
2190
2191 if (bytesJustRead == sizeof(smplLoopData)) {
2192 pMetadata->data.smpl.pLoops[iSampleLoop].cuePointId = drwav_bytes_to_u32(smplLoopData + 0);
2193 pMetadata->data.smpl.pLoops[iSampleLoop].type = drwav_bytes_to_u32(smplLoopData + 4);
2194 pMetadata->data.smpl.pLoops[iSampleLoop].firstSampleByteOffset = drwav_bytes_to_u32(smplLoopData + 8);
2195 pMetadata->data.smpl.pLoops[iSampleLoop].lastSampleByteOffset = drwav_bytes_to_u32(smplLoopData + 12);
2196 pMetadata->data.smpl.pLoops[iSampleLoop].sampleFraction = drwav_bytes_to_u32(smplLoopData + 16);
2197 pMetadata->data.smpl.pLoops[iSampleLoop].playCount = drwav_bytes_to_u32(smplLoopData + 20);
2198 } else {
2199 break;
2200 }
2201 }
2202
2203 if (pMetadata->data.smpl.samplerSpecificDataSizeInBytes > 0) {
2204 pMetadata->data.smpl.pSamplerSpecificData = drwav__metadata_get_memory(pParser, pMetadata->data.smpl.samplerSpecificDataSizeInBytes, 1);
2205 DRWAV_ASSERT(pMetadata->data.smpl.pSamplerSpecificData != NULL);
2206
2207 drwav__metadata_parser_read(pParser, pMetadata->data.smpl.pSamplerSpecificData, pMetadata->data.smpl.samplerSpecificDataSizeInBytes, &totalBytesRead);
2208 }
2209 }
2210 }
2211
2212 return totalBytesRead;
2213}
2214
2215DRWAV_PRIVATE drwav_uint64 drwav__read_cue_to_metadata_obj(drwav__metadata_parser* pParser, const drwav_chunk_header* pChunkHeader, drwav_metadata* pMetadata)
2216{
2217 drwav_uint8 cueHeaderSectionData[DRWAV_CUE_BYTES];
2218 drwav_uint64 totalBytesRead = 0;
2219 size_t bytesJustRead;
2220
2221 if (pMetadata == NULL) {
2222 return 0;
2223 }
2224
2225 bytesJustRead = drwav__metadata_parser_read(pParser, cueHeaderSectionData, sizeof(cueHeaderSectionData), &totalBytesRead);
2226
2227 DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
2228
2229 if (bytesJustRead == sizeof(cueHeaderSectionData)) {
2230 pMetadata->type = drwav_metadata_type_cue;
2231 pMetadata->data.cue.cuePointCount = drwav_bytes_to_u32(cueHeaderSectionData);
2232
2233 /*
2234 We need to validate the cue point count against the size of the chunk so we don't read
2235 beyond the chunk.
2236 */
2237 if (pMetadata->data.cue.cuePointCount == (pChunkHeader->sizeInBytes - DRWAV_CUE_BYTES) / DRWAV_CUE_POINT_BYTES) {
2238 pMetadata->data.cue.pCuePoints = (drwav_cue_point*)drwav__metadata_get_memory(pParser, sizeof(drwav_cue_point) * pMetadata->data.cue.cuePointCount, DRWAV_METADATA_ALIGNMENT);
2239 DRWAV_ASSERT(pMetadata->data.cue.pCuePoints != NULL);
2240
2241 if (pMetadata->data.cue.cuePointCount > 0) {
2242 drwav_uint32 iCuePoint;
2243
2244 for (iCuePoint = 0; iCuePoint < pMetadata->data.cue.cuePointCount; ++iCuePoint) {
2245 drwav_uint8 cuePointData[DRWAV_CUE_POINT_BYTES];
2246 bytesJustRead = drwav__metadata_parser_read(pParser, cuePointData, sizeof(cuePointData), &totalBytesRead);
2247
2248 if (bytesJustRead == sizeof(cuePointData)) {
2249 pMetadata->data.cue.pCuePoints[iCuePoint].id = drwav_bytes_to_u32(cuePointData + 0);
2250 pMetadata->data.cue.pCuePoints[iCuePoint].playOrderPosition = drwav_bytes_to_u32(cuePointData + 4);
2251 pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[0] = cuePointData[8];
2252 pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[1] = cuePointData[9];
2253 pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[2] = cuePointData[10];
2254 pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[3] = cuePointData[11];
2255 pMetadata->data.cue.pCuePoints[iCuePoint].chunkStart = drwav_bytes_to_u32(cuePointData + 12);
2256 pMetadata->data.cue.pCuePoints[iCuePoint].blockStart = drwav_bytes_to_u32(cuePointData + 16);
2257 pMetadata->data.cue.pCuePoints[iCuePoint].sampleByteOffset = drwav_bytes_to_u32(cuePointData + 20);
2258 } else {
2259 break;
2260 }
2261 }
2262 }
2263 }
2264 }
2265
2266 return totalBytesRead;
2267}
2268
2269DRWAV_PRIVATE drwav_uint64 drwav__read_inst_to_metadata_obj(drwav__metadata_parser* pParser, drwav_metadata* pMetadata)
2270{
2271 drwav_uint8 instData[DRWAV_INST_BYTES];
2272 drwav_uint64 bytesRead;
2273
2274 if (pMetadata == NULL) {
2275 return 0;
2276 }
2277
2278 bytesRead = drwav__metadata_parser_read(pParser, instData, sizeof(instData), NULL);
2279
2280 DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
2281
2282 if (bytesRead == sizeof(instData)) {
2283 pMetadata->type = drwav_metadata_type_inst;
2284 pMetadata->data.inst.midiUnityNote = (drwav_int8)instData[0];
2285 pMetadata->data.inst.fineTuneCents = (drwav_int8)instData[1];
2286 pMetadata->data.inst.gainDecibels = (drwav_int8)instData[2];
2287 pMetadata->data.inst.lowNote = (drwav_int8)instData[3];
2288 pMetadata->data.inst.highNote = (drwav_int8)instData[4];
2289 pMetadata->data.inst.lowVelocity = (drwav_int8)instData[5];
2290 pMetadata->data.inst.highVelocity = (drwav_int8)instData[6];
2291 }
2292
2293 return bytesRead;
2294}
2295
2296DRWAV_PRIVATE drwav_uint64 drwav__read_acid_to_metadata_obj(drwav__metadata_parser* pParser, drwav_metadata* pMetadata)
2297{
2298 drwav_uint8 acidData[DRWAV_ACID_BYTES];
2299 drwav_uint64 bytesRead;
2300
2301 if (pMetadata == NULL) {
2302 return 0;
2303 }
2304
2305 bytesRead = drwav__metadata_parser_read(pParser, acidData, sizeof(acidData), NULL);
2306
2307 DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
2308
2309 if (bytesRead == sizeof(acidData)) {
2310 pMetadata->type = drwav_metadata_type_acid;
2311 pMetadata->data.acid.flags = drwav_bytes_to_u32(acidData + 0);
2312 pMetadata->data.acid.midiUnityNote = drwav_bytes_to_u16(acidData + 4);
2313 pMetadata->data.acid.reserved1 = drwav_bytes_to_u16(acidData + 6);
2314 pMetadata->data.acid.reserved2 = drwav_bytes_to_f32(acidData + 8);
2315 pMetadata->data.acid.numBeats = drwav_bytes_to_u32(acidData + 12);
2316 pMetadata->data.acid.meterDenominator = drwav_bytes_to_u16(acidData + 16);
2317 pMetadata->data.acid.meterNumerator = drwav_bytes_to_u16(acidData + 18);
2318 pMetadata->data.acid.tempo = drwav_bytes_to_f32(acidData + 20);
2319 }
2320
2321 return bytesRead;
2322}
2323
2324DRWAV_PRIVATE size_t drwav__strlen(const char* str)
2325{
2326 size_t result = 0;
2327
2328 while (*str++) {
2329 result += 1;
2330 }
2331
2332 return result;
2333}
2334
2335DRWAV_PRIVATE size_t drwav__strlen_clamped(const char* str, size_t maxToRead)
2336{
2337 size_t result = 0;
2338
2339 while (*str++ && result < maxToRead) {
2340 result += 1;
2341 }
2342
2343 return result;
2344}
2345
2346DRWAV_PRIVATE char* drwav__metadata_copy_string(drwav__metadata_parser* pParser, const char* str, size_t maxToRead)
2347{
2348 size_t len = drwav__strlen_clamped(str, maxToRead);
2349
2350 if (len) {
2351 char* result = (char*)drwav__metadata_get_memory(pParser, len + 1, 1);
2352 DRWAV_ASSERT(result != NULL);
2353
2354 DRWAV_COPY_MEMORY(result, str, len);
2355 result[len] = '\0';
2356
2357 return result;
2358 } else {
2359 return NULL;
2360 }
2361}
2362
2363typedef struct
2364{
2365 const void* pBuffer;
2366 size_t sizeInBytes;
2367 size_t cursor;
2368} drwav_buffer_reader;
2369
2370DRWAV_PRIVATE drwav_result drwav_buffer_reader_init(const void* pBuffer, size_t sizeInBytes, drwav_buffer_reader* pReader)
2371{
2372 DRWAV_ASSERT(pBuffer != NULL);
2373 DRWAV_ASSERT(pReader != NULL);
2374
2375 DRWAV_ZERO_OBJECT(pReader);
2376
2377 pReader->pBuffer = pBuffer;
2378 pReader->sizeInBytes = sizeInBytes;
2379 pReader->cursor = 0;
2380
2381 return DRWAV_SUCCESS;
2382}
2383
2384DRWAV_PRIVATE const void* drwav_buffer_reader_ptr(const drwav_buffer_reader* pReader)
2385{
2386 DRWAV_ASSERT(pReader != NULL);
2387
2388 return drwav_offset_ptr(pReader->pBuffer, pReader->cursor);
2389}
2390
2391DRWAV_PRIVATE drwav_result drwav_buffer_reader_seek(drwav_buffer_reader* pReader, size_t bytesToSeek)
2392{
2393 DRWAV_ASSERT(pReader != NULL);
2394
2395 if (pReader->cursor + bytesToSeek > pReader->sizeInBytes) {
2396 return DRWAV_BAD_SEEK; /* Seeking too far forward. */
2397 }
2398
2399 pReader->cursor += bytesToSeek;
2400
2401 return DRWAV_SUCCESS;
2402}
2403
2404DRWAV_PRIVATE drwav_result drwav_buffer_reader_read(drwav_buffer_reader* pReader, void* pDst, size_t bytesToRead, size_t* pBytesRead)
2405{
2406 drwav_result result = DRWAV_SUCCESS;
2407 size_t bytesRemaining;
2408
2409 DRWAV_ASSERT(pReader != NULL);
2410
2411 if (pBytesRead != NULL) {
2412 *pBytesRead = 0;
2413 }
2414
2415 bytesRemaining = (pReader->sizeInBytes - pReader->cursor);
2416 if (bytesToRead > bytesRemaining) {
2417 bytesToRead = bytesRemaining;
2418 }
2419
2420 if (pDst == NULL) {
2421 /* Seek. */
2422 result = drwav_buffer_reader_seek(pReader, bytesToRead);
2423 } else {
2424 /* Read. */
2425 DRWAV_COPY_MEMORY(pDst, drwav_buffer_reader_ptr(pReader), bytesToRead);
2426 pReader->cursor += bytesToRead;
2427 }
2428
2429 DRWAV_ASSERT(pReader->cursor <= pReader->sizeInBytes);
2430
2431 if (result == DRWAV_SUCCESS) {
2432 if (pBytesRead != NULL) {
2433 *pBytesRead = bytesToRead;
2434 }
2435 }
2436
2437 return DRWAV_SUCCESS;
2438}
2439
2440DRWAV_PRIVATE drwav_result drwav_buffer_reader_read_u16(drwav_buffer_reader* pReader, drwav_uint16* pDst)
2441{
2442 drwav_result result;
2443 size_t bytesRead;
2444 drwav_uint8 data[2];
2445
2446 DRWAV_ASSERT(pReader != NULL);
2447 DRWAV_ASSERT(pDst != NULL);
2448
2449 *pDst = 0; /* Safety. */
2450
2451 result = drwav_buffer_reader_read(pReader, data, sizeof(*pDst), &bytesRead);
2452 if (result != DRWAV_SUCCESS || bytesRead != sizeof(*pDst)) {
2453 return result;
2454 }
2455
2456 *pDst = drwav_bytes_to_u16(data);
2457
2458 return DRWAV_SUCCESS;
2459}
2460
2461DRWAV_PRIVATE drwav_result drwav_buffer_reader_read_u32(drwav_buffer_reader* pReader, drwav_uint32* pDst)
2462{
2463 drwav_result result;
2464 size_t bytesRead;
2465 drwav_uint8 data[4];
2466
2467 DRWAV_ASSERT(pReader != NULL);
2468 DRWAV_ASSERT(pDst != NULL);
2469
2470 *pDst = 0; /* Safety. */
2471
2472 result = drwav_buffer_reader_read(pReader, data, sizeof(*pDst), &bytesRead);
2473 if (result != DRWAV_SUCCESS || bytesRead != sizeof(*pDst)) {
2474 return result;
2475 }
2476
2477 *pDst = drwav_bytes_to_u32(data);
2478
2479 return DRWAV_SUCCESS;
2480}
2481
2482
2483
2484DRWAV_PRIVATE drwav_uint64 drwav__read_bext_to_metadata_obj(drwav__metadata_parser* pParser, drwav_metadata* pMetadata, drwav_uint64 chunkSize)
2485{
2486 drwav_uint8 bextData[DRWAV_BEXT_BYTES];
2487 size_t bytesRead = drwav__metadata_parser_read(pParser, bextData, sizeof(bextData), NULL);
2488
2489 DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
2490
2491 if (bytesRead == sizeof(bextData)) {
2492 drwav_buffer_reader reader;
2493 drwav_uint32 timeReferenceLow;
2494 drwav_uint32 timeReferenceHigh;
2495 size_t extraBytes;
2496
2497 pMetadata->type = drwav_metadata_type_bext;
2498
2499 if (drwav_buffer_reader_init(bextData, bytesRead, &reader) == DRWAV_SUCCESS) {
2500 pMetadata->data.bext.pDescription = drwav__metadata_copy_string(pParser, (const char*)drwav_buffer_reader_ptr(&reader), DRWAV_BEXT_DESCRIPTION_BYTES);
2501 drwav_buffer_reader_seek(&reader, DRWAV_BEXT_DESCRIPTION_BYTES);
2502
2503 pMetadata->data.bext.pOriginatorName = drwav__metadata_copy_string(pParser, (const char*)drwav_buffer_reader_ptr(&reader), DRWAV_BEXT_ORIGINATOR_NAME_BYTES);
2504 drwav_buffer_reader_seek(&reader, DRWAV_BEXT_ORIGINATOR_NAME_BYTES);
2505
2506 pMetadata->data.bext.pOriginatorReference = drwav__metadata_copy_string(pParser, (const char*)drwav_buffer_reader_ptr(&reader), DRWAV_BEXT_ORIGINATOR_REF_BYTES);
2507 drwav_buffer_reader_seek(&reader, DRWAV_BEXT_ORIGINATOR_REF_BYTES);
2508
2509 drwav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationDate, sizeof(pMetadata->data.bext.pOriginationDate), NULL);
2510 drwav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationTime, sizeof(pMetadata->data.bext.pOriginationTime), NULL);
2511
2512 drwav_buffer_reader_read_u32(&reader, &timeReferenceLow);
2513 drwav_buffer_reader_read_u32(&reader, &timeReferenceHigh);
2514 pMetadata->data.bext.timeReference = ((drwav_uint64)timeReferenceHigh << 32) + timeReferenceLow;
2515
2516 drwav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.version);
2517
2518 pMetadata->data.bext.pUMID = drwav__metadata_get_memory(pParser, DRWAV_BEXT_UMID_BYTES, 1);
2519 drwav_buffer_reader_read(&reader, pMetadata->data.bext.pUMID, DRWAV_BEXT_UMID_BYTES, NULL);
2520
2521 drwav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.loudnessValue);
2522 drwav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.loudnessRange);
2523 drwav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.maxTruePeakLevel);
2524 drwav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.maxMomentaryLoudness);
2525 drwav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.maxShortTermLoudness);
2526
2527 DRWAV_ASSERT((drwav_offset_ptr(drwav_buffer_reader_ptr(&reader), DRWAV_BEXT_RESERVED_BYTES)) == (bextData + DRWAV_BEXT_BYTES));
2528
2529 extraBytes = (size_t)(chunkSize - DRWAV_BEXT_BYTES);
2530 if (extraBytes > 0) {
2531 pMetadata->data.bext.pCodingHistory = (char*)drwav__metadata_get_memory(pParser, extraBytes + 1, 1);
2532 DRWAV_ASSERT(pMetadata->data.bext.pCodingHistory != NULL);
2533
2534 bytesRead += drwav__metadata_parser_read(pParser, pMetadata->data.bext.pCodingHistory, extraBytes, NULL);
2535 pMetadata->data.bext.codingHistorySize = (drwav_uint32)drwav__strlen(pMetadata->data.bext.pCodingHistory);
2536 } else {
2537 pMetadata->data.bext.pCodingHistory = NULL;
2538 pMetadata->data.bext.codingHistorySize = 0;
2539 }
2540 }
2541 }
2542
2543 return bytesRead;
2544}
2545
2546DRWAV_PRIVATE drwav_uint64 drwav__read_list_label_or_note_to_metadata_obj(drwav__metadata_parser* pParser, drwav_metadata* pMetadata, drwav_uint64 chunkSize, drwav_metadata_type type)
2547{
2548 drwav_uint8 cueIDBuffer[DRWAV_LIST_LABEL_OR_NOTE_BYTES];
2549 drwav_uint64 totalBytesRead = 0;
2550 size_t bytesJustRead = drwav__metadata_parser_read(pParser, cueIDBuffer, sizeof(cueIDBuffer), &totalBytesRead);
2551
2552 DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
2553
2554 if (bytesJustRead == sizeof(cueIDBuffer)) {
2555 drwav_uint32 sizeIncludingNullTerminator;
2556
2557 pMetadata->type = type;
2558 pMetadata->data.labelOrNote.cuePointId = drwav_bytes_to_u32(cueIDBuffer);
2559
2560 sizeIncludingNullTerminator = (drwav_uint32)chunkSize - DRWAV_LIST_LABEL_OR_NOTE_BYTES;
2561 if (sizeIncludingNullTerminator > 0) {
2562 pMetadata->data.labelOrNote.stringLength = sizeIncludingNullTerminator - 1;
2563 pMetadata->data.labelOrNote.pString = (char*)drwav__metadata_get_memory(pParser, sizeIncludingNullTerminator, 1);
2564 DRWAV_ASSERT(pMetadata->data.labelOrNote.pString != NULL);
2565
2566 drwav__metadata_parser_read(pParser, pMetadata->data.labelOrNote.pString, sizeIncludingNullTerminator, &totalBytesRead);
2567 } else {
2568 pMetadata->data.labelOrNote.stringLength = 0;
2569 pMetadata->data.labelOrNote.pString = NULL;
2570 }
2571 }
2572
2573 return totalBytesRead;
2574}
2575
2576DRWAV_PRIVATE drwav_uint64 drwav__read_list_labelled_cue_region_to_metadata_obj(drwav__metadata_parser* pParser, drwav_metadata* pMetadata, drwav_uint64 chunkSize)
2577{
2578 drwav_uint8 buffer[DRWAV_LIST_LABELLED_TEXT_BYTES];
2579 drwav_uint64 totalBytesRead = 0;
2580 size_t bytesJustRead = drwav__metadata_parser_read(pParser, buffer, sizeof(buffer), &totalBytesRead);
2581
2582 DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
2583
2584 if (bytesJustRead == sizeof(buffer)) {
2585 drwav_uint32 sizeIncludingNullTerminator;
2586
2587 pMetadata->type = drwav_metadata_type_list_labelled_cue_region;
2588 pMetadata->data.labelledCueRegion.cuePointId = drwav_bytes_to_u32(buffer + 0);
2589 pMetadata->data.labelledCueRegion.sampleLength = drwav_bytes_to_u32(buffer + 4);
2590 pMetadata->data.labelledCueRegion.purposeId[0] = buffer[8];
2591 pMetadata->data.labelledCueRegion.purposeId[1] = buffer[9];
2592 pMetadata->data.labelledCueRegion.purposeId[2] = buffer[10];
2593 pMetadata->data.labelledCueRegion.purposeId[3] = buffer[11];
2594 pMetadata->data.labelledCueRegion.country = drwav_bytes_to_u16(buffer + 12);
2595 pMetadata->data.labelledCueRegion.language = drwav_bytes_to_u16(buffer + 14);
2596 pMetadata->data.labelledCueRegion.dialect = drwav_bytes_to_u16(buffer + 16);
2597 pMetadata->data.labelledCueRegion.codePage = drwav_bytes_to_u16(buffer + 18);
2598
2599 sizeIncludingNullTerminator = (drwav_uint32)chunkSize - DRWAV_LIST_LABELLED_TEXT_BYTES;
2600 if (sizeIncludingNullTerminator > 0) {
2601 pMetadata->data.labelledCueRegion.stringLength = sizeIncludingNullTerminator - 1;
2602 pMetadata->data.labelledCueRegion.pString = (char*)drwav__metadata_get_memory(pParser, sizeIncludingNullTerminator, 1);
2603 DRWAV_ASSERT(pMetadata->data.labelledCueRegion.pString != NULL);
2604
2605 drwav__metadata_parser_read(pParser, pMetadata->data.labelledCueRegion.pString, sizeIncludingNullTerminator, &totalBytesRead);
2606 } else {
2607 pMetadata->data.labelledCueRegion.stringLength = 0;
2608 pMetadata->data.labelledCueRegion.pString = NULL;
2609 }
2610 }
2611
2612 return totalBytesRead;
2613}
2614
2615DRWAV_PRIVATE drwav_uint64 drwav__metadata_process_info_text_chunk(drwav__metadata_parser* pParser, drwav_uint64 chunkSize, drwav_metadata_type type)
2616{
2617 drwav_uint64 bytesRead = 0;
2618 drwav_uint32 stringSizeWithNullTerminator = (drwav_uint32)chunkSize;
2619
2620 if (pParser->stage == drwav__metadata_parser_stage_count) {
2621 pParser->metadataCount += 1;
2622 drwav__metadata_request_extra_memory_for_stage_2(pParser, stringSizeWithNullTerminator, 1);
2623 } else {
2624 drwav_metadata* pMetadata = &pParser->pMetadata[pParser->metadataCursor];
2625 pMetadata->type = type;
2626 if (stringSizeWithNullTerminator > 0) {
2627 pMetadata->data.infoText.stringLength = stringSizeWithNullTerminator - 1;
2628 pMetadata->data.infoText.pString = (char*)drwav__metadata_get_memory(pParser, stringSizeWithNullTerminator, 1);
2629 DRWAV_ASSERT(pMetadata->data.infoText.pString != NULL);
2630
2631 bytesRead = drwav__metadata_parser_read(pParser, pMetadata->data.infoText.pString, (size_t)stringSizeWithNullTerminator, NULL);
2632 if (bytesRead == chunkSize) {
2633 pParser->metadataCursor += 1;
2634 } else {
2635 /* Failed to parse. */
2636 }
2637 } else {
2638 pMetadata->data.infoText.stringLength = 0;
2639 pMetadata->data.infoText.pString = NULL;
2640 pParser->metadataCursor += 1;
2641 }
2642 }
2643
2644 return bytesRead;
2645}
2646
2647DRWAV_PRIVATE drwav_uint64 drwav__metadata_process_unknown_chunk(drwav__metadata_parser* pParser, const drwav_uint8* pChunkId, drwav_uint64 chunkSize, drwav_metadata_location location)
2648{
2649 drwav_uint64 bytesRead = 0;
2650
2651 if (location == drwav_metadata_location_invalid) {
2652 return 0;
2653 }
2654
2655 if (drwav_fourcc_equal(pChunkId, "data") || drwav_fourcc_equal(pChunkId, "fmt ") || drwav_fourcc_equal(pChunkId, "fact")) {
2656 return 0;
2657 }
2658
2659 if (pParser->stage == drwav__metadata_parser_stage_count) {
2660 pParser->metadataCount += 1;
2661 drwav__metadata_request_extra_memory_for_stage_2(pParser, (size_t)chunkSize, 1);
2662 } else {
2663 drwav_metadata* pMetadata = &pParser->pMetadata[pParser->metadataCursor];
2664 pMetadata->type = drwav_metadata_type_unknown;
2665 pMetadata->data.unknown.chunkLocation = location;
2666 pMetadata->data.unknown.id[0] = pChunkId[0];
2667 pMetadata->data.unknown.id[1] = pChunkId[1];
2668 pMetadata->data.unknown.id[2] = pChunkId[2];
2669 pMetadata->data.unknown.id[3] = pChunkId[3];
2670 pMetadata->data.unknown.dataSizeInBytes = (drwav_uint32)chunkSize;
2671 pMetadata->data.unknown.pData = (drwav_uint8 *)drwav__metadata_get_memory(pParser, (size_t)chunkSize, 1);
2672 DRWAV_ASSERT(pMetadata->data.unknown.pData != NULL);
2673
2674 bytesRead = drwav__metadata_parser_read(pParser, pMetadata->data.unknown.pData, pMetadata->data.unknown.dataSizeInBytes, NULL);
2675 if (bytesRead == pMetadata->data.unknown.dataSizeInBytes) {
2676 pParser->metadataCursor += 1;
2677 } else {
2678 /* Failed to read. */
2679 }
2680 }
2681
2682 return bytesRead;
2683}
2684
2685DRWAV_PRIVATE drwav_bool32 drwav__chunk_matches(drwav_metadata_type allowedMetadataTypes, const drwav_uint8* pChunkID, drwav_metadata_type type, const char* pID)
2686{
2687 return (allowedMetadataTypes & type) && drwav_fourcc_equal(pChunkID, pID);
2688}
2689
2690DRWAV_PRIVATE drwav_uint64 drwav__metadata_process_chunk(drwav__metadata_parser* pParser, const drwav_chunk_header* pChunkHeader, drwav_metadata_type allowedMetadataTypes)
2691{
2692 const drwav_uint8 *pChunkID = pChunkHeader->id.fourcc;
2693 drwav_uint64 bytesRead = 0;
2694
2695 if (drwav__chunk_matches(allowedMetadataTypes, pChunkID, drwav_metadata_type_smpl, "smpl")) {
2696 if (pChunkHeader->sizeInBytes >= DRWAV_SMPL_BYTES) {
2697 if (pParser->stage == drwav__metadata_parser_stage_count) {
2698 drwav_uint8 buffer[4];
2699 size_t bytesJustRead;
2700
2701 if (!pParser->onSeek(pParser->pReadSeekUserData, 28, drwav_seek_origin_current)) {
2702 return bytesRead;
2703 }
2704 bytesRead += 28;
2705
2706 bytesJustRead = drwav__metadata_parser_read(pParser, buffer, sizeof(buffer), &bytesRead);
2707 if (bytesJustRead == sizeof(buffer)) {
2708 drwav_uint32 loopCount = drwav_bytes_to_u32(buffer);
2709 drwav_uint64 calculatedLoopCount;
2710
2711 /* The loop count must be validated against the size of the chunk. */
2712 calculatedLoopCount = (pChunkHeader->sizeInBytes - DRWAV_SMPL_BYTES) / DRWAV_SMPL_LOOP_BYTES;
2713 if (calculatedLoopCount == loopCount) {
2714 bytesJustRead = drwav__metadata_parser_read(pParser, buffer, sizeof(buffer), &bytesRead);
2715 if (bytesJustRead == sizeof(buffer)) {
2716 drwav_uint32 samplerSpecificDataSizeInBytes = drwav_bytes_to_u32(buffer);
2717
2718 pParser->metadataCount += 1;
2719 drwav__metadata_request_extra_memory_for_stage_2(pParser, sizeof(drwav_smpl_loop) * loopCount, DRWAV_METADATA_ALIGNMENT);
2720 drwav__metadata_request_extra_memory_for_stage_2(pParser, samplerSpecificDataSizeInBytes, 1);
2721 }
2722 } else {
2723 /* Loop count in header does not match the size of the chunk. */
2724 }
2725 }
2726 } else {
2727 bytesRead = drwav__read_smpl_to_metadata_obj(pParser, pChunkHeader, &pParser->pMetadata[pParser->metadataCursor]);
2728 if (bytesRead == pChunkHeader->sizeInBytes) {
2729 pParser->metadataCursor += 1;
2730 } else {
2731 /* Failed to parse. */
2732 }
2733 }
2734 } else {
2735 /* Incorrectly formed chunk. */
2736 }
2737 } else if (drwav__chunk_matches(allowedMetadataTypes, pChunkID, drwav_metadata_type_inst, "inst")) {
2738 if (pChunkHeader->sizeInBytes == DRWAV_INST_BYTES) {
2739 if (pParser->stage == drwav__metadata_parser_stage_count) {
2740 pParser->metadataCount += 1;
2741 } else {
2742 bytesRead = drwav__read_inst_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor]);
2743 if (bytesRead == pChunkHeader->sizeInBytes) {
2744 pParser->metadataCursor += 1;
2745 } else {
2746 /* Failed to parse. */
2747 }
2748 }
2749 } else {
2750 /* Incorrectly formed chunk. */
2751 }
2752 } else if (drwav__chunk_matches(allowedMetadataTypes, pChunkID, drwav_metadata_type_acid, "acid")) {
2753 if (pChunkHeader->sizeInBytes == DRWAV_ACID_BYTES) {
2754 if (pParser->stage == drwav__metadata_parser_stage_count) {
2755 pParser->metadataCount += 1;
2756 } else {
2757 bytesRead = drwav__read_acid_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor]);
2758 if (bytesRead == pChunkHeader->sizeInBytes) {
2759 pParser->metadataCursor += 1;
2760 } else {
2761 /* Failed to parse. */
2762 }
2763 }
2764 } else {
2765 /* Incorrectly formed chunk. */
2766 }
2767 } else if (drwav__chunk_matches(allowedMetadataTypes, pChunkID, drwav_metadata_type_cue, "cue ")) {
2768 if (pChunkHeader->sizeInBytes >= DRWAV_CUE_BYTES) {
2769 if (pParser->stage == drwav__metadata_parser_stage_count) {
2770 size_t cueCount;
2771
2772 pParser->metadataCount += 1;
2773 cueCount = (size_t)(pChunkHeader->sizeInBytes - DRWAV_CUE_BYTES) / DRWAV_CUE_POINT_BYTES;
2774 drwav__metadata_request_extra_memory_for_stage_2(pParser, sizeof(drwav_cue_point) * cueCount, DRWAV_METADATA_ALIGNMENT);
2775 } else {
2776 bytesRead = drwav__read_cue_to_metadata_obj(pParser, pChunkHeader, &pParser->pMetadata[pParser->metadataCursor]);
2777 if (bytesRead == pChunkHeader->sizeInBytes) {
2778 pParser->metadataCursor += 1;
2779 } else {
2780 /* Failed to parse. */
2781 }
2782 }
2783 } else {
2784 /* Incorrectly formed chunk. */
2785 }
2786 } else if (drwav__chunk_matches(allowedMetadataTypes, pChunkID, drwav_metadata_type_bext, "bext")) {
2787 if (pChunkHeader->sizeInBytes >= DRWAV_BEXT_BYTES) {
2788 if (pParser->stage == drwav__metadata_parser_stage_count) {
2789 /* The description field is the largest one in a bext chunk, so that is the max size of this temporary buffer. */
2790 char buffer[DRWAV_BEXT_DESCRIPTION_BYTES + 1];
2791 size_t allocSizeNeeded = DRWAV_BEXT_UMID_BYTES; /* We know we will need SMPTE umid size. */
2792 size_t bytesJustRead;
2793
2794 buffer[DRWAV_BEXT_DESCRIPTION_BYTES] = '\0';
2795 bytesJustRead = drwav__metadata_parser_read(pParser, buffer, DRWAV_BEXT_DESCRIPTION_BYTES, &bytesRead);
2796 if (bytesJustRead != DRWAV_BEXT_DESCRIPTION_BYTES) {
2797 return bytesRead;
2798 }
2799 allocSizeNeeded += drwav__strlen(buffer) + 1;
2800
2801 buffer[DRWAV_BEXT_ORIGINATOR_NAME_BYTES] = '\0';
2802 bytesJustRead = drwav__metadata_parser_read(pParser, buffer, DRWAV_BEXT_ORIGINATOR_NAME_BYTES, &bytesRead);
2803 if (bytesJustRead != DRWAV_BEXT_ORIGINATOR_NAME_BYTES) {
2804 return bytesRead;
2805 }
2806 allocSizeNeeded += drwav__strlen(buffer) + 1;
2807
2808 buffer[DRWAV_BEXT_ORIGINATOR_REF_BYTES] = '\0';
2809 bytesJustRead = drwav__metadata_parser_read(pParser, buffer, DRWAV_BEXT_ORIGINATOR_REF_BYTES, &bytesRead);
2810 if (bytesJustRead != DRWAV_BEXT_ORIGINATOR_REF_BYTES) {
2811 return bytesRead;
2812 }
2813 allocSizeNeeded += drwav__strlen(buffer) + 1;
2814 allocSizeNeeded += (size_t)pChunkHeader->sizeInBytes - DRWAV_BEXT_BYTES; /* Coding history. */
2815
2816 drwav__metadata_request_extra_memory_for_stage_2(pParser, allocSizeNeeded, 1);
2817
2818 pParser->metadataCount += 1;
2819 } else {
2820 bytesRead = drwav__read_bext_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor], pChunkHeader->sizeInBytes);
2821 if (bytesRead == pChunkHeader->sizeInBytes) {
2822 pParser->metadataCursor += 1;
2823 } else {
2824 /* Failed to parse. */
2825 }
2826 }
2827 } else {
2828 /* Incorrectly formed chunk. */
2829 }
2830 } else if (drwav_fourcc_equal(pChunkID, "LIST") || drwav_fourcc_equal(pChunkID, "list")) {
2831 drwav_metadata_location listType = drwav_metadata_location_invalid;
2832 while (bytesRead < pChunkHeader->sizeInBytes) {
2833 drwav_uint8 subchunkId[4];
2834 drwav_uint8 subchunkSizeBuffer[4];
2835 drwav_uint64 subchunkDataSize;
2836 drwav_uint64 subchunkBytesRead = 0;
2837 drwav_uint64 bytesJustRead = drwav__metadata_parser_read(pParser, subchunkId, sizeof(subchunkId), &bytesRead);
2838 if (bytesJustRead != sizeof(subchunkId)) {
2839 break;
2840 }
2841
2842 /*
2843 The first thing in a list chunk should be "adtl" or "INFO".
2844
2845 - adtl means this list is a Associated Data List Chunk and will contain labels, notes
2846 or labelled cue regions.
2847 - INFO means this list is an Info List Chunk containing info text chunks such as IPRD
2848 which would specifies the album of this wav file.
2849
2850 No data follows the adtl or INFO id so we just make note of what type this list is and
2851 continue.
2852 */
2853 if (drwav_fourcc_equal(subchunkId, "adtl")) {
2854 listType = drwav_metadata_location_inside_adtl_list;
2855 continue;
2856 } else if (drwav_fourcc_equal(subchunkId, "INFO")) {
2857 listType = drwav_metadata_location_inside_info_list;
2858 continue;
2859 }
2860
2861 bytesJustRead = drwav__metadata_parser_read(pParser, subchunkSizeBuffer, sizeof(subchunkSizeBuffer), &bytesRead);
2862 if (bytesJustRead != sizeof(subchunkSizeBuffer)) {
2863 break;
2864 }
2865 subchunkDataSize = drwav_bytes_to_u32(subchunkSizeBuffer);
2866
2867 if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_label, "labl") || drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_note, "note")) {
2868 if (subchunkDataSize >= DRWAV_LIST_LABEL_OR_NOTE_BYTES) {
2869 drwav_uint64 stringSizeWithNullTerm = subchunkDataSize - DRWAV_LIST_LABEL_OR_NOTE_BYTES;
2870 if (pParser->stage == drwav__metadata_parser_stage_count) {
2871 pParser->metadataCount += 1;
2872 drwav__metadata_request_extra_memory_for_stage_2(pParser, (size_t)stringSizeWithNullTerm, 1);
2873 } else {
2874 subchunkBytesRead = drwav__read_list_label_or_note_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor], subchunkDataSize, drwav_fourcc_equal(subchunkId, "labl") ? drwav_metadata_type_list_label : drwav_metadata_type_list_note);
2875 if (subchunkBytesRead == subchunkDataSize) {
2876 pParser->metadataCursor += 1;
2877 } else {
2878 /* Failed to parse. */
2879 }
2880 }
2881 } else {
2882 /* Incorrectly formed chunk. */
2883 }
2884 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_labelled_cue_region, "ltxt")) {
2885 if (subchunkDataSize >= DRWAV_LIST_LABELLED_TEXT_BYTES) {
2886 drwav_uint64 stringSizeWithNullTerminator = subchunkDataSize - DRWAV_LIST_LABELLED_TEXT_BYTES;
2887 if (pParser->stage == drwav__metadata_parser_stage_count) {
2888 pParser->metadataCount += 1;
2889 drwav__metadata_request_extra_memory_for_stage_2(pParser, (size_t)stringSizeWithNullTerminator, 1);
2890 } else {
2891 subchunkBytesRead = drwav__read_list_labelled_cue_region_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor], subchunkDataSize);
2892 if (subchunkBytesRead == subchunkDataSize) {
2893 pParser->metadataCursor += 1;
2894 } else {
2895 /* Failed to parse. */
2896 }
2897 }
2898 } else {
2899 /* Incorrectly formed chunk. */
2900 }
2901 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_software, "ISFT")) {
2902 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_software);
2903 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_copyright, "ICOP")) {
2904 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_copyright);
2905 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_title, "INAM")) {
2906 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_title);
2907 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_artist, "IART")) {
2908 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_artist);
2909 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_comment, "ICMT")) {
2910 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_comment);
2911 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_date, "ICRD")) {
2912 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_date);
2913 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_genre, "IGNR")) {
2914 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_genre);
2915 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_album, "IPRD")) {
2916 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_album);
2917 } else if (drwav__chunk_matches(allowedMetadataTypes, subchunkId, drwav_metadata_type_list_info_tracknumber, "ITRK")) {
2918 subchunkBytesRead = drwav__metadata_process_info_text_chunk(pParser, subchunkDataSize, drwav_metadata_type_list_info_tracknumber);
2919 } else if ((allowedMetadataTypes & drwav_metadata_type_unknown) != 0) {
2920 subchunkBytesRead = drwav__metadata_process_unknown_chunk(pParser, subchunkId, subchunkDataSize, listType);
2921 }
2922
2923 bytesRead += subchunkBytesRead;
2924 DRWAV_ASSERT(subchunkBytesRead <= subchunkDataSize);
2925
2926 if (subchunkBytesRead < subchunkDataSize) {
2927 drwav_uint64 bytesToSeek = subchunkDataSize - subchunkBytesRead;
2928
2929 if (!pParser->onSeek(pParser->pReadSeekUserData, (int)bytesToSeek, drwav_seek_origin_current)) {
2930 break;
2931 }
2932 bytesRead += bytesToSeek;
2933 }
2934
2935 if ((subchunkDataSize % 2) == 1) {
2936 if (!pParser->onSeek(pParser->pReadSeekUserData, 1, drwav_seek_origin_current)) {
2937 break;
2938 }
2939 bytesRead += 1;
2940 }
2941 }
2942 } else if ((allowedMetadataTypes & drwav_metadata_type_unknown) != 0) {
2943 bytesRead = drwav__metadata_process_unknown_chunk(pParser, pChunkID, pChunkHeader->sizeInBytes, drwav_metadata_location_top_level);
2944 }
2945
2946 return bytesRead;
2947}
2948
2949
2950DRWAV_PRIVATE drwav_uint32 drwav_get_bytes_per_pcm_frame(drwav* pWav)
2951{
2952 drwav_uint32 bytesPerFrame;
2953
2954 /*
2955 The bytes per frame is a bit ambiguous. It can be either be based on the bits per sample, or the block align. The way I'm doing it here
2956 is that if the bits per sample is a multiple of 8, use floor(bitsPerSample*channels/8), otherwise fall back to the block align.
2957 */
2958 if ((pWav->bitsPerSample & 0x7) == 0) {
2959 /* Bits per sample is a multiple of 8. */
2960 bytesPerFrame = (pWav->bitsPerSample * pWav->fmt.channels) >> 3;
2961 } else {
2962 bytesPerFrame = pWav->fmt.blockAlign;
2963 }
2964
2965 /* Validation for known formats. a-law and mu-law should be 1 byte per channel. If it's not, it's not decodable. */
2966 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW || pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
2967 if (bytesPerFrame != pWav->fmt.channels) {
2968 return 0; /* Invalid file. */
2969 }
2970 }
2971
2972 return bytesPerFrame;
2973}
2974
2975DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT)
2976{
2977 if (pFMT == NULL) {
2978 return 0;
2979 }
2980
2981 if (pFMT->formatTag != DR_WAVE_FORMAT_EXTENSIBLE) {
2982 return pFMT->formatTag;
2983 } else {
2984 return drwav_bytes_to_u16(pFMT->subFormat); /* Only the first two bytes are required. */
2985 }
2986}
2987
2988DRWAV_PRIVATE drwav_bool32 drwav_preinit(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
2989{
2990 if (pWav == NULL || onRead == NULL || onSeek == NULL) {
2991 return DRWAV_FALSE;
2992 }
2993
2994 DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
2995 pWav->onRead = onRead;
2996 pWav->onSeek = onSeek;
2997 pWav->pUserData = pReadSeekUserData;
2998 pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
2999
3000 if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
3001 return DRWAV_FALSE; /* Invalid allocation callbacks. */
3002 }
3003
3004 return DRWAV_TRUE;
3005}
3006
3007DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags)
3008{
3009 /* This function assumes drwav_preinit() has been called beforehand. */
3010 drwav_result result;
3011 drwav_uint64 cursor; /* <-- Keeps track of the byte position so we can seek to specific locations. */
3012 drwav_bool32 sequential;
3013 drwav_uint8 riff[4];
3014 drwav_fmt fmt;
3015 unsigned short translatedFormatTag;
3016 drwav_uint64 dataChunkSize = 0; /* <-- Important! Don't explicitly set this to 0 anywhere else. Calculation of the size of the data chunk is performed in different paths depending on the container. */
3017 drwav_uint64 sampleCountFromFactChunk = 0; /* Same as dataChunkSize - make sure this is the only place this is initialized to 0. */
3018 drwav_uint64 metadataStartPos;
3019 drwav__metadata_parser metadataParser;
3020 drwav_bool8 isProcessingMetadata = DRWAV_FALSE;
3021 drwav_bool8 foundChunk_fmt = DRWAV_FALSE;
3022 drwav_bool8 foundChunk_data = DRWAV_FALSE;
3023 drwav_bool8 isAIFCFormType = DRWAV_FALSE; /* Only used with AIFF. */
3024 drwav_uint64 aiffFrameCount = 0;
3025
3026 cursor = 0;
3027 sequential = (flags & DRWAV_SEQUENTIAL) != 0;
3028 DRWAV_ZERO_OBJECT(&fmt);
3029
3030 /* The first 4 bytes should be the RIFF identifier. */
3031 if (drwav__on_read(pWav->onRead, pWav->pUserData, riff, sizeof(riff), &cursor) != sizeof(riff)) {
3032 return DRWAV_FALSE;
3033 }
3034
3035 /*
3036 The first 4 bytes can be used to identify the container. For RIFF files it will start with "RIFF" and for
3037 w64 it will start with "riff".
3038 */
3039 if (drwav_fourcc_equal(riff, "RIFF")) {
3040 pWav->container = drwav_container_riff;
3041 } else if (drwav_fourcc_equal(riff, "RIFX")) {
3042 pWav->container = drwav_container_rifx;
3043 } else if (drwav_fourcc_equal(riff, "riff")) {
3044 int i;
3045 drwav_uint8 riff2[12];
3046
3047 pWav->container = drwav_container_w64;
3048
3049 /* Check the rest of the GUID for validity. */
3050 if (drwav__on_read(pWav->onRead, pWav->pUserData, riff2, sizeof(riff2), &cursor) != sizeof(riff2)) {
3051 return DRWAV_FALSE;
3052 }
3053
3054 for (i = 0; i < 12; ++i) {
3055 if (riff2[i] != drwavGUID_W64_RIFF[i+4]) {
3056 return DRWAV_FALSE;
3057 }
3058 }
3059 } else if (drwav_fourcc_equal(riff, "RF64")) {
3060 pWav->container = drwav_container_rf64;
3061 } else if (drwav_fourcc_equal(riff, "FORM")) {
3062 pWav->container = drwav_container_aiff;
3063 } else {
3064 return DRWAV_FALSE; /* Unknown or unsupported container. */
3065 }
3066
3067
3068 if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx || pWav->container == drwav_container_rf64) {
3069 drwav_uint8 chunkSizeBytes[4];
3070 drwav_uint8 wave[4];
3071
3072 if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
3073 return DRWAV_FALSE;
3074 }
3075
3076 if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx) {
3077 if (drwav_bytes_to_u32_ex(chunkSizeBytes, pWav->container) < 36) {
3078 /*
3079 I've had a report of a WAV file failing to load when the size of the WAVE chunk is not encoded
3080 and is instead just set to 0. I'm going to relax the validation here to allow these files to
3081 load. Considering the chunk size isn't actually used this should be safe. With this change my
3082 test suite still passes.
3083 */
3084 /*return DRWAV_FALSE;*/ /* Chunk size should always be at least 36 bytes. */
3085 }
3086 } else if (pWav->container == drwav_container_rf64) {
3087 if (drwav_bytes_to_u32_le(chunkSizeBytes) != 0xFFFFFFFF) {
3088 return DRWAV_FALSE; /* Chunk size should always be set to -1/0xFFFFFFFF for RF64. The actual size is retrieved later. */
3089 }
3090 } else {
3091 return DRWAV_FALSE; /* Should never hit this. */
3092 }
3093
3094 if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
3095 return DRWAV_FALSE;
3096 }
3097
3098 if (!drwav_fourcc_equal(wave, "WAVE")) {
3099 return DRWAV_FALSE; /* Expecting "WAVE". */
3100 }
3101 } else if (pWav->container == drwav_container_w64) {
3102 drwav_uint8 chunkSizeBytes[8];
3103 drwav_uint8 wave[16];
3104
3105 if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
3106 return DRWAV_FALSE;
3107 }
3108
3109 if (drwav_bytes_to_u64(chunkSizeBytes) < 80) {
3110 return DRWAV_FALSE;
3111 }
3112
3113 if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
3114 return DRWAV_FALSE;
3115 }
3116
3117 if (!drwav_guid_equal(wave, drwavGUID_W64_WAVE)) {
3118 return DRWAV_FALSE;
3119 }
3120 } else if (pWav->container == drwav_container_aiff) {
3121 drwav_uint8 chunkSizeBytes[4];
3122 drwav_uint8 aiff[4];
3123
3124 if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
3125 return DRWAV_FALSE;
3126 }
3127
3128 if (drwav_bytes_to_u32_be(chunkSizeBytes) < 18) {
3129 return DRWAV_FALSE;
3130 }
3131
3132 if (drwav__on_read(pWav->onRead, pWav->pUserData, aiff, sizeof(aiff), &cursor) != sizeof(aiff)) {
3133 return DRWAV_FALSE;
3134 }
3135
3136 if (drwav_fourcc_equal(aiff, "AIFF")) {
3137 isAIFCFormType = DRWAV_FALSE;
3138 } else if (drwav_fourcc_equal(aiff, "AIFC")) {
3139 isAIFCFormType = DRWAV_TRUE;
3140 } else {
3141 return DRWAV_FALSE; /* Expecting "AIFF" or "AIFC". */
3142 }
3143 } else {
3144 return DRWAV_FALSE;
3145 }
3146
3147
3148 /* For RF64, the "ds64" chunk must come next, before the "fmt " chunk. */
3149 if (pWav->container == drwav_container_rf64) {
3150 drwav_uint8 sizeBytes[8];
3151 drwav_uint64 bytesRemainingInChunk;
3152 drwav_chunk_header header;
3153 result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
3154 if (result != DRWAV_SUCCESS) {
3155 return DRWAV_FALSE;
3156 }
3157
3158 if (!drwav_fourcc_equal(header.id.fourcc, "ds64")) {
3159 return DRWAV_FALSE; /* Expecting "ds64". */
3160 }
3161
3162 bytesRemainingInChunk = header.sizeInBytes + header.paddingSize;
3163
3164 /* We don't care about the size of the RIFF chunk - skip it. */
3165 if (!drwav__seek_forward(pWav->onSeek, 8, pWav->pUserData)) {
3166 return DRWAV_FALSE;
3167 }
3168 bytesRemainingInChunk -= 8;
3169 cursor += 8;
3170
3171
3172 /* Next 8 bytes is the size of the "data" chunk. */
3173 if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
3174 return DRWAV_FALSE;
3175 }
3176 bytesRemainingInChunk -= 8;
3177 dataChunkSize = drwav_bytes_to_u64(sizeBytes);
3178
3179
3180 /* Next 8 bytes is the same count which we would usually derived from the FACT chunk if it was available. */
3181 if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
3182 return DRWAV_FALSE;
3183 }
3184 bytesRemainingInChunk -= 8;
3185 sampleCountFromFactChunk = drwav_bytes_to_u64(sizeBytes);
3186
3187
3188 /* Skip over everything else. */
3189 if (!drwav__seek_forward(pWav->onSeek, bytesRemainingInChunk, pWav->pUserData)) {
3190 return DRWAV_FALSE;
3191 }
3192 cursor += bytesRemainingInChunk;
3193 }
3194
3195
3196 metadataStartPos = cursor;
3197
3198 /*
3199 Whether or not we are processing metadata controls how we load. We can load more efficiently when
3200 metadata is not being processed, but we also cannot process metadata for Wave64 because I have not
3201 been able to test it. If someone is able to test this and provide a patch I'm happy to enable it.
3202
3203 Seqential mode cannot support metadata because it involves seeking backwards.
3204 */
3205 isProcessingMetadata = !sequential && ((flags & DRWAV_WITH_METADATA) != 0);
3206
3207 /* Don't allow processing of metadata with untested containers. */
3208 if (pWav->container != drwav_container_riff && pWav->container != drwav_container_rf64) {
3209 isProcessingMetadata = DRWAV_FALSE;
3210 }
3211
3212 DRWAV_ZERO_MEMORY(&metadataParser, sizeof(metadataParser));
3213 if (isProcessingMetadata) {
3214 metadataParser.onRead = pWav->onRead;
3215 metadataParser.onSeek = pWav->onSeek;
3216 metadataParser.pReadSeekUserData = pWav->pUserData;
3217 metadataParser.stage = drwav__metadata_parser_stage_count;
3218 }
3219
3220
3221 /*
3222 From here on out, chunks might be in any order. In order to robustly handle metadata we'll need
3223 to loop through every chunk and handle them as we find them. In sequential mode we need to get
3224 out of the loop as soon as we find the data chunk because we won't be able to seek back.
3225 */
3226 for (;;) { /* For each chunk... */
3227 drwav_chunk_header header;
3228 drwav_uint64 chunkSize;
3229
3230 result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
3231 if (result != DRWAV_SUCCESS) {
3232 break;
3233 }
3234
3235 chunkSize = header.sizeInBytes;
3236
3237
3238 /*
3239 Always tell the caller about this chunk. We cannot do this in sequential mode because the
3240 callback is allowed to read from the file, in which case we'll need to rewind.
3241 */
3242 if (!sequential && onChunk != NULL) {
3243 drwav_uint64 callbackBytesRead = onChunk(pChunkUserData, pWav->onRead, pWav->onSeek, pWav->pUserData, &header, pWav->container, &fmt);
3244
3245 /*
3246 dr_wav may need to read the contents of the chunk, so we now need to seek back to the position before
3247 we called the callback.
3248 */
3249 if (callbackBytesRead > 0) {
3250 if (drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData) == DRWAV_FALSE) {
3251 return DRWAV_FALSE;
3252 }
3253 }
3254 }
3255
3256
3257 /* Explicitly handle known chunks first. */
3258
3259 /* "fmt " */
3260 if (((pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx || pWav->container == drwav_container_rf64) && drwav_fourcc_equal(header.id.fourcc, "fmt ")) ||
3261 ((pWav->container == drwav_container_w64) && drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT))) {
3262 drwav_uint8 fmtData[16];
3263
3264 foundChunk_fmt = DRWAV_TRUE;
3265
3266 if (pWav->onRead(pWav->pUserData, fmtData, sizeof(fmtData)) != sizeof(fmtData)) {
3267 return DRWAV_FALSE;
3268 }
3269 cursor += sizeof(fmtData);
3270
3271 fmt.formatTag = drwav_bytes_to_u16_ex(fmtData + 0, pWav->container);
3272 fmt.channels = drwav_bytes_to_u16_ex(fmtData + 2, pWav->container);
3273 fmt.sampleRate = drwav_bytes_to_u32_ex(fmtData + 4, pWav->container);
3274 fmt.avgBytesPerSec = drwav_bytes_to_u32_ex(fmtData + 8, pWav->container);
3275 fmt.blockAlign = drwav_bytes_to_u16_ex(fmtData + 12, pWav->container);
3276 fmt.bitsPerSample = drwav_bytes_to_u16_ex(fmtData + 14, pWav->container);
3277
3278 fmt.extendedSize = 0;
3279 fmt.validBitsPerSample = 0;
3280 fmt.channelMask = 0;
3281 DRWAV_ZERO_MEMORY(fmt.subFormat, sizeof(fmt.subFormat));
3282
3283 if (header.sizeInBytes > 16) {
3284 drwav_uint8 fmt_cbSize[2];
3285 int bytesReadSoFar = 0;
3286
3287 if (pWav->onRead(pWav->pUserData, fmt_cbSize, sizeof(fmt_cbSize)) != sizeof(fmt_cbSize)) {
3288 return DRWAV_FALSE; /* Expecting more data. */
3289 }
3290 cursor += sizeof(fmt_cbSize);
3291
3292 bytesReadSoFar = 18;
3293
3294 fmt.extendedSize = drwav_bytes_to_u16_ex(fmt_cbSize, pWav->container);
3295 if (fmt.extendedSize > 0) {
3296 /* Simple validation. */
3297 if (fmt.formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
3298 if (fmt.extendedSize != 22) {
3299 return DRWAV_FALSE;
3300 }
3301 }
3302
3303 if (fmt.formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
3304 drwav_uint8 fmtext[22];
3305
3306 if (pWav->onRead(pWav->pUserData, fmtext, fmt.extendedSize) != fmt.extendedSize) {
3307 return DRWAV_FALSE; /* Expecting more data. */
3308 }
3309
3310 fmt.validBitsPerSample = drwav_bytes_to_u16_ex(fmtext + 0, pWav->container);
3311 fmt.channelMask = drwav_bytes_to_u32_ex(fmtext + 2, pWav->container);
3312 drwav_bytes_to_guid(fmtext + 6, fmt.subFormat);
3313 } else {
3314 if (pWav->onSeek(pWav->pUserData, fmt.extendedSize, drwav_seek_origin_current) == DRWAV_FALSE) {
3315 return DRWAV_FALSE;
3316 }
3317 }
3318 cursor += fmt.extendedSize;
3319
3320 bytesReadSoFar += fmt.extendedSize;
3321 }
3322
3323 /* Seek past any leftover bytes. For w64 the leftover will be defined based on the chunk size. */
3324 if (pWav->onSeek(pWav->pUserData, (int)(header.sizeInBytes - bytesReadSoFar), drwav_seek_origin_current) == DRWAV_FALSE) {
3325 return DRWAV_FALSE;
3326 }
3327 cursor += (header.sizeInBytes - bytesReadSoFar);
3328 }
3329
3330 if (header.paddingSize > 0) {
3331 if (drwav__seek_forward(pWav->onSeek, header.paddingSize, pWav->pUserData) == DRWAV_FALSE) {
3332 break;
3333 }
3334 cursor += header.paddingSize;
3335 }
3336
3337 /* Go to the next chunk. Don't include this chunk in metadata. */
3338 continue;
3339 }
3340
3341 /* "data" */
3342 if (((pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx || pWav->container == drwav_container_rf64) && drwav_fourcc_equal(header.id.fourcc, "data")) ||
3343 ((pWav->container == drwav_container_w64) && drwav_guid_equal(header.id.guid, drwavGUID_W64_DATA))) {
3344 foundChunk_data = DRWAV_TRUE;
3345
3346 pWav->dataChunkDataPos = cursor;
3347
3348 if (pWav->container != drwav_container_rf64) { /* The data chunk size for RF64 will always be set to 0xFFFFFFFF here. It was set to it's true value earlier. */
3349 dataChunkSize = chunkSize;
3350 }
3351
3352 /* If we're running in sequential mode, or we're not reading metadata, we have enough now that we can get out of the loop. */
3353 if (sequential || !isProcessingMetadata) {
3354 break; /* No need to keep reading beyond the data chunk. */
3355 } else {
3356 chunkSize += header.paddingSize; /* <-- Make sure we seek past the padding. */
3357 if (drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == DRWAV_FALSE) {
3358 break;
3359 }
3360 cursor += chunkSize;
3361
3362 continue; /* There may be some more metadata to read. */
3363 }
3364 }
3365
3366 /* "fact". This is optional. Can use this to get the sample count which is useful for compressed formats. For RF64 we retrieved the sample count from the ds64 chunk earlier. */
3367 if (((pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx || pWav->container == drwav_container_rf64) && drwav_fourcc_equal(header.id.fourcc, "fact")) ||
3368 ((pWav->container == drwav_container_w64) && drwav_guid_equal(header.id.guid, drwavGUID_W64_FACT))) {
3369 if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx) {
3370 drwav_uint8 sampleCount[4];
3371 if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) {
3372 return DRWAV_FALSE;
3373 }
3374
3375 chunkSize -= 4;
3376
3377 /*
3378 The sample count in the "fact" chunk is either unreliable, or I'm not understanding it properly. For now I am only enabling this
3379 for Microsoft ADPCM formats.
3380 */
3381 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
3382 sampleCountFromFactChunk = drwav_bytes_to_u32_ex(sampleCount, pWav->container);
3383 } else {
3384 sampleCountFromFactChunk = 0;
3385 }
3386 } else if (pWav->container == drwav_container_w64) {
3387 if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) {
3388 return DRWAV_FALSE;
3389 }
3390
3391 chunkSize -= 8;
3392 } else if (pWav->container == drwav_container_rf64) {
3393 /* We retrieved the sample count from the ds64 chunk earlier so no need to do that here. */
3394 }
3395
3396 /* Seek to the next chunk in preparation for the next iteration. */
3397 chunkSize += header.paddingSize; /* <-- Make sure we seek past the padding. */
3398 if (drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == DRWAV_FALSE) {
3399 break;
3400 }
3401 cursor += chunkSize;
3402
3403 continue;
3404 }
3405
3406
3407 /* "COMM". AIFF/AIFC only. */
3408 if (pWav->container == drwav_container_aiff && drwav_fourcc_equal(header.id.fourcc, "COMM")) {
3409 drwav_uint8 commData[24];
3410 drwav_uint32 commDataBytesToRead;
3411 drwav_uint16 channels;
3412 drwav_uint32 frameCount;
3413 drwav_uint16 sampleSizeInBits;
3414 drwav_int64 sampleRate;
3415 drwav_uint16 compressionFormat;
3416
3417 foundChunk_fmt = DRWAV_TRUE;
3418
3419 if (isAIFCFormType) {
3420 commDataBytesToRead = 24;
3421 if (header.sizeInBytes < commDataBytesToRead) {
3422 return DRWAV_FALSE; /* Invalid COMM chunk. */
3423 }
3424 } else {
3425 commDataBytesToRead = 18;
3426 if (header.sizeInBytes != commDataBytesToRead) {
3427 return DRWAV_FALSE; /* INVALID COMM chunk. */
3428 }
3429 }
3430
3431 if (drwav__on_read(pWav->onRead, pWav->pUserData, commData, commDataBytesToRead, &cursor) != commDataBytesToRead) {
3432 return DRWAV_FALSE;
3433 }
3434
3435
3436 channels = drwav_bytes_to_u16_ex (commData + 0, pWav->container);
3437 frameCount = drwav_bytes_to_u32_ex (commData + 2, pWav->container);
3438 sampleSizeInBits = drwav_bytes_to_u16_ex (commData + 6, pWav->container);
3439 sampleRate = drwav_aiff_extented_to_s64(commData + 8);
3440
3441 if (sampleRate < 0 || sampleRate > 0xFFFFFFFF) {
3442 return DRWAV_FALSE; /* Invalid sample rate. */
3443 }
3444
3445 if (isAIFCFormType) {
3446 const drwav_uint8* type = commData + 18;
3447
3448 if (drwav_fourcc_equal(type, "NONE")) {
3449 compressionFormat = DR_WAVE_FORMAT_PCM; /* PCM, big-endian. */
3450 } else if (drwav_fourcc_equal(type, "raw ")) {
3451 compressionFormat = DR_WAVE_FORMAT_PCM;
3452
3453 /* In my testing, it looks like when the "raw " compression type is used, 8-bit samples should be considered unsigned. */
3454 if (sampleSizeInBits == 8) {
3455 pWav->aiff.isUnsigned = DRWAV_TRUE;
3456 }
3457 } else if (drwav_fourcc_equal(type, "sowt")) {
3458 compressionFormat = DR_WAVE_FORMAT_PCM; /* PCM, little-endian. */
3459 pWav->aiff.isLE = DRWAV_TRUE;
3460 } else if (drwav_fourcc_equal(type, "fl32") || drwav_fourcc_equal(type, "fl64") || drwav_fourcc_equal(type, "FL32") || drwav_fourcc_equal(type, "FL64")) {
3461 compressionFormat = DR_WAVE_FORMAT_IEEE_FLOAT;
3462 } else if (drwav_fourcc_equal(type, "alaw") || drwav_fourcc_equal(type, "ALAW")) {
3463 compressionFormat = DR_WAVE_FORMAT_ALAW;
3464 } else if (drwav_fourcc_equal(type, "ulaw") || drwav_fourcc_equal(type, "ULAW")) {
3465 compressionFormat = DR_WAVE_FORMAT_MULAW;
3466 } else if (drwav_fourcc_equal(type, "ima4")) {
3467 compressionFormat = DR_WAVE_FORMAT_DVI_ADPCM;
3468 sampleSizeInBits = 4;
3469
3470 /*
3471 I haven't been able to figure out how to get correct decoding for IMA ADPCM. Until this is figured out
3472 we'll need to abort when we encounter such an encoding. Advice welcome!
3473 */
3474 return DRWAV_FALSE;
3475 } else {
3476 return DRWAV_FALSE; /* Unknown or unsupported compression format. Need to abort. */
3477 }
3478 } else {
3479 compressionFormat = DR_WAVE_FORMAT_PCM; /* It's a standard AIFF form which is always compressed. */
3480 }
3481
3482 /* With AIFF we want to use the explicitly defined frame count rather than deriving it from the size of the chunk. */
3483 aiffFrameCount = frameCount;
3484
3485 /* We should now have enough information to fill out our fmt structure. */
3486 fmt.formatTag = compressionFormat;
3487 fmt.channels = channels;
3488 fmt.sampleRate = (drwav_uint32)sampleRate;
3489 fmt.bitsPerSample = sampleSizeInBits;
3490 fmt.blockAlign = (drwav_uint16)(fmt.channels * fmt.bitsPerSample / 8);
3491 fmt.avgBytesPerSec = fmt.blockAlign * fmt.sampleRate;
3492
3493 if (fmt.blockAlign == 0 && compressionFormat == DR_WAVE_FORMAT_DVI_ADPCM) {
3494 fmt.blockAlign = 34 * fmt.channels;
3495 }
3496
3497 /*
3498 Weird one. I've seen some alaw and ulaw encoded files that for some reason set the bits per sample to 16 when
3499 it should be 8. To get this working I need to explicitly check for this and change it.
3500 */
3501 if (compressionFormat == DR_WAVE_FORMAT_ALAW || compressionFormat == DR_WAVE_FORMAT_MULAW) {
3502 if (fmt.bitsPerSample > 8) {
3503 fmt.bitsPerSample = 8;
3504 fmt.blockAlign = fmt.channels;
3505 }
3506 }
3507
3508 /* In AIFF, samples are padded to 8 byte boundaries. We need to round up our bits per sample here. */
3509 fmt.bitsPerSample += (fmt.bitsPerSample & 7);
3510
3511
3512 /* If the form type is AIFC there will be some additional data in the chunk. We need to seek past it. */
3513 if (isAIFCFormType) {
3514 if (drwav__seek_forward(pWav->onSeek, (chunkSize - commDataBytesToRead), pWav->pUserData) == DRWAV_FALSE) {
3515 return DRWAV_FALSE;
3516 }
3517 cursor += (chunkSize - commDataBytesToRead);
3518 }
3519
3520 /* Don't fall through or else we'll end up treating this chunk as metadata which is incorrect. */
3521 continue;
3522 }
3523
3524
3525 /* "SSND". AIFF/AIFC only. This is the AIFF equivalent of the "data" chunk. */
3526 if (pWav->container == drwav_container_aiff && drwav_fourcc_equal(header.id.fourcc, "SSND")) {
3527 drwav_uint8 offsetAndBlockSizeData[8];
3528 drwav_uint32 offset;
3529
3530 foundChunk_data = DRWAV_TRUE;
3531
3532 if (drwav__on_read(pWav->onRead, pWav->pUserData, offsetAndBlockSizeData, sizeof(offsetAndBlockSizeData), &cursor) != sizeof(offsetAndBlockSizeData)) {
3533 return DRWAV_FALSE;
3534 }
3535
3536 /* We need to seek forward by the offset. */
3537 offset = drwav_bytes_to_u32_ex(offsetAndBlockSizeData + 0, pWav->container);
3538 if (drwav__seek_forward(pWav->onSeek, offset, pWav->pUserData) == DRWAV_FALSE) {
3539 return DRWAV_FALSE;
3540 }
3541 cursor += offset;
3542
3543 pWav->dataChunkDataPos = cursor;
3544 dataChunkSize = chunkSize;
3545
3546 /* If we're running in sequential mode, or we're not reading metadata, we have enough now that we can get out of the loop. */
3547 if (sequential || !isProcessingMetadata) {
3548 break; /* No need to keep reading beyond the data chunk. */
3549 } else {
3550 if (drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == DRWAV_FALSE) {
3551 break;
3552 }
3553 cursor += chunkSize;
3554
3555 continue; /* There may be some more metadata to read. */
3556 }
3557 }
3558
3559
3560
3561 /* Getting here means it's not a chunk that we care about internally, but might need to be handled as metadata by the caller. */
3562 if (isProcessingMetadata) {
3563 drwav__metadata_process_chunk(&metadataParser, &header, drwav_metadata_type_all_including_unknown);
3564
3565 /* Go back to the start of the chunk so we can normalize the position of the cursor. */
3566 if (drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData) == DRWAV_FALSE) {
3567 break; /* Failed to seek. Can't reliable read the remaining chunks. Get out. */
3568 }
3569 }
3570
3571
3572 /* Make sure we skip past the content of this chunk before we go to the next one. */
3573 chunkSize += header.paddingSize; /* <-- Make sure we seek past the padding. */
3574 if (drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == DRWAV_FALSE) {
3575 break;
3576 }
3577 cursor += chunkSize;
3578 }
3579
3580 /* There's some mandatory chunks that must exist. If they were not found in the iteration above we must abort. */
3581 if (!foundChunk_fmt || !foundChunk_data) {
3582 return DRWAV_FALSE;
3583 }
3584
3585 /* Basic validation. */
3586 if ((fmt.sampleRate == 0 || fmt.sampleRate > DRWAV_MAX_SAMPLE_RATE ) ||
3587 (fmt.channels == 0 || fmt.channels > DRWAV_MAX_CHANNELS ) ||
3588 (fmt.bitsPerSample == 0 || fmt.bitsPerSample > DRWAV_MAX_BITS_PER_SAMPLE) ||
3589 fmt.blockAlign == 0) {
3590 return DRWAV_FALSE; /* Probably an invalid WAV file. */
3591 }
3592
3593 /* Translate the internal format. */
3594 translatedFormatTag = fmt.formatTag;
3595 if (translatedFormatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
3596 translatedFormatTag = drwav_bytes_to_u16_ex(fmt.subFormat + 0, pWav->container);
3597 }
3598
3599 /* We may have moved passed the data chunk. If so we need to move back. If running in sequential mode we can assume we are already sitting on the data chunk. */
3600 if (!sequential) {
3601 if (!drwav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData)) {
3602 return DRWAV_FALSE;
3603 }
3604 cursor = pWav->dataChunkDataPos;
3605 }
3606
3607
3608 /*
3609 At this point we should have done the initial parsing of each of our chunks, but we now need to
3610 do a second pass to extract the actual contents of the metadata (the first pass just calculated
3611 the length of the memory allocation).
3612
3613 We only do this if we've actually got metadata to parse.
3614 */
3615 if (isProcessingMetadata && metadataParser.metadataCount > 0) {
3616 if (drwav__seek_from_start(pWav->onSeek, metadataStartPos, pWav->pUserData) == DRWAV_FALSE) {
3617 return DRWAV_FALSE;
3618 }
3619
3620 result = drwav__metadata_alloc(&metadataParser, &pWav->allocationCallbacks);
3621 if (result != DRWAV_SUCCESS) {
3622 return DRWAV_FALSE;
3623 }
3624
3625 metadataParser.stage = drwav__metadata_parser_stage_read;
3626
3627 for (;;) {
3628 drwav_chunk_header header;
3629 drwav_uint64 metadataBytesRead;
3630
3631 result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
3632 if (result != DRWAV_SUCCESS) {
3633 break;
3634 }
3635
3636 metadataBytesRead = drwav__metadata_process_chunk(&metadataParser, &header, drwav_metadata_type_all_including_unknown);
3637
3638 /* Move to the end of the chunk so we can keep iterating. */
3639 if (drwav__seek_forward(pWav->onSeek, (header.sizeInBytes + header.paddingSize) - metadataBytesRead, pWav->pUserData) == DRWAV_FALSE) {
3640 drwav_free(metadataParser.pMetadata, &pWav->allocationCallbacks);
3641 return DRWAV_FALSE;
3642 }
3643 }
3644
3645 /* Getting here means we're finished parsing the metadata. */
3646 pWav->pMetadata = metadataParser.pMetadata;
3647 pWav->metadataCount = metadataParser.metadataCount;
3648 }
3649
3650
3651 /* At this point we should be sitting on the first byte of the raw audio data. */
3652
3653 /*
3654 I've seen a WAV file in the wild where a RIFF-ecapsulated file has the size of it's "RIFF" and
3655 "data" chunks set to 0xFFFFFFFF when the file is definitely not that big. In this case we're
3656 going to have to calculate the size by reading and discarding bytes, and then seeking back. We
3657 cannot do this in sequential mode. We just assume that the rest of the file is audio data.
3658 */
3659 if (dataChunkSize == 0xFFFFFFFF && (pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx) && pWav->isSequentialWrite == DRWAV_FALSE) {
3660 dataChunkSize = 0;
3661
3662 for (;;) {
3663 drwav_uint8 temp[4096];
3664 size_t bytesRead = pWav->onRead(pWav->pUserData, temp, sizeof(temp));
3665 dataChunkSize += bytesRead;
3666
3667 if (bytesRead < sizeof(temp)) {
3668 break;
3669 }
3670 }
3671 }
3672
3673 if (drwav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData) == DRWAV_FALSE) {
3674 drwav_free(pWav->pMetadata, &pWav->allocationCallbacks);
3675 return DRWAV_FALSE;
3676 }
3677
3678
3679 pWav->fmt = fmt;
3680 pWav->sampleRate = fmt.sampleRate;
3681 pWav->channels = fmt.channels;
3682 pWav->bitsPerSample = fmt.bitsPerSample;
3683 pWav->bytesRemaining = dataChunkSize;
3684 pWav->translatedFormatTag = translatedFormatTag;
3685 pWav->dataChunkDataSize = dataChunkSize;
3686
3687 if (sampleCountFromFactChunk != 0) {
3688 pWav->totalPCMFrameCount = sampleCountFromFactChunk;
3689 } else if (aiffFrameCount != 0) {
3690 pWav->totalPCMFrameCount = aiffFrameCount;
3691 } else {
3692 drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
3693 if (bytesPerFrame == 0) {
3694 drwav_free(pWav->pMetadata, &pWav->allocationCallbacks);
3695 return DRWAV_FALSE; /* Invalid file. */
3696 }
3697
3698 pWav->totalPCMFrameCount = dataChunkSize / bytesPerFrame;
3699
3700 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
3701 drwav_uint64 totalBlockHeaderSizeInBytes;
3702 drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
3703
3704 /* Make sure any trailing partial block is accounted for. */
3705 if ((blockCount * fmt.blockAlign) < dataChunkSize) {
3706 blockCount += 1;
3707 }
3708
3709 /* We decode two samples per byte. There will be blockCount headers in the data chunk. This is enough to know how to calculate the total PCM frame count. */
3710 totalBlockHeaderSizeInBytes = blockCount * (6*fmt.channels);
3711 pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
3712 }
3713 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
3714 drwav_uint64 totalBlockHeaderSizeInBytes;
3715 drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
3716
3717 /* Make sure any trailing partial block is accounted for. */
3718 if ((blockCount * fmt.blockAlign) < dataChunkSize) {
3719 blockCount += 1;
3720 }
3721
3722 /* We decode two samples per byte. There will be blockCount headers in the data chunk. This is enough to know how to calculate the total PCM frame count. */
3723 totalBlockHeaderSizeInBytes = blockCount * (4*fmt.channels);
3724 pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
3725
3726 /* The header includes a decoded sample for each channel which acts as the initial predictor sample. */
3727 pWav->totalPCMFrameCount += blockCount;
3728 }
3729 }
3730
3731 /* Some formats only support a certain number of channels. */
3732 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
3733 if (pWav->channels > 2) {
3734 drwav_free(pWav->pMetadata, &pWav->allocationCallbacks);
3735 return DRWAV_FALSE;
3736 }
3737 }
3738
3739 /* The number of bytes per frame must be known. If not, it's an invalid file and not decodable. */
3740 if (drwav_get_bytes_per_pcm_frame(pWav) == 0) {
3741 drwav_free(pWav->pMetadata, &pWav->allocationCallbacks);
3742 return DRWAV_FALSE;
3743 }
3744
3745#ifdef DR_WAV_LIBSNDFILE_COMPAT
3746 /*
3747 I use libsndfile as a benchmark for testing, however in the version I'm using (from the Windows installer on the libsndfile website),
3748 it appears the total sample count libsndfile uses for MS-ADPCM is incorrect. It would seem they are computing the total sample count
3749 from the number of blocks, however this results in the inclusion of extra silent samples at the end of the last block. The correct
3750 way to know the total sample count is to inspect the "fact" chunk, which should always be present for compressed formats, and should
3751 always include the sample count. This little block of code below is only used to emulate the libsndfile logic so I can properly run my
3752 correctness tests against libsndfile, and is disabled by default.
3753 */
3754 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
3755 drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
3756 pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (6*pWav->channels))) * 2)) / fmt.channels; /* x2 because two samples per byte. */
3757 }
3758 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
3759 drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
3760 pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (4*pWav->channels))) * 2) + (blockCount * pWav->channels)) / fmt.channels;
3761 }
3762#endif
3763
3764 return DRWAV_TRUE;
3765}
3766
3767DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
3768{
3769 return drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0, pAllocationCallbacks);
3770}
3771
3772DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
3773{
3774 if (!drwav_preinit(pWav, onRead, onSeek, pReadSeekUserData, pAllocationCallbacks)) {
3775 return DRWAV_FALSE;
3776 }
3777
3778 return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
3779}
3780
3781DRWAV_API drwav_bool32 drwav_init_with_metadata(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
3782{
3783 if (!drwav_preinit(pWav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
3784 return DRWAV_FALSE;
3785 }
3786
3787 return drwav_init__internal(pWav, NULL, NULL, flags | DRWAV_WITH_METADATA);
3788}
3789
3790DRWAV_API drwav_metadata* drwav_take_ownership_of_metadata(drwav* pWav)
3791{
3792 drwav_metadata *result = pWav->pMetadata;
3793
3794 pWav->pMetadata = NULL;
3795 pWav->metadataCount = 0;
3796
3797 return result;
3798}
3799
3800
3801DRWAV_PRIVATE size_t drwav__write(drwav* pWav, const void* pData, size_t dataSize)
3802{
3803 DRWAV_ASSERT(pWav != NULL);
3804 DRWAV_ASSERT(pWav->onWrite != NULL);
3805
3806 /* Generic write. Assumes no byte reordering required. */
3807 return pWav->onWrite(pWav->pUserData, pData, dataSize);
3808}
3809
3810DRWAV_PRIVATE size_t drwav__write_byte(drwav* pWav, drwav_uint8 byte)
3811{
3812 DRWAV_ASSERT(pWav != NULL);
3813 DRWAV_ASSERT(pWav->onWrite != NULL);
3814
3815 return pWav->onWrite(pWav->pUserData, &byte, 1);
3816}
3817
3818DRWAV_PRIVATE size_t drwav__write_u16ne_to_le(drwav* pWav, drwav_uint16 value)
3819{
3820 DRWAV_ASSERT(pWav != NULL);
3821 DRWAV_ASSERT(pWav->onWrite != NULL);
3822
3823 if (!drwav__is_little_endian()) {
3824 value = drwav__bswap16(value);
3825 }
3826
3827 return drwav__write(pWav, &value, 2);
3828}
3829
3830DRWAV_PRIVATE size_t drwav__write_u32ne_to_le(drwav* pWav, drwav_uint32 value)
3831{
3832 DRWAV_ASSERT(pWav != NULL);
3833 DRWAV_ASSERT(pWav->onWrite != NULL);
3834
3835 if (!drwav__is_little_endian()) {
3836 value = drwav__bswap32(value);
3837 }
3838
3839 return drwav__write(pWav, &value, 4);
3840}
3841
3842DRWAV_PRIVATE size_t drwav__write_u64ne_to_le(drwav* pWav, drwav_uint64 value)
3843{
3844 DRWAV_ASSERT(pWav != NULL);
3845 DRWAV_ASSERT(pWav->onWrite != NULL);
3846
3847 if (!drwav__is_little_endian()) {
3848 value = drwav__bswap64(value);
3849 }
3850
3851 return drwav__write(pWav, &value, 8);
3852}
3853
3854DRWAV_PRIVATE size_t drwav__write_f32ne_to_le(drwav* pWav, float value)
3855{
3856 union {
3857 drwav_uint32 u32;
3858 float f32;
3859 } u;
3860
3861 DRWAV_ASSERT(pWav != NULL);
3862 DRWAV_ASSERT(pWav->onWrite != NULL);
3863
3864 u.f32 = value;
3865
3866 if (!drwav__is_little_endian()) {
3867 u.u32 = drwav__bswap32(u.u32);
3868 }
3869
3870 return drwav__write(pWav, &u.u32, 4);
3871}
3872
3873DRWAV_PRIVATE size_t drwav__write_or_count(drwav* pWav, const void* pData, size_t dataSize)
3874{
3875 if (pWav == NULL) {
3876 return dataSize;
3877 }
3878
3879 return drwav__write(pWav, pData, dataSize);
3880}
3881
3882DRWAV_PRIVATE size_t drwav__write_or_count_byte(drwav* pWav, drwav_uint8 byte)
3883{
3884 if (pWav == NULL) {
3885 return 1;
3886 }
3887
3888 return drwav__write_byte(pWav, byte);
3889}
3890
3891DRWAV_PRIVATE size_t drwav__write_or_count_u16ne_to_le(drwav* pWav, drwav_uint16 value)
3892{
3893 if (pWav == NULL) {
3894 return 2;
3895 }
3896
3897 return drwav__write_u16ne_to_le(pWav, value);
3898}
3899
3900DRWAV_PRIVATE size_t drwav__write_or_count_u32ne_to_le(drwav* pWav, drwav_uint32 value)
3901{
3902 if (pWav == NULL) {
3903 return 4;
3904 }
3905
3906 return drwav__write_u32ne_to_le(pWav, value);
3907}
3908
3909#if 0 /* Unused for now. */
3910DRWAV_PRIVATE size_t drwav__write_or_count_u64ne_to_le(drwav* pWav, drwav_uint64 value)
3911{
3912 if (pWav == NULL) {
3913 return 8;
3914 }
3915
3916 return drwav__write_u64ne_to_le(pWav, value);
3917}
3918#endif
3919
3920DRWAV_PRIVATE size_t drwav__write_or_count_f32ne_to_le(drwav* pWav, float value)
3921{
3922 if (pWav == NULL) {
3923 return 4;
3924 }
3925
3926 return drwav__write_f32ne_to_le(pWav, value);
3927}
3928
3929DRWAV_PRIVATE size_t drwav__write_or_count_string_to_fixed_size_buf(drwav* pWav, char* str, size_t bufFixedSize)
3930{
3931 size_t len;
3932
3933 if (pWav == NULL) {
3934 return bufFixedSize;
3935 }
3936
3937 len = drwav__strlen_clamped(str, bufFixedSize);
3938 drwav__write_or_count(pWav, str, len);
3939
3940 if (len < bufFixedSize) {
3941 size_t i;
3942 for (i = 0; i < bufFixedSize - len; ++i) {
3943 drwav__write_byte(pWav, 0);
3944 }
3945 }
3946
3947 return bufFixedSize;
3948}
3949
3950
3951/* pWav can be NULL meaning just count the bytes that would be written. */
3952DRWAV_PRIVATE size_t drwav__write_or_count_metadata(drwav* pWav, drwav_metadata* pMetadatas, drwav_uint32 metadataCount)
3953{
3954 size_t bytesWritten = 0;
3955 drwav_bool32 hasListAdtl = DRWAV_FALSE;
3956 drwav_bool32 hasListInfo = DRWAV_FALSE;
3957 drwav_uint32 iMetadata;
3958
3959 if (pMetadatas == NULL || metadataCount == 0) {
3960 return 0;
3961 }
3962
3963 for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) {
3964 drwav_metadata* pMetadata = &pMetadatas[iMetadata];
3965 drwav_uint32 chunkSize = 0;
3966
3967 if ((pMetadata->type & drwav_metadata_type_list_all_info_strings) || (pMetadata->type == drwav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == drwav_metadata_location_inside_info_list)) {
3968 hasListInfo = DRWAV_TRUE;
3969 }
3970
3971 if ((pMetadata->type & drwav_metadata_type_list_all_adtl) || (pMetadata->type == drwav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == drwav_metadata_location_inside_adtl_list)) {
3972 hasListAdtl = DRWAV_TRUE;
3973 }
3974
3975 switch (pMetadata->type) {
3976 case drwav_metadata_type_smpl:
3977 {
3978 drwav_uint32 iLoop;
3979
3980 chunkSize = DRWAV_SMPL_BYTES + DRWAV_SMPL_LOOP_BYTES * pMetadata->data.smpl.sampleLoopCount + pMetadata->data.smpl.samplerSpecificDataSizeInBytes;
3981
3982 bytesWritten += drwav__write_or_count(pWav, "smpl", 4);
3983 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
3984
3985 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.manufacturerId);
3986 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.productId);
3987 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.samplePeriodNanoseconds);
3988 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.midiUnityNote);
3989 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.midiPitchFraction);
3990 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.smpteFormat);
3991 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.smpteOffset);
3992 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.sampleLoopCount);
3993 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.samplerSpecificDataSizeInBytes);
3994
3995 for (iLoop = 0; iLoop < pMetadata->data.smpl.sampleLoopCount; ++iLoop) {
3996 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].cuePointId);
3997 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].type);
3998 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].firstSampleByteOffset);
3999 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].lastSampleByteOffset);
4000 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].sampleFraction);
4001 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].playCount);
4002 }
4003
4004 if (pMetadata->data.smpl.samplerSpecificDataSizeInBytes > 0) {
4005 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.smpl.pSamplerSpecificData, pMetadata->data.smpl.samplerSpecificDataSizeInBytes);
4006 }
4007 } break;
4008
4009 case drwav_metadata_type_inst:
4010 {
4011 chunkSize = DRWAV_INST_BYTES;
4012
4013 bytesWritten += drwav__write_or_count(pWav, "inst", 4);
4014 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
4015 bytesWritten += drwav__write_or_count(pWav, &pMetadata->data.inst.midiUnityNote, 1);
4016 bytesWritten += drwav__write_or_count(pWav, &pMetadata->data.inst.fineTuneCents, 1);
4017 bytesWritten += drwav__write_or_count(pWav, &pMetadata->data.inst.gainDecibels, 1);
4018 bytesWritten += drwav__write_or_count(pWav, &pMetadata->data.inst.lowNote, 1);
4019 bytesWritten += drwav__write_or_count(pWav, &pMetadata->data.inst.highNote, 1);
4020 bytesWritten += drwav__write_or_count(pWav, &pMetadata->data.inst.lowVelocity, 1);
4021 bytesWritten += drwav__write_or_count(pWav, &pMetadata->data.inst.highVelocity, 1);
4022 } break;
4023
4024 case drwav_metadata_type_cue:
4025 {
4026 drwav_uint32 iCuePoint;
4027
4028 chunkSize = DRWAV_CUE_BYTES + DRWAV_CUE_POINT_BYTES * pMetadata->data.cue.cuePointCount;
4029
4030 bytesWritten += drwav__write_or_count(pWav, "cue ", 4);
4031 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
4032 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.cuePointCount);
4033 for (iCuePoint = 0; iCuePoint < pMetadata->data.cue.cuePointCount; ++iCuePoint) {
4034 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].id);
4035 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].playOrderPosition);
4036 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId, 4);
4037 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].chunkStart);
4038 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].blockStart);
4039 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].sampleByteOffset);
4040 }
4041 } break;
4042
4043 case drwav_metadata_type_acid:
4044 {
4045 chunkSize = DRWAV_ACID_BYTES;
4046
4047 bytesWritten += drwav__write_or_count(pWav, "acid", 4);
4048 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
4049 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.acid.flags);
4050 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.midiUnityNote);
4051 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.reserved1);
4052 bytesWritten += drwav__write_or_count_f32ne_to_le(pWav, pMetadata->data.acid.reserved2);
4053 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.acid.numBeats);
4054 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.meterDenominator);
4055 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.meterNumerator);
4056 bytesWritten += drwav__write_or_count_f32ne_to_le(pWav, pMetadata->data.acid.tempo);
4057 } break;
4058
4059 case drwav_metadata_type_bext:
4060 {
4061 char reservedBuf[DRWAV_BEXT_RESERVED_BYTES];
4062 drwav_uint32 timeReferenceLow;
4063 drwav_uint32 timeReferenceHigh;
4064
4065 chunkSize = DRWAV_BEXT_BYTES + pMetadata->data.bext.codingHistorySize;
4066
4067 bytesWritten += drwav__write_or_count(pWav, "bext", 4);
4068 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
4069
4070 bytesWritten += drwav__write_or_count_string_to_fixed_size_buf(pWav, pMetadata->data.bext.pDescription, DRWAV_BEXT_DESCRIPTION_BYTES);
4071 bytesWritten += drwav__write_or_count_string_to_fixed_size_buf(pWav, pMetadata->data.bext.pOriginatorName, DRWAV_BEXT_ORIGINATOR_NAME_BYTES);
4072 bytesWritten += drwav__write_or_count_string_to_fixed_size_buf(pWav, pMetadata->data.bext.pOriginatorReference, DRWAV_BEXT_ORIGINATOR_REF_BYTES);
4073 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.bext.pOriginationDate, sizeof(pMetadata->data.bext.pOriginationDate));
4074 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.bext.pOriginationTime, sizeof(pMetadata->data.bext.pOriginationTime));
4075
4076 timeReferenceLow = (drwav_uint32)(pMetadata->data.bext.timeReference & 0xFFFFFFFF);
4077 timeReferenceHigh = (drwav_uint32)(pMetadata->data.bext.timeReference >> 32);
4078 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, timeReferenceLow);
4079 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, timeReferenceHigh);
4080
4081 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.version);
4082 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.bext.pUMID, DRWAV_BEXT_UMID_BYTES);
4083 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.loudnessValue);
4084 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.loudnessRange);
4085 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxTruePeakLevel);
4086 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxMomentaryLoudness);
4087 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxShortTermLoudness);
4088
4089 DRWAV_ZERO_MEMORY(reservedBuf, sizeof(reservedBuf));
4090 bytesWritten += drwav__write_or_count(pWav, reservedBuf, sizeof(reservedBuf));
4091
4092 if (pMetadata->data.bext.codingHistorySize > 0) {
4093 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.bext.pCodingHistory, pMetadata->data.bext.codingHistorySize);
4094 }
4095 } break;
4096
4097 case drwav_metadata_type_unknown:
4098 {
4099 if (pMetadata->data.unknown.chunkLocation == drwav_metadata_location_top_level) {
4100 chunkSize = pMetadata->data.unknown.dataSizeInBytes;
4101
4102 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.unknown.id, 4);
4103 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
4104 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.unknown.pData, pMetadata->data.unknown.dataSizeInBytes);
4105 }
4106 } break;
4107
4108 default: break;
4109 }
4110 if ((chunkSize % 2) != 0) {
4111 bytesWritten += drwav__write_or_count_byte(pWav, 0);
4112 }
4113 }
4114
4115 if (hasListInfo) {
4116 drwav_uint32 chunkSize = 4; /* Start with 4 bytes for "INFO". */
4117 for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) {
4118 drwav_metadata* pMetadata = &pMetadatas[iMetadata];
4119
4120 if ((pMetadata->type & drwav_metadata_type_list_all_info_strings)) {
4121 chunkSize += 8; /* For id and string size. */
4122 chunkSize += pMetadata->data.infoText.stringLength + 1; /* Include null terminator. */
4123 } else if (pMetadata->type == drwav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == drwav_metadata_location_inside_info_list) {
4124 chunkSize += 8; /* For id string size. */
4125 chunkSize += pMetadata->data.unknown.dataSizeInBytes;
4126 }
4127
4128 if ((chunkSize % 2) != 0) {
4129 chunkSize += 1;
4130 }
4131 }
4132
4133 bytesWritten += drwav__write_or_count(pWav, "LIST", 4);
4134 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
4135 bytesWritten += drwav__write_or_count(pWav, "INFO", 4);
4136
4137 for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) {
4138 drwav_metadata* pMetadata = &pMetadatas[iMetadata];
4139 drwav_uint32 subchunkSize = 0;
4140
4141 if (pMetadata->type & drwav_metadata_type_list_all_info_strings) {
4142 const char* pID = NULL;
4143
4144 switch (pMetadata->type) {
4145 case drwav_metadata_type_list_info_software: pID = "ISFT"; break;
4146 case drwav_metadata_type_list_info_copyright: pID = "ICOP"; break;
4147 case drwav_metadata_type_list_info_title: pID = "INAM"; break;
4148 case drwav_metadata_type_list_info_artist: pID = "IART"; break;
4149 case drwav_metadata_type_list_info_comment: pID = "ICMT"; break;
4150 case drwav_metadata_type_list_info_date: pID = "ICRD"; break;
4151 case drwav_metadata_type_list_info_genre: pID = "IGNR"; break;
4152 case drwav_metadata_type_list_info_album: pID = "IPRD"; break;
4153 case drwav_metadata_type_list_info_tracknumber: pID = "ITRK"; break;
4154 default: break;
4155 }
4156
4157 DRWAV_ASSERT(pID != NULL);
4158
4159 if (pMetadata->data.infoText.stringLength) {
4160 subchunkSize = pMetadata->data.infoText.stringLength + 1;
4161 bytesWritten += drwav__write_or_count(pWav, pID, 4);
4162 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, subchunkSize);
4163 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.infoText.pString, pMetadata->data.infoText.stringLength);
4164 bytesWritten += drwav__write_or_count_byte(pWav, '\0');
4165 }
4166 } else if (pMetadata->type == drwav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == drwav_metadata_location_inside_info_list) {
4167 if (pMetadata->data.unknown.dataSizeInBytes) {
4168 subchunkSize = pMetadata->data.unknown.dataSizeInBytes;
4169
4170 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.unknown.id, 4);
4171 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.unknown.dataSizeInBytes);
4172 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.unknown.pData, subchunkSize);
4173 }
4174 }
4175
4176 if ((subchunkSize % 2) != 0) {
4177 bytesWritten += drwav__write_or_count_byte(pWav, 0);
4178 }
4179 }
4180 }
4181
4182 if (hasListAdtl) {
4183 drwav_uint32 chunkSize = 4; /* start with 4 bytes for "adtl" */
4184
4185 for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) {
4186 drwav_metadata* pMetadata = &pMetadatas[iMetadata];
4187
4188 switch (pMetadata->type)
4189 {
4190 case drwav_metadata_type_list_label:
4191 case drwav_metadata_type_list_note:
4192 {
4193 chunkSize += 8; /* for id and chunk size */
4194 chunkSize += DRWAV_LIST_LABEL_OR_NOTE_BYTES;
4195
4196 if (pMetadata->data.labelOrNote.stringLength > 0) {
4197 chunkSize += pMetadata->data.labelOrNote.stringLength + 1;
4198 }
4199 } break;
4200
4201 case drwav_metadata_type_list_labelled_cue_region:
4202 {
4203 chunkSize += 8; /* for id and chunk size */
4204 chunkSize += DRWAV_LIST_LABELLED_TEXT_BYTES;
4205
4206 if (pMetadata->data.labelledCueRegion.stringLength > 0) {
4207 chunkSize += pMetadata->data.labelledCueRegion.stringLength + 1;
4208 }
4209 } break;
4210
4211 case drwav_metadata_type_unknown:
4212 {
4213 if (pMetadata->data.unknown.chunkLocation == drwav_metadata_location_inside_adtl_list) {
4214 chunkSize += 8; /* for id and chunk size */
4215 chunkSize += pMetadata->data.unknown.dataSizeInBytes;
4216 }
4217 } break;
4218
4219 default: break;
4220 }
4221
4222 if ((chunkSize % 2) != 0) {
4223 chunkSize += 1;
4224 }
4225 }
4226
4227 bytesWritten += drwav__write_or_count(pWav, "LIST", 4);
4228 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, chunkSize);
4229 bytesWritten += drwav__write_or_count(pWav, "adtl", 4);
4230
4231 for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) {
4232 drwav_metadata* pMetadata = &pMetadatas[iMetadata];
4233 drwav_uint32 subchunkSize = 0;
4234
4235 switch (pMetadata->type)
4236 {
4237 case drwav_metadata_type_list_label:
4238 case drwav_metadata_type_list_note:
4239 {
4240 if (pMetadata->data.labelOrNote.stringLength > 0) {
4241 const char *pID = NULL;
4242
4243 if (pMetadata->type == drwav_metadata_type_list_label) {
4244 pID = "labl";
4245 }
4246 else if (pMetadata->type == drwav_metadata_type_list_note) {
4247 pID = "note";
4248 }
4249
4250 DRWAV_ASSERT(pID != NULL);
4251 DRWAV_ASSERT(pMetadata->data.labelOrNote.pString != NULL);
4252
4253 subchunkSize = DRWAV_LIST_LABEL_OR_NOTE_BYTES;
4254
4255 bytesWritten += drwav__write_or_count(pWav, pID, 4);
4256 subchunkSize += pMetadata->data.labelOrNote.stringLength + 1;
4257 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, subchunkSize);
4258
4259 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.labelOrNote.cuePointId);
4260 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.labelOrNote.pString, pMetadata->data.labelOrNote.stringLength);
4261 bytesWritten += drwav__write_or_count_byte(pWav, '\0');
4262 }
4263 } break;
4264
4265 case drwav_metadata_type_list_labelled_cue_region:
4266 {
4267 subchunkSize = DRWAV_LIST_LABELLED_TEXT_BYTES;
4268
4269 bytesWritten += drwav__write_or_count(pWav, "ltxt", 4);
4270 if (pMetadata->data.labelledCueRegion.stringLength > 0) {
4271 subchunkSize += pMetadata->data.labelledCueRegion.stringLength + 1;
4272 }
4273 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, subchunkSize);
4274 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.labelledCueRegion.cuePointId);
4275 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.labelledCueRegion.sampleLength);
4276 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.labelledCueRegion.purposeId, 4);
4277 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.country);
4278 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.language);
4279 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.dialect);
4280 bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.codePage);
4281
4282 if (pMetadata->data.labelledCueRegion.stringLength > 0) {
4283 DRWAV_ASSERT(pMetadata->data.labelledCueRegion.pString != NULL);
4284
4285 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.labelledCueRegion.pString, pMetadata->data.labelledCueRegion.stringLength);
4286 bytesWritten += drwav__write_or_count_byte(pWav, '\0');
4287 }
4288 } break;
4289
4290 case drwav_metadata_type_unknown:
4291 {
4292 if (pMetadata->data.unknown.chunkLocation == drwav_metadata_location_inside_adtl_list) {
4293 subchunkSize = pMetadata->data.unknown.dataSizeInBytes;
4294
4295 DRWAV_ASSERT(pMetadata->data.unknown.pData != NULL);
4296 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.unknown.id, 4);
4297 bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, subchunkSize);
4298 bytesWritten += drwav__write_or_count(pWav, pMetadata->data.unknown.pData, subchunkSize);
4299 }
4300 } break;
4301
4302 default: break;
4303 }
4304
4305 if ((subchunkSize % 2) != 0) {
4306 bytesWritten += drwav__write_or_count_byte(pWav, 0);
4307 }
4308 }
4309 }
4310
4311 DRWAV_ASSERT((bytesWritten % 2) == 0);
4312
4313 return bytesWritten;
4314}
4315
4316DRWAV_PRIVATE drwav_uint32 drwav__riff_chunk_size_riff(drwav_uint64 dataChunkSize, drwav_metadata* pMetadata, drwav_uint32 metadataCount)
4317{
4318 drwav_uint64 chunkSize = 4 + 24 + (drwav_uint64)drwav__write_or_count_metadata(NULL, pMetadata, metadataCount) + 8 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize); /* 4 = "WAVE". 24 = "fmt " chunk. 8 = "data" + u32 data size. */
4319 if (chunkSize > 0xFFFFFFFFUL) {
4320 chunkSize = 0xFFFFFFFFUL;
4321 }
4322
4323 return (drwav_uint32)chunkSize; /* Safe cast due to the clamp above. */
4324}
4325
4326DRWAV_PRIVATE drwav_uint32 drwav__data_chunk_size_riff(drwav_uint64 dataChunkSize)
4327{
4328 if (dataChunkSize <= 0xFFFFFFFFUL) {
4329 return (drwav_uint32)dataChunkSize;
4330 } else {
4331 return 0xFFFFFFFFUL;
4332 }
4333}
4334
4335DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_w64(drwav_uint64 dataChunkSize)
4336{
4337 drwav_uint64 dataSubchunkPaddingSize = drwav__chunk_padding_size_w64(dataChunkSize);
4338
4339 return 80 + 24 + dataChunkSize + dataSubchunkPaddingSize; /* +24 because W64 includes the size of the GUID and size fields. */
4340}
4341
4342DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_w64(drwav_uint64 dataChunkSize)
4343{
4344 return 24 + dataChunkSize; /* +24 because W64 includes the size of the GUID and size fields. */
4345}
4346
4347DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_rf64(drwav_uint64 dataChunkSize, drwav_metadata *metadata, drwav_uint32 numMetadata)
4348{
4349 drwav_uint64 chunkSize = 4 + 36 + 24 + (drwav_uint64)drwav__write_or_count_metadata(NULL, metadata, numMetadata) + 8 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize); /* 4 = "WAVE". 36 = "ds64" chunk. 24 = "fmt " chunk. 8 = "data" + u32 data size. */
4350 if (chunkSize > 0xFFFFFFFFUL) {
4351 chunkSize = 0xFFFFFFFFUL;
4352 }
4353
4354 return chunkSize;
4355}
4356
4357DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_rf64(drwav_uint64 dataChunkSize)
4358{
4359 return dataChunkSize;
4360}
4361
4362
4363
4364DRWAV_PRIVATE drwav_bool32 drwav_preinit_write(drwav* pWav, const drwav_data_format* pFormat, drwav_bool32 isSequential, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
4365{
4366 if (pWav == NULL || onWrite == NULL) {
4367 return DRWAV_FALSE;
4368 }
4369
4370 if (!isSequential && onSeek == NULL) {
4371 return DRWAV_FALSE; /* <-- onSeek is required when in non-sequential mode. */
4372 }
4373
4374 /* Not currently supporting compressed formats. Will need to add support for the "fact" chunk before we enable this. */
4375 if (pFormat->format == DR_WAVE_FORMAT_EXTENSIBLE) {
4376 return DRWAV_FALSE;
4377 }
4378 if (pFormat->format == DR_WAVE_FORMAT_ADPCM || pFormat->format == DR_WAVE_FORMAT_DVI_ADPCM) {
4379 return DRWAV_FALSE;
4380 }
4381
4382 DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
4383 pWav->onWrite = onWrite;
4384 pWav->onSeek = onSeek;
4385 pWav->pUserData = pUserData;
4386 pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
4387
4388 if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
4389 return DRWAV_FALSE; /* Invalid allocation callbacks. */
4390 }
4391
4392 pWav->fmt.formatTag = (drwav_uint16)pFormat->format;
4393 pWav->fmt.channels = (drwav_uint16)pFormat->channels;
4394 pWav->fmt.sampleRate = pFormat->sampleRate;
4395 pWav->fmt.avgBytesPerSec = (drwav_uint32)((pFormat->bitsPerSample * pFormat->sampleRate * pFormat->channels) / 8);
4396 pWav->fmt.blockAlign = (drwav_uint16)((pFormat->channels * pFormat->bitsPerSample) / 8);
4397 pWav->fmt.bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
4398 pWav->fmt.extendedSize = 0;
4399 pWav->isSequentialWrite = isSequential;
4400
4401 return DRWAV_TRUE;
4402}
4403
4404
4405DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
4406{
4407 /* The function assumes drwav_preinit_write() was called beforehand. */
4408
4409 size_t runningPos = 0;
4410 drwav_uint64 initialDataChunkSize = 0;
4411 drwav_uint64 chunkSizeFMT;
4412
4413 /*
4414 The initial values for the "RIFF" and "data" chunks depends on whether or not we are initializing in sequential mode or not. In
4415 sequential mode we set this to its final values straight away since they can be calculated from the total sample count. In non-
4416 sequential mode we initialize it all to zero and fill it out in drwav_uninit() using a backwards seek.
4417 */
4418 if (pWav->isSequentialWrite) {
4419 initialDataChunkSize = (totalSampleCount * pWav->fmt.bitsPerSample) / 8;
4420
4421 /*
4422 The RIFF container has a limit on the number of samples. drwav is not allowing this. There's no practical limits for Wave64
4423 so for the sake of simplicity I'm not doing any validation for that.
4424 */
4425 if (pFormat->container == drwav_container_riff) {
4426 if (initialDataChunkSize > (0xFFFFFFFFUL - 36)) {
4427 return DRWAV_FALSE; /* Not enough room to store every sample. */
4428 }
4429 }
4430 }
4431
4432 pWav->dataChunkDataSizeTargetWrite = initialDataChunkSize;
4433
4434
4435 /* "RIFF" chunk. */
4436 if (pFormat->container == drwav_container_riff) {
4437 drwav_uint32 chunkSizeRIFF = 28 + (drwav_uint32)initialDataChunkSize; /* +28 = "WAVE" + [sizeof "fmt " chunk] */
4438 runningPos += drwav__write(pWav, "RIFF", 4);
4439 runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeRIFF);
4440 runningPos += drwav__write(pWav, "WAVE", 4);
4441 } else if (pFormat->container == drwav_container_w64) {
4442 drwav_uint64 chunkSizeRIFF = 80 + 24 + initialDataChunkSize; /* +24 because W64 includes the size of the GUID and size fields. */
4443 runningPos += drwav__write(pWav, drwavGUID_W64_RIFF, 16);
4444 runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeRIFF);
4445 runningPos += drwav__write(pWav, drwavGUID_W64_WAVE, 16);
4446 } else if (pFormat->container == drwav_container_rf64) {
4447 runningPos += drwav__write(pWav, "RF64", 4);
4448 runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF); /* Always 0xFFFFFFFF for RF64. Set to a proper value in the "ds64" chunk. */
4449 runningPos += drwav__write(pWav, "WAVE", 4);
4450 } else {
4451 return DRWAV_FALSE; /* Container not supported for writing. */
4452 }
4453
4454
4455 /* "ds64" chunk (RF64 only). */
4456 if (pFormat->container == drwav_container_rf64) {
4457 drwav_uint32 initialds64ChunkSize = 28; /* 28 = [Size of RIFF (8 bytes)] + [Size of DATA (8 bytes)] + [Sample Count (8 bytes)] + [Table Length (4 bytes)]. Table length always set to 0. */
4458 drwav_uint64 initialRiffChunkSize = 8 + initialds64ChunkSize + initialDataChunkSize; /* +8 for the ds64 header. */
4459
4460 runningPos += drwav__write(pWav, "ds64", 4);
4461 runningPos += drwav__write_u32ne_to_le(pWav, initialds64ChunkSize); /* Size of ds64. */
4462 runningPos += drwav__write_u64ne_to_le(pWav, initialRiffChunkSize); /* Size of RIFF. Set to true value at the end. */
4463 runningPos += drwav__write_u64ne_to_le(pWav, initialDataChunkSize); /* Size of DATA. Set to true value at the end. */
4464 runningPos += drwav__write_u64ne_to_le(pWav, totalSampleCount); /* Sample count. */
4465 runningPos += drwav__write_u32ne_to_le(pWav, 0); /* Table length. Always set to zero in our case since we're not doing any other chunks than "DATA". */
4466 }
4467
4468
4469 /* "fmt " chunk. */
4470 if (pFormat->container == drwav_container_riff || pFormat->container == drwav_container_rf64) {
4471 chunkSizeFMT = 16;
4472 runningPos += drwav__write(pWav, "fmt ", 4);
4473 runningPos += drwav__write_u32ne_to_le(pWav, (drwav_uint32)chunkSizeFMT);
4474 } else if (pFormat->container == drwav_container_w64) {
4475 chunkSizeFMT = 40;
4476 runningPos += drwav__write(pWav, drwavGUID_W64_FMT, 16);
4477 runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeFMT);
4478 }
4479
4480 runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.formatTag);
4481 runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.channels);
4482 runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.sampleRate);
4483 runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.avgBytesPerSec);
4484 runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign);
4485 runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample);
4486
4487 /* TODO: is a 'fact' chunk required for DR_WAVE_FORMAT_IEEE_FLOAT? */
4488
4489 if (!pWav->isSequentialWrite && pWav->pMetadata != NULL && pWav->metadataCount > 0 && (pFormat->container == drwav_container_riff || pFormat->container == drwav_container_rf64)) {
4490 runningPos += drwav__write_or_count_metadata(pWav, pWav->pMetadata, pWav->metadataCount);
4491 }
4492
4493 pWav->dataChunkDataPos = runningPos;
4494
4495 /* "data" chunk. */
4496 if (pFormat->container == drwav_container_riff) {
4497 drwav_uint32 chunkSizeDATA = (drwav_uint32)initialDataChunkSize;
4498 runningPos += drwav__write(pWav, "data", 4);
4499 runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeDATA);
4500 } else if (pFormat->container == drwav_container_w64) {
4501 drwav_uint64 chunkSizeDATA = 24 + initialDataChunkSize; /* +24 because W64 includes the size of the GUID and size fields. */
4502 runningPos += drwav__write(pWav, drwavGUID_W64_DATA, 16);
4503 runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeDATA);
4504 } else if (pFormat->container == drwav_container_rf64) {
4505 runningPos += drwav__write(pWav, "data", 4);
4506 runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF); /* Always set to 0xFFFFFFFF for RF64. The true size of the data chunk is specified in the ds64 chunk. */
4507 }
4508
4509 /* Set some properties for the client's convenience. */
4510 pWav->container = pFormat->container;
4511 pWav->channels = (drwav_uint16)pFormat->channels;
4512 pWav->sampleRate = pFormat->sampleRate;
4513 pWav->bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
4514 pWav->translatedFormatTag = (drwav_uint16)pFormat->format;
4515 pWav->dataChunkDataPos = runningPos;
4516
4517 return DRWAV_TRUE;
4518}
4519
4520
4521DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
4522{
4523 if (!drwav_preinit_write(pWav, pFormat, DRWAV_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) {
4524 return DRWAV_FALSE;
4525 }
4526
4527 return drwav_init_write__internal(pWav, pFormat, 0); /* DRWAV_FALSE = Not Sequential */
4528}
4529
4530DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
4531{
4532 if (!drwav_preinit_write(pWav, pFormat, DRWAV_TRUE, onWrite, NULL, pUserData, pAllocationCallbacks)) {
4533 return DRWAV_FALSE;
4534 }
4535
4536 return drwav_init_write__internal(pWav, pFormat, totalSampleCount); /* DRWAV_TRUE = Sequential */
4537}
4538
4539DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
4540{
4541 if (pFormat == NULL) {
4542 return DRWAV_FALSE;
4543 }
4544
4545 return drwav_init_write_sequential(pWav, pFormat, totalPCMFrameCount*pFormat->channels, onWrite, pUserData, pAllocationCallbacks);
4546}
4547
4548DRWAV_API drwav_bool32 drwav_init_write_with_metadata(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks, drwav_metadata* pMetadata, drwav_uint32 metadataCount)
4549{
4550 if (!drwav_preinit_write(pWav, pFormat, DRWAV_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) {
4551 return DRWAV_FALSE;
4552 }
4553
4554 pWav->pMetadata = pMetadata;
4555 pWav->metadataCount = metadataCount;
4556
4557 return drwav_init_write__internal(pWav, pFormat, 0);
4558}
4559
4560
4561DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalFrameCount, drwav_metadata* pMetadata, drwav_uint32 metadataCount)
4562{
4563 /* Casting totalFrameCount to drwav_int64 for VC6 compatibility. No issues in practice because nobody is going to exhaust the whole 63 bits. */
4564 drwav_uint64 targetDataSizeBytes = (drwav_uint64)((drwav_int64)totalFrameCount * pFormat->channels * pFormat->bitsPerSample/8.0);
4565 drwav_uint64 riffChunkSizeBytes;
4566 drwav_uint64 fileSizeBytes = 0;
4567
4568 if (pFormat->container == drwav_container_riff) {
4569 riffChunkSizeBytes = drwav__riff_chunk_size_riff(targetDataSizeBytes, pMetadata, metadataCount);
4570 fileSizeBytes = (8 + riffChunkSizeBytes); /* +8 because WAV doesn't include the size of the ChunkID and ChunkSize fields. */
4571 } else if (pFormat->container == drwav_container_w64) {
4572 riffChunkSizeBytes = drwav__riff_chunk_size_w64(targetDataSizeBytes);
4573 fileSizeBytes = riffChunkSizeBytes;
4574 } else if (pFormat->container == drwav_container_rf64) {
4575 riffChunkSizeBytes = drwav__riff_chunk_size_rf64(targetDataSizeBytes, pMetadata, metadataCount);
4576 fileSizeBytes = (8 + riffChunkSizeBytes); /* +8 because WAV doesn't include the size of the ChunkID and ChunkSize fields. */
4577 }
4578
4579 return fileSizeBytes;
4580}
4581
4582
4583#ifndef DR_WAV_NO_STDIO
4584
4585/* Errno */
4586/* drwav_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
4587#include <errno.h>
4588DRWAV_PRIVATE drwav_result drwav_result_from_errno(int e)
4589{
4590 switch (e)
4591 {
4592 case 0: return DRWAV_SUCCESS;
4593 #ifdef EPERM
4594 case EPERM: return DRWAV_INVALID_OPERATION;
4595 #endif
4596 #ifdef ENOENT
4597 case ENOENT: return DRWAV_DOES_NOT_EXIST;
4598 #endif
4599 #ifdef ESRCH
4600 case ESRCH: return DRWAV_DOES_NOT_EXIST;
4601 #endif
4602 #ifdef EINTR
4603 case EINTR: return DRWAV_INTERRUPT;
4604 #endif
4605 #ifdef EIO
4606 case EIO: return DRWAV_IO_ERROR;
4607 #endif
4608 #ifdef ENXIO
4609 case ENXIO: return DRWAV_DOES_NOT_EXIST;
4610 #endif
4611 #ifdef E2BIG
4612 case E2BIG: return DRWAV_INVALID_ARGS;
4613 #endif
4614 #ifdef ENOEXEC
4615 case ENOEXEC: return DRWAV_INVALID_FILE;
4616 #endif
4617 #ifdef EBADF
4618 case EBADF: return DRWAV_INVALID_FILE;
4619 #endif
4620 #ifdef ECHILD
4621 case ECHILD: return DRWAV_ERROR;
4622 #endif
4623 #ifdef EAGAIN
4624 case EAGAIN: return DRWAV_UNAVAILABLE;
4625 #endif
4626 #ifdef ENOMEM
4627 case ENOMEM: return DRWAV_OUT_OF_MEMORY;
4628 #endif
4629 #ifdef EACCES
4630 case EACCES: return DRWAV_ACCESS_DENIED;
4631 #endif
4632 #ifdef EFAULT
4633 case EFAULT: return DRWAV_BAD_ADDRESS;
4634 #endif
4635 #ifdef ENOTBLK
4636 case ENOTBLK: return DRWAV_ERROR;
4637 #endif
4638 #ifdef EBUSY
4639 case EBUSY: return DRWAV_BUSY;
4640 #endif
4641 #ifdef EEXIST
4642 case EEXIST: return DRWAV_ALREADY_EXISTS;
4643 #endif
4644 #ifdef EXDEV
4645 case EXDEV: return DRWAV_ERROR;
4646 #endif
4647 #ifdef ENODEV
4648 case ENODEV: return DRWAV_DOES_NOT_EXIST;
4649 #endif
4650 #ifdef ENOTDIR
4651 case ENOTDIR: return DRWAV_NOT_DIRECTORY;
4652 #endif
4653 #ifdef EISDIR
4654 case EISDIR: return DRWAV_IS_DIRECTORY;
4655 #endif
4656 #ifdef EINVAL
4657 case EINVAL: return DRWAV_INVALID_ARGS;
4658 #endif
4659 #ifdef ENFILE
4660 case ENFILE: return DRWAV_TOO_MANY_OPEN_FILES;
4661 #endif
4662 #ifdef EMFILE
4663 case EMFILE: return DRWAV_TOO_MANY_OPEN_FILES;
4664 #endif
4665 #ifdef ENOTTY
4666 case ENOTTY: return DRWAV_INVALID_OPERATION;
4667 #endif
4668 #ifdef ETXTBSY
4669 case ETXTBSY: return DRWAV_BUSY;
4670 #endif
4671 #ifdef EFBIG
4672 case EFBIG: return DRWAV_TOO_BIG;
4673 #endif
4674 #ifdef ENOSPC
4675 case ENOSPC: return DRWAV_NO_SPACE;
4676 #endif
4677 #ifdef ESPIPE
4678 case ESPIPE: return DRWAV_BAD_SEEK;
4679 #endif
4680 #ifdef EROFS
4681 case EROFS: return DRWAV_ACCESS_DENIED;
4682 #endif
4683 #ifdef EMLINK
4684 case EMLINK: return DRWAV_TOO_MANY_LINKS;
4685 #endif
4686 #ifdef EPIPE
4687 case EPIPE: return DRWAV_BAD_PIPE;
4688 #endif
4689 #ifdef EDOM
4690 case EDOM: return DRWAV_OUT_OF_RANGE;
4691 #endif
4692 #ifdef ERANGE
4693 case ERANGE: return DRWAV_OUT_OF_RANGE;
4694 #endif
4695 #ifdef EDEADLK
4696 case EDEADLK: return DRWAV_DEADLOCK;
4697 #endif
4698 #ifdef ENAMETOOLONG
4699 case ENAMETOOLONG: return DRWAV_PATH_TOO_LONG;
4700 #endif
4701 #ifdef ENOLCK
4702 case ENOLCK: return DRWAV_ERROR;
4703 #endif
4704 #ifdef ENOSYS
4705 case ENOSYS: return DRWAV_NOT_IMPLEMENTED;
4706 #endif
4707 #ifdef ENOTEMPTY
4708 case ENOTEMPTY: return DRWAV_DIRECTORY_NOT_EMPTY;
4709 #endif
4710 #ifdef ELOOP
4711 case ELOOP: return DRWAV_TOO_MANY_LINKS;
4712 #endif
4713 #ifdef ENOMSG
4714 case ENOMSG: return DRWAV_NO_MESSAGE;
4715 #endif
4716 #ifdef EIDRM
4717 case EIDRM: return DRWAV_ERROR;
4718 #endif
4719 #ifdef ECHRNG
4720 case ECHRNG: return DRWAV_ERROR;
4721 #endif
4722 #ifdef EL2NSYNC
4723 case EL2NSYNC: return DRWAV_ERROR;
4724 #endif
4725 #ifdef EL3HLT
4726 case EL3HLT: return DRWAV_ERROR;
4727 #endif
4728 #ifdef EL3RST
4729 case EL3RST: return DRWAV_ERROR;
4730 #endif
4731 #ifdef ELNRNG
4732 case ELNRNG: return DRWAV_OUT_OF_RANGE;
4733 #endif
4734 #ifdef EUNATCH
4735 case EUNATCH: return DRWAV_ERROR;
4736 #endif
4737 #ifdef ENOCSI
4738 case ENOCSI: return DRWAV_ERROR;
4739 #endif
4740 #ifdef EL2HLT
4741 case EL2HLT: return DRWAV_ERROR;
4742 #endif
4743 #ifdef EBADE
4744 case EBADE: return DRWAV_ERROR;
4745 #endif
4746 #ifdef EBADR
4747 case EBADR: return DRWAV_ERROR;
4748 #endif
4749 #ifdef EXFULL
4750 case EXFULL: return DRWAV_ERROR;
4751 #endif
4752 #ifdef ENOANO
4753 case ENOANO: return DRWAV_ERROR;
4754 #endif
4755 #ifdef EBADRQC
4756 case EBADRQC: return DRWAV_ERROR;
4757 #endif
4758 #ifdef EBADSLT
4759 case EBADSLT: return DRWAV_ERROR;
4760 #endif
4761 #ifdef EBFONT
4762 case EBFONT: return DRWAV_INVALID_FILE;
4763 #endif
4764 #ifdef ENOSTR
4765 case ENOSTR: return DRWAV_ERROR;
4766 #endif
4767 #ifdef ENODATA
4768 case ENODATA: return DRWAV_NO_DATA_AVAILABLE;
4769 #endif
4770 #ifdef ETIME
4771 case ETIME: return DRWAV_TIMEOUT;
4772 #endif
4773 #ifdef ENOSR
4774 case ENOSR: return DRWAV_NO_DATA_AVAILABLE;
4775 #endif
4776 #ifdef ENONET
4777 case ENONET: return DRWAV_NO_NETWORK;
4778 #endif
4779 #ifdef ENOPKG
4780 case ENOPKG: return DRWAV_ERROR;
4781 #endif
4782 #ifdef EREMOTE
4783 case EREMOTE: return DRWAV_ERROR;
4784 #endif
4785 #ifdef ENOLINK
4786 case ENOLINK: return DRWAV_ERROR;
4787 #endif
4788 #ifdef EADV
4789 case EADV: return DRWAV_ERROR;
4790 #endif
4791 #ifdef ESRMNT
4792 case ESRMNT: return DRWAV_ERROR;
4793 #endif
4794 #ifdef ECOMM
4795 case ECOMM: return DRWAV_ERROR;
4796 #endif
4797 #ifdef EPROTO
4798 case EPROTO: return DRWAV_ERROR;
4799 #endif
4800 #ifdef EMULTIHOP
4801 case EMULTIHOP: return DRWAV_ERROR;
4802 #endif
4803 #ifdef EDOTDOT
4804 case EDOTDOT: return DRWAV_ERROR;
4805 #endif
4806 #ifdef EBADMSG
4807 case EBADMSG: return DRWAV_BAD_MESSAGE;
4808 #endif
4809 #ifdef EOVERFLOW
4810 case EOVERFLOW: return DRWAV_TOO_BIG;
4811 #endif
4812 #ifdef ENOTUNIQ
4813 case ENOTUNIQ: return DRWAV_NOT_UNIQUE;
4814 #endif
4815 #ifdef EBADFD
4816 case EBADFD: return DRWAV_ERROR;
4817 #endif
4818 #ifdef EREMCHG
4819 case EREMCHG: return DRWAV_ERROR;
4820 #endif
4821 #ifdef ELIBACC
4822 case ELIBACC: return DRWAV_ACCESS_DENIED;
4823 #endif
4824 #ifdef ELIBBAD
4825 case ELIBBAD: return DRWAV_INVALID_FILE;
4826 #endif
4827 #ifdef ELIBSCN
4828 case ELIBSCN: return DRWAV_INVALID_FILE;
4829 #endif
4830 #ifdef ELIBMAX
4831 case ELIBMAX: return DRWAV_ERROR;
4832 #endif
4833 #ifdef ELIBEXEC
4834 case ELIBEXEC: return DRWAV_ERROR;
4835 #endif
4836 #ifdef EILSEQ
4837 case EILSEQ: return DRWAV_INVALID_DATA;
4838 #endif
4839 #ifdef ERESTART
4840 case ERESTART: return DRWAV_ERROR;
4841 #endif
4842 #ifdef ESTRPIPE
4843 case ESTRPIPE: return DRWAV_ERROR;
4844 #endif
4845 #ifdef EUSERS
4846 case EUSERS: return DRWAV_ERROR;
4847 #endif
4848 #ifdef ENOTSOCK
4849 case ENOTSOCK: return DRWAV_NOT_SOCKET;
4850 #endif
4851 #ifdef EDESTADDRREQ
4852 case EDESTADDRREQ: return DRWAV_NO_ADDRESS;
4853 #endif
4854 #ifdef EMSGSIZE
4855 case EMSGSIZE: return DRWAV_TOO_BIG;
4856 #endif
4857 #ifdef EPROTOTYPE
4858 case EPROTOTYPE: return DRWAV_BAD_PROTOCOL;
4859 #endif
4860 #ifdef ENOPROTOOPT
4861 case ENOPROTOOPT: return DRWAV_PROTOCOL_UNAVAILABLE;
4862 #endif
4863 #ifdef EPROTONOSUPPORT
4864 case EPROTONOSUPPORT: return DRWAV_PROTOCOL_NOT_SUPPORTED;
4865 #endif
4866 #ifdef ESOCKTNOSUPPORT
4867 case ESOCKTNOSUPPORT: return DRWAV_SOCKET_NOT_SUPPORTED;
4868 #endif
4869 #ifdef EOPNOTSUPP
4870 case EOPNOTSUPP: return DRWAV_INVALID_OPERATION;
4871 #endif
4872 #ifdef EPFNOSUPPORT
4873 case EPFNOSUPPORT: return DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED;
4874 #endif
4875 #ifdef EAFNOSUPPORT
4876 case EAFNOSUPPORT: return DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED;
4877 #endif
4878 #ifdef EADDRINUSE
4879 case EADDRINUSE: return DRWAV_ALREADY_IN_USE;
4880 #endif
4881 #ifdef EADDRNOTAVAIL
4882 case EADDRNOTAVAIL: return DRWAV_ERROR;
4883 #endif
4884 #ifdef ENETDOWN
4885 case ENETDOWN: return DRWAV_NO_NETWORK;
4886 #endif
4887 #ifdef ENETUNREACH
4888 case ENETUNREACH: return DRWAV_NO_NETWORK;
4889 #endif
4890 #ifdef ENETRESET
4891 case ENETRESET: return DRWAV_NO_NETWORK;
4892 #endif
4893 #ifdef ECONNABORTED
4894 case ECONNABORTED: return DRWAV_NO_NETWORK;
4895 #endif
4896 #ifdef ECONNRESET
4897 case ECONNRESET: return DRWAV_CONNECTION_RESET;
4898 #endif
4899 #ifdef ENOBUFS
4900 case ENOBUFS: return DRWAV_NO_SPACE;
4901 #endif
4902 #ifdef EISCONN
4903 case EISCONN: return DRWAV_ALREADY_CONNECTED;
4904 #endif
4905 #ifdef ENOTCONN
4906 case ENOTCONN: return DRWAV_NOT_CONNECTED;
4907 #endif
4908 #ifdef ESHUTDOWN
4909 case ESHUTDOWN: return DRWAV_ERROR;
4910 #endif
4911 #ifdef ETOOMANYREFS
4912 case ETOOMANYREFS: return DRWAV_ERROR;
4913 #endif
4914 #ifdef ETIMEDOUT
4915 case ETIMEDOUT: return DRWAV_TIMEOUT;
4916 #endif
4917 #ifdef ECONNREFUSED
4918 case ECONNREFUSED: return DRWAV_CONNECTION_REFUSED;
4919 #endif
4920 #ifdef EHOSTDOWN
4921 case EHOSTDOWN: return DRWAV_NO_HOST;
4922 #endif
4923 #ifdef EHOSTUNREACH
4924 case EHOSTUNREACH: return DRWAV_NO_HOST;
4925 #endif
4926 #ifdef EALREADY
4927 case EALREADY: return DRWAV_IN_PROGRESS;
4928 #endif
4929 #ifdef EINPROGRESS
4930 case EINPROGRESS: return DRWAV_IN_PROGRESS;
4931 #endif
4932 #ifdef ESTALE
4933 case ESTALE: return DRWAV_INVALID_FILE;
4934 #endif
4935 #ifdef EUCLEAN
4936 case EUCLEAN: return DRWAV_ERROR;
4937 #endif
4938 #ifdef ENOTNAM
4939 case ENOTNAM: return DRWAV_ERROR;
4940 #endif
4941 #ifdef ENAVAIL
4942 case ENAVAIL: return DRWAV_ERROR;
4943 #endif
4944 #ifdef EISNAM
4945 case EISNAM: return DRWAV_ERROR;
4946 #endif
4947 #ifdef EREMOTEIO
4948 case EREMOTEIO: return DRWAV_IO_ERROR;
4949 #endif
4950 #ifdef EDQUOT
4951 case EDQUOT: return DRWAV_NO_SPACE;
4952 #endif
4953 #ifdef ENOMEDIUM
4954 case ENOMEDIUM: return DRWAV_DOES_NOT_EXIST;
4955 #endif
4956 #ifdef EMEDIUMTYPE
4957 case EMEDIUMTYPE: return DRWAV_ERROR;
4958 #endif
4959 #ifdef ECANCELED
4960 case ECANCELED: return DRWAV_CANCELLED;
4961 #endif
4962 #ifdef ENOKEY
4963 case ENOKEY: return DRWAV_ERROR;
4964 #endif
4965 #ifdef EKEYEXPIRED
4966 case EKEYEXPIRED: return DRWAV_ERROR;
4967 #endif
4968 #ifdef EKEYREVOKED
4969 case EKEYREVOKED: return DRWAV_ERROR;
4970 #endif
4971 #ifdef EKEYREJECTED
4972 case EKEYREJECTED: return DRWAV_ERROR;
4973 #endif
4974 #ifdef EOWNERDEAD
4975 case EOWNERDEAD: return DRWAV_ERROR;
4976 #endif
4977 #ifdef ENOTRECOVERABLE
4978 case ENOTRECOVERABLE: return DRWAV_ERROR;
4979 #endif
4980 #ifdef ERFKILL
4981 case ERFKILL: return DRWAV_ERROR;
4982 #endif
4983 #ifdef EHWPOISON
4984 case EHWPOISON: return DRWAV_ERROR;
4985 #endif
4986 default: return DRWAV_ERROR;
4987 }
4988}
4989/* End Errno */
4990
4991/* fopen */
4992DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
4993{
4994#if defined(_MSC_VER) && _MSC_VER >= 1400
4995 errno_t err;
4996#endif
4997
4998 if (ppFile != NULL) {
4999 *ppFile = NULL; /* Safety. */
5000 }
5001
5002 if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
5003 return DRWAV_INVALID_ARGS;
5004 }
5005
5006#if defined(_MSC_VER) && _MSC_VER >= 1400
5007 err = fopen_s(ppFile, pFilePath, pOpenMode);
5008 if (err != 0) {
5009 return drwav_result_from_errno(err);
5010 }
5011#else
5012#if defined(_WIN32) || defined(__APPLE__)
5013 *ppFile = fopen(pFilePath, pOpenMode);
5014#else
5015 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
5016 *ppFile = fopen64(pFilePath, pOpenMode);
5017 #else
5018 *ppFile = fopen(pFilePath, pOpenMode);
5019 #endif
5020#endif
5021 if (*ppFile == NULL) {
5022 drwav_result result = drwav_result_from_errno(errno);
5023 if (result == DRWAV_SUCCESS) {
5024 result = DRWAV_ERROR; /* Just a safety check to make sure we never ever return success when pFile == NULL. */
5025 }
5026
5027 return result;
5028 }
5029#endif
5030
5031 return DRWAV_SUCCESS;
5032}
5033
5034/*
5035_wfopen() isn't always available in all compilation environments.
5036
5037 * Windows only.
5038 * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
5039 * MinGW-64 (both 32- and 64-bit) seems to support it.
5040 * MinGW wraps it in !defined(__STRICT_ANSI__).
5041 * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
5042
5043This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
5044fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
5045*/
5046#if defined(_WIN32)
5047 #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
5048 #define DRWAV_HAS_WFOPEN
5049 #endif
5050#endif
5051
5052#ifndef DR_WAV_NO_WCHAR
5053DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drwav_allocation_callbacks* pAllocationCallbacks)
5054{
5055 if (ppFile != NULL) {
5056 *ppFile = NULL; /* Safety. */
5057 }
5058
5059 if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
5060 return DRWAV_INVALID_ARGS;
5061 }
5062
5063#if defined(DRWAV_HAS_WFOPEN)
5064 {
5065 /* Use _wfopen() on Windows. */
5066 #if defined(_MSC_VER) && _MSC_VER >= 1400
5067 errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
5068 if (err != 0) {
5069 return drwav_result_from_errno(err);
5070 }
5071 #else
5072 *ppFile = _wfopen(pFilePath, pOpenMode);
5073 if (*ppFile == NULL) {
5074 return drwav_result_from_errno(errno);
5075 }
5076 #endif
5077 (void)pAllocationCallbacks;
5078 }
5079#else
5080 /*
5081 Use fopen() on anything other than Windows. Requires a conversion. This is annoying because
5082 fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note
5083 that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
5084 maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler
5085 error I'll look into improving compatibility.
5086 */
5087
5088 /*
5089 Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just
5090 need to abort with an error. If you encounter a compiler lacking such support, add it to this list
5091 and submit a bug report and it'll be added to the library upstream.
5092 */
5093 #if defined(__DJGPP__)
5094 {
5095 /* Nothing to do here. This will fall through to the error check below. */
5096 }
5097 #else
5098 {
5099 mbstate_t mbs;
5100 size_t lenMB;
5101 const wchar_t* pFilePathTemp = pFilePath;
5102 char* pFilePathMB = NULL;
5103 char pOpenModeMB[32] = {0};
5104
5105 /* Get the length first. */
5106 DRWAV_ZERO_OBJECT(&mbs);
5107 lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
5108 if (lenMB == (size_t)-1) {
5109 return drwav_result_from_errno(errno);
5110 }
5111
5112 pFilePathMB = (char*)drwav__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
5113 if (pFilePathMB == NULL) {
5114 return DRWAV_OUT_OF_MEMORY;
5115 }
5116
5117 pFilePathTemp = pFilePath;
5118 DRWAV_ZERO_OBJECT(&mbs);
5119 wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
5120
5121 /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
5122 {
5123 size_t i = 0;
5124 for (;;) {
5125 if (pOpenMode[i] == 0) {
5126 pOpenModeMB[i] = '\0';
5127 break;
5128 }
5129
5130 pOpenModeMB[i] = (char)pOpenMode[i];
5131 i += 1;
5132 }
5133 }
5134
5135 *ppFile = fopen(pFilePathMB, pOpenModeMB);
5136
5137 drwav__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
5138 }
5139 #endif
5140
5141 if (*ppFile == NULL) {
5142 return DRWAV_ERROR;
5143 }
5144#endif
5145
5146 return DRWAV_SUCCESS;
5147}
5148#endif
5149/* End fopen */
5150
5151
5152DRWAV_PRIVATE size_t drwav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
5153{
5154 return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
5155}
5156
5157DRWAV_PRIVATE size_t drwav__on_write_stdio(void* pUserData, const void* pData, size_t bytesToWrite)
5158{
5159 return fwrite(pData, 1, bytesToWrite, (FILE*)pUserData);
5160}
5161
5162DRWAV_PRIVATE drwav_bool32 drwav__on_seek_stdio(void* pUserData, int offset, drwav_seek_origin origin)
5163{
5164 return fseek((FILE*)pUserData, offset, (origin == drwav_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
5165}
5166
5167DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
5168{
5169 return drwav_init_file_ex(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
5170}
5171
5172
5173DRWAV_PRIVATE drwav_bool32 drwav_init_file__internal_FILE(drwav* pWav, FILE* pFile, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
5174{
5175 drwav_bool32 result;
5176
5177 result = drwav_preinit(pWav, drwav__on_read_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
5178 if (result != DRWAV_TRUE) {
5179 fclose(pFile);
5180 return result;
5181 }
5182
5183 result = drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
5184 if (result != DRWAV_TRUE) {
5185 fclose(pFile);
5186 return result;
5187 }
5188
5189 return DRWAV_TRUE;
5190}
5191
5192DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
5193{
5194 FILE* pFile;
5195 if (drwav_fopen(&pFile, filename, "rb") != DRWAV_SUCCESS) {
5196 return DRWAV_FALSE;
5197 }
5198
5199 /* This takes ownership of the FILE* object. */
5200 return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
5201}
5202
5203#ifndef DR_WAV_NO_WCHAR
5204DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
5205{
5206 return drwav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
5207}
5208
5209DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
5210{
5211 FILE* pFile;
5212 if (drwav_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != DRWAV_SUCCESS) {
5213 return DRWAV_FALSE;
5214 }
5215
5216 /* This takes ownership of the FILE* object. */
5217 return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
5218}
5219#endif
5220
5221DRWAV_API drwav_bool32 drwav_init_file_with_metadata(drwav* pWav, const char* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
5222{
5223 FILE* pFile;
5224 if (drwav_fopen(&pFile, filename, "rb") != DRWAV_SUCCESS) {
5225 return DRWAV_FALSE;
5226 }
5227
5228 /* This takes ownership of the FILE* object. */
5229 return drwav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags | DRWAV_WITH_METADATA, pAllocationCallbacks);
5230}
5231
5232#ifndef DR_WAV_NO_WCHAR
5233DRWAV_API drwav_bool32 drwav_init_file_with_metadata_w(drwav* pWav, const wchar_t* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
5234{
5235 FILE* pFile;
5236 if (drwav_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != DRWAV_SUCCESS) {
5237 return DRWAV_FALSE;
5238 }
5239
5240 /* This takes ownership of the FILE* object. */
5241 return drwav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags | DRWAV_WITH_METADATA, pAllocationCallbacks);
5242}
5243#endif
5244
5245
5246DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal_FILE(drwav* pWav, FILE* pFile, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
5247{
5248 drwav_bool32 result;
5249
5250 result = drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
5251 if (result != DRWAV_TRUE) {
5252 fclose(pFile);
5253 return result;
5254 }
5255
5256 result = drwav_init_write__internal(pWav, pFormat, totalSampleCount);
5257 if (result != DRWAV_TRUE) {
5258 fclose(pFile);
5259 return result;
5260 }
5261
5262 return DRWAV_TRUE;
5263}
5264
5265DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
5266{
5267 FILE* pFile;
5268 if (drwav_fopen(&pFile, filename, "wb") != DRWAV_SUCCESS) {
5269 return DRWAV_FALSE;
5270 }
5271
5272 /* This takes ownership of the FILE* object. */
5273 return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
5274}
5275
5276#ifndef DR_WAV_NO_WCHAR
5277DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
5278{
5279 FILE* pFile;
5280 if (drwav_wfopen(&pFile, filename, L"wb", pAllocationCallbacks) != DRWAV_SUCCESS) {
5281 return DRWAV_FALSE;
5282 }
5283
5284 /* This takes ownership of the FILE* object. */
5285 return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
5286}
5287#endif
5288
5289DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
5290{
5291 return drwav_init_file_write__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
5292}
5293
5294DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
5295{
5296 return drwav_init_file_write__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
5297}
5298
5299DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
5300{
5301 if (pFormat == NULL) {
5302 return DRWAV_FALSE;
5303 }
5304
5305 return drwav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
5306}
5307
5308#ifndef DR_WAV_NO_WCHAR
5309DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
5310{
5311 return drwav_init_file_write_w__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
5312}
5313
5314DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
5315{
5316 return drwav_init_file_write_w__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
5317}
5318
5319DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
5320{
5321 if (pFormat == NULL) {
5322 return DRWAV_FALSE;
5323 }
5324
5325 return drwav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
5326}
5327#endif
5328#endif /* DR_WAV_NO_STDIO */
5329
5330
5331DRWAV_PRIVATE size_t drwav__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
5332{
5333 drwav* pWav = (drwav*)pUserData;
5334 size_t bytesRemaining;
5335
5336 DRWAV_ASSERT(pWav != NULL);
5337 DRWAV_ASSERT(pWav->memoryStream.dataSize >= pWav->memoryStream.currentReadPos);
5338
5339 bytesRemaining = pWav->memoryStream.dataSize - pWav->memoryStream.currentReadPos;
5340 if (bytesToRead > bytesRemaining) {
5341 bytesToRead = bytesRemaining;
5342 }
5343
5344 if (bytesToRead > 0) {
5345 DRWAV_COPY_MEMORY(pBufferOut, pWav->memoryStream.data + pWav->memoryStream.currentReadPos, bytesToRead);
5346 pWav->memoryStream.currentReadPos += bytesToRead;
5347 }
5348
5349 return bytesToRead;
5350}
5351
5352DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory(void* pUserData, int offset, drwav_seek_origin origin)
5353{
5354 drwav* pWav = (drwav*)pUserData;
5355 DRWAV_ASSERT(pWav != NULL);
5356
5357 if (origin == drwav_seek_origin_current) {
5358 if (offset > 0) {
5359 if (pWav->memoryStream.currentReadPos + offset > pWav->memoryStream.dataSize) {
5360 return DRWAV_FALSE; /* Trying to seek too far forward. */
5361 }
5362 } else {
5363 if (pWav->memoryStream.currentReadPos < (size_t)-offset) {
5364 return DRWAV_FALSE; /* Trying to seek too far backwards. */
5365 }
5366 }
5367
5368 /* This will never underflow thanks to the clamps above. */
5369 pWav->memoryStream.currentReadPos += offset;
5370 } else {
5371 if ((drwav_uint32)offset <= pWav->memoryStream.dataSize) {
5372 pWav->memoryStream.currentReadPos = offset;
5373 } else {
5374 return DRWAV_FALSE; /* Trying to seek too far forward. */
5375 }
5376 }
5377
5378 return DRWAV_TRUE;
5379}
5380
5381DRWAV_PRIVATE size_t drwav__on_write_memory(void* pUserData, const void* pDataIn, size_t bytesToWrite)
5382{
5383 drwav* pWav = (drwav*)pUserData;
5384 size_t bytesRemaining;
5385
5386 DRWAV_ASSERT(pWav != NULL);
5387 DRWAV_ASSERT(pWav->memoryStreamWrite.dataCapacity >= pWav->memoryStreamWrite.currentWritePos);
5388
5389 bytesRemaining = pWav->memoryStreamWrite.dataCapacity - pWav->memoryStreamWrite.currentWritePos;
5390 if (bytesRemaining < bytesToWrite) {
5391 /* Need to reallocate. */
5392 void* pNewData;
5393 size_t newDataCapacity = (pWav->memoryStreamWrite.dataCapacity == 0) ? 256 : pWav->memoryStreamWrite.dataCapacity * 2;
5394
5395 /* If doubling wasn't enough, just make it the minimum required size to write the data. */
5396 if ((newDataCapacity - pWav->memoryStreamWrite.currentWritePos) < bytesToWrite) {
5397 newDataCapacity = pWav->memoryStreamWrite.currentWritePos + bytesToWrite;
5398 }
5399
5400 pNewData = drwav__realloc_from_callbacks(*pWav->memoryStreamWrite.ppData, newDataCapacity, pWav->memoryStreamWrite.dataCapacity, &pWav->allocationCallbacks);
5401 if (pNewData == NULL) {
5402 return 0;
5403 }
5404
5405 *pWav->memoryStreamWrite.ppData = pNewData;
5406 pWav->memoryStreamWrite.dataCapacity = newDataCapacity;
5407 }
5408
5409 DRWAV_COPY_MEMORY(((drwav_uint8*)(*pWav->memoryStreamWrite.ppData)) + pWav->memoryStreamWrite.currentWritePos, pDataIn, bytesToWrite);
5410
5411 pWav->memoryStreamWrite.currentWritePos += bytesToWrite;
5412 if (pWav->memoryStreamWrite.dataSize < pWav->memoryStreamWrite.currentWritePos) {
5413 pWav->memoryStreamWrite.dataSize = pWav->memoryStreamWrite.currentWritePos;
5414 }
5415
5416 *pWav->memoryStreamWrite.pDataSize = pWav->memoryStreamWrite.dataSize;
5417
5418 return bytesToWrite;
5419}
5420
5421DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory_write(void* pUserData, int offset, drwav_seek_origin origin)
5422{
5423 drwav* pWav = (drwav*)pUserData;
5424 DRWAV_ASSERT(pWav != NULL);
5425
5426 if (origin == drwav_seek_origin_current) {
5427 if (offset > 0) {
5428 if (pWav->memoryStreamWrite.currentWritePos + offset > pWav->memoryStreamWrite.dataSize) {
5429 offset = (int)(pWav->memoryStreamWrite.dataSize - pWav->memoryStreamWrite.currentWritePos); /* Trying to seek too far forward. */
5430 }
5431 } else {
5432 if (pWav->memoryStreamWrite.currentWritePos < (size_t)-offset) {
5433 offset = -(int)pWav->memoryStreamWrite.currentWritePos; /* Trying to seek too far backwards. */
5434 }
5435 }
5436
5437 /* This will never underflow thanks to the clamps above. */
5438 pWav->memoryStreamWrite.currentWritePos += offset;
5439 } else {
5440 if ((drwav_uint32)offset <= pWav->memoryStreamWrite.dataSize) {
5441 pWav->memoryStreamWrite.currentWritePos = offset;
5442 } else {
5443 pWav->memoryStreamWrite.currentWritePos = pWav->memoryStreamWrite.dataSize; /* Trying to seek too far forward. */
5444 }
5445 }
5446
5447 return DRWAV_TRUE;
5448}
5449
5450DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks)
5451{
5452 return drwav_init_memory_ex(pWav, data, dataSize, NULL, NULL, 0, pAllocationCallbacks);
5453}
5454
5455DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
5456{
5457 if (data == NULL || dataSize == 0) {
5458 return DRWAV_FALSE;
5459 }
5460
5461 if (!drwav_preinit(pWav, drwav__on_read_memory, drwav__on_seek_memory, pWav, pAllocationCallbacks)) {
5462 return DRWAV_FALSE;
5463 }
5464
5465 pWav->memoryStream.data = (const drwav_uint8*)data;
5466 pWav->memoryStream.dataSize = dataSize;
5467 pWav->memoryStream.currentReadPos = 0;
5468
5469 return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
5470}
5471
5472DRWAV_API drwav_bool32 drwav_init_memory_with_metadata(drwav* pWav, const void* data, size_t dataSize, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
5473{
5474 if (data == NULL || dataSize == 0) {
5475 return DRWAV_FALSE;
5476 }
5477
5478 if (!drwav_preinit(pWav, drwav__on_read_memory, drwav__on_seek_memory, pWav, pAllocationCallbacks)) {
5479 return DRWAV_FALSE;
5480 }
5481
5482 pWav->memoryStream.data = (const drwav_uint8*)data;
5483 pWav->memoryStream.dataSize = dataSize;
5484 pWav->memoryStream.currentReadPos = 0;
5485
5486 return drwav_init__internal(pWav, NULL, NULL, flags | DRWAV_WITH_METADATA);
5487}
5488
5489
5490DRWAV_PRIVATE drwav_bool32 drwav_init_memory_write__internal(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
5491{
5492 if (ppData == NULL || pDataSize == NULL) {
5493 return DRWAV_FALSE;
5494 }
5495
5496 *ppData = NULL; /* Important because we're using realloc()! */
5497 *pDataSize = 0;
5498
5499 if (!drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_memory, drwav__on_seek_memory_write, pWav, pAllocationCallbacks)) {
5500 return DRWAV_FALSE;
5501 }
5502
5503 pWav->memoryStreamWrite.ppData = ppData;
5504 pWav->memoryStreamWrite.pDataSize = pDataSize;
5505 pWav->memoryStreamWrite.dataSize = 0;
5506 pWav->memoryStreamWrite.dataCapacity = 0;
5507 pWav->memoryStreamWrite.currentWritePos = 0;
5508
5509 return drwav_init_write__internal(pWav, pFormat, totalSampleCount);
5510}
5511
5512DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
5513{
5514 return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
5515}
5516
5517DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
5518{
5519 return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
5520}
5521
5522DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
5523{
5524 if (pFormat == NULL) {
5525 return DRWAV_FALSE;
5526 }
5527
5528 return drwav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
5529}
5530
5531
5532
5533DRWAV_API drwav_result drwav_uninit(drwav* pWav)
5534{
5535 drwav_result result = DRWAV_SUCCESS;
5536
5537 if (pWav == NULL) {
5538 return DRWAV_INVALID_ARGS;
5539 }
5540
5541 /*
5542 If the drwav object was opened in write mode we'll need to finalize a few things:
5543 - Make sure the "data" chunk is aligned to 16-bits for RIFF containers, or 64 bits for W64 containers.
5544 - Set the size of the "data" chunk.
5545 */
5546 if (pWav->onWrite != NULL) {
5547 drwav_uint32 paddingSize = 0;
5548
5549 /* Padding. Do not adjust pWav->dataChunkDataSize - this should not include the padding. */
5550 if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
5551 paddingSize = drwav__chunk_padding_size_riff(pWav->dataChunkDataSize);
5552 } else {
5553 paddingSize = drwav__chunk_padding_size_w64(pWav->dataChunkDataSize);
5554 }
5555
5556 if (paddingSize > 0) {
5557 drwav_uint64 paddingData = 0;
5558 drwav__write(pWav, &paddingData, paddingSize); /* Byte order does not matter for this. */
5559 }
5560
5561 /*
5562 Chunk sizes. When using sequential mode, these will have been filled in at initialization time. We only need
5563 to do this when using non-sequential mode.
5564 */
5565 if (pWav->onSeek && !pWav->isSequentialWrite) {
5566 if (pWav->container == drwav_container_riff) {
5567 /* The "RIFF" chunk size. */
5568 if (pWav->onSeek(pWav->pUserData, 4, drwav_seek_origin_start)) {
5569 drwav_uint32 riffChunkSize = drwav__riff_chunk_size_riff(pWav->dataChunkDataSize, pWav->pMetadata, pWav->metadataCount);
5570 drwav__write_u32ne_to_le(pWav, riffChunkSize);
5571 }
5572
5573 /* The "data" chunk size. */
5574 if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 4, drwav_seek_origin_start)) {
5575 drwav_uint32 dataChunkSize = drwav__data_chunk_size_riff(pWav->dataChunkDataSize);
5576 drwav__write_u32ne_to_le(pWav, dataChunkSize);
5577 }
5578 } else if (pWav->container == drwav_container_w64) {
5579 /* The "RIFF" chunk size. */
5580 if (pWav->onSeek(pWav->pUserData, 16, drwav_seek_origin_start)) {
5581 drwav_uint64 riffChunkSize = drwav__riff_chunk_size_w64(pWav->dataChunkDataSize);
5582 drwav__write_u64ne_to_le(pWav, riffChunkSize);
5583 }
5584
5585 /* The "data" chunk size. */
5586 if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 8, drwav_seek_origin_start)) {
5587 drwav_uint64 dataChunkSize = drwav__data_chunk_size_w64(pWav->dataChunkDataSize);
5588 drwav__write_u64ne_to_le(pWav, dataChunkSize);
5589 }
5590 } else if (pWav->container == drwav_container_rf64) {
5591 /* We only need to update the ds64 chunk. The "RIFF" and "data" chunks always have their sizes set to 0xFFFFFFFF for RF64. */
5592 int ds64BodyPos = 12 + 8;
5593
5594 /* The "RIFF" chunk size. */
5595 if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 0, drwav_seek_origin_start)) {
5596 drwav_uint64 riffChunkSize = drwav__riff_chunk_size_rf64(pWav->dataChunkDataSize, pWav->pMetadata, pWav->metadataCount);
5597 drwav__write_u64ne_to_le(pWav, riffChunkSize);
5598 }
5599
5600 /* The "data" chunk size. */
5601 if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 8, drwav_seek_origin_start)) {
5602 drwav_uint64 dataChunkSize = drwav__data_chunk_size_rf64(pWav->dataChunkDataSize);
5603 drwav__write_u64ne_to_le(pWav, dataChunkSize);
5604 }
5605 }
5606 }
5607
5608 /* Validation for sequential mode. */
5609 if (pWav->isSequentialWrite) {
5610 if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) {
5611 result = DRWAV_INVALID_FILE;
5612 }
5613 }
5614 } else {
5615 drwav_free(pWav->pMetadata, &pWav->allocationCallbacks);
5616 }
5617
5618#ifndef DR_WAV_NO_STDIO
5619 /*
5620 If we opened the file with drwav_open_file() we will want to close the file handle. We can know whether or not drwav_open_file()
5621 was used by looking at the onRead and onSeek callbacks.
5622 */
5623 if (pWav->onRead == drwav__on_read_stdio || pWav->onWrite == drwav__on_write_stdio) {
5624 fclose((FILE*)pWav->pUserData);
5625 }
5626#endif
5627
5628 return result;
5629}
5630
5631
5632
5633DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut)
5634{
5635 size_t bytesRead;
5636 drwav_uint32 bytesPerFrame;
5637
5638 if (pWav == NULL || bytesToRead == 0) {
5639 return 0; /* Invalid args. */
5640 }
5641
5642 if (bytesToRead > pWav->bytesRemaining) {
5643 bytesToRead = (size_t)pWav->bytesRemaining;
5644 }
5645
5646 if (bytesToRead == 0) {
5647 return 0; /* At end. */
5648 }
5649
5650 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
5651 if (bytesPerFrame == 0) {
5652 return 0; /* Could not determine the bytes per frame. */
5653 }
5654
5655 if (pBufferOut != NULL) {
5656 bytesRead = pWav->onRead(pWav->pUserData, pBufferOut, bytesToRead);
5657 } else {
5658 /* We need to seek. If we fail, we need to read-and-discard to make sure we get a good byte count. */
5659 bytesRead = 0;
5660 while (bytesRead < bytesToRead) {
5661 size_t bytesToSeek = (bytesToRead - bytesRead);
5662 if (bytesToSeek > 0x7FFFFFFF) {
5663 bytesToSeek = 0x7FFFFFFF;
5664 }
5665
5666 if (pWav->onSeek(pWav->pUserData, (int)bytesToSeek, drwav_seek_origin_current) == DRWAV_FALSE) {
5667 break;
5668 }
5669
5670 bytesRead += bytesToSeek;
5671 }
5672
5673 /* When we get here we may need to read-and-discard some data. */
5674 while (bytesRead < bytesToRead) {
5675 drwav_uint8 buffer[4096];
5676 size_t bytesSeeked;
5677 size_t bytesToSeek = (bytesToRead - bytesRead);
5678 if (bytesToSeek > sizeof(buffer)) {
5679 bytesToSeek = sizeof(buffer);
5680 }
5681
5682 bytesSeeked = pWav->onRead(pWav->pUserData, buffer, bytesToSeek);
5683 bytesRead += bytesSeeked;
5684
5685 if (bytesSeeked < bytesToSeek) {
5686 break; /* Reached the end. */
5687 }
5688 }
5689 }
5690
5691 pWav->readCursorInPCMFrames += bytesRead / bytesPerFrame;
5692
5693 pWav->bytesRemaining -= bytesRead;
5694 return bytesRead;
5695}
5696
5697
5698
5699DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
5700{
5701 drwav_uint32 bytesPerFrame;
5702 drwav_uint64 bytesToRead; /* Intentionally uint64 instead of size_t so we can do a check that we're not reading too much on 32-bit builds. */
5703 drwav_uint64 framesRemainingInFile;
5704
5705 if (pWav == NULL || framesToRead == 0) {
5706 return 0;
5707 }
5708
5709 /* Cannot use this function for compressed formats. */
5710 if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
5711 return 0;
5712 }
5713
5714 framesRemainingInFile = pWav->totalPCMFrameCount - pWav->readCursorInPCMFrames;
5715 if (framesToRead > framesRemainingInFile) {
5716 framesToRead = framesRemainingInFile;
5717 }
5718
5719 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
5720 if (bytesPerFrame == 0) {
5721 return 0;
5722 }
5723
5724 /* Don't try to read more samples than can potentially fit in the output buffer. */
5725 bytesToRead = framesToRead * bytesPerFrame;
5726 if (bytesToRead > DRWAV_SIZE_MAX) {
5727 bytesToRead = (DRWAV_SIZE_MAX / bytesPerFrame) * bytesPerFrame; /* Round the number of bytes to read to a clean frame boundary. */
5728 }
5729
5730 /*
5731 Doing an explicit check here just to make it clear that we don't want to be attempt to read anything if there's no bytes to read. There
5732 *could* be a time where it evaluates to 0 due to overflowing.
5733 */
5734 if (bytesToRead == 0) {
5735 return 0;
5736 }
5737
5738 return drwav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame;
5739}
5740
5741DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
5742{
5743 drwav_uint64 framesRead = drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
5744
5745 if (pBufferOut != NULL) {
5746 drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
5747 if (bytesPerFrame == 0) {
5748 return 0; /* Could not get the bytes per frame which means bytes per sample cannot be determined and we don't know how to byte swap. */
5749 }
5750
5751 drwav__bswap_samples(pBufferOut, framesRead*pWav->channels, bytesPerFrame/pWav->channels);
5752 }
5753
5754 return framesRead;
5755}
5756
5757DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
5758{
5759 drwav_uint64 framesRead = 0;
5760
5761 if (drwav_is_container_be(pWav->container)) {
5762 /*
5763 Special case for AIFF. AIFF is a big-endian encoded format, but it supports a format that is
5764 PCM in little-endian encoding. In this case, we fall through this branch and treate it as
5765 little-endian.
5766 */
5767 if (pWav->container != drwav_container_aiff || pWav->aiff.isLE == DRWAV_FALSE) {
5768 if (drwav__is_little_endian()) {
5769 framesRead = drwav_read_pcm_frames_be(pWav, framesToRead, pBufferOut);
5770 } else {
5771 framesRead = drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
5772 }
5773
5774 goto post_process;
5775 }
5776 }
5777
5778 /* Getting here means the data should be considered little-endian. */
5779 if (drwav__is_little_endian()) {
5780 framesRead = drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
5781 } else {
5782 framesRead = drwav_read_pcm_frames_be(pWav, framesToRead, pBufferOut);
5783 }
5784
5785 /*
5786 Here is where we check if we need to do a signed/unsigned conversion for AIFF. The reason we need to do this
5787 is because dr_wav always assumes an 8-bit sample is unsigned, whereas AIFF can have signed 8-bit formats.
5788 */
5789 post_process:
5790 {
5791 if (pWav->container == drwav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == DRWAV_FALSE) {
5792 if (pBufferOut != NULL) {
5793 drwav_uint64 iSample;
5794
5795 for (iSample = 0; iSample < framesRead * pWav->channels; iSample += 1) {
5796 ((drwav_uint8*)pBufferOut)[iSample] += 128;
5797 }
5798 }
5799 }
5800 }
5801
5802 return framesRead;
5803}
5804
5805
5806
5807DRWAV_PRIVATE drwav_bool32 drwav_seek_to_first_pcm_frame(drwav* pWav)
5808{
5809 if (pWav->onWrite != NULL) {
5810 return DRWAV_FALSE; /* No seeking in write mode. */
5811 }
5812
5813 if (!pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos, drwav_seek_origin_start)) {
5814 return DRWAV_FALSE;
5815 }
5816
5817 if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
5818 /* Cached data needs to be cleared for compressed formats. */
5819 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
5820 DRWAV_ZERO_OBJECT(&pWav->msadpcm);
5821 } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
5822 DRWAV_ZERO_OBJECT(&pWav->ima);
5823 } else {
5824 DRWAV_ASSERT(DRWAV_FALSE); /* If this assertion is triggered it means I've implemented a new compressed format but forgot to add a branch for it here. */
5825 }
5826 }
5827
5828 pWav->readCursorInPCMFrames = 0;
5829 pWav->bytesRemaining = pWav->dataChunkDataSize;
5830
5831 return DRWAV_TRUE;
5832}
5833
5834DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex)
5835{
5836 /* Seeking should be compatible with wave files > 2GB. */
5837
5838 if (pWav == NULL || pWav->onSeek == NULL) {
5839 return DRWAV_FALSE;
5840 }
5841
5842 /* No seeking in write mode. */
5843 if (pWav->onWrite != NULL) {
5844 return DRWAV_FALSE;
5845 }
5846
5847 /* If there are no samples, just return DRWAV_TRUE without doing anything. */
5848 if (pWav->totalPCMFrameCount == 0) {
5849 return DRWAV_TRUE;
5850 }
5851
5852 /* Make sure the sample is clamped. */
5853 if (targetFrameIndex > pWav->totalPCMFrameCount) {
5854 targetFrameIndex = pWav->totalPCMFrameCount;
5855 }
5856
5857 /*
5858 For compressed formats we just use a slow generic seek. If we are seeking forward we just seek forward. If we are going backwards we need
5859 to seek back to the start.
5860 */
5861 if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
5862 /* TODO: This can be optimized. */
5863
5864 /*
5865 If we're seeking forward it's simple - just keep reading samples until we hit the sample we're requesting. If we're seeking backwards,
5866 we first need to seek back to the start and then just do the same thing as a forward seek.
5867 */
5868 if (targetFrameIndex < pWav->readCursorInPCMFrames) {
5869 if (!drwav_seek_to_first_pcm_frame(pWav)) {
5870 return DRWAV_FALSE;
5871 }
5872 }
5873
5874 if (targetFrameIndex > pWav->readCursorInPCMFrames) {
5875 drwav_uint64 offsetInFrames = targetFrameIndex - pWav->readCursorInPCMFrames;
5876
5877 drwav_int16 devnull[2048];
5878 while (offsetInFrames > 0) {
5879 drwav_uint64 framesRead = 0;
5880 drwav_uint64 framesToRead = offsetInFrames;
5881 if (framesToRead > drwav_countof(devnull)/pWav->channels) {
5882 framesToRead = drwav_countof(devnull)/pWav->channels;
5883 }
5884
5885 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
5886 framesRead = drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, devnull);
5887 } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
5888 framesRead = drwav_read_pcm_frames_s16__ima(pWav, framesToRead, devnull);
5889 } else {
5890 DRWAV_ASSERT(DRWAV_FALSE); /* If this assertion is triggered it means I've implemented a new compressed format but forgot to add a branch for it here. */
5891 }
5892
5893 if (framesRead != framesToRead) {
5894 return DRWAV_FALSE;
5895 }
5896
5897 offsetInFrames -= framesRead;
5898 }
5899 }
5900 } else {
5901 drwav_uint64 totalSizeInBytes;
5902 drwav_uint64 currentBytePos;
5903 drwav_uint64 targetBytePos;
5904 drwav_uint64 offset;
5905 drwav_uint32 bytesPerFrame;
5906
5907 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
5908 if (bytesPerFrame == 0) {
5909 return DRWAV_FALSE; /* Not able to calculate offset. */
5910 }
5911
5912 totalSizeInBytes = pWav->totalPCMFrameCount * bytesPerFrame;
5913 /*DRWAV_ASSERT(totalSizeInBytes >= pWav->bytesRemaining);*/
5914
5915 currentBytePos = totalSizeInBytes - pWav->bytesRemaining;
5916 targetBytePos = targetFrameIndex * bytesPerFrame;
5917
5918 if (currentBytePos < targetBytePos) {
5919 /* Offset forwards. */
5920 offset = (targetBytePos - currentBytePos);
5921 } else {
5922 /* Offset backwards. */
5923 if (!drwav_seek_to_first_pcm_frame(pWav)) {
5924 return DRWAV_FALSE;
5925 }
5926 offset = targetBytePos;
5927 }
5928
5929 while (offset > 0) {
5930 int offset32 = ((offset > INT_MAX) ? INT_MAX : (int)offset);
5931 if (!pWav->onSeek(pWav->pUserData, offset32, drwav_seek_origin_current)) {
5932 return DRWAV_FALSE;
5933 }
5934
5935 pWav->readCursorInPCMFrames += offset32 / bytesPerFrame;
5936 pWav->bytesRemaining -= offset32;
5937 offset -= offset32;
5938 }
5939 }
5940
5941 return DRWAV_TRUE;
5942}
5943
5944DRWAV_API drwav_result drwav_get_cursor_in_pcm_frames(drwav* pWav, drwav_uint64* pCursor)
5945{
5946 if (pCursor == NULL) {
5947 return DRWAV_INVALID_ARGS;
5948 }
5949
5950 *pCursor = 0; /* Safety. */
5951
5952 if (pWav == NULL) {
5953 return DRWAV_INVALID_ARGS;
5954 }
5955
5956 *pCursor = pWav->readCursorInPCMFrames;
5957
5958 return DRWAV_SUCCESS;
5959}
5960
5961DRWAV_API drwav_result drwav_get_length_in_pcm_frames(drwav* pWav, drwav_uint64* pLength)
5962{
5963 if (pLength == NULL) {
5964 return DRWAV_INVALID_ARGS;
5965 }
5966
5967 *pLength = 0; /* Safety. */
5968
5969 if (pWav == NULL) {
5970 return DRWAV_INVALID_ARGS;
5971 }
5972
5973 *pLength = pWav->totalPCMFrameCount;
5974
5975 return DRWAV_SUCCESS;
5976}
5977
5978
5979DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData)
5980{
5981 size_t bytesWritten;
5982
5983 if (pWav == NULL || bytesToWrite == 0 || pData == NULL) {
5984 return 0;
5985 }
5986
5987 bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite);
5988 pWav->dataChunkDataSize += bytesWritten;
5989
5990 return bytesWritten;
5991}
5992
5993DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
5994{
5995 drwav_uint64 bytesToWrite;
5996 drwav_uint64 bytesWritten;
5997 const drwav_uint8* pRunningData;
5998
5999 if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
6000 return 0;
6001 }
6002
6003 bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
6004 if (bytesToWrite > DRWAV_SIZE_MAX) {
6005 return 0;
6006 }
6007
6008 bytesWritten = 0;
6009 pRunningData = (const drwav_uint8*)pData;
6010
6011 while (bytesToWrite > 0) {
6012 size_t bytesJustWritten;
6013 drwav_uint64 bytesToWriteThisIteration;
6014
6015 bytesToWriteThisIteration = bytesToWrite;
6016 DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX); /* <-- This is checked above. */
6017
6018 bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, pRunningData);
6019 if (bytesJustWritten == 0) {
6020 break;
6021 }
6022
6023 bytesToWrite -= bytesJustWritten;
6024 bytesWritten += bytesJustWritten;
6025 pRunningData += bytesJustWritten;
6026 }
6027
6028 return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
6029}
6030
6031DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
6032{
6033 drwav_uint64 bytesToWrite;
6034 drwav_uint64 bytesWritten;
6035 drwav_uint32 bytesPerSample;
6036 const drwav_uint8* pRunningData;
6037
6038 if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
6039 return 0;
6040 }
6041
6042 bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
6043 if (bytesToWrite > DRWAV_SIZE_MAX) {
6044 return 0;
6045 }
6046
6047 bytesWritten = 0;
6048 pRunningData = (const drwav_uint8*)pData;
6049
6050 bytesPerSample = drwav_get_bytes_per_pcm_frame(pWav) / pWav->channels;
6051 if (bytesPerSample == 0) {
6052 return 0; /* Cannot determine bytes per sample, or bytes per sample is less than one byte. */
6053 }
6054
6055 while (bytesToWrite > 0) {
6056 drwav_uint8 temp[4096];
6057 drwav_uint32 sampleCount;
6058 size_t bytesJustWritten;
6059 drwav_uint64 bytesToWriteThisIteration;
6060
6061 bytesToWriteThisIteration = bytesToWrite;
6062 DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX); /* <-- This is checked above. */
6063
6064 /*
6065 WAV files are always little-endian. We need to byte swap on big-endian architectures. Since our input buffer is read-only we need
6066 to use an intermediary buffer for the conversion.
6067 */
6068 sampleCount = sizeof(temp)/bytesPerSample;
6069
6070 if (bytesToWriteThisIteration > ((drwav_uint64)sampleCount)*bytesPerSample) {
6071 bytesToWriteThisIteration = ((drwav_uint64)sampleCount)*bytesPerSample;
6072 }
6073
6074 DRWAV_COPY_MEMORY(temp, pRunningData, (size_t)bytesToWriteThisIteration);
6075 drwav__bswap_samples(temp, sampleCount, bytesPerSample);
6076
6077 bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, temp);
6078 if (bytesJustWritten == 0) {
6079 break;
6080 }
6081
6082 bytesToWrite -= bytesJustWritten;
6083 bytesWritten += bytesJustWritten;
6084 pRunningData += bytesJustWritten;
6085 }
6086
6087 return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
6088}
6089
6090DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
6091{
6092 if (drwav__is_little_endian()) {
6093 return drwav_write_pcm_frames_le(pWav, framesToWrite, pData);
6094 } else {
6095 return drwav_write_pcm_frames_be(pWav, framesToWrite, pData);
6096 }
6097}
6098
6099
6100DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6101{
6102 drwav_uint64 totalFramesRead = 0;
6103
6104 DRWAV_ASSERT(pWav != NULL);
6105 DRWAV_ASSERT(framesToRead > 0);
6106
6107 /* TODO: Lots of room for optimization here. */
6108
6109 while (pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) {
6110 DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
6111
6112 /* If there are no cached frames we need to load a new block. */
6113 if (pWav->msadpcm.cachedFrameCount == 0 && pWav->msadpcm.bytesRemainingInBlock == 0) {
6114 if (pWav->channels == 1) {
6115 /* Mono. */
6116 drwav_uint8 header[7];
6117 if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
6118 return totalFramesRead;
6119 }
6120 pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
6121
6122 pWav->msadpcm.predictor[0] = header[0];
6123 pWav->msadpcm.delta[0] = drwav_bytes_to_s16(header + 1);
6124 pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 3);
6125 pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 5);
6126 pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][0];
6127 pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[0][1];
6128 pWav->msadpcm.cachedFrameCount = 2;
6129 } else {
6130 /* Stereo. */
6131 drwav_uint8 header[14];
6132 if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
6133 return totalFramesRead;
6134 }
6135 pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
6136
6137 pWav->msadpcm.predictor[0] = header[0];
6138 pWav->msadpcm.predictor[1] = header[1];
6139 pWav->msadpcm.delta[0] = drwav_bytes_to_s16(header + 2);
6140 pWav->msadpcm.delta[1] = drwav_bytes_to_s16(header + 4);
6141 pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 6);
6142 pWav->msadpcm.prevFrames[1][1] = (drwav_int32)drwav_bytes_to_s16(header + 8);
6143 pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 10);
6144 pWav->msadpcm.prevFrames[1][0] = (drwav_int32)drwav_bytes_to_s16(header + 12);
6145
6146 pWav->msadpcm.cachedFrames[0] = pWav->msadpcm.prevFrames[0][0];
6147 pWav->msadpcm.cachedFrames[1] = pWav->msadpcm.prevFrames[1][0];
6148 pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][1];
6149 pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[1][1];
6150 pWav->msadpcm.cachedFrameCount = 2;
6151 }
6152 }
6153
6154 /* Output anything that's cached. */
6155 while (framesToRead > 0 && pWav->msadpcm.cachedFrameCount > 0 && pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) {
6156 if (pBufferOut != NULL) {
6157 drwav_uint32 iSample = 0;
6158 for (iSample = 0; iSample < pWav->channels; iSample += 1) {
6159 pBufferOut[iSample] = (drwav_int16)pWav->msadpcm.cachedFrames[(drwav_countof(pWav->msadpcm.cachedFrames) - (pWav->msadpcm.cachedFrameCount*pWav->channels)) + iSample];
6160 }
6161
6162 pBufferOut += pWav->channels;
6163 }
6164
6165 framesToRead -= 1;
6166 totalFramesRead += 1;
6167 pWav->readCursorInPCMFrames += 1;
6168 pWav->msadpcm.cachedFrameCount -= 1;
6169 }
6170
6171 if (framesToRead == 0) {
6172 break;
6173 }
6174
6175
6176 /*
6177 If there's nothing left in the cache, just go ahead and load more. If there's nothing left to load in the current block we just continue to the next
6178 loop iteration which will trigger the loading of a new block.
6179 */
6180 if (pWav->msadpcm.cachedFrameCount == 0) {
6181 if (pWav->msadpcm.bytesRemainingInBlock == 0) {
6182 continue;
6183 } else {
6184 static drwav_int32 adaptationTable[] = {
6185 230, 230, 230, 230, 307, 409, 512, 614,
6186 768, 614, 512, 409, 307, 230, 230, 230
6187 };
6188 static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460, 392 };
6189 static drwav_int32 coeff2Table[] = { 0, -256, 0, 64, 0, -208, -232 };
6190
6191 drwav_uint8 nibbles;
6192 drwav_int32 nibble0;
6193 drwav_int32 nibble1;
6194
6195 if (pWav->onRead(pWav->pUserData, &nibbles, 1) != 1) {
6196 return totalFramesRead;
6197 }
6198 pWav->msadpcm.bytesRemainingInBlock -= 1;
6199
6200 /* TODO: Optimize away these if statements. */
6201 nibble0 = ((nibbles & 0xF0) >> 4); if ((nibbles & 0x80)) { nibble0 |= 0xFFFFFFF0UL; }
6202 nibble1 = ((nibbles & 0x0F) >> 0); if ((nibbles & 0x08)) { nibble1 |= 0xFFFFFFF0UL; }
6203
6204 if (pWav->channels == 1) {
6205 /* Mono. */
6206 drwav_int32 newSample0;
6207 drwav_int32 newSample1;
6208
6209 newSample0 = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
6210 newSample0 += nibble0 * pWav->msadpcm.delta[0];
6211 newSample0 = drwav_clamp(newSample0, -32768, 32767);
6212
6213 pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
6214 if (pWav->msadpcm.delta[0] < 16) {
6215 pWav->msadpcm.delta[0] = 16;
6216 }
6217
6218 pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
6219 pWav->msadpcm.prevFrames[0][1] = newSample0;
6220
6221
6222 newSample1 = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
6223 newSample1 += nibble1 * pWav->msadpcm.delta[0];
6224 newSample1 = drwav_clamp(newSample1, -32768, 32767);
6225
6226 pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[0]) >> 8;
6227 if (pWav->msadpcm.delta[0] < 16) {
6228 pWav->msadpcm.delta[0] = 16;
6229 }
6230
6231 pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
6232 pWav->msadpcm.prevFrames[0][1] = newSample1;
6233
6234
6235 pWav->msadpcm.cachedFrames[2] = newSample0;
6236 pWav->msadpcm.cachedFrames[3] = newSample1;
6237 pWav->msadpcm.cachedFrameCount = 2;
6238 } else {
6239 /* Stereo. */
6240 drwav_int32 newSample0;
6241 drwav_int32 newSample1;
6242
6243 /* Left. */
6244 newSample0 = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
6245 newSample0 += nibble0 * pWav->msadpcm.delta[0];
6246 newSample0 = drwav_clamp(newSample0, -32768, 32767);
6247
6248 pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
6249 if (pWav->msadpcm.delta[0] < 16) {
6250 pWav->msadpcm.delta[0] = 16;
6251 }
6252
6253 pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
6254 pWav->msadpcm.prevFrames[0][1] = newSample0;
6255
6256
6257 /* Right. */
6258 newSample1 = ((pWav->msadpcm.prevFrames[1][1] * coeff1Table[pWav->msadpcm.predictor[1]]) + (pWav->msadpcm.prevFrames[1][0] * coeff2Table[pWav->msadpcm.predictor[1]])) >> 8;
6259 newSample1 += nibble1 * pWav->msadpcm.delta[1];
6260 newSample1 = drwav_clamp(newSample1, -32768, 32767);
6261
6262 pWav->msadpcm.delta[1] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[1]) >> 8;
6263 if (pWav->msadpcm.delta[1] < 16) {
6264 pWav->msadpcm.delta[1] = 16;
6265 }
6266
6267 pWav->msadpcm.prevFrames[1][0] = pWav->msadpcm.prevFrames[1][1];
6268 pWav->msadpcm.prevFrames[1][1] = newSample1;
6269
6270 pWav->msadpcm.cachedFrames[2] = newSample0;
6271 pWav->msadpcm.cachedFrames[3] = newSample1;
6272 pWav->msadpcm.cachedFrameCount = 1;
6273 }
6274 }
6275 }
6276 }
6277
6278 return totalFramesRead;
6279}
6280
6281
6282DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6283{
6284 drwav_uint64 totalFramesRead = 0;
6285 drwav_uint32 iChannel;
6286
6287 static drwav_int32 indexTable[16] = {
6288 -1, -1, -1, -1, 2, 4, 6, 8,
6289 -1, -1, -1, -1, 2, 4, 6, 8
6290 };
6291
6292 static drwav_int32 stepTable[89] = {
6293 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
6294 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
6295 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
6296 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
6297 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
6298 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
6299 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
6300 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
6301 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
6302 };
6303
6304 DRWAV_ASSERT(pWav != NULL);
6305 DRWAV_ASSERT(framesToRead > 0);
6306
6307 /* TODO: Lots of room for optimization here. */
6308
6309 while (pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) {
6310 DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
6311
6312 /* If there are no cached samples we need to load a new block. */
6313 if (pWav->ima.cachedFrameCount == 0 && pWav->ima.bytesRemainingInBlock == 0) {
6314 if (pWav->channels == 1) {
6315 /* Mono. */
6316 drwav_uint8 header[4];
6317 if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
6318 return totalFramesRead;
6319 }
6320 pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
6321
6322 if (header[2] >= drwav_countof(stepTable)) {
6323 pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
6324 pWav->ima.bytesRemainingInBlock = 0;
6325 return totalFramesRead; /* Invalid data. */
6326 }
6327
6328 pWav->ima.predictor[0] = (drwav_int16)drwav_bytes_to_u16(header + 0);
6329 pWav->ima.stepIndex[0] = drwav_clamp(header[2], 0, (drwav_int32)drwav_countof(stepTable)-1); /* Clamp not necessary because we checked above, but adding here to silence a static analysis warning. */
6330 pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[0];
6331 pWav->ima.cachedFrameCount = 1;
6332 } else {
6333 /* Stereo. */
6334 drwav_uint8 header[8];
6335 if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
6336 return totalFramesRead;
6337 }
6338 pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
6339
6340 if (header[2] >= drwav_countof(stepTable) || header[6] >= drwav_countof(stepTable)) {
6341 pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
6342 pWav->ima.bytesRemainingInBlock = 0;
6343 return totalFramesRead; /* Invalid data. */
6344 }
6345
6346 pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
6347 pWav->ima.stepIndex[0] = drwav_clamp(header[2], 0, (drwav_int32)drwav_countof(stepTable)-1); /* Clamp not necessary because we checked above, but adding here to silence a static analysis warning. */
6348 pWav->ima.predictor[1] = drwav_bytes_to_s16(header + 4);
6349 pWav->ima.stepIndex[1] = drwav_clamp(header[6], 0, (drwav_int32)drwav_countof(stepTable)-1); /* Clamp not necessary because we checked above, but adding here to silence a static analysis warning. */
6350
6351 pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 2] = pWav->ima.predictor[0];
6352 pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[1];
6353 pWav->ima.cachedFrameCount = 1;
6354 }
6355 }
6356
6357 /* Output anything that's cached. */
6358 while (framesToRead > 0 && pWav->ima.cachedFrameCount > 0 && pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) {
6359 if (pBufferOut != NULL) {
6360 drwav_uint32 iSample;
6361 for (iSample = 0; iSample < pWav->channels; iSample += 1) {
6362 pBufferOut[iSample] = (drwav_int16)pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + iSample];
6363 }
6364 pBufferOut += pWav->channels;
6365 }
6366
6367 framesToRead -= 1;
6368 totalFramesRead += 1;
6369 pWav->readCursorInPCMFrames += 1;
6370 pWav->ima.cachedFrameCount -= 1;
6371 }
6372
6373 if (framesToRead == 0) {
6374 break;
6375 }
6376
6377 /*
6378 If there's nothing left in the cache, just go ahead and load more. If there's nothing left to load in the current block we just continue to the next
6379 loop iteration which will trigger the loading of a new block.
6380 */
6381 if (pWav->ima.cachedFrameCount == 0) {
6382 if (pWav->ima.bytesRemainingInBlock == 0) {
6383 continue;
6384 } else {
6385 /*
6386 From what I can tell with stereo streams, it looks like every 4 bytes (8 samples) is for one channel. So it goes 4 bytes for the
6387 left channel, 4 bytes for the right channel.
6388 */
6389 pWav->ima.cachedFrameCount = 8;
6390 for (iChannel = 0; iChannel < pWav->channels; ++iChannel) {
6391 drwav_uint32 iByte;
6392 drwav_uint8 nibbles[4];
6393 if (pWav->onRead(pWav->pUserData, &nibbles, 4) != 4) {
6394 pWav->ima.cachedFrameCount = 0;
6395 return totalFramesRead;
6396 }
6397 pWav->ima.bytesRemainingInBlock -= 4;
6398
6399 for (iByte = 0; iByte < 4; ++iByte) {
6400 drwav_uint8 nibble0 = ((nibbles[iByte] & 0x0F) >> 0);
6401 drwav_uint8 nibble1 = ((nibbles[iByte] & 0xF0) >> 4);
6402
6403 drwav_int32 step = stepTable[pWav->ima.stepIndex[iChannel]];
6404 drwav_int32 predictor = pWav->ima.predictor[iChannel];
6405
6406 drwav_int32 diff = step >> 3;
6407 if (nibble0 & 1) diff += step >> 2;
6408 if (nibble0 & 2) diff += step >> 1;
6409 if (nibble0 & 4) diff += step;
6410 if (nibble0 & 8) diff = -diff;
6411
6412 predictor = drwav_clamp(predictor + diff, -32768, 32767);
6413 pWav->ima.predictor[iChannel] = predictor;
6414 pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble0], 0, (drwav_int32)drwav_countof(stepTable)-1);
6415 pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+0)*pWav->channels + iChannel] = predictor;
6416
6417
6418 step = stepTable[pWav->ima.stepIndex[iChannel]];
6419 predictor = pWav->ima.predictor[iChannel];
6420
6421 diff = step >> 3;
6422 if (nibble1 & 1) diff += step >> 2;
6423 if (nibble1 & 2) diff += step >> 1;
6424 if (nibble1 & 4) diff += step;
6425 if (nibble1 & 8) diff = -diff;
6426
6427 predictor = drwav_clamp(predictor + diff, -32768, 32767);
6428 pWav->ima.predictor[iChannel] = predictor;
6429 pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble1], 0, (drwav_int32)drwav_countof(stepTable)-1);
6430 pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+1)*pWav->channels + iChannel] = predictor;
6431 }
6432 }
6433 }
6434 }
6435 }
6436
6437 return totalFramesRead;
6438}
6439
6440
6441#ifndef DR_WAV_NO_CONVERSION_API
6442static unsigned short g_drwavAlawTable[256] = {
6443 0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80, 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580,
6444 0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0, 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0,
6445 0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600, 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600,
6446 0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00, 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00,
6447 0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8, 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58,
6448 0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8, 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58,
6449 0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60, 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960,
6450 0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0, 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0,
6451 0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280, 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80,
6452 0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940, 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40,
6453 0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00, 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00,
6454 0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500, 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500,
6455 0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128, 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8,
6456 0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028, 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8,
6457 0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0, 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0,
6458 0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250, 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
6459};
6460
6461static unsigned short g_drwavMulawTable[256] = {
6462 0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84, 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84,
6463 0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84, 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84,
6464 0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804, 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004,
6465 0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444, 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844,
6466 0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64, 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64,
6467 0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74, 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74,
6468 0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC, 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C,
6469 0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0, 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000,
6470 0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C, 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C,
6471 0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C, 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C,
6472 0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC, 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC,
6473 0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC, 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC,
6474 0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C, 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C,
6475 0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C, 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C,
6476 0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104, 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084,
6477 0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
6478};
6479
6480static DRWAV_INLINE drwav_int16 drwav__alaw_to_s16(drwav_uint8 sampleIn)
6481{
6482 return (short)g_drwavAlawTable[sampleIn];
6483}
6484
6485static DRWAV_INLINE drwav_int16 drwav__mulaw_to_s16(drwav_uint8 sampleIn)
6486{
6487 return (short)g_drwavMulawTable[sampleIn];
6488}
6489
6490
6491
6492DRWAV_PRIVATE void drwav__pcm_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
6493{
6494 size_t i;
6495
6496 /* Special case for 8-bit sample data because it's treated as unsigned. */
6497 if (bytesPerSample == 1) {
6498 drwav_u8_to_s16(pOut, pIn, totalSampleCount);
6499 return;
6500 }
6501
6502
6503 /* Slightly more optimal implementation for common formats. */
6504 if (bytesPerSample == 2) {
6505 for (i = 0; i < totalSampleCount; ++i) {
6506 *pOut++ = ((const drwav_int16*)pIn)[i];
6507 }
6508 return;
6509 }
6510 if (bytesPerSample == 3) {
6511 drwav_s24_to_s16(pOut, pIn, totalSampleCount);
6512 return;
6513 }
6514 if (bytesPerSample == 4) {
6515 drwav_s32_to_s16(pOut, (const drwav_int32*)pIn, totalSampleCount);
6516 return;
6517 }
6518
6519
6520 /* Anything more than 64 bits per sample is not supported. */
6521 if (bytesPerSample > 8) {
6522 DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
6523 return;
6524 }
6525
6526
6527 /* Generic, slow converter. */
6528 for (i = 0; i < totalSampleCount; ++i) {
6529 drwav_uint64 sample = 0;
6530 unsigned int shift = (8 - bytesPerSample) * 8;
6531
6532 unsigned int j;
6533 for (j = 0; j < bytesPerSample; j += 1) {
6534 DRWAV_ASSERT(j < 8);
6535 sample |= (drwav_uint64)(pIn[j]) << shift;
6536 shift += 8;
6537 }
6538
6539 pIn += j;
6540 *pOut++ = (drwav_int16)((drwav_int64)sample >> 48);
6541 }
6542}
6543
6544DRWAV_PRIVATE void drwav__ieee_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
6545{
6546 if (bytesPerSample == 4) {
6547 drwav_f32_to_s16(pOut, (const float*)pIn, totalSampleCount);
6548 return;
6549 } else if (bytesPerSample == 8) {
6550 drwav_f64_to_s16(pOut, (const double*)pIn, totalSampleCount);
6551 return;
6552 } else {
6553 /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
6554 DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
6555 return;
6556 }
6557}
6558
6559DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6560{
6561 drwav_uint64 totalFramesRead;
6562 drwav_uint8 sampleData[4096] = {0};
6563 drwav_uint32 bytesPerFrame;
6564 drwav_uint32 bytesPerSample;
6565 drwav_uint64 samplesRead;
6566
6567 /* Fast path. */
6568 if ((pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == NULL) {
6569 return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
6570 }
6571
6572 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
6573 if (bytesPerFrame == 0) {
6574 return 0;
6575 }
6576
6577 bytesPerSample = bytesPerFrame / pWav->channels;
6578 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
6579 return 0; /* Only byte-aligned formats are supported. */
6580 }
6581
6582 totalFramesRead = 0;
6583
6584 while (framesToRead > 0) {
6585 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
6586 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
6587 if (framesRead == 0) {
6588 break;
6589 }
6590
6591 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
6592
6593 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
6594 samplesRead = framesRead * pWav->channels;
6595 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
6596 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
6597 break;
6598 }
6599
6600 drwav__pcm_to_s16(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample);
6601
6602 pBufferOut += samplesRead;
6603 framesToRead -= framesRead;
6604 totalFramesRead += framesRead;
6605 }
6606
6607 return totalFramesRead;
6608}
6609
6610DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6611{
6612 drwav_uint64 totalFramesRead;
6613 drwav_uint8 sampleData[4096] = {0};
6614 drwav_uint32 bytesPerFrame;
6615 drwav_uint32 bytesPerSample;
6616 drwav_uint64 samplesRead;
6617
6618 if (pBufferOut == NULL) {
6619 return drwav_read_pcm_frames(pWav, framesToRead, NULL);
6620 }
6621
6622 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
6623 if (bytesPerFrame == 0) {
6624 return 0;
6625 }
6626
6627 bytesPerSample = bytesPerFrame / pWav->channels;
6628 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
6629 return 0; /* Only byte-aligned formats are supported. */
6630 }
6631
6632 totalFramesRead = 0;
6633
6634 while (framesToRead > 0) {
6635 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
6636 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
6637 if (framesRead == 0) {
6638 break;
6639 }
6640
6641 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
6642
6643 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
6644 samplesRead = framesRead * pWav->channels;
6645 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
6646 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
6647 break;
6648 }
6649
6650 drwav__ieee_to_s16(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample); /* Safe cast. */
6651
6652 pBufferOut += samplesRead;
6653 framesToRead -= framesRead;
6654 totalFramesRead += framesRead;
6655 }
6656
6657 return totalFramesRead;
6658}
6659
6660DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6661{
6662 drwav_uint64 totalFramesRead;
6663 drwav_uint8 sampleData[4096] = {0};
6664 drwav_uint32 bytesPerFrame;
6665 drwav_uint32 bytesPerSample;
6666 drwav_uint64 samplesRead;
6667
6668 if (pBufferOut == NULL) {
6669 return drwav_read_pcm_frames(pWav, framesToRead, NULL);
6670 }
6671
6672 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
6673 if (bytesPerFrame == 0) {
6674 return 0;
6675 }
6676
6677 bytesPerSample = bytesPerFrame / pWav->channels;
6678 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
6679 return 0; /* Only byte-aligned formats are supported. */
6680 }
6681
6682 totalFramesRead = 0;
6683
6684 while (framesToRead > 0) {
6685 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
6686 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
6687 if (framesRead == 0) {
6688 break;
6689 }
6690
6691 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
6692
6693 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
6694 samplesRead = framesRead * pWav->channels;
6695 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
6696 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
6697 break;
6698 }
6699
6700 drwav_alaw_to_s16(pBufferOut, sampleData, (size_t)samplesRead);
6701
6702 /*
6703 For some reason libsndfile seems to be returning samples of the opposite sign for a-law, but only
6704 with AIFF files. For WAV files it seems to be the same as dr_wav. This is resulting in dr_wav's
6705 automated tests failing. I'm not sure which is correct, but will assume dr_wav. If we're enforcing
6706 libsndfile compatibility we'll swap the signs here.
6707 */
6708 #ifdef DR_WAV_LIBSNDFILE_COMPAT
6709 {
6710 if (pWav->container == drwav_container_aiff) {
6711 drwav_uint64 iSample;
6712 for (iSample = 0; iSample < samplesRead; iSample += 1) {
6713 pBufferOut[iSample] = -pBufferOut[iSample];
6714 }
6715 }
6716 }
6717 #endif
6718
6719 pBufferOut += samplesRead;
6720 framesToRead -= framesRead;
6721 totalFramesRead += framesRead;
6722 }
6723
6724 return totalFramesRead;
6725}
6726
6727DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6728{
6729 drwav_uint64 totalFramesRead;
6730 drwav_uint8 sampleData[4096] = {0};
6731 drwav_uint32 bytesPerFrame;
6732 drwav_uint32 bytesPerSample;
6733 drwav_uint64 samplesRead;
6734
6735 if (pBufferOut == NULL) {
6736 return drwav_read_pcm_frames(pWav, framesToRead, NULL);
6737 }
6738
6739 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
6740 if (bytesPerFrame == 0) {
6741 return 0;
6742 }
6743
6744 bytesPerSample = bytesPerFrame / pWav->channels;
6745 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
6746 return 0; /* Only byte-aligned formats are supported. */
6747 }
6748
6749 totalFramesRead = 0;
6750
6751 while (framesToRead > 0) {
6752 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
6753 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
6754 if (framesRead == 0) {
6755 break;
6756 }
6757
6758 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
6759
6760 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
6761 samplesRead = framesRead * pWav->channels;
6762 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
6763 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
6764 break;
6765 }
6766
6767 drwav_mulaw_to_s16(pBufferOut, sampleData, (size_t)samplesRead);
6768
6769 /*
6770 Just like with alaw, for some reason the signs between libsndfile and dr_wav are opposite. We just need to
6771 swap the sign if we're compiling with libsndfile compatiblity so our automated tests don't fail.
6772 */
6773 #ifdef DR_WAV_LIBSNDFILE_COMPAT
6774 {
6775 if (pWav->container == drwav_container_aiff) {
6776 drwav_uint64 iSample;
6777 for (iSample = 0; iSample < samplesRead; iSample += 1) {
6778 pBufferOut[iSample] = -pBufferOut[iSample];
6779 }
6780 }
6781 }
6782 #endif
6783
6784 pBufferOut += samplesRead;
6785 framesToRead -= framesRead;
6786 totalFramesRead += framesRead;
6787 }
6788
6789 return totalFramesRead;
6790}
6791
6792DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6793{
6794 if (pWav == NULL || framesToRead == 0) {
6795 return 0;
6796 }
6797
6798 if (pBufferOut == NULL) {
6799 return drwav_read_pcm_frames(pWav, framesToRead, NULL);
6800 }
6801
6802 /* Don't try to read more samples than can potentially fit in the output buffer. */
6803 if (framesToRead * pWav->channels * sizeof(drwav_int16) > DRWAV_SIZE_MAX) {
6804 framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int16) / pWav->channels;
6805 }
6806
6807 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
6808 return drwav_read_pcm_frames_s16__pcm(pWav, framesToRead, pBufferOut);
6809 }
6810
6811 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
6812 return drwav_read_pcm_frames_s16__ieee(pWav, framesToRead, pBufferOut);
6813 }
6814
6815 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
6816 return drwav_read_pcm_frames_s16__alaw(pWav, framesToRead, pBufferOut);
6817 }
6818
6819 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
6820 return drwav_read_pcm_frames_s16__mulaw(pWav, framesToRead, pBufferOut);
6821 }
6822
6823 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
6824 return drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, pBufferOut);
6825 }
6826
6827 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
6828 return drwav_read_pcm_frames_s16__ima(pWav, framesToRead, pBufferOut);
6829 }
6830
6831 return 0;
6832}
6833
6834DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6835{
6836 drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
6837 if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
6838 drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
6839 }
6840
6841 return framesRead;
6842}
6843
6844DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
6845{
6846 drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
6847 if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
6848 drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
6849 }
6850
6851 return framesRead;
6852}
6853
6854
6855DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
6856{
6857 int r;
6858 size_t i;
6859 for (i = 0; i < sampleCount; ++i) {
6860 int x = pIn[i];
6861 r = x << 8;
6862 r = r - 32768;
6863 pOut[i] = (short)r;
6864 }
6865}
6866
6867DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
6868{
6869 int r;
6870 size_t i;
6871 for (i = 0; i < sampleCount; ++i) {
6872 int x = ((int)(((unsigned int)(((const drwav_uint8*)pIn)[i*3+0]) << 8) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+1]) << 16) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+2])) << 24)) >> 8;
6873 r = x >> 8;
6874 pOut[i] = (short)r;
6875 }
6876}
6877
6878DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount)
6879{
6880 int r;
6881 size_t i;
6882 for (i = 0; i < sampleCount; ++i) {
6883 int x = pIn[i];
6884 r = x >> 16;
6885 pOut[i] = (short)r;
6886 }
6887}
6888
6889DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount)
6890{
6891 int r;
6892 size_t i;
6893 for (i = 0; i < sampleCount; ++i) {
6894 float x = pIn[i];
6895 float c;
6896 c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
6897 c = c + 1;
6898 r = (int)(c * 32767.5f);
6899 r = r - 32768;
6900 pOut[i] = (short)r;
6901 }
6902}
6903
6904DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount)
6905{
6906 int r;
6907 size_t i;
6908 for (i = 0; i < sampleCount; ++i) {
6909 double x = pIn[i];
6910 double c;
6911 c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
6912 c = c + 1;
6913 r = (int)(c * 32767.5);
6914 r = r - 32768;
6915 pOut[i] = (short)r;
6916 }
6917}
6918
6919DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
6920{
6921 size_t i;
6922 for (i = 0; i < sampleCount; ++i) {
6923 pOut[i] = drwav__alaw_to_s16(pIn[i]);
6924 }
6925}
6926
6927DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
6928{
6929 size_t i;
6930 for (i = 0; i < sampleCount; ++i) {
6931 pOut[i] = drwav__mulaw_to_s16(pIn[i]);
6932 }
6933}
6934
6935
6936DRWAV_PRIVATE void drwav__pcm_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
6937{
6938 unsigned int i;
6939
6940 /* Special case for 8-bit sample data because it's treated as unsigned. */
6941 if (bytesPerSample == 1) {
6942 drwav_u8_to_f32(pOut, pIn, sampleCount);
6943 return;
6944 }
6945
6946 /* Slightly more optimal implementation for common formats. */
6947 if (bytesPerSample == 2) {
6948 drwav_s16_to_f32(pOut, (const drwav_int16*)pIn, sampleCount);
6949 return;
6950 }
6951 if (bytesPerSample == 3) {
6952 drwav_s24_to_f32(pOut, pIn, sampleCount);
6953 return;
6954 }
6955 if (bytesPerSample == 4) {
6956 drwav_s32_to_f32(pOut, (const drwav_int32*)pIn, sampleCount);
6957 return;
6958 }
6959
6960
6961 /* Anything more than 64 bits per sample is not supported. */
6962 if (bytesPerSample > 8) {
6963 DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
6964 return;
6965 }
6966
6967
6968 /* Generic, slow converter. */
6969 for (i = 0; i < sampleCount; ++i) {
6970 drwav_uint64 sample = 0;
6971 unsigned int shift = (8 - bytesPerSample) * 8;
6972
6973 unsigned int j;
6974 for (j = 0; j < bytesPerSample; j += 1) {
6975 DRWAV_ASSERT(j < 8);
6976 sample |= (drwav_uint64)(pIn[j]) << shift;
6977 shift += 8;
6978 }
6979
6980 pIn += j;
6981 *pOut++ = (float)((drwav_int64)sample / 9223372036854775807.0);
6982 }
6983}
6984
6985DRWAV_PRIVATE void drwav__ieee_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
6986{
6987 if (bytesPerSample == 4) {
6988 unsigned int i;
6989 for (i = 0; i < sampleCount; ++i) {
6990 *pOut++ = ((const float*)pIn)[i];
6991 }
6992 return;
6993 } else if (bytesPerSample == 8) {
6994 drwav_f64_to_f32(pOut, (const double*)pIn, sampleCount);
6995 return;
6996 } else {
6997 /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
6998 DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
6999 return;
7000 }
7001}
7002
7003
7004DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__pcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7005{
7006 drwav_uint64 totalFramesRead;
7007 drwav_uint8 sampleData[4096] = {0};
7008 drwav_uint32 bytesPerFrame;
7009 drwav_uint32 bytesPerSample;
7010 drwav_uint64 samplesRead;
7011
7012 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7013 if (bytesPerFrame == 0) {
7014 return 0;
7015 }
7016
7017 bytesPerSample = bytesPerFrame / pWav->channels;
7018 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7019 return 0; /* Only byte-aligned formats are supported. */
7020 }
7021
7022 totalFramesRead = 0;
7023
7024 while (framesToRead > 0) {
7025 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7026 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7027 if (framesRead == 0) {
7028 break;
7029 }
7030
7031 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7032
7033 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7034 samplesRead = framesRead * pWav->channels;
7035 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7036 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7037 break;
7038 }
7039
7040 drwav__pcm_to_f32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample);
7041
7042 pBufferOut += samplesRead;
7043 framesToRead -= framesRead;
7044 totalFramesRead += framesRead;
7045 }
7046
7047 return totalFramesRead;
7048}
7049
7050DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__msadpcm_ima(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7051{
7052 /*
7053 We're just going to borrow the implementation from the drwav_read_s16() since ADPCM is a little bit more complicated than other formats and I don't
7054 want to duplicate that code.
7055 */
7056 drwav_uint64 totalFramesRead;
7057 drwav_int16 samples16[2048];
7058
7059 totalFramesRead = 0;
7060
7061 while (framesToRead > 0) {
7062 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels);
7063 drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToReadThisIteration, samples16);
7064 if (framesRead == 0) {
7065 break;
7066 }
7067
7068 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7069
7070 drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels)); /* <-- Safe cast because we're clamping to 2048. */
7071
7072 pBufferOut += framesRead*pWav->channels;
7073 framesToRead -= framesRead;
7074 totalFramesRead += framesRead;
7075 }
7076
7077 return totalFramesRead;
7078}
7079
7080DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ieee(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7081{
7082 drwav_uint64 totalFramesRead;
7083 drwav_uint8 sampleData[4096] = {0};
7084 drwav_uint32 bytesPerFrame;
7085 drwav_uint32 bytesPerSample;
7086 drwav_uint64 samplesRead;
7087
7088 /* Fast path. */
7089 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT && pWav->bitsPerSample == 32) {
7090 return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
7091 }
7092
7093 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7094 if (bytesPerFrame == 0) {
7095 return 0;
7096 }
7097
7098 bytesPerSample = bytesPerFrame / pWav->channels;
7099 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7100 return 0; /* Only byte-aligned formats are supported. */
7101 }
7102
7103 totalFramesRead = 0;
7104
7105 while (framesToRead > 0) {
7106 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7107 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7108 if (framesRead == 0) {
7109 break;
7110 }
7111
7112 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7113
7114 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7115 samplesRead = framesRead * pWav->channels;
7116 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7117 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7118 break;
7119 }
7120
7121 drwav__ieee_to_f32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample);
7122
7123 pBufferOut += samplesRead;
7124 framesToRead -= framesRead;
7125 totalFramesRead += framesRead;
7126 }
7127
7128 return totalFramesRead;
7129}
7130
7131DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__alaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7132{
7133 drwav_uint64 totalFramesRead;
7134 drwav_uint8 sampleData[4096] = {0};
7135 drwav_uint32 bytesPerFrame;
7136 drwav_uint32 bytesPerSample;
7137 drwav_uint64 samplesRead;
7138
7139 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7140 if (bytesPerFrame == 0) {
7141 return 0;
7142 }
7143
7144 bytesPerSample = bytesPerFrame / pWav->channels;
7145 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7146 return 0; /* Only byte-aligned formats are supported. */
7147 }
7148
7149 totalFramesRead = 0;
7150
7151 while (framesToRead > 0) {
7152 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7153 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7154 if (framesRead == 0) {
7155 break;
7156 }
7157
7158 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7159
7160 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7161 samplesRead = framesRead * pWav->channels;
7162 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7163 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7164 break;
7165 }
7166
7167 drwav_alaw_to_f32(pBufferOut, sampleData, (size_t)samplesRead);
7168
7169 #ifdef DR_WAV_LIBSNDFILE_COMPAT
7170 {
7171 if (pWav->container == drwav_container_aiff) {
7172 drwav_uint64 iSample;
7173 for (iSample = 0; iSample < samplesRead; iSample += 1) {
7174 pBufferOut[iSample] = -pBufferOut[iSample];
7175 }
7176 }
7177 }
7178 #endif
7179
7180 pBufferOut += samplesRead;
7181 framesToRead -= framesRead;
7182 totalFramesRead += framesRead;
7183 }
7184
7185 return totalFramesRead;
7186}
7187
7188DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__mulaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7189{
7190 drwav_uint64 totalFramesRead;
7191 drwav_uint8 sampleData[4096] = {0};
7192 drwav_uint32 bytesPerFrame;
7193 drwav_uint32 bytesPerSample;
7194 drwav_uint64 samplesRead;
7195
7196 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7197 if (bytesPerFrame == 0) {
7198 return 0;
7199 }
7200
7201 bytesPerSample = bytesPerFrame / pWav->channels;
7202 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7203 return 0; /* Only byte-aligned formats are supported. */
7204 }
7205
7206 totalFramesRead = 0;
7207
7208 while (framesToRead > 0) {
7209 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7210 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7211 if (framesRead == 0) {
7212 break;
7213 }
7214
7215 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7216
7217 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7218 samplesRead = framesRead * pWav->channels;
7219 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7220 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7221 break;
7222 }
7223
7224 drwav_mulaw_to_f32(pBufferOut, sampleData, (size_t)samplesRead);
7225
7226 #ifdef DR_WAV_LIBSNDFILE_COMPAT
7227 {
7228 if (pWav->container == drwav_container_aiff) {
7229 drwav_uint64 iSample;
7230 for (iSample = 0; iSample < samplesRead; iSample += 1) {
7231 pBufferOut[iSample] = -pBufferOut[iSample];
7232 }
7233 }
7234 }
7235 #endif
7236
7237 pBufferOut += samplesRead;
7238 framesToRead -= framesRead;
7239 totalFramesRead += framesRead;
7240 }
7241
7242 return totalFramesRead;
7243}
7244
7245DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7246{
7247 if (pWav == NULL || framesToRead == 0) {
7248 return 0;
7249 }
7250
7251 if (pBufferOut == NULL) {
7252 return drwav_read_pcm_frames(pWav, framesToRead, NULL);
7253 }
7254
7255 /* Don't try to read more samples than can potentially fit in the output buffer. */
7256 if (framesToRead * pWav->channels * sizeof(float) > DRWAV_SIZE_MAX) {
7257 framesToRead = DRWAV_SIZE_MAX / sizeof(float) / pWav->channels;
7258 }
7259
7260 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
7261 return drwav_read_pcm_frames_f32__pcm(pWav, framesToRead, pBufferOut);
7262 }
7263
7264 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
7265 return drwav_read_pcm_frames_f32__msadpcm_ima(pWav, framesToRead, pBufferOut);
7266 }
7267
7268 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
7269 return drwav_read_pcm_frames_f32__ieee(pWav, framesToRead, pBufferOut);
7270 }
7271
7272 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
7273 return drwav_read_pcm_frames_f32__alaw(pWav, framesToRead, pBufferOut);
7274 }
7275
7276 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
7277 return drwav_read_pcm_frames_f32__mulaw(pWav, framesToRead, pBufferOut);
7278 }
7279
7280 return 0;
7281}
7282
7283DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7284{
7285 drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
7286 if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
7287 drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
7288 }
7289
7290 return framesRead;
7291}
7292
7293DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
7294{
7295 drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
7296 if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
7297 drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
7298 }
7299
7300 return framesRead;
7301}
7302
7303
7304DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
7305{
7306 size_t i;
7307
7308 if (pOut == NULL || pIn == NULL) {
7309 return;
7310 }
7311
7312#ifdef DR_WAV_LIBSNDFILE_COMPAT
7313 /*
7314 It appears libsndfile uses slightly different logic for the u8 -> f32 conversion to dr_wav, which in my opinion is incorrect. It appears
7315 libsndfile performs the conversion something like "f32 = (u8 / 256) * 2 - 1", however I think it should be "f32 = (u8 / 255) * 2 - 1" (note
7316 the divisor of 256 vs 255). I use libsndfile as a benchmark for testing, so I'm therefore leaving this block here just for my automated
7317 correctness testing. This is disabled by default.
7318 */
7319 for (i = 0; i < sampleCount; ++i) {
7320 *pOut++ = (pIn[i] / 256.0f) * 2 - 1;
7321 }
7322#else
7323 for (i = 0; i < sampleCount; ++i) {
7324 float x = pIn[i];
7325 x = x * 0.00784313725490196078f; /* 0..255 to 0..2 */
7326 x = x - 1; /* 0..2 to -1..1 */
7327
7328 *pOut++ = x;
7329 }
7330#endif
7331}
7332
7333DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount)
7334{
7335 size_t i;
7336
7337 if (pOut == NULL || pIn == NULL) {
7338 return;
7339 }
7340
7341 for (i = 0; i < sampleCount; ++i) {
7342 *pOut++ = pIn[i] * 0.000030517578125f;
7343 }
7344}
7345
7346DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
7347{
7348 size_t i;
7349
7350 if (pOut == NULL || pIn == NULL) {
7351 return;
7352 }
7353
7354 for (i = 0; i < sampleCount; ++i) {
7355 double x;
7356 drwav_uint32 a = ((drwav_uint32)(pIn[i*3+0]) << 8);
7357 drwav_uint32 b = ((drwav_uint32)(pIn[i*3+1]) << 16);
7358 drwav_uint32 c = ((drwav_uint32)(pIn[i*3+2]) << 24);
7359
7360 x = (double)((drwav_int32)(a | b | c) >> 8);
7361 *pOut++ = (float)(x * 0.00000011920928955078125);
7362 }
7363}
7364
7365DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount)
7366{
7367 size_t i;
7368 if (pOut == NULL || pIn == NULL) {
7369 return;
7370 }
7371
7372 for (i = 0; i < sampleCount; ++i) {
7373 *pOut++ = (float)(pIn[i] / 2147483648.0);
7374 }
7375}
7376
7377DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount)
7378{
7379 size_t i;
7380
7381 if (pOut == NULL || pIn == NULL) {
7382 return;
7383 }
7384
7385 for (i = 0; i < sampleCount; ++i) {
7386 *pOut++ = (float)pIn[i];
7387 }
7388}
7389
7390DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
7391{
7392 size_t i;
7393
7394 if (pOut == NULL || pIn == NULL) {
7395 return;
7396 }
7397
7398 for (i = 0; i < sampleCount; ++i) {
7399 *pOut++ = drwav__alaw_to_s16(pIn[i]) / 32768.0f;
7400 }
7401}
7402
7403DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
7404{
7405 size_t i;
7406
7407 if (pOut == NULL || pIn == NULL) {
7408 return;
7409 }
7410
7411 for (i = 0; i < sampleCount; ++i) {
7412 *pOut++ = drwav__mulaw_to_s16(pIn[i]) / 32768.0f;
7413 }
7414}
7415
7416
7417
7418DRWAV_PRIVATE void drwav__pcm_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
7419{
7420 unsigned int i;
7421
7422 /* Special case for 8-bit sample data because it's treated as unsigned. */
7423 if (bytesPerSample == 1) {
7424 drwav_u8_to_s32(pOut, pIn, totalSampleCount);
7425 return;
7426 }
7427
7428 /* Slightly more optimal implementation for common formats. */
7429 if (bytesPerSample == 2) {
7430 drwav_s16_to_s32(pOut, (const drwav_int16*)pIn, totalSampleCount);
7431 return;
7432 }
7433 if (bytesPerSample == 3) {
7434 drwav_s24_to_s32(pOut, pIn, totalSampleCount);
7435 return;
7436 }
7437 if (bytesPerSample == 4) {
7438 for (i = 0; i < totalSampleCount; ++i) {
7439 *pOut++ = ((const drwav_int32*)pIn)[i];
7440 }
7441 return;
7442 }
7443
7444
7445 /* Anything more than 64 bits per sample is not supported. */
7446 if (bytesPerSample > 8) {
7447 DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
7448 return;
7449 }
7450
7451
7452 /* Generic, slow converter. */
7453 for (i = 0; i < totalSampleCount; ++i) {
7454 drwav_uint64 sample = 0;
7455 unsigned int shift = (8 - bytesPerSample) * 8;
7456
7457 unsigned int j;
7458 for (j = 0; j < bytesPerSample; j += 1) {
7459 DRWAV_ASSERT(j < 8);
7460 sample |= (drwav_uint64)(pIn[j]) << shift;
7461 shift += 8;
7462 }
7463
7464 pIn += j;
7465 *pOut++ = (drwav_int32)((drwav_int64)sample >> 32);
7466 }
7467}
7468
7469DRWAV_PRIVATE void drwav__ieee_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
7470{
7471 if (bytesPerSample == 4) {
7472 drwav_f32_to_s32(pOut, (const float*)pIn, totalSampleCount);
7473 return;
7474 } else if (bytesPerSample == 8) {
7475 drwav_f64_to_s32(pOut, (const double*)pIn, totalSampleCount);
7476 return;
7477 } else {
7478 /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
7479 DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
7480 return;
7481 }
7482}
7483
7484
7485DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7486{
7487 drwav_uint64 totalFramesRead;
7488 drwav_uint8 sampleData[4096] = {0};
7489 drwav_uint32 bytesPerFrame;
7490 drwav_uint32 bytesPerSample;
7491 drwav_uint64 samplesRead;
7492
7493 /* Fast path. */
7494 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 32) {
7495 return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
7496 }
7497
7498 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7499 if (bytesPerFrame == 0) {
7500 return 0;
7501 }
7502
7503 bytesPerSample = bytesPerFrame / pWav->channels;
7504 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7505 return 0; /* Only byte-aligned formats are supported. */
7506 }
7507
7508 totalFramesRead = 0;
7509
7510 while (framesToRead > 0) {
7511 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7512 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7513 if (framesRead == 0) {
7514 break;
7515 }
7516
7517 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7518
7519 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7520 samplesRead = framesRead * pWav->channels;
7521 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7522 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7523 break;
7524 }
7525
7526 drwav__pcm_to_s32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample);
7527
7528 pBufferOut += samplesRead;
7529 framesToRead -= framesRead;
7530 totalFramesRead += framesRead;
7531 }
7532
7533 return totalFramesRead;
7534}
7535
7536DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__msadpcm_ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7537{
7538 /*
7539 We're just going to borrow the implementation from the drwav_read_s16() since ADPCM is a little bit more complicated than other formats and I don't
7540 want to duplicate that code.
7541 */
7542 drwav_uint64 totalFramesRead = 0;
7543 drwav_int16 samples16[2048];
7544
7545 while (framesToRead > 0) {
7546 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels);
7547 drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToReadThisIteration, samples16);
7548 if (framesRead == 0) {
7549 break;
7550 }
7551
7552 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7553
7554 drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels)); /* <-- Safe cast because we're clamping to 2048. */
7555
7556 pBufferOut += framesRead*pWav->channels;
7557 framesToRead -= framesRead;
7558 totalFramesRead += framesRead;
7559 }
7560
7561 return totalFramesRead;
7562}
7563
7564DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7565{
7566 drwav_uint64 totalFramesRead;
7567 drwav_uint8 sampleData[4096] = {0};
7568 drwav_uint32 bytesPerFrame;
7569 drwav_uint32 bytesPerSample;
7570 drwav_uint64 samplesRead;
7571
7572 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7573 if (bytesPerFrame == 0) {
7574 return 0;
7575 }
7576
7577 bytesPerSample = bytesPerFrame / pWav->channels;
7578 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7579 return 0; /* Only byte-aligned formats are supported. */
7580 }
7581
7582 totalFramesRead = 0;
7583
7584 while (framesToRead > 0) {
7585 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7586 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7587 if (framesRead == 0) {
7588 break;
7589 }
7590
7591 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7592
7593 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7594 samplesRead = framesRead * pWav->channels;
7595 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7596 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7597 break;
7598 }
7599
7600 drwav__ieee_to_s32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample);
7601
7602 pBufferOut += samplesRead;
7603 framesToRead -= framesRead;
7604 totalFramesRead += framesRead;
7605 }
7606
7607 return totalFramesRead;
7608}
7609
7610DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7611{
7612 drwav_uint64 totalFramesRead;
7613 drwav_uint8 sampleData[4096] = {0};
7614 drwav_uint32 bytesPerFrame;
7615 drwav_uint32 bytesPerSample;
7616 drwav_uint64 samplesRead;
7617
7618 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7619 if (bytesPerFrame == 0) {
7620 return 0;
7621 }
7622
7623 bytesPerSample = bytesPerFrame / pWav->channels;
7624 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7625 return 0; /* Only byte-aligned formats are supported. */
7626 }
7627
7628 totalFramesRead = 0;
7629
7630 while (framesToRead > 0) {
7631 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7632 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7633 if (framesRead == 0) {
7634 break;
7635 }
7636
7637 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7638
7639 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7640 samplesRead = framesRead * pWav->channels;
7641 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7642 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7643 break;
7644 }
7645
7646 drwav_alaw_to_s32(pBufferOut, sampleData, (size_t)samplesRead);
7647
7648 #ifdef DR_WAV_LIBSNDFILE_COMPAT
7649 {
7650 if (pWav->container == drwav_container_aiff) {
7651 drwav_uint64 iSample;
7652 for (iSample = 0; iSample < samplesRead; iSample += 1) {
7653 pBufferOut[iSample] = -pBufferOut[iSample];
7654 }
7655 }
7656 }
7657 #endif
7658
7659 pBufferOut += samplesRead;
7660 framesToRead -= framesRead;
7661 totalFramesRead += framesRead;
7662 }
7663
7664 return totalFramesRead;
7665}
7666
7667DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7668{
7669 drwav_uint64 totalFramesRead;
7670 drwav_uint8 sampleData[4096] = {0};
7671 drwav_uint32 bytesPerFrame;
7672 drwav_uint32 bytesPerSample;
7673 drwav_uint64 samplesRead;
7674
7675 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
7676 if (bytesPerFrame == 0) {
7677 return 0;
7678 }
7679
7680 bytesPerSample = bytesPerFrame / pWav->channels;
7681 if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) {
7682 return 0; /* Only byte-aligned formats are supported. */
7683 }
7684
7685 totalFramesRead = 0;
7686
7687 while (framesToRead > 0) {
7688 drwav_uint64 framesToReadThisIteration = drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame);
7689 drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData);
7690 if (framesRead == 0) {
7691 break;
7692 }
7693
7694 DRWAV_ASSERT(framesRead <= framesToReadThisIteration); /* If this fails it means there's a bug in drwav_read_pcm_frames(). */
7695
7696 /* Validation to ensure we don't read too much from out intermediary buffer. This is to protect from invalid files. */
7697 samplesRead = framesRead * pWav->channels;
7698 if ((samplesRead * bytesPerSample) > sizeof(sampleData)) {
7699 DRWAV_ASSERT(DRWAV_FALSE); /* This should never happen with a valid file. */
7700 break;
7701 }
7702
7703 drwav_mulaw_to_s32(pBufferOut, sampleData, (size_t)samplesRead);
7704
7705 #ifdef DR_WAV_LIBSNDFILE_COMPAT
7706 {
7707 if (pWav->container == drwav_container_aiff) {
7708 drwav_uint64 iSample;
7709 for (iSample = 0; iSample < samplesRead; iSample += 1) {
7710 pBufferOut[iSample] = -pBufferOut[iSample];
7711 }
7712 }
7713 }
7714 #endif
7715
7716 pBufferOut += samplesRead;
7717 framesToRead -= framesRead;
7718 totalFramesRead += framesRead;
7719 }
7720
7721 return totalFramesRead;
7722}
7723
7724DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7725{
7726 if (pWav == NULL || framesToRead == 0) {
7727 return 0;
7728 }
7729
7730 if (pBufferOut == NULL) {
7731 return drwav_read_pcm_frames(pWav, framesToRead, NULL);
7732 }
7733
7734 /* Don't try to read more samples than can potentially fit in the output buffer. */
7735 if (framesToRead * pWav->channels * sizeof(drwav_int32) > DRWAV_SIZE_MAX) {
7736 framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int32) / pWav->channels;
7737 }
7738
7739 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
7740 return drwav_read_pcm_frames_s32__pcm(pWav, framesToRead, pBufferOut);
7741 }
7742
7743 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
7744 return drwav_read_pcm_frames_s32__msadpcm_ima(pWav, framesToRead, pBufferOut);
7745 }
7746
7747 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
7748 return drwav_read_pcm_frames_s32__ieee(pWav, framesToRead, pBufferOut);
7749 }
7750
7751 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
7752 return drwav_read_pcm_frames_s32__alaw(pWav, framesToRead, pBufferOut);
7753 }
7754
7755 if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
7756 return drwav_read_pcm_frames_s32__mulaw(pWav, framesToRead, pBufferOut);
7757 }
7758
7759 return 0;
7760}
7761
7762DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7763{
7764 drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
7765 if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
7766 drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
7767 }
7768
7769 return framesRead;
7770}
7771
7772DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
7773{
7774 drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
7775 if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
7776 drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
7777 }
7778
7779 return framesRead;
7780}
7781
7782
7783DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
7784{
7785 size_t i;
7786
7787 if (pOut == NULL || pIn == NULL) {
7788 return;
7789 }
7790
7791 for (i = 0; i < sampleCount; ++i) {
7792 *pOut++ = ((int)pIn[i] - 128) << 24;
7793 }
7794}
7795
7796DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount)
7797{
7798 size_t i;
7799
7800 if (pOut == NULL || pIn == NULL) {
7801 return;
7802 }
7803
7804 for (i = 0; i < sampleCount; ++i) {
7805 *pOut++ = pIn[i] << 16;
7806 }
7807}
7808
7809DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
7810{
7811 size_t i;
7812
7813 if (pOut == NULL || pIn == NULL) {
7814 return;
7815 }
7816
7817 for (i = 0; i < sampleCount; ++i) {
7818 unsigned int s0 = pIn[i*3 + 0];
7819 unsigned int s1 = pIn[i*3 + 1];
7820 unsigned int s2 = pIn[i*3 + 2];
7821
7822 drwav_int32 sample32 = (drwav_int32)((s0 << 8) | (s1 << 16) | (s2 << 24));
7823 *pOut++ = sample32;
7824 }
7825}
7826
7827DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount)
7828{
7829 size_t i;
7830
7831 if (pOut == NULL || pIn == NULL) {
7832 return;
7833 }
7834
7835 for (i = 0; i < sampleCount; ++i) {
7836 *pOut++ = (drwav_int32)(2147483648.0f * pIn[i]);
7837 }
7838}
7839
7840DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount)
7841{
7842 size_t i;
7843
7844 if (pOut == NULL || pIn == NULL) {
7845 return;
7846 }
7847
7848 for (i = 0; i < sampleCount; ++i) {
7849 *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
7850 }
7851}
7852
7853DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
7854{
7855 size_t i;
7856
7857 if (pOut == NULL || pIn == NULL) {
7858 return;
7859 }
7860
7861 for (i = 0; i < sampleCount; ++i) {
7862 *pOut++ = ((drwav_int32)drwav__alaw_to_s16(pIn[i])) << 16;
7863 }
7864}
7865
7866DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
7867{
7868 size_t i;
7869
7870 if (pOut == NULL || pIn == NULL) {
7871 return;
7872 }
7873
7874 for (i= 0; i < sampleCount; ++i) {
7875 *pOut++ = ((drwav_int32)drwav__mulaw_to_s16(pIn[i])) << 16;
7876 }
7877}
7878
7879
7880
7881DRWAV_PRIVATE drwav_int16* drwav__read_pcm_frames_and_close_s16(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
7882{
7883 drwav_uint64 sampleDataSize;
7884 drwav_int16* pSampleData;
7885 drwav_uint64 framesRead;
7886
7887 DRWAV_ASSERT(pWav != NULL);
7888
7889 sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int16);
7890 if (sampleDataSize > DRWAV_SIZE_MAX) {
7891 drwav_uninit(pWav);
7892 return NULL; /* File's too big. */
7893 }
7894
7895 pSampleData = (drwav_int16*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
7896 if (pSampleData == NULL) {
7897 drwav_uninit(pWav);
7898 return NULL; /* Failed to allocate memory. */
7899 }
7900
7901 framesRead = drwav_read_pcm_frames_s16(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
7902 if (framesRead != pWav->totalPCMFrameCount) {
7903 drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
7904 drwav_uninit(pWav);
7905 return NULL; /* There was an error reading the samples. */
7906 }
7907
7908 drwav_uninit(pWav);
7909
7910 if (sampleRate) {
7911 *sampleRate = pWav->sampleRate;
7912 }
7913 if (channels) {
7914 *channels = pWav->channels;
7915 }
7916 if (totalFrameCount) {
7917 *totalFrameCount = pWav->totalPCMFrameCount;
7918 }
7919
7920 return pSampleData;
7921}
7922
7923DRWAV_PRIVATE float* drwav__read_pcm_frames_and_close_f32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
7924{
7925 drwav_uint64 sampleDataSize;
7926 float* pSampleData;
7927 drwav_uint64 framesRead;
7928
7929 DRWAV_ASSERT(pWav != NULL);
7930
7931 sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(float);
7932 if (sampleDataSize > DRWAV_SIZE_MAX) {
7933 drwav_uninit(pWav);
7934 return NULL; /* File's too big. */
7935 }
7936
7937 pSampleData = (float*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
7938 if (pSampleData == NULL) {
7939 drwav_uninit(pWav);
7940 return NULL; /* Failed to allocate memory. */
7941 }
7942
7943 framesRead = drwav_read_pcm_frames_f32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
7944 if (framesRead != pWav->totalPCMFrameCount) {
7945 drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
7946 drwav_uninit(pWav);
7947 return NULL; /* There was an error reading the samples. */
7948 }
7949
7950 drwav_uninit(pWav);
7951
7952 if (sampleRate) {
7953 *sampleRate = pWav->sampleRate;
7954 }
7955 if (channels) {
7956 *channels = pWav->channels;
7957 }
7958 if (totalFrameCount) {
7959 *totalFrameCount = pWav->totalPCMFrameCount;
7960 }
7961
7962 return pSampleData;
7963}
7964
7965DRWAV_PRIVATE drwav_int32* drwav__read_pcm_frames_and_close_s32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
7966{
7967 drwav_uint64 sampleDataSize;
7968 drwav_int32* pSampleData;
7969 drwav_uint64 framesRead;
7970
7971 DRWAV_ASSERT(pWav != NULL);
7972
7973 sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int32);
7974 if (sampleDataSize > DRWAV_SIZE_MAX) {
7975 drwav_uninit(pWav);
7976 return NULL; /* File's too big. */
7977 }
7978
7979 pSampleData = (drwav_int32*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
7980 if (pSampleData == NULL) {
7981 drwav_uninit(pWav);
7982 return NULL; /* Failed to allocate memory. */
7983 }
7984
7985 framesRead = drwav_read_pcm_frames_s32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
7986 if (framesRead != pWav->totalPCMFrameCount) {
7987 drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
7988 drwav_uninit(pWav);
7989 return NULL; /* There was an error reading the samples. */
7990 }
7991
7992 drwav_uninit(pWav);
7993
7994 if (sampleRate) {
7995 *sampleRate = pWav->sampleRate;
7996 }
7997 if (channels) {
7998 *channels = pWav->channels;
7999 }
8000 if (totalFrameCount) {
8001 *totalFrameCount = pWav->totalPCMFrameCount;
8002 }
8003
8004 return pSampleData;
8005}
8006
8007
8008
8009DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8010{
8011 drwav wav;
8012
8013 if (channelsOut) {
8014 *channelsOut = 0;
8015 }
8016 if (sampleRateOut) {
8017 *sampleRateOut = 0;
8018 }
8019 if (totalFrameCountOut) {
8020 *totalFrameCountOut = 0;
8021 }
8022
8023 if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
8024 return NULL;
8025 }
8026
8027 return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8028}
8029
8030DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8031{
8032 drwav wav;
8033
8034 if (channelsOut) {
8035 *channelsOut = 0;
8036 }
8037 if (sampleRateOut) {
8038 *sampleRateOut = 0;
8039 }
8040 if (totalFrameCountOut) {
8041 *totalFrameCountOut = 0;
8042 }
8043
8044 if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
8045 return NULL;
8046 }
8047
8048 return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8049}
8050
8051DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8052{
8053 drwav wav;
8054
8055 if (channelsOut) {
8056 *channelsOut = 0;
8057 }
8058 if (sampleRateOut) {
8059 *sampleRateOut = 0;
8060 }
8061 if (totalFrameCountOut) {
8062 *totalFrameCountOut = 0;
8063 }
8064
8065 if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
8066 return NULL;
8067 }
8068
8069 return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8070}
8071
8072#ifndef DR_WAV_NO_STDIO
8073DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8074{
8075 drwav wav;
8076
8077 if (channelsOut) {
8078 *channelsOut = 0;
8079 }
8080 if (sampleRateOut) {
8081 *sampleRateOut = 0;
8082 }
8083 if (totalFrameCountOut) {
8084 *totalFrameCountOut = 0;
8085 }
8086
8087 if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
8088 return NULL;
8089 }
8090
8091 return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8092}
8093
8094DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8095{
8096 drwav wav;
8097
8098 if (channelsOut) {
8099 *channelsOut = 0;
8100 }
8101 if (sampleRateOut) {
8102 *sampleRateOut = 0;
8103 }
8104 if (totalFrameCountOut) {
8105 *totalFrameCountOut = 0;
8106 }
8107
8108 if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
8109 return NULL;
8110 }
8111
8112 return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8113}
8114
8115DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8116{
8117 drwav wav;
8118
8119 if (channelsOut) {
8120 *channelsOut = 0;
8121 }
8122 if (sampleRateOut) {
8123 *sampleRateOut = 0;
8124 }
8125 if (totalFrameCountOut) {
8126 *totalFrameCountOut = 0;
8127 }
8128
8129 if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
8130 return NULL;
8131 }
8132
8133 return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8134}
8135
8136
8137#ifndef DR_WAV_NO_WCHAR
8138DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8139{
8140 drwav wav;
8141
8142 if (sampleRateOut) {
8143 *sampleRateOut = 0;
8144 }
8145 if (channelsOut) {
8146 *channelsOut = 0;
8147 }
8148 if (totalFrameCountOut) {
8149 *totalFrameCountOut = 0;
8150 }
8151
8152 if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
8153 return NULL;
8154 }
8155
8156 return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8157}
8158
8159DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8160{
8161 drwav wav;
8162
8163 if (sampleRateOut) {
8164 *sampleRateOut = 0;
8165 }
8166 if (channelsOut) {
8167 *channelsOut = 0;
8168 }
8169 if (totalFrameCountOut) {
8170 *totalFrameCountOut = 0;
8171 }
8172
8173 if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
8174 return NULL;
8175 }
8176
8177 return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8178}
8179
8180DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8181{
8182 drwav wav;
8183
8184 if (sampleRateOut) {
8185 *sampleRateOut = 0;
8186 }
8187 if (channelsOut) {
8188 *channelsOut = 0;
8189 }
8190 if (totalFrameCountOut) {
8191 *totalFrameCountOut = 0;
8192 }
8193
8194 if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
8195 return NULL;
8196 }
8197
8198 return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8199}
8200#endif /* DR_WAV_NO_WCHAR */
8201#endif /* DR_WAV_NO_STDIO */
8202
8203DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8204{
8205 drwav wav;
8206
8207 if (channelsOut) {
8208 *channelsOut = 0;
8209 }
8210 if (sampleRateOut) {
8211 *sampleRateOut = 0;
8212 }
8213 if (totalFrameCountOut) {
8214 *totalFrameCountOut = 0;
8215 }
8216
8217 if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
8218 return NULL;
8219 }
8220
8221 return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8222}
8223
8224DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8225{
8226 drwav wav;
8227
8228 if (channelsOut) {
8229 *channelsOut = 0;
8230 }
8231 if (sampleRateOut) {
8232 *sampleRateOut = 0;
8233 }
8234 if (totalFrameCountOut) {
8235 *totalFrameCountOut = 0;
8236 }
8237
8238 if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
8239 return NULL;
8240 }
8241
8242 return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8243}
8244
8245DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
8246{
8247 drwav wav;
8248
8249 if (channelsOut) {
8250 *channelsOut = 0;
8251 }
8252 if (sampleRateOut) {
8253 *sampleRateOut = 0;
8254 }
8255 if (totalFrameCountOut) {
8256 *totalFrameCountOut = 0;
8257 }
8258
8259 if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
8260 return NULL;
8261 }
8262
8263 return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
8264}
8265#endif /* DR_WAV_NO_CONVERSION_API */
8266
8267
8268DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
8269{
8270 if (pAllocationCallbacks != NULL) {
8271 drwav__free_from_callbacks(p, pAllocationCallbacks);
8272 } else {
8273 drwav__free_default(p, NULL);
8274 }
8275}
8276
8277DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data)
8278{
8279 return ((drwav_uint16)data[0] << 0) | ((drwav_uint16)data[1] << 8);
8280}
8281
8282DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data)
8283{
8284 return (drwav_int16)drwav_bytes_to_u16(data);
8285}
8286
8287DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data)
8288{
8289 return drwav_bytes_to_u32_le(data);
8290}
8291
8292DRWAV_API float drwav_bytes_to_f32(const drwav_uint8* data)
8293{
8294 union {
8295 drwav_uint32 u32;
8296 float f32;
8297 } value;
8298
8299 value.u32 = drwav_bytes_to_u32(data);
8300 return value.f32;
8301}
8302
8303DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data)
8304{
8305 return (drwav_int32)drwav_bytes_to_u32(data);
8306}
8307
8308DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data)
8309{
8310 return
8311 ((drwav_uint64)data[0] << 0) | ((drwav_uint64)data[1] << 8) | ((drwav_uint64)data[2] << 16) | ((drwav_uint64)data[3] << 24) |
8312 ((drwav_uint64)data[4] << 32) | ((drwav_uint64)data[5] << 40) | ((drwav_uint64)data[6] << 48) | ((drwav_uint64)data[7] << 56);
8313}
8314
8315DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data)
8316{
8317 return (drwav_int64)drwav_bytes_to_u64(data);
8318}
8319
8320
8321DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16])
8322{
8323 int i;
8324 for (i = 0; i < 16; i += 1) {
8325 if (a[i] != b[i]) {
8326 return DRWAV_FALSE;
8327 }
8328 }
8329
8330 return DRWAV_TRUE;
8331}
8332
8333DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
8334{
8335 return
8336 a[0] == b[0] &&
8337 a[1] == b[1] &&
8338 a[2] == b[2] &&
8339 a[3] == b[3];
8340}
8341
8342#ifdef __MRC__
8343/* Undo the pragma at the beginning of this file. */
8344#pragma options opt reset
8345#endif
8346
8347#endif /* dr_wav_c */
8348#endif /* DR_WAV_IMPLEMENTATION */
8349
8350/*
8351REVISION HISTORY
8352================
8353v0.13.16 - 2024-02-27
8354 - Fix a Wdouble-promotion warning.
8355
8356v0.13.15 - 2024-01-23
8357 - Relax some unnecessary validation that prevented some files from loading.
8358
8359v0.13.14 - 2023-12-02
8360 - Fix a warning about an unused variable.
8361
8362v0.13.13 - 2023-11-02
8363 - Fix a warning when compiling with Clang.
8364
8365v0.13.12 - 2023-08-07
8366 - Fix a possible crash in drwav_read_pcm_frames().
8367
8368v0.13.11 - 2023-07-07
8369 - AIFF compatibility improvements.
8370
8371v0.13.10 - 2023-05-29
8372 - Fix a bug where drwav_init_with_metadata() does not decode any frames after initializtion.
8373
8374v0.13.9 - 2023-05-22
8375 - Add support for AIFF decoding (writing and metadata not supported).
8376 - Add support for RIFX decoding (writing and metadata not supported).
8377 - Fix a bug where metadata is not processed if it's located before the "fmt " chunk.
8378 - Add a workaround for a type of malformed WAV file where the size of the "RIFF" and "data" chunks
8379 are incorrectly set to 0xFFFFFFFF.
8380
8381v0.13.8 - 2023-03-25
8382 - Fix a possible null pointer dereference.
8383 - Fix a crash when loading files with badly formed metadata.
8384
8385v0.13.7 - 2022-09-17
8386 - Fix compilation with DJGPP.
8387 - Add support for disabling wchar_t with DR_WAV_NO_WCHAR.
8388
8389v0.13.6 - 2022-04-10
8390 - Fix compilation error on older versions of GCC.
8391 - Remove some dependencies on the standard library.
8392
8393v0.13.5 - 2022-01-26
8394 - Fix an error when seeking to the end of the file.
8395
8396v0.13.4 - 2021-12-08
8397 - Fix some static analysis warnings.
8398
8399v0.13.3 - 2021-11-24
8400 - Fix an incorrect assertion when trying to endian swap 1-byte sample formats. This is now a no-op
8401 rather than a failed assertion.
8402 - Fix a bug with parsing of the bext chunk.
8403 - Fix some static analysis warnings.
8404
8405v0.13.2 - 2021-10-02
8406 - Fix a possible buffer overflow when reading from compressed formats.
8407
8408v0.13.1 - 2021-07-31
8409 - Fix platform detection for ARM64.
8410
8411v0.13.0 - 2021-07-01
8412 - Improve support for reading and writing metadata. Use the `_with_metadata()` APIs to initialize
8413 a WAV decoder and store the metadata within the `drwav` object. Use the `pMetadata` and
8414 `metadataCount` members of the `drwav` object to read the data. The old way of handling metadata
8415 via a callback is still usable and valid.
8416 - API CHANGE: drwav_target_write_size_bytes() now takes extra parameters for calculating the
8417 required write size when writing metadata.
8418 - Add drwav_get_cursor_in_pcm_frames()
8419 - Add drwav_get_length_in_pcm_frames()
8420 - Fix a bug where drwav_read_raw() can call the read callback with a byte count of zero.
8421
8422v0.12.20 - 2021-06-11
8423 - Fix some undefined behavior.
8424
8425v0.12.19 - 2021-02-21
8426 - Fix a warning due to referencing _MSC_VER when it is undefined.
8427 - Minor improvements to the management of some internal state concerning the data chunk cursor.
8428
8429v0.12.18 - 2021-01-31
8430 - Clean up some static analysis warnings.
8431
8432v0.12.17 - 2021-01-17
8433 - Minor fix to sample code in documentation.
8434 - Correctly qualify a private API as private rather than public.
8435 - Code cleanup.
8436
8437v0.12.16 - 2020-12-02
8438 - Fix a bug when trying to read more bytes than can fit in a size_t.
8439
8440v0.12.15 - 2020-11-21
8441 - Fix compilation with OpenWatcom.
8442
8443v0.12.14 - 2020-11-13
8444 - Minor code clean up.
8445
8446v0.12.13 - 2020-11-01
8447 - Improve compiler support for older versions of GCC.
8448
8449v0.12.12 - 2020-09-28
8450 - Add support for RF64.
8451 - Fix a bug in writing mode where the size of the RIFF chunk incorrectly includes the header section.
8452
8453v0.12.11 - 2020-09-08
8454 - Fix a compilation error on older compilers.
8455
8456v0.12.10 - 2020-08-24
8457 - Fix a bug when seeking with ADPCM formats.
8458
8459v0.12.9 - 2020-08-02
8460 - Simplify sized types.
8461
8462v0.12.8 - 2020-07-25
8463 - Fix a compilation warning.
8464
8465v0.12.7 - 2020-07-15
8466 - Fix some bugs on big-endian architectures.
8467 - Fix an error in s24 to f32 conversion.
8468
8469v0.12.6 - 2020-06-23
8470 - Change drwav_read_*() to allow NULL to be passed in as the output buffer which is equivalent to a forward seek.
8471 - Fix a buffer overflow when trying to decode invalid IMA-ADPCM files.
8472 - Add include guard for the implementation section.
8473
8474v0.12.5 - 2020-05-27
8475 - Minor documentation fix.
8476
8477v0.12.4 - 2020-05-16
8478 - Replace assert() with DRWAV_ASSERT().
8479 - Add compile-time and run-time version querying.
8480 - DRWAV_VERSION_MINOR
8481 - DRWAV_VERSION_MAJOR
8482 - DRWAV_VERSION_REVISION
8483 - DRWAV_VERSION_STRING
8484 - drwav_version()
8485 - drwav_version_string()
8486
8487v0.12.3 - 2020-04-30
8488 - Fix compilation errors with VC6.
8489
8490v0.12.2 - 2020-04-21
8491 - Fix a bug where drwav_init_file() does not close the file handle after attempting to load an erroneous file.
8492
8493v0.12.1 - 2020-04-13
8494 - Fix some pedantic warnings.
8495
8496v0.12.0 - 2020-04-04
8497 - API CHANGE: Add container and format parameters to the chunk callback.
8498 - Minor documentation updates.
8499
8500v0.11.5 - 2020-03-07
8501 - Fix compilation error with Visual Studio .NET 2003.
8502
8503v0.11.4 - 2020-01-29
8504 - Fix some static analysis warnings.
8505 - Fix a bug when reading f32 samples from an A-law encoded stream.
8506
8507v0.11.3 - 2020-01-12
8508 - Minor changes to some f32 format conversion routines.
8509 - Minor bug fix for ADPCM conversion when end of file is reached.
8510
8511v0.11.2 - 2019-12-02
8512 - Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
8513 - Fix an integer overflow bug.
8514 - Fix a null pointer dereference bug.
8515 - Add limits to sample rate, channels and bits per sample to tighten up some validation.
8516
8517v0.11.1 - 2019-10-07
8518 - Internal code clean up.
8519
8520v0.11.0 - 2019-10-06
8521 - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
8522 routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
8523 - drwav_init()
8524 - drwav_init_ex()
8525 - drwav_init_file()
8526 - drwav_init_file_ex()
8527 - drwav_init_file_w()
8528 - drwav_init_file_w_ex()
8529 - drwav_init_memory()
8530 - drwav_init_memory_ex()
8531 - drwav_init_write()
8532 - drwav_init_write_sequential()
8533 - drwav_init_write_sequential_pcm_frames()
8534 - drwav_init_file_write()
8535 - drwav_init_file_write_sequential()
8536 - drwav_init_file_write_sequential_pcm_frames()
8537 - drwav_init_file_write_w()
8538 - drwav_init_file_write_sequential_w()
8539 - drwav_init_file_write_sequential_pcm_frames_w()
8540 - drwav_init_memory_write()
8541 - drwav_init_memory_write_sequential()
8542 - drwav_init_memory_write_sequential_pcm_frames()
8543 - drwav_open_and_read_pcm_frames_s16()
8544 - drwav_open_and_read_pcm_frames_f32()
8545 - drwav_open_and_read_pcm_frames_s32()
8546 - drwav_open_file_and_read_pcm_frames_s16()
8547 - drwav_open_file_and_read_pcm_frames_f32()
8548 - drwav_open_file_and_read_pcm_frames_s32()
8549 - drwav_open_file_and_read_pcm_frames_s16_w()
8550 - drwav_open_file_and_read_pcm_frames_f32_w()
8551 - drwav_open_file_and_read_pcm_frames_s32_w()
8552 - drwav_open_memory_and_read_pcm_frames_s16()
8553 - drwav_open_memory_and_read_pcm_frames_f32()
8554 - drwav_open_memory_and_read_pcm_frames_s32()
8555 Set this extra parameter to NULL to use defaults which is the same as the previous behaviour. Setting this NULL will use
8556 DRWAV_MALLOC, DRWAV_REALLOC and DRWAV_FREE.
8557 - Add support for reading and writing PCM frames in an explicit endianness. New APIs:
8558 - drwav_read_pcm_frames_le()
8559 - drwav_read_pcm_frames_be()
8560 - drwav_read_pcm_frames_s16le()
8561 - drwav_read_pcm_frames_s16be()
8562 - drwav_read_pcm_frames_f32le()
8563 - drwav_read_pcm_frames_f32be()
8564 - drwav_read_pcm_frames_s32le()
8565 - drwav_read_pcm_frames_s32be()
8566 - drwav_write_pcm_frames_le()
8567 - drwav_write_pcm_frames_be()
8568 - Remove deprecated APIs.
8569 - API CHANGE: The following APIs now return native-endian data. Previously they returned little-endian data.
8570 - drwav_read_pcm_frames()
8571 - drwav_read_pcm_frames_s16()
8572 - drwav_read_pcm_frames_s32()
8573 - drwav_read_pcm_frames_f32()
8574 - drwav_open_and_read_pcm_frames_s16()
8575 - drwav_open_and_read_pcm_frames_s32()
8576 - drwav_open_and_read_pcm_frames_f32()
8577 - drwav_open_file_and_read_pcm_frames_s16()
8578 - drwav_open_file_and_read_pcm_frames_s32()
8579 - drwav_open_file_and_read_pcm_frames_f32()
8580 - drwav_open_file_and_read_pcm_frames_s16_w()
8581 - drwav_open_file_and_read_pcm_frames_s32_w()
8582 - drwav_open_file_and_read_pcm_frames_f32_w()
8583 - drwav_open_memory_and_read_pcm_frames_s16()
8584 - drwav_open_memory_and_read_pcm_frames_s32()
8585 - drwav_open_memory_and_read_pcm_frames_f32()
8586
8587v0.10.1 - 2019-08-31
8588 - Correctly handle partial trailing ADPCM blocks.
8589
8590v0.10.0 - 2019-08-04
8591 - Remove deprecated APIs.
8592 - Add wchar_t variants for file loading APIs:
8593 drwav_init_file_w()
8594 drwav_init_file_ex_w()
8595 drwav_init_file_write_w()
8596 drwav_init_file_write_sequential_w()
8597 - Add drwav_target_write_size_bytes() which calculates the total size in bytes of a WAV file given a format and sample count.
8598 - Add APIs for specifying the PCM frame count instead of the sample count when opening in sequential write mode:
8599 drwav_init_write_sequential_pcm_frames()
8600 drwav_init_file_write_sequential_pcm_frames()
8601 drwav_init_file_write_sequential_pcm_frames_w()
8602 drwav_init_memory_write_sequential_pcm_frames()
8603 - Deprecate drwav_open*() and drwav_close():
8604 drwav_open()
8605 drwav_open_ex()
8606 drwav_open_write()
8607 drwav_open_write_sequential()
8608 drwav_open_file()
8609 drwav_open_file_ex()
8610 drwav_open_file_write()
8611 drwav_open_file_write_sequential()
8612 drwav_open_memory()
8613 drwav_open_memory_ex()
8614 drwav_open_memory_write()
8615 drwav_open_memory_write_sequential()
8616 drwav_close()
8617 - Minor documentation updates.
8618
8619v0.9.2 - 2019-05-21
8620 - Fix warnings.
8621
8622v0.9.1 - 2019-05-05
8623 - Add support for C89.
8624 - Change license to choice of public domain or MIT-0.
8625
8626v0.9.0 - 2018-12-16
8627 - API CHANGE: Add new reading APIs for reading by PCM frames instead of samples. Old APIs have been deprecated and
8628 will be removed in v0.10.0. Deprecated APIs and their replacements:
8629 drwav_read() -> drwav_read_pcm_frames()
8630 drwav_read_s16() -> drwav_read_pcm_frames_s16()
8631 drwav_read_f32() -> drwav_read_pcm_frames_f32()
8632 drwav_read_s32() -> drwav_read_pcm_frames_s32()
8633 drwav_seek_to_sample() -> drwav_seek_to_pcm_frame()
8634 drwav_write() -> drwav_write_pcm_frames()
8635 drwav_open_and_read_s16() -> drwav_open_and_read_pcm_frames_s16()
8636 drwav_open_and_read_f32() -> drwav_open_and_read_pcm_frames_f32()
8637 drwav_open_and_read_s32() -> drwav_open_and_read_pcm_frames_s32()
8638 drwav_open_file_and_read_s16() -> drwav_open_file_and_read_pcm_frames_s16()
8639 drwav_open_file_and_read_f32() -> drwav_open_file_and_read_pcm_frames_f32()
8640 drwav_open_file_and_read_s32() -> drwav_open_file_and_read_pcm_frames_s32()
8641 drwav_open_memory_and_read_s16() -> drwav_open_memory_and_read_pcm_frames_s16()
8642 drwav_open_memory_and_read_f32() -> drwav_open_memory_and_read_pcm_frames_f32()
8643 drwav_open_memory_and_read_s32() -> drwav_open_memory_and_read_pcm_frames_s32()
8644 drwav::totalSampleCount -> drwav::totalPCMFrameCount
8645 - API CHANGE: Rename drwav_open_and_read_file_*() to drwav_open_file_and_read_*().
8646 - API CHANGE: Rename drwav_open_and_read_memory_*() to drwav_open_memory_and_read_*().
8647 - Add built-in support for smpl chunks.
8648 - Add support for firing a callback for each chunk in the file at initialization time.
8649 - This is enabled through the drwav_init_ex(), etc. family of APIs.
8650 - Handle invalid FMT chunks more robustly.
8651
8652v0.8.5 - 2018-09-11
8653 - Const correctness.
8654 - Fix a potential stack overflow.
8655
8656v0.8.4 - 2018-08-07
8657 - Improve 64-bit detection.
8658
8659v0.8.3 - 2018-08-05
8660 - Fix C++ build on older versions of GCC.
8661
8662v0.8.2 - 2018-08-02
8663 - Fix some big-endian bugs.
8664
8665v0.8.1 - 2018-06-29
8666 - Add support for sequential writing APIs.
8667 - Disable seeking in write mode.
8668 - Fix bugs with Wave64.
8669 - Fix typos.
8670
8671v0.8 - 2018-04-27
8672 - Bug fix.
8673 - Start using major.minor.revision versioning.
8674
8675v0.7f - 2018-02-05
8676 - Restrict ADPCM formats to a maximum of 2 channels.
8677
8678v0.7e - 2018-02-02
8679 - Fix a crash.
8680
8681v0.7d - 2018-02-01
8682 - Fix a crash.
8683
8684v0.7c - 2018-02-01
8685 - Set drwav.bytesPerSample to 0 for all compressed formats.
8686 - Fix a crash when reading 16-bit floating point WAV files. In this case dr_wav will output silence for
8687 all format conversion reading APIs (*_s16, *_s32, *_f32 APIs).
8688 - Fix some divide-by-zero errors.
8689
8690v0.7b - 2018-01-22
8691 - Fix errors with seeking of compressed formats.
8692 - Fix compilation error when DR_WAV_NO_CONVERSION_API
8693
8694v0.7a - 2017-11-17
8695 - Fix some GCC warnings.
8696
8697v0.7 - 2017-11-04
8698 - Add writing APIs.
8699
8700v0.6 - 2017-08-16
8701 - API CHANGE: Rename dr_* types to drwav_*.
8702 - Add support for custom implementations of malloc(), realloc(), etc.
8703 - Add support for Microsoft ADPCM.
8704 - Add support for IMA ADPCM (DVI, format code 0x11).
8705 - Optimizations to drwav_read_s16().
8706 - Bug fixes.
8707
8708v0.5g - 2017-07-16
8709 - Change underlying type for booleans to unsigned.
8710
8711v0.5f - 2017-04-04
8712 - Fix a minor bug with drwav_open_and_read_s16() and family.
8713
8714v0.5e - 2016-12-29
8715 - Added support for reading samples as signed 16-bit integers. Use the _s16() family of APIs for this.
8716 - Minor fixes to documentation.
8717
8718v0.5d - 2016-12-28
8719 - Use drwav_int* and drwav_uint* sized types to improve compiler support.
8720
8721v0.5c - 2016-11-11
8722 - Properly handle JUNK chunks that come before the FMT chunk.
8723
8724v0.5b - 2016-10-23
8725 - A minor change to drwav_bool8 and drwav_bool32 types.
8726
8727v0.5a - 2016-10-11
8728 - Fixed a bug with drwav_open_and_read() and family due to incorrect argument ordering.
8729 - Improve A-law and mu-law efficiency.
8730
8731v0.5 - 2016-09-29
8732 - API CHANGE. Swap the order of "channels" and "sampleRate" parameters in drwav_open_and_read*(). Rationale for this is to
8733 keep it consistent with dr_audio and dr_flac.
8734
8735v0.4b - 2016-09-18
8736 - Fixed a typo in documentation.
8737
8738v0.4a - 2016-09-18
8739 - Fixed a typo.
8740 - Change date format to ISO 8601 (YYYY-MM-DD)
8741
8742v0.4 - 2016-07-13
8743 - API CHANGE. Make onSeek consistent with dr_flac.
8744 - API CHANGE. Rename drwav_seek() to drwav_seek_to_sample() for clarity and consistency with dr_flac.
8745 - Added support for Sony Wave64.
8746
8747v0.3a - 2016-05-28
8748 - API CHANGE. Return drwav_bool32 instead of int in onSeek callback.
8749 - Fixed a memory leak.
8750
8751v0.3 - 2016-05-22
8752 - Lots of API changes for consistency.
8753
8754v0.2a - 2016-05-16
8755 - Fixed Linux/GCC build.
8756
8757v0.2 - 2016-05-11
8758 - Added support for reading data as signed 32-bit PCM for consistency with dr_flac.
8759
8760v0.1a - 2016-05-07
8761 - Fixed a bug in drwav_open_file() where the file handle would not be closed if the loader failed to initialize.
8762
8763v0.1 - 2016-05-04
8764 - Initial versioned release.
8765*/
8766
8767/*
8768This software is available as a choice of the following licenses. Choose
8769whichever you prefer.
8770
8771===============================================================================
8772ALTERNATIVE 1 - Public Domain (www.unlicense.org)
8773===============================================================================
8774This is free and unencumbered software released into the public domain.
8775
8776Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
8777software, either in source code form or as a compiled binary, for any purpose,
8778commercial or non-commercial, and by any means.
8779
8780In jurisdictions that recognize copyright laws, the author or authors of this
8781software dedicate any and all copyright interest in the software to the public
8782domain. We make this dedication for the benefit of the public at large and to
8783the detriment of our heirs and successors. We intend this dedication to be an
8784overt act of relinquishment in perpetuity of all present and future rights to
8785this software under copyright law.
8786
8787THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8788IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8789FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8790AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
8791ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
8792WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8793
8794For more information, please refer to <http://unlicense.org/>
8795
8796===============================================================================
8797ALTERNATIVE 2 - MIT No Attribution
8798===============================================================================
8799Copyright 2023 David Reid
8800
8801Permission is hereby granted, free of charge, to any person obtaining a copy of
8802this software and associated documentation files (the "Software"), to deal in
8803the Software without restriction, including without limitation the rights to
8804use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8805of the Software, and to permit persons to whom the Software is furnished to do
8806so.
8807
8808THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8809IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8810FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8811AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8812LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8813OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8814SOFTWARE.
8815*/
diff --git a/raylib/src/external/glad.h b/raylib/src/external/glad.h
new file mode 100644
index 0000000..5bb79d4
--- /dev/null
+++ b/raylib/src/external/glad.h
@@ -0,0 +1,8682 @@
1/**
2 * Loader generated by glad 2.0.0-beta on Sun Sep 18 18:12:12 2022
3 *
4 * Generator: C/C++
5 * Specification: gl
6 * Extensions: 116
7 *
8 * APIs:
9 * - gl:core=4.3
10 *
11 * Options:
12 * - ALIAS = False
13 * - DEBUG = False
14 * - HEADER_ONLY = True
15 * - LOADER = False
16 * - MX = False
17 * - MX_GLOBAL = False
18 * - ON_DEMAND = False
19 *
20 * Commandline:
21 * --api='gl:core=4.3' --extensions='GL_ARB_ES2_compatibility,GL_ARB_ES3_1_compatibility,GL_ARB_ES3_2_compatibility,GL_ARB_ES3_compatibility,GL_ARB_blend_func_extended,GL_ARB_buffer_storage,GL_ARB_clear_buffer_object,GL_ARB_clear_texture,GL_ARB_color_buffer_float,GL_ARB_compatibility,GL_ARB_compressed_texture_pixel_storage,GL_ARB_compute_shader,GL_ARB_compute_variable_group_size,GL_ARB_copy_buffer,GL_ARB_copy_image,GL_ARB_debug_output,GL_ARB_depth_buffer_float,GL_ARB_depth_clamp,GL_ARB_depth_texture,GL_ARB_direct_state_access,GL_ARB_draw_buffers,GL_ARB_draw_buffers_blend,GL_ARB_draw_elements_base_vertex,GL_ARB_draw_indirect,GL_ARB_draw_instanced,GL_ARB_enhanced_layouts,GL_ARB_explicit_attrib_location,GL_ARB_explicit_uniform_location,GL_ARB_fragment_coord_conventions,GL_ARB_fragment_layer_viewport,GL_ARB_fragment_program,GL_ARB_fragment_program_shadow,GL_ARB_fragment_shader,GL_ARB_fragment_shader_interlock,GL_ARB_framebuffer_no_attachments,GL_ARB_framebuffer_object,GL_ARB_framebuffer_sRGB,GL_ARB_geometry_shader4,GL_ARB_get_program_binary,GL_ARB_get_texture_sub_image,GL_ARB_gl_spirv,GL_ARB_gpu_shader5,GL_ARB_gpu_shader_fp64,GL_ARB_gpu_shader_int64,GL_ARB_half_float_pixel,GL_ARB_half_float_vertex,GL_ARB_instanced_arrays,GL_ARB_internalformat_query,GL_ARB_internalformat_query2,GL_ARB_map_buffer_range,GL_ARB_multi_bind,GL_ARB_multi_draw_indirect,GL_ARB_multisample,GL_ARB_multitexture,GL_ARB_occlusion_query,GL_ARB_occlusion_query2,GL_ARB_pipeline_statistics_query,GL_ARB_query_buffer_object,GL_ARB_sample_locations,GL_ARB_sample_shading,GL_ARB_seamless_cube_map,GL_ARB_seamless_cubemap_per_texture,GL_ARB_shader_atomic_counter_ops,GL_ARB_shader_atomic_counters,GL_ARB_shader_bit_encoding,GL_ARB_shader_clock,GL_ARB_shader_image_load_store,GL_ARB_shader_image_size,GL_ARB_shader_objects,GL_ARB_shader_storage_buffer_object,GL_ARB_shader_texture_lod,GL_ARB_shading_language_100,GL_ARB_shading_language_420pack,GL_ARB_shading_language_include,GL_ARB_shading_language_packing,GL_ARB_spirv_extensions,GL_ARB_tessellation_shader,GL_ARB_texture_border_clamp,GL_ARB_texture_buffer_object_rgb32,GL_ARB_texture_compression,GL_ARB_texture_cube_map,GL_ARB_texture_cube_map_array,GL_ARB_texture_env_add,GL_ARB_texture_filter_anisotropic,GL_ARB_texture_filter_minmax,GL_ARB_texture_float,GL_ARB_texture_mirror_clamp_to_edge,GL_ARB_texture_mirrored_repeat,GL_ARB_texture_multisample,GL_ARB_texture_non_power_of_two,GL_ARB_texture_rg,GL_ARB_texture_storage,GL_ARB_texture_swizzle,GL_ARB_texture_view,GL_ARB_timer_query,GL_ARB_transpose_matrix,GL_ARB_uniform_buffer_object,GL_ARB_vertex_array_bgra,GL_ARB_vertex_array_object,GL_ARB_vertex_attrib_binding,GL_ARB_vertex_buffer_object,GL_ARB_vertex_program,GL_ARB_vertex_shader,GL_EXT_draw_instanced,GL_EXT_fog_coord,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_object,GL_EXT_framebuffer_sRGB,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_mirror_clamp,GL_KHR_texture_compression_astc_hdr,GL_KHR_texture_compression_astc_ldr,GL_OES_compressed_paletted_texture,GL_OES_fixed_point' c --header-only
22 *
23 * Online:
24 * http://glad.sh/#api=gl%3Acore%3D4.3&generator=c&options=HEADER_ONLY
25 *
26 */
27
28#ifndef GLAD_GL_H_
29#define GLAD_GL_H_
30
31#ifdef __clang__
32#pragma clang diagnostic push
33#pragma clang diagnostic ignored "-Wreserved-id-macro"
34#endif
35#ifdef __gl_h_
36 #error OpenGL (gl.h) header already included (API: gl), remove previous include!
37#endif
38#define __gl_h_ 1
39#ifdef __gl3_h_
40 #error OpenGL (gl3.h) header already included (API: gl), remove previous include!
41#endif
42#define __gl3_h_ 1
43#ifdef __glext_h_
44 #error OpenGL (glext.h) header already included (API: gl), remove previous include!
45#endif
46#define __glext_h_ 1
47#ifdef __gl3ext_h_
48 #error OpenGL (gl3ext.h) header already included (API: gl), remove previous include!
49#endif
50#define __gl3ext_h_ 1
51#ifdef __clang__
52#pragma clang diagnostic pop
53#endif
54
55#define GLAD_GL
56#define GLAD_OPTION_GL_HEADER_ONLY
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62#ifndef GLAD_PLATFORM_H_
63#define GLAD_PLATFORM_H_
64
65#ifndef GLAD_PLATFORM_WIN32
66 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
67 #define GLAD_PLATFORM_WIN32 1
68 #else
69 #define GLAD_PLATFORM_WIN32 0
70 #endif
71#endif
72
73#ifndef GLAD_PLATFORM_APPLE
74 #ifdef __APPLE__
75 #define GLAD_PLATFORM_APPLE 1
76 #else
77 #define GLAD_PLATFORM_APPLE 0
78 #endif
79#endif
80
81#ifndef GLAD_PLATFORM_EMSCRIPTEN
82 #ifdef __EMSCRIPTEN__
83 #define GLAD_PLATFORM_EMSCRIPTEN 1
84 #else
85 #define GLAD_PLATFORM_EMSCRIPTEN 0
86 #endif
87#endif
88
89#ifndef GLAD_PLATFORM_UWP
90 #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
91 #ifdef __has_include
92 #if __has_include(<winapifamily.h>)
93 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
94 #endif
95 #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
96 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
97 #endif
98 #endif
99
100 #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
101 #include <winapifamily.h>
102 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
103 #define GLAD_PLATFORM_UWP 1
104 #endif
105 #endif
106
107 #ifndef GLAD_PLATFORM_UWP
108 #define GLAD_PLATFORM_UWP 0
109 #endif
110#endif
111
112#ifdef __GNUC__
113 #define GLAD_GNUC_EXTENSION __extension__
114#else
115 #define GLAD_GNUC_EXTENSION
116#endif
117
118#ifndef GLAD_API_CALL
119 #if defined(GLAD_API_CALL_EXPORT)
120 #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
121 #if defined(GLAD_API_CALL_EXPORT_BUILD)
122 #if defined(__GNUC__)
123 #define GLAD_API_CALL __attribute__ ((dllexport)) extern
124 #else
125 #define GLAD_API_CALL __declspec(dllexport) extern
126 #endif
127 #else
128 #if defined(__GNUC__)
129 #define GLAD_API_CALL __attribute__ ((dllimport)) extern
130 #else
131 #define GLAD_API_CALL __declspec(dllimport) extern
132 #endif
133 #endif
134 #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
135 #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
136 #else
137 #define GLAD_API_CALL extern
138 #endif
139 #else
140 #define GLAD_API_CALL extern
141 #endif
142#endif
143
144#ifdef APIENTRY
145 #define GLAD_API_PTR APIENTRY
146#elif GLAD_PLATFORM_WIN32
147 #define GLAD_API_PTR __stdcall
148#else
149 #define GLAD_API_PTR
150#endif
151
152#ifndef GLAPI
153#define GLAPI GLAD_API_CALL
154#endif
155
156#ifndef GLAPIENTRY
157#define GLAPIENTRY GLAD_API_PTR
158#endif
159
160#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
161#define GLAD_VERSION_MAJOR(version) (version / 10000)
162#define GLAD_VERSION_MINOR(version) (version % 10000)
163
164#define GLAD_GENERATOR_VERSION "2.0.0-beta"
165
166typedef void (*GLADapiproc)(void);
167
168typedef GLADapiproc (*GLADloadfunc)(const char *name);
169typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
170
171typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
172typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
173
174#endif /* GLAD_PLATFORM_H_ */
175
176#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9
177#define GL_ACTIVE_ATTRIBUTES 0x8B89
178#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
179#define GL_ACTIVE_PROGRAM 0x8259
180#define GL_ACTIVE_RESOURCES 0x92F5
181#define GL_ACTIVE_SUBROUTINES 0x8DE5
182#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48
183#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6
184#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47
185#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49
186#define GL_ACTIVE_TEXTURE 0x84E0
187#define GL_ACTIVE_TEXTURE_ARB 0x84E0
188#define GL_ACTIVE_UNIFORMS 0x8B86
189#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
190#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
191#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
192#define GL_ACTIVE_VARIABLES 0x9305
193#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
194#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
195#define GL_ALL_SHADER_BITS 0xFFFFFFFF
196#define GL_ALPHA 0x1906
197#define GL_ALPHA16F_ARB 0x881C
198#define GL_ALPHA32F_ARB 0x8816
199#define GL_ALREADY_SIGNALED 0x911A
200#define GL_ALWAYS 0x0207
201#define GL_AND 0x1501
202#define GL_AND_INVERTED 0x1504
203#define GL_AND_REVERSE 0x1502
204#define GL_ANY_SAMPLES_PASSED 0x8C2F
205#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
206#define GL_ARRAY_BUFFER 0x8892
207#define GL_ARRAY_BUFFER_ARB 0x8892
208#define GL_ARRAY_BUFFER_BINDING 0x8894
209#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
210#define GL_ARRAY_SIZE 0x92FB
211#define GL_ARRAY_STRIDE 0x92FE
212#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
213#define GL_ATOMIC_COUNTER_BUFFER 0x92C0
214#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5
215#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6
216#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1
217#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4
218#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301
219#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED
220#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB
221#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA
222#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8
223#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9
224#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7
225#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3
226#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2
227#define GL_ATTACHED_SHADERS 0x8B85
228#define GL_AUTO_GENERATE_MIPMAP 0x8295
229#define GL_BACK 0x0405
230#define GL_BACK_LEFT 0x0402
231#define GL_BACK_RIGHT 0x0403
232#define GL_BGR 0x80E0
233#define GL_BGRA 0x80E1
234#define GL_BGRA_INTEGER 0x8D9B
235#define GL_BGR_INTEGER 0x8D9A
236#define GL_BLEND 0x0BE2
237#define GL_BLEND_COLOR 0x8005
238#define GL_BLEND_DST 0x0BE0
239#define GL_BLEND_DST_ALPHA 0x80CA
240#define GL_BLEND_DST_RGB 0x80C8
241#define GL_BLEND_EQUATION 0x8009
242#define GL_BLEND_EQUATION_ALPHA 0x883D
243#define GL_BLEND_EQUATION_RGB 0x8009
244#define GL_BLEND_SRC 0x0BE1
245#define GL_BLEND_SRC_ALPHA 0x80CB
246#define GL_BLEND_SRC_RGB 0x80C9
247#define GL_BLOCK_INDEX 0x92FD
248#define GL_BLUE 0x1905
249#define GL_BLUE_INTEGER 0x8D96
250#define GL_BOOL 0x8B56
251#define GL_BOOL_ARB 0x8B56
252#define GL_BOOL_VEC2 0x8B57
253#define GL_BOOL_VEC2_ARB 0x8B57
254#define GL_BOOL_VEC3 0x8B58
255#define GL_BOOL_VEC3_ARB 0x8B58
256#define GL_BOOL_VEC4 0x8B59
257#define GL_BOOL_VEC4_ARB 0x8B59
258#define GL_BUFFER 0x82E0
259#define GL_BUFFER_ACCESS 0x88BB
260#define GL_BUFFER_ACCESS_ARB 0x88BB
261#define GL_BUFFER_ACCESS_FLAGS 0x911F
262#define GL_BUFFER_BINDING 0x9302
263#define GL_BUFFER_DATA_SIZE 0x9303
264#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F
265#define GL_BUFFER_MAPPED 0x88BC
266#define GL_BUFFER_MAPPED_ARB 0x88BC
267#define GL_BUFFER_MAP_LENGTH 0x9120
268#define GL_BUFFER_MAP_OFFSET 0x9121
269#define GL_BUFFER_MAP_POINTER 0x88BD
270#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
271#define GL_BUFFER_SIZE 0x8764
272#define GL_BUFFER_SIZE_ARB 0x8764
273#define GL_BUFFER_STORAGE_FLAGS 0x8220
274#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
275#define GL_BUFFER_USAGE 0x8765
276#define GL_BUFFER_USAGE_ARB 0x8765
277#define GL_BUFFER_VARIABLE 0x92E5
278#define GL_BYTE 0x1400
279#define GL_CAVEAT_SUPPORT 0x82B8
280#define GL_CCW 0x0901
281#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
282#define GL_CLAMP_READ_COLOR 0x891C
283#define GL_CLAMP_READ_COLOR_ARB 0x891C
284#define GL_CLAMP_TO_BORDER 0x812D
285#define GL_CLAMP_TO_BORDER_ARB 0x812D
286#define GL_CLAMP_TO_EDGE 0x812F
287#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
288#define GL_CLEAR 0x1500
289#define GL_CLEAR_BUFFER 0x82B4
290#define GL_CLEAR_TEXTURE 0x9365
291#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
292#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000
293#define GL_CLIENT_STORAGE_BIT 0x0200
294#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6
295#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6
296#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7
297#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7
298#define GL_CLIP_DISTANCE0 0x3000
299#define GL_CLIP_DISTANCE1 0x3001
300#define GL_CLIP_DISTANCE2 0x3002
301#define GL_CLIP_DISTANCE3 0x3003
302#define GL_CLIP_DISTANCE4 0x3004
303#define GL_CLIP_DISTANCE5 0x3005
304#define GL_CLIP_DISTANCE6 0x3006
305#define GL_CLIP_DISTANCE7 0x3007
306#define GL_COLOR 0x1800
307#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
308#define GL_COLOR_ATTACHMENT0 0x8CE0
309#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
310#define GL_COLOR_ATTACHMENT1 0x8CE1
311#define GL_COLOR_ATTACHMENT10 0x8CEA
312#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
313#define GL_COLOR_ATTACHMENT11 0x8CEB
314#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
315#define GL_COLOR_ATTACHMENT12 0x8CEC
316#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
317#define GL_COLOR_ATTACHMENT13 0x8CED
318#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
319#define GL_COLOR_ATTACHMENT14 0x8CEE
320#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
321#define GL_COLOR_ATTACHMENT15 0x8CEF
322#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
323#define GL_COLOR_ATTACHMENT16 0x8CF0
324#define GL_COLOR_ATTACHMENT17 0x8CF1
325#define GL_COLOR_ATTACHMENT18 0x8CF2
326#define GL_COLOR_ATTACHMENT19 0x8CF3
327#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
328#define GL_COLOR_ATTACHMENT2 0x8CE2
329#define GL_COLOR_ATTACHMENT20 0x8CF4
330#define GL_COLOR_ATTACHMENT21 0x8CF5
331#define GL_COLOR_ATTACHMENT22 0x8CF6
332#define GL_COLOR_ATTACHMENT23 0x8CF7
333#define GL_COLOR_ATTACHMENT24 0x8CF8
334#define GL_COLOR_ATTACHMENT25 0x8CF9
335#define GL_COLOR_ATTACHMENT26 0x8CFA
336#define GL_COLOR_ATTACHMENT27 0x8CFB
337#define GL_COLOR_ATTACHMENT28 0x8CFC
338#define GL_COLOR_ATTACHMENT29 0x8CFD
339#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
340#define GL_COLOR_ATTACHMENT3 0x8CE3
341#define GL_COLOR_ATTACHMENT30 0x8CFE
342#define GL_COLOR_ATTACHMENT31 0x8CFF
343#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
344#define GL_COLOR_ATTACHMENT4 0x8CE4
345#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
346#define GL_COLOR_ATTACHMENT5 0x8CE5
347#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
348#define GL_COLOR_ATTACHMENT6 0x8CE6
349#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
350#define GL_COLOR_ATTACHMENT7 0x8CE7
351#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
352#define GL_COLOR_ATTACHMENT8 0x8CE8
353#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
354#define GL_COLOR_ATTACHMENT9 0x8CE9
355#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
356#define GL_COLOR_BUFFER_BIT 0x00004000
357#define GL_COLOR_CLEAR_VALUE 0x0C22
358#define GL_COLOR_COMPONENTS 0x8283
359#define GL_COLOR_ENCODING 0x8296
360#define GL_COLOR_LOGIC_OP 0x0BF2
361#define GL_COLOR_RENDERABLE 0x8286
362#define GL_COLOR_SUM_ARB 0x8458
363#define GL_COLOR_WRITEMASK 0x0C23
364#define GL_COMMAND_BARRIER_BIT 0x00000040
365#define GL_COMPARE_REF_TO_TEXTURE 0x884E
366#define GL_COMPATIBLE_SUBROUTINES 0x8E4B
367#define GL_COMPILE_STATUS 0x8B81
368#define GL_COMPRESSED_ALPHA_ARB 0x84E9
369#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
370#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
371#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
372#define GL_COMPRESSED_R11_EAC 0x9270
373#define GL_COMPRESSED_RED 0x8225
374#define GL_COMPRESSED_RED_RGTC1 0x8DBB
375#define GL_COMPRESSED_RG 0x8226
376#define GL_COMPRESSED_RG11_EAC 0x9272
377#define GL_COMPRESSED_RGB 0x84ED
378#define GL_COMPRESSED_RGB8_ETC2 0x9274
379#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
380#define GL_COMPRESSED_RGBA 0x84EE
381#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
382#define GL_COMPRESSED_RGBA_ARB 0x84EE
383#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
384#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
385#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
386#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
387#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
388#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
389#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
390#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
391#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
392#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
393#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
394#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
395#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
396#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
397#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C
398#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
399#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
400#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
401#define GL_COMPRESSED_RGB_ARB 0x84ED
402#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
403#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
404#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
405#define GL_COMPRESSED_RG_RGTC2 0x8DBD
406#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
407#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
408#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
409#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
410#define GL_COMPRESSED_SRGB 0x8C48
411#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
412#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
413#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
414#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
415#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
416#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
417#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
418#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
419#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
420#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
421#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
422#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
423#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
424#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
425#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
426#define GL_COMPRESSED_SRGB8_ETC2 0x9275
427#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
428#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
429#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D
430#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
431#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
432#define GL_COMPUTE_SHADER 0x91B9
433#define GL_COMPUTE_SHADER_BIT 0x00000020
434#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5
435#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5
436#define GL_COMPUTE_SUBROUTINE 0x92ED
437#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3
438#define GL_COMPUTE_TEXTURE 0x82A0
439#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267
440#define GL_CONDITION_SATISFIED 0x911C
441#define GL_CONSTANT_ALPHA 0x8003
442#define GL_CONSTANT_COLOR 0x8001
443#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
444#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
445#define GL_CONTEXT_FLAGS 0x821E
446#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
447#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
448#define GL_CONTEXT_PROFILE_MASK 0x9126
449#define GL_COPY 0x1503
450#define GL_COPY_INVERTED 0x150C
451#define GL_COPY_READ_BUFFER 0x8F36
452#define GL_COPY_READ_BUFFER_BINDING 0x8F36
453#define GL_COPY_WRITE_BUFFER 0x8F37
454#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37
455#define GL_CULL_FACE 0x0B44
456#define GL_CULL_FACE_MODE 0x0B45
457#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
458#define GL_CURRENT_MATRIX_ARB 0x8641
459#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
460#define GL_CURRENT_PROGRAM 0x8B8D
461#define GL_CURRENT_QUERY 0x8865
462#define GL_CURRENT_QUERY_ARB 0x8865
463#define GL_CURRENT_VERTEX_ATTRIB 0x8626
464#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
465#define GL_CW 0x0900
466#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
467#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244
468#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
469#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245
470#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
471#define GL_DEBUG_LOGGED_MESSAGES 0x9145
472#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145
473#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
474#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
475#define GL_DEBUG_OUTPUT 0x92E0
476#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
477#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
478#define GL_DEBUG_SEVERITY_HIGH 0x9146
479#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146
480#define GL_DEBUG_SEVERITY_LOW 0x9148
481#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148
482#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
483#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
484#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
485#define GL_DEBUG_SOURCE_API 0x8246
486#define GL_DEBUG_SOURCE_API_ARB 0x8246
487#define GL_DEBUG_SOURCE_APPLICATION 0x824A
488#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A
489#define GL_DEBUG_SOURCE_OTHER 0x824B
490#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B
491#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
492#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
493#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
494#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249
495#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
496#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
497#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
498#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
499#define GL_DEBUG_TYPE_ERROR 0x824C
500#define GL_DEBUG_TYPE_ERROR_ARB 0x824C
501#define GL_DEBUG_TYPE_MARKER 0x8268
502#define GL_DEBUG_TYPE_OTHER 0x8251
503#define GL_DEBUG_TYPE_OTHER_ARB 0x8251
504#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
505#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250
506#define GL_DEBUG_TYPE_POP_GROUP 0x826A
507#define GL_DEBUG_TYPE_PORTABILITY 0x824F
508#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F
509#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
510#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
511#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
512#define GL_DECR 0x1E03
513#define GL_DECR_WRAP 0x8508
514#define GL_DELETE_STATUS 0x8B80
515#define GL_DEPTH 0x1801
516#define GL_DEPTH24_STENCIL8 0x88F0
517#define GL_DEPTH32F_STENCIL8 0x8CAD
518#define GL_DEPTH_ATTACHMENT 0x8D00
519#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
520#define GL_DEPTH_BUFFER_BIT 0x00000100
521#define GL_DEPTH_CLAMP 0x864F
522#define GL_DEPTH_CLEAR_VALUE 0x0B73
523#define GL_DEPTH_COMPONENT 0x1902
524#define GL_DEPTH_COMPONENT16 0x81A5
525#define GL_DEPTH_COMPONENT16_ARB 0x81A5
526#define GL_DEPTH_COMPONENT24 0x81A6
527#define GL_DEPTH_COMPONENT24_ARB 0x81A6
528#define GL_DEPTH_COMPONENT32 0x81A7
529#define GL_DEPTH_COMPONENT32F 0x8CAC
530#define GL_DEPTH_COMPONENT32_ARB 0x81A7
531#define GL_DEPTH_COMPONENTS 0x8284
532#define GL_DEPTH_FUNC 0x0B74
533#define GL_DEPTH_RANGE 0x0B70
534#define GL_DEPTH_RENDERABLE 0x8287
535#define GL_DEPTH_STENCIL 0x84F9
536#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
537#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA
538#define GL_DEPTH_TEST 0x0B71
539#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
540#define GL_DEPTH_WRITEMASK 0x0B72
541#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE
542#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF
543#define GL_DITHER 0x0BD0
544#define GL_DONT_CARE 0x1100
545#define GL_DOUBLE 0x140A
546#define GL_DOUBLEBUFFER 0x0C32
547#define GL_DOUBLE_MAT2 0x8F46
548#define GL_DOUBLE_MAT2x3 0x8F49
549#define GL_DOUBLE_MAT2x4 0x8F4A
550#define GL_DOUBLE_MAT3 0x8F47
551#define GL_DOUBLE_MAT3x2 0x8F4B
552#define GL_DOUBLE_MAT3x4 0x8F4C
553#define GL_DOUBLE_MAT4 0x8F48
554#define GL_DOUBLE_MAT4x2 0x8F4D
555#define GL_DOUBLE_MAT4x3 0x8F4E
556#define GL_DOUBLE_VEC2 0x8FFC
557#define GL_DOUBLE_VEC3 0x8FFD
558#define GL_DOUBLE_VEC4 0x8FFE
559#define GL_DRAW_BUFFER 0x0C01
560#define GL_DRAW_BUFFER0 0x8825
561#define GL_DRAW_BUFFER0_ARB 0x8825
562#define GL_DRAW_BUFFER1 0x8826
563#define GL_DRAW_BUFFER10 0x882F
564#define GL_DRAW_BUFFER10_ARB 0x882F
565#define GL_DRAW_BUFFER11 0x8830
566#define GL_DRAW_BUFFER11_ARB 0x8830
567#define GL_DRAW_BUFFER12 0x8831
568#define GL_DRAW_BUFFER12_ARB 0x8831
569#define GL_DRAW_BUFFER13 0x8832
570#define GL_DRAW_BUFFER13_ARB 0x8832
571#define GL_DRAW_BUFFER14 0x8833
572#define GL_DRAW_BUFFER14_ARB 0x8833
573#define GL_DRAW_BUFFER15 0x8834
574#define GL_DRAW_BUFFER15_ARB 0x8834
575#define GL_DRAW_BUFFER1_ARB 0x8826
576#define GL_DRAW_BUFFER2 0x8827
577#define GL_DRAW_BUFFER2_ARB 0x8827
578#define GL_DRAW_BUFFER3 0x8828
579#define GL_DRAW_BUFFER3_ARB 0x8828
580#define GL_DRAW_BUFFER4 0x8829
581#define GL_DRAW_BUFFER4_ARB 0x8829
582#define GL_DRAW_BUFFER5 0x882A
583#define GL_DRAW_BUFFER5_ARB 0x882A
584#define GL_DRAW_BUFFER6 0x882B
585#define GL_DRAW_BUFFER6_ARB 0x882B
586#define GL_DRAW_BUFFER7 0x882C
587#define GL_DRAW_BUFFER7_ARB 0x882C
588#define GL_DRAW_BUFFER8 0x882D
589#define GL_DRAW_BUFFER8_ARB 0x882D
590#define GL_DRAW_BUFFER9 0x882E
591#define GL_DRAW_BUFFER9_ARB 0x882E
592#define GL_DRAW_FRAMEBUFFER 0x8CA9
593#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
594#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
595#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
596#define GL_DRAW_INDIRECT_BUFFER 0x8F3F
597#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43
598#define GL_DST_ALPHA 0x0304
599#define GL_DST_COLOR 0x0306
600#define GL_DYNAMIC_COPY 0x88EA
601#define GL_DYNAMIC_COPY_ARB 0x88EA
602#define GL_DYNAMIC_DRAW 0x88E8
603#define GL_DYNAMIC_DRAW_ARB 0x88E8
604#define GL_DYNAMIC_READ 0x88E9
605#define GL_DYNAMIC_READ_ARB 0x88E9
606#define GL_DYNAMIC_STORAGE_BIT 0x0100
607#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
608#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
609#define GL_ELEMENT_ARRAY_BUFFER 0x8893
610#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
611#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
612#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
613#define GL_EQUAL 0x0202
614#define GL_EQUIV 0x1509
615#define GL_EXTENSIONS 0x1F03
616#define GL_FALSE 0
617#define GL_FASTEST 0x1101
618#define GL_FILL 0x1B02
619#define GL_FILTER 0x829A
620#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
621#define GL_FIXED 0x140C
622#define GL_FIXED_OES 0x140C
623#define GL_FIXED_ONLY 0x891D
624#define GL_FIXED_ONLY_ARB 0x891D
625#define GL_FLOAT 0x1406
626#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
627#define GL_FLOAT_MAT2 0x8B5A
628#define GL_FLOAT_MAT2_ARB 0x8B5A
629#define GL_FLOAT_MAT2x3 0x8B65
630#define GL_FLOAT_MAT2x4 0x8B66
631#define GL_FLOAT_MAT3 0x8B5B
632#define GL_FLOAT_MAT3_ARB 0x8B5B
633#define GL_FLOAT_MAT3x2 0x8B67
634#define GL_FLOAT_MAT3x4 0x8B68
635#define GL_FLOAT_MAT4 0x8B5C
636#define GL_FLOAT_MAT4_ARB 0x8B5C
637#define GL_FLOAT_MAT4x2 0x8B69
638#define GL_FLOAT_MAT4x3 0x8B6A
639#define GL_FLOAT_VEC2 0x8B50
640#define GL_FLOAT_VEC2_ARB 0x8B50
641#define GL_FLOAT_VEC3 0x8B51
642#define GL_FLOAT_VEC3_ARB 0x8B51
643#define GL_FLOAT_VEC4 0x8B52
644#define GL_FLOAT_VEC4_ARB 0x8B52
645#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
646#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
647#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
648#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
649#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
650#define GL_FOG_COORDINATE_EXT 0x8451
651#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
652#define GL_FRACTIONAL_EVEN 0x8E7C
653#define GL_FRACTIONAL_ODD 0x8E7B
654#define GL_FRAGMENT_DEPTH_EXT 0x8452
655#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D
656#define GL_FRAGMENT_PROGRAM_ARB 0x8804
657#define GL_FRAGMENT_SHADER 0x8B30
658#define GL_FRAGMENT_SHADER_ARB 0x8B30
659#define GL_FRAGMENT_SHADER_BIT 0x00000002
660#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
661#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
662#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4
663#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4
664#define GL_FRAGMENT_SUBROUTINE 0x92EC
665#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2
666#define GL_FRAGMENT_TEXTURE 0x829F
667#define GL_FRAMEBUFFER 0x8D40
668#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
669#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
670#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
671#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
672#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
673#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
674#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
675#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7
676#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
677#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
678#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
679#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
680#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
681#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
682#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
683#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
684#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
685#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
686#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
687#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
688#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
689#define GL_FRAMEBUFFER_BINDING 0x8CA6
690#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
691#define GL_FRAMEBUFFER_BLEND 0x828B
692#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
693#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
694#define GL_FRAMEBUFFER_DEFAULT 0x8218
695#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314
696#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311
697#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312
698#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313
699#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310
700#define GL_FRAMEBUFFER_EXT 0x8D40
701#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
702#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
703#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
704#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
705#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
706#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
707#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9
708#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
709#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8
710#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
711#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
712#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
713#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
714#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
715#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
716#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342
717#define GL_FRAMEBUFFER_RENDERABLE 0x8289
718#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A
719#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343
720#define GL_FRAMEBUFFER_SRGB 0x8DB9
721#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
722#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
723#define GL_FRAMEBUFFER_UNDEFINED 0x8219
724#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
725#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
726#define GL_FRONT 0x0404
727#define GL_FRONT_AND_BACK 0x0408
728#define GL_FRONT_FACE 0x0B46
729#define GL_FRONT_LEFT 0x0400
730#define GL_FRONT_RIGHT 0x0401
731#define GL_FULL_SUPPORT 0x82B7
732#define GL_FUNC_ADD 0x8006
733#define GL_FUNC_REVERSE_SUBTRACT 0x800B
734#define GL_FUNC_SUBTRACT 0x800A
735#define GL_GEOMETRY_INPUT_TYPE 0x8917
736#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB
737#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
738#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC
739#define GL_GEOMETRY_SHADER 0x8DD9
740#define GL_GEOMETRY_SHADER_ARB 0x8DD9
741#define GL_GEOMETRY_SHADER_BIT 0x00000004
742#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F
743#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3
744#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3
745#define GL_GEOMETRY_SUBROUTINE 0x92EB
746#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1
747#define GL_GEOMETRY_TEXTURE 0x829E
748#define GL_GEOMETRY_VERTICES_OUT 0x8916
749#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA
750#define GL_GEQUAL 0x0206
751#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291
752#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292
753#define GL_GREATER 0x0204
754#define GL_GREEN 0x1904
755#define GL_GREEN_INTEGER 0x8D95
756#define GL_HALF_FLOAT 0x140B
757#define GL_HALF_FLOAT_ARB 0x140B
758#define GL_HIGH_FLOAT 0x8DF2
759#define GL_HIGH_INT 0x8DF5
760#define GL_IMAGE_1D 0x904C
761#define GL_IMAGE_1D_ARRAY 0x9052
762#define GL_IMAGE_2D 0x904D
763#define GL_IMAGE_2D_ARRAY 0x9053
764#define GL_IMAGE_2D_MULTISAMPLE 0x9055
765#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
766#define GL_IMAGE_2D_RECT 0x904F
767#define GL_IMAGE_3D 0x904E
768#define GL_IMAGE_BINDING_ACCESS 0x8F3E
769#define GL_IMAGE_BINDING_FORMAT 0x906E
770#define GL_IMAGE_BINDING_LAYER 0x8F3D
771#define GL_IMAGE_BINDING_LAYERED 0x8F3C
772#define GL_IMAGE_BINDING_LEVEL 0x8F3B
773#define GL_IMAGE_BINDING_NAME 0x8F3A
774#define GL_IMAGE_BUFFER 0x9051
775#define GL_IMAGE_CLASS_10_10_10_2 0x82C3
776#define GL_IMAGE_CLASS_11_11_10 0x82C2
777#define GL_IMAGE_CLASS_1_X_16 0x82BE
778#define GL_IMAGE_CLASS_1_X_32 0x82BB
779#define GL_IMAGE_CLASS_1_X_8 0x82C1
780#define GL_IMAGE_CLASS_2_X_16 0x82BD
781#define GL_IMAGE_CLASS_2_X_32 0x82BA
782#define GL_IMAGE_CLASS_2_X_8 0x82C0
783#define GL_IMAGE_CLASS_4_X_16 0x82BC
784#define GL_IMAGE_CLASS_4_X_32 0x82B9
785#define GL_IMAGE_CLASS_4_X_8 0x82BF
786#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8
787#define GL_IMAGE_CUBE 0x9050
788#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
789#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
790#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
791#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
792#define GL_IMAGE_PIXEL_FORMAT 0x82A9
793#define GL_IMAGE_PIXEL_TYPE 0x82AA
794#define GL_IMAGE_TEXEL_SIZE 0x82A7
795#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
796#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
797#define GL_INCR 0x1E02
798#define GL_INCR_WRAP 0x8507
799#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
800#define GL_INFO_LOG_LENGTH 0x8B84
801#define GL_INT 0x1404
802#define GL_INT64_ARB 0x140E
803#define GL_INT64_VEC2_ARB 0x8FE9
804#define GL_INT64_VEC3_ARB 0x8FEA
805#define GL_INT64_VEC4_ARB 0x8FEB
806#define GL_INTENSITY16F_ARB 0x881D
807#define GL_INTENSITY32F_ARB 0x8817
808#define GL_INTERLEAVED_ATTRIBS 0x8C8C
809#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274
810#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B
811#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273
812#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A
813#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275
814#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C
815#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272
816#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279
817#define GL_INTERNALFORMAT_PREFERRED 0x8270
818#define GL_INTERNALFORMAT_RED_SIZE 0x8271
819#define GL_INTERNALFORMAT_RED_TYPE 0x8278
820#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277
821#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276
822#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D
823#define GL_INTERNALFORMAT_SUPPORTED 0x826F
824#define GL_INT_2_10_10_10_REV 0x8D9F
825#define GL_INT_IMAGE_1D 0x9057
826#define GL_INT_IMAGE_1D_ARRAY 0x905D
827#define GL_INT_IMAGE_2D 0x9058
828#define GL_INT_IMAGE_2D_ARRAY 0x905E
829#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
830#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
831#define GL_INT_IMAGE_2D_RECT 0x905A
832#define GL_INT_IMAGE_3D 0x9059
833#define GL_INT_IMAGE_BUFFER 0x905C
834#define GL_INT_IMAGE_CUBE 0x905B
835#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
836#define GL_INT_SAMPLER_1D 0x8DC9
837#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
838#define GL_INT_SAMPLER_2D 0x8DCA
839#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
840#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
841#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
842#define GL_INT_SAMPLER_2D_RECT 0x8DCD
843#define GL_INT_SAMPLER_3D 0x8DCB
844#define GL_INT_SAMPLER_BUFFER 0x8DD0
845#define GL_INT_SAMPLER_CUBE 0x8DCC
846#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E
847#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E
848#define GL_INT_VEC2 0x8B53
849#define GL_INT_VEC2_ARB 0x8B53
850#define GL_INT_VEC3 0x8B54
851#define GL_INT_VEC3_ARB 0x8B54
852#define GL_INT_VEC4 0x8B55
853#define GL_INT_VEC4_ARB 0x8B55
854#define GL_INVALID_ENUM 0x0500
855#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
856#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
857#define GL_INVALID_INDEX 0xFFFFFFFF
858#define GL_INVALID_OPERATION 0x0502
859#define GL_INVALID_VALUE 0x0501
860#define GL_INVERT 0x150A
861#define GL_ISOLINES 0x8E7A
862#define GL_IS_PER_PATCH 0x92E7
863#define GL_IS_ROW_MAJOR 0x9300
864#define GL_KEEP 0x1E00
865#define GL_LAST_VERTEX_CONVENTION 0x8E4E
866#define GL_LAYER_PROVOKING_VERTEX 0x825E
867#define GL_LEFT 0x0406
868#define GL_LEQUAL 0x0203
869#define GL_LESS 0x0201
870#define GL_LINE 0x1B01
871#define GL_LINEAR 0x2601
872#define GL_LINEAR_MIPMAP_LINEAR 0x2703
873#define GL_LINEAR_MIPMAP_NEAREST 0x2701
874#define GL_LINES 0x0001
875#define GL_LINES_ADJACENCY 0x000A
876#define GL_LINES_ADJACENCY_ARB 0x000A
877#define GL_LINE_LOOP 0x0002
878#define GL_LINE_SMOOTH 0x0B20
879#define GL_LINE_SMOOTH_HINT 0x0C52
880#define GL_LINE_STRIP 0x0003
881#define GL_LINE_STRIP_ADJACENCY 0x000B
882#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B
883#define GL_LINE_WIDTH 0x0B21
884#define GL_LINE_WIDTH_GRANULARITY 0x0B23
885#define GL_LINE_WIDTH_RANGE 0x0B22
886#define GL_LINK_STATUS 0x8B82
887#define GL_LOCATION 0x930E
888#define GL_LOCATION_COMPONENT 0x934A
889#define GL_LOCATION_INDEX 0x930F
890#define GL_LOGIC_OP_MODE 0x0BF0
891#define GL_LOWER_LEFT 0x8CA1
892#define GL_LOW_FLOAT 0x8DF0
893#define GL_LOW_INT 0x8DF3
894#define GL_LUMINANCE16F_ARB 0x881E
895#define GL_LUMINANCE32F_ARB 0x8818
896#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
897#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
898#define GL_MAJOR_VERSION 0x821B
899#define GL_MANUAL_GENERATE_MIPMAP 0x8294
900#define GL_MAP_COHERENT_BIT 0x0080
901#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
902#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
903#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
904#define GL_MAP_PERSISTENT_BIT 0x0040
905#define GL_MAP_READ_BIT 0x0001
906#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
907#define GL_MAP_WRITE_BIT 0x0002
908#define GL_MATRIX0_ARB 0x88C0
909#define GL_MATRIX10_ARB 0x88CA
910#define GL_MATRIX11_ARB 0x88CB
911#define GL_MATRIX12_ARB 0x88CC
912#define GL_MATRIX13_ARB 0x88CD
913#define GL_MATRIX14_ARB 0x88CE
914#define GL_MATRIX15_ARB 0x88CF
915#define GL_MATRIX16_ARB 0x88D0
916#define GL_MATRIX17_ARB 0x88D1
917#define GL_MATRIX18_ARB 0x88D2
918#define GL_MATRIX19_ARB 0x88D3
919#define GL_MATRIX1_ARB 0x88C1
920#define GL_MATRIX20_ARB 0x88D4
921#define GL_MATRIX21_ARB 0x88D5
922#define GL_MATRIX22_ARB 0x88D6
923#define GL_MATRIX23_ARB 0x88D7
924#define GL_MATRIX24_ARB 0x88D8
925#define GL_MATRIX25_ARB 0x88D9
926#define GL_MATRIX26_ARB 0x88DA
927#define GL_MATRIX27_ARB 0x88DB
928#define GL_MATRIX28_ARB 0x88DC
929#define GL_MATRIX29_ARB 0x88DD
930#define GL_MATRIX2_ARB 0x88C2
931#define GL_MATRIX30_ARB 0x88DE
932#define GL_MATRIX31_ARB 0x88DF
933#define GL_MATRIX3_ARB 0x88C3
934#define GL_MATRIX4_ARB 0x88C4
935#define GL_MATRIX5_ARB 0x88C5
936#define GL_MATRIX6_ARB 0x88C6
937#define GL_MATRIX7_ARB 0x88C7
938#define GL_MATRIX8_ARB 0x88C8
939#define GL_MATRIX9_ARB 0x88C9
940#define GL_MATRIX_STRIDE 0x92FF
941#define GL_MAX 0x8008
942#define GL_MAX_3D_TEXTURE_SIZE 0x8073
943#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
944#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
945#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
946#define GL_MAX_CLIP_DISTANCES 0x0D32
947#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
948#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
949#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
950#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7
951#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
952#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266
953#define GL_MAX_COMBINED_DIMENSIONS 0x8282
954#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
955#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
956#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF
957#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
958#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39
959#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC
960#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E
961#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F
962#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
963#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
964#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
965#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
966#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265
967#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264
968#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB
969#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF
970#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD
971#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB
972#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262
973#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC
974#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB
975#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263
976#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344
977#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345
978#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE
979#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB
980#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF
981#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
982#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
983#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
984#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
985#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144
986#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
987#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143
988#define GL_MAX_DEPTH 0x8280
989#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
990#define GL_MAX_DRAW_BUFFERS 0x8824
991#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
992#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
993#define GL_MAX_ELEMENTS_INDICES 0x80E9
994#define GL_MAX_ELEMENTS_VERTICES 0x80E8
995#define GL_MAX_ELEMENT_INDEX 0x8D6B
996#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6
997#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
998#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE
999#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
1000#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C
1001#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA
1002#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
1003#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
1004#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
1005#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
1006#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316
1007#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317
1008#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318
1009#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315
1010#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5
1011#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF
1012#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD
1013#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
1014#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
1015#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
1016#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0
1017#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A
1018#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7
1019#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
1020#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29
1021#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
1022#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1
1023#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
1024#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
1025#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF
1026#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD
1027#define GL_MAX_HEIGHT 0x827F
1028#define GL_MAX_IMAGE_SAMPLES 0x906D
1029#define GL_MAX_IMAGE_UNITS 0x8F38
1030#define GL_MAX_INTEGER_SAMPLES 0x9110
1031#define GL_MAX_LABEL_LENGTH 0x82E8
1032#define GL_MAX_LAYERS 0x8281
1033#define GL_MAX_NAME_LENGTH 0x92F6
1034#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7
1035#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8
1036#define GL_MAX_PATCH_VERTICES 0x8E7D
1037#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
1038#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
1039#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
1040#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
1041#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
1042#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
1043#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
1044#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
1045#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
1046#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
1047#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
1048#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
1049#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
1050#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
1051#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
1052#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
1053#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
1054#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
1055#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
1056#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
1057#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
1058#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
1059#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
1060#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
1061#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
1062#define GL_MAX_SAMPLES 0x8D57
1063#define GL_MAX_SAMPLES_EXT 0x8D57
1064#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
1065#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
1066#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE
1067#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD
1068#define GL_MAX_SUBROUTINES 0x8DE7
1069#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8
1070#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3
1071#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD
1072#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
1073#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C
1074#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83
1075#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8
1076#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81
1077#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85
1078#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89
1079#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F
1080#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4
1081#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE
1082#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
1083#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D
1084#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86
1085#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9
1086#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82
1087#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A
1088#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80
1089#define GL_MAX_TESS_GEN_LEVEL 0x8E7E
1090#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84
1091#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
1092#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
1093#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
1094#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
1095#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
1096#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF
1097#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
1098#define GL_MAX_TEXTURE_SIZE 0x0D33
1099#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
1100#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70
1101#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
1102#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
1103#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
1104#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
1105#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
1106#define GL_MAX_UNIFORM_LOCATIONS 0x826E
1107#define GL_MAX_VARYING_COMPONENTS 0x8B4B
1108#define GL_MAX_VARYING_FLOATS 0x8B4B
1109#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
1110#define GL_MAX_VARYING_VECTORS 0x8DFC
1111#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2
1112#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
1113#define GL_MAX_VERTEX_ATTRIBS 0x8869
1114#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
1115#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA
1116#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9
1117#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA
1118#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
1119#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6
1120#define GL_MAX_VERTEX_STREAMS 0x8E71
1121#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
1122#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
1123#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
1124#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
1125#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
1126#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
1127#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE
1128#define GL_MAX_VIEWPORTS 0x825B
1129#define GL_MAX_VIEWPORT_DIMS 0x0D3A
1130#define GL_MAX_WIDTH 0x827E
1131#define GL_MEDIUM_FLOAT 0x8DF1
1132#define GL_MEDIUM_INT 0x8DF4
1133#define GL_MIN 0x8007
1134#define GL_MINOR_VERSION 0x821C
1135#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B
1136#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC
1137#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
1138#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
1139#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37
1140#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37
1141#define GL_MIPMAP 0x8293
1142#define GL_MIRRORED_REPEAT 0x8370
1143#define GL_MIRRORED_REPEAT_ARB 0x8370
1144#define GL_MIRROR_CLAMP_EXT 0x8742
1145#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
1146#define GL_MIRROR_CLAMP_TO_EDGE 0x8743
1147#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
1148#define GL_MULTISAMPLE 0x809D
1149#define GL_MULTISAMPLE_ARB 0x809D
1150#define GL_MULTISAMPLE_BIT_ARB 0x20000000
1151#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382
1152#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381
1153#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9
1154#define GL_NAMED_STRING_TYPE_ARB 0x8DEA
1155#define GL_NAME_LENGTH 0x92F9
1156#define GL_NAND 0x150E
1157#define GL_NEAREST 0x2600
1158#define GL_NEAREST_MIPMAP_LINEAR 0x2702
1159#define GL_NEAREST_MIPMAP_NEAREST 0x2700
1160#define GL_NEVER 0x0200
1161#define GL_NICEST 0x1102
1162#define GL_NONE 0
1163#define GL_NOOP 0x1505
1164#define GL_NOR 0x1508
1165#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
1166#define GL_NORMAL_MAP_ARB 0x8511
1167#define GL_NOTEQUAL 0x0205
1168#define GL_NO_ERROR 0
1169#define GL_NUM_ACTIVE_VARIABLES 0x9304
1170#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A
1171#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
1172#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
1173#define GL_NUM_EXTENSIONS 0x821D
1174#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
1175#define GL_NUM_SAMPLE_COUNTS 0x9380
1176#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
1177#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9
1178#define GL_NUM_SPIR_V_EXTENSIONS 0x9554
1179#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
1180#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
1181#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86
1182#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
1183#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85
1184#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
1185#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
1186#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
1187#define GL_OBJECT_LINK_STATUS_ARB 0x8B82
1188#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88
1189#define GL_OBJECT_SUBTYPE_ARB 0x8B4F
1190#define GL_OBJECT_TYPE 0x9112
1191#define GL_OBJECT_TYPE_ARB 0x8B4E
1192#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83
1193#define GL_OFFSET 0x92FC
1194#define GL_ONE 1
1195#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
1196#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
1197#define GL_ONE_MINUS_DST_ALPHA 0x0305
1198#define GL_ONE_MINUS_DST_COLOR 0x0307
1199#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
1200#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
1201#define GL_ONE_MINUS_SRC_ALPHA 0x0303
1202#define GL_ONE_MINUS_SRC_COLOR 0x0301
1203#define GL_OR 0x1507
1204#define GL_OR_INVERTED 0x150D
1205#define GL_OR_REVERSE 0x150B
1206#define GL_OUT_OF_MEMORY 0x0505
1207#define GL_PACK_ALIGNMENT 0x0D05
1208#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D
1209#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C
1210#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E
1211#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B
1212#define GL_PACK_IMAGE_HEIGHT 0x806C
1213#define GL_PACK_LSB_FIRST 0x0D01
1214#define GL_PACK_ROW_LENGTH 0x0D02
1215#define GL_PACK_SKIP_IMAGES 0x806B
1216#define GL_PACK_SKIP_PIXELS 0x0D04
1217#define GL_PACK_SKIP_ROWS 0x0D03
1218#define GL_PACK_SWAP_BYTES 0x0D00
1219#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
1220#define GL_PALETTE4_RGB5_A1_OES 0x8B94
1221#define GL_PALETTE4_RGB8_OES 0x8B90
1222#define GL_PALETTE4_RGBA4_OES 0x8B93
1223#define GL_PALETTE4_RGBA8_OES 0x8B91
1224#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
1225#define GL_PALETTE8_RGB5_A1_OES 0x8B99
1226#define GL_PALETTE8_RGB8_OES 0x8B95
1227#define GL_PALETTE8_RGBA4_OES 0x8B98
1228#define GL_PALETTE8_RGBA8_OES 0x8B96
1229#define GL_PATCHES 0x000E
1230#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73
1231#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74
1232#define GL_PATCH_VERTICES 0x8E72
1233#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
1234#define GL_PIXEL_PACK_BUFFER 0x88EB
1235#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
1236#define GL_PIXEL_UNPACK_BUFFER 0x88EC
1237#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
1238#define GL_POINT 0x1B00
1239#define GL_POINTS 0x0000
1240#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
1241#define GL_POINT_SIZE 0x0B11
1242#define GL_POINT_SIZE_GRANULARITY 0x0B13
1243#define GL_POINT_SIZE_RANGE 0x0B12
1244#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
1245#define GL_POLYGON_MODE 0x0B40
1246#define GL_POLYGON_OFFSET_FACTOR 0x8038
1247#define GL_POLYGON_OFFSET_FILL 0x8037
1248#define GL_POLYGON_OFFSET_LINE 0x2A02
1249#define GL_POLYGON_OFFSET_POINT 0x2A01
1250#define GL_POLYGON_OFFSET_UNITS 0x2A00
1251#define GL_POLYGON_SMOOTH 0x0B41
1252#define GL_POLYGON_SMOOTH_HINT 0x0C53
1253#define GL_PRIMITIVES_GENERATED 0x8C87
1254#define GL_PRIMITIVES_SUBMITTED 0x82EF
1255#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF
1256#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE
1257#define GL_PRIMITIVE_RESTART 0x8F9D
1258#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
1259#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
1260#define GL_PROGRAM 0x82E2
1261#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341
1262#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340
1263#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
1264#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
1265#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
1266#define GL_PROGRAM_BINARY_FORMATS 0x87FF
1267#define GL_PROGRAM_BINARY_LENGTH 0x8741
1268#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
1269#define GL_PROGRAM_BINDING_ARB 0x8677
1270#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
1271#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
1272#define GL_PROGRAM_FORMAT_ARB 0x8876
1273#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
1274#define GL_PROGRAM_INPUT 0x92E3
1275#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
1276#define GL_PROGRAM_LENGTH_ARB 0x8627
1277#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
1278#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
1279#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
1280#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
1281#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
1282#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
1283#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
1284#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
1285#define GL_PROGRAM_OBJECT_ARB 0x8B40
1286#define GL_PROGRAM_OUTPUT 0x92E4
1287#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
1288#define GL_PROGRAM_PIPELINE 0x82E4
1289#define GL_PROGRAM_PIPELINE_BINDING 0x825A
1290#define GL_PROGRAM_POINT_SIZE 0x8642
1291#define GL_PROGRAM_POINT_SIZE_ARB 0x8642
1292#define GL_PROGRAM_SEPARABLE 0x8258
1293#define GL_PROGRAM_STRING_ARB 0x8628
1294#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
1295#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
1296#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
1297#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
1298#define GL_PROVOKING_VERTEX 0x8E4F
1299#define GL_PROXY_TEXTURE_1D 0x8063
1300#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
1301#define GL_PROXY_TEXTURE_2D 0x8064
1302#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
1303#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
1304#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
1305#define GL_PROXY_TEXTURE_3D 0x8070
1306#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
1307#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
1308#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B
1309#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B
1310#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
1311#define GL_QUADS 0x0007
1312#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
1313#define GL_QUERY 0x82E3
1314#define GL_QUERY_BUFFER 0x9192
1315#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000
1316#define GL_QUERY_BUFFER_BINDING 0x9193
1317#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
1318#define GL_QUERY_BY_REGION_WAIT 0x8E15
1319#define GL_QUERY_COUNTER_BITS 0x8864
1320#define GL_QUERY_COUNTER_BITS_ARB 0x8864
1321#define GL_QUERY_NO_WAIT 0x8E14
1322#define GL_QUERY_RESULT 0x8866
1323#define GL_QUERY_RESULT_ARB 0x8866
1324#define GL_QUERY_RESULT_AVAILABLE 0x8867
1325#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
1326#define GL_QUERY_RESULT_NO_WAIT 0x9194
1327#define GL_QUERY_TARGET 0x82EA
1328#define GL_QUERY_WAIT 0x8E13
1329#define GL_R11F_G11F_B10F 0x8C3A
1330#define GL_R16 0x822A
1331#define GL_R16F 0x822D
1332#define GL_R16I 0x8233
1333#define GL_R16UI 0x8234
1334#define GL_R16_SNORM 0x8F98
1335#define GL_R32F 0x822E
1336#define GL_R32I 0x8235
1337#define GL_R32UI 0x8236
1338#define GL_R3_G3_B2 0x2A10
1339#define GL_R8 0x8229
1340#define GL_R8I 0x8231
1341#define GL_R8UI 0x8232
1342#define GL_R8_SNORM 0x8F94
1343#define GL_RASTERIZER_DISCARD 0x8C89
1344#define GL_READ_BUFFER 0x0C02
1345#define GL_READ_FRAMEBUFFER 0x8CA8
1346#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
1347#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
1348#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
1349#define GL_READ_ONLY 0x88B8
1350#define GL_READ_ONLY_ARB 0x88B8
1351#define GL_READ_PIXELS 0x828C
1352#define GL_READ_PIXELS_FORMAT 0x828D
1353#define GL_READ_PIXELS_TYPE 0x828E
1354#define GL_READ_WRITE 0x88BA
1355#define GL_READ_WRITE_ARB 0x88BA
1356#define GL_RED 0x1903
1357#define GL_RED_INTEGER 0x8D94
1358#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B
1359#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A
1360#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309
1361#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307
1362#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308
1363#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306
1364#define GL_REFLECTION_MAP_ARB 0x8512
1365#define GL_RENDERBUFFER 0x8D41
1366#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
1367#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
1368#define GL_RENDERBUFFER_BINDING 0x8CA7
1369#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
1370#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
1371#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
1372#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
1373#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
1374#define GL_RENDERBUFFER_EXT 0x8D41
1375#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
1376#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
1377#define GL_RENDERBUFFER_HEIGHT 0x8D43
1378#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
1379#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
1380#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
1381#define GL_RENDERBUFFER_RED_SIZE 0x8D50
1382#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
1383#define GL_RENDERBUFFER_SAMPLES 0x8CAB
1384#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
1385#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
1386#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
1387#define GL_RENDERBUFFER_WIDTH 0x8D42
1388#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
1389#define GL_RENDERER 0x1F01
1390#define GL_REPEAT 0x2901
1391#define GL_REPLACE 0x1E01
1392#define GL_RG 0x8227
1393#define GL_RG16 0x822C
1394#define GL_RG16F 0x822F
1395#define GL_RG16I 0x8239
1396#define GL_RG16UI 0x823A
1397#define GL_RG16_SNORM 0x8F99
1398#define GL_RG32F 0x8230
1399#define GL_RG32I 0x823B
1400#define GL_RG32UI 0x823C
1401#define GL_RG8 0x822B
1402#define GL_RG8I 0x8237
1403#define GL_RG8UI 0x8238
1404#define GL_RG8_SNORM 0x8F95
1405#define GL_RGB 0x1907
1406#define GL_RGB10 0x8052
1407#define GL_RGB10_A2 0x8059
1408#define GL_RGB10_A2UI 0x906F
1409#define GL_RGB12 0x8053
1410#define GL_RGB16 0x8054
1411#define GL_RGB16F 0x881B
1412#define GL_RGB16F_ARB 0x881B
1413#define GL_RGB16I 0x8D89
1414#define GL_RGB16UI 0x8D77
1415#define GL_RGB16_SNORM 0x8F9A
1416#define GL_RGB32F 0x8815
1417#define GL_RGB32F_ARB 0x8815
1418#define GL_RGB32I 0x8D83
1419#define GL_RGB32UI 0x8D71
1420#define GL_RGB4 0x804F
1421#define GL_RGB5 0x8050
1422#define GL_RGB565 0x8D62
1423#define GL_RGB5_A1 0x8057
1424#define GL_RGB8 0x8051
1425#define GL_RGB8I 0x8D8F
1426#define GL_RGB8UI 0x8D7D
1427#define GL_RGB8_SNORM 0x8F96
1428#define GL_RGB9_E5 0x8C3D
1429#define GL_RGBA 0x1908
1430#define GL_RGBA12 0x805A
1431#define GL_RGBA16 0x805B
1432#define GL_RGBA16F 0x881A
1433#define GL_RGBA16F_ARB 0x881A
1434#define GL_RGBA16I 0x8D88
1435#define GL_RGBA16UI 0x8D76
1436#define GL_RGBA16_SNORM 0x8F9B
1437#define GL_RGBA2 0x8055
1438#define GL_RGBA32F 0x8814
1439#define GL_RGBA32F_ARB 0x8814
1440#define GL_RGBA32I 0x8D82
1441#define GL_RGBA32UI 0x8D70
1442#define GL_RGBA4 0x8056
1443#define GL_RGBA8 0x8058
1444#define GL_RGBA8I 0x8D8E
1445#define GL_RGBA8UI 0x8D7C
1446#define GL_RGBA8_SNORM 0x8F97
1447#define GL_RGBA_FLOAT_MODE_ARB 0x8820
1448#define GL_RGBA_INTEGER 0x8D99
1449#define GL_RGB_INTEGER 0x8D98
1450#define GL_RG_INTEGER 0x8228
1451#define GL_RIGHT 0x0407
1452#define GL_SAMPLER 0x82E6
1453#define GL_SAMPLER_1D 0x8B5D
1454#define GL_SAMPLER_1D_ARB 0x8B5D
1455#define GL_SAMPLER_1D_ARRAY 0x8DC0
1456#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
1457#define GL_SAMPLER_1D_SHADOW 0x8B61
1458#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
1459#define GL_SAMPLER_2D 0x8B5E
1460#define GL_SAMPLER_2D_ARB 0x8B5E
1461#define GL_SAMPLER_2D_ARRAY 0x8DC1
1462#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
1463#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
1464#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
1465#define GL_SAMPLER_2D_RECT 0x8B63
1466#define GL_SAMPLER_2D_RECT_ARB 0x8B63
1467#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
1468#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
1469#define GL_SAMPLER_2D_SHADOW 0x8B62
1470#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
1471#define GL_SAMPLER_3D 0x8B5F
1472#define GL_SAMPLER_3D_ARB 0x8B5F
1473#define GL_SAMPLER_BINDING 0x8919
1474#define GL_SAMPLER_BUFFER 0x8DC2
1475#define GL_SAMPLER_CUBE 0x8B60
1476#define GL_SAMPLER_CUBE_ARB 0x8B60
1477#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C
1478#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C
1479#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D
1480#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D
1481#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
1482#define GL_SAMPLES 0x80A9
1483#define GL_SAMPLES_ARB 0x80A9
1484#define GL_SAMPLES_PASSED 0x8914
1485#define GL_SAMPLES_PASSED_ARB 0x8914
1486#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
1487#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
1488#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
1489#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
1490#define GL_SAMPLE_BUFFERS 0x80A8
1491#define GL_SAMPLE_BUFFERS_ARB 0x80A8
1492#define GL_SAMPLE_COVERAGE 0x80A0
1493#define GL_SAMPLE_COVERAGE_ARB 0x80A0
1494#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
1495#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
1496#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
1497#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
1498#define GL_SAMPLE_LOCATION_ARB 0x8E50
1499#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F
1500#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E
1501#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D
1502#define GL_SAMPLE_MASK 0x8E51
1503#define GL_SAMPLE_MASK_VALUE 0x8E52
1504#define GL_SAMPLE_POSITION 0x8E50
1505#define GL_SAMPLE_SHADING 0x8C36
1506#define GL_SAMPLE_SHADING_ARB 0x8C36
1507#define GL_SCISSOR_BOX 0x0C10
1508#define GL_SCISSOR_TEST 0x0C11
1509#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
1510#define GL_SEPARATE_ATTRIBS 0x8C8D
1511#define GL_SET 0x150F
1512#define GL_SHADER 0x82E1
1513#define GL_SHADER_BINARY_FORMATS 0x8DF8
1514#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551
1515#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551
1516#define GL_SHADER_COMPILER 0x8DFA
1517#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
1518#define GL_SHADER_IMAGE_ATOMIC 0x82A6
1519#define GL_SHADER_IMAGE_LOAD 0x82A4
1520#define GL_SHADER_IMAGE_STORE 0x82A5
1521#define GL_SHADER_INCLUDE_ARB 0x8DAE
1522#define GL_SHADER_OBJECT_ARB 0x8B48
1523#define GL_SHADER_SOURCE_LENGTH 0x8B88
1524#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000
1525#define GL_SHADER_STORAGE_BLOCK 0x92E6
1526#define GL_SHADER_STORAGE_BUFFER 0x90D2
1527#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3
1528#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF
1529#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5
1530#define GL_SHADER_STORAGE_BUFFER_START 0x90D4
1531#define GL_SHADER_TYPE 0x8B4F
1532#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
1533#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
1534#define GL_SHORT 0x1402
1535#define GL_SIGNALED 0x9119
1536#define GL_SIGNED_NORMALIZED 0x8F9C
1537#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC
1538#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE
1539#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD
1540#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF
1541#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
1542#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
1543#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
1544#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
1545#define GL_SOURCE1_ALPHA 0x8589
1546#define GL_SPIR_V_BINARY 0x9552
1547#define GL_SPIR_V_BINARY_ARB 0x9552
1548#define GL_SPIR_V_EXTENSIONS 0x9553
1549#define GL_SRC1_ALPHA 0x8589
1550#define GL_SRC1_COLOR 0x88F9
1551#define GL_SRC_ALPHA 0x0302
1552#define GL_SRC_ALPHA_SATURATE 0x0308
1553#define GL_SRC_COLOR 0x0300
1554#define GL_SRGB 0x8C40
1555#define GL_SRGB8 0x8C41
1556#define GL_SRGB8_ALPHA8 0x8C43
1557#define GL_SRGB_ALPHA 0x8C42
1558#define GL_SRGB_DECODE_ARB 0x8299
1559#define GL_SRGB_READ 0x8297
1560#define GL_SRGB_WRITE 0x8298
1561#define GL_STACK_OVERFLOW 0x0503
1562#define GL_STACK_UNDERFLOW 0x0504
1563#define GL_STATIC_COPY 0x88E6
1564#define GL_STATIC_COPY_ARB 0x88E6
1565#define GL_STATIC_DRAW 0x88E4
1566#define GL_STATIC_DRAW_ARB 0x88E4
1567#define GL_STATIC_READ 0x88E5
1568#define GL_STATIC_READ_ARB 0x88E5
1569#define GL_STENCIL 0x1802
1570#define GL_STENCIL_ATTACHMENT 0x8D20
1571#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
1572#define GL_STENCIL_BACK_FAIL 0x8801
1573#define GL_STENCIL_BACK_FUNC 0x8800
1574#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
1575#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
1576#define GL_STENCIL_BACK_REF 0x8CA3
1577#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
1578#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
1579#define GL_STENCIL_BUFFER_BIT 0x00000400
1580#define GL_STENCIL_CLEAR_VALUE 0x0B91
1581#define GL_STENCIL_COMPONENTS 0x8285
1582#define GL_STENCIL_FAIL 0x0B94
1583#define GL_STENCIL_FUNC 0x0B92
1584#define GL_STENCIL_INDEX 0x1901
1585#define GL_STENCIL_INDEX1 0x8D46
1586#define GL_STENCIL_INDEX16 0x8D49
1587#define GL_STENCIL_INDEX16_EXT 0x8D49
1588#define GL_STENCIL_INDEX1_EXT 0x8D46
1589#define GL_STENCIL_INDEX4 0x8D47
1590#define GL_STENCIL_INDEX4_EXT 0x8D47
1591#define GL_STENCIL_INDEX8 0x8D48
1592#define GL_STENCIL_INDEX8_EXT 0x8D48
1593#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
1594#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
1595#define GL_STENCIL_REF 0x0B97
1596#define GL_STENCIL_RENDERABLE 0x8288
1597#define GL_STENCIL_TEST 0x0B90
1598#define GL_STENCIL_VALUE_MASK 0x0B93
1599#define GL_STENCIL_WRITEMASK 0x0B98
1600#define GL_STEREO 0x0C33
1601#define GL_STREAM_COPY 0x88E2
1602#define GL_STREAM_COPY_ARB 0x88E2
1603#define GL_STREAM_DRAW 0x88E0
1604#define GL_STREAM_DRAW_ARB 0x88E0
1605#define GL_STREAM_READ 0x88E1
1606#define GL_STREAM_READ_ARB 0x88E1
1607#define GL_SUBPIXEL_BITS 0x0D50
1608#define GL_SYNC_CONDITION 0x9113
1609#define GL_SYNC_FENCE 0x9116
1610#define GL_SYNC_FLAGS 0x9115
1611#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
1612#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
1613#define GL_SYNC_STATUS 0x9114
1614#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75
1615#define GL_TESS_CONTROL_SHADER 0x8E88
1616#define GL_TESS_CONTROL_SHADER_BIT 0x00000008
1617#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1
1618#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1
1619#define GL_TESS_CONTROL_SUBROUTINE 0x92E9
1620#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF
1621#define GL_TESS_CONTROL_TEXTURE 0x829C
1622#define GL_TESS_EVALUATION_SHADER 0x8E87
1623#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010
1624#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2
1625#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2
1626#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA
1627#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0
1628#define GL_TESS_EVALUATION_TEXTURE 0x829D
1629#define GL_TESS_GEN_MODE 0x8E76
1630#define GL_TESS_GEN_POINT_MODE 0x8E79
1631#define GL_TESS_GEN_SPACING 0x8E77
1632#define GL_TESS_GEN_VERTEX_ORDER 0x8E78
1633#define GL_TEXTURE 0x1702
1634#define GL_TEXTURE0 0x84C0
1635#define GL_TEXTURE0_ARB 0x84C0
1636#define GL_TEXTURE1 0x84C1
1637#define GL_TEXTURE10 0x84CA
1638#define GL_TEXTURE10_ARB 0x84CA
1639#define GL_TEXTURE11 0x84CB
1640#define GL_TEXTURE11_ARB 0x84CB
1641#define GL_TEXTURE12 0x84CC
1642#define GL_TEXTURE12_ARB 0x84CC
1643#define GL_TEXTURE13 0x84CD
1644#define GL_TEXTURE13_ARB 0x84CD
1645#define GL_TEXTURE14 0x84CE
1646#define GL_TEXTURE14_ARB 0x84CE
1647#define GL_TEXTURE15 0x84CF
1648#define GL_TEXTURE15_ARB 0x84CF
1649#define GL_TEXTURE16 0x84D0
1650#define GL_TEXTURE16_ARB 0x84D0
1651#define GL_TEXTURE17 0x84D1
1652#define GL_TEXTURE17_ARB 0x84D1
1653#define GL_TEXTURE18 0x84D2
1654#define GL_TEXTURE18_ARB 0x84D2
1655#define GL_TEXTURE19 0x84D3
1656#define GL_TEXTURE19_ARB 0x84D3
1657#define GL_TEXTURE1_ARB 0x84C1
1658#define GL_TEXTURE2 0x84C2
1659#define GL_TEXTURE20 0x84D4
1660#define GL_TEXTURE20_ARB 0x84D4
1661#define GL_TEXTURE21 0x84D5
1662#define GL_TEXTURE21_ARB 0x84D5
1663#define GL_TEXTURE22 0x84D6
1664#define GL_TEXTURE22_ARB 0x84D6
1665#define GL_TEXTURE23 0x84D7
1666#define GL_TEXTURE23_ARB 0x84D7
1667#define GL_TEXTURE24 0x84D8
1668#define GL_TEXTURE24_ARB 0x84D8
1669#define GL_TEXTURE25 0x84D9
1670#define GL_TEXTURE25_ARB 0x84D9
1671#define GL_TEXTURE26 0x84DA
1672#define GL_TEXTURE26_ARB 0x84DA
1673#define GL_TEXTURE27 0x84DB
1674#define GL_TEXTURE27_ARB 0x84DB
1675#define GL_TEXTURE28 0x84DC
1676#define GL_TEXTURE28_ARB 0x84DC
1677#define GL_TEXTURE29 0x84DD
1678#define GL_TEXTURE29_ARB 0x84DD
1679#define GL_TEXTURE2_ARB 0x84C2
1680#define GL_TEXTURE3 0x84C3
1681#define GL_TEXTURE30 0x84DE
1682#define GL_TEXTURE30_ARB 0x84DE
1683#define GL_TEXTURE31 0x84DF
1684#define GL_TEXTURE31_ARB 0x84DF
1685#define GL_TEXTURE3_ARB 0x84C3
1686#define GL_TEXTURE4 0x84C4
1687#define GL_TEXTURE4_ARB 0x84C4
1688#define GL_TEXTURE5 0x84C5
1689#define GL_TEXTURE5_ARB 0x84C5
1690#define GL_TEXTURE6 0x84C6
1691#define GL_TEXTURE6_ARB 0x84C6
1692#define GL_TEXTURE7 0x84C7
1693#define GL_TEXTURE7_ARB 0x84C7
1694#define GL_TEXTURE8 0x84C8
1695#define GL_TEXTURE8_ARB 0x84C8
1696#define GL_TEXTURE9 0x84C9
1697#define GL_TEXTURE9_ARB 0x84C9
1698#define GL_TEXTURE_1D 0x0DE0
1699#define GL_TEXTURE_1D_ARRAY 0x8C18
1700#define GL_TEXTURE_2D 0x0DE1
1701#define GL_TEXTURE_2D_ARRAY 0x8C1A
1702#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
1703#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
1704#define GL_TEXTURE_3D 0x806F
1705#define GL_TEXTURE_ALPHA_SIZE 0x805F
1706#define GL_TEXTURE_ALPHA_TYPE 0x8C13
1707#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
1708#define GL_TEXTURE_BASE_LEVEL 0x813C
1709#define GL_TEXTURE_BINDING_1D 0x8068
1710#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
1711#define GL_TEXTURE_BINDING_2D 0x8069
1712#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
1713#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
1714#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
1715#define GL_TEXTURE_BINDING_3D 0x806A
1716#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
1717#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
1718#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
1719#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A
1720#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A
1721#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
1722#define GL_TEXTURE_BLUE_SIZE 0x805E
1723#define GL_TEXTURE_BLUE_TYPE 0x8C12
1724#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
1725#define GL_TEXTURE_BORDER_COLOR 0x1004
1726#define GL_TEXTURE_BUFFER 0x8C2A
1727#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
1728#define GL_TEXTURE_BUFFER_OFFSET 0x919D
1729#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F
1730#define GL_TEXTURE_BUFFER_SIZE 0x919E
1731#define GL_TEXTURE_COMPARE_FUNC 0x884D
1732#define GL_TEXTURE_COMPARE_MODE 0x884C
1733#define GL_TEXTURE_COMPRESSED 0x86A1
1734#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
1735#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2
1736#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3
1737#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1
1738#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
1739#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
1740#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
1741#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
1742#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
1743#define GL_TEXTURE_CUBE_MAP 0x8513
1744#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
1745#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
1746#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009
1747#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
1748#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
1749#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
1750#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
1751#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
1752#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
1753#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
1754#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
1755#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
1756#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
1757#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
1758#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
1759#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
1760#define GL_TEXTURE_DEPTH 0x8071
1761#define GL_TEXTURE_DEPTH_SIZE 0x884A
1762#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
1763#define GL_TEXTURE_DEPTH_TYPE 0x8C16
1764#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
1765#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
1766#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
1767#define GL_TEXTURE_GATHER 0x82A2
1768#define GL_TEXTURE_GATHER_SHADOW 0x82A3
1769#define GL_TEXTURE_GREEN_SIZE 0x805D
1770#define GL_TEXTURE_GREEN_TYPE 0x8C11
1771#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
1772#define GL_TEXTURE_HEIGHT 0x1001
1773#define GL_TEXTURE_IMAGE_FORMAT 0x828F
1774#define GL_TEXTURE_IMAGE_TYPE 0x8290
1775#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
1776#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
1777#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
1778#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
1779#define GL_TEXTURE_LOD_BIAS 0x8501
1780#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
1781#define GL_TEXTURE_MAG_FILTER 0x2800
1782#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE
1783#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
1784#define GL_TEXTURE_MAX_LEVEL 0x813D
1785#define GL_TEXTURE_MAX_LOD 0x813B
1786#define GL_TEXTURE_MIN_FILTER 0x2801
1787#define GL_TEXTURE_MIN_LOD 0x813A
1788#define GL_TEXTURE_RECTANGLE 0x84F5
1789#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366
1790#define GL_TEXTURE_RED_SIZE 0x805C
1791#define GL_TEXTURE_RED_TYPE 0x8C10
1792#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
1793#define GL_TEXTURE_SAMPLES 0x9106
1794#define GL_TEXTURE_SHADOW 0x82A1
1795#define GL_TEXTURE_SHARED_SIZE 0x8C3F
1796#define GL_TEXTURE_STENCIL_SIZE 0x88F1
1797#define GL_TEXTURE_SWIZZLE_A 0x8E45
1798#define GL_TEXTURE_SWIZZLE_B 0x8E44
1799#define GL_TEXTURE_SWIZZLE_G 0x8E43
1800#define GL_TEXTURE_SWIZZLE_R 0x8E42
1801#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
1802#define GL_TEXTURE_TARGET 0x1006
1803#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
1804#define GL_TEXTURE_VIEW 0x82B5
1805#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD
1806#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB
1807#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE
1808#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC
1809#define GL_TEXTURE_WIDTH 0x1000
1810#define GL_TEXTURE_WRAP_R 0x8072
1811#define GL_TEXTURE_WRAP_S 0x2802
1812#define GL_TEXTURE_WRAP_T 0x2803
1813#define GL_TIMEOUT_EXPIRED 0x911B
1814#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
1815#define GL_TIMESTAMP 0x8E28
1816#define GL_TIME_ELAPSED 0x88BF
1817#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C
1818#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D
1819#define GL_TRANSFORM_FEEDBACK 0x8E22
1820#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24
1821#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
1822#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25
1823#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
1824#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24
1825#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
1826#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B
1827#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
1828#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23
1829#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
1830#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
1831#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C
1832#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23
1833#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
1834#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4
1835#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
1836#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
1837#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6
1838#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
1839#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3
1840#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4
1841#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5
1842#define GL_TRIANGLES 0x0004
1843#define GL_TRIANGLES_ADJACENCY 0x000C
1844#define GL_TRIANGLES_ADJACENCY_ARB 0x000C
1845#define GL_TRIANGLE_FAN 0x0006
1846#define GL_TRIANGLE_STRIP 0x0005
1847#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
1848#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D
1849#define GL_TRUE 1
1850#define GL_TYPE 0x92FA
1851#define GL_UNDEFINED_VERTEX 0x8260
1852#define GL_UNIFORM 0x92E1
1853#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
1854#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA
1855#define GL_UNIFORM_BARRIER_BIT 0x00000004
1856#define GL_UNIFORM_BLOCK 0x92E2
1857#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
1858#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
1859#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
1860#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
1861#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
1862#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
1863#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC
1864#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
1865#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
1866#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0
1867#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1
1868#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
1869#define GL_UNIFORM_BUFFER 0x8A11
1870#define GL_UNIFORM_BUFFER_BINDING 0x8A28
1871#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
1872#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
1873#define GL_UNIFORM_BUFFER_START 0x8A29
1874#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
1875#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
1876#define GL_UNIFORM_NAME_LENGTH 0x8A39
1877#define GL_UNIFORM_OFFSET 0x8A3B
1878#define GL_UNIFORM_SIZE 0x8A38
1879#define GL_UNIFORM_TYPE 0x8A37
1880#define GL_UNPACK_ALIGNMENT 0x0CF5
1881#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129
1882#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
1883#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A
1884#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127
1885#define GL_UNPACK_IMAGE_HEIGHT 0x806E
1886#define GL_UNPACK_LSB_FIRST 0x0CF1
1887#define GL_UNPACK_ROW_LENGTH 0x0CF2
1888#define GL_UNPACK_SKIP_IMAGES 0x806D
1889#define GL_UNPACK_SKIP_PIXELS 0x0CF4
1890#define GL_UNPACK_SKIP_ROWS 0x0CF3
1891#define GL_UNPACK_SWAP_BYTES 0x0CF0
1892#define GL_UNSIGNALED 0x9118
1893#define GL_UNSIGNED_BYTE 0x1401
1894#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
1895#define GL_UNSIGNED_BYTE_3_3_2 0x8032
1896#define GL_UNSIGNED_INT 0x1405
1897#define GL_UNSIGNED_INT64_ARB 0x140F
1898#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5
1899#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6
1900#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7
1901#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
1902#define GL_UNSIGNED_INT_10_10_10_2 0x8036
1903#define GL_UNSIGNED_INT_24_8 0x84FA
1904#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
1905#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
1906#define GL_UNSIGNED_INT_8_8_8_8 0x8035
1907#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
1908#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB
1909#define GL_UNSIGNED_INT_IMAGE_1D 0x9062
1910#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
1911#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
1912#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
1913#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
1914#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
1915#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
1916#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
1917#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
1918#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
1919#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
1920#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
1921#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
1922#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
1923#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
1924#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
1925#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
1926#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
1927#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
1928#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
1929#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
1930#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
1931#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F
1932#define GL_UNSIGNED_INT_VEC2 0x8DC6
1933#define GL_UNSIGNED_INT_VEC3 0x8DC7
1934#define GL_UNSIGNED_INT_VEC4 0x8DC8
1935#define GL_UNSIGNED_NORMALIZED 0x8C17
1936#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
1937#define GL_UNSIGNED_SHORT 0x1403
1938#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
1939#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
1940#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
1941#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
1942#define GL_UNSIGNED_SHORT_5_6_5 0x8363
1943#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
1944#define GL_UPPER_LEFT 0x8CA2
1945#define GL_VALIDATE_STATUS 0x8B83
1946#define GL_VENDOR 0x1F00
1947#define GL_VERSION 0x1F02
1948#define GL_VERTEX_ARRAY 0x8074
1949#define GL_VERTEX_ARRAY_BINDING 0x85B5
1950#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
1951#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
1952#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
1953#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
1954#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
1955#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE
1956#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
1957#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
1958#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
1959#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E
1960#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
1961#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
1962#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
1963#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
1964#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
1965#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
1966#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
1967#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
1968#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
1969#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
1970#define GL_VERTEX_ATTRIB_BINDING 0x82D4
1971#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5
1972#define GL_VERTEX_BINDING_BUFFER 0x8F4F
1973#define GL_VERTEX_BINDING_DIVISOR 0x82D6
1974#define GL_VERTEX_BINDING_OFFSET 0x82D7
1975#define GL_VERTEX_BINDING_STRIDE 0x82D8
1976#define GL_VERTEX_PROGRAM_ARB 0x8620
1977#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
1978#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
1979#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
1980#define GL_VERTEX_SHADER 0x8B31
1981#define GL_VERTEX_SHADER_ARB 0x8B31
1982#define GL_VERTEX_SHADER_BIT 0x00000001
1983#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0
1984#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0
1985#define GL_VERTEX_SUBROUTINE 0x92E8
1986#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE
1987#define GL_VERTEX_TEXTURE 0x829B
1988#define GL_VERTICES_SUBMITTED 0x82EE
1989#define GL_VERTICES_SUBMITTED_ARB 0x82EE
1990#define GL_VIEWPORT 0x0BA2
1991#define GL_VIEWPORT_BOUNDS_RANGE 0x825D
1992#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F
1993#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C
1994#define GL_VIEW_CLASS_128_BITS 0x82C4
1995#define GL_VIEW_CLASS_16_BITS 0x82CA
1996#define GL_VIEW_CLASS_24_BITS 0x82C9
1997#define GL_VIEW_CLASS_32_BITS 0x82C8
1998#define GL_VIEW_CLASS_48_BITS 0x82C7
1999#define GL_VIEW_CLASS_64_BITS 0x82C6
2000#define GL_VIEW_CLASS_8_BITS 0x82CB
2001#define GL_VIEW_CLASS_96_BITS 0x82C5
2002#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393
2003#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390
2004#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391
2005#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392
2006#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394
2007#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395
2008#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388
2009#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389
2010#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A
2011#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B
2012#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C
2013#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D
2014#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E
2015#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F
2016#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3
2017#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2
2018#define GL_VIEW_CLASS_EAC_R11 0x9383
2019#define GL_VIEW_CLASS_EAC_RG11 0x9384
2020#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387
2021#define GL_VIEW_CLASS_ETC2_RGB 0x9385
2022#define GL_VIEW_CLASS_ETC2_RGBA 0x9386
2023#define GL_VIEW_CLASS_RGTC1_RED 0x82D0
2024#define GL_VIEW_CLASS_RGTC2_RG 0x82D1
2025#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC
2026#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD
2027#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE
2028#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF
2029#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6
2030#define GL_WAIT_FAILED 0x911D
2031#define GL_WEIGHTED_AVERAGE_ARB 0x9367
2032#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
2033#define GL_WRITE_ONLY 0x88B9
2034#define GL_WRITE_ONLY_ARB 0x88B9
2035#define GL_XOR 0x1506
2036#define GL_ZERO 0
2037
2038
2039#ifndef __khrplatform_h_
2040#define __khrplatform_h_
2041
2042/*
2043** Copyright (c) 2008-2018 The Khronos Group Inc.
2044**
2045** Permission is hereby granted, free of charge, to any person obtaining a
2046** copy of this software and/or associated documentation files (the
2047** "Materials"), to deal in the Materials without restriction, including
2048** without limitation the rights to use, copy, modify, merge, publish,
2049** distribute, sublicense, and/or sell copies of the Materials, and to
2050** permit persons to whom the Materials are furnished to do so, subject to
2051** the following conditions:
2052**
2053** The above copyright notice and this permission notice shall be included
2054** in all copies or substantial portions of the Materials.
2055**
2056** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2057** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2058** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2059** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
2060** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2061** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2062** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
2063*/
2064
2065/* Khronos platform-specific types and definitions.
2066 *
2067 * The master copy of khrplatform.h is maintained in the Khronos EGL
2068 * Registry repository at https://github.com/KhronosGroup/EGL-Registry
2069 * The last semantic modification to khrplatform.h was at commit ID:
2070 * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
2071 *
2072 * Adopters may modify this file to suit their platform. Adopters are
2073 * encouraged to submit platform specific modifications to the Khronos
2074 * group so that they can be included in future versions of this file.
2075 * Please submit changes by filing pull requests or issues on
2076 * the EGL Registry repository linked above.
2077 *
2078 *
2079 * See the Implementer's Guidelines for information about where this file
2080 * should be located on your system and for more details of its use:
2081 * http://www.khronos.org/registry/implementers_guide.pdf
2082 *
2083 * This file should be included as
2084 * #include <KHR/khrplatform.h>
2085 * by Khronos client API header files that use its types and defines.
2086 *
2087 * The types in khrplatform.h should only be used to define API-specific types.
2088 *
2089 * Types defined in khrplatform.h:
2090 * khronos_int8_t signed 8 bit
2091 * khronos_uint8_t unsigned 8 bit
2092 * khronos_int16_t signed 16 bit
2093 * khronos_uint16_t unsigned 16 bit
2094 * khronos_int32_t signed 32 bit
2095 * khronos_uint32_t unsigned 32 bit
2096 * khronos_int64_t signed 64 bit
2097 * khronos_uint64_t unsigned 64 bit
2098 * khronos_intptr_t signed same number of bits as a pointer
2099 * khronos_uintptr_t unsigned same number of bits as a pointer
2100 * khronos_ssize_t signed size
2101 * khronos_usize_t unsigned size
2102 * khronos_float_t signed 32 bit floating point
2103 * khronos_time_ns_t unsigned 64 bit time in nanoseconds
2104 * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
2105 * nanoseconds
2106 * khronos_stime_nanoseconds_t signed time interval in nanoseconds
2107 * khronos_boolean_enum_t enumerated boolean type. This should
2108 * only be used as a base type when a client API's boolean type is
2109 * an enum. Client APIs which use an integer or other type for
2110 * booleans cannot use this as the base type for their boolean.
2111 *
2112 * Tokens defined in khrplatform.h:
2113 *
2114 * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
2115 *
2116 * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
2117 * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
2118 *
2119 * Calling convention macros defined in this file:
2120 * KHRONOS_APICALL
2121 * KHRONOS_GLAD_API_PTR
2122 * KHRONOS_APIATTRIBUTES
2123 *
2124 * These may be used in function prototypes as:
2125 *
2126 * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname(
2127 * int arg1,
2128 * int arg2) KHRONOS_APIATTRIBUTES;
2129 */
2130
2131#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
2132# define KHRONOS_STATIC 1
2133#endif
2134
2135/*-------------------------------------------------------------------------
2136 * Definition of KHRONOS_APICALL
2137 *-------------------------------------------------------------------------
2138 * This precedes the return type of the function in the function prototype.
2139 */
2140#if defined(KHRONOS_STATIC)
2141 /* If the preprocessor constant KHRONOS_STATIC is defined, make the
2142 * header compatible with static linking. */
2143# define KHRONOS_APICALL
2144#elif defined(_WIN32)
2145# define KHRONOS_APICALL __declspec(dllimport)
2146#elif defined (__SYMBIAN32__)
2147# define KHRONOS_APICALL IMPORT_C
2148#elif defined(__ANDROID__)
2149# define KHRONOS_APICALL __attribute__((visibility("default")))
2150#else
2151# define KHRONOS_APICALL
2152#endif
2153
2154/*-------------------------------------------------------------------------
2155 * Definition of KHRONOS_GLAD_API_PTR
2156 *-------------------------------------------------------------------------
2157 * This follows the return type of the function and precedes the function
2158 * name in the function prototype.
2159 */
2160#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
2161 /* Win32 but not WinCE */
2162# define KHRONOS_GLAD_API_PTR __stdcall
2163#else
2164# define KHRONOS_GLAD_API_PTR
2165#endif
2166
2167/*-------------------------------------------------------------------------
2168 * Definition of KHRONOS_APIATTRIBUTES
2169 *-------------------------------------------------------------------------
2170 * This follows the closing parenthesis of the function prototype arguments.
2171 */
2172#if defined (__ARMCC_2__)
2173#define KHRONOS_APIATTRIBUTES __softfp
2174#else
2175#define KHRONOS_APIATTRIBUTES
2176#endif
2177
2178/*-------------------------------------------------------------------------
2179 * basic type definitions
2180 *-----------------------------------------------------------------------*/
2181#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
2182
2183
2184/*
2185 * Using <stdint.h>
2186 */
2187#include <stdint.h>
2188typedef int32_t khronos_int32_t;
2189typedef uint32_t khronos_uint32_t;
2190typedef int64_t khronos_int64_t;
2191typedef uint64_t khronos_uint64_t;
2192#define KHRONOS_SUPPORT_INT64 1
2193#define KHRONOS_SUPPORT_FLOAT 1
2194/*
2195 * To support platform where unsigned long cannot be used interchangeably with
2196 * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
2197 * Ideally, we could just use (u)intptr_t everywhere, but this could result in
2198 * ABI breakage if khronos_uintptr_t is changed from unsigned long to
2199 * unsigned long long or similar (this results in different C++ name mangling).
2200 * To avoid changes for existing platforms, we restrict usage of intptr_t to
2201 * platforms where the size of a pointer is larger than the size of long.
2202 */
2203#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
2204#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
2205#define KHRONOS_USE_INTPTR_T
2206#endif
2207#endif
2208
2209#elif defined(__VMS ) || defined(__sgi)
2210
2211/*
2212 * Using <inttypes.h>
2213 */
2214#include <inttypes.h>
2215typedef int32_t khronos_int32_t;
2216typedef uint32_t khronos_uint32_t;
2217typedef int64_t khronos_int64_t;
2218typedef uint64_t khronos_uint64_t;
2219#define KHRONOS_SUPPORT_INT64 1
2220#define KHRONOS_SUPPORT_FLOAT 1
2221
2222#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
2223
2224/*
2225 * Win32
2226 */
2227typedef __int32 khronos_int32_t;
2228typedef unsigned __int32 khronos_uint32_t;
2229typedef __int64 khronos_int64_t;
2230typedef unsigned __int64 khronos_uint64_t;
2231#define KHRONOS_SUPPORT_INT64 1
2232#define KHRONOS_SUPPORT_FLOAT 1
2233
2234#elif defined(__sun__) || defined(__digital__)
2235
2236/*
2237 * Sun or Digital
2238 */
2239typedef int khronos_int32_t;
2240typedef unsigned int khronos_uint32_t;
2241#if defined(__arch64__) || defined(_LP64)
2242typedef long int khronos_int64_t;
2243typedef unsigned long int khronos_uint64_t;
2244#else
2245typedef long long int khronos_int64_t;
2246typedef unsigned long long int khronos_uint64_t;
2247#endif /* __arch64__ */
2248#define KHRONOS_SUPPORT_INT64 1
2249#define KHRONOS_SUPPORT_FLOAT 1
2250
2251#elif 0
2252
2253/*
2254 * Hypothetical platform with no float or int64 support
2255 */
2256typedef int khronos_int32_t;
2257typedef unsigned int khronos_uint32_t;
2258#define KHRONOS_SUPPORT_INT64 0
2259#define KHRONOS_SUPPORT_FLOAT 0
2260
2261#else
2262
2263/*
2264 * Generic fallback
2265 */
2266#include <stdint.h>
2267typedef int32_t khronos_int32_t;
2268typedef uint32_t khronos_uint32_t;
2269typedef int64_t khronos_int64_t;
2270typedef uint64_t khronos_uint64_t;
2271#define KHRONOS_SUPPORT_INT64 1
2272#define KHRONOS_SUPPORT_FLOAT 1
2273
2274#endif
2275
2276
2277/*
2278 * Types that are (so far) the same on all platforms
2279 */
2280typedef signed char khronos_int8_t;
2281typedef unsigned char khronos_uint8_t;
2282typedef signed short int khronos_int16_t;
2283typedef unsigned short int khronos_uint16_t;
2284
2285/*
2286 * Types that differ between LLP64 and LP64 architectures - in LLP64,
2287 * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
2288 * to be the only LLP64 architecture in current use.
2289 */
2290#ifdef KHRONOS_USE_INTPTR_T
2291typedef intptr_t khronos_intptr_t;
2292typedef uintptr_t khronos_uintptr_t;
2293#elif defined(_WIN64)
2294typedef signed long long int khronos_intptr_t;
2295typedef unsigned long long int khronos_uintptr_t;
2296#else
2297typedef signed long int khronos_intptr_t;
2298typedef unsigned long int khronos_uintptr_t;
2299#endif
2300
2301#if defined(_WIN64)
2302typedef signed long long int khronos_ssize_t;
2303typedef unsigned long long int khronos_usize_t;
2304#else
2305typedef signed long int khronos_ssize_t;
2306typedef unsigned long int khronos_usize_t;
2307#endif
2308
2309#if KHRONOS_SUPPORT_FLOAT
2310/*
2311 * Float type
2312 */
2313typedef float khronos_float_t;
2314#endif
2315
2316#if KHRONOS_SUPPORT_INT64
2317/* Time types
2318 *
2319 * These types can be used to represent a time interval in nanoseconds or
2320 * an absolute Unadjusted System Time. Unadjusted System Time is the number
2321 * of nanoseconds since some arbitrary system event (e.g. since the last
2322 * time the system booted). The Unadjusted System Time is an unsigned
2323 * 64 bit value that wraps back to 0 every 584 years. Time intervals
2324 * may be either signed or unsigned.
2325 */
2326typedef khronos_uint64_t khronos_utime_nanoseconds_t;
2327typedef khronos_int64_t khronos_stime_nanoseconds_t;
2328#endif
2329
2330/*
2331 * Dummy value used to pad enum types to 32 bits.
2332 */
2333#ifndef KHRONOS_MAX_ENUM
2334#define KHRONOS_MAX_ENUM 0x7FFFFFFF
2335#endif
2336
2337/*
2338 * Enumerated boolean type
2339 *
2340 * Values other than zero should be considered to be true. Therefore
2341 * comparisons should not be made against KHRONOS_TRUE.
2342 */
2343typedef enum {
2344 KHRONOS_FALSE = 0,
2345 KHRONOS_TRUE = 1,
2346 KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
2347} khronos_boolean_enum_t;
2348
2349#endif /* __khrplatform_h_ */
2350typedef unsigned int GLenum;
2351typedef unsigned char GLboolean;
2352typedef unsigned int GLbitfield;
2353typedef void GLvoid;
2354typedef khronos_int8_t GLbyte;
2355typedef khronos_uint8_t GLubyte;
2356typedef khronos_int16_t GLshort;
2357typedef khronos_uint16_t GLushort;
2358typedef int GLint;
2359typedef unsigned int GLuint;
2360typedef khronos_int32_t GLclampx;
2361typedef int GLsizei;
2362typedef khronos_float_t GLfloat;
2363typedef khronos_float_t GLclampf;
2364typedef double GLdouble;
2365typedef double GLclampd;
2366typedef void *GLeglClientBufferEXT;
2367typedef void *GLeglImageOES;
2368typedef char GLchar;
2369typedef char GLcharARB;
2370#ifdef __APPLE__
2371typedef void *GLhandleARB;
2372#else
2373typedef unsigned int GLhandleARB;
2374#endif
2375typedef khronos_uint16_t GLhalf;
2376typedef khronos_uint16_t GLhalfARB;
2377typedef khronos_int32_t GLfixed;
2378#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
2379typedef khronos_intptr_t GLintptr;
2380#else
2381typedef khronos_intptr_t GLintptr;
2382#endif
2383#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
2384typedef khronos_intptr_t GLintptrARB;
2385#else
2386typedef khronos_intptr_t GLintptrARB;
2387#endif
2388#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
2389typedef khronos_ssize_t GLsizeiptr;
2390#else
2391typedef khronos_ssize_t GLsizeiptr;
2392#endif
2393#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
2394typedef khronos_ssize_t GLsizeiptrARB;
2395#else
2396typedef khronos_ssize_t GLsizeiptrARB;
2397#endif
2398typedef khronos_int64_t GLint64;
2399typedef khronos_int64_t GLint64EXT;
2400typedef khronos_uint64_t GLuint64;
2401typedef khronos_uint64_t GLuint64EXT;
2402typedef struct __GLsync *GLsync;
2403struct _cl_context;
2404struct _cl_event;
2405typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
2406typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
2407typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
2408typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
2409typedef unsigned short GLhalfNV;
2410typedef GLintptr GLvdpauSurfaceNV;
2411typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void);
2412
2413
2414#define GL_VERSION_1_0 1
2415GLAD_API_CALL int GLAD_GL_VERSION_1_0;
2416#define GL_VERSION_1_1 1
2417GLAD_API_CALL int GLAD_GL_VERSION_1_1;
2418#define GL_VERSION_1_2 1
2419GLAD_API_CALL int GLAD_GL_VERSION_1_2;
2420#define GL_VERSION_1_3 1
2421GLAD_API_CALL int GLAD_GL_VERSION_1_3;
2422#define GL_VERSION_1_4 1
2423GLAD_API_CALL int GLAD_GL_VERSION_1_4;
2424#define GL_VERSION_1_5 1
2425GLAD_API_CALL int GLAD_GL_VERSION_1_5;
2426#define GL_VERSION_2_0 1
2427GLAD_API_CALL int GLAD_GL_VERSION_2_0;
2428#define GL_VERSION_2_1 1
2429GLAD_API_CALL int GLAD_GL_VERSION_2_1;
2430#define GL_VERSION_3_0 1
2431GLAD_API_CALL int GLAD_GL_VERSION_3_0;
2432#define GL_VERSION_3_1 1
2433GLAD_API_CALL int GLAD_GL_VERSION_3_1;
2434#define GL_VERSION_3_2 1
2435GLAD_API_CALL int GLAD_GL_VERSION_3_2;
2436#define GL_VERSION_3_3 1
2437GLAD_API_CALL int GLAD_GL_VERSION_3_3;
2438#define GL_VERSION_4_0 1
2439GLAD_API_CALL int GLAD_GL_VERSION_4_0;
2440#define GL_VERSION_4_1 1
2441GLAD_API_CALL int GLAD_GL_VERSION_4_1;
2442#define GL_VERSION_4_2 1
2443GLAD_API_CALL int GLAD_GL_VERSION_4_2;
2444#define GL_VERSION_4_3 1
2445GLAD_API_CALL int GLAD_GL_VERSION_4_3;
2446#define GL_ARB_ES2_compatibility 1
2447GLAD_API_CALL int GLAD_GL_ARB_ES2_compatibility;
2448#define GL_ARB_ES3_1_compatibility 1
2449GLAD_API_CALL int GLAD_GL_ARB_ES3_1_compatibility;
2450#define GL_ARB_ES3_2_compatibility 1
2451GLAD_API_CALL int GLAD_GL_ARB_ES3_2_compatibility;
2452#define GL_ARB_ES3_compatibility 1
2453GLAD_API_CALL int GLAD_GL_ARB_ES3_compatibility;
2454#define GL_ARB_blend_func_extended 1
2455GLAD_API_CALL int GLAD_GL_ARB_blend_func_extended;
2456#define GL_ARB_buffer_storage 1
2457GLAD_API_CALL int GLAD_GL_ARB_buffer_storage;
2458#define GL_ARB_clear_buffer_object 1
2459GLAD_API_CALL int GLAD_GL_ARB_clear_buffer_object;
2460#define GL_ARB_clear_texture 1
2461GLAD_API_CALL int GLAD_GL_ARB_clear_texture;
2462#define GL_ARB_color_buffer_float 1
2463GLAD_API_CALL int GLAD_GL_ARB_color_buffer_float;
2464#define GL_ARB_compatibility 1
2465GLAD_API_CALL int GLAD_GL_ARB_compatibility;
2466#define GL_ARB_compressed_texture_pixel_storage 1
2467GLAD_API_CALL int GLAD_GL_ARB_compressed_texture_pixel_storage;
2468#define GL_ARB_compute_shader 1
2469GLAD_API_CALL int GLAD_GL_ARB_compute_shader;
2470#define GL_ARB_compute_variable_group_size 1
2471GLAD_API_CALL int GLAD_GL_ARB_compute_variable_group_size;
2472#define GL_ARB_copy_buffer 1
2473GLAD_API_CALL int GLAD_GL_ARB_copy_buffer;
2474#define GL_ARB_copy_image 1
2475GLAD_API_CALL int GLAD_GL_ARB_copy_image;
2476#define GL_ARB_debug_output 1
2477GLAD_API_CALL int GLAD_GL_ARB_debug_output;
2478#define GL_ARB_depth_buffer_float 1
2479GLAD_API_CALL int GLAD_GL_ARB_depth_buffer_float;
2480#define GL_ARB_depth_clamp 1
2481GLAD_API_CALL int GLAD_GL_ARB_depth_clamp;
2482#define GL_ARB_depth_texture 1
2483GLAD_API_CALL int GLAD_GL_ARB_depth_texture;
2484#define GL_ARB_direct_state_access 1
2485GLAD_API_CALL int GLAD_GL_ARB_direct_state_access;
2486#define GL_ARB_draw_buffers 1
2487GLAD_API_CALL int GLAD_GL_ARB_draw_buffers;
2488#define GL_ARB_draw_buffers_blend 1
2489GLAD_API_CALL int GLAD_GL_ARB_draw_buffers_blend;
2490#define GL_ARB_draw_elements_base_vertex 1
2491GLAD_API_CALL int GLAD_GL_ARB_draw_elements_base_vertex;
2492#define GL_ARB_draw_indirect 1
2493GLAD_API_CALL int GLAD_GL_ARB_draw_indirect;
2494#define GL_ARB_draw_instanced 1
2495GLAD_API_CALL int GLAD_GL_ARB_draw_instanced;
2496#define GL_ARB_enhanced_layouts 1
2497GLAD_API_CALL int GLAD_GL_ARB_enhanced_layouts;
2498#define GL_ARB_explicit_attrib_location 1
2499GLAD_API_CALL int GLAD_GL_ARB_explicit_attrib_location;
2500#define GL_ARB_explicit_uniform_location 1
2501GLAD_API_CALL int GLAD_GL_ARB_explicit_uniform_location;
2502#define GL_ARB_fragment_coord_conventions 1
2503GLAD_API_CALL int GLAD_GL_ARB_fragment_coord_conventions;
2504#define GL_ARB_fragment_layer_viewport 1
2505GLAD_API_CALL int GLAD_GL_ARB_fragment_layer_viewport;
2506#define GL_ARB_fragment_program 1
2507GLAD_API_CALL int GLAD_GL_ARB_fragment_program;
2508#define GL_ARB_fragment_program_shadow 1
2509GLAD_API_CALL int GLAD_GL_ARB_fragment_program_shadow;
2510#define GL_ARB_fragment_shader 1
2511GLAD_API_CALL int GLAD_GL_ARB_fragment_shader;
2512#define GL_ARB_fragment_shader_interlock 1
2513GLAD_API_CALL int GLAD_GL_ARB_fragment_shader_interlock;
2514#define GL_ARB_framebuffer_no_attachments 1
2515GLAD_API_CALL int GLAD_GL_ARB_framebuffer_no_attachments;
2516#define GL_ARB_framebuffer_object 1
2517GLAD_API_CALL int GLAD_GL_ARB_framebuffer_object;
2518#define GL_ARB_framebuffer_sRGB 1
2519GLAD_API_CALL int GLAD_GL_ARB_framebuffer_sRGB;
2520#define GL_ARB_geometry_shader4 1
2521GLAD_API_CALL int GLAD_GL_ARB_geometry_shader4;
2522#define GL_ARB_get_program_binary 1
2523GLAD_API_CALL int GLAD_GL_ARB_get_program_binary;
2524#define GL_ARB_get_texture_sub_image 1
2525GLAD_API_CALL int GLAD_GL_ARB_get_texture_sub_image;
2526#define GL_ARB_gl_spirv 1
2527GLAD_API_CALL int GLAD_GL_ARB_gl_spirv;
2528#define GL_ARB_gpu_shader5 1
2529GLAD_API_CALL int GLAD_GL_ARB_gpu_shader5;
2530#define GL_ARB_gpu_shader_fp64 1
2531GLAD_API_CALL int GLAD_GL_ARB_gpu_shader_fp64;
2532#define GL_ARB_gpu_shader_int64 1
2533GLAD_API_CALL int GLAD_GL_ARB_gpu_shader_int64;
2534#define GL_ARB_half_float_pixel 1
2535GLAD_API_CALL int GLAD_GL_ARB_half_float_pixel;
2536#define GL_ARB_half_float_vertex 1
2537GLAD_API_CALL int GLAD_GL_ARB_half_float_vertex;
2538#define GL_ARB_instanced_arrays 1
2539GLAD_API_CALL int GLAD_GL_ARB_instanced_arrays;
2540#define GL_ARB_internalformat_query 1
2541GLAD_API_CALL int GLAD_GL_ARB_internalformat_query;
2542#define GL_ARB_internalformat_query2 1
2543GLAD_API_CALL int GLAD_GL_ARB_internalformat_query2;
2544#define GL_ARB_map_buffer_range 1
2545GLAD_API_CALL int GLAD_GL_ARB_map_buffer_range;
2546#define GL_ARB_multi_bind 1
2547GLAD_API_CALL int GLAD_GL_ARB_multi_bind;
2548#define GL_ARB_multi_draw_indirect 1
2549GLAD_API_CALL int GLAD_GL_ARB_multi_draw_indirect;
2550#define GL_ARB_multisample 1
2551GLAD_API_CALL int GLAD_GL_ARB_multisample;
2552#define GL_ARB_multitexture 1
2553GLAD_API_CALL int GLAD_GL_ARB_multitexture;
2554#define GL_ARB_occlusion_query 1
2555GLAD_API_CALL int GLAD_GL_ARB_occlusion_query;
2556#define GL_ARB_occlusion_query2 1
2557GLAD_API_CALL int GLAD_GL_ARB_occlusion_query2;
2558#define GL_ARB_pipeline_statistics_query 1
2559GLAD_API_CALL int GLAD_GL_ARB_pipeline_statistics_query;
2560#define GL_ARB_query_buffer_object 1
2561GLAD_API_CALL int GLAD_GL_ARB_query_buffer_object;
2562#define GL_ARB_sample_locations 1
2563GLAD_API_CALL int GLAD_GL_ARB_sample_locations;
2564#define GL_ARB_sample_shading 1
2565GLAD_API_CALL int GLAD_GL_ARB_sample_shading;
2566#define GL_ARB_seamless_cube_map 1
2567GLAD_API_CALL int GLAD_GL_ARB_seamless_cube_map;
2568#define GL_ARB_seamless_cubemap_per_texture 1
2569GLAD_API_CALL int GLAD_GL_ARB_seamless_cubemap_per_texture;
2570#define GL_ARB_shader_atomic_counter_ops 1
2571GLAD_API_CALL int GLAD_GL_ARB_shader_atomic_counter_ops;
2572#define GL_ARB_shader_atomic_counters 1
2573GLAD_API_CALL int GLAD_GL_ARB_shader_atomic_counters;
2574#define GL_ARB_shader_bit_encoding 1
2575GLAD_API_CALL int GLAD_GL_ARB_shader_bit_encoding;
2576#define GL_ARB_shader_clock 1
2577GLAD_API_CALL int GLAD_GL_ARB_shader_clock;
2578#define GL_ARB_shader_image_load_store 1
2579GLAD_API_CALL int GLAD_GL_ARB_shader_image_load_store;
2580#define GL_ARB_shader_image_size 1
2581GLAD_API_CALL int GLAD_GL_ARB_shader_image_size;
2582#define GL_ARB_shader_objects 1
2583GLAD_API_CALL int GLAD_GL_ARB_shader_objects;
2584#define GL_ARB_shader_storage_buffer_object 1
2585GLAD_API_CALL int GLAD_GL_ARB_shader_storage_buffer_object;
2586#define GL_ARB_shader_texture_lod 1
2587GLAD_API_CALL int GLAD_GL_ARB_shader_texture_lod;
2588#define GL_ARB_shading_language_100 1
2589GLAD_API_CALL int GLAD_GL_ARB_shading_language_100;
2590#define GL_ARB_shading_language_420pack 1
2591GLAD_API_CALL int GLAD_GL_ARB_shading_language_420pack;
2592#define GL_ARB_shading_language_include 1
2593GLAD_API_CALL int GLAD_GL_ARB_shading_language_include;
2594#define GL_ARB_shading_language_packing 1
2595GLAD_API_CALL int GLAD_GL_ARB_shading_language_packing;
2596#define GL_ARB_spirv_extensions 1
2597GLAD_API_CALL int GLAD_GL_ARB_spirv_extensions;
2598#define GL_ARB_tessellation_shader 1
2599GLAD_API_CALL int GLAD_GL_ARB_tessellation_shader;
2600#define GL_ARB_texture_border_clamp 1
2601GLAD_API_CALL int GLAD_GL_ARB_texture_border_clamp;
2602#define GL_ARB_texture_buffer_object_rgb32 1
2603GLAD_API_CALL int GLAD_GL_ARB_texture_buffer_object_rgb32;
2604#define GL_ARB_texture_compression 1
2605GLAD_API_CALL int GLAD_GL_ARB_texture_compression;
2606#define GL_ARB_texture_cube_map 1
2607GLAD_API_CALL int GLAD_GL_ARB_texture_cube_map;
2608#define GL_ARB_texture_cube_map_array 1
2609GLAD_API_CALL int GLAD_GL_ARB_texture_cube_map_array;
2610#define GL_ARB_texture_env_add 1
2611GLAD_API_CALL int GLAD_GL_ARB_texture_env_add;
2612#define GL_ARB_texture_filter_anisotropic 1
2613GLAD_API_CALL int GLAD_GL_ARB_texture_filter_anisotropic;
2614#define GL_ARB_texture_filter_minmax 1
2615GLAD_API_CALL int GLAD_GL_ARB_texture_filter_minmax;
2616#define GL_ARB_texture_float 1
2617GLAD_API_CALL int GLAD_GL_ARB_texture_float;
2618#define GL_ARB_texture_mirror_clamp_to_edge 1
2619GLAD_API_CALL int GLAD_GL_ARB_texture_mirror_clamp_to_edge;
2620#define GL_ARB_texture_mirrored_repeat 1
2621GLAD_API_CALL int GLAD_GL_ARB_texture_mirrored_repeat;
2622#define GL_ARB_texture_multisample 1
2623GLAD_API_CALL int GLAD_GL_ARB_texture_multisample;
2624#define GL_ARB_texture_non_power_of_two 1
2625GLAD_API_CALL int GLAD_GL_ARB_texture_non_power_of_two;
2626#define GL_ARB_texture_rg 1
2627GLAD_API_CALL int GLAD_GL_ARB_texture_rg;
2628#define GL_ARB_texture_storage 1
2629GLAD_API_CALL int GLAD_GL_ARB_texture_storage;
2630#define GL_ARB_texture_swizzle 1
2631GLAD_API_CALL int GLAD_GL_ARB_texture_swizzle;
2632#define GL_ARB_texture_view 1
2633GLAD_API_CALL int GLAD_GL_ARB_texture_view;
2634#define GL_ARB_timer_query 1
2635GLAD_API_CALL int GLAD_GL_ARB_timer_query;
2636#define GL_ARB_transpose_matrix 1
2637GLAD_API_CALL int GLAD_GL_ARB_transpose_matrix;
2638#define GL_ARB_uniform_buffer_object 1
2639GLAD_API_CALL int GLAD_GL_ARB_uniform_buffer_object;
2640#define GL_ARB_vertex_array_bgra 1
2641GLAD_API_CALL int GLAD_GL_ARB_vertex_array_bgra;
2642#define GL_ARB_vertex_array_object 1
2643GLAD_API_CALL int GLAD_GL_ARB_vertex_array_object;
2644#define GL_ARB_vertex_attrib_binding 1
2645GLAD_API_CALL int GLAD_GL_ARB_vertex_attrib_binding;
2646#define GL_ARB_vertex_buffer_object 1
2647GLAD_API_CALL int GLAD_GL_ARB_vertex_buffer_object;
2648#define GL_ARB_vertex_program 1
2649GLAD_API_CALL int GLAD_GL_ARB_vertex_program;
2650#define GL_ARB_vertex_shader 1
2651GLAD_API_CALL int GLAD_GL_ARB_vertex_shader;
2652#define GL_EXT_draw_instanced 1
2653GLAD_API_CALL int GLAD_GL_EXT_draw_instanced;
2654#define GL_EXT_fog_coord 1
2655GLAD_API_CALL int GLAD_GL_EXT_fog_coord;
2656#define GL_EXT_framebuffer_blit 1
2657GLAD_API_CALL int GLAD_GL_EXT_framebuffer_blit;
2658#define GL_EXT_framebuffer_multisample 1
2659GLAD_API_CALL int GLAD_GL_EXT_framebuffer_multisample;
2660#define GL_EXT_framebuffer_object 1
2661GLAD_API_CALL int GLAD_GL_EXT_framebuffer_object;
2662#define GL_EXT_framebuffer_sRGB 1
2663GLAD_API_CALL int GLAD_GL_EXT_framebuffer_sRGB;
2664#define GL_EXT_texture_compression_s3tc 1
2665GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc;
2666#define GL_EXT_texture_filter_anisotropic 1
2667GLAD_API_CALL int GLAD_GL_EXT_texture_filter_anisotropic;
2668#define GL_EXT_texture_mirror_clamp 1
2669GLAD_API_CALL int GLAD_GL_EXT_texture_mirror_clamp;
2670#define GL_KHR_texture_compression_astc_hdr 1
2671GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_hdr;
2672#define GL_KHR_texture_compression_astc_ldr 1
2673GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_ldr;
2674#define GL_OES_compressed_paletted_texture 1
2675GLAD_API_CALL int GLAD_GL_OES_compressed_paletted_texture;
2676#define GL_OES_fixed_point 1
2677GLAD_API_CALL int GLAD_GL_OES_fixed_point;
2678
2679
2680typedef void (GLAD_API_PTR *PFNGLACCUMXOESPROC)(GLenum op, GLfixed value);
2681typedef void (GLAD_API_PTR *PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, GLuint program);
2682typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture);
2683typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREARBPROC)(GLenum texture);
2684typedef void (GLAD_API_PTR *PFNGLALPHAFUNCXOESPROC)(GLenum func, GLfixed ref);
2685typedef void (GLAD_API_PTR *PFNGLATTACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB obj);
2686typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
2687typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode);
2688typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum target, GLuint id);
2689typedef void (GLAD_API_PTR *PFNGLBEGINQUERYARBPROC)(GLenum target, GLuint id);
2690typedef void (GLAD_API_PTR *PFNGLBEGINQUERYINDEXEDPROC)(GLenum target, GLuint index, GLuint id);
2691typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode);
2692typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name);
2693typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONARBPROC)(GLhandleARB programObj, GLuint index, const GLcharARB * name);
2694typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
2695typedef void (GLAD_API_PTR *PFNGLBINDBUFFERARBPROC)(GLenum target, GLuint buffer);
2696typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer);
2697typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
2698typedef void (GLAD_API_PTR *PFNGLBINDBUFFERSBASEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint * buffers);
2699typedef void (GLAD_API_PTR *PFNGLBINDBUFFERSRANGEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizeiptr * sizes);
2700typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar * name);
2701typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);
2702typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
2703typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
2704typedef void (GLAD_API_PTR *PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
2705typedef void (GLAD_API_PTR *PFNGLBINDIMAGETEXTURESPROC)(GLuint first, GLsizei count, const GLuint * textures);
2706typedef void (GLAD_API_PTR *PFNGLBINDPROGRAMARBPROC)(GLenum target, GLuint program);
2707typedef void (GLAD_API_PTR *PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline);
2708typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
2709typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
2710typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler);
2711typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERSPROC)(GLuint first, GLsizei count, const GLuint * samplers);
2712typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
2713typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREUNITPROC)(GLuint unit, GLuint texture);
2714typedef void (GLAD_API_PTR *PFNGLBINDTEXTURESPROC)(GLuint first, GLsizei count, const GLuint * textures);
2715typedef void (GLAD_API_PTR *PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, GLuint id);
2716typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint array);
2717typedef void (GLAD_API_PTR *PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
2718typedef void (GLAD_API_PTR *PFNGLBINDVERTEXBUFFERSPROC)(GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizei * strides);
2719typedef void (GLAD_API_PTR *PFNGLBITMAPXOESPROC)(GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte * bitmap);
2720typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
2721typedef void (GLAD_API_PTR *PFNGLBLENDCOLORXOESPROC)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
2722typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode);
2723typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
2724typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
2725typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIARBPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
2726typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIPROC)(GLuint buf, GLenum mode);
2727typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIARBPROC)(GLuint buf, GLenum mode);
2728typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
2729typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
2730typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
2731typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIARBPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
2732typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIPROC)(GLuint buf, GLenum src, GLenum dst);
2733typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIARBPROC)(GLuint buf, GLenum src, GLenum dst);
2734typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
2735typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFEREXTPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
2736typedef void (GLAD_API_PTR *PFNGLBLITNAMEDFRAMEBUFFERPROC)(GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
2737typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
2738typedef void (GLAD_API_PTR *PFNGLBUFFERDATAARBPROC)(GLenum target, GLsizeiptrARB size, const void * data, GLenum usage);
2739typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags);
2740typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
2741typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAARBPROC)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void * data);
2742typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
2743typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
2744typedef GLenum (GLAD_API_PTR *PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)(GLuint framebuffer, GLenum target);
2745typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp);
2746typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORARBPROC)(GLenum target, GLenum clamp);
2747typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask);
2748typedef void (GLAD_API_PTR *PFNGLCLEARACCUMXOESPROC)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
2749typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERDATAPROC)(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void * data);
2750typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERSUBDATAPROC)(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void * data);
2751typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
2752typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat * value);
2753typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint * value);
2754typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint * value);
2755typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
2756typedef void (GLAD_API_PTR *PFNGLCLEARCOLORXOESPROC)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
2757typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble depth);
2758typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d);
2759typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHXOESPROC)(GLfixed depth);
2760typedef void (GLAD_API_PTR *PFNGLCLEARNAMEDBUFFERDATAPROC)(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void * data);
2761typedef void (GLAD_API_PTR *PFNGLCLEARNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void * data);
2762typedef void (GLAD_API_PTR *PFNGLCLEARNAMEDFRAMEBUFFERFIPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
2763typedef void (GLAD_API_PTR *PFNGLCLEARNAMEDFRAMEBUFFERFVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat * value);
2764typedef void (GLAD_API_PTR *PFNGLCLEARNAMEDFRAMEBUFFERIVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint * value);
2765typedef void (GLAD_API_PTR *PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint * value);
2766typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s);
2767typedef void (GLAD_API_PTR *PFNGLCLEARTEXIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void * data);
2768typedef void (GLAD_API_PTR *PFNGLCLEARTEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data);
2769typedef void (GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREARBPROC)(GLenum texture);
2770typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
2771typedef void (GLAD_API_PTR *PFNGLCLIPPLANEXOESPROC)(GLenum plane, const GLfixed * equation);
2772typedef void (GLAD_API_PTR *PFNGLCOLOR3XOESPROC)(GLfixed red, GLfixed green, GLfixed blue);
2773typedef void (GLAD_API_PTR *PFNGLCOLOR3XVOESPROC)(const GLfixed * components);
2774typedef void (GLAD_API_PTR *PFNGLCOLOR4XOESPROC)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
2775typedef void (GLAD_API_PTR *PFNGLCOLOR4XVOESPROC)(const GLfixed * components);
2776typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
2777typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
2778typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader);
2779typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERARBPROC)(GLhandleARB shaderObj);
2780typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERINCLUDEARBPROC)(GLuint shader, GLsizei count, const GLchar *const* path, const GLint * length);
2781typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data);
2782typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data);
2783typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
2784typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
2785typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
2786typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
2787typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data);
2788typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data);
2789typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
2790typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
2791typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
2792typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
2793typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data);
2794typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
2795typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
2796typedef void (GLAD_API_PTR *PFNGLCONVOLUTIONPARAMETERXOESPROC)(GLenum target, GLenum pname, GLfixed param);
2797typedef void (GLAD_API_PTR *PFNGLCONVOLUTIONPARAMETERXVOESPROC)(GLenum target, GLenum pname, const GLfixed * params);
2798typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
2799typedef void (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAPROC)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
2800typedef void (GLAD_API_PTR *PFNGLCOPYNAMEDBUFFERSUBDATAPROC)(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
2801typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
2802typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
2803typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
2804typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2805typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2806typedef void (GLAD_API_PTR *PFNGLCOPYTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
2807typedef void (GLAD_API_PTR *PFNGLCOPYTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2808typedef void (GLAD_API_PTR *PFNGLCOPYTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2809typedef void (GLAD_API_PTR *PFNGLCREATEBUFFERSPROC)(GLsizei n, GLuint * buffers);
2810typedef void (GLAD_API_PTR *PFNGLCREATEFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
2811typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
2812typedef GLhandleARB (GLAD_API_PTR *PFNGLCREATEPROGRAMOBJECTARBPROC)(void);
2813typedef void (GLAD_API_PTR *PFNGLCREATEPROGRAMPIPELINESPROC)(GLsizei n, GLuint * pipelines);
2814typedef void (GLAD_API_PTR *PFNGLCREATEQUERIESPROC)(GLenum target, GLsizei n, GLuint * ids);
2815typedef void (GLAD_API_PTR *PFNGLCREATERENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
2816typedef void (GLAD_API_PTR *PFNGLCREATESAMPLERSPROC)(GLsizei n, GLuint * samplers);
2817typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type);
2818typedef GLhandleARB (GLAD_API_PTR *PFNGLCREATESHADEROBJECTARBPROC)(GLenum shaderType);
2819typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROGRAMVPROC)(GLenum type, GLsizei count, const GLchar *const* strings);
2820typedef void (GLAD_API_PTR *PFNGLCREATETEXTURESPROC)(GLenum target, GLsizei n, GLuint * textures);
2821typedef void (GLAD_API_PTR *PFNGLCREATETRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint * ids);
2822typedef void (GLAD_API_PTR *PFNGLCREATEVERTEXARRAYSPROC)(GLsizei n, GLuint * arrays);
2823typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode);
2824typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void * userParam);
2825typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKARBPROC)(GLDEBUGPROCARB callback, const void * userParam);
2826typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled);
2827typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLARBPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled);
2828typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf);
2829typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTARBPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf);
2830typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers);
2831typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSARBPROC)(GLsizei n, const GLuint * buffers);
2832typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers);
2833typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint * framebuffers);
2834typedef void (GLAD_API_PTR *PFNGLDELETENAMEDSTRINGARBPROC)(GLint namelen, const GLchar * name);
2835typedef void (GLAD_API_PTR *PFNGLDELETEOBJECTARBPROC)(GLhandleARB obj);
2836typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program);
2837typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPIPELINESPROC)(GLsizei n, const GLuint * pipelines);
2838typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMSARBPROC)(GLsizei n, const GLuint * programs);
2839typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint * ids);
2840typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESARBPROC)(GLsizei n, const GLuint * ids);
2841typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers);
2842typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint * renderbuffers);
2843typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint * samplers);
2844typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader);
2845typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync sync);
2846typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures);
2847typedef void (GLAD_API_PTR *PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, const GLuint * ids);
2848typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint * arrays);
2849typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func);
2850typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag);
2851typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f);
2852typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEARRAYVPROC)(GLuint first, GLsizei count, const GLdouble * v);
2853typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEINDEXEDPROC)(GLuint index, GLdouble n, GLdouble f);
2854typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
2855typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEXOESPROC)(GLfixed n, GLfixed f);
2856typedef void (GLAD_API_PTR *PFNGLDETACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB attachedObj);
2857typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
2858typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap);
2859typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, GLuint index);
2860typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
2861typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
2862typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum target, GLuint index);
2863typedef void (GLAD_API_PTR *PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
2864typedef void (GLAD_API_PTR *PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z);
2865typedef void (GLAD_API_PTR *PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect);
2866typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
2867typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, const void * indirect);
2868typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
2869typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDARBPROC)(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
2870typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
2871typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDEXTPROC)(GLenum mode, GLint start, GLsizei count, GLsizei primcount);
2872typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum buf);
2873typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum * bufs);
2874typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSARBPROC)(GLsizei n, const GLenum * bufs);
2875typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices);
2876typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2877typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void * indirect);
2878typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount);
2879typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDARBPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
2880typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLuint baseinstance);
2881typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
2882typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
2883typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
2884typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices);
2885typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2886typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKPROC)(GLenum mode, GLuint id);
2887typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)(GLenum mode, GLuint id, GLsizei instancecount);
2888typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)(GLenum mode, GLuint id, GLuint stream);
2889typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)(GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);
2890typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap);
2891typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, GLuint index);
2892typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
2893typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
2894typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum target, GLuint index);
2895typedef void (GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void);
2896typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum target);
2897typedef void (GLAD_API_PTR *PFNGLENDQUERYARBPROC)(GLenum target);
2898typedef void (GLAD_API_PTR *PFNGLENDQUERYINDEXEDPROC)(GLenum target, GLuint index);
2899typedef void (GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void);
2900typedef void (GLAD_API_PTR *PFNGLEVALCOORD1XOESPROC)(GLfixed u);
2901typedef void (GLAD_API_PTR *PFNGLEVALCOORD1XVOESPROC)(const GLfixed * coords);
2902typedef void (GLAD_API_PTR *PFNGLEVALCOORD2XOESPROC)(GLfixed u, GLfixed v);
2903typedef void (GLAD_API_PTR *PFNGLEVALCOORD2XVOESPROC)(const GLfixed * coords);
2904typedef void (GLAD_API_PTR *PFNGLEVALUATEDEPTHVALUESARBPROC)(void);
2905typedef void (GLAD_API_PTR *PFNGLFEEDBACKBUFFERXOESPROC)(GLsizei n, GLenum type, const GLfixed * buffer);
2906typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags);
2907typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
2908typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
2909typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
2910typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length);
2911typedef void (GLAD_API_PTR *PFNGLFOGCOORDPOINTEREXTPROC)(GLenum type, GLsizei stride, const void * pointer);
2912typedef void (GLAD_API_PTR *PFNGLFOGCOORDDEXTPROC)(GLdouble coord);
2913typedef void (GLAD_API_PTR *PFNGLFOGCOORDDVEXTPROC)(const GLdouble * coord);
2914typedef void (GLAD_API_PTR *PFNGLFOGCOORDFEXTPROC)(GLfloat coord);
2915typedef void (GLAD_API_PTR *PFNGLFOGCOORDFVEXTPROC)(const GLfloat * coord);
2916typedef void (GLAD_API_PTR *PFNGLFOGXOESPROC)(GLenum pname, GLfixed param);
2917typedef void (GLAD_API_PTR *PFNGLFOGXVOESPROC)(GLenum pname, const GLfixed * param);
2918typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
2919typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
2920typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
2921typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)(GLenum target, GLuint start, GLsizei count, const GLfloat * v);
2922typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
2923typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
2924typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
2925typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
2926typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
2927typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
2928typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
2929typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREARBPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
2930typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREFACEARBPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
2931typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
2932typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERARBPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
2933typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode);
2934typedef void (GLAD_API_PTR *PFNGLFRUSTUMXOESPROC)(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
2935typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers);
2936typedef void (GLAD_API_PTR *PFNGLGENBUFFERSARBPROC)(GLsizei n, GLuint * buffers);
2937typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
2938typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint * framebuffers);
2939typedef void (GLAD_API_PTR *PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, GLuint * pipelines);
2940typedef void (GLAD_API_PTR *PFNGLGENPROGRAMSARBPROC)(GLsizei n, GLuint * programs);
2941typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei n, GLuint * ids);
2942typedef void (GLAD_API_PTR *PFNGLGENQUERIESARBPROC)(GLsizei n, GLuint * ids);
2943typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
2944typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint * renderbuffers);
2945typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint * samplers);
2946typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures);
2947typedef void (GLAD_API_PTR *PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint * ids);
2948typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint * arrays);
2949typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target);
2950typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPEXTPROC)(GLenum target);
2951typedef void (GLAD_API_PTR *PFNGLGENERATETEXTUREMIPMAPPROC)(GLuint texture);
2952typedef void (GLAD_API_PTR *PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)(GLuint program, GLuint bufferIndex, GLenum pname, GLint * params);
2953typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
2954typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBARBPROC)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, GLint * size, GLenum * type, GLcharARB * name);
2955typedef void (GLAD_API_PTR *PFNGLGETACTIVESUBROUTINENAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name);
2956typedef void (GLAD_API_PTR *PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name);
2957typedef void (GLAD_API_PTR *PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)(GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint * values);
2958typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
2959typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMARBPROC)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, GLint * size, GLenum * type, GLcharARB * name);
2960typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName);
2961typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params);
2962typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName);
2963typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params);
2964typedef void (GLAD_API_PTR *PFNGLGETATTACHEDOBJECTSARBPROC)(GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj);
2965typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
2966typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name);
2967typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB * name);
2968typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean * data);
2969typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data);
2970typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 * params);
2971typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2972typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVARBPROC)(GLenum target, GLenum pname, GLint * params);
2973typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void ** params);
2974typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVARBPROC)(GLenum target, GLenum pname, void ** params);
2975typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void * data);
2976typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAARBPROC)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data);
2977typedef void (GLAD_API_PTR *PFNGLGETCLIPPLANEXOESPROC)(GLenum plane, GLfixed * equation);
2978typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void * img);
2979typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)(GLenum target, GLint level, void * img);
2980typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC)(GLuint texture, GLint level, GLsizei bufSize, void * pixels);
2981typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void * pixels);
2982typedef void (GLAD_API_PTR *PFNGLGETCONVOLUTIONPARAMETERXVOESPROC)(GLenum target, GLenum pname, GLfixed * params);
2983typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog);
2984typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGARBPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog);
2985typedef void (GLAD_API_PTR *PFNGLGETDOUBLEI_VPROC)(GLenum target, GLuint index, GLdouble * data);
2986typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble * data);
2987typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
2988typedef void (GLAD_API_PTR *PFNGLGETFIXEDVOESPROC)(GLenum pname, GLfixed * params);
2989typedef void (GLAD_API_PTR *PFNGLGETFLOATI_VPROC)(GLenum target, GLuint index, GLfloat * data);
2990typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data);
2991typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar * name);
2992typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar * name);
2993typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
2994typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
2995typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2996typedef GLhandleARB (GLAD_API_PTR *PFNGLGETHANDLEARBPROC)(GLenum pname);
2997typedef void (GLAD_API_PTR *PFNGLGETHISTOGRAMPARAMETERXVOESPROC)(GLenum target, GLenum pname, GLfixed * params);
2998typedef void (GLAD_API_PTR *PFNGLGETINFOLOGARBPROC)(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog);
2999typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 * data);
3000typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 * data);
3001typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint * data);
3002typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data);
3003typedef void (GLAD_API_PTR *PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 * params);
3004typedef void (GLAD_API_PTR *PFNGLGETINTERNALFORMATIVPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint * params);
3005typedef void (GLAD_API_PTR *PFNGLGETLIGHTXOESPROC)(GLenum light, GLenum pname, GLfixed * params);
3006typedef void (GLAD_API_PTR *PFNGLGETMAPXVOESPROC)(GLenum target, GLenum query, GLfixed * v);
3007typedef void (GLAD_API_PTR *PFNGLGETMATERIALXOESPROC)(GLenum face, GLenum pname, GLfixed param);
3008typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat * val);
3009typedef void (GLAD_API_PTR *PFNGLGETNAMEDBUFFERPARAMETERI64VPROC)(GLuint buffer, GLenum pname, GLint64 * params);
3010typedef void (GLAD_API_PTR *PFNGLGETNAMEDBUFFERPARAMETERIVPROC)(GLuint buffer, GLenum pname, GLint * params);
3011typedef void (GLAD_API_PTR *PFNGLGETNAMEDBUFFERPOINTERVPROC)(GLuint buffer, GLenum pname, void ** params);
3012typedef void (GLAD_API_PTR *PFNGLGETNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, void * data);
3013typedef void (GLAD_API_PTR *PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLuint framebuffer, GLenum attachment, GLenum pname, GLint * params);
3014typedef void (GLAD_API_PTR *PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC)(GLuint framebuffer, GLenum pname, GLint * param);
3015typedef void (GLAD_API_PTR *PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC)(GLuint renderbuffer, GLenum pname, GLint * params);
3016typedef void (GLAD_API_PTR *PFNGLGETNAMEDSTRINGARBPROC)(GLint namelen, const GLchar * name, GLsizei bufSize, GLint * stringlen, GLchar * string);
3017typedef void (GLAD_API_PTR *PFNGLGETNAMEDSTRINGIVARBPROC)(GLint namelen, const GLchar * name, GLenum pname, GLint * params);
3018typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label);
3019typedef void (GLAD_API_PTR *PFNGLGETOBJECTPARAMETERFVARBPROC)(GLhandleARB obj, GLenum pname, GLfloat * params);
3020typedef void (GLAD_API_PTR *PFNGLGETOBJECTPARAMETERIVARBPROC)(GLhandleARB obj, GLenum pname, GLint * params);
3021typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label);
3022typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPXVPROC)(GLenum map, GLint size, GLfixed * values);
3023typedef void (GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum pname, void ** params);
3024typedef void (GLAD_API_PTR *PFNGLGETPROGRAMBINARYPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary);
3025typedef void (GLAD_API_PTR *PFNGLGETPROGRAMENVPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble * params);
3026typedef void (GLAD_API_PTR *PFNGLGETPROGRAMENVPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat * params);
3027typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
3028typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINTERFACEIVPROC)(GLuint program, GLenum programInterface, GLenum pname, GLint * params);
3029typedef void (GLAD_API_PTR *PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble * params);
3030typedef void (GLAD_API_PTR *PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat * params);
3031typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
3032typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, GLenum pname, GLint * params);
3033typedef GLuint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCEINDEXPROC)(GLuint program, GLenum programInterface, const GLchar * name);
3034typedef GLint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONPROC)(GLuint program, GLenum programInterface, const GLchar * name);
3035typedef GLint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)(GLuint program, GLenum programInterface, const GLchar * name);
3036typedef void (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCENAMEPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name);
3037typedef void (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCEIVPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei count, GLsizei * length, GLint * params);
3038typedef void (GLAD_API_PTR *PFNGLGETPROGRAMSTAGEIVPROC)(GLuint program, GLenum shadertype, GLenum pname, GLint * values);
3039typedef void (GLAD_API_PTR *PFNGLGETPROGRAMSTRINGARBPROC)(GLenum target, GLenum pname, void * string);
3040typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params);
3041typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVARBPROC)(GLenum target, GLenum pname, GLint * params);
3042typedef void (GLAD_API_PTR *PFNGLGETQUERYBUFFEROBJECTI64VPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
3043typedef void (GLAD_API_PTR *PFNGLGETQUERYBUFFEROBJECTIVPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
3044typedef void (GLAD_API_PTR *PFNGLGETQUERYBUFFEROBJECTUI64VPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
3045typedef void (GLAD_API_PTR *PFNGLGETQUERYBUFFEROBJECTUIVPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
3046typedef void (GLAD_API_PTR *PFNGLGETQUERYINDEXEDIVPROC)(GLenum target, GLuint index, GLenum pname, GLint * params);
3047typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 * params);
3048typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint * params);
3049typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVARBPROC)(GLuint id, GLenum pname, GLint * params);
3050typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 * params);
3051typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint * params);
3052typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVARBPROC)(GLuint id, GLenum pname, GLuint * params);
3053typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint * params);
3054typedef void (GLAD_API_PTR *PFNGLGETQUERYIVARBPROC)(GLenum target, GLenum pname, GLint * params);
3055typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
3056typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint * params);
3057typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint * params);
3058typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint * params);
3059typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat * params);
3060typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint * params);
3061typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
3062typedef void (GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision);
3063typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
3064typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEARBPROC)(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source);
3065typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params);
3066typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name);
3067typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum name, GLuint index);
3068typedef GLuint (GLAD_API_PTR *PFNGLGETSUBROUTINEINDEXPROC)(GLuint program, GLenum shadertype, const GLchar * name);
3069typedef GLint (GLAD_API_PTR *PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)(GLuint program, GLenum shadertype, const GLchar * name);
3070typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei * length, GLint * values);
3071typedef void (GLAD_API_PTR *PFNGLGETTEXENVXVOESPROC)(GLenum target, GLenum pname, GLfixed * params);
3072typedef void (GLAD_API_PTR *PFNGLGETTEXGENXVOESPROC)(GLenum coord, GLenum pname, GLfixed * params);
3073typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels);
3074typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat * params);
3075typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint * params);
3076typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERXVOESPROC)(GLenum target, GLint level, GLenum pname, GLfixed * params);
3077typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint * params);
3078typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint * params);
3079typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params);
3080typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
3081typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERXVOESPROC)(GLenum target, GLenum pname, GLfixed * params);
3082typedef void (GLAD_API_PTR *PFNGLGETTEXTUREIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void * pixels);
3083typedef void (GLAD_API_PTR *PFNGLGETTEXTURELEVELPARAMETERFVPROC)(GLuint texture, GLint level, GLenum pname, GLfloat * params);
3084typedef void (GLAD_API_PTR *PFNGLGETTEXTURELEVELPARAMETERIVPROC)(GLuint texture, GLint level, GLenum pname, GLint * params);
3085typedef void (GLAD_API_PTR *PFNGLGETTEXTUREPARAMETERIIVPROC)(GLuint texture, GLenum pname, GLint * params);
3086typedef void (GLAD_API_PTR *PFNGLGETTEXTUREPARAMETERIUIVPROC)(GLuint texture, GLenum pname, GLuint * params);
3087typedef void (GLAD_API_PTR *PFNGLGETTEXTUREPARAMETERFVPROC)(GLuint texture, GLenum pname, GLfloat * params);
3088typedef void (GLAD_API_PTR *PFNGLGETTEXTUREPARAMETERIVPROC)(GLuint texture, GLenum pname, GLint * params);
3089typedef void (GLAD_API_PTR *PFNGLGETTEXTURESUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void * pixels);
3090typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name);
3091typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKI64_VPROC)(GLuint xfb, GLenum pname, GLuint index, GLint64 * param);
3092typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKI_VPROC)(GLuint xfb, GLenum pname, GLuint index, GLint * param);
3093typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKIVPROC)(GLuint xfb, GLenum pname, GLint * param);
3094typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar * uniformBlockName);
3095typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices);
3096typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name);
3097typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB * name);
3098typedef void (GLAD_API_PTR *PFNGLGETUNIFORMSUBROUTINEUIVPROC)(GLenum shadertype, GLint location, GLuint * params);
3099typedef void (GLAD_API_PTR *PFNGLGETUNIFORMDVPROC)(GLuint program, GLint location, GLdouble * params);
3100typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params);
3101typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVARBPROC)(GLhandleARB programObj, GLint location, GLfloat * params);
3102typedef void (GLAD_API_PTR *PFNGLGETUNIFORMI64VARBPROC)(GLuint program, GLint location, GLint64 * params);
3103typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params);
3104typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVARBPROC)(GLhandleARB programObj, GLint location, GLint * params);
3105typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUI64VARBPROC)(GLuint program, GLint location, GLuint64 * params);
3106typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint * params);
3107typedef void (GLAD_API_PTR *PFNGLGETVERTEXARRAYINDEXED64IVPROC)(GLuint vaobj, GLuint index, GLenum pname, GLint64 * param);
3108typedef void (GLAD_API_PTR *PFNGLGETVERTEXARRAYINDEXEDIVPROC)(GLuint vaobj, GLuint index, GLenum pname, GLint * param);
3109typedef void (GLAD_API_PTR *PFNGLGETVERTEXARRAYIVPROC)(GLuint vaobj, GLenum pname, GLint * param);
3110typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint * params);
3111typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint * params);
3112typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBLDVPROC)(GLuint index, GLenum pname, GLdouble * params);
3113typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer);
3114typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVARBPROC)(GLuint index, GLenum pname, void ** pointer);
3115typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble * params);
3116typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVARBPROC)(GLuint index, GLenum pname, GLdouble * params);
3117typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params);
3118typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVARBPROC)(GLuint index, GLenum pname, GLfloat * params);
3119typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params);
3120typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVARBPROC)(GLuint index, GLenum pname, GLint * params);
3121typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMI64VARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLint64 * params);
3122typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUI64VARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint64 * params);
3123typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode);
3124typedef void (GLAD_API_PTR *PFNGLINDEXXOESPROC)(GLfixed component);
3125typedef void (GLAD_API_PTR *PFNGLINDEXXVOESPROC)(const GLfixed * component);
3126typedef void (GLAD_API_PTR *PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer);
3127typedef void (GLAD_API_PTR *PFNGLINVALIDATEBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length);
3128typedef void (GLAD_API_PTR *PFNGLINVALIDATEFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum * attachments);
3129typedef void (GLAD_API_PTR *PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC)(GLuint framebuffer, GLsizei numAttachments, const GLenum * attachments);
3130typedef void (GLAD_API_PTR *PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC)(GLuint framebuffer, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height);
3131typedef void (GLAD_API_PTR *PFNGLINVALIDATESUBFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height);
3132typedef void (GLAD_API_PTR *PFNGLINVALIDATETEXIMAGEPROC)(GLuint texture, GLint level);
3133typedef void (GLAD_API_PTR *PFNGLINVALIDATETEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
3134typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer);
3135typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERARBPROC)(GLuint buffer);
3136typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap);
3137typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum target, GLuint index);
3138typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
3139typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer);
3140typedef GLboolean (GLAD_API_PTR *PFNGLISNAMEDSTRINGARBPROC)(GLint namelen, const GLchar * name);
3141typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program);
3142typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMARBPROC)(GLuint program);
3143typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline);
3144typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint id);
3145typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYARBPROC)(GLuint id);
3146typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
3147typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer);
3148typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint sampler);
3149typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader);
3150typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync sync);
3151typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture);
3152typedef GLboolean (GLAD_API_PTR *PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id);
3153typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint array);
3154typedef void (GLAD_API_PTR *PFNGLLIGHTMODELXOESPROC)(GLenum pname, GLfixed param);
3155typedef void (GLAD_API_PTR *PFNGLLIGHTMODELXVOESPROC)(GLenum pname, const GLfixed * param);
3156typedef void (GLAD_API_PTR *PFNGLLIGHTXOESPROC)(GLenum light, GLenum pname, GLfixed param);
3157typedef void (GLAD_API_PTR *PFNGLLIGHTXVOESPROC)(GLenum light, GLenum pname, const GLfixed * params);
3158typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width);
3159typedef void (GLAD_API_PTR *PFNGLLINEWIDTHXOESPROC)(GLfixed width);
3160typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program);
3161typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMARBPROC)(GLhandleARB programObj);
3162typedef void (GLAD_API_PTR *PFNGLLOADMATRIXXOESPROC)(const GLfixed * m);
3163typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDARBPROC)(const GLdouble * m);
3164typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFARBPROC)(const GLfloat * m);
3165typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXXOESPROC)(const GLfixed * m);
3166typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum opcode);
3167typedef void (GLAD_API_PTR *PFNGLMAP1XOESPROC)(GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points);
3168typedef void (GLAD_API_PTR *PFNGLMAP2XOESPROC)(GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points);
3169typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum target, GLenum access);
3170typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERARBPROC)(GLenum target, GLenum access);
3171typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
3172typedef void (GLAD_API_PTR *PFNGLMAPGRID1XOESPROC)(GLint n, GLfixed u1, GLfixed u2);
3173typedef void (GLAD_API_PTR *PFNGLMAPGRID2XOESPROC)(GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2);
3174typedef void * (GLAD_API_PTR *PFNGLMAPNAMEDBUFFERPROC)(GLuint buffer, GLenum access);
3175typedef void * (GLAD_API_PTR *PFNGLMAPNAMEDBUFFERRANGEPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
3176typedef void (GLAD_API_PTR *PFNGLMATERIALXOESPROC)(GLenum face, GLenum pname, GLfixed param);
3177typedef void (GLAD_API_PTR *PFNGLMATERIALXVOESPROC)(GLenum face, GLenum pname, const GLfixed * param);
3178typedef void (GLAD_API_PTR *PFNGLMEMORYBARRIERPROC)(GLbitfield barriers);
3179typedef void (GLAD_API_PTR *PFNGLMEMORYBARRIERBYREGIONPROC)(GLbitfield barriers);
3180typedef void (GLAD_API_PTR *PFNGLMINSAMPLESHADINGPROC)(GLfloat value);
3181typedef void (GLAD_API_PTR *PFNGLMINSAMPLESHADINGARBPROC)(GLfloat value);
3182typedef void (GLAD_API_PTR *PFNGLMULTMATRIXXOESPROC)(const GLfixed * m);
3183typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDARBPROC)(const GLdouble * m);
3184typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFARBPROC)(const GLfloat * m);
3185typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXXOESPROC)(const GLfixed * m);
3186typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount);
3187typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSINDIRECTPROC)(GLenum mode, const void * indirect, GLsizei drawcount, GLsizei stride);
3188typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount);
3189typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex);
3190typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void * indirect, GLsizei drawcount, GLsizei stride);
3191typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DARBPROC)(GLenum target, GLdouble s);
3192typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DVARBPROC)(GLenum target, const GLdouble * v);
3193typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FARBPROC)(GLenum target, GLfloat s);
3194typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FVARBPROC)(GLenum target, const GLfloat * v);
3195typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IARBPROC)(GLenum target, GLint s);
3196typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IVARBPROC)(GLenum target, const GLint * v);
3197typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SARBPROC)(GLenum target, GLshort s);
3198typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SVARBPROC)(GLenum target, const GLshort * v);
3199typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1XOESPROC)(GLenum texture, GLfixed s);
3200typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1XVOESPROC)(GLenum texture, const GLfixed * coords);
3201typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DARBPROC)(GLenum target, GLdouble s, GLdouble t);
3202typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DVARBPROC)(GLenum target, const GLdouble * v);
3203typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FARBPROC)(GLenum target, GLfloat s, GLfloat t);
3204typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FVARBPROC)(GLenum target, const GLfloat * v);
3205typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IARBPROC)(GLenum target, GLint s, GLint t);
3206typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IVARBPROC)(GLenum target, const GLint * v);
3207typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SARBPROC)(GLenum target, GLshort s, GLshort t);
3208typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SVARBPROC)(GLenum target, const GLshort * v);
3209typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2XOESPROC)(GLenum texture, GLfixed s, GLfixed t);
3210typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2XVOESPROC)(GLenum texture, const GLfixed * coords);
3211typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DARBPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r);
3212typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DVARBPROC)(GLenum target, const GLdouble * v);
3213typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FARBPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r);
3214typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FVARBPROC)(GLenum target, const GLfloat * v);
3215typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IARBPROC)(GLenum target, GLint s, GLint t, GLint r);
3216typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IVARBPROC)(GLenum target, const GLint * v);
3217typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SARBPROC)(GLenum target, GLshort s, GLshort t, GLshort r);
3218typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SVARBPROC)(GLenum target, const GLshort * v);
3219typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3XOESPROC)(GLenum texture, GLfixed s, GLfixed t, GLfixed r);
3220typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3XVOESPROC)(GLenum texture, const GLfixed * coords);
3221typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DARBPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
3222typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DVARBPROC)(GLenum target, const GLdouble * v);
3223typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FARBPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
3224typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FVARBPROC)(GLenum target, const GLfloat * v);
3225typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IARBPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q);
3226typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IVARBPROC)(GLenum target, const GLint * v);
3227typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SARBPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
3228typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SVARBPROC)(GLenum target, const GLshort * v);
3229typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4XOESPROC)(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
3230typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4XVOESPROC)(GLenum texture, const GLfixed * coords);
3231typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERDATAPROC)(GLuint buffer, GLsizeiptr size, const void * data, GLenum usage);
3232typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSTORAGEPROC)(GLuint buffer, GLsizeiptr size, const void * data, GLbitfield flags);
3233typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, const void * data);
3234typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC)(GLuint framebuffer, GLenum buf);
3235typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC)(GLuint framebuffer, GLsizei n, const GLenum * bufs);
3236typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC)(GLuint framebuffer, GLenum pname, GLint param);
3237typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC)(GLuint framebuffer, GLenum src);
3238typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC)(GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
3239typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)(GLuint framebuffer, GLuint start, GLsizei count, const GLfloat * v);
3240typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
3241typedef void (GLAD_API_PTR *PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC)(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
3242typedef void (GLAD_API_PTR *PFNGLNAMEDRENDERBUFFERSTORAGEPROC)(GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
3243typedef void (GLAD_API_PTR *PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
3244typedef void (GLAD_API_PTR *PFNGLNAMEDSTRINGARBPROC)(GLenum type, GLint namelen, const GLchar * name, GLint stringlen, const GLchar * string);
3245typedef void (GLAD_API_PTR *PFNGLNORMAL3XOESPROC)(GLfixed nx, GLfixed ny, GLfixed nz);
3246typedef void (GLAD_API_PTR *PFNGLNORMAL3XVOESPROC)(const GLfixed * coords);
3247typedef void (GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label);
3248typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void * ptr, GLsizei length, const GLchar * label);
3249typedef void (GLAD_API_PTR *PFNGLORTHOXOESPROC)(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
3250typedef void (GLAD_API_PTR *PFNGLPASSTHROUGHXOESPROC)(GLfixed token);
3251typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERFVPROC)(GLenum pname, const GLfloat * values);
3252typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIPROC)(GLenum pname, GLint value);
3253typedef void (GLAD_API_PTR *PFNGLPAUSETRANSFORMFEEDBACKPROC)(void);
3254typedef void (GLAD_API_PTR *PFNGLPIXELMAPXPROC)(GLenum map, GLint size, const GLfixed * values);
3255typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param);
3256typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
3257typedef void (GLAD_API_PTR *PFNGLPIXELSTOREXPROC)(GLenum pname, GLfixed param);
3258typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERXOESPROC)(GLenum pname, GLfixed param);
3259typedef void (GLAD_API_PTR *PFNGLPIXELZOOMXOESPROC)(GLfixed xfactor, GLfixed yfactor);
3260typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param);
3261typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat * params);
3262typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param);
3263typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint * params);
3264typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERXVOESPROC)(GLenum pname, const GLfixed * params);
3265typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat size);
3266typedef void (GLAD_API_PTR *PFNGLPOINTSIZEXOESPROC)(GLfixed size);
3267typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode);
3268typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
3269typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETXOESPROC)(GLfixed factor, GLfixed units);
3270typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPPROC)(void);
3271typedef void (GLAD_API_PTR *PFNGLPRIMITIVEBOUNDINGBOXARBPROC)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
3272typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index);
3273typedef void (GLAD_API_PTR *PFNGLPRIORITIZETEXTURESXOESPROC)(GLsizei n, const GLuint * textures, const GLfixed * priorities);
3274typedef void (GLAD_API_PTR *PFNGLPROGRAMBINARYPROC)(GLuint program, GLenum binaryFormat, const void * binary, GLsizei length);
3275typedef void (GLAD_API_PTR *PFNGLPROGRAMENVPARAMETER4DARBPROC)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
3276typedef void (GLAD_API_PTR *PFNGLPROGRAMENVPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble * params);
3277typedef void (GLAD_API_PTR *PFNGLPROGRAMENVPARAMETER4FARBPROC)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
3278typedef void (GLAD_API_PTR *PFNGLPROGRAMENVPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat * params);
3279typedef void (GLAD_API_PTR *PFNGLPROGRAMLOCALPARAMETER4DARBPROC)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
3280typedef void (GLAD_API_PTR *PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble * params);
3281typedef void (GLAD_API_PTR *PFNGLPROGRAMLOCALPARAMETER4FARBPROC)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
3282typedef void (GLAD_API_PTR *PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat * params);
3283typedef void (GLAD_API_PTR *PFNGLPROGRAMPARAMETERIPROC)(GLuint program, GLenum pname, GLint value);
3284typedef void (GLAD_API_PTR *PFNGLPROGRAMPARAMETERIARBPROC)(GLuint program, GLenum pname, GLint value);
3285typedef void (GLAD_API_PTR *PFNGLPROGRAMSTRINGARBPROC)(GLenum target, GLenum format, GLsizei len, const void * string);
3286typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1DPROC)(GLuint program, GLint location, GLdouble v0);
3287typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value);
3288typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, GLint location, GLfloat v0);
3289typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
3290typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, GLint location, GLint v0);
3291typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1I64ARBPROC)(GLuint program, GLint location, GLint64 x);
3292typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1I64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLint64 * value);
3293typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
3294typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, GLint location, GLuint v0);
3295typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UI64ARBPROC)(GLuint program, GLint location, GLuint64 x);
3296typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UI64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLuint64 * value);
3297typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
3298typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1);
3299typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value);
3300typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1);
3301typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
3302typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, GLint location, GLint v0, GLint v1);
3303typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2I64ARBPROC)(GLuint program, GLint location, GLint64 x, GLint64 y);
3304typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2I64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLint64 * value);
3305typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
3306typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1);
3307typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UI64ARBPROC)(GLuint program, GLint location, GLuint64 x, GLuint64 y);
3308typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UI64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLuint64 * value);
3309typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
3310typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
3311typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value);
3312typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
3313typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
3314typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
3315typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3I64ARBPROC)(GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z);
3316typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3I64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLint64 * value);
3317typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
3318typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
3319typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UI64ARBPROC)(GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z);
3320typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UI64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLuint64 * value);
3321typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
3322typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
3323typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value);
3324typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
3325typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
3326typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
3327typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4I64ARBPROC)(GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w);
3328typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4I64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLint64 * value);
3329typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
3330typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
3331typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UI64ARBPROC)(GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w);
3332typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UI64VARBPROC)(GLuint program, GLint location, GLsizei count, const GLuint64 * value);
3333typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
3334typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3335typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3336typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3337typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3338typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3339typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3340typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3341typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3342typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3343typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3344typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3345typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3346typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3347typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3348typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3349typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3350typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3351typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3352typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum mode);
3353typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message);
3354typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target);
3355typedef void (GLAD_API_PTR *PFNGLRASTERPOS2XOESPROC)(GLfixed x, GLfixed y);
3356typedef void (GLAD_API_PTR *PFNGLRASTERPOS2XVOESPROC)(const GLfixed * coords);
3357typedef void (GLAD_API_PTR *PFNGLRASTERPOS3XOESPROC)(GLfixed x, GLfixed y, GLfixed z);
3358typedef void (GLAD_API_PTR *PFNGLRASTERPOS3XVOESPROC)(const GLfixed * coords);
3359typedef void (GLAD_API_PTR *PFNGLRASTERPOS4XOESPROC)(GLfixed x, GLfixed y, GLfixed z, GLfixed w);
3360typedef void (GLAD_API_PTR *PFNGLRASTERPOS4XVOESPROC)(const GLfixed * coords);
3361typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum src);
3362typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
3363typedef void (GLAD_API_PTR *PFNGLRECTXOESPROC)(GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2);
3364typedef void (GLAD_API_PTR *PFNGLRECTXVOESPROC)(const GLfixed * v1, const GLfixed * v2);
3365typedef void (GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void);
3366typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
3367typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
3368typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
3369typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
3370typedef void (GLAD_API_PTR *PFNGLRESUMETRANSFORMFEEDBACKPROC)(void);
3371typedef void (GLAD_API_PTR *PFNGLROTATEXOESPROC)(GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
3372typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
3373typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEARBPROC)(GLfloat value, GLboolean invert);
3374typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask);
3375typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint * param);
3376typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint * param);
3377typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param);
3378typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat * param);
3379typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param);
3380typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint * param);
3381typedef void (GLAD_API_PTR *PFNGLSCALEXOESPROC)(GLfixed x, GLfixed y, GLfixed z);
3382typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
3383typedef void (GLAD_API_PTR *PFNGLSCISSORARRAYVPROC)(GLuint first, GLsizei count, const GLint * v);
3384typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
3385typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDVPROC)(GLuint index, const GLint * v);
3386typedef void (GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length);
3387typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
3388typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEARBPROC)(GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint * length);
3389typedef void (GLAD_API_PTR *PFNGLSHADERSTORAGEBLOCKBINDINGPROC)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
3390typedef void (GLAD_API_PTR *PFNGLSPECIALIZESHADERARBPROC)(GLuint shader, const GLchar * pEntryPoint, GLuint numSpecializationConstants, const GLuint * pConstantIndex, const GLuint * pConstantValue);
3391typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
3392typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
3393typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask);
3394typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
3395typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
3396typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
3397typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer);
3398typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
3399typedef void (GLAD_API_PTR *PFNGLTEXCOORD1XOESPROC)(GLfixed s);
3400typedef void (GLAD_API_PTR *PFNGLTEXCOORD1XVOESPROC)(const GLfixed * coords);
3401typedef void (GLAD_API_PTR *PFNGLTEXCOORD2XOESPROC)(GLfixed s, GLfixed t);
3402typedef void (GLAD_API_PTR *PFNGLTEXCOORD2XVOESPROC)(const GLfixed * coords);
3403typedef void (GLAD_API_PTR *PFNGLTEXCOORD3XOESPROC)(GLfixed s, GLfixed t, GLfixed r);
3404typedef void (GLAD_API_PTR *PFNGLTEXCOORD3XVOESPROC)(const GLfixed * coords);
3405typedef void (GLAD_API_PTR *PFNGLTEXCOORD4XOESPROC)(GLfixed s, GLfixed t, GLfixed r, GLfixed q);
3406typedef void (GLAD_API_PTR *PFNGLTEXCOORD4XVOESPROC)(const GLfixed * coords);
3407typedef void (GLAD_API_PTR *PFNGLTEXENVXOESPROC)(GLenum target, GLenum pname, GLfixed param);
3408typedef void (GLAD_API_PTR *PFNGLTEXENVXVOESPROC)(GLenum target, GLenum pname, const GLfixed * params);
3409typedef void (GLAD_API_PTR *PFNGLTEXGENXOESPROC)(GLenum coord, GLenum pname, GLfixed param);
3410typedef void (GLAD_API_PTR *PFNGLTEXGENXVOESPROC)(GLenum coord, GLenum pname, const GLfixed * params);
3411typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels);
3412typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
3413typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
3414typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
3415typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
3416typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint * params);
3417typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint * params);
3418typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
3419typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
3420typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
3421typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params);
3422typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERXOESPROC)(GLenum target, GLenum pname, GLfixed param);
3423typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERXVOESPROC)(GLenum target, GLenum pname, const GLfixed * params);
3424typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
3425typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
3426typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
3427typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
3428typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
3429typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels);
3430typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
3431typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);
3432typedef void (GLAD_API_PTR *PFNGLTEXTUREBUFFERPROC)(GLuint texture, GLenum internalformat, GLuint buffer);
3433typedef void (GLAD_API_PTR *PFNGLTEXTUREBUFFERRANGEPROC)(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
3434typedef void (GLAD_API_PTR *PFNGLTEXTUREPARAMETERIIVPROC)(GLuint texture, GLenum pname, const GLint * params);
3435typedef void (GLAD_API_PTR *PFNGLTEXTUREPARAMETERIUIVPROC)(GLuint texture, GLenum pname, const GLuint * params);
3436typedef void (GLAD_API_PTR *PFNGLTEXTUREPARAMETERFPROC)(GLuint texture, GLenum pname, GLfloat param);
3437typedef void (GLAD_API_PTR *PFNGLTEXTUREPARAMETERFVPROC)(GLuint texture, GLenum pname, const GLfloat * param);
3438typedef void (GLAD_API_PTR *PFNGLTEXTUREPARAMETERIPROC)(GLuint texture, GLenum pname, GLint param);
3439typedef void (GLAD_API_PTR *PFNGLTEXTUREPARAMETERIVPROC)(GLuint texture, GLenum pname, const GLint * param);
3440typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE1DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width);
3441typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE2DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
3442typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC)(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
3443typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE3DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
3444typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC)(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
3445typedef void (GLAD_API_PTR *PFNGLTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels);
3446typedef void (GLAD_API_PTR *PFNGLTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
3447typedef void (GLAD_API_PTR *PFNGLTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);
3448typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
3449typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC)(GLuint xfb, GLuint index, GLuint buffer);
3450typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC)(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
3451typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode);
3452typedef void (GLAD_API_PTR *PFNGLTRANSLATEXOESPROC)(GLfixed x, GLfixed y, GLfixed z);
3453typedef void (GLAD_API_PTR *PFNGLUNIFORM1DPROC)(GLint location, GLdouble x);
3454typedef void (GLAD_API_PTR *PFNGLUNIFORM1DVPROC)(GLint location, GLsizei count, const GLdouble * value);
3455typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
3456typedef void (GLAD_API_PTR *PFNGLUNIFORM1FARBPROC)(GLint location, GLfloat v0);
3457typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value);
3458typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVARBPROC)(GLint location, GLsizei count, const GLfloat * value);
3459typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
3460typedef void (GLAD_API_PTR *PFNGLUNIFORM1I64ARBPROC)(GLint location, GLint64 x);
3461typedef void (GLAD_API_PTR *PFNGLUNIFORM1I64VARBPROC)(GLint location, GLsizei count, const GLint64 * value);
3462typedef void (GLAD_API_PTR *PFNGLUNIFORM1IARBPROC)(GLint location, GLint v0);
3463typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value);
3464typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVARBPROC)(GLint location, GLsizei count, const GLint * value);
3465typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0);
3466typedef void (GLAD_API_PTR *PFNGLUNIFORM1UI64ARBPROC)(GLint location, GLuint64 x);
3467typedef void (GLAD_API_PTR *PFNGLUNIFORM1UI64VARBPROC)(GLint location, GLsizei count, const GLuint64 * value);
3468typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint * value);
3469typedef void (GLAD_API_PTR *PFNGLUNIFORM2DPROC)(GLint location, GLdouble x, GLdouble y);
3470typedef void (GLAD_API_PTR *PFNGLUNIFORM2DVPROC)(GLint location, GLsizei count, const GLdouble * value);
3471typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
3472typedef void (GLAD_API_PTR *PFNGLUNIFORM2FARBPROC)(GLint location, GLfloat v0, GLfloat v1);
3473typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value);
3474typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVARBPROC)(GLint location, GLsizei count, const GLfloat * value);
3475typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
3476typedef void (GLAD_API_PTR *PFNGLUNIFORM2I64ARBPROC)(GLint location, GLint64 x, GLint64 y);
3477typedef void (GLAD_API_PTR *PFNGLUNIFORM2I64VARBPROC)(GLint location, GLsizei count, const GLint64 * value);
3478typedef void (GLAD_API_PTR *PFNGLUNIFORM2IARBPROC)(GLint location, GLint v0, GLint v1);
3479typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value);
3480typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVARBPROC)(GLint location, GLsizei count, const GLint * value);
3481typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1);
3482typedef void (GLAD_API_PTR *PFNGLUNIFORM2UI64ARBPROC)(GLint location, GLuint64 x, GLuint64 y);
3483typedef void (GLAD_API_PTR *PFNGLUNIFORM2UI64VARBPROC)(GLint location, GLsizei count, const GLuint64 * value);
3484typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint * value);
3485typedef void (GLAD_API_PTR *PFNGLUNIFORM3DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z);
3486typedef void (GLAD_API_PTR *PFNGLUNIFORM3DVPROC)(GLint location, GLsizei count, const GLdouble * value);
3487typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
3488typedef void (GLAD_API_PTR *PFNGLUNIFORM3FARBPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
3489typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value);
3490typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVARBPROC)(GLint location, GLsizei count, const GLfloat * value);
3491typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
3492typedef void (GLAD_API_PTR *PFNGLUNIFORM3I64ARBPROC)(GLint location, GLint64 x, GLint64 y, GLint64 z);
3493typedef void (GLAD_API_PTR *PFNGLUNIFORM3I64VARBPROC)(GLint location, GLsizei count, const GLint64 * value);
3494typedef void (GLAD_API_PTR *PFNGLUNIFORM3IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2);
3495typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value);
3496typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVARBPROC)(GLint location, GLsizei count, const GLint * value);
3497typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2);
3498typedef void (GLAD_API_PTR *PFNGLUNIFORM3UI64ARBPROC)(GLint location, GLuint64 x, GLuint64 y, GLuint64 z);
3499typedef void (GLAD_API_PTR *PFNGLUNIFORM3UI64VARBPROC)(GLint location, GLsizei count, const GLuint64 * value);
3500typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint * value);
3501typedef void (GLAD_API_PTR *PFNGLUNIFORM4DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
3502typedef void (GLAD_API_PTR *PFNGLUNIFORM4DVPROC)(GLint location, GLsizei count, const GLdouble * value);
3503typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
3504typedef void (GLAD_API_PTR *PFNGLUNIFORM4FARBPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
3505typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value);
3506typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVARBPROC)(GLint location, GLsizei count, const GLfloat * value);
3507typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
3508typedef void (GLAD_API_PTR *PFNGLUNIFORM4I64ARBPROC)(GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w);
3509typedef void (GLAD_API_PTR *PFNGLUNIFORM4I64VARBPROC)(GLint location, GLsizei count, const GLint64 * value);
3510typedef void (GLAD_API_PTR *PFNGLUNIFORM4IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
3511typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value);
3512typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVARBPROC)(GLint location, GLsizei count, const GLint * value);
3513typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
3514typedef void (GLAD_API_PTR *PFNGLUNIFORM4UI64ARBPROC)(GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w);
3515typedef void (GLAD_API_PTR *PFNGLUNIFORM4UI64VARBPROC)(GLint location, GLsizei count, const GLuint64 * value);
3516typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint * value);
3517typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
3518typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3519typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3520typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVARBPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3521typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3522typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3523typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3524typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3525typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3526typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3527typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVARBPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3528typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3529typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3530typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3531typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3532typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3533typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3534typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVARBPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3535typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3536typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3537typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value);
3538typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
3539typedef void (GLAD_API_PTR *PFNGLUNIFORMSUBROUTINESUIVPROC)(GLenum shadertype, GLsizei count, const GLuint * indices);
3540typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum target);
3541typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERARBPROC)(GLenum target);
3542typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPNAMEDBUFFERPROC)(GLuint buffer);
3543typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program);
3544typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMOBJECTARBPROC)(GLhandleARB programObj);
3545typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, GLbitfield stages, GLuint program);
3546typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program);
3547typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMARBPROC)(GLhandleARB programObj);
3548typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline);
3549typedef void (GLAD_API_PTR *PFNGLVERTEX2XOESPROC)(GLfixed x);
3550typedef void (GLAD_API_PTR *PFNGLVERTEX2XVOESPROC)(const GLfixed * coords);
3551typedef void (GLAD_API_PTR *PFNGLVERTEX3XOESPROC)(GLfixed x, GLfixed y);
3552typedef void (GLAD_API_PTR *PFNGLVERTEX3XVOESPROC)(const GLfixed * coords);
3553typedef void (GLAD_API_PTR *PFNGLVERTEX4XOESPROC)(GLfixed x, GLfixed y, GLfixed z);
3554typedef void (GLAD_API_PTR *PFNGLVERTEX4XVOESPROC)(const GLfixed * coords);
3555typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYATTRIBBINDINGPROC)(GLuint vaobj, GLuint attribindex, GLuint bindingindex);
3556typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYATTRIBFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
3557typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYATTRIBIFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
3558typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYATTRIBLFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
3559typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYBINDINGDIVISORPROC)(GLuint vaobj, GLuint bindingindex, GLuint divisor);
3560typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYELEMENTBUFFERPROC)(GLuint vaobj, GLuint buffer);
3561typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYVERTEXBUFFERPROC)(GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
3562typedef void (GLAD_API_PTR *PFNGLVERTEXARRAYVERTEXBUFFERSPROC)(GLuint vaobj, GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizei * strides);
3563typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x);
3564typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DARBPROC)(GLuint index, GLdouble x);
3565typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble * v);
3566typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVARBPROC)(GLuint index, const GLdouble * v);
3567typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
3568typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FARBPROC)(GLuint index, GLfloat x);
3569typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v);
3570typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVARBPROC)(GLuint index, const GLfloat * v);
3571typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x);
3572typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SARBPROC)(GLuint index, GLshort x);
3573typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort * v);
3574typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVARBPROC)(GLuint index, const GLshort * v);
3575typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y);
3576typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DARBPROC)(GLuint index, GLdouble x, GLdouble y);
3577typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble * v);
3578typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVARBPROC)(GLuint index, const GLdouble * v);
3579typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
3580typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FARBPROC)(GLuint index, GLfloat x, GLfloat y);
3581typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v);
3582typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVARBPROC)(GLuint index, const GLfloat * v);
3583typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y);
3584typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SARBPROC)(GLuint index, GLshort x, GLshort y);
3585typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort * v);
3586typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVARBPROC)(GLuint index, const GLshort * v);
3587typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
3588typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
3589typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble * v);
3590typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVARBPROC)(GLuint index, const GLdouble * v);
3591typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
3592typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
3593typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v);
3594typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVARBPROC)(GLuint index, const GLfloat * v);
3595typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
3596typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
3597typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort * v);
3598typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVARBPROC)(GLuint index, const GLshort * v);
3599typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte * v);
3600typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVARBPROC)(GLuint index, const GLbyte * v);
3601typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint * v);
3602typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVARBPROC)(GLuint index, const GLint * v);
3603typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort * v);
3604typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVARBPROC)(GLuint index, const GLshort * v);
3605typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
3606typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBARBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
3607typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte * v);
3608typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVARBPROC)(GLuint index, const GLubyte * v);
3609typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint * v);
3610typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVARBPROC)(GLuint index, const GLuint * v);
3611typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort * v);
3612typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVARBPROC)(GLuint index, const GLushort * v);
3613typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte * v);
3614typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVARBPROC)(GLuint index, const GLbyte * v);
3615typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
3616typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
3617typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble * v);
3618typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVARBPROC)(GLuint index, const GLdouble * v);
3619typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
3620typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
3621typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v);
3622typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVARBPROC)(GLuint index, const GLfloat * v);
3623typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint * v);
3624typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVARBPROC)(GLuint index, const GLint * v);
3625typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
3626typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
3627typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort * v);
3628typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVARBPROC)(GLuint index, const GLshort * v);
3629typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte * v);
3630typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVARBPROC)(GLuint index, const GLubyte * v);
3631typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint * v);
3632typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVARBPROC)(GLuint index, const GLuint * v);
3633typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort * v);
3634typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVARBPROC)(GLuint index, const GLushort * v);
3635typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, GLuint bindingindex);
3636typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor);
3637typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORARBPROC)(GLuint index, GLuint divisor);
3638typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
3639typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x);
3640typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint * v);
3641typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x);
3642typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint * v);
3643typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y);
3644typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint * v);
3645typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y);
3646typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint * v);
3647typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z);
3648typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint * v);
3649typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z);
3650typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint * v);
3651typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte * v);
3652typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w);
3653typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint * v);
3654typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort * v);
3655typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte * v);
3656typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
3657typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint * v);
3658typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort * v);
3659typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
3660typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer);
3661typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL1DPROC)(GLuint index, GLdouble x);
3662typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL1DVPROC)(GLuint index, const GLdouble * v);
3663typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL2DPROC)(GLuint index, GLdouble x, GLdouble y);
3664typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL2DVPROC)(GLuint index, const GLdouble * v);
3665typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
3666typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL3DVPROC)(GLuint index, const GLdouble * v);
3667typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
3668typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL4DVPROC)(GLuint index, const GLdouble * v);
3669typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
3670typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBLPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer);
3671typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
3672typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
3673typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
3674typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
3675typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
3676typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
3677typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
3678typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
3679typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
3680typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERARBPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
3681typedef void (GLAD_API_PTR *PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLuint divisor);
3682typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
3683typedef void (GLAD_API_PTR *PFNGLVIEWPORTARRAYVPROC)(GLuint first, GLsizei count, const GLfloat * v);
3684typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
3685typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFVPROC)(GLuint index, const GLfloat * v);
3686typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
3687
3688GLAD_API_CALL PFNGLACCUMXOESPROC glad_glAccumxOES;
3689#define glAccumxOES glad_glAccumxOES
3690GLAD_API_CALL PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram;
3691#define glActiveShaderProgram glad_glActiveShaderProgram
3692GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
3693#define glActiveTexture glad_glActiveTexture
3694GLAD_API_CALL PFNGLACTIVETEXTUREARBPROC glad_glActiveTextureARB;
3695#define glActiveTextureARB glad_glActiveTextureARB
3696GLAD_API_CALL PFNGLALPHAFUNCXOESPROC glad_glAlphaFuncxOES;
3697#define glAlphaFuncxOES glad_glAlphaFuncxOES
3698GLAD_API_CALL PFNGLATTACHOBJECTARBPROC glad_glAttachObjectARB;
3699#define glAttachObjectARB glad_glAttachObjectARB
3700GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
3701#define glAttachShader glad_glAttachShader
3702GLAD_API_CALL PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
3703#define glBeginConditionalRender glad_glBeginConditionalRender
3704GLAD_API_CALL PFNGLBEGINQUERYPROC glad_glBeginQuery;
3705#define glBeginQuery glad_glBeginQuery
3706GLAD_API_CALL PFNGLBEGINQUERYARBPROC glad_glBeginQueryARB;
3707#define glBeginQueryARB glad_glBeginQueryARB
3708GLAD_API_CALL PFNGLBEGINQUERYINDEXEDPROC glad_glBeginQueryIndexed;
3709#define glBeginQueryIndexed glad_glBeginQueryIndexed
3710GLAD_API_CALL PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
3711#define glBeginTransformFeedback glad_glBeginTransformFeedback
3712GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
3713#define glBindAttribLocation glad_glBindAttribLocation
3714GLAD_API_CALL PFNGLBINDATTRIBLOCATIONARBPROC glad_glBindAttribLocationARB;
3715#define glBindAttribLocationARB glad_glBindAttribLocationARB
3716GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
3717#define glBindBuffer glad_glBindBuffer
3718GLAD_API_CALL PFNGLBINDBUFFERARBPROC glad_glBindBufferARB;
3719#define glBindBufferARB glad_glBindBufferARB
3720GLAD_API_CALL PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
3721#define glBindBufferBase glad_glBindBufferBase
3722GLAD_API_CALL PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
3723#define glBindBufferRange glad_glBindBufferRange
3724GLAD_API_CALL PFNGLBINDBUFFERSBASEPROC glad_glBindBuffersBase;
3725#define glBindBuffersBase glad_glBindBuffersBase
3726GLAD_API_CALL PFNGLBINDBUFFERSRANGEPROC glad_glBindBuffersRange;
3727#define glBindBuffersRange glad_glBindBuffersRange
3728GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
3729#define glBindFragDataLocation glad_glBindFragDataLocation
3730GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
3731#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
3732GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
3733#define glBindFramebuffer glad_glBindFramebuffer
3734GLAD_API_CALL PFNGLBINDFRAMEBUFFEREXTPROC glad_glBindFramebufferEXT;
3735#define glBindFramebufferEXT glad_glBindFramebufferEXT
3736GLAD_API_CALL PFNGLBINDIMAGETEXTUREPROC glad_glBindImageTexture;
3737#define glBindImageTexture glad_glBindImageTexture
3738GLAD_API_CALL PFNGLBINDIMAGETEXTURESPROC glad_glBindImageTextures;
3739#define glBindImageTextures glad_glBindImageTextures
3740GLAD_API_CALL PFNGLBINDPROGRAMARBPROC glad_glBindProgramARB;
3741#define glBindProgramARB glad_glBindProgramARB
3742GLAD_API_CALL PFNGLBINDPROGRAMPIPELINEPROC glad_glBindProgramPipeline;
3743#define glBindProgramPipeline glad_glBindProgramPipeline
3744GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
3745#define glBindRenderbuffer glad_glBindRenderbuffer
3746GLAD_API_CALL PFNGLBINDRENDERBUFFEREXTPROC glad_glBindRenderbufferEXT;
3747#define glBindRenderbufferEXT glad_glBindRenderbufferEXT
3748GLAD_API_CALL PFNGLBINDSAMPLERPROC glad_glBindSampler;
3749#define glBindSampler glad_glBindSampler
3750GLAD_API_CALL PFNGLBINDSAMPLERSPROC glad_glBindSamplers;
3751#define glBindSamplers glad_glBindSamplers
3752GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
3753#define glBindTexture glad_glBindTexture
3754GLAD_API_CALL PFNGLBINDTEXTUREUNITPROC glad_glBindTextureUnit;
3755#define glBindTextureUnit glad_glBindTextureUnit
3756GLAD_API_CALL PFNGLBINDTEXTURESPROC glad_glBindTextures;
3757#define glBindTextures glad_glBindTextures
3758GLAD_API_CALL PFNGLBINDTRANSFORMFEEDBACKPROC glad_glBindTransformFeedback;
3759#define glBindTransformFeedback glad_glBindTransformFeedback
3760GLAD_API_CALL PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
3761#define glBindVertexArray glad_glBindVertexArray
3762GLAD_API_CALL PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer;
3763#define glBindVertexBuffer glad_glBindVertexBuffer
3764GLAD_API_CALL PFNGLBINDVERTEXBUFFERSPROC glad_glBindVertexBuffers;
3765#define glBindVertexBuffers glad_glBindVertexBuffers
3766GLAD_API_CALL PFNGLBITMAPXOESPROC glad_glBitmapxOES;
3767#define glBitmapxOES glad_glBitmapxOES
3768GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
3769#define glBlendColor glad_glBlendColor
3770GLAD_API_CALL PFNGLBLENDCOLORXOESPROC glad_glBlendColorxOES;
3771#define glBlendColorxOES glad_glBlendColorxOES
3772GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
3773#define glBlendEquation glad_glBlendEquation
3774GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
3775#define glBlendEquationSeparate glad_glBlendEquationSeparate
3776GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIPROC glad_glBlendEquationSeparatei;
3777#define glBlendEquationSeparatei glad_glBlendEquationSeparatei
3778GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIARBPROC glad_glBlendEquationSeparateiARB;
3779#define glBlendEquationSeparateiARB glad_glBlendEquationSeparateiARB
3780GLAD_API_CALL PFNGLBLENDEQUATIONIPROC glad_glBlendEquationi;
3781#define glBlendEquationi glad_glBlendEquationi
3782GLAD_API_CALL PFNGLBLENDEQUATIONIARBPROC glad_glBlendEquationiARB;
3783#define glBlendEquationiARB glad_glBlendEquationiARB
3784GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
3785#define glBlendFunc glad_glBlendFunc
3786GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
3787#define glBlendFuncSeparate glad_glBlendFuncSeparate
3788GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIPROC glad_glBlendFuncSeparatei;
3789#define glBlendFuncSeparatei glad_glBlendFuncSeparatei
3790GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIARBPROC glad_glBlendFuncSeparateiARB;
3791#define glBlendFuncSeparateiARB glad_glBlendFuncSeparateiARB
3792GLAD_API_CALL PFNGLBLENDFUNCIPROC glad_glBlendFunci;
3793#define glBlendFunci glad_glBlendFunci
3794GLAD_API_CALL PFNGLBLENDFUNCIARBPROC glad_glBlendFunciARB;
3795#define glBlendFunciARB glad_glBlendFunciARB
3796GLAD_API_CALL PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
3797#define glBlitFramebuffer glad_glBlitFramebuffer
3798GLAD_API_CALL PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT;
3799#define glBlitFramebufferEXT glad_glBlitFramebufferEXT
3800GLAD_API_CALL PFNGLBLITNAMEDFRAMEBUFFERPROC glad_glBlitNamedFramebuffer;
3801#define glBlitNamedFramebuffer glad_glBlitNamedFramebuffer
3802GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
3803#define glBufferData glad_glBufferData
3804GLAD_API_CALL PFNGLBUFFERDATAARBPROC glad_glBufferDataARB;
3805#define glBufferDataARB glad_glBufferDataARB
3806GLAD_API_CALL PFNGLBUFFERSTORAGEPROC glad_glBufferStorage;
3807#define glBufferStorage glad_glBufferStorage
3808GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
3809#define glBufferSubData glad_glBufferSubData
3810GLAD_API_CALL PFNGLBUFFERSUBDATAARBPROC glad_glBufferSubDataARB;
3811#define glBufferSubDataARB glad_glBufferSubDataARB
3812GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
3813#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
3814GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glad_glCheckFramebufferStatusEXT;
3815#define glCheckFramebufferStatusEXT glad_glCheckFramebufferStatusEXT
3816GLAD_API_CALL PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glad_glCheckNamedFramebufferStatus;
3817#define glCheckNamedFramebufferStatus glad_glCheckNamedFramebufferStatus
3818GLAD_API_CALL PFNGLCLAMPCOLORPROC glad_glClampColor;
3819#define glClampColor glad_glClampColor
3820GLAD_API_CALL PFNGLCLAMPCOLORARBPROC glad_glClampColorARB;
3821#define glClampColorARB glad_glClampColorARB
3822GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
3823#define glClear glad_glClear
3824GLAD_API_CALL PFNGLCLEARACCUMXOESPROC glad_glClearAccumxOES;
3825#define glClearAccumxOES glad_glClearAccumxOES
3826GLAD_API_CALL PFNGLCLEARBUFFERDATAPROC glad_glClearBufferData;
3827#define glClearBufferData glad_glClearBufferData
3828GLAD_API_CALL PFNGLCLEARBUFFERSUBDATAPROC glad_glClearBufferSubData;
3829#define glClearBufferSubData glad_glClearBufferSubData
3830GLAD_API_CALL PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
3831#define glClearBufferfi glad_glClearBufferfi
3832GLAD_API_CALL PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
3833#define glClearBufferfv glad_glClearBufferfv
3834GLAD_API_CALL PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
3835#define glClearBufferiv glad_glClearBufferiv
3836GLAD_API_CALL PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
3837#define glClearBufferuiv glad_glClearBufferuiv
3838GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
3839#define glClearColor glad_glClearColor
3840GLAD_API_CALL PFNGLCLEARCOLORXOESPROC glad_glClearColorxOES;
3841#define glClearColorxOES glad_glClearColorxOES
3842GLAD_API_CALL PFNGLCLEARDEPTHPROC glad_glClearDepth;
3843#define glClearDepth glad_glClearDepth
3844GLAD_API_CALL PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
3845#define glClearDepthf glad_glClearDepthf
3846GLAD_API_CALL PFNGLCLEARDEPTHXOESPROC glad_glClearDepthxOES;
3847#define glClearDepthxOES glad_glClearDepthxOES
3848GLAD_API_CALL PFNGLCLEARNAMEDBUFFERDATAPROC glad_glClearNamedBufferData;
3849#define glClearNamedBufferData glad_glClearNamedBufferData
3850GLAD_API_CALL PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_glClearNamedBufferSubData;
3851#define glClearNamedBufferSubData glad_glClearNamedBufferSubData
3852GLAD_API_CALL PFNGLCLEARNAMEDFRAMEBUFFERFIPROC glad_glClearNamedFramebufferfi;
3853#define glClearNamedFramebufferfi glad_glClearNamedFramebufferfi
3854GLAD_API_CALL PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glad_glClearNamedFramebufferfv;
3855#define glClearNamedFramebufferfv glad_glClearNamedFramebufferfv
3856GLAD_API_CALL PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glad_glClearNamedFramebufferiv;
3857#define glClearNamedFramebufferiv glad_glClearNamedFramebufferiv
3858GLAD_API_CALL PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glad_glClearNamedFramebufferuiv;
3859#define glClearNamedFramebufferuiv glad_glClearNamedFramebufferuiv
3860GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
3861#define glClearStencil glad_glClearStencil
3862GLAD_API_CALL PFNGLCLEARTEXIMAGEPROC glad_glClearTexImage;
3863#define glClearTexImage glad_glClearTexImage
3864GLAD_API_CALL PFNGLCLEARTEXSUBIMAGEPROC glad_glClearTexSubImage;
3865#define glClearTexSubImage glad_glClearTexSubImage
3866GLAD_API_CALL PFNGLCLIENTACTIVETEXTUREARBPROC glad_glClientActiveTextureARB;
3867#define glClientActiveTextureARB glad_glClientActiveTextureARB
3868GLAD_API_CALL PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
3869#define glClientWaitSync glad_glClientWaitSync
3870GLAD_API_CALL PFNGLCLIPPLANEXOESPROC glad_glClipPlanexOES;
3871#define glClipPlanexOES glad_glClipPlanexOES
3872GLAD_API_CALL PFNGLCOLOR3XOESPROC glad_glColor3xOES;
3873#define glColor3xOES glad_glColor3xOES
3874GLAD_API_CALL PFNGLCOLOR3XVOESPROC glad_glColor3xvOES;
3875#define glColor3xvOES glad_glColor3xvOES
3876GLAD_API_CALL PFNGLCOLOR4XOESPROC glad_glColor4xOES;
3877#define glColor4xOES glad_glColor4xOES
3878GLAD_API_CALL PFNGLCOLOR4XVOESPROC glad_glColor4xvOES;
3879#define glColor4xvOES glad_glColor4xvOES
3880GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
3881#define glColorMask glad_glColorMask
3882GLAD_API_CALL PFNGLCOLORMASKIPROC glad_glColorMaski;
3883#define glColorMaski glad_glColorMaski
3884GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
3885#define glCompileShader glad_glCompileShader
3886GLAD_API_CALL PFNGLCOMPILESHADERARBPROC glad_glCompileShaderARB;
3887#define glCompileShaderARB glad_glCompileShaderARB
3888GLAD_API_CALL PFNGLCOMPILESHADERINCLUDEARBPROC glad_glCompileShaderIncludeARB;
3889#define glCompileShaderIncludeARB glad_glCompileShaderIncludeARB
3890GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
3891#define glCompressedTexImage1D glad_glCompressedTexImage1D
3892GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glad_glCompressedTexImage1DARB;
3893#define glCompressedTexImage1DARB glad_glCompressedTexImage1DARB
3894GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
3895#define glCompressedTexImage2D glad_glCompressedTexImage2D
3896GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glad_glCompressedTexImage2DARB;
3897#define glCompressedTexImage2DARB glad_glCompressedTexImage2DARB
3898GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
3899#define glCompressedTexImage3D glad_glCompressedTexImage3D
3900GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glad_glCompressedTexImage3DARB;
3901#define glCompressedTexImage3DARB glad_glCompressedTexImage3DARB
3902GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
3903#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
3904GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glad_glCompressedTexSubImage1DARB;
3905#define glCompressedTexSubImage1DARB glad_glCompressedTexSubImage1DARB
3906GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
3907#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
3908GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glad_glCompressedTexSubImage2DARB;
3909#define glCompressedTexSubImage2DARB glad_glCompressedTexSubImage2DARB
3910GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
3911#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
3912GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glad_glCompressedTexSubImage3DARB;
3913#define glCompressedTexSubImage3DARB glad_glCompressedTexSubImage3DARB
3914GLAD_API_CALL PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC glad_glCompressedTextureSubImage1D;
3915#define glCompressedTextureSubImage1D glad_glCompressedTextureSubImage1D
3916GLAD_API_CALL PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC glad_glCompressedTextureSubImage2D;
3917#define glCompressedTextureSubImage2D glad_glCompressedTextureSubImage2D
3918GLAD_API_CALL PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC glad_glCompressedTextureSubImage3D;
3919#define glCompressedTextureSubImage3D glad_glCompressedTextureSubImage3D
3920GLAD_API_CALL PFNGLCONVOLUTIONPARAMETERXOESPROC glad_glConvolutionParameterxOES;
3921#define glConvolutionParameterxOES glad_glConvolutionParameterxOES
3922GLAD_API_CALL PFNGLCONVOLUTIONPARAMETERXVOESPROC glad_glConvolutionParameterxvOES;
3923#define glConvolutionParameterxvOES glad_glConvolutionParameterxvOES
3924GLAD_API_CALL PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
3925#define glCopyBufferSubData glad_glCopyBufferSubData
3926GLAD_API_CALL PFNGLCOPYIMAGESUBDATAPROC glad_glCopyImageSubData;
3927#define glCopyImageSubData glad_glCopyImageSubData
3928GLAD_API_CALL PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_glCopyNamedBufferSubData;
3929#define glCopyNamedBufferSubData glad_glCopyNamedBufferSubData
3930GLAD_API_CALL PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
3931#define glCopyTexImage1D glad_glCopyTexImage1D
3932GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
3933#define glCopyTexImage2D glad_glCopyTexImage2D
3934GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
3935#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
3936GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
3937#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
3938GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
3939#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
3940GLAD_API_CALL PFNGLCOPYTEXTURESUBIMAGE1DPROC glad_glCopyTextureSubImage1D;
3941#define glCopyTextureSubImage1D glad_glCopyTextureSubImage1D
3942GLAD_API_CALL PFNGLCOPYTEXTURESUBIMAGE2DPROC glad_glCopyTextureSubImage2D;
3943#define glCopyTextureSubImage2D glad_glCopyTextureSubImage2D
3944GLAD_API_CALL PFNGLCOPYTEXTURESUBIMAGE3DPROC glad_glCopyTextureSubImage3D;
3945#define glCopyTextureSubImage3D glad_glCopyTextureSubImage3D
3946GLAD_API_CALL PFNGLCREATEBUFFERSPROC glad_glCreateBuffers;
3947#define glCreateBuffers glad_glCreateBuffers
3948GLAD_API_CALL PFNGLCREATEFRAMEBUFFERSPROC glad_glCreateFramebuffers;
3949#define glCreateFramebuffers glad_glCreateFramebuffers
3950GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
3951#define glCreateProgram glad_glCreateProgram
3952GLAD_API_CALL PFNGLCREATEPROGRAMOBJECTARBPROC glad_glCreateProgramObjectARB;
3953#define glCreateProgramObjectARB glad_glCreateProgramObjectARB
3954GLAD_API_CALL PFNGLCREATEPROGRAMPIPELINESPROC glad_glCreateProgramPipelines;
3955#define glCreateProgramPipelines glad_glCreateProgramPipelines
3956GLAD_API_CALL PFNGLCREATEQUERIESPROC glad_glCreateQueries;
3957#define glCreateQueries glad_glCreateQueries
3958GLAD_API_CALL PFNGLCREATERENDERBUFFERSPROC glad_glCreateRenderbuffers;
3959#define glCreateRenderbuffers glad_glCreateRenderbuffers
3960GLAD_API_CALL PFNGLCREATESAMPLERSPROC glad_glCreateSamplers;
3961#define glCreateSamplers glad_glCreateSamplers
3962GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
3963#define glCreateShader glad_glCreateShader
3964GLAD_API_CALL PFNGLCREATESHADEROBJECTARBPROC glad_glCreateShaderObjectARB;
3965#define glCreateShaderObjectARB glad_glCreateShaderObjectARB
3966GLAD_API_CALL PFNGLCREATESHADERPROGRAMVPROC glad_glCreateShaderProgramv;
3967#define glCreateShaderProgramv glad_glCreateShaderProgramv
3968GLAD_API_CALL PFNGLCREATETEXTURESPROC glad_glCreateTextures;
3969#define glCreateTextures glad_glCreateTextures
3970GLAD_API_CALL PFNGLCREATETRANSFORMFEEDBACKSPROC glad_glCreateTransformFeedbacks;
3971#define glCreateTransformFeedbacks glad_glCreateTransformFeedbacks
3972GLAD_API_CALL PFNGLCREATEVERTEXARRAYSPROC glad_glCreateVertexArrays;
3973#define glCreateVertexArrays glad_glCreateVertexArrays
3974GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
3975#define glCullFace glad_glCullFace
3976GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback;
3977#define glDebugMessageCallback glad_glDebugMessageCallback
3978GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKARBPROC glad_glDebugMessageCallbackARB;
3979#define glDebugMessageCallbackARB glad_glDebugMessageCallbackARB
3980GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl;
3981#define glDebugMessageControl glad_glDebugMessageControl
3982GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
3983#define glDebugMessageControlARB glad_glDebugMessageControlARB
3984GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert;
3985#define glDebugMessageInsert glad_glDebugMessageInsert
3986GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
3987#define glDebugMessageInsertARB glad_glDebugMessageInsertARB
3988GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
3989#define glDeleteBuffers glad_glDeleteBuffers
3990GLAD_API_CALL PFNGLDELETEBUFFERSARBPROC glad_glDeleteBuffersARB;
3991#define glDeleteBuffersARB glad_glDeleteBuffersARB
3992GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
3993#define glDeleteFramebuffers glad_glDeleteFramebuffers
3994GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSEXTPROC glad_glDeleteFramebuffersEXT;
3995#define glDeleteFramebuffersEXT glad_glDeleteFramebuffersEXT
3996GLAD_API_CALL PFNGLDELETENAMEDSTRINGARBPROC glad_glDeleteNamedStringARB;
3997#define glDeleteNamedStringARB glad_glDeleteNamedStringARB
3998GLAD_API_CALL PFNGLDELETEOBJECTARBPROC glad_glDeleteObjectARB;
3999#define glDeleteObjectARB glad_glDeleteObjectARB
4000GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
4001#define glDeleteProgram glad_glDeleteProgram
4002GLAD_API_CALL PFNGLDELETEPROGRAMPIPELINESPROC glad_glDeleteProgramPipelines;
4003#define glDeleteProgramPipelines glad_glDeleteProgramPipelines
4004GLAD_API_CALL PFNGLDELETEPROGRAMSARBPROC glad_glDeleteProgramsARB;
4005#define glDeleteProgramsARB glad_glDeleteProgramsARB
4006GLAD_API_CALL PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
4007#define glDeleteQueries glad_glDeleteQueries
4008GLAD_API_CALL PFNGLDELETEQUERIESARBPROC glad_glDeleteQueriesARB;
4009#define glDeleteQueriesARB glad_glDeleteQueriesARB
4010GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
4011#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
4012GLAD_API_CALL PFNGLDELETERENDERBUFFERSEXTPROC glad_glDeleteRenderbuffersEXT;
4013#define glDeleteRenderbuffersEXT glad_glDeleteRenderbuffersEXT
4014GLAD_API_CALL PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
4015#define glDeleteSamplers glad_glDeleteSamplers
4016GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
4017#define glDeleteShader glad_glDeleteShader
4018GLAD_API_CALL PFNGLDELETESYNCPROC glad_glDeleteSync;
4019#define glDeleteSync glad_glDeleteSync
4020GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
4021#define glDeleteTextures glad_glDeleteTextures
4022GLAD_API_CALL PFNGLDELETETRANSFORMFEEDBACKSPROC glad_glDeleteTransformFeedbacks;
4023#define glDeleteTransformFeedbacks glad_glDeleteTransformFeedbacks
4024GLAD_API_CALL PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
4025#define glDeleteVertexArrays glad_glDeleteVertexArrays
4026GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
4027#define glDepthFunc glad_glDepthFunc
4028GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
4029#define glDepthMask glad_glDepthMask
4030GLAD_API_CALL PFNGLDEPTHRANGEPROC glad_glDepthRange;
4031#define glDepthRange glad_glDepthRange
4032GLAD_API_CALL PFNGLDEPTHRANGEARRAYVPROC glad_glDepthRangeArrayv;
4033#define glDepthRangeArrayv glad_glDepthRangeArrayv
4034GLAD_API_CALL PFNGLDEPTHRANGEINDEXEDPROC glad_glDepthRangeIndexed;
4035#define glDepthRangeIndexed glad_glDepthRangeIndexed
4036GLAD_API_CALL PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
4037#define glDepthRangef glad_glDepthRangef
4038GLAD_API_CALL PFNGLDEPTHRANGEXOESPROC glad_glDepthRangexOES;
4039#define glDepthRangexOES glad_glDepthRangexOES
4040GLAD_API_CALL PFNGLDETACHOBJECTARBPROC glad_glDetachObjectARB;
4041#define glDetachObjectARB glad_glDetachObjectARB
4042GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
4043#define glDetachShader glad_glDetachShader
4044GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
4045#define glDisable glad_glDisable
4046GLAD_API_CALL PFNGLDISABLEVERTEXARRAYATTRIBPROC glad_glDisableVertexArrayAttrib;
4047#define glDisableVertexArrayAttrib glad_glDisableVertexArrayAttrib
4048GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
4049#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
4050GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glad_glDisableVertexAttribArrayARB;
4051#define glDisableVertexAttribArrayARB glad_glDisableVertexAttribArrayARB
4052GLAD_API_CALL PFNGLDISABLEIPROC glad_glDisablei;
4053#define glDisablei glad_glDisablei
4054GLAD_API_CALL PFNGLDISPATCHCOMPUTEPROC glad_glDispatchCompute;
4055#define glDispatchCompute glad_glDispatchCompute
4056GLAD_API_CALL PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC glad_glDispatchComputeGroupSizeARB;
4057#define glDispatchComputeGroupSizeARB glad_glDispatchComputeGroupSizeARB
4058GLAD_API_CALL PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_glDispatchComputeIndirect;
4059#define glDispatchComputeIndirect glad_glDispatchComputeIndirect
4060GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
4061#define glDrawArrays glad_glDrawArrays
4062GLAD_API_CALL PFNGLDRAWARRAYSINDIRECTPROC glad_glDrawArraysIndirect;
4063#define glDrawArraysIndirect glad_glDrawArraysIndirect
4064GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
4065#define glDrawArraysInstanced glad_glDrawArraysInstanced
4066GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDARBPROC glad_glDrawArraysInstancedARB;
4067#define glDrawArraysInstancedARB glad_glDrawArraysInstancedARB
4068GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_glDrawArraysInstancedBaseInstance;
4069#define glDrawArraysInstancedBaseInstance glad_glDrawArraysInstancedBaseInstance
4070GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT;
4071#define glDrawArraysInstancedEXT glad_glDrawArraysInstancedEXT
4072GLAD_API_CALL PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
4073#define glDrawBuffer glad_glDrawBuffer
4074GLAD_API_CALL PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
4075#define glDrawBuffers glad_glDrawBuffers
4076GLAD_API_CALL PFNGLDRAWBUFFERSARBPROC glad_glDrawBuffersARB;
4077#define glDrawBuffersARB glad_glDrawBuffersARB
4078GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
4079#define glDrawElements glad_glDrawElements
4080GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
4081#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
4082GLAD_API_CALL PFNGLDRAWELEMENTSINDIRECTPROC glad_glDrawElementsIndirect;
4083#define glDrawElementsIndirect glad_glDrawElementsIndirect
4084GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
4085#define glDrawElementsInstanced glad_glDrawElementsInstanced
4086GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDARBPROC glad_glDrawElementsInstancedARB;
4087#define glDrawElementsInstancedARB glad_glDrawElementsInstancedARB
4088GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_glDrawElementsInstancedBaseInstance;
4089#define glDrawElementsInstancedBaseInstance glad_glDrawElementsInstancedBaseInstance
4090GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
4091#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
4092GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance;
4093#define glDrawElementsInstancedBaseVertexBaseInstance glad_glDrawElementsInstancedBaseVertexBaseInstance
4094GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT;
4095#define glDrawElementsInstancedEXT glad_glDrawElementsInstancedEXT
4096GLAD_API_CALL PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
4097#define glDrawRangeElements glad_glDrawRangeElements
4098GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
4099#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
4100GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKPROC glad_glDrawTransformFeedback;
4101#define glDrawTransformFeedback glad_glDrawTransformFeedback
4102GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_glDrawTransformFeedbackInstanced;
4103#define glDrawTransformFeedbackInstanced glad_glDrawTransformFeedbackInstanced
4104GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_glDrawTransformFeedbackStream;
4105#define glDrawTransformFeedbackStream glad_glDrawTransformFeedbackStream
4106GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_glDrawTransformFeedbackStreamInstanced;
4107#define glDrawTransformFeedbackStreamInstanced glad_glDrawTransformFeedbackStreamInstanced
4108GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
4109#define glEnable glad_glEnable
4110GLAD_API_CALL PFNGLENABLEVERTEXARRAYATTRIBPROC glad_glEnableVertexArrayAttrib;
4111#define glEnableVertexArrayAttrib glad_glEnableVertexArrayAttrib
4112GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
4113#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
4114GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYARBPROC glad_glEnableVertexAttribArrayARB;
4115#define glEnableVertexAttribArrayARB glad_glEnableVertexAttribArrayARB
4116GLAD_API_CALL PFNGLENABLEIPROC glad_glEnablei;
4117#define glEnablei glad_glEnablei
4118GLAD_API_CALL PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
4119#define glEndConditionalRender glad_glEndConditionalRender
4120GLAD_API_CALL PFNGLENDQUERYPROC glad_glEndQuery;
4121#define glEndQuery glad_glEndQuery
4122GLAD_API_CALL PFNGLENDQUERYARBPROC glad_glEndQueryARB;
4123#define glEndQueryARB glad_glEndQueryARB
4124GLAD_API_CALL PFNGLENDQUERYINDEXEDPROC glad_glEndQueryIndexed;
4125#define glEndQueryIndexed glad_glEndQueryIndexed
4126GLAD_API_CALL PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
4127#define glEndTransformFeedback glad_glEndTransformFeedback
4128GLAD_API_CALL PFNGLEVALCOORD1XOESPROC glad_glEvalCoord1xOES;
4129#define glEvalCoord1xOES glad_glEvalCoord1xOES
4130GLAD_API_CALL PFNGLEVALCOORD1XVOESPROC glad_glEvalCoord1xvOES;
4131#define glEvalCoord1xvOES glad_glEvalCoord1xvOES
4132GLAD_API_CALL PFNGLEVALCOORD2XOESPROC glad_glEvalCoord2xOES;
4133#define glEvalCoord2xOES glad_glEvalCoord2xOES
4134GLAD_API_CALL PFNGLEVALCOORD2XVOESPROC glad_glEvalCoord2xvOES;
4135#define glEvalCoord2xvOES glad_glEvalCoord2xvOES
4136GLAD_API_CALL PFNGLEVALUATEDEPTHVALUESARBPROC glad_glEvaluateDepthValuesARB;
4137#define glEvaluateDepthValuesARB glad_glEvaluateDepthValuesARB
4138GLAD_API_CALL PFNGLFEEDBACKBUFFERXOESPROC glad_glFeedbackBufferxOES;
4139#define glFeedbackBufferxOES glad_glFeedbackBufferxOES
4140GLAD_API_CALL PFNGLFENCESYNCPROC glad_glFenceSync;
4141#define glFenceSync glad_glFenceSync
4142GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
4143#define glFinish glad_glFinish
4144GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
4145#define glFlush glad_glFlush
4146GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
4147#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
4148GLAD_API_CALL PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_glFlushMappedNamedBufferRange;
4149#define glFlushMappedNamedBufferRange glad_glFlushMappedNamedBufferRange
4150GLAD_API_CALL PFNGLFOGCOORDPOINTEREXTPROC glad_glFogCoordPointerEXT;
4151#define glFogCoordPointerEXT glad_glFogCoordPointerEXT
4152GLAD_API_CALL PFNGLFOGCOORDDEXTPROC glad_glFogCoorddEXT;
4153#define glFogCoorddEXT glad_glFogCoorddEXT
4154GLAD_API_CALL PFNGLFOGCOORDDVEXTPROC glad_glFogCoorddvEXT;
4155#define glFogCoorddvEXT glad_glFogCoorddvEXT
4156GLAD_API_CALL PFNGLFOGCOORDFEXTPROC glad_glFogCoordfEXT;
4157#define glFogCoordfEXT glad_glFogCoordfEXT
4158GLAD_API_CALL PFNGLFOGCOORDFVEXTPROC glad_glFogCoordfvEXT;
4159#define glFogCoordfvEXT glad_glFogCoordfvEXT
4160GLAD_API_CALL PFNGLFOGXOESPROC glad_glFogxOES;
4161#define glFogxOES glad_glFogxOES
4162GLAD_API_CALL PFNGLFOGXVOESPROC glad_glFogxvOES;
4163#define glFogxvOES glad_glFogxvOES
4164GLAD_API_CALL PFNGLFRAMEBUFFERPARAMETERIPROC glad_glFramebufferParameteri;
4165#define glFramebufferParameteri glad_glFramebufferParameteri
4166GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
4167#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
4168GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glad_glFramebufferRenderbufferEXT;
4169#define glFramebufferRenderbufferEXT glad_glFramebufferRenderbufferEXT
4170GLAD_API_CALL PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glFramebufferSampleLocationsfvARB;
4171#define glFramebufferSampleLocationsfvARB glad_glFramebufferSampleLocationsfvARB
4172GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
4173#define glFramebufferTexture glad_glFramebufferTexture
4174GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
4175#define glFramebufferTexture1D glad_glFramebufferTexture1D
4176GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glad_glFramebufferTexture1DEXT;
4177#define glFramebufferTexture1DEXT glad_glFramebufferTexture1DEXT
4178GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
4179#define glFramebufferTexture2D glad_glFramebufferTexture2D
4180GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glad_glFramebufferTexture2DEXT;
4181#define glFramebufferTexture2DEXT glad_glFramebufferTexture2DEXT
4182GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
4183#define glFramebufferTexture3D glad_glFramebufferTexture3D
4184GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glad_glFramebufferTexture3DEXT;
4185#define glFramebufferTexture3DEXT glad_glFramebufferTexture3DEXT
4186GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREARBPROC glad_glFramebufferTextureARB;
4187#define glFramebufferTextureARB glad_glFramebufferTextureARB
4188GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREFACEARBPROC glad_glFramebufferTextureFaceARB;
4189#define glFramebufferTextureFaceARB glad_glFramebufferTextureFaceARB
4190GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
4191#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
4192GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURELAYERARBPROC glad_glFramebufferTextureLayerARB;
4193#define glFramebufferTextureLayerARB glad_glFramebufferTextureLayerARB
4194GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
4195#define glFrontFace glad_glFrontFace
4196GLAD_API_CALL PFNGLFRUSTUMXOESPROC glad_glFrustumxOES;
4197#define glFrustumxOES glad_glFrustumxOES
4198GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
4199#define glGenBuffers glad_glGenBuffers
4200GLAD_API_CALL PFNGLGENBUFFERSARBPROC glad_glGenBuffersARB;
4201#define glGenBuffersARB glad_glGenBuffersARB
4202GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
4203#define glGenFramebuffers glad_glGenFramebuffers
4204GLAD_API_CALL PFNGLGENFRAMEBUFFERSEXTPROC glad_glGenFramebuffersEXT;
4205#define glGenFramebuffersEXT glad_glGenFramebuffersEXT
4206GLAD_API_CALL PFNGLGENPROGRAMPIPELINESPROC glad_glGenProgramPipelines;
4207#define glGenProgramPipelines glad_glGenProgramPipelines
4208GLAD_API_CALL PFNGLGENPROGRAMSARBPROC glad_glGenProgramsARB;
4209#define glGenProgramsARB glad_glGenProgramsARB
4210GLAD_API_CALL PFNGLGENQUERIESPROC glad_glGenQueries;
4211#define glGenQueries glad_glGenQueries
4212GLAD_API_CALL PFNGLGENQUERIESARBPROC glad_glGenQueriesARB;
4213#define glGenQueriesARB glad_glGenQueriesARB
4214GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
4215#define glGenRenderbuffers glad_glGenRenderbuffers
4216GLAD_API_CALL PFNGLGENRENDERBUFFERSEXTPROC glad_glGenRenderbuffersEXT;
4217#define glGenRenderbuffersEXT glad_glGenRenderbuffersEXT
4218GLAD_API_CALL PFNGLGENSAMPLERSPROC glad_glGenSamplers;
4219#define glGenSamplers glad_glGenSamplers
4220GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
4221#define glGenTextures glad_glGenTextures
4222GLAD_API_CALL PFNGLGENTRANSFORMFEEDBACKSPROC glad_glGenTransformFeedbacks;
4223#define glGenTransformFeedbacks glad_glGenTransformFeedbacks
4224GLAD_API_CALL PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
4225#define glGenVertexArrays glad_glGenVertexArrays
4226GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
4227#define glGenerateMipmap glad_glGenerateMipmap
4228GLAD_API_CALL PFNGLGENERATEMIPMAPEXTPROC glad_glGenerateMipmapEXT;
4229#define glGenerateMipmapEXT glad_glGenerateMipmapEXT
4230GLAD_API_CALL PFNGLGENERATETEXTUREMIPMAPPROC glad_glGenerateTextureMipmap;
4231#define glGenerateTextureMipmap glad_glGenerateTextureMipmap
4232GLAD_API_CALL PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_glGetActiveAtomicCounterBufferiv;
4233#define glGetActiveAtomicCounterBufferiv glad_glGetActiveAtomicCounterBufferiv
4234GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
4235#define glGetActiveAttrib glad_glGetActiveAttrib
4236GLAD_API_CALL PFNGLGETACTIVEATTRIBARBPROC glad_glGetActiveAttribARB;
4237#define glGetActiveAttribARB glad_glGetActiveAttribARB
4238GLAD_API_CALL PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName;
4239#define glGetActiveSubroutineName glad_glGetActiveSubroutineName
4240GLAD_API_CALL PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName;
4241#define glGetActiveSubroutineUniformName glad_glGetActiveSubroutineUniformName
4242GLAD_API_CALL PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv;
4243#define glGetActiveSubroutineUniformiv glad_glGetActiveSubroutineUniformiv
4244GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
4245#define glGetActiveUniform glad_glGetActiveUniform
4246GLAD_API_CALL PFNGLGETACTIVEUNIFORMARBPROC glad_glGetActiveUniformARB;
4247#define glGetActiveUniformARB glad_glGetActiveUniformARB
4248GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
4249#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
4250GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
4251#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
4252GLAD_API_CALL PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
4253#define glGetActiveUniformName glad_glGetActiveUniformName
4254GLAD_API_CALL PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
4255#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
4256GLAD_API_CALL PFNGLGETATTACHEDOBJECTSARBPROC glad_glGetAttachedObjectsARB;
4257#define glGetAttachedObjectsARB glad_glGetAttachedObjectsARB
4258GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
4259#define glGetAttachedShaders glad_glGetAttachedShaders
4260GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
4261#define glGetAttribLocation glad_glGetAttribLocation
4262GLAD_API_CALL PFNGLGETATTRIBLOCATIONARBPROC glad_glGetAttribLocationARB;
4263#define glGetAttribLocationARB glad_glGetAttribLocationARB
4264GLAD_API_CALL PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
4265#define glGetBooleani_v glad_glGetBooleani_v
4266GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
4267#define glGetBooleanv glad_glGetBooleanv
4268GLAD_API_CALL PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
4269#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
4270GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
4271#define glGetBufferParameteriv glad_glGetBufferParameteriv
4272GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVARBPROC glad_glGetBufferParameterivARB;
4273#define glGetBufferParameterivARB glad_glGetBufferParameterivARB
4274GLAD_API_CALL PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
4275#define glGetBufferPointerv glad_glGetBufferPointerv
4276GLAD_API_CALL PFNGLGETBUFFERPOINTERVARBPROC glad_glGetBufferPointervARB;
4277#define glGetBufferPointervARB glad_glGetBufferPointervARB
4278GLAD_API_CALL PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
4279#define glGetBufferSubData glad_glGetBufferSubData
4280GLAD_API_CALL PFNGLGETBUFFERSUBDATAARBPROC glad_glGetBufferSubDataARB;
4281#define glGetBufferSubDataARB glad_glGetBufferSubDataARB
4282GLAD_API_CALL PFNGLGETCLIPPLANEXOESPROC glad_glGetClipPlanexOES;
4283#define glGetClipPlanexOES glad_glGetClipPlanexOES
4284GLAD_API_CALL PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
4285#define glGetCompressedTexImage glad_glGetCompressedTexImage
4286GLAD_API_CALL PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glad_glGetCompressedTexImageARB;
4287#define glGetCompressedTexImageARB glad_glGetCompressedTexImageARB
4288GLAD_API_CALL PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC glad_glGetCompressedTextureImage;
4289#define glGetCompressedTextureImage glad_glGetCompressedTextureImage
4290GLAD_API_CALL PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC glad_glGetCompressedTextureSubImage;
4291#define glGetCompressedTextureSubImage glad_glGetCompressedTextureSubImage
4292GLAD_API_CALL PFNGLGETCONVOLUTIONPARAMETERXVOESPROC glad_glGetConvolutionParameterxvOES;
4293#define glGetConvolutionParameterxvOES glad_glGetConvolutionParameterxvOES
4294GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog;
4295#define glGetDebugMessageLog glad_glGetDebugMessageLog
4296GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
4297#define glGetDebugMessageLogARB glad_glGetDebugMessageLogARB
4298GLAD_API_CALL PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v;
4299#define glGetDoublei_v glad_glGetDoublei_v
4300GLAD_API_CALL PFNGLGETDOUBLEVPROC glad_glGetDoublev;
4301#define glGetDoublev glad_glGetDoublev
4302GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
4303#define glGetError glad_glGetError
4304GLAD_API_CALL PFNGLGETFIXEDVOESPROC glad_glGetFixedvOES;
4305#define glGetFixedvOES glad_glGetFixedvOES
4306GLAD_API_CALL PFNGLGETFLOATI_VPROC glad_glGetFloati_v;
4307#define glGetFloati_v glad_glGetFloati_v
4308GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
4309#define glGetFloatv glad_glGetFloatv
4310GLAD_API_CALL PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
4311#define glGetFragDataIndex glad_glGetFragDataIndex
4312GLAD_API_CALL PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
4313#define glGetFragDataLocation glad_glGetFragDataLocation
4314GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
4315#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
4316GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glad_glGetFramebufferAttachmentParameterivEXT;
4317#define glGetFramebufferAttachmentParameterivEXT glad_glGetFramebufferAttachmentParameterivEXT
4318GLAD_API_CALL PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv;
4319#define glGetFramebufferParameteriv glad_glGetFramebufferParameteriv
4320GLAD_API_CALL PFNGLGETHANDLEARBPROC glad_glGetHandleARB;
4321#define glGetHandleARB glad_glGetHandleARB
4322GLAD_API_CALL PFNGLGETHISTOGRAMPARAMETERXVOESPROC glad_glGetHistogramParameterxvOES;
4323#define glGetHistogramParameterxvOES glad_glGetHistogramParameterxvOES
4324GLAD_API_CALL PFNGLGETINFOLOGARBPROC glad_glGetInfoLogARB;
4325#define glGetInfoLogARB glad_glGetInfoLogARB
4326GLAD_API_CALL PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
4327#define glGetInteger64i_v glad_glGetInteger64i_v
4328GLAD_API_CALL PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
4329#define glGetInteger64v glad_glGetInteger64v
4330GLAD_API_CALL PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
4331#define glGetIntegeri_v glad_glGetIntegeri_v
4332GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
4333#define glGetIntegerv glad_glGetIntegerv
4334GLAD_API_CALL PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v;
4335#define glGetInternalformati64v glad_glGetInternalformati64v
4336GLAD_API_CALL PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ;
4337#define glGetInternalformativ glad_glGetInternalformativ
4338GLAD_API_CALL PFNGLGETLIGHTXOESPROC glad_glGetLightxOES;
4339#define glGetLightxOES glad_glGetLightxOES
4340GLAD_API_CALL PFNGLGETMAPXVOESPROC glad_glGetMapxvOES;
4341#define glGetMapxvOES glad_glGetMapxvOES
4342GLAD_API_CALL PFNGLGETMATERIALXOESPROC glad_glGetMaterialxOES;
4343#define glGetMaterialxOES glad_glGetMaterialxOES
4344GLAD_API_CALL PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
4345#define glGetMultisamplefv glad_glGetMultisamplefv
4346GLAD_API_CALL PFNGLGETNAMEDBUFFERPARAMETERI64VPROC glad_glGetNamedBufferParameteri64v;
4347#define glGetNamedBufferParameteri64v glad_glGetNamedBufferParameteri64v
4348GLAD_API_CALL PFNGLGETNAMEDBUFFERPARAMETERIVPROC glad_glGetNamedBufferParameteriv;
4349#define glGetNamedBufferParameteriv glad_glGetNamedBufferParameteriv
4350GLAD_API_CALL PFNGLGETNAMEDBUFFERPOINTERVPROC glad_glGetNamedBufferPointerv;
4351#define glGetNamedBufferPointerv glad_glGetNamedBufferPointerv
4352GLAD_API_CALL PFNGLGETNAMEDBUFFERSUBDATAPROC glad_glGetNamedBufferSubData;
4353#define glGetNamedBufferSubData glad_glGetNamedBufferSubData
4354GLAD_API_CALL PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetNamedFramebufferAttachmentParameteriv;
4355#define glGetNamedFramebufferAttachmentParameteriv glad_glGetNamedFramebufferAttachmentParameteriv
4356GLAD_API_CALL PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC glad_glGetNamedFramebufferParameteriv;
4357#define glGetNamedFramebufferParameteriv glad_glGetNamedFramebufferParameteriv
4358GLAD_API_CALL PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC glad_glGetNamedRenderbufferParameteriv;
4359#define glGetNamedRenderbufferParameteriv glad_glGetNamedRenderbufferParameteriv
4360GLAD_API_CALL PFNGLGETNAMEDSTRINGARBPROC glad_glGetNamedStringARB;
4361#define glGetNamedStringARB glad_glGetNamedStringARB
4362GLAD_API_CALL PFNGLGETNAMEDSTRINGIVARBPROC glad_glGetNamedStringivARB;
4363#define glGetNamedStringivARB glad_glGetNamedStringivARB
4364GLAD_API_CALL PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel;
4365#define glGetObjectLabel glad_glGetObjectLabel
4366GLAD_API_CALL PFNGLGETOBJECTPARAMETERFVARBPROC glad_glGetObjectParameterfvARB;
4367#define glGetObjectParameterfvARB glad_glGetObjectParameterfvARB
4368GLAD_API_CALL PFNGLGETOBJECTPARAMETERIVARBPROC glad_glGetObjectParameterivARB;
4369#define glGetObjectParameterivARB glad_glGetObjectParameterivARB
4370GLAD_API_CALL PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel;
4371#define glGetObjectPtrLabel glad_glGetObjectPtrLabel
4372GLAD_API_CALL PFNGLGETPIXELMAPXVPROC glad_glGetPixelMapxv;
4373#define glGetPixelMapxv glad_glGetPixelMapxv
4374GLAD_API_CALL PFNGLGETPOINTERVPROC glad_glGetPointerv;
4375#define glGetPointerv glad_glGetPointerv
4376GLAD_API_CALL PFNGLGETPROGRAMBINARYPROC glad_glGetProgramBinary;
4377#define glGetProgramBinary glad_glGetProgramBinary
4378GLAD_API_CALL PFNGLGETPROGRAMENVPARAMETERDVARBPROC glad_glGetProgramEnvParameterdvARB;
4379#define glGetProgramEnvParameterdvARB glad_glGetProgramEnvParameterdvARB
4380GLAD_API_CALL PFNGLGETPROGRAMENVPARAMETERFVARBPROC glad_glGetProgramEnvParameterfvARB;
4381#define glGetProgramEnvParameterfvARB glad_glGetProgramEnvParameterfvARB
4382GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
4383#define glGetProgramInfoLog glad_glGetProgramInfoLog
4384GLAD_API_CALL PFNGLGETPROGRAMINTERFACEIVPROC glad_glGetProgramInterfaceiv;
4385#define glGetProgramInterfaceiv glad_glGetProgramInterfaceiv
4386GLAD_API_CALL PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glad_glGetProgramLocalParameterdvARB;
4387#define glGetProgramLocalParameterdvARB glad_glGetProgramLocalParameterdvARB
4388GLAD_API_CALL PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glad_glGetProgramLocalParameterfvARB;
4389#define glGetProgramLocalParameterfvARB glad_glGetProgramLocalParameterfvARB
4390GLAD_API_CALL PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_glGetProgramPipelineInfoLog;
4391#define glGetProgramPipelineInfoLog glad_glGetProgramPipelineInfoLog
4392GLAD_API_CALL PFNGLGETPROGRAMPIPELINEIVPROC glad_glGetProgramPipelineiv;
4393#define glGetProgramPipelineiv glad_glGetProgramPipelineiv
4394GLAD_API_CALL PFNGLGETPROGRAMRESOURCEINDEXPROC glad_glGetProgramResourceIndex;
4395#define glGetProgramResourceIndex glad_glGetProgramResourceIndex
4396GLAD_API_CALL PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_glGetProgramResourceLocation;
4397#define glGetProgramResourceLocation glad_glGetProgramResourceLocation
4398GLAD_API_CALL PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_glGetProgramResourceLocationIndex;
4399#define glGetProgramResourceLocationIndex glad_glGetProgramResourceLocationIndex
4400GLAD_API_CALL PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName;
4401#define glGetProgramResourceName glad_glGetProgramResourceName
4402GLAD_API_CALL PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv;
4403#define glGetProgramResourceiv glad_glGetProgramResourceiv
4404GLAD_API_CALL PFNGLGETPROGRAMSTAGEIVPROC glad_glGetProgramStageiv;
4405#define glGetProgramStageiv glad_glGetProgramStageiv
4406GLAD_API_CALL PFNGLGETPROGRAMSTRINGARBPROC glad_glGetProgramStringARB;
4407#define glGetProgramStringARB glad_glGetProgramStringARB
4408GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
4409#define glGetProgramiv glad_glGetProgramiv
4410GLAD_API_CALL PFNGLGETPROGRAMIVARBPROC glad_glGetProgramivARB;
4411#define glGetProgramivARB glad_glGetProgramivARB
4412GLAD_API_CALL PFNGLGETQUERYBUFFEROBJECTI64VPROC glad_glGetQueryBufferObjecti64v;
4413#define glGetQueryBufferObjecti64v glad_glGetQueryBufferObjecti64v
4414GLAD_API_CALL PFNGLGETQUERYBUFFEROBJECTIVPROC glad_glGetQueryBufferObjectiv;
4415#define glGetQueryBufferObjectiv glad_glGetQueryBufferObjectiv
4416GLAD_API_CALL PFNGLGETQUERYBUFFEROBJECTUI64VPROC glad_glGetQueryBufferObjectui64v;
4417#define glGetQueryBufferObjectui64v glad_glGetQueryBufferObjectui64v
4418GLAD_API_CALL PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv;
4419#define glGetQueryBufferObjectuiv glad_glGetQueryBufferObjectuiv
4420GLAD_API_CALL PFNGLGETQUERYINDEXEDIVPROC glad_glGetQueryIndexediv;
4421#define glGetQueryIndexediv glad_glGetQueryIndexediv
4422GLAD_API_CALL PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
4423#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
4424GLAD_API_CALL PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
4425#define glGetQueryObjectiv glad_glGetQueryObjectiv
4426GLAD_API_CALL PFNGLGETQUERYOBJECTIVARBPROC glad_glGetQueryObjectivARB;
4427#define glGetQueryObjectivARB glad_glGetQueryObjectivARB
4428GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
4429#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
4430GLAD_API_CALL PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
4431#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
4432GLAD_API_CALL PFNGLGETQUERYOBJECTUIVARBPROC glad_glGetQueryObjectuivARB;
4433#define glGetQueryObjectuivARB glad_glGetQueryObjectuivARB
4434GLAD_API_CALL PFNGLGETQUERYIVPROC glad_glGetQueryiv;
4435#define glGetQueryiv glad_glGetQueryiv
4436GLAD_API_CALL PFNGLGETQUERYIVARBPROC glad_glGetQueryivARB;
4437#define glGetQueryivARB glad_glGetQueryivARB
4438GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
4439#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
4440GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glad_glGetRenderbufferParameterivEXT;
4441#define glGetRenderbufferParameterivEXT glad_glGetRenderbufferParameterivEXT
4442GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
4443#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
4444GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
4445#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
4446GLAD_API_CALL PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
4447#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
4448GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
4449#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
4450GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
4451#define glGetShaderInfoLog glad_glGetShaderInfoLog
4452GLAD_API_CALL PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
4453#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
4454GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
4455#define glGetShaderSource glad_glGetShaderSource
4456GLAD_API_CALL PFNGLGETSHADERSOURCEARBPROC glad_glGetShaderSourceARB;
4457#define glGetShaderSourceARB glad_glGetShaderSourceARB
4458GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
4459#define glGetShaderiv glad_glGetShaderiv
4460GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
4461#define glGetString glad_glGetString
4462GLAD_API_CALL PFNGLGETSTRINGIPROC glad_glGetStringi;
4463#define glGetStringi glad_glGetStringi
4464GLAD_API_CALL PFNGLGETSUBROUTINEINDEXPROC glad_glGetSubroutineIndex;
4465#define glGetSubroutineIndex glad_glGetSubroutineIndex
4466GLAD_API_CALL PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_glGetSubroutineUniformLocation;
4467#define glGetSubroutineUniformLocation glad_glGetSubroutineUniformLocation
4468GLAD_API_CALL PFNGLGETSYNCIVPROC glad_glGetSynciv;
4469#define glGetSynciv glad_glGetSynciv
4470GLAD_API_CALL PFNGLGETTEXENVXVOESPROC glad_glGetTexEnvxvOES;
4471#define glGetTexEnvxvOES glad_glGetTexEnvxvOES
4472GLAD_API_CALL PFNGLGETTEXGENXVOESPROC glad_glGetTexGenxvOES;
4473#define glGetTexGenxvOES glad_glGetTexGenxvOES
4474GLAD_API_CALL PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
4475#define glGetTexImage glad_glGetTexImage
4476GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
4477#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
4478GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
4479#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
4480GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERXVOESPROC glad_glGetTexLevelParameterxvOES;
4481#define glGetTexLevelParameterxvOES glad_glGetTexLevelParameterxvOES
4482GLAD_API_CALL PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
4483#define glGetTexParameterIiv glad_glGetTexParameterIiv
4484GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
4485#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
4486GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
4487#define glGetTexParameterfv glad_glGetTexParameterfv
4488GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
4489#define glGetTexParameteriv glad_glGetTexParameteriv
4490GLAD_API_CALL PFNGLGETTEXPARAMETERXVOESPROC glad_glGetTexParameterxvOES;
4491#define glGetTexParameterxvOES glad_glGetTexParameterxvOES
4492GLAD_API_CALL PFNGLGETTEXTUREIMAGEPROC glad_glGetTextureImage;
4493#define glGetTextureImage glad_glGetTextureImage
4494GLAD_API_CALL PFNGLGETTEXTURELEVELPARAMETERFVPROC glad_glGetTextureLevelParameterfv;
4495#define glGetTextureLevelParameterfv glad_glGetTextureLevelParameterfv
4496GLAD_API_CALL PFNGLGETTEXTURELEVELPARAMETERIVPROC glad_glGetTextureLevelParameteriv;
4497#define glGetTextureLevelParameteriv glad_glGetTextureLevelParameteriv
4498GLAD_API_CALL PFNGLGETTEXTUREPARAMETERIIVPROC glad_glGetTextureParameterIiv;
4499#define glGetTextureParameterIiv glad_glGetTextureParameterIiv
4500GLAD_API_CALL PFNGLGETTEXTUREPARAMETERIUIVPROC glad_glGetTextureParameterIuiv;
4501#define glGetTextureParameterIuiv glad_glGetTextureParameterIuiv
4502GLAD_API_CALL PFNGLGETTEXTUREPARAMETERFVPROC glad_glGetTextureParameterfv;
4503#define glGetTextureParameterfv glad_glGetTextureParameterfv
4504GLAD_API_CALL PFNGLGETTEXTUREPARAMETERIVPROC glad_glGetTextureParameteriv;
4505#define glGetTextureParameteriv glad_glGetTextureParameteriv
4506GLAD_API_CALL PFNGLGETTEXTURESUBIMAGEPROC glad_glGetTextureSubImage;
4507#define glGetTextureSubImage glad_glGetTextureSubImage
4508GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
4509#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
4510GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKI64_VPROC glad_glGetTransformFeedbacki64_v;
4511#define glGetTransformFeedbacki64_v glad_glGetTransformFeedbacki64_v
4512GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKI_VPROC glad_glGetTransformFeedbacki_v;
4513#define glGetTransformFeedbacki_v glad_glGetTransformFeedbacki_v
4514GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKIVPROC glad_glGetTransformFeedbackiv;
4515#define glGetTransformFeedbackiv glad_glGetTransformFeedbackiv
4516GLAD_API_CALL PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
4517#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
4518GLAD_API_CALL PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
4519#define glGetUniformIndices glad_glGetUniformIndices
4520GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
4521#define glGetUniformLocation glad_glGetUniformLocation
4522GLAD_API_CALL PFNGLGETUNIFORMLOCATIONARBPROC glad_glGetUniformLocationARB;
4523#define glGetUniformLocationARB glad_glGetUniformLocationARB
4524GLAD_API_CALL PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_glGetUniformSubroutineuiv;
4525#define glGetUniformSubroutineuiv glad_glGetUniformSubroutineuiv
4526GLAD_API_CALL PFNGLGETUNIFORMDVPROC glad_glGetUniformdv;
4527#define glGetUniformdv glad_glGetUniformdv
4528GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
4529#define glGetUniformfv glad_glGetUniformfv
4530GLAD_API_CALL PFNGLGETUNIFORMFVARBPROC glad_glGetUniformfvARB;
4531#define glGetUniformfvARB glad_glGetUniformfvARB
4532GLAD_API_CALL PFNGLGETUNIFORMI64VARBPROC glad_glGetUniformi64vARB;
4533#define glGetUniformi64vARB glad_glGetUniformi64vARB
4534GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
4535#define glGetUniformiv glad_glGetUniformiv
4536GLAD_API_CALL PFNGLGETUNIFORMIVARBPROC glad_glGetUniformivARB;
4537#define glGetUniformivARB glad_glGetUniformivARB
4538GLAD_API_CALL PFNGLGETUNIFORMUI64VARBPROC glad_glGetUniformui64vARB;
4539#define glGetUniformui64vARB glad_glGetUniformui64vARB
4540GLAD_API_CALL PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
4541#define glGetUniformuiv glad_glGetUniformuiv
4542GLAD_API_CALL PFNGLGETVERTEXARRAYINDEXED64IVPROC glad_glGetVertexArrayIndexed64iv;
4543#define glGetVertexArrayIndexed64iv glad_glGetVertexArrayIndexed64iv
4544GLAD_API_CALL PFNGLGETVERTEXARRAYINDEXEDIVPROC glad_glGetVertexArrayIndexediv;
4545#define glGetVertexArrayIndexediv glad_glGetVertexArrayIndexediv
4546GLAD_API_CALL PFNGLGETVERTEXARRAYIVPROC glad_glGetVertexArrayiv;
4547#define glGetVertexArrayiv glad_glGetVertexArrayiv
4548GLAD_API_CALL PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
4549#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
4550GLAD_API_CALL PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
4551#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
4552GLAD_API_CALL PFNGLGETVERTEXATTRIBLDVPROC glad_glGetVertexAttribLdv;
4553#define glGetVertexAttribLdv glad_glGetVertexAttribLdv
4554GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
4555#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
4556GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVARBPROC glad_glGetVertexAttribPointervARB;
4557#define glGetVertexAttribPointervARB glad_glGetVertexAttribPointervARB
4558GLAD_API_CALL PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
4559#define glGetVertexAttribdv glad_glGetVertexAttribdv
4560GLAD_API_CALL PFNGLGETVERTEXATTRIBDVARBPROC glad_glGetVertexAttribdvARB;
4561#define glGetVertexAttribdvARB glad_glGetVertexAttribdvARB
4562GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
4563#define glGetVertexAttribfv glad_glGetVertexAttribfv
4564GLAD_API_CALL PFNGLGETVERTEXATTRIBFVARBPROC glad_glGetVertexAttribfvARB;
4565#define glGetVertexAttribfvARB glad_glGetVertexAttribfvARB
4566GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
4567#define glGetVertexAttribiv glad_glGetVertexAttribiv
4568GLAD_API_CALL PFNGLGETVERTEXATTRIBIVARBPROC glad_glGetVertexAttribivARB;
4569#define glGetVertexAttribivARB glad_glGetVertexAttribivARB
4570GLAD_API_CALL PFNGLGETNUNIFORMI64VARBPROC glad_glGetnUniformi64vARB;
4571#define glGetnUniformi64vARB glad_glGetnUniformi64vARB
4572GLAD_API_CALL PFNGLGETNUNIFORMUI64VARBPROC glad_glGetnUniformui64vARB;
4573#define glGetnUniformui64vARB glad_glGetnUniformui64vARB
4574GLAD_API_CALL PFNGLHINTPROC glad_glHint;
4575#define glHint glad_glHint
4576GLAD_API_CALL PFNGLINDEXXOESPROC glad_glIndexxOES;
4577#define glIndexxOES glad_glIndexxOES
4578GLAD_API_CALL PFNGLINDEXXVOESPROC glad_glIndexxvOES;
4579#define glIndexxvOES glad_glIndexxvOES
4580GLAD_API_CALL PFNGLINVALIDATEBUFFERDATAPROC glad_glInvalidateBufferData;
4581#define glInvalidateBufferData glad_glInvalidateBufferData
4582GLAD_API_CALL PFNGLINVALIDATEBUFFERSUBDATAPROC glad_glInvalidateBufferSubData;
4583#define glInvalidateBufferSubData glad_glInvalidateBufferSubData
4584GLAD_API_CALL PFNGLINVALIDATEFRAMEBUFFERPROC glad_glInvalidateFramebuffer;
4585#define glInvalidateFramebuffer glad_glInvalidateFramebuffer
4586GLAD_API_CALL PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_glInvalidateNamedFramebufferData;
4587#define glInvalidateNamedFramebufferData glad_glInvalidateNamedFramebufferData
4588GLAD_API_CALL PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_glInvalidateNamedFramebufferSubData;
4589#define glInvalidateNamedFramebufferSubData glad_glInvalidateNamedFramebufferSubData
4590GLAD_API_CALL PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_glInvalidateSubFramebuffer;
4591#define glInvalidateSubFramebuffer glad_glInvalidateSubFramebuffer
4592GLAD_API_CALL PFNGLINVALIDATETEXIMAGEPROC glad_glInvalidateTexImage;
4593#define glInvalidateTexImage glad_glInvalidateTexImage
4594GLAD_API_CALL PFNGLINVALIDATETEXSUBIMAGEPROC glad_glInvalidateTexSubImage;
4595#define glInvalidateTexSubImage glad_glInvalidateTexSubImage
4596GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
4597#define glIsBuffer glad_glIsBuffer
4598GLAD_API_CALL PFNGLISBUFFERARBPROC glad_glIsBufferARB;
4599#define glIsBufferARB glad_glIsBufferARB
4600GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
4601#define glIsEnabled glad_glIsEnabled
4602GLAD_API_CALL PFNGLISENABLEDIPROC glad_glIsEnabledi;
4603#define glIsEnabledi glad_glIsEnabledi
4604GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
4605#define glIsFramebuffer glad_glIsFramebuffer
4606GLAD_API_CALL PFNGLISFRAMEBUFFEREXTPROC glad_glIsFramebufferEXT;
4607#define glIsFramebufferEXT glad_glIsFramebufferEXT
4608GLAD_API_CALL PFNGLISNAMEDSTRINGARBPROC glad_glIsNamedStringARB;
4609#define glIsNamedStringARB glad_glIsNamedStringARB
4610GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
4611#define glIsProgram glad_glIsProgram
4612GLAD_API_CALL PFNGLISPROGRAMARBPROC glad_glIsProgramARB;
4613#define glIsProgramARB glad_glIsProgramARB
4614GLAD_API_CALL PFNGLISPROGRAMPIPELINEPROC glad_glIsProgramPipeline;
4615#define glIsProgramPipeline glad_glIsProgramPipeline
4616GLAD_API_CALL PFNGLISQUERYPROC glad_glIsQuery;
4617#define glIsQuery glad_glIsQuery
4618GLAD_API_CALL PFNGLISQUERYARBPROC glad_glIsQueryARB;
4619#define glIsQueryARB glad_glIsQueryARB
4620GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
4621#define glIsRenderbuffer glad_glIsRenderbuffer
4622GLAD_API_CALL PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT;
4623#define glIsRenderbufferEXT glad_glIsRenderbufferEXT
4624GLAD_API_CALL PFNGLISSAMPLERPROC glad_glIsSampler;
4625#define glIsSampler glad_glIsSampler
4626GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
4627#define glIsShader glad_glIsShader
4628GLAD_API_CALL PFNGLISSYNCPROC glad_glIsSync;
4629#define glIsSync glad_glIsSync
4630GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
4631#define glIsTexture glad_glIsTexture
4632GLAD_API_CALL PFNGLISTRANSFORMFEEDBACKPROC glad_glIsTransformFeedback;
4633#define glIsTransformFeedback glad_glIsTransformFeedback
4634GLAD_API_CALL PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
4635#define glIsVertexArray glad_glIsVertexArray
4636GLAD_API_CALL PFNGLLIGHTMODELXOESPROC glad_glLightModelxOES;
4637#define glLightModelxOES glad_glLightModelxOES
4638GLAD_API_CALL PFNGLLIGHTMODELXVOESPROC glad_glLightModelxvOES;
4639#define glLightModelxvOES glad_glLightModelxvOES
4640GLAD_API_CALL PFNGLLIGHTXOESPROC glad_glLightxOES;
4641#define glLightxOES glad_glLightxOES
4642GLAD_API_CALL PFNGLLIGHTXVOESPROC glad_glLightxvOES;
4643#define glLightxvOES glad_glLightxvOES
4644GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
4645#define glLineWidth glad_glLineWidth
4646GLAD_API_CALL PFNGLLINEWIDTHXOESPROC glad_glLineWidthxOES;
4647#define glLineWidthxOES glad_glLineWidthxOES
4648GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
4649#define glLinkProgram glad_glLinkProgram
4650GLAD_API_CALL PFNGLLINKPROGRAMARBPROC glad_glLinkProgramARB;
4651#define glLinkProgramARB glad_glLinkProgramARB
4652GLAD_API_CALL PFNGLLOADMATRIXXOESPROC glad_glLoadMatrixxOES;
4653#define glLoadMatrixxOES glad_glLoadMatrixxOES
4654GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXDARBPROC glad_glLoadTransposeMatrixdARB;
4655#define glLoadTransposeMatrixdARB glad_glLoadTransposeMatrixdARB
4656GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXFARBPROC glad_glLoadTransposeMatrixfARB;
4657#define glLoadTransposeMatrixfARB glad_glLoadTransposeMatrixfARB
4658GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXXOESPROC glad_glLoadTransposeMatrixxOES;
4659#define glLoadTransposeMatrixxOES glad_glLoadTransposeMatrixxOES
4660GLAD_API_CALL PFNGLLOGICOPPROC glad_glLogicOp;
4661#define glLogicOp glad_glLogicOp
4662GLAD_API_CALL PFNGLMAP1XOESPROC glad_glMap1xOES;
4663#define glMap1xOES glad_glMap1xOES
4664GLAD_API_CALL PFNGLMAP2XOESPROC glad_glMap2xOES;
4665#define glMap2xOES glad_glMap2xOES
4666GLAD_API_CALL PFNGLMAPBUFFERPROC glad_glMapBuffer;
4667#define glMapBuffer glad_glMapBuffer
4668GLAD_API_CALL PFNGLMAPBUFFERARBPROC glad_glMapBufferARB;
4669#define glMapBufferARB glad_glMapBufferARB
4670GLAD_API_CALL PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
4671#define glMapBufferRange glad_glMapBufferRange
4672GLAD_API_CALL PFNGLMAPGRID1XOESPROC glad_glMapGrid1xOES;
4673#define glMapGrid1xOES glad_glMapGrid1xOES
4674GLAD_API_CALL PFNGLMAPGRID2XOESPROC glad_glMapGrid2xOES;
4675#define glMapGrid2xOES glad_glMapGrid2xOES
4676GLAD_API_CALL PFNGLMAPNAMEDBUFFERPROC glad_glMapNamedBuffer;
4677#define glMapNamedBuffer glad_glMapNamedBuffer
4678GLAD_API_CALL PFNGLMAPNAMEDBUFFERRANGEPROC glad_glMapNamedBufferRange;
4679#define glMapNamedBufferRange glad_glMapNamedBufferRange
4680GLAD_API_CALL PFNGLMATERIALXOESPROC glad_glMaterialxOES;
4681#define glMaterialxOES glad_glMaterialxOES
4682GLAD_API_CALL PFNGLMATERIALXVOESPROC glad_glMaterialxvOES;
4683#define glMaterialxvOES glad_glMaterialxvOES
4684GLAD_API_CALL PFNGLMEMORYBARRIERPROC glad_glMemoryBarrier;
4685#define glMemoryBarrier glad_glMemoryBarrier
4686GLAD_API_CALL PFNGLMEMORYBARRIERBYREGIONPROC glad_glMemoryBarrierByRegion;
4687#define glMemoryBarrierByRegion glad_glMemoryBarrierByRegion
4688GLAD_API_CALL PFNGLMINSAMPLESHADINGPROC glad_glMinSampleShading;
4689#define glMinSampleShading glad_glMinSampleShading
4690GLAD_API_CALL PFNGLMINSAMPLESHADINGARBPROC glad_glMinSampleShadingARB;
4691#define glMinSampleShadingARB glad_glMinSampleShadingARB
4692GLAD_API_CALL PFNGLMULTMATRIXXOESPROC glad_glMultMatrixxOES;
4693#define glMultMatrixxOES glad_glMultMatrixxOES
4694GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXDARBPROC glad_glMultTransposeMatrixdARB;
4695#define glMultTransposeMatrixdARB glad_glMultTransposeMatrixdARB
4696GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXFARBPROC glad_glMultTransposeMatrixfARB;
4697#define glMultTransposeMatrixfARB glad_glMultTransposeMatrixfARB
4698GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXXOESPROC glad_glMultTransposeMatrixxOES;
4699#define glMultTransposeMatrixxOES glad_glMultTransposeMatrixxOES
4700GLAD_API_CALL PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
4701#define glMultiDrawArrays glad_glMultiDrawArrays
4702GLAD_API_CALL PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_glMultiDrawArraysIndirect;
4703#define glMultiDrawArraysIndirect glad_glMultiDrawArraysIndirect
4704GLAD_API_CALL PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
4705#define glMultiDrawElements glad_glMultiDrawElements
4706GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
4707#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
4708GLAD_API_CALL PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_glMultiDrawElementsIndirect;
4709#define glMultiDrawElementsIndirect glad_glMultiDrawElementsIndirect
4710GLAD_API_CALL PFNGLMULTITEXCOORD1DARBPROC glad_glMultiTexCoord1dARB;
4711#define glMultiTexCoord1dARB glad_glMultiTexCoord1dARB
4712GLAD_API_CALL PFNGLMULTITEXCOORD1DVARBPROC glad_glMultiTexCoord1dvARB;
4713#define glMultiTexCoord1dvARB glad_glMultiTexCoord1dvARB
4714GLAD_API_CALL PFNGLMULTITEXCOORD1FARBPROC glad_glMultiTexCoord1fARB;
4715#define glMultiTexCoord1fARB glad_glMultiTexCoord1fARB
4716GLAD_API_CALL PFNGLMULTITEXCOORD1FVARBPROC glad_glMultiTexCoord1fvARB;
4717#define glMultiTexCoord1fvARB glad_glMultiTexCoord1fvARB
4718GLAD_API_CALL PFNGLMULTITEXCOORD1IARBPROC glad_glMultiTexCoord1iARB;
4719#define glMultiTexCoord1iARB glad_glMultiTexCoord1iARB
4720GLAD_API_CALL PFNGLMULTITEXCOORD1IVARBPROC glad_glMultiTexCoord1ivARB;
4721#define glMultiTexCoord1ivARB glad_glMultiTexCoord1ivARB
4722GLAD_API_CALL PFNGLMULTITEXCOORD1SARBPROC glad_glMultiTexCoord1sARB;
4723#define glMultiTexCoord1sARB glad_glMultiTexCoord1sARB
4724GLAD_API_CALL PFNGLMULTITEXCOORD1SVARBPROC glad_glMultiTexCoord1svARB;
4725#define glMultiTexCoord1svARB glad_glMultiTexCoord1svARB
4726GLAD_API_CALL PFNGLMULTITEXCOORD1XOESPROC glad_glMultiTexCoord1xOES;
4727#define glMultiTexCoord1xOES glad_glMultiTexCoord1xOES
4728GLAD_API_CALL PFNGLMULTITEXCOORD1XVOESPROC glad_glMultiTexCoord1xvOES;
4729#define glMultiTexCoord1xvOES glad_glMultiTexCoord1xvOES
4730GLAD_API_CALL PFNGLMULTITEXCOORD2DARBPROC glad_glMultiTexCoord2dARB;
4731#define glMultiTexCoord2dARB glad_glMultiTexCoord2dARB
4732GLAD_API_CALL PFNGLMULTITEXCOORD2DVARBPROC glad_glMultiTexCoord2dvARB;
4733#define glMultiTexCoord2dvARB glad_glMultiTexCoord2dvARB
4734GLAD_API_CALL PFNGLMULTITEXCOORD2FARBPROC glad_glMultiTexCoord2fARB;
4735#define glMultiTexCoord2fARB glad_glMultiTexCoord2fARB
4736GLAD_API_CALL PFNGLMULTITEXCOORD2FVARBPROC glad_glMultiTexCoord2fvARB;
4737#define glMultiTexCoord2fvARB glad_glMultiTexCoord2fvARB
4738GLAD_API_CALL PFNGLMULTITEXCOORD2IARBPROC glad_glMultiTexCoord2iARB;
4739#define glMultiTexCoord2iARB glad_glMultiTexCoord2iARB
4740GLAD_API_CALL PFNGLMULTITEXCOORD2IVARBPROC glad_glMultiTexCoord2ivARB;
4741#define glMultiTexCoord2ivARB glad_glMultiTexCoord2ivARB
4742GLAD_API_CALL PFNGLMULTITEXCOORD2SARBPROC glad_glMultiTexCoord2sARB;
4743#define glMultiTexCoord2sARB glad_glMultiTexCoord2sARB
4744GLAD_API_CALL PFNGLMULTITEXCOORD2SVARBPROC glad_glMultiTexCoord2svARB;
4745#define glMultiTexCoord2svARB glad_glMultiTexCoord2svARB
4746GLAD_API_CALL PFNGLMULTITEXCOORD2XOESPROC glad_glMultiTexCoord2xOES;
4747#define glMultiTexCoord2xOES glad_glMultiTexCoord2xOES
4748GLAD_API_CALL PFNGLMULTITEXCOORD2XVOESPROC glad_glMultiTexCoord2xvOES;
4749#define glMultiTexCoord2xvOES glad_glMultiTexCoord2xvOES
4750GLAD_API_CALL PFNGLMULTITEXCOORD3DARBPROC glad_glMultiTexCoord3dARB;
4751#define glMultiTexCoord3dARB glad_glMultiTexCoord3dARB
4752GLAD_API_CALL PFNGLMULTITEXCOORD3DVARBPROC glad_glMultiTexCoord3dvARB;
4753#define glMultiTexCoord3dvARB glad_glMultiTexCoord3dvARB
4754GLAD_API_CALL PFNGLMULTITEXCOORD3FARBPROC glad_glMultiTexCoord3fARB;
4755#define glMultiTexCoord3fARB glad_glMultiTexCoord3fARB
4756GLAD_API_CALL PFNGLMULTITEXCOORD3FVARBPROC glad_glMultiTexCoord3fvARB;
4757#define glMultiTexCoord3fvARB glad_glMultiTexCoord3fvARB
4758GLAD_API_CALL PFNGLMULTITEXCOORD3IARBPROC glad_glMultiTexCoord3iARB;
4759#define glMultiTexCoord3iARB glad_glMultiTexCoord3iARB
4760GLAD_API_CALL PFNGLMULTITEXCOORD3IVARBPROC glad_glMultiTexCoord3ivARB;
4761#define glMultiTexCoord3ivARB glad_glMultiTexCoord3ivARB
4762GLAD_API_CALL PFNGLMULTITEXCOORD3SARBPROC glad_glMultiTexCoord3sARB;
4763#define glMultiTexCoord3sARB glad_glMultiTexCoord3sARB
4764GLAD_API_CALL PFNGLMULTITEXCOORD3SVARBPROC glad_glMultiTexCoord3svARB;
4765#define glMultiTexCoord3svARB glad_glMultiTexCoord3svARB
4766GLAD_API_CALL PFNGLMULTITEXCOORD3XOESPROC glad_glMultiTexCoord3xOES;
4767#define glMultiTexCoord3xOES glad_glMultiTexCoord3xOES
4768GLAD_API_CALL PFNGLMULTITEXCOORD3XVOESPROC glad_glMultiTexCoord3xvOES;
4769#define glMultiTexCoord3xvOES glad_glMultiTexCoord3xvOES
4770GLAD_API_CALL PFNGLMULTITEXCOORD4DARBPROC glad_glMultiTexCoord4dARB;
4771#define glMultiTexCoord4dARB glad_glMultiTexCoord4dARB
4772GLAD_API_CALL PFNGLMULTITEXCOORD4DVARBPROC glad_glMultiTexCoord4dvARB;
4773#define glMultiTexCoord4dvARB glad_glMultiTexCoord4dvARB
4774GLAD_API_CALL PFNGLMULTITEXCOORD4FARBPROC glad_glMultiTexCoord4fARB;
4775#define glMultiTexCoord4fARB glad_glMultiTexCoord4fARB
4776GLAD_API_CALL PFNGLMULTITEXCOORD4FVARBPROC glad_glMultiTexCoord4fvARB;
4777#define glMultiTexCoord4fvARB glad_glMultiTexCoord4fvARB
4778GLAD_API_CALL PFNGLMULTITEXCOORD4IARBPROC glad_glMultiTexCoord4iARB;
4779#define glMultiTexCoord4iARB glad_glMultiTexCoord4iARB
4780GLAD_API_CALL PFNGLMULTITEXCOORD4IVARBPROC glad_glMultiTexCoord4ivARB;
4781#define glMultiTexCoord4ivARB glad_glMultiTexCoord4ivARB
4782GLAD_API_CALL PFNGLMULTITEXCOORD4SARBPROC glad_glMultiTexCoord4sARB;
4783#define glMultiTexCoord4sARB glad_glMultiTexCoord4sARB
4784GLAD_API_CALL PFNGLMULTITEXCOORD4SVARBPROC glad_glMultiTexCoord4svARB;
4785#define glMultiTexCoord4svARB glad_glMultiTexCoord4svARB
4786GLAD_API_CALL PFNGLMULTITEXCOORD4XOESPROC glad_glMultiTexCoord4xOES;
4787#define glMultiTexCoord4xOES glad_glMultiTexCoord4xOES
4788GLAD_API_CALL PFNGLMULTITEXCOORD4XVOESPROC glad_glMultiTexCoord4xvOES;
4789#define glMultiTexCoord4xvOES glad_glMultiTexCoord4xvOES
4790GLAD_API_CALL PFNGLNAMEDBUFFERDATAPROC glad_glNamedBufferData;
4791#define glNamedBufferData glad_glNamedBufferData
4792GLAD_API_CALL PFNGLNAMEDBUFFERSTORAGEPROC glad_glNamedBufferStorage;
4793#define glNamedBufferStorage glad_glNamedBufferStorage
4794GLAD_API_CALL PFNGLNAMEDBUFFERSUBDATAPROC glad_glNamedBufferSubData;
4795#define glNamedBufferSubData glad_glNamedBufferSubData
4796GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC glad_glNamedFramebufferDrawBuffer;
4797#define glNamedFramebufferDrawBuffer glad_glNamedFramebufferDrawBuffer
4798GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glad_glNamedFramebufferDrawBuffers;
4799#define glNamedFramebufferDrawBuffers glad_glNamedFramebufferDrawBuffers
4800GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glad_glNamedFramebufferParameteri;
4801#define glNamedFramebufferParameteri glad_glNamedFramebufferParameteri
4802GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glad_glNamedFramebufferReadBuffer;
4803#define glNamedFramebufferReadBuffer glad_glNamedFramebufferReadBuffer
4804GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC glad_glNamedFramebufferRenderbuffer;
4805#define glNamedFramebufferRenderbuffer glad_glNamedFramebufferRenderbuffer
4806GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glNamedFramebufferSampleLocationsfvARB;
4807#define glNamedFramebufferSampleLocationsfvARB glad_glNamedFramebufferSampleLocationsfvARB
4808GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_glNamedFramebufferTexture;
4809#define glNamedFramebufferTexture glad_glNamedFramebufferTexture
4810GLAD_API_CALL PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_glNamedFramebufferTextureLayer;
4811#define glNamedFramebufferTextureLayer glad_glNamedFramebufferTextureLayer
4812GLAD_API_CALL PFNGLNAMEDRENDERBUFFERSTORAGEPROC glad_glNamedRenderbufferStorage;
4813#define glNamedRenderbufferStorage glad_glNamedRenderbufferStorage
4814GLAD_API_CALL PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glNamedRenderbufferStorageMultisample;
4815#define glNamedRenderbufferStorageMultisample glad_glNamedRenderbufferStorageMultisample
4816GLAD_API_CALL PFNGLNAMEDSTRINGARBPROC glad_glNamedStringARB;
4817#define glNamedStringARB glad_glNamedStringARB
4818GLAD_API_CALL PFNGLNORMAL3XOESPROC glad_glNormal3xOES;
4819#define glNormal3xOES glad_glNormal3xOES
4820GLAD_API_CALL PFNGLNORMAL3XVOESPROC glad_glNormal3xvOES;
4821#define glNormal3xvOES glad_glNormal3xvOES
4822GLAD_API_CALL PFNGLOBJECTLABELPROC glad_glObjectLabel;
4823#define glObjectLabel glad_glObjectLabel
4824GLAD_API_CALL PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel;
4825#define glObjectPtrLabel glad_glObjectPtrLabel
4826GLAD_API_CALL PFNGLORTHOXOESPROC glad_glOrthoxOES;
4827#define glOrthoxOES glad_glOrthoxOES
4828GLAD_API_CALL PFNGLPASSTHROUGHXOESPROC glad_glPassThroughxOES;
4829#define glPassThroughxOES glad_glPassThroughxOES
4830GLAD_API_CALL PFNGLPATCHPARAMETERFVPROC glad_glPatchParameterfv;
4831#define glPatchParameterfv glad_glPatchParameterfv
4832GLAD_API_CALL PFNGLPATCHPARAMETERIPROC glad_glPatchParameteri;
4833#define glPatchParameteri glad_glPatchParameteri
4834GLAD_API_CALL PFNGLPAUSETRANSFORMFEEDBACKPROC glad_glPauseTransformFeedback;
4835#define glPauseTransformFeedback glad_glPauseTransformFeedback
4836GLAD_API_CALL PFNGLPIXELMAPXPROC glad_glPixelMapx;
4837#define glPixelMapx glad_glPixelMapx
4838GLAD_API_CALL PFNGLPIXELSTOREFPROC glad_glPixelStoref;
4839#define glPixelStoref glad_glPixelStoref
4840GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
4841#define glPixelStorei glad_glPixelStorei
4842GLAD_API_CALL PFNGLPIXELSTOREXPROC glad_glPixelStorex;
4843#define glPixelStorex glad_glPixelStorex
4844GLAD_API_CALL PFNGLPIXELTRANSFERXOESPROC glad_glPixelTransferxOES;
4845#define glPixelTransferxOES glad_glPixelTransferxOES
4846GLAD_API_CALL PFNGLPIXELZOOMXOESPROC glad_glPixelZoomxOES;
4847#define glPixelZoomxOES glad_glPixelZoomxOES
4848GLAD_API_CALL PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
4849#define glPointParameterf glad_glPointParameterf
4850GLAD_API_CALL PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
4851#define glPointParameterfv glad_glPointParameterfv
4852GLAD_API_CALL PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
4853#define glPointParameteri glad_glPointParameteri
4854GLAD_API_CALL PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
4855#define glPointParameteriv glad_glPointParameteriv
4856GLAD_API_CALL PFNGLPOINTPARAMETERXVOESPROC glad_glPointParameterxvOES;
4857#define glPointParameterxvOES glad_glPointParameterxvOES
4858GLAD_API_CALL PFNGLPOINTSIZEPROC glad_glPointSize;
4859#define glPointSize glad_glPointSize
4860GLAD_API_CALL PFNGLPOINTSIZEXOESPROC glad_glPointSizexOES;
4861#define glPointSizexOES glad_glPointSizexOES
4862GLAD_API_CALL PFNGLPOLYGONMODEPROC glad_glPolygonMode;
4863#define glPolygonMode glad_glPolygonMode
4864GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
4865#define glPolygonOffset glad_glPolygonOffset
4866GLAD_API_CALL PFNGLPOLYGONOFFSETXOESPROC glad_glPolygonOffsetxOES;
4867#define glPolygonOffsetxOES glad_glPolygonOffsetxOES
4868GLAD_API_CALL PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup;
4869#define glPopDebugGroup glad_glPopDebugGroup
4870GLAD_API_CALL PFNGLPRIMITIVEBOUNDINGBOXARBPROC glad_glPrimitiveBoundingBoxARB;
4871#define glPrimitiveBoundingBoxARB glad_glPrimitiveBoundingBoxARB
4872GLAD_API_CALL PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
4873#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
4874GLAD_API_CALL PFNGLPRIORITIZETEXTURESXOESPROC glad_glPrioritizeTexturesxOES;
4875#define glPrioritizeTexturesxOES glad_glPrioritizeTexturesxOES
4876GLAD_API_CALL PFNGLPROGRAMBINARYPROC glad_glProgramBinary;
4877#define glProgramBinary glad_glProgramBinary
4878GLAD_API_CALL PFNGLPROGRAMENVPARAMETER4DARBPROC glad_glProgramEnvParameter4dARB;
4879#define glProgramEnvParameter4dARB glad_glProgramEnvParameter4dARB
4880GLAD_API_CALL PFNGLPROGRAMENVPARAMETER4DVARBPROC glad_glProgramEnvParameter4dvARB;
4881#define glProgramEnvParameter4dvARB glad_glProgramEnvParameter4dvARB
4882GLAD_API_CALL PFNGLPROGRAMENVPARAMETER4FARBPROC glad_glProgramEnvParameter4fARB;
4883#define glProgramEnvParameter4fARB glad_glProgramEnvParameter4fARB
4884GLAD_API_CALL PFNGLPROGRAMENVPARAMETER4FVARBPROC glad_glProgramEnvParameter4fvARB;
4885#define glProgramEnvParameter4fvARB glad_glProgramEnvParameter4fvARB
4886GLAD_API_CALL PFNGLPROGRAMLOCALPARAMETER4DARBPROC glad_glProgramLocalParameter4dARB;
4887#define glProgramLocalParameter4dARB glad_glProgramLocalParameter4dARB
4888GLAD_API_CALL PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glad_glProgramLocalParameter4dvARB;
4889#define glProgramLocalParameter4dvARB glad_glProgramLocalParameter4dvARB
4890GLAD_API_CALL PFNGLPROGRAMLOCALPARAMETER4FARBPROC glad_glProgramLocalParameter4fARB;
4891#define glProgramLocalParameter4fARB glad_glProgramLocalParameter4fARB
4892GLAD_API_CALL PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glad_glProgramLocalParameter4fvARB;
4893#define glProgramLocalParameter4fvARB glad_glProgramLocalParameter4fvARB
4894GLAD_API_CALL PFNGLPROGRAMPARAMETERIPROC glad_glProgramParameteri;
4895#define glProgramParameteri glad_glProgramParameteri
4896GLAD_API_CALL PFNGLPROGRAMPARAMETERIARBPROC glad_glProgramParameteriARB;
4897#define glProgramParameteriARB glad_glProgramParameteriARB
4898GLAD_API_CALL PFNGLPROGRAMSTRINGARBPROC glad_glProgramStringARB;
4899#define glProgramStringARB glad_glProgramStringARB
4900GLAD_API_CALL PFNGLPROGRAMUNIFORM1DPROC glad_glProgramUniform1d;
4901#define glProgramUniform1d glad_glProgramUniform1d
4902GLAD_API_CALL PFNGLPROGRAMUNIFORM1DVPROC glad_glProgramUniform1dv;
4903#define glProgramUniform1dv glad_glProgramUniform1dv
4904GLAD_API_CALL PFNGLPROGRAMUNIFORM1FPROC glad_glProgramUniform1f;
4905#define glProgramUniform1f glad_glProgramUniform1f
4906GLAD_API_CALL PFNGLPROGRAMUNIFORM1FVPROC glad_glProgramUniform1fv;
4907#define glProgramUniform1fv glad_glProgramUniform1fv
4908GLAD_API_CALL PFNGLPROGRAMUNIFORM1IPROC glad_glProgramUniform1i;
4909#define glProgramUniform1i glad_glProgramUniform1i
4910GLAD_API_CALL PFNGLPROGRAMUNIFORM1I64ARBPROC glad_glProgramUniform1i64ARB;
4911#define glProgramUniform1i64ARB glad_glProgramUniform1i64ARB
4912GLAD_API_CALL PFNGLPROGRAMUNIFORM1I64VARBPROC glad_glProgramUniform1i64vARB;
4913#define glProgramUniform1i64vARB glad_glProgramUniform1i64vARB
4914GLAD_API_CALL PFNGLPROGRAMUNIFORM1IVPROC glad_glProgramUniform1iv;
4915#define glProgramUniform1iv glad_glProgramUniform1iv
4916GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIPROC glad_glProgramUniform1ui;
4917#define glProgramUniform1ui glad_glProgramUniform1ui
4918GLAD_API_CALL PFNGLPROGRAMUNIFORM1UI64ARBPROC glad_glProgramUniform1ui64ARB;
4919#define glProgramUniform1ui64ARB glad_glProgramUniform1ui64ARB
4920GLAD_API_CALL PFNGLPROGRAMUNIFORM1UI64VARBPROC glad_glProgramUniform1ui64vARB;
4921#define glProgramUniform1ui64vARB glad_glProgramUniform1ui64vARB
4922GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIVPROC glad_glProgramUniform1uiv;
4923#define glProgramUniform1uiv glad_glProgramUniform1uiv
4924GLAD_API_CALL PFNGLPROGRAMUNIFORM2DPROC glad_glProgramUniform2d;
4925#define glProgramUniform2d glad_glProgramUniform2d
4926GLAD_API_CALL PFNGLPROGRAMUNIFORM2DVPROC glad_glProgramUniform2dv;
4927#define glProgramUniform2dv glad_glProgramUniform2dv
4928GLAD_API_CALL PFNGLPROGRAMUNIFORM2FPROC glad_glProgramUniform2f;
4929#define glProgramUniform2f glad_glProgramUniform2f
4930GLAD_API_CALL PFNGLPROGRAMUNIFORM2FVPROC glad_glProgramUniform2fv;
4931#define glProgramUniform2fv glad_glProgramUniform2fv
4932GLAD_API_CALL PFNGLPROGRAMUNIFORM2IPROC glad_glProgramUniform2i;
4933#define glProgramUniform2i glad_glProgramUniform2i
4934GLAD_API_CALL PFNGLPROGRAMUNIFORM2I64ARBPROC glad_glProgramUniform2i64ARB;
4935#define glProgramUniform2i64ARB glad_glProgramUniform2i64ARB
4936GLAD_API_CALL PFNGLPROGRAMUNIFORM2I64VARBPROC glad_glProgramUniform2i64vARB;
4937#define glProgramUniform2i64vARB glad_glProgramUniform2i64vARB
4938GLAD_API_CALL PFNGLPROGRAMUNIFORM2IVPROC glad_glProgramUniform2iv;
4939#define glProgramUniform2iv glad_glProgramUniform2iv
4940GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIPROC glad_glProgramUniform2ui;
4941#define glProgramUniform2ui glad_glProgramUniform2ui
4942GLAD_API_CALL PFNGLPROGRAMUNIFORM2UI64ARBPROC glad_glProgramUniform2ui64ARB;
4943#define glProgramUniform2ui64ARB glad_glProgramUniform2ui64ARB
4944GLAD_API_CALL PFNGLPROGRAMUNIFORM2UI64VARBPROC glad_glProgramUniform2ui64vARB;
4945#define glProgramUniform2ui64vARB glad_glProgramUniform2ui64vARB
4946GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIVPROC glad_glProgramUniform2uiv;
4947#define glProgramUniform2uiv glad_glProgramUniform2uiv
4948GLAD_API_CALL PFNGLPROGRAMUNIFORM3DPROC glad_glProgramUniform3d;
4949#define glProgramUniform3d glad_glProgramUniform3d
4950GLAD_API_CALL PFNGLPROGRAMUNIFORM3DVPROC glad_glProgramUniform3dv;
4951#define glProgramUniform3dv glad_glProgramUniform3dv
4952GLAD_API_CALL PFNGLPROGRAMUNIFORM3FPROC glad_glProgramUniform3f;
4953#define glProgramUniform3f glad_glProgramUniform3f
4954GLAD_API_CALL PFNGLPROGRAMUNIFORM3FVPROC glad_glProgramUniform3fv;
4955#define glProgramUniform3fv glad_glProgramUniform3fv
4956GLAD_API_CALL PFNGLPROGRAMUNIFORM3IPROC glad_glProgramUniform3i;
4957#define glProgramUniform3i glad_glProgramUniform3i
4958GLAD_API_CALL PFNGLPROGRAMUNIFORM3I64ARBPROC glad_glProgramUniform3i64ARB;
4959#define glProgramUniform3i64ARB glad_glProgramUniform3i64ARB
4960GLAD_API_CALL PFNGLPROGRAMUNIFORM3I64VARBPROC glad_glProgramUniform3i64vARB;
4961#define glProgramUniform3i64vARB glad_glProgramUniform3i64vARB
4962GLAD_API_CALL PFNGLPROGRAMUNIFORM3IVPROC glad_glProgramUniform3iv;
4963#define glProgramUniform3iv glad_glProgramUniform3iv
4964GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIPROC glad_glProgramUniform3ui;
4965#define glProgramUniform3ui glad_glProgramUniform3ui
4966GLAD_API_CALL PFNGLPROGRAMUNIFORM3UI64ARBPROC glad_glProgramUniform3ui64ARB;
4967#define glProgramUniform3ui64ARB glad_glProgramUniform3ui64ARB
4968GLAD_API_CALL PFNGLPROGRAMUNIFORM3UI64VARBPROC glad_glProgramUniform3ui64vARB;
4969#define glProgramUniform3ui64vARB glad_glProgramUniform3ui64vARB
4970GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIVPROC glad_glProgramUniform3uiv;
4971#define glProgramUniform3uiv glad_glProgramUniform3uiv
4972GLAD_API_CALL PFNGLPROGRAMUNIFORM4DPROC glad_glProgramUniform4d;
4973#define glProgramUniform4d glad_glProgramUniform4d
4974GLAD_API_CALL PFNGLPROGRAMUNIFORM4DVPROC glad_glProgramUniform4dv;
4975#define glProgramUniform4dv glad_glProgramUniform4dv
4976GLAD_API_CALL PFNGLPROGRAMUNIFORM4FPROC glad_glProgramUniform4f;
4977#define glProgramUniform4f glad_glProgramUniform4f
4978GLAD_API_CALL PFNGLPROGRAMUNIFORM4FVPROC glad_glProgramUniform4fv;
4979#define glProgramUniform4fv glad_glProgramUniform4fv
4980GLAD_API_CALL PFNGLPROGRAMUNIFORM4IPROC glad_glProgramUniform4i;
4981#define glProgramUniform4i glad_glProgramUniform4i
4982GLAD_API_CALL PFNGLPROGRAMUNIFORM4I64ARBPROC glad_glProgramUniform4i64ARB;
4983#define glProgramUniform4i64ARB glad_glProgramUniform4i64ARB
4984GLAD_API_CALL PFNGLPROGRAMUNIFORM4I64VARBPROC glad_glProgramUniform4i64vARB;
4985#define glProgramUniform4i64vARB glad_glProgramUniform4i64vARB
4986GLAD_API_CALL PFNGLPROGRAMUNIFORM4IVPROC glad_glProgramUniform4iv;
4987#define glProgramUniform4iv glad_glProgramUniform4iv
4988GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIPROC glad_glProgramUniform4ui;
4989#define glProgramUniform4ui glad_glProgramUniform4ui
4990GLAD_API_CALL PFNGLPROGRAMUNIFORM4UI64ARBPROC glad_glProgramUniform4ui64ARB;
4991#define glProgramUniform4ui64ARB glad_glProgramUniform4ui64ARB
4992GLAD_API_CALL PFNGLPROGRAMUNIFORM4UI64VARBPROC glad_glProgramUniform4ui64vARB;
4993#define glProgramUniform4ui64vARB glad_glProgramUniform4ui64vARB
4994GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIVPROC glad_glProgramUniform4uiv;
4995#define glProgramUniform4uiv glad_glProgramUniform4uiv
4996GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_glProgramUniformMatrix2dv;
4997#define glProgramUniformMatrix2dv glad_glProgramUniformMatrix2dv
4998GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_glProgramUniformMatrix2fv;
4999#define glProgramUniformMatrix2fv glad_glProgramUniformMatrix2fv
5000GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_glProgramUniformMatrix2x3dv;
5001#define glProgramUniformMatrix2x3dv glad_glProgramUniformMatrix2x3dv
5002GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_glProgramUniformMatrix2x3fv;
5003#define glProgramUniformMatrix2x3fv glad_glProgramUniformMatrix2x3fv
5004GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_glProgramUniformMatrix2x4dv;
5005#define glProgramUniformMatrix2x4dv glad_glProgramUniformMatrix2x4dv
5006GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_glProgramUniformMatrix2x4fv;
5007#define glProgramUniformMatrix2x4fv glad_glProgramUniformMatrix2x4fv
5008GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_glProgramUniformMatrix3dv;
5009#define glProgramUniformMatrix3dv glad_glProgramUniformMatrix3dv
5010GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_glProgramUniformMatrix3fv;
5011#define glProgramUniformMatrix3fv glad_glProgramUniformMatrix3fv
5012GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_glProgramUniformMatrix3x2dv;
5013#define glProgramUniformMatrix3x2dv glad_glProgramUniformMatrix3x2dv
5014GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_glProgramUniformMatrix3x2fv;
5015#define glProgramUniformMatrix3x2fv glad_glProgramUniformMatrix3x2fv
5016GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_glProgramUniformMatrix3x4dv;
5017#define glProgramUniformMatrix3x4dv glad_glProgramUniformMatrix3x4dv
5018GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_glProgramUniformMatrix3x4fv;
5019#define glProgramUniformMatrix3x4fv glad_glProgramUniformMatrix3x4fv
5020GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_glProgramUniformMatrix4dv;
5021#define glProgramUniformMatrix4dv glad_glProgramUniformMatrix4dv
5022GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_glProgramUniformMatrix4fv;
5023#define glProgramUniformMatrix4fv glad_glProgramUniformMatrix4fv
5024GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_glProgramUniformMatrix4x2dv;
5025#define glProgramUniformMatrix4x2dv glad_glProgramUniformMatrix4x2dv
5026GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_glProgramUniformMatrix4x2fv;
5027#define glProgramUniformMatrix4x2fv glad_glProgramUniformMatrix4x2fv
5028GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_glProgramUniformMatrix4x3dv;
5029#define glProgramUniformMatrix4x3dv glad_glProgramUniformMatrix4x3dv
5030GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_glProgramUniformMatrix4x3fv;
5031#define glProgramUniformMatrix4x3fv glad_glProgramUniformMatrix4x3fv
5032GLAD_API_CALL PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
5033#define glProvokingVertex glad_glProvokingVertex
5034GLAD_API_CALL PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup;
5035#define glPushDebugGroup glad_glPushDebugGroup
5036GLAD_API_CALL PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
5037#define glQueryCounter glad_glQueryCounter
5038GLAD_API_CALL PFNGLRASTERPOS2XOESPROC glad_glRasterPos2xOES;
5039#define glRasterPos2xOES glad_glRasterPos2xOES
5040GLAD_API_CALL PFNGLRASTERPOS2XVOESPROC glad_glRasterPos2xvOES;
5041#define glRasterPos2xvOES glad_glRasterPos2xvOES
5042GLAD_API_CALL PFNGLRASTERPOS3XOESPROC glad_glRasterPos3xOES;
5043#define glRasterPos3xOES glad_glRasterPos3xOES
5044GLAD_API_CALL PFNGLRASTERPOS3XVOESPROC glad_glRasterPos3xvOES;
5045#define glRasterPos3xvOES glad_glRasterPos3xvOES
5046GLAD_API_CALL PFNGLRASTERPOS4XOESPROC glad_glRasterPos4xOES;
5047#define glRasterPos4xOES glad_glRasterPos4xOES
5048GLAD_API_CALL PFNGLRASTERPOS4XVOESPROC glad_glRasterPos4xvOES;
5049#define glRasterPos4xvOES glad_glRasterPos4xvOES
5050GLAD_API_CALL PFNGLREADBUFFERPROC glad_glReadBuffer;
5051#define glReadBuffer glad_glReadBuffer
5052GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
5053#define glReadPixels glad_glReadPixels
5054GLAD_API_CALL PFNGLRECTXOESPROC glad_glRectxOES;
5055#define glRectxOES glad_glRectxOES
5056GLAD_API_CALL PFNGLRECTXVOESPROC glad_glRectxvOES;
5057#define glRectxvOES glad_glRectxvOES
5058GLAD_API_CALL PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
5059#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
5060GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
5061#define glRenderbufferStorage glad_glRenderbufferStorage
5062GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT;
5063#define glRenderbufferStorageEXT glad_glRenderbufferStorageEXT
5064GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
5065#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
5066GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
5067#define glRenderbufferStorageMultisampleEXT glad_glRenderbufferStorageMultisampleEXT
5068GLAD_API_CALL PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback;
5069#define glResumeTransformFeedback glad_glResumeTransformFeedback
5070GLAD_API_CALL PFNGLROTATEXOESPROC glad_glRotatexOES;
5071#define glRotatexOES glad_glRotatexOES
5072GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
5073#define glSampleCoverage glad_glSampleCoverage
5074GLAD_API_CALL PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
5075#define glSampleCoverageARB glad_glSampleCoverageARB
5076GLAD_API_CALL PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
5077#define glSampleMaski glad_glSampleMaski
5078GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
5079#define glSamplerParameterIiv glad_glSamplerParameterIiv
5080GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
5081#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
5082GLAD_API_CALL PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
5083#define glSamplerParameterf glad_glSamplerParameterf
5084GLAD_API_CALL PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
5085#define glSamplerParameterfv glad_glSamplerParameterfv
5086GLAD_API_CALL PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
5087#define glSamplerParameteri glad_glSamplerParameteri
5088GLAD_API_CALL PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
5089#define glSamplerParameteriv glad_glSamplerParameteriv
5090GLAD_API_CALL PFNGLSCALEXOESPROC glad_glScalexOES;
5091#define glScalexOES glad_glScalexOES
5092GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
5093#define glScissor glad_glScissor
5094GLAD_API_CALL PFNGLSCISSORARRAYVPROC glad_glScissorArrayv;
5095#define glScissorArrayv glad_glScissorArrayv
5096GLAD_API_CALL PFNGLSCISSORINDEXEDPROC glad_glScissorIndexed;
5097#define glScissorIndexed glad_glScissorIndexed
5098GLAD_API_CALL PFNGLSCISSORINDEXEDVPROC glad_glScissorIndexedv;
5099#define glScissorIndexedv glad_glScissorIndexedv
5100GLAD_API_CALL PFNGLSHADERBINARYPROC glad_glShaderBinary;
5101#define glShaderBinary glad_glShaderBinary
5102GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
5103#define glShaderSource glad_glShaderSource
5104GLAD_API_CALL PFNGLSHADERSOURCEARBPROC glad_glShaderSourceARB;
5105#define glShaderSourceARB glad_glShaderSourceARB
5106GLAD_API_CALL PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_glShaderStorageBlockBinding;
5107#define glShaderStorageBlockBinding glad_glShaderStorageBlockBinding
5108GLAD_API_CALL PFNGLSPECIALIZESHADERARBPROC glad_glSpecializeShaderARB;
5109#define glSpecializeShaderARB glad_glSpecializeShaderARB
5110GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
5111#define glStencilFunc glad_glStencilFunc
5112GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
5113#define glStencilFuncSeparate glad_glStencilFuncSeparate
5114GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
5115#define glStencilMask glad_glStencilMask
5116GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
5117#define glStencilMaskSeparate glad_glStencilMaskSeparate
5118GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
5119#define glStencilOp glad_glStencilOp
5120GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
5121#define glStencilOpSeparate glad_glStencilOpSeparate
5122GLAD_API_CALL PFNGLTEXBUFFERPROC glad_glTexBuffer;
5123#define glTexBuffer glad_glTexBuffer
5124GLAD_API_CALL PFNGLTEXBUFFERRANGEPROC glad_glTexBufferRange;
5125#define glTexBufferRange glad_glTexBufferRange
5126GLAD_API_CALL PFNGLTEXCOORD1XOESPROC glad_glTexCoord1xOES;
5127#define glTexCoord1xOES glad_glTexCoord1xOES
5128GLAD_API_CALL PFNGLTEXCOORD1XVOESPROC glad_glTexCoord1xvOES;
5129#define glTexCoord1xvOES glad_glTexCoord1xvOES
5130GLAD_API_CALL PFNGLTEXCOORD2XOESPROC glad_glTexCoord2xOES;
5131#define glTexCoord2xOES glad_glTexCoord2xOES
5132GLAD_API_CALL PFNGLTEXCOORD2XVOESPROC glad_glTexCoord2xvOES;
5133#define glTexCoord2xvOES glad_glTexCoord2xvOES
5134GLAD_API_CALL PFNGLTEXCOORD3XOESPROC glad_glTexCoord3xOES;
5135#define glTexCoord3xOES glad_glTexCoord3xOES
5136GLAD_API_CALL PFNGLTEXCOORD3XVOESPROC glad_glTexCoord3xvOES;
5137#define glTexCoord3xvOES glad_glTexCoord3xvOES
5138GLAD_API_CALL PFNGLTEXCOORD4XOESPROC glad_glTexCoord4xOES;
5139#define glTexCoord4xOES glad_glTexCoord4xOES
5140GLAD_API_CALL PFNGLTEXCOORD4XVOESPROC glad_glTexCoord4xvOES;
5141#define glTexCoord4xvOES glad_glTexCoord4xvOES
5142GLAD_API_CALL PFNGLTEXENVXOESPROC glad_glTexEnvxOES;
5143#define glTexEnvxOES glad_glTexEnvxOES
5144GLAD_API_CALL PFNGLTEXENVXVOESPROC glad_glTexEnvxvOES;
5145#define glTexEnvxvOES glad_glTexEnvxvOES
5146GLAD_API_CALL PFNGLTEXGENXOESPROC glad_glTexGenxOES;
5147#define glTexGenxOES glad_glTexGenxOES
5148GLAD_API_CALL PFNGLTEXGENXVOESPROC glad_glTexGenxvOES;
5149#define glTexGenxvOES glad_glTexGenxvOES
5150GLAD_API_CALL PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
5151#define glTexImage1D glad_glTexImage1D
5152GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
5153#define glTexImage2D glad_glTexImage2D
5154GLAD_API_CALL PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
5155#define glTexImage2DMultisample glad_glTexImage2DMultisample
5156GLAD_API_CALL PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
5157#define glTexImage3D glad_glTexImage3D
5158GLAD_API_CALL PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
5159#define glTexImage3DMultisample glad_glTexImage3DMultisample
5160GLAD_API_CALL PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
5161#define glTexParameterIiv glad_glTexParameterIiv
5162GLAD_API_CALL PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
5163#define glTexParameterIuiv glad_glTexParameterIuiv
5164GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
5165#define glTexParameterf glad_glTexParameterf
5166GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
5167#define glTexParameterfv glad_glTexParameterfv
5168GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
5169#define glTexParameteri glad_glTexParameteri
5170GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
5171#define glTexParameteriv glad_glTexParameteriv
5172GLAD_API_CALL PFNGLTEXPARAMETERXOESPROC glad_glTexParameterxOES;
5173#define glTexParameterxOES glad_glTexParameterxOES
5174GLAD_API_CALL PFNGLTEXPARAMETERXVOESPROC glad_glTexParameterxvOES;
5175#define glTexParameterxvOES glad_glTexParameterxvOES
5176GLAD_API_CALL PFNGLTEXSTORAGE1DPROC glad_glTexStorage1D;
5177#define glTexStorage1D glad_glTexStorage1D
5178GLAD_API_CALL PFNGLTEXSTORAGE2DPROC glad_glTexStorage2D;
5179#define glTexStorage2D glad_glTexStorage2D
5180GLAD_API_CALL PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_glTexStorage2DMultisample;
5181#define glTexStorage2DMultisample glad_glTexStorage2DMultisample
5182GLAD_API_CALL PFNGLTEXSTORAGE3DPROC glad_glTexStorage3D;
5183#define glTexStorage3D glad_glTexStorage3D
5184GLAD_API_CALL PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample;
5185#define glTexStorage3DMultisample glad_glTexStorage3DMultisample
5186GLAD_API_CALL PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
5187#define glTexSubImage1D glad_glTexSubImage1D
5188GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
5189#define glTexSubImage2D glad_glTexSubImage2D
5190GLAD_API_CALL PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
5191#define glTexSubImage3D glad_glTexSubImage3D
5192GLAD_API_CALL PFNGLTEXTUREBUFFERPROC glad_glTextureBuffer;
5193#define glTextureBuffer glad_glTextureBuffer
5194GLAD_API_CALL PFNGLTEXTUREBUFFERRANGEPROC glad_glTextureBufferRange;
5195#define glTextureBufferRange glad_glTextureBufferRange
5196GLAD_API_CALL PFNGLTEXTUREPARAMETERIIVPROC glad_glTextureParameterIiv;
5197#define glTextureParameterIiv glad_glTextureParameterIiv
5198GLAD_API_CALL PFNGLTEXTUREPARAMETERIUIVPROC glad_glTextureParameterIuiv;
5199#define glTextureParameterIuiv glad_glTextureParameterIuiv
5200GLAD_API_CALL PFNGLTEXTUREPARAMETERFPROC glad_glTextureParameterf;
5201#define glTextureParameterf glad_glTextureParameterf
5202GLAD_API_CALL PFNGLTEXTUREPARAMETERFVPROC glad_glTextureParameterfv;
5203#define glTextureParameterfv glad_glTextureParameterfv
5204GLAD_API_CALL PFNGLTEXTUREPARAMETERIPROC glad_glTextureParameteri;
5205#define glTextureParameteri glad_glTextureParameteri
5206GLAD_API_CALL PFNGLTEXTUREPARAMETERIVPROC glad_glTextureParameteriv;
5207#define glTextureParameteriv glad_glTextureParameteriv
5208GLAD_API_CALL PFNGLTEXTURESTORAGE1DPROC glad_glTextureStorage1D;
5209#define glTextureStorage1D glad_glTextureStorage1D
5210GLAD_API_CALL PFNGLTEXTURESTORAGE2DPROC glad_glTextureStorage2D;
5211#define glTextureStorage2D glad_glTextureStorage2D
5212GLAD_API_CALL PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC glad_glTextureStorage2DMultisample;
5213#define glTextureStorage2DMultisample glad_glTextureStorage2DMultisample
5214GLAD_API_CALL PFNGLTEXTURESTORAGE3DPROC glad_glTextureStorage3D;
5215#define glTextureStorage3D glad_glTextureStorage3D
5216GLAD_API_CALL PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC glad_glTextureStorage3DMultisample;
5217#define glTextureStorage3DMultisample glad_glTextureStorage3DMultisample
5218GLAD_API_CALL PFNGLTEXTURESUBIMAGE1DPROC glad_glTextureSubImage1D;
5219#define glTextureSubImage1D glad_glTextureSubImage1D
5220GLAD_API_CALL PFNGLTEXTURESUBIMAGE2DPROC glad_glTextureSubImage2D;
5221#define glTextureSubImage2D glad_glTextureSubImage2D
5222GLAD_API_CALL PFNGLTEXTURESUBIMAGE3DPROC glad_glTextureSubImage3D;
5223#define glTextureSubImage3D glad_glTextureSubImage3D
5224GLAD_API_CALL PFNGLTEXTUREVIEWPROC glad_glTextureView;
5225#define glTextureView glad_glTextureView
5226GLAD_API_CALL PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC glad_glTransformFeedbackBufferBase;
5227#define glTransformFeedbackBufferBase glad_glTransformFeedbackBufferBase
5228GLAD_API_CALL PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC glad_glTransformFeedbackBufferRange;
5229#define glTransformFeedbackBufferRange glad_glTransformFeedbackBufferRange
5230GLAD_API_CALL PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
5231#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
5232GLAD_API_CALL PFNGLTRANSLATEXOESPROC glad_glTranslatexOES;
5233#define glTranslatexOES glad_glTranslatexOES
5234GLAD_API_CALL PFNGLUNIFORM1DPROC glad_glUniform1d;
5235#define glUniform1d glad_glUniform1d
5236GLAD_API_CALL PFNGLUNIFORM1DVPROC glad_glUniform1dv;
5237#define glUniform1dv glad_glUniform1dv
5238GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
5239#define glUniform1f glad_glUniform1f
5240GLAD_API_CALL PFNGLUNIFORM1FARBPROC glad_glUniform1fARB;
5241#define glUniform1fARB glad_glUniform1fARB
5242GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
5243#define glUniform1fv glad_glUniform1fv
5244GLAD_API_CALL PFNGLUNIFORM1FVARBPROC glad_glUniform1fvARB;
5245#define glUniform1fvARB glad_glUniform1fvARB
5246GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
5247#define glUniform1i glad_glUniform1i
5248GLAD_API_CALL PFNGLUNIFORM1I64ARBPROC glad_glUniform1i64ARB;
5249#define glUniform1i64ARB glad_glUniform1i64ARB
5250GLAD_API_CALL PFNGLUNIFORM1I64VARBPROC glad_glUniform1i64vARB;
5251#define glUniform1i64vARB glad_glUniform1i64vARB
5252GLAD_API_CALL PFNGLUNIFORM1IARBPROC glad_glUniform1iARB;
5253#define glUniform1iARB glad_glUniform1iARB
5254GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
5255#define glUniform1iv glad_glUniform1iv
5256GLAD_API_CALL PFNGLUNIFORM1IVARBPROC glad_glUniform1ivARB;
5257#define glUniform1ivARB glad_glUniform1ivARB
5258GLAD_API_CALL PFNGLUNIFORM1UIPROC glad_glUniform1ui;
5259#define glUniform1ui glad_glUniform1ui
5260GLAD_API_CALL PFNGLUNIFORM1UI64ARBPROC glad_glUniform1ui64ARB;
5261#define glUniform1ui64ARB glad_glUniform1ui64ARB
5262GLAD_API_CALL PFNGLUNIFORM1UI64VARBPROC glad_glUniform1ui64vARB;
5263#define glUniform1ui64vARB glad_glUniform1ui64vARB
5264GLAD_API_CALL PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
5265#define glUniform1uiv glad_glUniform1uiv
5266GLAD_API_CALL PFNGLUNIFORM2DPROC glad_glUniform2d;
5267#define glUniform2d glad_glUniform2d
5268GLAD_API_CALL PFNGLUNIFORM2DVPROC glad_glUniform2dv;
5269#define glUniform2dv glad_glUniform2dv
5270GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
5271#define glUniform2f glad_glUniform2f
5272GLAD_API_CALL PFNGLUNIFORM2FARBPROC glad_glUniform2fARB;
5273#define glUniform2fARB glad_glUniform2fARB
5274GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
5275#define glUniform2fv glad_glUniform2fv
5276GLAD_API_CALL PFNGLUNIFORM2FVARBPROC glad_glUniform2fvARB;
5277#define glUniform2fvARB glad_glUniform2fvARB
5278GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
5279#define glUniform2i glad_glUniform2i
5280GLAD_API_CALL PFNGLUNIFORM2I64ARBPROC glad_glUniform2i64ARB;
5281#define glUniform2i64ARB glad_glUniform2i64ARB
5282GLAD_API_CALL PFNGLUNIFORM2I64VARBPROC glad_glUniform2i64vARB;
5283#define glUniform2i64vARB glad_glUniform2i64vARB
5284GLAD_API_CALL PFNGLUNIFORM2IARBPROC glad_glUniform2iARB;
5285#define glUniform2iARB glad_glUniform2iARB
5286GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
5287#define glUniform2iv glad_glUniform2iv
5288GLAD_API_CALL PFNGLUNIFORM2IVARBPROC glad_glUniform2ivARB;
5289#define glUniform2ivARB glad_glUniform2ivARB
5290GLAD_API_CALL PFNGLUNIFORM2UIPROC glad_glUniform2ui;
5291#define glUniform2ui glad_glUniform2ui
5292GLAD_API_CALL PFNGLUNIFORM2UI64ARBPROC glad_glUniform2ui64ARB;
5293#define glUniform2ui64ARB glad_glUniform2ui64ARB
5294GLAD_API_CALL PFNGLUNIFORM2UI64VARBPROC glad_glUniform2ui64vARB;
5295#define glUniform2ui64vARB glad_glUniform2ui64vARB
5296GLAD_API_CALL PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
5297#define glUniform2uiv glad_glUniform2uiv
5298GLAD_API_CALL PFNGLUNIFORM3DPROC glad_glUniform3d;
5299#define glUniform3d glad_glUniform3d
5300GLAD_API_CALL PFNGLUNIFORM3DVPROC glad_glUniform3dv;
5301#define glUniform3dv glad_glUniform3dv
5302GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
5303#define glUniform3f glad_glUniform3f
5304GLAD_API_CALL PFNGLUNIFORM3FARBPROC glad_glUniform3fARB;
5305#define glUniform3fARB glad_glUniform3fARB
5306GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
5307#define glUniform3fv glad_glUniform3fv
5308GLAD_API_CALL PFNGLUNIFORM3FVARBPROC glad_glUniform3fvARB;
5309#define glUniform3fvARB glad_glUniform3fvARB
5310GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
5311#define glUniform3i glad_glUniform3i
5312GLAD_API_CALL PFNGLUNIFORM3I64ARBPROC glad_glUniform3i64ARB;
5313#define glUniform3i64ARB glad_glUniform3i64ARB
5314GLAD_API_CALL PFNGLUNIFORM3I64VARBPROC glad_glUniform3i64vARB;
5315#define glUniform3i64vARB glad_glUniform3i64vARB
5316GLAD_API_CALL PFNGLUNIFORM3IARBPROC glad_glUniform3iARB;
5317#define glUniform3iARB glad_glUniform3iARB
5318GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
5319#define glUniform3iv glad_glUniform3iv
5320GLAD_API_CALL PFNGLUNIFORM3IVARBPROC glad_glUniform3ivARB;
5321#define glUniform3ivARB glad_glUniform3ivARB
5322GLAD_API_CALL PFNGLUNIFORM3UIPROC glad_glUniform3ui;
5323#define glUniform3ui glad_glUniform3ui
5324GLAD_API_CALL PFNGLUNIFORM3UI64ARBPROC glad_glUniform3ui64ARB;
5325#define glUniform3ui64ARB glad_glUniform3ui64ARB
5326GLAD_API_CALL PFNGLUNIFORM3UI64VARBPROC glad_glUniform3ui64vARB;
5327#define glUniform3ui64vARB glad_glUniform3ui64vARB
5328GLAD_API_CALL PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
5329#define glUniform3uiv glad_glUniform3uiv
5330GLAD_API_CALL PFNGLUNIFORM4DPROC glad_glUniform4d;
5331#define glUniform4d glad_glUniform4d
5332GLAD_API_CALL PFNGLUNIFORM4DVPROC glad_glUniform4dv;
5333#define glUniform4dv glad_glUniform4dv
5334GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
5335#define glUniform4f glad_glUniform4f
5336GLAD_API_CALL PFNGLUNIFORM4FARBPROC glad_glUniform4fARB;
5337#define glUniform4fARB glad_glUniform4fARB
5338GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
5339#define glUniform4fv glad_glUniform4fv
5340GLAD_API_CALL PFNGLUNIFORM4FVARBPROC glad_glUniform4fvARB;
5341#define glUniform4fvARB glad_glUniform4fvARB
5342GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
5343#define glUniform4i glad_glUniform4i
5344GLAD_API_CALL PFNGLUNIFORM4I64ARBPROC glad_glUniform4i64ARB;
5345#define glUniform4i64ARB glad_glUniform4i64ARB
5346GLAD_API_CALL PFNGLUNIFORM4I64VARBPROC glad_glUniform4i64vARB;
5347#define glUniform4i64vARB glad_glUniform4i64vARB
5348GLAD_API_CALL PFNGLUNIFORM4IARBPROC glad_glUniform4iARB;
5349#define glUniform4iARB glad_glUniform4iARB
5350GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
5351#define glUniform4iv glad_glUniform4iv
5352GLAD_API_CALL PFNGLUNIFORM4IVARBPROC glad_glUniform4ivARB;
5353#define glUniform4ivARB glad_glUniform4ivARB
5354GLAD_API_CALL PFNGLUNIFORM4UIPROC glad_glUniform4ui;
5355#define glUniform4ui glad_glUniform4ui
5356GLAD_API_CALL PFNGLUNIFORM4UI64ARBPROC glad_glUniform4ui64ARB;
5357#define glUniform4ui64ARB glad_glUniform4ui64ARB
5358GLAD_API_CALL PFNGLUNIFORM4UI64VARBPROC glad_glUniform4ui64vARB;
5359#define glUniform4ui64vARB glad_glUniform4ui64vARB
5360GLAD_API_CALL PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
5361#define glUniform4uiv glad_glUniform4uiv
5362GLAD_API_CALL PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
5363#define glUniformBlockBinding glad_glUniformBlockBinding
5364GLAD_API_CALL PFNGLUNIFORMMATRIX2DVPROC glad_glUniformMatrix2dv;
5365#define glUniformMatrix2dv glad_glUniformMatrix2dv
5366GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
5367#define glUniformMatrix2fv glad_glUniformMatrix2fv
5368GLAD_API_CALL PFNGLUNIFORMMATRIX2FVARBPROC glad_glUniformMatrix2fvARB;
5369#define glUniformMatrix2fvARB glad_glUniformMatrix2fvARB
5370GLAD_API_CALL PFNGLUNIFORMMATRIX2X3DVPROC glad_glUniformMatrix2x3dv;
5371#define glUniformMatrix2x3dv glad_glUniformMatrix2x3dv
5372GLAD_API_CALL PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
5373#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
5374GLAD_API_CALL PFNGLUNIFORMMATRIX2X4DVPROC glad_glUniformMatrix2x4dv;
5375#define glUniformMatrix2x4dv glad_glUniformMatrix2x4dv
5376GLAD_API_CALL PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
5377#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
5378GLAD_API_CALL PFNGLUNIFORMMATRIX3DVPROC glad_glUniformMatrix3dv;
5379#define glUniformMatrix3dv glad_glUniformMatrix3dv
5380GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
5381#define glUniformMatrix3fv glad_glUniformMatrix3fv
5382GLAD_API_CALL PFNGLUNIFORMMATRIX3FVARBPROC glad_glUniformMatrix3fvARB;
5383#define glUniformMatrix3fvARB glad_glUniformMatrix3fvARB
5384GLAD_API_CALL PFNGLUNIFORMMATRIX3X2DVPROC glad_glUniformMatrix3x2dv;
5385#define glUniformMatrix3x2dv glad_glUniformMatrix3x2dv
5386GLAD_API_CALL PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
5387#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
5388GLAD_API_CALL PFNGLUNIFORMMATRIX3X4DVPROC glad_glUniformMatrix3x4dv;
5389#define glUniformMatrix3x4dv glad_glUniformMatrix3x4dv
5390GLAD_API_CALL PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
5391#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
5392GLAD_API_CALL PFNGLUNIFORMMATRIX4DVPROC glad_glUniformMatrix4dv;
5393#define glUniformMatrix4dv glad_glUniformMatrix4dv
5394GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
5395#define glUniformMatrix4fv glad_glUniformMatrix4fv
5396GLAD_API_CALL PFNGLUNIFORMMATRIX4FVARBPROC glad_glUniformMatrix4fvARB;
5397#define glUniformMatrix4fvARB glad_glUniformMatrix4fvARB
5398GLAD_API_CALL PFNGLUNIFORMMATRIX4X2DVPROC glad_glUniformMatrix4x2dv;
5399#define glUniformMatrix4x2dv glad_glUniformMatrix4x2dv
5400GLAD_API_CALL PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
5401#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
5402GLAD_API_CALL PFNGLUNIFORMMATRIX4X3DVPROC glad_glUniformMatrix4x3dv;
5403#define glUniformMatrix4x3dv glad_glUniformMatrix4x3dv
5404GLAD_API_CALL PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
5405#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
5406GLAD_API_CALL PFNGLUNIFORMSUBROUTINESUIVPROC glad_glUniformSubroutinesuiv;
5407#define glUniformSubroutinesuiv glad_glUniformSubroutinesuiv
5408GLAD_API_CALL PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
5409#define glUnmapBuffer glad_glUnmapBuffer
5410GLAD_API_CALL PFNGLUNMAPBUFFERARBPROC glad_glUnmapBufferARB;
5411#define glUnmapBufferARB glad_glUnmapBufferARB
5412GLAD_API_CALL PFNGLUNMAPNAMEDBUFFERPROC glad_glUnmapNamedBuffer;
5413#define glUnmapNamedBuffer glad_glUnmapNamedBuffer
5414GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
5415#define glUseProgram glad_glUseProgram
5416GLAD_API_CALL PFNGLUSEPROGRAMOBJECTARBPROC glad_glUseProgramObjectARB;
5417#define glUseProgramObjectARB glad_glUseProgramObjectARB
5418GLAD_API_CALL PFNGLUSEPROGRAMSTAGESPROC glad_glUseProgramStages;
5419#define glUseProgramStages glad_glUseProgramStages
5420GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
5421#define glValidateProgram glad_glValidateProgram
5422GLAD_API_CALL PFNGLVALIDATEPROGRAMARBPROC glad_glValidateProgramARB;
5423#define glValidateProgramARB glad_glValidateProgramARB
5424GLAD_API_CALL PFNGLVALIDATEPROGRAMPIPELINEPROC glad_glValidateProgramPipeline;
5425#define glValidateProgramPipeline glad_glValidateProgramPipeline
5426GLAD_API_CALL PFNGLVERTEX2XOESPROC glad_glVertex2xOES;
5427#define glVertex2xOES glad_glVertex2xOES
5428GLAD_API_CALL PFNGLVERTEX2XVOESPROC glad_glVertex2xvOES;
5429#define glVertex2xvOES glad_glVertex2xvOES
5430GLAD_API_CALL PFNGLVERTEX3XOESPROC glad_glVertex3xOES;
5431#define glVertex3xOES glad_glVertex3xOES
5432GLAD_API_CALL PFNGLVERTEX3XVOESPROC glad_glVertex3xvOES;
5433#define glVertex3xvOES glad_glVertex3xvOES
5434GLAD_API_CALL PFNGLVERTEX4XOESPROC glad_glVertex4xOES;
5435#define glVertex4xOES glad_glVertex4xOES
5436GLAD_API_CALL PFNGLVERTEX4XVOESPROC glad_glVertex4xvOES;
5437#define glVertex4xvOES glad_glVertex4xvOES
5438GLAD_API_CALL PFNGLVERTEXARRAYATTRIBBINDINGPROC glad_glVertexArrayAttribBinding;
5439#define glVertexArrayAttribBinding glad_glVertexArrayAttribBinding
5440GLAD_API_CALL PFNGLVERTEXARRAYATTRIBFORMATPROC glad_glVertexArrayAttribFormat;
5441#define glVertexArrayAttribFormat glad_glVertexArrayAttribFormat
5442GLAD_API_CALL PFNGLVERTEXARRAYATTRIBIFORMATPROC glad_glVertexArrayAttribIFormat;
5443#define glVertexArrayAttribIFormat glad_glVertexArrayAttribIFormat
5444GLAD_API_CALL PFNGLVERTEXARRAYATTRIBLFORMATPROC glad_glVertexArrayAttribLFormat;
5445#define glVertexArrayAttribLFormat glad_glVertexArrayAttribLFormat
5446GLAD_API_CALL PFNGLVERTEXARRAYBINDINGDIVISORPROC glad_glVertexArrayBindingDivisor;
5447#define glVertexArrayBindingDivisor glad_glVertexArrayBindingDivisor
5448GLAD_API_CALL PFNGLVERTEXARRAYELEMENTBUFFERPROC glad_glVertexArrayElementBuffer;
5449#define glVertexArrayElementBuffer glad_glVertexArrayElementBuffer
5450GLAD_API_CALL PFNGLVERTEXARRAYVERTEXBUFFERPROC glad_glVertexArrayVertexBuffer;
5451#define glVertexArrayVertexBuffer glad_glVertexArrayVertexBuffer
5452GLAD_API_CALL PFNGLVERTEXARRAYVERTEXBUFFERSPROC glad_glVertexArrayVertexBuffers;
5453#define glVertexArrayVertexBuffers glad_glVertexArrayVertexBuffers
5454GLAD_API_CALL PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
5455#define glVertexAttrib1d glad_glVertexAttrib1d
5456GLAD_API_CALL PFNGLVERTEXATTRIB1DARBPROC glad_glVertexAttrib1dARB;
5457#define glVertexAttrib1dARB glad_glVertexAttrib1dARB
5458GLAD_API_CALL PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
5459#define glVertexAttrib1dv glad_glVertexAttrib1dv
5460GLAD_API_CALL PFNGLVERTEXATTRIB1DVARBPROC glad_glVertexAttrib1dvARB;
5461#define glVertexAttrib1dvARB glad_glVertexAttrib1dvARB
5462GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
5463#define glVertexAttrib1f glad_glVertexAttrib1f
5464GLAD_API_CALL PFNGLVERTEXATTRIB1FARBPROC glad_glVertexAttrib1fARB;
5465#define glVertexAttrib1fARB glad_glVertexAttrib1fARB
5466GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
5467#define glVertexAttrib1fv glad_glVertexAttrib1fv
5468GLAD_API_CALL PFNGLVERTEXATTRIB1FVARBPROC glad_glVertexAttrib1fvARB;
5469#define glVertexAttrib1fvARB glad_glVertexAttrib1fvARB
5470GLAD_API_CALL PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
5471#define glVertexAttrib1s glad_glVertexAttrib1s
5472GLAD_API_CALL PFNGLVERTEXATTRIB1SARBPROC glad_glVertexAttrib1sARB;
5473#define glVertexAttrib1sARB glad_glVertexAttrib1sARB
5474GLAD_API_CALL PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
5475#define glVertexAttrib1sv glad_glVertexAttrib1sv
5476GLAD_API_CALL PFNGLVERTEXATTRIB1SVARBPROC glad_glVertexAttrib1svARB;
5477#define glVertexAttrib1svARB glad_glVertexAttrib1svARB
5478GLAD_API_CALL PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
5479#define glVertexAttrib2d glad_glVertexAttrib2d
5480GLAD_API_CALL PFNGLVERTEXATTRIB2DARBPROC glad_glVertexAttrib2dARB;
5481#define glVertexAttrib2dARB glad_glVertexAttrib2dARB
5482GLAD_API_CALL PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
5483#define glVertexAttrib2dv glad_glVertexAttrib2dv
5484GLAD_API_CALL PFNGLVERTEXATTRIB2DVARBPROC glad_glVertexAttrib2dvARB;
5485#define glVertexAttrib2dvARB glad_glVertexAttrib2dvARB
5486GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
5487#define glVertexAttrib2f glad_glVertexAttrib2f
5488GLAD_API_CALL PFNGLVERTEXATTRIB2FARBPROC glad_glVertexAttrib2fARB;
5489#define glVertexAttrib2fARB glad_glVertexAttrib2fARB
5490GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
5491#define glVertexAttrib2fv glad_glVertexAttrib2fv
5492GLAD_API_CALL PFNGLVERTEXATTRIB2FVARBPROC glad_glVertexAttrib2fvARB;
5493#define glVertexAttrib2fvARB glad_glVertexAttrib2fvARB
5494GLAD_API_CALL PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
5495#define glVertexAttrib2s glad_glVertexAttrib2s
5496GLAD_API_CALL PFNGLVERTEXATTRIB2SARBPROC glad_glVertexAttrib2sARB;
5497#define glVertexAttrib2sARB glad_glVertexAttrib2sARB
5498GLAD_API_CALL PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
5499#define glVertexAttrib2sv glad_glVertexAttrib2sv
5500GLAD_API_CALL PFNGLVERTEXATTRIB2SVARBPROC glad_glVertexAttrib2svARB;
5501#define glVertexAttrib2svARB glad_glVertexAttrib2svARB
5502GLAD_API_CALL PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
5503#define glVertexAttrib3d glad_glVertexAttrib3d
5504GLAD_API_CALL PFNGLVERTEXATTRIB3DARBPROC glad_glVertexAttrib3dARB;
5505#define glVertexAttrib3dARB glad_glVertexAttrib3dARB
5506GLAD_API_CALL PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
5507#define glVertexAttrib3dv glad_glVertexAttrib3dv
5508GLAD_API_CALL PFNGLVERTEXATTRIB3DVARBPROC glad_glVertexAttrib3dvARB;
5509#define glVertexAttrib3dvARB glad_glVertexAttrib3dvARB
5510GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
5511#define glVertexAttrib3f glad_glVertexAttrib3f
5512GLAD_API_CALL PFNGLVERTEXATTRIB3FARBPROC glad_glVertexAttrib3fARB;
5513#define glVertexAttrib3fARB glad_glVertexAttrib3fARB
5514GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
5515#define glVertexAttrib3fv glad_glVertexAttrib3fv
5516GLAD_API_CALL PFNGLVERTEXATTRIB3FVARBPROC glad_glVertexAttrib3fvARB;
5517#define glVertexAttrib3fvARB glad_glVertexAttrib3fvARB
5518GLAD_API_CALL PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
5519#define glVertexAttrib3s glad_glVertexAttrib3s
5520GLAD_API_CALL PFNGLVERTEXATTRIB3SARBPROC glad_glVertexAttrib3sARB;
5521#define glVertexAttrib3sARB glad_glVertexAttrib3sARB
5522GLAD_API_CALL PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
5523#define glVertexAttrib3sv glad_glVertexAttrib3sv
5524GLAD_API_CALL PFNGLVERTEXATTRIB3SVARBPROC glad_glVertexAttrib3svARB;
5525#define glVertexAttrib3svARB glad_glVertexAttrib3svARB
5526GLAD_API_CALL PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
5527#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
5528GLAD_API_CALL PFNGLVERTEXATTRIB4NBVARBPROC glad_glVertexAttrib4NbvARB;
5529#define glVertexAttrib4NbvARB glad_glVertexAttrib4NbvARB
5530GLAD_API_CALL PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
5531#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
5532GLAD_API_CALL PFNGLVERTEXATTRIB4NIVARBPROC glad_glVertexAttrib4NivARB;
5533#define glVertexAttrib4NivARB glad_glVertexAttrib4NivARB
5534GLAD_API_CALL PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
5535#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
5536GLAD_API_CALL PFNGLVERTEXATTRIB4NSVARBPROC glad_glVertexAttrib4NsvARB;
5537#define glVertexAttrib4NsvARB glad_glVertexAttrib4NsvARB
5538GLAD_API_CALL PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
5539#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
5540GLAD_API_CALL PFNGLVERTEXATTRIB4NUBARBPROC glad_glVertexAttrib4NubARB;
5541#define glVertexAttrib4NubARB glad_glVertexAttrib4NubARB
5542GLAD_API_CALL PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
5543#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
5544GLAD_API_CALL PFNGLVERTEXATTRIB4NUBVARBPROC glad_glVertexAttrib4NubvARB;
5545#define glVertexAttrib4NubvARB glad_glVertexAttrib4NubvARB
5546GLAD_API_CALL PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
5547#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
5548GLAD_API_CALL PFNGLVERTEXATTRIB4NUIVARBPROC glad_glVertexAttrib4NuivARB;
5549#define glVertexAttrib4NuivARB glad_glVertexAttrib4NuivARB
5550GLAD_API_CALL PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
5551#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
5552GLAD_API_CALL PFNGLVERTEXATTRIB4NUSVARBPROC glad_glVertexAttrib4NusvARB;
5553#define glVertexAttrib4NusvARB glad_glVertexAttrib4NusvARB
5554GLAD_API_CALL PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
5555#define glVertexAttrib4bv glad_glVertexAttrib4bv
5556GLAD_API_CALL PFNGLVERTEXATTRIB4BVARBPROC glad_glVertexAttrib4bvARB;
5557#define glVertexAttrib4bvARB glad_glVertexAttrib4bvARB
5558GLAD_API_CALL PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
5559#define glVertexAttrib4d glad_glVertexAttrib4d
5560GLAD_API_CALL PFNGLVERTEXATTRIB4DARBPROC glad_glVertexAttrib4dARB;
5561#define glVertexAttrib4dARB glad_glVertexAttrib4dARB
5562GLAD_API_CALL PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
5563#define glVertexAttrib4dv glad_glVertexAttrib4dv
5564GLAD_API_CALL PFNGLVERTEXATTRIB4DVARBPROC glad_glVertexAttrib4dvARB;
5565#define glVertexAttrib4dvARB glad_glVertexAttrib4dvARB
5566GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
5567#define glVertexAttrib4f glad_glVertexAttrib4f
5568GLAD_API_CALL PFNGLVERTEXATTRIB4FARBPROC glad_glVertexAttrib4fARB;
5569#define glVertexAttrib4fARB glad_glVertexAttrib4fARB
5570GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
5571#define glVertexAttrib4fv glad_glVertexAttrib4fv
5572GLAD_API_CALL PFNGLVERTEXATTRIB4FVARBPROC glad_glVertexAttrib4fvARB;
5573#define glVertexAttrib4fvARB glad_glVertexAttrib4fvARB
5574GLAD_API_CALL PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
5575#define glVertexAttrib4iv glad_glVertexAttrib4iv
5576GLAD_API_CALL PFNGLVERTEXATTRIB4IVARBPROC glad_glVertexAttrib4ivARB;
5577#define glVertexAttrib4ivARB glad_glVertexAttrib4ivARB
5578GLAD_API_CALL PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
5579#define glVertexAttrib4s glad_glVertexAttrib4s
5580GLAD_API_CALL PFNGLVERTEXATTRIB4SARBPROC glad_glVertexAttrib4sARB;
5581#define glVertexAttrib4sARB glad_glVertexAttrib4sARB
5582GLAD_API_CALL PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
5583#define glVertexAttrib4sv glad_glVertexAttrib4sv
5584GLAD_API_CALL PFNGLVERTEXATTRIB4SVARBPROC glad_glVertexAttrib4svARB;
5585#define glVertexAttrib4svARB glad_glVertexAttrib4svARB
5586GLAD_API_CALL PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
5587#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
5588GLAD_API_CALL PFNGLVERTEXATTRIB4UBVARBPROC glad_glVertexAttrib4ubvARB;
5589#define glVertexAttrib4ubvARB glad_glVertexAttrib4ubvARB
5590GLAD_API_CALL PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
5591#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
5592GLAD_API_CALL PFNGLVERTEXATTRIB4UIVARBPROC glad_glVertexAttrib4uivARB;
5593#define glVertexAttrib4uivARB glad_glVertexAttrib4uivARB
5594GLAD_API_CALL PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
5595#define glVertexAttrib4usv glad_glVertexAttrib4usv
5596GLAD_API_CALL PFNGLVERTEXATTRIB4USVARBPROC glad_glVertexAttrib4usvARB;
5597#define glVertexAttrib4usvARB glad_glVertexAttrib4usvARB
5598GLAD_API_CALL PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding;
5599#define glVertexAttribBinding glad_glVertexAttribBinding
5600GLAD_API_CALL PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
5601#define glVertexAttribDivisor glad_glVertexAttribDivisor
5602GLAD_API_CALL PFNGLVERTEXATTRIBDIVISORARBPROC glad_glVertexAttribDivisorARB;
5603#define glVertexAttribDivisorARB glad_glVertexAttribDivisorARB
5604GLAD_API_CALL PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat;
5605#define glVertexAttribFormat glad_glVertexAttribFormat
5606GLAD_API_CALL PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
5607#define glVertexAttribI1i glad_glVertexAttribI1i
5608GLAD_API_CALL PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
5609#define glVertexAttribI1iv glad_glVertexAttribI1iv
5610GLAD_API_CALL PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
5611#define glVertexAttribI1ui glad_glVertexAttribI1ui
5612GLAD_API_CALL PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
5613#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
5614GLAD_API_CALL PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
5615#define glVertexAttribI2i glad_glVertexAttribI2i
5616GLAD_API_CALL PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
5617#define glVertexAttribI2iv glad_glVertexAttribI2iv
5618GLAD_API_CALL PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
5619#define glVertexAttribI2ui glad_glVertexAttribI2ui
5620GLAD_API_CALL PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
5621#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
5622GLAD_API_CALL PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
5623#define glVertexAttribI3i glad_glVertexAttribI3i
5624GLAD_API_CALL PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
5625#define glVertexAttribI3iv glad_glVertexAttribI3iv
5626GLAD_API_CALL PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
5627#define glVertexAttribI3ui glad_glVertexAttribI3ui
5628GLAD_API_CALL PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
5629#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
5630GLAD_API_CALL PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
5631#define glVertexAttribI4bv glad_glVertexAttribI4bv
5632GLAD_API_CALL PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
5633#define glVertexAttribI4i glad_glVertexAttribI4i
5634GLAD_API_CALL PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
5635#define glVertexAttribI4iv glad_glVertexAttribI4iv
5636GLAD_API_CALL PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
5637#define glVertexAttribI4sv glad_glVertexAttribI4sv
5638GLAD_API_CALL PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
5639#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
5640GLAD_API_CALL PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
5641#define glVertexAttribI4ui glad_glVertexAttribI4ui
5642GLAD_API_CALL PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
5643#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
5644GLAD_API_CALL PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
5645#define glVertexAttribI4usv glad_glVertexAttribI4usv
5646GLAD_API_CALL PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat;
5647#define glVertexAttribIFormat glad_glVertexAttribIFormat
5648GLAD_API_CALL PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
5649#define glVertexAttribIPointer glad_glVertexAttribIPointer
5650GLAD_API_CALL PFNGLVERTEXATTRIBL1DPROC glad_glVertexAttribL1d;
5651#define glVertexAttribL1d glad_glVertexAttribL1d
5652GLAD_API_CALL PFNGLVERTEXATTRIBL1DVPROC glad_glVertexAttribL1dv;
5653#define glVertexAttribL1dv glad_glVertexAttribL1dv
5654GLAD_API_CALL PFNGLVERTEXATTRIBL2DPROC glad_glVertexAttribL2d;
5655#define glVertexAttribL2d glad_glVertexAttribL2d
5656GLAD_API_CALL PFNGLVERTEXATTRIBL2DVPROC glad_glVertexAttribL2dv;
5657#define glVertexAttribL2dv glad_glVertexAttribL2dv
5658GLAD_API_CALL PFNGLVERTEXATTRIBL3DPROC glad_glVertexAttribL3d;
5659#define glVertexAttribL3d glad_glVertexAttribL3d
5660GLAD_API_CALL PFNGLVERTEXATTRIBL3DVPROC glad_glVertexAttribL3dv;
5661#define glVertexAttribL3dv glad_glVertexAttribL3dv
5662GLAD_API_CALL PFNGLVERTEXATTRIBL4DPROC glad_glVertexAttribL4d;
5663#define glVertexAttribL4d glad_glVertexAttribL4d
5664GLAD_API_CALL PFNGLVERTEXATTRIBL4DVPROC glad_glVertexAttribL4dv;
5665#define glVertexAttribL4dv glad_glVertexAttribL4dv
5666GLAD_API_CALL PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat;
5667#define glVertexAttribLFormat glad_glVertexAttribLFormat
5668GLAD_API_CALL PFNGLVERTEXATTRIBLPOINTERPROC glad_glVertexAttribLPointer;
5669#define glVertexAttribLPointer glad_glVertexAttribLPointer
5670GLAD_API_CALL PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
5671#define glVertexAttribP1ui glad_glVertexAttribP1ui
5672GLAD_API_CALL PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
5673#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
5674GLAD_API_CALL PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
5675#define glVertexAttribP2ui glad_glVertexAttribP2ui
5676GLAD_API_CALL PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
5677#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
5678GLAD_API_CALL PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
5679#define glVertexAttribP3ui glad_glVertexAttribP3ui
5680GLAD_API_CALL PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
5681#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
5682GLAD_API_CALL PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
5683#define glVertexAttribP4ui glad_glVertexAttribP4ui
5684GLAD_API_CALL PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
5685#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
5686GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
5687#define glVertexAttribPointer glad_glVertexAttribPointer
5688GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERARBPROC glad_glVertexAttribPointerARB;
5689#define glVertexAttribPointerARB glad_glVertexAttribPointerARB
5690GLAD_API_CALL PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor;
5691#define glVertexBindingDivisor glad_glVertexBindingDivisor
5692GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
5693#define glViewport glad_glViewport
5694GLAD_API_CALL PFNGLVIEWPORTARRAYVPROC glad_glViewportArrayv;
5695#define glViewportArrayv glad_glViewportArrayv
5696GLAD_API_CALL PFNGLVIEWPORTINDEXEDFPROC glad_glViewportIndexedf;
5697#define glViewportIndexedf glad_glViewportIndexedf
5698GLAD_API_CALL PFNGLVIEWPORTINDEXEDFVPROC glad_glViewportIndexedfv;
5699#define glViewportIndexedfv glad_glViewportIndexedfv
5700GLAD_API_CALL PFNGLWAITSYNCPROC glad_glWaitSync;
5701#define glWaitSync glad_glWaitSync
5702
5703
5704
5705
5706
5707GLAD_API_CALL int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr);
5708GLAD_API_CALL int gladLoadGL( GLADloadfunc load);
5709
5710
5711
5712#ifdef __cplusplus
5713}
5714#endif
5715#endif
5716
5717/* Source */
5718#ifdef GLAD_GL_IMPLEMENTATION
5719#include <stdio.h>
5720#include <stdlib.h>
5721#include <string.h>
5722
5723#ifndef GLAD_IMPL_UTIL_C_
5724#define GLAD_IMPL_UTIL_C_
5725
5726#ifdef _MSC_VER
5727#define GLAD_IMPL_UTIL_SSCANF sscanf_s
5728#else
5729#define GLAD_IMPL_UTIL_SSCANF sscanf
5730#endif
5731
5732#endif /* GLAD_IMPL_UTIL_C_ */
5733
5734#ifdef __cplusplus
5735extern "C" {
5736#endif
5737
5738
5739
5740int GLAD_GL_VERSION_1_0 = 0;
5741int GLAD_GL_VERSION_1_1 = 0;
5742int GLAD_GL_VERSION_1_2 = 0;
5743int GLAD_GL_VERSION_1_3 = 0;
5744int GLAD_GL_VERSION_1_4 = 0;
5745int GLAD_GL_VERSION_1_5 = 0;
5746int GLAD_GL_VERSION_2_0 = 0;
5747int GLAD_GL_VERSION_2_1 = 0;
5748int GLAD_GL_VERSION_3_0 = 0;
5749int GLAD_GL_VERSION_3_1 = 0;
5750int GLAD_GL_VERSION_3_2 = 0;
5751int GLAD_GL_VERSION_3_3 = 0;
5752int GLAD_GL_VERSION_4_0 = 0;
5753int GLAD_GL_VERSION_4_1 = 0;
5754int GLAD_GL_VERSION_4_2 = 0;
5755int GLAD_GL_VERSION_4_3 = 0;
5756int GLAD_GL_ARB_ES2_compatibility = 0;
5757int GLAD_GL_ARB_ES3_1_compatibility = 0;
5758int GLAD_GL_ARB_ES3_2_compatibility = 0;
5759int GLAD_GL_ARB_ES3_compatibility = 0;
5760int GLAD_GL_ARB_blend_func_extended = 0;
5761int GLAD_GL_ARB_buffer_storage = 0;
5762int GLAD_GL_ARB_clear_buffer_object = 0;
5763int GLAD_GL_ARB_clear_texture = 0;
5764int GLAD_GL_ARB_color_buffer_float = 0;
5765int GLAD_GL_ARB_compatibility = 0;
5766int GLAD_GL_ARB_compressed_texture_pixel_storage = 0;
5767int GLAD_GL_ARB_compute_shader = 0;
5768int GLAD_GL_ARB_compute_variable_group_size = 0;
5769int GLAD_GL_ARB_copy_buffer = 0;
5770int GLAD_GL_ARB_copy_image = 0;
5771int GLAD_GL_ARB_debug_output = 0;
5772int GLAD_GL_ARB_depth_buffer_float = 0;
5773int GLAD_GL_ARB_depth_clamp = 0;
5774int GLAD_GL_ARB_depth_texture = 0;
5775int GLAD_GL_ARB_direct_state_access = 0;
5776int GLAD_GL_ARB_draw_buffers = 0;
5777int GLAD_GL_ARB_draw_buffers_blend = 0;
5778int GLAD_GL_ARB_draw_elements_base_vertex = 0;
5779int GLAD_GL_ARB_draw_indirect = 0;
5780int GLAD_GL_ARB_draw_instanced = 0;
5781int GLAD_GL_ARB_enhanced_layouts = 0;
5782int GLAD_GL_ARB_explicit_attrib_location = 0;
5783int GLAD_GL_ARB_explicit_uniform_location = 0;
5784int GLAD_GL_ARB_fragment_coord_conventions = 0;
5785int GLAD_GL_ARB_fragment_layer_viewport = 0;
5786int GLAD_GL_ARB_fragment_program = 0;
5787int GLAD_GL_ARB_fragment_program_shadow = 0;
5788int GLAD_GL_ARB_fragment_shader = 0;
5789int GLAD_GL_ARB_fragment_shader_interlock = 0;
5790int GLAD_GL_ARB_framebuffer_no_attachments = 0;
5791int GLAD_GL_ARB_framebuffer_object = 0;
5792int GLAD_GL_ARB_framebuffer_sRGB = 0;
5793int GLAD_GL_ARB_geometry_shader4 = 0;
5794int GLAD_GL_ARB_get_program_binary = 0;
5795int GLAD_GL_ARB_get_texture_sub_image = 0;
5796int GLAD_GL_ARB_gl_spirv = 0;
5797int GLAD_GL_ARB_gpu_shader5 = 0;
5798int GLAD_GL_ARB_gpu_shader_fp64 = 0;
5799int GLAD_GL_ARB_gpu_shader_int64 = 0;
5800int GLAD_GL_ARB_half_float_pixel = 0;
5801int GLAD_GL_ARB_half_float_vertex = 0;
5802int GLAD_GL_ARB_instanced_arrays = 0;
5803int GLAD_GL_ARB_internalformat_query = 0;
5804int GLAD_GL_ARB_internalformat_query2 = 0;
5805int GLAD_GL_ARB_map_buffer_range = 0;
5806int GLAD_GL_ARB_multi_bind = 0;
5807int GLAD_GL_ARB_multi_draw_indirect = 0;
5808int GLAD_GL_ARB_multisample = 0;
5809int GLAD_GL_ARB_multitexture = 0;
5810int GLAD_GL_ARB_occlusion_query = 0;
5811int GLAD_GL_ARB_occlusion_query2 = 0;
5812int GLAD_GL_ARB_pipeline_statistics_query = 0;
5813int GLAD_GL_ARB_query_buffer_object = 0;
5814int GLAD_GL_ARB_sample_locations = 0;
5815int GLAD_GL_ARB_sample_shading = 0;
5816int GLAD_GL_ARB_seamless_cube_map = 0;
5817int GLAD_GL_ARB_seamless_cubemap_per_texture = 0;
5818int GLAD_GL_ARB_shader_atomic_counter_ops = 0;
5819int GLAD_GL_ARB_shader_atomic_counters = 0;
5820int GLAD_GL_ARB_shader_bit_encoding = 0;
5821int GLAD_GL_ARB_shader_clock = 0;
5822int GLAD_GL_ARB_shader_image_load_store = 0;
5823int GLAD_GL_ARB_shader_image_size = 0;
5824int GLAD_GL_ARB_shader_objects = 0;
5825int GLAD_GL_ARB_shader_storage_buffer_object = 0;
5826int GLAD_GL_ARB_shader_texture_lod = 0;
5827int GLAD_GL_ARB_shading_language_100 = 0;
5828int GLAD_GL_ARB_shading_language_420pack = 0;
5829int GLAD_GL_ARB_shading_language_include = 0;
5830int GLAD_GL_ARB_shading_language_packing = 0;
5831int GLAD_GL_ARB_spirv_extensions = 0;
5832int GLAD_GL_ARB_tessellation_shader = 0;
5833int GLAD_GL_ARB_texture_border_clamp = 0;
5834int GLAD_GL_ARB_texture_buffer_object_rgb32 = 0;
5835int GLAD_GL_ARB_texture_compression = 0;
5836int GLAD_GL_ARB_texture_cube_map = 0;
5837int GLAD_GL_ARB_texture_cube_map_array = 0;
5838int GLAD_GL_ARB_texture_env_add = 0;
5839int GLAD_GL_ARB_texture_filter_anisotropic = 0;
5840int GLAD_GL_ARB_texture_filter_minmax = 0;
5841int GLAD_GL_ARB_texture_float = 0;
5842int GLAD_GL_ARB_texture_mirror_clamp_to_edge = 0;
5843int GLAD_GL_ARB_texture_mirrored_repeat = 0;
5844int GLAD_GL_ARB_texture_multisample = 0;
5845int GLAD_GL_ARB_texture_non_power_of_two = 0;
5846int GLAD_GL_ARB_texture_rg = 0;
5847int GLAD_GL_ARB_texture_storage = 0;
5848int GLAD_GL_ARB_texture_swizzle = 0;
5849int GLAD_GL_ARB_texture_view = 0;
5850int GLAD_GL_ARB_timer_query = 0;
5851int GLAD_GL_ARB_transpose_matrix = 0;
5852int GLAD_GL_ARB_uniform_buffer_object = 0;
5853int GLAD_GL_ARB_vertex_array_bgra = 0;
5854int GLAD_GL_ARB_vertex_array_object = 0;
5855int GLAD_GL_ARB_vertex_attrib_binding = 0;
5856int GLAD_GL_ARB_vertex_buffer_object = 0;
5857int GLAD_GL_ARB_vertex_program = 0;
5858int GLAD_GL_ARB_vertex_shader = 0;
5859int GLAD_GL_EXT_draw_instanced = 0;
5860int GLAD_GL_EXT_fog_coord = 0;
5861int GLAD_GL_EXT_framebuffer_blit = 0;
5862int GLAD_GL_EXT_framebuffer_multisample = 0;
5863int GLAD_GL_EXT_framebuffer_object = 0;
5864int GLAD_GL_EXT_framebuffer_sRGB = 0;
5865int GLAD_GL_EXT_texture_compression_s3tc = 0;
5866int GLAD_GL_EXT_texture_filter_anisotropic = 0;
5867int GLAD_GL_EXT_texture_mirror_clamp = 0;
5868int GLAD_GL_KHR_texture_compression_astc_hdr = 0;
5869int GLAD_GL_KHR_texture_compression_astc_ldr = 0;
5870int GLAD_GL_OES_compressed_paletted_texture = 0;
5871int GLAD_GL_OES_fixed_point = 0;
5872
5873
5874
5875PFNGLACCUMXOESPROC glad_glAccumxOES = NULL;
5876PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram = NULL;
5877PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
5878PFNGLACTIVETEXTUREARBPROC glad_glActiveTextureARB = NULL;
5879PFNGLALPHAFUNCXOESPROC glad_glAlphaFuncxOES = NULL;
5880PFNGLATTACHOBJECTARBPROC glad_glAttachObjectARB = NULL;
5881PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
5882PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL;
5883PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL;
5884PFNGLBEGINQUERYARBPROC glad_glBeginQueryARB = NULL;
5885PFNGLBEGINQUERYINDEXEDPROC glad_glBeginQueryIndexed = NULL;
5886PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL;
5887PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
5888PFNGLBINDATTRIBLOCATIONARBPROC glad_glBindAttribLocationARB = NULL;
5889PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
5890PFNGLBINDBUFFERARBPROC glad_glBindBufferARB = NULL;
5891PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL;
5892PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL;
5893PFNGLBINDBUFFERSBASEPROC glad_glBindBuffersBase = NULL;
5894PFNGLBINDBUFFERSRANGEPROC glad_glBindBuffersRange = NULL;
5895PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL;
5896PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL;
5897PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
5898PFNGLBINDFRAMEBUFFEREXTPROC glad_glBindFramebufferEXT = NULL;
5899PFNGLBINDIMAGETEXTUREPROC glad_glBindImageTexture = NULL;
5900PFNGLBINDIMAGETEXTURESPROC glad_glBindImageTextures = NULL;
5901PFNGLBINDPROGRAMARBPROC glad_glBindProgramARB = NULL;
5902PFNGLBINDPROGRAMPIPELINEPROC glad_glBindProgramPipeline = NULL;
5903PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
5904PFNGLBINDRENDERBUFFEREXTPROC glad_glBindRenderbufferEXT = NULL;
5905PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL;
5906PFNGLBINDSAMPLERSPROC glad_glBindSamplers = NULL;
5907PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
5908PFNGLBINDTEXTUREUNITPROC glad_glBindTextureUnit = NULL;
5909PFNGLBINDTEXTURESPROC glad_glBindTextures = NULL;
5910PFNGLBINDTRANSFORMFEEDBACKPROC glad_glBindTransformFeedback = NULL;
5911PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL;
5912PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer = NULL;
5913PFNGLBINDVERTEXBUFFERSPROC glad_glBindVertexBuffers = NULL;
5914PFNGLBITMAPXOESPROC glad_glBitmapxOES = NULL;
5915PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
5916PFNGLBLENDCOLORXOESPROC glad_glBlendColorxOES = NULL;
5917PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
5918PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
5919PFNGLBLENDEQUATIONSEPARATEIPROC glad_glBlendEquationSeparatei = NULL;
5920PFNGLBLENDEQUATIONSEPARATEIARBPROC glad_glBlendEquationSeparateiARB = NULL;
5921PFNGLBLENDEQUATIONIPROC glad_glBlendEquationi = NULL;
5922PFNGLBLENDEQUATIONIARBPROC glad_glBlendEquationiARB = NULL;
5923PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
5924PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
5925PFNGLBLENDFUNCSEPARATEIPROC glad_glBlendFuncSeparatei = NULL;
5926PFNGLBLENDFUNCSEPARATEIARBPROC glad_glBlendFuncSeparateiARB = NULL;
5927PFNGLBLENDFUNCIPROC glad_glBlendFunci = NULL;
5928PFNGLBLENDFUNCIARBPROC glad_glBlendFunciARB = NULL;
5929PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL;
5930PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT = NULL;
5931PFNGLBLITNAMEDFRAMEBUFFERPROC glad_glBlitNamedFramebuffer = NULL;
5932PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
5933PFNGLBUFFERDATAARBPROC glad_glBufferDataARB = NULL;
5934PFNGLBUFFERSTORAGEPROC glad_glBufferStorage = NULL;
5935PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
5936PFNGLBUFFERSUBDATAARBPROC glad_glBufferSubDataARB = NULL;
5937PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
5938PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glad_glCheckFramebufferStatusEXT = NULL;
5939PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glad_glCheckNamedFramebufferStatus = NULL;
5940PFNGLCLAMPCOLORPROC glad_glClampColor = NULL;
5941PFNGLCLAMPCOLORARBPROC glad_glClampColorARB = NULL;
5942PFNGLCLEARPROC glad_glClear = NULL;
5943PFNGLCLEARACCUMXOESPROC glad_glClearAccumxOES = NULL;
5944PFNGLCLEARBUFFERDATAPROC glad_glClearBufferData = NULL;
5945PFNGLCLEARBUFFERSUBDATAPROC glad_glClearBufferSubData = NULL;
5946PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL;
5947PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL;
5948PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL;
5949PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL;
5950PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
5951PFNGLCLEARCOLORXOESPROC glad_glClearColorxOES = NULL;
5952PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL;
5953PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL;
5954PFNGLCLEARDEPTHXOESPROC glad_glClearDepthxOES = NULL;
5955PFNGLCLEARNAMEDBUFFERDATAPROC glad_glClearNamedBufferData = NULL;
5956PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_glClearNamedBufferSubData = NULL;
5957PFNGLCLEARNAMEDFRAMEBUFFERFIPROC glad_glClearNamedFramebufferfi = NULL;
5958PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glad_glClearNamedFramebufferfv = NULL;
5959PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glad_glClearNamedFramebufferiv = NULL;
5960PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glad_glClearNamedFramebufferuiv = NULL;
5961PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
5962PFNGLCLEARTEXIMAGEPROC glad_glClearTexImage = NULL;
5963PFNGLCLEARTEXSUBIMAGEPROC glad_glClearTexSubImage = NULL;
5964PFNGLCLIENTACTIVETEXTUREARBPROC glad_glClientActiveTextureARB = NULL;
5965PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL;
5966PFNGLCLIPPLANEXOESPROC glad_glClipPlanexOES = NULL;
5967PFNGLCOLOR3XOESPROC glad_glColor3xOES = NULL;
5968PFNGLCOLOR3XVOESPROC glad_glColor3xvOES = NULL;
5969PFNGLCOLOR4XOESPROC glad_glColor4xOES = NULL;
5970PFNGLCOLOR4XVOESPROC glad_glColor4xvOES = NULL;
5971PFNGLCOLORMASKPROC glad_glColorMask = NULL;
5972PFNGLCOLORMASKIPROC glad_glColorMaski = NULL;
5973PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
5974PFNGLCOMPILESHADERARBPROC glad_glCompileShaderARB = NULL;
5975PFNGLCOMPILESHADERINCLUDEARBPROC glad_glCompileShaderIncludeARB = NULL;
5976PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL;
5977PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glad_glCompressedTexImage1DARB = NULL;
5978PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
5979PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glad_glCompressedTexImage2DARB = NULL;
5980PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL;
5981PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glad_glCompressedTexImage3DARB = NULL;
5982PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL;
5983PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glad_glCompressedTexSubImage1DARB = NULL;
5984PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
5985PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glad_glCompressedTexSubImage2DARB = NULL;
5986PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL;
5987PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glad_glCompressedTexSubImage3DARB = NULL;
5988PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC glad_glCompressedTextureSubImage1D = NULL;
5989PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC glad_glCompressedTextureSubImage2D = NULL;
5990PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC glad_glCompressedTextureSubImage3D = NULL;
5991PFNGLCONVOLUTIONPARAMETERXOESPROC glad_glConvolutionParameterxOES = NULL;
5992PFNGLCONVOLUTIONPARAMETERXVOESPROC glad_glConvolutionParameterxvOES = NULL;
5993PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL;
5994PFNGLCOPYIMAGESUBDATAPROC glad_glCopyImageSubData = NULL;
5995PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_glCopyNamedBufferSubData = NULL;
5996PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL;
5997PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
5998PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL;
5999PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
6000PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL;
6001PFNGLCOPYTEXTURESUBIMAGE1DPROC glad_glCopyTextureSubImage1D = NULL;
6002PFNGLCOPYTEXTURESUBIMAGE2DPROC glad_glCopyTextureSubImage2D = NULL;
6003PFNGLCOPYTEXTURESUBIMAGE3DPROC glad_glCopyTextureSubImage3D = NULL;
6004PFNGLCREATEBUFFERSPROC glad_glCreateBuffers = NULL;
6005PFNGLCREATEFRAMEBUFFERSPROC glad_glCreateFramebuffers = NULL;
6006PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
6007PFNGLCREATEPROGRAMOBJECTARBPROC glad_glCreateProgramObjectARB = NULL;
6008PFNGLCREATEPROGRAMPIPELINESPROC glad_glCreateProgramPipelines = NULL;
6009PFNGLCREATEQUERIESPROC glad_glCreateQueries = NULL;
6010PFNGLCREATERENDERBUFFERSPROC glad_glCreateRenderbuffers = NULL;
6011PFNGLCREATESAMPLERSPROC glad_glCreateSamplers = NULL;
6012PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
6013PFNGLCREATESHADEROBJECTARBPROC glad_glCreateShaderObjectARB = NULL;
6014PFNGLCREATESHADERPROGRAMVPROC glad_glCreateShaderProgramv = NULL;
6015PFNGLCREATETEXTURESPROC glad_glCreateTextures = NULL;
6016PFNGLCREATETRANSFORMFEEDBACKSPROC glad_glCreateTransformFeedbacks = NULL;
6017PFNGLCREATEVERTEXARRAYSPROC glad_glCreateVertexArrays = NULL;
6018PFNGLCULLFACEPROC glad_glCullFace = NULL;
6019PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL;
6020PFNGLDEBUGMESSAGECALLBACKARBPROC glad_glDebugMessageCallbackARB = NULL;
6021PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL;
6022PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB = NULL;
6023PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL;
6024PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB = NULL;
6025PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
6026PFNGLDELETEBUFFERSARBPROC glad_glDeleteBuffersARB = NULL;
6027PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
6028PFNGLDELETEFRAMEBUFFERSEXTPROC glad_glDeleteFramebuffersEXT = NULL;
6029PFNGLDELETENAMEDSTRINGARBPROC glad_glDeleteNamedStringARB = NULL;
6030PFNGLDELETEOBJECTARBPROC glad_glDeleteObjectARB = NULL;
6031PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
6032PFNGLDELETEPROGRAMPIPELINESPROC glad_glDeleteProgramPipelines = NULL;
6033PFNGLDELETEPROGRAMSARBPROC glad_glDeleteProgramsARB = NULL;
6034PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL;
6035PFNGLDELETEQUERIESARBPROC glad_glDeleteQueriesARB = NULL;
6036PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
6037PFNGLDELETERENDERBUFFERSEXTPROC glad_glDeleteRenderbuffersEXT = NULL;
6038PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL;
6039PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
6040PFNGLDELETESYNCPROC glad_glDeleteSync = NULL;
6041PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
6042PFNGLDELETETRANSFORMFEEDBACKSPROC glad_glDeleteTransformFeedbacks = NULL;
6043PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL;
6044PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
6045PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
6046PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL;
6047PFNGLDEPTHRANGEARRAYVPROC glad_glDepthRangeArrayv = NULL;
6048PFNGLDEPTHRANGEINDEXEDPROC glad_glDepthRangeIndexed = NULL;
6049PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL;
6050PFNGLDEPTHRANGEXOESPROC glad_glDepthRangexOES = NULL;
6051PFNGLDETACHOBJECTARBPROC glad_glDetachObjectARB = NULL;
6052PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
6053PFNGLDISABLEPROC glad_glDisable = NULL;
6054PFNGLDISABLEVERTEXARRAYATTRIBPROC glad_glDisableVertexArrayAttrib = NULL;
6055PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
6056PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glad_glDisableVertexAttribArrayARB = NULL;
6057PFNGLDISABLEIPROC glad_glDisablei = NULL;
6058PFNGLDISPATCHCOMPUTEPROC glad_glDispatchCompute = NULL;
6059PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC glad_glDispatchComputeGroupSizeARB = NULL;
6060PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_glDispatchComputeIndirect = NULL;
6061PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
6062PFNGLDRAWARRAYSINDIRECTPROC glad_glDrawArraysIndirect = NULL;
6063PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL;
6064PFNGLDRAWARRAYSINSTANCEDARBPROC glad_glDrawArraysInstancedARB = NULL;
6065PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_glDrawArraysInstancedBaseInstance = NULL;
6066PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT = NULL;
6067PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL;
6068PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL;
6069PFNGLDRAWBUFFERSARBPROC glad_glDrawBuffersARB = NULL;
6070PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
6071PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL;
6072PFNGLDRAWELEMENTSINDIRECTPROC glad_glDrawElementsIndirect = NULL;
6073PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL;
6074PFNGLDRAWELEMENTSINSTANCEDARBPROC glad_glDrawElementsInstancedARB = NULL;
6075PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_glDrawElementsInstancedBaseInstance = NULL;
6076PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL;
6077PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance = NULL;
6078PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT = NULL;
6079PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL;
6080PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL;
6081PFNGLDRAWTRANSFORMFEEDBACKPROC glad_glDrawTransformFeedback = NULL;
6082PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_glDrawTransformFeedbackInstanced = NULL;
6083PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_glDrawTransformFeedbackStream = NULL;
6084PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_glDrawTransformFeedbackStreamInstanced = NULL;
6085PFNGLENABLEPROC glad_glEnable = NULL;
6086PFNGLENABLEVERTEXARRAYATTRIBPROC glad_glEnableVertexArrayAttrib = NULL;
6087PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
6088PFNGLENABLEVERTEXATTRIBARRAYARBPROC glad_glEnableVertexAttribArrayARB = NULL;
6089PFNGLENABLEIPROC glad_glEnablei = NULL;
6090PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL;
6091PFNGLENDQUERYPROC glad_glEndQuery = NULL;
6092PFNGLENDQUERYARBPROC glad_glEndQueryARB = NULL;
6093PFNGLENDQUERYINDEXEDPROC glad_glEndQueryIndexed = NULL;
6094PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL;
6095PFNGLEVALCOORD1XOESPROC glad_glEvalCoord1xOES = NULL;
6096PFNGLEVALCOORD1XVOESPROC glad_glEvalCoord1xvOES = NULL;
6097PFNGLEVALCOORD2XOESPROC glad_glEvalCoord2xOES = NULL;
6098PFNGLEVALCOORD2XVOESPROC glad_glEvalCoord2xvOES = NULL;
6099PFNGLEVALUATEDEPTHVALUESARBPROC glad_glEvaluateDepthValuesARB = NULL;
6100PFNGLFEEDBACKBUFFERXOESPROC glad_glFeedbackBufferxOES = NULL;
6101PFNGLFENCESYNCPROC glad_glFenceSync = NULL;
6102PFNGLFINISHPROC glad_glFinish = NULL;
6103PFNGLFLUSHPROC glad_glFlush = NULL;
6104PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL;
6105PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_glFlushMappedNamedBufferRange = NULL;
6106PFNGLFOGCOORDPOINTEREXTPROC glad_glFogCoordPointerEXT = NULL;
6107PFNGLFOGCOORDDEXTPROC glad_glFogCoorddEXT = NULL;
6108PFNGLFOGCOORDDVEXTPROC glad_glFogCoorddvEXT = NULL;
6109PFNGLFOGCOORDFEXTPROC glad_glFogCoordfEXT = NULL;
6110PFNGLFOGCOORDFVEXTPROC glad_glFogCoordfvEXT = NULL;
6111PFNGLFOGXOESPROC glad_glFogxOES = NULL;
6112PFNGLFOGXVOESPROC glad_glFogxvOES = NULL;
6113PFNGLFRAMEBUFFERPARAMETERIPROC glad_glFramebufferParameteri = NULL;
6114PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
6115PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glad_glFramebufferRenderbufferEXT = NULL;
6116PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glFramebufferSampleLocationsfvARB = NULL;
6117PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL;
6118PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL;
6119PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glad_glFramebufferTexture1DEXT = NULL;
6120PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
6121PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glad_glFramebufferTexture2DEXT = NULL;
6122PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL;
6123PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glad_glFramebufferTexture3DEXT = NULL;
6124PFNGLFRAMEBUFFERTEXTUREARBPROC glad_glFramebufferTextureARB = NULL;
6125PFNGLFRAMEBUFFERTEXTUREFACEARBPROC glad_glFramebufferTextureFaceARB = NULL;
6126PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL;
6127PFNGLFRAMEBUFFERTEXTURELAYERARBPROC glad_glFramebufferTextureLayerARB = NULL;
6128PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
6129PFNGLFRUSTUMXOESPROC glad_glFrustumxOES = NULL;
6130PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
6131PFNGLGENBUFFERSARBPROC glad_glGenBuffersARB = NULL;
6132PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
6133PFNGLGENFRAMEBUFFERSEXTPROC glad_glGenFramebuffersEXT = NULL;
6134PFNGLGENPROGRAMPIPELINESPROC glad_glGenProgramPipelines = NULL;
6135PFNGLGENPROGRAMSARBPROC glad_glGenProgramsARB = NULL;
6136PFNGLGENQUERIESPROC glad_glGenQueries = NULL;
6137PFNGLGENQUERIESARBPROC glad_glGenQueriesARB = NULL;
6138PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
6139PFNGLGENRENDERBUFFERSEXTPROC glad_glGenRenderbuffersEXT = NULL;
6140PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL;
6141PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
6142PFNGLGENTRANSFORMFEEDBACKSPROC glad_glGenTransformFeedbacks = NULL;
6143PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL;
6144PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
6145PFNGLGENERATEMIPMAPEXTPROC glad_glGenerateMipmapEXT = NULL;
6146PFNGLGENERATETEXTUREMIPMAPPROC glad_glGenerateTextureMipmap = NULL;
6147PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_glGetActiveAtomicCounterBufferiv = NULL;
6148PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
6149PFNGLGETACTIVEATTRIBARBPROC glad_glGetActiveAttribARB = NULL;
6150PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName = NULL;
6151PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName = NULL;
6152PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv = NULL;
6153PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
6154PFNGLGETACTIVEUNIFORMARBPROC glad_glGetActiveUniformARB = NULL;
6155PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL;
6156PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL;
6157PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL;
6158PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL;
6159PFNGLGETATTACHEDOBJECTSARBPROC glad_glGetAttachedObjectsARB = NULL;
6160PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
6161PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
6162PFNGLGETATTRIBLOCATIONARBPROC glad_glGetAttribLocationARB = NULL;
6163PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL;
6164PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
6165PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL;
6166PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
6167PFNGLGETBUFFERPARAMETERIVARBPROC glad_glGetBufferParameterivARB = NULL;
6168PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL;
6169PFNGLGETBUFFERPOINTERVARBPROC glad_glGetBufferPointervARB = NULL;
6170PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL;
6171PFNGLGETBUFFERSUBDATAARBPROC glad_glGetBufferSubDataARB = NULL;
6172PFNGLGETCLIPPLANEXOESPROC glad_glGetClipPlanexOES = NULL;
6173PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL;
6174PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glad_glGetCompressedTexImageARB = NULL;
6175PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC glad_glGetCompressedTextureImage = NULL;
6176PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC glad_glGetCompressedTextureSubImage = NULL;
6177PFNGLGETCONVOLUTIONPARAMETERXVOESPROC glad_glGetConvolutionParameterxvOES = NULL;
6178PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL;
6179PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB = NULL;
6180PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v = NULL;
6181PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL;
6182PFNGLGETERRORPROC glad_glGetError = NULL;
6183PFNGLGETFIXEDVOESPROC glad_glGetFixedvOES = NULL;
6184PFNGLGETFLOATI_VPROC glad_glGetFloati_v = NULL;
6185PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
6186PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL;
6187PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL;
6188PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
6189PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glad_glGetFramebufferAttachmentParameterivEXT = NULL;
6190PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv = NULL;
6191PFNGLGETHANDLEARBPROC glad_glGetHandleARB = NULL;
6192PFNGLGETHISTOGRAMPARAMETERXVOESPROC glad_glGetHistogramParameterxvOES = NULL;
6193PFNGLGETINFOLOGARBPROC glad_glGetInfoLogARB = NULL;
6194PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL;
6195PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL;
6196PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL;
6197PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
6198PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v = NULL;
6199PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ = NULL;
6200PFNGLGETLIGHTXOESPROC glad_glGetLightxOES = NULL;
6201PFNGLGETMAPXVOESPROC glad_glGetMapxvOES = NULL;
6202PFNGLGETMATERIALXOESPROC glad_glGetMaterialxOES = NULL;
6203PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL;
6204PFNGLGETNAMEDBUFFERPARAMETERI64VPROC glad_glGetNamedBufferParameteri64v = NULL;
6205PFNGLGETNAMEDBUFFERPARAMETERIVPROC glad_glGetNamedBufferParameteriv = NULL;
6206PFNGLGETNAMEDBUFFERPOINTERVPROC glad_glGetNamedBufferPointerv = NULL;
6207PFNGLGETNAMEDBUFFERSUBDATAPROC glad_glGetNamedBufferSubData = NULL;
6208PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetNamedFramebufferAttachmentParameteriv = NULL;
6209PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC glad_glGetNamedFramebufferParameteriv = NULL;
6210PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC glad_glGetNamedRenderbufferParameteriv = NULL;
6211PFNGLGETNAMEDSTRINGARBPROC glad_glGetNamedStringARB = NULL;
6212PFNGLGETNAMEDSTRINGIVARBPROC glad_glGetNamedStringivARB = NULL;
6213PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL;
6214PFNGLGETOBJECTPARAMETERFVARBPROC glad_glGetObjectParameterfvARB = NULL;
6215PFNGLGETOBJECTPARAMETERIVARBPROC glad_glGetObjectParameterivARB = NULL;
6216PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL;
6217PFNGLGETPIXELMAPXVPROC glad_glGetPixelMapxv = NULL;
6218PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL;
6219PFNGLGETPROGRAMBINARYPROC glad_glGetProgramBinary = NULL;
6220PFNGLGETPROGRAMENVPARAMETERDVARBPROC glad_glGetProgramEnvParameterdvARB = NULL;
6221PFNGLGETPROGRAMENVPARAMETERFVARBPROC glad_glGetProgramEnvParameterfvARB = NULL;
6222PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
6223PFNGLGETPROGRAMINTERFACEIVPROC glad_glGetProgramInterfaceiv = NULL;
6224PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glad_glGetProgramLocalParameterdvARB = NULL;
6225PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glad_glGetProgramLocalParameterfvARB = NULL;
6226PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_glGetProgramPipelineInfoLog = NULL;
6227PFNGLGETPROGRAMPIPELINEIVPROC glad_glGetProgramPipelineiv = NULL;
6228PFNGLGETPROGRAMRESOURCEINDEXPROC glad_glGetProgramResourceIndex = NULL;
6229PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_glGetProgramResourceLocation = NULL;
6230PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_glGetProgramResourceLocationIndex = NULL;
6231PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName = NULL;
6232PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv = NULL;
6233PFNGLGETPROGRAMSTAGEIVPROC glad_glGetProgramStageiv = NULL;
6234PFNGLGETPROGRAMSTRINGARBPROC glad_glGetProgramStringARB = NULL;
6235PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
6236PFNGLGETPROGRAMIVARBPROC glad_glGetProgramivARB = NULL;
6237PFNGLGETQUERYBUFFEROBJECTI64VPROC glad_glGetQueryBufferObjecti64v = NULL;
6238PFNGLGETQUERYBUFFEROBJECTIVPROC glad_glGetQueryBufferObjectiv = NULL;
6239PFNGLGETQUERYBUFFEROBJECTUI64VPROC glad_glGetQueryBufferObjectui64v = NULL;
6240PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv = NULL;
6241PFNGLGETQUERYINDEXEDIVPROC glad_glGetQueryIndexediv = NULL;
6242PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL;
6243PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL;
6244PFNGLGETQUERYOBJECTIVARBPROC glad_glGetQueryObjectivARB = NULL;
6245PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL;
6246PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL;
6247PFNGLGETQUERYOBJECTUIVARBPROC glad_glGetQueryObjectuivARB = NULL;
6248PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL;
6249PFNGLGETQUERYIVARBPROC glad_glGetQueryivARB = NULL;
6250PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
6251PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glad_glGetRenderbufferParameterivEXT = NULL;
6252PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL;
6253PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL;
6254PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL;
6255PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL;
6256PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
6257PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL;
6258PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
6259PFNGLGETSHADERSOURCEARBPROC glad_glGetShaderSourceARB = NULL;
6260PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
6261PFNGLGETSTRINGPROC glad_glGetString = NULL;
6262PFNGLGETSTRINGIPROC glad_glGetStringi = NULL;
6263PFNGLGETSUBROUTINEINDEXPROC glad_glGetSubroutineIndex = NULL;
6264PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_glGetSubroutineUniformLocation = NULL;
6265PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL;
6266PFNGLGETTEXENVXVOESPROC glad_glGetTexEnvxvOES = NULL;
6267PFNGLGETTEXGENXVOESPROC glad_glGetTexGenxvOES = NULL;
6268PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL;
6269PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL;
6270PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL;
6271PFNGLGETTEXLEVELPARAMETERXVOESPROC glad_glGetTexLevelParameterxvOES = NULL;
6272PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL;
6273PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL;
6274PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
6275PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
6276PFNGLGETTEXPARAMETERXVOESPROC glad_glGetTexParameterxvOES = NULL;
6277PFNGLGETTEXTUREIMAGEPROC glad_glGetTextureImage = NULL;
6278PFNGLGETTEXTURELEVELPARAMETERFVPROC glad_glGetTextureLevelParameterfv = NULL;
6279PFNGLGETTEXTURELEVELPARAMETERIVPROC glad_glGetTextureLevelParameteriv = NULL;
6280PFNGLGETTEXTUREPARAMETERIIVPROC glad_glGetTextureParameterIiv = NULL;
6281PFNGLGETTEXTUREPARAMETERIUIVPROC glad_glGetTextureParameterIuiv = NULL;
6282PFNGLGETTEXTUREPARAMETERFVPROC glad_glGetTextureParameterfv = NULL;
6283PFNGLGETTEXTUREPARAMETERIVPROC glad_glGetTextureParameteriv = NULL;
6284PFNGLGETTEXTURESUBIMAGEPROC glad_glGetTextureSubImage = NULL;
6285PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL;
6286PFNGLGETTRANSFORMFEEDBACKI64_VPROC glad_glGetTransformFeedbacki64_v = NULL;
6287PFNGLGETTRANSFORMFEEDBACKI_VPROC glad_glGetTransformFeedbacki_v = NULL;
6288PFNGLGETTRANSFORMFEEDBACKIVPROC glad_glGetTransformFeedbackiv = NULL;
6289PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL;
6290PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL;
6291PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
6292PFNGLGETUNIFORMLOCATIONARBPROC glad_glGetUniformLocationARB = NULL;
6293PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_glGetUniformSubroutineuiv = NULL;
6294PFNGLGETUNIFORMDVPROC glad_glGetUniformdv = NULL;
6295PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
6296PFNGLGETUNIFORMFVARBPROC glad_glGetUniformfvARB = NULL;
6297PFNGLGETUNIFORMI64VARBPROC glad_glGetUniformi64vARB = NULL;
6298PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
6299PFNGLGETUNIFORMIVARBPROC glad_glGetUniformivARB = NULL;
6300PFNGLGETUNIFORMUI64VARBPROC glad_glGetUniformui64vARB = NULL;
6301PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL;
6302PFNGLGETVERTEXARRAYINDEXED64IVPROC glad_glGetVertexArrayIndexed64iv = NULL;
6303PFNGLGETVERTEXARRAYINDEXEDIVPROC glad_glGetVertexArrayIndexediv = NULL;
6304PFNGLGETVERTEXARRAYIVPROC glad_glGetVertexArrayiv = NULL;
6305PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL;
6306PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL;
6307PFNGLGETVERTEXATTRIBLDVPROC glad_glGetVertexAttribLdv = NULL;
6308PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
6309PFNGLGETVERTEXATTRIBPOINTERVARBPROC glad_glGetVertexAttribPointervARB = NULL;
6310PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL;
6311PFNGLGETVERTEXATTRIBDVARBPROC glad_glGetVertexAttribdvARB = NULL;
6312PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
6313PFNGLGETVERTEXATTRIBFVARBPROC glad_glGetVertexAttribfvARB = NULL;
6314PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
6315PFNGLGETVERTEXATTRIBIVARBPROC glad_glGetVertexAttribivARB = NULL;
6316PFNGLGETNUNIFORMI64VARBPROC glad_glGetnUniformi64vARB = NULL;
6317PFNGLGETNUNIFORMUI64VARBPROC glad_glGetnUniformui64vARB = NULL;
6318PFNGLHINTPROC glad_glHint = NULL;
6319PFNGLINDEXXOESPROC glad_glIndexxOES = NULL;
6320PFNGLINDEXXVOESPROC glad_glIndexxvOES = NULL;
6321PFNGLINVALIDATEBUFFERDATAPROC glad_glInvalidateBufferData = NULL;
6322PFNGLINVALIDATEBUFFERSUBDATAPROC glad_glInvalidateBufferSubData = NULL;
6323PFNGLINVALIDATEFRAMEBUFFERPROC glad_glInvalidateFramebuffer = NULL;
6324PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_glInvalidateNamedFramebufferData = NULL;
6325PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_glInvalidateNamedFramebufferSubData = NULL;
6326PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_glInvalidateSubFramebuffer = NULL;
6327PFNGLINVALIDATETEXIMAGEPROC glad_glInvalidateTexImage = NULL;
6328PFNGLINVALIDATETEXSUBIMAGEPROC glad_glInvalidateTexSubImage = NULL;
6329PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
6330PFNGLISBUFFERARBPROC glad_glIsBufferARB = NULL;
6331PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
6332PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL;
6333PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
6334PFNGLISFRAMEBUFFEREXTPROC glad_glIsFramebufferEXT = NULL;
6335PFNGLISNAMEDSTRINGARBPROC glad_glIsNamedStringARB = NULL;
6336PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
6337PFNGLISPROGRAMARBPROC glad_glIsProgramARB = NULL;
6338PFNGLISPROGRAMPIPELINEPROC glad_glIsProgramPipeline = NULL;
6339PFNGLISQUERYPROC glad_glIsQuery = NULL;
6340PFNGLISQUERYARBPROC glad_glIsQueryARB = NULL;
6341PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
6342PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT = NULL;
6343PFNGLISSAMPLERPROC glad_glIsSampler = NULL;
6344PFNGLISSHADERPROC glad_glIsShader = NULL;
6345PFNGLISSYNCPROC glad_glIsSync = NULL;
6346PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
6347PFNGLISTRANSFORMFEEDBACKPROC glad_glIsTransformFeedback = NULL;
6348PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL;
6349PFNGLLIGHTMODELXOESPROC glad_glLightModelxOES = NULL;
6350PFNGLLIGHTMODELXVOESPROC glad_glLightModelxvOES = NULL;
6351PFNGLLIGHTXOESPROC glad_glLightxOES = NULL;
6352PFNGLLIGHTXVOESPROC glad_glLightxvOES = NULL;
6353PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
6354PFNGLLINEWIDTHXOESPROC glad_glLineWidthxOES = NULL;
6355PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
6356PFNGLLINKPROGRAMARBPROC glad_glLinkProgramARB = NULL;
6357PFNGLLOADMATRIXXOESPROC glad_glLoadMatrixxOES = NULL;
6358PFNGLLOADTRANSPOSEMATRIXDARBPROC glad_glLoadTransposeMatrixdARB = NULL;
6359PFNGLLOADTRANSPOSEMATRIXFARBPROC glad_glLoadTransposeMatrixfARB = NULL;
6360PFNGLLOADTRANSPOSEMATRIXXOESPROC glad_glLoadTransposeMatrixxOES = NULL;
6361PFNGLLOGICOPPROC glad_glLogicOp = NULL;
6362PFNGLMAP1XOESPROC glad_glMap1xOES = NULL;
6363PFNGLMAP2XOESPROC glad_glMap2xOES = NULL;
6364PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL;
6365PFNGLMAPBUFFERARBPROC glad_glMapBufferARB = NULL;
6366PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL;
6367PFNGLMAPGRID1XOESPROC glad_glMapGrid1xOES = NULL;
6368PFNGLMAPGRID2XOESPROC glad_glMapGrid2xOES = NULL;
6369PFNGLMAPNAMEDBUFFERPROC glad_glMapNamedBuffer = NULL;
6370PFNGLMAPNAMEDBUFFERRANGEPROC glad_glMapNamedBufferRange = NULL;
6371PFNGLMATERIALXOESPROC glad_glMaterialxOES = NULL;
6372PFNGLMATERIALXVOESPROC glad_glMaterialxvOES = NULL;
6373PFNGLMEMORYBARRIERPROC glad_glMemoryBarrier = NULL;
6374PFNGLMEMORYBARRIERBYREGIONPROC glad_glMemoryBarrierByRegion = NULL;
6375PFNGLMINSAMPLESHADINGPROC glad_glMinSampleShading = NULL;
6376PFNGLMINSAMPLESHADINGARBPROC glad_glMinSampleShadingARB = NULL;
6377PFNGLMULTMATRIXXOESPROC glad_glMultMatrixxOES = NULL;
6378PFNGLMULTTRANSPOSEMATRIXDARBPROC glad_glMultTransposeMatrixdARB = NULL;
6379PFNGLMULTTRANSPOSEMATRIXFARBPROC glad_glMultTransposeMatrixfARB = NULL;
6380PFNGLMULTTRANSPOSEMATRIXXOESPROC glad_glMultTransposeMatrixxOES = NULL;
6381PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL;
6382PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_glMultiDrawArraysIndirect = NULL;
6383PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL;
6384PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL;
6385PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_glMultiDrawElementsIndirect = NULL;
6386PFNGLMULTITEXCOORD1DARBPROC glad_glMultiTexCoord1dARB = NULL;
6387PFNGLMULTITEXCOORD1DVARBPROC glad_glMultiTexCoord1dvARB = NULL;
6388PFNGLMULTITEXCOORD1FARBPROC glad_glMultiTexCoord1fARB = NULL;
6389PFNGLMULTITEXCOORD1FVARBPROC glad_glMultiTexCoord1fvARB = NULL;
6390PFNGLMULTITEXCOORD1IARBPROC glad_glMultiTexCoord1iARB = NULL;
6391PFNGLMULTITEXCOORD1IVARBPROC glad_glMultiTexCoord1ivARB = NULL;
6392PFNGLMULTITEXCOORD1SARBPROC glad_glMultiTexCoord1sARB = NULL;
6393PFNGLMULTITEXCOORD1SVARBPROC glad_glMultiTexCoord1svARB = NULL;
6394PFNGLMULTITEXCOORD1XOESPROC glad_glMultiTexCoord1xOES = NULL;
6395PFNGLMULTITEXCOORD1XVOESPROC glad_glMultiTexCoord1xvOES = NULL;
6396PFNGLMULTITEXCOORD2DARBPROC glad_glMultiTexCoord2dARB = NULL;
6397PFNGLMULTITEXCOORD2DVARBPROC glad_glMultiTexCoord2dvARB = NULL;
6398PFNGLMULTITEXCOORD2FARBPROC glad_glMultiTexCoord2fARB = NULL;
6399PFNGLMULTITEXCOORD2FVARBPROC glad_glMultiTexCoord2fvARB = NULL;
6400PFNGLMULTITEXCOORD2IARBPROC glad_glMultiTexCoord2iARB = NULL;
6401PFNGLMULTITEXCOORD2IVARBPROC glad_glMultiTexCoord2ivARB = NULL;
6402PFNGLMULTITEXCOORD2SARBPROC glad_glMultiTexCoord2sARB = NULL;
6403PFNGLMULTITEXCOORD2SVARBPROC glad_glMultiTexCoord2svARB = NULL;
6404PFNGLMULTITEXCOORD2XOESPROC glad_glMultiTexCoord2xOES = NULL;
6405PFNGLMULTITEXCOORD2XVOESPROC glad_glMultiTexCoord2xvOES = NULL;
6406PFNGLMULTITEXCOORD3DARBPROC glad_glMultiTexCoord3dARB = NULL;
6407PFNGLMULTITEXCOORD3DVARBPROC glad_glMultiTexCoord3dvARB = NULL;
6408PFNGLMULTITEXCOORD3FARBPROC glad_glMultiTexCoord3fARB = NULL;
6409PFNGLMULTITEXCOORD3FVARBPROC glad_glMultiTexCoord3fvARB = NULL;
6410PFNGLMULTITEXCOORD3IARBPROC glad_glMultiTexCoord3iARB = NULL;
6411PFNGLMULTITEXCOORD3IVARBPROC glad_glMultiTexCoord3ivARB = NULL;
6412PFNGLMULTITEXCOORD3SARBPROC glad_glMultiTexCoord3sARB = NULL;
6413PFNGLMULTITEXCOORD3SVARBPROC glad_glMultiTexCoord3svARB = NULL;
6414PFNGLMULTITEXCOORD3XOESPROC glad_glMultiTexCoord3xOES = NULL;
6415PFNGLMULTITEXCOORD3XVOESPROC glad_glMultiTexCoord3xvOES = NULL;
6416PFNGLMULTITEXCOORD4DARBPROC glad_glMultiTexCoord4dARB = NULL;
6417PFNGLMULTITEXCOORD4DVARBPROC glad_glMultiTexCoord4dvARB = NULL;
6418PFNGLMULTITEXCOORD4FARBPROC glad_glMultiTexCoord4fARB = NULL;
6419PFNGLMULTITEXCOORD4FVARBPROC glad_glMultiTexCoord4fvARB = NULL;
6420PFNGLMULTITEXCOORD4IARBPROC glad_glMultiTexCoord4iARB = NULL;
6421PFNGLMULTITEXCOORD4IVARBPROC glad_glMultiTexCoord4ivARB = NULL;
6422PFNGLMULTITEXCOORD4SARBPROC glad_glMultiTexCoord4sARB = NULL;
6423PFNGLMULTITEXCOORD4SVARBPROC glad_glMultiTexCoord4svARB = NULL;
6424PFNGLMULTITEXCOORD4XOESPROC glad_glMultiTexCoord4xOES = NULL;
6425PFNGLMULTITEXCOORD4XVOESPROC glad_glMultiTexCoord4xvOES = NULL;
6426PFNGLNAMEDBUFFERDATAPROC glad_glNamedBufferData = NULL;
6427PFNGLNAMEDBUFFERSTORAGEPROC glad_glNamedBufferStorage = NULL;
6428PFNGLNAMEDBUFFERSUBDATAPROC glad_glNamedBufferSubData = NULL;
6429PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC glad_glNamedFramebufferDrawBuffer = NULL;
6430PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glad_glNamedFramebufferDrawBuffers = NULL;
6431PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glad_glNamedFramebufferParameteri = NULL;
6432PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glad_glNamedFramebufferReadBuffer = NULL;
6433PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC glad_glNamedFramebufferRenderbuffer = NULL;
6434PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glNamedFramebufferSampleLocationsfvARB = NULL;
6435PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_glNamedFramebufferTexture = NULL;
6436PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_glNamedFramebufferTextureLayer = NULL;
6437PFNGLNAMEDRENDERBUFFERSTORAGEPROC glad_glNamedRenderbufferStorage = NULL;
6438PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glNamedRenderbufferStorageMultisample = NULL;
6439PFNGLNAMEDSTRINGARBPROC glad_glNamedStringARB = NULL;
6440PFNGLNORMAL3XOESPROC glad_glNormal3xOES = NULL;
6441PFNGLNORMAL3XVOESPROC glad_glNormal3xvOES = NULL;
6442PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL;
6443PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL;
6444PFNGLORTHOXOESPROC glad_glOrthoxOES = NULL;
6445PFNGLPASSTHROUGHXOESPROC glad_glPassThroughxOES = NULL;
6446PFNGLPATCHPARAMETERFVPROC glad_glPatchParameterfv = NULL;
6447PFNGLPATCHPARAMETERIPROC glad_glPatchParameteri = NULL;
6448PFNGLPAUSETRANSFORMFEEDBACKPROC glad_glPauseTransformFeedback = NULL;
6449PFNGLPIXELMAPXPROC glad_glPixelMapx = NULL;
6450PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL;
6451PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
6452PFNGLPIXELSTOREXPROC glad_glPixelStorex = NULL;
6453PFNGLPIXELTRANSFERXOESPROC glad_glPixelTransferxOES = NULL;
6454PFNGLPIXELZOOMXOESPROC glad_glPixelZoomxOES = NULL;
6455PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL;
6456PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL;
6457PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL;
6458PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL;
6459PFNGLPOINTPARAMETERXVOESPROC glad_glPointParameterxvOES = NULL;
6460PFNGLPOINTSIZEPROC glad_glPointSize = NULL;
6461PFNGLPOINTSIZEXOESPROC glad_glPointSizexOES = NULL;
6462PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL;
6463PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
6464PFNGLPOLYGONOFFSETXOESPROC glad_glPolygonOffsetxOES = NULL;
6465PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL;
6466PFNGLPRIMITIVEBOUNDINGBOXARBPROC glad_glPrimitiveBoundingBoxARB = NULL;
6467PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL;
6468PFNGLPRIORITIZETEXTURESXOESPROC glad_glPrioritizeTexturesxOES = NULL;
6469PFNGLPROGRAMBINARYPROC glad_glProgramBinary = NULL;
6470PFNGLPROGRAMENVPARAMETER4DARBPROC glad_glProgramEnvParameter4dARB = NULL;
6471PFNGLPROGRAMENVPARAMETER4DVARBPROC glad_glProgramEnvParameter4dvARB = NULL;
6472PFNGLPROGRAMENVPARAMETER4FARBPROC glad_glProgramEnvParameter4fARB = NULL;
6473PFNGLPROGRAMENVPARAMETER4FVARBPROC glad_glProgramEnvParameter4fvARB = NULL;
6474PFNGLPROGRAMLOCALPARAMETER4DARBPROC glad_glProgramLocalParameter4dARB = NULL;
6475PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glad_glProgramLocalParameter4dvARB = NULL;
6476PFNGLPROGRAMLOCALPARAMETER4FARBPROC glad_glProgramLocalParameter4fARB = NULL;
6477PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glad_glProgramLocalParameter4fvARB = NULL;
6478PFNGLPROGRAMPARAMETERIPROC glad_glProgramParameteri = NULL;
6479PFNGLPROGRAMPARAMETERIARBPROC glad_glProgramParameteriARB = NULL;
6480PFNGLPROGRAMSTRINGARBPROC glad_glProgramStringARB = NULL;
6481PFNGLPROGRAMUNIFORM1DPROC glad_glProgramUniform1d = NULL;
6482PFNGLPROGRAMUNIFORM1DVPROC glad_glProgramUniform1dv = NULL;
6483PFNGLPROGRAMUNIFORM1FPROC glad_glProgramUniform1f = NULL;
6484PFNGLPROGRAMUNIFORM1FVPROC glad_glProgramUniform1fv = NULL;
6485PFNGLPROGRAMUNIFORM1IPROC glad_glProgramUniform1i = NULL;
6486PFNGLPROGRAMUNIFORM1I64ARBPROC glad_glProgramUniform1i64ARB = NULL;
6487PFNGLPROGRAMUNIFORM1I64VARBPROC glad_glProgramUniform1i64vARB = NULL;
6488PFNGLPROGRAMUNIFORM1IVPROC glad_glProgramUniform1iv = NULL;
6489PFNGLPROGRAMUNIFORM1UIPROC glad_glProgramUniform1ui = NULL;
6490PFNGLPROGRAMUNIFORM1UI64ARBPROC glad_glProgramUniform1ui64ARB = NULL;
6491PFNGLPROGRAMUNIFORM1UI64VARBPROC glad_glProgramUniform1ui64vARB = NULL;
6492PFNGLPROGRAMUNIFORM1UIVPROC glad_glProgramUniform1uiv = NULL;
6493PFNGLPROGRAMUNIFORM2DPROC glad_glProgramUniform2d = NULL;
6494PFNGLPROGRAMUNIFORM2DVPROC glad_glProgramUniform2dv = NULL;
6495PFNGLPROGRAMUNIFORM2FPROC glad_glProgramUniform2f = NULL;
6496PFNGLPROGRAMUNIFORM2FVPROC glad_glProgramUniform2fv = NULL;
6497PFNGLPROGRAMUNIFORM2IPROC glad_glProgramUniform2i = NULL;
6498PFNGLPROGRAMUNIFORM2I64ARBPROC glad_glProgramUniform2i64ARB = NULL;
6499PFNGLPROGRAMUNIFORM2I64VARBPROC glad_glProgramUniform2i64vARB = NULL;
6500PFNGLPROGRAMUNIFORM2IVPROC glad_glProgramUniform2iv = NULL;
6501PFNGLPROGRAMUNIFORM2UIPROC glad_glProgramUniform2ui = NULL;
6502PFNGLPROGRAMUNIFORM2UI64ARBPROC glad_glProgramUniform2ui64ARB = NULL;
6503PFNGLPROGRAMUNIFORM2UI64VARBPROC glad_glProgramUniform2ui64vARB = NULL;
6504PFNGLPROGRAMUNIFORM2UIVPROC glad_glProgramUniform2uiv = NULL;
6505PFNGLPROGRAMUNIFORM3DPROC glad_glProgramUniform3d = NULL;
6506PFNGLPROGRAMUNIFORM3DVPROC glad_glProgramUniform3dv = NULL;
6507PFNGLPROGRAMUNIFORM3FPROC glad_glProgramUniform3f = NULL;
6508PFNGLPROGRAMUNIFORM3FVPROC glad_glProgramUniform3fv = NULL;
6509PFNGLPROGRAMUNIFORM3IPROC glad_glProgramUniform3i = NULL;
6510PFNGLPROGRAMUNIFORM3I64ARBPROC glad_glProgramUniform3i64ARB = NULL;
6511PFNGLPROGRAMUNIFORM3I64VARBPROC glad_glProgramUniform3i64vARB = NULL;
6512PFNGLPROGRAMUNIFORM3IVPROC glad_glProgramUniform3iv = NULL;
6513PFNGLPROGRAMUNIFORM3UIPROC glad_glProgramUniform3ui = NULL;
6514PFNGLPROGRAMUNIFORM3UI64ARBPROC glad_glProgramUniform3ui64ARB = NULL;
6515PFNGLPROGRAMUNIFORM3UI64VARBPROC glad_glProgramUniform3ui64vARB = NULL;
6516PFNGLPROGRAMUNIFORM3UIVPROC glad_glProgramUniform3uiv = NULL;
6517PFNGLPROGRAMUNIFORM4DPROC glad_glProgramUniform4d = NULL;
6518PFNGLPROGRAMUNIFORM4DVPROC glad_glProgramUniform4dv = NULL;
6519PFNGLPROGRAMUNIFORM4FPROC glad_glProgramUniform4f = NULL;
6520PFNGLPROGRAMUNIFORM4FVPROC glad_glProgramUniform4fv = NULL;
6521PFNGLPROGRAMUNIFORM4IPROC glad_glProgramUniform4i = NULL;
6522PFNGLPROGRAMUNIFORM4I64ARBPROC glad_glProgramUniform4i64ARB = NULL;
6523PFNGLPROGRAMUNIFORM4I64VARBPROC glad_glProgramUniform4i64vARB = NULL;
6524PFNGLPROGRAMUNIFORM4IVPROC glad_glProgramUniform4iv = NULL;
6525PFNGLPROGRAMUNIFORM4UIPROC glad_glProgramUniform4ui = NULL;
6526PFNGLPROGRAMUNIFORM4UI64ARBPROC glad_glProgramUniform4ui64ARB = NULL;
6527PFNGLPROGRAMUNIFORM4UI64VARBPROC glad_glProgramUniform4ui64vARB = NULL;
6528PFNGLPROGRAMUNIFORM4UIVPROC glad_glProgramUniform4uiv = NULL;
6529PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_glProgramUniformMatrix2dv = NULL;
6530PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_glProgramUniformMatrix2fv = NULL;
6531PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_glProgramUniformMatrix2x3dv = NULL;
6532PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_glProgramUniformMatrix2x3fv = NULL;
6533PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_glProgramUniformMatrix2x4dv = NULL;
6534PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_glProgramUniformMatrix2x4fv = NULL;
6535PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_glProgramUniformMatrix3dv = NULL;
6536PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_glProgramUniformMatrix3fv = NULL;
6537PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_glProgramUniformMatrix3x2dv = NULL;
6538PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_glProgramUniformMatrix3x2fv = NULL;
6539PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_glProgramUniformMatrix3x4dv = NULL;
6540PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_glProgramUniformMatrix3x4fv = NULL;
6541PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_glProgramUniformMatrix4dv = NULL;
6542PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_glProgramUniformMatrix4fv = NULL;
6543PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_glProgramUniformMatrix4x2dv = NULL;
6544PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_glProgramUniformMatrix4x2fv = NULL;
6545PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_glProgramUniformMatrix4x3dv = NULL;
6546PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_glProgramUniformMatrix4x3fv = NULL;
6547PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL;
6548PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL;
6549PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL;
6550PFNGLRASTERPOS2XOESPROC glad_glRasterPos2xOES = NULL;
6551PFNGLRASTERPOS2XVOESPROC glad_glRasterPos2xvOES = NULL;
6552PFNGLRASTERPOS3XOESPROC glad_glRasterPos3xOES = NULL;
6553PFNGLRASTERPOS3XVOESPROC glad_glRasterPos3xvOES = NULL;
6554PFNGLRASTERPOS4XOESPROC glad_glRasterPos4xOES = NULL;
6555PFNGLRASTERPOS4XVOESPROC glad_glRasterPos4xvOES = NULL;
6556PFNGLREADBUFFERPROC glad_glReadBuffer = NULL;
6557PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
6558PFNGLRECTXOESPROC glad_glRectxOES = NULL;
6559PFNGLRECTXVOESPROC glad_glRectxvOES = NULL;
6560PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL;
6561PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
6562PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT = NULL;
6563PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
6564PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT = NULL;
6565PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback = NULL;
6566PFNGLROTATEXOESPROC glad_glRotatexOES = NULL;
6567PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
6568PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB = NULL;
6569PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL;
6570PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL;
6571PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL;
6572PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL;
6573PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL;
6574PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL;
6575PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL;
6576PFNGLSCALEXOESPROC glad_glScalexOES = NULL;
6577PFNGLSCISSORPROC glad_glScissor = NULL;
6578PFNGLSCISSORARRAYVPROC glad_glScissorArrayv = NULL;
6579PFNGLSCISSORINDEXEDPROC glad_glScissorIndexed = NULL;
6580PFNGLSCISSORINDEXEDVPROC glad_glScissorIndexedv = NULL;
6581PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL;
6582PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
6583PFNGLSHADERSOURCEARBPROC glad_glShaderSourceARB = NULL;
6584PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_glShaderStorageBlockBinding = NULL;
6585PFNGLSPECIALIZESHADERARBPROC glad_glSpecializeShaderARB = NULL;
6586PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
6587PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
6588PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
6589PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
6590PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
6591PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
6592PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL;
6593PFNGLTEXBUFFERRANGEPROC glad_glTexBufferRange = NULL;
6594PFNGLTEXCOORD1XOESPROC glad_glTexCoord1xOES = NULL;
6595PFNGLTEXCOORD1XVOESPROC glad_glTexCoord1xvOES = NULL;
6596PFNGLTEXCOORD2XOESPROC glad_glTexCoord2xOES = NULL;
6597PFNGLTEXCOORD2XVOESPROC glad_glTexCoord2xvOES = NULL;
6598PFNGLTEXCOORD3XOESPROC glad_glTexCoord3xOES = NULL;
6599PFNGLTEXCOORD3XVOESPROC glad_glTexCoord3xvOES = NULL;
6600PFNGLTEXCOORD4XOESPROC glad_glTexCoord4xOES = NULL;
6601PFNGLTEXCOORD4XVOESPROC glad_glTexCoord4xvOES = NULL;
6602PFNGLTEXENVXOESPROC glad_glTexEnvxOES = NULL;
6603PFNGLTEXENVXVOESPROC glad_glTexEnvxvOES = NULL;
6604PFNGLTEXGENXOESPROC glad_glTexGenxOES = NULL;
6605PFNGLTEXGENXVOESPROC glad_glTexGenxvOES = NULL;
6606PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL;
6607PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
6608PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL;
6609PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL;
6610PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL;
6611PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL;
6612PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL;
6613PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
6614PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
6615PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
6616PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
6617PFNGLTEXPARAMETERXOESPROC glad_glTexParameterxOES = NULL;
6618PFNGLTEXPARAMETERXVOESPROC glad_glTexParameterxvOES = NULL;
6619PFNGLTEXSTORAGE1DPROC glad_glTexStorage1D = NULL;
6620PFNGLTEXSTORAGE2DPROC glad_glTexStorage2D = NULL;
6621PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_glTexStorage2DMultisample = NULL;
6622PFNGLTEXSTORAGE3DPROC glad_glTexStorage3D = NULL;
6623PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample = NULL;
6624PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL;
6625PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
6626PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL;
6627PFNGLTEXTUREBUFFERPROC glad_glTextureBuffer = NULL;
6628PFNGLTEXTUREBUFFERRANGEPROC glad_glTextureBufferRange = NULL;
6629PFNGLTEXTUREPARAMETERIIVPROC glad_glTextureParameterIiv = NULL;
6630PFNGLTEXTUREPARAMETERIUIVPROC glad_glTextureParameterIuiv = NULL;
6631PFNGLTEXTUREPARAMETERFPROC glad_glTextureParameterf = NULL;
6632PFNGLTEXTUREPARAMETERFVPROC glad_glTextureParameterfv = NULL;
6633PFNGLTEXTUREPARAMETERIPROC glad_glTextureParameteri = NULL;
6634PFNGLTEXTUREPARAMETERIVPROC glad_glTextureParameteriv = NULL;
6635PFNGLTEXTURESTORAGE1DPROC glad_glTextureStorage1D = NULL;
6636PFNGLTEXTURESTORAGE2DPROC glad_glTextureStorage2D = NULL;
6637PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC glad_glTextureStorage2DMultisample = NULL;
6638PFNGLTEXTURESTORAGE3DPROC glad_glTextureStorage3D = NULL;
6639PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC glad_glTextureStorage3DMultisample = NULL;
6640PFNGLTEXTURESUBIMAGE1DPROC glad_glTextureSubImage1D = NULL;
6641PFNGLTEXTURESUBIMAGE2DPROC glad_glTextureSubImage2D = NULL;
6642PFNGLTEXTURESUBIMAGE3DPROC glad_glTextureSubImage3D = NULL;
6643PFNGLTEXTUREVIEWPROC glad_glTextureView = NULL;
6644PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC glad_glTransformFeedbackBufferBase = NULL;
6645PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC glad_glTransformFeedbackBufferRange = NULL;
6646PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL;
6647PFNGLTRANSLATEXOESPROC glad_glTranslatexOES = NULL;
6648PFNGLUNIFORM1DPROC glad_glUniform1d = NULL;
6649PFNGLUNIFORM1DVPROC glad_glUniform1dv = NULL;
6650PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
6651PFNGLUNIFORM1FARBPROC glad_glUniform1fARB = NULL;
6652PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
6653PFNGLUNIFORM1FVARBPROC glad_glUniform1fvARB = NULL;
6654PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
6655PFNGLUNIFORM1I64ARBPROC glad_glUniform1i64ARB = NULL;
6656PFNGLUNIFORM1I64VARBPROC glad_glUniform1i64vARB = NULL;
6657PFNGLUNIFORM1IARBPROC glad_glUniform1iARB = NULL;
6658PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
6659PFNGLUNIFORM1IVARBPROC glad_glUniform1ivARB = NULL;
6660PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL;
6661PFNGLUNIFORM1UI64ARBPROC glad_glUniform1ui64ARB = NULL;
6662PFNGLUNIFORM1UI64VARBPROC glad_glUniform1ui64vARB = NULL;
6663PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL;
6664PFNGLUNIFORM2DPROC glad_glUniform2d = NULL;
6665PFNGLUNIFORM2DVPROC glad_glUniform2dv = NULL;
6666PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
6667PFNGLUNIFORM2FARBPROC glad_glUniform2fARB = NULL;
6668PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
6669PFNGLUNIFORM2FVARBPROC glad_glUniform2fvARB = NULL;
6670PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
6671PFNGLUNIFORM2I64ARBPROC glad_glUniform2i64ARB = NULL;
6672PFNGLUNIFORM2I64VARBPROC glad_glUniform2i64vARB = NULL;
6673PFNGLUNIFORM2IARBPROC glad_glUniform2iARB = NULL;
6674PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
6675PFNGLUNIFORM2IVARBPROC glad_glUniform2ivARB = NULL;
6676PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL;
6677PFNGLUNIFORM2UI64ARBPROC glad_glUniform2ui64ARB = NULL;
6678PFNGLUNIFORM2UI64VARBPROC glad_glUniform2ui64vARB = NULL;
6679PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL;
6680PFNGLUNIFORM3DPROC glad_glUniform3d = NULL;
6681PFNGLUNIFORM3DVPROC glad_glUniform3dv = NULL;
6682PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
6683PFNGLUNIFORM3FARBPROC glad_glUniform3fARB = NULL;
6684PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
6685PFNGLUNIFORM3FVARBPROC glad_glUniform3fvARB = NULL;
6686PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
6687PFNGLUNIFORM3I64ARBPROC glad_glUniform3i64ARB = NULL;
6688PFNGLUNIFORM3I64VARBPROC glad_glUniform3i64vARB = NULL;
6689PFNGLUNIFORM3IARBPROC glad_glUniform3iARB = NULL;
6690PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
6691PFNGLUNIFORM3IVARBPROC glad_glUniform3ivARB = NULL;
6692PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL;
6693PFNGLUNIFORM3UI64ARBPROC glad_glUniform3ui64ARB = NULL;
6694PFNGLUNIFORM3UI64VARBPROC glad_glUniform3ui64vARB = NULL;
6695PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL;
6696PFNGLUNIFORM4DPROC glad_glUniform4d = NULL;
6697PFNGLUNIFORM4DVPROC glad_glUniform4dv = NULL;
6698PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
6699PFNGLUNIFORM4FARBPROC glad_glUniform4fARB = NULL;
6700PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
6701PFNGLUNIFORM4FVARBPROC glad_glUniform4fvARB = NULL;
6702PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
6703PFNGLUNIFORM4I64ARBPROC glad_glUniform4i64ARB = NULL;
6704PFNGLUNIFORM4I64VARBPROC glad_glUniform4i64vARB = NULL;
6705PFNGLUNIFORM4IARBPROC glad_glUniform4iARB = NULL;
6706PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
6707PFNGLUNIFORM4IVARBPROC glad_glUniform4ivARB = NULL;
6708PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL;
6709PFNGLUNIFORM4UI64ARBPROC glad_glUniform4ui64ARB = NULL;
6710PFNGLUNIFORM4UI64VARBPROC glad_glUniform4ui64vARB = NULL;
6711PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL;
6712PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL;
6713PFNGLUNIFORMMATRIX2DVPROC glad_glUniformMatrix2dv = NULL;
6714PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
6715PFNGLUNIFORMMATRIX2FVARBPROC glad_glUniformMatrix2fvARB = NULL;
6716PFNGLUNIFORMMATRIX2X3DVPROC glad_glUniformMatrix2x3dv = NULL;
6717PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL;
6718PFNGLUNIFORMMATRIX2X4DVPROC glad_glUniformMatrix2x4dv = NULL;
6719PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL;
6720PFNGLUNIFORMMATRIX3DVPROC glad_glUniformMatrix3dv = NULL;
6721PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
6722PFNGLUNIFORMMATRIX3FVARBPROC glad_glUniformMatrix3fvARB = NULL;
6723PFNGLUNIFORMMATRIX3X2DVPROC glad_glUniformMatrix3x2dv = NULL;
6724PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL;
6725PFNGLUNIFORMMATRIX3X4DVPROC glad_glUniformMatrix3x4dv = NULL;
6726PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL;
6727PFNGLUNIFORMMATRIX4DVPROC glad_glUniformMatrix4dv = NULL;
6728PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
6729PFNGLUNIFORMMATRIX4FVARBPROC glad_glUniformMatrix4fvARB = NULL;
6730PFNGLUNIFORMMATRIX4X2DVPROC glad_glUniformMatrix4x2dv = NULL;
6731PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL;
6732PFNGLUNIFORMMATRIX4X3DVPROC glad_glUniformMatrix4x3dv = NULL;
6733PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL;
6734PFNGLUNIFORMSUBROUTINESUIVPROC glad_glUniformSubroutinesuiv = NULL;
6735PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL;
6736PFNGLUNMAPBUFFERARBPROC glad_glUnmapBufferARB = NULL;
6737PFNGLUNMAPNAMEDBUFFERPROC glad_glUnmapNamedBuffer = NULL;
6738PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
6739PFNGLUSEPROGRAMOBJECTARBPROC glad_glUseProgramObjectARB = NULL;
6740PFNGLUSEPROGRAMSTAGESPROC glad_glUseProgramStages = NULL;
6741PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
6742PFNGLVALIDATEPROGRAMARBPROC glad_glValidateProgramARB = NULL;
6743PFNGLVALIDATEPROGRAMPIPELINEPROC glad_glValidateProgramPipeline = NULL;
6744PFNGLVERTEX2XOESPROC glad_glVertex2xOES = NULL;
6745PFNGLVERTEX2XVOESPROC glad_glVertex2xvOES = NULL;
6746PFNGLVERTEX3XOESPROC glad_glVertex3xOES = NULL;
6747PFNGLVERTEX3XVOESPROC glad_glVertex3xvOES = NULL;
6748PFNGLVERTEX4XOESPROC glad_glVertex4xOES = NULL;
6749PFNGLVERTEX4XVOESPROC glad_glVertex4xvOES = NULL;
6750PFNGLVERTEXARRAYATTRIBBINDINGPROC glad_glVertexArrayAttribBinding = NULL;
6751PFNGLVERTEXARRAYATTRIBFORMATPROC glad_glVertexArrayAttribFormat = NULL;
6752PFNGLVERTEXARRAYATTRIBIFORMATPROC glad_glVertexArrayAttribIFormat = NULL;
6753PFNGLVERTEXARRAYATTRIBLFORMATPROC glad_glVertexArrayAttribLFormat = NULL;
6754PFNGLVERTEXARRAYBINDINGDIVISORPROC glad_glVertexArrayBindingDivisor = NULL;
6755PFNGLVERTEXARRAYELEMENTBUFFERPROC glad_glVertexArrayElementBuffer = NULL;
6756PFNGLVERTEXARRAYVERTEXBUFFERPROC glad_glVertexArrayVertexBuffer = NULL;
6757PFNGLVERTEXARRAYVERTEXBUFFERSPROC glad_glVertexArrayVertexBuffers = NULL;
6758PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL;
6759PFNGLVERTEXATTRIB1DARBPROC glad_glVertexAttrib1dARB = NULL;
6760PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL;
6761PFNGLVERTEXATTRIB1DVARBPROC glad_glVertexAttrib1dvARB = NULL;
6762PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
6763PFNGLVERTEXATTRIB1FARBPROC glad_glVertexAttrib1fARB = NULL;
6764PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
6765PFNGLVERTEXATTRIB1FVARBPROC glad_glVertexAttrib1fvARB = NULL;
6766PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL;
6767PFNGLVERTEXATTRIB1SARBPROC glad_glVertexAttrib1sARB = NULL;
6768PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL;
6769PFNGLVERTEXATTRIB1SVARBPROC glad_glVertexAttrib1svARB = NULL;
6770PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL;
6771PFNGLVERTEXATTRIB2DARBPROC glad_glVertexAttrib2dARB = NULL;
6772PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL;
6773PFNGLVERTEXATTRIB2DVARBPROC glad_glVertexAttrib2dvARB = NULL;
6774PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
6775PFNGLVERTEXATTRIB2FARBPROC glad_glVertexAttrib2fARB = NULL;
6776PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
6777PFNGLVERTEXATTRIB2FVARBPROC glad_glVertexAttrib2fvARB = NULL;
6778PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL;
6779PFNGLVERTEXATTRIB2SARBPROC glad_glVertexAttrib2sARB = NULL;
6780PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL;
6781PFNGLVERTEXATTRIB2SVARBPROC glad_glVertexAttrib2svARB = NULL;
6782PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL;
6783PFNGLVERTEXATTRIB3DARBPROC glad_glVertexAttrib3dARB = NULL;
6784PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL;
6785PFNGLVERTEXATTRIB3DVARBPROC glad_glVertexAttrib3dvARB = NULL;
6786PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
6787PFNGLVERTEXATTRIB3FARBPROC glad_glVertexAttrib3fARB = NULL;
6788PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
6789PFNGLVERTEXATTRIB3FVARBPROC glad_glVertexAttrib3fvARB = NULL;
6790PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL;
6791PFNGLVERTEXATTRIB3SARBPROC glad_glVertexAttrib3sARB = NULL;
6792PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL;
6793PFNGLVERTEXATTRIB3SVARBPROC glad_glVertexAttrib3svARB = NULL;
6794PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL;
6795PFNGLVERTEXATTRIB4NBVARBPROC glad_glVertexAttrib4NbvARB = NULL;
6796PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL;
6797PFNGLVERTEXATTRIB4NIVARBPROC glad_glVertexAttrib4NivARB = NULL;
6798PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL;
6799PFNGLVERTEXATTRIB4NSVARBPROC glad_glVertexAttrib4NsvARB = NULL;
6800PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL;
6801PFNGLVERTEXATTRIB4NUBARBPROC glad_glVertexAttrib4NubARB = NULL;
6802PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL;
6803PFNGLVERTEXATTRIB4NUBVARBPROC glad_glVertexAttrib4NubvARB = NULL;
6804PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL;
6805PFNGLVERTEXATTRIB4NUIVARBPROC glad_glVertexAttrib4NuivARB = NULL;
6806PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL;
6807PFNGLVERTEXATTRIB4NUSVARBPROC glad_glVertexAttrib4NusvARB = NULL;
6808PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL;
6809PFNGLVERTEXATTRIB4BVARBPROC glad_glVertexAttrib4bvARB = NULL;
6810PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL;
6811PFNGLVERTEXATTRIB4DARBPROC glad_glVertexAttrib4dARB = NULL;
6812PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL;
6813PFNGLVERTEXATTRIB4DVARBPROC glad_glVertexAttrib4dvARB = NULL;
6814PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
6815PFNGLVERTEXATTRIB4FARBPROC glad_glVertexAttrib4fARB = NULL;
6816PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
6817PFNGLVERTEXATTRIB4FVARBPROC glad_glVertexAttrib4fvARB = NULL;
6818PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL;
6819PFNGLVERTEXATTRIB4IVARBPROC glad_glVertexAttrib4ivARB = NULL;
6820PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL;
6821PFNGLVERTEXATTRIB4SARBPROC glad_glVertexAttrib4sARB = NULL;
6822PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL;
6823PFNGLVERTEXATTRIB4SVARBPROC glad_glVertexAttrib4svARB = NULL;
6824PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL;
6825PFNGLVERTEXATTRIB4UBVARBPROC glad_glVertexAttrib4ubvARB = NULL;
6826PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL;
6827PFNGLVERTEXATTRIB4UIVARBPROC glad_glVertexAttrib4uivARB = NULL;
6828PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL;
6829PFNGLVERTEXATTRIB4USVARBPROC glad_glVertexAttrib4usvARB = NULL;
6830PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding = NULL;
6831PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL;
6832PFNGLVERTEXATTRIBDIVISORARBPROC glad_glVertexAttribDivisorARB = NULL;
6833PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat = NULL;
6834PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL;
6835PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL;
6836PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL;
6837PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL;
6838PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL;
6839PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL;
6840PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL;
6841PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL;
6842PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL;
6843PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL;
6844PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL;
6845PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL;
6846PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL;
6847PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL;
6848PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL;
6849PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL;
6850PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL;
6851PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL;
6852PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL;
6853PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL;
6854PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat = NULL;
6855PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL;
6856PFNGLVERTEXATTRIBL1DPROC glad_glVertexAttribL1d = NULL;
6857PFNGLVERTEXATTRIBL1DVPROC glad_glVertexAttribL1dv = NULL;
6858PFNGLVERTEXATTRIBL2DPROC glad_glVertexAttribL2d = NULL;
6859PFNGLVERTEXATTRIBL2DVPROC glad_glVertexAttribL2dv = NULL;
6860PFNGLVERTEXATTRIBL3DPROC glad_glVertexAttribL3d = NULL;
6861PFNGLVERTEXATTRIBL3DVPROC glad_glVertexAttribL3dv = NULL;
6862PFNGLVERTEXATTRIBL4DPROC glad_glVertexAttribL4d = NULL;
6863PFNGLVERTEXATTRIBL4DVPROC glad_glVertexAttribL4dv = NULL;
6864PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat = NULL;
6865PFNGLVERTEXATTRIBLPOINTERPROC glad_glVertexAttribLPointer = NULL;
6866PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL;
6867PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL;
6868PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL;
6869PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL;
6870PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL;
6871PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL;
6872PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL;
6873PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL;
6874PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
6875PFNGLVERTEXATTRIBPOINTERARBPROC glad_glVertexAttribPointerARB = NULL;
6876PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor = NULL;
6877PFNGLVIEWPORTPROC glad_glViewport = NULL;
6878PFNGLVIEWPORTARRAYVPROC glad_glViewportArrayv = NULL;
6879PFNGLVIEWPORTINDEXEDFPROC glad_glViewportIndexedf = NULL;
6880PFNGLVIEWPORTINDEXEDFVPROC glad_glViewportIndexedfv = NULL;
6881PFNGLWAITSYNCPROC glad_glWaitSync = NULL;
6882
6883
6884static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
6885 if(!GLAD_GL_VERSION_1_0) return;
6886 glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
6887 glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
6888 glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
6889 glad_glClearDepth = (PFNGLCLEARDEPTHPROC) load(userptr, "glClearDepth");
6890 glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
6891 glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
6892 glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
6893 glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
6894 glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
6895 glad_glDepthRange = (PFNGLDEPTHRANGEPROC) load(userptr, "glDepthRange");
6896 glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
6897 glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC) load(userptr, "glDrawBuffer");
6898 glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
6899 glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
6900 glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
6901 glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
6902 glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
6903 glad_glGetDoublev = (PFNGLGETDOUBLEVPROC) load(userptr, "glGetDoublev");
6904 glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
6905 glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
6906 glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
6907 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
6908 glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC) load(userptr, "glGetTexImage");
6909 glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load(userptr, "glGetTexLevelParameterfv");
6910 glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load(userptr, "glGetTexLevelParameteriv");
6911 glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
6912 glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
6913 glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
6914 glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
6915 glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
6916 glad_glLogicOp = (PFNGLLOGICOPPROC) load(userptr, "glLogicOp");
6917 glad_glPixelStoref = (PFNGLPIXELSTOREFPROC) load(userptr, "glPixelStoref");
6918 glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
6919 glad_glPointSize = (PFNGLPOINTSIZEPROC) load(userptr, "glPointSize");
6920 glad_glPolygonMode = (PFNGLPOLYGONMODEPROC) load(userptr, "glPolygonMode");
6921 glad_glReadBuffer = (PFNGLREADBUFFERPROC) load(userptr, "glReadBuffer");
6922 glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
6923 glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
6924 glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
6925 glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
6926 glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
6927 glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC) load(userptr, "glTexImage1D");
6928 glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
6929 glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
6930 glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
6931 glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
6932 glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
6933 glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
6934}
6935static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
6936 if(!GLAD_GL_VERSION_1_1) return;
6937 glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
6938 glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load(userptr, "glCopyTexImage1D");
6939 glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
6940 glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load(userptr, "glCopyTexSubImage1D");
6941 glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
6942 glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
6943 glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
6944 glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
6945 glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
6946 glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv");
6947 glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
6948 glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
6949 glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load(userptr, "glTexSubImage1D");
6950 glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
6951}
6952static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) {
6953 if(!GLAD_GL_VERSION_1_2) return;
6954 glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load(userptr, "glCopyTexSubImage3D");
6955 glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load(userptr, "glDrawRangeElements");
6956 glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC) load(userptr, "glTexImage3D");
6957 glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load(userptr, "glTexSubImage3D");
6958}
6959static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) {
6960 if(!GLAD_GL_VERSION_1_3) return;
6961 glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
6962 glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load(userptr, "glCompressedTexImage1D");
6963 glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
6964 glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load(userptr, "glCompressedTexImage3D");
6965 glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load(userptr, "glCompressedTexSubImage1D");
6966 glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
6967 glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load(userptr, "glCompressedTexSubImage3D");
6968 glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load(userptr, "glGetCompressedTexImage");
6969 glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
6970}
6971static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) {
6972 if(!GLAD_GL_VERSION_1_4) return;
6973 glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor");
6974 glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation");
6975 glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate");
6976 glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load(userptr, "glMultiDrawArrays");
6977 glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load(userptr, "glMultiDrawElements");
6978 glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load(userptr, "glPointParameterf");
6979 glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load(userptr, "glPointParameterfv");
6980 glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load(userptr, "glPointParameteri");
6981 glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load(userptr, "glPointParameteriv");
6982}
6983static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) {
6984 if(!GLAD_GL_VERSION_1_5) return;
6985 glad_glBeginQuery = (PFNGLBEGINQUERYPROC) load(userptr, "glBeginQuery");
6986 glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
6987 glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
6988 glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
6989 glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
6990 glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC) load(userptr, "glDeleteQueries");
6991 glad_glEndQuery = (PFNGLENDQUERYPROC) load(userptr, "glEndQuery");
6992 glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
6993 glad_glGenQueries = (PFNGLGENQUERIESPROC) load(userptr, "glGenQueries");
6994 glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
6995 glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load(userptr, "glGetBufferPointerv");
6996 glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load(userptr, "glGetBufferSubData");
6997 glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load(userptr, "glGetQueryObjectiv");
6998 glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load(userptr, "glGetQueryObjectuiv");
6999 glad_glGetQueryiv = (PFNGLGETQUERYIVPROC) load(userptr, "glGetQueryiv");
7000 glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
7001 glad_glIsQuery = (PFNGLISQUERYPROC) load(userptr, "glIsQuery");
7002 glad_glMapBuffer = (PFNGLMAPBUFFERPROC) load(userptr, "glMapBuffer");
7003 glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load(userptr, "glUnmapBuffer");
7004}
7005static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
7006 if(!GLAD_GL_VERSION_2_0) return;
7007 glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader");
7008 glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation");
7009 glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate");
7010 glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader");
7011 glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram");
7012 glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader");
7013 glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram");
7014 glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader");
7015 glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader");
7016 glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray");
7017 glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load(userptr, "glDrawBuffers");
7018 glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray");
7019 glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib");
7020 glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform");
7021 glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders");
7022 glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation");
7023 glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog");
7024 glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv");
7025 glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog");
7026 glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource");
7027 glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv");
7028 glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation");
7029 glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv");
7030 glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv");
7031 glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv");
7032 glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load(userptr, "glGetVertexAttribdv");
7033 glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv");
7034 glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv");
7035 glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram");
7036 glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader");
7037 glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram");
7038 glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource");
7039 glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate");
7040 glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate");
7041 glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate");
7042 glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f");
7043 glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv");
7044 glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i");
7045 glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv");
7046 glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f");
7047 glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv");
7048 glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i");
7049 glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv");
7050 glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f");
7051 glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv");
7052 glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i");
7053 glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv");
7054 glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f");
7055 glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv");
7056 glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i");
7057 glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv");
7058 glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv");
7059 glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv");
7060 glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv");
7061 glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram");
7062 glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram");
7063 glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load(userptr, "glVertexAttrib1d");
7064 glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load(userptr, "glVertexAttrib1dv");
7065 glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f");
7066 glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv");
7067 glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load(userptr, "glVertexAttrib1s");
7068 glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load(userptr, "glVertexAttrib1sv");
7069 glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load(userptr, "glVertexAttrib2d");
7070 glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load(userptr, "glVertexAttrib2dv");
7071 glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f");
7072 glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv");
7073 glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load(userptr, "glVertexAttrib2s");
7074 glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load(userptr, "glVertexAttrib2sv");
7075 glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load(userptr, "glVertexAttrib3d");
7076 glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load(userptr, "glVertexAttrib3dv");
7077 glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f");
7078 glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv");
7079 glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load(userptr, "glVertexAttrib3s");
7080 glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load(userptr, "glVertexAttrib3sv");
7081 glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load(userptr, "glVertexAttrib4Nbv");
7082 glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load(userptr, "glVertexAttrib4Niv");
7083 glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load(userptr, "glVertexAttrib4Nsv");
7084 glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load(userptr, "glVertexAttrib4Nub");
7085 glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load(userptr, "glVertexAttrib4Nubv");
7086 glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load(userptr, "glVertexAttrib4Nuiv");
7087 glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load(userptr, "glVertexAttrib4Nusv");
7088 glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load(userptr, "glVertexAttrib4bv");
7089 glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load(userptr, "glVertexAttrib4d");
7090 glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load(userptr, "glVertexAttrib4dv");
7091 glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f");
7092 glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv");
7093 glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load(userptr, "glVertexAttrib4iv");
7094 glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load(userptr, "glVertexAttrib4s");
7095 glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load(userptr, "glVertexAttrib4sv");
7096 glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load(userptr, "glVertexAttrib4ubv");
7097 glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load(userptr, "glVertexAttrib4uiv");
7098 glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load(userptr, "glVertexAttrib4usv");
7099 glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer");
7100}
7101static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) {
7102 if(!GLAD_GL_VERSION_2_1) return;
7103 glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load(userptr, "glUniformMatrix2x3fv");
7104 glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load(userptr, "glUniformMatrix2x4fv");
7105 glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load(userptr, "glUniformMatrix3x2fv");
7106 glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load(userptr, "glUniformMatrix3x4fv");
7107 glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load(userptr, "glUniformMatrix4x2fv");
7108 glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load(userptr, "glUniformMatrix4x3fv");
7109}
7110static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) {
7111 if(!GLAD_GL_VERSION_3_0) return;
7112 glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load(userptr, "glBeginConditionalRender");
7113 glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load(userptr, "glBeginTransformFeedback");
7114 glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase");
7115 glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange");
7116 glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load(userptr, "glBindFragDataLocation");
7117 glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
7118 glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
7119 glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load(userptr, "glBindVertexArray");
7120 glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load(userptr, "glBlitFramebuffer");
7121 glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
7122 glad_glClampColor = (PFNGLCLAMPCOLORPROC) load(userptr, "glClampColor");
7123 glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load(userptr, "glClearBufferfi");
7124 glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load(userptr, "glClearBufferfv");
7125 glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load(userptr, "glClearBufferiv");
7126 glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load(userptr, "glClearBufferuiv");
7127 glad_glColorMaski = (PFNGLCOLORMASKIPROC) load(userptr, "glColorMaski");
7128 glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
7129 glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
7130 glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load(userptr, "glDeleteVertexArrays");
7131 glad_glDisablei = (PFNGLDISABLEIPROC) load(userptr, "glDisablei");
7132 glad_glEnablei = (PFNGLENABLEIPROC) load(userptr, "glEnablei");
7133 glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load(userptr, "glEndConditionalRender");
7134 glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load(userptr, "glEndTransformFeedback");
7135 glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load(userptr, "glFlushMappedBufferRange");
7136 glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
7137 glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load(userptr, "glFramebufferTexture1D");
7138 glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
7139 glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load(userptr, "glFramebufferTexture3D");
7140 glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load(userptr, "glFramebufferTextureLayer");
7141 glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
7142 glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
7143 glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load(userptr, "glGenVertexArrays");
7144 glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
7145 glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load(userptr, "glGetBooleani_v");
7146 glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load(userptr, "glGetFragDataLocation");
7147 glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
7148 glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v");
7149 glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
7150 glad_glGetStringi = (PFNGLGETSTRINGIPROC) load(userptr, "glGetStringi");
7151 glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load(userptr, "glGetTexParameterIiv");
7152 glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load(userptr, "glGetTexParameterIuiv");
7153 glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load(userptr, "glGetTransformFeedbackVarying");
7154 glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load(userptr, "glGetUniformuiv");
7155 glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load(userptr, "glGetVertexAttribIiv");
7156 glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load(userptr, "glGetVertexAttribIuiv");
7157 glad_glIsEnabledi = (PFNGLISENABLEDIPROC) load(userptr, "glIsEnabledi");
7158 glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
7159 glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
7160 glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load(userptr, "glIsVertexArray");
7161 glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load(userptr, "glMapBufferRange");
7162 glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
7163 glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load(userptr, "glRenderbufferStorageMultisample");
7164 glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load(userptr, "glTexParameterIiv");
7165 glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load(userptr, "glTexParameterIuiv");
7166 glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load(userptr, "glTransformFeedbackVaryings");
7167 glad_glUniform1ui = (PFNGLUNIFORM1UIPROC) load(userptr, "glUniform1ui");
7168 glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load(userptr, "glUniform1uiv");
7169 glad_glUniform2ui = (PFNGLUNIFORM2UIPROC) load(userptr, "glUniform2ui");
7170 glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load(userptr, "glUniform2uiv");
7171 glad_glUniform3ui = (PFNGLUNIFORM3UIPROC) load(userptr, "glUniform3ui");
7172 glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load(userptr, "glUniform3uiv");
7173 glad_glUniform4ui = (PFNGLUNIFORM4UIPROC) load(userptr, "glUniform4ui");
7174 glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load(userptr, "glUniform4uiv");
7175 glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load(userptr, "glVertexAttribI1i");
7176 glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load(userptr, "glVertexAttribI1iv");
7177 glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load(userptr, "glVertexAttribI1ui");
7178 glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load(userptr, "glVertexAttribI1uiv");
7179 glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load(userptr, "glVertexAttribI2i");
7180 glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load(userptr, "glVertexAttribI2iv");
7181 glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load(userptr, "glVertexAttribI2ui");
7182 glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load(userptr, "glVertexAttribI2uiv");
7183 glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load(userptr, "glVertexAttribI3i");
7184 glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load(userptr, "glVertexAttribI3iv");
7185 glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load(userptr, "glVertexAttribI3ui");
7186 glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load(userptr, "glVertexAttribI3uiv");
7187 glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load(userptr, "glVertexAttribI4bv");
7188 glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load(userptr, "glVertexAttribI4i");
7189 glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load(userptr, "glVertexAttribI4iv");
7190 glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load(userptr, "glVertexAttribI4sv");
7191 glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load(userptr, "glVertexAttribI4ubv");
7192 glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load(userptr, "glVertexAttribI4ui");
7193 glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load(userptr, "glVertexAttribI4uiv");
7194 glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load(userptr, "glVertexAttribI4usv");
7195 glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load(userptr, "glVertexAttribIPointer");
7196}
7197static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) {
7198 if(!GLAD_GL_VERSION_3_1) return;
7199 glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase");
7200 glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange");
7201 glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load(userptr, "glCopyBufferSubData");
7202 glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load(userptr, "glDrawArraysInstanced");
7203 glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load(userptr, "glDrawElementsInstanced");
7204 glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load(userptr, "glGetActiveUniformBlockName");
7205 glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load(userptr, "glGetActiveUniformBlockiv");
7206 glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load(userptr, "glGetActiveUniformName");
7207 glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load(userptr, "glGetActiveUniformsiv");
7208 glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v");
7209 glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load(userptr, "glGetUniformBlockIndex");
7210 glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load(userptr, "glGetUniformIndices");
7211 glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load(userptr, "glPrimitiveRestartIndex");
7212 glad_glTexBuffer = (PFNGLTEXBUFFERPROC) load(userptr, "glTexBuffer");
7213 glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load(userptr, "glUniformBlockBinding");
7214}
7215static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) {
7216 if(!GLAD_GL_VERSION_3_2) return;
7217 glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load(userptr, "glClientWaitSync");
7218 glad_glDeleteSync = (PFNGLDELETESYNCPROC) load(userptr, "glDeleteSync");
7219 glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glDrawElementsBaseVertex");
7220 glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load(userptr, "glDrawElementsInstancedBaseVertex");
7221 glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load(userptr, "glDrawRangeElementsBaseVertex");
7222 glad_glFenceSync = (PFNGLFENCESYNCPROC) load(userptr, "glFenceSync");
7223 glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load(userptr, "glFramebufferTexture");
7224 glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load(userptr, "glGetBufferParameteri64v");
7225 glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load(userptr, "glGetInteger64i_v");
7226 glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC) load(userptr, "glGetInteger64v");
7227 glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load(userptr, "glGetMultisamplefv");
7228 glad_glGetSynciv = (PFNGLGETSYNCIVPROC) load(userptr, "glGetSynciv");
7229 glad_glIsSync = (PFNGLISSYNCPROC) load(userptr, "glIsSync");
7230 glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glMultiDrawElementsBaseVertex");
7231 glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load(userptr, "glProvokingVertex");
7232 glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC) load(userptr, "glSampleMaski");
7233 glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load(userptr, "glTexImage2DMultisample");
7234 glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load(userptr, "glTexImage3DMultisample");
7235 glad_glWaitSync = (PFNGLWAITSYNCPROC) load(userptr, "glWaitSync");
7236}
7237static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) {
7238 if(!GLAD_GL_VERSION_3_3) return;
7239 glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load(userptr, "glBindFragDataLocationIndexed");
7240 glad_glBindSampler = (PFNGLBINDSAMPLERPROC) load(userptr, "glBindSampler");
7241 glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load(userptr, "glDeleteSamplers");
7242 glad_glGenSamplers = (PFNGLGENSAMPLERSPROC) load(userptr, "glGenSamplers");
7243 glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load(userptr, "glGetFragDataIndex");
7244 glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load(userptr, "glGetQueryObjecti64v");
7245 glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load(userptr, "glGetQueryObjectui64v");
7246 glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load(userptr, "glGetSamplerParameterIiv");
7247 glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load(userptr, "glGetSamplerParameterIuiv");
7248 glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load(userptr, "glGetSamplerParameterfv");
7249 glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load(userptr, "glGetSamplerParameteriv");
7250 glad_glIsSampler = (PFNGLISSAMPLERPROC) load(userptr, "glIsSampler");
7251 glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC) load(userptr, "glQueryCounter");
7252 glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load(userptr, "glSamplerParameterIiv");
7253 glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load(userptr, "glSamplerParameterIuiv");
7254 glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load(userptr, "glSamplerParameterf");
7255 glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load(userptr, "glSamplerParameterfv");
7256 glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load(userptr, "glSamplerParameteri");
7257 glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load(userptr, "glSamplerParameteriv");
7258 glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load(userptr, "glVertexAttribDivisor");
7259 glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load(userptr, "glVertexAttribP1ui");
7260 glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load(userptr, "glVertexAttribP1uiv");
7261 glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load(userptr, "glVertexAttribP2ui");
7262 glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load(userptr, "glVertexAttribP2uiv");
7263 glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load(userptr, "glVertexAttribP3ui");
7264 glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load(userptr, "glVertexAttribP3uiv");
7265 glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load(userptr, "glVertexAttribP4ui");
7266 glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load(userptr, "glVertexAttribP4uiv");
7267}
7268static void glad_gl_load_GL_VERSION_4_0( GLADuserptrloadfunc load, void* userptr) {
7269 if(!GLAD_GL_VERSION_4_0) return;
7270 glad_glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC) load(userptr, "glBeginQueryIndexed");
7271 glad_glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC) load(userptr, "glBindTransformFeedback");
7272 glad_glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC) load(userptr, "glBlendEquationSeparatei");
7273 glad_glBlendEquationi = (PFNGLBLENDEQUATIONIPROC) load(userptr, "glBlendEquationi");
7274 glad_glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC) load(userptr, "glBlendFuncSeparatei");
7275 glad_glBlendFunci = (PFNGLBLENDFUNCIPROC) load(userptr, "glBlendFunci");
7276 glad_glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC) load(userptr, "glDeleteTransformFeedbacks");
7277 glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC) load(userptr, "glDrawArraysIndirect");
7278 glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC) load(userptr, "glDrawElementsIndirect");
7279 glad_glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC) load(userptr, "glDrawTransformFeedback");
7280 glad_glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) load(userptr, "glDrawTransformFeedbackStream");
7281 glad_glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC) load(userptr, "glEndQueryIndexed");
7282 glad_glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC) load(userptr, "glGenTransformFeedbacks");
7283 glad_glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC) load(userptr, "glGetActiveSubroutineName");
7284 glad_glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) load(userptr, "glGetActiveSubroutineUniformName");
7285 glad_glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) load(userptr, "glGetActiveSubroutineUniformiv");
7286 glad_glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC) load(userptr, "glGetProgramStageiv");
7287 glad_glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC) load(userptr, "glGetQueryIndexediv");
7288 glad_glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC) load(userptr, "glGetSubroutineIndex");
7289 glad_glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) load(userptr, "glGetSubroutineUniformLocation");
7290 glad_glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC) load(userptr, "glGetUniformSubroutineuiv");
7291 glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC) load(userptr, "glGetUniformdv");
7292 glad_glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC) load(userptr, "glIsTransformFeedback");
7293 glad_glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC) load(userptr, "glMinSampleShading");
7294 glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC) load(userptr, "glPatchParameterfv");
7295 glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC) load(userptr, "glPatchParameteri");
7296 glad_glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC) load(userptr, "glPauseTransformFeedback");
7297 glad_glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC) load(userptr, "glResumeTransformFeedback");
7298 glad_glUniform1d = (PFNGLUNIFORM1DPROC) load(userptr, "glUniform1d");
7299 glad_glUniform1dv = (PFNGLUNIFORM1DVPROC) load(userptr, "glUniform1dv");
7300 glad_glUniform2d = (PFNGLUNIFORM2DPROC) load(userptr, "glUniform2d");
7301 glad_glUniform2dv = (PFNGLUNIFORM2DVPROC) load(userptr, "glUniform2dv");
7302 glad_glUniform3d = (PFNGLUNIFORM3DPROC) load(userptr, "glUniform3d");
7303 glad_glUniform3dv = (PFNGLUNIFORM3DVPROC) load(userptr, "glUniform3dv");
7304 glad_glUniform4d = (PFNGLUNIFORM4DPROC) load(userptr, "glUniform4d");
7305 glad_glUniform4dv = (PFNGLUNIFORM4DVPROC) load(userptr, "glUniform4dv");
7306 glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC) load(userptr, "glUniformMatrix2dv");
7307 glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC) load(userptr, "glUniformMatrix2x3dv");
7308 glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC) load(userptr, "glUniformMatrix2x4dv");
7309 glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC) load(userptr, "glUniformMatrix3dv");
7310 glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC) load(userptr, "glUniformMatrix3x2dv");
7311 glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC) load(userptr, "glUniformMatrix3x4dv");
7312 glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC) load(userptr, "glUniformMatrix4dv");
7313 glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC) load(userptr, "glUniformMatrix4x2dv");
7314 glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC) load(userptr, "glUniformMatrix4x3dv");
7315 glad_glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC) load(userptr, "glUniformSubroutinesuiv");
7316}
7317static void glad_gl_load_GL_VERSION_4_1( GLADuserptrloadfunc load, void* userptr) {
7318 if(!GLAD_GL_VERSION_4_1) return;
7319 glad_glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC) load(userptr, "glActiveShaderProgram");
7320 glad_glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC) load(userptr, "glBindProgramPipeline");
7321 glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
7322 glad_glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC) load(userptr, "glCreateShaderProgramv");
7323 glad_glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC) load(userptr, "glDeleteProgramPipelines");
7324 glad_glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC) load(userptr, "glDepthRangeArrayv");
7325 glad_glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC) load(userptr, "glDepthRangeIndexed");
7326 glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef");
7327 glad_glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC) load(userptr, "glGenProgramPipelines");
7328 glad_glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC) load(userptr, "glGetDoublei_v");
7329 glad_glGetFloati_v = (PFNGLGETFLOATI_VPROC) load(userptr, "glGetFloati_v");
7330 glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC) load(userptr, "glGetProgramBinary");
7331 glad_glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC) load(userptr, "glGetProgramPipelineInfoLog");
7332 glad_glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC) load(userptr, "glGetProgramPipelineiv");
7333 glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat");
7334 glad_glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC) load(userptr, "glGetVertexAttribLdv");
7335 glad_glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC) load(userptr, "glIsProgramPipeline");
7336 glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC) load(userptr, "glProgramBinary");
7337 glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) load(userptr, "glProgramParameteri");
7338 glad_glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC) load(userptr, "glProgramUniform1d");
7339 glad_glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC) load(userptr, "glProgramUniform1dv");
7340 glad_glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC) load(userptr, "glProgramUniform1f");
7341 glad_glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC) load(userptr, "glProgramUniform1fv");
7342 glad_glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC) load(userptr, "glProgramUniform1i");
7343 glad_glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC) load(userptr, "glProgramUniform1iv");
7344 glad_glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC) load(userptr, "glProgramUniform1ui");
7345 glad_glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC) load(userptr, "glProgramUniform1uiv");
7346 glad_glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC) load(userptr, "glProgramUniform2d");
7347 glad_glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC) load(userptr, "glProgramUniform2dv");
7348 glad_glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC) load(userptr, "glProgramUniform2f");
7349 glad_glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC) load(userptr, "glProgramUniform2fv");
7350 glad_glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC) load(userptr, "glProgramUniform2i");
7351 glad_glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC) load(userptr, "glProgramUniform2iv");
7352 glad_glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC) load(userptr, "glProgramUniform2ui");
7353 glad_glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC) load(userptr, "glProgramUniform2uiv");
7354 glad_glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC) load(userptr, "glProgramUniform3d");
7355 glad_glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC) load(userptr, "glProgramUniform3dv");
7356 glad_glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC) load(userptr, "glProgramUniform3f");
7357 glad_glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC) load(userptr, "glProgramUniform3fv");
7358 glad_glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC) load(userptr, "glProgramUniform3i");
7359 glad_glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC) load(userptr, "glProgramUniform3iv");
7360 glad_glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC) load(userptr, "glProgramUniform3ui");
7361 glad_glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC) load(userptr, "glProgramUniform3uiv");
7362 glad_glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC) load(userptr, "glProgramUniform4d");
7363 glad_glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC) load(userptr, "glProgramUniform4dv");
7364 glad_glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC) load(userptr, "glProgramUniform4f");
7365 glad_glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC) load(userptr, "glProgramUniform4fv");
7366 glad_glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC) load(userptr, "glProgramUniform4i");
7367 glad_glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC) load(userptr, "glProgramUniform4iv");
7368 glad_glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC) load(userptr, "glProgramUniform4ui");
7369 glad_glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC) load(userptr, "glProgramUniform4uiv");
7370 glad_glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC) load(userptr, "glProgramUniformMatrix2dv");
7371 glad_glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC) load(userptr, "glProgramUniformMatrix2fv");
7372 glad_glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) load(userptr, "glProgramUniformMatrix2x3dv");
7373 glad_glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) load(userptr, "glProgramUniformMatrix2x3fv");
7374 glad_glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) load(userptr, "glProgramUniformMatrix2x4dv");
7375 glad_glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) load(userptr, "glProgramUniformMatrix2x4fv");
7376 glad_glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC) load(userptr, "glProgramUniformMatrix3dv");
7377 glad_glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC) load(userptr, "glProgramUniformMatrix3fv");
7378 glad_glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) load(userptr, "glProgramUniformMatrix3x2dv");
7379 glad_glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) load(userptr, "glProgramUniformMatrix3x2fv");
7380 glad_glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) load(userptr, "glProgramUniformMatrix3x4dv");
7381 glad_glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) load(userptr, "glProgramUniformMatrix3x4fv");
7382 glad_glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC) load(userptr, "glProgramUniformMatrix4dv");
7383 glad_glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC) load(userptr, "glProgramUniformMatrix4fv");
7384 glad_glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) load(userptr, "glProgramUniformMatrix4x2dv");
7385 glad_glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) load(userptr, "glProgramUniformMatrix4x2fv");
7386 glad_glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) load(userptr, "glProgramUniformMatrix4x3dv");
7387 glad_glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) load(userptr, "glProgramUniformMatrix4x3fv");
7388 glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler");
7389 glad_glScissorArrayv = (PFNGLSCISSORARRAYVPROC) load(userptr, "glScissorArrayv");
7390 glad_glScissorIndexed = (PFNGLSCISSORINDEXEDPROC) load(userptr, "glScissorIndexed");
7391 glad_glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC) load(userptr, "glScissorIndexedv");
7392 glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary");
7393 glad_glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC) load(userptr, "glUseProgramStages");
7394 glad_glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC) load(userptr, "glValidateProgramPipeline");
7395 glad_glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC) load(userptr, "glVertexAttribL1d");
7396 glad_glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC) load(userptr, "glVertexAttribL1dv");
7397 glad_glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC) load(userptr, "glVertexAttribL2d");
7398 glad_glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC) load(userptr, "glVertexAttribL2dv");
7399 glad_glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC) load(userptr, "glVertexAttribL3d");
7400 glad_glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC) load(userptr, "glVertexAttribL3dv");
7401 glad_glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC) load(userptr, "glVertexAttribL4d");
7402 glad_glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC) load(userptr, "glVertexAttribL4dv");
7403 glad_glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC) load(userptr, "glVertexAttribLPointer");
7404 glad_glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC) load(userptr, "glViewportArrayv");
7405 glad_glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC) load(userptr, "glViewportIndexedf");
7406 glad_glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC) load(userptr, "glViewportIndexedfv");
7407}
7408static void glad_gl_load_GL_VERSION_4_2( GLADuserptrloadfunc load, void* userptr) {
7409 if(!GLAD_GL_VERSION_4_2) return;
7410 glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC) load(userptr, "glBindImageTexture");
7411 glad_glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) load(userptr, "glDrawArraysInstancedBaseInstance");
7412 glad_glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) load(userptr, "glDrawElementsInstancedBaseInstance");
7413 glad_glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) load(userptr, "glDrawElementsInstancedBaseVertexBaseInstance");
7414 glad_glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) load(userptr, "glDrawTransformFeedbackInstanced");
7415 glad_glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) load(userptr, "glDrawTransformFeedbackStreamInstanced");
7416 glad_glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) load(userptr, "glGetActiveAtomicCounterBufferiv");
7417 glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC) load(userptr, "glGetInternalformativ");
7418 glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC) load(userptr, "glMemoryBarrier");
7419 glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC) load(userptr, "glTexStorage1D");
7420 glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC) load(userptr, "glTexStorage2D");
7421 glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC) load(userptr, "glTexStorage3D");
7422}
7423static void glad_gl_load_GL_VERSION_4_3( GLADuserptrloadfunc load, void* userptr) {
7424 if(!GLAD_GL_VERSION_4_3) return;
7425 glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC) load(userptr, "glBindVertexBuffer");
7426 glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC) load(userptr, "glClearBufferData");
7427 glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC) load(userptr, "glClearBufferSubData");
7428 glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC) load(userptr, "glCopyImageSubData");
7429 glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load(userptr, "glDebugMessageCallback");
7430 glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load(userptr, "glDebugMessageControl");
7431 glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load(userptr, "glDebugMessageInsert");
7432 glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC) load(userptr, "glDispatchCompute");
7433 glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC) load(userptr, "glDispatchComputeIndirect");
7434 glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC) load(userptr, "glFramebufferParameteri");
7435 glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load(userptr, "glGetDebugMessageLog");
7436 glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC) load(userptr, "glGetFramebufferParameteriv");
7437 glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC) load(userptr, "glGetInternalformati64v");
7438 glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load(userptr, "glGetObjectLabel");
7439 glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load(userptr, "glGetObjectPtrLabel");
7440 glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv");
7441 glad_glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC) load(userptr, "glGetProgramInterfaceiv");
7442 glad_glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC) load(userptr, "glGetProgramResourceIndex");
7443 glad_glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC) load(userptr, "glGetProgramResourceLocation");
7444 glad_glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) load(userptr, "glGetProgramResourceLocationIndex");
7445 glad_glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC) load(userptr, "glGetProgramResourceName");
7446 glad_glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC) load(userptr, "glGetProgramResourceiv");
7447 glad_glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC) load(userptr, "glInvalidateBufferData");
7448 glad_glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC) load(userptr, "glInvalidateBufferSubData");
7449 glad_glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC) load(userptr, "glInvalidateFramebuffer");
7450 glad_glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC) load(userptr, "glInvalidateSubFramebuffer");
7451 glad_glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC) load(userptr, "glInvalidateTexImage");
7452 glad_glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC) load(userptr, "glInvalidateTexSubImage");
7453 glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC) load(userptr, "glMultiDrawArraysIndirect");
7454 glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC) load(userptr, "glMultiDrawElementsIndirect");
7455 glad_glObjectLabel = (PFNGLOBJECTLABELPROC) load(userptr, "glObjectLabel");
7456 glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load(userptr, "glObjectPtrLabel");
7457 glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load(userptr, "glPopDebugGroup");
7458 glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load(userptr, "glPushDebugGroup");
7459 glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC) load(userptr, "glShaderStorageBlockBinding");
7460 glad_glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC) load(userptr, "glTexBufferRange");
7461 glad_glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC) load(userptr, "glTexStorage2DMultisample");
7462 glad_glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC) load(userptr, "glTexStorage3DMultisample");
7463 glad_glTextureView = (PFNGLTEXTUREVIEWPROC) load(userptr, "glTextureView");
7464 glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC) load(userptr, "glVertexAttribBinding");
7465 glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC) load(userptr, "glVertexAttribFormat");
7466 glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC) load(userptr, "glVertexAttribIFormat");
7467 glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC) load(userptr, "glVertexAttribLFormat");
7468 glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC) load(userptr, "glVertexBindingDivisor");
7469}
7470static void glad_gl_load_GL_ARB_ES2_compatibility( GLADuserptrloadfunc load, void* userptr) {
7471 if(!GLAD_GL_ARB_ES2_compatibility) return;
7472 glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
7473 glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef");
7474 glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat");
7475 glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler");
7476 glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary");
7477}
7478static void glad_gl_load_GL_ARB_ES3_1_compatibility( GLADuserptrloadfunc load, void* userptr) {
7479 if(!GLAD_GL_ARB_ES3_1_compatibility) return;
7480 glad_glMemoryBarrierByRegion = (PFNGLMEMORYBARRIERBYREGIONPROC) load(userptr, "glMemoryBarrierByRegion");
7481}
7482static void glad_gl_load_GL_ARB_ES3_2_compatibility( GLADuserptrloadfunc load, void* userptr) {
7483 if(!GLAD_GL_ARB_ES3_2_compatibility) return;
7484 glad_glPrimitiveBoundingBoxARB = (PFNGLPRIMITIVEBOUNDINGBOXARBPROC) load(userptr, "glPrimitiveBoundingBoxARB");
7485}
7486static void glad_gl_load_GL_ARB_blend_func_extended( GLADuserptrloadfunc load, void* userptr) {
7487 if(!GLAD_GL_ARB_blend_func_extended) return;
7488 glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load(userptr, "glBindFragDataLocationIndexed");
7489 glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load(userptr, "glGetFragDataIndex");
7490}
7491static void glad_gl_load_GL_ARB_buffer_storage( GLADuserptrloadfunc load, void* userptr) {
7492 if(!GLAD_GL_ARB_buffer_storage) return;
7493 glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC) load(userptr, "glBufferStorage");
7494}
7495static void glad_gl_load_GL_ARB_clear_buffer_object( GLADuserptrloadfunc load, void* userptr) {
7496 if(!GLAD_GL_ARB_clear_buffer_object) return;
7497 glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC) load(userptr, "glClearBufferData");
7498 glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC) load(userptr, "glClearBufferSubData");
7499}
7500static void glad_gl_load_GL_ARB_clear_texture( GLADuserptrloadfunc load, void* userptr) {
7501 if(!GLAD_GL_ARB_clear_texture) return;
7502 glad_glClearTexImage = (PFNGLCLEARTEXIMAGEPROC) load(userptr, "glClearTexImage");
7503 glad_glClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC) load(userptr, "glClearTexSubImage");
7504}
7505static void glad_gl_load_GL_ARB_color_buffer_float( GLADuserptrloadfunc load, void* userptr) {
7506 if(!GLAD_GL_ARB_color_buffer_float) return;
7507 glad_glClampColorARB = (PFNGLCLAMPCOLORARBPROC) load(userptr, "glClampColorARB");
7508}
7509static void glad_gl_load_GL_ARB_compute_shader( GLADuserptrloadfunc load, void* userptr) {
7510 if(!GLAD_GL_ARB_compute_shader) return;
7511 glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC) load(userptr, "glDispatchCompute");
7512 glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC) load(userptr, "glDispatchComputeIndirect");
7513}
7514static void glad_gl_load_GL_ARB_compute_variable_group_size( GLADuserptrloadfunc load, void* userptr) {
7515 if(!GLAD_GL_ARB_compute_variable_group_size) return;
7516 glad_glDispatchComputeGroupSizeARB = (PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) load(userptr, "glDispatchComputeGroupSizeARB");
7517}
7518static void glad_gl_load_GL_ARB_copy_buffer( GLADuserptrloadfunc load, void* userptr) {
7519 if(!GLAD_GL_ARB_copy_buffer) return;
7520 glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load(userptr, "glCopyBufferSubData");
7521}
7522static void glad_gl_load_GL_ARB_copy_image( GLADuserptrloadfunc load, void* userptr) {
7523 if(!GLAD_GL_ARB_copy_image) return;
7524 glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC) load(userptr, "glCopyImageSubData");
7525}
7526static void glad_gl_load_GL_ARB_debug_output( GLADuserptrloadfunc load, void* userptr) {
7527 if(!GLAD_GL_ARB_debug_output) return;
7528 glad_glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC) load(userptr, "glDebugMessageCallbackARB");
7529 glad_glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC) load(userptr, "glDebugMessageControlARB");
7530 glad_glDebugMessageInsertARB = (PFNGLDEBUGMESSAGEINSERTARBPROC) load(userptr, "glDebugMessageInsertARB");
7531 glad_glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC) load(userptr, "glGetDebugMessageLogARB");
7532}
7533static void glad_gl_load_GL_ARB_direct_state_access( GLADuserptrloadfunc load, void* userptr) {
7534 if(!GLAD_GL_ARB_direct_state_access) return;
7535 glad_glBindTextureUnit = (PFNGLBINDTEXTUREUNITPROC) load(userptr, "glBindTextureUnit");
7536 glad_glBlitNamedFramebuffer = (PFNGLBLITNAMEDFRAMEBUFFERPROC) load(userptr, "glBlitNamedFramebuffer");
7537 glad_glCheckNamedFramebufferStatus = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckNamedFramebufferStatus");
7538 glad_glClearNamedBufferData = (PFNGLCLEARNAMEDBUFFERDATAPROC) load(userptr, "glClearNamedBufferData");
7539 glad_glClearNamedBufferSubData = (PFNGLCLEARNAMEDBUFFERSUBDATAPROC) load(userptr, "glClearNamedBufferSubData");
7540 glad_glClearNamedFramebufferfi = (PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) load(userptr, "glClearNamedFramebufferfi");
7541 glad_glClearNamedFramebufferfv = (PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) load(userptr, "glClearNamedFramebufferfv");
7542 glad_glClearNamedFramebufferiv = (PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) load(userptr, "glClearNamedFramebufferiv");
7543 glad_glClearNamedFramebufferuiv = (PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) load(userptr, "glClearNamedFramebufferuiv");
7544 glad_glCompressedTextureSubImage1D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) load(userptr, "glCompressedTextureSubImage1D");
7545 glad_glCompressedTextureSubImage2D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) load(userptr, "glCompressedTextureSubImage2D");
7546 glad_glCompressedTextureSubImage3D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) load(userptr, "glCompressedTextureSubImage3D");
7547 glad_glCopyNamedBufferSubData = (PFNGLCOPYNAMEDBUFFERSUBDATAPROC) load(userptr, "glCopyNamedBufferSubData");
7548 glad_glCopyTextureSubImage1D = (PFNGLCOPYTEXTURESUBIMAGE1DPROC) load(userptr, "glCopyTextureSubImage1D");
7549 glad_glCopyTextureSubImage2D = (PFNGLCOPYTEXTURESUBIMAGE2DPROC) load(userptr, "glCopyTextureSubImage2D");
7550 glad_glCopyTextureSubImage3D = (PFNGLCOPYTEXTURESUBIMAGE3DPROC) load(userptr, "glCopyTextureSubImage3D");
7551 glad_glCreateBuffers = (PFNGLCREATEBUFFERSPROC) load(userptr, "glCreateBuffers");
7552 glad_glCreateFramebuffers = (PFNGLCREATEFRAMEBUFFERSPROC) load(userptr, "glCreateFramebuffers");
7553 glad_glCreateProgramPipelines = (PFNGLCREATEPROGRAMPIPELINESPROC) load(userptr, "glCreateProgramPipelines");
7554 glad_glCreateQueries = (PFNGLCREATEQUERIESPROC) load(userptr, "glCreateQueries");
7555 glad_glCreateRenderbuffers = (PFNGLCREATERENDERBUFFERSPROC) load(userptr, "glCreateRenderbuffers");
7556 glad_glCreateSamplers = (PFNGLCREATESAMPLERSPROC) load(userptr, "glCreateSamplers");
7557 glad_glCreateTextures = (PFNGLCREATETEXTURESPROC) load(userptr, "glCreateTextures");
7558 glad_glCreateTransformFeedbacks = (PFNGLCREATETRANSFORMFEEDBACKSPROC) load(userptr, "glCreateTransformFeedbacks");
7559 glad_glCreateVertexArrays = (PFNGLCREATEVERTEXARRAYSPROC) load(userptr, "glCreateVertexArrays");
7560 glad_glDisableVertexArrayAttrib = (PFNGLDISABLEVERTEXARRAYATTRIBPROC) load(userptr, "glDisableVertexArrayAttrib");
7561 glad_glEnableVertexArrayAttrib = (PFNGLENABLEVERTEXARRAYATTRIBPROC) load(userptr, "glEnableVertexArrayAttrib");
7562 glad_glFlushMappedNamedBufferRange = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) load(userptr, "glFlushMappedNamedBufferRange");
7563 glad_glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) load(userptr, "glGenerateTextureMipmap");
7564 glad_glGetCompressedTextureImage = (PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) load(userptr, "glGetCompressedTextureImage");
7565 glad_glGetNamedBufferParameteri64v = (PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) load(userptr, "glGetNamedBufferParameteri64v");
7566 glad_glGetNamedBufferParameteriv = (PFNGLGETNAMEDBUFFERPARAMETERIVPROC) load(userptr, "glGetNamedBufferParameteriv");
7567 glad_glGetNamedBufferPointerv = (PFNGLGETNAMEDBUFFERPOINTERVPROC) load(userptr, "glGetNamedBufferPointerv");
7568 glad_glGetNamedBufferSubData = (PFNGLGETNAMEDBUFFERSUBDATAPROC) load(userptr, "glGetNamedBufferSubData");
7569 glad_glGetNamedFramebufferAttachmentParameteriv = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetNamedFramebufferAttachmentParameteriv");
7570 glad_glGetNamedFramebufferParameteriv = (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) load(userptr, "glGetNamedFramebufferParameteriv");
7571 glad_glGetNamedRenderbufferParameteriv = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetNamedRenderbufferParameteriv");
7572 glad_glGetQueryBufferObjecti64v = (PFNGLGETQUERYBUFFEROBJECTI64VPROC) load(userptr, "glGetQueryBufferObjecti64v");
7573 glad_glGetQueryBufferObjectiv = (PFNGLGETQUERYBUFFEROBJECTIVPROC) load(userptr, "glGetQueryBufferObjectiv");
7574 glad_glGetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC) load(userptr, "glGetQueryBufferObjectui64v");
7575 glad_glGetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC) load(userptr, "glGetQueryBufferObjectuiv");
7576 glad_glGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC) load(userptr, "glGetTextureImage");
7577 glad_glGetTextureLevelParameterfv = (PFNGLGETTEXTURELEVELPARAMETERFVPROC) load(userptr, "glGetTextureLevelParameterfv");
7578 glad_glGetTextureLevelParameteriv = (PFNGLGETTEXTURELEVELPARAMETERIVPROC) load(userptr, "glGetTextureLevelParameteriv");
7579 glad_glGetTextureParameterIiv = (PFNGLGETTEXTUREPARAMETERIIVPROC) load(userptr, "glGetTextureParameterIiv");
7580 glad_glGetTextureParameterIuiv = (PFNGLGETTEXTUREPARAMETERIUIVPROC) load(userptr, "glGetTextureParameterIuiv");
7581 glad_glGetTextureParameterfv = (PFNGLGETTEXTUREPARAMETERFVPROC) load(userptr, "glGetTextureParameterfv");
7582 glad_glGetTextureParameteriv = (PFNGLGETTEXTUREPARAMETERIVPROC) load(userptr, "glGetTextureParameteriv");
7583 glad_glGetTransformFeedbacki64_v = (PFNGLGETTRANSFORMFEEDBACKI64_VPROC) load(userptr, "glGetTransformFeedbacki64_v");
7584 glad_glGetTransformFeedbacki_v = (PFNGLGETTRANSFORMFEEDBACKI_VPROC) load(userptr, "glGetTransformFeedbacki_v");
7585 glad_glGetTransformFeedbackiv = (PFNGLGETTRANSFORMFEEDBACKIVPROC) load(userptr, "glGetTransformFeedbackiv");
7586 glad_glGetVertexArrayIndexed64iv = (PFNGLGETVERTEXARRAYINDEXED64IVPROC) load(userptr, "glGetVertexArrayIndexed64iv");
7587 glad_glGetVertexArrayIndexediv = (PFNGLGETVERTEXARRAYINDEXEDIVPROC) load(userptr, "glGetVertexArrayIndexediv");
7588 glad_glGetVertexArrayiv = (PFNGLGETVERTEXARRAYIVPROC) load(userptr, "glGetVertexArrayiv");
7589 glad_glInvalidateNamedFramebufferData = (PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) load(userptr, "glInvalidateNamedFramebufferData");
7590 glad_glInvalidateNamedFramebufferSubData = (PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) load(userptr, "glInvalidateNamedFramebufferSubData");
7591 glad_glMapNamedBuffer = (PFNGLMAPNAMEDBUFFERPROC) load(userptr, "glMapNamedBuffer");
7592 glad_glMapNamedBufferRange = (PFNGLMAPNAMEDBUFFERRANGEPROC) load(userptr, "glMapNamedBufferRange");
7593 glad_glNamedBufferData = (PFNGLNAMEDBUFFERDATAPROC) load(userptr, "glNamedBufferData");
7594 glad_glNamedBufferStorage = (PFNGLNAMEDBUFFERSTORAGEPROC) load(userptr, "glNamedBufferStorage");
7595 glad_glNamedBufferSubData = (PFNGLNAMEDBUFFERSUBDATAPROC) load(userptr, "glNamedBufferSubData");
7596 glad_glNamedFramebufferDrawBuffer = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) load(userptr, "glNamedFramebufferDrawBuffer");
7597 glad_glNamedFramebufferDrawBuffers = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) load(userptr, "glNamedFramebufferDrawBuffers");
7598 glad_glNamedFramebufferParameteri = (PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) load(userptr, "glNamedFramebufferParameteri");
7599 glad_glNamedFramebufferReadBuffer = (PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) load(userptr, "glNamedFramebufferReadBuffer");
7600 glad_glNamedFramebufferRenderbuffer = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glNamedFramebufferRenderbuffer");
7601 glad_glNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) load(userptr, "glNamedFramebufferTexture");
7602 glad_glNamedFramebufferTextureLayer = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) load(userptr, "glNamedFramebufferTextureLayer");
7603 glad_glNamedRenderbufferStorage = (PFNGLNAMEDRENDERBUFFERSTORAGEPROC) load(userptr, "glNamedRenderbufferStorage");
7604 glad_glNamedRenderbufferStorageMultisample = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) load(userptr, "glNamedRenderbufferStorageMultisample");
7605 glad_glTextureBuffer = (PFNGLTEXTUREBUFFERPROC) load(userptr, "glTextureBuffer");
7606 glad_glTextureBufferRange = (PFNGLTEXTUREBUFFERRANGEPROC) load(userptr, "glTextureBufferRange");
7607 glad_glTextureParameterIiv = (PFNGLTEXTUREPARAMETERIIVPROC) load(userptr, "glTextureParameterIiv");
7608 glad_glTextureParameterIuiv = (PFNGLTEXTUREPARAMETERIUIVPROC) load(userptr, "glTextureParameterIuiv");
7609 glad_glTextureParameterf = (PFNGLTEXTUREPARAMETERFPROC) load(userptr, "glTextureParameterf");
7610 glad_glTextureParameterfv = (PFNGLTEXTUREPARAMETERFVPROC) load(userptr, "glTextureParameterfv");
7611 glad_glTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC) load(userptr, "glTextureParameteri");
7612 glad_glTextureParameteriv = (PFNGLTEXTUREPARAMETERIVPROC) load(userptr, "glTextureParameteriv");
7613 glad_glTextureStorage1D = (PFNGLTEXTURESTORAGE1DPROC) load(userptr, "glTextureStorage1D");
7614 glad_glTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC) load(userptr, "glTextureStorage2D");
7615 glad_glTextureStorage2DMultisample = (PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) load(userptr, "glTextureStorage2DMultisample");
7616 glad_glTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC) load(userptr, "glTextureStorage3D");
7617 glad_glTextureStorage3DMultisample = (PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) load(userptr, "glTextureStorage3DMultisample");
7618 glad_glTextureSubImage1D = (PFNGLTEXTURESUBIMAGE1DPROC) load(userptr, "glTextureSubImage1D");
7619 glad_glTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC) load(userptr, "glTextureSubImage2D");
7620 glad_glTextureSubImage3D = (PFNGLTEXTURESUBIMAGE3DPROC) load(userptr, "glTextureSubImage3D");
7621 glad_glTransformFeedbackBufferBase = (PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) load(userptr, "glTransformFeedbackBufferBase");
7622 glad_glTransformFeedbackBufferRange = (PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) load(userptr, "glTransformFeedbackBufferRange");
7623 glad_glUnmapNamedBuffer = (PFNGLUNMAPNAMEDBUFFERPROC) load(userptr, "glUnmapNamedBuffer");
7624 glad_glVertexArrayAttribBinding = (PFNGLVERTEXARRAYATTRIBBINDINGPROC) load(userptr, "glVertexArrayAttribBinding");
7625 glad_glVertexArrayAttribFormat = (PFNGLVERTEXARRAYATTRIBFORMATPROC) load(userptr, "glVertexArrayAttribFormat");
7626 glad_glVertexArrayAttribIFormat = (PFNGLVERTEXARRAYATTRIBIFORMATPROC) load(userptr, "glVertexArrayAttribIFormat");
7627 glad_glVertexArrayAttribLFormat = (PFNGLVERTEXARRAYATTRIBLFORMATPROC) load(userptr, "glVertexArrayAttribLFormat");
7628 glad_glVertexArrayBindingDivisor = (PFNGLVERTEXARRAYBINDINGDIVISORPROC) load(userptr, "glVertexArrayBindingDivisor");
7629 glad_glVertexArrayElementBuffer = (PFNGLVERTEXARRAYELEMENTBUFFERPROC) load(userptr, "glVertexArrayElementBuffer");
7630 glad_glVertexArrayVertexBuffer = (PFNGLVERTEXARRAYVERTEXBUFFERPROC) load(userptr, "glVertexArrayVertexBuffer");
7631 glad_glVertexArrayVertexBuffers = (PFNGLVERTEXARRAYVERTEXBUFFERSPROC) load(userptr, "glVertexArrayVertexBuffers");
7632}
7633static void glad_gl_load_GL_ARB_draw_buffers( GLADuserptrloadfunc load, void* userptr) {
7634 if(!GLAD_GL_ARB_draw_buffers) return;
7635 glad_glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) load(userptr, "glDrawBuffersARB");
7636}
7637static void glad_gl_load_GL_ARB_draw_buffers_blend( GLADuserptrloadfunc load, void* userptr) {
7638 if(!GLAD_GL_ARB_draw_buffers_blend) return;
7639 glad_glBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIARBPROC) load(userptr, "glBlendEquationSeparateiARB");
7640 glad_glBlendEquationiARB = (PFNGLBLENDEQUATIONIARBPROC) load(userptr, "glBlendEquationiARB");
7641 glad_glBlendFuncSeparateiARB = (PFNGLBLENDFUNCSEPARATEIARBPROC) load(userptr, "glBlendFuncSeparateiARB");
7642 glad_glBlendFunciARB = (PFNGLBLENDFUNCIARBPROC) load(userptr, "glBlendFunciARB");
7643}
7644static void glad_gl_load_GL_ARB_draw_elements_base_vertex( GLADuserptrloadfunc load, void* userptr) {
7645 if(!GLAD_GL_ARB_draw_elements_base_vertex) return;
7646 glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glDrawElementsBaseVertex");
7647 glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load(userptr, "glDrawElementsInstancedBaseVertex");
7648 glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load(userptr, "glDrawRangeElementsBaseVertex");
7649 glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glMultiDrawElementsBaseVertex");
7650}
7651static void glad_gl_load_GL_ARB_draw_indirect( GLADuserptrloadfunc load, void* userptr) {
7652 if(!GLAD_GL_ARB_draw_indirect) return;
7653 glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC) load(userptr, "glDrawArraysIndirect");
7654 glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC) load(userptr, "glDrawElementsIndirect");
7655}
7656static void glad_gl_load_GL_ARB_draw_instanced( GLADuserptrloadfunc load, void* userptr) {
7657 if(!GLAD_GL_ARB_draw_instanced) return;
7658 glad_glDrawArraysInstancedARB = (PFNGLDRAWARRAYSINSTANCEDARBPROC) load(userptr, "glDrawArraysInstancedARB");
7659 glad_glDrawElementsInstancedARB = (PFNGLDRAWELEMENTSINSTANCEDARBPROC) load(userptr, "glDrawElementsInstancedARB");
7660}
7661static void glad_gl_load_GL_ARB_fragment_program( GLADuserptrloadfunc load, void* userptr) {
7662 if(!GLAD_GL_ARB_fragment_program) return;
7663 glad_glBindProgramARB = (PFNGLBINDPROGRAMARBPROC) load(userptr, "glBindProgramARB");
7664 glad_glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) load(userptr, "glDeleteProgramsARB");
7665 glad_glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) load(userptr, "glGenProgramsARB");
7666 glad_glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC) load(userptr, "glGetProgramEnvParameterdvARB");
7667 glad_glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) load(userptr, "glGetProgramEnvParameterfvARB");
7668 glad_glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) load(userptr, "glGetProgramLocalParameterdvARB");
7669 glad_glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) load(userptr, "glGetProgramLocalParameterfvARB");
7670 glad_glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC) load(userptr, "glGetProgramStringARB");
7671 glad_glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) load(userptr, "glGetProgramivARB");
7672 glad_glIsProgramARB = (PFNGLISPROGRAMARBPROC) load(userptr, "glIsProgramARB");
7673 glad_glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC) load(userptr, "glProgramEnvParameter4dARB");
7674 glad_glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC) load(userptr, "glProgramEnvParameter4dvARB");
7675 glad_glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC) load(userptr, "glProgramEnvParameter4fARB");
7676 glad_glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) load(userptr, "glProgramEnvParameter4fvARB");
7677 glad_glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) load(userptr, "glProgramLocalParameter4dARB");
7678 glad_glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) load(userptr, "glProgramLocalParameter4dvARB");
7679 glad_glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC) load(userptr, "glProgramLocalParameter4fARB");
7680 glad_glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) load(userptr, "glProgramLocalParameter4fvARB");
7681 glad_glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) load(userptr, "glProgramStringARB");
7682}
7683static void glad_gl_load_GL_ARB_framebuffer_no_attachments( GLADuserptrloadfunc load, void* userptr) {
7684 if(!GLAD_GL_ARB_framebuffer_no_attachments) return;
7685 glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC) load(userptr, "glFramebufferParameteri");
7686 glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC) load(userptr, "glGetFramebufferParameteriv");
7687}
7688static void glad_gl_load_GL_ARB_framebuffer_object( GLADuserptrloadfunc load, void* userptr) {
7689 if(!GLAD_GL_ARB_framebuffer_object) return;
7690 glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
7691 glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
7692 glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load(userptr, "glBlitFramebuffer");
7693 glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
7694 glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
7695 glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
7696 glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
7697 glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load(userptr, "glFramebufferTexture1D");
7698 glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
7699 glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load(userptr, "glFramebufferTexture3D");
7700 glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load(userptr, "glFramebufferTextureLayer");
7701 glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
7702 glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
7703 glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
7704 glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
7705 glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
7706 glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
7707 glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
7708 glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
7709 glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load(userptr, "glRenderbufferStorageMultisample");
7710}
7711static void glad_gl_load_GL_ARB_geometry_shader4( GLADuserptrloadfunc load, void* userptr) {
7712 if(!GLAD_GL_ARB_geometry_shader4) return;
7713 glad_glFramebufferTextureARB = (PFNGLFRAMEBUFFERTEXTUREARBPROC) load(userptr, "glFramebufferTextureARB");
7714 glad_glFramebufferTextureFaceARB = (PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) load(userptr, "glFramebufferTextureFaceARB");
7715 glad_glFramebufferTextureLayerARB = (PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) load(userptr, "glFramebufferTextureLayerARB");
7716 glad_glProgramParameteriARB = (PFNGLPROGRAMPARAMETERIARBPROC) load(userptr, "glProgramParameteriARB");
7717}
7718static void glad_gl_load_GL_ARB_get_program_binary( GLADuserptrloadfunc load, void* userptr) {
7719 if(!GLAD_GL_ARB_get_program_binary) return;
7720 glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC) load(userptr, "glGetProgramBinary");
7721 glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC) load(userptr, "glProgramBinary");
7722 glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) load(userptr, "glProgramParameteri");
7723}
7724static void glad_gl_load_GL_ARB_get_texture_sub_image( GLADuserptrloadfunc load, void* userptr) {
7725 if(!GLAD_GL_ARB_get_texture_sub_image) return;
7726 glad_glGetCompressedTextureSubImage = (PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) load(userptr, "glGetCompressedTextureSubImage");
7727 glad_glGetTextureSubImage = (PFNGLGETTEXTURESUBIMAGEPROC) load(userptr, "glGetTextureSubImage");
7728}
7729static void glad_gl_load_GL_ARB_gl_spirv( GLADuserptrloadfunc load, void* userptr) {
7730 if(!GLAD_GL_ARB_gl_spirv) return;
7731 glad_glSpecializeShaderARB = (PFNGLSPECIALIZESHADERARBPROC) load(userptr, "glSpecializeShaderARB");
7732}
7733static void glad_gl_load_GL_ARB_gpu_shader_fp64( GLADuserptrloadfunc load, void* userptr) {
7734 if(!GLAD_GL_ARB_gpu_shader_fp64) return;
7735 glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC) load(userptr, "glGetUniformdv");
7736 glad_glUniform1d = (PFNGLUNIFORM1DPROC) load(userptr, "glUniform1d");
7737 glad_glUniform1dv = (PFNGLUNIFORM1DVPROC) load(userptr, "glUniform1dv");
7738 glad_glUniform2d = (PFNGLUNIFORM2DPROC) load(userptr, "glUniform2d");
7739 glad_glUniform2dv = (PFNGLUNIFORM2DVPROC) load(userptr, "glUniform2dv");
7740 glad_glUniform3d = (PFNGLUNIFORM3DPROC) load(userptr, "glUniform3d");
7741 glad_glUniform3dv = (PFNGLUNIFORM3DVPROC) load(userptr, "glUniform3dv");
7742 glad_glUniform4d = (PFNGLUNIFORM4DPROC) load(userptr, "glUniform4d");
7743 glad_glUniform4dv = (PFNGLUNIFORM4DVPROC) load(userptr, "glUniform4dv");
7744 glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC) load(userptr, "glUniformMatrix2dv");
7745 glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC) load(userptr, "glUniformMatrix2x3dv");
7746 glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC) load(userptr, "glUniformMatrix2x4dv");
7747 glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC) load(userptr, "glUniformMatrix3dv");
7748 glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC) load(userptr, "glUniformMatrix3x2dv");
7749 glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC) load(userptr, "glUniformMatrix3x4dv");
7750 glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC) load(userptr, "glUniformMatrix4dv");
7751 glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC) load(userptr, "glUniformMatrix4x2dv");
7752 glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC) load(userptr, "glUniformMatrix4x3dv");
7753}
7754static void glad_gl_load_GL_ARB_gpu_shader_int64( GLADuserptrloadfunc load, void* userptr) {
7755 if(!GLAD_GL_ARB_gpu_shader_int64) return;
7756 glad_glGetUniformi64vARB = (PFNGLGETUNIFORMI64VARBPROC) load(userptr, "glGetUniformi64vARB");
7757 glad_glGetUniformui64vARB = (PFNGLGETUNIFORMUI64VARBPROC) load(userptr, "glGetUniformui64vARB");
7758 glad_glGetnUniformi64vARB = (PFNGLGETNUNIFORMI64VARBPROC) load(userptr, "glGetnUniformi64vARB");
7759 glad_glGetnUniformui64vARB = (PFNGLGETNUNIFORMUI64VARBPROC) load(userptr, "glGetnUniformui64vARB");
7760 glad_glProgramUniform1i64ARB = (PFNGLPROGRAMUNIFORM1I64ARBPROC) load(userptr, "glProgramUniform1i64ARB");
7761 glad_glProgramUniform1i64vARB = (PFNGLPROGRAMUNIFORM1I64VARBPROC) load(userptr, "glProgramUniform1i64vARB");
7762 glad_glProgramUniform1ui64ARB = (PFNGLPROGRAMUNIFORM1UI64ARBPROC) load(userptr, "glProgramUniform1ui64ARB");
7763 glad_glProgramUniform1ui64vARB = (PFNGLPROGRAMUNIFORM1UI64VARBPROC) load(userptr, "glProgramUniform1ui64vARB");
7764 glad_glProgramUniform2i64ARB = (PFNGLPROGRAMUNIFORM2I64ARBPROC) load(userptr, "glProgramUniform2i64ARB");
7765 glad_glProgramUniform2i64vARB = (PFNGLPROGRAMUNIFORM2I64VARBPROC) load(userptr, "glProgramUniform2i64vARB");
7766 glad_glProgramUniform2ui64ARB = (PFNGLPROGRAMUNIFORM2UI64ARBPROC) load(userptr, "glProgramUniform2ui64ARB");
7767 glad_glProgramUniform2ui64vARB = (PFNGLPROGRAMUNIFORM2UI64VARBPROC) load(userptr, "glProgramUniform2ui64vARB");
7768 glad_glProgramUniform3i64ARB = (PFNGLPROGRAMUNIFORM3I64ARBPROC) load(userptr, "glProgramUniform3i64ARB");
7769 glad_glProgramUniform3i64vARB = (PFNGLPROGRAMUNIFORM3I64VARBPROC) load(userptr, "glProgramUniform3i64vARB");
7770 glad_glProgramUniform3ui64ARB = (PFNGLPROGRAMUNIFORM3UI64ARBPROC) load(userptr, "glProgramUniform3ui64ARB");
7771 glad_glProgramUniform3ui64vARB = (PFNGLPROGRAMUNIFORM3UI64VARBPROC) load(userptr, "glProgramUniform3ui64vARB");
7772 glad_glProgramUniform4i64ARB = (PFNGLPROGRAMUNIFORM4I64ARBPROC) load(userptr, "glProgramUniform4i64ARB");
7773 glad_glProgramUniform4i64vARB = (PFNGLPROGRAMUNIFORM4I64VARBPROC) load(userptr, "glProgramUniform4i64vARB");
7774 glad_glProgramUniform4ui64ARB = (PFNGLPROGRAMUNIFORM4UI64ARBPROC) load(userptr, "glProgramUniform4ui64ARB");
7775 glad_glProgramUniform4ui64vARB = (PFNGLPROGRAMUNIFORM4UI64VARBPROC) load(userptr, "glProgramUniform4ui64vARB");
7776 glad_glUniform1i64ARB = (PFNGLUNIFORM1I64ARBPROC) load(userptr, "glUniform1i64ARB");
7777 glad_glUniform1i64vARB = (PFNGLUNIFORM1I64VARBPROC) load(userptr, "glUniform1i64vARB");
7778 glad_glUniform1ui64ARB = (PFNGLUNIFORM1UI64ARBPROC) load(userptr, "glUniform1ui64ARB");
7779 glad_glUniform1ui64vARB = (PFNGLUNIFORM1UI64VARBPROC) load(userptr, "glUniform1ui64vARB");
7780 glad_glUniform2i64ARB = (PFNGLUNIFORM2I64ARBPROC) load(userptr, "glUniform2i64ARB");
7781 glad_glUniform2i64vARB = (PFNGLUNIFORM2I64VARBPROC) load(userptr, "glUniform2i64vARB");
7782 glad_glUniform2ui64ARB = (PFNGLUNIFORM2UI64ARBPROC) load(userptr, "glUniform2ui64ARB");
7783 glad_glUniform2ui64vARB = (PFNGLUNIFORM2UI64VARBPROC) load(userptr, "glUniform2ui64vARB");
7784 glad_glUniform3i64ARB = (PFNGLUNIFORM3I64ARBPROC) load(userptr, "glUniform3i64ARB");
7785 glad_glUniform3i64vARB = (PFNGLUNIFORM3I64VARBPROC) load(userptr, "glUniform3i64vARB");
7786 glad_glUniform3ui64ARB = (PFNGLUNIFORM3UI64ARBPROC) load(userptr, "glUniform3ui64ARB");
7787 glad_glUniform3ui64vARB = (PFNGLUNIFORM3UI64VARBPROC) load(userptr, "glUniform3ui64vARB");
7788 glad_glUniform4i64ARB = (PFNGLUNIFORM4I64ARBPROC) load(userptr, "glUniform4i64ARB");
7789 glad_glUniform4i64vARB = (PFNGLUNIFORM4I64VARBPROC) load(userptr, "glUniform4i64vARB");
7790 glad_glUniform4ui64ARB = (PFNGLUNIFORM4UI64ARBPROC) load(userptr, "glUniform4ui64ARB");
7791 glad_glUniform4ui64vARB = (PFNGLUNIFORM4UI64VARBPROC) load(userptr, "glUniform4ui64vARB");
7792}
7793static void glad_gl_load_GL_ARB_instanced_arrays( GLADuserptrloadfunc load, void* userptr) {
7794 if(!GLAD_GL_ARB_instanced_arrays) return;
7795 glad_glVertexAttribDivisorARB = (PFNGLVERTEXATTRIBDIVISORARBPROC) load(userptr, "glVertexAttribDivisorARB");
7796}
7797static void glad_gl_load_GL_ARB_internalformat_query( GLADuserptrloadfunc load, void* userptr) {
7798 if(!GLAD_GL_ARB_internalformat_query) return;
7799 glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC) load(userptr, "glGetInternalformativ");
7800}
7801static void glad_gl_load_GL_ARB_internalformat_query2( GLADuserptrloadfunc load, void* userptr) {
7802 if(!GLAD_GL_ARB_internalformat_query2) return;
7803 glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC) load(userptr, "glGetInternalformati64v");
7804}
7805static void glad_gl_load_GL_ARB_map_buffer_range( GLADuserptrloadfunc load, void* userptr) {
7806 if(!GLAD_GL_ARB_map_buffer_range) return;
7807 glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load(userptr, "glFlushMappedBufferRange");
7808 glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load(userptr, "glMapBufferRange");
7809}
7810static void glad_gl_load_GL_ARB_multi_bind( GLADuserptrloadfunc load, void* userptr) {
7811 if(!GLAD_GL_ARB_multi_bind) return;
7812 glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC) load(userptr, "glBindBuffersBase");
7813 glad_glBindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC) load(userptr, "glBindBuffersRange");
7814 glad_glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC) load(userptr, "glBindImageTextures");
7815 glad_glBindSamplers = (PFNGLBINDSAMPLERSPROC) load(userptr, "glBindSamplers");
7816 glad_glBindTextures = (PFNGLBINDTEXTURESPROC) load(userptr, "glBindTextures");
7817 glad_glBindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC) load(userptr, "glBindVertexBuffers");
7818}
7819static void glad_gl_load_GL_ARB_multi_draw_indirect( GLADuserptrloadfunc load, void* userptr) {
7820 if(!GLAD_GL_ARB_multi_draw_indirect) return;
7821 glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC) load(userptr, "glMultiDrawArraysIndirect");
7822 glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC) load(userptr, "glMultiDrawElementsIndirect");
7823}
7824static void glad_gl_load_GL_ARB_multisample( GLADuserptrloadfunc load, void* userptr) {
7825 if(!GLAD_GL_ARB_multisample) return;
7826 glad_glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC) load(userptr, "glSampleCoverageARB");
7827}
7828static void glad_gl_load_GL_ARB_multitexture( GLADuserptrloadfunc load, void* userptr) {
7829 if(!GLAD_GL_ARB_multitexture) return;
7830 glad_glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) load(userptr, "glActiveTextureARB");
7831 glad_glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) load(userptr, "glClientActiveTextureARB");
7832 glad_glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC) load(userptr, "glMultiTexCoord1dARB");
7833 glad_glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC) load(userptr, "glMultiTexCoord1dvARB");
7834 glad_glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC) load(userptr, "glMultiTexCoord1fARB");
7835 glad_glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC) load(userptr, "glMultiTexCoord1fvARB");
7836 glad_glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC) load(userptr, "glMultiTexCoord1iARB");
7837 glad_glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC) load(userptr, "glMultiTexCoord1ivARB");
7838 glad_glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC) load(userptr, "glMultiTexCoord1sARB");
7839 glad_glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC) load(userptr, "glMultiTexCoord1svARB");
7840 glad_glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC) load(userptr, "glMultiTexCoord2dARB");
7841 glad_glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC) load(userptr, "glMultiTexCoord2dvARB");
7842 glad_glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) load(userptr, "glMultiTexCoord2fARB");
7843 glad_glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC) load(userptr, "glMultiTexCoord2fvARB");
7844 glad_glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC) load(userptr, "glMultiTexCoord2iARB");
7845 glad_glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC) load(userptr, "glMultiTexCoord2ivARB");
7846 glad_glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC) load(userptr, "glMultiTexCoord2sARB");
7847 glad_glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC) load(userptr, "glMultiTexCoord2svARB");
7848 glad_glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC) load(userptr, "glMultiTexCoord3dARB");
7849 glad_glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC) load(userptr, "glMultiTexCoord3dvARB");
7850 glad_glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC) load(userptr, "glMultiTexCoord3fARB");
7851 glad_glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC) load(userptr, "glMultiTexCoord3fvARB");
7852 glad_glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC) load(userptr, "glMultiTexCoord3iARB");
7853 glad_glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC) load(userptr, "glMultiTexCoord3ivARB");
7854 glad_glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC) load(userptr, "glMultiTexCoord3sARB");
7855 glad_glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC) load(userptr, "glMultiTexCoord3svARB");
7856 glad_glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC) load(userptr, "glMultiTexCoord4dARB");
7857 glad_glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC) load(userptr, "glMultiTexCoord4dvARB");
7858 glad_glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC) load(userptr, "glMultiTexCoord4fARB");
7859 glad_glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC) load(userptr, "glMultiTexCoord4fvARB");
7860 glad_glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC) load(userptr, "glMultiTexCoord4iARB");
7861 glad_glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC) load(userptr, "glMultiTexCoord4ivARB");
7862 glad_glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC) load(userptr, "glMultiTexCoord4sARB");
7863 glad_glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC) load(userptr, "glMultiTexCoord4svARB");
7864}
7865static void glad_gl_load_GL_ARB_occlusion_query( GLADuserptrloadfunc load, void* userptr) {
7866 if(!GLAD_GL_ARB_occlusion_query) return;
7867 glad_glBeginQueryARB = (PFNGLBEGINQUERYARBPROC) load(userptr, "glBeginQueryARB");
7868 glad_glDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) load(userptr, "glDeleteQueriesARB");
7869 glad_glEndQueryARB = (PFNGLENDQUERYARBPROC) load(userptr, "glEndQueryARB");
7870 glad_glGenQueriesARB = (PFNGLGENQUERIESARBPROC) load(userptr, "glGenQueriesARB");
7871 glad_glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) load(userptr, "glGetQueryObjectivARB");
7872 glad_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) load(userptr, "glGetQueryObjectuivARB");
7873 glad_glGetQueryivARB = (PFNGLGETQUERYIVARBPROC) load(userptr, "glGetQueryivARB");
7874 glad_glIsQueryARB = (PFNGLISQUERYARBPROC) load(userptr, "glIsQueryARB");
7875}
7876static void glad_gl_load_GL_ARB_sample_locations( GLADuserptrloadfunc load, void* userptr) {
7877 if(!GLAD_GL_ARB_sample_locations) return;
7878 glad_glEvaluateDepthValuesARB = (PFNGLEVALUATEDEPTHVALUESARBPROC) load(userptr, "glEvaluateDepthValuesARB");
7879 glad_glFramebufferSampleLocationsfvARB = (PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) load(userptr, "glFramebufferSampleLocationsfvARB");
7880 glad_glNamedFramebufferSampleLocationsfvARB = (PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) load(userptr, "glNamedFramebufferSampleLocationsfvARB");
7881}
7882static void glad_gl_load_GL_ARB_sample_shading( GLADuserptrloadfunc load, void* userptr) {
7883 if(!GLAD_GL_ARB_sample_shading) return;
7884 glad_glMinSampleShadingARB = (PFNGLMINSAMPLESHADINGARBPROC) load(userptr, "glMinSampleShadingARB");
7885}
7886static void glad_gl_load_GL_ARB_shader_atomic_counters( GLADuserptrloadfunc load, void* userptr) {
7887 if(!GLAD_GL_ARB_shader_atomic_counters) return;
7888 glad_glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) load(userptr, "glGetActiveAtomicCounterBufferiv");
7889}
7890static void glad_gl_load_GL_ARB_shader_image_load_store( GLADuserptrloadfunc load, void* userptr) {
7891 if(!GLAD_GL_ARB_shader_image_load_store) return;
7892 glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC) load(userptr, "glBindImageTexture");
7893 glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC) load(userptr, "glMemoryBarrier");
7894}
7895static void glad_gl_load_GL_ARB_shader_objects( GLADuserptrloadfunc load, void* userptr) {
7896 if(!GLAD_GL_ARB_shader_objects) return;
7897 glad_glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) load(userptr, "glAttachObjectARB");
7898 glad_glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) load(userptr, "glCompileShaderARB");
7899 glad_glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) load(userptr, "glCreateProgramObjectARB");
7900 glad_glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) load(userptr, "glCreateShaderObjectARB");
7901 glad_glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) load(userptr, "glDeleteObjectARB");
7902 glad_glDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) load(userptr, "glDetachObjectARB");
7903 glad_glGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) load(userptr, "glGetActiveUniformARB");
7904 glad_glGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) load(userptr, "glGetAttachedObjectsARB");
7905 glad_glGetHandleARB = (PFNGLGETHANDLEARBPROC) load(userptr, "glGetHandleARB");
7906 glad_glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) load(userptr, "glGetInfoLogARB");
7907 glad_glGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) load(userptr, "glGetObjectParameterfvARB");
7908 glad_glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) load(userptr, "glGetObjectParameterivARB");
7909 glad_glGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) load(userptr, "glGetShaderSourceARB");
7910 glad_glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) load(userptr, "glGetUniformLocationARB");
7911 glad_glGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) load(userptr, "glGetUniformfvARB");
7912 glad_glGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) load(userptr, "glGetUniformivARB");
7913 glad_glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) load(userptr, "glLinkProgramARB");
7914 glad_glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) load(userptr, "glShaderSourceARB");
7915 glad_glUniform1fARB = (PFNGLUNIFORM1FARBPROC) load(userptr, "glUniform1fARB");
7916 glad_glUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) load(userptr, "glUniform1fvARB");
7917 glad_glUniform1iARB = (PFNGLUNIFORM1IARBPROC) load(userptr, "glUniform1iARB");
7918 glad_glUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) load(userptr, "glUniform1ivARB");
7919 glad_glUniform2fARB = (PFNGLUNIFORM2FARBPROC) load(userptr, "glUniform2fARB");
7920 glad_glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) load(userptr, "glUniform2fvARB");
7921 glad_glUniform2iARB = (PFNGLUNIFORM2IARBPROC) load(userptr, "glUniform2iARB");
7922 glad_glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) load(userptr, "glUniform2ivARB");
7923 glad_glUniform3fARB = (PFNGLUNIFORM3FARBPROC) load(userptr, "glUniform3fARB");
7924 glad_glUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) load(userptr, "glUniform3fvARB");
7925 glad_glUniform3iARB = (PFNGLUNIFORM3IARBPROC) load(userptr, "glUniform3iARB");
7926 glad_glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) load(userptr, "glUniform3ivARB");
7927 glad_glUniform4fARB = (PFNGLUNIFORM4FARBPROC) load(userptr, "glUniform4fARB");
7928 glad_glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) load(userptr, "glUniform4fvARB");
7929 glad_glUniform4iARB = (PFNGLUNIFORM4IARBPROC) load(userptr, "glUniform4iARB");
7930 glad_glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) load(userptr, "glUniform4ivARB");
7931 glad_glUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) load(userptr, "glUniformMatrix2fvARB");
7932 glad_glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) load(userptr, "glUniformMatrix3fvARB");
7933 glad_glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) load(userptr, "glUniformMatrix4fvARB");
7934 glad_glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) load(userptr, "glUseProgramObjectARB");
7935 glad_glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) load(userptr, "glValidateProgramARB");
7936}
7937static void glad_gl_load_GL_ARB_shader_storage_buffer_object( GLADuserptrloadfunc load, void* userptr) {
7938 if(!GLAD_GL_ARB_shader_storage_buffer_object) return;
7939 glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC) load(userptr, "glShaderStorageBlockBinding");
7940}
7941static void glad_gl_load_GL_ARB_shading_language_include( GLADuserptrloadfunc load, void* userptr) {
7942 if(!GLAD_GL_ARB_shading_language_include) return;
7943 glad_glCompileShaderIncludeARB = (PFNGLCOMPILESHADERINCLUDEARBPROC) load(userptr, "glCompileShaderIncludeARB");
7944 glad_glDeleteNamedStringARB = (PFNGLDELETENAMEDSTRINGARBPROC) load(userptr, "glDeleteNamedStringARB");
7945 glad_glGetNamedStringARB = (PFNGLGETNAMEDSTRINGARBPROC) load(userptr, "glGetNamedStringARB");
7946 glad_glGetNamedStringivARB = (PFNGLGETNAMEDSTRINGIVARBPROC) load(userptr, "glGetNamedStringivARB");
7947 glad_glIsNamedStringARB = (PFNGLISNAMEDSTRINGARBPROC) load(userptr, "glIsNamedStringARB");
7948 glad_glNamedStringARB = (PFNGLNAMEDSTRINGARBPROC) load(userptr, "glNamedStringARB");
7949}
7950static void glad_gl_load_GL_ARB_tessellation_shader( GLADuserptrloadfunc load, void* userptr) {
7951 if(!GLAD_GL_ARB_tessellation_shader) return;
7952 glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC) load(userptr, "glPatchParameterfv");
7953 glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC) load(userptr, "glPatchParameteri");
7954}
7955static void glad_gl_load_GL_ARB_texture_compression( GLADuserptrloadfunc load, void* userptr) {
7956 if(!GLAD_GL_ARB_texture_compression) return;
7957 glad_glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) load(userptr, "glCompressedTexImage1DARB");
7958 glad_glCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) load(userptr, "glCompressedTexImage2DARB");
7959 glad_glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) load(userptr, "glCompressedTexImage3DARB");
7960 glad_glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) load(userptr, "glCompressedTexSubImage1DARB");
7961 glad_glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) load(userptr, "glCompressedTexSubImage2DARB");
7962 glad_glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) load(userptr, "glCompressedTexSubImage3DARB");
7963 glad_glGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) load(userptr, "glGetCompressedTexImageARB");
7964}
7965static void glad_gl_load_GL_ARB_texture_multisample( GLADuserptrloadfunc load, void* userptr) {
7966 if(!GLAD_GL_ARB_texture_multisample) return;
7967 glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load(userptr, "glGetMultisamplefv");
7968 glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC) load(userptr, "glSampleMaski");
7969 glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load(userptr, "glTexImage2DMultisample");
7970 glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load(userptr, "glTexImage3DMultisample");
7971}
7972static void glad_gl_load_GL_ARB_texture_storage( GLADuserptrloadfunc load, void* userptr) {
7973 if(!GLAD_GL_ARB_texture_storage) return;
7974 glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC) load(userptr, "glTexStorage1D");
7975 glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC) load(userptr, "glTexStorage2D");
7976 glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC) load(userptr, "glTexStorage3D");
7977}
7978static void glad_gl_load_GL_ARB_texture_view( GLADuserptrloadfunc load, void* userptr) {
7979 if(!GLAD_GL_ARB_texture_view) return;
7980 glad_glTextureView = (PFNGLTEXTUREVIEWPROC) load(userptr, "glTextureView");
7981}
7982static void glad_gl_load_GL_ARB_timer_query( GLADuserptrloadfunc load, void* userptr) {
7983 if(!GLAD_GL_ARB_timer_query) return;
7984 glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load(userptr, "glGetQueryObjecti64v");
7985 glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load(userptr, "glGetQueryObjectui64v");
7986 glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC) load(userptr, "glQueryCounter");
7987}
7988static void glad_gl_load_GL_ARB_transpose_matrix( GLADuserptrloadfunc load, void* userptr) {
7989 if(!GLAD_GL_ARB_transpose_matrix) return;
7990 glad_glLoadTransposeMatrixdARB = (PFNGLLOADTRANSPOSEMATRIXDARBPROC) load(userptr, "glLoadTransposeMatrixdARB");
7991 glad_glLoadTransposeMatrixfARB = (PFNGLLOADTRANSPOSEMATRIXFARBPROC) load(userptr, "glLoadTransposeMatrixfARB");
7992 glad_glMultTransposeMatrixdARB = (PFNGLMULTTRANSPOSEMATRIXDARBPROC) load(userptr, "glMultTransposeMatrixdARB");
7993 glad_glMultTransposeMatrixfARB = (PFNGLMULTTRANSPOSEMATRIXFARBPROC) load(userptr, "glMultTransposeMatrixfARB");
7994}
7995static void glad_gl_load_GL_ARB_uniform_buffer_object( GLADuserptrloadfunc load, void* userptr) {
7996 if(!GLAD_GL_ARB_uniform_buffer_object) return;
7997 glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase");
7998 glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange");
7999 glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load(userptr, "glGetActiveUniformBlockName");
8000 glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load(userptr, "glGetActiveUniformBlockiv");
8001 glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load(userptr, "glGetActiveUniformName");
8002 glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load(userptr, "glGetActiveUniformsiv");
8003 glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v");
8004 glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load(userptr, "glGetUniformBlockIndex");
8005 glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load(userptr, "glGetUniformIndices");
8006 glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load(userptr, "glUniformBlockBinding");
8007}
8008static void glad_gl_load_GL_ARB_vertex_array_object( GLADuserptrloadfunc load, void* userptr) {
8009 if(!GLAD_GL_ARB_vertex_array_object) return;
8010 glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load(userptr, "glBindVertexArray");
8011 glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load(userptr, "glDeleteVertexArrays");
8012 glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load(userptr, "glGenVertexArrays");
8013 glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load(userptr, "glIsVertexArray");
8014}
8015static void glad_gl_load_GL_ARB_vertex_attrib_binding( GLADuserptrloadfunc load, void* userptr) {
8016 if(!GLAD_GL_ARB_vertex_attrib_binding) return;
8017 glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC) load(userptr, "glBindVertexBuffer");
8018 glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC) load(userptr, "glVertexAttribBinding");
8019 glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC) load(userptr, "glVertexAttribFormat");
8020 glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC) load(userptr, "glVertexAttribIFormat");
8021 glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC) load(userptr, "glVertexAttribLFormat");
8022 glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC) load(userptr, "glVertexBindingDivisor");
8023}
8024static void glad_gl_load_GL_ARB_vertex_buffer_object( GLADuserptrloadfunc load, void* userptr) {
8025 if(!GLAD_GL_ARB_vertex_buffer_object) return;
8026 glad_glBindBufferARB = (PFNGLBINDBUFFERARBPROC) load(userptr, "glBindBufferARB");
8027 glad_glBufferDataARB = (PFNGLBUFFERDATAARBPROC) load(userptr, "glBufferDataARB");
8028 glad_glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC) load(userptr, "glBufferSubDataARB");
8029 glad_glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) load(userptr, "glDeleteBuffersARB");
8030 glad_glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) load(userptr, "glGenBuffersARB");
8031 glad_glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) load(userptr, "glGetBufferParameterivARB");
8032 glad_glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) load(userptr, "glGetBufferPointervARB");
8033 glad_glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC) load(userptr, "glGetBufferSubDataARB");
8034 glad_glIsBufferARB = (PFNGLISBUFFERARBPROC) load(userptr, "glIsBufferARB");
8035 glad_glMapBufferARB = (PFNGLMAPBUFFERARBPROC) load(userptr, "glMapBufferARB");
8036 glad_glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC) load(userptr, "glUnmapBufferARB");
8037}
8038static void glad_gl_load_GL_ARB_vertex_program( GLADuserptrloadfunc load, void* userptr) {
8039 if(!GLAD_GL_ARB_vertex_program) return;
8040 glad_glBindProgramARB = (PFNGLBINDPROGRAMARBPROC) load(userptr, "glBindProgramARB");
8041 glad_glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) load(userptr, "glDeleteProgramsARB");
8042 glad_glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) load(userptr, "glDisableVertexAttribArrayARB");
8043 glad_glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) load(userptr, "glEnableVertexAttribArrayARB");
8044 glad_glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) load(userptr, "glGenProgramsARB");
8045 glad_glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC) load(userptr, "glGetProgramEnvParameterdvARB");
8046 glad_glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) load(userptr, "glGetProgramEnvParameterfvARB");
8047 glad_glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) load(userptr, "glGetProgramLocalParameterdvARB");
8048 glad_glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) load(userptr, "glGetProgramLocalParameterfvARB");
8049 glad_glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC) load(userptr, "glGetProgramStringARB");
8050 glad_glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) load(userptr, "glGetProgramivARB");
8051 glad_glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC) load(userptr, "glGetVertexAttribPointervARB");
8052 glad_glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC) load(userptr, "glGetVertexAttribdvARB");
8053 glad_glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) load(userptr, "glGetVertexAttribfvARB");
8054 glad_glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC) load(userptr, "glGetVertexAttribivARB");
8055 glad_glIsProgramARB = (PFNGLISPROGRAMARBPROC) load(userptr, "glIsProgramARB");
8056 glad_glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC) load(userptr, "glProgramEnvParameter4dARB");
8057 glad_glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC) load(userptr, "glProgramEnvParameter4dvARB");
8058 glad_glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC) load(userptr, "glProgramEnvParameter4fARB");
8059 glad_glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) load(userptr, "glProgramEnvParameter4fvARB");
8060 glad_glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) load(userptr, "glProgramLocalParameter4dARB");
8061 glad_glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) load(userptr, "glProgramLocalParameter4dvARB");
8062 glad_glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC) load(userptr, "glProgramLocalParameter4fARB");
8063 glad_glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) load(userptr, "glProgramLocalParameter4fvARB");
8064 glad_glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) load(userptr, "glProgramStringARB");
8065 glad_glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC) load(userptr, "glVertexAttrib1dARB");
8066 glad_glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC) load(userptr, "glVertexAttrib1dvARB");
8067 glad_glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC) load(userptr, "glVertexAttrib1fARB");
8068 glad_glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC) load(userptr, "glVertexAttrib1fvARB");
8069 glad_glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC) load(userptr, "glVertexAttrib1sARB");
8070 glad_glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC) load(userptr, "glVertexAttrib1svARB");
8071 glad_glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC) load(userptr, "glVertexAttrib2dARB");
8072 glad_glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC) load(userptr, "glVertexAttrib2dvARB");
8073 glad_glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC) load(userptr, "glVertexAttrib2fARB");
8074 glad_glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC) load(userptr, "glVertexAttrib2fvARB");
8075 glad_glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC) load(userptr, "glVertexAttrib2sARB");
8076 glad_glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC) load(userptr, "glVertexAttrib2svARB");
8077 glad_glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC) load(userptr, "glVertexAttrib3dARB");
8078 glad_glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC) load(userptr, "glVertexAttrib3dvARB");
8079 glad_glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC) load(userptr, "glVertexAttrib3fARB");
8080 glad_glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC) load(userptr, "glVertexAttrib3fvARB");
8081 glad_glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC) load(userptr, "glVertexAttrib3sARB");
8082 glad_glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC) load(userptr, "glVertexAttrib3svARB");
8083 glad_glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC) load(userptr, "glVertexAttrib4NbvARB");
8084 glad_glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC) load(userptr, "glVertexAttrib4NivARB");
8085 glad_glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC) load(userptr, "glVertexAttrib4NsvARB");
8086 glad_glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC) load(userptr, "glVertexAttrib4NubARB");
8087 glad_glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC) load(userptr, "glVertexAttrib4NubvARB");
8088 glad_glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC) load(userptr, "glVertexAttrib4NuivARB");
8089 glad_glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC) load(userptr, "glVertexAttrib4NusvARB");
8090 glad_glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC) load(userptr, "glVertexAttrib4bvARB");
8091 glad_glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC) load(userptr, "glVertexAttrib4dARB");
8092 glad_glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC) load(userptr, "glVertexAttrib4dvARB");
8093 glad_glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) load(userptr, "glVertexAttrib4fARB");
8094 glad_glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) load(userptr, "glVertexAttrib4fvARB");
8095 glad_glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC) load(userptr, "glVertexAttrib4ivARB");
8096 glad_glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC) load(userptr, "glVertexAttrib4sARB");
8097 glad_glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC) load(userptr, "glVertexAttrib4svARB");
8098 glad_glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC) load(userptr, "glVertexAttrib4ubvARB");
8099 glad_glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC) load(userptr, "glVertexAttrib4uivARB");
8100 glad_glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC) load(userptr, "glVertexAttrib4usvARB");
8101 glad_glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) load(userptr, "glVertexAttribPointerARB");
8102}
8103static void glad_gl_load_GL_ARB_vertex_shader( GLADuserptrloadfunc load, void* userptr) {
8104 if(!GLAD_GL_ARB_vertex_shader) return;
8105 glad_glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) load(userptr, "glBindAttribLocationARB");
8106 glad_glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) load(userptr, "glDisableVertexAttribArrayARB");
8107 glad_glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) load(userptr, "glEnableVertexAttribArrayARB");
8108 glad_glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) load(userptr, "glGetActiveAttribARB");
8109 glad_glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) load(userptr, "glGetAttribLocationARB");
8110 glad_glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC) load(userptr, "glGetVertexAttribPointervARB");
8111 glad_glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC) load(userptr, "glGetVertexAttribdvARB");
8112 glad_glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) load(userptr, "glGetVertexAttribfvARB");
8113 glad_glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC) load(userptr, "glGetVertexAttribivARB");
8114 glad_glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC) load(userptr, "glVertexAttrib1dARB");
8115 glad_glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC) load(userptr, "glVertexAttrib1dvARB");
8116 glad_glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC) load(userptr, "glVertexAttrib1fARB");
8117 glad_glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC) load(userptr, "glVertexAttrib1fvARB");
8118 glad_glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC) load(userptr, "glVertexAttrib1sARB");
8119 glad_glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC) load(userptr, "glVertexAttrib1svARB");
8120 glad_glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC) load(userptr, "glVertexAttrib2dARB");
8121 glad_glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC) load(userptr, "glVertexAttrib2dvARB");
8122 glad_glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC) load(userptr, "glVertexAttrib2fARB");
8123 glad_glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC) load(userptr, "glVertexAttrib2fvARB");
8124 glad_glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC) load(userptr, "glVertexAttrib2sARB");
8125 glad_glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC) load(userptr, "glVertexAttrib2svARB");
8126 glad_glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC) load(userptr, "glVertexAttrib3dARB");
8127 glad_glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC) load(userptr, "glVertexAttrib3dvARB");
8128 glad_glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC) load(userptr, "glVertexAttrib3fARB");
8129 glad_glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC) load(userptr, "glVertexAttrib3fvARB");
8130 glad_glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC) load(userptr, "glVertexAttrib3sARB");
8131 glad_glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC) load(userptr, "glVertexAttrib3svARB");
8132 glad_glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC) load(userptr, "glVertexAttrib4NbvARB");
8133 glad_glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC) load(userptr, "glVertexAttrib4NivARB");
8134 glad_glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC) load(userptr, "glVertexAttrib4NsvARB");
8135 glad_glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC) load(userptr, "glVertexAttrib4NubARB");
8136 glad_glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC) load(userptr, "glVertexAttrib4NubvARB");
8137 glad_glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC) load(userptr, "glVertexAttrib4NuivARB");
8138 glad_glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC) load(userptr, "glVertexAttrib4NusvARB");
8139 glad_glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC) load(userptr, "glVertexAttrib4bvARB");
8140 glad_glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC) load(userptr, "glVertexAttrib4dARB");
8141 glad_glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC) load(userptr, "glVertexAttrib4dvARB");
8142 glad_glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) load(userptr, "glVertexAttrib4fARB");
8143 glad_glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) load(userptr, "glVertexAttrib4fvARB");
8144 glad_glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC) load(userptr, "glVertexAttrib4ivARB");
8145 glad_glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC) load(userptr, "glVertexAttrib4sARB");
8146 glad_glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC) load(userptr, "glVertexAttrib4svARB");
8147 glad_glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC) load(userptr, "glVertexAttrib4ubvARB");
8148 glad_glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC) load(userptr, "glVertexAttrib4uivARB");
8149 glad_glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC) load(userptr, "glVertexAttrib4usvARB");
8150 glad_glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) load(userptr, "glVertexAttribPointerARB");
8151}
8152static void glad_gl_load_GL_EXT_draw_instanced( GLADuserptrloadfunc load, void* userptr) {
8153 if(!GLAD_GL_EXT_draw_instanced) return;
8154 glad_glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC) load(userptr, "glDrawArraysInstancedEXT");
8155 glad_glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) load(userptr, "glDrawElementsInstancedEXT");
8156}
8157static void glad_gl_load_GL_EXT_fog_coord( GLADuserptrloadfunc load, void* userptr) {
8158 if(!GLAD_GL_EXT_fog_coord) return;
8159 glad_glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC) load(userptr, "glFogCoordPointerEXT");
8160 glad_glFogCoorddEXT = (PFNGLFOGCOORDDEXTPROC) load(userptr, "glFogCoorddEXT");
8161 glad_glFogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC) load(userptr, "glFogCoorddvEXT");
8162 glad_glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC) load(userptr, "glFogCoordfEXT");
8163 glad_glFogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC) load(userptr, "glFogCoordfvEXT");
8164}
8165static void glad_gl_load_GL_EXT_framebuffer_blit( GLADuserptrloadfunc load, void* userptr) {
8166 if(!GLAD_GL_EXT_framebuffer_blit) return;
8167 glad_glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC) load(userptr, "glBlitFramebufferEXT");
8168}
8169static void glad_gl_load_GL_EXT_framebuffer_multisample( GLADuserptrloadfunc load, void* userptr) {
8170 if(!GLAD_GL_EXT_framebuffer_multisample) return;
8171 glad_glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) load(userptr, "glRenderbufferStorageMultisampleEXT");
8172}
8173static void glad_gl_load_GL_EXT_framebuffer_object( GLADuserptrloadfunc load, void* userptr) {
8174 if(!GLAD_GL_EXT_framebuffer_object) return;
8175 glad_glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) load(userptr, "glBindFramebufferEXT");
8176 glad_glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) load(userptr, "glBindRenderbufferEXT");
8177 glad_glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) load(userptr, "glCheckFramebufferStatusEXT");
8178 glad_glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) load(userptr, "glDeleteFramebuffersEXT");
8179 glad_glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) load(userptr, "glDeleteRenderbuffersEXT");
8180 glad_glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) load(userptr, "glFramebufferRenderbufferEXT");
8181 glad_glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) load(userptr, "glFramebufferTexture1DEXT");
8182 glad_glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) load(userptr, "glFramebufferTexture2DEXT");
8183 glad_glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) load(userptr, "glFramebufferTexture3DEXT");
8184 glad_glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) load(userptr, "glGenFramebuffersEXT");
8185 glad_glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) load(userptr, "glGenRenderbuffersEXT");
8186 glad_glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) load(userptr, "glGenerateMipmapEXT");
8187 glad_glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) load(userptr, "glGetFramebufferAttachmentParameterivEXT");
8188 glad_glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) load(userptr, "glGetRenderbufferParameterivEXT");
8189 glad_glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) load(userptr, "glIsFramebufferEXT");
8190 glad_glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) load(userptr, "glIsRenderbufferEXT");
8191 glad_glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) load(userptr, "glRenderbufferStorageEXT");
8192}
8193static void glad_gl_load_GL_OES_fixed_point( GLADuserptrloadfunc load, void* userptr) {
8194 if(!GLAD_GL_OES_fixed_point) return;
8195 glad_glAccumxOES = (PFNGLACCUMXOESPROC) load(userptr, "glAccumxOES");
8196 glad_glAlphaFuncxOES = (PFNGLALPHAFUNCXOESPROC) load(userptr, "glAlphaFuncxOES");
8197 glad_glBitmapxOES = (PFNGLBITMAPXOESPROC) load(userptr, "glBitmapxOES");
8198 glad_glBlendColorxOES = (PFNGLBLENDCOLORXOESPROC) load(userptr, "glBlendColorxOES");
8199 glad_glClearAccumxOES = (PFNGLCLEARACCUMXOESPROC) load(userptr, "glClearAccumxOES");
8200 glad_glClearColorxOES = (PFNGLCLEARCOLORXOESPROC) load(userptr, "glClearColorxOES");
8201 glad_glClearDepthxOES = (PFNGLCLEARDEPTHXOESPROC) load(userptr, "glClearDepthxOES");
8202 glad_glClipPlanexOES = (PFNGLCLIPPLANEXOESPROC) load(userptr, "glClipPlanexOES");
8203 glad_glColor3xOES = (PFNGLCOLOR3XOESPROC) load(userptr, "glColor3xOES");
8204 glad_glColor3xvOES = (PFNGLCOLOR3XVOESPROC) load(userptr, "glColor3xvOES");
8205 glad_glColor4xOES = (PFNGLCOLOR4XOESPROC) load(userptr, "glColor4xOES");
8206 glad_glColor4xvOES = (PFNGLCOLOR4XVOESPROC) load(userptr, "glColor4xvOES");
8207 glad_glConvolutionParameterxOES = (PFNGLCONVOLUTIONPARAMETERXOESPROC) load(userptr, "glConvolutionParameterxOES");
8208 glad_glConvolutionParameterxvOES = (PFNGLCONVOLUTIONPARAMETERXVOESPROC) load(userptr, "glConvolutionParameterxvOES");
8209 glad_glDepthRangexOES = (PFNGLDEPTHRANGEXOESPROC) load(userptr, "glDepthRangexOES");
8210 glad_glEvalCoord1xOES = (PFNGLEVALCOORD1XOESPROC) load(userptr, "glEvalCoord1xOES");
8211 glad_glEvalCoord1xvOES = (PFNGLEVALCOORD1XVOESPROC) load(userptr, "glEvalCoord1xvOES");
8212 glad_glEvalCoord2xOES = (PFNGLEVALCOORD2XOESPROC) load(userptr, "glEvalCoord2xOES");
8213 glad_glEvalCoord2xvOES = (PFNGLEVALCOORD2XVOESPROC) load(userptr, "glEvalCoord2xvOES");
8214 glad_glFeedbackBufferxOES = (PFNGLFEEDBACKBUFFERXOESPROC) load(userptr, "glFeedbackBufferxOES");
8215 glad_glFogxOES = (PFNGLFOGXOESPROC) load(userptr, "glFogxOES");
8216 glad_glFogxvOES = (PFNGLFOGXVOESPROC) load(userptr, "glFogxvOES");
8217 glad_glFrustumxOES = (PFNGLFRUSTUMXOESPROC) load(userptr, "glFrustumxOES");
8218 glad_glGetClipPlanexOES = (PFNGLGETCLIPPLANEXOESPROC) load(userptr, "glGetClipPlanexOES");
8219 glad_glGetConvolutionParameterxvOES = (PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) load(userptr, "glGetConvolutionParameterxvOES");
8220 glad_glGetFixedvOES = (PFNGLGETFIXEDVOESPROC) load(userptr, "glGetFixedvOES");
8221 glad_glGetHistogramParameterxvOES = (PFNGLGETHISTOGRAMPARAMETERXVOESPROC) load(userptr, "glGetHistogramParameterxvOES");
8222 glad_glGetLightxOES = (PFNGLGETLIGHTXOESPROC) load(userptr, "glGetLightxOES");
8223 glad_glGetMapxvOES = (PFNGLGETMAPXVOESPROC) load(userptr, "glGetMapxvOES");
8224 glad_glGetMaterialxOES = (PFNGLGETMATERIALXOESPROC) load(userptr, "glGetMaterialxOES");
8225 glad_glGetPixelMapxv = (PFNGLGETPIXELMAPXVPROC) load(userptr, "glGetPixelMapxv");
8226 glad_glGetTexEnvxvOES = (PFNGLGETTEXENVXVOESPROC) load(userptr, "glGetTexEnvxvOES");
8227 glad_glGetTexGenxvOES = (PFNGLGETTEXGENXVOESPROC) load(userptr, "glGetTexGenxvOES");
8228 glad_glGetTexLevelParameterxvOES = (PFNGLGETTEXLEVELPARAMETERXVOESPROC) load(userptr, "glGetTexLevelParameterxvOES");
8229 glad_glGetTexParameterxvOES = (PFNGLGETTEXPARAMETERXVOESPROC) load(userptr, "glGetTexParameterxvOES");
8230 glad_glIndexxOES = (PFNGLINDEXXOESPROC) load(userptr, "glIndexxOES");
8231 glad_glIndexxvOES = (PFNGLINDEXXVOESPROC) load(userptr, "glIndexxvOES");
8232 glad_glLightModelxOES = (PFNGLLIGHTMODELXOESPROC) load(userptr, "glLightModelxOES");
8233 glad_glLightModelxvOES = (PFNGLLIGHTMODELXVOESPROC) load(userptr, "glLightModelxvOES");
8234 glad_glLightxOES = (PFNGLLIGHTXOESPROC) load(userptr, "glLightxOES");
8235 glad_glLightxvOES = (PFNGLLIGHTXVOESPROC) load(userptr, "glLightxvOES");
8236 glad_glLineWidthxOES = (PFNGLLINEWIDTHXOESPROC) load(userptr, "glLineWidthxOES");
8237 glad_glLoadMatrixxOES = (PFNGLLOADMATRIXXOESPROC) load(userptr, "glLoadMatrixxOES");
8238 glad_glLoadTransposeMatrixxOES = (PFNGLLOADTRANSPOSEMATRIXXOESPROC) load(userptr, "glLoadTransposeMatrixxOES");
8239 glad_glMap1xOES = (PFNGLMAP1XOESPROC) load(userptr, "glMap1xOES");
8240 glad_glMap2xOES = (PFNGLMAP2XOESPROC) load(userptr, "glMap2xOES");
8241 glad_glMapGrid1xOES = (PFNGLMAPGRID1XOESPROC) load(userptr, "glMapGrid1xOES");
8242 glad_glMapGrid2xOES = (PFNGLMAPGRID2XOESPROC) load(userptr, "glMapGrid2xOES");
8243 glad_glMaterialxOES = (PFNGLMATERIALXOESPROC) load(userptr, "glMaterialxOES");
8244 glad_glMaterialxvOES = (PFNGLMATERIALXVOESPROC) load(userptr, "glMaterialxvOES");
8245 glad_glMultMatrixxOES = (PFNGLMULTMATRIXXOESPROC) load(userptr, "glMultMatrixxOES");
8246 glad_glMultTransposeMatrixxOES = (PFNGLMULTTRANSPOSEMATRIXXOESPROC) load(userptr, "glMultTransposeMatrixxOES");
8247 glad_glMultiTexCoord1xOES = (PFNGLMULTITEXCOORD1XOESPROC) load(userptr, "glMultiTexCoord1xOES");
8248 glad_glMultiTexCoord1xvOES = (PFNGLMULTITEXCOORD1XVOESPROC) load(userptr, "glMultiTexCoord1xvOES");
8249 glad_glMultiTexCoord2xOES = (PFNGLMULTITEXCOORD2XOESPROC) load(userptr, "glMultiTexCoord2xOES");
8250 glad_glMultiTexCoord2xvOES = (PFNGLMULTITEXCOORD2XVOESPROC) load(userptr, "glMultiTexCoord2xvOES");
8251 glad_glMultiTexCoord3xOES = (PFNGLMULTITEXCOORD3XOESPROC) load(userptr, "glMultiTexCoord3xOES");
8252 glad_glMultiTexCoord3xvOES = (PFNGLMULTITEXCOORD3XVOESPROC) load(userptr, "glMultiTexCoord3xvOES");
8253 glad_glMultiTexCoord4xOES = (PFNGLMULTITEXCOORD4XOESPROC) load(userptr, "glMultiTexCoord4xOES");
8254 glad_glMultiTexCoord4xvOES = (PFNGLMULTITEXCOORD4XVOESPROC) load(userptr, "glMultiTexCoord4xvOES");
8255 glad_glNormal3xOES = (PFNGLNORMAL3XOESPROC) load(userptr, "glNormal3xOES");
8256 glad_glNormal3xvOES = (PFNGLNORMAL3XVOESPROC) load(userptr, "glNormal3xvOES");
8257 glad_glOrthoxOES = (PFNGLORTHOXOESPROC) load(userptr, "glOrthoxOES");
8258 glad_glPassThroughxOES = (PFNGLPASSTHROUGHXOESPROC) load(userptr, "glPassThroughxOES");
8259 glad_glPixelMapx = (PFNGLPIXELMAPXPROC) load(userptr, "glPixelMapx");
8260 glad_glPixelStorex = (PFNGLPIXELSTOREXPROC) load(userptr, "glPixelStorex");
8261 glad_glPixelTransferxOES = (PFNGLPIXELTRANSFERXOESPROC) load(userptr, "glPixelTransferxOES");
8262 glad_glPixelZoomxOES = (PFNGLPIXELZOOMXOESPROC) load(userptr, "glPixelZoomxOES");
8263 glad_glPointParameterxvOES = (PFNGLPOINTPARAMETERXVOESPROC) load(userptr, "glPointParameterxvOES");
8264 glad_glPointSizexOES = (PFNGLPOINTSIZEXOESPROC) load(userptr, "glPointSizexOES");
8265 glad_glPolygonOffsetxOES = (PFNGLPOLYGONOFFSETXOESPROC) load(userptr, "glPolygonOffsetxOES");
8266 glad_glPrioritizeTexturesxOES = (PFNGLPRIORITIZETEXTURESXOESPROC) load(userptr, "glPrioritizeTexturesxOES");
8267 glad_glRasterPos2xOES = (PFNGLRASTERPOS2XOESPROC) load(userptr, "glRasterPos2xOES");
8268 glad_glRasterPos2xvOES = (PFNGLRASTERPOS2XVOESPROC) load(userptr, "glRasterPos2xvOES");
8269 glad_glRasterPos3xOES = (PFNGLRASTERPOS3XOESPROC) load(userptr, "glRasterPos3xOES");
8270 glad_glRasterPos3xvOES = (PFNGLRASTERPOS3XVOESPROC) load(userptr, "glRasterPos3xvOES");
8271 glad_glRasterPos4xOES = (PFNGLRASTERPOS4XOESPROC) load(userptr, "glRasterPos4xOES");
8272 glad_glRasterPos4xvOES = (PFNGLRASTERPOS4XVOESPROC) load(userptr, "glRasterPos4xvOES");
8273 glad_glRectxOES = (PFNGLRECTXOESPROC) load(userptr, "glRectxOES");
8274 glad_glRectxvOES = (PFNGLRECTXVOESPROC) load(userptr, "glRectxvOES");
8275 glad_glRotatexOES = (PFNGLROTATEXOESPROC) load(userptr, "glRotatexOES");
8276 glad_glScalexOES = (PFNGLSCALEXOESPROC) load(userptr, "glScalexOES");
8277 glad_glTexCoord1xOES = (PFNGLTEXCOORD1XOESPROC) load(userptr, "glTexCoord1xOES");
8278 glad_glTexCoord1xvOES = (PFNGLTEXCOORD1XVOESPROC) load(userptr, "glTexCoord1xvOES");
8279 glad_glTexCoord2xOES = (PFNGLTEXCOORD2XOESPROC) load(userptr, "glTexCoord2xOES");
8280 glad_glTexCoord2xvOES = (PFNGLTEXCOORD2XVOESPROC) load(userptr, "glTexCoord2xvOES");
8281 glad_glTexCoord3xOES = (PFNGLTEXCOORD3XOESPROC) load(userptr, "glTexCoord3xOES");
8282 glad_glTexCoord3xvOES = (PFNGLTEXCOORD3XVOESPROC) load(userptr, "glTexCoord3xvOES");
8283 glad_glTexCoord4xOES = (PFNGLTEXCOORD4XOESPROC) load(userptr, "glTexCoord4xOES");
8284 glad_glTexCoord4xvOES = (PFNGLTEXCOORD4XVOESPROC) load(userptr, "glTexCoord4xvOES");
8285 glad_glTexEnvxOES = (PFNGLTEXENVXOESPROC) load(userptr, "glTexEnvxOES");
8286 glad_glTexEnvxvOES = (PFNGLTEXENVXVOESPROC) load(userptr, "glTexEnvxvOES");
8287 glad_glTexGenxOES = (PFNGLTEXGENXOESPROC) load(userptr, "glTexGenxOES");
8288 glad_glTexGenxvOES = (PFNGLTEXGENXVOESPROC) load(userptr, "glTexGenxvOES");
8289 glad_glTexParameterxOES = (PFNGLTEXPARAMETERXOESPROC) load(userptr, "glTexParameterxOES");
8290 glad_glTexParameterxvOES = (PFNGLTEXPARAMETERXVOESPROC) load(userptr, "glTexParameterxvOES");
8291 glad_glTranslatexOES = (PFNGLTRANSLATEXOESPROC) load(userptr, "glTranslatexOES");
8292 glad_glVertex2xOES = (PFNGLVERTEX2XOESPROC) load(userptr, "glVertex2xOES");
8293 glad_glVertex2xvOES = (PFNGLVERTEX2XVOESPROC) load(userptr, "glVertex2xvOES");
8294 glad_glVertex3xOES = (PFNGLVERTEX3XOESPROC) load(userptr, "glVertex3xOES");
8295 glad_glVertex3xvOES = (PFNGLVERTEX3XVOESPROC) load(userptr, "glVertex3xvOES");
8296 glad_glVertex4xOES = (PFNGLVERTEX4XOESPROC) load(userptr, "glVertex4xOES");
8297 glad_glVertex4xvOES = (PFNGLVERTEX4XVOESPROC) load(userptr, "glVertex4xvOES");
8298}
8299
8300
8301
8302#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
8303#define GLAD_GL_IS_SOME_NEW_VERSION 1
8304#else
8305#define GLAD_GL_IS_SOME_NEW_VERSION 0
8306#endif
8307
8308static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
8309#if GLAD_GL_IS_SOME_NEW_VERSION
8310 if(GLAD_VERSION_MAJOR(version) < 3) {
8311#else
8312 (void) version;
8313 (void) out_num_exts_i;
8314 (void) out_exts_i;
8315#endif
8316 if (glad_glGetString == NULL) {
8317 return 0;
8318 }
8319 *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS);
8320#if GLAD_GL_IS_SOME_NEW_VERSION
8321 } else {
8322 unsigned int index = 0;
8323 unsigned int num_exts_i = 0;
8324 char **exts_i = NULL;
8325 if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) {
8326 return 0;
8327 }
8328 glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
8329 if (num_exts_i > 0) {
8330 exts_i = (char **) GLAD_MALLOC(num_exts_i * (sizeof *exts_i));
8331 }
8332 if (exts_i == NULL) {
8333 return 0;
8334 }
8335 for(index = 0; index < num_exts_i; index++) {
8336 const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index);
8337 size_t len = strlen(gl_str_tmp) + 1;
8338
8339 char *local_str = (char*) GLAD_MALLOC(len * sizeof(char));
8340 if(local_str != NULL) {
8341 memcpy(local_str, gl_str_tmp, len * sizeof(char));
8342 }
8343
8344 exts_i[index] = local_str;
8345 }
8346
8347 *out_num_exts_i = num_exts_i;
8348 *out_exts_i = exts_i;
8349 }
8350#endif
8351 return 1;
8352}
8353static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
8354 if (exts_i != NULL) {
8355 unsigned int index;
8356 for(index = 0; index < num_exts_i; index++) {
8357 GLAD_FREE((void *) (exts_i[index]));
8358 }
8359 GLAD_FREE((void *)exts_i);
8360 exts_i = NULL;
8361 }
8362}
8363static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
8364 if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
8365 const char *extensions;
8366 const char *loc;
8367 const char *terminator;
8368 extensions = exts;
8369 if(extensions == NULL || ext == NULL) {
8370 return 0;
8371 }
8372 while(1) {
8373 loc = strstr(extensions, ext);
8374 if(loc == NULL) {
8375 return 0;
8376 }
8377 terminator = loc + strlen(ext);
8378 if((loc == extensions || *(loc - 1) == ' ') &&
8379 (*terminator == ' ' || *terminator == '\0')) {
8380 return 1;
8381 }
8382 extensions = terminator;
8383 }
8384 } else {
8385 unsigned int index;
8386 for(index = 0; index < num_exts_i; index++) {
8387 const char *e = exts_i[index];
8388 if(strcmp(e, ext) == 0) {
8389 return 1;
8390 }
8391 }
8392 }
8393 return 0;
8394}
8395
8396static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
8397 return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
8398}
8399
8400static int glad_gl_find_extensions_gl( int version) {
8401 const char *exts = NULL;
8402 unsigned int num_exts_i = 0;
8403 char **exts_i = NULL;
8404 if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
8405
8406 GLAD_GL_ARB_ES2_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_ES2_compatibility");
8407 GLAD_GL_ARB_ES3_1_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_ES3_1_compatibility");
8408 GLAD_GL_ARB_ES3_2_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_ES3_2_compatibility");
8409 GLAD_GL_ARB_ES3_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_ES3_compatibility");
8410 GLAD_GL_ARB_blend_func_extended = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_blend_func_extended");
8411 GLAD_GL_ARB_buffer_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_buffer_storage");
8412 GLAD_GL_ARB_clear_buffer_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_clear_buffer_object");
8413 GLAD_GL_ARB_clear_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_clear_texture");
8414 GLAD_GL_ARB_color_buffer_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_color_buffer_float");
8415 GLAD_GL_ARB_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_compatibility");
8416 GLAD_GL_ARB_compressed_texture_pixel_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_compressed_texture_pixel_storage");
8417 GLAD_GL_ARB_compute_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_compute_shader");
8418 GLAD_GL_ARB_compute_variable_group_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_compute_variable_group_size");
8419 GLAD_GL_ARB_copy_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_copy_buffer");
8420 GLAD_GL_ARB_copy_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_copy_image");
8421 GLAD_GL_ARB_debug_output = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_debug_output");
8422 GLAD_GL_ARB_depth_buffer_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_depth_buffer_float");
8423 GLAD_GL_ARB_depth_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_depth_clamp");
8424 GLAD_GL_ARB_depth_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_depth_texture");
8425 GLAD_GL_ARB_direct_state_access = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_direct_state_access");
8426 GLAD_GL_ARB_draw_buffers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_draw_buffers");
8427 GLAD_GL_ARB_draw_buffers_blend = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_draw_buffers_blend");
8428 GLAD_GL_ARB_draw_elements_base_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_draw_elements_base_vertex");
8429 GLAD_GL_ARB_draw_indirect = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_draw_indirect");
8430 GLAD_GL_ARB_draw_instanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_draw_instanced");
8431 GLAD_GL_ARB_enhanced_layouts = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_enhanced_layouts");
8432 GLAD_GL_ARB_explicit_attrib_location = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_explicit_attrib_location");
8433 GLAD_GL_ARB_explicit_uniform_location = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_explicit_uniform_location");
8434 GLAD_GL_ARB_fragment_coord_conventions = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_fragment_coord_conventions");
8435 GLAD_GL_ARB_fragment_layer_viewport = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_fragment_layer_viewport");
8436 GLAD_GL_ARB_fragment_program = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_fragment_program");
8437 GLAD_GL_ARB_fragment_program_shadow = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_fragment_program_shadow");
8438 GLAD_GL_ARB_fragment_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_fragment_shader");
8439 GLAD_GL_ARB_fragment_shader_interlock = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_fragment_shader_interlock");
8440 GLAD_GL_ARB_framebuffer_no_attachments = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_framebuffer_no_attachments");
8441 GLAD_GL_ARB_framebuffer_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_framebuffer_object");
8442 GLAD_GL_ARB_framebuffer_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_framebuffer_sRGB");
8443 GLAD_GL_ARB_geometry_shader4 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_geometry_shader4");
8444 GLAD_GL_ARB_get_program_binary = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_get_program_binary");
8445 GLAD_GL_ARB_get_texture_sub_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_get_texture_sub_image");
8446 GLAD_GL_ARB_gl_spirv = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_gl_spirv");
8447 GLAD_GL_ARB_gpu_shader5 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_gpu_shader5");
8448 GLAD_GL_ARB_gpu_shader_fp64 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_gpu_shader_fp64");
8449 GLAD_GL_ARB_gpu_shader_int64 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_gpu_shader_int64");
8450 GLAD_GL_ARB_half_float_pixel = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_half_float_pixel");
8451 GLAD_GL_ARB_half_float_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_half_float_vertex");
8452 GLAD_GL_ARB_instanced_arrays = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_instanced_arrays");
8453 GLAD_GL_ARB_internalformat_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_internalformat_query");
8454 GLAD_GL_ARB_internalformat_query2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_internalformat_query2");
8455 GLAD_GL_ARB_map_buffer_range = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_map_buffer_range");
8456 GLAD_GL_ARB_multi_bind = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multi_bind");
8457 GLAD_GL_ARB_multi_draw_indirect = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multi_draw_indirect");
8458 GLAD_GL_ARB_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multisample");
8459 GLAD_GL_ARB_multitexture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multitexture");
8460 GLAD_GL_ARB_occlusion_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_occlusion_query");
8461 GLAD_GL_ARB_occlusion_query2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_occlusion_query2");
8462 GLAD_GL_ARB_pipeline_statistics_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_pipeline_statistics_query");
8463 GLAD_GL_ARB_query_buffer_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_query_buffer_object");
8464 GLAD_GL_ARB_sample_locations = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_sample_locations");
8465 GLAD_GL_ARB_sample_shading = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_sample_shading");
8466 GLAD_GL_ARB_seamless_cube_map = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_seamless_cube_map");
8467 GLAD_GL_ARB_seamless_cubemap_per_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_seamless_cubemap_per_texture");
8468 GLAD_GL_ARB_shader_atomic_counter_ops = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_atomic_counter_ops");
8469 GLAD_GL_ARB_shader_atomic_counters = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_atomic_counters");
8470 GLAD_GL_ARB_shader_bit_encoding = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_bit_encoding");
8471 GLAD_GL_ARB_shader_clock = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_clock");
8472 GLAD_GL_ARB_shader_image_load_store = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_image_load_store");
8473 GLAD_GL_ARB_shader_image_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_image_size");
8474 GLAD_GL_ARB_shader_objects = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_objects");
8475 GLAD_GL_ARB_shader_storage_buffer_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_storage_buffer_object");
8476 GLAD_GL_ARB_shader_texture_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shader_texture_lod");
8477 GLAD_GL_ARB_shading_language_100 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shading_language_100");
8478 GLAD_GL_ARB_shading_language_420pack = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shading_language_420pack");
8479 GLAD_GL_ARB_shading_language_include = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shading_language_include");
8480 GLAD_GL_ARB_shading_language_packing = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_shading_language_packing");
8481 GLAD_GL_ARB_spirv_extensions = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_spirv_extensions");
8482 GLAD_GL_ARB_tessellation_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_tessellation_shader");
8483 GLAD_GL_ARB_texture_border_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_border_clamp");
8484 GLAD_GL_ARB_texture_buffer_object_rgb32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_buffer_object_rgb32");
8485 GLAD_GL_ARB_texture_compression = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_compression");
8486 GLAD_GL_ARB_texture_cube_map = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_cube_map");
8487 GLAD_GL_ARB_texture_cube_map_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_cube_map_array");
8488 GLAD_GL_ARB_texture_env_add = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_env_add");
8489 GLAD_GL_ARB_texture_filter_anisotropic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_filter_anisotropic");
8490 GLAD_GL_ARB_texture_filter_minmax = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_filter_minmax");
8491 GLAD_GL_ARB_texture_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_float");
8492 GLAD_GL_ARB_texture_mirror_clamp_to_edge = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_mirror_clamp_to_edge");
8493 GLAD_GL_ARB_texture_mirrored_repeat = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_mirrored_repeat");
8494 GLAD_GL_ARB_texture_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_multisample");
8495 GLAD_GL_ARB_texture_non_power_of_two = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_non_power_of_two");
8496 GLAD_GL_ARB_texture_rg = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_rg");
8497 GLAD_GL_ARB_texture_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_storage");
8498 GLAD_GL_ARB_texture_swizzle = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_swizzle");
8499 GLAD_GL_ARB_texture_view = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_texture_view");
8500 GLAD_GL_ARB_timer_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_timer_query");
8501 GLAD_GL_ARB_transpose_matrix = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_transpose_matrix");
8502 GLAD_GL_ARB_uniform_buffer_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_uniform_buffer_object");
8503 GLAD_GL_ARB_vertex_array_bgra = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_vertex_array_bgra");
8504 GLAD_GL_ARB_vertex_array_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_vertex_array_object");
8505 GLAD_GL_ARB_vertex_attrib_binding = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_vertex_attrib_binding");
8506 GLAD_GL_ARB_vertex_buffer_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_vertex_buffer_object");
8507 GLAD_GL_ARB_vertex_program = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_vertex_program");
8508 GLAD_GL_ARB_vertex_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_vertex_shader");
8509 GLAD_GL_EXT_draw_instanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_instanced");
8510 GLAD_GL_EXT_fog_coord = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_fog_coord");
8511 GLAD_GL_EXT_framebuffer_blit = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_framebuffer_blit");
8512 GLAD_GL_EXT_framebuffer_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_framebuffer_multisample");
8513 GLAD_GL_EXT_framebuffer_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_framebuffer_object");
8514 GLAD_GL_EXT_framebuffer_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_framebuffer_sRGB");
8515 GLAD_GL_EXT_texture_compression_s3tc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_s3tc");
8516 GLAD_GL_EXT_texture_filter_anisotropic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_filter_anisotropic");
8517 GLAD_GL_EXT_texture_mirror_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_mirror_clamp");
8518 GLAD_GL_KHR_texture_compression_astc_hdr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_hdr");
8519 GLAD_GL_KHR_texture_compression_astc_ldr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_ldr");
8520 GLAD_GL_OES_compressed_paletted_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_paletted_texture");
8521 GLAD_GL_OES_fixed_point = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_fixed_point");
8522
8523 glad_gl_free_extensions(exts_i, num_exts_i);
8524
8525 return 1;
8526}
8527
8528static int glad_gl_find_core_gl(void) {
8529 int i;
8530 const char* version;
8531 const char* prefixes[] = {
8532 "OpenGL ES-CM ",
8533 "OpenGL ES-CL ",
8534 "OpenGL ES ",
8535 "OpenGL SC ",
8536 NULL
8537 };
8538 int major = 0;
8539 int minor = 0;
8540 version = (const char*) glad_glGetString(GL_VERSION);
8541 if (!version) return 0;
8542 for (i = 0; prefixes[i]; i++) {
8543 const size_t length = strlen(prefixes[i]);
8544 if (strncmp(version, prefixes[i], length) == 0) {
8545 version += length;
8546 break;
8547 }
8548 }
8549
8550 GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
8551
8552 GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
8553 GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
8554 GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
8555 GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
8556 GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
8557 GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
8558 GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
8559 GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
8560 GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
8561 GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
8562 GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
8563 GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
8564 GLAD_GL_VERSION_4_0 = (major == 4 && minor >= 0) || major > 4;
8565 GLAD_GL_VERSION_4_1 = (major == 4 && minor >= 1) || major > 4;
8566 GLAD_GL_VERSION_4_2 = (major == 4 && minor >= 2) || major > 4;
8567 GLAD_GL_VERSION_4_3 = (major == 4 && minor >= 3) || major > 4;
8568
8569 return GLAD_MAKE_VERSION(major, minor);
8570}
8571
8572int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) {
8573 int version;
8574
8575 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
8576 if(glad_glGetString == NULL) return 0;
8577 if(glad_glGetString(GL_VERSION) == NULL) return 0;
8578 version = glad_gl_find_core_gl();
8579
8580 glad_gl_load_GL_VERSION_1_0(load, userptr);
8581 glad_gl_load_GL_VERSION_1_1(load, userptr);
8582 glad_gl_load_GL_VERSION_1_2(load, userptr);
8583 glad_gl_load_GL_VERSION_1_3(load, userptr);
8584 glad_gl_load_GL_VERSION_1_4(load, userptr);
8585 glad_gl_load_GL_VERSION_1_5(load, userptr);
8586 glad_gl_load_GL_VERSION_2_0(load, userptr);
8587 glad_gl_load_GL_VERSION_2_1(load, userptr);
8588 glad_gl_load_GL_VERSION_3_0(load, userptr);
8589 glad_gl_load_GL_VERSION_3_1(load, userptr);
8590 glad_gl_load_GL_VERSION_3_2(load, userptr);
8591 glad_gl_load_GL_VERSION_3_3(load, userptr);
8592 glad_gl_load_GL_VERSION_4_0(load, userptr);
8593 glad_gl_load_GL_VERSION_4_1(load, userptr);
8594 glad_gl_load_GL_VERSION_4_2(load, userptr);
8595 glad_gl_load_GL_VERSION_4_3(load, userptr);
8596
8597 if (!glad_gl_find_extensions_gl(version)) return 0;
8598 glad_gl_load_GL_ARB_ES2_compatibility(load, userptr);
8599 glad_gl_load_GL_ARB_ES3_1_compatibility(load, userptr);
8600 glad_gl_load_GL_ARB_ES3_2_compatibility(load, userptr);
8601 glad_gl_load_GL_ARB_blend_func_extended(load, userptr);
8602 glad_gl_load_GL_ARB_buffer_storage(load, userptr);
8603 glad_gl_load_GL_ARB_clear_buffer_object(load, userptr);
8604 glad_gl_load_GL_ARB_clear_texture(load, userptr);
8605 glad_gl_load_GL_ARB_color_buffer_float(load, userptr);
8606 glad_gl_load_GL_ARB_compute_shader(load, userptr);
8607 glad_gl_load_GL_ARB_compute_variable_group_size(load, userptr);
8608 glad_gl_load_GL_ARB_copy_buffer(load, userptr);
8609 glad_gl_load_GL_ARB_copy_image(load, userptr);
8610 glad_gl_load_GL_ARB_debug_output(load, userptr);
8611 glad_gl_load_GL_ARB_direct_state_access(load, userptr);
8612 glad_gl_load_GL_ARB_draw_buffers(load, userptr);
8613 glad_gl_load_GL_ARB_draw_buffers_blend(load, userptr);
8614 glad_gl_load_GL_ARB_draw_elements_base_vertex(load, userptr);
8615 glad_gl_load_GL_ARB_draw_indirect(load, userptr);
8616 glad_gl_load_GL_ARB_draw_instanced(load, userptr);
8617 glad_gl_load_GL_ARB_fragment_program(load, userptr);
8618 glad_gl_load_GL_ARB_framebuffer_no_attachments(load, userptr);
8619 glad_gl_load_GL_ARB_framebuffer_object(load, userptr);
8620 glad_gl_load_GL_ARB_geometry_shader4(load, userptr);
8621 glad_gl_load_GL_ARB_get_program_binary(load, userptr);
8622 glad_gl_load_GL_ARB_get_texture_sub_image(load, userptr);
8623 glad_gl_load_GL_ARB_gl_spirv(load, userptr);
8624 glad_gl_load_GL_ARB_gpu_shader_fp64(load, userptr);
8625 glad_gl_load_GL_ARB_gpu_shader_int64(load, userptr);
8626 glad_gl_load_GL_ARB_instanced_arrays(load, userptr);
8627 glad_gl_load_GL_ARB_internalformat_query(load, userptr);
8628 glad_gl_load_GL_ARB_internalformat_query2(load, userptr);
8629 glad_gl_load_GL_ARB_map_buffer_range(load, userptr);
8630 glad_gl_load_GL_ARB_multi_bind(load, userptr);
8631 glad_gl_load_GL_ARB_multi_draw_indirect(load, userptr);
8632 glad_gl_load_GL_ARB_multisample(load, userptr);
8633 glad_gl_load_GL_ARB_multitexture(load, userptr);
8634 glad_gl_load_GL_ARB_occlusion_query(load, userptr);
8635 glad_gl_load_GL_ARB_sample_locations(load, userptr);
8636 glad_gl_load_GL_ARB_sample_shading(load, userptr);
8637 glad_gl_load_GL_ARB_shader_atomic_counters(load, userptr);
8638 glad_gl_load_GL_ARB_shader_image_load_store(load, userptr);
8639 glad_gl_load_GL_ARB_shader_objects(load, userptr);
8640 glad_gl_load_GL_ARB_shader_storage_buffer_object(load, userptr);
8641 glad_gl_load_GL_ARB_shading_language_include(load, userptr);
8642 glad_gl_load_GL_ARB_tessellation_shader(load, userptr);
8643 glad_gl_load_GL_ARB_texture_compression(load, userptr);
8644 glad_gl_load_GL_ARB_texture_multisample(load, userptr);
8645 glad_gl_load_GL_ARB_texture_storage(load, userptr);
8646 glad_gl_load_GL_ARB_texture_view(load, userptr);
8647 glad_gl_load_GL_ARB_timer_query(load, userptr);
8648 glad_gl_load_GL_ARB_transpose_matrix(load, userptr);
8649 glad_gl_load_GL_ARB_uniform_buffer_object(load, userptr);
8650 glad_gl_load_GL_ARB_vertex_array_object(load, userptr);
8651 glad_gl_load_GL_ARB_vertex_attrib_binding(load, userptr);
8652 glad_gl_load_GL_ARB_vertex_buffer_object(load, userptr);
8653 glad_gl_load_GL_ARB_vertex_program(load, userptr);
8654 glad_gl_load_GL_ARB_vertex_shader(load, userptr);
8655 glad_gl_load_GL_EXT_draw_instanced(load, userptr);
8656 glad_gl_load_GL_EXT_fog_coord(load, userptr);
8657 glad_gl_load_GL_EXT_framebuffer_blit(load, userptr);
8658 glad_gl_load_GL_EXT_framebuffer_multisample(load, userptr);
8659 glad_gl_load_GL_EXT_framebuffer_object(load, userptr);
8660 glad_gl_load_GL_OES_fixed_point(load, userptr);
8661
8662
8663
8664 return version;
8665}
8666
8667
8668int gladLoadGL( GLADloadfunc load) {
8669 return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
8670}
8671
8672
8673
8674
8675
8676
8677#ifdef __cplusplus
8678}
8679#endif
8680
8681#endif /* GLAD_GL_IMPLEMENTATION */
8682
diff --git a/raylib/src/external/glad_gles2.h b/raylib/src/external/glad_gles2.h
new file mode 100644
index 0000000..6c753d0
--- /dev/null
+++ b/raylib/src/external/glad_gles2.h
@@ -0,0 +1,4774 @@
1/**
2 * Loader generated by glad 2.0.2 on Wed Dec 28 13:28:51 2022
3 *
4 * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
5 *
6 * Generator: C/C++
7 * Specification: gl
8 * Extensions: 170
9 *
10 * APIs:
11 * - gles2=2.0
12 *
13 * Options:
14 * - ALIAS = False
15 * - DEBUG = False
16 * - HEADER_ONLY = True
17 * - LOADER = False
18 * - MX = False
19 * - ON_DEMAND = False
20 *
21 * Commandline:
22 * --api='gles2=2.0' --extensions='GL_EXT_EGL_image_array,GL_EXT_EGL_image_storage,GL_EXT_EGL_image_storage_compression,GL_EXT_YUV_target,GL_EXT_base_instance,GL_EXT_blend_func_extended,GL_EXT_blend_minmax,GL_EXT_buffer_storage,GL_EXT_clear_texture,GL_EXT_clip_control,GL_EXT_clip_cull_distance,GL_EXT_color_buffer_float,GL_EXT_color_buffer_half_float,GL_EXT_conservative_depth,GL_EXT_copy_image,GL_EXT_debug_label,GL_EXT_debug_marker,GL_EXT_depth_clamp,GL_EXT_discard_framebuffer,GL_EXT_disjoint_timer_query,GL_EXT_draw_buffers,GL_EXT_draw_buffers_indexed,GL_EXT_draw_elements_base_vertex,GL_EXT_draw_instanced,GL_EXT_draw_transform_feedback,GL_EXT_external_buffer,GL_EXT_float_blend,GL_EXT_fragment_shading_rate,GL_EXT_geometry_point_size,GL_EXT_geometry_shader,GL_EXT_gpu_shader5,GL_EXT_instanced_arrays,GL_EXT_map_buffer_range,GL_EXT_memory_object,GL_EXT_memory_object_fd,GL_EXT_memory_object_win32,GL_EXT_multi_draw_arrays,GL_EXT_multi_draw_indirect,GL_EXT_multisampled_compatibility,GL_EXT_multisampled_render_to_texture,GL_EXT_multisampled_render_to_texture2,GL_EXT_multiview_draw_buffers,GL_EXT_multiview_tessellation_geometry_shader,GL_EXT_multiview_texture_multisample,GL_EXT_multiview_timer_query,GL_EXT_occlusion_query_boolean,GL_EXT_polygon_offset_clamp,GL_EXT_post_depth_coverage,GL_EXT_primitive_bounding_box,GL_EXT_protected_textures,GL_EXT_pvrtc_sRGB,GL_EXT_raster_multisample,GL_EXT_read_format_bgra,GL_EXT_render_snorm,GL_EXT_robustness,GL_EXT_sRGB,GL_EXT_sRGB_write_control,GL_EXT_semaphore,GL_EXT_semaphore_fd,GL_EXT_semaphore_win32,GL_EXT_separate_depth_stencil,GL_EXT_separate_shader_objects,GL_EXT_shader_framebuffer_fetch,GL_EXT_shader_framebuffer_fetch_non_coherent,GL_EXT_shader_group_vote,GL_EXT_shader_implicit_conversions,GL_EXT_shader_integer_mix,GL_EXT_shader_io_blocks,GL_EXT_shader_non_constant_global_initializers,GL_EXT_shader_pixel_local_storage,GL_EXT_shader_pixel_local_storage2,GL_EXT_shader_samples_identical,GL_EXT_shader_texture_lod,GL_EXT_shadow_samplers,GL_EXT_sparse_texture,GL_EXT_sparse_texture2,GL_EXT_tessellation_point_size,GL_EXT_tessellation_shader,GL_EXT_texture_border_clamp,GL_EXT_texture_buffer,GL_EXT_texture_compression_astc_decode_mode,GL_EXT_texture_compression_bptc,GL_EXT_texture_compression_dxt1,GL_EXT_texture_compression_rgtc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_compression_s3tc_srgb,GL_EXT_texture_cube_map_array,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_filter_minmax,GL_EXT_texture_format_BGRA8888,GL_EXT_texture_format_sRGB_override,GL_EXT_texture_mirror_clamp_to_edge,GL_EXT_texture_norm16,GL_EXT_texture_query_lod,GL_EXT_texture_rg,GL_EXT_texture_sRGB_R8,GL_EXT_texture_sRGB_RG8,GL_EXT_texture_sRGB_decode,GL_EXT_texture_shadow_lod,GL_EXT_texture_storage,GL_EXT_texture_storage_compression,GL_EXT_texture_type_2_10_10_10_REV,GL_EXT_texture_view,GL_EXT_unpack_subimage,GL_EXT_win32_keyed_mutex,GL_EXT_window_rectangles,GL_KHR_blend_equation_advanced,GL_KHR_blend_equation_advanced_coherent,GL_KHR_context_flush_control,GL_KHR_debug,GL_KHR_no_error,GL_KHR_parallel_shader_compile,GL_KHR_robust_buffer_access_behavior,GL_KHR_robustness,GL_KHR_shader_subgroup,GL_KHR_texture_compression_astc_hdr,GL_KHR_texture_compression_astc_ldr,GL_KHR_texture_compression_astc_sliced_3d,GL_OES_EGL_image,GL_OES_EGL_image_external,GL_OES_EGL_image_external_essl3,GL_OES_compressed_ETC1_RGB8_sub_texture,GL_OES_compressed_ETC1_RGB8_texture,GL_OES_compressed_paletted_texture,GL_OES_copy_image,GL_OES_depth24,GL_OES_depth32,GL_OES_depth_texture,GL_OES_draw_buffers_indexed,GL_OES_draw_elements_base_vertex,GL_OES_element_index_uint,GL_OES_fbo_render_mipmap,GL_OES_fragment_precision_high,GL_OES_geometry_point_size,GL_OES_geometry_shader,GL_OES_get_program_binary,GL_OES_gpu_shader5,GL_OES_mapbuffer,GL_OES_packed_depth_stencil,GL_OES_primitive_bounding_box,GL_OES_required_internalformat,GL_OES_rgb8_rgba8,GL_OES_sample_shading,GL_OES_sample_variables,GL_OES_shader_image_atomic,GL_OES_shader_io_blocks,GL_OES_shader_multisample_interpolation,GL_OES_standard_derivatives,GL_OES_stencil1,GL_OES_stencil4,GL_OES_surfaceless_context,GL_OES_tessellation_point_size,GL_OES_tessellation_shader,GL_OES_texture_3D,GL_OES_texture_border_clamp,GL_OES_texture_buffer,GL_OES_texture_compression_astc,GL_OES_texture_cube_map_array,GL_OES_texture_float,GL_OES_texture_float_linear,GL_OES_texture_half_float,GL_OES_texture_half_float_linear,GL_OES_texture_npot,GL_OES_texture_stencil8,GL_OES_texture_storage_multisample_2d_array,GL_OES_texture_view,GL_OES_vertex_array_object,GL_OES_vertex_half_float,GL_OES_vertex_type_10_10_10_2,GL_OES_viewport_array' c --header-only
23 *
24 * Online:
25 * http://glad.sh/#api=gles2%3D2.0&generator=c&options=HEADER_ONLY
26 *
27 */
28
29#ifndef GLAD_GLES2_H_
30#define GLAD_GLES2_H_
31
32#ifdef __clang__
33#pragma clang diagnostic push
34#pragma clang diagnostic ignored "-Wreserved-id-macro"
35#endif
36#ifdef __gl2_h_
37 #error OpenGL ES 2 header already included (API: gles2), remove previous include!
38#endif
39#define __gl2_h_ 1
40#ifdef __gles2_gl2_h_
41 #error OpenGL ES 2 header already included (API: gles2), remove previous include!
42#endif
43#define __gles2_gl2_h_ 1
44#ifdef __gl3_h_
45 #error OpenGL ES 3 header already included (API: gles2), remove previous include!
46#endif
47#define __gl3_h_ 1
48#ifdef __gles2_gl3_h_
49 #error OpenGL ES 3 header already included (API: gles2), remove previous include!
50#endif
51#define __gles2_gl3_h_ 1
52#ifdef __clang__
53#pragma clang diagnostic pop
54#endif
55
56#define GLAD_GLES2
57#define GLAD_OPTION_GLES2_HEADER_ONLY
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
63#ifndef GLAD_PLATFORM_H_
64#define GLAD_PLATFORM_H_
65
66#ifndef GLAD_PLATFORM_WIN32
67 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
68 #define GLAD_PLATFORM_WIN32 1
69 #else
70 #define GLAD_PLATFORM_WIN32 0
71 #endif
72#endif
73
74#ifndef GLAD_PLATFORM_APPLE
75 #ifdef __APPLE__
76 #define GLAD_PLATFORM_APPLE 1
77 #else
78 #define GLAD_PLATFORM_APPLE 0
79 #endif
80#endif
81
82#ifndef GLAD_PLATFORM_EMSCRIPTEN
83 #ifdef __EMSCRIPTEN__
84 #define GLAD_PLATFORM_EMSCRIPTEN 1
85 #else
86 #define GLAD_PLATFORM_EMSCRIPTEN 0
87 #endif
88#endif
89
90#ifndef GLAD_PLATFORM_UWP
91 #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
92 #ifdef __has_include
93 #if __has_include(<winapifamily.h>)
94 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
95 #endif
96 #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
97 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
98 #endif
99 #endif
100
101 #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
102 #include <winapifamily.h>
103 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
104 #define GLAD_PLATFORM_UWP 1
105 #endif
106 #endif
107
108 #ifndef GLAD_PLATFORM_UWP
109 #define GLAD_PLATFORM_UWP 0
110 #endif
111#endif
112
113#ifdef __GNUC__
114 #define GLAD_GNUC_EXTENSION __extension__
115#else
116 #define GLAD_GNUC_EXTENSION
117#endif
118
119#define GLAD_UNUSED(x) (void)(x)
120
121#ifndef GLAD_API_CALL
122 #if defined(GLAD_API_CALL_EXPORT)
123 #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
124 #if defined(GLAD_API_CALL_EXPORT_BUILD)
125 #if defined(__GNUC__)
126 #define GLAD_API_CALL __attribute__ ((dllexport)) extern
127 #else
128 #define GLAD_API_CALL __declspec(dllexport) extern
129 #endif
130 #else
131 #if defined(__GNUC__)
132 #define GLAD_API_CALL __attribute__ ((dllimport)) extern
133 #else
134 #define GLAD_API_CALL __declspec(dllimport) extern
135 #endif
136 #endif
137 #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
138 #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
139 #else
140 #define GLAD_API_CALL extern
141 #endif
142 #else
143 #define GLAD_API_CALL extern
144 #endif
145#endif
146
147#ifdef APIENTRY
148 #define GLAD_API_PTR APIENTRY
149#elif GLAD_PLATFORM_WIN32
150 #define GLAD_API_PTR __stdcall
151#else
152 #define GLAD_API_PTR
153#endif
154
155#ifndef GLAPI
156#define GLAPI GLAD_API_CALL
157#endif
158
159#ifndef GLAPIENTRY
160#define GLAPIENTRY GLAD_API_PTR
161#endif
162
163#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
164#define GLAD_VERSION_MAJOR(version) (version / 10000)
165#define GLAD_VERSION_MINOR(version) (version % 10000)
166
167#define GLAD_GENERATOR_VERSION "2.0.2"
168
169typedef void (*GLADapiproc)(void);
170
171typedef GLADapiproc (*GLADloadfunc)(const char *name);
172typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
173
174typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
175typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
176
177#endif /* GLAD_PLATFORM_H_ */
178
179#define GL_ACTIVE_ATTRIBUTES 0x8B89
180#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
181#define GL_ACTIVE_PROGRAM_EXT 0x8259
182#define GL_ACTIVE_TEXTURE 0x84E0
183#define GL_ACTIVE_UNIFORMS 0x8B86
184#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
185#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
186#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
187#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
188#define GL_ALPHA 0x1906
189#define GL_ALPHA16F_EXT 0x881C
190#define GL_ALPHA32F_EXT 0x8816
191#define GL_ALPHA8_EXT 0x803C
192#define GL_ALPHA8_OES 0x803C
193#define GL_ALPHA_BITS 0x0D55
194#define GL_ALWAYS 0x0207
195#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
196#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
197#define GL_ARRAY_BUFFER 0x8892
198#define GL_ARRAY_BUFFER_BINDING 0x8894
199#define GL_ATTACHED_SHADERS 0x8B85
200#define GL_BACK 0x0405
201#define GL_BGRA8_EXT 0x93A1
202#define GL_BGRA_EXT 0x80E1
203#define GL_BLEND 0x0BE2
204#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
205#define GL_BLEND_COLOR 0x8005
206#define GL_BLEND_DST_ALPHA 0x80CA
207#define GL_BLEND_DST_RGB 0x80C8
208#define GL_BLEND_EQUATION 0x8009
209#define GL_BLEND_EQUATION_ALPHA 0x883D
210#define GL_BLEND_EQUATION_RGB 0x8009
211#define GL_BLEND_SRC_ALPHA 0x80CB
212#define GL_BLEND_SRC_RGB 0x80C9
213#define GL_BLUE_BITS 0x0D54
214#define GL_BOOL 0x8B56
215#define GL_BOOL_VEC2 0x8B57
216#define GL_BOOL_VEC3 0x8B58
217#define GL_BOOL_VEC4 0x8B59
218#define GL_BUFFER_ACCESS_OES 0x88BB
219#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F
220#define GL_BUFFER_KHR 0x82E0
221#define GL_BUFFER_MAPPED_OES 0x88BC
222#define GL_BUFFER_MAP_POINTER_OES 0x88BD
223#define GL_BUFFER_OBJECT_EXT 0x9151
224#define GL_BUFFER_SIZE 0x8764
225#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220
226#define GL_BUFFER_USAGE 0x8765
227#define GL_BYTE 0x1400
228#define GL_CCW 0x0901
229#define GL_CLAMP_TO_BORDER_EXT 0x812D
230#define GL_CLAMP_TO_BORDER_OES 0x812D
231#define GL_CLAMP_TO_EDGE 0x812F
232#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000
233#define GL_CLIENT_STORAGE_BIT_EXT 0x0200
234#define GL_CLIP_DEPTH_MODE 0x935D
235#define GL_CLIP_DEPTH_MODE_EXT 0x935D
236#define GL_CLIP_DISTANCE0_EXT 0x3000
237#define GL_CLIP_DISTANCE1_EXT 0x3001
238#define GL_CLIP_DISTANCE2_EXT 0x3002
239#define GL_CLIP_DISTANCE3_EXT 0x3003
240#define GL_CLIP_DISTANCE4_EXT 0x3004
241#define GL_CLIP_DISTANCE5_EXT 0x3005
242#define GL_CLIP_DISTANCE6 0x3006
243#define GL_CLIP_DISTANCE6_EXT 0x3006
244#define GL_CLIP_DISTANCE7 0x3007
245#define GL_CLIP_DISTANCE7_EXT 0x3007
246#define GL_CLIP_ORIGIN 0x935C
247#define GL_CLIP_ORIGIN_EXT 0x935C
248#define GL_CLIP_PLANE0 0x3000
249#define GL_CLIP_PLANE1 0x3001
250#define GL_CLIP_PLANE2 0x3002
251#define GL_CLIP_PLANE3 0x3003
252#define GL_CLIP_PLANE4 0x3004
253#define GL_CLIP_PLANE5 0x3005
254#define GL_COLORBURN_KHR 0x929A
255#define GL_COLORDODGE_KHR 0x9299
256#define GL_COLOR_ATTACHMENT0 0x8CE0
257#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
258#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
259#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
260#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
261#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
262#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
263#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
264#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
265#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
266#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
267#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
268#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
269#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
270#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
271#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
272#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
273#define GL_COLOR_ATTACHMENT_EXT 0x90F0
274#define GL_COLOR_BUFFER_BIT 0x00004000
275#define GL_COLOR_CLEAR_VALUE 0x0C22
276#define GL_COLOR_EXT 0x1800
277#define GL_COLOR_WRITEMASK 0x0C23
278#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
279#define GL_COMPILE_STATUS 0x8B81
280#define GL_COMPLETION_STATUS_KHR 0x91B1
281#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
282#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
283#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
284#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
285#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
286#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
287#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
288#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
289#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
290#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
291#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
292#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
293#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
294#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
295#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
296#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
297#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
298#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
299#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
300#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
301#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
302#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
303#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
304#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
305#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
306#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
307#define GL_COMPRESSED_RGBA_BPTC_UNORM_EXT 0x8E8C
308#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
309#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
310#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
311#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E
312#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F
313#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
314#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
315#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
316#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
317#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
318#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
319#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
320#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
321#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
322#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
323#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
324#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
325#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
326#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
327#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
328#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
329#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
330#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
331#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
332#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
333#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
334#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
335#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
336#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
337#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
338#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
339#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
340#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D
341#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
342#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
343#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
344#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
345#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
346#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
347#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
348#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
349#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
350#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
351#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
352#define GL_CONSTANT_ALPHA 0x8003
353#define GL_CONSTANT_COLOR 0x8001
354#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002
355#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008
356#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
357#define GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010
358#define GL_CONTEXT_LOST_KHR 0x0507
359#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC
360#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB
361#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
362#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3
363#define GL_CULL_FACE 0x0B44
364#define GL_CULL_FACE_MODE 0x0B45
365#define GL_CURRENT_PROGRAM 0x8B8D
366#define GL_CURRENT_QUERY_EXT 0x8865
367#define GL_CURRENT_VERTEX_ATTRIB 0x8626
368#define GL_CW 0x0900
369#define GL_D3D12_FENCE_VALUE_EXT 0x9595
370#define GL_DARKEN_KHR 0x9297
371#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244
372#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245
373#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D
374#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145
375#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
376#define GL_DEBUG_OUTPUT_KHR 0x92E0
377#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242
378#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146
379#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148
380#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147
381#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
382#define GL_DEBUG_SOURCE_API_KHR 0x8246
383#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A
384#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B
385#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
386#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249
387#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
388#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
389#define GL_DEBUG_TYPE_ERROR_KHR 0x824C
390#define GL_DEBUG_TYPE_MARKER_KHR 0x8268
391#define GL_DEBUG_TYPE_OTHER_KHR 0x8251
392#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250
393#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A
394#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F
395#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269
396#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
397#define GL_DECODE_EXT 0x8A49
398#define GL_DECR 0x1E03
399#define GL_DECR_WRAP 0x8508
400#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581
401#define GL_DELETE_STATUS 0x8B80
402#define GL_DEPTH24_STENCIL8_OES 0x88F0
403#define GL_DEPTH_ATTACHMENT 0x8D00
404#define GL_DEPTH_BITS 0x0D56
405#define GL_DEPTH_BUFFER_BIT 0x00000100
406#define GL_DEPTH_CLAMP_EXT 0x864F
407#define GL_DEPTH_CLEAR_VALUE 0x0B73
408#define GL_DEPTH_COMPONENT 0x1902
409#define GL_DEPTH_COMPONENT16 0x81A5
410#define GL_DEPTH_COMPONENT16_OES 0x81A5
411#define GL_DEPTH_COMPONENT24_OES 0x81A6
412#define GL_DEPTH_COMPONENT32_OES 0x81A7
413#define GL_DEPTH_EXT 0x1801
414#define GL_DEPTH_FUNC 0x0B74
415#define GL_DEPTH_RANGE 0x0B70
416#define GL_DEPTH_STENCIL_OES 0x84F9
417#define GL_DEPTH_TEST 0x0B71
418#define GL_DEPTH_WRITEMASK 0x0B72
419#define GL_DEVICE_LUID_EXT 0x9599
420#define GL_DEVICE_NODE_MASK_EXT 0x959A
421#define GL_DEVICE_UUID_EXT 0x9597
422#define GL_DIFFERENCE_KHR 0x929E
423#define GL_DITHER 0x0BD0
424#define GL_DONT_CARE 0x1100
425#define GL_DRAW_BUFFER0_EXT 0x8825
426#define GL_DRAW_BUFFER10_EXT 0x882F
427#define GL_DRAW_BUFFER11_EXT 0x8830
428#define GL_DRAW_BUFFER12_EXT 0x8831
429#define GL_DRAW_BUFFER13_EXT 0x8832
430#define GL_DRAW_BUFFER14_EXT 0x8833
431#define GL_DRAW_BUFFER15_EXT 0x8834
432#define GL_DRAW_BUFFER1_EXT 0x8826
433#define GL_DRAW_BUFFER2_EXT 0x8827
434#define GL_DRAW_BUFFER3_EXT 0x8828
435#define GL_DRAW_BUFFER4_EXT 0x8829
436#define GL_DRAW_BUFFER5_EXT 0x882A
437#define GL_DRAW_BUFFER6_EXT 0x882B
438#define GL_DRAW_BUFFER7_EXT 0x882C
439#define GL_DRAW_BUFFER8_EXT 0x882D
440#define GL_DRAW_BUFFER9_EXT 0x882E
441#define GL_DRAW_BUFFER_EXT 0x0C01
442#define GL_DRIVER_UUID_EXT 0x9598
443#define GL_DST_ALPHA 0x0304
444#define GL_DST_COLOR 0x0306
445#define GL_DYNAMIC_DRAW 0x88E8
446#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100
447#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C
448#define GL_ELEMENT_ARRAY_BUFFER 0x8893
449#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
450#define GL_EQUAL 0x0202
451#define GL_ETC1_RGB8_OES 0x8D64
452#define GL_EXCLUSION_KHR 0x92A0
453#define GL_EXCLUSIVE_EXT 0x8F11
454#define GL_EXTENSIONS 0x1F03
455#define GL_FALSE 0
456#define GL_FASTEST 0x1101
457#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
458#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D
459#define GL_FIXED 0x140C
460#define GL_FLOAT 0x1406
461#define GL_FLOAT_MAT2 0x8B5A
462#define GL_FLOAT_MAT3 0x8B5B
463#define GL_FLOAT_MAT4 0x8B5C
464#define GL_FLOAT_VEC2 0x8B50
465#define GL_FLOAT_VEC3 0x8B51
466#define GL_FLOAT_VEC4 0x8B52
467#define GL_FRACTIONAL_EVEN_EXT 0x8E7C
468#define GL_FRACTIONAL_EVEN_OES 0x8E7C
469#define GL_FRACTIONAL_ODD_EXT 0x8E7B
470#define GL_FRACTIONAL_ODD_OES 0x8E7B
471#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D
472#define GL_FRAGMENT_SHADER 0x8B30
473#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
474#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
475#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
476#define GL_FRAGMENT_SHADING_RATE_ATTACHMENT_WITH_DEFAULT_FRAMEBUFFER_SUPPORTED_EXT 0x96DF
477#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_EXT 0x96D2
478#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_EXT 0x96D5
479#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_EXT 0x96D4
480#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_EXT 0x96D6
481#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_EXT 0x96D3
482#define GL_FRAGMENT_SHADING_RATE_NON_TRIVIAL_COMBINERS_SUPPORTED_EXT 0x8F6F
483#define GL_FRAGMENT_SHADING_RATE_WITH_SAMPLE_MASK_SUPPORTED_EXT 0x96DE
484#define GL_FRAGMENT_SHADING_RATE_WITH_SHADER_DEPTH_STENCIL_WRITES_SUPPORTED_EXT 0x96DD
485#define GL_FRAMEBUFFER 0x8D40
486#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
487#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
488#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
489#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7
490#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
491#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
492#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
493#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
494#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
495#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
496#define GL_FRAMEBUFFER_BINDING 0x8CA6
497#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
498#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312
499#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312
500#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
501#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
502#define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652
503#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
504#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8
505#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
506#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
507#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
508#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
509#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
510#define GL_FRONT 0x0404
511#define GL_FRONT_AND_BACK 0x0408
512#define GL_FRONT_FACE 0x0B46
513#define GL_FUNC_ADD 0x8006
514#define GL_FUNC_REVERSE_SUBTRACT 0x800B
515#define GL_FUNC_SUBTRACT 0x800A
516#define GL_GENERATE_MIPMAP_HINT 0x8192
517#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917
518#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917
519#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918
520#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918
521#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916
522#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916
523#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004
524#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004
525#define GL_GEOMETRY_SHADER_EXT 0x8DD9
526#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F
527#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F
528#define GL_GEOMETRY_SHADER_OES 0x8DD9
529#define GL_GEQUAL 0x0206
530#define GL_GPU_DISJOINT_EXT 0x8FBB
531#define GL_GREATER 0x0204
532#define GL_GREEN_BITS 0x0D53
533#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
534#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253
535#define GL_HALF_FLOAT_OES 0x8D61
536#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B
537#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C
538#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594
539#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A
540#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589
541#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586
542#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587
543#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588
544#define GL_HARDLIGHT_KHR 0x929B
545#define GL_HIGH_FLOAT 0x8DF2
546#define GL_HIGH_INT 0x8DF5
547#define GL_HSL_COLOR_KHR 0x92AF
548#define GL_HSL_HUE_KHR 0x92AD
549#define GL_HSL_LUMINOSITY_KHR 0x92B0
550#define GL_HSL_SATURATION_KHR 0x92AE
551#define GL_IMAGE_BUFFER_EXT 0x9051
552#define GL_IMAGE_BUFFER_OES 0x9051
553#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054
554#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054
555#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
556#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
557#define GL_INCLUSIVE_EXT 0x8F10
558#define GL_INCR 0x1E02
559#define GL_INCR_WRAP 0x8507
560#define GL_INFO_LOG_LENGTH 0x8B84
561#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
562#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254
563#define GL_INT 0x1404
564#define GL_INT_10_10_10_2_OES 0x8DF7
565#define GL_INT_IMAGE_BUFFER_EXT 0x905C
566#define GL_INT_IMAGE_BUFFER_OES 0x905C
567#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F
568#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F
569#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C
570#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0
571#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0
572#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E
573#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E
574#define GL_INT_VEC2 0x8B53
575#define GL_INT_VEC3 0x8B54
576#define GL_INT_VEC4 0x8B55
577#define GL_INVALID_ENUM 0x0500
578#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
579#define GL_INVALID_OPERATION 0x0502
580#define GL_INVALID_VALUE 0x0501
581#define GL_INVERT 0x150A
582#define GL_ISOLINES_EXT 0x8E7A
583#define GL_ISOLINES_OES 0x8E7A
584#define GL_IS_PER_PATCH_EXT 0x92E7
585#define GL_IS_PER_PATCH_OES 0x92E7
586#define GL_KEEP 0x1E00
587#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
588#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E
589#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E
590#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E
591#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E
592#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531
593#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530
594#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F
595#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590
596#define GL_LAYOUT_GENERAL_EXT 0x958D
597#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591
598#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593
599#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592
600#define GL_LEQUAL 0x0203
601#define GL_LESS 0x0201
602#define GL_LIGHTEN_KHR 0x9298
603#define GL_LINEAR 0x2601
604#define GL_LINEAR_MIPMAP_LINEAR 0x2703
605#define GL_LINEAR_MIPMAP_NEAREST 0x2701
606#define GL_LINEAR_TILING_EXT 0x9585
607#define GL_LINES 0x0001
608#define GL_LINES_ADJACENCY_EXT 0x000A
609#define GL_LINES_ADJACENCY_OES 0x000A
610#define GL_LINE_LOOP 0x0002
611#define GL_LINE_STRIP 0x0003
612#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B
613#define GL_LINE_STRIP_ADJACENCY_OES 0x000B
614#define GL_LINE_WIDTH 0x0B21
615#define GL_LINK_STATUS 0x8B82
616#define GL_LOCATION_INDEX_EXT 0x930F
617#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
618#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252
619#define GL_LOWER_LEFT 0x8CA1
620#define GL_LOWER_LEFT_EXT 0x8CA1
621#define GL_LOW_FLOAT 0x8DF0
622#define GL_LOW_INT 0x8DF3
623#define GL_LUID_SIZE_EXT 8
624#define GL_LUMINANCE 0x1909
625#define GL_LUMINANCE16F_EXT 0x881E
626#define GL_LUMINANCE32F_EXT 0x8818
627#define GL_LUMINANCE4_ALPHA4_OES 0x8043
628#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
629#define GL_LUMINANCE8_ALPHA8_OES 0x8045
630#define GL_LUMINANCE8_EXT 0x8040
631#define GL_LUMINANCE8_OES 0x8040
632#define GL_LUMINANCE_ALPHA 0x190A
633#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
634#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
635#define GL_MAP_COHERENT_BIT_EXT 0x0080
636#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
637#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
638#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
639#define GL_MAP_PERSISTENT_BIT_EXT 0x0040
640#define GL_MAP_READ_BIT 0x0001
641#define GL_MAP_READ_BIT_EXT 0x0001
642#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
643#define GL_MAP_WRITE_BIT 0x0002
644#define GL_MAP_WRITE_BIT_EXT 0x0002
645#define GL_MAX 0x8008
646#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
647#define GL_MAX_CLIP_DISTANCES_EXT 0x0D32
648#define GL_MAX_CLIP_PLANES 0x0D32
649#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
650#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA
651#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA
652#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32
653#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32
654#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E
655#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E
656#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F
657#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F
658#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
659#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
660#define GL_MAX_CULL_DISTANCES 0x82F9
661#define GL_MAX_CULL_DISTANCES_EXT 0x82F9
662#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
663#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144
664#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143
665#define GL_MAX_DRAW_BUFFERS_EXT 0x8824
666#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC
667#define GL_MAX_EXT 0x8008
668#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C
669#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_LAYERS_EXT 0x96DC
670#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_ASPECT_RATIO_EXT 0x96DB
671#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96DA
672#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D8
673#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
674#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317
675#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317
676#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5
677#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5
678#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF
679#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF
680#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD
681#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD
682#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123
683#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123
684#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124
685#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124
686#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
687#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0
688#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A
689#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A
690#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7
691#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7
692#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
693#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29
694#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
695#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1
696#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C
697#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C
698#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
699#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF
700#define GL_MAX_LABEL_LENGTH_KHR 0x82E8
701#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
702#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D
703#define GL_MAX_PATCH_VERTICES_OES 0x8E7D
704#define GL_MAX_RASTER_SAMPLES_EXT 0x9329
705#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
706#define GL_MAX_SAMPLES_EXT 0x8D57
707#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650
708#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651
709#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0
710#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
711#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67
712#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199
713#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A
714#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198
715#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3
716#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3
717#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD
718#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD
719#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB
720#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB
721#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C
722#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C
723#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83
724#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83
725#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8
726#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8
727#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81
728#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81
729#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85
730#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85
731#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89
732#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89
733#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F
734#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F
735#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4
736#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4
737#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE
738#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE
739#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC
740#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC
741#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D
742#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D
743#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86
744#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86
745#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9
746#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9
747#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82
748#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82
749#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A
750#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A
751#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80
752#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80
753#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E
754#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E
755#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84
756#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84
757#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B
758#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B
759#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
760#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF
761#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
762#define GL_MAX_TEXTURE_SIZE 0x0D33
763#define GL_MAX_VARYING_VECTORS 0x8DFC
764#define GL_MAX_VERTEX_ATTRIBS 0x8869
765#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
766#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
767#define GL_MAX_VIEWPORTS_OES 0x825B
768#define GL_MAX_VIEWPORT_DIMS 0x0D3A
769#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14
770#define GL_MEDIUM_FLOAT 0x8DF1
771#define GL_MEDIUM_INT 0x8DF4
772#define GL_MIN 0x8007
773#define GL_MIN_EXT 0x8007
774#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B
775#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96D9
776#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D7
777#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37
778#define GL_MIRRORED_REPEAT 0x8370
779#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
780#define GL_MULTIPLY_KHR 0x9294
781#define GL_MULTISAMPLE_EXT 0x809D
782#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B
783#define GL_MULTIVIEW_EXT 0x90F1
784#define GL_NEAREST 0x2600
785#define GL_NEAREST_MIPMAP_LINEAR 0x2702
786#define GL_NEAREST_MIPMAP_NEAREST 0x2700
787#define GL_NEGATIVE_ONE_TO_ONE 0x935E
788#define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E
789#define GL_NEVER 0x0200
790#define GL_NICEST 0x1102
791#define GL_NONE 0
792#define GL_NOTEQUAL 0x0205
793#define GL_NO_ERROR 0
794#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
795#define GL_NO_RESET_NOTIFICATION_KHR 0x8261
796#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
797#define GL_NUM_DEVICE_UUIDS_EXT 0x9596
798#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
799#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
800#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA
801#define GL_NUM_SURFACE_COMPRESSION_FIXED_RATES_EXT 0x8F6E
802#define GL_NUM_TILING_TYPES_EXT 0x9582
803#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8
804#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15
805#define GL_ONE 1
806#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
807#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
808#define GL_ONE_MINUS_DST_ALPHA 0x0305
809#define GL_ONE_MINUS_DST_COLOR 0x0307
810#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB
811#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA
812#define GL_ONE_MINUS_SRC_ALPHA 0x0303
813#define GL_ONE_MINUS_SRC_COLOR 0x0301
814#define GL_OPTIMAL_TILING_EXT 0x9584
815#define GL_OUT_OF_MEMORY 0x0505
816#define GL_OVERLAY_KHR 0x9296
817#define GL_PACK_ALIGNMENT 0x0D05
818#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
819#define GL_PALETTE4_RGB5_A1_OES 0x8B94
820#define GL_PALETTE4_RGB8_OES 0x8B90
821#define GL_PALETTE4_RGBA4_OES 0x8B93
822#define GL_PALETTE4_RGBA8_OES 0x8B91
823#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
824#define GL_PALETTE8_RGB5_A1_OES 0x8B99
825#define GL_PALETTE8_RGB8_OES 0x8B95
826#define GL_PALETTE8_RGBA4_OES 0x8B98
827#define GL_PALETTE8_RGBA8_OES 0x8B96
828#define GL_PATCHES_EXT 0x000E
829#define GL_PATCHES_OES 0x000E
830#define GL_PATCH_VERTICES_EXT 0x8E72
831#define GL_PATCH_VERTICES_OES 0x8E72
832#define GL_POINTS 0x0000
833#define GL_POLYGON_OFFSET_CLAMP 0x8E1B
834#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B
835#define GL_POLYGON_OFFSET_FACTOR 0x8038
836#define GL_POLYGON_OFFSET_FILL 0x8037
837#define GL_POLYGON_OFFSET_UNITS 0x2A00
838#define GL_PRIMITIVES_GENERATED_EXT 0x8C87
839#define GL_PRIMITIVES_GENERATED_OES 0x8C87
840#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE
841#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE
842#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221
843#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221
844#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
845#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
846#define GL_PROGRAM_KHR 0x82E2
847#define GL_PROGRAM_OBJECT_EXT 0x8B40
848#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
849#define GL_PROGRAM_PIPELINE_KHR 0x82E4
850#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
851#define GL_PROGRAM_SEPARABLE_EXT 0x8258
852#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B
853#define GL_QUADS_EXT 0x0007
854#define GL_QUADS_OES 0x0007
855#define GL_QUERY_COUNTER_BITS_EXT 0x8864
856#define GL_QUERY_KHR 0x82E3
857#define GL_QUERY_OBJECT_EXT 0x9153
858#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
859#define GL_QUERY_RESULT_EXT 0x8866
860#define GL_R16F_EXT 0x822D
861#define GL_R16_EXT 0x822A
862#define GL_R16_SNORM_EXT 0x8F98
863#define GL_R32F_EXT 0x822E
864#define GL_R8_EXT 0x8229
865#define GL_R8_SNORM 0x8F94
866#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A
867#define GL_RASTER_MULTISAMPLE_EXT 0x9327
868#define GL_RASTER_SAMPLES_EXT 0x9328
869#define GL_READ_BUFFER_EXT 0x0C02
870#define GL_RED_BITS 0x0D52
871#define GL_RED_EXT 0x1903
872#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309
873#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309
874#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307
875#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307
876#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308
877#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308
878#define GL_RENDERBUFFER 0x8D41
879#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
880#define GL_RENDERBUFFER_BINDING 0x8CA7
881#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
882#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
883#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
884#define GL_RENDERBUFFER_HEIGHT 0x8D43
885#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
886#define GL_RENDERBUFFER_RED_SIZE 0x8D50
887#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
888#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
889#define GL_RENDERBUFFER_WIDTH 0x8D42
890#define GL_RENDERER 0x1F01
891#define GL_REPEAT 0x2901
892#define GL_REPLACE 0x1E01
893#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
894#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
895#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
896#define GL_RG16F_EXT 0x822F
897#define GL_RG16_EXT 0x822C
898#define GL_RG16_SNORM_EXT 0x8F99
899#define GL_RG32F_EXT 0x8230
900#define GL_RG8_EXT 0x822B
901#define GL_RG8_SNORM 0x8F95
902#define GL_RGB 0x1907
903#define GL_RGB10_A2_EXT 0x8059
904#define GL_RGB10_EXT 0x8052
905#define GL_RGB16F_EXT 0x881B
906#define GL_RGB16_EXT 0x8054
907#define GL_RGB16_SNORM_EXT 0x8F9A
908#define GL_RGB32F_EXT 0x8815
909#define GL_RGB565 0x8D62
910#define GL_RGB565_OES 0x8D62
911#define GL_RGB5_A1 0x8057
912#define GL_RGB5_A1_OES 0x8057
913#define GL_RGB8_OES 0x8051
914#define GL_RGBA 0x1908
915#define GL_RGBA16F_EXT 0x881A
916#define GL_RGBA16_EXT 0x805B
917#define GL_RGBA16_SNORM_EXT 0x8F9B
918#define GL_RGBA32F_EXT 0x8814
919#define GL_RGBA4 0x8056
920#define GL_RGBA4_OES 0x8056
921#define GL_RGBA8_OES 0x8058
922#define GL_RGBA8_SNORM 0x8F97
923#define GL_RG_EXT 0x8227
924#define GL_SAMPLER 0x82E6
925#define GL_SAMPLER_2D 0x8B5E
926#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B
927#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
928#define GL_SAMPLER_3D_OES 0x8B5F
929#define GL_SAMPLER_BUFFER_EXT 0x8DC2
930#define GL_SAMPLER_BUFFER_OES 0x8DC2
931#define GL_SAMPLER_CUBE 0x8B60
932#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C
933#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C
934#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D
935#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D
936#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7
937#define GL_SAMPLER_EXTERNAL_OES 0x8D66
938#define GL_SAMPLER_KHR 0x82E6
939#define GL_SAMPLES 0x80A9
940#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
941#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
942#define GL_SAMPLE_BUFFERS 0x80A8
943#define GL_SAMPLE_COVERAGE 0x80A0
944#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
945#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
946#define GL_SAMPLE_SHADING_OES 0x8C36
947#define GL_SCISSOR_BOX 0x0C10
948#define GL_SCISSOR_TEST 0x0C11
949#define GL_SCREEN_KHR 0x9295
950#define GL_SHADER_BINARY_FORMATS 0x8DF8
951#define GL_SHADER_COMPILER 0x8DFA
952#define GL_SHADER_KHR 0x82E1
953#define GL_SHADER_OBJECT_EXT 0x8B48
954#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64
955#define GL_SHADER_SOURCE_LENGTH 0x8B88
956#define GL_SHADER_TYPE 0x8B4F
957#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
958#define GL_SHADING_RATE_1X1_PIXELS_EXT 0x96A6
959#define GL_SHADING_RATE_1X1_PIXELS_QCOM 0x96A6
960#define GL_SHADING_RATE_1X2_PIXELS_EXT 0x96A7
961#define GL_SHADING_RATE_1X2_PIXELS_QCOM 0x96A7
962#define GL_SHADING_RATE_1X4_PIXELS_EXT 0x96AA
963#define GL_SHADING_RATE_1X4_PIXELS_QCOM 0x96AA
964#define GL_SHADING_RATE_2X1_PIXELS_EXT 0x96A8
965#define GL_SHADING_RATE_2X1_PIXELS_QCOM 0x96A8
966#define GL_SHADING_RATE_2X2_PIXELS_EXT 0x96A9
967#define GL_SHADING_RATE_2X2_PIXELS_QCOM 0x96A9
968#define GL_SHADING_RATE_2X4_PIXELS_EXT 0x96AD
969#define GL_SHADING_RATE_2X4_PIXELS_QCOM 0x96AD
970#define GL_SHADING_RATE_4X1_PIXELS_EXT 0x96AB
971#define GL_SHADING_RATE_4X1_PIXELS_QCOM 0x96AB
972#define GL_SHADING_RATE_4X2_PIXELS_EXT 0x96AC
973#define GL_SHADING_RATE_4X2_PIXELS_QCOM 0x96AC
974#define GL_SHADING_RATE_4X4_PIXELS_EXT 0x96AE
975#define GL_SHADING_RATE_4X4_PIXELS_QCOM 0x96AE
976#define GL_SHADING_RATE_ATTACHMENT_EXT 0x96D1
977#define GL_SHADING_RATE_EXT 0x96D0
978#define GL_SHORT 0x1402
979#define GL_SKIP_DECODE_EXT 0x8A4A
980#define GL_SOFTLIGHT_KHR 0x929C
981#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9
982#define GL_SR8_EXT 0x8FBD
983#define GL_SRC1_ALPHA_EXT 0x8589
984#define GL_SRC1_COLOR_EXT 0x88F9
985#define GL_SRC_ALPHA 0x0302
986#define GL_SRC_ALPHA_SATURATE 0x0308
987#define GL_SRC_ALPHA_SATURATE_EXT 0x0308
988#define GL_SRC_COLOR 0x0300
989#define GL_SRG8_EXT 0x8FBE
990#define GL_SRGB8_ALPHA8_EXT 0x8C43
991#define GL_SRGB_ALPHA_EXT 0x8C42
992#define GL_SRGB_EXT 0x8C40
993#define GL_STACK_OVERFLOW_KHR 0x0503
994#define GL_STACK_UNDERFLOW_KHR 0x0504
995#define GL_STATIC_DRAW 0x88E4
996#define GL_STENCIL_ATTACHMENT 0x8D20
997#define GL_STENCIL_BACK_FAIL 0x8801
998#define GL_STENCIL_BACK_FUNC 0x8800
999#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
1000#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
1001#define GL_STENCIL_BACK_REF 0x8CA3
1002#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
1003#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
1004#define GL_STENCIL_BITS 0x0D57
1005#define GL_STENCIL_BUFFER_BIT 0x00000400
1006#define GL_STENCIL_CLEAR_VALUE 0x0B91
1007#define GL_STENCIL_EXT 0x1802
1008#define GL_STENCIL_FAIL 0x0B94
1009#define GL_STENCIL_FUNC 0x0B92
1010#define GL_STENCIL_INDEX1_OES 0x8D46
1011#define GL_STENCIL_INDEX4_OES 0x8D47
1012#define GL_STENCIL_INDEX8 0x8D48
1013#define GL_STENCIL_INDEX8_OES 0x8D48
1014#define GL_STENCIL_INDEX_OES 0x1901
1015#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
1016#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
1017#define GL_STENCIL_REF 0x0B97
1018#define GL_STENCIL_TEST 0x0B90
1019#define GL_STENCIL_VALUE_MASK 0x0B93
1020#define GL_STENCIL_WRITEMASK 0x0B98
1021#define GL_STREAM_DRAW 0x88E0
1022#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004
1023#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008
1024#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001
1025#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040
1026#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080
1027#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010
1028#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020
1029#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002
1030#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535
1031#define GL_SUBGROUP_SIZE_KHR 0x9532
1032#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534
1033#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533
1034#define GL_SUBPIXEL_BITS 0x0D50
1035#define GL_SURFACE_COMPRESSION_EXT 0x96C0
1036#define GL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x96CD
1037#define GL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x96CE
1038#define GL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x96CF
1039#define GL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x96C4
1040#define GL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x96C5
1041#define GL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x96C6
1042#define GL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x96C7
1043#define GL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x96C8
1044#define GL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x96C9
1045#define GL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x96CA
1046#define GL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x96CB
1047#define GL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x96CC
1048#define GL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x96C2
1049#define GL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x96C1
1050#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75
1051#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75
1052#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008
1053#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008
1054#define GL_TESS_CONTROL_SHADER_EXT 0x8E88
1055#define GL_TESS_CONTROL_SHADER_OES 0x8E88
1056#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010
1057#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010
1058#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87
1059#define GL_TESS_EVALUATION_SHADER_OES 0x8E87
1060#define GL_TESS_GEN_MODE_EXT 0x8E76
1061#define GL_TESS_GEN_MODE_OES 0x8E76
1062#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79
1063#define GL_TESS_GEN_POINT_MODE_OES 0x8E79
1064#define GL_TESS_GEN_SPACING_EXT 0x8E77
1065#define GL_TESS_GEN_SPACING_OES 0x8E77
1066#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78
1067#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78
1068#define GL_TEXTURE 0x1702
1069#define GL_TEXTURE0 0x84C0
1070#define GL_TEXTURE1 0x84C1
1071#define GL_TEXTURE10 0x84CA
1072#define GL_TEXTURE11 0x84CB
1073#define GL_TEXTURE12 0x84CC
1074#define GL_TEXTURE13 0x84CD
1075#define GL_TEXTURE14 0x84CE
1076#define GL_TEXTURE15 0x84CF
1077#define GL_TEXTURE16 0x84D0
1078#define GL_TEXTURE17 0x84D1
1079#define GL_TEXTURE18 0x84D2
1080#define GL_TEXTURE19 0x84D3
1081#define GL_TEXTURE2 0x84C2
1082#define GL_TEXTURE20 0x84D4
1083#define GL_TEXTURE21 0x84D5
1084#define GL_TEXTURE22 0x84D6
1085#define GL_TEXTURE23 0x84D7
1086#define GL_TEXTURE24 0x84D8
1087#define GL_TEXTURE25 0x84D9
1088#define GL_TEXTURE26 0x84DA
1089#define GL_TEXTURE27 0x84DB
1090#define GL_TEXTURE28 0x84DC
1091#define GL_TEXTURE29 0x84DD
1092#define GL_TEXTURE3 0x84C3
1093#define GL_TEXTURE30 0x84DE
1094#define GL_TEXTURE31 0x84DF
1095#define GL_TEXTURE4 0x84C4
1096#define GL_TEXTURE5 0x84C5
1097#define GL_TEXTURE6 0x84C6
1098#define GL_TEXTURE7 0x84C7
1099#define GL_TEXTURE8 0x84C8
1100#define GL_TEXTURE9 0x84C9
1101#define GL_TEXTURE_2D 0x0DE1
1102#define GL_TEXTURE_2D_ARRAY 0x8C1A
1103#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102
1104#define GL_TEXTURE_3D 0x806F
1105#define GL_TEXTURE_3D_OES 0x806F
1106#define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69
1107#define GL_TEXTURE_BINDING_2D 0x8069
1108#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105
1109#define GL_TEXTURE_BINDING_3D_OES 0x806A
1110#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C
1111#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C
1112#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
1113#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A
1114#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A
1115#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
1116#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004
1117#define GL_TEXTURE_BORDER_COLOR_OES 0x1004
1118#define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A
1119#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A
1120#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
1121#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D
1122#define GL_TEXTURE_BUFFER_EXT 0x8C2A
1123#define GL_TEXTURE_BUFFER_OES 0x8C2A
1124#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F
1125#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F
1126#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D
1127#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D
1128#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E
1129#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E
1130#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
1131#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
1132#define GL_TEXTURE_CUBE_MAP 0x8513
1133#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009
1134#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009
1135#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
1136#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
1137#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
1138#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
1139#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
1140#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
1141#define GL_TEXTURE_EXTERNAL_OES 0x8D65
1142#define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF
1143#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
1144#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
1145#define GL_TEXTURE_MAG_FILTER 0x2800
1146#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE
1147#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
1148#define GL_TEXTURE_MIN_FILTER 0x2801
1149#define GL_TEXTURE_PROTECTED_EXT 0x8BFA
1150#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366
1151#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366
1152#define GL_TEXTURE_SPARSE_EXT 0x91A6
1153#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
1154#define GL_TEXTURE_TILING_EXT 0x9580
1155#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD
1156#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD
1157#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB
1158#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB
1159#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE
1160#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE
1161#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC
1162#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC
1163#define GL_TEXTURE_WRAP_R_OES 0x8072
1164#define GL_TEXTURE_WRAP_S 0x2802
1165#define GL_TEXTURE_WRAP_T 0x2803
1166#define GL_TILING_TYPES_EXT 0x9583
1167#define GL_TIMESTAMP_EXT 0x8E28
1168#define GL_TIME_ELAPSED_EXT 0x88BF
1169#define GL_TRANSFORM_FEEDBACK 0x8E22
1170#define GL_TRIANGLES 0x0004
1171#define GL_TRIANGLES_ADJACENCY_EXT 0x000C
1172#define GL_TRIANGLES_ADJACENCY_OES 0x000C
1173#define GL_TRIANGLE_FAN 0x0006
1174#define GL_TRIANGLE_STRIP 0x0005
1175#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D
1176#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D
1177#define GL_TRUE 1
1178#define GL_UNDEFINED_VERTEX_EXT 0x8260
1179#define GL_UNDEFINED_VERTEX_OES 0x8260
1180#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
1181#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255
1182#define GL_UNPACK_ALIGNMENT 0x0CF5
1183#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
1184#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
1185#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
1186#define GL_UNSIGNED_BYTE 0x1401
1187#define GL_UNSIGNED_INT 0x1405
1188#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
1189#define GL_UNSIGNED_INT_24_8_OES 0x84FA
1190#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
1191#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067
1192#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067
1193#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
1194#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A
1195#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D
1196#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
1197#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8
1198#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F
1199#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F
1200#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
1201#define GL_UNSIGNED_SHORT 0x1403
1202#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
1203#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
1204#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
1205#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
1206#define GL_UNSIGNED_SHORT_5_6_5 0x8363
1207#define GL_UPPER_LEFT 0x8CA2
1208#define GL_UPPER_LEFT_EXT 0x8CA2
1209#define GL_UUID_SIZE_EXT 16
1210#define GL_VALIDATE_STATUS 0x8B83
1211#define GL_VENDOR 0x1F00
1212#define GL_VERSION 0x1F02
1213#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
1214#define GL_VERTEX_ARRAY_KHR 0x8074
1215#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
1216#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
1217#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE
1218#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
1219#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
1220#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
1221#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
1222#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
1223#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
1224#define GL_VERTEX_SHADER 0x8B31
1225#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
1226#define GL_VIEWPORT 0x0BA2
1227#define GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D
1228#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F
1229#define GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C
1230#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7
1231#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195
1232#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196
1233#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197
1234#define GL_WEIGHTED_AVERAGE_ARB 0x9367
1235#define GL_WEIGHTED_AVERAGE_EXT 0x9367
1236#define GL_WINDOW_RECTANGLE_EXT 0x8F12
1237#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13
1238#define GL_WRITE_ONLY_OES 0x88B9
1239#define GL_ZERO 0
1240#define GL_ZERO_TO_ONE 0x935F
1241#define GL_ZERO_TO_ONE_EXT 0x935F
1242
1243
1244#ifndef __khrplatform_h_
1245#define __khrplatform_h_
1246
1247/*
1248** Copyright (c) 2008-2018 The Khronos Group Inc.
1249**
1250** Permission is hereby granted, free of charge, to any person obtaining a
1251** copy of this software and/or associated documentation files (the
1252** "Materials"), to deal in the Materials without restriction, including
1253** without limitation the rights to use, copy, modify, merge, publish,
1254** distribute, sublicense, and/or sell copies of the Materials, and to
1255** permit persons to whom the Materials are furnished to do so, subject to
1256** the following conditions:
1257**
1258** The above copyright notice and this permission notice shall be included
1259** in all copies or substantial portions of the Materials.
1260**
1261** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1262** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1263** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1264** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1265** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1266** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1267** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
1268*/
1269
1270/* Khronos platform-specific types and definitions.
1271 *
1272 * The master copy of khrplatform.h is maintained in the Khronos EGL
1273 * Registry repository at https://github.com/KhronosGroup/EGL-Registry
1274 * The last semantic modification to khrplatform.h was at commit ID:
1275 * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
1276 *
1277 * Adopters may modify this file to suit their platform. Adopters are
1278 * encouraged to submit platform specific modifications to the Khronos
1279 * group so that they can be included in future versions of this file.
1280 * Please submit changes by filing pull requests or issues on
1281 * the EGL Registry repository linked above.
1282 *
1283 *
1284 * See the Implementer's Guidelines for information about where this file
1285 * should be located on your system and for more details of its use:
1286 * http://www.khronos.org/registry/implementers_guide.pdf
1287 *
1288 * This file should be included as
1289 * #include <KHR/khrplatform.h>
1290 * by Khronos client API header files that use its types and defines.
1291 *
1292 * The types in khrplatform.h should only be used to define API-specific types.
1293 *
1294 * Types defined in khrplatform.h:
1295 * khronos_int8_t signed 8 bit
1296 * khronos_uint8_t unsigned 8 bit
1297 * khronos_int16_t signed 16 bit
1298 * khronos_uint16_t unsigned 16 bit
1299 * khronos_int32_t signed 32 bit
1300 * khronos_uint32_t unsigned 32 bit
1301 * khronos_int64_t signed 64 bit
1302 * khronos_uint64_t unsigned 64 bit
1303 * khronos_intptr_t signed same number of bits as a pointer
1304 * khronos_uintptr_t unsigned same number of bits as a pointer
1305 * khronos_ssize_t signed size
1306 * khronos_usize_t unsigned size
1307 * khronos_float_t signed 32 bit floating point
1308 * khronos_time_ns_t unsigned 64 bit time in nanoseconds
1309 * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
1310 * nanoseconds
1311 * khronos_stime_nanoseconds_t signed time interval in nanoseconds
1312 * khronos_boolean_enum_t enumerated boolean type. This should
1313 * only be used as a base type when a client API's boolean type is
1314 * an enum. Client APIs which use an integer or other type for
1315 * booleans cannot use this as the base type for their boolean.
1316 *
1317 * Tokens defined in khrplatform.h:
1318 *
1319 * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
1320 *
1321 * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
1322 * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
1323 *
1324 * Calling convention macros defined in this file:
1325 * KHRONOS_APICALL
1326 * KHRONOS_GLAD_API_PTR
1327 * KHRONOS_APIATTRIBUTES
1328 *
1329 * These may be used in function prototypes as:
1330 *
1331 * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname(
1332 * int arg1,
1333 * int arg2) KHRONOS_APIATTRIBUTES;
1334 */
1335
1336#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
1337# define KHRONOS_STATIC 1
1338#endif
1339
1340/*-------------------------------------------------------------------------
1341 * Definition of KHRONOS_APICALL
1342 *-------------------------------------------------------------------------
1343 * This precedes the return type of the function in the function prototype.
1344 */
1345#if defined(KHRONOS_STATIC)
1346 /* If the preprocessor constant KHRONOS_STATIC is defined, make the
1347 * header compatible with static linking. */
1348# define KHRONOS_APICALL
1349#elif defined(_WIN32)
1350# define KHRONOS_APICALL __declspec(dllimport)
1351#elif defined (__SYMBIAN32__)
1352# define KHRONOS_APICALL IMPORT_C
1353#elif defined(__ANDROID__)
1354# define KHRONOS_APICALL __attribute__((visibility("default")))
1355#else
1356# define KHRONOS_APICALL
1357#endif
1358
1359/*-------------------------------------------------------------------------
1360 * Definition of KHRONOS_GLAD_API_PTR
1361 *-------------------------------------------------------------------------
1362 * This follows the return type of the function and precedes the function
1363 * name in the function prototype.
1364 */
1365#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
1366 /* Win32 but not WinCE */
1367# define KHRONOS_GLAD_API_PTR __stdcall
1368#else
1369# define KHRONOS_GLAD_API_PTR
1370#endif
1371
1372/*-------------------------------------------------------------------------
1373 * Definition of KHRONOS_APIATTRIBUTES
1374 *-------------------------------------------------------------------------
1375 * This follows the closing parenthesis of the function prototype arguments.
1376 */
1377#if defined (__ARMCC_2__)
1378#define KHRONOS_APIATTRIBUTES __softfp
1379#else
1380#define KHRONOS_APIATTRIBUTES
1381#endif
1382
1383/*-------------------------------------------------------------------------
1384 * basic type definitions
1385 *-----------------------------------------------------------------------*/
1386#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
1387
1388
1389/*
1390 * Using <stdint.h>
1391 */
1392#include <stdint.h>
1393typedef int32_t khronos_int32_t;
1394typedef uint32_t khronos_uint32_t;
1395typedef int64_t khronos_int64_t;
1396typedef uint64_t khronos_uint64_t;
1397#define KHRONOS_SUPPORT_INT64 1
1398#define KHRONOS_SUPPORT_FLOAT 1
1399/*
1400 * To support platform where unsigned long cannot be used interchangeably with
1401 * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
1402 * Ideally, we could just use (u)intptr_t everywhere, but this could result in
1403 * ABI breakage if khronos_uintptr_t is changed from unsigned long to
1404 * unsigned long long or similar (this results in different C++ name mangling).
1405 * To avoid changes for existing platforms, we restrict usage of intptr_t to
1406 * platforms where the size of a pointer is larger than the size of long.
1407 */
1408#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
1409#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
1410#define KHRONOS_USE_INTPTR_T
1411#endif
1412#endif
1413
1414#elif defined(__VMS ) || defined(__sgi)
1415
1416/*
1417 * Using <inttypes.h>
1418 */
1419#include <inttypes.h>
1420typedef int32_t khronos_int32_t;
1421typedef uint32_t khronos_uint32_t;
1422typedef int64_t khronos_int64_t;
1423typedef uint64_t khronos_uint64_t;
1424#define KHRONOS_SUPPORT_INT64 1
1425#define KHRONOS_SUPPORT_FLOAT 1
1426
1427#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
1428
1429/*
1430 * Win32
1431 */
1432typedef __int32 khronos_int32_t;
1433typedef unsigned __int32 khronos_uint32_t;
1434typedef __int64 khronos_int64_t;
1435typedef unsigned __int64 khronos_uint64_t;
1436#define KHRONOS_SUPPORT_INT64 1
1437#define KHRONOS_SUPPORT_FLOAT 1
1438
1439#elif defined(__sun__) || defined(__digital__)
1440
1441/*
1442 * Sun or Digital
1443 */
1444typedef int khronos_int32_t;
1445typedef unsigned int khronos_uint32_t;
1446#if defined(__arch64__) || defined(_LP64)
1447typedef long int khronos_int64_t;
1448typedef unsigned long int khronos_uint64_t;
1449#else
1450typedef long long int khronos_int64_t;
1451typedef unsigned long long int khronos_uint64_t;
1452#endif /* __arch64__ */
1453#define KHRONOS_SUPPORT_INT64 1
1454#define KHRONOS_SUPPORT_FLOAT 1
1455
1456#elif 0
1457
1458/*
1459 * Hypothetical platform with no float or int64 support
1460 */
1461typedef int khronos_int32_t;
1462typedef unsigned int khronos_uint32_t;
1463#define KHRONOS_SUPPORT_INT64 0
1464#define KHRONOS_SUPPORT_FLOAT 0
1465
1466#else
1467
1468/*
1469 * Generic fallback
1470 */
1471#include <stdint.h>
1472typedef int32_t khronos_int32_t;
1473typedef uint32_t khronos_uint32_t;
1474typedef int64_t khronos_int64_t;
1475typedef uint64_t khronos_uint64_t;
1476#define KHRONOS_SUPPORT_INT64 1
1477#define KHRONOS_SUPPORT_FLOAT 1
1478
1479#endif
1480
1481
1482/*
1483 * Types that are (so far) the same on all platforms
1484 */
1485typedef signed char khronos_int8_t;
1486typedef unsigned char khronos_uint8_t;
1487typedef signed short int khronos_int16_t;
1488typedef unsigned short int khronos_uint16_t;
1489
1490/*
1491 * Types that differ between LLP64 and LP64 architectures - in LLP64,
1492 * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
1493 * to be the only LLP64 architecture in current use.
1494 */
1495#ifdef KHRONOS_USE_INTPTR_T
1496typedef intptr_t khronos_intptr_t;
1497typedef uintptr_t khronos_uintptr_t;
1498#elif defined(_WIN64)
1499typedef signed long long int khronos_intptr_t;
1500typedef unsigned long long int khronos_uintptr_t;
1501#else
1502typedef signed long int khronos_intptr_t;
1503typedef unsigned long int khronos_uintptr_t;
1504#endif
1505
1506#if defined(_WIN64)
1507typedef signed long long int khronos_ssize_t;
1508typedef unsigned long long int khronos_usize_t;
1509#else
1510typedef signed long int khronos_ssize_t;
1511typedef unsigned long int khronos_usize_t;
1512#endif
1513
1514#if KHRONOS_SUPPORT_FLOAT
1515/*
1516 * Float type
1517 */
1518typedef float khronos_float_t;
1519#endif
1520
1521#if KHRONOS_SUPPORT_INT64
1522/* Time types
1523 *
1524 * These types can be used to represent a time interval in nanoseconds or
1525 * an absolute Unadjusted System Time. Unadjusted System Time is the number
1526 * of nanoseconds since some arbitrary system event (e.g. since the last
1527 * time the system booted). The Unadjusted System Time is an unsigned
1528 * 64 bit value that wraps back to 0 every 584 years. Time intervals
1529 * may be either signed or unsigned.
1530 */
1531typedef khronos_uint64_t khronos_utime_nanoseconds_t;
1532typedef khronos_int64_t khronos_stime_nanoseconds_t;
1533#endif
1534
1535/*
1536 * Dummy value used to pad enum types to 32 bits.
1537 */
1538#ifndef KHRONOS_MAX_ENUM
1539#define KHRONOS_MAX_ENUM 0x7FFFFFFF
1540#endif
1541
1542/*
1543 * Enumerated boolean type
1544 *
1545 * Values other than zero should be considered to be true. Therefore
1546 * comparisons should not be made against KHRONOS_TRUE.
1547 */
1548typedef enum {
1549 KHRONOS_FALSE = 0,
1550 KHRONOS_TRUE = 1,
1551 KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
1552} khronos_boolean_enum_t;
1553
1554#endif /* __khrplatform_h_ */
1555typedef unsigned int GLenum;
1556typedef unsigned char GLboolean;
1557typedef unsigned int GLbitfield;
1558typedef void GLvoid;
1559typedef khronos_int8_t GLbyte;
1560typedef khronos_uint8_t GLubyte;
1561typedef khronos_int16_t GLshort;
1562typedef khronos_uint16_t GLushort;
1563typedef int GLint;
1564typedef unsigned int GLuint;
1565typedef khronos_int32_t GLclampx;
1566typedef int GLsizei;
1567typedef khronos_float_t GLfloat;
1568typedef khronos_float_t GLclampf;
1569typedef double GLdouble;
1570typedef double GLclampd;
1571typedef void *GLeglClientBufferEXT;
1572typedef void *GLeglImageOES;
1573typedef char GLchar;
1574typedef char GLcharARB;
1575#ifdef __APPLE__
1576typedef void *GLhandleARB;
1577#else
1578typedef unsigned int GLhandleARB;
1579#endif
1580typedef khronos_uint16_t GLhalf;
1581typedef khronos_uint16_t GLhalfARB;
1582typedef khronos_int32_t GLfixed;
1583#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1584typedef khronos_intptr_t GLintptr;
1585#else
1586typedef khronos_intptr_t GLintptr;
1587#endif
1588#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1589typedef khronos_intptr_t GLintptrARB;
1590#else
1591typedef khronos_intptr_t GLintptrARB;
1592#endif
1593#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1594typedef khronos_ssize_t GLsizeiptr;
1595#else
1596typedef khronos_ssize_t GLsizeiptr;
1597#endif
1598#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1599typedef khronos_ssize_t GLsizeiptrARB;
1600#else
1601typedef khronos_ssize_t GLsizeiptrARB;
1602#endif
1603typedef khronos_int64_t GLint64;
1604typedef khronos_int64_t GLint64EXT;
1605typedef khronos_uint64_t GLuint64;
1606typedef khronos_uint64_t GLuint64EXT;
1607typedef struct __GLsync *GLsync;
1608struct _cl_context;
1609struct _cl_event;
1610typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
1611typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
1612typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
1613typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
1614typedef unsigned short GLhalfNV;
1615typedef GLintptr GLvdpauSurfaceNV;
1616typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void);
1617
1618
1619#define GL_ES_VERSION_2_0 1
1620GLAD_API_CALL int GLAD_GL_ES_VERSION_2_0;
1621#define GL_EXT_EGL_image_array 1
1622GLAD_API_CALL int GLAD_GL_EXT_EGL_image_array;
1623#define GL_EXT_EGL_image_storage 1
1624GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage;
1625#define GL_EXT_EGL_image_storage_compression 1
1626GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage_compression;
1627#define GL_EXT_YUV_target 1
1628GLAD_API_CALL int GLAD_GL_EXT_YUV_target;
1629#define GL_EXT_base_instance 1
1630GLAD_API_CALL int GLAD_GL_EXT_base_instance;
1631#define GL_EXT_blend_func_extended 1
1632GLAD_API_CALL int GLAD_GL_EXT_blend_func_extended;
1633#define GL_EXT_blend_minmax 1
1634GLAD_API_CALL int GLAD_GL_EXT_blend_minmax;
1635#define GL_EXT_buffer_storage 1
1636GLAD_API_CALL int GLAD_GL_EXT_buffer_storage;
1637#define GL_EXT_clear_texture 1
1638GLAD_API_CALL int GLAD_GL_EXT_clear_texture;
1639#define GL_EXT_clip_control 1
1640GLAD_API_CALL int GLAD_GL_EXT_clip_control;
1641#define GL_EXT_clip_cull_distance 1
1642GLAD_API_CALL int GLAD_GL_EXT_clip_cull_distance;
1643#define GL_EXT_color_buffer_float 1
1644GLAD_API_CALL int GLAD_GL_EXT_color_buffer_float;
1645#define GL_EXT_color_buffer_half_float 1
1646GLAD_API_CALL int GLAD_GL_EXT_color_buffer_half_float;
1647#define GL_EXT_conservative_depth 1
1648GLAD_API_CALL int GLAD_GL_EXT_conservative_depth;
1649#define GL_EXT_copy_image 1
1650GLAD_API_CALL int GLAD_GL_EXT_copy_image;
1651#define GL_EXT_debug_label 1
1652GLAD_API_CALL int GLAD_GL_EXT_debug_label;
1653#define GL_EXT_debug_marker 1
1654GLAD_API_CALL int GLAD_GL_EXT_debug_marker;
1655#define GL_EXT_depth_clamp 1
1656GLAD_API_CALL int GLAD_GL_EXT_depth_clamp;
1657#define GL_EXT_discard_framebuffer 1
1658GLAD_API_CALL int GLAD_GL_EXT_discard_framebuffer;
1659#define GL_EXT_disjoint_timer_query 1
1660GLAD_API_CALL int GLAD_GL_EXT_disjoint_timer_query;
1661#define GL_EXT_draw_buffers 1
1662GLAD_API_CALL int GLAD_GL_EXT_draw_buffers;
1663#define GL_EXT_draw_buffers_indexed 1
1664GLAD_API_CALL int GLAD_GL_EXT_draw_buffers_indexed;
1665#define GL_EXT_draw_elements_base_vertex 1
1666GLAD_API_CALL int GLAD_GL_EXT_draw_elements_base_vertex;
1667#define GL_EXT_draw_instanced 1
1668GLAD_API_CALL int GLAD_GL_EXT_draw_instanced;
1669#define GL_EXT_draw_transform_feedback 1
1670GLAD_API_CALL int GLAD_GL_EXT_draw_transform_feedback;
1671#define GL_EXT_external_buffer 1
1672GLAD_API_CALL int GLAD_GL_EXT_external_buffer;
1673#define GL_EXT_float_blend 1
1674GLAD_API_CALL int GLAD_GL_EXT_float_blend;
1675#define GL_EXT_fragment_shading_rate 1
1676GLAD_API_CALL int GLAD_GL_EXT_fragment_shading_rate;
1677#define GL_EXT_geometry_point_size 1
1678GLAD_API_CALL int GLAD_GL_EXT_geometry_point_size;
1679#define GL_EXT_geometry_shader 1
1680GLAD_API_CALL int GLAD_GL_EXT_geometry_shader;
1681#define GL_EXT_gpu_shader5 1
1682GLAD_API_CALL int GLAD_GL_EXT_gpu_shader5;
1683#define GL_EXT_instanced_arrays 1
1684GLAD_API_CALL int GLAD_GL_EXT_instanced_arrays;
1685#define GL_EXT_map_buffer_range 1
1686GLAD_API_CALL int GLAD_GL_EXT_map_buffer_range;
1687#define GL_EXT_memory_object 1
1688GLAD_API_CALL int GLAD_GL_EXT_memory_object;
1689#define GL_EXT_memory_object_fd 1
1690GLAD_API_CALL int GLAD_GL_EXT_memory_object_fd;
1691#define GL_EXT_memory_object_win32 1
1692GLAD_API_CALL int GLAD_GL_EXT_memory_object_win32;
1693#define GL_EXT_multi_draw_arrays 1
1694GLAD_API_CALL int GLAD_GL_EXT_multi_draw_arrays;
1695#define GL_EXT_multi_draw_indirect 1
1696GLAD_API_CALL int GLAD_GL_EXT_multi_draw_indirect;
1697#define GL_EXT_multisampled_compatibility 1
1698GLAD_API_CALL int GLAD_GL_EXT_multisampled_compatibility;
1699#define GL_EXT_multisampled_render_to_texture 1
1700GLAD_API_CALL int GLAD_GL_EXT_multisampled_render_to_texture;
1701#define GL_EXT_multisampled_render_to_texture2 1
1702GLAD_API_CALL int GLAD_GL_EXT_multisampled_render_to_texture2;
1703#define GL_EXT_multiview_draw_buffers 1
1704GLAD_API_CALL int GLAD_GL_EXT_multiview_draw_buffers;
1705#define GL_EXT_multiview_tessellation_geometry_shader 1
1706GLAD_API_CALL int GLAD_GL_EXT_multiview_tessellation_geometry_shader;
1707#define GL_EXT_multiview_texture_multisample 1
1708GLAD_API_CALL int GLAD_GL_EXT_multiview_texture_multisample;
1709#define GL_EXT_multiview_timer_query 1
1710GLAD_API_CALL int GLAD_GL_EXT_multiview_timer_query;
1711#define GL_EXT_occlusion_query_boolean 1
1712GLAD_API_CALL int GLAD_GL_EXT_occlusion_query_boolean;
1713#define GL_EXT_polygon_offset_clamp 1
1714GLAD_API_CALL int GLAD_GL_EXT_polygon_offset_clamp;
1715#define GL_EXT_post_depth_coverage 1
1716GLAD_API_CALL int GLAD_GL_EXT_post_depth_coverage;
1717#define GL_EXT_primitive_bounding_box 1
1718GLAD_API_CALL int GLAD_GL_EXT_primitive_bounding_box;
1719#define GL_EXT_protected_textures 1
1720GLAD_API_CALL int GLAD_GL_EXT_protected_textures;
1721#define GL_EXT_pvrtc_sRGB 1
1722GLAD_API_CALL int GLAD_GL_EXT_pvrtc_sRGB;
1723#define GL_EXT_raster_multisample 1
1724GLAD_API_CALL int GLAD_GL_EXT_raster_multisample;
1725#define GL_EXT_read_format_bgra 1
1726GLAD_API_CALL int GLAD_GL_EXT_read_format_bgra;
1727#define GL_EXT_render_snorm 1
1728GLAD_API_CALL int GLAD_GL_EXT_render_snorm;
1729#define GL_EXT_robustness 1
1730GLAD_API_CALL int GLAD_GL_EXT_robustness;
1731#define GL_EXT_sRGB 1
1732GLAD_API_CALL int GLAD_GL_EXT_sRGB;
1733#define GL_EXT_sRGB_write_control 1
1734GLAD_API_CALL int GLAD_GL_EXT_sRGB_write_control;
1735#define GL_EXT_semaphore 1
1736GLAD_API_CALL int GLAD_GL_EXT_semaphore;
1737#define GL_EXT_semaphore_fd 1
1738GLAD_API_CALL int GLAD_GL_EXT_semaphore_fd;
1739#define GL_EXT_semaphore_win32 1
1740GLAD_API_CALL int GLAD_GL_EXT_semaphore_win32;
1741#define GL_EXT_separate_depth_stencil 1
1742GLAD_API_CALL int GLAD_GL_EXT_separate_depth_stencil;
1743#define GL_EXT_separate_shader_objects 1
1744GLAD_API_CALL int GLAD_GL_EXT_separate_shader_objects;
1745#define GL_EXT_shader_framebuffer_fetch 1
1746GLAD_API_CALL int GLAD_GL_EXT_shader_framebuffer_fetch;
1747#define GL_EXT_shader_framebuffer_fetch_non_coherent 1
1748GLAD_API_CALL int GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent;
1749#define GL_EXT_shader_group_vote 1
1750GLAD_API_CALL int GLAD_GL_EXT_shader_group_vote;
1751#define GL_EXT_shader_implicit_conversions 1
1752GLAD_API_CALL int GLAD_GL_EXT_shader_implicit_conversions;
1753#define GL_EXT_shader_integer_mix 1
1754GLAD_API_CALL int GLAD_GL_EXT_shader_integer_mix;
1755#define GL_EXT_shader_io_blocks 1
1756GLAD_API_CALL int GLAD_GL_EXT_shader_io_blocks;
1757#define GL_EXT_shader_non_constant_global_initializers 1
1758GLAD_API_CALL int GLAD_GL_EXT_shader_non_constant_global_initializers;
1759#define GL_EXT_shader_pixel_local_storage 1
1760GLAD_API_CALL int GLAD_GL_EXT_shader_pixel_local_storage;
1761#define GL_EXT_shader_pixel_local_storage2 1
1762GLAD_API_CALL int GLAD_GL_EXT_shader_pixel_local_storage2;
1763#define GL_EXT_shader_samples_identical 1
1764GLAD_API_CALL int GLAD_GL_EXT_shader_samples_identical;
1765#define GL_EXT_shader_texture_lod 1
1766GLAD_API_CALL int GLAD_GL_EXT_shader_texture_lod;
1767#define GL_EXT_shadow_samplers 1
1768GLAD_API_CALL int GLAD_GL_EXT_shadow_samplers;
1769#define GL_EXT_sparse_texture 1
1770GLAD_API_CALL int GLAD_GL_EXT_sparse_texture;
1771#define GL_EXT_sparse_texture2 1
1772GLAD_API_CALL int GLAD_GL_EXT_sparse_texture2;
1773#define GL_EXT_tessellation_point_size 1
1774GLAD_API_CALL int GLAD_GL_EXT_tessellation_point_size;
1775#define GL_EXT_tessellation_shader 1
1776GLAD_API_CALL int GLAD_GL_EXT_tessellation_shader;
1777#define GL_EXT_texture_border_clamp 1
1778GLAD_API_CALL int GLAD_GL_EXT_texture_border_clamp;
1779#define GL_EXT_texture_buffer 1
1780GLAD_API_CALL int GLAD_GL_EXT_texture_buffer;
1781#define GL_EXT_texture_compression_astc_decode_mode 1
1782GLAD_API_CALL int GLAD_GL_EXT_texture_compression_astc_decode_mode;
1783#define GL_EXT_texture_compression_bptc 1
1784GLAD_API_CALL int GLAD_GL_EXT_texture_compression_bptc;
1785#define GL_EXT_texture_compression_dxt1 1
1786GLAD_API_CALL int GLAD_GL_EXT_texture_compression_dxt1;
1787#define GL_EXT_texture_compression_rgtc 1
1788GLAD_API_CALL int GLAD_GL_EXT_texture_compression_rgtc;
1789#define GL_EXT_texture_compression_s3tc 1
1790GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc;
1791#define GL_EXT_texture_compression_s3tc_srgb 1
1792GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc_srgb;
1793#define GL_EXT_texture_cube_map_array 1
1794GLAD_API_CALL int GLAD_GL_EXT_texture_cube_map_array;
1795#define GL_EXT_texture_filter_anisotropic 1
1796GLAD_API_CALL int GLAD_GL_EXT_texture_filter_anisotropic;
1797#define GL_EXT_texture_filter_minmax 1
1798GLAD_API_CALL int GLAD_GL_EXT_texture_filter_minmax;
1799#define GL_EXT_texture_format_BGRA8888 1
1800GLAD_API_CALL int GLAD_GL_EXT_texture_format_BGRA8888;
1801#define GL_EXT_texture_format_sRGB_override 1
1802GLAD_API_CALL int GLAD_GL_EXT_texture_format_sRGB_override;
1803#define GL_EXT_texture_mirror_clamp_to_edge 1
1804GLAD_API_CALL int GLAD_GL_EXT_texture_mirror_clamp_to_edge;
1805#define GL_EXT_texture_norm16 1
1806GLAD_API_CALL int GLAD_GL_EXT_texture_norm16;
1807#define GL_EXT_texture_query_lod 1
1808GLAD_API_CALL int GLAD_GL_EXT_texture_query_lod;
1809#define GL_EXT_texture_rg 1
1810GLAD_API_CALL int GLAD_GL_EXT_texture_rg;
1811#define GL_EXT_texture_sRGB_R8 1
1812GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_R8;
1813#define GL_EXT_texture_sRGB_RG8 1
1814GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_RG8;
1815#define GL_EXT_texture_sRGB_decode 1
1816GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_decode;
1817#define GL_EXT_texture_shadow_lod 1
1818GLAD_API_CALL int GLAD_GL_EXT_texture_shadow_lod;
1819#define GL_EXT_texture_storage 1
1820GLAD_API_CALL int GLAD_GL_EXT_texture_storage;
1821#define GL_EXT_texture_storage_compression 1
1822GLAD_API_CALL int GLAD_GL_EXT_texture_storage_compression;
1823#define GL_EXT_texture_type_2_10_10_10_REV 1
1824GLAD_API_CALL int GLAD_GL_EXT_texture_type_2_10_10_10_REV;
1825#define GL_EXT_texture_view 1
1826GLAD_API_CALL int GLAD_GL_EXT_texture_view;
1827#define GL_EXT_unpack_subimage 1
1828GLAD_API_CALL int GLAD_GL_EXT_unpack_subimage;
1829#define GL_EXT_win32_keyed_mutex 1
1830GLAD_API_CALL int GLAD_GL_EXT_win32_keyed_mutex;
1831#define GL_EXT_window_rectangles 1
1832GLAD_API_CALL int GLAD_GL_EXT_window_rectangles;
1833#define GL_KHR_blend_equation_advanced 1
1834GLAD_API_CALL int GLAD_GL_KHR_blend_equation_advanced;
1835#define GL_KHR_blend_equation_advanced_coherent 1
1836GLAD_API_CALL int GLAD_GL_KHR_blend_equation_advanced_coherent;
1837#define GL_KHR_context_flush_control 1
1838GLAD_API_CALL int GLAD_GL_KHR_context_flush_control;
1839#define GL_KHR_debug 1
1840GLAD_API_CALL int GLAD_GL_KHR_debug;
1841#define GL_KHR_no_error 1
1842GLAD_API_CALL int GLAD_GL_KHR_no_error;
1843#define GL_KHR_parallel_shader_compile 1
1844GLAD_API_CALL int GLAD_GL_KHR_parallel_shader_compile;
1845#define GL_KHR_robust_buffer_access_behavior 1
1846GLAD_API_CALL int GLAD_GL_KHR_robust_buffer_access_behavior;
1847#define GL_KHR_robustness 1
1848GLAD_API_CALL int GLAD_GL_KHR_robustness;
1849#define GL_KHR_shader_subgroup 1
1850GLAD_API_CALL int GLAD_GL_KHR_shader_subgroup;
1851#define GL_KHR_texture_compression_astc_hdr 1
1852GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_hdr;
1853#define GL_KHR_texture_compression_astc_ldr 1
1854GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_ldr;
1855#define GL_KHR_texture_compression_astc_sliced_3d 1
1856GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_sliced_3d;
1857#define GL_OES_EGL_image 1
1858GLAD_API_CALL int GLAD_GL_OES_EGL_image;
1859#define GL_OES_EGL_image_external 1
1860GLAD_API_CALL int GLAD_GL_OES_EGL_image_external;
1861#define GL_OES_EGL_image_external_essl3 1
1862GLAD_API_CALL int GLAD_GL_OES_EGL_image_external_essl3;
1863#define GL_OES_compressed_ETC1_RGB8_sub_texture 1
1864GLAD_API_CALL int GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture;
1865#define GL_OES_compressed_ETC1_RGB8_texture 1
1866GLAD_API_CALL int GLAD_GL_OES_compressed_ETC1_RGB8_texture;
1867#define GL_OES_compressed_paletted_texture 1
1868GLAD_API_CALL int GLAD_GL_OES_compressed_paletted_texture;
1869#define GL_OES_copy_image 1
1870GLAD_API_CALL int GLAD_GL_OES_copy_image;
1871#define GL_OES_depth24 1
1872GLAD_API_CALL int GLAD_GL_OES_depth24;
1873#define GL_OES_depth32 1
1874GLAD_API_CALL int GLAD_GL_OES_depth32;
1875#define GL_OES_depth_texture 1
1876GLAD_API_CALL int GLAD_GL_OES_depth_texture;
1877#define GL_OES_draw_buffers_indexed 1
1878GLAD_API_CALL int GLAD_GL_OES_draw_buffers_indexed;
1879#define GL_OES_draw_elements_base_vertex 1
1880GLAD_API_CALL int GLAD_GL_OES_draw_elements_base_vertex;
1881#define GL_OES_element_index_uint 1
1882GLAD_API_CALL int GLAD_GL_OES_element_index_uint;
1883#define GL_OES_fbo_render_mipmap 1
1884GLAD_API_CALL int GLAD_GL_OES_fbo_render_mipmap;
1885#define GL_OES_fragment_precision_high 1
1886GLAD_API_CALL int GLAD_GL_OES_fragment_precision_high;
1887#define GL_OES_geometry_point_size 1
1888GLAD_API_CALL int GLAD_GL_OES_geometry_point_size;
1889#define GL_OES_geometry_shader 1
1890GLAD_API_CALL int GLAD_GL_OES_geometry_shader;
1891#define GL_OES_get_program_binary 1
1892GLAD_API_CALL int GLAD_GL_OES_get_program_binary;
1893#define GL_OES_gpu_shader5 1
1894GLAD_API_CALL int GLAD_GL_OES_gpu_shader5;
1895#define GL_OES_mapbuffer 1
1896GLAD_API_CALL int GLAD_GL_OES_mapbuffer;
1897#define GL_OES_packed_depth_stencil 1
1898GLAD_API_CALL int GLAD_GL_OES_packed_depth_stencil;
1899#define GL_OES_primitive_bounding_box 1
1900GLAD_API_CALL int GLAD_GL_OES_primitive_bounding_box;
1901#define GL_OES_required_internalformat 1
1902GLAD_API_CALL int GLAD_GL_OES_required_internalformat;
1903#define GL_OES_rgb8_rgba8 1
1904GLAD_API_CALL int GLAD_GL_OES_rgb8_rgba8;
1905#define GL_OES_sample_shading 1
1906GLAD_API_CALL int GLAD_GL_OES_sample_shading;
1907#define GL_OES_sample_variables 1
1908GLAD_API_CALL int GLAD_GL_OES_sample_variables;
1909#define GL_OES_shader_image_atomic 1
1910GLAD_API_CALL int GLAD_GL_OES_shader_image_atomic;
1911#define GL_OES_shader_io_blocks 1
1912GLAD_API_CALL int GLAD_GL_OES_shader_io_blocks;
1913#define GL_OES_shader_multisample_interpolation 1
1914GLAD_API_CALL int GLAD_GL_OES_shader_multisample_interpolation;
1915#define GL_OES_standard_derivatives 1
1916GLAD_API_CALL int GLAD_GL_OES_standard_derivatives;
1917#define GL_OES_stencil1 1
1918GLAD_API_CALL int GLAD_GL_OES_stencil1;
1919#define GL_OES_stencil4 1
1920GLAD_API_CALL int GLAD_GL_OES_stencil4;
1921#define GL_OES_surfaceless_context 1
1922GLAD_API_CALL int GLAD_GL_OES_surfaceless_context;
1923#define GL_OES_tessellation_point_size 1
1924GLAD_API_CALL int GLAD_GL_OES_tessellation_point_size;
1925#define GL_OES_tessellation_shader 1
1926GLAD_API_CALL int GLAD_GL_OES_tessellation_shader;
1927#define GL_OES_texture_3D 1
1928GLAD_API_CALL int GLAD_GL_OES_texture_3D;
1929#define GL_OES_texture_border_clamp 1
1930GLAD_API_CALL int GLAD_GL_OES_texture_border_clamp;
1931#define GL_OES_texture_buffer 1
1932GLAD_API_CALL int GLAD_GL_OES_texture_buffer;
1933#define GL_OES_texture_compression_astc 1
1934GLAD_API_CALL int GLAD_GL_OES_texture_compression_astc;
1935#define GL_OES_texture_cube_map_array 1
1936GLAD_API_CALL int GLAD_GL_OES_texture_cube_map_array;
1937#define GL_OES_texture_float 1
1938GLAD_API_CALL int GLAD_GL_OES_texture_float;
1939#define GL_OES_texture_float_linear 1
1940GLAD_API_CALL int GLAD_GL_OES_texture_float_linear;
1941#define GL_OES_texture_half_float 1
1942GLAD_API_CALL int GLAD_GL_OES_texture_half_float;
1943#define GL_OES_texture_half_float_linear 1
1944GLAD_API_CALL int GLAD_GL_OES_texture_half_float_linear;
1945#define GL_OES_texture_npot 1
1946GLAD_API_CALL int GLAD_GL_OES_texture_npot;
1947#define GL_OES_texture_stencil8 1
1948GLAD_API_CALL int GLAD_GL_OES_texture_stencil8;
1949#define GL_OES_texture_storage_multisample_2d_array 1
1950GLAD_API_CALL int GLAD_GL_OES_texture_storage_multisample_2d_array;
1951#define GL_OES_texture_view 1
1952GLAD_API_CALL int GLAD_GL_OES_texture_view;
1953#define GL_OES_vertex_array_object 1
1954GLAD_API_CALL int GLAD_GL_OES_vertex_array_object;
1955#define GL_OES_vertex_half_float 1
1956GLAD_API_CALL int GLAD_GL_OES_vertex_half_float;
1957#define GL_OES_vertex_type_10_10_10_2 1
1958GLAD_API_CALL int GLAD_GL_OES_vertex_type_10_10_10_2;
1959#define GL_OES_viewport_array 1
1960GLAD_API_CALL int GLAD_GL_OES_viewport_array;
1961
1962
1963typedef GLboolean (GLAD_API_PTR *PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC)(GLuint memory, GLuint64 key, GLuint timeout);
1964typedef void (GLAD_API_PTR *PFNGLACTIVESHADERPROGRAMEXTPROC)(GLuint pipeline, GLuint program);
1965typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture);
1966typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
1967typedef void (GLAD_API_PTR *PFNGLBEGINQUERYEXTPROC)(GLenum target, GLuint id);
1968typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name);
1969typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
1970typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONEXTPROC)(GLuint program, GLuint color, const GLchar * name);
1971typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);
1972typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
1973typedef void (GLAD_API_PTR *PFNGLBINDPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
1974typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
1975typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
1976typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYOESPROC)(GLuint array);
1977typedef void (GLAD_API_PTR *PFNGLBLENDBARRIERKHRPROC)(void);
1978typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
1979typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode);
1980typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
1981typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIEXTPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
1982typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIOESPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
1983typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIEXTPROC)(GLuint buf, GLenum mode);
1984typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIOESPROC)(GLuint buf, GLenum mode);
1985typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
1986typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
1987typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIEXTPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
1988typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIOESPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
1989typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIEXTPROC)(GLuint buf, GLenum src, GLenum dst);
1990typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIOESPROC)(GLuint buf, GLenum src, GLenum dst);
1991typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
1992typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEEXTPROC)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags);
1993typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEEXTERNALEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags);
1994typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEMEMEXTPROC)(GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset);
1995typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
1996typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
1997typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask);
1998typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
1999typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d);
2000typedef void (GLAD_API_PTR *PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC)(GLsizei offset, GLsizei n, const GLuint * values);
2001typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s);
2002typedef void (GLAD_API_PTR *PFNGLCLEARTEXIMAGEEXTPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void * data);
2003typedef void (GLAD_API_PTR *PFNGLCLEARTEXSUBIMAGEEXTPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data);
2004typedef void (GLAD_API_PTR *PFNGLCLIPCONTROLEXTPROC)(GLenum origin, GLenum depth);
2005typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
2006typedef void (GLAD_API_PTR *PFNGLCOLORMASKIEXTPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
2007typedef void (GLAD_API_PTR *PFNGLCOLORMASKIOESPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
2008typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader);
2009typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
2010typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
2011typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
2012typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
2013typedef void (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAEXTPROC)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
2014typedef void (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAOESPROC)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
2015typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
2016typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2017typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2018typedef void (GLAD_API_PTR *PFNGLCREATEMEMORYOBJECTSEXTPROC)(GLsizei n, GLuint * memoryObjects);
2019typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
2020typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type);
2021typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROGRAMVEXTPROC)(GLenum type, GLsizei count, const GLchar *const* strings);
2022typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode);
2023typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKKHRPROC)(GLDEBUGPROCKHR callback, const void * userParam);
2024typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLKHRPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled);
2025typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTKHRPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf);
2026typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers);
2027typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers);
2028typedef void (GLAD_API_PTR *PFNGLDELETEMEMORYOBJECTSEXTPROC)(GLsizei n, const GLuint * memoryObjects);
2029typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program);
2030typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPIPELINESEXTPROC)(GLsizei n, const GLuint * pipelines);
2031typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESEXTPROC)(GLsizei n, const GLuint * ids);
2032typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers);
2033typedef void (GLAD_API_PTR *PFNGLDELETESEMAPHORESEXTPROC)(GLsizei n, const GLuint * semaphores);
2034typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader);
2035typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures);
2036typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSOESPROC)(GLsizei n, const GLuint * arrays);
2037typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func);
2038typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag);
2039typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEARRAYFVOESPROC)(GLuint first, GLsizei count, const GLfloat * v);
2040typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEINDEXEDFOESPROC)(GLuint index, GLfloat n, GLfloat f);
2041typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
2042typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
2043typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap);
2044typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
2045typedef void (GLAD_API_PTR *PFNGLDISABLEIEXTPROC)(GLenum target, GLuint index);
2046typedef void (GLAD_API_PTR *PFNGLDISABLEIOESPROC)(GLenum target, GLuint index);
2047typedef void (GLAD_API_PTR *PFNGLDISCARDFRAMEBUFFEREXTPROC)(GLenum target, GLsizei numAttachments, const GLenum * attachments);
2048typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
2049typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
2050typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDEXTPROC)(GLenum mode, GLint start, GLsizei count, GLsizei primcount);
2051typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSEXTPROC)(GLsizei n, const GLenum * bufs);
2052typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSINDEXEDEXTPROC)(GLint n, const GLenum * location, const GLint * indices);
2053typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices);
2054typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2055typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXOESPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2056typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLuint baseinstance);
2057typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
2058typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
2059typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
2060typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
2061typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2062typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2063typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKEXTPROC)(GLenum mode, GLuint id);
2064typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC)(GLenum mode, GLuint id, GLsizei instancecount);
2065typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)(GLenum target, GLeglImageOES image);
2066typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC)(GLenum target, GLeglImageOES image, const GLint * attrib_list);
2067typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)(GLenum target, GLeglImageOES image);
2068typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC)(GLuint texture, GLeglImageOES image, const GLint * attrib_list);
2069typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap);
2070typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
2071typedef void (GLAD_API_PTR *PFNGLENABLEIEXTPROC)(GLenum target, GLuint index);
2072typedef void (GLAD_API_PTR *PFNGLENABLEIOESPROC)(GLenum target, GLuint index);
2073typedef void (GLAD_API_PTR *PFNGLENDQUERYEXTPROC)(GLenum target);
2074typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
2075typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
2076typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
2077typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC)(void);
2078typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target, GLsizei size);
2079typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
2080typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERSHADINGRATEEXTPROC)(GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight);
2081typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
2082typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
2083typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DOESPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
2084typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREEXTPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
2085typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREOESPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
2086typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode);
2087typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers);
2088typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
2089typedef void (GLAD_API_PTR *PFNGLGENPROGRAMPIPELINESEXTPROC)(GLsizei n, GLuint * pipelines);
2090typedef void (GLAD_API_PTR *PFNGLGENQUERIESEXTPROC)(GLsizei n, GLuint * ids);
2091typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
2092typedef void (GLAD_API_PTR *PFNGLGENSEMAPHORESEXTPROC)(GLsizei n, GLuint * semaphores);
2093typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures);
2094typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSOESPROC)(GLsizei n, GLuint * arrays);
2095typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target);
2096typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
2097typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
2098typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
2099typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name);
2100typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data);
2101typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2102typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVOESPROC)(GLenum target, GLenum pname, void ** params);
2103typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog);
2104typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
2105typedef void (GLAD_API_PTR *PFNGLGETFLOATI_VOESPROC)(GLenum target, GLuint index, GLfloat * data);
2106typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data);
2107typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXEXTPROC)(GLuint program, const GLchar * name);
2108typedef void (GLAD_API_PTR *PFNGLGETFRAGMENTSHADINGRATESEXTPROC)(GLsizei samples, GLsizei maxCount, GLsizei * count, GLenum * shadingRates);
2109typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
2110typedef GLsizei (GLAD_API_PTR *PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target);
2111typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSEXTPROC)(void);
2112typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void);
2113typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VEXTPROC)(GLenum pname, GLint64 * data);
2114typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VEXTPROC)(GLenum target, GLuint index, GLint * data);
2115typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data);
2116typedef void (GLAD_API_PTR *PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC)(GLuint memoryObject, GLenum pname, GLint * params);
2117typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELEXTPROC)(GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label);
2118typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELKHRPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label);
2119typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELKHRPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label);
2120typedef void (GLAD_API_PTR *PFNGLGETPOINTERVKHRPROC)(GLenum pname, void ** params);
2121typedef void (GLAD_API_PTR *PFNGLGETPROGRAMBINARYOESPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary);
2122typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
2123typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC)(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
2124typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEIVEXTPROC)(GLuint pipeline, GLenum pname, GLint * params);
2125typedef GLint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program, GLenum programInterface, const GLchar * name);
2126typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params);
2127typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VEXTPROC)(GLuint id, GLenum pname, GLint64 * params);
2128typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVEXTPROC)(GLuint id, GLenum pname, GLint * params);
2129typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VEXTPROC)(GLuint id, GLenum pname, GLuint64 * params);
2130typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVEXTPROC)(GLuint id, GLenum pname, GLuint * params);
2131typedef void (GLAD_API_PTR *PFNGLGETQUERYIVEXTPROC)(GLenum target, GLenum pname, GLint * params);
2132typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2133typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, GLenum pname, GLint * params);
2134typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, GLenum pname, GLint * params);
2135typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVEXTPROC)(GLuint sampler, GLenum pname, GLuint * params);
2136typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVOESPROC)(GLuint sampler, GLenum pname, GLuint * params);
2137typedef void (GLAD_API_PTR *PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC)(GLuint semaphore, GLenum pname, GLuint64 * params);
2138typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
2139typedef void (GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision);
2140typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
2141typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params);
2142typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name);
2143typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVEXTPROC)(GLenum target, GLenum pname, GLint * params);
2144typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVOESPROC)(GLenum target, GLenum pname, GLint * params);
2145typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVEXTPROC)(GLenum target, GLenum pname, GLuint * params);
2146typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVOESPROC)(GLenum target, GLenum pname, GLuint * params);
2147typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params);
2148typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2149typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name);
2150typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params);
2151typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params);
2152typedef void (GLAD_API_PTR *PFNGLGETUNSIGNEDBYTEI_VEXTPROC)(GLenum target, GLuint index, GLubyte * data);
2153typedef void (GLAD_API_PTR *PFNGLGETUNSIGNEDBYTEVEXTPROC)(GLenum pname, GLubyte * data);
2154typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer);
2155typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params);
2156typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params);
2157typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVEXTPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
2158typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
2159typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVEXTPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params);
2160typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params);
2161typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint * params);
2162typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode);
2163typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYFDEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, GLint fd);
2164typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, void * handle);
2165typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYWIN32NAMEEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, const void * name);
2166typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREFDEXTPROC)(GLuint semaphore, GLenum handleType, GLint fd);
2167typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC)(GLuint semaphore, GLenum handleType, void * handle);
2168typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC)(GLuint semaphore, GLenum handleType, const void * name);
2169typedef void (GLAD_API_PTR *PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length, const GLchar * marker);
2170typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer);
2171typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap);
2172typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIEXTPROC)(GLenum target, GLuint index);
2173typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIOESPROC)(GLenum target, GLuint index);
2174typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
2175typedef GLboolean (GLAD_API_PTR *PFNGLISMEMORYOBJECTEXTPROC)(GLuint memoryObject);
2176typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program);
2177typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
2178typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYEXTPROC)(GLuint id);
2179typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
2180typedef GLboolean (GLAD_API_PTR *PFNGLISSEMAPHOREEXTPROC)(GLuint semaphore);
2181typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader);
2182typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture);
2183typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYOESPROC)(GLuint array);
2184typedef void (GLAD_API_PTR *PFNGLLABELOBJECTEXTPROC)(GLenum type, GLuint object, GLsizei length, const GLchar * label);
2185typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width);
2186typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program);
2187typedef void * (GLAD_API_PTR *PFNGLMAPBUFFEROESPROC)(GLenum target, GLenum access);
2188typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
2189typedef void (GLAD_API_PTR *PFNGLMAXSHADERCOMPILERTHREADSKHRPROC)(GLuint count);
2190typedef void (GLAD_API_PTR *PFNGLMEMORYOBJECTPARAMETERIVEXTPROC)(GLuint memoryObject, GLenum pname, const GLint * params);
2191typedef void (GLAD_API_PTR *PFNGLMINSAMPLESHADINGOESPROC)(GLfloat value);
2192typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSEXTPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount);
2193typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC)(GLenum mode, const void * indirect, GLsizei drawcount, GLsizei stride);
2194typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex);
2195typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSEXTPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount);
2196typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC)(GLenum mode, GLenum type, const void * indirect, GLsizei drawcount, GLsizei stride);
2197typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags);
2198typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC)(GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset);
2199typedef void (GLAD_API_PTR *PFNGLOBJECTLABELKHRPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label);
2200typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELKHRPROC)(const void * ptr, GLsizei length, const GLchar * label);
2201typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIEXTPROC)(GLenum pname, GLint value);
2202typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIOESPROC)(GLenum pname, GLint value);
2203typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
2204typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
2205typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETCLAMPEXTPROC)(GLfloat factor, GLfloat units, GLfloat clamp);
2206typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPKHRPROC)(void);
2207typedef void (GLAD_API_PTR *PFNGLPOPGROUPMARKEREXTPROC)(void);
2208typedef void (GLAD_API_PTR *PFNGLPRIMITIVEBOUNDINGBOXEXTPROC)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
2209typedef void (GLAD_API_PTR *PFNGLPRIMITIVEBOUNDINGBOXOESPROC)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
2210typedef void (GLAD_API_PTR *PFNGLPROGRAMBINARYOESPROC)(GLuint program, GLenum binaryFormat, const void * binary, GLint length);
2211typedef void (GLAD_API_PTR *PFNGLPROGRAMPARAMETERIEXTPROC)(GLuint program, GLenum pname, GLint value);
2212typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FEXTPROC)(GLuint program, GLint location, GLfloat v0);
2213typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
2214typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IEXTPROC)(GLuint program, GLint location, GLint v0);
2215typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
2216typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIEXTPROC)(GLuint program, GLint location, GLuint v0);
2217typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
2218typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1);
2219typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
2220typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1);
2221typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
2222typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1);
2223typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
2224typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
2225typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
2226typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
2227typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
2228typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
2229typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
2230typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
2231typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
2232typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
2233typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
2234typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
2235typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
2236typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2237typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2238typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2239typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2240typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2241typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2242typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2243typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2244typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2245typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPKHRPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message);
2246typedef void (GLAD_API_PTR *PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length, const GLchar * marker);
2247typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTEREXTPROC)(GLuint id, GLenum target);
2248typedef void (GLAD_API_PTR *PFNGLRASTERSAMPLESEXTPROC)(GLuint samples, GLboolean fixedsamplelocations);
2249typedef void (GLAD_API_PTR *PFNGLREADBUFFERINDEXEDEXTPROC)(GLenum src, GLint index);
2250typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
2251typedef void (GLAD_API_PTR *PFNGLREADNPIXELSEXTPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
2252typedef void (GLAD_API_PTR *PFNGLREADNPIXELSKHRPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
2253typedef GLboolean (GLAD_API_PTR *PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC)(GLuint memory, GLuint64 key);
2254typedef void (GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void);
2255typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
2256typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
2257typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
2258typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, GLenum pname, const GLint * param);
2259typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, GLenum pname, const GLint * param);
2260typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVEXTPROC)(GLuint sampler, GLenum pname, const GLuint * param);
2261typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVOESPROC)(GLuint sampler, GLenum pname, const GLuint * param);
2262typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
2263typedef void (GLAD_API_PTR *PFNGLSCISSORARRAYVOESPROC)(GLuint first, GLsizei count, const GLint * v);
2264typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDOESPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
2265typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDVOESPROC)(GLuint index, const GLint * v);
2266typedef void (GLAD_API_PTR *PFNGLSEMAPHOREPARAMETERUI64VEXTPROC)(GLuint semaphore, GLenum pname, const GLuint64 * params);
2267typedef void (GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length);
2268typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
2269typedef void (GLAD_API_PTR *PFNGLSHADINGRATECOMBINEROPSEXTPROC)(GLenum combinerOp0, GLenum combinerOp1);
2270typedef void (GLAD_API_PTR *PFNGLSHADINGRATEEXTPROC)(GLenum rate);
2271typedef void (GLAD_API_PTR *PFNGLSIGNALSEMAPHOREEXTPROC)(GLuint semaphore, GLuint numBufferBarriers, const GLuint * buffers, GLuint numTextureBarriers, const GLuint * textures, const GLenum * dstLayouts);
2272typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
2273typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
2274typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask);
2275typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
2276typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
2277typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
2278typedef void (GLAD_API_PTR *PFNGLTEXBUFFEREXTPROC)(GLenum target, GLenum internalformat, GLuint buffer);
2279typedef void (GLAD_API_PTR *PFNGLTEXBUFFEROESPROC)(GLenum target, GLenum internalformat, GLuint buffer);
2280typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEEXTPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
2281typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEOESPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
2282typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
2283typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
2284typedef void (GLAD_API_PTR *PFNGLTEXPAGECOMMITMENTEXTPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
2285typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVEXTPROC)(GLenum target, GLenum pname, const GLint * params);
2286typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVOESPROC)(GLenum target, GLenum pname, const GLint * params);
2287typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVEXTPROC)(GLenum target, GLenum pname, const GLuint * params);
2288typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVOESPROC)(GLenum target, GLenum pname, const GLuint * params);
2289typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
2290typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
2291typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
2292typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params);
2293typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE1DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
2294typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
2295typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
2296typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
2297typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEATTRIBS2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint * attrib_list);
2298typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEATTRIBS3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint * attrib_list);
2299typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset);
2300typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
2301typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset);
2302typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
2303typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
2304typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);
2305typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE1DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
2306typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE2DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
2307typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE3DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
2308typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM2DEXTPROC)(GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset);
2309typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC)(GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
2310typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM3DEXTPROC)(GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset);
2311typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC)(GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
2312typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWEXTPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
2313typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWOESPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
2314typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
2315typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2316typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
2317typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value);
2318typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
2319typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2320typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
2321typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value);
2322typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
2323typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2324typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
2325typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value);
2326typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
2327typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2328typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
2329typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value);
2330typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2331typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2332typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2333typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFEROESPROC)(GLenum target);
2334typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program);
2335typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMSTAGESEXTPROC)(GLuint pipeline, GLbitfield stages, GLuint program);
2336typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program);
2337typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
2338typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
2339typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v);
2340typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
2341typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v);
2342typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
2343typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v);
2344typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
2345typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v);
2346typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISOREXTPROC)(GLuint index, GLuint divisor);
2347typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
2348typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
2349typedef void (GLAD_API_PTR *PFNGLVIEWPORTARRAYVOESPROC)(GLuint first, GLsizei count, const GLfloat * v);
2350typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFOESPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
2351typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFVOESPROC)(GLuint index, const GLfloat * v);
2352typedef void (GLAD_API_PTR *PFNGLWAITSEMAPHOREEXTPROC)(GLuint semaphore, GLuint numBufferBarriers, const GLuint * buffers, GLuint numTextureBarriers, const GLuint * textures, const GLenum * srcLayouts);
2353typedef void (GLAD_API_PTR *PFNGLWINDOWRECTANGLESEXTPROC)(GLenum mode, GLsizei count, const GLint * box);
2354
2355GLAD_API_CALL PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC glad_glAcquireKeyedMutexWin32EXT;
2356#define glAcquireKeyedMutexWin32EXT glad_glAcquireKeyedMutexWin32EXT
2357GLAD_API_CALL PFNGLACTIVESHADERPROGRAMEXTPROC glad_glActiveShaderProgramEXT;
2358#define glActiveShaderProgramEXT glad_glActiveShaderProgramEXT
2359GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
2360#define glActiveTexture glad_glActiveTexture
2361GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
2362#define glAttachShader glad_glAttachShader
2363GLAD_API_CALL PFNGLBEGINQUERYEXTPROC glad_glBeginQueryEXT;
2364#define glBeginQueryEXT glad_glBeginQueryEXT
2365GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
2366#define glBindAttribLocation glad_glBindAttribLocation
2367GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
2368#define glBindBuffer glad_glBindBuffer
2369GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONEXTPROC glad_glBindFragDataLocationEXT;
2370#define glBindFragDataLocationEXT glad_glBindFragDataLocationEXT
2371GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC glad_glBindFragDataLocationIndexedEXT;
2372#define glBindFragDataLocationIndexedEXT glad_glBindFragDataLocationIndexedEXT
2373GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
2374#define glBindFramebuffer glad_glBindFramebuffer
2375GLAD_API_CALL PFNGLBINDPROGRAMPIPELINEEXTPROC glad_glBindProgramPipelineEXT;
2376#define glBindProgramPipelineEXT glad_glBindProgramPipelineEXT
2377GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
2378#define glBindRenderbuffer glad_glBindRenderbuffer
2379GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
2380#define glBindTexture glad_glBindTexture
2381GLAD_API_CALL PFNGLBINDVERTEXARRAYOESPROC glad_glBindVertexArrayOES;
2382#define glBindVertexArrayOES glad_glBindVertexArrayOES
2383GLAD_API_CALL PFNGLBLENDBARRIERKHRPROC glad_glBlendBarrierKHR;
2384#define glBlendBarrierKHR glad_glBlendBarrierKHR
2385GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
2386#define glBlendColor glad_glBlendColor
2387GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
2388#define glBlendEquation glad_glBlendEquation
2389GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
2390#define glBlendEquationSeparate glad_glBlendEquationSeparate
2391GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIEXTPROC glad_glBlendEquationSeparateiEXT;
2392#define glBlendEquationSeparateiEXT glad_glBlendEquationSeparateiEXT
2393GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIOESPROC glad_glBlendEquationSeparateiOES;
2394#define glBlendEquationSeparateiOES glad_glBlendEquationSeparateiOES
2395GLAD_API_CALL PFNGLBLENDEQUATIONIEXTPROC glad_glBlendEquationiEXT;
2396#define glBlendEquationiEXT glad_glBlendEquationiEXT
2397GLAD_API_CALL PFNGLBLENDEQUATIONIOESPROC glad_glBlendEquationiOES;
2398#define glBlendEquationiOES glad_glBlendEquationiOES
2399GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
2400#define glBlendFunc glad_glBlendFunc
2401GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
2402#define glBlendFuncSeparate glad_glBlendFuncSeparate
2403GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIEXTPROC glad_glBlendFuncSeparateiEXT;
2404#define glBlendFuncSeparateiEXT glad_glBlendFuncSeparateiEXT
2405GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIOESPROC glad_glBlendFuncSeparateiOES;
2406#define glBlendFuncSeparateiOES glad_glBlendFuncSeparateiOES
2407GLAD_API_CALL PFNGLBLENDFUNCIEXTPROC glad_glBlendFunciEXT;
2408#define glBlendFunciEXT glad_glBlendFunciEXT
2409GLAD_API_CALL PFNGLBLENDFUNCIOESPROC glad_glBlendFunciOES;
2410#define glBlendFunciOES glad_glBlendFunciOES
2411GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
2412#define glBufferData glad_glBufferData
2413GLAD_API_CALL PFNGLBUFFERSTORAGEEXTPROC glad_glBufferStorageEXT;
2414#define glBufferStorageEXT glad_glBufferStorageEXT
2415GLAD_API_CALL PFNGLBUFFERSTORAGEEXTERNALEXTPROC glad_glBufferStorageExternalEXT;
2416#define glBufferStorageExternalEXT glad_glBufferStorageExternalEXT
2417GLAD_API_CALL PFNGLBUFFERSTORAGEMEMEXTPROC glad_glBufferStorageMemEXT;
2418#define glBufferStorageMemEXT glad_glBufferStorageMemEXT
2419GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
2420#define glBufferSubData glad_glBufferSubData
2421GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
2422#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
2423GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
2424#define glClear glad_glClear
2425GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
2426#define glClearColor glad_glClearColor
2427GLAD_API_CALL PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
2428#define glClearDepthf glad_glClearDepthf
2429GLAD_API_CALL PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC glad_glClearPixelLocalStorageuiEXT;
2430#define glClearPixelLocalStorageuiEXT glad_glClearPixelLocalStorageuiEXT
2431GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
2432#define glClearStencil glad_glClearStencil
2433GLAD_API_CALL PFNGLCLEARTEXIMAGEEXTPROC glad_glClearTexImageEXT;
2434#define glClearTexImageEXT glad_glClearTexImageEXT
2435GLAD_API_CALL PFNGLCLEARTEXSUBIMAGEEXTPROC glad_glClearTexSubImageEXT;
2436#define glClearTexSubImageEXT glad_glClearTexSubImageEXT
2437GLAD_API_CALL PFNGLCLIPCONTROLEXTPROC glad_glClipControlEXT;
2438#define glClipControlEXT glad_glClipControlEXT
2439GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
2440#define glColorMask glad_glColorMask
2441GLAD_API_CALL PFNGLCOLORMASKIEXTPROC glad_glColorMaskiEXT;
2442#define glColorMaskiEXT glad_glColorMaskiEXT
2443GLAD_API_CALL PFNGLCOLORMASKIOESPROC glad_glColorMaskiOES;
2444#define glColorMaskiOES glad_glColorMaskiOES
2445GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
2446#define glCompileShader glad_glCompileShader
2447GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
2448#define glCompressedTexImage2D glad_glCompressedTexImage2D
2449GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DOESPROC glad_glCompressedTexImage3DOES;
2450#define glCompressedTexImage3DOES glad_glCompressedTexImage3DOES
2451GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
2452#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
2453GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glad_glCompressedTexSubImage3DOES;
2454#define glCompressedTexSubImage3DOES glad_glCompressedTexSubImage3DOES
2455GLAD_API_CALL PFNGLCOPYIMAGESUBDATAEXTPROC glad_glCopyImageSubDataEXT;
2456#define glCopyImageSubDataEXT glad_glCopyImageSubDataEXT
2457GLAD_API_CALL PFNGLCOPYIMAGESUBDATAOESPROC glad_glCopyImageSubDataOES;
2458#define glCopyImageSubDataOES glad_glCopyImageSubDataOES
2459GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
2460#define glCopyTexImage2D glad_glCopyTexImage2D
2461GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
2462#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
2463GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DOESPROC glad_glCopyTexSubImage3DOES;
2464#define glCopyTexSubImage3DOES glad_glCopyTexSubImage3DOES
2465GLAD_API_CALL PFNGLCREATEMEMORYOBJECTSEXTPROC glad_glCreateMemoryObjectsEXT;
2466#define glCreateMemoryObjectsEXT glad_glCreateMemoryObjectsEXT
2467GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
2468#define glCreateProgram glad_glCreateProgram
2469GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
2470#define glCreateShader glad_glCreateShader
2471GLAD_API_CALL PFNGLCREATESHADERPROGRAMVEXTPROC glad_glCreateShaderProgramvEXT;
2472#define glCreateShaderProgramvEXT glad_glCreateShaderProgramvEXT
2473GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
2474#define glCullFace glad_glCullFace
2475GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKKHRPROC glad_glDebugMessageCallbackKHR;
2476#define glDebugMessageCallbackKHR glad_glDebugMessageCallbackKHR
2477GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLKHRPROC glad_glDebugMessageControlKHR;
2478#define glDebugMessageControlKHR glad_glDebugMessageControlKHR
2479GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTKHRPROC glad_glDebugMessageInsertKHR;
2480#define glDebugMessageInsertKHR glad_glDebugMessageInsertKHR
2481GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
2482#define glDeleteBuffers glad_glDeleteBuffers
2483GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
2484#define glDeleteFramebuffers glad_glDeleteFramebuffers
2485GLAD_API_CALL PFNGLDELETEMEMORYOBJECTSEXTPROC glad_glDeleteMemoryObjectsEXT;
2486#define glDeleteMemoryObjectsEXT glad_glDeleteMemoryObjectsEXT
2487GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
2488#define glDeleteProgram glad_glDeleteProgram
2489GLAD_API_CALL PFNGLDELETEPROGRAMPIPELINESEXTPROC glad_glDeleteProgramPipelinesEXT;
2490#define glDeleteProgramPipelinesEXT glad_glDeleteProgramPipelinesEXT
2491GLAD_API_CALL PFNGLDELETEQUERIESEXTPROC glad_glDeleteQueriesEXT;
2492#define glDeleteQueriesEXT glad_glDeleteQueriesEXT
2493GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
2494#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
2495GLAD_API_CALL PFNGLDELETESEMAPHORESEXTPROC glad_glDeleteSemaphoresEXT;
2496#define glDeleteSemaphoresEXT glad_glDeleteSemaphoresEXT
2497GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
2498#define glDeleteShader glad_glDeleteShader
2499GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
2500#define glDeleteTextures glad_glDeleteTextures
2501GLAD_API_CALL PFNGLDELETEVERTEXARRAYSOESPROC glad_glDeleteVertexArraysOES;
2502#define glDeleteVertexArraysOES glad_glDeleteVertexArraysOES
2503GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
2504#define glDepthFunc glad_glDepthFunc
2505GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
2506#define glDepthMask glad_glDepthMask
2507GLAD_API_CALL PFNGLDEPTHRANGEARRAYFVOESPROC glad_glDepthRangeArrayfvOES;
2508#define glDepthRangeArrayfvOES glad_glDepthRangeArrayfvOES
2509GLAD_API_CALL PFNGLDEPTHRANGEINDEXEDFOESPROC glad_glDepthRangeIndexedfOES;
2510#define glDepthRangeIndexedfOES glad_glDepthRangeIndexedfOES
2511GLAD_API_CALL PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
2512#define glDepthRangef glad_glDepthRangef
2513GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
2514#define glDetachShader glad_glDetachShader
2515GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
2516#define glDisable glad_glDisable
2517GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
2518#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
2519GLAD_API_CALL PFNGLDISABLEIEXTPROC glad_glDisableiEXT;
2520#define glDisableiEXT glad_glDisableiEXT
2521GLAD_API_CALL PFNGLDISABLEIOESPROC glad_glDisableiOES;
2522#define glDisableiOES glad_glDisableiOES
2523GLAD_API_CALL PFNGLDISCARDFRAMEBUFFEREXTPROC glad_glDiscardFramebufferEXT;
2524#define glDiscardFramebufferEXT glad_glDiscardFramebufferEXT
2525GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
2526#define glDrawArrays glad_glDrawArrays
2527GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawArraysInstancedBaseInstanceEXT;
2528#define glDrawArraysInstancedBaseInstanceEXT glad_glDrawArraysInstancedBaseInstanceEXT
2529GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT;
2530#define glDrawArraysInstancedEXT glad_glDrawArraysInstancedEXT
2531GLAD_API_CALL PFNGLDRAWBUFFERSEXTPROC glad_glDrawBuffersEXT;
2532#define glDrawBuffersEXT glad_glDrawBuffersEXT
2533GLAD_API_CALL PFNGLDRAWBUFFERSINDEXEDEXTPROC glad_glDrawBuffersIndexedEXT;
2534#define glDrawBuffersIndexedEXT glad_glDrawBuffersIndexedEXT
2535GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
2536#define glDrawElements glad_glDrawElements
2537GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXEXTPROC glad_glDrawElementsBaseVertexEXT;
2538#define glDrawElementsBaseVertexEXT glad_glDrawElementsBaseVertexEXT
2539GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXOESPROC glad_glDrawElementsBaseVertexOES;
2540#define glDrawElementsBaseVertexOES glad_glDrawElementsBaseVertexOES
2541GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseInstanceEXT;
2542#define glDrawElementsInstancedBaseInstanceEXT glad_glDrawElementsInstancedBaseInstanceEXT
2543GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT;
2544#define glDrawElementsInstancedBaseVertexBaseInstanceEXT glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT
2545GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC glad_glDrawElementsInstancedBaseVertexEXT;
2546#define glDrawElementsInstancedBaseVertexEXT glad_glDrawElementsInstancedBaseVertexEXT
2547GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC glad_glDrawElementsInstancedBaseVertexOES;
2548#define glDrawElementsInstancedBaseVertexOES glad_glDrawElementsInstancedBaseVertexOES
2549GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT;
2550#define glDrawElementsInstancedEXT glad_glDrawElementsInstancedEXT
2551GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC glad_glDrawRangeElementsBaseVertexEXT;
2552#define glDrawRangeElementsBaseVertexEXT glad_glDrawRangeElementsBaseVertexEXT
2553GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC glad_glDrawRangeElementsBaseVertexOES;
2554#define glDrawRangeElementsBaseVertexOES glad_glDrawRangeElementsBaseVertexOES
2555GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKEXTPROC glad_glDrawTransformFeedbackEXT;
2556#define glDrawTransformFeedbackEXT glad_glDrawTransformFeedbackEXT
2557GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC glad_glDrawTransformFeedbackInstancedEXT;
2558#define glDrawTransformFeedbackInstancedEXT glad_glDrawTransformFeedbackInstancedEXT
2559GLAD_API_CALL PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glad_glEGLImageTargetRenderbufferStorageOES;
2560#define glEGLImageTargetRenderbufferStorageOES glad_glEGLImageTargetRenderbufferStorageOES
2561GLAD_API_CALL PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC glad_glEGLImageTargetTexStorageEXT;
2562#define glEGLImageTargetTexStorageEXT glad_glEGLImageTargetTexStorageEXT
2563GLAD_API_CALL PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glad_glEGLImageTargetTexture2DOES;
2564#define glEGLImageTargetTexture2DOES glad_glEGLImageTargetTexture2DOES
2565GLAD_API_CALL PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC glad_glEGLImageTargetTextureStorageEXT;
2566#define glEGLImageTargetTextureStorageEXT glad_glEGLImageTargetTextureStorageEXT
2567GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
2568#define glEnable glad_glEnable
2569GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
2570#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
2571GLAD_API_CALL PFNGLENABLEIEXTPROC glad_glEnableiEXT;
2572#define glEnableiEXT glad_glEnableiEXT
2573GLAD_API_CALL PFNGLENABLEIOESPROC glad_glEnableiOES;
2574#define glEnableiOES glad_glEnableiOES
2575GLAD_API_CALL PFNGLENDQUERYEXTPROC glad_glEndQueryEXT;
2576#define glEndQueryEXT glad_glEndQueryEXT
2577GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
2578#define glFinish glad_glFinish
2579GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
2580#define glFlush glad_glFlush
2581GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC glad_glFlushMappedBufferRangeEXT;
2582#define glFlushMappedBufferRangeEXT glad_glFlushMappedBufferRangeEXT
2583GLAD_API_CALL PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC glad_glFramebufferFetchBarrierEXT;
2584#define glFramebufferFetchBarrierEXT glad_glFramebufferFetchBarrierEXT
2585GLAD_API_CALL PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glFramebufferPixelLocalStorageSizeEXT;
2586#define glFramebufferPixelLocalStorageSizeEXT glad_glFramebufferPixelLocalStorageSizeEXT
2587GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
2588#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
2589GLAD_API_CALL PFNGLFRAMEBUFFERSHADINGRATEEXTPROC glad_glFramebufferShadingRateEXT;
2590#define glFramebufferShadingRateEXT glad_glFramebufferShadingRateEXT
2591GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
2592#define glFramebufferTexture2D glad_glFramebufferTexture2D
2593GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glad_glFramebufferTexture2DMultisampleEXT;
2594#define glFramebufferTexture2DMultisampleEXT glad_glFramebufferTexture2DMultisampleEXT
2595GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DOESPROC glad_glFramebufferTexture3DOES;
2596#define glFramebufferTexture3DOES glad_glFramebufferTexture3DOES
2597GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREEXTPROC glad_glFramebufferTextureEXT;
2598#define glFramebufferTextureEXT glad_glFramebufferTextureEXT
2599GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREOESPROC glad_glFramebufferTextureOES;
2600#define glFramebufferTextureOES glad_glFramebufferTextureOES
2601GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
2602#define glFrontFace glad_glFrontFace
2603GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
2604#define glGenBuffers glad_glGenBuffers
2605GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
2606#define glGenFramebuffers glad_glGenFramebuffers
2607GLAD_API_CALL PFNGLGENPROGRAMPIPELINESEXTPROC glad_glGenProgramPipelinesEXT;
2608#define glGenProgramPipelinesEXT glad_glGenProgramPipelinesEXT
2609GLAD_API_CALL PFNGLGENQUERIESEXTPROC glad_glGenQueriesEXT;
2610#define glGenQueriesEXT glad_glGenQueriesEXT
2611GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
2612#define glGenRenderbuffers glad_glGenRenderbuffers
2613GLAD_API_CALL PFNGLGENSEMAPHORESEXTPROC glad_glGenSemaphoresEXT;
2614#define glGenSemaphoresEXT glad_glGenSemaphoresEXT
2615GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
2616#define glGenTextures glad_glGenTextures
2617GLAD_API_CALL PFNGLGENVERTEXARRAYSOESPROC glad_glGenVertexArraysOES;
2618#define glGenVertexArraysOES glad_glGenVertexArraysOES
2619GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
2620#define glGenerateMipmap glad_glGenerateMipmap
2621GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
2622#define glGetActiveAttrib glad_glGetActiveAttrib
2623GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
2624#define glGetActiveUniform glad_glGetActiveUniform
2625GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
2626#define glGetAttachedShaders glad_glGetAttachedShaders
2627GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
2628#define glGetAttribLocation glad_glGetAttribLocation
2629GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
2630#define glGetBooleanv glad_glGetBooleanv
2631GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
2632#define glGetBufferParameteriv glad_glGetBufferParameteriv
2633GLAD_API_CALL PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES;
2634#define glGetBufferPointervOES glad_glGetBufferPointervOES
2635GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGKHRPROC glad_glGetDebugMessageLogKHR;
2636#define glGetDebugMessageLogKHR glad_glGetDebugMessageLogKHR
2637GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
2638#define glGetError glad_glGetError
2639GLAD_API_CALL PFNGLGETFLOATI_VOESPROC glad_glGetFloati_vOES;
2640#define glGetFloati_vOES glad_glGetFloati_vOES
2641GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
2642#define glGetFloatv glad_glGetFloatv
2643GLAD_API_CALL PFNGLGETFRAGDATAINDEXEXTPROC glad_glGetFragDataIndexEXT;
2644#define glGetFragDataIndexEXT glad_glGetFragDataIndexEXT
2645GLAD_API_CALL PFNGLGETFRAGMENTSHADINGRATESEXTPROC glad_glGetFragmentShadingRatesEXT;
2646#define glGetFragmentShadingRatesEXT glad_glGetFragmentShadingRatesEXT
2647GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
2648#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
2649GLAD_API_CALL PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glGetFramebufferPixelLocalStorageSizeEXT;
2650#define glGetFramebufferPixelLocalStorageSizeEXT glad_glGetFramebufferPixelLocalStorageSizeEXT
2651GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSEXTPROC glad_glGetGraphicsResetStatusEXT;
2652#define glGetGraphicsResetStatusEXT glad_glGetGraphicsResetStatusEXT
2653GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSKHRPROC glad_glGetGraphicsResetStatusKHR;
2654#define glGetGraphicsResetStatusKHR glad_glGetGraphicsResetStatusKHR
2655GLAD_API_CALL PFNGLGETINTEGER64VEXTPROC glad_glGetInteger64vEXT;
2656#define glGetInteger64vEXT glad_glGetInteger64vEXT
2657GLAD_API_CALL PFNGLGETINTEGERI_VEXTPROC glad_glGetIntegeri_vEXT;
2658#define glGetIntegeri_vEXT glad_glGetIntegeri_vEXT
2659GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
2660#define glGetIntegerv glad_glGetIntegerv
2661GLAD_API_CALL PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC glad_glGetMemoryObjectParameterivEXT;
2662#define glGetMemoryObjectParameterivEXT glad_glGetMemoryObjectParameterivEXT
2663GLAD_API_CALL PFNGLGETOBJECTLABELEXTPROC glad_glGetObjectLabelEXT;
2664#define glGetObjectLabelEXT glad_glGetObjectLabelEXT
2665GLAD_API_CALL PFNGLGETOBJECTLABELKHRPROC glad_glGetObjectLabelKHR;
2666#define glGetObjectLabelKHR glad_glGetObjectLabelKHR
2667GLAD_API_CALL PFNGLGETOBJECTPTRLABELKHRPROC glad_glGetObjectPtrLabelKHR;
2668#define glGetObjectPtrLabelKHR glad_glGetObjectPtrLabelKHR
2669GLAD_API_CALL PFNGLGETPOINTERVKHRPROC glad_glGetPointervKHR;
2670#define glGetPointervKHR glad_glGetPointervKHR
2671GLAD_API_CALL PFNGLGETPROGRAMBINARYOESPROC glad_glGetProgramBinaryOES;
2672#define glGetProgramBinaryOES glad_glGetProgramBinaryOES
2673GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
2674#define glGetProgramInfoLog glad_glGetProgramInfoLog
2675GLAD_API_CALL PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC glad_glGetProgramPipelineInfoLogEXT;
2676#define glGetProgramPipelineInfoLogEXT glad_glGetProgramPipelineInfoLogEXT
2677GLAD_API_CALL PFNGLGETPROGRAMPIPELINEIVEXTPROC glad_glGetProgramPipelineivEXT;
2678#define glGetProgramPipelineivEXT glad_glGetProgramPipelineivEXT
2679GLAD_API_CALL PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC glad_glGetProgramResourceLocationIndexEXT;
2680#define glGetProgramResourceLocationIndexEXT glad_glGetProgramResourceLocationIndexEXT
2681GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
2682#define glGetProgramiv glad_glGetProgramiv
2683GLAD_API_CALL PFNGLGETQUERYOBJECTI64VEXTPROC glad_glGetQueryObjecti64vEXT;
2684#define glGetQueryObjecti64vEXT glad_glGetQueryObjecti64vEXT
2685GLAD_API_CALL PFNGLGETQUERYOBJECTIVEXTPROC glad_glGetQueryObjectivEXT;
2686#define glGetQueryObjectivEXT glad_glGetQueryObjectivEXT
2687GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VEXTPROC glad_glGetQueryObjectui64vEXT;
2688#define glGetQueryObjectui64vEXT glad_glGetQueryObjectui64vEXT
2689GLAD_API_CALL PFNGLGETQUERYOBJECTUIVEXTPROC glad_glGetQueryObjectuivEXT;
2690#define glGetQueryObjectuivEXT glad_glGetQueryObjectuivEXT
2691GLAD_API_CALL PFNGLGETQUERYIVEXTPROC glad_glGetQueryivEXT;
2692#define glGetQueryivEXT glad_glGetQueryivEXT
2693GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
2694#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
2695GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVEXTPROC glad_glGetSamplerParameterIivEXT;
2696#define glGetSamplerParameterIivEXT glad_glGetSamplerParameterIivEXT
2697GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVOESPROC glad_glGetSamplerParameterIivOES;
2698#define glGetSamplerParameterIivOES glad_glGetSamplerParameterIivOES
2699GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVEXTPROC glad_glGetSamplerParameterIuivEXT;
2700#define glGetSamplerParameterIuivEXT glad_glGetSamplerParameterIuivEXT
2701GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVOESPROC glad_glGetSamplerParameterIuivOES;
2702#define glGetSamplerParameterIuivOES glad_glGetSamplerParameterIuivOES
2703GLAD_API_CALL PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC glad_glGetSemaphoreParameterui64vEXT;
2704#define glGetSemaphoreParameterui64vEXT glad_glGetSemaphoreParameterui64vEXT
2705GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
2706#define glGetShaderInfoLog glad_glGetShaderInfoLog
2707GLAD_API_CALL PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
2708#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
2709GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
2710#define glGetShaderSource glad_glGetShaderSource
2711GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
2712#define glGetShaderiv glad_glGetShaderiv
2713GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
2714#define glGetString glad_glGetString
2715GLAD_API_CALL PFNGLGETTEXPARAMETERIIVEXTPROC glad_glGetTexParameterIivEXT;
2716#define glGetTexParameterIivEXT glad_glGetTexParameterIivEXT
2717GLAD_API_CALL PFNGLGETTEXPARAMETERIIVOESPROC glad_glGetTexParameterIivOES;
2718#define glGetTexParameterIivOES glad_glGetTexParameterIivOES
2719GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVEXTPROC glad_glGetTexParameterIuivEXT;
2720#define glGetTexParameterIuivEXT glad_glGetTexParameterIuivEXT
2721GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVOESPROC glad_glGetTexParameterIuivOES;
2722#define glGetTexParameterIuivOES glad_glGetTexParameterIuivOES
2723GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
2724#define glGetTexParameterfv glad_glGetTexParameterfv
2725GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
2726#define glGetTexParameteriv glad_glGetTexParameteriv
2727GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
2728#define glGetUniformLocation glad_glGetUniformLocation
2729GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
2730#define glGetUniformfv glad_glGetUniformfv
2731GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
2732#define glGetUniformiv glad_glGetUniformiv
2733GLAD_API_CALL PFNGLGETUNSIGNEDBYTEI_VEXTPROC glad_glGetUnsignedBytei_vEXT;
2734#define glGetUnsignedBytei_vEXT glad_glGetUnsignedBytei_vEXT
2735GLAD_API_CALL PFNGLGETUNSIGNEDBYTEVEXTPROC glad_glGetUnsignedBytevEXT;
2736#define glGetUnsignedBytevEXT glad_glGetUnsignedBytevEXT
2737GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
2738#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
2739GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
2740#define glGetVertexAttribfv glad_glGetVertexAttribfv
2741GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
2742#define glGetVertexAttribiv glad_glGetVertexAttribiv
2743GLAD_API_CALL PFNGLGETNUNIFORMFVEXTPROC glad_glGetnUniformfvEXT;
2744#define glGetnUniformfvEXT glad_glGetnUniformfvEXT
2745GLAD_API_CALL PFNGLGETNUNIFORMFVKHRPROC glad_glGetnUniformfvKHR;
2746#define glGetnUniformfvKHR glad_glGetnUniformfvKHR
2747GLAD_API_CALL PFNGLGETNUNIFORMIVEXTPROC glad_glGetnUniformivEXT;
2748#define glGetnUniformivEXT glad_glGetnUniformivEXT
2749GLAD_API_CALL PFNGLGETNUNIFORMIVKHRPROC glad_glGetnUniformivKHR;
2750#define glGetnUniformivKHR glad_glGetnUniformivKHR
2751GLAD_API_CALL PFNGLGETNUNIFORMUIVKHRPROC glad_glGetnUniformuivKHR;
2752#define glGetnUniformuivKHR glad_glGetnUniformuivKHR
2753GLAD_API_CALL PFNGLHINTPROC glad_glHint;
2754#define glHint glad_glHint
2755GLAD_API_CALL PFNGLIMPORTMEMORYFDEXTPROC glad_glImportMemoryFdEXT;
2756#define glImportMemoryFdEXT glad_glImportMemoryFdEXT
2757GLAD_API_CALL PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC glad_glImportMemoryWin32HandleEXT;
2758#define glImportMemoryWin32HandleEXT glad_glImportMemoryWin32HandleEXT
2759GLAD_API_CALL PFNGLIMPORTMEMORYWIN32NAMEEXTPROC glad_glImportMemoryWin32NameEXT;
2760#define glImportMemoryWin32NameEXT glad_glImportMemoryWin32NameEXT
2761GLAD_API_CALL PFNGLIMPORTSEMAPHOREFDEXTPROC glad_glImportSemaphoreFdEXT;
2762#define glImportSemaphoreFdEXT glad_glImportSemaphoreFdEXT
2763GLAD_API_CALL PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC glad_glImportSemaphoreWin32HandleEXT;
2764#define glImportSemaphoreWin32HandleEXT glad_glImportSemaphoreWin32HandleEXT
2765GLAD_API_CALL PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC glad_glImportSemaphoreWin32NameEXT;
2766#define glImportSemaphoreWin32NameEXT glad_glImportSemaphoreWin32NameEXT
2767GLAD_API_CALL PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
2768#define glInsertEventMarkerEXT glad_glInsertEventMarkerEXT
2769GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
2770#define glIsBuffer glad_glIsBuffer
2771GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
2772#define glIsEnabled glad_glIsEnabled
2773GLAD_API_CALL PFNGLISENABLEDIEXTPROC glad_glIsEnablediEXT;
2774#define glIsEnablediEXT glad_glIsEnablediEXT
2775GLAD_API_CALL PFNGLISENABLEDIOESPROC glad_glIsEnablediOES;
2776#define glIsEnablediOES glad_glIsEnablediOES
2777GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
2778#define glIsFramebuffer glad_glIsFramebuffer
2779GLAD_API_CALL PFNGLISMEMORYOBJECTEXTPROC glad_glIsMemoryObjectEXT;
2780#define glIsMemoryObjectEXT glad_glIsMemoryObjectEXT
2781GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
2782#define glIsProgram glad_glIsProgram
2783GLAD_API_CALL PFNGLISPROGRAMPIPELINEEXTPROC glad_glIsProgramPipelineEXT;
2784#define glIsProgramPipelineEXT glad_glIsProgramPipelineEXT
2785GLAD_API_CALL PFNGLISQUERYEXTPROC glad_glIsQueryEXT;
2786#define glIsQueryEXT glad_glIsQueryEXT
2787GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
2788#define glIsRenderbuffer glad_glIsRenderbuffer
2789GLAD_API_CALL PFNGLISSEMAPHOREEXTPROC glad_glIsSemaphoreEXT;
2790#define glIsSemaphoreEXT glad_glIsSemaphoreEXT
2791GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
2792#define glIsShader glad_glIsShader
2793GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
2794#define glIsTexture glad_glIsTexture
2795GLAD_API_CALL PFNGLISVERTEXARRAYOESPROC glad_glIsVertexArrayOES;
2796#define glIsVertexArrayOES glad_glIsVertexArrayOES
2797GLAD_API_CALL PFNGLLABELOBJECTEXTPROC glad_glLabelObjectEXT;
2798#define glLabelObjectEXT glad_glLabelObjectEXT
2799GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
2800#define glLineWidth glad_glLineWidth
2801GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
2802#define glLinkProgram glad_glLinkProgram
2803GLAD_API_CALL PFNGLMAPBUFFEROESPROC glad_glMapBufferOES;
2804#define glMapBufferOES glad_glMapBufferOES
2805GLAD_API_CALL PFNGLMAPBUFFERRANGEEXTPROC glad_glMapBufferRangeEXT;
2806#define glMapBufferRangeEXT glad_glMapBufferRangeEXT
2807GLAD_API_CALL PFNGLMAXSHADERCOMPILERTHREADSKHRPROC glad_glMaxShaderCompilerThreadsKHR;
2808#define glMaxShaderCompilerThreadsKHR glad_glMaxShaderCompilerThreadsKHR
2809GLAD_API_CALL PFNGLMEMORYOBJECTPARAMETERIVEXTPROC glad_glMemoryObjectParameterivEXT;
2810#define glMemoryObjectParameterivEXT glad_glMemoryObjectParameterivEXT
2811GLAD_API_CALL PFNGLMINSAMPLESHADINGOESPROC glad_glMinSampleShadingOES;
2812#define glMinSampleShadingOES glad_glMinSampleShadingOES
2813GLAD_API_CALL PFNGLMULTIDRAWARRAYSEXTPROC glad_glMultiDrawArraysEXT;
2814#define glMultiDrawArraysEXT glad_glMultiDrawArraysEXT
2815GLAD_API_CALL PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC glad_glMultiDrawArraysIndirectEXT;
2816#define glMultiDrawArraysIndirectEXT glad_glMultiDrawArraysIndirectEXT
2817GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC glad_glMultiDrawElementsBaseVertexEXT;
2818#define glMultiDrawElementsBaseVertexEXT glad_glMultiDrawElementsBaseVertexEXT
2819GLAD_API_CALL PFNGLMULTIDRAWELEMENTSEXTPROC glad_glMultiDrawElementsEXT;
2820#define glMultiDrawElementsEXT glad_glMultiDrawElementsEXT
2821GLAD_API_CALL PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC glad_glMultiDrawElementsIndirectEXT;
2822#define glMultiDrawElementsIndirectEXT glad_glMultiDrawElementsIndirectEXT
2823GLAD_API_CALL PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC glad_glNamedBufferStorageExternalEXT;
2824#define glNamedBufferStorageExternalEXT glad_glNamedBufferStorageExternalEXT
2825GLAD_API_CALL PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC glad_glNamedBufferStorageMemEXT;
2826#define glNamedBufferStorageMemEXT glad_glNamedBufferStorageMemEXT
2827GLAD_API_CALL PFNGLOBJECTLABELKHRPROC glad_glObjectLabelKHR;
2828#define glObjectLabelKHR glad_glObjectLabelKHR
2829GLAD_API_CALL PFNGLOBJECTPTRLABELKHRPROC glad_glObjectPtrLabelKHR;
2830#define glObjectPtrLabelKHR glad_glObjectPtrLabelKHR
2831GLAD_API_CALL PFNGLPATCHPARAMETERIEXTPROC glad_glPatchParameteriEXT;
2832#define glPatchParameteriEXT glad_glPatchParameteriEXT
2833GLAD_API_CALL PFNGLPATCHPARAMETERIOESPROC glad_glPatchParameteriOES;
2834#define glPatchParameteriOES glad_glPatchParameteriOES
2835GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
2836#define glPixelStorei glad_glPixelStorei
2837GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
2838#define glPolygonOffset glad_glPolygonOffset
2839GLAD_API_CALL PFNGLPOLYGONOFFSETCLAMPEXTPROC glad_glPolygonOffsetClampEXT;
2840#define glPolygonOffsetClampEXT glad_glPolygonOffsetClampEXT
2841GLAD_API_CALL PFNGLPOPDEBUGGROUPKHRPROC glad_glPopDebugGroupKHR;
2842#define glPopDebugGroupKHR glad_glPopDebugGroupKHR
2843GLAD_API_CALL PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
2844#define glPopGroupMarkerEXT glad_glPopGroupMarkerEXT
2845GLAD_API_CALL PFNGLPRIMITIVEBOUNDINGBOXEXTPROC glad_glPrimitiveBoundingBoxEXT;
2846#define glPrimitiveBoundingBoxEXT glad_glPrimitiveBoundingBoxEXT
2847GLAD_API_CALL PFNGLPRIMITIVEBOUNDINGBOXOESPROC glad_glPrimitiveBoundingBoxOES;
2848#define glPrimitiveBoundingBoxOES glad_glPrimitiveBoundingBoxOES
2849GLAD_API_CALL PFNGLPROGRAMBINARYOESPROC glad_glProgramBinaryOES;
2850#define glProgramBinaryOES glad_glProgramBinaryOES
2851GLAD_API_CALL PFNGLPROGRAMPARAMETERIEXTPROC glad_glProgramParameteriEXT;
2852#define glProgramParameteriEXT glad_glProgramParameteriEXT
2853GLAD_API_CALL PFNGLPROGRAMUNIFORM1FEXTPROC glad_glProgramUniform1fEXT;
2854#define glProgramUniform1fEXT glad_glProgramUniform1fEXT
2855GLAD_API_CALL PFNGLPROGRAMUNIFORM1FVEXTPROC glad_glProgramUniform1fvEXT;
2856#define glProgramUniform1fvEXT glad_glProgramUniform1fvEXT
2857GLAD_API_CALL PFNGLPROGRAMUNIFORM1IEXTPROC glad_glProgramUniform1iEXT;
2858#define glProgramUniform1iEXT glad_glProgramUniform1iEXT
2859GLAD_API_CALL PFNGLPROGRAMUNIFORM1IVEXTPROC glad_glProgramUniform1ivEXT;
2860#define glProgramUniform1ivEXT glad_glProgramUniform1ivEXT
2861GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIEXTPROC glad_glProgramUniform1uiEXT;
2862#define glProgramUniform1uiEXT glad_glProgramUniform1uiEXT
2863GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIVEXTPROC glad_glProgramUniform1uivEXT;
2864#define glProgramUniform1uivEXT glad_glProgramUniform1uivEXT
2865GLAD_API_CALL PFNGLPROGRAMUNIFORM2FEXTPROC glad_glProgramUniform2fEXT;
2866#define glProgramUniform2fEXT glad_glProgramUniform2fEXT
2867GLAD_API_CALL PFNGLPROGRAMUNIFORM2FVEXTPROC glad_glProgramUniform2fvEXT;
2868#define glProgramUniform2fvEXT glad_glProgramUniform2fvEXT
2869GLAD_API_CALL PFNGLPROGRAMUNIFORM2IEXTPROC glad_glProgramUniform2iEXT;
2870#define glProgramUniform2iEXT glad_glProgramUniform2iEXT
2871GLAD_API_CALL PFNGLPROGRAMUNIFORM2IVEXTPROC glad_glProgramUniform2ivEXT;
2872#define glProgramUniform2ivEXT glad_glProgramUniform2ivEXT
2873GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIEXTPROC glad_glProgramUniform2uiEXT;
2874#define glProgramUniform2uiEXT glad_glProgramUniform2uiEXT
2875GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIVEXTPROC glad_glProgramUniform2uivEXT;
2876#define glProgramUniform2uivEXT glad_glProgramUniform2uivEXT
2877GLAD_API_CALL PFNGLPROGRAMUNIFORM3FEXTPROC glad_glProgramUniform3fEXT;
2878#define glProgramUniform3fEXT glad_glProgramUniform3fEXT
2879GLAD_API_CALL PFNGLPROGRAMUNIFORM3FVEXTPROC glad_glProgramUniform3fvEXT;
2880#define glProgramUniform3fvEXT glad_glProgramUniform3fvEXT
2881GLAD_API_CALL PFNGLPROGRAMUNIFORM3IEXTPROC glad_glProgramUniform3iEXT;
2882#define glProgramUniform3iEXT glad_glProgramUniform3iEXT
2883GLAD_API_CALL PFNGLPROGRAMUNIFORM3IVEXTPROC glad_glProgramUniform3ivEXT;
2884#define glProgramUniform3ivEXT glad_glProgramUniform3ivEXT
2885GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIEXTPROC glad_glProgramUniform3uiEXT;
2886#define glProgramUniform3uiEXT glad_glProgramUniform3uiEXT
2887GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIVEXTPROC glad_glProgramUniform3uivEXT;
2888#define glProgramUniform3uivEXT glad_glProgramUniform3uivEXT
2889GLAD_API_CALL PFNGLPROGRAMUNIFORM4FEXTPROC glad_glProgramUniform4fEXT;
2890#define glProgramUniform4fEXT glad_glProgramUniform4fEXT
2891GLAD_API_CALL PFNGLPROGRAMUNIFORM4FVEXTPROC glad_glProgramUniform4fvEXT;
2892#define glProgramUniform4fvEXT glad_glProgramUniform4fvEXT
2893GLAD_API_CALL PFNGLPROGRAMUNIFORM4IEXTPROC glad_glProgramUniform4iEXT;
2894#define glProgramUniform4iEXT glad_glProgramUniform4iEXT
2895GLAD_API_CALL PFNGLPROGRAMUNIFORM4IVEXTPROC glad_glProgramUniform4ivEXT;
2896#define glProgramUniform4ivEXT glad_glProgramUniform4ivEXT
2897GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIEXTPROC glad_glProgramUniform4uiEXT;
2898#define glProgramUniform4uiEXT glad_glProgramUniform4uiEXT
2899GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIVEXTPROC glad_glProgramUniform4uivEXT;
2900#define glProgramUniform4uivEXT glad_glProgramUniform4uivEXT
2901GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC glad_glProgramUniformMatrix2fvEXT;
2902#define glProgramUniformMatrix2fvEXT glad_glProgramUniformMatrix2fvEXT
2903GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC glad_glProgramUniformMatrix2x3fvEXT;
2904#define glProgramUniformMatrix2x3fvEXT glad_glProgramUniformMatrix2x3fvEXT
2905GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC glad_glProgramUniformMatrix2x4fvEXT;
2906#define glProgramUniformMatrix2x4fvEXT glad_glProgramUniformMatrix2x4fvEXT
2907GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC glad_glProgramUniformMatrix3fvEXT;
2908#define glProgramUniformMatrix3fvEXT glad_glProgramUniformMatrix3fvEXT
2909GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC glad_glProgramUniformMatrix3x2fvEXT;
2910#define glProgramUniformMatrix3x2fvEXT glad_glProgramUniformMatrix3x2fvEXT
2911GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC glad_glProgramUniformMatrix3x4fvEXT;
2912#define glProgramUniformMatrix3x4fvEXT glad_glProgramUniformMatrix3x4fvEXT
2913GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC glad_glProgramUniformMatrix4fvEXT;
2914#define glProgramUniformMatrix4fvEXT glad_glProgramUniformMatrix4fvEXT
2915GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC glad_glProgramUniformMatrix4x2fvEXT;
2916#define glProgramUniformMatrix4x2fvEXT glad_glProgramUniformMatrix4x2fvEXT
2917GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC glad_glProgramUniformMatrix4x3fvEXT;
2918#define glProgramUniformMatrix4x3fvEXT glad_glProgramUniformMatrix4x3fvEXT
2919GLAD_API_CALL PFNGLPUSHDEBUGGROUPKHRPROC glad_glPushDebugGroupKHR;
2920#define glPushDebugGroupKHR glad_glPushDebugGroupKHR
2921GLAD_API_CALL PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
2922#define glPushGroupMarkerEXT glad_glPushGroupMarkerEXT
2923GLAD_API_CALL PFNGLQUERYCOUNTEREXTPROC glad_glQueryCounterEXT;
2924#define glQueryCounterEXT glad_glQueryCounterEXT
2925GLAD_API_CALL PFNGLRASTERSAMPLESEXTPROC glad_glRasterSamplesEXT;
2926#define glRasterSamplesEXT glad_glRasterSamplesEXT
2927GLAD_API_CALL PFNGLREADBUFFERINDEXEDEXTPROC glad_glReadBufferIndexedEXT;
2928#define glReadBufferIndexedEXT glad_glReadBufferIndexedEXT
2929GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
2930#define glReadPixels glad_glReadPixels
2931GLAD_API_CALL PFNGLREADNPIXELSEXTPROC glad_glReadnPixelsEXT;
2932#define glReadnPixelsEXT glad_glReadnPixelsEXT
2933GLAD_API_CALL PFNGLREADNPIXELSKHRPROC glad_glReadnPixelsKHR;
2934#define glReadnPixelsKHR glad_glReadnPixelsKHR
2935GLAD_API_CALL PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC glad_glReleaseKeyedMutexWin32EXT;
2936#define glReleaseKeyedMutexWin32EXT glad_glReleaseKeyedMutexWin32EXT
2937GLAD_API_CALL PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
2938#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
2939GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
2940#define glRenderbufferStorage glad_glRenderbufferStorage
2941GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
2942#define glRenderbufferStorageMultisampleEXT glad_glRenderbufferStorageMultisampleEXT
2943GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
2944#define glSampleCoverage glad_glSampleCoverage
2945GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVEXTPROC glad_glSamplerParameterIivEXT;
2946#define glSamplerParameterIivEXT glad_glSamplerParameterIivEXT
2947GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVOESPROC glad_glSamplerParameterIivOES;
2948#define glSamplerParameterIivOES glad_glSamplerParameterIivOES
2949GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVEXTPROC glad_glSamplerParameterIuivEXT;
2950#define glSamplerParameterIuivEXT glad_glSamplerParameterIuivEXT
2951GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVOESPROC glad_glSamplerParameterIuivOES;
2952#define glSamplerParameterIuivOES glad_glSamplerParameterIuivOES
2953GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
2954#define glScissor glad_glScissor
2955GLAD_API_CALL PFNGLSCISSORARRAYVOESPROC glad_glScissorArrayvOES;
2956#define glScissorArrayvOES glad_glScissorArrayvOES
2957GLAD_API_CALL PFNGLSCISSORINDEXEDOESPROC glad_glScissorIndexedOES;
2958#define glScissorIndexedOES glad_glScissorIndexedOES
2959GLAD_API_CALL PFNGLSCISSORINDEXEDVOESPROC glad_glScissorIndexedvOES;
2960#define glScissorIndexedvOES glad_glScissorIndexedvOES
2961GLAD_API_CALL PFNGLSEMAPHOREPARAMETERUI64VEXTPROC glad_glSemaphoreParameterui64vEXT;
2962#define glSemaphoreParameterui64vEXT glad_glSemaphoreParameterui64vEXT
2963GLAD_API_CALL PFNGLSHADERBINARYPROC glad_glShaderBinary;
2964#define glShaderBinary glad_glShaderBinary
2965GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
2966#define glShaderSource glad_glShaderSource
2967GLAD_API_CALL PFNGLSHADINGRATECOMBINEROPSEXTPROC glad_glShadingRateCombinerOpsEXT;
2968#define glShadingRateCombinerOpsEXT glad_glShadingRateCombinerOpsEXT
2969GLAD_API_CALL PFNGLSHADINGRATEEXTPROC glad_glShadingRateEXT;
2970#define glShadingRateEXT glad_glShadingRateEXT
2971GLAD_API_CALL PFNGLSIGNALSEMAPHOREEXTPROC glad_glSignalSemaphoreEXT;
2972#define glSignalSemaphoreEXT glad_glSignalSemaphoreEXT
2973GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
2974#define glStencilFunc glad_glStencilFunc
2975GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
2976#define glStencilFuncSeparate glad_glStencilFuncSeparate
2977GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
2978#define glStencilMask glad_glStencilMask
2979GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
2980#define glStencilMaskSeparate glad_glStencilMaskSeparate
2981GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
2982#define glStencilOp glad_glStencilOp
2983GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
2984#define glStencilOpSeparate glad_glStencilOpSeparate
2985GLAD_API_CALL PFNGLTEXBUFFEREXTPROC glad_glTexBufferEXT;
2986#define glTexBufferEXT glad_glTexBufferEXT
2987GLAD_API_CALL PFNGLTEXBUFFEROESPROC glad_glTexBufferOES;
2988#define glTexBufferOES glad_glTexBufferOES
2989GLAD_API_CALL PFNGLTEXBUFFERRANGEEXTPROC glad_glTexBufferRangeEXT;
2990#define glTexBufferRangeEXT glad_glTexBufferRangeEXT
2991GLAD_API_CALL PFNGLTEXBUFFERRANGEOESPROC glad_glTexBufferRangeOES;
2992#define glTexBufferRangeOES glad_glTexBufferRangeOES
2993GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
2994#define glTexImage2D glad_glTexImage2D
2995GLAD_API_CALL PFNGLTEXIMAGE3DOESPROC glad_glTexImage3DOES;
2996#define glTexImage3DOES glad_glTexImage3DOES
2997GLAD_API_CALL PFNGLTEXPAGECOMMITMENTEXTPROC glad_glTexPageCommitmentEXT;
2998#define glTexPageCommitmentEXT glad_glTexPageCommitmentEXT
2999GLAD_API_CALL PFNGLTEXPARAMETERIIVEXTPROC glad_glTexParameterIivEXT;
3000#define glTexParameterIivEXT glad_glTexParameterIivEXT
3001GLAD_API_CALL PFNGLTEXPARAMETERIIVOESPROC glad_glTexParameterIivOES;
3002#define glTexParameterIivOES glad_glTexParameterIivOES
3003GLAD_API_CALL PFNGLTEXPARAMETERIUIVEXTPROC glad_glTexParameterIuivEXT;
3004#define glTexParameterIuivEXT glad_glTexParameterIuivEXT
3005GLAD_API_CALL PFNGLTEXPARAMETERIUIVOESPROC glad_glTexParameterIuivOES;
3006#define glTexParameterIuivOES glad_glTexParameterIuivOES
3007GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
3008#define glTexParameterf glad_glTexParameterf
3009GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
3010#define glTexParameterfv glad_glTexParameterfv
3011GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
3012#define glTexParameteri glad_glTexParameteri
3013GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
3014#define glTexParameteriv glad_glTexParameteriv
3015GLAD_API_CALL PFNGLTEXSTORAGE1DEXTPROC glad_glTexStorage1DEXT;
3016#define glTexStorage1DEXT glad_glTexStorage1DEXT
3017GLAD_API_CALL PFNGLTEXSTORAGE2DEXTPROC glad_glTexStorage2DEXT;
3018#define glTexStorage2DEXT glad_glTexStorage2DEXT
3019GLAD_API_CALL PFNGLTEXSTORAGE3DEXTPROC glad_glTexStorage3DEXT;
3020#define glTexStorage3DEXT glad_glTexStorage3DEXT
3021GLAD_API_CALL PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC glad_glTexStorage3DMultisampleOES;
3022#define glTexStorage3DMultisampleOES glad_glTexStorage3DMultisampleOES
3023GLAD_API_CALL PFNGLTEXSTORAGEATTRIBS2DEXTPROC glad_glTexStorageAttribs2DEXT;
3024#define glTexStorageAttribs2DEXT glad_glTexStorageAttribs2DEXT
3025GLAD_API_CALL PFNGLTEXSTORAGEATTRIBS3DEXTPROC glad_glTexStorageAttribs3DEXT;
3026#define glTexStorageAttribs3DEXT glad_glTexStorageAttribs3DEXT
3027GLAD_API_CALL PFNGLTEXSTORAGEMEM2DEXTPROC glad_glTexStorageMem2DEXT;
3028#define glTexStorageMem2DEXT glad_glTexStorageMem2DEXT
3029GLAD_API_CALL PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTexStorageMem2DMultisampleEXT;
3030#define glTexStorageMem2DMultisampleEXT glad_glTexStorageMem2DMultisampleEXT
3031GLAD_API_CALL PFNGLTEXSTORAGEMEM3DEXTPROC glad_glTexStorageMem3DEXT;
3032#define glTexStorageMem3DEXT glad_glTexStorageMem3DEXT
3033GLAD_API_CALL PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTexStorageMem3DMultisampleEXT;
3034#define glTexStorageMem3DMultisampleEXT glad_glTexStorageMem3DMultisampleEXT
3035GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
3036#define glTexSubImage2D glad_glTexSubImage2D
3037GLAD_API_CALL PFNGLTEXSUBIMAGE3DOESPROC glad_glTexSubImage3DOES;
3038#define glTexSubImage3DOES glad_glTexSubImage3DOES
3039GLAD_API_CALL PFNGLTEXTURESTORAGE1DEXTPROC glad_glTextureStorage1DEXT;
3040#define glTextureStorage1DEXT glad_glTextureStorage1DEXT
3041GLAD_API_CALL PFNGLTEXTURESTORAGE2DEXTPROC glad_glTextureStorage2DEXT;
3042#define glTextureStorage2DEXT glad_glTextureStorage2DEXT
3043GLAD_API_CALL PFNGLTEXTURESTORAGE3DEXTPROC glad_glTextureStorage3DEXT;
3044#define glTextureStorage3DEXT glad_glTextureStorage3DEXT
3045GLAD_API_CALL PFNGLTEXTURESTORAGEMEM2DEXTPROC glad_glTextureStorageMem2DEXT;
3046#define glTextureStorageMem2DEXT glad_glTextureStorageMem2DEXT
3047GLAD_API_CALL PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTextureStorageMem2DMultisampleEXT;
3048#define glTextureStorageMem2DMultisampleEXT glad_glTextureStorageMem2DMultisampleEXT
3049GLAD_API_CALL PFNGLTEXTURESTORAGEMEM3DEXTPROC glad_glTextureStorageMem3DEXT;
3050#define glTextureStorageMem3DEXT glad_glTextureStorageMem3DEXT
3051GLAD_API_CALL PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTextureStorageMem3DMultisampleEXT;
3052#define glTextureStorageMem3DMultisampleEXT glad_glTextureStorageMem3DMultisampleEXT
3053GLAD_API_CALL PFNGLTEXTUREVIEWEXTPROC glad_glTextureViewEXT;
3054#define glTextureViewEXT glad_glTextureViewEXT
3055GLAD_API_CALL PFNGLTEXTUREVIEWOESPROC glad_glTextureViewOES;
3056#define glTextureViewOES glad_glTextureViewOES
3057GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
3058#define glUniform1f glad_glUniform1f
3059GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
3060#define glUniform1fv glad_glUniform1fv
3061GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
3062#define glUniform1i glad_glUniform1i
3063GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
3064#define glUniform1iv glad_glUniform1iv
3065GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
3066#define glUniform2f glad_glUniform2f
3067GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
3068#define glUniform2fv glad_glUniform2fv
3069GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
3070#define glUniform2i glad_glUniform2i
3071GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
3072#define glUniform2iv glad_glUniform2iv
3073GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
3074#define glUniform3f glad_glUniform3f
3075GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
3076#define glUniform3fv glad_glUniform3fv
3077GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
3078#define glUniform3i glad_glUniform3i
3079GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
3080#define glUniform3iv glad_glUniform3iv
3081GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
3082#define glUniform4f glad_glUniform4f
3083GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
3084#define glUniform4fv glad_glUniform4fv
3085GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
3086#define glUniform4i glad_glUniform4i
3087GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
3088#define glUniform4iv glad_glUniform4iv
3089GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
3090#define glUniformMatrix2fv glad_glUniformMatrix2fv
3091GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
3092#define glUniformMatrix3fv glad_glUniformMatrix3fv
3093GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
3094#define glUniformMatrix4fv glad_glUniformMatrix4fv
3095GLAD_API_CALL PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES;
3096#define glUnmapBufferOES glad_glUnmapBufferOES
3097GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
3098#define glUseProgram glad_glUseProgram
3099GLAD_API_CALL PFNGLUSEPROGRAMSTAGESEXTPROC glad_glUseProgramStagesEXT;
3100#define glUseProgramStagesEXT glad_glUseProgramStagesEXT
3101GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
3102#define glValidateProgram glad_glValidateProgram
3103GLAD_API_CALL PFNGLVALIDATEPROGRAMPIPELINEEXTPROC glad_glValidateProgramPipelineEXT;
3104#define glValidateProgramPipelineEXT glad_glValidateProgramPipelineEXT
3105GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
3106#define glVertexAttrib1f glad_glVertexAttrib1f
3107GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
3108#define glVertexAttrib1fv glad_glVertexAttrib1fv
3109GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
3110#define glVertexAttrib2f glad_glVertexAttrib2f
3111GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
3112#define glVertexAttrib2fv glad_glVertexAttrib2fv
3113GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
3114#define glVertexAttrib3f glad_glVertexAttrib3f
3115GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
3116#define glVertexAttrib3fv glad_glVertexAttrib3fv
3117GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
3118#define glVertexAttrib4f glad_glVertexAttrib4f
3119GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
3120#define glVertexAttrib4fv glad_glVertexAttrib4fv
3121GLAD_API_CALL PFNGLVERTEXATTRIBDIVISOREXTPROC glad_glVertexAttribDivisorEXT;
3122#define glVertexAttribDivisorEXT glad_glVertexAttribDivisorEXT
3123GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
3124#define glVertexAttribPointer glad_glVertexAttribPointer
3125GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
3126#define glViewport glad_glViewport
3127GLAD_API_CALL PFNGLVIEWPORTARRAYVOESPROC glad_glViewportArrayvOES;
3128#define glViewportArrayvOES glad_glViewportArrayvOES
3129GLAD_API_CALL PFNGLVIEWPORTINDEXEDFOESPROC glad_glViewportIndexedfOES;
3130#define glViewportIndexedfOES glad_glViewportIndexedfOES
3131GLAD_API_CALL PFNGLVIEWPORTINDEXEDFVOESPROC glad_glViewportIndexedfvOES;
3132#define glViewportIndexedfvOES glad_glViewportIndexedfvOES
3133GLAD_API_CALL PFNGLWAITSEMAPHOREEXTPROC glad_glWaitSemaphoreEXT;
3134#define glWaitSemaphoreEXT glad_glWaitSemaphoreEXT
3135GLAD_API_CALL PFNGLWINDOWRECTANGLESEXTPROC glad_glWindowRectanglesEXT;
3136#define glWindowRectanglesEXT glad_glWindowRectanglesEXT
3137
3138
3139
3140
3141
3142GLAD_API_CALL int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr);
3143GLAD_API_CALL int gladLoadGLES2( GLADloadfunc load);
3144
3145
3146
3147#ifdef __cplusplus
3148}
3149#endif
3150#endif
3151
3152/* Source */
3153#ifdef GLAD_GLES2_IMPLEMENTATION
3154/**
3155 * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
3156 */
3157#include <stdio.h>
3158#include <stdlib.h>
3159#include <string.h>
3160
3161#ifndef GLAD_IMPL_UTIL_C_
3162#define GLAD_IMPL_UTIL_C_
3163
3164#ifdef _MSC_VER
3165#define GLAD_IMPL_UTIL_SSCANF sscanf_s
3166#else
3167#define GLAD_IMPL_UTIL_SSCANF sscanf
3168#endif
3169
3170#endif /* GLAD_IMPL_UTIL_C_ */
3171
3172#ifdef __cplusplus
3173extern "C" {
3174#endif
3175
3176
3177
3178int GLAD_GL_ES_VERSION_2_0 = 0;
3179int GLAD_GL_EXT_EGL_image_array = 0;
3180int GLAD_GL_EXT_EGL_image_storage = 0;
3181int GLAD_GL_EXT_EGL_image_storage_compression = 0;
3182int GLAD_GL_EXT_YUV_target = 0;
3183int GLAD_GL_EXT_base_instance = 0;
3184int GLAD_GL_EXT_blend_func_extended = 0;
3185int GLAD_GL_EXT_blend_minmax = 0;
3186int GLAD_GL_EXT_buffer_storage = 0;
3187int GLAD_GL_EXT_clear_texture = 0;
3188int GLAD_GL_EXT_clip_control = 0;
3189int GLAD_GL_EXT_clip_cull_distance = 0;
3190int GLAD_GL_EXT_color_buffer_float = 0;
3191int GLAD_GL_EXT_color_buffer_half_float = 0;
3192int GLAD_GL_EXT_conservative_depth = 0;
3193int GLAD_GL_EXT_copy_image = 0;
3194int GLAD_GL_EXT_debug_label = 0;
3195int GLAD_GL_EXT_debug_marker = 0;
3196int GLAD_GL_EXT_depth_clamp = 0;
3197int GLAD_GL_EXT_discard_framebuffer = 0;
3198int GLAD_GL_EXT_disjoint_timer_query = 0;
3199int GLAD_GL_EXT_draw_buffers = 0;
3200int GLAD_GL_EXT_draw_buffers_indexed = 0;
3201int GLAD_GL_EXT_draw_elements_base_vertex = 0;
3202int GLAD_GL_EXT_draw_instanced = 0;
3203int GLAD_GL_EXT_draw_transform_feedback = 0;
3204int GLAD_GL_EXT_external_buffer = 0;
3205int GLAD_GL_EXT_float_blend = 0;
3206int GLAD_GL_EXT_fragment_shading_rate = 0;
3207int GLAD_GL_EXT_geometry_point_size = 0;
3208int GLAD_GL_EXT_geometry_shader = 0;
3209int GLAD_GL_EXT_gpu_shader5 = 0;
3210int GLAD_GL_EXT_instanced_arrays = 0;
3211int GLAD_GL_EXT_map_buffer_range = 0;
3212int GLAD_GL_EXT_memory_object = 0;
3213int GLAD_GL_EXT_memory_object_fd = 0;
3214int GLAD_GL_EXT_memory_object_win32 = 0;
3215int GLAD_GL_EXT_multi_draw_arrays = 0;
3216int GLAD_GL_EXT_multi_draw_indirect = 0;
3217int GLAD_GL_EXT_multisampled_compatibility = 0;
3218int GLAD_GL_EXT_multisampled_render_to_texture = 0;
3219int GLAD_GL_EXT_multisampled_render_to_texture2 = 0;
3220int GLAD_GL_EXT_multiview_draw_buffers = 0;
3221int GLAD_GL_EXT_multiview_tessellation_geometry_shader = 0;
3222int GLAD_GL_EXT_multiview_texture_multisample = 0;
3223int GLAD_GL_EXT_multiview_timer_query = 0;
3224int GLAD_GL_EXT_occlusion_query_boolean = 0;
3225int GLAD_GL_EXT_polygon_offset_clamp = 0;
3226int GLAD_GL_EXT_post_depth_coverage = 0;
3227int GLAD_GL_EXT_primitive_bounding_box = 0;
3228int GLAD_GL_EXT_protected_textures = 0;
3229int GLAD_GL_EXT_pvrtc_sRGB = 0;
3230int GLAD_GL_EXT_raster_multisample = 0;
3231int GLAD_GL_EXT_read_format_bgra = 0;
3232int GLAD_GL_EXT_render_snorm = 0;
3233int GLAD_GL_EXT_robustness = 0;
3234int GLAD_GL_EXT_sRGB = 0;
3235int GLAD_GL_EXT_sRGB_write_control = 0;
3236int GLAD_GL_EXT_semaphore = 0;
3237int GLAD_GL_EXT_semaphore_fd = 0;
3238int GLAD_GL_EXT_semaphore_win32 = 0;
3239int GLAD_GL_EXT_separate_depth_stencil = 0;
3240int GLAD_GL_EXT_separate_shader_objects = 0;
3241int GLAD_GL_EXT_shader_framebuffer_fetch = 0;
3242int GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent = 0;
3243int GLAD_GL_EXT_shader_group_vote = 0;
3244int GLAD_GL_EXT_shader_implicit_conversions = 0;
3245int GLAD_GL_EXT_shader_integer_mix = 0;
3246int GLAD_GL_EXT_shader_io_blocks = 0;
3247int GLAD_GL_EXT_shader_non_constant_global_initializers = 0;
3248int GLAD_GL_EXT_shader_pixel_local_storage = 0;
3249int GLAD_GL_EXT_shader_pixel_local_storage2 = 0;
3250int GLAD_GL_EXT_shader_samples_identical = 0;
3251int GLAD_GL_EXT_shader_texture_lod = 0;
3252int GLAD_GL_EXT_shadow_samplers = 0;
3253int GLAD_GL_EXT_sparse_texture = 0;
3254int GLAD_GL_EXT_sparse_texture2 = 0;
3255int GLAD_GL_EXT_tessellation_point_size = 0;
3256int GLAD_GL_EXT_tessellation_shader = 0;
3257int GLAD_GL_EXT_texture_border_clamp = 0;
3258int GLAD_GL_EXT_texture_buffer = 0;
3259int GLAD_GL_EXT_texture_compression_astc_decode_mode = 0;
3260int GLAD_GL_EXT_texture_compression_bptc = 0;
3261int GLAD_GL_EXT_texture_compression_dxt1 = 0;
3262int GLAD_GL_EXT_texture_compression_rgtc = 0;
3263int GLAD_GL_EXT_texture_compression_s3tc = 0;
3264int GLAD_GL_EXT_texture_compression_s3tc_srgb = 0;
3265int GLAD_GL_EXT_texture_cube_map_array = 0;
3266int GLAD_GL_EXT_texture_filter_anisotropic = 0;
3267int GLAD_GL_EXT_texture_filter_minmax = 0;
3268int GLAD_GL_EXT_texture_format_BGRA8888 = 0;
3269int GLAD_GL_EXT_texture_format_sRGB_override = 0;
3270int GLAD_GL_EXT_texture_mirror_clamp_to_edge = 0;
3271int GLAD_GL_EXT_texture_norm16 = 0;
3272int GLAD_GL_EXT_texture_query_lod = 0;
3273int GLAD_GL_EXT_texture_rg = 0;
3274int GLAD_GL_EXT_texture_sRGB_R8 = 0;
3275int GLAD_GL_EXT_texture_sRGB_RG8 = 0;
3276int GLAD_GL_EXT_texture_sRGB_decode = 0;
3277int GLAD_GL_EXT_texture_shadow_lod = 0;
3278int GLAD_GL_EXT_texture_storage = 0;
3279int GLAD_GL_EXT_texture_storage_compression = 0;
3280int GLAD_GL_EXT_texture_type_2_10_10_10_REV = 0;
3281int GLAD_GL_EXT_texture_view = 0;
3282int GLAD_GL_EXT_unpack_subimage = 0;
3283int GLAD_GL_EXT_win32_keyed_mutex = 0;
3284int GLAD_GL_EXT_window_rectangles = 0;
3285int GLAD_GL_KHR_blend_equation_advanced = 0;
3286int GLAD_GL_KHR_blend_equation_advanced_coherent = 0;
3287int GLAD_GL_KHR_context_flush_control = 0;
3288int GLAD_GL_KHR_debug = 0;
3289int GLAD_GL_KHR_no_error = 0;
3290int GLAD_GL_KHR_parallel_shader_compile = 0;
3291int GLAD_GL_KHR_robust_buffer_access_behavior = 0;
3292int GLAD_GL_KHR_robustness = 0;
3293int GLAD_GL_KHR_shader_subgroup = 0;
3294int GLAD_GL_KHR_texture_compression_astc_hdr = 0;
3295int GLAD_GL_KHR_texture_compression_astc_ldr = 0;
3296int GLAD_GL_KHR_texture_compression_astc_sliced_3d = 0;
3297int GLAD_GL_OES_EGL_image = 0;
3298int GLAD_GL_OES_EGL_image_external = 0;
3299int GLAD_GL_OES_EGL_image_external_essl3 = 0;
3300int GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture = 0;
3301int GLAD_GL_OES_compressed_ETC1_RGB8_texture = 0;
3302int GLAD_GL_OES_compressed_paletted_texture = 0;
3303int GLAD_GL_OES_copy_image = 0;
3304int GLAD_GL_OES_depth24 = 0;
3305int GLAD_GL_OES_depth32 = 0;
3306int GLAD_GL_OES_depth_texture = 0;
3307int GLAD_GL_OES_draw_buffers_indexed = 0;
3308int GLAD_GL_OES_draw_elements_base_vertex = 0;
3309int GLAD_GL_OES_element_index_uint = 0;
3310int GLAD_GL_OES_fbo_render_mipmap = 0;
3311int GLAD_GL_OES_fragment_precision_high = 0;
3312int GLAD_GL_OES_geometry_point_size = 0;
3313int GLAD_GL_OES_geometry_shader = 0;
3314int GLAD_GL_OES_get_program_binary = 0;
3315int GLAD_GL_OES_gpu_shader5 = 0;
3316int GLAD_GL_OES_mapbuffer = 0;
3317int GLAD_GL_OES_packed_depth_stencil = 0;
3318int GLAD_GL_OES_primitive_bounding_box = 0;
3319int GLAD_GL_OES_required_internalformat = 0;
3320int GLAD_GL_OES_rgb8_rgba8 = 0;
3321int GLAD_GL_OES_sample_shading = 0;
3322int GLAD_GL_OES_sample_variables = 0;
3323int GLAD_GL_OES_shader_image_atomic = 0;
3324int GLAD_GL_OES_shader_io_blocks = 0;
3325int GLAD_GL_OES_shader_multisample_interpolation = 0;
3326int GLAD_GL_OES_standard_derivatives = 0;
3327int GLAD_GL_OES_stencil1 = 0;
3328int GLAD_GL_OES_stencil4 = 0;
3329int GLAD_GL_OES_surfaceless_context = 0;
3330int GLAD_GL_OES_tessellation_point_size = 0;
3331int GLAD_GL_OES_tessellation_shader = 0;
3332int GLAD_GL_OES_texture_3D = 0;
3333int GLAD_GL_OES_texture_border_clamp = 0;
3334int GLAD_GL_OES_texture_buffer = 0;
3335int GLAD_GL_OES_texture_compression_astc = 0;
3336int GLAD_GL_OES_texture_cube_map_array = 0;
3337int GLAD_GL_OES_texture_float = 0;
3338int GLAD_GL_OES_texture_float_linear = 0;
3339int GLAD_GL_OES_texture_half_float = 0;
3340int GLAD_GL_OES_texture_half_float_linear = 0;
3341int GLAD_GL_OES_texture_npot = 0;
3342int GLAD_GL_OES_texture_stencil8 = 0;
3343int GLAD_GL_OES_texture_storage_multisample_2d_array = 0;
3344int GLAD_GL_OES_texture_view = 0;
3345int GLAD_GL_OES_vertex_array_object = 0;
3346int GLAD_GL_OES_vertex_half_float = 0;
3347int GLAD_GL_OES_vertex_type_10_10_10_2 = 0;
3348int GLAD_GL_OES_viewport_array = 0;
3349
3350
3351
3352PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC glad_glAcquireKeyedMutexWin32EXT = NULL;
3353PFNGLACTIVESHADERPROGRAMEXTPROC glad_glActiveShaderProgramEXT = NULL;
3354PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
3355PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
3356PFNGLBEGINQUERYEXTPROC glad_glBeginQueryEXT = NULL;
3357PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
3358PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
3359PFNGLBINDFRAGDATALOCATIONEXTPROC glad_glBindFragDataLocationEXT = NULL;
3360PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC glad_glBindFragDataLocationIndexedEXT = NULL;
3361PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
3362PFNGLBINDPROGRAMPIPELINEEXTPROC glad_glBindProgramPipelineEXT = NULL;
3363PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
3364PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
3365PFNGLBINDVERTEXARRAYOESPROC glad_glBindVertexArrayOES = NULL;
3366PFNGLBLENDBARRIERKHRPROC glad_glBlendBarrierKHR = NULL;
3367PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
3368PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
3369PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
3370PFNGLBLENDEQUATIONSEPARATEIEXTPROC glad_glBlendEquationSeparateiEXT = NULL;
3371PFNGLBLENDEQUATIONSEPARATEIOESPROC glad_glBlendEquationSeparateiOES = NULL;
3372PFNGLBLENDEQUATIONIEXTPROC glad_glBlendEquationiEXT = NULL;
3373PFNGLBLENDEQUATIONIOESPROC glad_glBlendEquationiOES = NULL;
3374PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
3375PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
3376PFNGLBLENDFUNCSEPARATEIEXTPROC glad_glBlendFuncSeparateiEXT = NULL;
3377PFNGLBLENDFUNCSEPARATEIOESPROC glad_glBlendFuncSeparateiOES = NULL;
3378PFNGLBLENDFUNCIEXTPROC glad_glBlendFunciEXT = NULL;
3379PFNGLBLENDFUNCIOESPROC glad_glBlendFunciOES = NULL;
3380PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
3381PFNGLBUFFERSTORAGEEXTPROC glad_glBufferStorageEXT = NULL;
3382PFNGLBUFFERSTORAGEEXTERNALEXTPROC glad_glBufferStorageExternalEXT = NULL;
3383PFNGLBUFFERSTORAGEMEMEXTPROC glad_glBufferStorageMemEXT = NULL;
3384PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
3385PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
3386PFNGLCLEARPROC glad_glClear = NULL;
3387PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
3388PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL;
3389PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC glad_glClearPixelLocalStorageuiEXT = NULL;
3390PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
3391PFNGLCLEARTEXIMAGEEXTPROC glad_glClearTexImageEXT = NULL;
3392PFNGLCLEARTEXSUBIMAGEEXTPROC glad_glClearTexSubImageEXT = NULL;
3393PFNGLCLIPCONTROLEXTPROC glad_glClipControlEXT = NULL;
3394PFNGLCOLORMASKPROC glad_glColorMask = NULL;
3395PFNGLCOLORMASKIEXTPROC glad_glColorMaskiEXT = NULL;
3396PFNGLCOLORMASKIOESPROC glad_glColorMaskiOES = NULL;
3397PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
3398PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
3399PFNGLCOMPRESSEDTEXIMAGE3DOESPROC glad_glCompressedTexImage3DOES = NULL;
3400PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
3401PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glad_glCompressedTexSubImage3DOES = NULL;
3402PFNGLCOPYIMAGESUBDATAEXTPROC glad_glCopyImageSubDataEXT = NULL;
3403PFNGLCOPYIMAGESUBDATAOESPROC glad_glCopyImageSubDataOES = NULL;
3404PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
3405PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
3406PFNGLCOPYTEXSUBIMAGE3DOESPROC glad_glCopyTexSubImage3DOES = NULL;
3407PFNGLCREATEMEMORYOBJECTSEXTPROC glad_glCreateMemoryObjectsEXT = NULL;
3408PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
3409PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
3410PFNGLCREATESHADERPROGRAMVEXTPROC glad_glCreateShaderProgramvEXT = NULL;
3411PFNGLCULLFACEPROC glad_glCullFace = NULL;
3412PFNGLDEBUGMESSAGECALLBACKKHRPROC glad_glDebugMessageCallbackKHR = NULL;
3413PFNGLDEBUGMESSAGECONTROLKHRPROC glad_glDebugMessageControlKHR = NULL;
3414PFNGLDEBUGMESSAGEINSERTKHRPROC glad_glDebugMessageInsertKHR = NULL;
3415PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
3416PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
3417PFNGLDELETEMEMORYOBJECTSEXTPROC glad_glDeleteMemoryObjectsEXT = NULL;
3418PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
3419PFNGLDELETEPROGRAMPIPELINESEXTPROC glad_glDeleteProgramPipelinesEXT = NULL;
3420PFNGLDELETEQUERIESEXTPROC glad_glDeleteQueriesEXT = NULL;
3421PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
3422PFNGLDELETESEMAPHORESEXTPROC glad_glDeleteSemaphoresEXT = NULL;
3423PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
3424PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
3425PFNGLDELETEVERTEXARRAYSOESPROC glad_glDeleteVertexArraysOES = NULL;
3426PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
3427PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
3428PFNGLDEPTHRANGEARRAYFVOESPROC glad_glDepthRangeArrayfvOES = NULL;
3429PFNGLDEPTHRANGEINDEXEDFOESPROC glad_glDepthRangeIndexedfOES = NULL;
3430PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL;
3431PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
3432PFNGLDISABLEPROC glad_glDisable = NULL;
3433PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
3434PFNGLDISABLEIEXTPROC glad_glDisableiEXT = NULL;
3435PFNGLDISABLEIOESPROC glad_glDisableiOES = NULL;
3436PFNGLDISCARDFRAMEBUFFEREXTPROC glad_glDiscardFramebufferEXT = NULL;
3437PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
3438PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawArraysInstancedBaseInstanceEXT = NULL;
3439PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT = NULL;
3440PFNGLDRAWBUFFERSEXTPROC glad_glDrawBuffersEXT = NULL;
3441PFNGLDRAWBUFFERSINDEXEDEXTPROC glad_glDrawBuffersIndexedEXT = NULL;
3442PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
3443PFNGLDRAWELEMENTSBASEVERTEXEXTPROC glad_glDrawElementsBaseVertexEXT = NULL;
3444PFNGLDRAWELEMENTSBASEVERTEXOESPROC glad_glDrawElementsBaseVertexOES = NULL;
3445PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseInstanceEXT = NULL;
3446PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT = NULL;
3447PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC glad_glDrawElementsInstancedBaseVertexEXT = NULL;
3448PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC glad_glDrawElementsInstancedBaseVertexOES = NULL;
3449PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT = NULL;
3450PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC glad_glDrawRangeElementsBaseVertexEXT = NULL;
3451PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC glad_glDrawRangeElementsBaseVertexOES = NULL;
3452PFNGLDRAWTRANSFORMFEEDBACKEXTPROC glad_glDrawTransformFeedbackEXT = NULL;
3453PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC glad_glDrawTransformFeedbackInstancedEXT = NULL;
3454PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glad_glEGLImageTargetRenderbufferStorageOES = NULL;
3455PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC glad_glEGLImageTargetTexStorageEXT = NULL;
3456PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glad_glEGLImageTargetTexture2DOES = NULL;
3457PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC glad_glEGLImageTargetTextureStorageEXT = NULL;
3458PFNGLENABLEPROC glad_glEnable = NULL;
3459PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
3460PFNGLENABLEIEXTPROC glad_glEnableiEXT = NULL;
3461PFNGLENABLEIOESPROC glad_glEnableiOES = NULL;
3462PFNGLENDQUERYEXTPROC glad_glEndQueryEXT = NULL;
3463PFNGLFINISHPROC glad_glFinish = NULL;
3464PFNGLFLUSHPROC glad_glFlush = NULL;
3465PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC glad_glFlushMappedBufferRangeEXT = NULL;
3466PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC glad_glFramebufferFetchBarrierEXT = NULL;
3467PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glFramebufferPixelLocalStorageSizeEXT = NULL;
3468PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
3469PFNGLFRAMEBUFFERSHADINGRATEEXTPROC glad_glFramebufferShadingRateEXT = NULL;
3470PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
3471PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glad_glFramebufferTexture2DMultisampleEXT = NULL;
3472PFNGLFRAMEBUFFERTEXTURE3DOESPROC glad_glFramebufferTexture3DOES = NULL;
3473PFNGLFRAMEBUFFERTEXTUREEXTPROC glad_glFramebufferTextureEXT = NULL;
3474PFNGLFRAMEBUFFERTEXTUREOESPROC glad_glFramebufferTextureOES = NULL;
3475PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
3476PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
3477PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
3478PFNGLGENPROGRAMPIPELINESEXTPROC glad_glGenProgramPipelinesEXT = NULL;
3479PFNGLGENQUERIESEXTPROC glad_glGenQueriesEXT = NULL;
3480PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
3481PFNGLGENSEMAPHORESEXTPROC glad_glGenSemaphoresEXT = NULL;
3482PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
3483PFNGLGENVERTEXARRAYSOESPROC glad_glGenVertexArraysOES = NULL;
3484PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
3485PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
3486PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
3487PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
3488PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
3489PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
3490PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
3491PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES = NULL;
3492PFNGLGETDEBUGMESSAGELOGKHRPROC glad_glGetDebugMessageLogKHR = NULL;
3493PFNGLGETERRORPROC glad_glGetError = NULL;
3494PFNGLGETFLOATI_VOESPROC glad_glGetFloati_vOES = NULL;
3495PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
3496PFNGLGETFRAGDATAINDEXEXTPROC glad_glGetFragDataIndexEXT = NULL;
3497PFNGLGETFRAGMENTSHADINGRATESEXTPROC glad_glGetFragmentShadingRatesEXT = NULL;
3498PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
3499PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glGetFramebufferPixelLocalStorageSizeEXT = NULL;
3500PFNGLGETGRAPHICSRESETSTATUSEXTPROC glad_glGetGraphicsResetStatusEXT = NULL;
3501PFNGLGETGRAPHICSRESETSTATUSKHRPROC glad_glGetGraphicsResetStatusKHR = NULL;
3502PFNGLGETINTEGER64VEXTPROC glad_glGetInteger64vEXT = NULL;
3503PFNGLGETINTEGERI_VEXTPROC glad_glGetIntegeri_vEXT = NULL;
3504PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
3505PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC glad_glGetMemoryObjectParameterivEXT = NULL;
3506PFNGLGETOBJECTLABELEXTPROC glad_glGetObjectLabelEXT = NULL;
3507PFNGLGETOBJECTLABELKHRPROC glad_glGetObjectLabelKHR = NULL;
3508PFNGLGETOBJECTPTRLABELKHRPROC glad_glGetObjectPtrLabelKHR = NULL;
3509PFNGLGETPOINTERVKHRPROC glad_glGetPointervKHR = NULL;
3510PFNGLGETPROGRAMBINARYOESPROC glad_glGetProgramBinaryOES = NULL;
3511PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
3512PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC glad_glGetProgramPipelineInfoLogEXT = NULL;
3513PFNGLGETPROGRAMPIPELINEIVEXTPROC glad_glGetProgramPipelineivEXT = NULL;
3514PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC glad_glGetProgramResourceLocationIndexEXT = NULL;
3515PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
3516PFNGLGETQUERYOBJECTI64VEXTPROC glad_glGetQueryObjecti64vEXT = NULL;
3517PFNGLGETQUERYOBJECTIVEXTPROC glad_glGetQueryObjectivEXT = NULL;
3518PFNGLGETQUERYOBJECTUI64VEXTPROC glad_glGetQueryObjectui64vEXT = NULL;
3519PFNGLGETQUERYOBJECTUIVEXTPROC glad_glGetQueryObjectuivEXT = NULL;
3520PFNGLGETQUERYIVEXTPROC glad_glGetQueryivEXT = NULL;
3521PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
3522PFNGLGETSAMPLERPARAMETERIIVEXTPROC glad_glGetSamplerParameterIivEXT = NULL;
3523PFNGLGETSAMPLERPARAMETERIIVOESPROC glad_glGetSamplerParameterIivOES = NULL;
3524PFNGLGETSAMPLERPARAMETERIUIVEXTPROC glad_glGetSamplerParameterIuivEXT = NULL;
3525PFNGLGETSAMPLERPARAMETERIUIVOESPROC glad_glGetSamplerParameterIuivOES = NULL;
3526PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC glad_glGetSemaphoreParameterui64vEXT = NULL;
3527PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
3528PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL;
3529PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
3530PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
3531PFNGLGETSTRINGPROC glad_glGetString = NULL;
3532PFNGLGETTEXPARAMETERIIVEXTPROC glad_glGetTexParameterIivEXT = NULL;
3533PFNGLGETTEXPARAMETERIIVOESPROC glad_glGetTexParameterIivOES = NULL;
3534PFNGLGETTEXPARAMETERIUIVEXTPROC glad_glGetTexParameterIuivEXT = NULL;
3535PFNGLGETTEXPARAMETERIUIVOESPROC glad_glGetTexParameterIuivOES = NULL;
3536PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
3537PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
3538PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
3539PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
3540PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
3541PFNGLGETUNSIGNEDBYTEI_VEXTPROC glad_glGetUnsignedBytei_vEXT = NULL;
3542PFNGLGETUNSIGNEDBYTEVEXTPROC glad_glGetUnsignedBytevEXT = NULL;
3543PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
3544PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
3545PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
3546PFNGLGETNUNIFORMFVEXTPROC glad_glGetnUniformfvEXT = NULL;
3547PFNGLGETNUNIFORMFVKHRPROC glad_glGetnUniformfvKHR = NULL;
3548PFNGLGETNUNIFORMIVEXTPROC glad_glGetnUniformivEXT = NULL;
3549PFNGLGETNUNIFORMIVKHRPROC glad_glGetnUniformivKHR = NULL;
3550PFNGLGETNUNIFORMUIVKHRPROC glad_glGetnUniformuivKHR = NULL;
3551PFNGLHINTPROC glad_glHint = NULL;
3552PFNGLIMPORTMEMORYFDEXTPROC glad_glImportMemoryFdEXT = NULL;
3553PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC glad_glImportMemoryWin32HandleEXT = NULL;
3554PFNGLIMPORTMEMORYWIN32NAMEEXTPROC glad_glImportMemoryWin32NameEXT = NULL;
3555PFNGLIMPORTSEMAPHOREFDEXTPROC glad_glImportSemaphoreFdEXT = NULL;
3556PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC glad_glImportSemaphoreWin32HandleEXT = NULL;
3557PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC glad_glImportSemaphoreWin32NameEXT = NULL;
3558PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT = NULL;
3559PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
3560PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
3561PFNGLISENABLEDIEXTPROC glad_glIsEnablediEXT = NULL;
3562PFNGLISENABLEDIOESPROC glad_glIsEnablediOES = NULL;
3563PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
3564PFNGLISMEMORYOBJECTEXTPROC glad_glIsMemoryObjectEXT = NULL;
3565PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
3566PFNGLISPROGRAMPIPELINEEXTPROC glad_glIsProgramPipelineEXT = NULL;
3567PFNGLISQUERYEXTPROC glad_glIsQueryEXT = NULL;
3568PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
3569PFNGLISSEMAPHOREEXTPROC glad_glIsSemaphoreEXT = NULL;
3570PFNGLISSHADERPROC glad_glIsShader = NULL;
3571PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
3572PFNGLISVERTEXARRAYOESPROC glad_glIsVertexArrayOES = NULL;
3573PFNGLLABELOBJECTEXTPROC glad_glLabelObjectEXT = NULL;
3574PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
3575PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
3576PFNGLMAPBUFFEROESPROC glad_glMapBufferOES = NULL;
3577PFNGLMAPBUFFERRANGEEXTPROC glad_glMapBufferRangeEXT = NULL;
3578PFNGLMAXSHADERCOMPILERTHREADSKHRPROC glad_glMaxShaderCompilerThreadsKHR = NULL;
3579PFNGLMEMORYOBJECTPARAMETERIVEXTPROC glad_glMemoryObjectParameterivEXT = NULL;
3580PFNGLMINSAMPLESHADINGOESPROC glad_glMinSampleShadingOES = NULL;
3581PFNGLMULTIDRAWARRAYSEXTPROC glad_glMultiDrawArraysEXT = NULL;
3582PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC glad_glMultiDrawArraysIndirectEXT = NULL;
3583PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC glad_glMultiDrawElementsBaseVertexEXT = NULL;
3584PFNGLMULTIDRAWELEMENTSEXTPROC glad_glMultiDrawElementsEXT = NULL;
3585PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC glad_glMultiDrawElementsIndirectEXT = NULL;
3586PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC glad_glNamedBufferStorageExternalEXT = NULL;
3587PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC glad_glNamedBufferStorageMemEXT = NULL;
3588PFNGLOBJECTLABELKHRPROC glad_glObjectLabelKHR = NULL;
3589PFNGLOBJECTPTRLABELKHRPROC glad_glObjectPtrLabelKHR = NULL;
3590PFNGLPATCHPARAMETERIEXTPROC glad_glPatchParameteriEXT = NULL;
3591PFNGLPATCHPARAMETERIOESPROC glad_glPatchParameteriOES = NULL;
3592PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
3593PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
3594PFNGLPOLYGONOFFSETCLAMPEXTPROC glad_glPolygonOffsetClampEXT = NULL;
3595PFNGLPOPDEBUGGROUPKHRPROC glad_glPopDebugGroupKHR = NULL;
3596PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT = NULL;
3597PFNGLPRIMITIVEBOUNDINGBOXEXTPROC glad_glPrimitiveBoundingBoxEXT = NULL;
3598PFNGLPRIMITIVEBOUNDINGBOXOESPROC glad_glPrimitiveBoundingBoxOES = NULL;
3599PFNGLPROGRAMBINARYOESPROC glad_glProgramBinaryOES = NULL;
3600PFNGLPROGRAMPARAMETERIEXTPROC glad_glProgramParameteriEXT = NULL;
3601PFNGLPROGRAMUNIFORM1FEXTPROC glad_glProgramUniform1fEXT = NULL;
3602PFNGLPROGRAMUNIFORM1FVEXTPROC glad_glProgramUniform1fvEXT = NULL;
3603PFNGLPROGRAMUNIFORM1IEXTPROC glad_glProgramUniform1iEXT = NULL;
3604PFNGLPROGRAMUNIFORM1IVEXTPROC glad_glProgramUniform1ivEXT = NULL;
3605PFNGLPROGRAMUNIFORM1UIEXTPROC glad_glProgramUniform1uiEXT = NULL;
3606PFNGLPROGRAMUNIFORM1UIVEXTPROC glad_glProgramUniform1uivEXT = NULL;
3607PFNGLPROGRAMUNIFORM2FEXTPROC glad_glProgramUniform2fEXT = NULL;
3608PFNGLPROGRAMUNIFORM2FVEXTPROC glad_glProgramUniform2fvEXT = NULL;
3609PFNGLPROGRAMUNIFORM2IEXTPROC glad_glProgramUniform2iEXT = NULL;
3610PFNGLPROGRAMUNIFORM2IVEXTPROC glad_glProgramUniform2ivEXT = NULL;
3611PFNGLPROGRAMUNIFORM2UIEXTPROC glad_glProgramUniform2uiEXT = NULL;
3612PFNGLPROGRAMUNIFORM2UIVEXTPROC glad_glProgramUniform2uivEXT = NULL;
3613PFNGLPROGRAMUNIFORM3FEXTPROC glad_glProgramUniform3fEXT = NULL;
3614PFNGLPROGRAMUNIFORM3FVEXTPROC glad_glProgramUniform3fvEXT = NULL;
3615PFNGLPROGRAMUNIFORM3IEXTPROC glad_glProgramUniform3iEXT = NULL;
3616PFNGLPROGRAMUNIFORM3IVEXTPROC glad_glProgramUniform3ivEXT = NULL;
3617PFNGLPROGRAMUNIFORM3UIEXTPROC glad_glProgramUniform3uiEXT = NULL;
3618PFNGLPROGRAMUNIFORM3UIVEXTPROC glad_glProgramUniform3uivEXT = NULL;
3619PFNGLPROGRAMUNIFORM4FEXTPROC glad_glProgramUniform4fEXT = NULL;
3620PFNGLPROGRAMUNIFORM4FVEXTPROC glad_glProgramUniform4fvEXT = NULL;
3621PFNGLPROGRAMUNIFORM4IEXTPROC glad_glProgramUniform4iEXT = NULL;
3622PFNGLPROGRAMUNIFORM4IVEXTPROC glad_glProgramUniform4ivEXT = NULL;
3623PFNGLPROGRAMUNIFORM4UIEXTPROC glad_glProgramUniform4uiEXT = NULL;
3624PFNGLPROGRAMUNIFORM4UIVEXTPROC glad_glProgramUniform4uivEXT = NULL;
3625PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC glad_glProgramUniformMatrix2fvEXT = NULL;
3626PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC glad_glProgramUniformMatrix2x3fvEXT = NULL;
3627PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC glad_glProgramUniformMatrix2x4fvEXT = NULL;
3628PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC glad_glProgramUniformMatrix3fvEXT = NULL;
3629PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC glad_glProgramUniformMatrix3x2fvEXT = NULL;
3630PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC glad_glProgramUniformMatrix3x4fvEXT = NULL;
3631PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC glad_glProgramUniformMatrix4fvEXT = NULL;
3632PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC glad_glProgramUniformMatrix4x2fvEXT = NULL;
3633PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC glad_glProgramUniformMatrix4x3fvEXT = NULL;
3634PFNGLPUSHDEBUGGROUPKHRPROC glad_glPushDebugGroupKHR = NULL;
3635PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT = NULL;
3636PFNGLQUERYCOUNTEREXTPROC glad_glQueryCounterEXT = NULL;
3637PFNGLRASTERSAMPLESEXTPROC glad_glRasterSamplesEXT = NULL;
3638PFNGLREADBUFFERINDEXEDEXTPROC glad_glReadBufferIndexedEXT = NULL;
3639PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
3640PFNGLREADNPIXELSEXTPROC glad_glReadnPixelsEXT = NULL;
3641PFNGLREADNPIXELSKHRPROC glad_glReadnPixelsKHR = NULL;
3642PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC glad_glReleaseKeyedMutexWin32EXT = NULL;
3643PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL;
3644PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
3645PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT = NULL;
3646PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
3647PFNGLSAMPLERPARAMETERIIVEXTPROC glad_glSamplerParameterIivEXT = NULL;
3648PFNGLSAMPLERPARAMETERIIVOESPROC glad_glSamplerParameterIivOES = NULL;
3649PFNGLSAMPLERPARAMETERIUIVEXTPROC glad_glSamplerParameterIuivEXT = NULL;
3650PFNGLSAMPLERPARAMETERIUIVOESPROC glad_glSamplerParameterIuivOES = NULL;
3651PFNGLSCISSORPROC glad_glScissor = NULL;
3652PFNGLSCISSORARRAYVOESPROC glad_glScissorArrayvOES = NULL;
3653PFNGLSCISSORINDEXEDOESPROC glad_glScissorIndexedOES = NULL;
3654PFNGLSCISSORINDEXEDVOESPROC glad_glScissorIndexedvOES = NULL;
3655PFNGLSEMAPHOREPARAMETERUI64VEXTPROC glad_glSemaphoreParameterui64vEXT = NULL;
3656PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL;
3657PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
3658PFNGLSHADINGRATECOMBINEROPSEXTPROC glad_glShadingRateCombinerOpsEXT = NULL;
3659PFNGLSHADINGRATEEXTPROC glad_glShadingRateEXT = NULL;
3660PFNGLSIGNALSEMAPHOREEXTPROC glad_glSignalSemaphoreEXT = NULL;
3661PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
3662PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
3663PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
3664PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
3665PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
3666PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
3667PFNGLTEXBUFFEREXTPROC glad_glTexBufferEXT = NULL;
3668PFNGLTEXBUFFEROESPROC glad_glTexBufferOES = NULL;
3669PFNGLTEXBUFFERRANGEEXTPROC glad_glTexBufferRangeEXT = NULL;
3670PFNGLTEXBUFFERRANGEOESPROC glad_glTexBufferRangeOES = NULL;
3671PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
3672PFNGLTEXIMAGE3DOESPROC glad_glTexImage3DOES = NULL;
3673PFNGLTEXPAGECOMMITMENTEXTPROC glad_glTexPageCommitmentEXT = NULL;
3674PFNGLTEXPARAMETERIIVEXTPROC glad_glTexParameterIivEXT = NULL;
3675PFNGLTEXPARAMETERIIVOESPROC glad_glTexParameterIivOES = NULL;
3676PFNGLTEXPARAMETERIUIVEXTPROC glad_glTexParameterIuivEXT = NULL;
3677PFNGLTEXPARAMETERIUIVOESPROC glad_glTexParameterIuivOES = NULL;
3678PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
3679PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
3680PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
3681PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
3682PFNGLTEXSTORAGE1DEXTPROC glad_glTexStorage1DEXT = NULL;
3683PFNGLTEXSTORAGE2DEXTPROC glad_glTexStorage2DEXT = NULL;
3684PFNGLTEXSTORAGE3DEXTPROC glad_glTexStorage3DEXT = NULL;
3685PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC glad_glTexStorage3DMultisampleOES = NULL;
3686PFNGLTEXSTORAGEATTRIBS2DEXTPROC glad_glTexStorageAttribs2DEXT = NULL;
3687PFNGLTEXSTORAGEATTRIBS3DEXTPROC glad_glTexStorageAttribs3DEXT = NULL;
3688PFNGLTEXSTORAGEMEM2DEXTPROC glad_glTexStorageMem2DEXT = NULL;
3689PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTexStorageMem2DMultisampleEXT = NULL;
3690PFNGLTEXSTORAGEMEM3DEXTPROC glad_glTexStorageMem3DEXT = NULL;
3691PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTexStorageMem3DMultisampleEXT = NULL;
3692PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
3693PFNGLTEXSUBIMAGE3DOESPROC glad_glTexSubImage3DOES = NULL;
3694PFNGLTEXTURESTORAGE1DEXTPROC glad_glTextureStorage1DEXT = NULL;
3695PFNGLTEXTURESTORAGE2DEXTPROC glad_glTextureStorage2DEXT = NULL;
3696PFNGLTEXTURESTORAGE3DEXTPROC glad_glTextureStorage3DEXT = NULL;
3697PFNGLTEXTURESTORAGEMEM2DEXTPROC glad_glTextureStorageMem2DEXT = NULL;
3698PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTextureStorageMem2DMultisampleEXT = NULL;
3699PFNGLTEXTURESTORAGEMEM3DEXTPROC glad_glTextureStorageMem3DEXT = NULL;
3700PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTextureStorageMem3DMultisampleEXT = NULL;
3701PFNGLTEXTUREVIEWEXTPROC glad_glTextureViewEXT = NULL;
3702PFNGLTEXTUREVIEWOESPROC glad_glTextureViewOES = NULL;
3703PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
3704PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
3705PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
3706PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
3707PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
3708PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
3709PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
3710PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
3711PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
3712PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
3713PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
3714PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
3715PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
3716PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
3717PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
3718PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
3719PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
3720PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
3721PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
3722PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES = NULL;
3723PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
3724PFNGLUSEPROGRAMSTAGESEXTPROC glad_glUseProgramStagesEXT = NULL;
3725PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
3726PFNGLVALIDATEPROGRAMPIPELINEEXTPROC glad_glValidateProgramPipelineEXT = NULL;
3727PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
3728PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
3729PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
3730PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
3731PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
3732PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
3733PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
3734PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
3735PFNGLVERTEXATTRIBDIVISOREXTPROC glad_glVertexAttribDivisorEXT = NULL;
3736PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
3737PFNGLVIEWPORTPROC glad_glViewport = NULL;
3738PFNGLVIEWPORTARRAYVOESPROC glad_glViewportArrayvOES = NULL;
3739PFNGLVIEWPORTINDEXEDFOESPROC glad_glViewportIndexedfOES = NULL;
3740PFNGLVIEWPORTINDEXEDFVOESPROC glad_glViewportIndexedfvOES = NULL;
3741PFNGLWAITSEMAPHOREEXTPROC glad_glWaitSemaphoreEXT = NULL;
3742PFNGLWINDOWRECTANGLESEXTPROC glad_glWindowRectanglesEXT = NULL;
3743
3744
3745static void glad_gl_load_GL_ES_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
3746 if(!GLAD_GL_ES_VERSION_2_0) return;
3747 glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
3748 glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader");
3749 glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation");
3750 glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
3751 glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
3752 glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
3753 glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
3754 glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor");
3755 glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation");
3756 glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate");
3757 glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
3758 glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate");
3759 glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
3760 glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
3761 glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
3762 glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
3763 glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
3764 glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
3765 glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
3766 glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
3767 glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader");
3768 glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
3769 glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
3770 glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
3771 glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
3772 glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram");
3773 glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader");
3774 glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
3775 glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
3776 glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
3777 glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram");
3778 glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
3779 glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader");
3780 glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
3781 glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
3782 glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
3783 glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef");
3784 glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader");
3785 glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
3786 glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray");
3787 glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
3788 glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
3789 glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
3790 glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray");
3791 glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
3792 glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
3793 glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
3794 glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
3795 glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
3796 glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
3797 glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
3798 glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
3799 glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
3800 glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
3801 glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib");
3802 glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform");
3803 glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders");
3804 glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation");
3805 glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
3806 glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
3807 glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
3808 glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
3809 glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
3810 glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
3811 glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog");
3812 glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv");
3813 glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
3814 glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog");
3815 glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat");
3816 glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource");
3817 glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv");
3818 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
3819 glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
3820 glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
3821 glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation");
3822 glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv");
3823 glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv");
3824 glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv");
3825 glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv");
3826 glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv");
3827 glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
3828 glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
3829 glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
3830 glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
3831 glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram");
3832 glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
3833 glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader");
3834 glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
3835 glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
3836 glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram");
3837 glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
3838 glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
3839 glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
3840 glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler");
3841 glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
3842 glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
3843 glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
3844 glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary");
3845 glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource");
3846 glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
3847 glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate");
3848 glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
3849 glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate");
3850 glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
3851 glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate");
3852 glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
3853 glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
3854 glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
3855 glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
3856 glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
3857 glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
3858 glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f");
3859 glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv");
3860 glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i");
3861 glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv");
3862 glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f");
3863 glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv");
3864 glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i");
3865 glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv");
3866 glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f");
3867 glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv");
3868 glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i");
3869 glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv");
3870 glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f");
3871 glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv");
3872 glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i");
3873 glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv");
3874 glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv");
3875 glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv");
3876 glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv");
3877 glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram");
3878 glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram");
3879 glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f");
3880 glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv");
3881 glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f");
3882 glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv");
3883 glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f");
3884 glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv");
3885 glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f");
3886 glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv");
3887 glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer");
3888 glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
3889}
3890static void glad_gl_load_GL_EXT_EGL_image_storage( GLADuserptrloadfunc load, void* userptr) {
3891 if(!GLAD_GL_EXT_EGL_image_storage) return;
3892 glad_glEGLImageTargetTexStorageEXT = (PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) load(userptr, "glEGLImageTargetTexStorageEXT");
3893 glad_glEGLImageTargetTextureStorageEXT = (PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) load(userptr, "glEGLImageTargetTextureStorageEXT");
3894}
3895static void glad_gl_load_GL_EXT_base_instance( GLADuserptrloadfunc load, void* userptr) {
3896 if(!GLAD_GL_EXT_base_instance) return;
3897 glad_glDrawArraysInstancedBaseInstanceEXT = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) load(userptr, "glDrawArraysInstancedBaseInstanceEXT");
3898 glad_glDrawElementsInstancedBaseInstanceEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) load(userptr, "glDrawElementsInstancedBaseInstanceEXT");
3899 glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) load(userptr, "glDrawElementsInstancedBaseVertexBaseInstanceEXT");
3900}
3901static void glad_gl_load_GL_EXT_blend_func_extended( GLADuserptrloadfunc load, void* userptr) {
3902 if(!GLAD_GL_EXT_blend_func_extended) return;
3903 glad_glBindFragDataLocationEXT = (PFNGLBINDFRAGDATALOCATIONEXTPROC) load(userptr, "glBindFragDataLocationEXT");
3904 glad_glBindFragDataLocationIndexedEXT = (PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) load(userptr, "glBindFragDataLocationIndexedEXT");
3905 glad_glGetFragDataIndexEXT = (PFNGLGETFRAGDATAINDEXEXTPROC) load(userptr, "glGetFragDataIndexEXT");
3906 glad_glGetProgramResourceLocationIndexEXT = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) load(userptr, "glGetProgramResourceLocationIndexEXT");
3907}
3908static void glad_gl_load_GL_EXT_buffer_storage( GLADuserptrloadfunc load, void* userptr) {
3909 if(!GLAD_GL_EXT_buffer_storage) return;
3910 glad_glBufferStorageEXT = (PFNGLBUFFERSTORAGEEXTPROC) load(userptr, "glBufferStorageEXT");
3911}
3912static void glad_gl_load_GL_EXT_clear_texture( GLADuserptrloadfunc load, void* userptr) {
3913 if(!GLAD_GL_EXT_clear_texture) return;
3914 glad_glClearTexImageEXT = (PFNGLCLEARTEXIMAGEEXTPROC) load(userptr, "glClearTexImageEXT");
3915 glad_glClearTexSubImageEXT = (PFNGLCLEARTEXSUBIMAGEEXTPROC) load(userptr, "glClearTexSubImageEXT");
3916}
3917static void glad_gl_load_GL_EXT_clip_control( GLADuserptrloadfunc load, void* userptr) {
3918 if(!GLAD_GL_EXT_clip_control) return;
3919 glad_glClipControlEXT = (PFNGLCLIPCONTROLEXTPROC) load(userptr, "glClipControlEXT");
3920}
3921static void glad_gl_load_GL_EXT_copy_image( GLADuserptrloadfunc load, void* userptr) {
3922 if(!GLAD_GL_EXT_copy_image) return;
3923 glad_glCopyImageSubDataEXT = (PFNGLCOPYIMAGESUBDATAEXTPROC) load(userptr, "glCopyImageSubDataEXT");
3924}
3925static void glad_gl_load_GL_EXT_debug_label( GLADuserptrloadfunc load, void* userptr) {
3926 if(!GLAD_GL_EXT_debug_label) return;
3927 glad_glGetObjectLabelEXT = (PFNGLGETOBJECTLABELEXTPROC) load(userptr, "glGetObjectLabelEXT");
3928 glad_glLabelObjectEXT = (PFNGLLABELOBJECTEXTPROC) load(userptr, "glLabelObjectEXT");
3929}
3930static void glad_gl_load_GL_EXT_debug_marker( GLADuserptrloadfunc load, void* userptr) {
3931 if(!GLAD_GL_EXT_debug_marker) return;
3932 glad_glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC) load(userptr, "glInsertEventMarkerEXT");
3933 glad_glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC) load(userptr, "glPopGroupMarkerEXT");
3934 glad_glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC) load(userptr, "glPushGroupMarkerEXT");
3935}
3936static void glad_gl_load_GL_EXT_discard_framebuffer( GLADuserptrloadfunc load, void* userptr) {
3937 if(!GLAD_GL_EXT_discard_framebuffer) return;
3938 glad_glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC) load(userptr, "glDiscardFramebufferEXT");
3939}
3940static void glad_gl_load_GL_EXT_disjoint_timer_query( GLADuserptrloadfunc load, void* userptr) {
3941 if(!GLAD_GL_EXT_disjoint_timer_query) return;
3942 glad_glBeginQueryEXT = (PFNGLBEGINQUERYEXTPROC) load(userptr, "glBeginQueryEXT");
3943 glad_glDeleteQueriesEXT = (PFNGLDELETEQUERIESEXTPROC) load(userptr, "glDeleteQueriesEXT");
3944 glad_glEndQueryEXT = (PFNGLENDQUERYEXTPROC) load(userptr, "glEndQueryEXT");
3945 glad_glGenQueriesEXT = (PFNGLGENQUERIESEXTPROC) load(userptr, "glGenQueriesEXT");
3946 glad_glGetInteger64vEXT = (PFNGLGETINTEGER64VEXTPROC) load(userptr, "glGetInteger64vEXT");
3947 glad_glGetQueryObjecti64vEXT = (PFNGLGETQUERYOBJECTI64VEXTPROC) load(userptr, "glGetQueryObjecti64vEXT");
3948 glad_glGetQueryObjectivEXT = (PFNGLGETQUERYOBJECTIVEXTPROC) load(userptr, "glGetQueryObjectivEXT");
3949 glad_glGetQueryObjectui64vEXT = (PFNGLGETQUERYOBJECTUI64VEXTPROC) load(userptr, "glGetQueryObjectui64vEXT");
3950 glad_glGetQueryObjectuivEXT = (PFNGLGETQUERYOBJECTUIVEXTPROC) load(userptr, "glGetQueryObjectuivEXT");
3951 glad_glGetQueryivEXT = (PFNGLGETQUERYIVEXTPROC) load(userptr, "glGetQueryivEXT");
3952 glad_glIsQueryEXT = (PFNGLISQUERYEXTPROC) load(userptr, "glIsQueryEXT");
3953 glad_glQueryCounterEXT = (PFNGLQUERYCOUNTEREXTPROC) load(userptr, "glQueryCounterEXT");
3954}
3955static void glad_gl_load_GL_EXT_draw_buffers( GLADuserptrloadfunc load, void* userptr) {
3956 if(!GLAD_GL_EXT_draw_buffers) return;
3957 glad_glDrawBuffersEXT = (PFNGLDRAWBUFFERSEXTPROC) load(userptr, "glDrawBuffersEXT");
3958}
3959static void glad_gl_load_GL_EXT_draw_buffers_indexed( GLADuserptrloadfunc load, void* userptr) {
3960 if(!GLAD_GL_EXT_draw_buffers_indexed) return;
3961 glad_glBlendEquationSeparateiEXT = (PFNGLBLENDEQUATIONSEPARATEIEXTPROC) load(userptr, "glBlendEquationSeparateiEXT");
3962 glad_glBlendEquationiEXT = (PFNGLBLENDEQUATIONIEXTPROC) load(userptr, "glBlendEquationiEXT");
3963 glad_glBlendFuncSeparateiEXT = (PFNGLBLENDFUNCSEPARATEIEXTPROC) load(userptr, "glBlendFuncSeparateiEXT");
3964 glad_glBlendFunciEXT = (PFNGLBLENDFUNCIEXTPROC) load(userptr, "glBlendFunciEXT");
3965 glad_glColorMaskiEXT = (PFNGLCOLORMASKIEXTPROC) load(userptr, "glColorMaskiEXT");
3966 glad_glDisableiEXT = (PFNGLDISABLEIEXTPROC) load(userptr, "glDisableiEXT");
3967 glad_glEnableiEXT = (PFNGLENABLEIEXTPROC) load(userptr, "glEnableiEXT");
3968 glad_glIsEnablediEXT = (PFNGLISENABLEDIEXTPROC) load(userptr, "glIsEnablediEXT");
3969}
3970static void glad_gl_load_GL_EXT_draw_elements_base_vertex( GLADuserptrloadfunc load, void* userptr) {
3971 if(!GLAD_GL_EXT_draw_elements_base_vertex) return;
3972 glad_glDrawElementsBaseVertexEXT = (PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glDrawElementsBaseVertexEXT");
3973 glad_glDrawElementsInstancedBaseVertexEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) load(userptr, "glDrawElementsInstancedBaseVertexEXT");
3974 glad_glDrawRangeElementsBaseVertexEXT = (PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) load(userptr, "glDrawRangeElementsBaseVertexEXT");
3975 glad_glMultiDrawElementsBaseVertexEXT = (PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glMultiDrawElementsBaseVertexEXT");
3976}
3977static void glad_gl_load_GL_EXT_draw_instanced( GLADuserptrloadfunc load, void* userptr) {
3978 if(!GLAD_GL_EXT_draw_instanced) return;
3979 glad_glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC) load(userptr, "glDrawArraysInstancedEXT");
3980 glad_glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) load(userptr, "glDrawElementsInstancedEXT");
3981}
3982static void glad_gl_load_GL_EXT_draw_transform_feedback( GLADuserptrloadfunc load, void* userptr) {
3983 if(!GLAD_GL_EXT_draw_transform_feedback) return;
3984 glad_glDrawTransformFeedbackEXT = (PFNGLDRAWTRANSFORMFEEDBACKEXTPROC) load(userptr, "glDrawTransformFeedbackEXT");
3985 glad_glDrawTransformFeedbackInstancedEXT = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC) load(userptr, "glDrawTransformFeedbackInstancedEXT");
3986}
3987static void glad_gl_load_GL_EXT_external_buffer( GLADuserptrloadfunc load, void* userptr) {
3988 if(!GLAD_GL_EXT_external_buffer) return;
3989 glad_glBufferStorageExternalEXT = (PFNGLBUFFERSTORAGEEXTERNALEXTPROC) load(userptr, "glBufferStorageExternalEXT");
3990 glad_glNamedBufferStorageExternalEXT = (PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) load(userptr, "glNamedBufferStorageExternalEXT");
3991}
3992static void glad_gl_load_GL_EXT_fragment_shading_rate( GLADuserptrloadfunc load, void* userptr) {
3993 if(!GLAD_GL_EXT_fragment_shading_rate) return;
3994 glad_glFramebufferShadingRateEXT = (PFNGLFRAMEBUFFERSHADINGRATEEXTPROC) load(userptr, "glFramebufferShadingRateEXT");
3995 glad_glGetFragmentShadingRatesEXT = (PFNGLGETFRAGMENTSHADINGRATESEXTPROC) load(userptr, "glGetFragmentShadingRatesEXT");
3996 glad_glShadingRateCombinerOpsEXT = (PFNGLSHADINGRATECOMBINEROPSEXTPROC) load(userptr, "glShadingRateCombinerOpsEXT");
3997 glad_glShadingRateEXT = (PFNGLSHADINGRATEEXTPROC) load(userptr, "glShadingRateEXT");
3998}
3999static void glad_gl_load_GL_EXT_geometry_shader( GLADuserptrloadfunc load, void* userptr) {
4000 if(!GLAD_GL_EXT_geometry_shader) return;
4001 glad_glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTUREEXTPROC) load(userptr, "glFramebufferTextureEXT");
4002}
4003static void glad_gl_load_GL_EXT_instanced_arrays( GLADuserptrloadfunc load, void* userptr) {
4004 if(!GLAD_GL_EXT_instanced_arrays) return;
4005 glad_glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC) load(userptr, "glDrawArraysInstancedEXT");
4006 glad_glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) load(userptr, "glDrawElementsInstancedEXT");
4007 glad_glVertexAttribDivisorEXT = (PFNGLVERTEXATTRIBDIVISOREXTPROC) load(userptr, "glVertexAttribDivisorEXT");
4008}
4009static void glad_gl_load_GL_EXT_map_buffer_range( GLADuserptrloadfunc load, void* userptr) {
4010 if(!GLAD_GL_EXT_map_buffer_range) return;
4011 glad_glFlushMappedBufferRangeEXT = (PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) load(userptr, "glFlushMappedBufferRangeEXT");
4012 glad_glMapBufferRangeEXT = (PFNGLMAPBUFFERRANGEEXTPROC) load(userptr, "glMapBufferRangeEXT");
4013}
4014static void glad_gl_load_GL_EXT_memory_object( GLADuserptrloadfunc load, void* userptr) {
4015 if(!GLAD_GL_EXT_memory_object) return;
4016 glad_glBufferStorageMemEXT = (PFNGLBUFFERSTORAGEMEMEXTPROC) load(userptr, "glBufferStorageMemEXT");
4017 glad_glCreateMemoryObjectsEXT = (PFNGLCREATEMEMORYOBJECTSEXTPROC) load(userptr, "glCreateMemoryObjectsEXT");
4018 glad_glDeleteMemoryObjectsEXT = (PFNGLDELETEMEMORYOBJECTSEXTPROC) load(userptr, "glDeleteMemoryObjectsEXT");
4019 glad_glGetMemoryObjectParameterivEXT = (PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) load(userptr, "glGetMemoryObjectParameterivEXT");
4020 glad_glGetUnsignedBytei_vEXT = (PFNGLGETUNSIGNEDBYTEI_VEXTPROC) load(userptr, "glGetUnsignedBytei_vEXT");
4021 glad_glGetUnsignedBytevEXT = (PFNGLGETUNSIGNEDBYTEVEXTPROC) load(userptr, "glGetUnsignedBytevEXT");
4022 glad_glIsMemoryObjectEXT = (PFNGLISMEMORYOBJECTEXTPROC) load(userptr, "glIsMemoryObjectEXT");
4023 glad_glMemoryObjectParameterivEXT = (PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) load(userptr, "glMemoryObjectParameterivEXT");
4024 glad_glNamedBufferStorageMemEXT = (PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) load(userptr, "glNamedBufferStorageMemEXT");
4025 glad_glTexStorageMem2DEXT = (PFNGLTEXSTORAGEMEM2DEXTPROC) load(userptr, "glTexStorageMem2DEXT");
4026 glad_glTexStorageMem2DMultisampleEXT = (PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) load(userptr, "glTexStorageMem2DMultisampleEXT");
4027 glad_glTexStorageMem3DEXT = (PFNGLTEXSTORAGEMEM3DEXTPROC) load(userptr, "glTexStorageMem3DEXT");
4028 glad_glTexStorageMem3DMultisampleEXT = (PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) load(userptr, "glTexStorageMem3DMultisampleEXT");
4029 glad_glTextureStorageMem2DEXT = (PFNGLTEXTURESTORAGEMEM2DEXTPROC) load(userptr, "glTextureStorageMem2DEXT");
4030 glad_glTextureStorageMem2DMultisampleEXT = (PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) load(userptr, "glTextureStorageMem2DMultisampleEXT");
4031 glad_glTextureStorageMem3DEXT = (PFNGLTEXTURESTORAGEMEM3DEXTPROC) load(userptr, "glTextureStorageMem3DEXT");
4032 glad_glTextureStorageMem3DMultisampleEXT = (PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) load(userptr, "glTextureStorageMem3DMultisampleEXT");
4033}
4034static void glad_gl_load_GL_EXT_memory_object_fd( GLADuserptrloadfunc load, void* userptr) {
4035 if(!GLAD_GL_EXT_memory_object_fd) return;
4036 glad_glImportMemoryFdEXT = (PFNGLIMPORTMEMORYFDEXTPROC) load(userptr, "glImportMemoryFdEXT");
4037}
4038static void glad_gl_load_GL_EXT_memory_object_win32( GLADuserptrloadfunc load, void* userptr) {
4039 if(!GLAD_GL_EXT_memory_object_win32) return;
4040 glad_glImportMemoryWin32HandleEXT = (PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) load(userptr, "glImportMemoryWin32HandleEXT");
4041 glad_glImportMemoryWin32NameEXT = (PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) load(userptr, "glImportMemoryWin32NameEXT");
4042}
4043static void glad_gl_load_GL_EXT_multi_draw_arrays( GLADuserptrloadfunc load, void* userptr) {
4044 if(!GLAD_GL_EXT_multi_draw_arrays) return;
4045 glad_glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) load(userptr, "glMultiDrawArraysEXT");
4046 glad_glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) load(userptr, "glMultiDrawElementsEXT");
4047}
4048static void glad_gl_load_GL_EXT_multi_draw_indirect( GLADuserptrloadfunc load, void* userptr) {
4049 if(!GLAD_GL_EXT_multi_draw_indirect) return;
4050 glad_glMultiDrawArraysIndirectEXT = (PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) load(userptr, "glMultiDrawArraysIndirectEXT");
4051 glad_glMultiDrawElementsIndirectEXT = (PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) load(userptr, "glMultiDrawElementsIndirectEXT");
4052}
4053static void glad_gl_load_GL_EXT_multisampled_render_to_texture( GLADuserptrloadfunc load, void* userptr) {
4054 if(!GLAD_GL_EXT_multisampled_render_to_texture) return;
4055 glad_glFramebufferTexture2DMultisampleEXT = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) load(userptr, "glFramebufferTexture2DMultisampleEXT");
4056 glad_glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) load(userptr, "glRenderbufferStorageMultisampleEXT");
4057}
4058static void glad_gl_load_GL_EXT_multiview_draw_buffers( GLADuserptrloadfunc load, void* userptr) {
4059 if(!GLAD_GL_EXT_multiview_draw_buffers) return;
4060 glad_glDrawBuffersIndexedEXT = (PFNGLDRAWBUFFERSINDEXEDEXTPROC) load(userptr, "glDrawBuffersIndexedEXT");
4061 glad_glGetIntegeri_vEXT = (PFNGLGETINTEGERI_VEXTPROC) load(userptr, "glGetIntegeri_vEXT");
4062 glad_glReadBufferIndexedEXT = (PFNGLREADBUFFERINDEXEDEXTPROC) load(userptr, "glReadBufferIndexedEXT");
4063}
4064static void glad_gl_load_GL_EXT_occlusion_query_boolean( GLADuserptrloadfunc load, void* userptr) {
4065 if(!GLAD_GL_EXT_occlusion_query_boolean) return;
4066 glad_glBeginQueryEXT = (PFNGLBEGINQUERYEXTPROC) load(userptr, "glBeginQueryEXT");
4067 glad_glDeleteQueriesEXT = (PFNGLDELETEQUERIESEXTPROC) load(userptr, "glDeleteQueriesEXT");
4068 glad_glEndQueryEXT = (PFNGLENDQUERYEXTPROC) load(userptr, "glEndQueryEXT");
4069 glad_glGenQueriesEXT = (PFNGLGENQUERIESEXTPROC) load(userptr, "glGenQueriesEXT");
4070 glad_glGetQueryObjectuivEXT = (PFNGLGETQUERYOBJECTUIVEXTPROC) load(userptr, "glGetQueryObjectuivEXT");
4071 glad_glGetQueryivEXT = (PFNGLGETQUERYIVEXTPROC) load(userptr, "glGetQueryivEXT");
4072 glad_glIsQueryEXT = (PFNGLISQUERYEXTPROC) load(userptr, "glIsQueryEXT");
4073}
4074static void glad_gl_load_GL_EXT_polygon_offset_clamp( GLADuserptrloadfunc load, void* userptr) {
4075 if(!GLAD_GL_EXT_polygon_offset_clamp) return;
4076 glad_glPolygonOffsetClampEXT = (PFNGLPOLYGONOFFSETCLAMPEXTPROC) load(userptr, "glPolygonOffsetClampEXT");
4077}
4078static void glad_gl_load_GL_EXT_primitive_bounding_box( GLADuserptrloadfunc load, void* userptr) {
4079 if(!GLAD_GL_EXT_primitive_bounding_box) return;
4080 glad_glPrimitiveBoundingBoxEXT = (PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) load(userptr, "glPrimitiveBoundingBoxEXT");
4081}
4082static void glad_gl_load_GL_EXT_raster_multisample( GLADuserptrloadfunc load, void* userptr) {
4083 if(!GLAD_GL_EXT_raster_multisample) return;
4084 glad_glRasterSamplesEXT = (PFNGLRASTERSAMPLESEXTPROC) load(userptr, "glRasterSamplesEXT");
4085}
4086static void glad_gl_load_GL_EXT_robustness( GLADuserptrloadfunc load, void* userptr) {
4087 if(!GLAD_GL_EXT_robustness) return;
4088 glad_glGetGraphicsResetStatusEXT = (PFNGLGETGRAPHICSRESETSTATUSEXTPROC) load(userptr, "glGetGraphicsResetStatusEXT");
4089 glad_glGetnUniformfvEXT = (PFNGLGETNUNIFORMFVEXTPROC) load(userptr, "glGetnUniformfvEXT");
4090 glad_glGetnUniformivEXT = (PFNGLGETNUNIFORMIVEXTPROC) load(userptr, "glGetnUniformivEXT");
4091 glad_glReadnPixelsEXT = (PFNGLREADNPIXELSEXTPROC) load(userptr, "glReadnPixelsEXT");
4092}
4093static void glad_gl_load_GL_EXT_semaphore( GLADuserptrloadfunc load, void* userptr) {
4094 if(!GLAD_GL_EXT_semaphore) return;
4095 glad_glDeleteSemaphoresEXT = (PFNGLDELETESEMAPHORESEXTPROC) load(userptr, "glDeleteSemaphoresEXT");
4096 glad_glGenSemaphoresEXT = (PFNGLGENSEMAPHORESEXTPROC) load(userptr, "glGenSemaphoresEXT");
4097 glad_glGetSemaphoreParameterui64vEXT = (PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) load(userptr, "glGetSemaphoreParameterui64vEXT");
4098 glad_glGetUnsignedBytei_vEXT = (PFNGLGETUNSIGNEDBYTEI_VEXTPROC) load(userptr, "glGetUnsignedBytei_vEXT");
4099 glad_glGetUnsignedBytevEXT = (PFNGLGETUNSIGNEDBYTEVEXTPROC) load(userptr, "glGetUnsignedBytevEXT");
4100 glad_glIsSemaphoreEXT = (PFNGLISSEMAPHOREEXTPROC) load(userptr, "glIsSemaphoreEXT");
4101 glad_glSemaphoreParameterui64vEXT = (PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) load(userptr, "glSemaphoreParameterui64vEXT");
4102 glad_glSignalSemaphoreEXT = (PFNGLSIGNALSEMAPHOREEXTPROC) load(userptr, "glSignalSemaphoreEXT");
4103 glad_glWaitSemaphoreEXT = (PFNGLWAITSEMAPHOREEXTPROC) load(userptr, "glWaitSemaphoreEXT");
4104}
4105static void glad_gl_load_GL_EXT_semaphore_fd( GLADuserptrloadfunc load, void* userptr) {
4106 if(!GLAD_GL_EXT_semaphore_fd) return;
4107 glad_glImportSemaphoreFdEXT = (PFNGLIMPORTSEMAPHOREFDEXTPROC) load(userptr, "glImportSemaphoreFdEXT");
4108}
4109static void glad_gl_load_GL_EXT_semaphore_win32( GLADuserptrloadfunc load, void* userptr) {
4110 if(!GLAD_GL_EXT_semaphore_win32) return;
4111 glad_glImportSemaphoreWin32HandleEXT = (PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) load(userptr, "glImportSemaphoreWin32HandleEXT");
4112 glad_glImportSemaphoreWin32NameEXT = (PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) load(userptr, "glImportSemaphoreWin32NameEXT");
4113}
4114static void glad_gl_load_GL_EXT_separate_shader_objects( GLADuserptrloadfunc load, void* userptr) {
4115 if(!GLAD_GL_EXT_separate_shader_objects) return;
4116 glad_glActiveShaderProgramEXT = (PFNGLACTIVESHADERPROGRAMEXTPROC) load(userptr, "glActiveShaderProgramEXT");
4117 glad_glBindProgramPipelineEXT = (PFNGLBINDPROGRAMPIPELINEEXTPROC) load(userptr, "glBindProgramPipelineEXT");
4118 glad_glCreateShaderProgramvEXT = (PFNGLCREATESHADERPROGRAMVEXTPROC) load(userptr, "glCreateShaderProgramvEXT");
4119 glad_glDeleteProgramPipelinesEXT = (PFNGLDELETEPROGRAMPIPELINESEXTPROC) load(userptr, "glDeleteProgramPipelinesEXT");
4120 glad_glGenProgramPipelinesEXT = (PFNGLGENPROGRAMPIPELINESEXTPROC) load(userptr, "glGenProgramPipelinesEXT");
4121 glad_glGetProgramPipelineInfoLogEXT = (PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) load(userptr, "glGetProgramPipelineInfoLogEXT");
4122 glad_glGetProgramPipelineivEXT = (PFNGLGETPROGRAMPIPELINEIVEXTPROC) load(userptr, "glGetProgramPipelineivEXT");
4123 glad_glIsProgramPipelineEXT = (PFNGLISPROGRAMPIPELINEEXTPROC) load(userptr, "glIsProgramPipelineEXT");
4124 glad_glProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC) load(userptr, "glProgramParameteriEXT");
4125 glad_glProgramUniform1fEXT = (PFNGLPROGRAMUNIFORM1FEXTPROC) load(userptr, "glProgramUniform1fEXT");
4126 glad_glProgramUniform1fvEXT = (PFNGLPROGRAMUNIFORM1FVEXTPROC) load(userptr, "glProgramUniform1fvEXT");
4127 glad_glProgramUniform1iEXT = (PFNGLPROGRAMUNIFORM1IEXTPROC) load(userptr, "glProgramUniform1iEXT");
4128 glad_glProgramUniform1ivEXT = (PFNGLPROGRAMUNIFORM1IVEXTPROC) load(userptr, "glProgramUniform1ivEXT");
4129 glad_glProgramUniform1uiEXT = (PFNGLPROGRAMUNIFORM1UIEXTPROC) load(userptr, "glProgramUniform1uiEXT");
4130 glad_glProgramUniform1uivEXT = (PFNGLPROGRAMUNIFORM1UIVEXTPROC) load(userptr, "glProgramUniform1uivEXT");
4131 glad_glProgramUniform2fEXT = (PFNGLPROGRAMUNIFORM2FEXTPROC) load(userptr, "glProgramUniform2fEXT");
4132 glad_glProgramUniform2fvEXT = (PFNGLPROGRAMUNIFORM2FVEXTPROC) load(userptr, "glProgramUniform2fvEXT");
4133 glad_glProgramUniform2iEXT = (PFNGLPROGRAMUNIFORM2IEXTPROC) load(userptr, "glProgramUniform2iEXT");
4134 glad_glProgramUniform2ivEXT = (PFNGLPROGRAMUNIFORM2IVEXTPROC) load(userptr, "glProgramUniform2ivEXT");
4135 glad_glProgramUniform2uiEXT = (PFNGLPROGRAMUNIFORM2UIEXTPROC) load(userptr, "glProgramUniform2uiEXT");
4136 glad_glProgramUniform2uivEXT = (PFNGLPROGRAMUNIFORM2UIVEXTPROC) load(userptr, "glProgramUniform2uivEXT");
4137 glad_glProgramUniform3fEXT = (PFNGLPROGRAMUNIFORM3FEXTPROC) load(userptr, "glProgramUniform3fEXT");
4138 glad_glProgramUniform3fvEXT = (PFNGLPROGRAMUNIFORM3FVEXTPROC) load(userptr, "glProgramUniform3fvEXT");
4139 glad_glProgramUniform3iEXT = (PFNGLPROGRAMUNIFORM3IEXTPROC) load(userptr, "glProgramUniform3iEXT");
4140 glad_glProgramUniform3ivEXT = (PFNGLPROGRAMUNIFORM3IVEXTPROC) load(userptr, "glProgramUniform3ivEXT");
4141 glad_glProgramUniform3uiEXT = (PFNGLPROGRAMUNIFORM3UIEXTPROC) load(userptr, "glProgramUniform3uiEXT");
4142 glad_glProgramUniform3uivEXT = (PFNGLPROGRAMUNIFORM3UIVEXTPROC) load(userptr, "glProgramUniform3uivEXT");
4143 glad_glProgramUniform4fEXT = (PFNGLPROGRAMUNIFORM4FEXTPROC) load(userptr, "glProgramUniform4fEXT");
4144 glad_glProgramUniform4fvEXT = (PFNGLPROGRAMUNIFORM4FVEXTPROC) load(userptr, "glProgramUniform4fvEXT");
4145 glad_glProgramUniform4iEXT = (PFNGLPROGRAMUNIFORM4IEXTPROC) load(userptr, "glProgramUniform4iEXT");
4146 glad_glProgramUniform4ivEXT = (PFNGLPROGRAMUNIFORM4IVEXTPROC) load(userptr, "glProgramUniform4ivEXT");
4147 glad_glProgramUniform4uiEXT = (PFNGLPROGRAMUNIFORM4UIEXTPROC) load(userptr, "glProgramUniform4uiEXT");
4148 glad_glProgramUniform4uivEXT = (PFNGLPROGRAMUNIFORM4UIVEXTPROC) load(userptr, "glProgramUniform4uivEXT");
4149 glad_glProgramUniformMatrix2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) load(userptr, "glProgramUniformMatrix2fvEXT");
4150 glad_glProgramUniformMatrix2x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) load(userptr, "glProgramUniformMatrix2x3fvEXT");
4151 glad_glProgramUniformMatrix2x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) load(userptr, "glProgramUniformMatrix2x4fvEXT");
4152 glad_glProgramUniformMatrix3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) load(userptr, "glProgramUniformMatrix3fvEXT");
4153 glad_glProgramUniformMatrix3x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) load(userptr, "glProgramUniformMatrix3x2fvEXT");
4154 glad_glProgramUniformMatrix3x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) load(userptr, "glProgramUniformMatrix3x4fvEXT");
4155 glad_glProgramUniformMatrix4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) load(userptr, "glProgramUniformMatrix4fvEXT");
4156 glad_glProgramUniformMatrix4x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) load(userptr, "glProgramUniformMatrix4x2fvEXT");
4157 glad_glProgramUniformMatrix4x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) load(userptr, "glProgramUniformMatrix4x3fvEXT");
4158 glad_glUseProgramStagesEXT = (PFNGLUSEPROGRAMSTAGESEXTPROC) load(userptr, "glUseProgramStagesEXT");
4159 glad_glValidateProgramPipelineEXT = (PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) load(userptr, "glValidateProgramPipelineEXT");
4160}
4161static void glad_gl_load_GL_EXT_shader_framebuffer_fetch_non_coherent( GLADuserptrloadfunc load, void* userptr) {
4162 if(!GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent) return;
4163 glad_glFramebufferFetchBarrierEXT = (PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) load(userptr, "glFramebufferFetchBarrierEXT");
4164}
4165static void glad_gl_load_GL_EXT_shader_pixel_local_storage2( GLADuserptrloadfunc load, void* userptr) {
4166 if(!GLAD_GL_EXT_shader_pixel_local_storage2) return;
4167 glad_glClearPixelLocalStorageuiEXT = (PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) load(userptr, "glClearPixelLocalStorageuiEXT");
4168 glad_glFramebufferPixelLocalStorageSizeEXT = (PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) load(userptr, "glFramebufferPixelLocalStorageSizeEXT");
4169 glad_glGetFramebufferPixelLocalStorageSizeEXT = (PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) load(userptr, "glGetFramebufferPixelLocalStorageSizeEXT");
4170}
4171static void glad_gl_load_GL_EXT_sparse_texture( GLADuserptrloadfunc load, void* userptr) {
4172 if(!GLAD_GL_EXT_sparse_texture) return;
4173 glad_glTexPageCommitmentEXT = (PFNGLTEXPAGECOMMITMENTEXTPROC) load(userptr, "glTexPageCommitmentEXT");
4174}
4175static void glad_gl_load_GL_EXT_tessellation_shader( GLADuserptrloadfunc load, void* userptr) {
4176 if(!GLAD_GL_EXT_tessellation_shader) return;
4177 glad_glPatchParameteriEXT = (PFNGLPATCHPARAMETERIEXTPROC) load(userptr, "glPatchParameteriEXT");
4178}
4179static void glad_gl_load_GL_EXT_texture_border_clamp( GLADuserptrloadfunc load, void* userptr) {
4180 if(!GLAD_GL_EXT_texture_border_clamp) return;
4181 glad_glGetSamplerParameterIivEXT = (PFNGLGETSAMPLERPARAMETERIIVEXTPROC) load(userptr, "glGetSamplerParameterIivEXT");
4182 glad_glGetSamplerParameterIuivEXT = (PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) load(userptr, "glGetSamplerParameterIuivEXT");
4183 glad_glGetTexParameterIivEXT = (PFNGLGETTEXPARAMETERIIVEXTPROC) load(userptr, "glGetTexParameterIivEXT");
4184 glad_glGetTexParameterIuivEXT = (PFNGLGETTEXPARAMETERIUIVEXTPROC) load(userptr, "glGetTexParameterIuivEXT");
4185 glad_glSamplerParameterIivEXT = (PFNGLSAMPLERPARAMETERIIVEXTPROC) load(userptr, "glSamplerParameterIivEXT");
4186 glad_glSamplerParameterIuivEXT = (PFNGLSAMPLERPARAMETERIUIVEXTPROC) load(userptr, "glSamplerParameterIuivEXT");
4187 glad_glTexParameterIivEXT = (PFNGLTEXPARAMETERIIVEXTPROC) load(userptr, "glTexParameterIivEXT");
4188 glad_glTexParameterIuivEXT = (PFNGLTEXPARAMETERIUIVEXTPROC) load(userptr, "glTexParameterIuivEXT");
4189}
4190static void glad_gl_load_GL_EXT_texture_buffer( GLADuserptrloadfunc load, void* userptr) {
4191 if(!GLAD_GL_EXT_texture_buffer) return;
4192 glad_glTexBufferEXT = (PFNGLTEXBUFFEREXTPROC) load(userptr, "glTexBufferEXT");
4193 glad_glTexBufferRangeEXT = (PFNGLTEXBUFFERRANGEEXTPROC) load(userptr, "glTexBufferRangeEXT");
4194}
4195static void glad_gl_load_GL_EXT_texture_storage( GLADuserptrloadfunc load, void* userptr) {
4196 if(!GLAD_GL_EXT_texture_storage) return;
4197 glad_glTexStorage1DEXT = (PFNGLTEXSTORAGE1DEXTPROC) load(userptr, "glTexStorage1DEXT");
4198 glad_glTexStorage2DEXT = (PFNGLTEXSTORAGE2DEXTPROC) load(userptr, "glTexStorage2DEXT");
4199 glad_glTexStorage3DEXT = (PFNGLTEXSTORAGE3DEXTPROC) load(userptr, "glTexStorage3DEXT");
4200 glad_glTextureStorage1DEXT = (PFNGLTEXTURESTORAGE1DEXTPROC) load(userptr, "glTextureStorage1DEXT");
4201 glad_glTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC) load(userptr, "glTextureStorage2DEXT");
4202 glad_glTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC) load(userptr, "glTextureStorage3DEXT");
4203}
4204static void glad_gl_load_GL_EXT_texture_storage_compression( GLADuserptrloadfunc load, void* userptr) {
4205 if(!GLAD_GL_EXT_texture_storage_compression) return;
4206 glad_glTexStorageAttribs2DEXT = (PFNGLTEXSTORAGEATTRIBS2DEXTPROC) load(userptr, "glTexStorageAttribs2DEXT");
4207 glad_glTexStorageAttribs3DEXT = (PFNGLTEXSTORAGEATTRIBS3DEXTPROC) load(userptr, "glTexStorageAttribs3DEXT");
4208}
4209static void glad_gl_load_GL_EXT_texture_view( GLADuserptrloadfunc load, void* userptr) {
4210 if(!GLAD_GL_EXT_texture_view) return;
4211 glad_glTextureViewEXT = (PFNGLTEXTUREVIEWEXTPROC) load(userptr, "glTextureViewEXT");
4212}
4213static void glad_gl_load_GL_EXT_win32_keyed_mutex( GLADuserptrloadfunc load, void* userptr) {
4214 if(!GLAD_GL_EXT_win32_keyed_mutex) return;
4215 glad_glAcquireKeyedMutexWin32EXT = (PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) load(userptr, "glAcquireKeyedMutexWin32EXT");
4216 glad_glReleaseKeyedMutexWin32EXT = (PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) load(userptr, "glReleaseKeyedMutexWin32EXT");
4217}
4218static void glad_gl_load_GL_EXT_window_rectangles( GLADuserptrloadfunc load, void* userptr) {
4219 if(!GLAD_GL_EXT_window_rectangles) return;
4220 glad_glWindowRectanglesEXT = (PFNGLWINDOWRECTANGLESEXTPROC) load(userptr, "glWindowRectanglesEXT");
4221}
4222static void glad_gl_load_GL_KHR_blend_equation_advanced( GLADuserptrloadfunc load, void* userptr) {
4223 if(!GLAD_GL_KHR_blend_equation_advanced) return;
4224 glad_glBlendBarrierKHR = (PFNGLBLENDBARRIERKHRPROC) load(userptr, "glBlendBarrierKHR");
4225}
4226static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
4227 if(!GLAD_GL_KHR_debug) return;
4228 glad_glDebugMessageCallbackKHR = (PFNGLDEBUGMESSAGECALLBACKKHRPROC) load(userptr, "glDebugMessageCallbackKHR");
4229 glad_glDebugMessageControlKHR = (PFNGLDEBUGMESSAGECONTROLKHRPROC) load(userptr, "glDebugMessageControlKHR");
4230 glad_glDebugMessageInsertKHR = (PFNGLDEBUGMESSAGEINSERTKHRPROC) load(userptr, "glDebugMessageInsertKHR");
4231 glad_glGetDebugMessageLogKHR = (PFNGLGETDEBUGMESSAGELOGKHRPROC) load(userptr, "glGetDebugMessageLogKHR");
4232 glad_glGetObjectLabelKHR = (PFNGLGETOBJECTLABELKHRPROC) load(userptr, "glGetObjectLabelKHR");
4233 glad_glGetObjectPtrLabelKHR = (PFNGLGETOBJECTPTRLABELKHRPROC) load(userptr, "glGetObjectPtrLabelKHR");
4234 glad_glGetPointervKHR = (PFNGLGETPOINTERVKHRPROC) load(userptr, "glGetPointervKHR");
4235 glad_glObjectLabelKHR = (PFNGLOBJECTLABELKHRPROC) load(userptr, "glObjectLabelKHR");
4236 glad_glObjectPtrLabelKHR = (PFNGLOBJECTPTRLABELKHRPROC) load(userptr, "glObjectPtrLabelKHR");
4237 glad_glPopDebugGroupKHR = (PFNGLPOPDEBUGGROUPKHRPROC) load(userptr, "glPopDebugGroupKHR");
4238 glad_glPushDebugGroupKHR = (PFNGLPUSHDEBUGGROUPKHRPROC) load(userptr, "glPushDebugGroupKHR");
4239}
4240static void glad_gl_load_GL_KHR_parallel_shader_compile( GLADuserptrloadfunc load, void* userptr) {
4241 if(!GLAD_GL_KHR_parallel_shader_compile) return;
4242 glad_glMaxShaderCompilerThreadsKHR = (PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) load(userptr, "glMaxShaderCompilerThreadsKHR");
4243}
4244static void glad_gl_load_GL_KHR_robustness( GLADuserptrloadfunc load, void* userptr) {
4245 if(!GLAD_GL_KHR_robustness) return;
4246 glad_glGetGraphicsResetStatusKHR = (PFNGLGETGRAPHICSRESETSTATUSKHRPROC) load(userptr, "glGetGraphicsResetStatusKHR");
4247 glad_glGetnUniformfvKHR = (PFNGLGETNUNIFORMFVKHRPROC) load(userptr, "glGetnUniformfvKHR");
4248 glad_glGetnUniformivKHR = (PFNGLGETNUNIFORMIVKHRPROC) load(userptr, "glGetnUniformivKHR");
4249 glad_glGetnUniformuivKHR = (PFNGLGETNUNIFORMUIVKHRPROC) load(userptr, "glGetnUniformuivKHR");
4250 glad_glReadnPixelsKHR = (PFNGLREADNPIXELSKHRPROC) load(userptr, "glReadnPixelsKHR");
4251}
4252static void glad_gl_load_GL_OES_EGL_image( GLADuserptrloadfunc load, void* userptr) {
4253 if(!GLAD_GL_OES_EGL_image) return;
4254 glad_glEGLImageTargetRenderbufferStorageOES = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) load(userptr, "glEGLImageTargetRenderbufferStorageOES");
4255 glad_glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) load(userptr, "glEGLImageTargetTexture2DOES");
4256}
4257static void glad_gl_load_GL_OES_copy_image( GLADuserptrloadfunc load, void* userptr) {
4258 if(!GLAD_GL_OES_copy_image) return;
4259 glad_glCopyImageSubDataOES = (PFNGLCOPYIMAGESUBDATAOESPROC) load(userptr, "glCopyImageSubDataOES");
4260}
4261static void glad_gl_load_GL_OES_draw_buffers_indexed( GLADuserptrloadfunc load, void* userptr) {
4262 if(!GLAD_GL_OES_draw_buffers_indexed) return;
4263 glad_glBlendEquationSeparateiOES = (PFNGLBLENDEQUATIONSEPARATEIOESPROC) load(userptr, "glBlendEquationSeparateiOES");
4264 glad_glBlendEquationiOES = (PFNGLBLENDEQUATIONIOESPROC) load(userptr, "glBlendEquationiOES");
4265 glad_glBlendFuncSeparateiOES = (PFNGLBLENDFUNCSEPARATEIOESPROC) load(userptr, "glBlendFuncSeparateiOES");
4266 glad_glBlendFunciOES = (PFNGLBLENDFUNCIOESPROC) load(userptr, "glBlendFunciOES");
4267 glad_glColorMaskiOES = (PFNGLCOLORMASKIOESPROC) load(userptr, "glColorMaskiOES");
4268 glad_glDisableiOES = (PFNGLDISABLEIOESPROC) load(userptr, "glDisableiOES");
4269 glad_glEnableiOES = (PFNGLENABLEIOESPROC) load(userptr, "glEnableiOES");
4270 glad_glIsEnablediOES = (PFNGLISENABLEDIOESPROC) load(userptr, "glIsEnablediOES");
4271}
4272static void glad_gl_load_GL_OES_draw_elements_base_vertex( GLADuserptrloadfunc load, void* userptr) {
4273 if(!GLAD_GL_OES_draw_elements_base_vertex) return;
4274 glad_glDrawElementsBaseVertexOES = (PFNGLDRAWELEMENTSBASEVERTEXOESPROC) load(userptr, "glDrawElementsBaseVertexOES");
4275 glad_glDrawElementsInstancedBaseVertexOES = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) load(userptr, "glDrawElementsInstancedBaseVertexOES");
4276 glad_glDrawRangeElementsBaseVertexOES = (PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) load(userptr, "glDrawRangeElementsBaseVertexOES");
4277 glad_glMultiDrawElementsBaseVertexEXT = (PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glMultiDrawElementsBaseVertexEXT");
4278}
4279static void glad_gl_load_GL_OES_geometry_shader( GLADuserptrloadfunc load, void* userptr) {
4280 if(!GLAD_GL_OES_geometry_shader) return;
4281 glad_glFramebufferTextureOES = (PFNGLFRAMEBUFFERTEXTUREOESPROC) load(userptr, "glFramebufferTextureOES");
4282}
4283static void glad_gl_load_GL_OES_get_program_binary( GLADuserptrloadfunc load, void* userptr) {
4284 if(!GLAD_GL_OES_get_program_binary) return;
4285 glad_glGetProgramBinaryOES = (PFNGLGETPROGRAMBINARYOESPROC) load(userptr, "glGetProgramBinaryOES");
4286 glad_glProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC) load(userptr, "glProgramBinaryOES");
4287}
4288static void glad_gl_load_GL_OES_mapbuffer( GLADuserptrloadfunc load, void* userptr) {
4289 if(!GLAD_GL_OES_mapbuffer) return;
4290 glad_glGetBufferPointervOES = (PFNGLGETBUFFERPOINTERVOESPROC) load(userptr, "glGetBufferPointervOES");
4291 glad_glMapBufferOES = (PFNGLMAPBUFFEROESPROC) load(userptr, "glMapBufferOES");
4292 glad_glUnmapBufferOES = (PFNGLUNMAPBUFFEROESPROC) load(userptr, "glUnmapBufferOES");
4293}
4294static void glad_gl_load_GL_OES_primitive_bounding_box( GLADuserptrloadfunc load, void* userptr) {
4295 if(!GLAD_GL_OES_primitive_bounding_box) return;
4296 glad_glPrimitiveBoundingBoxOES = (PFNGLPRIMITIVEBOUNDINGBOXOESPROC) load(userptr, "glPrimitiveBoundingBoxOES");
4297}
4298static void glad_gl_load_GL_OES_sample_shading( GLADuserptrloadfunc load, void* userptr) {
4299 if(!GLAD_GL_OES_sample_shading) return;
4300 glad_glMinSampleShadingOES = (PFNGLMINSAMPLESHADINGOESPROC) load(userptr, "glMinSampleShadingOES");
4301}
4302static void glad_gl_load_GL_OES_tessellation_shader( GLADuserptrloadfunc load, void* userptr) {
4303 if(!GLAD_GL_OES_tessellation_shader) return;
4304 glad_glPatchParameteriOES = (PFNGLPATCHPARAMETERIOESPROC) load(userptr, "glPatchParameteriOES");
4305}
4306static void glad_gl_load_GL_OES_texture_3D( GLADuserptrloadfunc load, void* userptr) {
4307 if(!GLAD_GL_OES_texture_3D) return;
4308 glad_glCompressedTexImage3DOES = (PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) load(userptr, "glCompressedTexImage3DOES");
4309 glad_glCompressedTexSubImage3DOES = (PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) load(userptr, "glCompressedTexSubImage3DOES");
4310 glad_glCopyTexSubImage3DOES = (PFNGLCOPYTEXSUBIMAGE3DOESPROC) load(userptr, "glCopyTexSubImage3DOES");
4311 glad_glFramebufferTexture3DOES = (PFNGLFRAMEBUFFERTEXTURE3DOESPROC) load(userptr, "glFramebufferTexture3DOES");
4312 glad_glTexImage3DOES = (PFNGLTEXIMAGE3DOESPROC) load(userptr, "glTexImage3DOES");
4313 glad_glTexSubImage3DOES = (PFNGLTEXSUBIMAGE3DOESPROC) load(userptr, "glTexSubImage3DOES");
4314}
4315static void glad_gl_load_GL_OES_texture_border_clamp( GLADuserptrloadfunc load, void* userptr) {
4316 if(!GLAD_GL_OES_texture_border_clamp) return;
4317 glad_glGetSamplerParameterIivOES = (PFNGLGETSAMPLERPARAMETERIIVOESPROC) load(userptr, "glGetSamplerParameterIivOES");
4318 glad_glGetSamplerParameterIuivOES = (PFNGLGETSAMPLERPARAMETERIUIVOESPROC) load(userptr, "glGetSamplerParameterIuivOES");
4319 glad_glGetTexParameterIivOES = (PFNGLGETTEXPARAMETERIIVOESPROC) load(userptr, "glGetTexParameterIivOES");
4320 glad_glGetTexParameterIuivOES = (PFNGLGETTEXPARAMETERIUIVOESPROC) load(userptr, "glGetTexParameterIuivOES");
4321 glad_glSamplerParameterIivOES = (PFNGLSAMPLERPARAMETERIIVOESPROC) load(userptr, "glSamplerParameterIivOES");
4322 glad_glSamplerParameterIuivOES = (PFNGLSAMPLERPARAMETERIUIVOESPROC) load(userptr, "glSamplerParameterIuivOES");
4323 glad_glTexParameterIivOES = (PFNGLTEXPARAMETERIIVOESPROC) load(userptr, "glTexParameterIivOES");
4324 glad_glTexParameterIuivOES = (PFNGLTEXPARAMETERIUIVOESPROC) load(userptr, "glTexParameterIuivOES");
4325}
4326static void glad_gl_load_GL_OES_texture_buffer( GLADuserptrloadfunc load, void* userptr) {
4327 if(!GLAD_GL_OES_texture_buffer) return;
4328 glad_glTexBufferOES = (PFNGLTEXBUFFEROESPROC) load(userptr, "glTexBufferOES");
4329 glad_glTexBufferRangeOES = (PFNGLTEXBUFFERRANGEOESPROC) load(userptr, "glTexBufferRangeOES");
4330}
4331static void glad_gl_load_GL_OES_texture_storage_multisample_2d_array( GLADuserptrloadfunc load, void* userptr) {
4332 if(!GLAD_GL_OES_texture_storage_multisample_2d_array) return;
4333 glad_glTexStorage3DMultisampleOES = (PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) load(userptr, "glTexStorage3DMultisampleOES");
4334}
4335static void glad_gl_load_GL_OES_texture_view( GLADuserptrloadfunc load, void* userptr) {
4336 if(!GLAD_GL_OES_texture_view) return;
4337 glad_glTextureViewOES = (PFNGLTEXTUREVIEWOESPROC) load(userptr, "glTextureViewOES");
4338}
4339static void glad_gl_load_GL_OES_vertex_array_object( GLADuserptrloadfunc load, void* userptr) {
4340 if(!GLAD_GL_OES_vertex_array_object) return;
4341 glad_glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC) load(userptr, "glBindVertexArrayOES");
4342 glad_glDeleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOESPROC) load(userptr, "glDeleteVertexArraysOES");
4343 glad_glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC) load(userptr, "glGenVertexArraysOES");
4344 glad_glIsVertexArrayOES = (PFNGLISVERTEXARRAYOESPROC) load(userptr, "glIsVertexArrayOES");
4345}
4346static void glad_gl_load_GL_OES_viewport_array( GLADuserptrloadfunc load, void* userptr) {
4347 if(!GLAD_GL_OES_viewport_array) return;
4348 glad_glDepthRangeArrayfvOES = (PFNGLDEPTHRANGEARRAYFVOESPROC) load(userptr, "glDepthRangeArrayfvOES");
4349 glad_glDepthRangeIndexedfOES = (PFNGLDEPTHRANGEINDEXEDFOESPROC) load(userptr, "glDepthRangeIndexedfOES");
4350 glad_glDisableiOES = (PFNGLDISABLEIOESPROC) load(userptr, "glDisableiOES");
4351 glad_glEnableiOES = (PFNGLENABLEIOESPROC) load(userptr, "glEnableiOES");
4352 glad_glGetFloati_vOES = (PFNGLGETFLOATI_VOESPROC) load(userptr, "glGetFloati_vOES");
4353 glad_glIsEnablediOES = (PFNGLISENABLEDIOESPROC) load(userptr, "glIsEnablediOES");
4354 glad_glScissorArrayvOES = (PFNGLSCISSORARRAYVOESPROC) load(userptr, "glScissorArrayvOES");
4355 glad_glScissorIndexedOES = (PFNGLSCISSORINDEXEDOESPROC) load(userptr, "glScissorIndexedOES");
4356 glad_glScissorIndexedvOES = (PFNGLSCISSORINDEXEDVOESPROC) load(userptr, "glScissorIndexedvOES");
4357 glad_glViewportArrayvOES = (PFNGLVIEWPORTARRAYVOESPROC) load(userptr, "glViewportArrayvOES");
4358 glad_glViewportIndexedfOES = (PFNGLVIEWPORTINDEXEDFOESPROC) load(userptr, "glViewportIndexedfOES");
4359 glad_glViewportIndexedfvOES = (PFNGLVIEWPORTINDEXEDFVOESPROC) load(userptr, "glViewportIndexedfvOES");
4360}
4361
4362
4363
4364#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
4365#define GLAD_GL_IS_SOME_NEW_VERSION 1
4366#else
4367#define GLAD_GL_IS_SOME_NEW_VERSION 0
4368#endif
4369
4370static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
4371#if GLAD_GL_IS_SOME_NEW_VERSION
4372 if(GLAD_VERSION_MAJOR(version) < 3) {
4373#else
4374 GLAD_UNUSED(version);
4375 GLAD_UNUSED(out_num_exts_i);
4376 GLAD_UNUSED(out_exts_i);
4377#endif
4378 if (glad_glGetString == NULL) {
4379 return 0;
4380 }
4381 *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS);
4382#if GLAD_GL_IS_SOME_NEW_VERSION
4383 } else {
4384 unsigned int index = 0;
4385 unsigned int num_exts_i = 0;
4386 char **exts_i = NULL;
4387 if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) {
4388 return 0;
4389 }
4390 glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
4391 if (num_exts_i > 0) {
4392 exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
4393 }
4394 if (exts_i == NULL) {
4395 return 0;
4396 }
4397 for(index = 0; index < num_exts_i; index++) {
4398 const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index);
4399 size_t len = strlen(gl_str_tmp) + 1;
4400
4401 char *local_str = (char*) malloc(len * sizeof(char));
4402 if(local_str != NULL) {
4403 memcpy(local_str, gl_str_tmp, len * sizeof(char));
4404 }
4405
4406 exts_i[index] = local_str;
4407 }
4408
4409 *out_num_exts_i = num_exts_i;
4410 *out_exts_i = exts_i;
4411 }
4412#endif
4413 return 1;
4414}
4415static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
4416 if (exts_i != NULL) {
4417 unsigned int index;
4418 for(index = 0; index < num_exts_i; index++) {
4419 free((void *) (exts_i[index]));
4420 }
4421 free((void *)exts_i);
4422 exts_i = NULL;
4423 }
4424}
4425static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
4426 if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
4427 const char *extensions;
4428 const char *loc;
4429 const char *terminator;
4430 extensions = exts;
4431 if(extensions == NULL || ext == NULL) {
4432 return 0;
4433 }
4434 while(1) {
4435 loc = strstr(extensions, ext);
4436 if(loc == NULL) {
4437 return 0;
4438 }
4439 terminator = loc + strlen(ext);
4440 if((loc == extensions || *(loc - 1) == ' ') &&
4441 (*terminator == ' ' || *terminator == '\0')) {
4442 return 1;
4443 }
4444 extensions = terminator;
4445 }
4446 } else {
4447 unsigned int index;
4448 for(index = 0; index < num_exts_i; index++) {
4449 const char *e = exts_i[index];
4450 if(strcmp(e, ext) == 0) {
4451 return 1;
4452 }
4453 }
4454 }
4455 return 0;
4456}
4457
4458static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
4459 return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
4460}
4461
4462static int glad_gl_find_extensions_gles2( int version) {
4463 const char *exts = NULL;
4464 unsigned int num_exts_i = 0;
4465 char **exts_i = NULL;
4466 if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
4467
4468 GLAD_GL_EXT_EGL_image_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_array");
4469 GLAD_GL_EXT_EGL_image_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_storage");
4470 GLAD_GL_EXT_EGL_image_storage_compression = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_storage_compression");
4471 GLAD_GL_EXT_YUV_target = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_YUV_target");
4472 GLAD_GL_EXT_base_instance = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_base_instance");
4473 GLAD_GL_EXT_blend_func_extended = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_blend_func_extended");
4474 GLAD_GL_EXT_blend_minmax = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_blend_minmax");
4475 GLAD_GL_EXT_buffer_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_buffer_storage");
4476 GLAD_GL_EXT_clear_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clear_texture");
4477 GLAD_GL_EXT_clip_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clip_control");
4478 GLAD_GL_EXT_clip_cull_distance = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clip_cull_distance");
4479 GLAD_GL_EXT_color_buffer_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_color_buffer_float");
4480 GLAD_GL_EXT_color_buffer_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_color_buffer_half_float");
4481 GLAD_GL_EXT_conservative_depth = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_conservative_depth");
4482 GLAD_GL_EXT_copy_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_copy_image");
4483 GLAD_GL_EXT_debug_label = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_debug_label");
4484 GLAD_GL_EXT_debug_marker = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_debug_marker");
4485 GLAD_GL_EXT_depth_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_depth_clamp");
4486 GLAD_GL_EXT_discard_framebuffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_discard_framebuffer");
4487 GLAD_GL_EXT_disjoint_timer_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_disjoint_timer_query");
4488 GLAD_GL_EXT_draw_buffers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_buffers");
4489 GLAD_GL_EXT_draw_buffers_indexed = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_buffers_indexed");
4490 GLAD_GL_EXT_draw_elements_base_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_elements_base_vertex");
4491 GLAD_GL_EXT_draw_instanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_instanced");
4492 GLAD_GL_EXT_draw_transform_feedback = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_transform_feedback");
4493 GLAD_GL_EXT_external_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_external_buffer");
4494 GLAD_GL_EXT_float_blend = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_float_blend");
4495 GLAD_GL_EXT_fragment_shading_rate = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_fragment_shading_rate");
4496 GLAD_GL_EXT_geometry_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_geometry_point_size");
4497 GLAD_GL_EXT_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_geometry_shader");
4498 GLAD_GL_EXT_gpu_shader5 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_gpu_shader5");
4499 GLAD_GL_EXT_instanced_arrays = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_instanced_arrays");
4500 GLAD_GL_EXT_map_buffer_range = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_map_buffer_range");
4501 GLAD_GL_EXT_memory_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object");
4502 GLAD_GL_EXT_memory_object_fd = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object_fd");
4503 GLAD_GL_EXT_memory_object_win32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object_win32");
4504 GLAD_GL_EXT_multi_draw_arrays = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multi_draw_arrays");
4505 GLAD_GL_EXT_multi_draw_indirect = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multi_draw_indirect");
4506 GLAD_GL_EXT_multisampled_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_compatibility");
4507 GLAD_GL_EXT_multisampled_render_to_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_render_to_texture");
4508 GLAD_GL_EXT_multisampled_render_to_texture2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_render_to_texture2");
4509 GLAD_GL_EXT_multiview_draw_buffers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_draw_buffers");
4510 GLAD_GL_EXT_multiview_tessellation_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_tessellation_geometry_shader");
4511 GLAD_GL_EXT_multiview_texture_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_texture_multisample");
4512 GLAD_GL_EXT_multiview_timer_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_timer_query");
4513 GLAD_GL_EXT_occlusion_query_boolean = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_occlusion_query_boolean");
4514 GLAD_GL_EXT_polygon_offset_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_polygon_offset_clamp");
4515 GLAD_GL_EXT_post_depth_coverage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_post_depth_coverage");
4516 GLAD_GL_EXT_primitive_bounding_box = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_primitive_bounding_box");
4517 GLAD_GL_EXT_protected_textures = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_protected_textures");
4518 GLAD_GL_EXT_pvrtc_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_pvrtc_sRGB");
4519 GLAD_GL_EXT_raster_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_raster_multisample");
4520 GLAD_GL_EXT_read_format_bgra = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_read_format_bgra");
4521 GLAD_GL_EXT_render_snorm = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_render_snorm");
4522 GLAD_GL_EXT_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_robustness");
4523 GLAD_GL_EXT_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sRGB");
4524 GLAD_GL_EXT_sRGB_write_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sRGB_write_control");
4525 GLAD_GL_EXT_semaphore = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore");
4526 GLAD_GL_EXT_semaphore_fd = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore_fd");
4527 GLAD_GL_EXT_semaphore_win32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore_win32");
4528 GLAD_GL_EXT_separate_depth_stencil = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_separate_depth_stencil");
4529 GLAD_GL_EXT_separate_shader_objects = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_separate_shader_objects");
4530 GLAD_GL_EXT_shader_framebuffer_fetch = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_framebuffer_fetch");
4531 GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_framebuffer_fetch_non_coherent");
4532 GLAD_GL_EXT_shader_group_vote = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_group_vote");
4533 GLAD_GL_EXT_shader_implicit_conversions = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_implicit_conversions");
4534 GLAD_GL_EXT_shader_integer_mix = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_integer_mix");
4535 GLAD_GL_EXT_shader_io_blocks = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_io_blocks");
4536 GLAD_GL_EXT_shader_non_constant_global_initializers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_non_constant_global_initializers");
4537 GLAD_GL_EXT_shader_pixel_local_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_pixel_local_storage");
4538 GLAD_GL_EXT_shader_pixel_local_storage2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_pixel_local_storage2");
4539 GLAD_GL_EXT_shader_samples_identical = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_samples_identical");
4540 GLAD_GL_EXT_shader_texture_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_texture_lod");
4541 GLAD_GL_EXT_shadow_samplers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shadow_samplers");
4542 GLAD_GL_EXT_sparse_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sparse_texture");
4543 GLAD_GL_EXT_sparse_texture2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sparse_texture2");
4544 GLAD_GL_EXT_tessellation_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_tessellation_point_size");
4545 GLAD_GL_EXT_tessellation_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_tessellation_shader");
4546 GLAD_GL_EXT_texture_border_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_border_clamp");
4547 GLAD_GL_EXT_texture_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_buffer");
4548 GLAD_GL_EXT_texture_compression_astc_decode_mode = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_astc_decode_mode");
4549 GLAD_GL_EXT_texture_compression_bptc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_bptc");
4550 GLAD_GL_EXT_texture_compression_dxt1 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_dxt1");
4551 GLAD_GL_EXT_texture_compression_rgtc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_rgtc");
4552 GLAD_GL_EXT_texture_compression_s3tc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_s3tc");
4553 GLAD_GL_EXT_texture_compression_s3tc_srgb = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_s3tc_srgb");
4554 GLAD_GL_EXT_texture_cube_map_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_cube_map_array");
4555 GLAD_GL_EXT_texture_filter_anisotropic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_filter_anisotropic");
4556 GLAD_GL_EXT_texture_filter_minmax = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_filter_minmax");
4557 GLAD_GL_EXT_texture_format_BGRA8888 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_format_BGRA8888");
4558 GLAD_GL_EXT_texture_format_sRGB_override = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_format_sRGB_override");
4559 GLAD_GL_EXT_texture_mirror_clamp_to_edge = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_mirror_clamp_to_edge");
4560 GLAD_GL_EXT_texture_norm16 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_norm16");
4561 GLAD_GL_EXT_texture_query_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_query_lod");
4562 GLAD_GL_EXT_texture_rg = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_rg");
4563 GLAD_GL_EXT_texture_sRGB_R8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_R8");
4564 GLAD_GL_EXT_texture_sRGB_RG8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_RG8");
4565 GLAD_GL_EXT_texture_sRGB_decode = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_decode");
4566 GLAD_GL_EXT_texture_shadow_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_shadow_lod");
4567 GLAD_GL_EXT_texture_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_storage");
4568 GLAD_GL_EXT_texture_storage_compression = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_storage_compression");
4569 GLAD_GL_EXT_texture_type_2_10_10_10_REV = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_type_2_10_10_10_REV");
4570 GLAD_GL_EXT_texture_view = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_view");
4571 GLAD_GL_EXT_unpack_subimage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_unpack_subimage");
4572 GLAD_GL_EXT_win32_keyed_mutex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_win32_keyed_mutex");
4573 GLAD_GL_EXT_window_rectangles = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_window_rectangles");
4574 GLAD_GL_KHR_blend_equation_advanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_blend_equation_advanced");
4575 GLAD_GL_KHR_blend_equation_advanced_coherent = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_blend_equation_advanced_coherent");
4576 GLAD_GL_KHR_context_flush_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_context_flush_control");
4577 GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug");
4578 GLAD_GL_KHR_no_error = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_no_error");
4579 GLAD_GL_KHR_parallel_shader_compile = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_parallel_shader_compile");
4580 GLAD_GL_KHR_robust_buffer_access_behavior = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_robust_buffer_access_behavior");
4581 GLAD_GL_KHR_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_robustness");
4582 GLAD_GL_KHR_shader_subgroup = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_shader_subgroup");
4583 GLAD_GL_KHR_texture_compression_astc_hdr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_hdr");
4584 GLAD_GL_KHR_texture_compression_astc_ldr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_ldr");
4585 GLAD_GL_KHR_texture_compression_astc_sliced_3d = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_sliced_3d");
4586 GLAD_GL_OES_EGL_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image");
4587 GLAD_GL_OES_EGL_image_external = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image_external");
4588 GLAD_GL_OES_EGL_image_external_essl3 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image_external_essl3");
4589 GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_ETC1_RGB8_sub_texture");
4590 GLAD_GL_OES_compressed_ETC1_RGB8_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_ETC1_RGB8_texture");
4591 GLAD_GL_OES_compressed_paletted_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_paletted_texture");
4592 GLAD_GL_OES_copy_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_copy_image");
4593 GLAD_GL_OES_depth24 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth24");
4594 GLAD_GL_OES_depth32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth32");
4595 GLAD_GL_OES_depth_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth_texture");
4596 GLAD_GL_OES_draw_buffers_indexed = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_draw_buffers_indexed");
4597 GLAD_GL_OES_draw_elements_base_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_draw_elements_base_vertex");
4598 GLAD_GL_OES_element_index_uint = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_element_index_uint");
4599 GLAD_GL_OES_fbo_render_mipmap = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_fbo_render_mipmap");
4600 GLAD_GL_OES_fragment_precision_high = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_fragment_precision_high");
4601 GLAD_GL_OES_geometry_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_geometry_point_size");
4602 GLAD_GL_OES_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_geometry_shader");
4603 GLAD_GL_OES_get_program_binary = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_get_program_binary");
4604 GLAD_GL_OES_gpu_shader5 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_gpu_shader5");
4605 GLAD_GL_OES_mapbuffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_mapbuffer");
4606 GLAD_GL_OES_packed_depth_stencil = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_packed_depth_stencil");
4607 GLAD_GL_OES_primitive_bounding_box = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_primitive_bounding_box");
4608 GLAD_GL_OES_required_internalformat = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_required_internalformat");
4609 GLAD_GL_OES_rgb8_rgba8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_rgb8_rgba8");
4610 GLAD_GL_OES_sample_shading = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_sample_shading");
4611 GLAD_GL_OES_sample_variables = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_sample_variables");
4612 GLAD_GL_OES_shader_image_atomic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_image_atomic");
4613 GLAD_GL_OES_shader_io_blocks = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_io_blocks");
4614 GLAD_GL_OES_shader_multisample_interpolation = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_multisample_interpolation");
4615 GLAD_GL_OES_standard_derivatives = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_standard_derivatives");
4616 GLAD_GL_OES_stencil1 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_stencil1");
4617 GLAD_GL_OES_stencil4 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_stencil4");
4618 GLAD_GL_OES_surfaceless_context = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_surfaceless_context");
4619 GLAD_GL_OES_tessellation_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_tessellation_point_size");
4620 GLAD_GL_OES_tessellation_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_tessellation_shader");
4621 GLAD_GL_OES_texture_3D = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_3D");
4622 GLAD_GL_OES_texture_border_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_border_clamp");
4623 GLAD_GL_OES_texture_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_buffer");
4624 GLAD_GL_OES_texture_compression_astc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_compression_astc");
4625 GLAD_GL_OES_texture_cube_map_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_cube_map_array");
4626 GLAD_GL_OES_texture_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_float");
4627 GLAD_GL_OES_texture_float_linear = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_float_linear");
4628 GLAD_GL_OES_texture_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_half_float");
4629 GLAD_GL_OES_texture_half_float_linear = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_half_float_linear");
4630 GLAD_GL_OES_texture_npot = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_npot");
4631 GLAD_GL_OES_texture_stencil8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_stencil8");
4632 GLAD_GL_OES_texture_storage_multisample_2d_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_storage_multisample_2d_array");
4633 GLAD_GL_OES_texture_view = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_view");
4634 GLAD_GL_OES_vertex_array_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_array_object");
4635 GLAD_GL_OES_vertex_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_half_float");
4636 GLAD_GL_OES_vertex_type_10_10_10_2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_type_10_10_10_2");
4637 GLAD_GL_OES_viewport_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_viewport_array");
4638
4639 glad_gl_free_extensions(exts_i, num_exts_i);
4640
4641 return 1;
4642}
4643
4644static int glad_gl_find_core_gles2(void) {
4645 int i;
4646 const char* version;
4647 const char* prefixes[] = {
4648 "OpenGL ES-CM ",
4649 "OpenGL ES-CL ",
4650 "OpenGL ES ",
4651 "OpenGL SC ",
4652 NULL
4653 };
4654 int major = 0;
4655 int minor = 0;
4656 version = (const char*) glad_glGetString(GL_VERSION);
4657 if (!version) return 0;
4658 for (i = 0; prefixes[i]; i++) {
4659 const size_t length = strlen(prefixes[i]);
4660 if (strncmp(version, prefixes[i], length) == 0) {
4661 version += length;
4662 break;
4663 }
4664 }
4665
4666 GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
4667
4668 GLAD_GL_ES_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
4669
4670 return GLAD_MAKE_VERSION(major, minor);
4671}
4672
4673int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr) {
4674 int version;
4675
4676 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
4677 if(glad_glGetString == NULL) return 0;
4678 if(glad_glGetString(GL_VERSION) == NULL) return 0;
4679 version = glad_gl_find_core_gles2();
4680
4681 glad_gl_load_GL_ES_VERSION_2_0(load, userptr);
4682
4683 if (!glad_gl_find_extensions_gles2(version)) return 0;
4684 glad_gl_load_GL_EXT_EGL_image_storage(load, userptr);
4685 glad_gl_load_GL_EXT_base_instance(load, userptr);
4686 glad_gl_load_GL_EXT_blend_func_extended(load, userptr);
4687 glad_gl_load_GL_EXT_buffer_storage(load, userptr);
4688 glad_gl_load_GL_EXT_clear_texture(load, userptr);
4689 glad_gl_load_GL_EXT_clip_control(load, userptr);
4690 glad_gl_load_GL_EXT_copy_image(load, userptr);
4691 glad_gl_load_GL_EXT_debug_label(load, userptr);
4692 glad_gl_load_GL_EXT_debug_marker(load, userptr);
4693 glad_gl_load_GL_EXT_discard_framebuffer(load, userptr);
4694 glad_gl_load_GL_EXT_disjoint_timer_query(load, userptr);
4695 glad_gl_load_GL_EXT_draw_buffers(load, userptr);
4696 glad_gl_load_GL_EXT_draw_buffers_indexed(load, userptr);
4697 glad_gl_load_GL_EXT_draw_elements_base_vertex(load, userptr);
4698 glad_gl_load_GL_EXT_draw_instanced(load, userptr);
4699 glad_gl_load_GL_EXT_draw_transform_feedback(load, userptr);
4700 glad_gl_load_GL_EXT_external_buffer(load, userptr);
4701 glad_gl_load_GL_EXT_fragment_shading_rate(load, userptr);
4702 glad_gl_load_GL_EXT_geometry_shader(load, userptr);
4703 glad_gl_load_GL_EXT_instanced_arrays(load, userptr);
4704 glad_gl_load_GL_EXT_map_buffer_range(load, userptr);
4705 glad_gl_load_GL_EXT_memory_object(load, userptr);
4706 glad_gl_load_GL_EXT_memory_object_fd(load, userptr);
4707 glad_gl_load_GL_EXT_memory_object_win32(load, userptr);
4708 glad_gl_load_GL_EXT_multi_draw_arrays(load, userptr);
4709 glad_gl_load_GL_EXT_multi_draw_indirect(load, userptr);
4710 glad_gl_load_GL_EXT_multisampled_render_to_texture(load, userptr);
4711 glad_gl_load_GL_EXT_multiview_draw_buffers(load, userptr);
4712 glad_gl_load_GL_EXT_occlusion_query_boolean(load, userptr);
4713 glad_gl_load_GL_EXT_polygon_offset_clamp(load, userptr);
4714 glad_gl_load_GL_EXT_primitive_bounding_box(load, userptr);
4715 glad_gl_load_GL_EXT_raster_multisample(load, userptr);
4716 glad_gl_load_GL_EXT_robustness(load, userptr);
4717 glad_gl_load_GL_EXT_semaphore(load, userptr);
4718 glad_gl_load_GL_EXT_semaphore_fd(load, userptr);
4719 glad_gl_load_GL_EXT_semaphore_win32(load, userptr);
4720 glad_gl_load_GL_EXT_separate_shader_objects(load, userptr);
4721 glad_gl_load_GL_EXT_shader_framebuffer_fetch_non_coherent(load, userptr);
4722 glad_gl_load_GL_EXT_shader_pixel_local_storage2(load, userptr);
4723 glad_gl_load_GL_EXT_sparse_texture(load, userptr);
4724 glad_gl_load_GL_EXT_tessellation_shader(load, userptr);
4725 glad_gl_load_GL_EXT_texture_border_clamp(load, userptr);
4726 glad_gl_load_GL_EXT_texture_buffer(load, userptr);
4727 glad_gl_load_GL_EXT_texture_storage(load, userptr);
4728 glad_gl_load_GL_EXT_texture_storage_compression(load, userptr);
4729 glad_gl_load_GL_EXT_texture_view(load, userptr);
4730 glad_gl_load_GL_EXT_win32_keyed_mutex(load, userptr);
4731 glad_gl_load_GL_EXT_window_rectangles(load, userptr);
4732 glad_gl_load_GL_KHR_blend_equation_advanced(load, userptr);
4733 glad_gl_load_GL_KHR_debug(load, userptr);
4734 glad_gl_load_GL_KHR_parallel_shader_compile(load, userptr);
4735 glad_gl_load_GL_KHR_robustness(load, userptr);
4736 glad_gl_load_GL_OES_EGL_image(load, userptr);
4737 glad_gl_load_GL_OES_copy_image(load, userptr);
4738 glad_gl_load_GL_OES_draw_buffers_indexed(load, userptr);
4739 glad_gl_load_GL_OES_draw_elements_base_vertex(load, userptr);
4740 glad_gl_load_GL_OES_geometry_shader(load, userptr);
4741 glad_gl_load_GL_OES_get_program_binary(load, userptr);
4742 glad_gl_load_GL_OES_mapbuffer(load, userptr);
4743 glad_gl_load_GL_OES_primitive_bounding_box(load, userptr);
4744 glad_gl_load_GL_OES_sample_shading(load, userptr);
4745 glad_gl_load_GL_OES_tessellation_shader(load, userptr);
4746 glad_gl_load_GL_OES_texture_3D(load, userptr);
4747 glad_gl_load_GL_OES_texture_border_clamp(load, userptr);
4748 glad_gl_load_GL_OES_texture_buffer(load, userptr);
4749 glad_gl_load_GL_OES_texture_storage_multisample_2d_array(load, userptr);
4750 glad_gl_load_GL_OES_texture_view(load, userptr);
4751 glad_gl_load_GL_OES_vertex_array_object(load, userptr);
4752 glad_gl_load_GL_OES_viewport_array(load, userptr);
4753
4754
4755
4756 return version;
4757}
4758
4759
4760int gladLoadGLES2( GLADloadfunc load) {
4761 return gladLoadGLES2UserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
4762}
4763
4764
4765
4766
4767
4768
4769#ifdef __cplusplus
4770}
4771#endif
4772
4773#endif /* GLAD_GLES2_IMPLEMENTATION */
4774
diff --git a/raylib/src/external/glfw/.mailmap b/raylib/src/external/glfw/.mailmap
new file mode 100644
index 0000000..96d8a9b
--- /dev/null
+++ b/raylib/src/external/glfw/.mailmap
@@ -0,0 +1,10 @@
1Camilla Löwy <elmindreda@glfw.org> <elmindreda@users.sourceforge.net>
2Camilla Löwy <elmindreda@glfw.org> <elmindreda@elmindreda.org>
3Camilla Löwy <elmindreda@glfw.org>
4
5Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
6
7Marcus Geelnard <m@bitsnbites.eu> <marcus256@users.sourceforge.net>
8Marcus Geelnard <m@bitsnbites.eu> <marcus@geelnards-pc.(none)>
9Marcus Geelnard <m@bitsnbites.eu>
10
diff --git a/raylib/src/external/glfw/CMake/GenerateMappings.cmake b/raylib/src/external/glfw/CMake/GenerateMappings.cmake
new file mode 100644
index 0000000..c8c9e23
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/GenerateMappings.cmake
@@ -0,0 +1,48 @@
1# Usage:
2# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
3
4set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
5set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
6set(template_path "${CMAKE_ARGV3}")
7set(target_path "${CMAKE_ARGV4}")
8
9if (NOT EXISTS "${template_path}")
10 message(FATAL_ERROR "Failed to find template file ${template_path}")
11endif()
12
13file(DOWNLOAD "${source_url}" "${source_path}"
14 STATUS download_status
15 TLS_VERIFY on)
16
17list(GET download_status 0 status_code)
18list(GET download_status 1 status_message)
19
20if (status_code)
21 message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}")
22endif()
23
24file(STRINGS "${source_path}" lines)
25foreach(line ${lines})
26 if (line MATCHES "^[0-9a-fA-F]")
27 if (line MATCHES "platform:Windows")
28 if (GLFW_WIN32_MAPPINGS)
29 string(APPEND GLFW_WIN32_MAPPINGS "\n")
30 endif()
31 string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",")
32 elseif (line MATCHES "platform:Mac OS X")
33 if (GLFW_COCOA_MAPPINGS)
34 string(APPEND GLFW_COCOA_MAPPINGS "\n")
35 endif()
36 string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",")
37 elseif (line MATCHES "platform:Linux")
38 if (GLFW_LINUX_MAPPINGS)
39 string(APPEND GLFW_LINUX_MAPPINGS "\n")
40 endif()
41 string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",")
42 endif()
43 endif()
44endforeach()
45
46configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
47file(REMOVE "${source_path}")
48
diff --git a/raylib/src/external/glfw/CMake/Info.plist.in b/raylib/src/external/glfw/CMake/Info.plist.in
new file mode 100644
index 0000000..684ad79
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/Info.plist.in
@@ -0,0 +1,38 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>CFBundleDevelopmentRegion</key>
6 <string>English</string>
7 <key>CFBundleExecutable</key>
8 <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
9 <key>CFBundleGetInfoString</key>
10 <string>${MACOSX_BUNDLE_INFO_STRING}</string>
11 <key>CFBundleIconFile</key>
12 <string>${MACOSX_BUNDLE_ICON_FILE}</string>
13 <key>CFBundleIdentifier</key>
14 <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
15 <key>CFBundleInfoDictionaryVersion</key>
16 <string>6.0</string>
17 <key>CFBundleLongVersionString</key>
18 <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
19 <key>CFBundleName</key>
20 <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
21 <key>CFBundlePackageType</key>
22 <string>APPL</string>
23 <key>CFBundleShortVersionString</key>
24 <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
25 <key>CFBundleSignature</key>
26 <string>????</string>
27 <key>CFBundleVersion</key>
28 <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
29 <key>CSResourcesFileMapped</key>
30 <true/>
31 <key>LSRequiresCarbon</key>
32 <true/>
33 <key>NSHumanReadableCopyright</key>
34 <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
35 <key>NSHighResolutionCapable</key>
36 <true/>
37</dict>
38</plist>
diff --git a/raylib/src/external/glfw/CMake/cmake_uninstall.cmake.in b/raylib/src/external/glfw/CMake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..5ecc476
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/cmake_uninstall.cmake.in
@@ -0,0 +1,29 @@
1
2if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt")
3 message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"")
4endif()
5
6file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files)
7string(REGEX REPLACE "\n" ";" files "${files}")
8
9foreach (file ${files})
10 message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
11 if (EXISTS "$ENV{DESTDIR}${file}")
12 exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
13 OUTPUT_VARIABLE rm_out
14 RETURN_VALUE rm_retval)
15 if (NOT "${rm_retval}" STREQUAL 0)
16 MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
17 endif()
18 elseif (IS_SYMLINK "$ENV{DESTDIR}${file}")
19 EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
20 OUTPUT_VARIABLE rm_out
21 RETURN_VALUE rm_retval)
22 if (NOT "${rm_retval}" STREQUAL 0)
23 message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"")
24 endif()
25 else()
26 message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
27 endif()
28endforeach()
29
diff --git a/raylib/src/external/glfw/CMake/glfw3.pc.in b/raylib/src/external/glfw/CMake/glfw3.pc.in
new file mode 100644
index 0000000..36ee218
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/glfw3.pc.in
@@ -0,0 +1,13 @@
1prefix=@CMAKE_INSTALL_PREFIX@
2exec_prefix=${prefix}
3includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
4libdir=@CMAKE_INSTALL_FULL_LIBDIR@
5
6Name: GLFW
7Description: A multi-platform library for OpenGL, window and input
8Version: @GLFW_VERSION@
9URL: https://www.glfw.org/
10Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@
11Libs: -L${libdir} -l@GLFW_LIB_NAME@@GLFW_LIB_NAME_SUFFIX@
12Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@
13Cflags: -I${includedir}
diff --git a/raylib/src/external/glfw/CMake/glfw3Config.cmake.in b/raylib/src/external/glfw/CMake/glfw3Config.cmake.in
new file mode 100644
index 0000000..4a13a88
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/glfw3Config.cmake.in
@@ -0,0 +1,3 @@
1include(CMakeFindDependencyMacro)
2find_dependency(Threads)
3include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake")
diff --git a/raylib/src/external/glfw/CMake/i686-w64-mingw32-clang.cmake b/raylib/src/external/glfw/CMake/i686-w64-mingw32-clang.cmake
new file mode 100644
index 0000000..8726b23
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/i686-w64-mingw32-clang.cmake
@@ -0,0 +1,13 @@
1# Define the environment for cross-compiling with 32-bit MinGW-w64 Clang
2SET(CMAKE_SYSTEM_NAME Windows) # Target system name
3SET(CMAKE_SYSTEM_VERSION 1)
4SET(CMAKE_C_COMPILER "i686-w64-mingw32-clang")
5SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-clang++")
6SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres")
7SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib")
8
9# Configure the behaviour of the find commands
10SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
11SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
12SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
13SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/src/external/glfw/CMake/i686-w64-mingw32.cmake b/raylib/src/external/glfw/CMake/i686-w64-mingw32.cmake
new file mode 100644
index 0000000..2ca4dcd
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/i686-w64-mingw32.cmake
@@ -0,0 +1,13 @@
1# Define the environment for cross-compiling with 32-bit MinGW-w64 GCC
2SET(CMAKE_SYSTEM_NAME Windows) # Target system name
3SET(CMAKE_SYSTEM_VERSION 1)
4SET(CMAKE_C_COMPILER "i686-w64-mingw32-gcc")
5SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-g++")
6SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres")
7SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib")
8
9# Configure the behaviour of the find commands
10SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
11SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
12SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
13SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/src/external/glfw/CMake/modules/FindEpollShim.cmake b/raylib/src/external/glfw/CMake/modules/FindEpollShim.cmake
new file mode 100644
index 0000000..f34d070
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/modules/FindEpollShim.cmake
@@ -0,0 +1,17 @@
1# Find EpollShim
2# Once done, this will define
3#
4# EPOLLSHIM_FOUND - System has EpollShim
5# EPOLLSHIM_INCLUDE_DIRS - The EpollShim include directories
6# EPOLLSHIM_LIBRARIES - The libraries needed to use EpollShim
7
8find_path(EPOLLSHIM_INCLUDE_DIRS NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim)
9find_library(EPOLLSHIM_LIBRARIES NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
10
11if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
12 set(EPOLLSHIM_FOUND TRUE)
13endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
14
15include(FindPackageHandleStandardArgs)
16find_package_handle_standard_args(EpollShim DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
17mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)
diff --git a/raylib/src/external/glfw/CMake/modules/FindOSMesa.cmake b/raylib/src/external/glfw/CMake/modules/FindOSMesa.cmake
new file mode 100644
index 0000000..3194bd9
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/modules/FindOSMesa.cmake
@@ -0,0 +1,18 @@
1# Try to find OSMesa on a Unix system
2#
3# This will define:
4#
5# OSMESA_LIBRARIES - Link these to use OSMesa
6# OSMESA_INCLUDE_DIR - Include directory for OSMesa
7#
8# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
9
10if (NOT WIN32)
11
12 find_package (PkgConfig)
13 pkg_check_modules (PKG_OSMESA QUIET osmesa)
14
15 set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS})
16 set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES})
17
18endif ()
diff --git a/raylib/src/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake b/raylib/src/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake
new file mode 100644
index 0000000..60f7914
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake
@@ -0,0 +1,13 @@
1# Define the environment for cross-compiling with 64-bit MinGW-w64 Clang
2SET(CMAKE_SYSTEM_NAME Windows) # Target system name
3SET(CMAKE_SYSTEM_VERSION 1)
4SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-clang")
5SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-clang++")
6SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres")
7SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib")
8
9# Configure the behaviour of the find commands
10SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
11SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
12SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
13SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/src/external/glfw/CMake/x86_64-w64-mingw32.cmake b/raylib/src/external/glfw/CMake/x86_64-w64-mingw32.cmake
new file mode 100644
index 0000000..063e845
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/x86_64-w64-mingw32.cmake
@@ -0,0 +1,13 @@
1# Define the environment for cross-compiling with 64-bit MinGW-w64 GCC
2SET(CMAKE_SYSTEM_NAME Windows) # Target system name
3SET(CMAKE_SYSTEM_VERSION 1)
4SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc")
5SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++")
6SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres")
7SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib")
8
9# Configure the behaviour of the find commands
10SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
11SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
12SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
13SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/src/external/glfw/CMakeLists.txt b/raylib/src/external/glfw/CMakeLists.txt
new file mode 100644
index 0000000..a3cb1fe
--- /dev/null
+++ b/raylib/src/external/glfw/CMakeLists.txt
@@ -0,0 +1,165 @@
1cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR)
2
3project(GLFW VERSION 3.4.0 LANGUAGES C)
4
5if (POLICY CMP0069)
6 cmake_policy(SET CMP0069 NEW)
7endif()
8
9if (POLICY CMP0077)
10 cmake_policy(SET CMP0077 NEW)
11endif()
12
13set_property(GLOBAL PROPERTY USE_FOLDERS ON)
14
15string(COMPARE EQUAL "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" GLFW_STANDALONE)
16
17option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
18option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
19option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
20option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
21option(GLFW_INSTALL "Generate installation target" ON)
22
23include(GNUInstallDirs)
24include(CMakeDependentOption)
25
26if (GLFW_USE_OSMESA)
27 message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint")
28endif()
29
30if (DEFINED GLFW_USE_WAYLAND AND UNIX AND NOT APPLE)
31 message(FATAL_ERROR
32 "GLFW_USE_WAYLAND has been removed; delete the CMake cache and set GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 instead")
33endif()
34
35cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF)
36cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF)
37cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF)
38cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" ON "UNIX;NOT APPLE" OFF)
39
40cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
41 "WIN32" OFF)
42cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
43 "MSVC" OFF)
44
45set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING
46 "Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
47
48if (GLFW_LIBRARY_TYPE)
49 if (GLFW_LIBRARY_TYPE STREQUAL "SHARED")
50 set(GLFW_BUILD_SHARED_LIBRARY TRUE)
51 else()
52 set(GLFW_BUILD_SHARED_LIBRARY FALSE)
53 endif()
54else()
55 set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
56endif()
57
58list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
59
60find_package(Threads REQUIRED)
61
62#--------------------------------------------------------------------
63# Report backend selection
64#--------------------------------------------------------------------
65if (GLFW_BUILD_WIN32)
66 message(STATUS "Including Win32 support")
67endif()
68if (GLFW_BUILD_COCOA)
69 message(STATUS "Including Cocoa support")
70endif()
71if (GLFW_BUILD_WAYLAND)
72 message(STATUS "Including Wayland support")
73endif()
74if (GLFW_BUILD_X11)
75 message(STATUS "Including X11 support")
76endif()
77
78#--------------------------------------------------------------------
79# Apply Microsoft C runtime library option
80# This is here because it also applies to tests and examples
81#--------------------------------------------------------------------
82if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
83 if (CMAKE_VERSION VERSION_LESS 3.15)
84 foreach (flag CMAKE_C_FLAGS
85 CMAKE_C_FLAGS_DEBUG
86 CMAKE_C_FLAGS_RELEASE
87 CMAKE_C_FLAGS_MINSIZEREL
88 CMAKE_C_FLAGS_RELWITHDEBINFO)
89
90 if (flag MATCHES "/MD")
91 string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
92 endif()
93 if (flag MATCHES "/MDd")
94 string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
95 endif()
96
97 endforeach()
98 else()
99 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
100 endif()
101endif()
102
103#--------------------------------------------------------------------
104# Create generated files
105#--------------------------------------------------------------------
106include(CMakePackageConfigHelpers)
107
108set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/glfw3")
109
110configure_package_config_file(CMake/glfw3Config.cmake.in
111 src/glfw3Config.cmake
112 INSTALL_DESTINATION "${GLFW_CONFIG_PATH}"
113 NO_CHECK_REQUIRED_COMPONENTS_MACRO)
114
115write_basic_package_version_file(src/glfw3ConfigVersion.cmake
116 VERSION ${GLFW_VERSION}
117 COMPATIBILITY SameMajorVersion)
118
119#--------------------------------------------------------------------
120# Add subdirectories
121#--------------------------------------------------------------------
122add_subdirectory(src)
123
124if (GLFW_BUILD_EXAMPLES)
125 add_subdirectory(examples)
126endif()
127
128if (GLFW_BUILD_TESTS)
129 add_subdirectory(tests)
130endif()
131
132if (GLFW_BUILD_DOCS)
133 add_subdirectory(docs)
134endif()
135
136#--------------------------------------------------------------------
137# Install files other than the library
138# The library is installed by src/CMakeLists.txt
139#--------------------------------------------------------------------
140if (GLFW_INSTALL)
141 install(DIRECTORY include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
142 FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h)
143
144 install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
145 "${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
146 DESTINATION "${GLFW_CONFIG_PATH}")
147
148 install(EXPORT glfwTargets FILE glfw3Targets.cmake
149 EXPORT_LINK_INTERFACE_LIBRARIES
150 DESTINATION "${GLFW_CONFIG_PATH}")
151 install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
152 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
153
154 # Only generate this target if no higher-level project already has
155 if (NOT TARGET uninstall)
156 configure_file(CMake/cmake_uninstall.cmake.in
157 cmake_uninstall.cmake IMMEDIATE @ONLY)
158
159 add_custom_target(uninstall
160 "${CMAKE_COMMAND}" -P
161 "${GLFW_BINARY_DIR}/cmake_uninstall.cmake")
162 set_target_properties(uninstall PROPERTIES FOLDER "GLFW3")
163 endif()
164endif()
165
diff --git a/raylib/src/external/glfw/CONTRIBUTORS.md b/raylib/src/external/glfw/CONTRIBUTORS.md
new file mode 100644
index 0000000..c4c74ad
--- /dev/null
+++ b/raylib/src/external/glfw/CONTRIBUTORS.md
@@ -0,0 +1,297 @@
1# Acknowledgements
2
3GLFW exists because people around the world donated their time and lent their
4skills. This list only includes contributions to the main repository and
5excludes other invaluable contributions like language bindings and text and
6video tutorials.
7
8 - Bobyshev Alexander
9 - Laurent Aphecetche
10 - Matt Arsenault
11 - Takuro Ashie
12 - ashishgamedev
13 - David Avedissian
14 - Luca Bacci
15 - Keith Bauer
16 - John Bartholomew
17 - Coşku Baş
18 - Bayemite
19 - Niklas Behrens
20 - Andrew Belt
21 - Nevyn Bengtsson
22 - Niklas Bergström
23 - Denis Bernard
24 - BiBi
25 - Doug Binks
26 - blanco
27 - Waris Boonyasiriwat
28 - Kyle Brenneman
29 - Rok Breulj
30 - TheBrokenRail
31 - Kai Burjack
32 - Martin Capitanio
33 - Nicolas Caramelli
34 - David Carlier
35 - Arturo Castro
36 - Chi-kwan Chan
37 - Victor Chernyakin
38 - TheChocolateOre
39 - Ali Chraghi
40 - Joseph Chua
41 - Ian Clarkson
42 - Michał Cichoń
43 - Lambert Clara
44 - Anna Clarke
45 - Josh Codd
46 - Yaron Cohen-Tal
47 - Omar Cornut
48 - Andrew Corrigan
49 - Bailey Cosier
50 - Noel Cower
51 - CuriouserThing
52 - Bill Currie
53 - Jason Daly
54 - danhambleton
55 - Jarrod Davis
56 - Olivier Delannoy
57 - Paul R. Deppe
58 - Michael Dickens
59 - Роман Донченко
60 - Mario Dorn
61 - Wolfgang Draxinger
62 - Jonathan Dummer
63 - Ralph Eastwood
64 - Fredrik Ehnbom
65 - Robin Eklind
66 - Jan Ekström
67 - Siavash Eliasi
68 - Ahmad Fatoum
69 - Nikita Fediuchin
70 - Felipe Ferreira
71 - Michael Fogleman
72 - forworldm
73 - Jason Francis
74 - Gerald Franz
75 - Mário Freitas
76 - GeO4d
77 - Marcus Geelnard
78 - Gegy
79 - ghuser404
80 - Charles Giessen
81 - Ryan C. Gordon
82 - Stephen Gowen
83 - Kovid Goyal
84 - Kevin Grandemange
85 - Eloi Marín Gratacós
86 - Grzesiek11
87 - Stefan Gustavson
88 - Andrew Gutekanst
89 - Stephen Gutekanst
90 - Jonathan Hale
91 - Daniel Hauser
92 - hdf89shfdfs
93 - Moritz Heinemann
94 - Sylvain Hellegouarch
95 - Björn Hempel
96 - Matthew Henry
97 - heromyth
98 - Lucas Hinderberger
99 - Paul Holden
100 - Hajime Hoshi
101 - Warren Hu
102 - Charles Huber
103 - Brent Huisman
104 - Florian Hülsmann
105 - illustris
106 - InKryption
107 - IntellectualKitty
108 - Aaron Jacobs
109 - JannikGM
110 - Erik S. V. Jansson
111 - jjYBdx4IL
112 - Peter Johnson
113 - Toni Jovanoski
114 - Arseny Kapoulkine
115 - Cem Karan
116 - Osman Keskin
117 - Koray Kilinc
118 - Josh Kilmer
119 - Byunghoon Kim
120 - Cameron King
121 - Peter Knut
122 - Christoph Kubisch
123 - Yuri Kunde Schlesner
124 - Rokas Kupstys
125 - Konstantin Käfer
126 - Eric Larson
127 - Guillaume Lebrun
128 - Francis Lecavalier
129 - Jong Won Lee
130 - Robin Leffmann
131 - Glenn Lewis
132 - Shane Liesegang
133 - Anders Lindqvist
134 - Leon Linhart
135 - Marco Lizza
136 - lo-v-ol
137 - Eyal Lotem
138 - Aaron Loucks
139 - Ned Loynd
140 - Luflosi
141 - lukect
142 - Tristam MacDonald
143 - Jean-Luc Mackail
144 - Hans Mackowiak
145 - Ramiro Magno
146 - Дмитри Малышев
147 - Zbigniew Mandziejewicz
148 - Adam Marcus
149 - Célestin Marot
150 - Kyle McDonald
151 - David V. McKay
152 - David Medlock
153 - Bryce Mehring
154 - Jonathan Mercier
155 - Marcel Metz
156 - Liam Middlebrook
157 - mightgoyardstill
158 - Ave Milia
159 - Icyllis Milica
160 - Jonathan Miller
161 - Kenneth Miller
162 - Bruce Mitchener
163 - Jack Moffitt
164 - Ravi Mohan
165 - Jeff Molofee
166 - Alexander Monakov
167 - Pierre Morel
168 - Jon Morton
169 - Pierre Moulon
170 - Martins Mozeiko
171 - Pascal Muetschard
172 - James Murphy
173 - Julian Møller
174 - Julius Häger
175 - Nat!
176 - NateIsStalling
177 - ndogxj
178 - F. Nedelec
179 - n3rdopolis
180 - Kristian Nielsen
181 - Joel Niemelä
182 - Victor Nova
183 - Kamil Nowakowski
184 - onox
185 - Denis Ovod
186 - Ozzy
187 - Andri Pálsson
188 - luz paz
189 - Peoro
190 - Braden Pellett
191 - Christopher Pelloux
192 - Michael Pennington
193 - Arturo J. Pérez
194 - Vladimir Perminov
195 - Olivier Perret
196 - Anthony Pesch
197 - Orson Peters
198 - Emmanuel Gil Peyrot
199 - Cyril Pichard
200 - Pilzschaf
201 - Keith Pitt
202 - Stanislav Podgorskiy
203 - Konstantin Podsvirov
204 - Nathan Poirier
205 - Pokechu22
206 - Alexandre Pretyman
207 - Pablo Prietz
208 - przemekmirek
209 - pthom
210 - Martin Pulec
211 - Guillaume Racicot
212 - Juan Ramos
213 - Christian Rauch
214 - Philip Rideout
215 - Eddie Ringle
216 - Max Risuhin
217 - Joe Roback
218 - Jorge Rodriguez
219 - Jari Ronkainen
220 - Luca Rood
221 - Ed Ropple
222 - Aleksey Rybalkin
223 - Mikko Rytkönen
224 - Riku Salminen
225 - Yoshinori Sano
226 - Brandon Schaefer
227 - Sebastian Schuberth
228 - Scr3amer
229 - Jan Schuerkamp
230 - Christian Sdunek
231 - Matt Sealey
232 - Steve Sexton
233 - Arkady Shapkin
234 - Mingjie Shen
235 - Ali Sherief
236 - Yoshiki Shibukawa
237 - Dmitri Shuralyov
238 - Joao da Silva
239 - Daniel Sieger
240 - Daljit Singh
241 - Michael Skec
242 - Daniel Skorupski
243 - Slemmie
244 - Anthony Smith
245 - Bradley Smith
246 - Cliff Smolinsky
247 - Patrick Snape
248 - Erlend Sogge Heggen
249 - Olivier Sohn
250 - Julian Squires
251 - Johannes Stein
252 - Pontus Stenetorp
253 - Michael Stocker
254 - Justin Stoecker
255 - Elviss Strazdins
256 - Paul Sultana
257 - Nathan Sweet
258 - TTK-Bandit
259 - Nuno Teixeira
260 - Jared Tiala
261 - Sergey Tikhomirov
262 - Arthur Tombs
263 - TronicLabs
264 - Ioannis Tsakpinis
265 - Samuli Tuomola
266 - Matthew Turner
267 - urraka
268 - Elias Vanderstuyft
269 - Stef Velzel
270 - Jari Vetoniemi
271 - Ricardo Vieira
272 - Nicholas Vitovitch
273 - Vladimír Vondruš
274 - Simon Voordouw
275 - Corentin Wallez
276 - Torsten Walluhn
277 - Patrick Walton
278 - Jim Wang
279 - Xo Wang
280 - Andre Weissflog
281 - Jay Weisskopf
282 - Frank Wille
283 - Andy Williams
284 - Joel Winarske
285 - Richard A. Wilkes
286 - Tatsuya Yatagawa
287 - Ryogo Yoshimura
288 - Lukas Zanner
289 - Andrey Zholos
290 - Aihui Zhu
291 - Santi Zupancic
292 - Jonas Ådahl
293 - Lasse Öörni
294 - Leonard König
295 - All the unmentioned and anonymous contributors in the GLFW community, for bug
296 reports, patches, feedback, testing and encouragement
297
diff --git a/raylib/src/external/glfw/LICENSE.md b/raylib/src/external/glfw/LICENSE.md
new file mode 100644
index 0000000..7494a3f
--- /dev/null
+++ b/raylib/src/external/glfw/LICENSE.md
@@ -0,0 +1,23 @@
1Copyright (c) 2002-2006 Marcus Geelnard
2
3Copyright (c) 2006-2019 Camilla Löwy
4
5This software is provided 'as-is', without any express or implied
6warranty. In no event will the authors be held liable for any damages
7arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose,
10including commercial applications, and to alter it and redistribute it
11freely, subject to the following restrictions:
12
131. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would
16 be appreciated but is not required.
17
182. Altered source versions must be plainly marked as such, and must not
19 be misrepresented as being the original software.
20
213. This notice may not be removed or altered from any source
22 distribution.
23
diff --git a/raylib/src/external/glfw/README.md b/raylib/src/external/glfw/README.md
new file mode 100644
index 0000000..c5501ff
--- /dev/null
+++ b/raylib/src/external/glfw/README.md
@@ -0,0 +1,18 @@
1# GLFW (modified for raylib)
2
3This directory contains a modification of GLFW, whose official website and
4upstream repository are https://glfw.org and https://github.com/glfw/glfw,
5respectively.
6
7In this modification, some static functions sharing the same name in different
8platforms have been renamed so all of GLFW's source files can be combined into
9one (as done by ``rglfw.c``). Also, the Null platform, which is not used by
10raylib, has been disabled. The renamed functions are:
11
12``
13createKeyTables()
14translateKey()
15acquireMonitor()
16releaseMonitor()
17``
18
diff --git a/raylib/src/external/glfw/deps/getopt.c b/raylib/src/external/glfw/deps/getopt.c
new file mode 100644
index 0000000..9743046
--- /dev/null
+++ b/raylib/src/external/glfw/deps/getopt.c
@@ -0,0 +1,230 @@
1/* Copyright (c) 2012, Kim Gräsman
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * * Neither the name of Kim Gräsman nor the names of contributors may be used
12 * to endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "getopt.h"
28
29#include <stddef.h>
30#include <string.h>
31
32const int no_argument = 0;
33const int required_argument = 1;
34const int optional_argument = 2;
35
36char* optarg;
37int optopt;
38/* The variable optind [...] shall be initialized to 1 by the system. */
39int optind = 1;
40int opterr;
41
42static char* optcursor = NULL;
43
44/* Implemented based on [1] and [2] for optional arguments.
45 optopt is handled FreeBSD-style, per [3].
46 Other GNU and FreeBSD extensions are purely accidental.
47
48[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html
49[2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
50[3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE
51*/
52int getopt(int argc, char* const argv[], const char* optstring) {
53 int optchar = -1;
54 const char* optdecl = NULL;
55
56 optarg = NULL;
57 opterr = 0;
58 optopt = 0;
59
60 /* Unspecified, but we need it to avoid overrunning the argv bounds. */
61 if (optind >= argc)
62 goto no_more_optchars;
63
64 /* If, when getopt() is called argv[optind] is a null pointer, getopt()
65 shall return -1 without changing optind. */
66 if (argv[optind] == NULL)
67 goto no_more_optchars;
68
69 /* If, when getopt() is called *argv[optind] is not the character '-',
70 getopt() shall return -1 without changing optind. */
71 if (*argv[optind] != '-')
72 goto no_more_optchars;
73
74 /* If, when getopt() is called argv[optind] points to the string "-",
75 getopt() shall return -1 without changing optind. */
76 if (strcmp(argv[optind], "-") == 0)
77 goto no_more_optchars;
78
79 /* If, when getopt() is called argv[optind] points to the string "--",
80 getopt() shall return -1 after incrementing optind. */
81 if (strcmp(argv[optind], "--") == 0) {
82 ++optind;
83 goto no_more_optchars;
84 }
85
86 if (optcursor == NULL || *optcursor == '\0')
87 optcursor = argv[optind] + 1;
88
89 optchar = *optcursor;
90
91 /* FreeBSD: The variable optopt saves the last known option character
92 returned by getopt(). */
93 optopt = optchar;
94
95 /* The getopt() function shall return the next option character (if one is
96 found) from argv that matches a character in optstring, if there is
97 one that matches. */
98 optdecl = strchr(optstring, optchar);
99 if (optdecl) {
100 /* [I]f a character is followed by a colon, the option takes an
101 argument. */
102 if (optdecl[1] == ':') {
103 optarg = ++optcursor;
104 if (*optarg == '\0') {
105 /* GNU extension: Two colons mean an option takes an
106 optional arg; if there is text in the current argv-element
107 (i.e., in the same word as the option name itself, for example,
108 "-oarg"), then it is returned in optarg, otherwise optarg is set
109 to zero. */
110 if (optdecl[2] != ':') {
111 /* If the option was the last character in the string pointed to by
112 an element of argv, then optarg shall contain the next element
113 of argv, and optind shall be incremented by 2. If the resulting
114 value of optind is greater than argc, this indicates a missing
115 option-argument, and getopt() shall return an error indication.
116
117 Otherwise, optarg shall point to the string following the
118 option character in that element of argv, and optind shall be
119 incremented by 1.
120 */
121 if (++optind < argc) {
122 optarg = argv[optind];
123 } else {
124 /* If it detects a missing option-argument, it shall return the
125 colon character ( ':' ) if the first character of optstring
126 was a colon, or a question-mark character ( '?' ) otherwise.
127 */
128 optarg = NULL;
129 optchar = (optstring[0] == ':') ? ':' : '?';
130 }
131 } else {
132 optarg = NULL;
133 }
134 }
135
136 optcursor = NULL;
137 }
138 } else {
139 /* If getopt() encounters an option character that is not contained in
140 optstring, it shall return the question-mark ( '?' ) character. */
141 optchar = '?';
142 }
143
144 if (optcursor == NULL || *++optcursor == '\0')
145 ++optind;
146
147 return optchar;
148
149no_more_optchars:
150 optcursor = NULL;
151 return -1;
152}
153
154/* Implementation based on [1].
155
156[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
157*/
158int getopt_long(int argc, char* const argv[], const char* optstring,
159 const struct option* longopts, int* longindex) {
160 const struct option* o = longopts;
161 const struct option* match = NULL;
162 int num_matches = 0;
163 size_t argument_name_length = 0;
164 const char* current_argument = NULL;
165 int retval = -1;
166
167 optarg = NULL;
168 optopt = 0;
169
170 if (optind >= argc)
171 return -1;
172
173 if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0)
174 return getopt(argc, argv, optstring);
175
176 /* It's an option; starts with -- and is longer than two chars. */
177 current_argument = argv[optind] + 2;
178 argument_name_length = strcspn(current_argument, "=");
179 for (; o->name; ++o) {
180 if (strncmp(o->name, current_argument, argument_name_length) == 0) {
181 match = o;
182 ++num_matches;
183 }
184 }
185
186 if (num_matches == 1) {
187 /* If longindex is not NULL, it points to a variable which is set to the
188 index of the long option relative to longopts. */
189 if (longindex)
190 *longindex = (int) (match - longopts);
191
192 /* If flag is NULL, then getopt_long() shall return val.
193 Otherwise, getopt_long() returns 0, and flag shall point to a variable
194 which shall be set to val if the option is found, but left unchanged if
195 the option is not found. */
196 if (match->flag)
197 *(match->flag) = match->val;
198
199 retval = match->flag ? 0 : match->val;
200
201 if (match->has_arg != no_argument) {
202 optarg = strchr(argv[optind], '=');
203 if (optarg != NULL)
204 ++optarg;
205
206 if (match->has_arg == required_argument) {
207 /* Only scan the next argv for required arguments. Behavior is not
208 specified, but has been observed with Ubuntu and Mac OSX. */
209 if (optarg == NULL && ++optind < argc) {
210 optarg = argv[optind];
211 }
212
213 if (optarg == NULL)
214 retval = ':';
215 }
216 } else if (strchr(argv[optind], '=')) {
217 /* An argument was provided to a non-argument option.
218 I haven't seen this specified explicitly, but both GNU and BSD-based
219 implementations show this behavior.
220 */
221 retval = '?';
222 }
223 } else {
224 /* Unknown option or ambiguous match. */
225 retval = '?';
226 }
227
228 ++optind;
229 return retval;
230}
diff --git a/raylib/src/external/glfw/deps/getopt.h b/raylib/src/external/glfw/deps/getopt.h
new file mode 100644
index 0000000..e1eb540
--- /dev/null
+++ b/raylib/src/external/glfw/deps/getopt.h
@@ -0,0 +1,57 @@
1/* Copyright (c) 2012, Kim Gräsman
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * * Neither the name of Kim Gräsman nor the names of contributors may be used
12 * to endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef INCLUDED_GETOPT_PORT_H
28#define INCLUDED_GETOPT_PORT_H
29
30#if defined(__cplusplus)
31extern "C" {
32#endif
33
34extern const int no_argument;
35extern const int required_argument;
36extern const int optional_argument;
37
38extern char* optarg;
39extern int optind, opterr, optopt;
40
41struct option {
42 const char* name;
43 int has_arg;
44 int* flag;
45 int val;
46};
47
48int getopt(int argc, char* const argv[], const char* optstring);
49
50int getopt_long(int argc, char* const argv[],
51 const char* optstring, const struct option* longopts, int* longindex);
52
53#if defined(__cplusplus)
54}
55#endif
56
57#endif // INCLUDED_GETOPT_PORT_H
diff --git a/raylib/src/external/glfw/deps/glad/gl.h b/raylib/src/external/glfw/deps/glad/gl.h
new file mode 100644
index 0000000..b421fe0
--- /dev/null
+++ b/raylib/src/external/glfw/deps/glad/gl.h
@@ -0,0 +1,5996 @@
1/**
2 * Loader generated by glad 2.0.0-beta on Tue Aug 24 22:51:07 2021
3 *
4 * Generator: C/C++
5 * Specification: gl
6 * Extensions: 3
7 *
8 * APIs:
9 * - gl:compatibility=3.3
10 *
11 * Options:
12 * - ALIAS = False
13 * - DEBUG = False
14 * - HEADER_ONLY = True
15 * - LOADER = False
16 * - MX = False
17 * - MX_GLOBAL = False
18 * - ON_DEMAND = False
19 *
20 * Commandline:
21 * --api='gl:compatibility=3.3' --extensions='GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug' c --header-only
22 *
23 * Online:
24 * http://glad.sh/#api=gl%3Acompatibility%3D3.3&extensions=GL_ARB_multisample%2CGL_ARB_robustness%2CGL_KHR_debug&generator=c&options=HEADER_ONLY
25 *
26 */
27
28#ifndef GLAD_GL_H_
29#define GLAD_GL_H_
30
31#ifdef __clang__
32#pragma clang diagnostic push
33#pragma clang diagnostic ignored "-Wreserved-id-macro"
34#endif
35#ifdef __gl_h_
36 #error OpenGL (gl.h) header already included (API: gl), remove previous include!
37#endif
38#define __gl_h_ 1
39#ifdef __gl3_h_
40 #error OpenGL (gl3.h) header already included (API: gl), remove previous include!
41#endif
42#define __gl3_h_ 1
43#ifdef __glext_h_
44 #error OpenGL (glext.h) header already included (API: gl), remove previous include!
45#endif
46#define __glext_h_ 1
47#ifdef __gl3ext_h_
48 #error OpenGL (gl3ext.h) header already included (API: gl), remove previous include!
49#endif
50#define __gl3ext_h_ 1
51#ifdef __clang__
52#pragma clang diagnostic pop
53#endif
54
55#define GLAD_GL
56#define GLAD_OPTION_GL_HEADER_ONLY
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62#ifndef GLAD_PLATFORM_H_
63#define GLAD_PLATFORM_H_
64
65#ifndef GLAD_PLATFORM_WIN32
66 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
67 #define GLAD_PLATFORM_WIN32 1
68 #else
69 #define GLAD_PLATFORM_WIN32 0
70 #endif
71#endif
72
73#ifndef GLAD_PLATFORM_APPLE
74 #ifdef __APPLE__
75 #define GLAD_PLATFORM_APPLE 1
76 #else
77 #define GLAD_PLATFORM_APPLE 0
78 #endif
79#endif
80
81#ifndef GLAD_PLATFORM_EMSCRIPTEN
82 #ifdef __EMSCRIPTEN__
83 #define GLAD_PLATFORM_EMSCRIPTEN 1
84 #else
85 #define GLAD_PLATFORM_EMSCRIPTEN 0
86 #endif
87#endif
88
89#ifndef GLAD_PLATFORM_UWP
90 #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
91 #ifdef __has_include
92 #if __has_include(<winapifamily.h>)
93 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
94 #endif
95 #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
96 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
97 #endif
98 #endif
99
100 #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
101 #include <winapifamily.h>
102 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
103 #define GLAD_PLATFORM_UWP 1
104 #endif
105 #endif
106
107 #ifndef GLAD_PLATFORM_UWP
108 #define GLAD_PLATFORM_UWP 0
109 #endif
110#endif
111
112#ifdef __GNUC__
113 #define GLAD_GNUC_EXTENSION __extension__
114#else
115 #define GLAD_GNUC_EXTENSION
116#endif
117
118#ifndef GLAD_API_CALL
119 #if defined(GLAD_API_CALL_EXPORT)
120 #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
121 #if defined(GLAD_API_CALL_EXPORT_BUILD)
122 #if defined(__GNUC__)
123 #define GLAD_API_CALL __attribute__ ((dllexport)) extern
124 #else
125 #define GLAD_API_CALL __declspec(dllexport) extern
126 #endif
127 #else
128 #if defined(__GNUC__)
129 #define GLAD_API_CALL __attribute__ ((dllimport)) extern
130 #else
131 #define GLAD_API_CALL __declspec(dllimport) extern
132 #endif
133 #endif
134 #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
135 #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
136 #else
137 #define GLAD_API_CALL extern
138 #endif
139 #else
140 #define GLAD_API_CALL extern
141 #endif
142#endif
143
144#ifdef APIENTRY
145 #define GLAD_API_PTR APIENTRY
146#elif GLAD_PLATFORM_WIN32
147 #define GLAD_API_PTR __stdcall
148#else
149 #define GLAD_API_PTR
150#endif
151
152#ifndef GLAPI
153#define GLAPI GLAD_API_CALL
154#endif
155
156#ifndef GLAPIENTRY
157#define GLAPIENTRY GLAD_API_PTR
158#endif
159
160#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
161#define GLAD_VERSION_MAJOR(version) (version / 10000)
162#define GLAD_VERSION_MINOR(version) (version % 10000)
163
164#define GLAD_GENERATOR_VERSION "2.0.0-beta"
165
166typedef void (*GLADapiproc)(void);
167
168typedef GLADapiproc (*GLADloadfunc)(const char *name);
169typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
170
171typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
172typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
173
174#endif /* GLAD_PLATFORM_H_ */
175
176#define GL_2D 0x0600
177#define GL_2_BYTES 0x1407
178#define GL_3D 0x0601
179#define GL_3D_COLOR 0x0602
180#define GL_3D_COLOR_TEXTURE 0x0603
181#define GL_3_BYTES 0x1408
182#define GL_4D_COLOR_TEXTURE 0x0604
183#define GL_4_BYTES 0x1409
184#define GL_ACCUM 0x0100
185#define GL_ACCUM_ALPHA_BITS 0x0D5B
186#define GL_ACCUM_BLUE_BITS 0x0D5A
187#define GL_ACCUM_BUFFER_BIT 0x00000200
188#define GL_ACCUM_CLEAR_VALUE 0x0B80
189#define GL_ACCUM_GREEN_BITS 0x0D59
190#define GL_ACCUM_RED_BITS 0x0D58
191#define GL_ACTIVE_ATTRIBUTES 0x8B89
192#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
193#define GL_ACTIVE_TEXTURE 0x84E0
194#define GL_ACTIVE_UNIFORMS 0x8B86
195#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
196#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
197#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
198#define GL_ADD 0x0104
199#define GL_ADD_SIGNED 0x8574
200#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
201#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
202#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF
203#define GL_ALPHA 0x1906
204#define GL_ALPHA12 0x803D
205#define GL_ALPHA16 0x803E
206#define GL_ALPHA4 0x803B
207#define GL_ALPHA8 0x803C
208#define GL_ALPHA_BIAS 0x0D1D
209#define GL_ALPHA_BITS 0x0D55
210#define GL_ALPHA_INTEGER 0x8D97
211#define GL_ALPHA_SCALE 0x0D1C
212#define GL_ALPHA_TEST 0x0BC0
213#define GL_ALPHA_TEST_FUNC 0x0BC1
214#define GL_ALPHA_TEST_REF 0x0BC2
215#define GL_ALREADY_SIGNALED 0x911A
216#define GL_ALWAYS 0x0207
217#define GL_AMBIENT 0x1200
218#define GL_AMBIENT_AND_DIFFUSE 0x1602
219#define GL_AND 0x1501
220#define GL_AND_INVERTED 0x1504
221#define GL_AND_REVERSE 0x1502
222#define GL_ANY_SAMPLES_PASSED 0x8C2F
223#define GL_ARRAY_BUFFER 0x8892
224#define GL_ARRAY_BUFFER_BINDING 0x8894
225#define GL_ATTACHED_SHADERS 0x8B85
226#define GL_ATTRIB_STACK_DEPTH 0x0BB0
227#define GL_AUTO_NORMAL 0x0D80
228#define GL_AUX0 0x0409
229#define GL_AUX1 0x040A
230#define GL_AUX2 0x040B
231#define GL_AUX3 0x040C
232#define GL_AUX_BUFFERS 0x0C00
233#define GL_BACK 0x0405
234#define GL_BACK_LEFT 0x0402
235#define GL_BACK_RIGHT 0x0403
236#define GL_BGR 0x80E0
237#define GL_BGRA 0x80E1
238#define GL_BGRA_INTEGER 0x8D9B
239#define GL_BGR_INTEGER 0x8D9A
240#define GL_BITMAP 0x1A00
241#define GL_BITMAP_TOKEN 0x0704
242#define GL_BLEND 0x0BE2
243#define GL_BLEND_COLOR 0x8005
244#define GL_BLEND_DST 0x0BE0
245#define GL_BLEND_DST_ALPHA 0x80CA
246#define GL_BLEND_DST_RGB 0x80C8
247#define GL_BLEND_EQUATION 0x8009
248#define GL_BLEND_EQUATION_ALPHA 0x883D
249#define GL_BLEND_EQUATION_RGB 0x8009
250#define GL_BLEND_SRC 0x0BE1
251#define GL_BLEND_SRC_ALPHA 0x80CB
252#define GL_BLEND_SRC_RGB 0x80C9
253#define GL_BLUE 0x1905
254#define GL_BLUE_BIAS 0x0D1B
255#define GL_BLUE_BITS 0x0D54
256#define GL_BLUE_INTEGER 0x8D96
257#define GL_BLUE_SCALE 0x0D1A
258#define GL_BOOL 0x8B56
259#define GL_BOOL_VEC2 0x8B57
260#define GL_BOOL_VEC3 0x8B58
261#define GL_BOOL_VEC4 0x8B59
262#define GL_BUFFER 0x82E0
263#define GL_BUFFER_ACCESS 0x88BB
264#define GL_BUFFER_ACCESS_FLAGS 0x911F
265#define GL_BUFFER_MAPPED 0x88BC
266#define GL_BUFFER_MAP_LENGTH 0x9120
267#define GL_BUFFER_MAP_OFFSET 0x9121
268#define GL_BUFFER_MAP_POINTER 0x88BD
269#define GL_BUFFER_SIZE 0x8764
270#define GL_BUFFER_USAGE 0x8765
271#define GL_BYTE 0x1400
272#define GL_C3F_V3F 0x2A24
273#define GL_C4F_N3F_V3F 0x2A26
274#define GL_C4UB_V2F 0x2A22
275#define GL_C4UB_V3F 0x2A23
276#define GL_CCW 0x0901
277#define GL_CLAMP 0x2900
278#define GL_CLAMP_FRAGMENT_COLOR 0x891B
279#define GL_CLAMP_READ_COLOR 0x891C
280#define GL_CLAMP_TO_BORDER 0x812D
281#define GL_CLAMP_TO_EDGE 0x812F
282#define GL_CLAMP_VERTEX_COLOR 0x891A
283#define GL_CLEAR 0x1500
284#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
285#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
286#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
287#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
288#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
289#define GL_CLIP_DISTANCE0 0x3000
290#define GL_CLIP_DISTANCE1 0x3001
291#define GL_CLIP_DISTANCE2 0x3002
292#define GL_CLIP_DISTANCE3 0x3003
293#define GL_CLIP_DISTANCE4 0x3004
294#define GL_CLIP_DISTANCE5 0x3005
295#define GL_CLIP_DISTANCE6 0x3006
296#define GL_CLIP_DISTANCE7 0x3007
297#define GL_CLIP_PLANE0 0x3000
298#define GL_CLIP_PLANE1 0x3001
299#define GL_CLIP_PLANE2 0x3002
300#define GL_CLIP_PLANE3 0x3003
301#define GL_CLIP_PLANE4 0x3004
302#define GL_CLIP_PLANE5 0x3005
303#define GL_COEFF 0x0A00
304#define GL_COLOR 0x1800
305#define GL_COLOR_ARRAY 0x8076
306#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
307#define GL_COLOR_ARRAY_POINTER 0x8090
308#define GL_COLOR_ARRAY_SIZE 0x8081
309#define GL_COLOR_ARRAY_STRIDE 0x8083
310#define GL_COLOR_ARRAY_TYPE 0x8082
311#define GL_COLOR_ATTACHMENT0 0x8CE0
312#define GL_COLOR_ATTACHMENT1 0x8CE1
313#define GL_COLOR_ATTACHMENT10 0x8CEA
314#define GL_COLOR_ATTACHMENT11 0x8CEB
315#define GL_COLOR_ATTACHMENT12 0x8CEC
316#define GL_COLOR_ATTACHMENT13 0x8CED
317#define GL_COLOR_ATTACHMENT14 0x8CEE
318#define GL_COLOR_ATTACHMENT15 0x8CEF
319#define GL_COLOR_ATTACHMENT16 0x8CF0
320#define GL_COLOR_ATTACHMENT17 0x8CF1
321#define GL_COLOR_ATTACHMENT18 0x8CF2
322#define GL_COLOR_ATTACHMENT19 0x8CF3
323#define GL_COLOR_ATTACHMENT2 0x8CE2
324#define GL_COLOR_ATTACHMENT20 0x8CF4
325#define GL_COLOR_ATTACHMENT21 0x8CF5
326#define GL_COLOR_ATTACHMENT22 0x8CF6
327#define GL_COLOR_ATTACHMENT23 0x8CF7
328#define GL_COLOR_ATTACHMENT24 0x8CF8
329#define GL_COLOR_ATTACHMENT25 0x8CF9
330#define GL_COLOR_ATTACHMENT26 0x8CFA
331#define GL_COLOR_ATTACHMENT27 0x8CFB
332#define GL_COLOR_ATTACHMENT28 0x8CFC
333#define GL_COLOR_ATTACHMENT29 0x8CFD
334#define GL_COLOR_ATTACHMENT3 0x8CE3
335#define GL_COLOR_ATTACHMENT30 0x8CFE
336#define GL_COLOR_ATTACHMENT31 0x8CFF
337#define GL_COLOR_ATTACHMENT4 0x8CE4
338#define GL_COLOR_ATTACHMENT5 0x8CE5
339#define GL_COLOR_ATTACHMENT6 0x8CE6
340#define GL_COLOR_ATTACHMENT7 0x8CE7
341#define GL_COLOR_ATTACHMENT8 0x8CE8
342#define GL_COLOR_ATTACHMENT9 0x8CE9
343#define GL_COLOR_BUFFER_BIT 0x00004000
344#define GL_COLOR_CLEAR_VALUE 0x0C22
345#define GL_COLOR_INDEX 0x1900
346#define GL_COLOR_INDEXES 0x1603
347#define GL_COLOR_LOGIC_OP 0x0BF2
348#define GL_COLOR_MATERIAL 0x0B57
349#define GL_COLOR_MATERIAL_FACE 0x0B55
350#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
351#define GL_COLOR_SUM 0x8458
352#define GL_COLOR_WRITEMASK 0x0C23
353#define GL_COMBINE 0x8570
354#define GL_COMBINE_ALPHA 0x8572
355#define GL_COMBINE_RGB 0x8571
356#define GL_COMPARE_REF_TO_TEXTURE 0x884E
357#define GL_COMPARE_R_TO_TEXTURE 0x884E
358#define GL_COMPILE 0x1300
359#define GL_COMPILE_AND_EXECUTE 0x1301
360#define GL_COMPILE_STATUS 0x8B81
361#define GL_COMPRESSED_ALPHA 0x84E9
362#define GL_COMPRESSED_INTENSITY 0x84EC
363#define GL_COMPRESSED_LUMINANCE 0x84EA
364#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
365#define GL_COMPRESSED_RED 0x8225
366#define GL_COMPRESSED_RED_RGTC1 0x8DBB
367#define GL_COMPRESSED_RG 0x8226
368#define GL_COMPRESSED_RGB 0x84ED
369#define GL_COMPRESSED_RGBA 0x84EE
370#define GL_COMPRESSED_RG_RGTC2 0x8DBD
371#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
372#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
373#define GL_COMPRESSED_SLUMINANCE 0x8C4A
374#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B
375#define GL_COMPRESSED_SRGB 0x8C48
376#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
377#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
378#define GL_CONDITION_SATISFIED 0x911C
379#define GL_CONSTANT 0x8576
380#define GL_CONSTANT_ALPHA 0x8003
381#define GL_CONSTANT_ATTENUATION 0x1207
382#define GL_CONSTANT_COLOR 0x8001
383#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
384#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
385#define GL_CONTEXT_FLAGS 0x821E
386#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
387#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
388#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
389#define GL_CONTEXT_PROFILE_MASK 0x9126
390#define GL_COORD_REPLACE 0x8862
391#define GL_COPY 0x1503
392#define GL_COPY_INVERTED 0x150C
393#define GL_COPY_PIXEL_TOKEN 0x0706
394#define GL_COPY_READ_BUFFER 0x8F36
395#define GL_COPY_WRITE_BUFFER 0x8F37
396#define GL_CULL_FACE 0x0B44
397#define GL_CULL_FACE_MODE 0x0B45
398#define GL_CURRENT_BIT 0x00000001
399#define GL_CURRENT_COLOR 0x0B00
400#define GL_CURRENT_FOG_COORD 0x8453
401#define GL_CURRENT_FOG_COORDINATE 0x8453
402#define GL_CURRENT_INDEX 0x0B01
403#define GL_CURRENT_NORMAL 0x0B02
404#define GL_CURRENT_PROGRAM 0x8B8D
405#define GL_CURRENT_QUERY 0x8865
406#define GL_CURRENT_RASTER_COLOR 0x0B04
407#define GL_CURRENT_RASTER_DISTANCE 0x0B09
408#define GL_CURRENT_RASTER_INDEX 0x0B05
409#define GL_CURRENT_RASTER_POSITION 0x0B07
410#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
411#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
412#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
413#define GL_CURRENT_SECONDARY_COLOR 0x8459
414#define GL_CURRENT_TEXTURE_COORDS 0x0B03
415#define GL_CURRENT_VERTEX_ATTRIB 0x8626
416#define GL_CW 0x0900
417#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
418#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
419#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
420#define GL_DEBUG_LOGGED_MESSAGES 0x9145
421#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
422#define GL_DEBUG_OUTPUT 0x92E0
423#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
424#define GL_DEBUG_SEVERITY_HIGH 0x9146
425#define GL_DEBUG_SEVERITY_LOW 0x9148
426#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
427#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
428#define GL_DEBUG_SOURCE_API 0x8246
429#define GL_DEBUG_SOURCE_APPLICATION 0x824A
430#define GL_DEBUG_SOURCE_OTHER 0x824B
431#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
432#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
433#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
434#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
435#define GL_DEBUG_TYPE_ERROR 0x824C
436#define GL_DEBUG_TYPE_MARKER 0x8268
437#define GL_DEBUG_TYPE_OTHER 0x8251
438#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
439#define GL_DEBUG_TYPE_POP_GROUP 0x826A
440#define GL_DEBUG_TYPE_PORTABILITY 0x824F
441#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
442#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
443#define GL_DECAL 0x2101
444#define GL_DECR 0x1E03
445#define GL_DECR_WRAP 0x8508
446#define GL_DELETE_STATUS 0x8B80
447#define GL_DEPTH 0x1801
448#define GL_DEPTH24_STENCIL8 0x88F0
449#define GL_DEPTH32F_STENCIL8 0x8CAD
450#define GL_DEPTH_ATTACHMENT 0x8D00
451#define GL_DEPTH_BIAS 0x0D1F
452#define GL_DEPTH_BITS 0x0D56
453#define GL_DEPTH_BUFFER_BIT 0x00000100
454#define GL_DEPTH_CLAMP 0x864F
455#define GL_DEPTH_CLEAR_VALUE 0x0B73
456#define GL_DEPTH_COMPONENT 0x1902
457#define GL_DEPTH_COMPONENT16 0x81A5
458#define GL_DEPTH_COMPONENT24 0x81A6
459#define GL_DEPTH_COMPONENT32 0x81A7
460#define GL_DEPTH_COMPONENT32F 0x8CAC
461#define GL_DEPTH_FUNC 0x0B74
462#define GL_DEPTH_RANGE 0x0B70
463#define GL_DEPTH_SCALE 0x0D1E
464#define GL_DEPTH_STENCIL 0x84F9
465#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
466#define GL_DEPTH_TEST 0x0B71
467#define GL_DEPTH_TEXTURE_MODE 0x884B
468#define GL_DEPTH_WRITEMASK 0x0B72
469#define GL_DIFFUSE 0x1201
470#define GL_DISPLAY_LIST 0x82E7
471#define GL_DITHER 0x0BD0
472#define GL_DOMAIN 0x0A02
473#define GL_DONT_CARE 0x1100
474#define GL_DOT3_RGB 0x86AE
475#define GL_DOT3_RGBA 0x86AF
476#define GL_DOUBLE 0x140A
477#define GL_DOUBLEBUFFER 0x0C32
478#define GL_DRAW_BUFFER 0x0C01
479#define GL_DRAW_BUFFER0 0x8825
480#define GL_DRAW_BUFFER1 0x8826
481#define GL_DRAW_BUFFER10 0x882F
482#define GL_DRAW_BUFFER11 0x8830
483#define GL_DRAW_BUFFER12 0x8831
484#define GL_DRAW_BUFFER13 0x8832
485#define GL_DRAW_BUFFER14 0x8833
486#define GL_DRAW_BUFFER15 0x8834
487#define GL_DRAW_BUFFER2 0x8827
488#define GL_DRAW_BUFFER3 0x8828
489#define GL_DRAW_BUFFER4 0x8829
490#define GL_DRAW_BUFFER5 0x882A
491#define GL_DRAW_BUFFER6 0x882B
492#define GL_DRAW_BUFFER7 0x882C
493#define GL_DRAW_BUFFER8 0x882D
494#define GL_DRAW_BUFFER9 0x882E
495#define GL_DRAW_FRAMEBUFFER 0x8CA9
496#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
497#define GL_DRAW_PIXEL_TOKEN 0x0705
498#define GL_DST_ALPHA 0x0304
499#define GL_DST_COLOR 0x0306
500#define GL_DYNAMIC_COPY 0x88EA
501#define GL_DYNAMIC_DRAW 0x88E8
502#define GL_DYNAMIC_READ 0x88E9
503#define GL_EDGE_FLAG 0x0B43
504#define GL_EDGE_FLAG_ARRAY 0x8079
505#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
506#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
507#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
508#define GL_ELEMENT_ARRAY_BUFFER 0x8893
509#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
510#define GL_EMISSION 0x1600
511#define GL_ENABLE_BIT 0x00002000
512#define GL_EQUAL 0x0202
513#define GL_EQUIV 0x1509
514#define GL_EVAL_BIT 0x00010000
515#define GL_EXP 0x0800
516#define GL_EXP2 0x0801
517#define GL_EXTENSIONS 0x1F03
518#define GL_EYE_LINEAR 0x2400
519#define GL_EYE_PLANE 0x2502
520#define GL_FALSE 0
521#define GL_FASTEST 0x1101
522#define GL_FEEDBACK 0x1C01
523#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
524#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
525#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
526#define GL_FILL 0x1B02
527#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
528#define GL_FIXED_ONLY 0x891D
529#define GL_FLAT 0x1D00
530#define GL_FLOAT 0x1406
531#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
532#define GL_FLOAT_MAT2 0x8B5A
533#define GL_FLOAT_MAT2x3 0x8B65
534#define GL_FLOAT_MAT2x4 0x8B66
535#define GL_FLOAT_MAT3 0x8B5B
536#define GL_FLOAT_MAT3x2 0x8B67
537#define GL_FLOAT_MAT3x4 0x8B68
538#define GL_FLOAT_MAT4 0x8B5C
539#define GL_FLOAT_MAT4x2 0x8B69
540#define GL_FLOAT_MAT4x3 0x8B6A
541#define GL_FLOAT_VEC2 0x8B50
542#define GL_FLOAT_VEC3 0x8B51
543#define GL_FLOAT_VEC4 0x8B52
544#define GL_FOG 0x0B60
545#define GL_FOG_BIT 0x00000080
546#define GL_FOG_COLOR 0x0B66
547#define GL_FOG_COORD 0x8451
548#define GL_FOG_COORDINATE 0x8451
549#define GL_FOG_COORDINATE_ARRAY 0x8457
550#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
551#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
552#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
553#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
554#define GL_FOG_COORDINATE_SOURCE 0x8450
555#define GL_FOG_COORD_ARRAY 0x8457
556#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
557#define GL_FOG_COORD_ARRAY_POINTER 0x8456
558#define GL_FOG_COORD_ARRAY_STRIDE 0x8455
559#define GL_FOG_COORD_ARRAY_TYPE 0x8454
560#define GL_FOG_COORD_SRC 0x8450
561#define GL_FOG_DENSITY 0x0B62
562#define GL_FOG_END 0x0B64
563#define GL_FOG_HINT 0x0C54
564#define GL_FOG_INDEX 0x0B61
565#define GL_FOG_MODE 0x0B65
566#define GL_FOG_START 0x0B63
567#define GL_FRAGMENT_DEPTH 0x8452
568#define GL_FRAGMENT_SHADER 0x8B30
569#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
570#define GL_FRAMEBUFFER 0x8D40
571#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
572#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
573#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
574#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
575#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
576#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
577#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
578#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
579#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
580#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
581#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
582#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
583#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
584#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
585#define GL_FRAMEBUFFER_BINDING 0x8CA6
586#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
587#define GL_FRAMEBUFFER_DEFAULT 0x8218
588#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
589#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
590#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
591#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
592#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
593#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
594#define GL_FRAMEBUFFER_SRGB 0x8DB9
595#define GL_FRAMEBUFFER_UNDEFINED 0x8219
596#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
597#define GL_FRONT 0x0404
598#define GL_FRONT_AND_BACK 0x0408
599#define GL_FRONT_FACE 0x0B46
600#define GL_FRONT_LEFT 0x0400
601#define GL_FRONT_RIGHT 0x0401
602#define GL_FUNC_ADD 0x8006
603#define GL_FUNC_REVERSE_SUBTRACT 0x800B
604#define GL_FUNC_SUBTRACT 0x800A
605#define GL_GENERATE_MIPMAP 0x8191
606#define GL_GENERATE_MIPMAP_HINT 0x8192
607#define GL_GEOMETRY_INPUT_TYPE 0x8917
608#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
609#define GL_GEOMETRY_SHADER 0x8DD9
610#define GL_GEOMETRY_VERTICES_OUT 0x8916
611#define GL_GEQUAL 0x0206
612#define GL_GREATER 0x0204
613#define GL_GREEN 0x1904
614#define GL_GREEN_BIAS 0x0D19
615#define GL_GREEN_BITS 0x0D53
616#define GL_GREEN_INTEGER 0x8D95
617#define GL_GREEN_SCALE 0x0D18
618#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
619#define GL_HALF_FLOAT 0x140B
620#define GL_HINT_BIT 0x00008000
621#define GL_INCR 0x1E02
622#define GL_INCR_WRAP 0x8507
623#define GL_INDEX 0x8222
624#define GL_INDEX_ARRAY 0x8077
625#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
626#define GL_INDEX_ARRAY_POINTER 0x8091
627#define GL_INDEX_ARRAY_STRIDE 0x8086
628#define GL_INDEX_ARRAY_TYPE 0x8085
629#define GL_INDEX_BITS 0x0D51
630#define GL_INDEX_CLEAR_VALUE 0x0C20
631#define GL_INDEX_LOGIC_OP 0x0BF1
632#define GL_INDEX_MODE 0x0C30
633#define GL_INDEX_OFFSET 0x0D13
634#define GL_INDEX_SHIFT 0x0D12
635#define GL_INDEX_WRITEMASK 0x0C21
636#define GL_INFO_LOG_LENGTH 0x8B84
637#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
638#define GL_INT 0x1404
639#define GL_INTENSITY 0x8049
640#define GL_INTENSITY12 0x804C
641#define GL_INTENSITY16 0x804D
642#define GL_INTENSITY4 0x804A
643#define GL_INTENSITY8 0x804B
644#define GL_INTERLEAVED_ATTRIBS 0x8C8C
645#define GL_INTERPOLATE 0x8575
646#define GL_INT_2_10_10_10_REV 0x8D9F
647#define GL_INT_SAMPLER_1D 0x8DC9
648#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
649#define GL_INT_SAMPLER_2D 0x8DCA
650#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
651#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
652#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
653#define GL_INT_SAMPLER_2D_RECT 0x8DCD
654#define GL_INT_SAMPLER_3D 0x8DCB
655#define GL_INT_SAMPLER_BUFFER 0x8DD0
656#define GL_INT_SAMPLER_CUBE 0x8DCC
657#define GL_INT_VEC2 0x8B53
658#define GL_INT_VEC3 0x8B54
659#define GL_INT_VEC4 0x8B55
660#define GL_INVALID_ENUM 0x0500
661#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
662#define GL_INVALID_INDEX 0xFFFFFFFF
663#define GL_INVALID_OPERATION 0x0502
664#define GL_INVALID_VALUE 0x0501
665#define GL_INVERT 0x150A
666#define GL_KEEP 0x1E00
667#define GL_LAST_VERTEX_CONVENTION 0x8E4E
668#define GL_LEFT 0x0406
669#define GL_LEQUAL 0x0203
670#define GL_LESS 0x0201
671#define GL_LIGHT0 0x4000
672#define GL_LIGHT1 0x4001
673#define GL_LIGHT2 0x4002
674#define GL_LIGHT3 0x4003
675#define GL_LIGHT4 0x4004
676#define GL_LIGHT5 0x4005
677#define GL_LIGHT6 0x4006
678#define GL_LIGHT7 0x4007
679#define GL_LIGHTING 0x0B50
680#define GL_LIGHTING_BIT 0x00000040
681#define GL_LIGHT_MODEL_AMBIENT 0x0B53
682#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
683#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
684#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
685#define GL_LINE 0x1B01
686#define GL_LINEAR 0x2601
687#define GL_LINEAR_ATTENUATION 0x1208
688#define GL_LINEAR_MIPMAP_LINEAR 0x2703
689#define GL_LINEAR_MIPMAP_NEAREST 0x2701
690#define GL_LINES 0x0001
691#define GL_LINES_ADJACENCY 0x000A
692#define GL_LINE_BIT 0x00000004
693#define GL_LINE_LOOP 0x0002
694#define GL_LINE_RESET_TOKEN 0x0707
695#define GL_LINE_SMOOTH 0x0B20
696#define GL_LINE_SMOOTH_HINT 0x0C52
697#define GL_LINE_STIPPLE 0x0B24
698#define GL_LINE_STIPPLE_PATTERN 0x0B25
699#define GL_LINE_STIPPLE_REPEAT 0x0B26
700#define GL_LINE_STRIP 0x0003
701#define GL_LINE_STRIP_ADJACENCY 0x000B
702#define GL_LINE_TOKEN 0x0702
703#define GL_LINE_WIDTH 0x0B21
704#define GL_LINE_WIDTH_GRANULARITY 0x0B23
705#define GL_LINE_WIDTH_RANGE 0x0B22
706#define GL_LINK_STATUS 0x8B82
707#define GL_LIST_BASE 0x0B32
708#define GL_LIST_BIT 0x00020000
709#define GL_LIST_INDEX 0x0B33
710#define GL_LIST_MODE 0x0B30
711#define GL_LOAD 0x0101
712#define GL_LOGIC_OP 0x0BF1
713#define GL_LOGIC_OP_MODE 0x0BF0
714#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
715#define GL_LOWER_LEFT 0x8CA1
716#define GL_LUMINANCE 0x1909
717#define GL_LUMINANCE12 0x8041
718#define GL_LUMINANCE12_ALPHA12 0x8047
719#define GL_LUMINANCE12_ALPHA4 0x8046
720#define GL_LUMINANCE16 0x8042
721#define GL_LUMINANCE16_ALPHA16 0x8048
722#define GL_LUMINANCE4 0x803F
723#define GL_LUMINANCE4_ALPHA4 0x8043
724#define GL_LUMINANCE6_ALPHA2 0x8044
725#define GL_LUMINANCE8 0x8040
726#define GL_LUMINANCE8_ALPHA8 0x8045
727#define GL_LUMINANCE_ALPHA 0x190A
728#define GL_MAJOR_VERSION 0x821B
729#define GL_MAP1_COLOR_4 0x0D90
730#define GL_MAP1_GRID_DOMAIN 0x0DD0
731#define GL_MAP1_GRID_SEGMENTS 0x0DD1
732#define GL_MAP1_INDEX 0x0D91
733#define GL_MAP1_NORMAL 0x0D92
734#define GL_MAP1_TEXTURE_COORD_1 0x0D93
735#define GL_MAP1_TEXTURE_COORD_2 0x0D94
736#define GL_MAP1_TEXTURE_COORD_3 0x0D95
737#define GL_MAP1_TEXTURE_COORD_4 0x0D96
738#define GL_MAP1_VERTEX_3 0x0D97
739#define GL_MAP1_VERTEX_4 0x0D98
740#define GL_MAP2_COLOR_4 0x0DB0
741#define GL_MAP2_GRID_DOMAIN 0x0DD2
742#define GL_MAP2_GRID_SEGMENTS 0x0DD3
743#define GL_MAP2_INDEX 0x0DB1
744#define GL_MAP2_NORMAL 0x0DB2
745#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
746#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
747#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
748#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
749#define GL_MAP2_VERTEX_3 0x0DB7
750#define GL_MAP2_VERTEX_4 0x0DB8
751#define GL_MAP_COLOR 0x0D10
752#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
753#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
754#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
755#define GL_MAP_READ_BIT 0x0001
756#define GL_MAP_STENCIL 0x0D11
757#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
758#define GL_MAP_WRITE_BIT 0x0002
759#define GL_MATRIX_MODE 0x0BA0
760#define GL_MAX 0x8008
761#define GL_MAX_3D_TEXTURE_SIZE 0x8073
762#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
763#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
764#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
765#define GL_MAX_CLIP_DISTANCES 0x0D32
766#define GL_MAX_CLIP_PLANES 0x0D32
767#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
768#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
769#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
770#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
771#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
772#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
773#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
774#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
775#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
776#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
777#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
778#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
779#define GL_MAX_DRAW_BUFFERS 0x8824
780#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
781#define GL_MAX_ELEMENTS_INDICES 0x80E9
782#define GL_MAX_ELEMENTS_VERTICES 0x80E8
783#define GL_MAX_EVAL_ORDER 0x0D30
784#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
785#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
786#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
787#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
788#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
789#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
790#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
791#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
792#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
793#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
794#define GL_MAX_INTEGER_SAMPLES 0x9110
795#define GL_MAX_LABEL_LENGTH 0x82E8
796#define GL_MAX_LIGHTS 0x0D31
797#define GL_MAX_LIST_NESTING 0x0B31
798#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
799#define GL_MAX_NAME_STACK_DEPTH 0x0D37
800#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
801#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
802#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
803#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
804#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
805#define GL_MAX_SAMPLES 0x8D57
806#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
807#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
808#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
809#define GL_MAX_TEXTURE_COORDS 0x8871
810#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
811#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
812#define GL_MAX_TEXTURE_SIZE 0x0D33
813#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
814#define GL_MAX_TEXTURE_UNITS 0x84E2
815#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
816#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
817#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
818#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
819#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
820#define GL_MAX_VARYING_COMPONENTS 0x8B4B
821#define GL_MAX_VARYING_FLOATS 0x8B4B
822#define GL_MAX_VERTEX_ATTRIBS 0x8869
823#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
824#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
825#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
826#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
827#define GL_MAX_VIEWPORT_DIMS 0x0D3A
828#define GL_MIN 0x8007
829#define GL_MINOR_VERSION 0x821C
830#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
831#define GL_MIRRORED_REPEAT 0x8370
832#define GL_MODELVIEW 0x1700
833#define GL_MODELVIEW_MATRIX 0x0BA6
834#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
835#define GL_MODULATE 0x2100
836#define GL_MULT 0x0103
837#define GL_MULTISAMPLE 0x809D
838#define GL_MULTISAMPLE_ARB 0x809D
839#define GL_MULTISAMPLE_BIT 0x20000000
840#define GL_MULTISAMPLE_BIT_ARB 0x20000000
841#define GL_N3F_V3F 0x2A25
842#define GL_NAME_STACK_DEPTH 0x0D70
843#define GL_NAND 0x150E
844#define GL_NEAREST 0x2600
845#define GL_NEAREST_MIPMAP_LINEAR 0x2702
846#define GL_NEAREST_MIPMAP_NEAREST 0x2700
847#define GL_NEVER 0x0200
848#define GL_NICEST 0x1102
849#define GL_NONE 0
850#define GL_NOOP 0x1505
851#define GL_NOR 0x1508
852#define GL_NORMALIZE 0x0BA1
853#define GL_NORMAL_ARRAY 0x8075
854#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
855#define GL_NORMAL_ARRAY_POINTER 0x808F
856#define GL_NORMAL_ARRAY_STRIDE 0x807F
857#define GL_NORMAL_ARRAY_TYPE 0x807E
858#define GL_NORMAL_MAP 0x8511
859#define GL_NOTEQUAL 0x0205
860#define GL_NO_ERROR 0
861#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
862#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
863#define GL_NUM_EXTENSIONS 0x821D
864#define GL_OBJECT_LINEAR 0x2401
865#define GL_OBJECT_PLANE 0x2501
866#define GL_OBJECT_TYPE 0x9112
867#define GL_ONE 1
868#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
869#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
870#define GL_ONE_MINUS_DST_ALPHA 0x0305
871#define GL_ONE_MINUS_DST_COLOR 0x0307
872#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
873#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
874#define GL_ONE_MINUS_SRC_ALPHA 0x0303
875#define GL_ONE_MINUS_SRC_COLOR 0x0301
876#define GL_OPERAND0_ALPHA 0x8598
877#define GL_OPERAND0_RGB 0x8590
878#define GL_OPERAND1_ALPHA 0x8599
879#define GL_OPERAND1_RGB 0x8591
880#define GL_OPERAND2_ALPHA 0x859A
881#define GL_OPERAND2_RGB 0x8592
882#define GL_OR 0x1507
883#define GL_ORDER 0x0A01
884#define GL_OR_INVERTED 0x150D
885#define GL_OR_REVERSE 0x150B
886#define GL_OUT_OF_MEMORY 0x0505
887#define GL_PACK_ALIGNMENT 0x0D05
888#define GL_PACK_IMAGE_HEIGHT 0x806C
889#define GL_PACK_LSB_FIRST 0x0D01
890#define GL_PACK_ROW_LENGTH 0x0D02
891#define GL_PACK_SKIP_IMAGES 0x806B
892#define GL_PACK_SKIP_PIXELS 0x0D04
893#define GL_PACK_SKIP_ROWS 0x0D03
894#define GL_PACK_SWAP_BYTES 0x0D00
895#define GL_PASS_THROUGH_TOKEN 0x0700
896#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
897#define GL_PIXEL_MAP_A_TO_A 0x0C79
898#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
899#define GL_PIXEL_MAP_B_TO_B 0x0C78
900#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
901#define GL_PIXEL_MAP_G_TO_G 0x0C77
902#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
903#define GL_PIXEL_MAP_I_TO_A 0x0C75
904#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
905#define GL_PIXEL_MAP_I_TO_B 0x0C74
906#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
907#define GL_PIXEL_MAP_I_TO_G 0x0C73
908#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
909#define GL_PIXEL_MAP_I_TO_I 0x0C70
910#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
911#define GL_PIXEL_MAP_I_TO_R 0x0C72
912#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
913#define GL_PIXEL_MAP_R_TO_R 0x0C76
914#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
915#define GL_PIXEL_MAP_S_TO_S 0x0C71
916#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
917#define GL_PIXEL_MODE_BIT 0x00000020
918#define GL_PIXEL_PACK_BUFFER 0x88EB
919#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
920#define GL_PIXEL_UNPACK_BUFFER 0x88EC
921#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
922#define GL_POINT 0x1B00
923#define GL_POINTS 0x0000
924#define GL_POINT_BIT 0x00000002
925#define GL_POINT_DISTANCE_ATTENUATION 0x8129
926#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
927#define GL_POINT_SIZE 0x0B11
928#define GL_POINT_SIZE_GRANULARITY 0x0B13
929#define GL_POINT_SIZE_MAX 0x8127
930#define GL_POINT_SIZE_MIN 0x8126
931#define GL_POINT_SIZE_RANGE 0x0B12
932#define GL_POINT_SMOOTH 0x0B10
933#define GL_POINT_SMOOTH_HINT 0x0C51
934#define GL_POINT_SPRITE 0x8861
935#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
936#define GL_POINT_TOKEN 0x0701
937#define GL_POLYGON 0x0009
938#define GL_POLYGON_BIT 0x00000008
939#define GL_POLYGON_MODE 0x0B40
940#define GL_POLYGON_OFFSET_FACTOR 0x8038
941#define GL_POLYGON_OFFSET_FILL 0x8037
942#define GL_POLYGON_OFFSET_LINE 0x2A02
943#define GL_POLYGON_OFFSET_POINT 0x2A01
944#define GL_POLYGON_OFFSET_UNITS 0x2A00
945#define GL_POLYGON_SMOOTH 0x0B41
946#define GL_POLYGON_SMOOTH_HINT 0x0C53
947#define GL_POLYGON_STIPPLE 0x0B42
948#define GL_POLYGON_STIPPLE_BIT 0x00000010
949#define GL_POLYGON_TOKEN 0x0703
950#define GL_POSITION 0x1203
951#define GL_PREVIOUS 0x8578
952#define GL_PRIMARY_COLOR 0x8577
953#define GL_PRIMITIVES_GENERATED 0x8C87
954#define GL_PRIMITIVE_RESTART 0x8F9D
955#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
956#define GL_PROGRAM 0x82E2
957#define GL_PROGRAM_PIPELINE 0x82E4
958#define GL_PROGRAM_POINT_SIZE 0x8642
959#define GL_PROJECTION 0x1701
960#define GL_PROJECTION_MATRIX 0x0BA7
961#define GL_PROJECTION_STACK_DEPTH 0x0BA4
962#define GL_PROVOKING_VERTEX 0x8E4F
963#define GL_PROXY_TEXTURE_1D 0x8063
964#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
965#define GL_PROXY_TEXTURE_2D 0x8064
966#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
967#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
968#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
969#define GL_PROXY_TEXTURE_3D 0x8070
970#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
971#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
972#define GL_Q 0x2003
973#define GL_QUADRATIC_ATTENUATION 0x1209
974#define GL_QUADS 0x0007
975#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
976#define GL_QUAD_STRIP 0x0008
977#define GL_QUERY 0x82E3
978#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
979#define GL_QUERY_BY_REGION_WAIT 0x8E15
980#define GL_QUERY_COUNTER_BITS 0x8864
981#define GL_QUERY_NO_WAIT 0x8E14
982#define GL_QUERY_RESULT 0x8866
983#define GL_QUERY_RESULT_AVAILABLE 0x8867
984#define GL_QUERY_WAIT 0x8E13
985#define GL_R 0x2002
986#define GL_R11F_G11F_B10F 0x8C3A
987#define GL_R16 0x822A
988#define GL_R16F 0x822D
989#define GL_R16I 0x8233
990#define GL_R16UI 0x8234
991#define GL_R16_SNORM 0x8F98
992#define GL_R32F 0x822E
993#define GL_R32I 0x8235
994#define GL_R32UI 0x8236
995#define GL_R3_G3_B2 0x2A10
996#define GL_R8 0x8229
997#define GL_R8I 0x8231
998#define GL_R8UI 0x8232
999#define GL_R8_SNORM 0x8F94
1000#define GL_RASTERIZER_DISCARD 0x8C89
1001#define GL_READ_BUFFER 0x0C02
1002#define GL_READ_FRAMEBUFFER 0x8CA8
1003#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
1004#define GL_READ_ONLY 0x88B8
1005#define GL_READ_WRITE 0x88BA
1006#define GL_RED 0x1903
1007#define GL_RED_BIAS 0x0D15
1008#define GL_RED_BITS 0x0D52
1009#define GL_RED_INTEGER 0x8D94
1010#define GL_RED_SCALE 0x0D14
1011#define GL_REFLECTION_MAP 0x8512
1012#define GL_RENDER 0x1C00
1013#define GL_RENDERBUFFER 0x8D41
1014#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
1015#define GL_RENDERBUFFER_BINDING 0x8CA7
1016#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
1017#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
1018#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
1019#define GL_RENDERBUFFER_HEIGHT 0x8D43
1020#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
1021#define GL_RENDERBUFFER_RED_SIZE 0x8D50
1022#define GL_RENDERBUFFER_SAMPLES 0x8CAB
1023#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
1024#define GL_RENDERBUFFER_WIDTH 0x8D42
1025#define GL_RENDERER 0x1F01
1026#define GL_RENDER_MODE 0x0C40
1027#define GL_REPEAT 0x2901
1028#define GL_REPLACE 0x1E01
1029#define GL_RESCALE_NORMAL 0x803A
1030#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
1031#define GL_RETURN 0x0102
1032#define GL_RG 0x8227
1033#define GL_RG16 0x822C
1034#define GL_RG16F 0x822F
1035#define GL_RG16I 0x8239
1036#define GL_RG16UI 0x823A
1037#define GL_RG16_SNORM 0x8F99
1038#define GL_RG32F 0x8230
1039#define GL_RG32I 0x823B
1040#define GL_RG32UI 0x823C
1041#define GL_RG8 0x822B
1042#define GL_RG8I 0x8237
1043#define GL_RG8UI 0x8238
1044#define GL_RG8_SNORM 0x8F95
1045#define GL_RGB 0x1907
1046#define GL_RGB10 0x8052
1047#define GL_RGB10_A2 0x8059
1048#define GL_RGB10_A2UI 0x906F
1049#define GL_RGB12 0x8053
1050#define GL_RGB16 0x8054
1051#define GL_RGB16F 0x881B
1052#define GL_RGB16I 0x8D89
1053#define GL_RGB16UI 0x8D77
1054#define GL_RGB16_SNORM 0x8F9A
1055#define GL_RGB32F 0x8815
1056#define GL_RGB32I 0x8D83
1057#define GL_RGB32UI 0x8D71
1058#define GL_RGB4 0x804F
1059#define GL_RGB5 0x8050
1060#define GL_RGB5_A1 0x8057
1061#define GL_RGB8 0x8051
1062#define GL_RGB8I 0x8D8F
1063#define GL_RGB8UI 0x8D7D
1064#define GL_RGB8_SNORM 0x8F96
1065#define GL_RGB9_E5 0x8C3D
1066#define GL_RGBA 0x1908
1067#define GL_RGBA12 0x805A
1068#define GL_RGBA16 0x805B
1069#define GL_RGBA16F 0x881A
1070#define GL_RGBA16I 0x8D88
1071#define GL_RGBA16UI 0x8D76
1072#define GL_RGBA16_SNORM 0x8F9B
1073#define GL_RGBA2 0x8055
1074#define GL_RGBA32F 0x8814
1075#define GL_RGBA32I 0x8D82
1076#define GL_RGBA32UI 0x8D70
1077#define GL_RGBA4 0x8056
1078#define GL_RGBA8 0x8058
1079#define GL_RGBA8I 0x8D8E
1080#define GL_RGBA8UI 0x8D7C
1081#define GL_RGBA8_SNORM 0x8F97
1082#define GL_RGBA_INTEGER 0x8D99
1083#define GL_RGBA_MODE 0x0C31
1084#define GL_RGB_INTEGER 0x8D98
1085#define GL_RGB_SCALE 0x8573
1086#define GL_RG_INTEGER 0x8228
1087#define GL_RIGHT 0x0407
1088#define GL_S 0x2000
1089#define GL_SAMPLER 0x82E6
1090#define GL_SAMPLER_1D 0x8B5D
1091#define GL_SAMPLER_1D_ARRAY 0x8DC0
1092#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
1093#define GL_SAMPLER_1D_SHADOW 0x8B61
1094#define GL_SAMPLER_2D 0x8B5E
1095#define GL_SAMPLER_2D_ARRAY 0x8DC1
1096#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
1097#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
1098#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
1099#define GL_SAMPLER_2D_RECT 0x8B63
1100#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
1101#define GL_SAMPLER_2D_SHADOW 0x8B62
1102#define GL_SAMPLER_3D 0x8B5F
1103#define GL_SAMPLER_BINDING 0x8919
1104#define GL_SAMPLER_BUFFER 0x8DC2
1105#define GL_SAMPLER_CUBE 0x8B60
1106#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
1107#define GL_SAMPLES 0x80A9
1108#define GL_SAMPLES_ARB 0x80A9
1109#define GL_SAMPLES_PASSED 0x8914
1110#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
1111#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
1112#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
1113#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
1114#define GL_SAMPLE_BUFFERS 0x80A8
1115#define GL_SAMPLE_BUFFERS_ARB 0x80A8
1116#define GL_SAMPLE_COVERAGE 0x80A0
1117#define GL_SAMPLE_COVERAGE_ARB 0x80A0
1118#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
1119#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
1120#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
1121#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
1122#define GL_SAMPLE_MASK 0x8E51
1123#define GL_SAMPLE_MASK_VALUE 0x8E52
1124#define GL_SAMPLE_POSITION 0x8E50
1125#define GL_SCISSOR_BIT 0x00080000
1126#define GL_SCISSOR_BOX 0x0C10
1127#define GL_SCISSOR_TEST 0x0C11
1128#define GL_SECONDARY_COLOR_ARRAY 0x845E
1129#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
1130#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
1131#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
1132#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
1133#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
1134#define GL_SELECT 0x1C02
1135#define GL_SELECTION_BUFFER_POINTER 0x0DF3
1136#define GL_SELECTION_BUFFER_SIZE 0x0DF4
1137#define GL_SEPARATE_ATTRIBS 0x8C8D
1138#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
1139#define GL_SET 0x150F
1140#define GL_SHADER 0x82E1
1141#define GL_SHADER_SOURCE_LENGTH 0x8B88
1142#define GL_SHADER_TYPE 0x8B4F
1143#define GL_SHADE_MODEL 0x0B54
1144#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
1145#define GL_SHININESS 0x1601
1146#define GL_SHORT 0x1402
1147#define GL_SIGNALED 0x9119
1148#define GL_SIGNED_NORMALIZED 0x8F9C
1149#define GL_SINGLE_COLOR 0x81F9
1150#define GL_SLUMINANCE 0x8C46
1151#define GL_SLUMINANCE8 0x8C47
1152#define GL_SLUMINANCE8_ALPHA8 0x8C45
1153#define GL_SLUMINANCE_ALPHA 0x8C44
1154#define GL_SMOOTH 0x1D01
1155#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
1156#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
1157#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
1158#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
1159#define GL_SOURCE0_ALPHA 0x8588
1160#define GL_SOURCE0_RGB 0x8580
1161#define GL_SOURCE1_ALPHA 0x8589
1162#define GL_SOURCE1_RGB 0x8581
1163#define GL_SOURCE2_ALPHA 0x858A
1164#define GL_SOURCE2_RGB 0x8582
1165#define GL_SPECULAR 0x1202
1166#define GL_SPHERE_MAP 0x2402
1167#define GL_SPOT_CUTOFF 0x1206
1168#define GL_SPOT_DIRECTION 0x1204
1169#define GL_SPOT_EXPONENT 0x1205
1170#define GL_SRC0_ALPHA 0x8588
1171#define GL_SRC0_RGB 0x8580
1172#define GL_SRC1_ALPHA 0x8589
1173#define GL_SRC1_COLOR 0x88F9
1174#define GL_SRC1_RGB 0x8581
1175#define GL_SRC2_ALPHA 0x858A
1176#define GL_SRC2_RGB 0x8582
1177#define GL_SRC_ALPHA 0x0302
1178#define GL_SRC_ALPHA_SATURATE 0x0308
1179#define GL_SRC_COLOR 0x0300
1180#define GL_SRGB 0x8C40
1181#define GL_SRGB8 0x8C41
1182#define GL_SRGB8_ALPHA8 0x8C43
1183#define GL_SRGB_ALPHA 0x8C42
1184#define GL_STACK_OVERFLOW 0x0503
1185#define GL_STACK_UNDERFLOW 0x0504
1186#define GL_STATIC_COPY 0x88E6
1187#define GL_STATIC_DRAW 0x88E4
1188#define GL_STATIC_READ 0x88E5
1189#define GL_STENCIL 0x1802
1190#define GL_STENCIL_ATTACHMENT 0x8D20
1191#define GL_STENCIL_BACK_FAIL 0x8801
1192#define GL_STENCIL_BACK_FUNC 0x8800
1193#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
1194#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
1195#define GL_STENCIL_BACK_REF 0x8CA3
1196#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
1197#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
1198#define GL_STENCIL_BITS 0x0D57
1199#define GL_STENCIL_BUFFER_BIT 0x00000400
1200#define GL_STENCIL_CLEAR_VALUE 0x0B91
1201#define GL_STENCIL_FAIL 0x0B94
1202#define GL_STENCIL_FUNC 0x0B92
1203#define GL_STENCIL_INDEX 0x1901
1204#define GL_STENCIL_INDEX1 0x8D46
1205#define GL_STENCIL_INDEX16 0x8D49
1206#define GL_STENCIL_INDEX4 0x8D47
1207#define GL_STENCIL_INDEX8 0x8D48
1208#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
1209#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
1210#define GL_STENCIL_REF 0x0B97
1211#define GL_STENCIL_TEST 0x0B90
1212#define GL_STENCIL_VALUE_MASK 0x0B93
1213#define GL_STENCIL_WRITEMASK 0x0B98
1214#define GL_STEREO 0x0C33
1215#define GL_STREAM_COPY 0x88E2
1216#define GL_STREAM_DRAW 0x88E0
1217#define GL_STREAM_READ 0x88E1
1218#define GL_SUBPIXEL_BITS 0x0D50
1219#define GL_SUBTRACT 0x84E7
1220#define GL_SYNC_CONDITION 0x9113
1221#define GL_SYNC_FENCE 0x9116
1222#define GL_SYNC_FLAGS 0x9115
1223#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
1224#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
1225#define GL_SYNC_STATUS 0x9114
1226#define GL_T 0x2001
1227#define GL_T2F_C3F_V3F 0x2A2A
1228#define GL_T2F_C4F_N3F_V3F 0x2A2C
1229#define GL_T2F_C4UB_V3F 0x2A29
1230#define GL_T2F_N3F_V3F 0x2A2B
1231#define GL_T2F_V3F 0x2A27
1232#define GL_T4F_C4F_N3F_V4F 0x2A2D
1233#define GL_T4F_V4F 0x2A28
1234#define GL_TEXTURE 0x1702
1235#define GL_TEXTURE0 0x84C0
1236#define GL_TEXTURE1 0x84C1
1237#define GL_TEXTURE10 0x84CA
1238#define GL_TEXTURE11 0x84CB
1239#define GL_TEXTURE12 0x84CC
1240#define GL_TEXTURE13 0x84CD
1241#define GL_TEXTURE14 0x84CE
1242#define GL_TEXTURE15 0x84CF
1243#define GL_TEXTURE16 0x84D0
1244#define GL_TEXTURE17 0x84D1
1245#define GL_TEXTURE18 0x84D2
1246#define GL_TEXTURE19 0x84D3
1247#define GL_TEXTURE2 0x84C2
1248#define GL_TEXTURE20 0x84D4
1249#define GL_TEXTURE21 0x84D5
1250#define GL_TEXTURE22 0x84D6
1251#define GL_TEXTURE23 0x84D7
1252#define GL_TEXTURE24 0x84D8
1253#define GL_TEXTURE25 0x84D9
1254#define GL_TEXTURE26 0x84DA
1255#define GL_TEXTURE27 0x84DB
1256#define GL_TEXTURE28 0x84DC
1257#define GL_TEXTURE29 0x84DD
1258#define GL_TEXTURE3 0x84C3
1259#define GL_TEXTURE30 0x84DE
1260#define GL_TEXTURE31 0x84DF
1261#define GL_TEXTURE4 0x84C4
1262#define GL_TEXTURE5 0x84C5
1263#define GL_TEXTURE6 0x84C6
1264#define GL_TEXTURE7 0x84C7
1265#define GL_TEXTURE8 0x84C8
1266#define GL_TEXTURE9 0x84C9
1267#define GL_TEXTURE_1D 0x0DE0
1268#define GL_TEXTURE_1D_ARRAY 0x8C18
1269#define GL_TEXTURE_2D 0x0DE1
1270#define GL_TEXTURE_2D_ARRAY 0x8C1A
1271#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
1272#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
1273#define GL_TEXTURE_3D 0x806F
1274#define GL_TEXTURE_ALPHA_SIZE 0x805F
1275#define GL_TEXTURE_ALPHA_TYPE 0x8C13
1276#define GL_TEXTURE_BASE_LEVEL 0x813C
1277#define GL_TEXTURE_BINDING_1D 0x8068
1278#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
1279#define GL_TEXTURE_BINDING_2D 0x8069
1280#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
1281#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
1282#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
1283#define GL_TEXTURE_BINDING_3D 0x806A
1284#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
1285#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
1286#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
1287#define GL_TEXTURE_BIT 0x00040000
1288#define GL_TEXTURE_BLUE_SIZE 0x805E
1289#define GL_TEXTURE_BLUE_TYPE 0x8C12
1290#define GL_TEXTURE_BORDER 0x1005
1291#define GL_TEXTURE_BORDER_COLOR 0x1004
1292#define GL_TEXTURE_BUFFER 0x8C2A
1293#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
1294#define GL_TEXTURE_COMPARE_FUNC 0x884D
1295#define GL_TEXTURE_COMPARE_MODE 0x884C
1296#define GL_TEXTURE_COMPONENTS 0x1003
1297#define GL_TEXTURE_COMPRESSED 0x86A1
1298#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
1299#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
1300#define GL_TEXTURE_COORD_ARRAY 0x8078
1301#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
1302#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
1303#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
1304#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
1305#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
1306#define GL_TEXTURE_CUBE_MAP 0x8513
1307#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
1308#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
1309#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
1310#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
1311#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
1312#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
1313#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
1314#define GL_TEXTURE_DEPTH 0x8071
1315#define GL_TEXTURE_DEPTH_SIZE 0x884A
1316#define GL_TEXTURE_DEPTH_TYPE 0x8C16
1317#define GL_TEXTURE_ENV 0x2300
1318#define GL_TEXTURE_ENV_COLOR 0x2201
1319#define GL_TEXTURE_ENV_MODE 0x2200
1320#define GL_TEXTURE_FILTER_CONTROL 0x8500
1321#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
1322#define GL_TEXTURE_GEN_MODE 0x2500
1323#define GL_TEXTURE_GEN_Q 0x0C63
1324#define GL_TEXTURE_GEN_R 0x0C62
1325#define GL_TEXTURE_GEN_S 0x0C60
1326#define GL_TEXTURE_GEN_T 0x0C61
1327#define GL_TEXTURE_GREEN_SIZE 0x805D
1328#define GL_TEXTURE_GREEN_TYPE 0x8C11
1329#define GL_TEXTURE_HEIGHT 0x1001
1330#define GL_TEXTURE_INTENSITY_SIZE 0x8061
1331#define GL_TEXTURE_INTENSITY_TYPE 0x8C15
1332#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
1333#define GL_TEXTURE_LOD_BIAS 0x8501
1334#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
1335#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14
1336#define GL_TEXTURE_MAG_FILTER 0x2800
1337#define GL_TEXTURE_MATRIX 0x0BA8
1338#define GL_TEXTURE_MAX_LEVEL 0x813D
1339#define GL_TEXTURE_MAX_LOD 0x813B
1340#define GL_TEXTURE_MIN_FILTER 0x2801
1341#define GL_TEXTURE_MIN_LOD 0x813A
1342#define GL_TEXTURE_PRIORITY 0x8066
1343#define GL_TEXTURE_RECTANGLE 0x84F5
1344#define GL_TEXTURE_RED_SIZE 0x805C
1345#define GL_TEXTURE_RED_TYPE 0x8C10
1346#define GL_TEXTURE_RESIDENT 0x8067
1347#define GL_TEXTURE_SAMPLES 0x9106
1348#define GL_TEXTURE_SHARED_SIZE 0x8C3F
1349#define GL_TEXTURE_STACK_DEPTH 0x0BA5
1350#define GL_TEXTURE_STENCIL_SIZE 0x88F1
1351#define GL_TEXTURE_SWIZZLE_A 0x8E45
1352#define GL_TEXTURE_SWIZZLE_B 0x8E44
1353#define GL_TEXTURE_SWIZZLE_G 0x8E43
1354#define GL_TEXTURE_SWIZZLE_R 0x8E42
1355#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
1356#define GL_TEXTURE_WIDTH 0x1000
1357#define GL_TEXTURE_WRAP_R 0x8072
1358#define GL_TEXTURE_WRAP_S 0x2802
1359#define GL_TEXTURE_WRAP_T 0x2803
1360#define GL_TIMEOUT_EXPIRED 0x911B
1361#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
1362#define GL_TIMESTAMP 0x8E28
1363#define GL_TIME_ELAPSED 0x88BF
1364#define GL_TRANSFORM_BIT 0x00001000
1365#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
1366#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
1367#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
1368#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
1369#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
1370#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
1371#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
1372#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
1373#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
1374#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
1375#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
1376#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
1377#define GL_TRIANGLES 0x0004
1378#define GL_TRIANGLES_ADJACENCY 0x000C
1379#define GL_TRIANGLE_FAN 0x0006
1380#define GL_TRIANGLE_STRIP 0x0005
1381#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
1382#define GL_TRUE 1
1383#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
1384#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
1385#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
1386#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
1387#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
1388#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
1389#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
1390#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
1391#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
1392#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
1393#define GL_UNIFORM_BUFFER 0x8A11
1394#define GL_UNIFORM_BUFFER_BINDING 0x8A28
1395#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
1396#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
1397#define GL_UNIFORM_BUFFER_START 0x8A29
1398#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
1399#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
1400#define GL_UNIFORM_NAME_LENGTH 0x8A39
1401#define GL_UNIFORM_OFFSET 0x8A3B
1402#define GL_UNIFORM_SIZE 0x8A38
1403#define GL_UNIFORM_TYPE 0x8A37
1404#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
1405#define GL_UNPACK_ALIGNMENT 0x0CF5
1406#define GL_UNPACK_IMAGE_HEIGHT 0x806E
1407#define GL_UNPACK_LSB_FIRST 0x0CF1
1408#define GL_UNPACK_ROW_LENGTH 0x0CF2
1409#define GL_UNPACK_SKIP_IMAGES 0x806D
1410#define GL_UNPACK_SKIP_PIXELS 0x0CF4
1411#define GL_UNPACK_SKIP_ROWS 0x0CF3
1412#define GL_UNPACK_SWAP_BYTES 0x0CF0
1413#define GL_UNSIGNALED 0x9118
1414#define GL_UNSIGNED_BYTE 0x1401
1415#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
1416#define GL_UNSIGNED_BYTE_3_3_2 0x8032
1417#define GL_UNSIGNED_INT 0x1405
1418#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
1419#define GL_UNSIGNED_INT_10_10_10_2 0x8036
1420#define GL_UNSIGNED_INT_24_8 0x84FA
1421#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
1422#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
1423#define GL_UNSIGNED_INT_8_8_8_8 0x8035
1424#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
1425#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
1426#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
1427#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
1428#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
1429#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
1430#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
1431#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
1432#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
1433#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
1434#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
1435#define GL_UNSIGNED_INT_VEC2 0x8DC6
1436#define GL_UNSIGNED_INT_VEC3 0x8DC7
1437#define GL_UNSIGNED_INT_VEC4 0x8DC8
1438#define GL_UNSIGNED_NORMALIZED 0x8C17
1439#define GL_UNSIGNED_SHORT 0x1403
1440#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
1441#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
1442#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
1443#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
1444#define GL_UNSIGNED_SHORT_5_6_5 0x8363
1445#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
1446#define GL_UPPER_LEFT 0x8CA2
1447#define GL_V2F 0x2A20
1448#define GL_V3F 0x2A21
1449#define GL_VALIDATE_STATUS 0x8B83
1450#define GL_VENDOR 0x1F00
1451#define GL_VERSION 0x1F02
1452#define GL_VERTEX_ARRAY 0x8074
1453#define GL_VERTEX_ARRAY_BINDING 0x85B5
1454#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
1455#define GL_VERTEX_ARRAY_POINTER 0x808E
1456#define GL_VERTEX_ARRAY_SIZE 0x807A
1457#define GL_VERTEX_ARRAY_STRIDE 0x807C
1458#define GL_VERTEX_ARRAY_TYPE 0x807B
1459#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
1460#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
1461#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
1462#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
1463#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
1464#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
1465#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
1466#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
1467#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
1468#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
1469#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
1470#define GL_VERTEX_SHADER 0x8B31
1471#define GL_VIEWPORT 0x0BA2
1472#define GL_VIEWPORT_BIT 0x00000800
1473#define GL_WAIT_FAILED 0x911D
1474#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
1475#define GL_WRITE_ONLY 0x88B9
1476#define GL_XOR 0x1506
1477#define GL_ZERO 0
1478#define GL_ZOOM_X 0x0D16
1479#define GL_ZOOM_Y 0x0D17
1480
1481
1482#ifndef __khrplatform_h_
1483#define __khrplatform_h_
1484
1485/*
1486** Copyright (c) 2008-2018 The Khronos Group Inc.
1487**
1488** Permission is hereby granted, free of charge, to any person obtaining a
1489** copy of this software and/or associated documentation files (the
1490** "Materials"), to deal in the Materials without restriction, including
1491** without limitation the rights to use, copy, modify, merge, publish,
1492** distribute, sublicense, and/or sell copies of the Materials, and to
1493** permit persons to whom the Materials are furnished to do so, subject to
1494** the following conditions:
1495**
1496** The above copyright notice and this permission notice shall be included
1497** in all copies or substantial portions of the Materials.
1498**
1499** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1500** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1501** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1502** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1503** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1504** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1505** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
1506*/
1507
1508/* Khronos platform-specific types and definitions.
1509 *
1510 * The master copy of khrplatform.h is maintained in the Khronos EGL
1511 * Registry repository at https://github.com/KhronosGroup/EGL-Registry
1512 * The last semantic modification to khrplatform.h was at commit ID:
1513 * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
1514 *
1515 * Adopters may modify this file to suit their platform. Adopters are
1516 * encouraged to submit platform specific modifications to the Khronos
1517 * group so that they can be included in future versions of this file.
1518 * Please submit changes by filing pull requests or issues on
1519 * the EGL Registry repository linked above.
1520 *
1521 *
1522 * See the Implementer's Guidelines for information about where this file
1523 * should be located on your system and for more details of its use:
1524 * http://www.khronos.org/registry/implementers_guide.pdf
1525 *
1526 * This file should be included as
1527 * #include <KHR/khrplatform.h>
1528 * by Khronos client API header files that use its types and defines.
1529 *
1530 * The types in khrplatform.h should only be used to define API-specific types.
1531 *
1532 * Types defined in khrplatform.h:
1533 * khronos_int8_t signed 8 bit
1534 * khronos_uint8_t unsigned 8 bit
1535 * khronos_int16_t signed 16 bit
1536 * khronos_uint16_t unsigned 16 bit
1537 * khronos_int32_t signed 32 bit
1538 * khronos_uint32_t unsigned 32 bit
1539 * khronos_int64_t signed 64 bit
1540 * khronos_uint64_t unsigned 64 bit
1541 * khronos_intptr_t signed same number of bits as a pointer
1542 * khronos_uintptr_t unsigned same number of bits as a pointer
1543 * khronos_ssize_t signed size
1544 * khronos_usize_t unsigned size
1545 * khronos_float_t signed 32 bit floating point
1546 * khronos_time_ns_t unsigned 64 bit time in nanoseconds
1547 * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
1548 * nanoseconds
1549 * khronos_stime_nanoseconds_t signed time interval in nanoseconds
1550 * khronos_boolean_enum_t enumerated boolean type. This should
1551 * only be used as a base type when a client API's boolean type is
1552 * an enum. Client APIs which use an integer or other type for
1553 * booleans cannot use this as the base type for their boolean.
1554 *
1555 * Tokens defined in khrplatform.h:
1556 *
1557 * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
1558 *
1559 * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
1560 * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
1561 *
1562 * Calling convention macros defined in this file:
1563 * KHRONOS_APICALL
1564 * KHRONOS_GLAD_API_PTR
1565 * KHRONOS_APIATTRIBUTES
1566 *
1567 * These may be used in function prototypes as:
1568 *
1569 * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname(
1570 * int arg1,
1571 * int arg2) KHRONOS_APIATTRIBUTES;
1572 */
1573
1574#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
1575# define KHRONOS_STATIC 1
1576#endif
1577
1578/*-------------------------------------------------------------------------
1579 * Definition of KHRONOS_APICALL
1580 *-------------------------------------------------------------------------
1581 * This precedes the return type of the function in the function prototype.
1582 */
1583#if defined(KHRONOS_STATIC)
1584 /* If the preprocessor constant KHRONOS_STATIC is defined, make the
1585 * header compatible with static linking. */
1586# define KHRONOS_APICALL
1587#elif defined(_WIN32)
1588# define KHRONOS_APICALL __declspec(dllimport)
1589#elif defined (__SYMBIAN32__)
1590# define KHRONOS_APICALL IMPORT_C
1591#elif defined(__ANDROID__)
1592# define KHRONOS_APICALL __attribute__((visibility("default")))
1593#else
1594# define KHRONOS_APICALL
1595#endif
1596
1597/*-------------------------------------------------------------------------
1598 * Definition of KHRONOS_GLAD_API_PTR
1599 *-------------------------------------------------------------------------
1600 * This follows the return type of the function and precedes the function
1601 * name in the function prototype.
1602 */
1603#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
1604 /* Win32 but not WinCE */
1605# define KHRONOS_GLAD_API_PTR __stdcall
1606#else
1607# define KHRONOS_GLAD_API_PTR
1608#endif
1609
1610/*-------------------------------------------------------------------------
1611 * Definition of KHRONOS_APIATTRIBUTES
1612 *-------------------------------------------------------------------------
1613 * This follows the closing parenthesis of the function prototype arguments.
1614 */
1615#if defined (__ARMCC_2__)
1616#define KHRONOS_APIATTRIBUTES __softfp
1617#else
1618#define KHRONOS_APIATTRIBUTES
1619#endif
1620
1621/*-------------------------------------------------------------------------
1622 * basic type definitions
1623 *-----------------------------------------------------------------------*/
1624#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
1625
1626
1627/*
1628 * Using <stdint.h>
1629 */
1630#include <stdint.h>
1631typedef int32_t khronos_int32_t;
1632typedef uint32_t khronos_uint32_t;
1633typedef int64_t khronos_int64_t;
1634typedef uint64_t khronos_uint64_t;
1635#define KHRONOS_SUPPORT_INT64 1
1636#define KHRONOS_SUPPORT_FLOAT 1
1637
1638#elif defined(__VMS ) || defined(__sgi)
1639
1640/*
1641 * Using <inttypes.h>
1642 */
1643#include <inttypes.h>
1644typedef int32_t khronos_int32_t;
1645typedef uint32_t khronos_uint32_t;
1646typedef int64_t khronos_int64_t;
1647typedef uint64_t khronos_uint64_t;
1648#define KHRONOS_SUPPORT_INT64 1
1649#define KHRONOS_SUPPORT_FLOAT 1
1650
1651#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
1652
1653/*
1654 * Win32
1655 */
1656typedef __int32 khronos_int32_t;
1657typedef unsigned __int32 khronos_uint32_t;
1658typedef __int64 khronos_int64_t;
1659typedef unsigned __int64 khronos_uint64_t;
1660#define KHRONOS_SUPPORT_INT64 1
1661#define KHRONOS_SUPPORT_FLOAT 1
1662
1663#elif defined(__sun__) || defined(__digital__)
1664
1665/*
1666 * Sun or Digital
1667 */
1668typedef int khronos_int32_t;
1669typedef unsigned int khronos_uint32_t;
1670#if defined(__arch64__) || defined(_LP64)
1671typedef long int khronos_int64_t;
1672typedef unsigned long int khronos_uint64_t;
1673#else
1674typedef long long int khronos_int64_t;
1675typedef unsigned long long int khronos_uint64_t;
1676#endif /* __arch64__ */
1677#define KHRONOS_SUPPORT_INT64 1
1678#define KHRONOS_SUPPORT_FLOAT 1
1679
1680#elif 0
1681
1682/*
1683 * Hypothetical platform with no float or int64 support
1684 */
1685typedef int khronos_int32_t;
1686typedef unsigned int khronos_uint32_t;
1687#define KHRONOS_SUPPORT_INT64 0
1688#define KHRONOS_SUPPORT_FLOAT 0
1689
1690#else
1691
1692/*
1693 * Generic fallback
1694 */
1695#include <stdint.h>
1696typedef int32_t khronos_int32_t;
1697typedef uint32_t khronos_uint32_t;
1698typedef int64_t khronos_int64_t;
1699typedef uint64_t khronos_uint64_t;
1700#define KHRONOS_SUPPORT_INT64 1
1701#define KHRONOS_SUPPORT_FLOAT 1
1702
1703#endif
1704
1705
1706/*
1707 * Types that are (so far) the same on all platforms
1708 */
1709typedef signed char khronos_int8_t;
1710typedef unsigned char khronos_uint8_t;
1711typedef signed short int khronos_int16_t;
1712typedef unsigned short int khronos_uint16_t;
1713
1714/*
1715 * Types that differ between LLP64 and LP64 architectures - in LLP64,
1716 * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
1717 * to be the only LLP64 architecture in current use.
1718 */
1719#ifdef _WIN64
1720typedef signed long long int khronos_intptr_t;
1721typedef unsigned long long int khronos_uintptr_t;
1722typedef signed long long int khronos_ssize_t;
1723typedef unsigned long long int khronos_usize_t;
1724#else
1725typedef signed long int khronos_intptr_t;
1726typedef unsigned long int khronos_uintptr_t;
1727typedef signed long int khronos_ssize_t;
1728typedef unsigned long int khronos_usize_t;
1729#endif
1730
1731#if KHRONOS_SUPPORT_FLOAT
1732/*
1733 * Float type
1734 */
1735typedef float khronos_float_t;
1736#endif
1737
1738#if KHRONOS_SUPPORT_INT64
1739/* Time types
1740 *
1741 * These types can be used to represent a time interval in nanoseconds or
1742 * an absolute Unadjusted System Time. Unadjusted System Time is the number
1743 * of nanoseconds since some arbitrary system event (e.g. since the last
1744 * time the system booted). The Unadjusted System Time is an unsigned
1745 * 64 bit value that wraps back to 0 every 584 years. Time intervals
1746 * may be either signed or unsigned.
1747 */
1748typedef khronos_uint64_t khronos_utime_nanoseconds_t;
1749typedef khronos_int64_t khronos_stime_nanoseconds_t;
1750#endif
1751
1752/*
1753 * Dummy value used to pad enum types to 32 bits.
1754 */
1755#ifndef KHRONOS_MAX_ENUM
1756#define KHRONOS_MAX_ENUM 0x7FFFFFFF
1757#endif
1758
1759/*
1760 * Enumerated boolean type
1761 *
1762 * Values other than zero should be considered to be true. Therefore
1763 * comparisons should not be made against KHRONOS_TRUE.
1764 */
1765typedef enum {
1766 KHRONOS_FALSE = 0,
1767 KHRONOS_TRUE = 1,
1768 KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
1769} khronos_boolean_enum_t;
1770
1771#endif /* __khrplatform_h_ */
1772
1773typedef unsigned int GLenum;
1774
1775typedef unsigned char GLboolean;
1776
1777typedef unsigned int GLbitfield;
1778
1779typedef void GLvoid;
1780
1781typedef khronos_int8_t GLbyte;
1782
1783typedef khronos_uint8_t GLubyte;
1784
1785typedef khronos_int16_t GLshort;
1786
1787typedef khronos_uint16_t GLushort;
1788
1789typedef int GLint;
1790
1791typedef unsigned int GLuint;
1792
1793typedef khronos_int32_t GLclampx;
1794
1795typedef int GLsizei;
1796
1797typedef khronos_float_t GLfloat;
1798
1799typedef khronos_float_t GLclampf;
1800
1801typedef double GLdouble;
1802
1803typedef double GLclampd;
1804
1805typedef void *GLeglClientBufferEXT;
1806
1807typedef void *GLeglImageOES;
1808
1809typedef char GLchar;
1810
1811typedef char GLcharARB;
1812
1813#ifdef __APPLE__
1814typedef void *GLhandleARB;
1815#else
1816typedef unsigned int GLhandleARB;
1817#endif
1818
1819typedef khronos_uint16_t GLhalf;
1820
1821typedef khronos_uint16_t GLhalfARB;
1822
1823typedef khronos_int32_t GLfixed;
1824
1825#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1826typedef khronos_intptr_t GLintptr;
1827#else
1828typedef khronos_intptr_t GLintptr;
1829#endif
1830
1831#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1832typedef khronos_intptr_t GLintptrARB;
1833#else
1834typedef khronos_intptr_t GLintptrARB;
1835#endif
1836
1837#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1838typedef khronos_ssize_t GLsizeiptr;
1839#else
1840typedef khronos_ssize_t GLsizeiptr;
1841#endif
1842
1843#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
1844typedef khronos_ssize_t GLsizeiptrARB;
1845#else
1846typedef khronos_ssize_t GLsizeiptrARB;
1847#endif
1848
1849typedef khronos_int64_t GLint64;
1850
1851typedef khronos_int64_t GLint64EXT;
1852
1853typedef khronos_uint64_t GLuint64;
1854
1855typedef khronos_uint64_t GLuint64EXT;
1856
1857typedef struct __GLsync *GLsync;
1858
1859struct _cl_context;
1860
1861struct _cl_event;
1862
1863typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
1864
1865typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
1866
1867typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
1868
1869typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
1870
1871typedef unsigned short GLhalfNV;
1872
1873typedef GLintptr GLvdpauSurfaceNV;
1874
1875typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void);
1876
1877
1878
1879#define GL_VERSION_1_0 1
1880GLAD_API_CALL int GLAD_GL_VERSION_1_0;
1881#define GL_VERSION_1_1 1
1882GLAD_API_CALL int GLAD_GL_VERSION_1_1;
1883#define GL_VERSION_1_2 1
1884GLAD_API_CALL int GLAD_GL_VERSION_1_2;
1885#define GL_VERSION_1_3 1
1886GLAD_API_CALL int GLAD_GL_VERSION_1_3;
1887#define GL_VERSION_1_4 1
1888GLAD_API_CALL int GLAD_GL_VERSION_1_4;
1889#define GL_VERSION_1_5 1
1890GLAD_API_CALL int GLAD_GL_VERSION_1_5;
1891#define GL_VERSION_2_0 1
1892GLAD_API_CALL int GLAD_GL_VERSION_2_0;
1893#define GL_VERSION_2_1 1
1894GLAD_API_CALL int GLAD_GL_VERSION_2_1;
1895#define GL_VERSION_3_0 1
1896GLAD_API_CALL int GLAD_GL_VERSION_3_0;
1897#define GL_VERSION_3_1 1
1898GLAD_API_CALL int GLAD_GL_VERSION_3_1;
1899#define GL_VERSION_3_2 1
1900GLAD_API_CALL int GLAD_GL_VERSION_3_2;
1901#define GL_VERSION_3_3 1
1902GLAD_API_CALL int GLAD_GL_VERSION_3_3;
1903#define GL_ARB_multisample 1
1904GLAD_API_CALL int GLAD_GL_ARB_multisample;
1905#define GL_ARB_robustness 1
1906GLAD_API_CALL int GLAD_GL_ARB_robustness;
1907#define GL_KHR_debug 1
1908GLAD_API_CALL int GLAD_GL_KHR_debug;
1909
1910
1911typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum op, GLfloat value);
1912typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture);
1913typedef void (GLAD_API_PTR *PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref);
1914typedef GLboolean (GLAD_API_PTR *PFNGLARETEXTURESRESIDENTPROC)(GLsizei n, const GLuint * textures, GLboolean * residences);
1915typedef void (GLAD_API_PTR *PFNGLARRAYELEMENTPROC)(GLint i);
1916typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
1917typedef void (GLAD_API_PTR *PFNGLBEGINPROC)(GLenum mode);
1918typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode);
1919typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum target, GLuint id);
1920typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode);
1921typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name);
1922typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
1923typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer);
1924typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
1925typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar * name);
1926typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);
1927typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
1928typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
1929typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler);
1930typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
1931typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint array);
1932typedef void (GLAD_API_PTR *PFNGLBITMAPPROC)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap);
1933typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
1934typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode);
1935typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
1936typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
1937typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
1938typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
1939typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
1940typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
1941typedef void (GLAD_API_PTR *PFNGLCALLLISTPROC)(GLuint list);
1942typedef void (GLAD_API_PTR *PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, const void * lists);
1943typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
1944typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp);
1945typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask);
1946typedef void (GLAD_API_PTR *PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
1947typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
1948typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat * value);
1949typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint * value);
1950typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint * value);
1951typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
1952typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble depth);
1953typedef void (GLAD_API_PTR *PFNGLCLEARINDEXPROC)(GLfloat c);
1954typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s);
1955typedef void (GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture);
1956typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
1957typedef void (GLAD_API_PTR *PFNGLCLIPPLANEPROC)(GLenum plane, const GLdouble * equation);
1958typedef void (GLAD_API_PTR *PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue);
1959typedef void (GLAD_API_PTR *PFNGLCOLOR3BVPROC)(const GLbyte * v);
1960typedef void (GLAD_API_PTR *PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue);
1961typedef void (GLAD_API_PTR *PFNGLCOLOR3DVPROC)(const GLdouble * v);
1962typedef void (GLAD_API_PTR *PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue);
1963typedef void (GLAD_API_PTR *PFNGLCOLOR3FVPROC)(const GLfloat * v);
1964typedef void (GLAD_API_PTR *PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue);
1965typedef void (GLAD_API_PTR *PFNGLCOLOR3IVPROC)(const GLint * v);
1966typedef void (GLAD_API_PTR *PFNGLCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue);
1967typedef void (GLAD_API_PTR *PFNGLCOLOR3SVPROC)(const GLshort * v);
1968typedef void (GLAD_API_PTR *PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue);
1969typedef void (GLAD_API_PTR *PFNGLCOLOR3UBVPROC)(const GLubyte * v);
1970typedef void (GLAD_API_PTR *PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue);
1971typedef void (GLAD_API_PTR *PFNGLCOLOR3UIVPROC)(const GLuint * v);
1972typedef void (GLAD_API_PTR *PFNGLCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue);
1973typedef void (GLAD_API_PTR *PFNGLCOLOR3USVPROC)(const GLushort * v);
1974typedef void (GLAD_API_PTR *PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
1975typedef void (GLAD_API_PTR *PFNGLCOLOR4BVPROC)(const GLbyte * v);
1976typedef void (GLAD_API_PTR *PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
1977typedef void (GLAD_API_PTR *PFNGLCOLOR4DVPROC)(const GLdouble * v);
1978typedef void (GLAD_API_PTR *PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
1979typedef void (GLAD_API_PTR *PFNGLCOLOR4FVPROC)(const GLfloat * v);
1980typedef void (GLAD_API_PTR *PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, GLint alpha);
1981typedef void (GLAD_API_PTR *PFNGLCOLOR4IVPROC)(const GLint * v);
1982typedef void (GLAD_API_PTR *PFNGLCOLOR4SPROC)(GLshort red, GLshort green, GLshort blue, GLshort alpha);
1983typedef void (GLAD_API_PTR *PFNGLCOLOR4SVPROC)(const GLshort * v);
1984typedef void (GLAD_API_PTR *PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
1985typedef void (GLAD_API_PTR *PFNGLCOLOR4UBVPROC)(const GLubyte * v);
1986typedef void (GLAD_API_PTR *PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, GLuint alpha);
1987typedef void (GLAD_API_PTR *PFNGLCOLOR4UIVPROC)(const GLuint * v);
1988typedef void (GLAD_API_PTR *PFNGLCOLOR4USPROC)(GLushort red, GLushort green, GLushort blue, GLushort alpha);
1989typedef void (GLAD_API_PTR *PFNGLCOLOR4USVPROC)(const GLushort * v);
1990typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
1991typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
1992typedef void (GLAD_API_PTR *PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode);
1993typedef void (GLAD_API_PTR *PFNGLCOLORP3UIPROC)(GLenum type, GLuint color);
1994typedef void (GLAD_API_PTR *PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint * color);
1995typedef void (GLAD_API_PTR *PFNGLCOLORP4UIPROC)(GLenum type, GLuint color);
1996typedef void (GLAD_API_PTR *PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint * color);
1997typedef void (GLAD_API_PTR *PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer);
1998typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader);
1999typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data);
2000typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
2001typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
2002typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data);
2003typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
2004typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
2005typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
2006typedef void (GLAD_API_PTR *PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
2007typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
2008typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
2009typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
2010typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2011typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
2012typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
2013typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type);
2014typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode);
2015typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void * userParam);
2016typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled);
2017typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf);
2018typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers);
2019typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers);
2020typedef void (GLAD_API_PTR *PFNGLDELETELISTSPROC)(GLuint list, GLsizei range);
2021typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program);
2022typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint * ids);
2023typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers);
2024typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint * samplers);
2025typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader);
2026typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync sync);
2027typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures);
2028typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint * arrays);
2029typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func);
2030typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag);
2031typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f);
2032typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
2033typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap);
2034typedef void (GLAD_API_PTR *PFNGLDISABLECLIENTSTATEPROC)(GLenum array);
2035typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
2036typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum target, GLuint index);
2037typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
2038typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
2039typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum buf);
2040typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum * bufs);
2041typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices);
2042typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2043typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount);
2044typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
2045typedef void (GLAD_API_PTR *PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
2046typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices);
2047typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
2048typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPROC)(GLboolean flag);
2049typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, const void * pointer);
2050typedef void (GLAD_API_PTR *PFNGLEDGEFLAGVPROC)(const GLboolean * flag);
2051typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap);
2052typedef void (GLAD_API_PTR *PFNGLENABLECLIENTSTATEPROC)(GLenum array);
2053typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
2054typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum target, GLuint index);
2055typedef void (GLAD_API_PTR *PFNGLENDPROC)(void);
2056typedef void (GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void);
2057typedef void (GLAD_API_PTR *PFNGLENDLISTPROC)(void);
2058typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum target);
2059typedef void (GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void);
2060typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DPROC)(GLdouble u);
2061typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DVPROC)(const GLdouble * u);
2062typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FPROC)(GLfloat u);
2063typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FVPROC)(const GLfloat * u);
2064typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v);
2065typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DVPROC)(const GLdouble * u);
2066typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v);
2067typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FVPROC)(const GLfloat * u);
2068typedef void (GLAD_API_PTR *PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2);
2069typedef void (GLAD_API_PTR *PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
2070typedef void (GLAD_API_PTR *PFNGLEVALPOINT1PROC)(GLint i);
2071typedef void (GLAD_API_PTR *PFNGLEVALPOINT2PROC)(GLint i, GLint j);
2072typedef void (GLAD_API_PTR *PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, GLfloat * buffer);
2073typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags);
2074typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
2075typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
2076typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
2077typedef void (GLAD_API_PTR *PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer);
2078typedef void (GLAD_API_PTR *PFNGLFOGCOORDDPROC)(GLdouble coord);
2079typedef void (GLAD_API_PTR *PFNGLFOGCOORDDVPROC)(const GLdouble * coord);
2080typedef void (GLAD_API_PTR *PFNGLFOGCOORDFPROC)(GLfloat coord);
2081typedef void (GLAD_API_PTR *PFNGLFOGCOORDFVPROC)(const GLfloat * coord);
2082typedef void (GLAD_API_PTR *PFNGLFOGFPROC)(GLenum pname, GLfloat param);
2083typedef void (GLAD_API_PTR *PFNGLFOGFVPROC)(GLenum pname, const GLfloat * params);
2084typedef void (GLAD_API_PTR *PFNGLFOGIPROC)(GLenum pname, GLint param);
2085typedef void (GLAD_API_PTR *PFNGLFOGIVPROC)(GLenum pname, const GLint * params);
2086typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
2087typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
2088typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
2089typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
2090typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
2091typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
2092typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode);
2093typedef void (GLAD_API_PTR *PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
2094typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers);
2095typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
2096typedef GLuint (GLAD_API_PTR *PFNGLGENLISTSPROC)(GLsizei range);
2097typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei n, GLuint * ids);
2098typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
2099typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint * samplers);
2100typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures);
2101typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint * arrays);
2102typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target);
2103typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
2104typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
2105typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName);
2106typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params);
2107typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName);
2108typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params);
2109typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
2110typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name);
2111typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean * data);
2112typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data);
2113typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 * params);
2114typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2115typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void ** params);
2116typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void * data);
2117typedef void (GLAD_API_PTR *PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble * equation);
2118typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void * img);
2119typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog);
2120typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble * data);
2121typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
2122typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data);
2123typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar * name);
2124typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar * name);
2125typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
2126typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSARBPROC)(void);
2127typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 * data);
2128typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 * data);
2129typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint * data);
2130typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data);
2131typedef void (GLAD_API_PTR *PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, GLfloat * params);
2132typedef void (GLAD_API_PTR *PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, GLint * params);
2133typedef void (GLAD_API_PTR *PFNGLGETMAPDVPROC)(GLenum target, GLenum query, GLdouble * v);
2134typedef void (GLAD_API_PTR *PFNGLGETMAPFVPROC)(GLenum target, GLenum query, GLfloat * v);
2135typedef void (GLAD_API_PTR *PFNGLGETMAPIVPROC)(GLenum target, GLenum query, GLint * v);
2136typedef void (GLAD_API_PTR *PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, GLfloat * params);
2137typedef void (GLAD_API_PTR *PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, GLint * params);
2138typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat * val);
2139typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label);
2140typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label);
2141typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat * values);
2142typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint * values);
2143typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort * values);
2144typedef void (GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum pname, void ** params);
2145typedef void (GLAD_API_PTR *PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte * mask);
2146typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
2147typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params);
2148typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 * params);
2149typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint * params);
2150typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 * params);
2151typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint * params);
2152typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint * params);
2153typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2154typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint * params);
2155typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint * params);
2156typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat * params);
2157typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint * params);
2158typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
2159typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
2160typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params);
2161typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name);
2162typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum name, GLuint index);
2163typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei * length, GLint * values);
2164typedef void (GLAD_API_PTR *PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, GLfloat * params);
2165typedef void (GLAD_API_PTR *PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, GLint * params);
2166typedef void (GLAD_API_PTR *PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, GLdouble * params);
2167typedef void (GLAD_API_PTR *PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, GLfloat * params);
2168typedef void (GLAD_API_PTR *PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, GLint * params);
2169typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels);
2170typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat * params);
2171typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint * params);
2172typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint * params);
2173typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint * params);
2174typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params);
2175typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
2176typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name);
2177typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar * uniformBlockName);
2178typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices);
2179typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name);
2180typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params);
2181typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params);
2182typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint * params);
2183typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint * params);
2184typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint * params);
2185typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer);
2186typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble * params);
2187typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params);
2188typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params);
2189typedef void (GLAD_API_PTR *PFNGLGETNCOLORTABLEARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void * table);
2190typedef void (GLAD_API_PTR *PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC)(GLenum target, GLint lod, GLsizei bufSize, void * img);
2191typedef void (GLAD_API_PTR *PFNGLGETNCONVOLUTIONFILTERARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void * image);
2192typedef void (GLAD_API_PTR *PFNGLGETNHISTOGRAMARBPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void * values);
2193typedef void (GLAD_API_PTR *PFNGLGETNMAPDVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLdouble * v);
2194typedef void (GLAD_API_PTR *PFNGLGETNMAPFVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLfloat * v);
2195typedef void (GLAD_API_PTR *PFNGLGETNMAPIVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLint * v);
2196typedef void (GLAD_API_PTR *PFNGLGETNMINMAXARBPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void * values);
2197typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPFVARBPROC)(GLenum map, GLsizei bufSize, GLfloat * values);
2198typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUIVARBPROC)(GLenum map, GLsizei bufSize, GLuint * values);
2199typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUSVARBPROC)(GLenum map, GLsizei bufSize, GLushort * values);
2200typedef void (GLAD_API_PTR *PFNGLGETNPOLYGONSTIPPLEARBPROC)(GLsizei bufSize, GLubyte * pattern);
2201typedef void (GLAD_API_PTR *PFNGLGETNSEPARABLEFILTERARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void * row, GLsizei columnBufSize, void * column, void * span);
2202typedef void (GLAD_API_PTR *PFNGLGETNTEXIMAGEARBPROC)(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void * img);
2203typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMDVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLdouble * params);
2204typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
2205typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params);
2206typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint * params);
2207typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode);
2208typedef void (GLAD_API_PTR *PFNGLINDEXMASKPROC)(GLuint mask);
2209typedef void (GLAD_API_PTR *PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer);
2210typedef void (GLAD_API_PTR *PFNGLINDEXDPROC)(GLdouble c);
2211typedef void (GLAD_API_PTR *PFNGLINDEXDVPROC)(const GLdouble * c);
2212typedef void (GLAD_API_PTR *PFNGLINDEXFPROC)(GLfloat c);
2213typedef void (GLAD_API_PTR *PFNGLINDEXFVPROC)(const GLfloat * c);
2214typedef void (GLAD_API_PTR *PFNGLINDEXIPROC)(GLint c);
2215typedef void (GLAD_API_PTR *PFNGLINDEXIVPROC)(const GLint * c);
2216typedef void (GLAD_API_PTR *PFNGLINDEXSPROC)(GLshort c);
2217typedef void (GLAD_API_PTR *PFNGLINDEXSVPROC)(const GLshort * c);
2218typedef void (GLAD_API_PTR *PFNGLINDEXUBPROC)(GLubyte c);
2219typedef void (GLAD_API_PTR *PFNGLINDEXUBVPROC)(const GLubyte * c);
2220typedef void (GLAD_API_PTR *PFNGLINITNAMESPROC)(void);
2221typedef void (GLAD_API_PTR *PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, GLsizei stride, const void * pointer);
2222typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer);
2223typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap);
2224typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum target, GLuint index);
2225typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
2226typedef GLboolean (GLAD_API_PTR *PFNGLISLISTPROC)(GLuint list);
2227typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program);
2228typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint id);
2229typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
2230typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint sampler);
2231typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader);
2232typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync sync);
2233typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture);
2234typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint array);
2235typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param);
2236typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFVPROC)(GLenum pname, const GLfloat * params);
2237typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param);
2238typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIVPROC)(GLenum pname, const GLint * params);
2239typedef void (GLAD_API_PTR *PFNGLLIGHTFPROC)(GLenum light, GLenum pname, GLfloat param);
2240typedef void (GLAD_API_PTR *PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, const GLfloat * params);
2241typedef void (GLAD_API_PTR *PFNGLLIGHTIPROC)(GLenum light, GLenum pname, GLint param);
2242typedef void (GLAD_API_PTR *PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, const GLint * params);
2243typedef void (GLAD_API_PTR *PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern);
2244typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width);
2245typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program);
2246typedef void (GLAD_API_PTR *PFNGLLISTBASEPROC)(GLuint base);
2247typedef void (GLAD_API_PTR *PFNGLLOADIDENTITYPROC)(void);
2248typedef void (GLAD_API_PTR *PFNGLLOADMATRIXDPROC)(const GLdouble * m);
2249typedef void (GLAD_API_PTR *PFNGLLOADMATRIXFPROC)(const GLfloat * m);
2250typedef void (GLAD_API_PTR *PFNGLLOADNAMEPROC)(GLuint name);
2251typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble * m);
2252typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat * m);
2253typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum opcode);
2254typedef void (GLAD_API_PTR *PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points);
2255typedef void (GLAD_API_PTR *PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points);
2256typedef void (GLAD_API_PTR *PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points);
2257typedef void (GLAD_API_PTR *PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points);
2258typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum target, GLenum access);
2259typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
2260typedef void (GLAD_API_PTR *PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2);
2261typedef void (GLAD_API_PTR *PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2);
2262typedef void (GLAD_API_PTR *PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
2263typedef void (GLAD_API_PTR *PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
2264typedef void (GLAD_API_PTR *PFNGLMATERIALFPROC)(GLenum face, GLenum pname, GLfloat param);
2265typedef void (GLAD_API_PTR *PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, const GLfloat * params);
2266typedef void (GLAD_API_PTR *PFNGLMATERIALIPROC)(GLenum face, GLenum pname, GLint param);
2267typedef void (GLAD_API_PTR *PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, const GLint * params);
2268typedef void (GLAD_API_PTR *PFNGLMATRIXMODEPROC)(GLenum mode);
2269typedef void (GLAD_API_PTR *PFNGLMULTMATRIXDPROC)(const GLdouble * m);
2270typedef void (GLAD_API_PTR *PFNGLMULTMATRIXFPROC)(const GLfloat * m);
2271typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble * m);
2272typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat * m);
2273typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount);
2274typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount);
2275typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex);
2276typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s);
2277typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DVPROC)(GLenum target, const GLdouble * v);
2278typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s);
2279typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FVPROC)(GLenum target, const GLfloat * v);
2280typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s);
2281typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IVPROC)(GLenum target, const GLint * v);
2282typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s);
2283typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SVPROC)(GLenum target, const GLshort * v);
2284typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, GLdouble t);
2285typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DVPROC)(GLenum target, const GLdouble * v);
2286typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t);
2287typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FVPROC)(GLenum target, const GLfloat * v);
2288typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, GLint t);
2289typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IVPROC)(GLenum target, const GLint * v);
2290typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, GLshort t);
2291typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SVPROC)(GLenum target, const GLshort * v);
2292typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r);
2293typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DVPROC)(GLenum target, const GLdouble * v);
2294typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r);
2295typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FVPROC)(GLenum target, const GLfloat * v);
2296typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, GLint t, GLint r);
2297typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IVPROC)(GLenum target, const GLint * v);
2298typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, GLshort t, GLshort r);
2299typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SVPROC)(GLenum target, const GLshort * v);
2300typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
2301typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DVPROC)(GLenum target, const GLdouble * v);
2302typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
2303typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FVPROC)(GLenum target, const GLfloat * v);
2304typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q);
2305typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IVPROC)(GLenum target, const GLint * v);
2306typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
2307typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SVPROC)(GLenum target, const GLshort * v);
2308typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords);
2309typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint * coords);
2310typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords);
2311typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint * coords);
2312typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords);
2313typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint * coords);
2314typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords);
2315typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint * coords);
2316typedef void (GLAD_API_PTR *PFNGLNEWLISTPROC)(GLuint list, GLenum mode);
2317typedef void (GLAD_API_PTR *PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz);
2318typedef void (GLAD_API_PTR *PFNGLNORMAL3BVPROC)(const GLbyte * v);
2319typedef void (GLAD_API_PTR *PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, GLdouble nz);
2320typedef void (GLAD_API_PTR *PFNGLNORMAL3DVPROC)(const GLdouble * v);
2321typedef void (GLAD_API_PTR *PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz);
2322typedef void (GLAD_API_PTR *PFNGLNORMAL3FVPROC)(const GLfloat * v);
2323typedef void (GLAD_API_PTR *PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz);
2324typedef void (GLAD_API_PTR *PFNGLNORMAL3IVPROC)(const GLint * v);
2325typedef void (GLAD_API_PTR *PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz);
2326typedef void (GLAD_API_PTR *PFNGLNORMAL3SVPROC)(const GLshort * v);
2327typedef void (GLAD_API_PTR *PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords);
2328typedef void (GLAD_API_PTR *PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint * coords);
2329typedef void (GLAD_API_PTR *PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer);
2330typedef void (GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label);
2331typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void * ptr, GLsizei length, const GLchar * label);
2332typedef void (GLAD_API_PTR *PFNGLORTHOPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
2333typedef void (GLAD_API_PTR *PFNGLPASSTHROUGHPROC)(GLfloat token);
2334typedef void (GLAD_API_PTR *PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, const GLfloat * values);
2335typedef void (GLAD_API_PTR *PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, const GLuint * values);
2336typedef void (GLAD_API_PTR *PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, const GLushort * values);
2337typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param);
2338typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
2339typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param);
2340typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param);
2341typedef void (GLAD_API_PTR *PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor);
2342typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param);
2343typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat * params);
2344typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param);
2345typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint * params);
2346typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat size);
2347typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode);
2348typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
2349typedef void (GLAD_API_PTR *PFNGLPOLYGONSTIPPLEPROC)(const GLubyte * mask);
2350typedef void (GLAD_API_PTR *PFNGLPOPATTRIBPROC)(void);
2351typedef void (GLAD_API_PTR *PFNGLPOPCLIENTATTRIBPROC)(void);
2352typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPPROC)(void);
2353typedef void (GLAD_API_PTR *PFNGLPOPMATRIXPROC)(void);
2354typedef void (GLAD_API_PTR *PFNGLPOPNAMEPROC)(void);
2355typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index);
2356typedef void (GLAD_API_PTR *PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, const GLuint * textures, const GLfloat * priorities);
2357typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum mode);
2358typedef void (GLAD_API_PTR *PFNGLPUSHATTRIBPROC)(GLbitfield mask);
2359typedef void (GLAD_API_PTR *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask);
2360typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message);
2361typedef void (GLAD_API_PTR *PFNGLPUSHMATRIXPROC)(void);
2362typedef void (GLAD_API_PTR *PFNGLPUSHNAMEPROC)(GLuint name);
2363typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target);
2364typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y);
2365typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DVPROC)(const GLdouble * v);
2366typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y);
2367typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FVPROC)(const GLfloat * v);
2368typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IPROC)(GLint x, GLint y);
2369typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IVPROC)(const GLint * v);
2370typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y);
2371typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SVPROC)(const GLshort * v);
2372typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z);
2373typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DVPROC)(const GLdouble * v);
2374typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z);
2375typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FVPROC)(const GLfloat * v);
2376typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z);
2377typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IVPROC)(const GLint * v);
2378typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z);
2379typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SVPROC)(const GLshort * v);
2380typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
2381typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DVPROC)(const GLdouble * v);
2382typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
2383typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FVPROC)(const GLfloat * v);
2384typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, GLint w);
2385typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IVPROC)(const GLint * v);
2386typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w);
2387typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SVPROC)(const GLshort * v);
2388typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum src);
2389typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
2390typedef void (GLAD_API_PTR *PFNGLREADNPIXELSARBPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
2391typedef void (GLAD_API_PTR *PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
2392typedef void (GLAD_API_PTR *PFNGLRECTDVPROC)(const GLdouble * v1, const GLdouble * v2);
2393typedef void (GLAD_API_PTR *PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
2394typedef void (GLAD_API_PTR *PFNGLRECTFVPROC)(const GLfloat * v1, const GLfloat * v2);
2395typedef void (GLAD_API_PTR *PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2);
2396typedef void (GLAD_API_PTR *PFNGLRECTIVPROC)(const GLint * v1, const GLint * v2);
2397typedef void (GLAD_API_PTR *PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
2398typedef void (GLAD_API_PTR *PFNGLRECTSVPROC)(const GLshort * v1, const GLshort * v2);
2399typedef GLint (GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum mode);
2400typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
2401typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
2402typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
2403typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
2404typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
2405typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEARBPROC)(GLfloat value, GLboolean invert);
2406typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask);
2407typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint * param);
2408typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint * param);
2409typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param);
2410typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat * param);
2411typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param);
2412typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint * param);
2413typedef void (GLAD_API_PTR *PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z);
2414typedef void (GLAD_API_PTR *PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z);
2415typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
2416typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue);
2417typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte * v);
2418typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue);
2419typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble * v);
2420typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue);
2421typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat * v);
2422typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, GLint blue);
2423typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IVPROC)(const GLint * v);
2424typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue);
2425typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SVPROC)(const GLshort * v);
2426typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue);
2427typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte * v);
2428typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue);
2429typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint * v);
2430typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue);
2431typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USVPROC)(const GLushort * v);
2432typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color);
2433typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint * color);
2434typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer);
2435typedef void (GLAD_API_PTR *PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint * buffer);
2436typedef void (GLAD_API_PTR *PFNGLSHADEMODELPROC)(GLenum mode);
2437typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
2438typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
2439typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
2440typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask);
2441typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
2442typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
2443typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
2444typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer);
2445typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DPROC)(GLdouble s);
2446typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DVPROC)(const GLdouble * v);
2447typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FPROC)(GLfloat s);
2448typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FVPROC)(const GLfloat * v);
2449typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IPROC)(GLint s);
2450typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IVPROC)(const GLint * v);
2451typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SPROC)(GLshort s);
2452typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SVPROC)(const GLshort * v);
2453typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t);
2454typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DVPROC)(const GLdouble * v);
2455typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t);
2456typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FVPROC)(const GLfloat * v);
2457typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IPROC)(GLint s, GLint t);
2458typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IVPROC)(const GLint * v);
2459typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t);
2460typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SVPROC)(const GLshort * v);
2461typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r);
2462typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DVPROC)(const GLdouble * v);
2463typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r);
2464typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FVPROC)(const GLfloat * v);
2465typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r);
2466typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IVPROC)(const GLint * v);
2467typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r);
2468typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SVPROC)(const GLshort * v);
2469typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, GLdouble q);
2470typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DVPROC)(const GLdouble * v);
2471typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
2472typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FVPROC)(const GLfloat * v);
2473typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q);
2474typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IVPROC)(const GLint * v);
2475typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, GLshort q);
2476typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SVPROC)(const GLshort * v);
2477typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords);
2478typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint * coords);
2479typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords);
2480typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint * coords);
2481typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords);
2482typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint * coords);
2483typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords);
2484typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint * coords);
2485typedef void (GLAD_API_PTR *PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer);
2486typedef void (GLAD_API_PTR *PFNGLTEXENVFPROC)(GLenum target, GLenum pname, GLfloat param);
2487typedef void (GLAD_API_PTR *PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
2488typedef void (GLAD_API_PTR *PFNGLTEXENVIPROC)(GLenum target, GLenum pname, GLint param);
2489typedef void (GLAD_API_PTR *PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, const GLint * params);
2490typedef void (GLAD_API_PTR *PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, GLdouble param);
2491typedef void (GLAD_API_PTR *PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, const GLdouble * params);
2492typedef void (GLAD_API_PTR *PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, GLfloat param);
2493typedef void (GLAD_API_PTR *PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, const GLfloat * params);
2494typedef void (GLAD_API_PTR *PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, GLint param);
2495typedef void (GLAD_API_PTR *PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, const GLint * params);
2496typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels);
2497typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
2498typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
2499typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
2500typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
2501typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint * params);
2502typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint * params);
2503typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
2504typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
2505typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
2506typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params);
2507typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels);
2508typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
2509typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);
2510typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode);
2511typedef void (GLAD_API_PTR *PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z);
2512typedef void (GLAD_API_PTR *PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z);
2513typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
2514typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2515typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
2516typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value);
2517typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0);
2518typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint * value);
2519typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
2520typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2521typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
2522typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value);
2523typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1);
2524typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint * value);
2525typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
2526typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2527typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
2528typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value);
2529typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2);
2530typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint * value);
2531typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
2532typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value);
2533typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
2534typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value);
2535typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
2536typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint * value);
2537typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
2538typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2539typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2540typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2541typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2542typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2543typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2544typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2545typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2546typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
2547typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum target);
2548typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program);
2549typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program);
2550typedef void (GLAD_API_PTR *PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y);
2551typedef void (GLAD_API_PTR *PFNGLVERTEX2DVPROC)(const GLdouble * v);
2552typedef void (GLAD_API_PTR *PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y);
2553typedef void (GLAD_API_PTR *PFNGLVERTEX2FVPROC)(const GLfloat * v);
2554typedef void (GLAD_API_PTR *PFNGLVERTEX2IPROC)(GLint x, GLint y);
2555typedef void (GLAD_API_PTR *PFNGLVERTEX2IVPROC)(const GLint * v);
2556typedef void (GLAD_API_PTR *PFNGLVERTEX2SPROC)(GLshort x, GLshort y);
2557typedef void (GLAD_API_PTR *PFNGLVERTEX2SVPROC)(const GLshort * v);
2558typedef void (GLAD_API_PTR *PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z);
2559typedef void (GLAD_API_PTR *PFNGLVERTEX3DVPROC)(const GLdouble * v);
2560typedef void (GLAD_API_PTR *PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z);
2561typedef void (GLAD_API_PTR *PFNGLVERTEX3FVPROC)(const GLfloat * v);
2562typedef void (GLAD_API_PTR *PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z);
2563typedef void (GLAD_API_PTR *PFNGLVERTEX3IVPROC)(const GLint * v);
2564typedef void (GLAD_API_PTR *PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z);
2565typedef void (GLAD_API_PTR *PFNGLVERTEX3SVPROC)(const GLshort * v);
2566typedef void (GLAD_API_PTR *PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
2567typedef void (GLAD_API_PTR *PFNGLVERTEX4DVPROC)(const GLdouble * v);
2568typedef void (GLAD_API_PTR *PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
2569typedef void (GLAD_API_PTR *PFNGLVERTEX4FVPROC)(const GLfloat * v);
2570typedef void (GLAD_API_PTR *PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w);
2571typedef void (GLAD_API_PTR *PFNGLVERTEX4IVPROC)(const GLint * v);
2572typedef void (GLAD_API_PTR *PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w);
2573typedef void (GLAD_API_PTR *PFNGLVERTEX4SVPROC)(const GLshort * v);
2574typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x);
2575typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble * v);
2576typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
2577typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v);
2578typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x);
2579typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort * v);
2580typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y);
2581typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble * v);
2582typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
2583typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v);
2584typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y);
2585typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort * v);
2586typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
2587typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble * v);
2588typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
2589typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v);
2590typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
2591typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort * v);
2592typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte * v);
2593typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint * v);
2594typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort * v);
2595typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
2596typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte * v);
2597typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint * v);
2598typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort * v);
2599typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte * v);
2600typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
2601typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble * v);
2602typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
2603typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v);
2604typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint * v);
2605typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
2606typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort * v);
2607typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte * v);
2608typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint * v);
2609typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort * v);
2610typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor);
2611typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x);
2612typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint * v);
2613typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x);
2614typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint * v);
2615typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y);
2616typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint * v);
2617typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y);
2618typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint * v);
2619typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z);
2620typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint * v);
2621typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z);
2622typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint * v);
2623typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte * v);
2624typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w);
2625typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint * v);
2626typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort * v);
2627typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte * v);
2628typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
2629typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint * v);
2630typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort * v);
2631typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer);
2632typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
2633typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
2634typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
2635typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
2636typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
2637typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
2638typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
2639typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
2640typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
2641typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value);
2642typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint * value);
2643typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value);
2644typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint * value);
2645typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value);
2646typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint * value);
2647typedef void (GLAD_API_PTR *PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer);
2648typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
2649typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
2650typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y);
2651typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DVPROC)(const GLdouble * v);
2652typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y);
2653typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FVPROC)(const GLfloat * v);
2654typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IPROC)(GLint x, GLint y);
2655typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IVPROC)(const GLint * v);
2656typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y);
2657typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SVPROC)(const GLshort * v);
2658typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z);
2659typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DVPROC)(const GLdouble * v);
2660typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z);
2661typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FVPROC)(const GLfloat * v);
2662typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z);
2663typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IVPROC)(const GLint * v);
2664typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z);
2665typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SVPROC)(const GLshort * v);
2666
2667GLAD_API_CALL PFNGLACCUMPROC glad_glAccum;
2668#define glAccum glad_glAccum
2669GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
2670#define glActiveTexture glad_glActiveTexture
2671GLAD_API_CALL PFNGLALPHAFUNCPROC glad_glAlphaFunc;
2672#define glAlphaFunc glad_glAlphaFunc
2673GLAD_API_CALL PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident;
2674#define glAreTexturesResident glad_glAreTexturesResident
2675GLAD_API_CALL PFNGLARRAYELEMENTPROC glad_glArrayElement;
2676#define glArrayElement glad_glArrayElement
2677GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
2678#define glAttachShader glad_glAttachShader
2679GLAD_API_CALL PFNGLBEGINPROC glad_glBegin;
2680#define glBegin glad_glBegin
2681GLAD_API_CALL PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
2682#define glBeginConditionalRender glad_glBeginConditionalRender
2683GLAD_API_CALL PFNGLBEGINQUERYPROC glad_glBeginQuery;
2684#define glBeginQuery glad_glBeginQuery
2685GLAD_API_CALL PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
2686#define glBeginTransformFeedback glad_glBeginTransformFeedback
2687GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
2688#define glBindAttribLocation glad_glBindAttribLocation
2689GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
2690#define glBindBuffer glad_glBindBuffer
2691GLAD_API_CALL PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
2692#define glBindBufferBase glad_glBindBufferBase
2693GLAD_API_CALL PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
2694#define glBindBufferRange glad_glBindBufferRange
2695GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
2696#define glBindFragDataLocation glad_glBindFragDataLocation
2697GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
2698#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
2699GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
2700#define glBindFramebuffer glad_glBindFramebuffer
2701GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
2702#define glBindRenderbuffer glad_glBindRenderbuffer
2703GLAD_API_CALL PFNGLBINDSAMPLERPROC glad_glBindSampler;
2704#define glBindSampler glad_glBindSampler
2705GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
2706#define glBindTexture glad_glBindTexture
2707GLAD_API_CALL PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
2708#define glBindVertexArray glad_glBindVertexArray
2709GLAD_API_CALL PFNGLBITMAPPROC glad_glBitmap;
2710#define glBitmap glad_glBitmap
2711GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
2712#define glBlendColor glad_glBlendColor
2713GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
2714#define glBlendEquation glad_glBlendEquation
2715GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
2716#define glBlendEquationSeparate glad_glBlendEquationSeparate
2717GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
2718#define glBlendFunc glad_glBlendFunc
2719GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
2720#define glBlendFuncSeparate glad_glBlendFuncSeparate
2721GLAD_API_CALL PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
2722#define glBlitFramebuffer glad_glBlitFramebuffer
2723GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
2724#define glBufferData glad_glBufferData
2725GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
2726#define glBufferSubData glad_glBufferSubData
2727GLAD_API_CALL PFNGLCALLLISTPROC glad_glCallList;
2728#define glCallList glad_glCallList
2729GLAD_API_CALL PFNGLCALLLISTSPROC glad_glCallLists;
2730#define glCallLists glad_glCallLists
2731GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
2732#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
2733GLAD_API_CALL PFNGLCLAMPCOLORPROC glad_glClampColor;
2734#define glClampColor glad_glClampColor
2735GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
2736#define glClear glad_glClear
2737GLAD_API_CALL PFNGLCLEARACCUMPROC glad_glClearAccum;
2738#define glClearAccum glad_glClearAccum
2739GLAD_API_CALL PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
2740#define glClearBufferfi glad_glClearBufferfi
2741GLAD_API_CALL PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
2742#define glClearBufferfv glad_glClearBufferfv
2743GLAD_API_CALL PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
2744#define glClearBufferiv glad_glClearBufferiv
2745GLAD_API_CALL PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
2746#define glClearBufferuiv glad_glClearBufferuiv
2747GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
2748#define glClearColor glad_glClearColor
2749GLAD_API_CALL PFNGLCLEARDEPTHPROC glad_glClearDepth;
2750#define glClearDepth glad_glClearDepth
2751GLAD_API_CALL PFNGLCLEARINDEXPROC glad_glClearIndex;
2752#define glClearIndex glad_glClearIndex
2753GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
2754#define glClearStencil glad_glClearStencil
2755GLAD_API_CALL PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture;
2756#define glClientActiveTexture glad_glClientActiveTexture
2757GLAD_API_CALL PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
2758#define glClientWaitSync glad_glClientWaitSync
2759GLAD_API_CALL PFNGLCLIPPLANEPROC glad_glClipPlane;
2760#define glClipPlane glad_glClipPlane
2761GLAD_API_CALL PFNGLCOLOR3BPROC glad_glColor3b;
2762#define glColor3b glad_glColor3b
2763GLAD_API_CALL PFNGLCOLOR3BVPROC glad_glColor3bv;
2764#define glColor3bv glad_glColor3bv
2765GLAD_API_CALL PFNGLCOLOR3DPROC glad_glColor3d;
2766#define glColor3d glad_glColor3d
2767GLAD_API_CALL PFNGLCOLOR3DVPROC glad_glColor3dv;
2768#define glColor3dv glad_glColor3dv
2769GLAD_API_CALL PFNGLCOLOR3FPROC glad_glColor3f;
2770#define glColor3f glad_glColor3f
2771GLAD_API_CALL PFNGLCOLOR3FVPROC glad_glColor3fv;
2772#define glColor3fv glad_glColor3fv
2773GLAD_API_CALL PFNGLCOLOR3IPROC glad_glColor3i;
2774#define glColor3i glad_glColor3i
2775GLAD_API_CALL PFNGLCOLOR3IVPROC glad_glColor3iv;
2776#define glColor3iv glad_glColor3iv
2777GLAD_API_CALL PFNGLCOLOR3SPROC glad_glColor3s;
2778#define glColor3s glad_glColor3s
2779GLAD_API_CALL PFNGLCOLOR3SVPROC glad_glColor3sv;
2780#define glColor3sv glad_glColor3sv
2781GLAD_API_CALL PFNGLCOLOR3UBPROC glad_glColor3ub;
2782#define glColor3ub glad_glColor3ub
2783GLAD_API_CALL PFNGLCOLOR3UBVPROC glad_glColor3ubv;
2784#define glColor3ubv glad_glColor3ubv
2785GLAD_API_CALL PFNGLCOLOR3UIPROC glad_glColor3ui;
2786#define glColor3ui glad_glColor3ui
2787GLAD_API_CALL PFNGLCOLOR3UIVPROC glad_glColor3uiv;
2788#define glColor3uiv glad_glColor3uiv
2789GLAD_API_CALL PFNGLCOLOR3USPROC glad_glColor3us;
2790#define glColor3us glad_glColor3us
2791GLAD_API_CALL PFNGLCOLOR3USVPROC glad_glColor3usv;
2792#define glColor3usv glad_glColor3usv
2793GLAD_API_CALL PFNGLCOLOR4BPROC glad_glColor4b;
2794#define glColor4b glad_glColor4b
2795GLAD_API_CALL PFNGLCOLOR4BVPROC glad_glColor4bv;
2796#define glColor4bv glad_glColor4bv
2797GLAD_API_CALL PFNGLCOLOR4DPROC glad_glColor4d;
2798#define glColor4d glad_glColor4d
2799GLAD_API_CALL PFNGLCOLOR4DVPROC glad_glColor4dv;
2800#define glColor4dv glad_glColor4dv
2801GLAD_API_CALL PFNGLCOLOR4FPROC glad_glColor4f;
2802#define glColor4f glad_glColor4f
2803GLAD_API_CALL PFNGLCOLOR4FVPROC glad_glColor4fv;
2804#define glColor4fv glad_glColor4fv
2805GLAD_API_CALL PFNGLCOLOR4IPROC glad_glColor4i;
2806#define glColor4i glad_glColor4i
2807GLAD_API_CALL PFNGLCOLOR4IVPROC glad_glColor4iv;
2808#define glColor4iv glad_glColor4iv
2809GLAD_API_CALL PFNGLCOLOR4SPROC glad_glColor4s;
2810#define glColor4s glad_glColor4s
2811GLAD_API_CALL PFNGLCOLOR4SVPROC glad_glColor4sv;
2812#define glColor4sv glad_glColor4sv
2813GLAD_API_CALL PFNGLCOLOR4UBPROC glad_glColor4ub;
2814#define glColor4ub glad_glColor4ub
2815GLAD_API_CALL PFNGLCOLOR4UBVPROC glad_glColor4ubv;
2816#define glColor4ubv glad_glColor4ubv
2817GLAD_API_CALL PFNGLCOLOR4UIPROC glad_glColor4ui;
2818#define glColor4ui glad_glColor4ui
2819GLAD_API_CALL PFNGLCOLOR4UIVPROC glad_glColor4uiv;
2820#define glColor4uiv glad_glColor4uiv
2821GLAD_API_CALL PFNGLCOLOR4USPROC glad_glColor4us;
2822#define glColor4us glad_glColor4us
2823GLAD_API_CALL PFNGLCOLOR4USVPROC glad_glColor4usv;
2824#define glColor4usv glad_glColor4usv
2825GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
2826#define glColorMask glad_glColorMask
2827GLAD_API_CALL PFNGLCOLORMASKIPROC glad_glColorMaski;
2828#define glColorMaski glad_glColorMaski
2829GLAD_API_CALL PFNGLCOLORMATERIALPROC glad_glColorMaterial;
2830#define glColorMaterial glad_glColorMaterial
2831GLAD_API_CALL PFNGLCOLORP3UIPROC glad_glColorP3ui;
2832#define glColorP3ui glad_glColorP3ui
2833GLAD_API_CALL PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
2834#define glColorP3uiv glad_glColorP3uiv
2835GLAD_API_CALL PFNGLCOLORP4UIPROC glad_glColorP4ui;
2836#define glColorP4ui glad_glColorP4ui
2837GLAD_API_CALL PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
2838#define glColorP4uiv glad_glColorP4uiv
2839GLAD_API_CALL PFNGLCOLORPOINTERPROC glad_glColorPointer;
2840#define glColorPointer glad_glColorPointer
2841GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
2842#define glCompileShader glad_glCompileShader
2843GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
2844#define glCompressedTexImage1D glad_glCompressedTexImage1D
2845GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
2846#define glCompressedTexImage2D glad_glCompressedTexImage2D
2847GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
2848#define glCompressedTexImage3D glad_glCompressedTexImage3D
2849GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
2850#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
2851GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
2852#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
2853GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
2854#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
2855GLAD_API_CALL PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
2856#define glCopyBufferSubData glad_glCopyBufferSubData
2857GLAD_API_CALL PFNGLCOPYPIXELSPROC glad_glCopyPixels;
2858#define glCopyPixels glad_glCopyPixels
2859GLAD_API_CALL PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
2860#define glCopyTexImage1D glad_glCopyTexImage1D
2861GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
2862#define glCopyTexImage2D glad_glCopyTexImage2D
2863GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
2864#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
2865GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
2866#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
2867GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
2868#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
2869GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
2870#define glCreateProgram glad_glCreateProgram
2871GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
2872#define glCreateShader glad_glCreateShader
2873GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
2874#define glCullFace glad_glCullFace
2875GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback;
2876#define glDebugMessageCallback glad_glDebugMessageCallback
2877GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl;
2878#define glDebugMessageControl glad_glDebugMessageControl
2879GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert;
2880#define glDebugMessageInsert glad_glDebugMessageInsert
2881GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
2882#define glDeleteBuffers glad_glDeleteBuffers
2883GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
2884#define glDeleteFramebuffers glad_glDeleteFramebuffers
2885GLAD_API_CALL PFNGLDELETELISTSPROC glad_glDeleteLists;
2886#define glDeleteLists glad_glDeleteLists
2887GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
2888#define glDeleteProgram glad_glDeleteProgram
2889GLAD_API_CALL PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
2890#define glDeleteQueries glad_glDeleteQueries
2891GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
2892#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
2893GLAD_API_CALL PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
2894#define glDeleteSamplers glad_glDeleteSamplers
2895GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
2896#define glDeleteShader glad_glDeleteShader
2897GLAD_API_CALL PFNGLDELETESYNCPROC glad_glDeleteSync;
2898#define glDeleteSync glad_glDeleteSync
2899GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
2900#define glDeleteTextures glad_glDeleteTextures
2901GLAD_API_CALL PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
2902#define glDeleteVertexArrays glad_glDeleteVertexArrays
2903GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
2904#define glDepthFunc glad_glDepthFunc
2905GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
2906#define glDepthMask glad_glDepthMask
2907GLAD_API_CALL PFNGLDEPTHRANGEPROC glad_glDepthRange;
2908#define glDepthRange glad_glDepthRange
2909GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
2910#define glDetachShader glad_glDetachShader
2911GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
2912#define glDisable glad_glDisable
2913GLAD_API_CALL PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState;
2914#define glDisableClientState glad_glDisableClientState
2915GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
2916#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
2917GLAD_API_CALL PFNGLDISABLEIPROC glad_glDisablei;
2918#define glDisablei glad_glDisablei
2919GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
2920#define glDrawArrays glad_glDrawArrays
2921GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
2922#define glDrawArraysInstanced glad_glDrawArraysInstanced
2923GLAD_API_CALL PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
2924#define glDrawBuffer glad_glDrawBuffer
2925GLAD_API_CALL PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
2926#define glDrawBuffers glad_glDrawBuffers
2927GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
2928#define glDrawElements glad_glDrawElements
2929GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
2930#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
2931GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
2932#define glDrawElementsInstanced glad_glDrawElementsInstanced
2933GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
2934#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
2935GLAD_API_CALL PFNGLDRAWPIXELSPROC glad_glDrawPixels;
2936#define glDrawPixels glad_glDrawPixels
2937GLAD_API_CALL PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
2938#define glDrawRangeElements glad_glDrawRangeElements
2939GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
2940#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
2941GLAD_API_CALL PFNGLEDGEFLAGPROC glad_glEdgeFlag;
2942#define glEdgeFlag glad_glEdgeFlag
2943GLAD_API_CALL PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer;
2944#define glEdgeFlagPointer glad_glEdgeFlagPointer
2945GLAD_API_CALL PFNGLEDGEFLAGVPROC glad_glEdgeFlagv;
2946#define glEdgeFlagv glad_glEdgeFlagv
2947GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
2948#define glEnable glad_glEnable
2949GLAD_API_CALL PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState;
2950#define glEnableClientState glad_glEnableClientState
2951GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
2952#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
2953GLAD_API_CALL PFNGLENABLEIPROC glad_glEnablei;
2954#define glEnablei glad_glEnablei
2955GLAD_API_CALL PFNGLENDPROC glad_glEnd;
2956#define glEnd glad_glEnd
2957GLAD_API_CALL PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
2958#define glEndConditionalRender glad_glEndConditionalRender
2959GLAD_API_CALL PFNGLENDLISTPROC glad_glEndList;
2960#define glEndList glad_glEndList
2961GLAD_API_CALL PFNGLENDQUERYPROC glad_glEndQuery;
2962#define glEndQuery glad_glEndQuery
2963GLAD_API_CALL PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
2964#define glEndTransformFeedback glad_glEndTransformFeedback
2965GLAD_API_CALL PFNGLEVALCOORD1DPROC glad_glEvalCoord1d;
2966#define glEvalCoord1d glad_glEvalCoord1d
2967GLAD_API_CALL PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv;
2968#define glEvalCoord1dv glad_glEvalCoord1dv
2969GLAD_API_CALL PFNGLEVALCOORD1FPROC glad_glEvalCoord1f;
2970#define glEvalCoord1f glad_glEvalCoord1f
2971GLAD_API_CALL PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv;
2972#define glEvalCoord1fv glad_glEvalCoord1fv
2973GLAD_API_CALL PFNGLEVALCOORD2DPROC glad_glEvalCoord2d;
2974#define glEvalCoord2d glad_glEvalCoord2d
2975GLAD_API_CALL PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv;
2976#define glEvalCoord2dv glad_glEvalCoord2dv
2977GLAD_API_CALL PFNGLEVALCOORD2FPROC glad_glEvalCoord2f;
2978#define glEvalCoord2f glad_glEvalCoord2f
2979GLAD_API_CALL PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv;
2980#define glEvalCoord2fv glad_glEvalCoord2fv
2981GLAD_API_CALL PFNGLEVALMESH1PROC glad_glEvalMesh1;
2982#define glEvalMesh1 glad_glEvalMesh1
2983GLAD_API_CALL PFNGLEVALMESH2PROC glad_glEvalMesh2;
2984#define glEvalMesh2 glad_glEvalMesh2
2985GLAD_API_CALL PFNGLEVALPOINT1PROC glad_glEvalPoint1;
2986#define glEvalPoint1 glad_glEvalPoint1
2987GLAD_API_CALL PFNGLEVALPOINT2PROC glad_glEvalPoint2;
2988#define glEvalPoint2 glad_glEvalPoint2
2989GLAD_API_CALL PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer;
2990#define glFeedbackBuffer glad_glFeedbackBuffer
2991GLAD_API_CALL PFNGLFENCESYNCPROC glad_glFenceSync;
2992#define glFenceSync glad_glFenceSync
2993GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
2994#define glFinish glad_glFinish
2995GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
2996#define glFlush glad_glFlush
2997GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
2998#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
2999GLAD_API_CALL PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer;
3000#define glFogCoordPointer glad_glFogCoordPointer
3001GLAD_API_CALL PFNGLFOGCOORDDPROC glad_glFogCoordd;
3002#define glFogCoordd glad_glFogCoordd
3003GLAD_API_CALL PFNGLFOGCOORDDVPROC glad_glFogCoorddv;
3004#define glFogCoorddv glad_glFogCoorddv
3005GLAD_API_CALL PFNGLFOGCOORDFPROC glad_glFogCoordf;
3006#define glFogCoordf glad_glFogCoordf
3007GLAD_API_CALL PFNGLFOGCOORDFVPROC glad_glFogCoordfv;
3008#define glFogCoordfv glad_glFogCoordfv
3009GLAD_API_CALL PFNGLFOGFPROC glad_glFogf;
3010#define glFogf glad_glFogf
3011GLAD_API_CALL PFNGLFOGFVPROC glad_glFogfv;
3012#define glFogfv glad_glFogfv
3013GLAD_API_CALL PFNGLFOGIPROC glad_glFogi;
3014#define glFogi glad_glFogi
3015GLAD_API_CALL PFNGLFOGIVPROC glad_glFogiv;
3016#define glFogiv glad_glFogiv
3017GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
3018#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
3019GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
3020#define glFramebufferTexture glad_glFramebufferTexture
3021GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
3022#define glFramebufferTexture1D glad_glFramebufferTexture1D
3023GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
3024#define glFramebufferTexture2D glad_glFramebufferTexture2D
3025GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
3026#define glFramebufferTexture3D glad_glFramebufferTexture3D
3027GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
3028#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
3029GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
3030#define glFrontFace glad_glFrontFace
3031GLAD_API_CALL PFNGLFRUSTUMPROC glad_glFrustum;
3032#define glFrustum glad_glFrustum
3033GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
3034#define glGenBuffers glad_glGenBuffers
3035GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
3036#define glGenFramebuffers glad_glGenFramebuffers
3037GLAD_API_CALL PFNGLGENLISTSPROC glad_glGenLists;
3038#define glGenLists glad_glGenLists
3039GLAD_API_CALL PFNGLGENQUERIESPROC glad_glGenQueries;
3040#define glGenQueries glad_glGenQueries
3041GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
3042#define glGenRenderbuffers glad_glGenRenderbuffers
3043GLAD_API_CALL PFNGLGENSAMPLERSPROC glad_glGenSamplers;
3044#define glGenSamplers glad_glGenSamplers
3045GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
3046#define glGenTextures glad_glGenTextures
3047GLAD_API_CALL PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
3048#define glGenVertexArrays glad_glGenVertexArrays
3049GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
3050#define glGenerateMipmap glad_glGenerateMipmap
3051GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
3052#define glGetActiveAttrib glad_glGetActiveAttrib
3053GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
3054#define glGetActiveUniform glad_glGetActiveUniform
3055GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
3056#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
3057GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
3058#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
3059GLAD_API_CALL PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
3060#define glGetActiveUniformName glad_glGetActiveUniformName
3061GLAD_API_CALL PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
3062#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
3063GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
3064#define glGetAttachedShaders glad_glGetAttachedShaders
3065GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
3066#define glGetAttribLocation glad_glGetAttribLocation
3067GLAD_API_CALL PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
3068#define glGetBooleani_v glad_glGetBooleani_v
3069GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
3070#define glGetBooleanv glad_glGetBooleanv
3071GLAD_API_CALL PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
3072#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
3073GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
3074#define glGetBufferParameteriv glad_glGetBufferParameteriv
3075GLAD_API_CALL PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
3076#define glGetBufferPointerv glad_glGetBufferPointerv
3077GLAD_API_CALL PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
3078#define glGetBufferSubData glad_glGetBufferSubData
3079GLAD_API_CALL PFNGLGETCLIPPLANEPROC glad_glGetClipPlane;
3080#define glGetClipPlane glad_glGetClipPlane
3081GLAD_API_CALL PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
3082#define glGetCompressedTexImage glad_glGetCompressedTexImage
3083GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog;
3084#define glGetDebugMessageLog glad_glGetDebugMessageLog
3085GLAD_API_CALL PFNGLGETDOUBLEVPROC glad_glGetDoublev;
3086#define glGetDoublev glad_glGetDoublev
3087GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
3088#define glGetError glad_glGetError
3089GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
3090#define glGetFloatv glad_glGetFloatv
3091GLAD_API_CALL PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
3092#define glGetFragDataIndex glad_glGetFragDataIndex
3093GLAD_API_CALL PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
3094#define glGetFragDataLocation glad_glGetFragDataLocation
3095GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
3096#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
3097GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB;
3098#define glGetGraphicsResetStatusARB glad_glGetGraphicsResetStatusARB
3099GLAD_API_CALL PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
3100#define glGetInteger64i_v glad_glGetInteger64i_v
3101GLAD_API_CALL PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
3102#define glGetInteger64v glad_glGetInteger64v
3103GLAD_API_CALL PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
3104#define glGetIntegeri_v glad_glGetIntegeri_v
3105GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
3106#define glGetIntegerv glad_glGetIntegerv
3107GLAD_API_CALL PFNGLGETLIGHTFVPROC glad_glGetLightfv;
3108#define glGetLightfv glad_glGetLightfv
3109GLAD_API_CALL PFNGLGETLIGHTIVPROC glad_glGetLightiv;
3110#define glGetLightiv glad_glGetLightiv
3111GLAD_API_CALL PFNGLGETMAPDVPROC glad_glGetMapdv;
3112#define glGetMapdv glad_glGetMapdv
3113GLAD_API_CALL PFNGLGETMAPFVPROC glad_glGetMapfv;
3114#define glGetMapfv glad_glGetMapfv
3115GLAD_API_CALL PFNGLGETMAPIVPROC glad_glGetMapiv;
3116#define glGetMapiv glad_glGetMapiv
3117GLAD_API_CALL PFNGLGETMATERIALFVPROC glad_glGetMaterialfv;
3118#define glGetMaterialfv glad_glGetMaterialfv
3119GLAD_API_CALL PFNGLGETMATERIALIVPROC glad_glGetMaterialiv;
3120#define glGetMaterialiv glad_glGetMaterialiv
3121GLAD_API_CALL PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
3122#define glGetMultisamplefv glad_glGetMultisamplefv
3123GLAD_API_CALL PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel;
3124#define glGetObjectLabel glad_glGetObjectLabel
3125GLAD_API_CALL PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel;
3126#define glGetObjectPtrLabel glad_glGetObjectPtrLabel
3127GLAD_API_CALL PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv;
3128#define glGetPixelMapfv glad_glGetPixelMapfv
3129GLAD_API_CALL PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv;
3130#define glGetPixelMapuiv glad_glGetPixelMapuiv
3131GLAD_API_CALL PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv;
3132#define glGetPixelMapusv glad_glGetPixelMapusv
3133GLAD_API_CALL PFNGLGETPOINTERVPROC glad_glGetPointerv;
3134#define glGetPointerv glad_glGetPointerv
3135GLAD_API_CALL PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple;
3136#define glGetPolygonStipple glad_glGetPolygonStipple
3137GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
3138#define glGetProgramInfoLog glad_glGetProgramInfoLog
3139GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
3140#define glGetProgramiv glad_glGetProgramiv
3141GLAD_API_CALL PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
3142#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
3143GLAD_API_CALL PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
3144#define glGetQueryObjectiv glad_glGetQueryObjectiv
3145GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
3146#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
3147GLAD_API_CALL PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
3148#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
3149GLAD_API_CALL PFNGLGETQUERYIVPROC glad_glGetQueryiv;
3150#define glGetQueryiv glad_glGetQueryiv
3151GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
3152#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
3153GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
3154#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
3155GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
3156#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
3157GLAD_API_CALL PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
3158#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
3159GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
3160#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
3161GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
3162#define glGetShaderInfoLog glad_glGetShaderInfoLog
3163GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
3164#define glGetShaderSource glad_glGetShaderSource
3165GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
3166#define glGetShaderiv glad_glGetShaderiv
3167GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
3168#define glGetString glad_glGetString
3169GLAD_API_CALL PFNGLGETSTRINGIPROC glad_glGetStringi;
3170#define glGetStringi glad_glGetStringi
3171GLAD_API_CALL PFNGLGETSYNCIVPROC glad_glGetSynciv;
3172#define glGetSynciv glad_glGetSynciv
3173GLAD_API_CALL PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv;
3174#define glGetTexEnvfv glad_glGetTexEnvfv
3175GLAD_API_CALL PFNGLGETTEXENVIVPROC glad_glGetTexEnviv;
3176#define glGetTexEnviv glad_glGetTexEnviv
3177GLAD_API_CALL PFNGLGETTEXGENDVPROC glad_glGetTexGendv;
3178#define glGetTexGendv glad_glGetTexGendv
3179GLAD_API_CALL PFNGLGETTEXGENFVPROC glad_glGetTexGenfv;
3180#define glGetTexGenfv glad_glGetTexGenfv
3181GLAD_API_CALL PFNGLGETTEXGENIVPROC glad_glGetTexGeniv;
3182#define glGetTexGeniv glad_glGetTexGeniv
3183GLAD_API_CALL PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
3184#define glGetTexImage glad_glGetTexImage
3185GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
3186#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
3187GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
3188#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
3189GLAD_API_CALL PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
3190#define glGetTexParameterIiv glad_glGetTexParameterIiv
3191GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
3192#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
3193GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
3194#define glGetTexParameterfv glad_glGetTexParameterfv
3195GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
3196#define glGetTexParameteriv glad_glGetTexParameteriv
3197GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
3198#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
3199GLAD_API_CALL PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
3200#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
3201GLAD_API_CALL PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
3202#define glGetUniformIndices glad_glGetUniformIndices
3203GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
3204#define glGetUniformLocation glad_glGetUniformLocation
3205GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
3206#define glGetUniformfv glad_glGetUniformfv
3207GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
3208#define glGetUniformiv glad_glGetUniformiv
3209GLAD_API_CALL PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
3210#define glGetUniformuiv glad_glGetUniformuiv
3211GLAD_API_CALL PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
3212#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
3213GLAD_API_CALL PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
3214#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
3215GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
3216#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
3217GLAD_API_CALL PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
3218#define glGetVertexAttribdv glad_glGetVertexAttribdv
3219GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
3220#define glGetVertexAttribfv glad_glGetVertexAttribfv
3221GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
3222#define glGetVertexAttribiv glad_glGetVertexAttribiv
3223GLAD_API_CALL PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB;
3224#define glGetnColorTableARB glad_glGetnColorTableARB
3225GLAD_API_CALL PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB;
3226#define glGetnCompressedTexImageARB glad_glGetnCompressedTexImageARB
3227GLAD_API_CALL PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB;
3228#define glGetnConvolutionFilterARB glad_glGetnConvolutionFilterARB
3229GLAD_API_CALL PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB;
3230#define glGetnHistogramARB glad_glGetnHistogramARB
3231GLAD_API_CALL PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB;
3232#define glGetnMapdvARB glad_glGetnMapdvARB
3233GLAD_API_CALL PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB;
3234#define glGetnMapfvARB glad_glGetnMapfvARB
3235GLAD_API_CALL PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB;
3236#define glGetnMapivARB glad_glGetnMapivARB
3237GLAD_API_CALL PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB;
3238#define glGetnMinmaxARB glad_glGetnMinmaxARB
3239GLAD_API_CALL PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB;
3240#define glGetnPixelMapfvARB glad_glGetnPixelMapfvARB
3241GLAD_API_CALL PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB;
3242#define glGetnPixelMapuivARB glad_glGetnPixelMapuivARB
3243GLAD_API_CALL PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB;
3244#define glGetnPixelMapusvARB glad_glGetnPixelMapusvARB
3245GLAD_API_CALL PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB;
3246#define glGetnPolygonStippleARB glad_glGetnPolygonStippleARB
3247GLAD_API_CALL PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB;
3248#define glGetnSeparableFilterARB glad_glGetnSeparableFilterARB
3249GLAD_API_CALL PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB;
3250#define glGetnTexImageARB glad_glGetnTexImageARB
3251GLAD_API_CALL PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB;
3252#define glGetnUniformdvARB glad_glGetnUniformdvARB
3253GLAD_API_CALL PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB;
3254#define glGetnUniformfvARB glad_glGetnUniformfvARB
3255GLAD_API_CALL PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB;
3256#define glGetnUniformivARB glad_glGetnUniformivARB
3257GLAD_API_CALL PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB;
3258#define glGetnUniformuivARB glad_glGetnUniformuivARB
3259GLAD_API_CALL PFNGLHINTPROC glad_glHint;
3260#define glHint glad_glHint
3261GLAD_API_CALL PFNGLINDEXMASKPROC glad_glIndexMask;
3262#define glIndexMask glad_glIndexMask
3263GLAD_API_CALL PFNGLINDEXPOINTERPROC glad_glIndexPointer;
3264#define glIndexPointer glad_glIndexPointer
3265GLAD_API_CALL PFNGLINDEXDPROC glad_glIndexd;
3266#define glIndexd glad_glIndexd
3267GLAD_API_CALL PFNGLINDEXDVPROC glad_glIndexdv;
3268#define glIndexdv glad_glIndexdv
3269GLAD_API_CALL PFNGLINDEXFPROC glad_glIndexf;
3270#define glIndexf glad_glIndexf
3271GLAD_API_CALL PFNGLINDEXFVPROC glad_glIndexfv;
3272#define glIndexfv glad_glIndexfv
3273GLAD_API_CALL PFNGLINDEXIPROC glad_glIndexi;
3274#define glIndexi glad_glIndexi
3275GLAD_API_CALL PFNGLINDEXIVPROC glad_glIndexiv;
3276#define glIndexiv glad_glIndexiv
3277GLAD_API_CALL PFNGLINDEXSPROC glad_glIndexs;
3278#define glIndexs glad_glIndexs
3279GLAD_API_CALL PFNGLINDEXSVPROC glad_glIndexsv;
3280#define glIndexsv glad_glIndexsv
3281GLAD_API_CALL PFNGLINDEXUBPROC glad_glIndexub;
3282#define glIndexub glad_glIndexub
3283GLAD_API_CALL PFNGLINDEXUBVPROC glad_glIndexubv;
3284#define glIndexubv glad_glIndexubv
3285GLAD_API_CALL PFNGLINITNAMESPROC glad_glInitNames;
3286#define glInitNames glad_glInitNames
3287GLAD_API_CALL PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays;
3288#define glInterleavedArrays glad_glInterleavedArrays
3289GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
3290#define glIsBuffer glad_glIsBuffer
3291GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
3292#define glIsEnabled glad_glIsEnabled
3293GLAD_API_CALL PFNGLISENABLEDIPROC glad_glIsEnabledi;
3294#define glIsEnabledi glad_glIsEnabledi
3295GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
3296#define glIsFramebuffer glad_glIsFramebuffer
3297GLAD_API_CALL PFNGLISLISTPROC glad_glIsList;
3298#define glIsList glad_glIsList
3299GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
3300#define glIsProgram glad_glIsProgram
3301GLAD_API_CALL PFNGLISQUERYPROC glad_glIsQuery;
3302#define glIsQuery glad_glIsQuery
3303GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
3304#define glIsRenderbuffer glad_glIsRenderbuffer
3305GLAD_API_CALL PFNGLISSAMPLERPROC glad_glIsSampler;
3306#define glIsSampler glad_glIsSampler
3307GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
3308#define glIsShader glad_glIsShader
3309GLAD_API_CALL PFNGLISSYNCPROC glad_glIsSync;
3310#define glIsSync glad_glIsSync
3311GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
3312#define glIsTexture glad_glIsTexture
3313GLAD_API_CALL PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
3314#define glIsVertexArray glad_glIsVertexArray
3315GLAD_API_CALL PFNGLLIGHTMODELFPROC glad_glLightModelf;
3316#define glLightModelf glad_glLightModelf
3317GLAD_API_CALL PFNGLLIGHTMODELFVPROC glad_glLightModelfv;
3318#define glLightModelfv glad_glLightModelfv
3319GLAD_API_CALL PFNGLLIGHTMODELIPROC glad_glLightModeli;
3320#define glLightModeli glad_glLightModeli
3321GLAD_API_CALL PFNGLLIGHTMODELIVPROC glad_glLightModeliv;
3322#define glLightModeliv glad_glLightModeliv
3323GLAD_API_CALL PFNGLLIGHTFPROC glad_glLightf;
3324#define glLightf glad_glLightf
3325GLAD_API_CALL PFNGLLIGHTFVPROC glad_glLightfv;
3326#define glLightfv glad_glLightfv
3327GLAD_API_CALL PFNGLLIGHTIPROC glad_glLighti;
3328#define glLighti glad_glLighti
3329GLAD_API_CALL PFNGLLIGHTIVPROC glad_glLightiv;
3330#define glLightiv glad_glLightiv
3331GLAD_API_CALL PFNGLLINESTIPPLEPROC glad_glLineStipple;
3332#define glLineStipple glad_glLineStipple
3333GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
3334#define glLineWidth glad_glLineWidth
3335GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
3336#define glLinkProgram glad_glLinkProgram
3337GLAD_API_CALL PFNGLLISTBASEPROC glad_glListBase;
3338#define glListBase glad_glListBase
3339GLAD_API_CALL PFNGLLOADIDENTITYPROC glad_glLoadIdentity;
3340#define glLoadIdentity glad_glLoadIdentity
3341GLAD_API_CALL PFNGLLOADMATRIXDPROC glad_glLoadMatrixd;
3342#define glLoadMatrixd glad_glLoadMatrixd
3343GLAD_API_CALL PFNGLLOADMATRIXFPROC glad_glLoadMatrixf;
3344#define glLoadMatrixf glad_glLoadMatrixf
3345GLAD_API_CALL PFNGLLOADNAMEPROC glad_glLoadName;
3346#define glLoadName glad_glLoadName
3347GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd;
3348#define glLoadTransposeMatrixd glad_glLoadTransposeMatrixd
3349GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf;
3350#define glLoadTransposeMatrixf glad_glLoadTransposeMatrixf
3351GLAD_API_CALL PFNGLLOGICOPPROC glad_glLogicOp;
3352#define glLogicOp glad_glLogicOp
3353GLAD_API_CALL PFNGLMAP1DPROC glad_glMap1d;
3354#define glMap1d glad_glMap1d
3355GLAD_API_CALL PFNGLMAP1FPROC glad_glMap1f;
3356#define glMap1f glad_glMap1f
3357GLAD_API_CALL PFNGLMAP2DPROC glad_glMap2d;
3358#define glMap2d glad_glMap2d
3359GLAD_API_CALL PFNGLMAP2FPROC glad_glMap2f;
3360#define glMap2f glad_glMap2f
3361GLAD_API_CALL PFNGLMAPBUFFERPROC glad_glMapBuffer;
3362#define glMapBuffer glad_glMapBuffer
3363GLAD_API_CALL PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
3364#define glMapBufferRange glad_glMapBufferRange
3365GLAD_API_CALL PFNGLMAPGRID1DPROC glad_glMapGrid1d;
3366#define glMapGrid1d glad_glMapGrid1d
3367GLAD_API_CALL PFNGLMAPGRID1FPROC glad_glMapGrid1f;
3368#define glMapGrid1f glad_glMapGrid1f
3369GLAD_API_CALL PFNGLMAPGRID2DPROC glad_glMapGrid2d;
3370#define glMapGrid2d glad_glMapGrid2d
3371GLAD_API_CALL PFNGLMAPGRID2FPROC glad_glMapGrid2f;
3372#define glMapGrid2f glad_glMapGrid2f
3373GLAD_API_CALL PFNGLMATERIALFPROC glad_glMaterialf;
3374#define glMaterialf glad_glMaterialf
3375GLAD_API_CALL PFNGLMATERIALFVPROC glad_glMaterialfv;
3376#define glMaterialfv glad_glMaterialfv
3377GLAD_API_CALL PFNGLMATERIALIPROC glad_glMateriali;
3378#define glMateriali glad_glMateriali
3379GLAD_API_CALL PFNGLMATERIALIVPROC glad_glMaterialiv;
3380#define glMaterialiv glad_glMaterialiv
3381GLAD_API_CALL PFNGLMATRIXMODEPROC glad_glMatrixMode;
3382#define glMatrixMode glad_glMatrixMode
3383GLAD_API_CALL PFNGLMULTMATRIXDPROC glad_glMultMatrixd;
3384#define glMultMatrixd glad_glMultMatrixd
3385GLAD_API_CALL PFNGLMULTMATRIXFPROC glad_glMultMatrixf;
3386#define glMultMatrixf glad_glMultMatrixf
3387GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd;
3388#define glMultTransposeMatrixd glad_glMultTransposeMatrixd
3389GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf;
3390#define glMultTransposeMatrixf glad_glMultTransposeMatrixf
3391GLAD_API_CALL PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
3392#define glMultiDrawArrays glad_glMultiDrawArrays
3393GLAD_API_CALL PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
3394#define glMultiDrawElements glad_glMultiDrawElements
3395GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
3396#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
3397GLAD_API_CALL PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d;
3398#define glMultiTexCoord1d glad_glMultiTexCoord1d
3399GLAD_API_CALL PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv;
3400#define glMultiTexCoord1dv glad_glMultiTexCoord1dv
3401GLAD_API_CALL PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f;
3402#define glMultiTexCoord1f glad_glMultiTexCoord1f
3403GLAD_API_CALL PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv;
3404#define glMultiTexCoord1fv glad_glMultiTexCoord1fv
3405GLAD_API_CALL PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i;
3406#define glMultiTexCoord1i glad_glMultiTexCoord1i
3407GLAD_API_CALL PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv;
3408#define glMultiTexCoord1iv glad_glMultiTexCoord1iv
3409GLAD_API_CALL PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s;
3410#define glMultiTexCoord1s glad_glMultiTexCoord1s
3411GLAD_API_CALL PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv;
3412#define glMultiTexCoord1sv glad_glMultiTexCoord1sv
3413GLAD_API_CALL PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d;
3414#define glMultiTexCoord2d glad_glMultiTexCoord2d
3415GLAD_API_CALL PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv;
3416#define glMultiTexCoord2dv glad_glMultiTexCoord2dv
3417GLAD_API_CALL PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f;
3418#define glMultiTexCoord2f glad_glMultiTexCoord2f
3419GLAD_API_CALL PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv;
3420#define glMultiTexCoord2fv glad_glMultiTexCoord2fv
3421GLAD_API_CALL PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i;
3422#define glMultiTexCoord2i glad_glMultiTexCoord2i
3423GLAD_API_CALL PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv;
3424#define glMultiTexCoord2iv glad_glMultiTexCoord2iv
3425GLAD_API_CALL PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s;
3426#define glMultiTexCoord2s glad_glMultiTexCoord2s
3427GLAD_API_CALL PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv;
3428#define glMultiTexCoord2sv glad_glMultiTexCoord2sv
3429GLAD_API_CALL PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d;
3430#define glMultiTexCoord3d glad_glMultiTexCoord3d
3431GLAD_API_CALL PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv;
3432#define glMultiTexCoord3dv glad_glMultiTexCoord3dv
3433GLAD_API_CALL PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f;
3434#define glMultiTexCoord3f glad_glMultiTexCoord3f
3435GLAD_API_CALL PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv;
3436#define glMultiTexCoord3fv glad_glMultiTexCoord3fv
3437GLAD_API_CALL PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i;
3438#define glMultiTexCoord3i glad_glMultiTexCoord3i
3439GLAD_API_CALL PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv;
3440#define glMultiTexCoord3iv glad_glMultiTexCoord3iv
3441GLAD_API_CALL PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s;
3442#define glMultiTexCoord3s glad_glMultiTexCoord3s
3443GLAD_API_CALL PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv;
3444#define glMultiTexCoord3sv glad_glMultiTexCoord3sv
3445GLAD_API_CALL PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d;
3446#define glMultiTexCoord4d glad_glMultiTexCoord4d
3447GLAD_API_CALL PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv;
3448#define glMultiTexCoord4dv glad_glMultiTexCoord4dv
3449GLAD_API_CALL PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f;
3450#define glMultiTexCoord4f glad_glMultiTexCoord4f
3451GLAD_API_CALL PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv;
3452#define glMultiTexCoord4fv glad_glMultiTexCoord4fv
3453GLAD_API_CALL PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i;
3454#define glMultiTexCoord4i glad_glMultiTexCoord4i
3455GLAD_API_CALL PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv;
3456#define glMultiTexCoord4iv glad_glMultiTexCoord4iv
3457GLAD_API_CALL PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s;
3458#define glMultiTexCoord4s glad_glMultiTexCoord4s
3459GLAD_API_CALL PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv;
3460#define glMultiTexCoord4sv glad_glMultiTexCoord4sv
3461GLAD_API_CALL PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
3462#define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui
3463GLAD_API_CALL PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
3464#define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv
3465GLAD_API_CALL PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
3466#define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui
3467GLAD_API_CALL PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
3468#define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv
3469GLAD_API_CALL PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
3470#define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui
3471GLAD_API_CALL PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
3472#define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv
3473GLAD_API_CALL PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
3474#define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui
3475GLAD_API_CALL PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
3476#define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv
3477GLAD_API_CALL PFNGLNEWLISTPROC glad_glNewList;
3478#define glNewList glad_glNewList
3479GLAD_API_CALL PFNGLNORMAL3BPROC glad_glNormal3b;
3480#define glNormal3b glad_glNormal3b
3481GLAD_API_CALL PFNGLNORMAL3BVPROC glad_glNormal3bv;
3482#define glNormal3bv glad_glNormal3bv
3483GLAD_API_CALL PFNGLNORMAL3DPROC glad_glNormal3d;
3484#define glNormal3d glad_glNormal3d
3485GLAD_API_CALL PFNGLNORMAL3DVPROC glad_glNormal3dv;
3486#define glNormal3dv glad_glNormal3dv
3487GLAD_API_CALL PFNGLNORMAL3FPROC glad_glNormal3f;
3488#define glNormal3f glad_glNormal3f
3489GLAD_API_CALL PFNGLNORMAL3FVPROC glad_glNormal3fv;
3490#define glNormal3fv glad_glNormal3fv
3491GLAD_API_CALL PFNGLNORMAL3IPROC glad_glNormal3i;
3492#define glNormal3i glad_glNormal3i
3493GLAD_API_CALL PFNGLNORMAL3IVPROC glad_glNormal3iv;
3494#define glNormal3iv glad_glNormal3iv
3495GLAD_API_CALL PFNGLNORMAL3SPROC glad_glNormal3s;
3496#define glNormal3s glad_glNormal3s
3497GLAD_API_CALL PFNGLNORMAL3SVPROC glad_glNormal3sv;
3498#define glNormal3sv glad_glNormal3sv
3499GLAD_API_CALL PFNGLNORMALP3UIPROC glad_glNormalP3ui;
3500#define glNormalP3ui glad_glNormalP3ui
3501GLAD_API_CALL PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
3502#define glNormalP3uiv glad_glNormalP3uiv
3503GLAD_API_CALL PFNGLNORMALPOINTERPROC glad_glNormalPointer;
3504#define glNormalPointer glad_glNormalPointer
3505GLAD_API_CALL PFNGLOBJECTLABELPROC glad_glObjectLabel;
3506#define glObjectLabel glad_glObjectLabel
3507GLAD_API_CALL PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel;
3508#define glObjectPtrLabel glad_glObjectPtrLabel
3509GLAD_API_CALL PFNGLORTHOPROC glad_glOrtho;
3510#define glOrtho glad_glOrtho
3511GLAD_API_CALL PFNGLPASSTHROUGHPROC glad_glPassThrough;
3512#define glPassThrough glad_glPassThrough
3513GLAD_API_CALL PFNGLPIXELMAPFVPROC glad_glPixelMapfv;
3514#define glPixelMapfv glad_glPixelMapfv
3515GLAD_API_CALL PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv;
3516#define glPixelMapuiv glad_glPixelMapuiv
3517GLAD_API_CALL PFNGLPIXELMAPUSVPROC glad_glPixelMapusv;
3518#define glPixelMapusv glad_glPixelMapusv
3519GLAD_API_CALL PFNGLPIXELSTOREFPROC glad_glPixelStoref;
3520#define glPixelStoref glad_glPixelStoref
3521GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
3522#define glPixelStorei glad_glPixelStorei
3523GLAD_API_CALL PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf;
3524#define glPixelTransferf glad_glPixelTransferf
3525GLAD_API_CALL PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi;
3526#define glPixelTransferi glad_glPixelTransferi
3527GLAD_API_CALL PFNGLPIXELZOOMPROC glad_glPixelZoom;
3528#define glPixelZoom glad_glPixelZoom
3529GLAD_API_CALL PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
3530#define glPointParameterf glad_glPointParameterf
3531GLAD_API_CALL PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
3532#define glPointParameterfv glad_glPointParameterfv
3533GLAD_API_CALL PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
3534#define glPointParameteri glad_glPointParameteri
3535GLAD_API_CALL PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
3536#define glPointParameteriv glad_glPointParameteriv
3537GLAD_API_CALL PFNGLPOINTSIZEPROC glad_glPointSize;
3538#define glPointSize glad_glPointSize
3539GLAD_API_CALL PFNGLPOLYGONMODEPROC glad_glPolygonMode;
3540#define glPolygonMode glad_glPolygonMode
3541GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
3542#define glPolygonOffset glad_glPolygonOffset
3543GLAD_API_CALL PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple;
3544#define glPolygonStipple glad_glPolygonStipple
3545GLAD_API_CALL PFNGLPOPATTRIBPROC glad_glPopAttrib;
3546#define glPopAttrib glad_glPopAttrib
3547GLAD_API_CALL PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib;
3548#define glPopClientAttrib glad_glPopClientAttrib
3549GLAD_API_CALL PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup;
3550#define glPopDebugGroup glad_glPopDebugGroup
3551GLAD_API_CALL PFNGLPOPMATRIXPROC glad_glPopMatrix;
3552#define glPopMatrix glad_glPopMatrix
3553GLAD_API_CALL PFNGLPOPNAMEPROC glad_glPopName;
3554#define glPopName glad_glPopName
3555GLAD_API_CALL PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
3556#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
3557GLAD_API_CALL PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures;
3558#define glPrioritizeTextures glad_glPrioritizeTextures
3559GLAD_API_CALL PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
3560#define glProvokingVertex glad_glProvokingVertex
3561GLAD_API_CALL PFNGLPUSHATTRIBPROC glad_glPushAttrib;
3562#define glPushAttrib glad_glPushAttrib
3563GLAD_API_CALL PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib;
3564#define glPushClientAttrib glad_glPushClientAttrib
3565GLAD_API_CALL PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup;
3566#define glPushDebugGroup glad_glPushDebugGroup
3567GLAD_API_CALL PFNGLPUSHMATRIXPROC glad_glPushMatrix;
3568#define glPushMatrix glad_glPushMatrix
3569GLAD_API_CALL PFNGLPUSHNAMEPROC glad_glPushName;
3570#define glPushName glad_glPushName
3571GLAD_API_CALL PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
3572#define glQueryCounter glad_glQueryCounter
3573GLAD_API_CALL PFNGLRASTERPOS2DPROC glad_glRasterPos2d;
3574#define glRasterPos2d glad_glRasterPos2d
3575GLAD_API_CALL PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv;
3576#define glRasterPos2dv glad_glRasterPos2dv
3577GLAD_API_CALL PFNGLRASTERPOS2FPROC glad_glRasterPos2f;
3578#define glRasterPos2f glad_glRasterPos2f
3579GLAD_API_CALL PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv;
3580#define glRasterPos2fv glad_glRasterPos2fv
3581GLAD_API_CALL PFNGLRASTERPOS2IPROC glad_glRasterPos2i;
3582#define glRasterPos2i glad_glRasterPos2i
3583GLAD_API_CALL PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv;
3584#define glRasterPos2iv glad_glRasterPos2iv
3585GLAD_API_CALL PFNGLRASTERPOS2SPROC glad_glRasterPos2s;
3586#define glRasterPos2s glad_glRasterPos2s
3587GLAD_API_CALL PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv;
3588#define glRasterPos2sv glad_glRasterPos2sv
3589GLAD_API_CALL PFNGLRASTERPOS3DPROC glad_glRasterPos3d;
3590#define glRasterPos3d glad_glRasterPos3d
3591GLAD_API_CALL PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv;
3592#define glRasterPos3dv glad_glRasterPos3dv
3593GLAD_API_CALL PFNGLRASTERPOS3FPROC glad_glRasterPos3f;
3594#define glRasterPos3f glad_glRasterPos3f
3595GLAD_API_CALL PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv;
3596#define glRasterPos3fv glad_glRasterPos3fv
3597GLAD_API_CALL PFNGLRASTERPOS3IPROC glad_glRasterPos3i;
3598#define glRasterPos3i glad_glRasterPos3i
3599GLAD_API_CALL PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv;
3600#define glRasterPos3iv glad_glRasterPos3iv
3601GLAD_API_CALL PFNGLRASTERPOS3SPROC glad_glRasterPos3s;
3602#define glRasterPos3s glad_glRasterPos3s
3603GLAD_API_CALL PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv;
3604#define glRasterPos3sv glad_glRasterPos3sv
3605GLAD_API_CALL PFNGLRASTERPOS4DPROC glad_glRasterPos4d;
3606#define glRasterPos4d glad_glRasterPos4d
3607GLAD_API_CALL PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv;
3608#define glRasterPos4dv glad_glRasterPos4dv
3609GLAD_API_CALL PFNGLRASTERPOS4FPROC glad_glRasterPos4f;
3610#define glRasterPos4f glad_glRasterPos4f
3611GLAD_API_CALL PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv;
3612#define glRasterPos4fv glad_glRasterPos4fv
3613GLAD_API_CALL PFNGLRASTERPOS4IPROC glad_glRasterPos4i;
3614#define glRasterPos4i glad_glRasterPos4i
3615GLAD_API_CALL PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv;
3616#define glRasterPos4iv glad_glRasterPos4iv
3617GLAD_API_CALL PFNGLRASTERPOS4SPROC glad_glRasterPos4s;
3618#define glRasterPos4s glad_glRasterPos4s
3619GLAD_API_CALL PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv;
3620#define glRasterPos4sv glad_glRasterPos4sv
3621GLAD_API_CALL PFNGLREADBUFFERPROC glad_glReadBuffer;
3622#define glReadBuffer glad_glReadBuffer
3623GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
3624#define glReadPixels glad_glReadPixels
3625GLAD_API_CALL PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB;
3626#define glReadnPixelsARB glad_glReadnPixelsARB
3627GLAD_API_CALL PFNGLRECTDPROC glad_glRectd;
3628#define glRectd glad_glRectd
3629GLAD_API_CALL PFNGLRECTDVPROC glad_glRectdv;
3630#define glRectdv glad_glRectdv
3631GLAD_API_CALL PFNGLRECTFPROC glad_glRectf;
3632#define glRectf glad_glRectf
3633GLAD_API_CALL PFNGLRECTFVPROC glad_glRectfv;
3634#define glRectfv glad_glRectfv
3635GLAD_API_CALL PFNGLRECTIPROC glad_glRecti;
3636#define glRecti glad_glRecti
3637GLAD_API_CALL PFNGLRECTIVPROC glad_glRectiv;
3638#define glRectiv glad_glRectiv
3639GLAD_API_CALL PFNGLRECTSPROC glad_glRects;
3640#define glRects glad_glRects
3641GLAD_API_CALL PFNGLRECTSVPROC glad_glRectsv;
3642#define glRectsv glad_glRectsv
3643GLAD_API_CALL PFNGLRENDERMODEPROC glad_glRenderMode;
3644#define glRenderMode glad_glRenderMode
3645GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
3646#define glRenderbufferStorage glad_glRenderbufferStorage
3647GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
3648#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
3649GLAD_API_CALL PFNGLROTATEDPROC glad_glRotated;
3650#define glRotated glad_glRotated
3651GLAD_API_CALL PFNGLROTATEFPROC glad_glRotatef;
3652#define glRotatef glad_glRotatef
3653GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
3654#define glSampleCoverage glad_glSampleCoverage
3655GLAD_API_CALL PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
3656#define glSampleCoverageARB glad_glSampleCoverageARB
3657GLAD_API_CALL PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
3658#define glSampleMaski glad_glSampleMaski
3659GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
3660#define glSamplerParameterIiv glad_glSamplerParameterIiv
3661GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
3662#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
3663GLAD_API_CALL PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
3664#define glSamplerParameterf glad_glSamplerParameterf
3665GLAD_API_CALL PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
3666#define glSamplerParameterfv glad_glSamplerParameterfv
3667GLAD_API_CALL PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
3668#define glSamplerParameteri glad_glSamplerParameteri
3669GLAD_API_CALL PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
3670#define glSamplerParameteriv glad_glSamplerParameteriv
3671GLAD_API_CALL PFNGLSCALEDPROC glad_glScaled;
3672#define glScaled glad_glScaled
3673GLAD_API_CALL PFNGLSCALEFPROC glad_glScalef;
3674#define glScalef glad_glScalef
3675GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
3676#define glScissor glad_glScissor
3677GLAD_API_CALL PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b;
3678#define glSecondaryColor3b glad_glSecondaryColor3b
3679GLAD_API_CALL PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv;
3680#define glSecondaryColor3bv glad_glSecondaryColor3bv
3681GLAD_API_CALL PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d;
3682#define glSecondaryColor3d glad_glSecondaryColor3d
3683GLAD_API_CALL PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv;
3684#define glSecondaryColor3dv glad_glSecondaryColor3dv
3685GLAD_API_CALL PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f;
3686#define glSecondaryColor3f glad_glSecondaryColor3f
3687GLAD_API_CALL PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv;
3688#define glSecondaryColor3fv glad_glSecondaryColor3fv
3689GLAD_API_CALL PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i;
3690#define glSecondaryColor3i glad_glSecondaryColor3i
3691GLAD_API_CALL PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv;
3692#define glSecondaryColor3iv glad_glSecondaryColor3iv
3693GLAD_API_CALL PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s;
3694#define glSecondaryColor3s glad_glSecondaryColor3s
3695GLAD_API_CALL PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv;
3696#define glSecondaryColor3sv glad_glSecondaryColor3sv
3697GLAD_API_CALL PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub;
3698#define glSecondaryColor3ub glad_glSecondaryColor3ub
3699GLAD_API_CALL PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv;
3700#define glSecondaryColor3ubv glad_glSecondaryColor3ubv
3701GLAD_API_CALL PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui;
3702#define glSecondaryColor3ui glad_glSecondaryColor3ui
3703GLAD_API_CALL PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv;
3704#define glSecondaryColor3uiv glad_glSecondaryColor3uiv
3705GLAD_API_CALL PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us;
3706#define glSecondaryColor3us glad_glSecondaryColor3us
3707GLAD_API_CALL PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv;
3708#define glSecondaryColor3usv glad_glSecondaryColor3usv
3709GLAD_API_CALL PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
3710#define glSecondaryColorP3ui glad_glSecondaryColorP3ui
3711GLAD_API_CALL PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
3712#define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv
3713GLAD_API_CALL PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer;
3714#define glSecondaryColorPointer glad_glSecondaryColorPointer
3715GLAD_API_CALL PFNGLSELECTBUFFERPROC glad_glSelectBuffer;
3716#define glSelectBuffer glad_glSelectBuffer
3717GLAD_API_CALL PFNGLSHADEMODELPROC glad_glShadeModel;
3718#define glShadeModel glad_glShadeModel
3719GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
3720#define glShaderSource glad_glShaderSource
3721GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
3722#define glStencilFunc glad_glStencilFunc
3723GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
3724#define glStencilFuncSeparate glad_glStencilFuncSeparate
3725GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
3726#define glStencilMask glad_glStencilMask
3727GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
3728#define glStencilMaskSeparate glad_glStencilMaskSeparate
3729GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
3730#define glStencilOp glad_glStencilOp
3731GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
3732#define glStencilOpSeparate glad_glStencilOpSeparate
3733GLAD_API_CALL PFNGLTEXBUFFERPROC glad_glTexBuffer;
3734#define glTexBuffer glad_glTexBuffer
3735GLAD_API_CALL PFNGLTEXCOORD1DPROC glad_glTexCoord1d;
3736#define glTexCoord1d glad_glTexCoord1d
3737GLAD_API_CALL PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv;
3738#define glTexCoord1dv glad_glTexCoord1dv
3739GLAD_API_CALL PFNGLTEXCOORD1FPROC glad_glTexCoord1f;
3740#define glTexCoord1f glad_glTexCoord1f
3741GLAD_API_CALL PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv;
3742#define glTexCoord1fv glad_glTexCoord1fv
3743GLAD_API_CALL PFNGLTEXCOORD1IPROC glad_glTexCoord1i;
3744#define glTexCoord1i glad_glTexCoord1i
3745GLAD_API_CALL PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv;
3746#define glTexCoord1iv glad_glTexCoord1iv
3747GLAD_API_CALL PFNGLTEXCOORD1SPROC glad_glTexCoord1s;
3748#define glTexCoord1s glad_glTexCoord1s
3749GLAD_API_CALL PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv;
3750#define glTexCoord1sv glad_glTexCoord1sv
3751GLAD_API_CALL PFNGLTEXCOORD2DPROC glad_glTexCoord2d;
3752#define glTexCoord2d glad_glTexCoord2d
3753GLAD_API_CALL PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv;
3754#define glTexCoord2dv glad_glTexCoord2dv
3755GLAD_API_CALL PFNGLTEXCOORD2FPROC glad_glTexCoord2f;
3756#define glTexCoord2f glad_glTexCoord2f
3757GLAD_API_CALL PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv;
3758#define glTexCoord2fv glad_glTexCoord2fv
3759GLAD_API_CALL PFNGLTEXCOORD2IPROC glad_glTexCoord2i;
3760#define glTexCoord2i glad_glTexCoord2i
3761GLAD_API_CALL PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv;
3762#define glTexCoord2iv glad_glTexCoord2iv
3763GLAD_API_CALL PFNGLTEXCOORD2SPROC glad_glTexCoord2s;
3764#define glTexCoord2s glad_glTexCoord2s
3765GLAD_API_CALL PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv;
3766#define glTexCoord2sv glad_glTexCoord2sv
3767GLAD_API_CALL PFNGLTEXCOORD3DPROC glad_glTexCoord3d;
3768#define glTexCoord3d glad_glTexCoord3d
3769GLAD_API_CALL PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv;
3770#define glTexCoord3dv glad_glTexCoord3dv
3771GLAD_API_CALL PFNGLTEXCOORD3FPROC glad_glTexCoord3f;
3772#define glTexCoord3f glad_glTexCoord3f
3773GLAD_API_CALL PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv;
3774#define glTexCoord3fv glad_glTexCoord3fv
3775GLAD_API_CALL PFNGLTEXCOORD3IPROC glad_glTexCoord3i;
3776#define glTexCoord3i glad_glTexCoord3i
3777GLAD_API_CALL PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv;
3778#define glTexCoord3iv glad_glTexCoord3iv
3779GLAD_API_CALL PFNGLTEXCOORD3SPROC glad_glTexCoord3s;
3780#define glTexCoord3s glad_glTexCoord3s
3781GLAD_API_CALL PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv;
3782#define glTexCoord3sv glad_glTexCoord3sv
3783GLAD_API_CALL PFNGLTEXCOORD4DPROC glad_glTexCoord4d;
3784#define glTexCoord4d glad_glTexCoord4d
3785GLAD_API_CALL PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv;
3786#define glTexCoord4dv glad_glTexCoord4dv
3787GLAD_API_CALL PFNGLTEXCOORD4FPROC glad_glTexCoord4f;
3788#define glTexCoord4f glad_glTexCoord4f
3789GLAD_API_CALL PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv;
3790#define glTexCoord4fv glad_glTexCoord4fv
3791GLAD_API_CALL PFNGLTEXCOORD4IPROC glad_glTexCoord4i;
3792#define glTexCoord4i glad_glTexCoord4i
3793GLAD_API_CALL PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv;
3794#define glTexCoord4iv glad_glTexCoord4iv
3795GLAD_API_CALL PFNGLTEXCOORD4SPROC glad_glTexCoord4s;
3796#define glTexCoord4s glad_glTexCoord4s
3797GLAD_API_CALL PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv;
3798#define glTexCoord4sv glad_glTexCoord4sv
3799GLAD_API_CALL PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
3800#define glTexCoordP1ui glad_glTexCoordP1ui
3801GLAD_API_CALL PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
3802#define glTexCoordP1uiv glad_glTexCoordP1uiv
3803GLAD_API_CALL PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
3804#define glTexCoordP2ui glad_glTexCoordP2ui
3805GLAD_API_CALL PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
3806#define glTexCoordP2uiv glad_glTexCoordP2uiv
3807GLAD_API_CALL PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
3808#define glTexCoordP3ui glad_glTexCoordP3ui
3809GLAD_API_CALL PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
3810#define glTexCoordP3uiv glad_glTexCoordP3uiv
3811GLAD_API_CALL PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
3812#define glTexCoordP4ui glad_glTexCoordP4ui
3813GLAD_API_CALL PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
3814#define glTexCoordP4uiv glad_glTexCoordP4uiv
3815GLAD_API_CALL PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer;
3816#define glTexCoordPointer glad_glTexCoordPointer
3817GLAD_API_CALL PFNGLTEXENVFPROC glad_glTexEnvf;
3818#define glTexEnvf glad_glTexEnvf
3819GLAD_API_CALL PFNGLTEXENVFVPROC glad_glTexEnvfv;
3820#define glTexEnvfv glad_glTexEnvfv
3821GLAD_API_CALL PFNGLTEXENVIPROC glad_glTexEnvi;
3822#define glTexEnvi glad_glTexEnvi
3823GLAD_API_CALL PFNGLTEXENVIVPROC glad_glTexEnviv;
3824#define glTexEnviv glad_glTexEnviv
3825GLAD_API_CALL PFNGLTEXGENDPROC glad_glTexGend;
3826#define glTexGend glad_glTexGend
3827GLAD_API_CALL PFNGLTEXGENDVPROC glad_glTexGendv;
3828#define glTexGendv glad_glTexGendv
3829GLAD_API_CALL PFNGLTEXGENFPROC glad_glTexGenf;
3830#define glTexGenf glad_glTexGenf
3831GLAD_API_CALL PFNGLTEXGENFVPROC glad_glTexGenfv;
3832#define glTexGenfv glad_glTexGenfv
3833GLAD_API_CALL PFNGLTEXGENIPROC glad_glTexGeni;
3834#define glTexGeni glad_glTexGeni
3835GLAD_API_CALL PFNGLTEXGENIVPROC glad_glTexGeniv;
3836#define glTexGeniv glad_glTexGeniv
3837GLAD_API_CALL PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
3838#define glTexImage1D glad_glTexImage1D
3839GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
3840#define glTexImage2D glad_glTexImage2D
3841GLAD_API_CALL PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
3842#define glTexImage2DMultisample glad_glTexImage2DMultisample
3843GLAD_API_CALL PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
3844#define glTexImage3D glad_glTexImage3D
3845GLAD_API_CALL PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
3846#define glTexImage3DMultisample glad_glTexImage3DMultisample
3847GLAD_API_CALL PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
3848#define glTexParameterIiv glad_glTexParameterIiv
3849GLAD_API_CALL PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
3850#define glTexParameterIuiv glad_glTexParameterIuiv
3851GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
3852#define glTexParameterf glad_glTexParameterf
3853GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
3854#define glTexParameterfv glad_glTexParameterfv
3855GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
3856#define glTexParameteri glad_glTexParameteri
3857GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
3858#define glTexParameteriv glad_glTexParameteriv
3859GLAD_API_CALL PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
3860#define glTexSubImage1D glad_glTexSubImage1D
3861GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
3862#define glTexSubImage2D glad_glTexSubImage2D
3863GLAD_API_CALL PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
3864#define glTexSubImage3D glad_glTexSubImage3D
3865GLAD_API_CALL PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
3866#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
3867GLAD_API_CALL PFNGLTRANSLATEDPROC glad_glTranslated;
3868#define glTranslated glad_glTranslated
3869GLAD_API_CALL PFNGLTRANSLATEFPROC glad_glTranslatef;
3870#define glTranslatef glad_glTranslatef
3871GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
3872#define glUniform1f glad_glUniform1f
3873GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
3874#define glUniform1fv glad_glUniform1fv
3875GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
3876#define glUniform1i glad_glUniform1i
3877GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
3878#define glUniform1iv glad_glUniform1iv
3879GLAD_API_CALL PFNGLUNIFORM1UIPROC glad_glUniform1ui;
3880#define glUniform1ui glad_glUniform1ui
3881GLAD_API_CALL PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
3882#define glUniform1uiv glad_glUniform1uiv
3883GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
3884#define glUniform2f glad_glUniform2f
3885GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
3886#define glUniform2fv glad_glUniform2fv
3887GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
3888#define glUniform2i glad_glUniform2i
3889GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
3890#define glUniform2iv glad_glUniform2iv
3891GLAD_API_CALL PFNGLUNIFORM2UIPROC glad_glUniform2ui;
3892#define glUniform2ui glad_glUniform2ui
3893GLAD_API_CALL PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
3894#define glUniform2uiv glad_glUniform2uiv
3895GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
3896#define glUniform3f glad_glUniform3f
3897GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
3898#define glUniform3fv glad_glUniform3fv
3899GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
3900#define glUniform3i glad_glUniform3i
3901GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
3902#define glUniform3iv glad_glUniform3iv
3903GLAD_API_CALL PFNGLUNIFORM3UIPROC glad_glUniform3ui;
3904#define glUniform3ui glad_glUniform3ui
3905GLAD_API_CALL PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
3906#define glUniform3uiv glad_glUniform3uiv
3907GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
3908#define glUniform4f glad_glUniform4f
3909GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
3910#define glUniform4fv glad_glUniform4fv
3911GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
3912#define glUniform4i glad_glUniform4i
3913GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
3914#define glUniform4iv glad_glUniform4iv
3915GLAD_API_CALL PFNGLUNIFORM4UIPROC glad_glUniform4ui;
3916#define glUniform4ui glad_glUniform4ui
3917GLAD_API_CALL PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
3918#define glUniform4uiv glad_glUniform4uiv
3919GLAD_API_CALL PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
3920#define glUniformBlockBinding glad_glUniformBlockBinding
3921GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
3922#define glUniformMatrix2fv glad_glUniformMatrix2fv
3923GLAD_API_CALL PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
3924#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
3925GLAD_API_CALL PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
3926#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
3927GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
3928#define glUniformMatrix3fv glad_glUniformMatrix3fv
3929GLAD_API_CALL PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
3930#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
3931GLAD_API_CALL PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
3932#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
3933GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
3934#define glUniformMatrix4fv glad_glUniformMatrix4fv
3935GLAD_API_CALL PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
3936#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
3937GLAD_API_CALL PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
3938#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
3939GLAD_API_CALL PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
3940#define glUnmapBuffer glad_glUnmapBuffer
3941GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
3942#define glUseProgram glad_glUseProgram
3943GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
3944#define glValidateProgram glad_glValidateProgram
3945GLAD_API_CALL PFNGLVERTEX2DPROC glad_glVertex2d;
3946#define glVertex2d glad_glVertex2d
3947GLAD_API_CALL PFNGLVERTEX2DVPROC glad_glVertex2dv;
3948#define glVertex2dv glad_glVertex2dv
3949GLAD_API_CALL PFNGLVERTEX2FPROC glad_glVertex2f;
3950#define glVertex2f glad_glVertex2f
3951GLAD_API_CALL PFNGLVERTEX2FVPROC glad_glVertex2fv;
3952#define glVertex2fv glad_glVertex2fv
3953GLAD_API_CALL PFNGLVERTEX2IPROC glad_glVertex2i;
3954#define glVertex2i glad_glVertex2i
3955GLAD_API_CALL PFNGLVERTEX2IVPROC glad_glVertex2iv;
3956#define glVertex2iv glad_glVertex2iv
3957GLAD_API_CALL PFNGLVERTEX2SPROC glad_glVertex2s;
3958#define glVertex2s glad_glVertex2s
3959GLAD_API_CALL PFNGLVERTEX2SVPROC glad_glVertex2sv;
3960#define glVertex2sv glad_glVertex2sv
3961GLAD_API_CALL PFNGLVERTEX3DPROC glad_glVertex3d;
3962#define glVertex3d glad_glVertex3d
3963GLAD_API_CALL PFNGLVERTEX3DVPROC glad_glVertex3dv;
3964#define glVertex3dv glad_glVertex3dv
3965GLAD_API_CALL PFNGLVERTEX3FPROC glad_glVertex3f;
3966#define glVertex3f glad_glVertex3f
3967GLAD_API_CALL PFNGLVERTEX3FVPROC glad_glVertex3fv;
3968#define glVertex3fv glad_glVertex3fv
3969GLAD_API_CALL PFNGLVERTEX3IPROC glad_glVertex3i;
3970#define glVertex3i glad_glVertex3i
3971GLAD_API_CALL PFNGLVERTEX3IVPROC glad_glVertex3iv;
3972#define glVertex3iv glad_glVertex3iv
3973GLAD_API_CALL PFNGLVERTEX3SPROC glad_glVertex3s;
3974#define glVertex3s glad_glVertex3s
3975GLAD_API_CALL PFNGLVERTEX3SVPROC glad_glVertex3sv;
3976#define glVertex3sv glad_glVertex3sv
3977GLAD_API_CALL PFNGLVERTEX4DPROC glad_glVertex4d;
3978#define glVertex4d glad_glVertex4d
3979GLAD_API_CALL PFNGLVERTEX4DVPROC glad_glVertex4dv;
3980#define glVertex4dv glad_glVertex4dv
3981GLAD_API_CALL PFNGLVERTEX4FPROC glad_glVertex4f;
3982#define glVertex4f glad_glVertex4f
3983GLAD_API_CALL PFNGLVERTEX4FVPROC glad_glVertex4fv;
3984#define glVertex4fv glad_glVertex4fv
3985GLAD_API_CALL PFNGLVERTEX4IPROC glad_glVertex4i;
3986#define glVertex4i glad_glVertex4i
3987GLAD_API_CALL PFNGLVERTEX4IVPROC glad_glVertex4iv;
3988#define glVertex4iv glad_glVertex4iv
3989GLAD_API_CALL PFNGLVERTEX4SPROC glad_glVertex4s;
3990#define glVertex4s glad_glVertex4s
3991GLAD_API_CALL PFNGLVERTEX4SVPROC glad_glVertex4sv;
3992#define glVertex4sv glad_glVertex4sv
3993GLAD_API_CALL PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
3994#define glVertexAttrib1d glad_glVertexAttrib1d
3995GLAD_API_CALL PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
3996#define glVertexAttrib1dv glad_glVertexAttrib1dv
3997GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
3998#define glVertexAttrib1f glad_glVertexAttrib1f
3999GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
4000#define glVertexAttrib1fv glad_glVertexAttrib1fv
4001GLAD_API_CALL PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
4002#define glVertexAttrib1s glad_glVertexAttrib1s
4003GLAD_API_CALL PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
4004#define glVertexAttrib1sv glad_glVertexAttrib1sv
4005GLAD_API_CALL PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
4006#define glVertexAttrib2d glad_glVertexAttrib2d
4007GLAD_API_CALL PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
4008#define glVertexAttrib2dv glad_glVertexAttrib2dv
4009GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
4010#define glVertexAttrib2f glad_glVertexAttrib2f
4011GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
4012#define glVertexAttrib2fv glad_glVertexAttrib2fv
4013GLAD_API_CALL PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
4014#define glVertexAttrib2s glad_glVertexAttrib2s
4015GLAD_API_CALL PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
4016#define glVertexAttrib2sv glad_glVertexAttrib2sv
4017GLAD_API_CALL PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
4018#define glVertexAttrib3d glad_glVertexAttrib3d
4019GLAD_API_CALL PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
4020#define glVertexAttrib3dv glad_glVertexAttrib3dv
4021GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
4022#define glVertexAttrib3f glad_glVertexAttrib3f
4023GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
4024#define glVertexAttrib3fv glad_glVertexAttrib3fv
4025GLAD_API_CALL PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
4026#define glVertexAttrib3s glad_glVertexAttrib3s
4027GLAD_API_CALL PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
4028#define glVertexAttrib3sv glad_glVertexAttrib3sv
4029GLAD_API_CALL PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
4030#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
4031GLAD_API_CALL PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
4032#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
4033GLAD_API_CALL PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
4034#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
4035GLAD_API_CALL PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
4036#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
4037GLAD_API_CALL PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
4038#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
4039GLAD_API_CALL PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
4040#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
4041GLAD_API_CALL PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
4042#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
4043GLAD_API_CALL PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
4044#define glVertexAttrib4bv glad_glVertexAttrib4bv
4045GLAD_API_CALL PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
4046#define glVertexAttrib4d glad_glVertexAttrib4d
4047GLAD_API_CALL PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
4048#define glVertexAttrib4dv glad_glVertexAttrib4dv
4049GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
4050#define glVertexAttrib4f glad_glVertexAttrib4f
4051GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
4052#define glVertexAttrib4fv glad_glVertexAttrib4fv
4053GLAD_API_CALL PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
4054#define glVertexAttrib4iv glad_glVertexAttrib4iv
4055GLAD_API_CALL PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
4056#define glVertexAttrib4s glad_glVertexAttrib4s
4057GLAD_API_CALL PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
4058#define glVertexAttrib4sv glad_glVertexAttrib4sv
4059GLAD_API_CALL PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
4060#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
4061GLAD_API_CALL PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
4062#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
4063GLAD_API_CALL PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
4064#define glVertexAttrib4usv glad_glVertexAttrib4usv
4065GLAD_API_CALL PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
4066#define glVertexAttribDivisor glad_glVertexAttribDivisor
4067GLAD_API_CALL PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
4068#define glVertexAttribI1i glad_glVertexAttribI1i
4069GLAD_API_CALL PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
4070#define glVertexAttribI1iv glad_glVertexAttribI1iv
4071GLAD_API_CALL PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
4072#define glVertexAttribI1ui glad_glVertexAttribI1ui
4073GLAD_API_CALL PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
4074#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
4075GLAD_API_CALL PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
4076#define glVertexAttribI2i glad_glVertexAttribI2i
4077GLAD_API_CALL PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
4078#define glVertexAttribI2iv glad_glVertexAttribI2iv
4079GLAD_API_CALL PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
4080#define glVertexAttribI2ui glad_glVertexAttribI2ui
4081GLAD_API_CALL PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
4082#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
4083GLAD_API_CALL PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
4084#define glVertexAttribI3i glad_glVertexAttribI3i
4085GLAD_API_CALL PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
4086#define glVertexAttribI3iv glad_glVertexAttribI3iv
4087GLAD_API_CALL PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
4088#define glVertexAttribI3ui glad_glVertexAttribI3ui
4089GLAD_API_CALL PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
4090#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
4091GLAD_API_CALL PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
4092#define glVertexAttribI4bv glad_glVertexAttribI4bv
4093GLAD_API_CALL PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
4094#define glVertexAttribI4i glad_glVertexAttribI4i
4095GLAD_API_CALL PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
4096#define glVertexAttribI4iv glad_glVertexAttribI4iv
4097GLAD_API_CALL PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
4098#define glVertexAttribI4sv glad_glVertexAttribI4sv
4099GLAD_API_CALL PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
4100#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
4101GLAD_API_CALL PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
4102#define glVertexAttribI4ui glad_glVertexAttribI4ui
4103GLAD_API_CALL PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
4104#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
4105GLAD_API_CALL PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
4106#define glVertexAttribI4usv glad_glVertexAttribI4usv
4107GLAD_API_CALL PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
4108#define glVertexAttribIPointer glad_glVertexAttribIPointer
4109GLAD_API_CALL PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
4110#define glVertexAttribP1ui glad_glVertexAttribP1ui
4111GLAD_API_CALL PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
4112#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
4113GLAD_API_CALL PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
4114#define glVertexAttribP2ui glad_glVertexAttribP2ui
4115GLAD_API_CALL PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
4116#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
4117GLAD_API_CALL PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
4118#define glVertexAttribP3ui glad_glVertexAttribP3ui
4119GLAD_API_CALL PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
4120#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
4121GLAD_API_CALL PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
4122#define glVertexAttribP4ui glad_glVertexAttribP4ui
4123GLAD_API_CALL PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
4124#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
4125GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
4126#define glVertexAttribPointer glad_glVertexAttribPointer
4127GLAD_API_CALL PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
4128#define glVertexP2ui glad_glVertexP2ui
4129GLAD_API_CALL PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
4130#define glVertexP2uiv glad_glVertexP2uiv
4131GLAD_API_CALL PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
4132#define glVertexP3ui glad_glVertexP3ui
4133GLAD_API_CALL PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
4134#define glVertexP3uiv glad_glVertexP3uiv
4135GLAD_API_CALL PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
4136#define glVertexP4ui glad_glVertexP4ui
4137GLAD_API_CALL PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
4138#define glVertexP4uiv glad_glVertexP4uiv
4139GLAD_API_CALL PFNGLVERTEXPOINTERPROC glad_glVertexPointer;
4140#define glVertexPointer glad_glVertexPointer
4141GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
4142#define glViewport glad_glViewport
4143GLAD_API_CALL PFNGLWAITSYNCPROC glad_glWaitSync;
4144#define glWaitSync glad_glWaitSync
4145GLAD_API_CALL PFNGLWINDOWPOS2DPROC glad_glWindowPos2d;
4146#define glWindowPos2d glad_glWindowPos2d
4147GLAD_API_CALL PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv;
4148#define glWindowPos2dv glad_glWindowPos2dv
4149GLAD_API_CALL PFNGLWINDOWPOS2FPROC glad_glWindowPos2f;
4150#define glWindowPos2f glad_glWindowPos2f
4151GLAD_API_CALL PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv;
4152#define glWindowPos2fv glad_glWindowPos2fv
4153GLAD_API_CALL PFNGLWINDOWPOS2IPROC glad_glWindowPos2i;
4154#define glWindowPos2i glad_glWindowPos2i
4155GLAD_API_CALL PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv;
4156#define glWindowPos2iv glad_glWindowPos2iv
4157GLAD_API_CALL PFNGLWINDOWPOS2SPROC glad_glWindowPos2s;
4158#define glWindowPos2s glad_glWindowPos2s
4159GLAD_API_CALL PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv;
4160#define glWindowPos2sv glad_glWindowPos2sv
4161GLAD_API_CALL PFNGLWINDOWPOS3DPROC glad_glWindowPos3d;
4162#define glWindowPos3d glad_glWindowPos3d
4163GLAD_API_CALL PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv;
4164#define glWindowPos3dv glad_glWindowPos3dv
4165GLAD_API_CALL PFNGLWINDOWPOS3FPROC glad_glWindowPos3f;
4166#define glWindowPos3f glad_glWindowPos3f
4167GLAD_API_CALL PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv;
4168#define glWindowPos3fv glad_glWindowPos3fv
4169GLAD_API_CALL PFNGLWINDOWPOS3IPROC glad_glWindowPos3i;
4170#define glWindowPos3i glad_glWindowPos3i
4171GLAD_API_CALL PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv;
4172#define glWindowPos3iv glad_glWindowPos3iv
4173GLAD_API_CALL PFNGLWINDOWPOS3SPROC glad_glWindowPos3s;
4174#define glWindowPos3s glad_glWindowPos3s
4175GLAD_API_CALL PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv;
4176#define glWindowPos3sv glad_glWindowPos3sv
4177
4178
4179
4180
4181
4182GLAD_API_CALL int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr);
4183GLAD_API_CALL int gladLoadGL( GLADloadfunc load);
4184
4185
4186
4187#ifdef __cplusplus
4188}
4189#endif
4190#endif
4191
4192/* Source */
4193#ifdef GLAD_GL_IMPLEMENTATION
4194#include <stdio.h>
4195#include <stdlib.h>
4196#include <string.h>
4197
4198#ifndef GLAD_IMPL_UTIL_C_
4199#define GLAD_IMPL_UTIL_C_
4200
4201#ifdef _MSC_VER
4202#define GLAD_IMPL_UTIL_SSCANF sscanf_s
4203#else
4204#define GLAD_IMPL_UTIL_SSCANF sscanf
4205#endif
4206
4207#endif /* GLAD_IMPL_UTIL_C_ */
4208
4209#ifdef __cplusplus
4210extern "C" {
4211#endif
4212
4213
4214
4215int GLAD_GL_VERSION_1_0 = 0;
4216int GLAD_GL_VERSION_1_1 = 0;
4217int GLAD_GL_VERSION_1_2 = 0;
4218int GLAD_GL_VERSION_1_3 = 0;
4219int GLAD_GL_VERSION_1_4 = 0;
4220int GLAD_GL_VERSION_1_5 = 0;
4221int GLAD_GL_VERSION_2_0 = 0;
4222int GLAD_GL_VERSION_2_1 = 0;
4223int GLAD_GL_VERSION_3_0 = 0;
4224int GLAD_GL_VERSION_3_1 = 0;
4225int GLAD_GL_VERSION_3_2 = 0;
4226int GLAD_GL_VERSION_3_3 = 0;
4227int GLAD_GL_ARB_multisample = 0;
4228int GLAD_GL_ARB_robustness = 0;
4229int GLAD_GL_KHR_debug = 0;
4230
4231
4232
4233PFNGLACCUMPROC glad_glAccum = NULL;
4234PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
4235PFNGLALPHAFUNCPROC glad_glAlphaFunc = NULL;
4236PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident = NULL;
4237PFNGLARRAYELEMENTPROC glad_glArrayElement = NULL;
4238PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
4239PFNGLBEGINPROC glad_glBegin = NULL;
4240PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL;
4241PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL;
4242PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL;
4243PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
4244PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
4245PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL;
4246PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL;
4247PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL;
4248PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL;
4249PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
4250PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
4251PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL;
4252PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
4253PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL;
4254PFNGLBITMAPPROC glad_glBitmap = NULL;
4255PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
4256PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
4257PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
4258PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
4259PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
4260PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL;
4261PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
4262PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
4263PFNGLCALLLISTPROC glad_glCallList = NULL;
4264PFNGLCALLLISTSPROC glad_glCallLists = NULL;
4265PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
4266PFNGLCLAMPCOLORPROC glad_glClampColor = NULL;
4267PFNGLCLEARPROC glad_glClear = NULL;
4268PFNGLCLEARACCUMPROC glad_glClearAccum = NULL;
4269PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL;
4270PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL;
4271PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL;
4272PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL;
4273PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
4274PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL;
4275PFNGLCLEARINDEXPROC glad_glClearIndex = NULL;
4276PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
4277PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture = NULL;
4278PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL;
4279PFNGLCLIPPLANEPROC glad_glClipPlane = NULL;
4280PFNGLCOLOR3BPROC glad_glColor3b = NULL;
4281PFNGLCOLOR3BVPROC glad_glColor3bv = NULL;
4282PFNGLCOLOR3DPROC glad_glColor3d = NULL;
4283PFNGLCOLOR3DVPROC glad_glColor3dv = NULL;
4284PFNGLCOLOR3FPROC glad_glColor3f = NULL;
4285PFNGLCOLOR3FVPROC glad_glColor3fv = NULL;
4286PFNGLCOLOR3IPROC glad_glColor3i = NULL;
4287PFNGLCOLOR3IVPROC glad_glColor3iv = NULL;
4288PFNGLCOLOR3SPROC glad_glColor3s = NULL;
4289PFNGLCOLOR3SVPROC glad_glColor3sv = NULL;
4290PFNGLCOLOR3UBPROC glad_glColor3ub = NULL;
4291PFNGLCOLOR3UBVPROC glad_glColor3ubv = NULL;
4292PFNGLCOLOR3UIPROC glad_glColor3ui = NULL;
4293PFNGLCOLOR3UIVPROC glad_glColor3uiv = NULL;
4294PFNGLCOLOR3USPROC glad_glColor3us = NULL;
4295PFNGLCOLOR3USVPROC glad_glColor3usv = NULL;
4296PFNGLCOLOR4BPROC glad_glColor4b = NULL;
4297PFNGLCOLOR4BVPROC glad_glColor4bv = NULL;
4298PFNGLCOLOR4DPROC glad_glColor4d = NULL;
4299PFNGLCOLOR4DVPROC glad_glColor4dv = NULL;
4300PFNGLCOLOR4FPROC glad_glColor4f = NULL;
4301PFNGLCOLOR4FVPROC glad_glColor4fv = NULL;
4302PFNGLCOLOR4IPROC glad_glColor4i = NULL;
4303PFNGLCOLOR4IVPROC glad_glColor4iv = NULL;
4304PFNGLCOLOR4SPROC glad_glColor4s = NULL;
4305PFNGLCOLOR4SVPROC glad_glColor4sv = NULL;
4306PFNGLCOLOR4UBPROC glad_glColor4ub = NULL;
4307PFNGLCOLOR4UBVPROC glad_glColor4ubv = NULL;
4308PFNGLCOLOR4UIPROC glad_glColor4ui = NULL;
4309PFNGLCOLOR4UIVPROC glad_glColor4uiv = NULL;
4310PFNGLCOLOR4USPROC glad_glColor4us = NULL;
4311PFNGLCOLOR4USVPROC glad_glColor4usv = NULL;
4312PFNGLCOLORMASKPROC glad_glColorMask = NULL;
4313PFNGLCOLORMASKIPROC glad_glColorMaski = NULL;
4314PFNGLCOLORMATERIALPROC glad_glColorMaterial = NULL;
4315PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL;
4316PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL;
4317PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL;
4318PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL;
4319PFNGLCOLORPOINTERPROC glad_glColorPointer = NULL;
4320PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
4321PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL;
4322PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
4323PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL;
4324PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL;
4325PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
4326PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL;
4327PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL;
4328PFNGLCOPYPIXELSPROC glad_glCopyPixels = NULL;
4329PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL;
4330PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
4331PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL;
4332PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
4333PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL;
4334PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
4335PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
4336PFNGLCULLFACEPROC glad_glCullFace = NULL;
4337PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL;
4338PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL;
4339PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL;
4340PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
4341PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
4342PFNGLDELETELISTSPROC glad_glDeleteLists = NULL;
4343PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
4344PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL;
4345PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
4346PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL;
4347PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
4348PFNGLDELETESYNCPROC glad_glDeleteSync = NULL;
4349PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
4350PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL;
4351PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
4352PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
4353PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL;
4354PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
4355PFNGLDISABLEPROC glad_glDisable = NULL;
4356PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState = NULL;
4357PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
4358PFNGLDISABLEIPROC glad_glDisablei = NULL;
4359PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
4360PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL;
4361PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL;
4362PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL;
4363PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
4364PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL;
4365PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL;
4366PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL;
4367PFNGLDRAWPIXELSPROC glad_glDrawPixels = NULL;
4368PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL;
4369PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL;
4370PFNGLEDGEFLAGPROC glad_glEdgeFlag = NULL;
4371PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer = NULL;
4372PFNGLEDGEFLAGVPROC glad_glEdgeFlagv = NULL;
4373PFNGLENABLEPROC glad_glEnable = NULL;
4374PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState = NULL;
4375PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
4376PFNGLENABLEIPROC glad_glEnablei = NULL;
4377PFNGLENDPROC glad_glEnd = NULL;
4378PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL;
4379PFNGLENDLISTPROC glad_glEndList = NULL;
4380PFNGLENDQUERYPROC glad_glEndQuery = NULL;
4381PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL;
4382PFNGLEVALCOORD1DPROC glad_glEvalCoord1d = NULL;
4383PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv = NULL;
4384PFNGLEVALCOORD1FPROC glad_glEvalCoord1f = NULL;
4385PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv = NULL;
4386PFNGLEVALCOORD2DPROC glad_glEvalCoord2d = NULL;
4387PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv = NULL;
4388PFNGLEVALCOORD2FPROC glad_glEvalCoord2f = NULL;
4389PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv = NULL;
4390PFNGLEVALMESH1PROC glad_glEvalMesh1 = NULL;
4391PFNGLEVALMESH2PROC glad_glEvalMesh2 = NULL;
4392PFNGLEVALPOINT1PROC glad_glEvalPoint1 = NULL;
4393PFNGLEVALPOINT2PROC glad_glEvalPoint2 = NULL;
4394PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer = NULL;
4395PFNGLFENCESYNCPROC glad_glFenceSync = NULL;
4396PFNGLFINISHPROC glad_glFinish = NULL;
4397PFNGLFLUSHPROC glad_glFlush = NULL;
4398PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL;
4399PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer = NULL;
4400PFNGLFOGCOORDDPROC glad_glFogCoordd = NULL;
4401PFNGLFOGCOORDDVPROC glad_glFogCoorddv = NULL;
4402PFNGLFOGCOORDFPROC glad_glFogCoordf = NULL;
4403PFNGLFOGCOORDFVPROC glad_glFogCoordfv = NULL;
4404PFNGLFOGFPROC glad_glFogf = NULL;
4405PFNGLFOGFVPROC glad_glFogfv = NULL;
4406PFNGLFOGIPROC glad_glFogi = NULL;
4407PFNGLFOGIVPROC glad_glFogiv = NULL;
4408PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
4409PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL;
4410PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL;
4411PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
4412PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL;
4413PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL;
4414PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
4415PFNGLFRUSTUMPROC glad_glFrustum = NULL;
4416PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
4417PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
4418PFNGLGENLISTSPROC glad_glGenLists = NULL;
4419PFNGLGENQUERIESPROC glad_glGenQueries = NULL;
4420PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
4421PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL;
4422PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
4423PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL;
4424PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
4425PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
4426PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
4427PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL;
4428PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL;
4429PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL;
4430PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL;
4431PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
4432PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
4433PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL;
4434PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
4435PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL;
4436PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
4437PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL;
4438PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL;
4439PFNGLGETCLIPPLANEPROC glad_glGetClipPlane = NULL;
4440PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL;
4441PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL;
4442PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL;
4443PFNGLGETERRORPROC glad_glGetError = NULL;
4444PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
4445PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL;
4446PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL;
4447PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
4448PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB = NULL;
4449PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL;
4450PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL;
4451PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL;
4452PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
4453PFNGLGETLIGHTFVPROC glad_glGetLightfv = NULL;
4454PFNGLGETLIGHTIVPROC glad_glGetLightiv = NULL;
4455PFNGLGETMAPDVPROC glad_glGetMapdv = NULL;
4456PFNGLGETMAPFVPROC glad_glGetMapfv = NULL;
4457PFNGLGETMAPIVPROC glad_glGetMapiv = NULL;
4458PFNGLGETMATERIALFVPROC glad_glGetMaterialfv = NULL;
4459PFNGLGETMATERIALIVPROC glad_glGetMaterialiv = NULL;
4460PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL;
4461PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL;
4462PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL;
4463PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv = NULL;
4464PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv = NULL;
4465PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv = NULL;
4466PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL;
4467PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple = NULL;
4468PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
4469PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
4470PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL;
4471PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL;
4472PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL;
4473PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL;
4474PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL;
4475PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
4476PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL;
4477PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL;
4478PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL;
4479PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL;
4480PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
4481PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
4482PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
4483PFNGLGETSTRINGPROC glad_glGetString = NULL;
4484PFNGLGETSTRINGIPROC glad_glGetStringi = NULL;
4485PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL;
4486PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv = NULL;
4487PFNGLGETTEXENVIVPROC glad_glGetTexEnviv = NULL;
4488PFNGLGETTEXGENDVPROC glad_glGetTexGendv = NULL;
4489PFNGLGETTEXGENFVPROC glad_glGetTexGenfv = NULL;
4490PFNGLGETTEXGENIVPROC glad_glGetTexGeniv = NULL;
4491PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL;
4492PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL;
4493PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL;
4494PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL;
4495PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL;
4496PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
4497PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
4498PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL;
4499PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL;
4500PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL;
4501PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
4502PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
4503PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
4504PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL;
4505PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL;
4506PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL;
4507PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
4508PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL;
4509PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
4510PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
4511PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB = NULL;
4512PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB = NULL;
4513PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB = NULL;
4514PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB = NULL;
4515PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB = NULL;
4516PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB = NULL;
4517PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB = NULL;
4518PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB = NULL;
4519PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB = NULL;
4520PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB = NULL;
4521PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB = NULL;
4522PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB = NULL;
4523PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB = NULL;
4524PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB = NULL;
4525PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB = NULL;
4526PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB = NULL;
4527PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB = NULL;
4528PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB = NULL;
4529PFNGLHINTPROC glad_glHint = NULL;
4530PFNGLINDEXMASKPROC glad_glIndexMask = NULL;
4531PFNGLINDEXPOINTERPROC glad_glIndexPointer = NULL;
4532PFNGLINDEXDPROC glad_glIndexd = NULL;
4533PFNGLINDEXDVPROC glad_glIndexdv = NULL;
4534PFNGLINDEXFPROC glad_glIndexf = NULL;
4535PFNGLINDEXFVPROC glad_glIndexfv = NULL;
4536PFNGLINDEXIPROC glad_glIndexi = NULL;
4537PFNGLINDEXIVPROC glad_glIndexiv = NULL;
4538PFNGLINDEXSPROC glad_glIndexs = NULL;
4539PFNGLINDEXSVPROC glad_glIndexsv = NULL;
4540PFNGLINDEXUBPROC glad_glIndexub = NULL;
4541PFNGLINDEXUBVPROC glad_glIndexubv = NULL;
4542PFNGLINITNAMESPROC glad_glInitNames = NULL;
4543PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays = NULL;
4544PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
4545PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
4546PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL;
4547PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
4548PFNGLISLISTPROC glad_glIsList = NULL;
4549PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
4550PFNGLISQUERYPROC glad_glIsQuery = NULL;
4551PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
4552PFNGLISSAMPLERPROC glad_glIsSampler = NULL;
4553PFNGLISSHADERPROC glad_glIsShader = NULL;
4554PFNGLISSYNCPROC glad_glIsSync = NULL;
4555PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
4556PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL;
4557PFNGLLIGHTMODELFPROC glad_glLightModelf = NULL;
4558PFNGLLIGHTMODELFVPROC glad_glLightModelfv = NULL;
4559PFNGLLIGHTMODELIPROC glad_glLightModeli = NULL;
4560PFNGLLIGHTMODELIVPROC glad_glLightModeliv = NULL;
4561PFNGLLIGHTFPROC glad_glLightf = NULL;
4562PFNGLLIGHTFVPROC glad_glLightfv = NULL;
4563PFNGLLIGHTIPROC glad_glLighti = NULL;
4564PFNGLLIGHTIVPROC glad_glLightiv = NULL;
4565PFNGLLINESTIPPLEPROC glad_glLineStipple = NULL;
4566PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
4567PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
4568PFNGLLISTBASEPROC glad_glListBase = NULL;
4569PFNGLLOADIDENTITYPROC glad_glLoadIdentity = NULL;
4570PFNGLLOADMATRIXDPROC glad_glLoadMatrixd = NULL;
4571PFNGLLOADMATRIXFPROC glad_glLoadMatrixf = NULL;
4572PFNGLLOADNAMEPROC glad_glLoadName = NULL;
4573PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd = NULL;
4574PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf = NULL;
4575PFNGLLOGICOPPROC glad_glLogicOp = NULL;
4576PFNGLMAP1DPROC glad_glMap1d = NULL;
4577PFNGLMAP1FPROC glad_glMap1f = NULL;
4578PFNGLMAP2DPROC glad_glMap2d = NULL;
4579PFNGLMAP2FPROC glad_glMap2f = NULL;
4580PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL;
4581PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL;
4582PFNGLMAPGRID1DPROC glad_glMapGrid1d = NULL;
4583PFNGLMAPGRID1FPROC glad_glMapGrid1f = NULL;
4584PFNGLMAPGRID2DPROC glad_glMapGrid2d = NULL;
4585PFNGLMAPGRID2FPROC glad_glMapGrid2f = NULL;
4586PFNGLMATERIALFPROC glad_glMaterialf = NULL;
4587PFNGLMATERIALFVPROC glad_glMaterialfv = NULL;
4588PFNGLMATERIALIPROC glad_glMateriali = NULL;
4589PFNGLMATERIALIVPROC glad_glMaterialiv = NULL;
4590PFNGLMATRIXMODEPROC glad_glMatrixMode = NULL;
4591PFNGLMULTMATRIXDPROC glad_glMultMatrixd = NULL;
4592PFNGLMULTMATRIXFPROC glad_glMultMatrixf = NULL;
4593PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd = NULL;
4594PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf = NULL;
4595PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL;
4596PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL;
4597PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL;
4598PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d = NULL;
4599PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv = NULL;
4600PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f = NULL;
4601PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv = NULL;
4602PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i = NULL;
4603PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv = NULL;
4604PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s = NULL;
4605PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv = NULL;
4606PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d = NULL;
4607PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv = NULL;
4608PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f = NULL;
4609PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv = NULL;
4610PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i = NULL;
4611PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv = NULL;
4612PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s = NULL;
4613PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv = NULL;
4614PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d = NULL;
4615PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv = NULL;
4616PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f = NULL;
4617PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv = NULL;
4618PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i = NULL;
4619PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv = NULL;
4620PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s = NULL;
4621PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv = NULL;
4622PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d = NULL;
4623PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv = NULL;
4624PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f = NULL;
4625PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv = NULL;
4626PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i = NULL;
4627PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv = NULL;
4628PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s = NULL;
4629PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv = NULL;
4630PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL;
4631PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL;
4632PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL;
4633PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL;
4634PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL;
4635PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL;
4636PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL;
4637PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL;
4638PFNGLNEWLISTPROC glad_glNewList = NULL;
4639PFNGLNORMAL3BPROC glad_glNormal3b = NULL;
4640PFNGLNORMAL3BVPROC glad_glNormal3bv = NULL;
4641PFNGLNORMAL3DPROC glad_glNormal3d = NULL;
4642PFNGLNORMAL3DVPROC glad_glNormal3dv = NULL;
4643PFNGLNORMAL3FPROC glad_glNormal3f = NULL;
4644PFNGLNORMAL3FVPROC glad_glNormal3fv = NULL;
4645PFNGLNORMAL3IPROC glad_glNormal3i = NULL;
4646PFNGLNORMAL3IVPROC glad_glNormal3iv = NULL;
4647PFNGLNORMAL3SPROC glad_glNormal3s = NULL;
4648PFNGLNORMAL3SVPROC glad_glNormal3sv = NULL;
4649PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL;
4650PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL;
4651PFNGLNORMALPOINTERPROC glad_glNormalPointer = NULL;
4652PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL;
4653PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL;
4654PFNGLORTHOPROC glad_glOrtho = NULL;
4655PFNGLPASSTHROUGHPROC glad_glPassThrough = NULL;
4656PFNGLPIXELMAPFVPROC glad_glPixelMapfv = NULL;
4657PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv = NULL;
4658PFNGLPIXELMAPUSVPROC glad_glPixelMapusv = NULL;
4659PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL;
4660PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
4661PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf = NULL;
4662PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi = NULL;
4663PFNGLPIXELZOOMPROC glad_glPixelZoom = NULL;
4664PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL;
4665PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL;
4666PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL;
4667PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL;
4668PFNGLPOINTSIZEPROC glad_glPointSize = NULL;
4669PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL;
4670PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
4671PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple = NULL;
4672PFNGLPOPATTRIBPROC glad_glPopAttrib = NULL;
4673PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib = NULL;
4674PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL;
4675PFNGLPOPMATRIXPROC glad_glPopMatrix = NULL;
4676PFNGLPOPNAMEPROC glad_glPopName = NULL;
4677PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL;
4678PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures = NULL;
4679PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL;
4680PFNGLPUSHATTRIBPROC glad_glPushAttrib = NULL;
4681PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib = NULL;
4682PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL;
4683PFNGLPUSHMATRIXPROC glad_glPushMatrix = NULL;
4684PFNGLPUSHNAMEPROC glad_glPushName = NULL;
4685PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL;
4686PFNGLRASTERPOS2DPROC glad_glRasterPos2d = NULL;
4687PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv = NULL;
4688PFNGLRASTERPOS2FPROC glad_glRasterPos2f = NULL;
4689PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv = NULL;
4690PFNGLRASTERPOS2IPROC glad_glRasterPos2i = NULL;
4691PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv = NULL;
4692PFNGLRASTERPOS2SPROC glad_glRasterPos2s = NULL;
4693PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv = NULL;
4694PFNGLRASTERPOS3DPROC glad_glRasterPos3d = NULL;
4695PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv = NULL;
4696PFNGLRASTERPOS3FPROC glad_glRasterPos3f = NULL;
4697PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv = NULL;
4698PFNGLRASTERPOS3IPROC glad_glRasterPos3i = NULL;
4699PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv = NULL;
4700PFNGLRASTERPOS3SPROC glad_glRasterPos3s = NULL;
4701PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv = NULL;
4702PFNGLRASTERPOS4DPROC glad_glRasterPos4d = NULL;
4703PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv = NULL;
4704PFNGLRASTERPOS4FPROC glad_glRasterPos4f = NULL;
4705PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv = NULL;
4706PFNGLRASTERPOS4IPROC glad_glRasterPos4i = NULL;
4707PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv = NULL;
4708PFNGLRASTERPOS4SPROC glad_glRasterPos4s = NULL;
4709PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv = NULL;
4710PFNGLREADBUFFERPROC glad_glReadBuffer = NULL;
4711PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
4712PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB = NULL;
4713PFNGLRECTDPROC glad_glRectd = NULL;
4714PFNGLRECTDVPROC glad_glRectdv = NULL;
4715PFNGLRECTFPROC glad_glRectf = NULL;
4716PFNGLRECTFVPROC glad_glRectfv = NULL;
4717PFNGLRECTIPROC glad_glRecti = NULL;
4718PFNGLRECTIVPROC glad_glRectiv = NULL;
4719PFNGLRECTSPROC glad_glRects = NULL;
4720PFNGLRECTSVPROC glad_glRectsv = NULL;
4721PFNGLRENDERMODEPROC glad_glRenderMode = NULL;
4722PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
4723PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
4724PFNGLROTATEDPROC glad_glRotated = NULL;
4725PFNGLROTATEFPROC glad_glRotatef = NULL;
4726PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
4727PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB = NULL;
4728PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL;
4729PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL;
4730PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL;
4731PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL;
4732PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL;
4733PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL;
4734PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL;
4735PFNGLSCALEDPROC glad_glScaled = NULL;
4736PFNGLSCALEFPROC glad_glScalef = NULL;
4737PFNGLSCISSORPROC glad_glScissor = NULL;
4738PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b = NULL;
4739PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv = NULL;
4740PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d = NULL;
4741PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv = NULL;
4742PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f = NULL;
4743PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv = NULL;
4744PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i = NULL;
4745PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv = NULL;
4746PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s = NULL;
4747PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv = NULL;
4748PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub = NULL;
4749PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv = NULL;
4750PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui = NULL;
4751PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv = NULL;
4752PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us = NULL;
4753PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv = NULL;
4754PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL;
4755PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL;
4756PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer = NULL;
4757PFNGLSELECTBUFFERPROC glad_glSelectBuffer = NULL;
4758PFNGLSHADEMODELPROC glad_glShadeModel = NULL;
4759PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
4760PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
4761PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
4762PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
4763PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
4764PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
4765PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
4766PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL;
4767PFNGLTEXCOORD1DPROC glad_glTexCoord1d = NULL;
4768PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv = NULL;
4769PFNGLTEXCOORD1FPROC glad_glTexCoord1f = NULL;
4770PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv = NULL;
4771PFNGLTEXCOORD1IPROC glad_glTexCoord1i = NULL;
4772PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv = NULL;
4773PFNGLTEXCOORD1SPROC glad_glTexCoord1s = NULL;
4774PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv = NULL;
4775PFNGLTEXCOORD2DPROC glad_glTexCoord2d = NULL;
4776PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv = NULL;
4777PFNGLTEXCOORD2FPROC glad_glTexCoord2f = NULL;
4778PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv = NULL;
4779PFNGLTEXCOORD2IPROC glad_glTexCoord2i = NULL;
4780PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv = NULL;
4781PFNGLTEXCOORD2SPROC glad_glTexCoord2s = NULL;
4782PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv = NULL;
4783PFNGLTEXCOORD3DPROC glad_glTexCoord3d = NULL;
4784PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv = NULL;
4785PFNGLTEXCOORD3FPROC glad_glTexCoord3f = NULL;
4786PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv = NULL;
4787PFNGLTEXCOORD3IPROC glad_glTexCoord3i = NULL;
4788PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv = NULL;
4789PFNGLTEXCOORD3SPROC glad_glTexCoord3s = NULL;
4790PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv = NULL;
4791PFNGLTEXCOORD4DPROC glad_glTexCoord4d = NULL;
4792PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv = NULL;
4793PFNGLTEXCOORD4FPROC glad_glTexCoord4f = NULL;
4794PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv = NULL;
4795PFNGLTEXCOORD4IPROC glad_glTexCoord4i = NULL;
4796PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv = NULL;
4797PFNGLTEXCOORD4SPROC glad_glTexCoord4s = NULL;
4798PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv = NULL;
4799PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL;
4800PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL;
4801PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL;
4802PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL;
4803PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL;
4804PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL;
4805PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL;
4806PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL;
4807PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer = NULL;
4808PFNGLTEXENVFPROC glad_glTexEnvf = NULL;
4809PFNGLTEXENVFVPROC glad_glTexEnvfv = NULL;
4810PFNGLTEXENVIPROC glad_glTexEnvi = NULL;
4811PFNGLTEXENVIVPROC glad_glTexEnviv = NULL;
4812PFNGLTEXGENDPROC glad_glTexGend = NULL;
4813PFNGLTEXGENDVPROC glad_glTexGendv = NULL;
4814PFNGLTEXGENFPROC glad_glTexGenf = NULL;
4815PFNGLTEXGENFVPROC glad_glTexGenfv = NULL;
4816PFNGLTEXGENIPROC glad_glTexGeni = NULL;
4817PFNGLTEXGENIVPROC glad_glTexGeniv = NULL;
4818PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL;
4819PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
4820PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL;
4821PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL;
4822PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL;
4823PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL;
4824PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL;
4825PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
4826PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
4827PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
4828PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
4829PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL;
4830PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
4831PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL;
4832PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL;
4833PFNGLTRANSLATEDPROC glad_glTranslated = NULL;
4834PFNGLTRANSLATEFPROC glad_glTranslatef = NULL;
4835PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
4836PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
4837PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
4838PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
4839PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL;
4840PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL;
4841PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
4842PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
4843PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
4844PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
4845PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL;
4846PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL;
4847PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
4848PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
4849PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
4850PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
4851PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL;
4852PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL;
4853PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
4854PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
4855PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
4856PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
4857PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL;
4858PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL;
4859PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL;
4860PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
4861PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL;
4862PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL;
4863PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
4864PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL;
4865PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL;
4866PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
4867PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL;
4868PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL;
4869PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL;
4870PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
4871PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
4872PFNGLVERTEX2DPROC glad_glVertex2d = NULL;
4873PFNGLVERTEX2DVPROC glad_glVertex2dv = NULL;
4874PFNGLVERTEX2FPROC glad_glVertex2f = NULL;
4875PFNGLVERTEX2FVPROC glad_glVertex2fv = NULL;
4876PFNGLVERTEX2IPROC glad_glVertex2i = NULL;
4877PFNGLVERTEX2IVPROC glad_glVertex2iv = NULL;
4878PFNGLVERTEX2SPROC glad_glVertex2s = NULL;
4879PFNGLVERTEX2SVPROC glad_glVertex2sv = NULL;
4880PFNGLVERTEX3DPROC glad_glVertex3d = NULL;
4881PFNGLVERTEX3DVPROC glad_glVertex3dv = NULL;
4882PFNGLVERTEX3FPROC glad_glVertex3f = NULL;
4883PFNGLVERTEX3FVPROC glad_glVertex3fv = NULL;
4884PFNGLVERTEX3IPROC glad_glVertex3i = NULL;
4885PFNGLVERTEX3IVPROC glad_glVertex3iv = NULL;
4886PFNGLVERTEX3SPROC glad_glVertex3s = NULL;
4887PFNGLVERTEX3SVPROC glad_glVertex3sv = NULL;
4888PFNGLVERTEX4DPROC glad_glVertex4d = NULL;
4889PFNGLVERTEX4DVPROC glad_glVertex4dv = NULL;
4890PFNGLVERTEX4FPROC glad_glVertex4f = NULL;
4891PFNGLVERTEX4FVPROC glad_glVertex4fv = NULL;
4892PFNGLVERTEX4IPROC glad_glVertex4i = NULL;
4893PFNGLVERTEX4IVPROC glad_glVertex4iv = NULL;
4894PFNGLVERTEX4SPROC glad_glVertex4s = NULL;
4895PFNGLVERTEX4SVPROC glad_glVertex4sv = NULL;
4896PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL;
4897PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL;
4898PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
4899PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
4900PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL;
4901PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL;
4902PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL;
4903PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL;
4904PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
4905PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
4906PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL;
4907PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL;
4908PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL;
4909PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL;
4910PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
4911PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
4912PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL;
4913PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL;
4914PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL;
4915PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL;
4916PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL;
4917PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL;
4918PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL;
4919PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL;
4920PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL;
4921PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL;
4922PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL;
4923PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL;
4924PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
4925PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
4926PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL;
4927PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL;
4928PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL;
4929PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL;
4930PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL;
4931PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL;
4932PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL;
4933PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL;
4934PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL;
4935PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL;
4936PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL;
4937PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL;
4938PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL;
4939PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL;
4940PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL;
4941PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL;
4942PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL;
4943PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL;
4944PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL;
4945PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL;
4946PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL;
4947PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL;
4948PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL;
4949PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL;
4950PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL;
4951PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL;
4952PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL;
4953PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL;
4954PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL;
4955PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL;
4956PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL;
4957PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL;
4958PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL;
4959PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL;
4960PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL;
4961PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL;
4962PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
4963PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL;
4964PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL;
4965PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL;
4966PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL;
4967PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL;
4968PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL;
4969PFNGLVERTEXPOINTERPROC glad_glVertexPointer = NULL;
4970PFNGLVIEWPORTPROC glad_glViewport = NULL;
4971PFNGLWAITSYNCPROC glad_glWaitSync = NULL;
4972PFNGLWINDOWPOS2DPROC glad_glWindowPos2d = NULL;
4973PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv = NULL;
4974PFNGLWINDOWPOS2FPROC glad_glWindowPos2f = NULL;
4975PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv = NULL;
4976PFNGLWINDOWPOS2IPROC glad_glWindowPos2i = NULL;
4977PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv = NULL;
4978PFNGLWINDOWPOS2SPROC glad_glWindowPos2s = NULL;
4979PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv = NULL;
4980PFNGLWINDOWPOS3DPROC glad_glWindowPos3d = NULL;
4981PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv = NULL;
4982PFNGLWINDOWPOS3FPROC glad_glWindowPos3f = NULL;
4983PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv = NULL;
4984PFNGLWINDOWPOS3IPROC glad_glWindowPos3i = NULL;
4985PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL;
4986PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL;
4987PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL;
4988
4989
4990static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
4991 if(!GLAD_GL_VERSION_1_0) return;
4992 glad_glAccum = (PFNGLACCUMPROC) load(userptr, "glAccum");
4993 glad_glAlphaFunc = (PFNGLALPHAFUNCPROC) load(userptr, "glAlphaFunc");
4994 glad_glBegin = (PFNGLBEGINPROC) load(userptr, "glBegin");
4995 glad_glBitmap = (PFNGLBITMAPPROC) load(userptr, "glBitmap");
4996 glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
4997 glad_glCallList = (PFNGLCALLLISTPROC) load(userptr, "glCallList");
4998 glad_glCallLists = (PFNGLCALLLISTSPROC) load(userptr, "glCallLists");
4999 glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
5000 glad_glClearAccum = (PFNGLCLEARACCUMPROC) load(userptr, "glClearAccum");
5001 glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
5002 glad_glClearDepth = (PFNGLCLEARDEPTHPROC) load(userptr, "glClearDepth");
5003 glad_glClearIndex = (PFNGLCLEARINDEXPROC) load(userptr, "glClearIndex");
5004 glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
5005 glad_glClipPlane = (PFNGLCLIPPLANEPROC) load(userptr, "glClipPlane");
5006 glad_glColor3b = (PFNGLCOLOR3BPROC) load(userptr, "glColor3b");
5007 glad_glColor3bv = (PFNGLCOLOR3BVPROC) load(userptr, "glColor3bv");
5008 glad_glColor3d = (PFNGLCOLOR3DPROC) load(userptr, "glColor3d");
5009 glad_glColor3dv = (PFNGLCOLOR3DVPROC) load(userptr, "glColor3dv");
5010 glad_glColor3f = (PFNGLCOLOR3FPROC) load(userptr, "glColor3f");
5011 glad_glColor3fv = (PFNGLCOLOR3FVPROC) load(userptr, "glColor3fv");
5012 glad_glColor3i = (PFNGLCOLOR3IPROC) load(userptr, "glColor3i");
5013 glad_glColor3iv = (PFNGLCOLOR3IVPROC) load(userptr, "glColor3iv");
5014 glad_glColor3s = (PFNGLCOLOR3SPROC) load(userptr, "glColor3s");
5015 glad_glColor3sv = (PFNGLCOLOR3SVPROC) load(userptr, "glColor3sv");
5016 glad_glColor3ub = (PFNGLCOLOR3UBPROC) load(userptr, "glColor3ub");
5017 glad_glColor3ubv = (PFNGLCOLOR3UBVPROC) load(userptr, "glColor3ubv");
5018 glad_glColor3ui = (PFNGLCOLOR3UIPROC) load(userptr, "glColor3ui");
5019 glad_glColor3uiv = (PFNGLCOLOR3UIVPROC) load(userptr, "glColor3uiv");
5020 glad_glColor3us = (PFNGLCOLOR3USPROC) load(userptr, "glColor3us");
5021 glad_glColor3usv = (PFNGLCOLOR3USVPROC) load(userptr, "glColor3usv");
5022 glad_glColor4b = (PFNGLCOLOR4BPROC) load(userptr, "glColor4b");
5023 glad_glColor4bv = (PFNGLCOLOR4BVPROC) load(userptr, "glColor4bv");
5024 glad_glColor4d = (PFNGLCOLOR4DPROC) load(userptr, "glColor4d");
5025 glad_glColor4dv = (PFNGLCOLOR4DVPROC) load(userptr, "glColor4dv");
5026 glad_glColor4f = (PFNGLCOLOR4FPROC) load(userptr, "glColor4f");
5027 glad_glColor4fv = (PFNGLCOLOR4FVPROC) load(userptr, "glColor4fv");
5028 glad_glColor4i = (PFNGLCOLOR4IPROC) load(userptr, "glColor4i");
5029 glad_glColor4iv = (PFNGLCOLOR4IVPROC) load(userptr, "glColor4iv");
5030 glad_glColor4s = (PFNGLCOLOR4SPROC) load(userptr, "glColor4s");
5031 glad_glColor4sv = (PFNGLCOLOR4SVPROC) load(userptr, "glColor4sv");
5032 glad_glColor4ub = (PFNGLCOLOR4UBPROC) load(userptr, "glColor4ub");
5033 glad_glColor4ubv = (PFNGLCOLOR4UBVPROC) load(userptr, "glColor4ubv");
5034 glad_glColor4ui = (PFNGLCOLOR4UIPROC) load(userptr, "glColor4ui");
5035 glad_glColor4uiv = (PFNGLCOLOR4UIVPROC) load(userptr, "glColor4uiv");
5036 glad_glColor4us = (PFNGLCOLOR4USPROC) load(userptr, "glColor4us");
5037 glad_glColor4usv = (PFNGLCOLOR4USVPROC) load(userptr, "glColor4usv");
5038 glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
5039 glad_glColorMaterial = (PFNGLCOLORMATERIALPROC) load(userptr, "glColorMaterial");
5040 glad_glCopyPixels = (PFNGLCOPYPIXELSPROC) load(userptr, "glCopyPixels");
5041 glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
5042 glad_glDeleteLists = (PFNGLDELETELISTSPROC) load(userptr, "glDeleteLists");
5043 glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
5044 glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
5045 glad_glDepthRange = (PFNGLDEPTHRANGEPROC) load(userptr, "glDepthRange");
5046 glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
5047 glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC) load(userptr, "glDrawBuffer");
5048 glad_glDrawPixels = (PFNGLDRAWPIXELSPROC) load(userptr, "glDrawPixels");
5049 glad_glEdgeFlag = (PFNGLEDGEFLAGPROC) load(userptr, "glEdgeFlag");
5050 glad_glEdgeFlagv = (PFNGLEDGEFLAGVPROC) load(userptr, "glEdgeFlagv");
5051 glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
5052 glad_glEnd = (PFNGLENDPROC) load(userptr, "glEnd");
5053 glad_glEndList = (PFNGLENDLISTPROC) load(userptr, "glEndList");
5054 glad_glEvalCoord1d = (PFNGLEVALCOORD1DPROC) load(userptr, "glEvalCoord1d");
5055 glad_glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC) load(userptr, "glEvalCoord1dv");
5056 glad_glEvalCoord1f = (PFNGLEVALCOORD1FPROC) load(userptr, "glEvalCoord1f");
5057 glad_glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC) load(userptr, "glEvalCoord1fv");
5058 glad_glEvalCoord2d = (PFNGLEVALCOORD2DPROC) load(userptr, "glEvalCoord2d");
5059 glad_glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC) load(userptr, "glEvalCoord2dv");
5060 glad_glEvalCoord2f = (PFNGLEVALCOORD2FPROC) load(userptr, "glEvalCoord2f");
5061 glad_glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC) load(userptr, "glEvalCoord2fv");
5062 glad_glEvalMesh1 = (PFNGLEVALMESH1PROC) load(userptr, "glEvalMesh1");
5063 glad_glEvalMesh2 = (PFNGLEVALMESH2PROC) load(userptr, "glEvalMesh2");
5064 glad_glEvalPoint1 = (PFNGLEVALPOINT1PROC) load(userptr, "glEvalPoint1");
5065 glad_glEvalPoint2 = (PFNGLEVALPOINT2PROC) load(userptr, "glEvalPoint2");
5066 glad_glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC) load(userptr, "glFeedbackBuffer");
5067 glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
5068 glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
5069 glad_glFogf = (PFNGLFOGFPROC) load(userptr, "glFogf");
5070 glad_glFogfv = (PFNGLFOGFVPROC) load(userptr, "glFogfv");
5071 glad_glFogi = (PFNGLFOGIPROC) load(userptr, "glFogi");
5072 glad_glFogiv = (PFNGLFOGIVPROC) load(userptr, "glFogiv");
5073 glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
5074 glad_glFrustum = (PFNGLFRUSTUMPROC) load(userptr, "glFrustum");
5075 glad_glGenLists = (PFNGLGENLISTSPROC) load(userptr, "glGenLists");
5076 glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
5077 glad_glGetClipPlane = (PFNGLGETCLIPPLANEPROC) load(userptr, "glGetClipPlane");
5078 glad_glGetDoublev = (PFNGLGETDOUBLEVPROC) load(userptr, "glGetDoublev");
5079 glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
5080 glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
5081 glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
5082 glad_glGetLightfv = (PFNGLGETLIGHTFVPROC) load(userptr, "glGetLightfv");
5083 glad_glGetLightiv = (PFNGLGETLIGHTIVPROC) load(userptr, "glGetLightiv");
5084 glad_glGetMapdv = (PFNGLGETMAPDVPROC) load(userptr, "glGetMapdv");
5085 glad_glGetMapfv = (PFNGLGETMAPFVPROC) load(userptr, "glGetMapfv");
5086 glad_glGetMapiv = (PFNGLGETMAPIVPROC) load(userptr, "glGetMapiv");
5087 glad_glGetMaterialfv = (PFNGLGETMATERIALFVPROC) load(userptr, "glGetMaterialfv");
5088 glad_glGetMaterialiv = (PFNGLGETMATERIALIVPROC) load(userptr, "glGetMaterialiv");
5089 glad_glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC) load(userptr, "glGetPixelMapfv");
5090 glad_glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC) load(userptr, "glGetPixelMapuiv");
5091 glad_glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC) load(userptr, "glGetPixelMapusv");
5092 glad_glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC) load(userptr, "glGetPolygonStipple");
5093 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
5094 glad_glGetTexEnvfv = (PFNGLGETTEXENVFVPROC) load(userptr, "glGetTexEnvfv");
5095 glad_glGetTexEnviv = (PFNGLGETTEXENVIVPROC) load(userptr, "glGetTexEnviv");
5096 glad_glGetTexGendv = (PFNGLGETTEXGENDVPROC) load(userptr, "glGetTexGendv");
5097 glad_glGetTexGenfv = (PFNGLGETTEXGENFVPROC) load(userptr, "glGetTexGenfv");
5098 glad_glGetTexGeniv = (PFNGLGETTEXGENIVPROC) load(userptr, "glGetTexGeniv");
5099 glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC) load(userptr, "glGetTexImage");
5100 glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load(userptr, "glGetTexLevelParameterfv");
5101 glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load(userptr, "glGetTexLevelParameteriv");
5102 glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
5103 glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
5104 glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
5105 glad_glIndexMask = (PFNGLINDEXMASKPROC) load(userptr, "glIndexMask");
5106 glad_glIndexd = (PFNGLINDEXDPROC) load(userptr, "glIndexd");
5107 glad_glIndexdv = (PFNGLINDEXDVPROC) load(userptr, "glIndexdv");
5108 glad_glIndexf = (PFNGLINDEXFPROC) load(userptr, "glIndexf");
5109 glad_glIndexfv = (PFNGLINDEXFVPROC) load(userptr, "glIndexfv");
5110 glad_glIndexi = (PFNGLINDEXIPROC) load(userptr, "glIndexi");
5111 glad_glIndexiv = (PFNGLINDEXIVPROC) load(userptr, "glIndexiv");
5112 glad_glIndexs = (PFNGLINDEXSPROC) load(userptr, "glIndexs");
5113 glad_glIndexsv = (PFNGLINDEXSVPROC) load(userptr, "glIndexsv");
5114 glad_glInitNames = (PFNGLINITNAMESPROC) load(userptr, "glInitNames");
5115 glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
5116 glad_glIsList = (PFNGLISLISTPROC) load(userptr, "glIsList");
5117 glad_glLightModelf = (PFNGLLIGHTMODELFPROC) load(userptr, "glLightModelf");
5118 glad_glLightModelfv = (PFNGLLIGHTMODELFVPROC) load(userptr, "glLightModelfv");
5119 glad_glLightModeli = (PFNGLLIGHTMODELIPROC) load(userptr, "glLightModeli");
5120 glad_glLightModeliv = (PFNGLLIGHTMODELIVPROC) load(userptr, "glLightModeliv");
5121 glad_glLightf = (PFNGLLIGHTFPROC) load(userptr, "glLightf");
5122 glad_glLightfv = (PFNGLLIGHTFVPROC) load(userptr, "glLightfv");
5123 glad_glLighti = (PFNGLLIGHTIPROC) load(userptr, "glLighti");
5124 glad_glLightiv = (PFNGLLIGHTIVPROC) load(userptr, "glLightiv");
5125 glad_glLineStipple = (PFNGLLINESTIPPLEPROC) load(userptr, "glLineStipple");
5126 glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
5127 glad_glListBase = (PFNGLLISTBASEPROC) load(userptr, "glListBase");
5128 glad_glLoadIdentity = (PFNGLLOADIDENTITYPROC) load(userptr, "glLoadIdentity");
5129 glad_glLoadMatrixd = (PFNGLLOADMATRIXDPROC) load(userptr, "glLoadMatrixd");
5130 glad_glLoadMatrixf = (PFNGLLOADMATRIXFPROC) load(userptr, "glLoadMatrixf");
5131 glad_glLoadName = (PFNGLLOADNAMEPROC) load(userptr, "glLoadName");
5132 glad_glLogicOp = (PFNGLLOGICOPPROC) load(userptr, "glLogicOp");
5133 glad_glMap1d = (PFNGLMAP1DPROC) load(userptr, "glMap1d");
5134 glad_glMap1f = (PFNGLMAP1FPROC) load(userptr, "glMap1f");
5135 glad_glMap2d = (PFNGLMAP2DPROC) load(userptr, "glMap2d");
5136 glad_glMap2f = (PFNGLMAP2FPROC) load(userptr, "glMap2f");
5137 glad_glMapGrid1d = (PFNGLMAPGRID1DPROC) load(userptr, "glMapGrid1d");
5138 glad_glMapGrid1f = (PFNGLMAPGRID1FPROC) load(userptr, "glMapGrid1f");
5139 glad_glMapGrid2d = (PFNGLMAPGRID2DPROC) load(userptr, "glMapGrid2d");
5140 glad_glMapGrid2f = (PFNGLMAPGRID2FPROC) load(userptr, "glMapGrid2f");
5141 glad_glMaterialf = (PFNGLMATERIALFPROC) load(userptr, "glMaterialf");
5142 glad_glMaterialfv = (PFNGLMATERIALFVPROC) load(userptr, "glMaterialfv");
5143 glad_glMateriali = (PFNGLMATERIALIPROC) load(userptr, "glMateriali");
5144 glad_glMaterialiv = (PFNGLMATERIALIVPROC) load(userptr, "glMaterialiv");
5145 glad_glMatrixMode = (PFNGLMATRIXMODEPROC) load(userptr, "glMatrixMode");
5146 glad_glMultMatrixd = (PFNGLMULTMATRIXDPROC) load(userptr, "glMultMatrixd");
5147 glad_glMultMatrixf = (PFNGLMULTMATRIXFPROC) load(userptr, "glMultMatrixf");
5148 glad_glNewList = (PFNGLNEWLISTPROC) load(userptr, "glNewList");
5149 glad_glNormal3b = (PFNGLNORMAL3BPROC) load(userptr, "glNormal3b");
5150 glad_glNormal3bv = (PFNGLNORMAL3BVPROC) load(userptr, "glNormal3bv");
5151 glad_glNormal3d = (PFNGLNORMAL3DPROC) load(userptr, "glNormal3d");
5152 glad_glNormal3dv = (PFNGLNORMAL3DVPROC) load(userptr, "glNormal3dv");
5153 glad_glNormal3f = (PFNGLNORMAL3FPROC) load(userptr, "glNormal3f");
5154 glad_glNormal3fv = (PFNGLNORMAL3FVPROC) load(userptr, "glNormal3fv");
5155 glad_glNormal3i = (PFNGLNORMAL3IPROC) load(userptr, "glNormal3i");
5156 glad_glNormal3iv = (PFNGLNORMAL3IVPROC) load(userptr, "glNormal3iv");
5157 glad_glNormal3s = (PFNGLNORMAL3SPROC) load(userptr, "glNormal3s");
5158 glad_glNormal3sv = (PFNGLNORMAL3SVPROC) load(userptr, "glNormal3sv");
5159 glad_glOrtho = (PFNGLORTHOPROC) load(userptr, "glOrtho");
5160 glad_glPassThrough = (PFNGLPASSTHROUGHPROC) load(userptr, "glPassThrough");
5161 glad_glPixelMapfv = (PFNGLPIXELMAPFVPROC) load(userptr, "glPixelMapfv");
5162 glad_glPixelMapuiv = (PFNGLPIXELMAPUIVPROC) load(userptr, "glPixelMapuiv");
5163 glad_glPixelMapusv = (PFNGLPIXELMAPUSVPROC) load(userptr, "glPixelMapusv");
5164 glad_glPixelStoref = (PFNGLPIXELSTOREFPROC) load(userptr, "glPixelStoref");
5165 glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
5166 glad_glPixelTransferf = (PFNGLPIXELTRANSFERFPROC) load(userptr, "glPixelTransferf");
5167 glad_glPixelTransferi = (PFNGLPIXELTRANSFERIPROC) load(userptr, "glPixelTransferi");
5168 glad_glPixelZoom = (PFNGLPIXELZOOMPROC) load(userptr, "glPixelZoom");
5169 glad_glPointSize = (PFNGLPOINTSIZEPROC) load(userptr, "glPointSize");
5170 glad_glPolygonMode = (PFNGLPOLYGONMODEPROC) load(userptr, "glPolygonMode");
5171 glad_glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC) load(userptr, "glPolygonStipple");
5172 glad_glPopAttrib = (PFNGLPOPATTRIBPROC) load(userptr, "glPopAttrib");
5173 glad_glPopMatrix = (PFNGLPOPMATRIXPROC) load(userptr, "glPopMatrix");
5174 glad_glPopName = (PFNGLPOPNAMEPROC) load(userptr, "glPopName");
5175 glad_glPushAttrib = (PFNGLPUSHATTRIBPROC) load(userptr, "glPushAttrib");
5176 glad_glPushMatrix = (PFNGLPUSHMATRIXPROC) load(userptr, "glPushMatrix");
5177 glad_glPushName = (PFNGLPUSHNAMEPROC) load(userptr, "glPushName");
5178 glad_glRasterPos2d = (PFNGLRASTERPOS2DPROC) load(userptr, "glRasterPos2d");
5179 glad_glRasterPos2dv = (PFNGLRASTERPOS2DVPROC) load(userptr, "glRasterPos2dv");
5180 glad_glRasterPos2f = (PFNGLRASTERPOS2FPROC) load(userptr, "glRasterPos2f");
5181 glad_glRasterPos2fv = (PFNGLRASTERPOS2FVPROC) load(userptr, "glRasterPos2fv");
5182 glad_glRasterPos2i = (PFNGLRASTERPOS2IPROC) load(userptr, "glRasterPos2i");
5183 glad_glRasterPos2iv = (PFNGLRASTERPOS2IVPROC) load(userptr, "glRasterPos2iv");
5184 glad_glRasterPos2s = (PFNGLRASTERPOS2SPROC) load(userptr, "glRasterPos2s");
5185 glad_glRasterPos2sv = (PFNGLRASTERPOS2SVPROC) load(userptr, "glRasterPos2sv");
5186 glad_glRasterPos3d = (PFNGLRASTERPOS3DPROC) load(userptr, "glRasterPos3d");
5187 glad_glRasterPos3dv = (PFNGLRASTERPOS3DVPROC) load(userptr, "glRasterPos3dv");
5188 glad_glRasterPos3f = (PFNGLRASTERPOS3FPROC) load(userptr, "glRasterPos3f");
5189 glad_glRasterPos3fv = (PFNGLRASTERPOS3FVPROC) load(userptr, "glRasterPos3fv");
5190 glad_glRasterPos3i = (PFNGLRASTERPOS3IPROC) load(userptr, "glRasterPos3i");
5191 glad_glRasterPos3iv = (PFNGLRASTERPOS3IVPROC) load(userptr, "glRasterPos3iv");
5192 glad_glRasterPos3s = (PFNGLRASTERPOS3SPROC) load(userptr, "glRasterPos3s");
5193 glad_glRasterPos3sv = (PFNGLRASTERPOS3SVPROC) load(userptr, "glRasterPos3sv");
5194 glad_glRasterPos4d = (PFNGLRASTERPOS4DPROC) load(userptr, "glRasterPos4d");
5195 glad_glRasterPos4dv = (PFNGLRASTERPOS4DVPROC) load(userptr, "glRasterPos4dv");
5196 glad_glRasterPos4f = (PFNGLRASTERPOS4FPROC) load(userptr, "glRasterPos4f");
5197 glad_glRasterPos4fv = (PFNGLRASTERPOS4FVPROC) load(userptr, "glRasterPos4fv");
5198 glad_glRasterPos4i = (PFNGLRASTERPOS4IPROC) load(userptr, "glRasterPos4i");
5199 glad_glRasterPos4iv = (PFNGLRASTERPOS4IVPROC) load(userptr, "glRasterPos4iv");
5200 glad_glRasterPos4s = (PFNGLRASTERPOS4SPROC) load(userptr, "glRasterPos4s");
5201 glad_glRasterPos4sv = (PFNGLRASTERPOS4SVPROC) load(userptr, "glRasterPos4sv");
5202 glad_glReadBuffer = (PFNGLREADBUFFERPROC) load(userptr, "glReadBuffer");
5203 glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
5204 glad_glRectd = (PFNGLRECTDPROC) load(userptr, "glRectd");
5205 glad_glRectdv = (PFNGLRECTDVPROC) load(userptr, "glRectdv");
5206 glad_glRectf = (PFNGLRECTFPROC) load(userptr, "glRectf");
5207 glad_glRectfv = (PFNGLRECTFVPROC) load(userptr, "glRectfv");
5208 glad_glRecti = (PFNGLRECTIPROC) load(userptr, "glRecti");
5209 glad_glRectiv = (PFNGLRECTIVPROC) load(userptr, "glRectiv");
5210 glad_glRects = (PFNGLRECTSPROC) load(userptr, "glRects");
5211 glad_glRectsv = (PFNGLRECTSVPROC) load(userptr, "glRectsv");
5212 glad_glRenderMode = (PFNGLRENDERMODEPROC) load(userptr, "glRenderMode");
5213 glad_glRotated = (PFNGLROTATEDPROC) load(userptr, "glRotated");
5214 glad_glRotatef = (PFNGLROTATEFPROC) load(userptr, "glRotatef");
5215 glad_glScaled = (PFNGLSCALEDPROC) load(userptr, "glScaled");
5216 glad_glScalef = (PFNGLSCALEFPROC) load(userptr, "glScalef");
5217 glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
5218 glad_glSelectBuffer = (PFNGLSELECTBUFFERPROC) load(userptr, "glSelectBuffer");
5219 glad_glShadeModel = (PFNGLSHADEMODELPROC) load(userptr, "glShadeModel");
5220 glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
5221 glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
5222 glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
5223 glad_glTexCoord1d = (PFNGLTEXCOORD1DPROC) load(userptr, "glTexCoord1d");
5224 glad_glTexCoord1dv = (PFNGLTEXCOORD1DVPROC) load(userptr, "glTexCoord1dv");
5225 glad_glTexCoord1f = (PFNGLTEXCOORD1FPROC) load(userptr, "glTexCoord1f");
5226 glad_glTexCoord1fv = (PFNGLTEXCOORD1FVPROC) load(userptr, "glTexCoord1fv");
5227 glad_glTexCoord1i = (PFNGLTEXCOORD1IPROC) load(userptr, "glTexCoord1i");
5228 glad_glTexCoord1iv = (PFNGLTEXCOORD1IVPROC) load(userptr, "glTexCoord1iv");
5229 glad_glTexCoord1s = (PFNGLTEXCOORD1SPROC) load(userptr, "glTexCoord1s");
5230 glad_glTexCoord1sv = (PFNGLTEXCOORD1SVPROC) load(userptr, "glTexCoord1sv");
5231 glad_glTexCoord2d = (PFNGLTEXCOORD2DPROC) load(userptr, "glTexCoord2d");
5232 glad_glTexCoord2dv = (PFNGLTEXCOORD2DVPROC) load(userptr, "glTexCoord2dv");
5233 glad_glTexCoord2f = (PFNGLTEXCOORD2FPROC) load(userptr, "glTexCoord2f");
5234 glad_glTexCoord2fv = (PFNGLTEXCOORD2FVPROC) load(userptr, "glTexCoord2fv");
5235 glad_glTexCoord2i = (PFNGLTEXCOORD2IPROC) load(userptr, "glTexCoord2i");
5236 glad_glTexCoord2iv = (PFNGLTEXCOORD2IVPROC) load(userptr, "glTexCoord2iv");
5237 glad_glTexCoord2s = (PFNGLTEXCOORD2SPROC) load(userptr, "glTexCoord2s");
5238 glad_glTexCoord2sv = (PFNGLTEXCOORD2SVPROC) load(userptr, "glTexCoord2sv");
5239 glad_glTexCoord3d = (PFNGLTEXCOORD3DPROC) load(userptr, "glTexCoord3d");
5240 glad_glTexCoord3dv = (PFNGLTEXCOORD3DVPROC) load(userptr, "glTexCoord3dv");
5241 glad_glTexCoord3f = (PFNGLTEXCOORD3FPROC) load(userptr, "glTexCoord3f");
5242 glad_glTexCoord3fv = (PFNGLTEXCOORD3FVPROC) load(userptr, "glTexCoord3fv");
5243 glad_glTexCoord3i = (PFNGLTEXCOORD3IPROC) load(userptr, "glTexCoord3i");
5244 glad_glTexCoord3iv = (PFNGLTEXCOORD3IVPROC) load(userptr, "glTexCoord3iv");
5245 glad_glTexCoord3s = (PFNGLTEXCOORD3SPROC) load(userptr, "glTexCoord3s");
5246 glad_glTexCoord3sv = (PFNGLTEXCOORD3SVPROC) load(userptr, "glTexCoord3sv");
5247 glad_glTexCoord4d = (PFNGLTEXCOORD4DPROC) load(userptr, "glTexCoord4d");
5248 glad_glTexCoord4dv = (PFNGLTEXCOORD4DVPROC) load(userptr, "glTexCoord4dv");
5249 glad_glTexCoord4f = (PFNGLTEXCOORD4FPROC) load(userptr, "glTexCoord4f");
5250 glad_glTexCoord4fv = (PFNGLTEXCOORD4FVPROC) load(userptr, "glTexCoord4fv");
5251 glad_glTexCoord4i = (PFNGLTEXCOORD4IPROC) load(userptr, "glTexCoord4i");
5252 glad_glTexCoord4iv = (PFNGLTEXCOORD4IVPROC) load(userptr, "glTexCoord4iv");
5253 glad_glTexCoord4s = (PFNGLTEXCOORD4SPROC) load(userptr, "glTexCoord4s");
5254 glad_glTexCoord4sv = (PFNGLTEXCOORD4SVPROC) load(userptr, "glTexCoord4sv");
5255 glad_glTexEnvf = (PFNGLTEXENVFPROC) load(userptr, "glTexEnvf");
5256 glad_glTexEnvfv = (PFNGLTEXENVFVPROC) load(userptr, "glTexEnvfv");
5257 glad_glTexEnvi = (PFNGLTEXENVIPROC) load(userptr, "glTexEnvi");
5258 glad_glTexEnviv = (PFNGLTEXENVIVPROC) load(userptr, "glTexEnviv");
5259 glad_glTexGend = (PFNGLTEXGENDPROC) load(userptr, "glTexGend");
5260 glad_glTexGendv = (PFNGLTEXGENDVPROC) load(userptr, "glTexGendv");
5261 glad_glTexGenf = (PFNGLTEXGENFPROC) load(userptr, "glTexGenf");
5262 glad_glTexGenfv = (PFNGLTEXGENFVPROC) load(userptr, "glTexGenfv");
5263 glad_glTexGeni = (PFNGLTEXGENIPROC) load(userptr, "glTexGeni");
5264 glad_glTexGeniv = (PFNGLTEXGENIVPROC) load(userptr, "glTexGeniv");
5265 glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC) load(userptr, "glTexImage1D");
5266 glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
5267 glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
5268 glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
5269 glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
5270 glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
5271 glad_glTranslated = (PFNGLTRANSLATEDPROC) load(userptr, "glTranslated");
5272 glad_glTranslatef = (PFNGLTRANSLATEFPROC) load(userptr, "glTranslatef");
5273 glad_glVertex2d = (PFNGLVERTEX2DPROC) load(userptr, "glVertex2d");
5274 glad_glVertex2dv = (PFNGLVERTEX2DVPROC) load(userptr, "glVertex2dv");
5275 glad_glVertex2f = (PFNGLVERTEX2FPROC) load(userptr, "glVertex2f");
5276 glad_glVertex2fv = (PFNGLVERTEX2FVPROC) load(userptr, "glVertex2fv");
5277 glad_glVertex2i = (PFNGLVERTEX2IPROC) load(userptr, "glVertex2i");
5278 glad_glVertex2iv = (PFNGLVERTEX2IVPROC) load(userptr, "glVertex2iv");
5279 glad_glVertex2s = (PFNGLVERTEX2SPROC) load(userptr, "glVertex2s");
5280 glad_glVertex2sv = (PFNGLVERTEX2SVPROC) load(userptr, "glVertex2sv");
5281 glad_glVertex3d = (PFNGLVERTEX3DPROC) load(userptr, "glVertex3d");
5282 glad_glVertex3dv = (PFNGLVERTEX3DVPROC) load(userptr, "glVertex3dv");
5283 glad_glVertex3f = (PFNGLVERTEX3FPROC) load(userptr, "glVertex3f");
5284 glad_glVertex3fv = (PFNGLVERTEX3FVPROC) load(userptr, "glVertex3fv");
5285 glad_glVertex3i = (PFNGLVERTEX3IPROC) load(userptr, "glVertex3i");
5286 glad_glVertex3iv = (PFNGLVERTEX3IVPROC) load(userptr, "glVertex3iv");
5287 glad_glVertex3s = (PFNGLVERTEX3SPROC) load(userptr, "glVertex3s");
5288 glad_glVertex3sv = (PFNGLVERTEX3SVPROC) load(userptr, "glVertex3sv");
5289 glad_glVertex4d = (PFNGLVERTEX4DPROC) load(userptr, "glVertex4d");
5290 glad_glVertex4dv = (PFNGLVERTEX4DVPROC) load(userptr, "glVertex4dv");
5291 glad_glVertex4f = (PFNGLVERTEX4FPROC) load(userptr, "glVertex4f");
5292 glad_glVertex4fv = (PFNGLVERTEX4FVPROC) load(userptr, "glVertex4fv");
5293 glad_glVertex4i = (PFNGLVERTEX4IPROC) load(userptr, "glVertex4i");
5294 glad_glVertex4iv = (PFNGLVERTEX4IVPROC) load(userptr, "glVertex4iv");
5295 glad_glVertex4s = (PFNGLVERTEX4SPROC) load(userptr, "glVertex4s");
5296 glad_glVertex4sv = (PFNGLVERTEX4SVPROC) load(userptr, "glVertex4sv");
5297 glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
5298}
5299static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
5300 if(!GLAD_GL_VERSION_1_1) return;
5301 glad_glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC) load(userptr, "glAreTexturesResident");
5302 glad_glArrayElement = (PFNGLARRAYELEMENTPROC) load(userptr, "glArrayElement");
5303 glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
5304 glad_glColorPointer = (PFNGLCOLORPOINTERPROC) load(userptr, "glColorPointer");
5305 glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load(userptr, "glCopyTexImage1D");
5306 glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
5307 glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load(userptr, "glCopyTexSubImage1D");
5308 glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
5309 glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
5310 glad_glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC) load(userptr, "glDisableClientState");
5311 glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
5312 glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
5313 glad_glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC) load(userptr, "glEdgeFlagPointer");
5314 glad_glEnableClientState = (PFNGLENABLECLIENTSTATEPROC) load(userptr, "glEnableClientState");
5315 glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
5316 glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv");
5317 glad_glIndexPointer = (PFNGLINDEXPOINTERPROC) load(userptr, "glIndexPointer");
5318 glad_glIndexub = (PFNGLINDEXUBPROC) load(userptr, "glIndexub");
5319 glad_glIndexubv = (PFNGLINDEXUBVPROC) load(userptr, "glIndexubv");
5320 glad_glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC) load(userptr, "glInterleavedArrays");
5321 glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
5322 glad_glNormalPointer = (PFNGLNORMALPOINTERPROC) load(userptr, "glNormalPointer");
5323 glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
5324 glad_glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC) load(userptr, "glPopClientAttrib");
5325 glad_glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC) load(userptr, "glPrioritizeTextures");
5326 glad_glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC) load(userptr, "glPushClientAttrib");
5327 glad_glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC) load(userptr, "glTexCoordPointer");
5328 glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load(userptr, "glTexSubImage1D");
5329 glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
5330 glad_glVertexPointer = (PFNGLVERTEXPOINTERPROC) load(userptr, "glVertexPointer");
5331}
5332static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) {
5333 if(!GLAD_GL_VERSION_1_2) return;
5334 glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load(userptr, "glCopyTexSubImage3D");
5335 glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load(userptr, "glDrawRangeElements");
5336 glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC) load(userptr, "glTexImage3D");
5337 glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load(userptr, "glTexSubImage3D");
5338}
5339static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) {
5340 if(!GLAD_GL_VERSION_1_3) return;
5341 glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
5342 glad_glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC) load(userptr, "glClientActiveTexture");
5343 glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load(userptr, "glCompressedTexImage1D");
5344 glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
5345 glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load(userptr, "glCompressedTexImage3D");
5346 glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load(userptr, "glCompressedTexSubImage1D");
5347 glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
5348 glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load(userptr, "glCompressedTexSubImage3D");
5349 glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load(userptr, "glGetCompressedTexImage");
5350 glad_glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC) load(userptr, "glLoadTransposeMatrixd");
5351 glad_glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC) load(userptr, "glLoadTransposeMatrixf");
5352 glad_glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC) load(userptr, "glMultTransposeMatrixd");
5353 glad_glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC) load(userptr, "glMultTransposeMatrixf");
5354 glad_glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) load(userptr, "glMultiTexCoord1d");
5355 glad_glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC) load(userptr, "glMultiTexCoord1dv");
5356 glad_glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) load(userptr, "glMultiTexCoord1f");
5357 glad_glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC) load(userptr, "glMultiTexCoord1fv");
5358 glad_glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC) load(userptr, "glMultiTexCoord1i");
5359 glad_glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC) load(userptr, "glMultiTexCoord1iv");
5360 glad_glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC) load(userptr, "glMultiTexCoord1s");
5361 glad_glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC) load(userptr, "glMultiTexCoord1sv");
5362 glad_glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) load(userptr, "glMultiTexCoord2d");
5363 glad_glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC) load(userptr, "glMultiTexCoord2dv");
5364 glad_glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) load(userptr, "glMultiTexCoord2f");
5365 glad_glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) load(userptr, "glMultiTexCoord2fv");
5366 glad_glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC) load(userptr, "glMultiTexCoord2i");
5367 glad_glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC) load(userptr, "glMultiTexCoord2iv");
5368 glad_glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC) load(userptr, "glMultiTexCoord2s");
5369 glad_glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC) load(userptr, "glMultiTexCoord2sv");
5370 glad_glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) load(userptr, "glMultiTexCoord3d");
5371 glad_glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC) load(userptr, "glMultiTexCoord3dv");
5372 glad_glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) load(userptr, "glMultiTexCoord3f");
5373 glad_glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC) load(userptr, "glMultiTexCoord3fv");
5374 glad_glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC) load(userptr, "glMultiTexCoord3i");
5375 glad_glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC) load(userptr, "glMultiTexCoord3iv");
5376 glad_glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC) load(userptr, "glMultiTexCoord3s");
5377 glad_glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC) load(userptr, "glMultiTexCoord3sv");
5378 glad_glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) load(userptr, "glMultiTexCoord4d");
5379 glad_glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC) load(userptr, "glMultiTexCoord4dv");
5380 glad_glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) load(userptr, "glMultiTexCoord4f");
5381 glad_glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC) load(userptr, "glMultiTexCoord4fv");
5382 glad_glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC) load(userptr, "glMultiTexCoord4i");
5383 glad_glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC) load(userptr, "glMultiTexCoord4iv");
5384 glad_glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC) load(userptr, "glMultiTexCoord4s");
5385 glad_glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC) load(userptr, "glMultiTexCoord4sv");
5386 glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
5387}
5388static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) {
5389 if(!GLAD_GL_VERSION_1_4) return;
5390 glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor");
5391 glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation");
5392 glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate");
5393 glad_glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC) load(userptr, "glFogCoordPointer");
5394 glad_glFogCoordd = (PFNGLFOGCOORDDPROC) load(userptr, "glFogCoordd");
5395 glad_glFogCoorddv = (PFNGLFOGCOORDDVPROC) load(userptr, "glFogCoorddv");
5396 glad_glFogCoordf = (PFNGLFOGCOORDFPROC) load(userptr, "glFogCoordf");
5397 glad_glFogCoordfv = (PFNGLFOGCOORDFVPROC) load(userptr, "glFogCoordfv");
5398 glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load(userptr, "glMultiDrawArrays");
5399 glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load(userptr, "glMultiDrawElements");
5400 glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load(userptr, "glPointParameterf");
5401 glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load(userptr, "glPointParameterfv");
5402 glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load(userptr, "glPointParameteri");
5403 glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load(userptr, "glPointParameteriv");
5404 glad_glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC) load(userptr, "glSecondaryColor3b");
5405 glad_glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC) load(userptr, "glSecondaryColor3bv");
5406 glad_glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC) load(userptr, "glSecondaryColor3d");
5407 glad_glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC) load(userptr, "glSecondaryColor3dv");
5408 glad_glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC) load(userptr, "glSecondaryColor3f");
5409 glad_glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC) load(userptr, "glSecondaryColor3fv");
5410 glad_glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC) load(userptr, "glSecondaryColor3i");
5411 glad_glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC) load(userptr, "glSecondaryColor3iv");
5412 glad_glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC) load(userptr, "glSecondaryColor3s");
5413 glad_glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC) load(userptr, "glSecondaryColor3sv");
5414 glad_glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC) load(userptr, "glSecondaryColor3ub");
5415 glad_glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC) load(userptr, "glSecondaryColor3ubv");
5416 glad_glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC) load(userptr, "glSecondaryColor3ui");
5417 glad_glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC) load(userptr, "glSecondaryColor3uiv");
5418 glad_glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC) load(userptr, "glSecondaryColor3us");
5419 glad_glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC) load(userptr, "glSecondaryColor3usv");
5420 glad_glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) load(userptr, "glSecondaryColorPointer");
5421 glad_glWindowPos2d = (PFNGLWINDOWPOS2DPROC) load(userptr, "glWindowPos2d");
5422 glad_glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC) load(userptr, "glWindowPos2dv");
5423 glad_glWindowPos2f = (PFNGLWINDOWPOS2FPROC) load(userptr, "glWindowPos2f");
5424 glad_glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC) load(userptr, "glWindowPos2fv");
5425 glad_glWindowPos2i = (PFNGLWINDOWPOS2IPROC) load(userptr, "glWindowPos2i");
5426 glad_glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC) load(userptr, "glWindowPos2iv");
5427 glad_glWindowPos2s = (PFNGLWINDOWPOS2SPROC) load(userptr, "glWindowPos2s");
5428 glad_glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC) load(userptr, "glWindowPos2sv");
5429 glad_glWindowPos3d = (PFNGLWINDOWPOS3DPROC) load(userptr, "glWindowPos3d");
5430 glad_glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC) load(userptr, "glWindowPos3dv");
5431 glad_glWindowPos3f = (PFNGLWINDOWPOS3FPROC) load(userptr, "glWindowPos3f");
5432 glad_glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC) load(userptr, "glWindowPos3fv");
5433 glad_glWindowPos3i = (PFNGLWINDOWPOS3IPROC) load(userptr, "glWindowPos3i");
5434 glad_glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC) load(userptr, "glWindowPos3iv");
5435 glad_glWindowPos3s = (PFNGLWINDOWPOS3SPROC) load(userptr, "glWindowPos3s");
5436 glad_glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC) load(userptr, "glWindowPos3sv");
5437}
5438static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) {
5439 if(!GLAD_GL_VERSION_1_5) return;
5440 glad_glBeginQuery = (PFNGLBEGINQUERYPROC) load(userptr, "glBeginQuery");
5441 glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
5442 glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
5443 glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
5444 glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
5445 glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC) load(userptr, "glDeleteQueries");
5446 glad_glEndQuery = (PFNGLENDQUERYPROC) load(userptr, "glEndQuery");
5447 glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
5448 glad_glGenQueries = (PFNGLGENQUERIESPROC) load(userptr, "glGenQueries");
5449 glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
5450 glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load(userptr, "glGetBufferPointerv");
5451 glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load(userptr, "glGetBufferSubData");
5452 glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load(userptr, "glGetQueryObjectiv");
5453 glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load(userptr, "glGetQueryObjectuiv");
5454 glad_glGetQueryiv = (PFNGLGETQUERYIVPROC) load(userptr, "glGetQueryiv");
5455 glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
5456 glad_glIsQuery = (PFNGLISQUERYPROC) load(userptr, "glIsQuery");
5457 glad_glMapBuffer = (PFNGLMAPBUFFERPROC) load(userptr, "glMapBuffer");
5458 glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load(userptr, "glUnmapBuffer");
5459}
5460static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
5461 if(!GLAD_GL_VERSION_2_0) return;
5462 glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader");
5463 glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation");
5464 glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate");
5465 glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader");
5466 glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram");
5467 glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader");
5468 glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram");
5469 glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader");
5470 glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader");
5471 glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray");
5472 glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load(userptr, "glDrawBuffers");
5473 glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray");
5474 glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib");
5475 glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform");
5476 glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders");
5477 glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation");
5478 glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog");
5479 glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv");
5480 glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog");
5481 glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource");
5482 glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv");
5483 glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation");
5484 glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv");
5485 glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv");
5486 glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv");
5487 glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load(userptr, "glGetVertexAttribdv");
5488 glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv");
5489 glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv");
5490 glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram");
5491 glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader");
5492 glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram");
5493 glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource");
5494 glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate");
5495 glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate");
5496 glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate");
5497 glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f");
5498 glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv");
5499 glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i");
5500 glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv");
5501 glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f");
5502 glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv");
5503 glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i");
5504 glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv");
5505 glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f");
5506 glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv");
5507 glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i");
5508 glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv");
5509 glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f");
5510 glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv");
5511 glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i");
5512 glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv");
5513 glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv");
5514 glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv");
5515 glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv");
5516 glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram");
5517 glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram");
5518 glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load(userptr, "glVertexAttrib1d");
5519 glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load(userptr, "glVertexAttrib1dv");
5520 glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f");
5521 glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv");
5522 glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load(userptr, "glVertexAttrib1s");
5523 glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load(userptr, "glVertexAttrib1sv");
5524 glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load(userptr, "glVertexAttrib2d");
5525 glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load(userptr, "glVertexAttrib2dv");
5526 glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f");
5527 glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv");
5528 glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load(userptr, "glVertexAttrib2s");
5529 glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load(userptr, "glVertexAttrib2sv");
5530 glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load(userptr, "glVertexAttrib3d");
5531 glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load(userptr, "glVertexAttrib3dv");
5532 glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f");
5533 glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv");
5534 glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load(userptr, "glVertexAttrib3s");
5535 glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load(userptr, "glVertexAttrib3sv");
5536 glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load(userptr, "glVertexAttrib4Nbv");
5537 glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load(userptr, "glVertexAttrib4Niv");
5538 glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load(userptr, "glVertexAttrib4Nsv");
5539 glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load(userptr, "glVertexAttrib4Nub");
5540 glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load(userptr, "glVertexAttrib4Nubv");
5541 glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load(userptr, "glVertexAttrib4Nuiv");
5542 glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load(userptr, "glVertexAttrib4Nusv");
5543 glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load(userptr, "glVertexAttrib4bv");
5544 glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load(userptr, "glVertexAttrib4d");
5545 glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load(userptr, "glVertexAttrib4dv");
5546 glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f");
5547 glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv");
5548 glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load(userptr, "glVertexAttrib4iv");
5549 glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load(userptr, "glVertexAttrib4s");
5550 glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load(userptr, "glVertexAttrib4sv");
5551 glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load(userptr, "glVertexAttrib4ubv");
5552 glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load(userptr, "glVertexAttrib4uiv");
5553 glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load(userptr, "glVertexAttrib4usv");
5554 glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer");
5555}
5556static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) {
5557 if(!GLAD_GL_VERSION_2_1) return;
5558 glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load(userptr, "glUniformMatrix2x3fv");
5559 glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load(userptr, "glUniformMatrix2x4fv");
5560 glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load(userptr, "glUniformMatrix3x2fv");
5561 glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load(userptr, "glUniformMatrix3x4fv");
5562 glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load(userptr, "glUniformMatrix4x2fv");
5563 glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load(userptr, "glUniformMatrix4x3fv");
5564}
5565static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) {
5566 if(!GLAD_GL_VERSION_3_0) return;
5567 glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load(userptr, "glBeginConditionalRender");
5568 glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load(userptr, "glBeginTransformFeedback");
5569 glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase");
5570 glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange");
5571 glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load(userptr, "glBindFragDataLocation");
5572 glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
5573 glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
5574 glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load(userptr, "glBindVertexArray");
5575 glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load(userptr, "glBlitFramebuffer");
5576 glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
5577 glad_glClampColor = (PFNGLCLAMPCOLORPROC) load(userptr, "glClampColor");
5578 glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load(userptr, "glClearBufferfi");
5579 glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load(userptr, "glClearBufferfv");
5580 glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load(userptr, "glClearBufferiv");
5581 glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load(userptr, "glClearBufferuiv");
5582 glad_glColorMaski = (PFNGLCOLORMASKIPROC) load(userptr, "glColorMaski");
5583 glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
5584 glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
5585 glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load(userptr, "glDeleteVertexArrays");
5586 glad_glDisablei = (PFNGLDISABLEIPROC) load(userptr, "glDisablei");
5587 glad_glEnablei = (PFNGLENABLEIPROC) load(userptr, "glEnablei");
5588 glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load(userptr, "glEndConditionalRender");
5589 glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load(userptr, "glEndTransformFeedback");
5590 glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load(userptr, "glFlushMappedBufferRange");
5591 glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
5592 glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load(userptr, "glFramebufferTexture1D");
5593 glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
5594 glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load(userptr, "glFramebufferTexture3D");
5595 glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load(userptr, "glFramebufferTextureLayer");
5596 glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
5597 glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
5598 glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load(userptr, "glGenVertexArrays");
5599 glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
5600 glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load(userptr, "glGetBooleani_v");
5601 glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load(userptr, "glGetFragDataLocation");
5602 glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
5603 glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v");
5604 glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
5605 glad_glGetStringi = (PFNGLGETSTRINGIPROC) load(userptr, "glGetStringi");
5606 glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load(userptr, "glGetTexParameterIiv");
5607 glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load(userptr, "glGetTexParameterIuiv");
5608 glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load(userptr, "glGetTransformFeedbackVarying");
5609 glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load(userptr, "glGetUniformuiv");
5610 glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load(userptr, "glGetVertexAttribIiv");
5611 glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load(userptr, "glGetVertexAttribIuiv");
5612 glad_glIsEnabledi = (PFNGLISENABLEDIPROC) load(userptr, "glIsEnabledi");
5613 glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
5614 glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
5615 glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load(userptr, "glIsVertexArray");
5616 glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load(userptr, "glMapBufferRange");
5617 glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
5618 glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load(userptr, "glRenderbufferStorageMultisample");
5619 glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load(userptr, "glTexParameterIiv");
5620 glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load(userptr, "glTexParameterIuiv");
5621 glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load(userptr, "glTransformFeedbackVaryings");
5622 glad_glUniform1ui = (PFNGLUNIFORM1UIPROC) load(userptr, "glUniform1ui");
5623 glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load(userptr, "glUniform1uiv");
5624 glad_glUniform2ui = (PFNGLUNIFORM2UIPROC) load(userptr, "glUniform2ui");
5625 glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load(userptr, "glUniform2uiv");
5626 glad_glUniform3ui = (PFNGLUNIFORM3UIPROC) load(userptr, "glUniform3ui");
5627 glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load(userptr, "glUniform3uiv");
5628 glad_glUniform4ui = (PFNGLUNIFORM4UIPROC) load(userptr, "glUniform4ui");
5629 glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load(userptr, "glUniform4uiv");
5630 glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load(userptr, "glVertexAttribI1i");
5631 glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load(userptr, "glVertexAttribI1iv");
5632 glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load(userptr, "glVertexAttribI1ui");
5633 glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load(userptr, "glVertexAttribI1uiv");
5634 glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load(userptr, "glVertexAttribI2i");
5635 glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load(userptr, "glVertexAttribI2iv");
5636 glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load(userptr, "glVertexAttribI2ui");
5637 glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load(userptr, "glVertexAttribI2uiv");
5638 glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load(userptr, "glVertexAttribI3i");
5639 glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load(userptr, "glVertexAttribI3iv");
5640 glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load(userptr, "glVertexAttribI3ui");
5641 glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load(userptr, "glVertexAttribI3uiv");
5642 glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load(userptr, "glVertexAttribI4bv");
5643 glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load(userptr, "glVertexAttribI4i");
5644 glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load(userptr, "glVertexAttribI4iv");
5645 glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load(userptr, "glVertexAttribI4sv");
5646 glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load(userptr, "glVertexAttribI4ubv");
5647 glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load(userptr, "glVertexAttribI4ui");
5648 glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load(userptr, "glVertexAttribI4uiv");
5649 glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load(userptr, "glVertexAttribI4usv");
5650 glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load(userptr, "glVertexAttribIPointer");
5651}
5652static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) {
5653 if(!GLAD_GL_VERSION_3_1) return;
5654 glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase");
5655 glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange");
5656 glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load(userptr, "glCopyBufferSubData");
5657 glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load(userptr, "glDrawArraysInstanced");
5658 glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load(userptr, "glDrawElementsInstanced");
5659 glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load(userptr, "glGetActiveUniformBlockName");
5660 glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load(userptr, "glGetActiveUniformBlockiv");
5661 glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load(userptr, "glGetActiveUniformName");
5662 glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load(userptr, "glGetActiveUniformsiv");
5663 glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v");
5664 glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load(userptr, "glGetUniformBlockIndex");
5665 glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load(userptr, "glGetUniformIndices");
5666 glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load(userptr, "glPrimitiveRestartIndex");
5667 glad_glTexBuffer = (PFNGLTEXBUFFERPROC) load(userptr, "glTexBuffer");
5668 glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load(userptr, "glUniformBlockBinding");
5669}
5670static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) {
5671 if(!GLAD_GL_VERSION_3_2) return;
5672 glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load(userptr, "glClientWaitSync");
5673 glad_glDeleteSync = (PFNGLDELETESYNCPROC) load(userptr, "glDeleteSync");
5674 glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glDrawElementsBaseVertex");
5675 glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load(userptr, "glDrawElementsInstancedBaseVertex");
5676 glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load(userptr, "glDrawRangeElementsBaseVertex");
5677 glad_glFenceSync = (PFNGLFENCESYNCPROC) load(userptr, "glFenceSync");
5678 glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load(userptr, "glFramebufferTexture");
5679 glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load(userptr, "glGetBufferParameteri64v");
5680 glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load(userptr, "glGetInteger64i_v");
5681 glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC) load(userptr, "glGetInteger64v");
5682 glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load(userptr, "glGetMultisamplefv");
5683 glad_glGetSynciv = (PFNGLGETSYNCIVPROC) load(userptr, "glGetSynciv");
5684 glad_glIsSync = (PFNGLISSYNCPROC) load(userptr, "glIsSync");
5685 glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glMultiDrawElementsBaseVertex");
5686 glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load(userptr, "glProvokingVertex");
5687 glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC) load(userptr, "glSampleMaski");
5688 glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load(userptr, "glTexImage2DMultisample");
5689 glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load(userptr, "glTexImage3DMultisample");
5690 glad_glWaitSync = (PFNGLWAITSYNCPROC) load(userptr, "glWaitSync");
5691}
5692static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) {
5693 if(!GLAD_GL_VERSION_3_3) return;
5694 glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load(userptr, "glBindFragDataLocationIndexed");
5695 glad_glBindSampler = (PFNGLBINDSAMPLERPROC) load(userptr, "glBindSampler");
5696 glad_glColorP3ui = (PFNGLCOLORP3UIPROC) load(userptr, "glColorP3ui");
5697 glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC) load(userptr, "glColorP3uiv");
5698 glad_glColorP4ui = (PFNGLCOLORP4UIPROC) load(userptr, "glColorP4ui");
5699 glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC) load(userptr, "glColorP4uiv");
5700 glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load(userptr, "glDeleteSamplers");
5701 glad_glGenSamplers = (PFNGLGENSAMPLERSPROC) load(userptr, "glGenSamplers");
5702 glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load(userptr, "glGetFragDataIndex");
5703 glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load(userptr, "glGetQueryObjecti64v");
5704 glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load(userptr, "glGetQueryObjectui64v");
5705 glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load(userptr, "glGetSamplerParameterIiv");
5706 glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load(userptr, "glGetSamplerParameterIuiv");
5707 glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load(userptr, "glGetSamplerParameterfv");
5708 glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load(userptr, "glGetSamplerParameteriv");
5709 glad_glIsSampler = (PFNGLISSAMPLERPROC) load(userptr, "glIsSampler");
5710 glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC) load(userptr, "glMultiTexCoordP1ui");
5711 glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC) load(userptr, "glMultiTexCoordP1uiv");
5712 glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC) load(userptr, "glMultiTexCoordP2ui");
5713 glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC) load(userptr, "glMultiTexCoordP2uiv");
5714 glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC) load(userptr, "glMultiTexCoordP3ui");
5715 glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC) load(userptr, "glMultiTexCoordP3uiv");
5716 glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC) load(userptr, "glMultiTexCoordP4ui");
5717 glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC) load(userptr, "glMultiTexCoordP4uiv");
5718 glad_glNormalP3ui = (PFNGLNORMALP3UIPROC) load(userptr, "glNormalP3ui");
5719 glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC) load(userptr, "glNormalP3uiv");
5720 glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC) load(userptr, "glQueryCounter");
5721 glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load(userptr, "glSamplerParameterIiv");
5722 glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load(userptr, "glSamplerParameterIuiv");
5723 glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load(userptr, "glSamplerParameterf");
5724 glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load(userptr, "glSamplerParameterfv");
5725 glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load(userptr, "glSamplerParameteri");
5726 glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load(userptr, "glSamplerParameteriv");
5727 glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC) load(userptr, "glSecondaryColorP3ui");
5728 glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC) load(userptr, "glSecondaryColorP3uiv");
5729 glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC) load(userptr, "glTexCoordP1ui");
5730 glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC) load(userptr, "glTexCoordP1uiv");
5731 glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC) load(userptr, "glTexCoordP2ui");
5732 glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC) load(userptr, "glTexCoordP2uiv");
5733 glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC) load(userptr, "glTexCoordP3ui");
5734 glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC) load(userptr, "glTexCoordP3uiv");
5735 glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC) load(userptr, "glTexCoordP4ui");
5736 glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC) load(userptr, "glTexCoordP4uiv");
5737 glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load(userptr, "glVertexAttribDivisor");
5738 glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load(userptr, "glVertexAttribP1ui");
5739 glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load(userptr, "glVertexAttribP1uiv");
5740 glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load(userptr, "glVertexAttribP2ui");
5741 glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load(userptr, "glVertexAttribP2uiv");
5742 glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load(userptr, "glVertexAttribP3ui");
5743 glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load(userptr, "glVertexAttribP3uiv");
5744 glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load(userptr, "glVertexAttribP4ui");
5745 glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load(userptr, "glVertexAttribP4uiv");
5746 glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC) load(userptr, "glVertexP2ui");
5747 glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC) load(userptr, "glVertexP2uiv");
5748 glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC) load(userptr, "glVertexP3ui");
5749 glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC) load(userptr, "glVertexP3uiv");
5750 glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC) load(userptr, "glVertexP4ui");
5751 glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC) load(userptr, "glVertexP4uiv");
5752}
5753static void glad_gl_load_GL_ARB_multisample( GLADuserptrloadfunc load, void* userptr) {
5754 if(!GLAD_GL_ARB_multisample) return;
5755 glad_glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC) load(userptr, "glSampleCoverageARB");
5756}
5757static void glad_gl_load_GL_ARB_robustness( GLADuserptrloadfunc load, void* userptr) {
5758 if(!GLAD_GL_ARB_robustness) return;
5759 glad_glGetGraphicsResetStatusARB = (PFNGLGETGRAPHICSRESETSTATUSARBPROC) load(userptr, "glGetGraphicsResetStatusARB");
5760 glad_glGetnColorTableARB = (PFNGLGETNCOLORTABLEARBPROC) load(userptr, "glGetnColorTableARB");
5761 glad_glGetnCompressedTexImageARB = (PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) load(userptr, "glGetnCompressedTexImageARB");
5762 glad_glGetnConvolutionFilterARB = (PFNGLGETNCONVOLUTIONFILTERARBPROC) load(userptr, "glGetnConvolutionFilterARB");
5763 glad_glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC) load(userptr, "glGetnHistogramARB");
5764 glad_glGetnMapdvARB = (PFNGLGETNMAPDVARBPROC) load(userptr, "glGetnMapdvARB");
5765 glad_glGetnMapfvARB = (PFNGLGETNMAPFVARBPROC) load(userptr, "glGetnMapfvARB");
5766 glad_glGetnMapivARB = (PFNGLGETNMAPIVARBPROC) load(userptr, "glGetnMapivARB");
5767 glad_glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC) load(userptr, "glGetnMinmaxARB");
5768 glad_glGetnPixelMapfvARB = (PFNGLGETNPIXELMAPFVARBPROC) load(userptr, "glGetnPixelMapfvARB");
5769 glad_glGetnPixelMapuivARB = (PFNGLGETNPIXELMAPUIVARBPROC) load(userptr, "glGetnPixelMapuivARB");
5770 glad_glGetnPixelMapusvARB = (PFNGLGETNPIXELMAPUSVARBPROC) load(userptr, "glGetnPixelMapusvARB");
5771 glad_glGetnPolygonStippleARB = (PFNGLGETNPOLYGONSTIPPLEARBPROC) load(userptr, "glGetnPolygonStippleARB");
5772 glad_glGetnSeparableFilterARB = (PFNGLGETNSEPARABLEFILTERARBPROC) load(userptr, "glGetnSeparableFilterARB");
5773 glad_glGetnTexImageARB = (PFNGLGETNTEXIMAGEARBPROC) load(userptr, "glGetnTexImageARB");
5774 glad_glGetnUniformdvARB = (PFNGLGETNUNIFORMDVARBPROC) load(userptr, "glGetnUniformdvARB");
5775 glad_glGetnUniformfvARB = (PFNGLGETNUNIFORMFVARBPROC) load(userptr, "glGetnUniformfvARB");
5776 glad_glGetnUniformivARB = (PFNGLGETNUNIFORMIVARBPROC) load(userptr, "glGetnUniformivARB");
5777 glad_glGetnUniformuivARB = (PFNGLGETNUNIFORMUIVARBPROC) load(userptr, "glGetnUniformuivARB");
5778 glad_glReadnPixelsARB = (PFNGLREADNPIXELSARBPROC) load(userptr, "glReadnPixelsARB");
5779}
5780static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
5781 if(!GLAD_GL_KHR_debug) return;
5782 glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load(userptr, "glDebugMessageCallback");
5783 glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load(userptr, "glDebugMessageControl");
5784 glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load(userptr, "glDebugMessageInsert");
5785 glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load(userptr, "glGetDebugMessageLog");
5786 glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load(userptr, "glGetObjectLabel");
5787 glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load(userptr, "glGetObjectPtrLabel");
5788 glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv");
5789 glad_glObjectLabel = (PFNGLOBJECTLABELPROC) load(userptr, "glObjectLabel");
5790 glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load(userptr, "glObjectPtrLabel");
5791 glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load(userptr, "glPopDebugGroup");
5792 glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load(userptr, "glPushDebugGroup");
5793}
5794
5795
5796
5797#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
5798#define GLAD_GL_IS_SOME_NEW_VERSION 1
5799#else
5800#define GLAD_GL_IS_SOME_NEW_VERSION 0
5801#endif
5802
5803static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
5804#if GLAD_GL_IS_SOME_NEW_VERSION
5805 if(GLAD_VERSION_MAJOR(version) < 3) {
5806#else
5807 (void) version;
5808 (void) out_num_exts_i;
5809 (void) out_exts_i;
5810#endif
5811 if (glad_glGetString == NULL) {
5812 return 0;
5813 }
5814 *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS);
5815#if GLAD_GL_IS_SOME_NEW_VERSION
5816 } else {
5817 unsigned int index = 0;
5818 unsigned int num_exts_i = 0;
5819 char **exts_i = NULL;
5820 if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) {
5821 return 0;
5822 }
5823 glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
5824 if (num_exts_i > 0) {
5825 exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
5826 }
5827 if (exts_i == NULL) {
5828 return 0;
5829 }
5830 for(index = 0; index < num_exts_i; index++) {
5831 const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index);
5832 size_t len = strlen(gl_str_tmp) + 1;
5833
5834 char *local_str = (char*) malloc(len * sizeof(char));
5835 if(local_str != NULL) {
5836 memcpy(local_str, gl_str_tmp, len * sizeof(char));
5837 }
5838
5839 exts_i[index] = local_str;
5840 }
5841
5842 *out_num_exts_i = num_exts_i;
5843 *out_exts_i = exts_i;
5844 }
5845#endif
5846 return 1;
5847}
5848static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
5849 if (exts_i != NULL) {
5850 unsigned int index;
5851 for(index = 0; index < num_exts_i; index++) {
5852 free((void *) (exts_i[index]));
5853 }
5854 free((void *)exts_i);
5855 exts_i = NULL;
5856 }
5857}
5858static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
5859 if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
5860 const char *extensions;
5861 const char *loc;
5862 const char *terminator;
5863 extensions = exts;
5864 if(extensions == NULL || ext == NULL) {
5865 return 0;
5866 }
5867 while(1) {
5868 loc = strstr(extensions, ext);
5869 if(loc == NULL) {
5870 return 0;
5871 }
5872 terminator = loc + strlen(ext);
5873 if((loc == extensions || *(loc - 1) == ' ') &&
5874 (*terminator == ' ' || *terminator == '\0')) {
5875 return 1;
5876 }
5877 extensions = terminator;
5878 }
5879 } else {
5880 unsigned int index;
5881 for(index = 0; index < num_exts_i; index++) {
5882 const char *e = exts_i[index];
5883 if(strcmp(e, ext) == 0) {
5884 return 1;
5885 }
5886 }
5887 }
5888 return 0;
5889}
5890
5891static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
5892 return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
5893}
5894
5895static int glad_gl_find_extensions_gl( int version) {
5896 const char *exts = NULL;
5897 unsigned int num_exts_i = 0;
5898 char **exts_i = NULL;
5899 if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
5900
5901 GLAD_GL_ARB_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multisample");
5902 GLAD_GL_ARB_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_robustness");
5903 GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug");
5904
5905 glad_gl_free_extensions(exts_i, num_exts_i);
5906
5907 return 1;
5908}
5909
5910static int glad_gl_find_core_gl(void) {
5911 int i;
5912 const char* version;
5913 const char* prefixes[] = {
5914 "OpenGL ES-CM ",
5915 "OpenGL ES-CL ",
5916 "OpenGL ES ",
5917 "OpenGL SC ",
5918 NULL
5919 };
5920 int major = 0;
5921 int minor = 0;
5922 version = (const char*) glad_glGetString(GL_VERSION);
5923 if (!version) return 0;
5924 for (i = 0; prefixes[i]; i++) {
5925 const size_t length = strlen(prefixes[i]);
5926 if (strncmp(version, prefixes[i], length) == 0) {
5927 version += length;
5928 break;
5929 }
5930 }
5931
5932 GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
5933
5934 GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
5935 GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
5936 GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
5937 GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
5938 GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
5939 GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
5940 GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
5941 GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
5942 GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
5943 GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
5944 GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
5945 GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
5946
5947 return GLAD_MAKE_VERSION(major, minor);
5948}
5949
5950int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) {
5951 int version;
5952
5953 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
5954 if(glad_glGetString == NULL) return 0;
5955 if(glad_glGetString(GL_VERSION) == NULL) return 0;
5956 version = glad_gl_find_core_gl();
5957
5958 glad_gl_load_GL_VERSION_1_0(load, userptr);
5959 glad_gl_load_GL_VERSION_1_1(load, userptr);
5960 glad_gl_load_GL_VERSION_1_2(load, userptr);
5961 glad_gl_load_GL_VERSION_1_3(load, userptr);
5962 glad_gl_load_GL_VERSION_1_4(load, userptr);
5963 glad_gl_load_GL_VERSION_1_5(load, userptr);
5964 glad_gl_load_GL_VERSION_2_0(load, userptr);
5965 glad_gl_load_GL_VERSION_2_1(load, userptr);
5966 glad_gl_load_GL_VERSION_3_0(load, userptr);
5967 glad_gl_load_GL_VERSION_3_1(load, userptr);
5968 glad_gl_load_GL_VERSION_3_2(load, userptr);
5969 glad_gl_load_GL_VERSION_3_3(load, userptr);
5970
5971 if (!glad_gl_find_extensions_gl(version)) return 0;
5972 glad_gl_load_GL_ARB_multisample(load, userptr);
5973 glad_gl_load_GL_ARB_robustness(load, userptr);
5974 glad_gl_load_GL_KHR_debug(load, userptr);
5975
5976
5977
5978 return version;
5979}
5980
5981
5982int gladLoadGL( GLADloadfunc load) {
5983 return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
5984}
5985
5986
5987
5988
5989
5990
5991#ifdef __cplusplus
5992}
5993#endif
5994
5995#endif /* GLAD_GL_IMPLEMENTATION */
5996
diff --git a/raylib/src/external/glfw/deps/glad/gles2.h b/raylib/src/external/glfw/deps/glad/gles2.h
new file mode 100644
index 0000000..d67f110
--- /dev/null
+++ b/raylib/src/external/glfw/deps/glad/gles2.h
@@ -0,0 +1,1805 @@
1/**
2 * Loader generated by glad 2.0.0-beta on Tue Aug 24 22:51:42 2021
3 *
4 * Generator: C/C++
5 * Specification: gl
6 * Extensions: 0
7 *
8 * APIs:
9 * - gles2=2.0
10 *
11 * Options:
12 * - ALIAS = False
13 * - DEBUG = False
14 * - HEADER_ONLY = True
15 * - LOADER = False
16 * - MX = False
17 * - MX_GLOBAL = False
18 * - ON_DEMAND = False
19 *
20 * Commandline:
21 * --api='gles2=2.0' --extensions='' c --header-only
22 *
23 * Online:
24 * http://glad.sh/#api=gles2%3D2.0&extensions=&generator=c&options=HEADER_ONLY
25 *
26 */
27
28#ifndef GLAD_GLES2_H_
29#define GLAD_GLES2_H_
30
31#ifdef __clang__
32#pragma clang diagnostic push
33#pragma clang diagnostic ignored "-Wreserved-id-macro"
34#endif
35#ifdef __gl2_h_
36 #error OpenGL ES 2 header already included (API: gles2), remove previous include!
37#endif
38#define __gl2_h_ 1
39#ifdef __gl3_h_
40 #error OpenGL ES 3 header already included (API: gles2), remove previous include!
41#endif
42#define __gl3_h_ 1
43#ifdef __clang__
44#pragma clang diagnostic pop
45#endif
46
47#define GLAD_GLES2
48#define GLAD_OPTION_GLES2_HEADER_ONLY
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#ifndef GLAD_PLATFORM_H_
55#define GLAD_PLATFORM_H_
56
57#ifndef GLAD_PLATFORM_WIN32
58 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
59 #define GLAD_PLATFORM_WIN32 1
60 #else
61 #define GLAD_PLATFORM_WIN32 0
62 #endif
63#endif
64
65#ifndef GLAD_PLATFORM_APPLE
66 #ifdef __APPLE__
67 #define GLAD_PLATFORM_APPLE 1
68 #else
69 #define GLAD_PLATFORM_APPLE 0
70 #endif
71#endif
72
73#ifndef GLAD_PLATFORM_EMSCRIPTEN
74 #ifdef __EMSCRIPTEN__
75 #define GLAD_PLATFORM_EMSCRIPTEN 1
76 #else
77 #define GLAD_PLATFORM_EMSCRIPTEN 0
78 #endif
79#endif
80
81#ifndef GLAD_PLATFORM_UWP
82 #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
83 #ifdef __has_include
84 #if __has_include(<winapifamily.h>)
85 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
86 #endif
87 #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
88 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
89 #endif
90 #endif
91
92 #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
93 #include <winapifamily.h>
94 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
95 #define GLAD_PLATFORM_UWP 1
96 #endif
97 #endif
98
99 #ifndef GLAD_PLATFORM_UWP
100 #define GLAD_PLATFORM_UWP 0
101 #endif
102#endif
103
104#ifdef __GNUC__
105 #define GLAD_GNUC_EXTENSION __extension__
106#else
107 #define GLAD_GNUC_EXTENSION
108#endif
109
110#ifndef GLAD_API_CALL
111 #if defined(GLAD_API_CALL_EXPORT)
112 #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
113 #if defined(GLAD_API_CALL_EXPORT_BUILD)
114 #if defined(__GNUC__)
115 #define GLAD_API_CALL __attribute__ ((dllexport)) extern
116 #else
117 #define GLAD_API_CALL __declspec(dllexport) extern
118 #endif
119 #else
120 #if defined(__GNUC__)
121 #define GLAD_API_CALL __attribute__ ((dllimport)) extern
122 #else
123 #define GLAD_API_CALL __declspec(dllimport) extern
124 #endif
125 #endif
126 #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
127 #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
128 #else
129 #define GLAD_API_CALL extern
130 #endif
131 #else
132 #define GLAD_API_CALL extern
133 #endif
134#endif
135
136#ifdef APIENTRY
137 #define GLAD_API_PTR APIENTRY
138#elif GLAD_PLATFORM_WIN32
139 #define GLAD_API_PTR __stdcall
140#else
141 #define GLAD_API_PTR
142#endif
143
144#ifndef GLAPI
145#define GLAPI GLAD_API_CALL
146#endif
147
148#ifndef GLAPIENTRY
149#define GLAPIENTRY GLAD_API_PTR
150#endif
151
152#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
153#define GLAD_VERSION_MAJOR(version) (version / 10000)
154#define GLAD_VERSION_MINOR(version) (version % 10000)
155
156#define GLAD_GENERATOR_VERSION "2.0.0-beta"
157
158typedef void (*GLADapiproc)(void);
159
160typedef GLADapiproc (*GLADloadfunc)(const char *name);
161typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
162
163typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
164typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
165
166#endif /* GLAD_PLATFORM_H_ */
167
168#define GL_ACTIVE_ATTRIBUTES 0x8B89
169#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
170#define GL_ACTIVE_TEXTURE 0x84E0
171#define GL_ACTIVE_UNIFORMS 0x8B86
172#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
173#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
174#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
175#define GL_ALPHA 0x1906
176#define GL_ALPHA_BITS 0x0D55
177#define GL_ALWAYS 0x0207
178#define GL_ARRAY_BUFFER 0x8892
179#define GL_ARRAY_BUFFER_BINDING 0x8894
180#define GL_ATTACHED_SHADERS 0x8B85
181#define GL_BACK 0x0405
182#define GL_BLEND 0x0BE2
183#define GL_BLEND_COLOR 0x8005
184#define GL_BLEND_DST_ALPHA 0x80CA
185#define GL_BLEND_DST_RGB 0x80C8
186#define GL_BLEND_EQUATION 0x8009
187#define GL_BLEND_EQUATION_ALPHA 0x883D
188#define GL_BLEND_EQUATION_RGB 0x8009
189#define GL_BLEND_SRC_ALPHA 0x80CB
190#define GL_BLEND_SRC_RGB 0x80C9
191#define GL_BLUE_BITS 0x0D54
192#define GL_BOOL 0x8B56
193#define GL_BOOL_VEC2 0x8B57
194#define GL_BOOL_VEC3 0x8B58
195#define GL_BOOL_VEC4 0x8B59
196#define GL_BUFFER_SIZE 0x8764
197#define GL_BUFFER_USAGE 0x8765
198#define GL_BYTE 0x1400
199#define GL_CCW 0x0901
200#define GL_CLAMP_TO_EDGE 0x812F
201#define GL_COLOR_ATTACHMENT0 0x8CE0
202#define GL_COLOR_BUFFER_BIT 0x00004000
203#define GL_COLOR_CLEAR_VALUE 0x0C22
204#define GL_COLOR_WRITEMASK 0x0C23
205#define GL_COMPILE_STATUS 0x8B81
206#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
207#define GL_CONSTANT_ALPHA 0x8003
208#define GL_CONSTANT_COLOR 0x8001
209#define GL_CULL_FACE 0x0B44
210#define GL_CULL_FACE_MODE 0x0B45
211#define GL_CURRENT_PROGRAM 0x8B8D
212#define GL_CURRENT_VERTEX_ATTRIB 0x8626
213#define GL_CW 0x0900
214#define GL_DECR 0x1E03
215#define GL_DECR_WRAP 0x8508
216#define GL_DELETE_STATUS 0x8B80
217#define GL_DEPTH_ATTACHMENT 0x8D00
218#define GL_DEPTH_BITS 0x0D56
219#define GL_DEPTH_BUFFER_BIT 0x00000100
220#define GL_DEPTH_CLEAR_VALUE 0x0B73
221#define GL_DEPTH_COMPONENT 0x1902
222#define GL_DEPTH_COMPONENT16 0x81A5
223#define GL_DEPTH_FUNC 0x0B74
224#define GL_DEPTH_RANGE 0x0B70
225#define GL_DEPTH_TEST 0x0B71
226#define GL_DEPTH_WRITEMASK 0x0B72
227#define GL_DITHER 0x0BD0
228#define GL_DONT_CARE 0x1100
229#define GL_DST_ALPHA 0x0304
230#define GL_DST_COLOR 0x0306
231#define GL_DYNAMIC_DRAW 0x88E8
232#define GL_ELEMENT_ARRAY_BUFFER 0x8893
233#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
234#define GL_EQUAL 0x0202
235#define GL_EXTENSIONS 0x1F03
236#define GL_FALSE 0
237#define GL_FASTEST 0x1101
238#define GL_FIXED 0x140C
239#define GL_FLOAT 0x1406
240#define GL_FLOAT_MAT2 0x8B5A
241#define GL_FLOAT_MAT3 0x8B5B
242#define GL_FLOAT_MAT4 0x8B5C
243#define GL_FLOAT_VEC2 0x8B50
244#define GL_FLOAT_VEC3 0x8B51
245#define GL_FLOAT_VEC4 0x8B52
246#define GL_FRAGMENT_SHADER 0x8B30
247#define GL_FRAMEBUFFER 0x8D40
248#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
249#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
250#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
251#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
252#define GL_FRAMEBUFFER_BINDING 0x8CA6
253#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
254#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
255#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
256#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
257#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
258#define GL_FRONT 0x0404
259#define GL_FRONT_AND_BACK 0x0408
260#define GL_FRONT_FACE 0x0B46
261#define GL_FUNC_ADD 0x8006
262#define GL_FUNC_REVERSE_SUBTRACT 0x800B
263#define GL_FUNC_SUBTRACT 0x800A
264#define GL_GENERATE_MIPMAP_HINT 0x8192
265#define GL_GEQUAL 0x0206
266#define GL_GREATER 0x0204
267#define GL_GREEN_BITS 0x0D53
268#define GL_HIGH_FLOAT 0x8DF2
269#define GL_HIGH_INT 0x8DF5
270#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
271#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
272#define GL_INCR 0x1E02
273#define GL_INCR_WRAP 0x8507
274#define GL_INFO_LOG_LENGTH 0x8B84
275#define GL_INT 0x1404
276#define GL_INT_VEC2 0x8B53
277#define GL_INT_VEC3 0x8B54
278#define GL_INT_VEC4 0x8B55
279#define GL_INVALID_ENUM 0x0500
280#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
281#define GL_INVALID_OPERATION 0x0502
282#define GL_INVALID_VALUE 0x0501
283#define GL_INVERT 0x150A
284#define GL_KEEP 0x1E00
285#define GL_LEQUAL 0x0203
286#define GL_LESS 0x0201
287#define GL_LINEAR 0x2601
288#define GL_LINEAR_MIPMAP_LINEAR 0x2703
289#define GL_LINEAR_MIPMAP_NEAREST 0x2701
290#define GL_LINES 0x0001
291#define GL_LINE_LOOP 0x0002
292#define GL_LINE_STRIP 0x0003
293#define GL_LINE_WIDTH 0x0B21
294#define GL_LINK_STATUS 0x8B82
295#define GL_LOW_FLOAT 0x8DF0
296#define GL_LOW_INT 0x8DF3
297#define GL_LUMINANCE 0x1909
298#define GL_LUMINANCE_ALPHA 0x190A
299#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
300#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
301#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
302#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
303#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
304#define GL_MAX_TEXTURE_SIZE 0x0D33
305#define GL_MAX_VARYING_VECTORS 0x8DFC
306#define GL_MAX_VERTEX_ATTRIBS 0x8869
307#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
308#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
309#define GL_MAX_VIEWPORT_DIMS 0x0D3A
310#define GL_MEDIUM_FLOAT 0x8DF1
311#define GL_MEDIUM_INT 0x8DF4
312#define GL_MIRRORED_REPEAT 0x8370
313#define GL_NEAREST 0x2600
314#define GL_NEAREST_MIPMAP_LINEAR 0x2702
315#define GL_NEAREST_MIPMAP_NEAREST 0x2700
316#define GL_NEVER 0x0200
317#define GL_NICEST 0x1102
318#define GL_NONE 0
319#define GL_NOTEQUAL 0x0205
320#define GL_NO_ERROR 0
321#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
322#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
323#define GL_ONE 1
324#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
325#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
326#define GL_ONE_MINUS_DST_ALPHA 0x0305
327#define GL_ONE_MINUS_DST_COLOR 0x0307
328#define GL_ONE_MINUS_SRC_ALPHA 0x0303
329#define GL_ONE_MINUS_SRC_COLOR 0x0301
330#define GL_OUT_OF_MEMORY 0x0505
331#define GL_PACK_ALIGNMENT 0x0D05
332#define GL_POINTS 0x0000
333#define GL_POLYGON_OFFSET_FACTOR 0x8038
334#define GL_POLYGON_OFFSET_FILL 0x8037
335#define GL_POLYGON_OFFSET_UNITS 0x2A00
336#define GL_RED_BITS 0x0D52
337#define GL_RENDERBUFFER 0x8D41
338#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
339#define GL_RENDERBUFFER_BINDING 0x8CA7
340#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
341#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
342#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
343#define GL_RENDERBUFFER_HEIGHT 0x8D43
344#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
345#define GL_RENDERBUFFER_RED_SIZE 0x8D50
346#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
347#define GL_RENDERBUFFER_WIDTH 0x8D42
348#define GL_RENDERER 0x1F01
349#define GL_REPEAT 0x2901
350#define GL_REPLACE 0x1E01
351#define GL_RGB 0x1907
352#define GL_RGB565 0x8D62
353#define GL_RGB5_A1 0x8057
354#define GL_RGBA 0x1908
355#define GL_RGBA4 0x8056
356#define GL_SAMPLER_2D 0x8B5E
357#define GL_SAMPLER_CUBE 0x8B60
358#define GL_SAMPLES 0x80A9
359#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
360#define GL_SAMPLE_BUFFERS 0x80A8
361#define GL_SAMPLE_COVERAGE 0x80A0
362#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
363#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
364#define GL_SCISSOR_BOX 0x0C10
365#define GL_SCISSOR_TEST 0x0C11
366#define GL_SHADER_BINARY_FORMATS 0x8DF8
367#define GL_SHADER_COMPILER 0x8DFA
368#define GL_SHADER_SOURCE_LENGTH 0x8B88
369#define GL_SHADER_TYPE 0x8B4F
370#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
371#define GL_SHORT 0x1402
372#define GL_SRC_ALPHA 0x0302
373#define GL_SRC_ALPHA_SATURATE 0x0308
374#define GL_SRC_COLOR 0x0300
375#define GL_STATIC_DRAW 0x88E4
376#define GL_STENCIL_ATTACHMENT 0x8D20
377#define GL_STENCIL_BACK_FAIL 0x8801
378#define GL_STENCIL_BACK_FUNC 0x8800
379#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
380#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
381#define GL_STENCIL_BACK_REF 0x8CA3
382#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
383#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
384#define GL_STENCIL_BITS 0x0D57
385#define GL_STENCIL_BUFFER_BIT 0x00000400
386#define GL_STENCIL_CLEAR_VALUE 0x0B91
387#define GL_STENCIL_FAIL 0x0B94
388#define GL_STENCIL_FUNC 0x0B92
389#define GL_STENCIL_INDEX8 0x8D48
390#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
391#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
392#define GL_STENCIL_REF 0x0B97
393#define GL_STENCIL_TEST 0x0B90
394#define GL_STENCIL_VALUE_MASK 0x0B93
395#define GL_STENCIL_WRITEMASK 0x0B98
396#define GL_STREAM_DRAW 0x88E0
397#define GL_SUBPIXEL_BITS 0x0D50
398#define GL_TEXTURE 0x1702
399#define GL_TEXTURE0 0x84C0
400#define GL_TEXTURE1 0x84C1
401#define GL_TEXTURE10 0x84CA
402#define GL_TEXTURE11 0x84CB
403#define GL_TEXTURE12 0x84CC
404#define GL_TEXTURE13 0x84CD
405#define GL_TEXTURE14 0x84CE
406#define GL_TEXTURE15 0x84CF
407#define GL_TEXTURE16 0x84D0
408#define GL_TEXTURE17 0x84D1
409#define GL_TEXTURE18 0x84D2
410#define GL_TEXTURE19 0x84D3
411#define GL_TEXTURE2 0x84C2
412#define GL_TEXTURE20 0x84D4
413#define GL_TEXTURE21 0x84D5
414#define GL_TEXTURE22 0x84D6
415#define GL_TEXTURE23 0x84D7
416#define GL_TEXTURE24 0x84D8
417#define GL_TEXTURE25 0x84D9
418#define GL_TEXTURE26 0x84DA
419#define GL_TEXTURE27 0x84DB
420#define GL_TEXTURE28 0x84DC
421#define GL_TEXTURE29 0x84DD
422#define GL_TEXTURE3 0x84C3
423#define GL_TEXTURE30 0x84DE
424#define GL_TEXTURE31 0x84DF
425#define GL_TEXTURE4 0x84C4
426#define GL_TEXTURE5 0x84C5
427#define GL_TEXTURE6 0x84C6
428#define GL_TEXTURE7 0x84C7
429#define GL_TEXTURE8 0x84C8
430#define GL_TEXTURE9 0x84C9
431#define GL_TEXTURE_2D 0x0DE1
432#define GL_TEXTURE_BINDING_2D 0x8069
433#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
434#define GL_TEXTURE_CUBE_MAP 0x8513
435#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
436#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
437#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
438#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
439#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
440#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
441#define GL_TEXTURE_MAG_FILTER 0x2800
442#define GL_TEXTURE_MIN_FILTER 0x2801
443#define GL_TEXTURE_WRAP_S 0x2802
444#define GL_TEXTURE_WRAP_T 0x2803
445#define GL_TRIANGLES 0x0004
446#define GL_TRIANGLE_FAN 0x0006
447#define GL_TRIANGLE_STRIP 0x0005
448#define GL_TRUE 1
449#define GL_UNPACK_ALIGNMENT 0x0CF5
450#define GL_UNSIGNED_BYTE 0x1401
451#define GL_UNSIGNED_INT 0x1405
452#define GL_UNSIGNED_SHORT 0x1403
453#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
454#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
455#define GL_UNSIGNED_SHORT_5_6_5 0x8363
456#define GL_VALIDATE_STATUS 0x8B83
457#define GL_VENDOR 0x1F00
458#define GL_VERSION 0x1F02
459#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
460#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
461#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
462#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
463#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
464#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
465#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
466#define GL_VERTEX_SHADER 0x8B31
467#define GL_VIEWPORT 0x0BA2
468#define GL_ZERO 0
469
470
471#ifndef __khrplatform_h_
472#define __khrplatform_h_
473
474/*
475** Copyright (c) 2008-2018 The Khronos Group Inc.
476**
477** Permission is hereby granted, free of charge, to any person obtaining a
478** copy of this software and/or associated documentation files (the
479** "Materials"), to deal in the Materials without restriction, including
480** without limitation the rights to use, copy, modify, merge, publish,
481** distribute, sublicense, and/or sell copies of the Materials, and to
482** permit persons to whom the Materials are furnished to do so, subject to
483** the following conditions:
484**
485** The above copyright notice and this permission notice shall be included
486** in all copies or substantial portions of the Materials.
487**
488** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
489** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
490** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
491** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
492** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
493** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
494** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
495*/
496
497/* Khronos platform-specific types and definitions.
498 *
499 * The master copy of khrplatform.h is maintained in the Khronos EGL
500 * Registry repository at https://github.com/KhronosGroup/EGL-Registry
501 * The last semantic modification to khrplatform.h was at commit ID:
502 * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
503 *
504 * Adopters may modify this file to suit their platform. Adopters are
505 * encouraged to submit platform specific modifications to the Khronos
506 * group so that they can be included in future versions of this file.
507 * Please submit changes by filing pull requests or issues on
508 * the EGL Registry repository linked above.
509 *
510 *
511 * See the Implementer's Guidelines for information about where this file
512 * should be located on your system and for more details of its use:
513 * http://www.khronos.org/registry/implementers_guide.pdf
514 *
515 * This file should be included as
516 * #include <KHR/khrplatform.h>
517 * by Khronos client API header files that use its types and defines.
518 *
519 * The types in khrplatform.h should only be used to define API-specific types.
520 *
521 * Types defined in khrplatform.h:
522 * khronos_int8_t signed 8 bit
523 * khronos_uint8_t unsigned 8 bit
524 * khronos_int16_t signed 16 bit
525 * khronos_uint16_t unsigned 16 bit
526 * khronos_int32_t signed 32 bit
527 * khronos_uint32_t unsigned 32 bit
528 * khronos_int64_t signed 64 bit
529 * khronos_uint64_t unsigned 64 bit
530 * khronos_intptr_t signed same number of bits as a pointer
531 * khronos_uintptr_t unsigned same number of bits as a pointer
532 * khronos_ssize_t signed size
533 * khronos_usize_t unsigned size
534 * khronos_float_t signed 32 bit floating point
535 * khronos_time_ns_t unsigned 64 bit time in nanoseconds
536 * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
537 * nanoseconds
538 * khronos_stime_nanoseconds_t signed time interval in nanoseconds
539 * khronos_boolean_enum_t enumerated boolean type. This should
540 * only be used as a base type when a client API's boolean type is
541 * an enum. Client APIs which use an integer or other type for
542 * booleans cannot use this as the base type for their boolean.
543 *
544 * Tokens defined in khrplatform.h:
545 *
546 * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
547 *
548 * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
549 * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
550 *
551 * Calling convention macros defined in this file:
552 * KHRONOS_APICALL
553 * KHRONOS_GLAD_API_PTR
554 * KHRONOS_APIATTRIBUTES
555 *
556 * These may be used in function prototypes as:
557 *
558 * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname(
559 * int arg1,
560 * int arg2) KHRONOS_APIATTRIBUTES;
561 */
562
563#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
564# define KHRONOS_STATIC 1
565#endif
566
567/*-------------------------------------------------------------------------
568 * Definition of KHRONOS_APICALL
569 *-------------------------------------------------------------------------
570 * This precedes the return type of the function in the function prototype.
571 */
572#if defined(KHRONOS_STATIC)
573 /* If the preprocessor constant KHRONOS_STATIC is defined, make the
574 * header compatible with static linking. */
575# define KHRONOS_APICALL
576#elif defined(_WIN32)
577# define KHRONOS_APICALL __declspec(dllimport)
578#elif defined (__SYMBIAN32__)
579# define KHRONOS_APICALL IMPORT_C
580#elif defined(__ANDROID__)
581# define KHRONOS_APICALL __attribute__((visibility("default")))
582#else
583# define KHRONOS_APICALL
584#endif
585
586/*-------------------------------------------------------------------------
587 * Definition of KHRONOS_GLAD_API_PTR
588 *-------------------------------------------------------------------------
589 * This follows the return type of the function and precedes the function
590 * name in the function prototype.
591 */
592#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
593 /* Win32 but not WinCE */
594# define KHRONOS_GLAD_API_PTR __stdcall
595#else
596# define KHRONOS_GLAD_API_PTR
597#endif
598
599/*-------------------------------------------------------------------------
600 * Definition of KHRONOS_APIATTRIBUTES
601 *-------------------------------------------------------------------------
602 * This follows the closing parenthesis of the function prototype arguments.
603 */
604#if defined (__ARMCC_2__)
605#define KHRONOS_APIATTRIBUTES __softfp
606#else
607#define KHRONOS_APIATTRIBUTES
608#endif
609
610/*-------------------------------------------------------------------------
611 * basic type definitions
612 *-----------------------------------------------------------------------*/
613#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
614
615
616/*
617 * Using <stdint.h>
618 */
619#include <stdint.h>
620typedef int32_t khronos_int32_t;
621typedef uint32_t khronos_uint32_t;
622typedef int64_t khronos_int64_t;
623typedef uint64_t khronos_uint64_t;
624#define KHRONOS_SUPPORT_INT64 1
625#define KHRONOS_SUPPORT_FLOAT 1
626
627#elif defined(__VMS ) || defined(__sgi)
628
629/*
630 * Using <inttypes.h>
631 */
632#include <inttypes.h>
633typedef int32_t khronos_int32_t;
634typedef uint32_t khronos_uint32_t;
635typedef int64_t khronos_int64_t;
636typedef uint64_t khronos_uint64_t;
637#define KHRONOS_SUPPORT_INT64 1
638#define KHRONOS_SUPPORT_FLOAT 1
639
640#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
641
642/*
643 * Win32
644 */
645typedef __int32 khronos_int32_t;
646typedef unsigned __int32 khronos_uint32_t;
647typedef __int64 khronos_int64_t;
648typedef unsigned __int64 khronos_uint64_t;
649#define KHRONOS_SUPPORT_INT64 1
650#define KHRONOS_SUPPORT_FLOAT 1
651
652#elif defined(__sun__) || defined(__digital__)
653
654/*
655 * Sun or Digital
656 */
657typedef int khronos_int32_t;
658typedef unsigned int khronos_uint32_t;
659#if defined(__arch64__) || defined(_LP64)
660typedef long int khronos_int64_t;
661typedef unsigned long int khronos_uint64_t;
662#else
663typedef long long int khronos_int64_t;
664typedef unsigned long long int khronos_uint64_t;
665#endif /* __arch64__ */
666#define KHRONOS_SUPPORT_INT64 1
667#define KHRONOS_SUPPORT_FLOAT 1
668
669#elif 0
670
671/*
672 * Hypothetical platform with no float or int64 support
673 */
674typedef int khronos_int32_t;
675typedef unsigned int khronos_uint32_t;
676#define KHRONOS_SUPPORT_INT64 0
677#define KHRONOS_SUPPORT_FLOAT 0
678
679#else
680
681/*
682 * Generic fallback
683 */
684#include <stdint.h>
685typedef int32_t khronos_int32_t;
686typedef uint32_t khronos_uint32_t;
687typedef int64_t khronos_int64_t;
688typedef uint64_t khronos_uint64_t;
689#define KHRONOS_SUPPORT_INT64 1
690#define KHRONOS_SUPPORT_FLOAT 1
691
692#endif
693
694
695/*
696 * Types that are (so far) the same on all platforms
697 */
698typedef signed char khronos_int8_t;
699typedef unsigned char khronos_uint8_t;
700typedef signed short int khronos_int16_t;
701typedef unsigned short int khronos_uint16_t;
702
703/*
704 * Types that differ between LLP64 and LP64 architectures - in LLP64,
705 * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
706 * to be the only LLP64 architecture in current use.
707 */
708#ifdef _WIN64
709typedef signed long long int khronos_intptr_t;
710typedef unsigned long long int khronos_uintptr_t;
711typedef signed long long int khronos_ssize_t;
712typedef unsigned long long int khronos_usize_t;
713#else
714typedef signed long int khronos_intptr_t;
715typedef unsigned long int khronos_uintptr_t;
716typedef signed long int khronos_ssize_t;
717typedef unsigned long int khronos_usize_t;
718#endif
719
720#if KHRONOS_SUPPORT_FLOAT
721/*
722 * Float type
723 */
724typedef float khronos_float_t;
725#endif
726
727#if KHRONOS_SUPPORT_INT64
728/* Time types
729 *
730 * These types can be used to represent a time interval in nanoseconds or
731 * an absolute Unadjusted System Time. Unadjusted System Time is the number
732 * of nanoseconds since some arbitrary system event (e.g. since the last
733 * time the system booted). The Unadjusted System Time is an unsigned
734 * 64 bit value that wraps back to 0 every 584 years. Time intervals
735 * may be either signed or unsigned.
736 */
737typedef khronos_uint64_t khronos_utime_nanoseconds_t;
738typedef khronos_int64_t khronos_stime_nanoseconds_t;
739#endif
740
741/*
742 * Dummy value used to pad enum types to 32 bits.
743 */
744#ifndef KHRONOS_MAX_ENUM
745#define KHRONOS_MAX_ENUM 0x7FFFFFFF
746#endif
747
748/*
749 * Enumerated boolean type
750 *
751 * Values other than zero should be considered to be true. Therefore
752 * comparisons should not be made against KHRONOS_TRUE.
753 */
754typedef enum {
755 KHRONOS_FALSE = 0,
756 KHRONOS_TRUE = 1,
757 KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
758} khronos_boolean_enum_t;
759
760#endif /* __khrplatform_h_ */
761
762typedef unsigned int GLenum;
763
764typedef unsigned char GLboolean;
765
766typedef unsigned int GLbitfield;
767
768typedef void GLvoid;
769
770typedef khronos_int8_t GLbyte;
771
772typedef khronos_uint8_t GLubyte;
773
774typedef khronos_int16_t GLshort;
775
776typedef khronos_uint16_t GLushort;
777
778typedef int GLint;
779
780typedef unsigned int GLuint;
781
782typedef khronos_int32_t GLclampx;
783
784typedef int GLsizei;
785
786typedef khronos_float_t GLfloat;
787
788typedef khronos_float_t GLclampf;
789
790typedef double GLdouble;
791
792typedef double GLclampd;
793
794typedef void *GLeglClientBufferEXT;
795
796typedef void *GLeglImageOES;
797
798typedef char GLchar;
799
800typedef char GLcharARB;
801
802#ifdef __APPLE__
803typedef void *GLhandleARB;
804#else
805typedef unsigned int GLhandleARB;
806#endif
807
808typedef khronos_uint16_t GLhalf;
809
810typedef khronos_uint16_t GLhalfARB;
811
812typedef khronos_int32_t GLfixed;
813
814#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
815typedef khronos_intptr_t GLintptr;
816#else
817typedef khronos_intptr_t GLintptr;
818#endif
819
820#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
821typedef khronos_intptr_t GLintptrARB;
822#else
823typedef khronos_intptr_t GLintptrARB;
824#endif
825
826#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
827typedef khronos_ssize_t GLsizeiptr;
828#else
829typedef khronos_ssize_t GLsizeiptr;
830#endif
831
832#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
833typedef khronos_ssize_t GLsizeiptrARB;
834#else
835typedef khronos_ssize_t GLsizeiptrARB;
836#endif
837
838typedef khronos_int64_t GLint64;
839
840typedef khronos_int64_t GLint64EXT;
841
842typedef khronos_uint64_t GLuint64;
843
844typedef khronos_uint64_t GLuint64EXT;
845
846typedef struct __GLsync *GLsync;
847
848struct _cl_context;
849
850struct _cl_event;
851
852typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
853
854typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
855
856typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
857
858typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
859
860typedef unsigned short GLhalfNV;
861
862typedef GLintptr GLvdpauSurfaceNV;
863
864typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void);
865
866
867
868#define GL_ES_VERSION_2_0 1
869GLAD_API_CALL int GLAD_GL_ES_VERSION_2_0;
870
871
872typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture);
873typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
874typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name);
875typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
876typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
877typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
878typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
879typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
880typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode);
881typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
882typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
883typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
884typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
885typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
886typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
887typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask);
888typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
889typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d);
890typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s);
891typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
892typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader);
893typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
894typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
895typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
896typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
897typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
898typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type);
899typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode);
900typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers);
901typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers);
902typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program);
903typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers);
904typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader);
905typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures);
906typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func);
907typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag);
908typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
909typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
910typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap);
911typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
912typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
913typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices);
914typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap);
915typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
916typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
917typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
918typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
919typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
920typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode);
921typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers);
922typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
923typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
924typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures);
925typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target);
926typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
927typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
928typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
929typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name);
930typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data);
931typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
932typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
933typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data);
934typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
935typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data);
936typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
937typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params);
938typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
939typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
940typedef void (GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision);
941typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
942typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params);
943typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name);
944typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params);
945typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
946typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name);
947typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params);
948typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params);
949typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer);
950typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params);
951typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params);
952typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode);
953typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer);
954typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap);
955typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
956typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program);
957typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
958typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader);
959typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture);
960typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width);
961typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program);
962typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
963typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
964typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
965typedef void (GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void);
966typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
967typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
968typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
969typedef void (GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length);
970typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
971typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
972typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
973typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask);
974typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
975typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
976typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
977typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
978typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
979typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
980typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
981typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params);
982typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
983typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
984typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value);
985typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
986typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value);
987typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
988typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value);
989typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
990typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value);
991typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
992typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value);
993typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
994typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value);
995typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
996typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value);
997typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
998typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value);
999typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
1000typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
1001typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
1002typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program);
1003typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program);
1004typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
1005typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v);
1006typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
1007typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v);
1008typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
1009typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v);
1010typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1011typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v);
1012typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
1013typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
1014
1015GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
1016#define glActiveTexture glad_glActiveTexture
1017GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
1018#define glAttachShader glad_glAttachShader
1019GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
1020#define glBindAttribLocation glad_glBindAttribLocation
1021GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
1022#define glBindBuffer glad_glBindBuffer
1023GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
1024#define glBindFramebuffer glad_glBindFramebuffer
1025GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
1026#define glBindRenderbuffer glad_glBindRenderbuffer
1027GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
1028#define glBindTexture glad_glBindTexture
1029GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
1030#define glBlendColor glad_glBlendColor
1031GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
1032#define glBlendEquation glad_glBlendEquation
1033GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
1034#define glBlendEquationSeparate glad_glBlendEquationSeparate
1035GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
1036#define glBlendFunc glad_glBlendFunc
1037GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
1038#define glBlendFuncSeparate glad_glBlendFuncSeparate
1039GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
1040#define glBufferData glad_glBufferData
1041GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
1042#define glBufferSubData glad_glBufferSubData
1043GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
1044#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
1045GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
1046#define glClear glad_glClear
1047GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
1048#define glClearColor glad_glClearColor
1049GLAD_API_CALL PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
1050#define glClearDepthf glad_glClearDepthf
1051GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
1052#define glClearStencil glad_glClearStencil
1053GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
1054#define glColorMask glad_glColorMask
1055GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
1056#define glCompileShader glad_glCompileShader
1057GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
1058#define glCompressedTexImage2D glad_glCompressedTexImage2D
1059GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
1060#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
1061GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
1062#define glCopyTexImage2D glad_glCopyTexImage2D
1063GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
1064#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
1065GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
1066#define glCreateProgram glad_glCreateProgram
1067GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
1068#define glCreateShader glad_glCreateShader
1069GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
1070#define glCullFace glad_glCullFace
1071GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
1072#define glDeleteBuffers glad_glDeleteBuffers
1073GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
1074#define glDeleteFramebuffers glad_glDeleteFramebuffers
1075GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
1076#define glDeleteProgram glad_glDeleteProgram
1077GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
1078#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
1079GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
1080#define glDeleteShader glad_glDeleteShader
1081GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
1082#define glDeleteTextures glad_glDeleteTextures
1083GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
1084#define glDepthFunc glad_glDepthFunc
1085GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
1086#define glDepthMask glad_glDepthMask
1087GLAD_API_CALL PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
1088#define glDepthRangef glad_glDepthRangef
1089GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
1090#define glDetachShader glad_glDetachShader
1091GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
1092#define glDisable glad_glDisable
1093GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
1094#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
1095GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
1096#define glDrawArrays glad_glDrawArrays
1097GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
1098#define glDrawElements glad_glDrawElements
1099GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
1100#define glEnable glad_glEnable
1101GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
1102#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
1103GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
1104#define glFinish glad_glFinish
1105GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
1106#define glFlush glad_glFlush
1107GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
1108#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
1109GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
1110#define glFramebufferTexture2D glad_glFramebufferTexture2D
1111GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
1112#define glFrontFace glad_glFrontFace
1113GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
1114#define glGenBuffers glad_glGenBuffers
1115GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
1116#define glGenFramebuffers glad_glGenFramebuffers
1117GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
1118#define glGenRenderbuffers glad_glGenRenderbuffers
1119GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
1120#define glGenTextures glad_glGenTextures
1121GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
1122#define glGenerateMipmap glad_glGenerateMipmap
1123GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
1124#define glGetActiveAttrib glad_glGetActiveAttrib
1125GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
1126#define glGetActiveUniform glad_glGetActiveUniform
1127GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
1128#define glGetAttachedShaders glad_glGetAttachedShaders
1129GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
1130#define glGetAttribLocation glad_glGetAttribLocation
1131GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
1132#define glGetBooleanv glad_glGetBooleanv
1133GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
1134#define glGetBufferParameteriv glad_glGetBufferParameteriv
1135GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
1136#define glGetError glad_glGetError
1137GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
1138#define glGetFloatv glad_glGetFloatv
1139GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
1140#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
1141GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
1142#define glGetIntegerv glad_glGetIntegerv
1143GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
1144#define glGetProgramInfoLog glad_glGetProgramInfoLog
1145GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
1146#define glGetProgramiv glad_glGetProgramiv
1147GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
1148#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
1149GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
1150#define glGetShaderInfoLog glad_glGetShaderInfoLog
1151GLAD_API_CALL PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
1152#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
1153GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
1154#define glGetShaderSource glad_glGetShaderSource
1155GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
1156#define glGetShaderiv glad_glGetShaderiv
1157GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
1158#define glGetString glad_glGetString
1159GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
1160#define glGetTexParameterfv glad_glGetTexParameterfv
1161GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
1162#define glGetTexParameteriv glad_glGetTexParameteriv
1163GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
1164#define glGetUniformLocation glad_glGetUniformLocation
1165GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
1166#define glGetUniformfv glad_glGetUniformfv
1167GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
1168#define glGetUniformiv glad_glGetUniformiv
1169GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
1170#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
1171GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
1172#define glGetVertexAttribfv glad_glGetVertexAttribfv
1173GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
1174#define glGetVertexAttribiv glad_glGetVertexAttribiv
1175GLAD_API_CALL PFNGLHINTPROC glad_glHint;
1176#define glHint glad_glHint
1177GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
1178#define glIsBuffer glad_glIsBuffer
1179GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
1180#define glIsEnabled glad_glIsEnabled
1181GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
1182#define glIsFramebuffer glad_glIsFramebuffer
1183GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
1184#define glIsProgram glad_glIsProgram
1185GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
1186#define glIsRenderbuffer glad_glIsRenderbuffer
1187GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
1188#define glIsShader glad_glIsShader
1189GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
1190#define glIsTexture glad_glIsTexture
1191GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
1192#define glLineWidth glad_glLineWidth
1193GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
1194#define glLinkProgram glad_glLinkProgram
1195GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
1196#define glPixelStorei glad_glPixelStorei
1197GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
1198#define glPolygonOffset glad_glPolygonOffset
1199GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
1200#define glReadPixels glad_glReadPixels
1201GLAD_API_CALL PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
1202#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
1203GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
1204#define glRenderbufferStorage glad_glRenderbufferStorage
1205GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
1206#define glSampleCoverage glad_glSampleCoverage
1207GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
1208#define glScissor glad_glScissor
1209GLAD_API_CALL PFNGLSHADERBINARYPROC glad_glShaderBinary;
1210#define glShaderBinary glad_glShaderBinary
1211GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
1212#define glShaderSource glad_glShaderSource
1213GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
1214#define glStencilFunc glad_glStencilFunc
1215GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
1216#define glStencilFuncSeparate glad_glStencilFuncSeparate
1217GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
1218#define glStencilMask glad_glStencilMask
1219GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
1220#define glStencilMaskSeparate glad_glStencilMaskSeparate
1221GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
1222#define glStencilOp glad_glStencilOp
1223GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
1224#define glStencilOpSeparate glad_glStencilOpSeparate
1225GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
1226#define glTexImage2D glad_glTexImage2D
1227GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
1228#define glTexParameterf glad_glTexParameterf
1229GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
1230#define glTexParameterfv glad_glTexParameterfv
1231GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
1232#define glTexParameteri glad_glTexParameteri
1233GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
1234#define glTexParameteriv glad_glTexParameteriv
1235GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
1236#define glTexSubImage2D glad_glTexSubImage2D
1237GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
1238#define glUniform1f glad_glUniform1f
1239GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
1240#define glUniform1fv glad_glUniform1fv
1241GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
1242#define glUniform1i glad_glUniform1i
1243GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
1244#define glUniform1iv glad_glUniform1iv
1245GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
1246#define glUniform2f glad_glUniform2f
1247GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
1248#define glUniform2fv glad_glUniform2fv
1249GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
1250#define glUniform2i glad_glUniform2i
1251GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
1252#define glUniform2iv glad_glUniform2iv
1253GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
1254#define glUniform3f glad_glUniform3f
1255GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
1256#define glUniform3fv glad_glUniform3fv
1257GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
1258#define glUniform3i glad_glUniform3i
1259GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
1260#define glUniform3iv glad_glUniform3iv
1261GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
1262#define glUniform4f glad_glUniform4f
1263GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
1264#define glUniform4fv glad_glUniform4fv
1265GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
1266#define glUniform4i glad_glUniform4i
1267GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
1268#define glUniform4iv glad_glUniform4iv
1269GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
1270#define glUniformMatrix2fv glad_glUniformMatrix2fv
1271GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
1272#define glUniformMatrix3fv glad_glUniformMatrix3fv
1273GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
1274#define glUniformMatrix4fv glad_glUniformMatrix4fv
1275GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
1276#define glUseProgram glad_glUseProgram
1277GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
1278#define glValidateProgram glad_glValidateProgram
1279GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
1280#define glVertexAttrib1f glad_glVertexAttrib1f
1281GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
1282#define glVertexAttrib1fv glad_glVertexAttrib1fv
1283GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
1284#define glVertexAttrib2f glad_glVertexAttrib2f
1285GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
1286#define glVertexAttrib2fv glad_glVertexAttrib2fv
1287GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
1288#define glVertexAttrib3f glad_glVertexAttrib3f
1289GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
1290#define glVertexAttrib3fv glad_glVertexAttrib3fv
1291GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
1292#define glVertexAttrib4f glad_glVertexAttrib4f
1293GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
1294#define glVertexAttrib4fv glad_glVertexAttrib4fv
1295GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
1296#define glVertexAttribPointer glad_glVertexAttribPointer
1297GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
1298#define glViewport glad_glViewport
1299
1300
1301
1302
1303
1304GLAD_API_CALL int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr);
1305GLAD_API_CALL int gladLoadGLES2( GLADloadfunc load);
1306
1307
1308
1309#ifdef __cplusplus
1310}
1311#endif
1312#endif
1313
1314/* Source */
1315#ifdef GLAD_GLES2_IMPLEMENTATION
1316#include <stdio.h>
1317#include <stdlib.h>
1318#include <string.h>
1319
1320#ifndef GLAD_IMPL_UTIL_C_
1321#define GLAD_IMPL_UTIL_C_
1322
1323#ifdef _MSC_VER
1324#define GLAD_IMPL_UTIL_SSCANF sscanf_s
1325#else
1326#define GLAD_IMPL_UTIL_SSCANF sscanf
1327#endif
1328
1329#endif /* GLAD_IMPL_UTIL_C_ */
1330
1331#ifdef __cplusplus
1332extern "C" {
1333#endif
1334
1335
1336
1337int GLAD_GL_ES_VERSION_2_0 = 0;
1338
1339
1340
1341PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
1342PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
1343PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
1344PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
1345PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
1346PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
1347PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
1348PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
1349PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
1350PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
1351PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
1352PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
1353PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
1354PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
1355PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
1356PFNGLCLEARPROC glad_glClear = NULL;
1357PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
1358PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL;
1359PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
1360PFNGLCOLORMASKPROC glad_glColorMask = NULL;
1361PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
1362PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
1363PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
1364PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
1365PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
1366PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
1367PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
1368PFNGLCULLFACEPROC glad_glCullFace = NULL;
1369PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
1370PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
1371PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
1372PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
1373PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
1374PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
1375PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
1376PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
1377PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL;
1378PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
1379PFNGLDISABLEPROC glad_glDisable = NULL;
1380PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
1381PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
1382PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
1383PFNGLENABLEPROC glad_glEnable = NULL;
1384PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
1385PFNGLFINISHPROC glad_glFinish = NULL;
1386PFNGLFLUSHPROC glad_glFlush = NULL;
1387PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
1388PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
1389PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
1390PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
1391PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
1392PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
1393PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
1394PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
1395PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
1396PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
1397PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
1398PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
1399PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
1400PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
1401PFNGLGETERRORPROC glad_glGetError = NULL;
1402PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
1403PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
1404PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
1405PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
1406PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
1407PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
1408PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
1409PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL;
1410PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
1411PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
1412PFNGLGETSTRINGPROC glad_glGetString = NULL;
1413PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
1414PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
1415PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
1416PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
1417PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
1418PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
1419PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
1420PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
1421PFNGLHINTPROC glad_glHint = NULL;
1422PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
1423PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
1424PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
1425PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
1426PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
1427PFNGLISSHADERPROC glad_glIsShader = NULL;
1428PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
1429PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
1430PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
1431PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
1432PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
1433PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
1434PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL;
1435PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
1436PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
1437PFNGLSCISSORPROC glad_glScissor = NULL;
1438PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL;
1439PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
1440PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
1441PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
1442PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
1443PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
1444PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
1445PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
1446PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
1447PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
1448PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
1449PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
1450PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
1451PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
1452PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
1453PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
1454PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
1455PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
1456PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
1457PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
1458PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
1459PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
1460PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
1461PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
1462PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
1463PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
1464PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
1465PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
1466PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
1467PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
1468PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
1469PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
1470PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
1471PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
1472PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
1473PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
1474PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
1475PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
1476PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
1477PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
1478PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
1479PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
1480PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
1481PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
1482PFNGLVIEWPORTPROC glad_glViewport = NULL;
1483
1484
1485static void glad_gl_load_GL_ES_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
1486 if(!GLAD_GL_ES_VERSION_2_0) return;
1487 glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
1488 glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader");
1489 glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation");
1490 glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
1491 glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
1492 glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
1493 glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
1494 glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor");
1495 glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation");
1496 glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate");
1497 glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
1498 glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate");
1499 glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
1500 glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
1501 glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
1502 glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
1503 glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
1504 glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
1505 glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
1506 glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
1507 glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader");
1508 glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
1509 glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
1510 glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
1511 glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
1512 glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram");
1513 glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader");
1514 glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
1515 glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
1516 glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
1517 glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram");
1518 glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
1519 glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader");
1520 glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
1521 glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
1522 glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
1523 glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef");
1524 glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader");
1525 glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
1526 glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray");
1527 glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
1528 glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
1529 glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
1530 glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray");
1531 glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
1532 glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
1533 glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
1534 glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
1535 glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
1536 glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
1537 glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
1538 glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
1539 glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
1540 glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
1541 glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib");
1542 glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform");
1543 glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders");
1544 glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation");
1545 glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
1546 glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
1547 glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
1548 glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
1549 glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
1550 glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
1551 glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog");
1552 glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv");
1553 glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
1554 glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog");
1555 glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat");
1556 glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource");
1557 glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv");
1558 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
1559 glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
1560 glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
1561 glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation");
1562 glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv");
1563 glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv");
1564 glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv");
1565 glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv");
1566 glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv");
1567 glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
1568 glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
1569 glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
1570 glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
1571 glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram");
1572 glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
1573 glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader");
1574 glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
1575 glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
1576 glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram");
1577 glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
1578 glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
1579 glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
1580 glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler");
1581 glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
1582 glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
1583 glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
1584 glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary");
1585 glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource");
1586 glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
1587 glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate");
1588 glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
1589 glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate");
1590 glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
1591 glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate");
1592 glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
1593 glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
1594 glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
1595 glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
1596 glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
1597 glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
1598 glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f");
1599 glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv");
1600 glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i");
1601 glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv");
1602 glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f");
1603 glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv");
1604 glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i");
1605 glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv");
1606 glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f");
1607 glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv");
1608 glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i");
1609 glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv");
1610 glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f");
1611 glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv");
1612 glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i");
1613 glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv");
1614 glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv");
1615 glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv");
1616 glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv");
1617 glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram");
1618 glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram");
1619 glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f");
1620 glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv");
1621 glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f");
1622 glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv");
1623 glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f");
1624 glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv");
1625 glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f");
1626 glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv");
1627 glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer");
1628 glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
1629}
1630
1631
1632
1633#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
1634#define GLAD_GL_IS_SOME_NEW_VERSION 1
1635#else
1636#define GLAD_GL_IS_SOME_NEW_VERSION 0
1637#endif
1638
1639static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
1640#if GLAD_GL_IS_SOME_NEW_VERSION
1641 if(GLAD_VERSION_MAJOR(version) < 3) {
1642#else
1643 (void) version;
1644 (void) out_num_exts_i;
1645 (void) out_exts_i;
1646#endif
1647 if (glad_glGetString == NULL) {
1648 return 0;
1649 }
1650 *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS);
1651#if GLAD_GL_IS_SOME_NEW_VERSION
1652 } else {
1653 unsigned int index = 0;
1654 unsigned int num_exts_i = 0;
1655 char **exts_i = NULL;
1656 if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) {
1657 return 0;
1658 }
1659 glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
1660 if (num_exts_i > 0) {
1661 exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
1662 }
1663 if (exts_i == NULL) {
1664 return 0;
1665 }
1666 for(index = 0; index < num_exts_i; index++) {
1667 const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index);
1668 size_t len = strlen(gl_str_tmp) + 1;
1669
1670 char *local_str = (char*) malloc(len * sizeof(char));
1671 if(local_str != NULL) {
1672 memcpy(local_str, gl_str_tmp, len * sizeof(char));
1673 }
1674
1675 exts_i[index] = local_str;
1676 }
1677
1678 *out_num_exts_i = num_exts_i;
1679 *out_exts_i = exts_i;
1680 }
1681#endif
1682 return 1;
1683}
1684static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
1685 if (exts_i != NULL) {
1686 unsigned int index;
1687 for(index = 0; index < num_exts_i; index++) {
1688 free((void *) (exts_i[index]));
1689 }
1690 free((void *)exts_i);
1691 exts_i = NULL;
1692 }
1693}
1694static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
1695 if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
1696 const char *extensions;
1697 const char *loc;
1698 const char *terminator;
1699 extensions = exts;
1700 if(extensions == NULL || ext == NULL) {
1701 return 0;
1702 }
1703 while(1) {
1704 loc = strstr(extensions, ext);
1705 if(loc == NULL) {
1706 return 0;
1707 }
1708 terminator = loc + strlen(ext);
1709 if((loc == extensions || *(loc - 1) == ' ') &&
1710 (*terminator == ' ' || *terminator == '\0')) {
1711 return 1;
1712 }
1713 extensions = terminator;
1714 }
1715 } else {
1716 unsigned int index;
1717 for(index = 0; index < num_exts_i; index++) {
1718 const char *e = exts_i[index];
1719 if(strcmp(e, ext) == 0) {
1720 return 1;
1721 }
1722 }
1723 }
1724 return 0;
1725}
1726
1727static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
1728 return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
1729}
1730
1731static int glad_gl_find_extensions_gles2( int version) {
1732 const char *exts = NULL;
1733 unsigned int num_exts_i = 0;
1734 char **exts_i = NULL;
1735 if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
1736
1737 (void) glad_gl_has_extension;
1738
1739 glad_gl_free_extensions(exts_i, num_exts_i);
1740
1741 return 1;
1742}
1743
1744static int glad_gl_find_core_gles2(void) {
1745 int i;
1746 const char* version;
1747 const char* prefixes[] = {
1748 "OpenGL ES-CM ",
1749 "OpenGL ES-CL ",
1750 "OpenGL ES ",
1751 "OpenGL SC ",
1752 NULL
1753 };
1754 int major = 0;
1755 int minor = 0;
1756 version = (const char*) glad_glGetString(GL_VERSION);
1757 if (!version) return 0;
1758 for (i = 0; prefixes[i]; i++) {
1759 const size_t length = strlen(prefixes[i]);
1760 if (strncmp(version, prefixes[i], length) == 0) {
1761 version += length;
1762 break;
1763 }
1764 }
1765
1766 GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
1767
1768 GLAD_GL_ES_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
1769
1770 return GLAD_MAKE_VERSION(major, minor);
1771}
1772
1773int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr) {
1774 int version;
1775
1776 glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
1777 if(glad_glGetString == NULL) return 0;
1778 if(glad_glGetString(GL_VERSION) == NULL) return 0;
1779 version = glad_gl_find_core_gles2();
1780
1781 glad_gl_load_GL_ES_VERSION_2_0(load, userptr);
1782
1783 if (!glad_gl_find_extensions_gles2(version)) return 0;
1784
1785
1786
1787 return version;
1788}
1789
1790
1791int gladLoadGLES2( GLADloadfunc load) {
1792 return gladLoadGLES2UserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
1793}
1794
1795
1796
1797
1798
1799
1800#ifdef __cplusplus
1801}
1802#endif
1803
1804#endif /* GLAD_GLES2_IMPLEMENTATION */
1805
diff --git a/raylib/src/external/glfw/deps/glad/vulkan.h b/raylib/src/external/glfw/deps/glad/vulkan.h
new file mode 100644
index 0000000..469ffe5
--- /dev/null
+++ b/raylib/src/external/glfw/deps/glad/vulkan.h
@@ -0,0 +1,6330 @@
1/**
2 * Loader generated by glad 2.0.0-beta on Thu Jul 7 20:52:04 2022
3 *
4 * Generator: C/C++
5 * Specification: vk
6 * Extensions: 4
7 *
8 * APIs:
9 * - vulkan=1.3
10 *
11 * Options:
12 * - ALIAS = False
13 * - DEBUG = False
14 * - HEADER_ONLY = True
15 * - LOADER = False
16 * - MX = False
17 * - MX_GLOBAL = False
18 * - ON_DEMAND = False
19 *
20 * Commandline:
21 * --api='vulkan=1.3' --extensions='VK_EXT_debug_report,VK_KHR_portability_enumeration,VK_KHR_surface,VK_KHR_swapchain' c --header-only
22 *
23 * Online:
24 * http://glad.sh/#api=vulkan%3D1.3&extensions=VK_EXT_debug_report%2CVK_KHR_portability_enumeration%2CVK_KHR_surface%2CVK_KHR_swapchain&generator=c&options=HEADER_ONLY
25 *
26 */
27
28#ifndef GLAD_VULKAN_H_
29#define GLAD_VULKAN_H_
30
31#ifdef VULKAN_H_
32 #error header already included (API: vulkan), remove previous include!
33#endif
34#define VULKAN_H_ 1
35
36#ifdef VULKAN_CORE_H_
37 #error header already included (API: vulkan), remove previous include!
38#endif
39#define VULKAN_CORE_H_ 1
40
41
42#define GLAD_VULKAN
43#define GLAD_OPTION_VULKAN_HEADER_ONLY
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#ifndef GLAD_PLATFORM_H_
50#define GLAD_PLATFORM_H_
51
52#ifndef GLAD_PLATFORM_WIN32
53 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
54 #define GLAD_PLATFORM_WIN32 1
55 #else
56 #define GLAD_PLATFORM_WIN32 0
57 #endif
58#endif
59
60#ifndef GLAD_PLATFORM_APPLE
61 #ifdef __APPLE__
62 #define GLAD_PLATFORM_APPLE 1
63 #else
64 #define GLAD_PLATFORM_APPLE 0
65 #endif
66#endif
67
68#ifndef GLAD_PLATFORM_EMSCRIPTEN
69 #ifdef __EMSCRIPTEN__
70 #define GLAD_PLATFORM_EMSCRIPTEN 1
71 #else
72 #define GLAD_PLATFORM_EMSCRIPTEN 0
73 #endif
74#endif
75
76#ifndef GLAD_PLATFORM_UWP
77 #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
78 #ifdef __has_include
79 #if __has_include(<winapifamily.h>)
80 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
81 #endif
82 #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
83 #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
84 #endif
85 #endif
86
87 #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
88 #include <winapifamily.h>
89 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
90 #define GLAD_PLATFORM_UWP 1
91 #endif
92 #endif
93
94 #ifndef GLAD_PLATFORM_UWP
95 #define GLAD_PLATFORM_UWP 0
96 #endif
97#endif
98
99#ifdef __GNUC__
100 #define GLAD_GNUC_EXTENSION __extension__
101#else
102 #define GLAD_GNUC_EXTENSION
103#endif
104
105#ifndef GLAD_API_CALL
106 #if defined(GLAD_API_CALL_EXPORT)
107 #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
108 #if defined(GLAD_API_CALL_EXPORT_BUILD)
109 #if defined(__GNUC__)
110 #define GLAD_API_CALL __attribute__ ((dllexport)) extern
111 #else
112 #define GLAD_API_CALL __declspec(dllexport) extern
113 #endif
114 #else
115 #if defined(__GNUC__)
116 #define GLAD_API_CALL __attribute__ ((dllimport)) extern
117 #else
118 #define GLAD_API_CALL __declspec(dllimport) extern
119 #endif
120 #endif
121 #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
122 #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
123 #else
124 #define GLAD_API_CALL extern
125 #endif
126 #else
127 #define GLAD_API_CALL extern
128 #endif
129#endif
130
131#ifdef APIENTRY
132 #define GLAD_API_PTR APIENTRY
133#elif GLAD_PLATFORM_WIN32
134 #define GLAD_API_PTR __stdcall
135#else
136 #define GLAD_API_PTR
137#endif
138
139#ifndef GLAPI
140#define GLAPI GLAD_API_CALL
141#endif
142
143#ifndef GLAPIENTRY
144#define GLAPIENTRY GLAD_API_PTR
145#endif
146
147#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
148#define GLAD_VERSION_MAJOR(version) (version / 10000)
149#define GLAD_VERSION_MINOR(version) (version % 10000)
150
151#define GLAD_GENERATOR_VERSION "2.0.0-beta"
152
153typedef void (*GLADapiproc)(void);
154
155typedef GLADapiproc (*GLADloadfunc)(const char *name);
156typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
157
158typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
159typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
160
161#endif /* GLAD_PLATFORM_H_ */
162
163#define VK_ATTACHMENT_UNUSED (~0U)
164#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report"
165#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 10
166#define VK_FALSE 0
167#define VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME "VK_KHR_portability_enumeration"
168#define VK_KHR_PORTABILITY_ENUMERATION_SPEC_VERSION 1
169#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface"
170#define VK_KHR_SURFACE_SPEC_VERSION 25
171#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain"
172#define VK_KHR_SWAPCHAIN_SPEC_VERSION 70
173#define VK_LOD_CLAMP_NONE 1000.0F
174#define VK_LUID_SIZE 8
175#define VK_MAX_DESCRIPTION_SIZE 256
176#define VK_MAX_DEVICE_GROUP_SIZE 32
177#define VK_MAX_DRIVER_INFO_SIZE 256
178#define VK_MAX_DRIVER_NAME_SIZE 256
179#define VK_MAX_EXTENSION_NAME_SIZE 256
180#define VK_MAX_MEMORY_HEAPS 16
181#define VK_MAX_MEMORY_TYPES 32
182#define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256
183#define VK_QUEUE_FAMILY_EXTERNAL (~1U)
184#define VK_QUEUE_FAMILY_IGNORED (~0U)
185#define VK_REMAINING_ARRAY_LAYERS (~0U)
186#define VK_REMAINING_MIP_LEVELS (~0U)
187#define VK_SUBPASS_EXTERNAL (~0U)
188#define VK_TRUE 1
189#define VK_UUID_SIZE 16
190#define VK_WHOLE_SIZE (~0ULL)
191
192
193/* */
194/* File: vk_platform.h */
195/* */
196/*
197** Copyright 2014-2022 The Khronos Group Inc.
198**
199** SPDX-License-Identifier: Apache-2.0
200*/
201
202
203#ifndef VK_PLATFORM_H_
204#define VK_PLATFORM_H_
205
206#ifdef __cplusplus
207extern "C"
208{
209#endif /* __cplusplus */
210
211/*
212***************************************************************************************************
213* Platform-specific directives and type declarations
214***************************************************************************************************
215*/
216
217/* Platform-specific calling convention macros.
218 *
219 * Platforms should define these so that Vulkan clients call Vulkan commands
220 * with the same calling conventions that the Vulkan implementation expects.
221 *
222 * VKAPI_ATTR - Placed before the return type in function declarations.
223 * Useful for C++11 and GCC/Clang-style function attribute syntax.
224 * VKAPI_CALL - Placed after the return type in function declarations.
225 * Useful for MSVC-style calling convention syntax.
226 * VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
227 *
228 * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
229 * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
230 */
231#if defined(_WIN32)
232 /* On Windows, Vulkan commands use the stdcall convention */
233 #define VKAPI_ATTR
234 #define VKAPI_CALL __stdcall
235 #define VKAPI_PTR VKAPI_CALL
236#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
237 #error "Vulkan is not supported for the 'armeabi' NDK ABI"
238#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
239 /* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */
240 /* calling convention, i.e. float parameters are passed in registers. This */
241 /* is true even if the rest of the application passes floats on the stack, */
242 /* as it does by default when compiling for the armeabi-v7a NDK ABI. */
243 #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
244 #define VKAPI_CALL
245 #define VKAPI_PTR VKAPI_ATTR
246#else
247 /* On other platforms, use the default calling convention */
248 #define VKAPI_ATTR
249 #define VKAPI_CALL
250 #define VKAPI_PTR
251#endif
252
253#if !defined(VK_NO_STDDEF_H)
254 #include <stddef.h>
255#endif /* !defined(VK_NO_STDDEF_H) */
256
257#if !defined(VK_NO_STDINT_H)
258 #if defined(_MSC_VER) && (_MSC_VER < 1600)
259 typedef signed __int8 int8_t;
260 typedef unsigned __int8 uint8_t;
261 typedef signed __int16 int16_t;
262 typedef unsigned __int16 uint16_t;
263 typedef signed __int32 int32_t;
264 typedef unsigned __int32 uint32_t;
265 typedef signed __int64 int64_t;
266 typedef unsigned __int64 uint64_t;
267 #else
268 #include <stdint.h>
269 #endif
270#endif /* !defined(VK_NO_STDINT_H) */
271
272#ifdef __cplusplus
273} /* extern "C" */
274#endif /* __cplusplus */
275
276#endif
277/* DEPRECATED: This define is deprecated. VK_MAKE_API_VERSION should be used instead. */
278#define VK_MAKE_VERSION(major, minor, patch) \
279 ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))
280/* DEPRECATED: This define is deprecated. VK_API_VERSION_MAJOR should be used instead. */
281#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
282/* DEPRECATED: This define is deprecated. VK_API_VERSION_MINOR should be used instead. */
283#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU)
284/* DEPRECATED: This define is deprecated. VK_API_VERSION_PATCH should be used instead. */
285#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU)
286#define VK_MAKE_API_VERSION(variant, major, minor, patch) \
287 ((((uint32_t)(variant)) << 29) | (((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))
288#define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29)
289#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22) & 0x7FU)
290#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU)
291#define VK_API_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU)
292/* DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. */
293/*#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 */
294/* Vulkan 1.0 version number */
295#define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)/* Patch version should always be set to 0 */
296/* Vulkan 1.1 version number */
297#define VK_API_VERSION_1_1 VK_MAKE_API_VERSION(0, 1, 1, 0)/* Patch version should always be set to 0 */
298/* Vulkan 1.2 version number */
299#define VK_API_VERSION_1_2 VK_MAKE_API_VERSION(0, 1, 2, 0)/* Patch version should always be set to 0 */
300/* Vulkan 1.3 version number */
301#define VK_API_VERSION_1_3 VK_MAKE_API_VERSION(0, 1, 3, 0)/* Patch version should always be set to 0 */
302/* Version of this file */
303#define VK_HEADER_VERSION 220
304/* Complete version of this file */
305#define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 1, 3, VK_HEADER_VERSION)
306#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
307#ifndef VK_USE_64_BIT_PTR_DEFINES
308 #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
309 #define VK_USE_64_BIT_PTR_DEFINES 1
310 #else
311 #define VK_USE_64_BIT_PTR_DEFINES 0
312 #endif
313#endif
314#ifndef VK_DEFINE_NON_DISPATCHABLE_HANDLE
315 #if (VK_USE_64_BIT_PTR_DEFINES==1)
316 #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))
317 #define VK_NULL_HANDLE nullptr
318 #else
319 #define VK_NULL_HANDLE ((void*)0)
320 #endif
321 #else
322 #define VK_NULL_HANDLE 0ULL
323 #endif
324#endif
325#ifndef VK_NULL_HANDLE
326 #define VK_NULL_HANDLE 0
327#endif
328#ifndef VK_DEFINE_NON_DISPATCHABLE_HANDLE
329 #if (VK_USE_64_BIT_PTR_DEFINES==1)
330 #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
331 #else
332 #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
333 #endif
334#endif
335
336
337
338
339
340
341
342
343VK_DEFINE_HANDLE(VkInstance)
344VK_DEFINE_HANDLE(VkPhysicalDevice)
345VK_DEFINE_HANDLE(VkDevice)
346VK_DEFINE_HANDLE(VkQueue)
347VK_DEFINE_HANDLE(VkCommandBuffer)
348VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory)
349VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool)
350VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer)
351VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView)
352VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage)
353VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView)
354VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule)
355VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline)
356VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout)
357VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler)
358VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet)
359VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout)
360VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool)
361VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence)
362VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore)
363VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent)
364VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool)
365VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer)
366VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass)
367VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache)
368VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplate)
369VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversion)
370VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPrivateDataSlot)
371VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
372VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR)
373VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT)
374typedef enum VkAttachmentLoadOp {
375 VK_ATTACHMENT_LOAD_OP_LOAD = 0,
376 VK_ATTACHMENT_LOAD_OP_CLEAR = 1,
377 VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2,
378 VK_ATTACHMENT_LOAD_OP_MAX_ENUM = 0x7FFFFFFF
379} VkAttachmentLoadOp;
380typedef enum VkAttachmentStoreOp {
381 VK_ATTACHMENT_STORE_OP_STORE = 0,
382 VK_ATTACHMENT_STORE_OP_DONT_CARE = 1,
383 VK_ATTACHMENT_STORE_OP_NONE = 1000301000,
384 VK_ATTACHMENT_STORE_OP_MAX_ENUM = 0x7FFFFFFF
385} VkAttachmentStoreOp;
386typedef enum VkBlendFactor {
387 VK_BLEND_FACTOR_ZERO = 0,
388 VK_BLEND_FACTOR_ONE = 1,
389 VK_BLEND_FACTOR_SRC_COLOR = 2,
390 VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 3,
391 VK_BLEND_FACTOR_DST_COLOR = 4,
392 VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR = 5,
393 VK_BLEND_FACTOR_SRC_ALPHA = 6,
394 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 7,
395 VK_BLEND_FACTOR_DST_ALPHA = 8,
396 VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 9,
397 VK_BLEND_FACTOR_CONSTANT_COLOR = 10,
398 VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR = 11,
399 VK_BLEND_FACTOR_CONSTANT_ALPHA = 12,
400 VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = 13,
401 VK_BLEND_FACTOR_SRC_ALPHA_SATURATE = 14,
402 VK_BLEND_FACTOR_SRC1_COLOR = 15,
403 VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR = 16,
404 VK_BLEND_FACTOR_SRC1_ALPHA = 17,
405 VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18,
406 VK_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF
407} VkBlendFactor;
408typedef enum VkBlendOp {
409 VK_BLEND_OP_ADD = 0,
410 VK_BLEND_OP_SUBTRACT = 1,
411 VK_BLEND_OP_REVERSE_SUBTRACT = 2,
412 VK_BLEND_OP_MIN = 3,
413 VK_BLEND_OP_MAX = 4,
414 VK_BLEND_OP_MAX_ENUM = 0x7FFFFFFF
415} VkBlendOp;
416typedef enum VkBorderColor {
417 VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0,
418 VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1,
419 VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2,
420 VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3,
421 VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4,
422 VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5,
423 VK_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF
424} VkBorderColor;
425typedef enum VkFramebufferCreateFlagBits {
426 VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT = 1,
427 VK_FRAMEBUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
428} VkFramebufferCreateFlagBits;
429typedef enum VkPipelineCacheHeaderVersion {
430 VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1,
431 VK_PIPELINE_CACHE_HEADER_VERSION_MAX_ENUM = 0x7FFFFFFF
432} VkPipelineCacheHeaderVersion;
433typedef enum VkPipelineCacheCreateFlagBits {
434 VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT = 1,
435 VK_PIPELINE_CACHE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
436} VkPipelineCacheCreateFlagBits;
437typedef enum VkPipelineShaderStageCreateFlagBits {
438 VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT = 1,
439 VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT = 2,
440 VK_PIPELINE_SHADER_STAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
441} VkPipelineShaderStageCreateFlagBits;
442typedef enum VkDescriptorSetLayoutCreateFlagBits {
443 VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT = 2,
444 VK_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
445} VkDescriptorSetLayoutCreateFlagBits;
446typedef enum VkInstanceCreateFlagBits {
447 VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR = 1,
448 VK_INSTANCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
449} VkInstanceCreateFlagBits;
450typedef enum VkDeviceQueueCreateFlagBits {
451 VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 1,
452 VK_DEVICE_QUEUE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
453} VkDeviceQueueCreateFlagBits;
454typedef enum VkBufferCreateFlagBits {
455 VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 1,
456 VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 2,
457 VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 4,
458 VK_BUFFER_CREATE_PROTECTED_BIT = 8,
459 VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 16,
460 VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
461} VkBufferCreateFlagBits;
462typedef enum VkBufferUsageFlagBits {
463 VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 1,
464 VK_BUFFER_USAGE_TRANSFER_DST_BIT = 2,
465 VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 4,
466 VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 8,
467 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 16,
468 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 32,
469 VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 64,
470 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 128,
471 VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 256,
472 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT = 131072,
473 VK_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
474} VkBufferUsageFlagBits;
475typedef enum VkColorComponentFlagBits {
476 VK_COLOR_COMPONENT_R_BIT = 1,
477 VK_COLOR_COMPONENT_G_BIT = 2,
478 VK_COLOR_COMPONENT_B_BIT = 4,
479 VK_COLOR_COMPONENT_A_BIT = 8,
480 VK_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
481} VkColorComponentFlagBits;
482typedef enum VkComponentSwizzle {
483 VK_COMPONENT_SWIZZLE_IDENTITY = 0,
484 VK_COMPONENT_SWIZZLE_ZERO = 1,
485 VK_COMPONENT_SWIZZLE_ONE = 2,
486 VK_COMPONENT_SWIZZLE_R = 3,
487 VK_COMPONENT_SWIZZLE_G = 4,
488 VK_COMPONENT_SWIZZLE_B = 5,
489 VK_COMPONENT_SWIZZLE_A = 6,
490 VK_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF
491} VkComponentSwizzle;
492typedef enum VkCommandPoolCreateFlagBits {
493 VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 1,
494 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 2,
495 VK_COMMAND_POOL_CREATE_PROTECTED_BIT = 4,
496 VK_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
497} VkCommandPoolCreateFlagBits;
498typedef enum VkCommandPoolResetFlagBits {
499 VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 1,
500 VK_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
501} VkCommandPoolResetFlagBits;
502typedef enum VkCommandBufferResetFlagBits {
503 VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 1,
504 VK_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
505} VkCommandBufferResetFlagBits;
506typedef enum VkCommandBufferLevel {
507 VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0,
508 VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1,
509 VK_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF
510} VkCommandBufferLevel;
511typedef enum VkCommandBufferUsageFlagBits {
512 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 1,
513 VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 2,
514 VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 4,
515 VK_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
516} VkCommandBufferUsageFlagBits;
517typedef enum VkCompareOp {
518 VK_COMPARE_OP_NEVER = 0,
519 VK_COMPARE_OP_LESS = 1,
520 VK_COMPARE_OP_EQUAL = 2,
521 VK_COMPARE_OP_LESS_OR_EQUAL = 3,
522 VK_COMPARE_OP_GREATER = 4,
523 VK_COMPARE_OP_NOT_EQUAL = 5,
524 VK_COMPARE_OP_GREATER_OR_EQUAL = 6,
525 VK_COMPARE_OP_ALWAYS = 7,
526 VK_COMPARE_OP_MAX_ENUM = 0x7FFFFFFF
527} VkCompareOp;
528typedef enum VkCullModeFlagBits {
529 VK_CULL_MODE_NONE = 0,
530 VK_CULL_MODE_FRONT_BIT = 1,
531 VK_CULL_MODE_BACK_BIT = 2,
532 VK_CULL_MODE_FRONT_AND_BACK = 0x00000003,
533 VK_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
534} VkCullModeFlagBits;
535typedef enum VkDescriptorType {
536 VK_DESCRIPTOR_TYPE_SAMPLER = 0,
537 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1,
538 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2,
539 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3,
540 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4,
541 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5,
542 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6,
543 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7,
544 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8,
545 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9,
546 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10,
547 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK = 1000138000,
548 VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF
549} VkDescriptorType;
550typedef enum VkDynamicState {
551 VK_DYNAMIC_STATE_VIEWPORT = 0,
552 VK_DYNAMIC_STATE_SCISSOR = 1,
553 VK_DYNAMIC_STATE_LINE_WIDTH = 2,
554 VK_DYNAMIC_STATE_DEPTH_BIAS = 3,
555 VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4,
556 VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5,
557 VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6,
558 VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7,
559 VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8,
560 VK_DYNAMIC_STATE_CULL_MODE = 1000267000,
561 VK_DYNAMIC_STATE_FRONT_FACE = 1000267001,
562 VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY = 1000267002,
563 VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT = 1000267003,
564 VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT = 1000267004,
565 VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE = 1000267005,
566 VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE = 1000267006,
567 VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE = 1000267007,
568 VK_DYNAMIC_STATE_DEPTH_COMPARE_OP = 1000267008,
569 VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE = 1000267009,
570 VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE = 1000267010,
571 VK_DYNAMIC_STATE_STENCIL_OP = 1000267011,
572 VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE = 1000377001,
573 VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE = 1000377002,
574 VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE = 1000377004,
575 VK_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF
576} VkDynamicState;
577typedef enum VkFenceCreateFlagBits {
578 VK_FENCE_CREATE_SIGNALED_BIT = 1,
579 VK_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
580} VkFenceCreateFlagBits;
581typedef enum VkPolygonMode {
582 VK_POLYGON_MODE_FILL = 0,
583 VK_POLYGON_MODE_LINE = 1,
584 VK_POLYGON_MODE_POINT = 2,
585 VK_POLYGON_MODE_MAX_ENUM = 0x7FFFFFFF
586} VkPolygonMode;
587typedef enum VkFormat {
588 VK_FORMAT_UNDEFINED = 0,
589 VK_FORMAT_R4G4_UNORM_PACK8 = 1,
590 VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2,
591 VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3,
592 VK_FORMAT_R5G6B5_UNORM_PACK16 = 4,
593 VK_FORMAT_B5G6R5_UNORM_PACK16 = 5,
594 VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6,
595 VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7,
596 VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8,
597 VK_FORMAT_R8_UNORM = 9,
598 VK_FORMAT_R8_SNORM = 10,
599 VK_FORMAT_R8_USCALED = 11,
600 VK_FORMAT_R8_SSCALED = 12,
601 VK_FORMAT_R8_UINT = 13,
602 VK_FORMAT_R8_SINT = 14,
603 VK_FORMAT_R8_SRGB = 15,
604 VK_FORMAT_R8G8_UNORM = 16,
605 VK_FORMAT_R8G8_SNORM = 17,
606 VK_FORMAT_R8G8_USCALED = 18,
607 VK_FORMAT_R8G8_SSCALED = 19,
608 VK_FORMAT_R8G8_UINT = 20,
609 VK_FORMAT_R8G8_SINT = 21,
610 VK_FORMAT_R8G8_SRGB = 22,
611 VK_FORMAT_R8G8B8_UNORM = 23,
612 VK_FORMAT_R8G8B8_SNORM = 24,
613 VK_FORMAT_R8G8B8_USCALED = 25,
614 VK_FORMAT_R8G8B8_SSCALED = 26,
615 VK_FORMAT_R8G8B8_UINT = 27,
616 VK_FORMAT_R8G8B8_SINT = 28,
617 VK_FORMAT_R8G8B8_SRGB = 29,
618 VK_FORMAT_B8G8R8_UNORM = 30,
619 VK_FORMAT_B8G8R8_SNORM = 31,
620 VK_FORMAT_B8G8R8_USCALED = 32,
621 VK_FORMAT_B8G8R8_SSCALED = 33,
622 VK_FORMAT_B8G8R8_UINT = 34,
623 VK_FORMAT_B8G8R8_SINT = 35,
624 VK_FORMAT_B8G8R8_SRGB = 36,
625 VK_FORMAT_R8G8B8A8_UNORM = 37,
626 VK_FORMAT_R8G8B8A8_SNORM = 38,
627 VK_FORMAT_R8G8B8A8_USCALED = 39,
628 VK_FORMAT_R8G8B8A8_SSCALED = 40,
629 VK_FORMAT_R8G8B8A8_UINT = 41,
630 VK_FORMAT_R8G8B8A8_SINT = 42,
631 VK_FORMAT_R8G8B8A8_SRGB = 43,
632 VK_FORMAT_B8G8R8A8_UNORM = 44,
633 VK_FORMAT_B8G8R8A8_SNORM = 45,
634 VK_FORMAT_B8G8R8A8_USCALED = 46,
635 VK_FORMAT_B8G8R8A8_SSCALED = 47,
636 VK_FORMAT_B8G8R8A8_UINT = 48,
637 VK_FORMAT_B8G8R8A8_SINT = 49,
638 VK_FORMAT_B8G8R8A8_SRGB = 50,
639 VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51,
640 VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52,
641 VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53,
642 VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54,
643 VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55,
644 VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56,
645 VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57,
646 VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58,
647 VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59,
648 VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60,
649 VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61,
650 VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62,
651 VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63,
652 VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64,
653 VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65,
654 VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66,
655 VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67,
656 VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68,
657 VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69,
658 VK_FORMAT_R16_UNORM = 70,
659 VK_FORMAT_R16_SNORM = 71,
660 VK_FORMAT_R16_USCALED = 72,
661 VK_FORMAT_R16_SSCALED = 73,
662 VK_FORMAT_R16_UINT = 74,
663 VK_FORMAT_R16_SINT = 75,
664 VK_FORMAT_R16_SFLOAT = 76,
665 VK_FORMAT_R16G16_UNORM = 77,
666 VK_FORMAT_R16G16_SNORM = 78,
667 VK_FORMAT_R16G16_USCALED = 79,
668 VK_FORMAT_R16G16_SSCALED = 80,
669 VK_FORMAT_R16G16_UINT = 81,
670 VK_FORMAT_R16G16_SINT = 82,
671 VK_FORMAT_R16G16_SFLOAT = 83,
672 VK_FORMAT_R16G16B16_UNORM = 84,
673 VK_FORMAT_R16G16B16_SNORM = 85,
674 VK_FORMAT_R16G16B16_USCALED = 86,
675 VK_FORMAT_R16G16B16_SSCALED = 87,
676 VK_FORMAT_R16G16B16_UINT = 88,
677 VK_FORMAT_R16G16B16_SINT = 89,
678 VK_FORMAT_R16G16B16_SFLOAT = 90,
679 VK_FORMAT_R16G16B16A16_UNORM = 91,
680 VK_FORMAT_R16G16B16A16_SNORM = 92,
681 VK_FORMAT_R16G16B16A16_USCALED = 93,
682 VK_FORMAT_R16G16B16A16_SSCALED = 94,
683 VK_FORMAT_R16G16B16A16_UINT = 95,
684 VK_FORMAT_R16G16B16A16_SINT = 96,
685 VK_FORMAT_R16G16B16A16_SFLOAT = 97,
686 VK_FORMAT_R32_UINT = 98,
687 VK_FORMAT_R32_SINT = 99,
688 VK_FORMAT_R32_SFLOAT = 100,
689 VK_FORMAT_R32G32_UINT = 101,
690 VK_FORMAT_R32G32_SINT = 102,
691 VK_FORMAT_R32G32_SFLOAT = 103,
692 VK_FORMAT_R32G32B32_UINT = 104,
693 VK_FORMAT_R32G32B32_SINT = 105,
694 VK_FORMAT_R32G32B32_SFLOAT = 106,
695 VK_FORMAT_R32G32B32A32_UINT = 107,
696 VK_FORMAT_R32G32B32A32_SINT = 108,
697 VK_FORMAT_R32G32B32A32_SFLOAT = 109,
698 VK_FORMAT_R64_UINT = 110,
699 VK_FORMAT_R64_SINT = 111,
700 VK_FORMAT_R64_SFLOAT = 112,
701 VK_FORMAT_R64G64_UINT = 113,
702 VK_FORMAT_R64G64_SINT = 114,
703 VK_FORMAT_R64G64_SFLOAT = 115,
704 VK_FORMAT_R64G64B64_UINT = 116,
705 VK_FORMAT_R64G64B64_SINT = 117,
706 VK_FORMAT_R64G64B64_SFLOAT = 118,
707 VK_FORMAT_R64G64B64A64_UINT = 119,
708 VK_FORMAT_R64G64B64A64_SINT = 120,
709 VK_FORMAT_R64G64B64A64_SFLOAT = 121,
710 VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122,
711 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123,
712 VK_FORMAT_D16_UNORM = 124,
713 VK_FORMAT_X8_D24_UNORM_PACK32 = 125,
714 VK_FORMAT_D32_SFLOAT = 126,
715 VK_FORMAT_S8_UINT = 127,
716 VK_FORMAT_D16_UNORM_S8_UINT = 128,
717 VK_FORMAT_D24_UNORM_S8_UINT = 129,
718 VK_FORMAT_D32_SFLOAT_S8_UINT = 130,
719 VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131,
720 VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132,
721 VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133,
722 VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134,
723 VK_FORMAT_BC2_UNORM_BLOCK = 135,
724 VK_FORMAT_BC2_SRGB_BLOCK = 136,
725 VK_FORMAT_BC3_UNORM_BLOCK = 137,
726 VK_FORMAT_BC3_SRGB_BLOCK = 138,
727 VK_FORMAT_BC4_UNORM_BLOCK = 139,
728 VK_FORMAT_BC4_SNORM_BLOCK = 140,
729 VK_FORMAT_BC5_UNORM_BLOCK = 141,
730 VK_FORMAT_BC5_SNORM_BLOCK = 142,
731 VK_FORMAT_BC6H_UFLOAT_BLOCK = 143,
732 VK_FORMAT_BC6H_SFLOAT_BLOCK = 144,
733 VK_FORMAT_BC7_UNORM_BLOCK = 145,
734 VK_FORMAT_BC7_SRGB_BLOCK = 146,
735 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147,
736 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148,
737 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149,
738 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150,
739 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151,
740 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152,
741 VK_FORMAT_EAC_R11_UNORM_BLOCK = 153,
742 VK_FORMAT_EAC_R11_SNORM_BLOCK = 154,
743 VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155,
744 VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156,
745 VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157,
746 VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158,
747 VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159,
748 VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160,
749 VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161,
750 VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162,
751 VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163,
752 VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164,
753 VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165,
754 VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166,
755 VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167,
756 VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168,
757 VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169,
758 VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170,
759 VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171,
760 VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172,
761 VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173,
762 VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174,
763 VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175,
764 VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176,
765 VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177,
766 VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178,
767 VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179,
768 VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180,
769 VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181,
770 VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182,
771 VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183,
772 VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184,
773 VK_FORMAT_G8B8G8R8_422_UNORM = 1000156000,
774 VK_FORMAT_B8G8R8G8_422_UNORM = 1000156001,
775 VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM = 1000156002,
776 VK_FORMAT_G8_B8R8_2PLANE_420_UNORM = 1000156003,
777 VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM = 1000156004,
778 VK_FORMAT_G8_B8R8_2PLANE_422_UNORM = 1000156005,
779 VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM = 1000156006,
780 VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007,
781 VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008,
782 VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009,
783 VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010,
784 VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011,
785 VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012,
786 VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013,
787 VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014,
788 VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015,
789 VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016,
790 VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017,
791 VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018,
792 VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019,
793 VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020,
794 VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021,
795 VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022,
796 VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023,
797 VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024,
798 VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025,
799 VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026,
800 VK_FORMAT_G16B16G16R16_422_UNORM = 1000156027,
801 VK_FORMAT_B16G16R16G16_422_UNORM = 1000156028,
802 VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM = 1000156029,
803 VK_FORMAT_G16_B16R16_2PLANE_420_UNORM = 1000156030,
804 VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM = 1000156031,
805 VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032,
806 VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033,
807 VK_FORMAT_G8_B8R8_2PLANE_444_UNORM = 1000330000,
808 VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16 = 1000330001,
809 VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16 = 1000330002,
810 VK_FORMAT_G16_B16R16_2PLANE_444_UNORM = 1000330003,
811 VK_FORMAT_A4R4G4B4_UNORM_PACK16 = 1000340000,
812 VK_FORMAT_A4B4G4R4_UNORM_PACK16 = 1000340001,
813 VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK = 1000066000,
814 VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK = 1000066001,
815 VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK = 1000066002,
816 VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK = 1000066003,
817 VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK = 1000066004,
818 VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK = 1000066005,
819 VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK = 1000066006,
820 VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK = 1000066007,
821 VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK = 1000066008,
822 VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK = 1000066009,
823 VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK = 1000066010,
824 VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK = 1000066011,
825 VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK = 1000066012,
826 VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK = 1000066013,
827 VK_FORMAT_MAX_ENUM = 0x7FFFFFFF
828} VkFormat;
829typedef enum VkFormatFeatureFlagBits {
830 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 1,
831 VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 2,
832 VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 4,
833 VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 8,
834 VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 16,
835 VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 32,
836 VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 64,
837 VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 128,
838 VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 256,
839 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 512,
840 VK_FORMAT_FEATURE_BLIT_SRC_BIT = 1024,
841 VK_FORMAT_FEATURE_BLIT_DST_BIT = 2048,
842 VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 4096,
843 VK_FORMAT_FEATURE_TRANSFER_SRC_BIT = 16384,
844 VK_FORMAT_FEATURE_TRANSFER_DST_BIT = 32768,
845 VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT = 131072,
846 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT = 262144,
847 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT = 524288,
848 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT = 1048576,
849 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT = 2097152,
850 VK_FORMAT_FEATURE_DISJOINT_BIT = 4194304,
851 VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 8388608,
852 VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT = 65536,
853 VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
854} VkFormatFeatureFlagBits;
855typedef enum VkFrontFace {
856 VK_FRONT_FACE_COUNTER_CLOCKWISE = 0,
857 VK_FRONT_FACE_CLOCKWISE = 1,
858 VK_FRONT_FACE_MAX_ENUM = 0x7FFFFFFF
859} VkFrontFace;
860typedef enum VkImageAspectFlagBits {
861 VK_IMAGE_ASPECT_COLOR_BIT = 1,
862 VK_IMAGE_ASPECT_DEPTH_BIT = 2,
863 VK_IMAGE_ASPECT_STENCIL_BIT = 4,
864 VK_IMAGE_ASPECT_METADATA_BIT = 8,
865 VK_IMAGE_ASPECT_PLANE_0_BIT = 16,
866 VK_IMAGE_ASPECT_PLANE_1_BIT = 32,
867 VK_IMAGE_ASPECT_PLANE_2_BIT = 64,
868 VK_IMAGE_ASPECT_NONE = 0,
869 VK_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
870} VkImageAspectFlagBits;
871typedef enum VkImageCreateFlagBits {
872 VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 1,
873 VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 2,
874 VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 4,
875 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 8,
876 VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 16,
877 VK_IMAGE_CREATE_ALIAS_BIT = 1024,
878 VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT = 64,
879 VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT = 32,
880 VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT = 128,
881 VK_IMAGE_CREATE_EXTENDED_USAGE_BIT = 256,
882 VK_IMAGE_CREATE_PROTECTED_BIT = 2048,
883 VK_IMAGE_CREATE_DISJOINT_BIT = 512,
884 VK_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
885} VkImageCreateFlagBits;
886typedef enum VkImageLayout {
887 VK_IMAGE_LAYOUT_UNDEFINED = 0,
888 VK_IMAGE_LAYOUT_GENERAL = 1,
889 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2,
890 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3,
891 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4,
892 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5,
893 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6,
894 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7,
895 VK_IMAGE_LAYOUT_PREINITIALIZED = 8,
896 VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000,
897 VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001,
898 VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL = 1000241000,
899 VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL = 1000241001,
900 VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL = 1000241002,
901 VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL = 1000241003,
902 VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL = 1000314000,
903 VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL = 1000314001,
904 VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002,
905 VK_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF
906} VkImageLayout;
907typedef enum VkImageTiling {
908 VK_IMAGE_TILING_OPTIMAL = 0,
909 VK_IMAGE_TILING_LINEAR = 1,
910 VK_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF
911} VkImageTiling;
912typedef enum VkImageType {
913 VK_IMAGE_TYPE_1D = 0,
914 VK_IMAGE_TYPE_2D = 1,
915 VK_IMAGE_TYPE_3D = 2,
916 VK_IMAGE_TYPE_MAX_ENUM = 0x7FFFFFFF
917} VkImageType;
918typedef enum VkImageUsageFlagBits {
919 VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 1,
920 VK_IMAGE_USAGE_TRANSFER_DST_BIT = 2,
921 VK_IMAGE_USAGE_SAMPLED_BIT = 4,
922 VK_IMAGE_USAGE_STORAGE_BIT = 8,
923 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 16,
924 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 32,
925 VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 64,
926 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 128,
927 VK_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
928} VkImageUsageFlagBits;
929typedef enum VkImageViewType {
930 VK_IMAGE_VIEW_TYPE_1D = 0,
931 VK_IMAGE_VIEW_TYPE_2D = 1,
932 VK_IMAGE_VIEW_TYPE_3D = 2,
933 VK_IMAGE_VIEW_TYPE_CUBE = 3,
934 VK_IMAGE_VIEW_TYPE_1D_ARRAY = 4,
935 VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5,
936 VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6,
937 VK_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF
938} VkImageViewType;
939typedef enum VkSharingMode {
940 VK_SHARING_MODE_EXCLUSIVE = 0,
941 VK_SHARING_MODE_CONCURRENT = 1,
942 VK_SHARING_MODE_MAX_ENUM = 0x7FFFFFFF
943} VkSharingMode;
944typedef enum VkIndexType {
945 VK_INDEX_TYPE_UINT16 = 0,
946 VK_INDEX_TYPE_UINT32 = 1,
947 VK_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF
948} VkIndexType;
949typedef enum VkLogicOp {
950 VK_LOGIC_OP_CLEAR = 0,
951 VK_LOGIC_OP_AND = 1,
952 VK_LOGIC_OP_AND_REVERSE = 2,
953 VK_LOGIC_OP_COPY = 3,
954 VK_LOGIC_OP_AND_INVERTED = 4,
955 VK_LOGIC_OP_NO_OP = 5,
956 VK_LOGIC_OP_XOR = 6,
957 VK_LOGIC_OP_OR = 7,
958 VK_LOGIC_OP_NOR = 8,
959 VK_LOGIC_OP_EQUIVALENT = 9,
960 VK_LOGIC_OP_INVERT = 10,
961 VK_LOGIC_OP_OR_REVERSE = 11,
962 VK_LOGIC_OP_COPY_INVERTED = 12,
963 VK_LOGIC_OP_OR_INVERTED = 13,
964 VK_LOGIC_OP_NAND = 14,
965 VK_LOGIC_OP_SET = 15,
966 VK_LOGIC_OP_MAX_ENUM = 0x7FFFFFFF
967} VkLogicOp;
968typedef enum VkMemoryHeapFlagBits {
969 VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 1,
970 VK_MEMORY_HEAP_MULTI_INSTANCE_BIT = 2,
971 VK_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
972} VkMemoryHeapFlagBits;
973typedef enum VkAccessFlagBits {
974 VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 1,
975 VK_ACCESS_INDEX_READ_BIT = 2,
976 VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 4,
977 VK_ACCESS_UNIFORM_READ_BIT = 8,
978 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT = 16,
979 VK_ACCESS_SHADER_READ_BIT = 32,
980 VK_ACCESS_SHADER_WRITE_BIT = 64,
981 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT = 128,
982 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT = 256,
983 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 512,
984 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 1024,
985 VK_ACCESS_TRANSFER_READ_BIT = 2048,
986 VK_ACCESS_TRANSFER_WRITE_BIT = 4096,
987 VK_ACCESS_HOST_READ_BIT = 8192,
988 VK_ACCESS_HOST_WRITE_BIT = 16384,
989 VK_ACCESS_MEMORY_READ_BIT = 32768,
990 VK_ACCESS_MEMORY_WRITE_BIT = 65536,
991 VK_ACCESS_NONE = 0,
992 VK_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
993} VkAccessFlagBits;
994typedef enum VkMemoryPropertyFlagBits {
995 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 1,
996 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 2,
997 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 4,
998 VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 8,
999 VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 16,
1000 VK_MEMORY_PROPERTY_PROTECTED_BIT = 32,
1001 VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1002} VkMemoryPropertyFlagBits;
1003typedef enum VkPhysicalDeviceType {
1004 VK_PHYSICAL_DEVICE_TYPE_OTHER = 0,
1005 VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1,
1006 VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2,
1007 VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3,
1008 VK_PHYSICAL_DEVICE_TYPE_CPU = 4,
1009 VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF
1010} VkPhysicalDeviceType;
1011typedef enum VkPipelineBindPoint {
1012 VK_PIPELINE_BIND_POINT_GRAPHICS = 0,
1013 VK_PIPELINE_BIND_POINT_COMPUTE = 1,
1014 VK_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF
1015} VkPipelineBindPoint;
1016typedef enum VkPipelineCreateFlagBits {
1017 VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 1,
1018 VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 2,
1019 VK_PIPELINE_CREATE_DERIVATIVE_BIT = 4,
1020 VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT = 8,
1021 VK_PIPELINE_CREATE_DISPATCH_BASE_BIT = 16,
1022 VK_PIPELINE_CREATE_DISPATCH_BASE = VK_PIPELINE_CREATE_DISPATCH_BASE_BIT,
1023 VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT = 256,
1024 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT = 512,
1025 VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1026} VkPipelineCreateFlagBits;
1027typedef enum VkPrimitiveTopology {
1028 VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0,
1029 VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1,
1030 VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2,
1031 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3,
1032 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4,
1033 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5,
1034 VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6,
1035 VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7,
1036 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8,
1037 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9,
1038 VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10,
1039 VK_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF
1040} VkPrimitiveTopology;
1041typedef enum VkQueryControlFlagBits {
1042 VK_QUERY_CONTROL_PRECISE_BIT = 1,
1043 VK_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1044} VkQueryControlFlagBits;
1045typedef enum VkQueryPipelineStatisticFlagBits {
1046 VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 1,
1047 VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 2,
1048 VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 4,
1049 VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 8,
1050 VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 16,
1051 VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 32,
1052 VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 64,
1053 VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 128,
1054 VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 256,
1055 VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 512,
1056 VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 1024,
1057 VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1058} VkQueryPipelineStatisticFlagBits;
1059typedef enum VkQueryResultFlagBits {
1060 VK_QUERY_RESULT_64_BIT = 1,
1061 VK_QUERY_RESULT_WAIT_BIT = 2,
1062 VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 4,
1063 VK_QUERY_RESULT_PARTIAL_BIT = 8,
1064 VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1065} VkQueryResultFlagBits;
1066typedef enum VkQueryType {
1067 VK_QUERY_TYPE_OCCLUSION = 0,
1068 VK_QUERY_TYPE_PIPELINE_STATISTICS = 1,
1069 VK_QUERY_TYPE_TIMESTAMP = 2,
1070 VK_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF
1071} VkQueryType;
1072typedef enum VkQueueFlagBits {
1073 VK_QUEUE_GRAPHICS_BIT = 1,
1074 VK_QUEUE_COMPUTE_BIT = 2,
1075 VK_QUEUE_TRANSFER_BIT = 4,
1076 VK_QUEUE_SPARSE_BINDING_BIT = 8,
1077 VK_QUEUE_PROTECTED_BIT = 16,
1078 VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1079} VkQueueFlagBits;
1080typedef enum VkSubpassContents {
1081 VK_SUBPASS_CONTENTS_INLINE = 0,
1082 VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1,
1083 VK_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF
1084} VkSubpassContents;
1085typedef enum VkResult {
1086 VK_SUCCESS = 0,
1087 VK_NOT_READY = 1,
1088 VK_TIMEOUT = 2,
1089 VK_EVENT_SET = 3,
1090 VK_EVENT_RESET = 4,
1091 VK_INCOMPLETE = 5,
1092 VK_ERROR_OUT_OF_HOST_MEMORY = -1,
1093 VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
1094 VK_ERROR_INITIALIZATION_FAILED = -3,
1095 VK_ERROR_DEVICE_LOST = -4,
1096 VK_ERROR_MEMORY_MAP_FAILED = -5,
1097 VK_ERROR_LAYER_NOT_PRESENT = -6,
1098 VK_ERROR_EXTENSION_NOT_PRESENT = -7,
1099 VK_ERROR_FEATURE_NOT_PRESENT = -8,
1100 VK_ERROR_INCOMPATIBLE_DRIVER = -9,
1101 VK_ERROR_TOO_MANY_OBJECTS = -10,
1102 VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
1103 VK_ERROR_FRAGMENTED_POOL = -12,
1104 VK_ERROR_UNKNOWN = -13,
1105 VK_ERROR_OUT_OF_POOL_MEMORY = -1000069000,
1106 VK_ERROR_INVALID_EXTERNAL_HANDLE = -1000072003,
1107 VK_ERROR_FRAGMENTATION = -1000161000,
1108 VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS = -1000257000,
1109 VK_PIPELINE_COMPILE_REQUIRED = 1000297000,
1110 VK_ERROR_SURFACE_LOST_KHR = -1000000000,
1111 VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
1112 VK_SUBOPTIMAL_KHR = 1000001003,
1113 VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
1114 VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
1115 VK_RESULT_MAX_ENUM = 0x7FFFFFFF
1116} VkResult;
1117typedef enum VkShaderStageFlagBits {
1118 VK_SHADER_STAGE_VERTEX_BIT = 1,
1119 VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 2,
1120 VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 4,
1121 VK_SHADER_STAGE_GEOMETRY_BIT = 8,
1122 VK_SHADER_STAGE_FRAGMENT_BIT = 16,
1123 VK_SHADER_STAGE_COMPUTE_BIT = 32,
1124 VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
1125 VK_SHADER_STAGE_ALL = 0x7FFFFFFF,
1126 VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1127} VkShaderStageFlagBits;
1128typedef enum VkSparseMemoryBindFlagBits {
1129 VK_SPARSE_MEMORY_BIND_METADATA_BIT = 1,
1130 VK_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1131} VkSparseMemoryBindFlagBits;
1132typedef enum VkStencilFaceFlagBits {
1133 VK_STENCIL_FACE_FRONT_BIT = 1,
1134 VK_STENCIL_FACE_BACK_BIT = 2,
1135 VK_STENCIL_FACE_FRONT_AND_BACK = 0x00000003,
1136 VK_STENCIL_FRONT_AND_BACK = VK_STENCIL_FACE_FRONT_AND_BACK,
1137 VK_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1138} VkStencilFaceFlagBits;
1139typedef enum VkStencilOp {
1140 VK_STENCIL_OP_KEEP = 0,
1141 VK_STENCIL_OP_ZERO = 1,
1142 VK_STENCIL_OP_REPLACE = 2,
1143 VK_STENCIL_OP_INCREMENT_AND_CLAMP = 3,
1144 VK_STENCIL_OP_DECREMENT_AND_CLAMP = 4,
1145 VK_STENCIL_OP_INVERT = 5,
1146 VK_STENCIL_OP_INCREMENT_AND_WRAP = 6,
1147 VK_STENCIL_OP_DECREMENT_AND_WRAP = 7,
1148 VK_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF
1149} VkStencilOp;
1150typedef enum VkStructureType {
1151 VK_STRUCTURE_TYPE_APPLICATION_INFO = 0,
1152 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1,
1153 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2,
1154 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3,
1155 VK_STRUCTURE_TYPE_SUBMIT_INFO = 4,
1156 VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5,
1157 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 6,
1158 VK_STRUCTURE_TYPE_BIND_SPARSE_INFO = 7,
1159 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8,
1160 VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 9,
1161 VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10,
1162 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 11,
1163 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12,
1164 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 13,
1165 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 14,
1166 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 15,
1167 VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16,
1168 VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 17,
1169 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 18,
1170 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19,
1171 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20,
1172 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21,
1173 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22,
1174 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23,
1175 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24,
1176 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25,
1177 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26,
1178 VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27,
1179 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 28,
1180 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29,
1181 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30,
1182 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 31,
1183 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32,
1184 VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33,
1185 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34,
1186 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35,
1187 VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 36,
1188 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 37,
1189 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 38,
1190 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39,
1191 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40,
1192 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO = 41,
1193 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42,
1194 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43,
1195 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 44,
1196 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 45,
1197 VK_STRUCTURE_TYPE_MEMORY_BARRIER = 46,
1198 VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 47,
1199 VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 48,
1200 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000,
1201 VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO = 1000157000,
1202 VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO = 1000157001,
1203 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000,
1204 VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS = 1000127000,
1205 VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001,
1206 VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO = 1000060000,
1207 VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003,
1208 VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004,
1209 VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO = 1000060005,
1210 VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006,
1211 VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013,
1212 VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014,
1213 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000,
1214 VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001,
1215 VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000,
1216 VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001,
1217 VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002,
1218 VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 = 1000146003,
1219 VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004,
1220 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 = 1000059000,
1221 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001,
1222 VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2 = 1000059002,
1223 VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 = 1000059003,
1224 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004,
1225 VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2 = 1000059005,
1226 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006,
1227 VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007,
1228 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008,
1229 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000,
1230 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001,
1231 VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002,
1232 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003,
1233 VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000,
1234 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001,
1235 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002,
1236 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000,
1237 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES,
1238 VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO = 1000145000,
1239 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001,
1240 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002,
1241 VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2 = 1000145003,
1242 VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000,
1243 VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO = 1000156001,
1244 VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002,
1245 VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003,
1246 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004,
1247 VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005,
1248 VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000,
1249 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000,
1250 VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001,
1251 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002,
1252 VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES = 1000071003,
1253 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004,
1254 VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000,
1255 VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001,
1256 VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO = 1000072002,
1257 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000,
1258 VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES = 1000112001,
1259 VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO = 1000113000,
1260 VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO = 1000077000,
1261 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000,
1262 VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001,
1263 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000,
1264 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001,
1265 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000,
1266 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES,
1267 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES = 49,
1268 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES = 50,
1269 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES = 51,
1270 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES = 52,
1271 VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO = 1000147000,
1272 VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2 = 1000109000,
1273 VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2 = 1000109001,
1274 VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2 = 1000109002,
1275 VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2 = 1000109003,
1276 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2 = 1000109004,
1277 VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO = 1000109005,
1278 VK_STRUCTURE_TYPE_SUBPASS_END_INFO = 1000109006,
1279 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES = 1000177000,
1280 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES = 1000196000,
1281 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES = 1000180000,
1282 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES = 1000082000,
1283 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES = 1000197000,
1284 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO = 1000161000,
1285 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES = 1000161001,
1286 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES = 1000161002,
1287 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO = 1000161003,
1288 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT = 1000161004,
1289 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES = 1000199000,
1290 VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE = 1000199001,
1291 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES = 1000221000,
1292 VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO = 1000246000,
1293 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES = 1000130000,
1294 VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO = 1000130001,
1295 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES = 1000211000,
1296 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES = 1000108000,
1297 VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO = 1000108001,
1298 VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO = 1000108002,
1299 VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO = 1000108003,
1300 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES = 1000253000,
1301 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES = 1000175000,
1302 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES = 1000241000,
1303 VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT = 1000241001,
1304 VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT = 1000241002,
1305 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES = 1000261000,
1306 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES = 1000207000,
1307 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES = 1000207001,
1308 VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO = 1000207002,
1309 VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO = 1000207003,
1310 VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO = 1000207004,
1311 VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO = 1000207005,
1312 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES = 1000257000,
1313 VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO = 1000244001,
1314 VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO = 1000257002,
1315 VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO = 1000257003,
1316 VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO = 1000257004,
1317 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES = 53,
1318 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES = 54,
1319 VK_STRUCTURE_TYPE_PIPELINE_CREATION_FEEDBACK_CREATE_INFO = 1000192000,
1320 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES = 1000215000,
1321 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES = 1000245000,
1322 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES = 1000276000,
1323 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES = 1000295000,
1324 VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO = 1000295001,
1325 VK_STRUCTURE_TYPE_PRIVATE_DATA_SLOT_CREATE_INFO = 1000295002,
1326 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES = 1000297000,
1327 VK_STRUCTURE_TYPE_MEMORY_BARRIER_2 = 1000314000,
1328 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2 = 1000314001,
1329 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2 = 1000314002,
1330 VK_STRUCTURE_TYPE_DEPENDENCY_INFO = 1000314003,
1331 VK_STRUCTURE_TYPE_SUBMIT_INFO_2 = 1000314004,
1332 VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO = 1000314005,
1333 VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO = 1000314006,
1334 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES = 1000314007,
1335 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES = 1000325000,
1336 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES = 1000335000,
1337 VK_STRUCTURE_TYPE_COPY_BUFFER_INFO_2 = 1000337000,
1338 VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2 = 1000337001,
1339 VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2 = 1000337002,
1340 VK_STRUCTURE_TYPE_COPY_IMAGE_TO_BUFFER_INFO_2 = 1000337003,
1341 VK_STRUCTURE_TYPE_BLIT_IMAGE_INFO_2 = 1000337004,
1342 VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2 = 1000337005,
1343 VK_STRUCTURE_TYPE_BUFFER_COPY_2 = 1000337006,
1344 VK_STRUCTURE_TYPE_IMAGE_COPY_2 = 1000337007,
1345 VK_STRUCTURE_TYPE_IMAGE_BLIT_2 = 1000337008,
1346 VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2 = 1000337009,
1347 VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2 = 1000337010,
1348 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES = 1000225000,
1349 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO = 1000225001,
1350 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES = 1000225002,
1351 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES = 1000138000,
1352 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES = 1000138001,
1353 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK = 1000138002,
1354 VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO = 1000138003,
1355 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES = 1000066000,
1356 VK_STRUCTURE_TYPE_RENDERING_INFO = 1000044000,
1357 VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO = 1000044001,
1358 VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO = 1000044002,
1359 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES = 1000044003,
1360 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO = 1000044004,
1361 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES = 1000280000,
1362 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES = 1000280001,
1363 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES = 1000281001,
1364 VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3 = 1000360000,
1365 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES = 1000413000,
1366 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES = 1000413001,
1367 VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS = 1000413002,
1368 VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS = 1000413003,
1369 VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000,
1370 VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001,
1371 VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007,
1372 VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008,
1373 VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009,
1374 VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010,
1375 VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011,
1376 VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012,
1377 VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000,
1378 VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
1379 VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
1380} VkStructureType;
1381typedef enum VkSystemAllocationScope {
1382 VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
1383 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
1384 VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2,
1385 VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3,
1386 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4,
1387 VK_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF
1388} VkSystemAllocationScope;
1389typedef enum VkInternalAllocationType {
1390 VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0,
1391 VK_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF
1392} VkInternalAllocationType;
1393typedef enum VkSamplerAddressMode {
1394 VK_SAMPLER_ADDRESS_MODE_REPEAT = 0,
1395 VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1,
1396 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2,
1397 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3,
1398 VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE = 4,
1399 VK_SAMPLER_ADDRESS_MODE_MAX_ENUM = 0x7FFFFFFF
1400} VkSamplerAddressMode;
1401typedef enum VkFilter {
1402 VK_FILTER_NEAREST = 0,
1403 VK_FILTER_LINEAR = 1,
1404 VK_FILTER_MAX_ENUM = 0x7FFFFFFF
1405} VkFilter;
1406typedef enum VkSamplerMipmapMode {
1407 VK_SAMPLER_MIPMAP_MODE_NEAREST = 0,
1408 VK_SAMPLER_MIPMAP_MODE_LINEAR = 1,
1409 VK_SAMPLER_MIPMAP_MODE_MAX_ENUM = 0x7FFFFFFF
1410} VkSamplerMipmapMode;
1411typedef enum VkVertexInputRate {
1412 VK_VERTEX_INPUT_RATE_VERTEX = 0,
1413 VK_VERTEX_INPUT_RATE_INSTANCE = 1,
1414 VK_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF
1415} VkVertexInputRate;
1416typedef enum VkPipelineStageFlagBits {
1417 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 1,
1418 VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 2,
1419 VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 4,
1420 VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 8,
1421 VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 16,
1422 VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 32,
1423 VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 64,
1424 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 128,
1425 VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 256,
1426 VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 512,
1427 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 1024,
1428 VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 2048,
1429 VK_PIPELINE_STAGE_TRANSFER_BIT = 4096,
1430 VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 8192,
1431 VK_PIPELINE_STAGE_HOST_BIT = 16384,
1432 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 32768,
1433 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 65536,
1434 VK_PIPELINE_STAGE_NONE = 0,
1435 VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1436} VkPipelineStageFlagBits;
1437typedef enum VkSparseImageFormatFlagBits {
1438 VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 1,
1439 VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 2,
1440 VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 4,
1441 VK_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1442} VkSparseImageFormatFlagBits;
1443typedef enum VkSampleCountFlagBits {
1444 VK_SAMPLE_COUNT_1_BIT = 1,
1445 VK_SAMPLE_COUNT_2_BIT = 2,
1446 VK_SAMPLE_COUNT_4_BIT = 4,
1447 VK_SAMPLE_COUNT_8_BIT = 8,
1448 VK_SAMPLE_COUNT_16_BIT = 16,
1449 VK_SAMPLE_COUNT_32_BIT = 32,
1450 VK_SAMPLE_COUNT_64_BIT = 64,
1451 VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1452} VkSampleCountFlagBits;
1453typedef enum VkAttachmentDescriptionFlagBits {
1454 VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 1,
1455 VK_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1456} VkAttachmentDescriptionFlagBits;
1457typedef enum VkDescriptorPoolCreateFlagBits {
1458 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 1,
1459 VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT = 2,
1460 VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1461} VkDescriptorPoolCreateFlagBits;
1462typedef enum VkDependencyFlagBits {
1463 VK_DEPENDENCY_BY_REGION_BIT = 1,
1464 VK_DEPENDENCY_DEVICE_GROUP_BIT = 4,
1465 VK_DEPENDENCY_VIEW_LOCAL_BIT = 2,
1466 VK_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1467} VkDependencyFlagBits;
1468typedef enum VkObjectType {
1469 VK_OBJECT_TYPE_UNKNOWN = 0,
1470 VK_OBJECT_TYPE_INSTANCE = 1,
1471 VK_OBJECT_TYPE_PHYSICAL_DEVICE = 2,
1472 VK_OBJECT_TYPE_DEVICE = 3,
1473 VK_OBJECT_TYPE_QUEUE = 4,
1474 VK_OBJECT_TYPE_SEMAPHORE = 5,
1475 VK_OBJECT_TYPE_COMMAND_BUFFER = 6,
1476 VK_OBJECT_TYPE_FENCE = 7,
1477 VK_OBJECT_TYPE_DEVICE_MEMORY = 8,
1478 VK_OBJECT_TYPE_BUFFER = 9,
1479 VK_OBJECT_TYPE_IMAGE = 10,
1480 VK_OBJECT_TYPE_EVENT = 11,
1481 VK_OBJECT_TYPE_QUERY_POOL = 12,
1482 VK_OBJECT_TYPE_BUFFER_VIEW = 13,
1483 VK_OBJECT_TYPE_IMAGE_VIEW = 14,
1484 VK_OBJECT_TYPE_SHADER_MODULE = 15,
1485 VK_OBJECT_TYPE_PIPELINE_CACHE = 16,
1486 VK_OBJECT_TYPE_PIPELINE_LAYOUT = 17,
1487 VK_OBJECT_TYPE_RENDER_PASS = 18,
1488 VK_OBJECT_TYPE_PIPELINE = 19,
1489 VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 20,
1490 VK_OBJECT_TYPE_SAMPLER = 21,
1491 VK_OBJECT_TYPE_DESCRIPTOR_POOL = 22,
1492 VK_OBJECT_TYPE_DESCRIPTOR_SET = 23,
1493 VK_OBJECT_TYPE_FRAMEBUFFER = 24,
1494 VK_OBJECT_TYPE_COMMAND_POOL = 25,
1495 VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION = 1000156000,
1496 VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE = 1000085000,
1497 VK_OBJECT_TYPE_PRIVATE_DATA_SLOT = 1000295000,
1498 VK_OBJECT_TYPE_SURFACE_KHR = 1000000000,
1499 VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000,
1500 VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000,
1501 VK_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF
1502} VkObjectType;
1503typedef enum VkEventCreateFlagBits {
1504 VK_EVENT_CREATE_DEVICE_ONLY_BIT = 1,
1505 VK_EVENT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1506} VkEventCreateFlagBits;
1507typedef enum VkDescriptorUpdateTemplateType {
1508 VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET = 0,
1509 VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_MAX_ENUM = 0x7FFFFFFF
1510} VkDescriptorUpdateTemplateType;
1511typedef enum VkPointClippingBehavior {
1512 VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES = 0,
1513 VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY = 1,
1514 VK_POINT_CLIPPING_BEHAVIOR_MAX_ENUM = 0x7FFFFFFF
1515} VkPointClippingBehavior;
1516typedef enum VkResolveModeFlagBits {
1517 VK_RESOLVE_MODE_NONE = 0,
1518 VK_RESOLVE_MODE_SAMPLE_ZERO_BIT = 1,
1519 VK_RESOLVE_MODE_AVERAGE_BIT = 2,
1520 VK_RESOLVE_MODE_MIN_BIT = 4,
1521 VK_RESOLVE_MODE_MAX_BIT = 8,
1522 VK_RESOLVE_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1523} VkResolveModeFlagBits;
1524typedef enum VkDescriptorBindingFlagBits {
1525 VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT = 1,
1526 VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT = 2,
1527 VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT = 4,
1528 VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT = 8,
1529 VK_DESCRIPTOR_BINDING_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1530} VkDescriptorBindingFlagBits;
1531typedef enum VkSemaphoreType {
1532 VK_SEMAPHORE_TYPE_BINARY = 0,
1533 VK_SEMAPHORE_TYPE_TIMELINE = 1,
1534 VK_SEMAPHORE_TYPE_MAX_ENUM = 0x7FFFFFFF
1535} VkSemaphoreType;
1536typedef enum VkPipelineCreationFeedbackFlagBits {
1537 VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT = 1,
1538 VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT,
1539 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT = 2,
1540 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT_EXT = VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT,
1541 VK_PIPELINE_CREATION_FEEDBACK_BASE_PIPELINE_ACCELERATION_BIT = 4,
1542 VK_PIPELINE_CREATION_FEEDBACK_BASE_PIPELINE_ACCELERATION_BIT_EXT = VK_PIPELINE_CREATION_FEEDBACK_BASE_PIPELINE_ACCELERATION_BIT,
1543 VK_PIPELINE_CREATION_FEEDBACK_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1544} VkPipelineCreationFeedbackFlagBits;
1545typedef enum VkSemaphoreWaitFlagBits {
1546 VK_SEMAPHORE_WAIT_ANY_BIT = 1,
1547 VK_SEMAPHORE_WAIT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1548} VkSemaphoreWaitFlagBits;
1549typedef enum VkToolPurposeFlagBits {
1550 VK_TOOL_PURPOSE_VALIDATION_BIT = 1,
1551 VK_TOOL_PURPOSE_VALIDATION_BIT_EXT = VK_TOOL_PURPOSE_VALIDATION_BIT,
1552 VK_TOOL_PURPOSE_PROFILING_BIT = 2,
1553 VK_TOOL_PURPOSE_PROFILING_BIT_EXT = VK_TOOL_PURPOSE_PROFILING_BIT,
1554 VK_TOOL_PURPOSE_TRACING_BIT = 4,
1555 VK_TOOL_PURPOSE_TRACING_BIT_EXT = VK_TOOL_PURPOSE_TRACING_BIT,
1556 VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT = 8,
1557 VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT_EXT = VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT,
1558 VK_TOOL_PURPOSE_MODIFYING_FEATURES_BIT = 16,
1559 VK_TOOL_PURPOSE_MODIFYING_FEATURES_BIT_EXT = VK_TOOL_PURPOSE_MODIFYING_FEATURES_BIT,
1560 VK_TOOL_PURPOSE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1561} VkToolPurposeFlagBits;
1562typedef uint64_t VkAccessFlagBits2;
1563static const VkAccessFlagBits2 VK_ACCESS_2_NONE = 0;
1564static const VkAccessFlagBits2 VK_ACCESS_2_NONE_KHR = 0;
1565static const VkAccessFlagBits2 VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT = 1;
1566static const VkAccessFlagBits2 VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT_KHR = 1;
1567static const VkAccessFlagBits2 VK_ACCESS_2_INDEX_READ_BIT = 2;
1568static const VkAccessFlagBits2 VK_ACCESS_2_INDEX_READ_BIT_KHR = 2;
1569static const VkAccessFlagBits2 VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT = 4;
1570static const VkAccessFlagBits2 VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT_KHR = 4;
1571static const VkAccessFlagBits2 VK_ACCESS_2_UNIFORM_READ_BIT = 8;
1572static const VkAccessFlagBits2 VK_ACCESS_2_UNIFORM_READ_BIT_KHR = 8;
1573static const VkAccessFlagBits2 VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT = 16;
1574static const VkAccessFlagBits2 VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT_KHR = 16;
1575static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_READ_BIT = 32;
1576static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_READ_BIT_KHR = 32;
1577static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_WRITE_BIT = 64;
1578static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_WRITE_BIT_KHR = 64;
1579static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT = 128;
1580static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT_KHR = 128;
1581static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT = 256;
1582static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT_KHR = 256;
1583static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 512;
1584static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT_KHR = 512;
1585static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 1024;
1586static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT_KHR = 1024;
1587static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_READ_BIT = 2048;
1588static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_READ_BIT_KHR = 2048;
1589static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_WRITE_BIT = 4096;
1590static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR = 4096;
1591static const VkAccessFlagBits2 VK_ACCESS_2_HOST_READ_BIT = 8192;
1592static const VkAccessFlagBits2 VK_ACCESS_2_HOST_READ_BIT_KHR = 8192;
1593static const VkAccessFlagBits2 VK_ACCESS_2_HOST_WRITE_BIT = 16384;
1594static const VkAccessFlagBits2 VK_ACCESS_2_HOST_WRITE_BIT_KHR = 16384;
1595static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_READ_BIT = 32768;
1596static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_READ_BIT_KHR = 32768;
1597static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_WRITE_BIT = 65536;
1598static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_WRITE_BIT_KHR = 65536;
1599static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_SAMPLED_READ_BIT = 4294967296;
1600static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_SAMPLED_READ_BIT_KHR = 4294967296;
1601static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT = 8589934592;
1602static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT_KHR = 8589934592;
1603static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT = 17179869184;
1604static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT_KHR = 17179869184;
1605
1606typedef uint64_t VkPipelineStageFlagBits2;
1607static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_NONE = 0;
1608static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_NONE_KHR = 0;
1609static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT = 1;
1610static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT_KHR = 1;
1611static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT = 2;
1612static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT_KHR = 2;
1613static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT = 4;
1614static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT_KHR = 4;
1615static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT = 8;
1616static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR = 8;
1617static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_CONTROL_SHADER_BIT = 16;
1618static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_CONTROL_SHADER_BIT_KHR = 16;
1619static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_EVALUATION_SHADER_BIT = 32;
1620static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_EVALUATION_SHADER_BIT_KHR = 32;
1621static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT = 64;
1622static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT_KHR = 64;
1623static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT = 128;
1624static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT_KHR = 128;
1625static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT = 256;
1626static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT_KHR = 256;
1627static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT = 512;
1628static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT_KHR = 512;
1629static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT = 1024;
1630static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR = 1024;
1631static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT = 2048;
1632static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT_KHR = 2048;
1633static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT = 4096;
1634static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT_KHR = 4096;
1635static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TRANSFER_BIT = 4096;
1636static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TRANSFER_BIT_KHR = 4096;
1637static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT = 8192;
1638static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT_KHR = 8192;
1639static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_HOST_BIT = 16384;
1640static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_HOST_BIT_KHR = 16384;
1641static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT = 32768;
1642static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT_KHR = 32768;
1643static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT = 65536;
1644static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT_KHR = 65536;
1645static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COPY_BIT = 4294967296;
1646static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COPY_BIT_KHR = 4294967296;
1647static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_RESOLVE_BIT = 8589934592;
1648static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_RESOLVE_BIT_KHR = 8589934592;
1649static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BLIT_BIT = 17179869184;
1650static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BLIT_BIT_KHR = 17179869184;
1651static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CLEAR_BIT = 34359738368;
1652static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CLEAR_BIT_KHR = 34359738368;
1653static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT = 68719476736;
1654static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT_KHR = 68719476736;
1655static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT = 137438953472;
1656static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT_KHR = 137438953472;
1657static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT = 274877906944;
1658static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT_KHR = 274877906944;
1659
1660typedef uint64_t VkFormatFeatureFlagBits2;
1661static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT = 1;
1662static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT_KHR = 1;
1663static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT = 2;
1664static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT_KHR = 2;
1665static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT = 4;
1666static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT_KHR = 4;
1667static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT = 8;
1668static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT_KHR = 8;
1669static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT = 16;
1670static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT_KHR = 16;
1671static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 32;
1672static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT_KHR = 32;
1673static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT = 64;
1674static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT_KHR = 64;
1675static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT = 128;
1676static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT_KHR = 128;
1677static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT = 256;
1678static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT_KHR = 256;
1679static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT = 512;
1680static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT_KHR = 512;
1681static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_SRC_BIT = 1024;
1682static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_SRC_BIT_KHR = 1024;
1683static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_DST_BIT = 2048;
1684static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_DST_BIT_KHR = 2048;
1685static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 4096;
1686static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT_KHR = 4096;
1687static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_CUBIC_BIT = 8192;
1688static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = 8192;
1689static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT = 16384;
1690static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT_KHR = 16384;
1691static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT = 32768;
1692static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT_KHR = 32768;
1693static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT = 65536;
1694static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT_KHR = 65536;
1695static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_MIDPOINT_CHROMA_SAMPLES_BIT = 131072;
1696static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_MIDPOINT_CHROMA_SAMPLES_BIT_KHR = 131072;
1697static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT = 262144;
1698static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR = 262144;
1699static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT = 524288;
1700static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT_KHR = 524288;
1701static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT = 1048576;
1702static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR = 1048576;
1703static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT = 2097152;
1704static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR = 2097152;
1705static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DISJOINT_BIT = 4194304;
1706static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DISJOINT_BIT_KHR = 4194304;
1707static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COSITED_CHROMA_SAMPLES_BIT = 8388608;
1708static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COSITED_CHROMA_SAMPLES_BIT_KHR = 8388608;
1709static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT = 2147483648;
1710static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT_KHR = 2147483648;
1711static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT = 4294967296;
1712static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT_KHR = 4294967296;
1713static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT = 8589934592;
1714static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT_KHR = 8589934592;
1715
1716typedef enum VkRenderingFlagBits {
1717 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT = 1,
1718 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT,
1719 VK_RENDERING_SUSPENDING_BIT = 2,
1720 VK_RENDERING_SUSPENDING_BIT_KHR = VK_RENDERING_SUSPENDING_BIT,
1721 VK_RENDERING_RESUMING_BIT = 4,
1722 VK_RENDERING_RESUMING_BIT_KHR = VK_RENDERING_RESUMING_BIT,
1723 VK_RENDERING_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1724} VkRenderingFlagBits;
1725typedef enum VkColorSpaceKHR {
1726 VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0,
1727 VK_COLORSPACE_SRGB_NONLINEAR_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
1728 VK_COLOR_SPACE_MAX_ENUM_KHR = 0x7FFFFFFF
1729} VkColorSpaceKHR;
1730typedef enum VkCompositeAlphaFlagBitsKHR {
1731 VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 1,
1732 VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 2,
1733 VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 4,
1734 VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 8,
1735 VK_COMPOSITE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
1736} VkCompositeAlphaFlagBitsKHR;
1737typedef enum VkPresentModeKHR {
1738 VK_PRESENT_MODE_IMMEDIATE_KHR = 0,
1739 VK_PRESENT_MODE_MAILBOX_KHR = 1,
1740 VK_PRESENT_MODE_FIFO_KHR = 2,
1741 VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3,
1742 VK_PRESENT_MODE_MAX_ENUM_KHR = 0x7FFFFFFF
1743} VkPresentModeKHR;
1744typedef enum VkSurfaceTransformFlagBitsKHR {
1745 VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 1,
1746 VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 2,
1747 VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 4,
1748 VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 8,
1749 VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 16,
1750 VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 32,
1751 VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 64,
1752 VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 128,
1753 VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 256,
1754 VK_SURFACE_TRANSFORM_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
1755} VkSurfaceTransformFlagBitsKHR;
1756typedef enum VkDebugReportFlagBitsEXT {
1757 VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 1,
1758 VK_DEBUG_REPORT_WARNING_BIT_EXT = 2,
1759 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 4,
1760 VK_DEBUG_REPORT_ERROR_BIT_EXT = 8,
1761 VK_DEBUG_REPORT_DEBUG_BIT_EXT = 16,
1762 VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
1763} VkDebugReportFlagBitsEXT;
1764typedef enum VkDebugReportObjectTypeEXT {
1765 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0,
1766 VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1,
1767 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2,
1768 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT = 3,
1769 VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT = 4,
1770 VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT = 5,
1771 VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT = 6,
1772 VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT = 7,
1773 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT = 8,
1774 VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT = 9,
1775 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT = 10,
1776 VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT = 11,
1777 VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT = 12,
1778 VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT = 13,
1779 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT = 14,
1780 VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT = 15,
1781 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT = 16,
1782 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT = 17,
1783 VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT = 18,
1784 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT = 19,
1785 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT = 20,
1786 VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT = 21,
1787 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT = 22,
1788 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT = 23,
1789 VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT = 24,
1790 VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT = 25,
1791 VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26,
1792 VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27,
1793 VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT = 28,
1794 VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT,
1795 VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29,
1796 VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30,
1797 VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT = 33,
1798 VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT,
1799 VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT = 1000156000,
1800 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT = 1000085000,
1801 VK_DEBUG_REPORT_OBJECT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF
1802} VkDebugReportObjectTypeEXT;
1803typedef enum VkExternalMemoryHandleTypeFlagBits {
1804 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
1805 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
1806 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
1807 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT = 8,
1808 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT = 16,
1809 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT = 32,
1810 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT = 64,
1811 VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1812} VkExternalMemoryHandleTypeFlagBits;
1813typedef enum VkExternalMemoryFeatureFlagBits {
1814 VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT = 1,
1815 VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT = 2,
1816 VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT = 4,
1817 VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1818} VkExternalMemoryFeatureFlagBits;
1819typedef enum VkExternalSemaphoreHandleTypeFlagBits {
1820 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
1821 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
1822 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
1823 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT = 8,
1824 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE_BIT = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT,
1825 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 16,
1826 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1827} VkExternalSemaphoreHandleTypeFlagBits;
1828typedef enum VkExternalSemaphoreFeatureFlagBits {
1829 VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT = 1,
1830 VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT = 2,
1831 VK_EXTERNAL_SEMAPHORE_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1832} VkExternalSemaphoreFeatureFlagBits;
1833typedef enum VkSemaphoreImportFlagBits {
1834 VK_SEMAPHORE_IMPORT_TEMPORARY_BIT = 1,
1835 VK_SEMAPHORE_IMPORT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1836} VkSemaphoreImportFlagBits;
1837typedef enum VkExternalFenceHandleTypeFlagBits {
1838 VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
1839 VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
1840 VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
1841 VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 8,
1842 VK_EXTERNAL_FENCE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1843} VkExternalFenceHandleTypeFlagBits;
1844typedef enum VkExternalFenceFeatureFlagBits {
1845 VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT = 1,
1846 VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT = 2,
1847 VK_EXTERNAL_FENCE_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1848} VkExternalFenceFeatureFlagBits;
1849typedef enum VkFenceImportFlagBits {
1850 VK_FENCE_IMPORT_TEMPORARY_BIT = 1,
1851 VK_FENCE_IMPORT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1852} VkFenceImportFlagBits;
1853typedef enum VkPeerMemoryFeatureFlagBits {
1854 VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT = 1,
1855 VK_PEER_MEMORY_FEATURE_COPY_DST_BIT = 2,
1856 VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT = 4,
1857 VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT = 8,
1858 VK_PEER_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1859} VkPeerMemoryFeatureFlagBits;
1860typedef enum VkMemoryAllocateFlagBits {
1861 VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT = 1,
1862 VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT = 2,
1863 VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 4,
1864 VK_MEMORY_ALLOCATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1865} VkMemoryAllocateFlagBits;
1866typedef enum VkDeviceGroupPresentModeFlagBitsKHR {
1867 VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR = 1,
1868 VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR = 2,
1869 VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR = 4,
1870 VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR = 8,
1871 VK_DEVICE_GROUP_PRESENT_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
1872} VkDeviceGroupPresentModeFlagBitsKHR;
1873typedef enum VkSwapchainCreateFlagBitsKHR {
1874 VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 1,
1875 VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 2,
1876 VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
1877} VkSwapchainCreateFlagBitsKHR;
1878typedef enum VkSubgroupFeatureFlagBits {
1879 VK_SUBGROUP_FEATURE_BASIC_BIT = 1,
1880 VK_SUBGROUP_FEATURE_VOTE_BIT = 2,
1881 VK_SUBGROUP_FEATURE_ARITHMETIC_BIT = 4,
1882 VK_SUBGROUP_FEATURE_BALLOT_BIT = 8,
1883 VK_SUBGROUP_FEATURE_SHUFFLE_BIT = 16,
1884 VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT = 32,
1885 VK_SUBGROUP_FEATURE_CLUSTERED_BIT = 64,
1886 VK_SUBGROUP_FEATURE_QUAD_BIT = 128,
1887 VK_SUBGROUP_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1888} VkSubgroupFeatureFlagBits;
1889typedef enum VkTessellationDomainOrigin {
1890 VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT = 0,
1891 VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT = 1,
1892 VK_TESSELLATION_DOMAIN_ORIGIN_MAX_ENUM = 0x7FFFFFFF
1893} VkTessellationDomainOrigin;
1894typedef enum VkSamplerYcbcrModelConversion {
1895 VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0,
1896 VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY = 1,
1897 VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709 = 2,
1898 VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601 = 3,
1899 VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 = 4,
1900 VK_SAMPLER_YCBCR_MODEL_CONVERSION_MAX_ENUM = 0x7FFFFFFF
1901} VkSamplerYcbcrModelConversion;
1902typedef enum VkSamplerYcbcrRange {
1903 VK_SAMPLER_YCBCR_RANGE_ITU_FULL = 0,
1904 VK_SAMPLER_YCBCR_RANGE_ITU_NARROW = 1,
1905 VK_SAMPLER_YCBCR_RANGE_MAX_ENUM = 0x7FFFFFFF
1906} VkSamplerYcbcrRange;
1907typedef enum VkChromaLocation {
1908 VK_CHROMA_LOCATION_COSITED_EVEN = 0,
1909 VK_CHROMA_LOCATION_MIDPOINT = 1,
1910 VK_CHROMA_LOCATION_MAX_ENUM = 0x7FFFFFFF
1911} VkChromaLocation;
1912typedef enum VkSamplerReductionMode {
1913 VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE = 0,
1914 VK_SAMPLER_REDUCTION_MODE_MIN = 1,
1915 VK_SAMPLER_REDUCTION_MODE_MAX = 2,
1916 VK_SAMPLER_REDUCTION_MODE_MAX_ENUM = 0x7FFFFFFF
1917} VkSamplerReductionMode;
1918typedef enum VkShaderFloatControlsIndependence {
1919 VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY = 0,
1920 VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL = 1,
1921 VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE = 2,
1922 VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_MAX_ENUM = 0x7FFFFFFF
1923} VkShaderFloatControlsIndependence;
1924typedef enum VkSubmitFlagBits {
1925 VK_SUBMIT_PROTECTED_BIT = 1,
1926 VK_SUBMIT_PROTECTED_BIT_KHR = VK_SUBMIT_PROTECTED_BIT,
1927 VK_SUBMIT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
1928} VkSubmitFlagBits;
1929typedef enum VkVendorId {
1930 VK_VENDOR_ID_VIV = 0x10001,
1931 VK_VENDOR_ID_VSI = 0x10002,
1932 VK_VENDOR_ID_KAZAN = 0x10003,
1933 VK_VENDOR_ID_CODEPLAY = 0x10004,
1934 VK_VENDOR_ID_MESA = 0x10005,
1935 VK_VENDOR_ID_POCL = 0x10006,
1936 VK_VENDOR_ID_MAX_ENUM = 0x7FFFFFFF
1937} VkVendorId;
1938typedef enum VkDriverId {
1939 VK_DRIVER_ID_AMD_PROPRIETARY = 1,
1940 VK_DRIVER_ID_AMD_OPEN_SOURCE = 2,
1941 VK_DRIVER_ID_MESA_RADV = 3,
1942 VK_DRIVER_ID_NVIDIA_PROPRIETARY = 4,
1943 VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS = 5,
1944 VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA = 6,
1945 VK_DRIVER_ID_IMAGINATION_PROPRIETARY = 7,
1946 VK_DRIVER_ID_QUALCOMM_PROPRIETARY = 8,
1947 VK_DRIVER_ID_ARM_PROPRIETARY = 9,
1948 VK_DRIVER_ID_GOOGLE_SWIFTSHADER = 10,
1949 VK_DRIVER_ID_GGP_PROPRIETARY = 11,
1950 VK_DRIVER_ID_BROADCOM_PROPRIETARY = 12,
1951 VK_DRIVER_ID_MESA_LLVMPIPE = 13,
1952 VK_DRIVER_ID_MOLTENVK = 14,
1953 VK_DRIVER_ID_COREAVI_PROPRIETARY = 15,
1954 VK_DRIVER_ID_JUICE_PROPRIETARY = 16,
1955 VK_DRIVER_ID_VERISILICON_PROPRIETARY = 17,
1956 VK_DRIVER_ID_MESA_TURNIP = 18,
1957 VK_DRIVER_ID_MESA_V3DV = 19,
1958 VK_DRIVER_ID_MESA_PANVK = 20,
1959 VK_DRIVER_ID_SAMSUNG_PROPRIETARY = 21,
1960 VK_DRIVER_ID_MESA_VENUS = 22,
1961 VK_DRIVER_ID_MESA_DOZEN = 23,
1962 VK_DRIVER_ID_MAX_ENUM = 0x7FFFFFFF
1963} VkDriverId;
1964typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)(
1965 void* pUserData,
1966 size_t size,
1967 VkInternalAllocationType allocationType,
1968 VkSystemAllocationScope allocationScope);
1969typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)(
1970 void* pUserData,
1971 size_t size,
1972 VkInternalAllocationType allocationType,
1973 VkSystemAllocationScope allocationScope);
1974typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)(
1975 void* pUserData,
1976 void* pOriginal,
1977 size_t size,
1978 size_t alignment,
1979 VkSystemAllocationScope allocationScope);
1980typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)(
1981 void* pUserData,
1982 size_t size,
1983 size_t alignment,
1984 VkSystemAllocationScope allocationScope);
1985typedef void (VKAPI_PTR *PFN_vkFreeFunction)(
1986 void* pUserData,
1987 void* pMemory);
1988typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void);
1989typedef struct VkBaseOutStructure {
1990 VkStructureType sType;
1991 struct VkBaseOutStructure * pNext;
1992} VkBaseOutStructure;
1993
1994typedef struct VkBaseInStructure {
1995 VkStructureType sType;
1996 const struct VkBaseInStructure * pNext;
1997} VkBaseInStructure;
1998
1999typedef struct VkOffset2D {
2000 int32_t x;
2001 int32_t y;
2002} VkOffset2D;
2003
2004typedef struct VkOffset3D {
2005 int32_t x;
2006 int32_t y;
2007 int32_t z;
2008} VkOffset3D;
2009
2010typedef struct VkExtent2D {
2011 uint32_t width;
2012 uint32_t height;
2013} VkExtent2D;
2014
2015typedef struct VkExtent3D {
2016 uint32_t width;
2017 uint32_t height;
2018 uint32_t depth;
2019} VkExtent3D;
2020
2021typedef struct VkViewport {
2022 float x;
2023 float y;
2024 float width;
2025 float height;
2026 float minDepth;
2027 float maxDepth;
2028} VkViewport;
2029
2030typedef struct VkRect2D {
2031 VkOffset2D offset;
2032 VkExtent2D extent;
2033} VkRect2D;
2034
2035typedef struct VkClearRect {
2036 VkRect2D rect;
2037 uint32_t baseArrayLayer;
2038 uint32_t layerCount;
2039} VkClearRect;
2040
2041typedef struct VkComponentMapping {
2042 VkComponentSwizzle r;
2043 VkComponentSwizzle g;
2044 VkComponentSwizzle b;
2045 VkComponentSwizzle a;
2046} VkComponentMapping;
2047
2048typedef struct VkExtensionProperties {
2049 char extensionName [ VK_MAX_EXTENSION_NAME_SIZE ];
2050 uint32_t specVersion;
2051} VkExtensionProperties;
2052
2053typedef struct VkLayerProperties {
2054 char layerName [ VK_MAX_EXTENSION_NAME_SIZE ];
2055 uint32_t specVersion;
2056 uint32_t implementationVersion;
2057 char description [ VK_MAX_DESCRIPTION_SIZE ];
2058} VkLayerProperties;
2059
2060typedef struct VkApplicationInfo {
2061 VkStructureType sType;
2062 const void * pNext;
2063 const char * pApplicationName;
2064 uint32_t applicationVersion;
2065 const char * pEngineName;
2066 uint32_t engineVersion;
2067 uint32_t apiVersion;
2068} VkApplicationInfo;
2069
2070typedef struct VkAllocationCallbacks {
2071 void * pUserData;
2072 PFN_vkAllocationFunction pfnAllocation;
2073 PFN_vkReallocationFunction pfnReallocation;
2074 PFN_vkFreeFunction pfnFree;
2075 PFN_vkInternalAllocationNotification pfnInternalAllocation;
2076 PFN_vkInternalFreeNotification pfnInternalFree;
2077} VkAllocationCallbacks;
2078
2079typedef struct VkDescriptorImageInfo {
2080 VkSampler sampler;
2081 VkImageView imageView;
2082 VkImageLayout imageLayout;
2083} VkDescriptorImageInfo;
2084
2085typedef struct VkCopyDescriptorSet {
2086 VkStructureType sType;
2087 const void * pNext;
2088 VkDescriptorSet srcSet;
2089 uint32_t srcBinding;
2090 uint32_t srcArrayElement;
2091 VkDescriptorSet dstSet;
2092 uint32_t dstBinding;
2093 uint32_t dstArrayElement;
2094 uint32_t descriptorCount;
2095} VkCopyDescriptorSet;
2096
2097typedef struct VkDescriptorPoolSize {
2098 VkDescriptorType type;
2099 uint32_t descriptorCount;
2100} VkDescriptorPoolSize;
2101
2102typedef struct VkDescriptorSetAllocateInfo {
2103 VkStructureType sType;
2104 const void * pNext;
2105 VkDescriptorPool descriptorPool;
2106 uint32_t descriptorSetCount;
2107 const VkDescriptorSetLayout * pSetLayouts;
2108} VkDescriptorSetAllocateInfo;
2109
2110typedef struct VkSpecializationMapEntry {
2111 uint32_t constantID;
2112 uint32_t offset;
2113 size_t size;
2114} VkSpecializationMapEntry;
2115
2116typedef struct VkSpecializationInfo {
2117 uint32_t mapEntryCount;
2118 const VkSpecializationMapEntry * pMapEntries;
2119 size_t dataSize;
2120 const void * pData;
2121} VkSpecializationInfo;
2122
2123typedef struct VkVertexInputBindingDescription {
2124 uint32_t binding;
2125 uint32_t stride;
2126 VkVertexInputRate inputRate;
2127} VkVertexInputBindingDescription;
2128
2129typedef struct VkVertexInputAttributeDescription {
2130 uint32_t location;
2131 uint32_t binding;
2132 VkFormat format;
2133 uint32_t offset;
2134} VkVertexInputAttributeDescription;
2135
2136typedef struct VkStencilOpState {
2137 VkStencilOp failOp;
2138 VkStencilOp passOp;
2139 VkStencilOp depthFailOp;
2140 VkCompareOp compareOp;
2141 uint32_t compareMask;
2142 uint32_t writeMask;
2143 uint32_t reference;
2144} VkStencilOpState;
2145
2146typedef struct VkPipelineCacheHeaderVersionOne {
2147 uint32_t headerSize;
2148 VkPipelineCacheHeaderVersion headerVersion;
2149 uint32_t vendorID;
2150 uint32_t deviceID;
2151 uint8_t pipelineCacheUUID [ VK_UUID_SIZE ];
2152} VkPipelineCacheHeaderVersionOne;
2153
2154typedef struct VkCommandBufferAllocateInfo {
2155 VkStructureType sType;
2156 const void * pNext;
2157 VkCommandPool commandPool;
2158 VkCommandBufferLevel level;
2159 uint32_t commandBufferCount;
2160} VkCommandBufferAllocateInfo;
2161
2162typedef union VkClearColorValue {
2163 float float32 [4];
2164 int32_t int32 [4];
2165 uint32_t uint32 [4];
2166} VkClearColorValue;
2167
2168typedef struct VkClearDepthStencilValue {
2169 float depth;
2170 uint32_t stencil;
2171} VkClearDepthStencilValue;
2172
2173typedef union VkClearValue {
2174 VkClearColorValue color;
2175 VkClearDepthStencilValue depthStencil;
2176} VkClearValue;
2177
2178typedef struct VkAttachmentReference {
2179 uint32_t attachment;
2180 VkImageLayout layout;
2181} VkAttachmentReference;
2182
2183typedef struct VkDrawIndirectCommand {
2184 uint32_t vertexCount;
2185 uint32_t instanceCount;
2186 uint32_t firstVertex;
2187 uint32_t firstInstance;
2188} VkDrawIndirectCommand;
2189
2190typedef struct VkDrawIndexedIndirectCommand {
2191 uint32_t indexCount;
2192 uint32_t instanceCount;
2193 uint32_t firstIndex;
2194 int32_t vertexOffset;
2195 uint32_t firstInstance;
2196} VkDrawIndexedIndirectCommand;
2197
2198typedef struct VkDispatchIndirectCommand {
2199 uint32_t x;
2200 uint32_t y;
2201 uint32_t z;
2202} VkDispatchIndirectCommand;
2203
2204typedef struct VkSurfaceFormatKHR {
2205 VkFormat format;
2206 VkColorSpaceKHR colorSpace;
2207} VkSurfaceFormatKHR;
2208
2209typedef struct VkPresentInfoKHR {
2210 VkStructureType sType;
2211 const void * pNext;
2212 uint32_t waitSemaphoreCount;
2213 const VkSemaphore * pWaitSemaphores;
2214 uint32_t swapchainCount;
2215 const VkSwapchainKHR * pSwapchains;
2216 const uint32_t * pImageIndices;
2217 VkResult * pResults;
2218} VkPresentInfoKHR;
2219
2220typedef struct VkDevicePrivateDataCreateInfo {
2221 VkStructureType sType;
2222 const void * pNext;
2223 uint32_t privateDataSlotRequestCount;
2224} VkDevicePrivateDataCreateInfo;
2225
2226typedef struct VkConformanceVersion {
2227 uint8_t major;
2228 uint8_t minor;
2229 uint8_t subminor;
2230 uint8_t patch;
2231} VkConformanceVersion;
2232
2233typedef struct VkPhysicalDeviceDriverProperties {
2234 VkStructureType sType;
2235 void * pNext;
2236 VkDriverId driverID;
2237 char driverName [ VK_MAX_DRIVER_NAME_SIZE ];
2238 char driverInfo [ VK_MAX_DRIVER_INFO_SIZE ];
2239 VkConformanceVersion conformanceVersion;
2240} VkPhysicalDeviceDriverProperties;
2241
2242typedef struct VkPhysicalDeviceExternalImageFormatInfo {
2243 VkStructureType sType;
2244 const void * pNext;
2245 VkExternalMemoryHandleTypeFlagBits handleType;
2246} VkPhysicalDeviceExternalImageFormatInfo;
2247
2248typedef struct VkPhysicalDeviceExternalSemaphoreInfo {
2249 VkStructureType sType;
2250 const void * pNext;
2251 VkExternalSemaphoreHandleTypeFlagBits handleType;
2252} VkPhysicalDeviceExternalSemaphoreInfo;
2253
2254typedef struct VkPhysicalDeviceExternalFenceInfo {
2255 VkStructureType sType;
2256 const void * pNext;
2257 VkExternalFenceHandleTypeFlagBits handleType;
2258} VkPhysicalDeviceExternalFenceInfo;
2259
2260typedef struct VkPhysicalDeviceMultiviewProperties {
2261 VkStructureType sType;
2262 void * pNext;
2263 uint32_t maxMultiviewViewCount;
2264 uint32_t maxMultiviewInstanceIndex;
2265} VkPhysicalDeviceMultiviewProperties;
2266
2267typedef struct VkRenderPassMultiviewCreateInfo {
2268 VkStructureType sType;
2269 const void * pNext;
2270 uint32_t subpassCount;
2271 const uint32_t * pViewMasks;
2272 uint32_t dependencyCount;
2273 const int32_t * pViewOffsets;
2274 uint32_t correlationMaskCount;
2275 const uint32_t * pCorrelationMasks;
2276} VkRenderPassMultiviewCreateInfo;
2277
2278typedef struct VkBindBufferMemoryDeviceGroupInfo {
2279 VkStructureType sType;
2280 const void * pNext;
2281 uint32_t deviceIndexCount;
2282 const uint32_t * pDeviceIndices;
2283} VkBindBufferMemoryDeviceGroupInfo;
2284
2285typedef struct VkBindImageMemoryDeviceGroupInfo {
2286 VkStructureType sType;
2287 const void * pNext;
2288 uint32_t deviceIndexCount;
2289 const uint32_t * pDeviceIndices;
2290 uint32_t splitInstanceBindRegionCount;
2291 const VkRect2D * pSplitInstanceBindRegions;
2292} VkBindImageMemoryDeviceGroupInfo;
2293
2294typedef struct VkDeviceGroupRenderPassBeginInfo {
2295 VkStructureType sType;
2296 const void * pNext;
2297 uint32_t deviceMask;
2298 uint32_t deviceRenderAreaCount;
2299 const VkRect2D * pDeviceRenderAreas;
2300} VkDeviceGroupRenderPassBeginInfo;
2301
2302typedef struct VkDeviceGroupCommandBufferBeginInfo {
2303 VkStructureType sType;
2304 const void * pNext;
2305 uint32_t deviceMask;
2306} VkDeviceGroupCommandBufferBeginInfo;
2307
2308typedef struct VkDeviceGroupSubmitInfo {
2309 VkStructureType sType;
2310 const void * pNext;
2311 uint32_t waitSemaphoreCount;
2312 const uint32_t * pWaitSemaphoreDeviceIndices;
2313 uint32_t commandBufferCount;
2314 const uint32_t * pCommandBufferDeviceMasks;
2315 uint32_t signalSemaphoreCount;
2316 const uint32_t * pSignalSemaphoreDeviceIndices;
2317} VkDeviceGroupSubmitInfo;
2318
2319typedef struct VkDeviceGroupBindSparseInfo {
2320 VkStructureType sType;
2321 const void * pNext;
2322 uint32_t resourceDeviceIndex;
2323 uint32_t memoryDeviceIndex;
2324} VkDeviceGroupBindSparseInfo;
2325
2326typedef struct VkImageSwapchainCreateInfoKHR {
2327 VkStructureType sType;
2328 const void * pNext;
2329 VkSwapchainKHR swapchain;
2330} VkImageSwapchainCreateInfoKHR;
2331
2332typedef struct VkBindImageMemorySwapchainInfoKHR {
2333 VkStructureType sType;
2334 const void * pNext;
2335 VkSwapchainKHR swapchain;
2336 uint32_t imageIndex;
2337} VkBindImageMemorySwapchainInfoKHR;
2338
2339typedef struct VkAcquireNextImageInfoKHR {
2340 VkStructureType sType;
2341 const void * pNext;
2342 VkSwapchainKHR swapchain;
2343 uint64_t timeout;
2344 VkSemaphore semaphore;
2345 VkFence fence;
2346 uint32_t deviceMask;
2347} VkAcquireNextImageInfoKHR;
2348
2349typedef struct VkDeviceGroupPresentInfoKHR {
2350 VkStructureType sType;
2351 const void * pNext;
2352 uint32_t swapchainCount;
2353 const uint32_t * pDeviceMasks;
2354 VkDeviceGroupPresentModeFlagBitsKHR mode;
2355} VkDeviceGroupPresentInfoKHR;
2356
2357typedef struct VkDeviceGroupDeviceCreateInfo {
2358 VkStructureType sType;
2359 const void * pNext;
2360 uint32_t physicalDeviceCount;
2361 const VkPhysicalDevice * pPhysicalDevices;
2362} VkDeviceGroupDeviceCreateInfo;
2363
2364typedef struct VkDescriptorUpdateTemplateEntry {
2365 uint32_t dstBinding;
2366 uint32_t dstArrayElement;
2367 uint32_t descriptorCount;
2368 VkDescriptorType descriptorType;
2369 size_t offset;
2370 size_t stride;
2371} VkDescriptorUpdateTemplateEntry;
2372
2373typedef struct VkBufferMemoryRequirementsInfo2 {
2374 VkStructureType sType;
2375 const void * pNext;
2376 VkBuffer buffer;
2377} VkBufferMemoryRequirementsInfo2;
2378
2379typedef struct VkImageMemoryRequirementsInfo2 {
2380 VkStructureType sType;
2381 const void * pNext;
2382 VkImage image;
2383} VkImageMemoryRequirementsInfo2;
2384
2385typedef struct VkImageSparseMemoryRequirementsInfo2 {
2386 VkStructureType sType;
2387 const void * pNext;
2388 VkImage image;
2389} VkImageSparseMemoryRequirementsInfo2;
2390
2391typedef struct VkPhysicalDevicePointClippingProperties {
2392 VkStructureType sType;
2393 void * pNext;
2394 VkPointClippingBehavior pointClippingBehavior;
2395} VkPhysicalDevicePointClippingProperties;
2396
2397typedef struct VkMemoryDedicatedAllocateInfo {
2398 VkStructureType sType;
2399 const void * pNext;
2400 VkImage image;
2401 VkBuffer buffer;
2402} VkMemoryDedicatedAllocateInfo;
2403
2404typedef struct VkPipelineTessellationDomainOriginStateCreateInfo {
2405 VkStructureType sType;
2406 const void * pNext;
2407 VkTessellationDomainOrigin domainOrigin;
2408} VkPipelineTessellationDomainOriginStateCreateInfo;
2409
2410typedef struct VkSamplerYcbcrConversionInfo {
2411 VkStructureType sType;
2412 const void * pNext;
2413 VkSamplerYcbcrConversion conversion;
2414} VkSamplerYcbcrConversionInfo;
2415
2416typedef struct VkBindImagePlaneMemoryInfo {
2417 VkStructureType sType;
2418 const void * pNext;
2419 VkImageAspectFlagBits planeAspect;
2420} VkBindImagePlaneMemoryInfo;
2421
2422typedef struct VkImagePlaneMemoryRequirementsInfo {
2423 VkStructureType sType;
2424 const void * pNext;
2425 VkImageAspectFlagBits planeAspect;
2426} VkImagePlaneMemoryRequirementsInfo;
2427
2428typedef struct VkSamplerYcbcrConversionImageFormatProperties {
2429 VkStructureType sType;
2430 void * pNext;
2431 uint32_t combinedImageSamplerDescriptorCount;
2432} VkSamplerYcbcrConversionImageFormatProperties;
2433
2434typedef struct VkSamplerReductionModeCreateInfo {
2435 VkStructureType sType;
2436 const void * pNext;
2437 VkSamplerReductionMode reductionMode;
2438} VkSamplerReductionModeCreateInfo;
2439
2440typedef struct VkPhysicalDeviceInlineUniformBlockProperties {
2441 VkStructureType sType;
2442 void * pNext;
2443 uint32_t maxInlineUniformBlockSize;
2444 uint32_t maxPerStageDescriptorInlineUniformBlocks;
2445 uint32_t maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks;
2446 uint32_t maxDescriptorSetInlineUniformBlocks;
2447 uint32_t maxDescriptorSetUpdateAfterBindInlineUniformBlocks;
2448} VkPhysicalDeviceInlineUniformBlockProperties;
2449
2450typedef struct VkWriteDescriptorSetInlineUniformBlock {
2451 VkStructureType sType;
2452 const void * pNext;
2453 uint32_t dataSize;
2454 const void * pData;
2455} VkWriteDescriptorSetInlineUniformBlock;
2456
2457typedef struct VkDescriptorPoolInlineUniformBlockCreateInfo {
2458 VkStructureType sType;
2459 const void * pNext;
2460 uint32_t maxInlineUniformBlockBindings;
2461} VkDescriptorPoolInlineUniformBlockCreateInfo;
2462
2463typedef struct VkImageFormatListCreateInfo {
2464 VkStructureType sType;
2465 const void * pNext;
2466 uint32_t viewFormatCount;
2467 const VkFormat * pViewFormats;
2468} VkImageFormatListCreateInfo;
2469
2470typedef struct VkDescriptorSetVariableDescriptorCountAllocateInfo {
2471 VkStructureType sType;
2472 const void * pNext;
2473 uint32_t descriptorSetCount;
2474 const uint32_t * pDescriptorCounts;
2475} VkDescriptorSetVariableDescriptorCountAllocateInfo;
2476
2477typedef struct VkDescriptorSetVariableDescriptorCountLayoutSupport {
2478 VkStructureType sType;
2479 void * pNext;
2480 uint32_t maxVariableDescriptorCount;
2481} VkDescriptorSetVariableDescriptorCountLayoutSupport;
2482
2483typedef struct VkSubpassBeginInfo {
2484 VkStructureType sType;
2485 const void * pNext;
2486 VkSubpassContents contents;
2487} VkSubpassBeginInfo;
2488
2489typedef struct VkSubpassEndInfo {
2490 VkStructureType sType;
2491 const void * pNext;
2492} VkSubpassEndInfo;
2493
2494typedef struct VkPhysicalDeviceTimelineSemaphoreProperties {
2495 VkStructureType sType;
2496 void * pNext;
2497 uint64_t maxTimelineSemaphoreValueDifference;
2498} VkPhysicalDeviceTimelineSemaphoreProperties;
2499
2500typedef struct VkSemaphoreTypeCreateInfo {
2501 VkStructureType sType;
2502 const void * pNext;
2503 VkSemaphoreType semaphoreType;
2504 uint64_t initialValue;
2505} VkSemaphoreTypeCreateInfo;
2506
2507typedef struct VkTimelineSemaphoreSubmitInfo {
2508 VkStructureType sType;
2509 const void * pNext;
2510 uint32_t waitSemaphoreValueCount;
2511 const uint64_t * pWaitSemaphoreValues;
2512 uint32_t signalSemaphoreValueCount;
2513 const uint64_t * pSignalSemaphoreValues;
2514} VkTimelineSemaphoreSubmitInfo;
2515
2516typedef struct VkSemaphoreSignalInfo {
2517 VkStructureType sType;
2518 const void * pNext;
2519 VkSemaphore semaphore;
2520 uint64_t value;
2521} VkSemaphoreSignalInfo;
2522
2523typedef struct VkBufferDeviceAddressInfo {
2524 VkStructureType sType;
2525 const void * pNext;
2526 VkBuffer buffer;
2527} VkBufferDeviceAddressInfo;
2528
2529typedef struct VkBufferOpaqueCaptureAddressCreateInfo {
2530 VkStructureType sType;
2531 const void * pNext;
2532 uint64_t opaqueCaptureAddress;
2533} VkBufferOpaqueCaptureAddressCreateInfo;
2534
2535typedef struct VkRenderPassAttachmentBeginInfo {
2536 VkStructureType sType;
2537 const void * pNext;
2538 uint32_t attachmentCount;
2539 const VkImageView * pAttachments;
2540} VkRenderPassAttachmentBeginInfo;
2541
2542typedef struct VkAttachmentReferenceStencilLayout {
2543 VkStructureType sType;
2544 void * pNext;
2545 VkImageLayout stencilLayout;
2546} VkAttachmentReferenceStencilLayout;
2547
2548typedef struct VkAttachmentDescriptionStencilLayout {
2549 VkStructureType sType;
2550 void * pNext;
2551 VkImageLayout stencilInitialLayout;
2552 VkImageLayout stencilFinalLayout;
2553} VkAttachmentDescriptionStencilLayout;
2554
2555typedef struct VkPipelineShaderStageRequiredSubgroupSizeCreateInfo {
2556 VkStructureType sType;
2557 void * pNext;
2558 uint32_t requiredSubgroupSize;
2559} VkPipelineShaderStageRequiredSubgroupSizeCreateInfo;
2560
2561typedef struct VkMemoryOpaqueCaptureAddressAllocateInfo {
2562 VkStructureType sType;
2563 const void * pNext;
2564 uint64_t opaqueCaptureAddress;
2565} VkMemoryOpaqueCaptureAddressAllocateInfo;
2566
2567typedef struct VkDeviceMemoryOpaqueCaptureAddressInfo {
2568 VkStructureType sType;
2569 const void * pNext;
2570 VkDeviceMemory memory;
2571} VkDeviceMemoryOpaqueCaptureAddressInfo;
2572
2573typedef struct VkCommandBufferSubmitInfo {
2574 VkStructureType sType;
2575 const void * pNext;
2576 VkCommandBuffer commandBuffer;
2577 uint32_t deviceMask;
2578} VkCommandBufferSubmitInfo;
2579
2580typedef struct VkPipelineRenderingCreateInfo {
2581 VkStructureType sType;
2582 const void * pNext;
2583 uint32_t viewMask;
2584 uint32_t colorAttachmentCount;
2585 const VkFormat * pColorAttachmentFormats;
2586 VkFormat depthAttachmentFormat;
2587 VkFormat stencilAttachmentFormat;
2588} VkPipelineRenderingCreateInfo;
2589
2590typedef struct VkRenderingAttachmentInfo {
2591 VkStructureType sType;
2592 const void * pNext;
2593 VkImageView imageView;
2594 VkImageLayout imageLayout;
2595 VkResolveModeFlagBits resolveMode;
2596 VkImageView resolveImageView;
2597 VkImageLayout resolveImageLayout;
2598 VkAttachmentLoadOp loadOp;
2599 VkAttachmentStoreOp storeOp;
2600 VkClearValue clearValue;
2601} VkRenderingAttachmentInfo;
2602
2603typedef uint32_t VkSampleMask;
2604typedef uint32_t VkBool32;
2605typedef uint32_t VkFlags;
2606typedef uint64_t VkFlags64;
2607typedef uint64_t VkDeviceSize;
2608typedef uint64_t VkDeviceAddress;
2609typedef VkFlags VkFramebufferCreateFlags;
2610typedef VkFlags VkQueryPoolCreateFlags;
2611typedef VkFlags VkRenderPassCreateFlags;
2612typedef VkFlags VkSamplerCreateFlags;
2613typedef VkFlags VkPipelineLayoutCreateFlags;
2614typedef VkFlags VkPipelineCacheCreateFlags;
2615typedef VkFlags VkPipelineDepthStencilStateCreateFlags;
2616typedef VkFlags VkPipelineDynamicStateCreateFlags;
2617typedef VkFlags VkPipelineColorBlendStateCreateFlags;
2618typedef VkFlags VkPipelineMultisampleStateCreateFlags;
2619typedef VkFlags VkPipelineRasterizationStateCreateFlags;
2620typedef VkFlags VkPipelineViewportStateCreateFlags;
2621typedef VkFlags VkPipelineTessellationStateCreateFlags;
2622typedef VkFlags VkPipelineInputAssemblyStateCreateFlags;
2623typedef VkFlags VkPipelineVertexInputStateCreateFlags;
2624typedef VkFlags VkPipelineShaderStageCreateFlags;
2625typedef VkFlags VkDescriptorSetLayoutCreateFlags;
2626typedef VkFlags VkBufferViewCreateFlags;
2627typedef VkFlags VkInstanceCreateFlags;
2628typedef VkFlags VkDeviceCreateFlags;
2629typedef VkFlags VkDeviceQueueCreateFlags;
2630typedef VkFlags VkQueueFlags;
2631typedef VkFlags VkMemoryPropertyFlags;
2632typedef VkFlags VkMemoryHeapFlags;
2633typedef VkFlags VkAccessFlags;
2634typedef VkFlags VkBufferUsageFlags;
2635typedef VkFlags VkBufferCreateFlags;
2636typedef VkFlags VkShaderStageFlags;
2637typedef VkFlags VkImageUsageFlags;
2638typedef VkFlags VkImageCreateFlags;
2639typedef VkFlags VkImageViewCreateFlags;
2640typedef VkFlags VkPipelineCreateFlags;
2641typedef VkFlags VkColorComponentFlags;
2642typedef VkFlags VkFenceCreateFlags;
2643typedef VkFlags VkSemaphoreCreateFlags;
2644typedef VkFlags VkFormatFeatureFlags;
2645typedef VkFlags VkQueryControlFlags;
2646typedef VkFlags VkQueryResultFlags;
2647typedef VkFlags VkShaderModuleCreateFlags;
2648typedef VkFlags VkEventCreateFlags;
2649typedef VkFlags VkCommandPoolCreateFlags;
2650typedef VkFlags VkCommandPoolResetFlags;
2651typedef VkFlags VkCommandBufferResetFlags;
2652typedef VkFlags VkCommandBufferUsageFlags;
2653typedef VkFlags VkQueryPipelineStatisticFlags;
2654typedef VkFlags VkMemoryMapFlags;
2655typedef VkFlags VkImageAspectFlags;
2656typedef VkFlags VkSparseMemoryBindFlags;
2657typedef VkFlags VkSparseImageFormatFlags;
2658typedef VkFlags VkSubpassDescriptionFlags;
2659typedef VkFlags VkPipelineStageFlags;
2660typedef VkFlags VkSampleCountFlags;
2661typedef VkFlags VkAttachmentDescriptionFlags;
2662typedef VkFlags VkStencilFaceFlags;
2663typedef VkFlags VkCullModeFlags;
2664typedef VkFlags VkDescriptorPoolCreateFlags;
2665typedef VkFlags VkDescriptorPoolResetFlags;
2666typedef VkFlags VkDependencyFlags;
2667typedef VkFlags VkSubgroupFeatureFlags;
2668typedef VkFlags VkPrivateDataSlotCreateFlags;
2669typedef VkFlags VkDescriptorUpdateTemplateCreateFlags;
2670typedef VkFlags VkPipelineCreationFeedbackFlags;
2671typedef VkFlags VkSemaphoreWaitFlags;
2672typedef VkFlags64 VkAccessFlags2;
2673typedef VkFlags64 VkPipelineStageFlags2;
2674typedef VkFlags64 VkFormatFeatureFlags2;
2675typedef VkFlags VkRenderingFlags;
2676typedef VkFlags VkCompositeAlphaFlagsKHR;
2677typedef VkFlags VkSurfaceTransformFlagsKHR;
2678typedef VkFlags VkSwapchainCreateFlagsKHR;
2679typedef VkFlags VkPeerMemoryFeatureFlags;
2680typedef VkFlags VkMemoryAllocateFlags;
2681typedef VkFlags VkDeviceGroupPresentModeFlagsKHR;
2682typedef VkFlags VkDebugReportFlagsEXT;
2683typedef VkFlags VkCommandPoolTrimFlags;
2684typedef VkFlags VkExternalMemoryHandleTypeFlags;
2685typedef VkFlags VkExternalMemoryFeatureFlags;
2686typedef VkFlags VkExternalSemaphoreHandleTypeFlags;
2687typedef VkFlags VkExternalSemaphoreFeatureFlags;
2688typedef VkFlags VkSemaphoreImportFlags;
2689typedef VkFlags VkExternalFenceHandleTypeFlags;
2690typedef VkFlags VkExternalFenceFeatureFlags;
2691typedef VkFlags VkFenceImportFlags;
2692typedef VkFlags VkDescriptorBindingFlags;
2693typedef VkFlags VkResolveModeFlags;
2694typedef VkFlags VkToolPurposeFlags;
2695typedef VkFlags VkSubmitFlags;
2696typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)(
2697 VkDebugReportFlagsEXT flags,
2698 VkDebugReportObjectTypeEXT objectType,
2699 uint64_t object,
2700 size_t location,
2701 int32_t messageCode,
2702 const char* pLayerPrefix,
2703 const char* pMessage,
2704 void* pUserData);
2705typedef struct VkDeviceQueueCreateInfo {
2706 VkStructureType sType;
2707 const void * pNext;
2708 VkDeviceQueueCreateFlags flags;
2709 uint32_t queueFamilyIndex;
2710 uint32_t queueCount;
2711 const float * pQueuePriorities;
2712} VkDeviceQueueCreateInfo;
2713
2714typedef struct VkInstanceCreateInfo {
2715 VkStructureType sType;
2716 const void * pNext;
2717 VkInstanceCreateFlags flags;
2718 const VkApplicationInfo * pApplicationInfo;
2719 uint32_t enabledLayerCount;
2720 const char * const* ppEnabledLayerNames;
2721 uint32_t enabledExtensionCount;
2722 const char * const* ppEnabledExtensionNames;
2723} VkInstanceCreateInfo;
2724
2725typedef struct VkQueueFamilyProperties {
2726 VkQueueFlags queueFlags;
2727 uint32_t queueCount;
2728 uint32_t timestampValidBits;
2729 VkExtent3D minImageTransferGranularity;
2730} VkQueueFamilyProperties;
2731
2732typedef struct VkMemoryAllocateInfo {
2733 VkStructureType sType;
2734 const void * pNext;
2735 VkDeviceSize allocationSize;
2736 uint32_t memoryTypeIndex;
2737} VkMemoryAllocateInfo;
2738
2739typedef struct VkMemoryRequirements {
2740 VkDeviceSize size;
2741 VkDeviceSize alignment;
2742 uint32_t memoryTypeBits;
2743} VkMemoryRequirements;
2744
2745typedef struct VkSparseImageFormatProperties {
2746 VkImageAspectFlags aspectMask;
2747 VkExtent3D imageGranularity;
2748 VkSparseImageFormatFlags flags;
2749} VkSparseImageFormatProperties;
2750
2751typedef struct VkSparseImageMemoryRequirements {
2752 VkSparseImageFormatProperties formatProperties;
2753 uint32_t imageMipTailFirstLod;
2754 VkDeviceSize imageMipTailSize;
2755 VkDeviceSize imageMipTailOffset;
2756 VkDeviceSize imageMipTailStride;
2757} VkSparseImageMemoryRequirements;
2758
2759typedef struct VkMemoryType {
2760 VkMemoryPropertyFlags propertyFlags;
2761 uint32_t heapIndex;
2762} VkMemoryType;
2763
2764typedef struct VkMemoryHeap {
2765 VkDeviceSize size;
2766 VkMemoryHeapFlags flags;
2767} VkMemoryHeap;
2768
2769typedef struct VkMappedMemoryRange {
2770 VkStructureType sType;
2771 const void * pNext;
2772 VkDeviceMemory memory;
2773 VkDeviceSize offset;
2774 VkDeviceSize size;
2775} VkMappedMemoryRange;
2776
2777typedef struct VkFormatProperties {
2778 VkFormatFeatureFlags linearTilingFeatures;
2779 VkFormatFeatureFlags optimalTilingFeatures;
2780 VkFormatFeatureFlags bufferFeatures;
2781} VkFormatProperties;
2782
2783typedef struct VkImageFormatProperties {
2784 VkExtent3D maxExtent;
2785 uint32_t maxMipLevels;
2786 uint32_t maxArrayLayers;
2787 VkSampleCountFlags sampleCounts;
2788 VkDeviceSize maxResourceSize;
2789} VkImageFormatProperties;
2790
2791typedef struct VkDescriptorBufferInfo {
2792 VkBuffer buffer;
2793 VkDeviceSize offset;
2794 VkDeviceSize range;
2795} VkDescriptorBufferInfo;
2796
2797typedef struct VkWriteDescriptorSet {
2798 VkStructureType sType;
2799 const void * pNext;
2800 VkDescriptorSet dstSet;
2801 uint32_t dstBinding;
2802 uint32_t dstArrayElement;
2803 uint32_t descriptorCount;
2804 VkDescriptorType descriptorType;
2805 const VkDescriptorImageInfo * pImageInfo;
2806 const VkDescriptorBufferInfo * pBufferInfo;
2807 const VkBufferView * pTexelBufferView;
2808} VkWriteDescriptorSet;
2809
2810typedef struct VkBufferCreateInfo {
2811 VkStructureType sType;
2812 const void * pNext;
2813 VkBufferCreateFlags flags;
2814 VkDeviceSize size;
2815 VkBufferUsageFlags usage;
2816 VkSharingMode sharingMode;
2817 uint32_t queueFamilyIndexCount;
2818 const uint32_t * pQueueFamilyIndices;
2819} VkBufferCreateInfo;
2820
2821typedef struct VkBufferViewCreateInfo {
2822 VkStructureType sType;
2823 const void * pNext;
2824 VkBufferViewCreateFlags flags;
2825 VkBuffer buffer;
2826 VkFormat format;
2827 VkDeviceSize offset;
2828 VkDeviceSize range;
2829} VkBufferViewCreateInfo;
2830
2831typedef struct VkImageSubresource {
2832 VkImageAspectFlags aspectMask;
2833 uint32_t mipLevel;
2834 uint32_t arrayLayer;
2835} VkImageSubresource;
2836
2837typedef struct VkImageSubresourceLayers {
2838 VkImageAspectFlags aspectMask;
2839 uint32_t mipLevel;
2840 uint32_t baseArrayLayer;
2841 uint32_t layerCount;
2842} VkImageSubresourceLayers;
2843
2844typedef struct VkImageSubresourceRange {
2845 VkImageAspectFlags aspectMask;
2846 uint32_t baseMipLevel;
2847 uint32_t levelCount;
2848 uint32_t baseArrayLayer;
2849 uint32_t layerCount;
2850} VkImageSubresourceRange;
2851
2852typedef struct VkMemoryBarrier {
2853 VkStructureType sType;
2854 const void * pNext;
2855 VkAccessFlags srcAccessMask;
2856 VkAccessFlags dstAccessMask;
2857} VkMemoryBarrier;
2858
2859typedef struct VkBufferMemoryBarrier {
2860 VkStructureType sType;
2861 const void * pNext;
2862 VkAccessFlags srcAccessMask;
2863 VkAccessFlags dstAccessMask;
2864 uint32_t srcQueueFamilyIndex;
2865 uint32_t dstQueueFamilyIndex;
2866 VkBuffer buffer;
2867 VkDeviceSize offset;
2868 VkDeviceSize size;
2869} VkBufferMemoryBarrier;
2870
2871typedef struct VkImageMemoryBarrier {
2872 VkStructureType sType;
2873 const void * pNext;
2874 VkAccessFlags srcAccessMask;
2875 VkAccessFlags dstAccessMask;
2876 VkImageLayout oldLayout;
2877 VkImageLayout newLayout;
2878 uint32_t srcQueueFamilyIndex;
2879 uint32_t dstQueueFamilyIndex;
2880 VkImage image;
2881 VkImageSubresourceRange subresourceRange;
2882} VkImageMemoryBarrier;
2883
2884typedef struct VkImageCreateInfo {
2885 VkStructureType sType;
2886 const void * pNext;
2887 VkImageCreateFlags flags;
2888 VkImageType imageType;
2889 VkFormat format;
2890 VkExtent3D extent;
2891 uint32_t mipLevels;
2892 uint32_t arrayLayers;
2893 VkSampleCountFlagBits samples;
2894 VkImageTiling tiling;
2895 VkImageUsageFlags usage;
2896 VkSharingMode sharingMode;
2897 uint32_t queueFamilyIndexCount;
2898 const uint32_t * pQueueFamilyIndices;
2899 VkImageLayout initialLayout;
2900} VkImageCreateInfo;
2901
2902typedef struct VkSubresourceLayout {
2903 VkDeviceSize offset;
2904 VkDeviceSize size;
2905 VkDeviceSize rowPitch;
2906 VkDeviceSize arrayPitch;
2907 VkDeviceSize depthPitch;
2908} VkSubresourceLayout;
2909
2910typedef struct VkImageViewCreateInfo {
2911 VkStructureType sType;
2912 const void * pNext;
2913 VkImageViewCreateFlags flags;
2914 VkImage image;
2915 VkImageViewType viewType;
2916 VkFormat format;
2917 VkComponentMapping components;
2918 VkImageSubresourceRange subresourceRange;
2919} VkImageViewCreateInfo;
2920
2921typedef struct VkBufferCopy {
2922 VkDeviceSize srcOffset;
2923 VkDeviceSize dstOffset;
2924 VkDeviceSize size;
2925} VkBufferCopy;
2926
2927typedef struct VkSparseMemoryBind {
2928 VkDeviceSize resourceOffset;
2929 VkDeviceSize size;
2930 VkDeviceMemory memory;
2931 VkDeviceSize memoryOffset;
2932 VkSparseMemoryBindFlags flags;
2933} VkSparseMemoryBind;
2934
2935typedef struct VkSparseImageMemoryBind {
2936 VkImageSubresource subresource;
2937 VkOffset3D offset;
2938 VkExtent3D extent;
2939 VkDeviceMemory memory;
2940 VkDeviceSize memoryOffset;
2941 VkSparseMemoryBindFlags flags;
2942} VkSparseImageMemoryBind;
2943
2944typedef struct VkSparseBufferMemoryBindInfo {
2945 VkBuffer buffer;
2946 uint32_t bindCount;
2947 const VkSparseMemoryBind * pBinds;
2948} VkSparseBufferMemoryBindInfo;
2949
2950typedef struct VkSparseImageOpaqueMemoryBindInfo {
2951 VkImage image;
2952 uint32_t bindCount;
2953 const VkSparseMemoryBind * pBinds;
2954} VkSparseImageOpaqueMemoryBindInfo;
2955
2956typedef struct VkSparseImageMemoryBindInfo {
2957 VkImage image;
2958 uint32_t bindCount;
2959 const VkSparseImageMemoryBind * pBinds;
2960} VkSparseImageMemoryBindInfo;
2961
2962typedef struct VkBindSparseInfo {
2963 VkStructureType sType;
2964 const void * pNext;
2965 uint32_t waitSemaphoreCount;
2966 const VkSemaphore * pWaitSemaphores;
2967 uint32_t bufferBindCount;
2968 const VkSparseBufferMemoryBindInfo * pBufferBinds;
2969 uint32_t imageOpaqueBindCount;
2970 const VkSparseImageOpaqueMemoryBindInfo * pImageOpaqueBinds;
2971 uint32_t imageBindCount;
2972 const VkSparseImageMemoryBindInfo * pImageBinds;
2973 uint32_t signalSemaphoreCount;
2974 const VkSemaphore * pSignalSemaphores;
2975} VkBindSparseInfo;
2976
2977typedef struct VkImageCopy {
2978 VkImageSubresourceLayers srcSubresource;
2979 VkOffset3D srcOffset;
2980 VkImageSubresourceLayers dstSubresource;
2981 VkOffset3D dstOffset;
2982 VkExtent3D extent;
2983} VkImageCopy;
2984
2985typedef struct VkImageBlit {
2986 VkImageSubresourceLayers srcSubresource;
2987 VkOffset3D srcOffsets [2];
2988 VkImageSubresourceLayers dstSubresource;
2989 VkOffset3D dstOffsets [2];
2990} VkImageBlit;
2991
2992typedef struct VkBufferImageCopy {
2993 VkDeviceSize bufferOffset;
2994 uint32_t bufferRowLength;
2995 uint32_t bufferImageHeight;
2996 VkImageSubresourceLayers imageSubresource;
2997 VkOffset3D imageOffset;
2998 VkExtent3D imageExtent;
2999} VkBufferImageCopy;
3000
3001typedef struct VkImageResolve {
3002 VkImageSubresourceLayers srcSubresource;
3003 VkOffset3D srcOffset;
3004 VkImageSubresourceLayers dstSubresource;
3005 VkOffset3D dstOffset;
3006 VkExtent3D extent;
3007} VkImageResolve;
3008
3009typedef struct VkShaderModuleCreateInfo {
3010 VkStructureType sType;
3011 const void * pNext;
3012 VkShaderModuleCreateFlags flags;
3013 size_t codeSize;
3014 const uint32_t * pCode;
3015} VkShaderModuleCreateInfo;
3016
3017typedef struct VkDescriptorSetLayoutBinding {
3018 uint32_t binding;
3019 VkDescriptorType descriptorType;
3020 uint32_t descriptorCount;
3021 VkShaderStageFlags stageFlags;
3022 const VkSampler * pImmutableSamplers;
3023} VkDescriptorSetLayoutBinding;
3024
3025typedef struct VkDescriptorSetLayoutCreateInfo {
3026 VkStructureType sType;
3027 const void * pNext;
3028 VkDescriptorSetLayoutCreateFlags flags;
3029 uint32_t bindingCount;
3030 const VkDescriptorSetLayoutBinding * pBindings;
3031} VkDescriptorSetLayoutCreateInfo;
3032
3033typedef struct VkDescriptorPoolCreateInfo {
3034 VkStructureType sType;
3035 const void * pNext;
3036 VkDescriptorPoolCreateFlags flags;
3037 uint32_t maxSets;
3038 uint32_t poolSizeCount;
3039 const VkDescriptorPoolSize * pPoolSizes;
3040} VkDescriptorPoolCreateInfo;
3041
3042typedef struct VkPipelineShaderStageCreateInfo {
3043 VkStructureType sType;
3044 const void * pNext;
3045 VkPipelineShaderStageCreateFlags flags;
3046 VkShaderStageFlagBits stage;
3047 VkShaderModule module;
3048 const char * pName;
3049 const VkSpecializationInfo * pSpecializationInfo;
3050} VkPipelineShaderStageCreateInfo;
3051
3052typedef struct VkComputePipelineCreateInfo {
3053 VkStructureType sType;
3054 const void * pNext;
3055 VkPipelineCreateFlags flags;
3056 VkPipelineShaderStageCreateInfo stage;
3057 VkPipelineLayout layout;
3058 VkPipeline basePipelineHandle;
3059 int32_t basePipelineIndex;
3060} VkComputePipelineCreateInfo;
3061
3062typedef struct VkPipelineVertexInputStateCreateInfo {
3063 VkStructureType sType;
3064 const void * pNext;
3065 VkPipelineVertexInputStateCreateFlags flags;
3066 uint32_t vertexBindingDescriptionCount;
3067 const VkVertexInputBindingDescription * pVertexBindingDescriptions;
3068 uint32_t vertexAttributeDescriptionCount;
3069 const VkVertexInputAttributeDescription * pVertexAttributeDescriptions;
3070} VkPipelineVertexInputStateCreateInfo;
3071
3072typedef struct VkPipelineInputAssemblyStateCreateInfo {
3073 VkStructureType sType;
3074 const void * pNext;
3075 VkPipelineInputAssemblyStateCreateFlags flags;
3076 VkPrimitiveTopology topology;
3077 VkBool32 primitiveRestartEnable;
3078} VkPipelineInputAssemblyStateCreateInfo;
3079
3080typedef struct VkPipelineTessellationStateCreateInfo {
3081 VkStructureType sType;
3082 const void * pNext;
3083 VkPipelineTessellationStateCreateFlags flags;
3084 uint32_t patchControlPoints;
3085} VkPipelineTessellationStateCreateInfo;
3086
3087typedef struct VkPipelineViewportStateCreateInfo {
3088 VkStructureType sType;
3089 const void * pNext;
3090 VkPipelineViewportStateCreateFlags flags;
3091 uint32_t viewportCount;
3092 const VkViewport * pViewports;
3093 uint32_t scissorCount;
3094 const VkRect2D * pScissors;
3095} VkPipelineViewportStateCreateInfo;
3096
3097typedef struct VkPipelineRasterizationStateCreateInfo {
3098 VkStructureType sType;
3099 const void * pNext;
3100 VkPipelineRasterizationStateCreateFlags flags;
3101 VkBool32 depthClampEnable;
3102 VkBool32 rasterizerDiscardEnable;
3103 VkPolygonMode polygonMode;
3104 VkCullModeFlags cullMode;
3105 VkFrontFace frontFace;
3106 VkBool32 depthBiasEnable;
3107 float depthBiasConstantFactor;
3108 float depthBiasClamp;
3109 float depthBiasSlopeFactor;
3110 float lineWidth;
3111} VkPipelineRasterizationStateCreateInfo;
3112
3113typedef struct VkPipelineMultisampleStateCreateInfo {
3114 VkStructureType sType;
3115 const void * pNext;
3116 VkPipelineMultisampleStateCreateFlags flags;
3117 VkSampleCountFlagBits rasterizationSamples;
3118 VkBool32 sampleShadingEnable;
3119 float minSampleShading;
3120 const VkSampleMask * pSampleMask;
3121 VkBool32 alphaToCoverageEnable;
3122 VkBool32 alphaToOneEnable;
3123} VkPipelineMultisampleStateCreateInfo;
3124
3125typedef struct VkPipelineColorBlendAttachmentState {
3126 VkBool32 blendEnable;
3127 VkBlendFactor srcColorBlendFactor;
3128 VkBlendFactor dstColorBlendFactor;
3129 VkBlendOp colorBlendOp;
3130 VkBlendFactor srcAlphaBlendFactor;
3131 VkBlendFactor dstAlphaBlendFactor;
3132 VkBlendOp alphaBlendOp;
3133 VkColorComponentFlags colorWriteMask;
3134} VkPipelineColorBlendAttachmentState;
3135
3136typedef struct VkPipelineColorBlendStateCreateInfo {
3137 VkStructureType sType;
3138 const void * pNext;
3139 VkPipelineColorBlendStateCreateFlags flags;
3140 VkBool32 logicOpEnable;
3141 VkLogicOp logicOp;
3142 uint32_t attachmentCount;
3143 const VkPipelineColorBlendAttachmentState * pAttachments;
3144 float blendConstants [4];
3145} VkPipelineColorBlendStateCreateInfo;
3146
3147typedef struct VkPipelineDynamicStateCreateInfo {
3148 VkStructureType sType;
3149 const void * pNext;
3150 VkPipelineDynamicStateCreateFlags flags;
3151 uint32_t dynamicStateCount;
3152 const VkDynamicState * pDynamicStates;
3153} VkPipelineDynamicStateCreateInfo;
3154
3155typedef struct VkPipelineDepthStencilStateCreateInfo {
3156 VkStructureType sType;
3157 const void * pNext;
3158 VkPipelineDepthStencilStateCreateFlags flags;
3159 VkBool32 depthTestEnable;
3160 VkBool32 depthWriteEnable;
3161 VkCompareOp depthCompareOp;
3162 VkBool32 depthBoundsTestEnable;
3163 VkBool32 stencilTestEnable;
3164 VkStencilOpState front;
3165 VkStencilOpState back;
3166 float minDepthBounds;
3167 float maxDepthBounds;
3168} VkPipelineDepthStencilStateCreateInfo;
3169
3170typedef struct VkGraphicsPipelineCreateInfo {
3171 VkStructureType sType;
3172 const void * pNext;
3173 VkPipelineCreateFlags flags;
3174 uint32_t stageCount;
3175 const VkPipelineShaderStageCreateInfo * pStages;
3176 const VkPipelineVertexInputStateCreateInfo * pVertexInputState;
3177 const VkPipelineInputAssemblyStateCreateInfo * pInputAssemblyState;
3178 const VkPipelineTessellationStateCreateInfo * pTessellationState;
3179 const VkPipelineViewportStateCreateInfo * pViewportState;
3180 const VkPipelineRasterizationStateCreateInfo * pRasterizationState;
3181 const VkPipelineMultisampleStateCreateInfo * pMultisampleState;
3182 const VkPipelineDepthStencilStateCreateInfo * pDepthStencilState;
3183 const VkPipelineColorBlendStateCreateInfo * pColorBlendState;
3184 const VkPipelineDynamicStateCreateInfo * pDynamicState;
3185 VkPipelineLayout layout;
3186 VkRenderPass renderPass;
3187 uint32_t subpass;
3188 VkPipeline basePipelineHandle;
3189 int32_t basePipelineIndex;
3190} VkGraphicsPipelineCreateInfo;
3191
3192typedef struct VkPipelineCacheCreateInfo {
3193 VkStructureType sType;
3194 const void * pNext;
3195 VkPipelineCacheCreateFlags flags;
3196 size_t initialDataSize;
3197 const void * pInitialData;
3198} VkPipelineCacheCreateInfo;
3199
3200typedef struct VkPushConstantRange {
3201 VkShaderStageFlags stageFlags;
3202 uint32_t offset;
3203 uint32_t size;
3204} VkPushConstantRange;
3205
3206typedef struct VkPipelineLayoutCreateInfo {
3207 VkStructureType sType;
3208 const void * pNext;
3209 VkPipelineLayoutCreateFlags flags;
3210 uint32_t setLayoutCount;
3211 const VkDescriptorSetLayout * pSetLayouts;
3212 uint32_t pushConstantRangeCount;
3213 const VkPushConstantRange * pPushConstantRanges;
3214} VkPipelineLayoutCreateInfo;
3215
3216typedef struct VkSamplerCreateInfo {
3217 VkStructureType sType;
3218 const void * pNext;
3219 VkSamplerCreateFlags flags;
3220 VkFilter magFilter;
3221 VkFilter minFilter;
3222 VkSamplerMipmapMode mipmapMode;
3223 VkSamplerAddressMode addressModeU;
3224 VkSamplerAddressMode addressModeV;
3225 VkSamplerAddressMode addressModeW;
3226 float mipLodBias;
3227 VkBool32 anisotropyEnable;
3228 float maxAnisotropy;
3229 VkBool32 compareEnable;
3230 VkCompareOp compareOp;
3231 float minLod;
3232 float maxLod;
3233 VkBorderColor borderColor;
3234 VkBool32 unnormalizedCoordinates;
3235} VkSamplerCreateInfo;
3236
3237typedef struct VkCommandPoolCreateInfo {
3238 VkStructureType sType;
3239 const void * pNext;
3240 VkCommandPoolCreateFlags flags;
3241 uint32_t queueFamilyIndex;
3242} VkCommandPoolCreateInfo;
3243
3244typedef struct VkCommandBufferInheritanceInfo {
3245 VkStructureType sType;
3246 const void * pNext;
3247 VkRenderPass renderPass;
3248 uint32_t subpass;
3249 VkFramebuffer framebuffer;
3250 VkBool32 occlusionQueryEnable;
3251 VkQueryControlFlags queryFlags;
3252 VkQueryPipelineStatisticFlags pipelineStatistics;
3253} VkCommandBufferInheritanceInfo;
3254
3255typedef struct VkCommandBufferBeginInfo {
3256 VkStructureType sType;
3257 const void * pNext;
3258 VkCommandBufferUsageFlags flags;
3259 const VkCommandBufferInheritanceInfo * pInheritanceInfo;
3260} VkCommandBufferBeginInfo;
3261
3262typedef struct VkRenderPassBeginInfo {
3263 VkStructureType sType;
3264 const void * pNext;
3265 VkRenderPass renderPass;
3266 VkFramebuffer framebuffer;
3267 VkRect2D renderArea;
3268 uint32_t clearValueCount;
3269 const VkClearValue * pClearValues;
3270} VkRenderPassBeginInfo;
3271
3272typedef struct VkClearAttachment {
3273 VkImageAspectFlags aspectMask;
3274 uint32_t colorAttachment;
3275 VkClearValue clearValue;
3276} VkClearAttachment;
3277
3278typedef struct VkAttachmentDescription {
3279 VkAttachmentDescriptionFlags flags;
3280 VkFormat format;
3281 VkSampleCountFlagBits samples;
3282 VkAttachmentLoadOp loadOp;
3283 VkAttachmentStoreOp storeOp;
3284 VkAttachmentLoadOp stencilLoadOp;
3285 VkAttachmentStoreOp stencilStoreOp;
3286 VkImageLayout initialLayout;
3287 VkImageLayout finalLayout;
3288} VkAttachmentDescription;
3289
3290typedef struct VkSubpassDescription {
3291 VkSubpassDescriptionFlags flags;
3292 VkPipelineBindPoint pipelineBindPoint;
3293 uint32_t inputAttachmentCount;
3294 const VkAttachmentReference * pInputAttachments;
3295 uint32_t colorAttachmentCount;
3296 const VkAttachmentReference * pColorAttachments;
3297 const VkAttachmentReference * pResolveAttachments;
3298 const VkAttachmentReference * pDepthStencilAttachment;
3299 uint32_t preserveAttachmentCount;
3300 const uint32_t * pPreserveAttachments;
3301} VkSubpassDescription;
3302
3303typedef struct VkSubpassDependency {
3304 uint32_t srcSubpass;
3305 uint32_t dstSubpass;
3306 VkPipelineStageFlags srcStageMask;
3307 VkPipelineStageFlags dstStageMask;
3308 VkAccessFlags srcAccessMask;
3309 VkAccessFlags dstAccessMask;
3310 VkDependencyFlags dependencyFlags;
3311} VkSubpassDependency;
3312
3313typedef struct VkRenderPassCreateInfo {
3314 VkStructureType sType;
3315 const void * pNext;
3316 VkRenderPassCreateFlags flags;
3317 uint32_t attachmentCount;
3318 const VkAttachmentDescription * pAttachments;
3319 uint32_t subpassCount;
3320 const VkSubpassDescription * pSubpasses;
3321 uint32_t dependencyCount;
3322 const VkSubpassDependency * pDependencies;
3323} VkRenderPassCreateInfo;
3324
3325typedef struct VkEventCreateInfo {
3326 VkStructureType sType;
3327 const void * pNext;
3328 VkEventCreateFlags flags;
3329} VkEventCreateInfo;
3330
3331typedef struct VkFenceCreateInfo {
3332 VkStructureType sType;
3333 const void * pNext;
3334 VkFenceCreateFlags flags;
3335} VkFenceCreateInfo;
3336
3337typedef struct VkPhysicalDeviceFeatures {
3338 VkBool32 robustBufferAccess;
3339 VkBool32 fullDrawIndexUint32;
3340 VkBool32 imageCubeArray;
3341 VkBool32 independentBlend;
3342 VkBool32 geometryShader;
3343 VkBool32 tessellationShader;
3344 VkBool32 sampleRateShading;
3345 VkBool32 dualSrcBlend;
3346 VkBool32 logicOp;
3347 VkBool32 multiDrawIndirect;
3348 VkBool32 drawIndirectFirstInstance;
3349 VkBool32 depthClamp;
3350 VkBool32 depthBiasClamp;
3351 VkBool32 fillModeNonSolid;
3352 VkBool32 depthBounds;
3353 VkBool32 wideLines;
3354 VkBool32 largePoints;
3355 VkBool32 alphaToOne;
3356 VkBool32 multiViewport;
3357 VkBool32 samplerAnisotropy;
3358 VkBool32 textureCompressionETC2;
3359 VkBool32 textureCompressionASTC_LDR;
3360 VkBool32 textureCompressionBC;
3361 VkBool32 occlusionQueryPrecise;
3362 VkBool32 pipelineStatisticsQuery;
3363 VkBool32 vertexPipelineStoresAndAtomics;
3364 VkBool32 fragmentStoresAndAtomics;
3365 VkBool32 shaderTessellationAndGeometryPointSize;
3366 VkBool32 shaderImageGatherExtended;
3367 VkBool32 shaderStorageImageExtendedFormats;
3368 VkBool32 shaderStorageImageMultisample;
3369 VkBool32 shaderStorageImageReadWithoutFormat;
3370 VkBool32 shaderStorageImageWriteWithoutFormat;
3371 VkBool32 shaderUniformBufferArrayDynamicIndexing;
3372 VkBool32 shaderSampledImageArrayDynamicIndexing;
3373 VkBool32 shaderStorageBufferArrayDynamicIndexing;
3374 VkBool32 shaderStorageImageArrayDynamicIndexing;
3375 VkBool32 shaderClipDistance;
3376 VkBool32 shaderCullDistance;
3377 VkBool32 shaderFloat64;
3378 VkBool32 shaderInt64;
3379 VkBool32 shaderInt16;
3380 VkBool32 shaderResourceResidency;
3381 VkBool32 shaderResourceMinLod;
3382 VkBool32 sparseBinding;
3383 VkBool32 sparseResidencyBuffer;
3384 VkBool32 sparseResidencyImage2D;
3385 VkBool32 sparseResidencyImage3D;
3386 VkBool32 sparseResidency2Samples;
3387 VkBool32 sparseResidency4Samples;
3388 VkBool32 sparseResidency8Samples;
3389 VkBool32 sparseResidency16Samples;
3390 VkBool32 sparseResidencyAliased;
3391 VkBool32 variableMultisampleRate;
3392 VkBool32 inheritedQueries;
3393} VkPhysicalDeviceFeatures;
3394
3395typedef struct VkPhysicalDeviceSparseProperties {
3396 VkBool32 residencyStandard2DBlockShape;
3397 VkBool32 residencyStandard2DMultisampleBlockShape;
3398 VkBool32 residencyStandard3DBlockShape;
3399 VkBool32 residencyAlignedMipSize;
3400 VkBool32 residencyNonResidentStrict;
3401} VkPhysicalDeviceSparseProperties;
3402
3403typedef struct VkPhysicalDeviceLimits {
3404 uint32_t maxImageDimension1D;
3405 uint32_t maxImageDimension2D;
3406 uint32_t maxImageDimension3D;
3407 uint32_t maxImageDimensionCube;
3408 uint32_t maxImageArrayLayers;
3409 uint32_t maxTexelBufferElements;
3410 uint32_t maxUniformBufferRange;
3411 uint32_t maxStorageBufferRange;
3412 uint32_t maxPushConstantsSize;
3413 uint32_t maxMemoryAllocationCount;
3414 uint32_t maxSamplerAllocationCount;
3415 VkDeviceSize bufferImageGranularity;
3416 VkDeviceSize sparseAddressSpaceSize;
3417 uint32_t maxBoundDescriptorSets;
3418 uint32_t maxPerStageDescriptorSamplers;
3419 uint32_t maxPerStageDescriptorUniformBuffers;
3420 uint32_t maxPerStageDescriptorStorageBuffers;
3421 uint32_t maxPerStageDescriptorSampledImages;
3422 uint32_t maxPerStageDescriptorStorageImages;
3423 uint32_t maxPerStageDescriptorInputAttachments;
3424 uint32_t maxPerStageResources;
3425 uint32_t maxDescriptorSetSamplers;
3426 uint32_t maxDescriptorSetUniformBuffers;
3427 uint32_t maxDescriptorSetUniformBuffersDynamic;
3428 uint32_t maxDescriptorSetStorageBuffers;
3429 uint32_t maxDescriptorSetStorageBuffersDynamic;
3430 uint32_t maxDescriptorSetSampledImages;
3431 uint32_t maxDescriptorSetStorageImages;
3432 uint32_t maxDescriptorSetInputAttachments;
3433 uint32_t maxVertexInputAttributes;
3434 uint32_t maxVertexInputBindings;
3435 uint32_t maxVertexInputAttributeOffset;
3436 uint32_t maxVertexInputBindingStride;
3437 uint32_t maxVertexOutputComponents;
3438 uint32_t maxTessellationGenerationLevel;
3439 uint32_t maxTessellationPatchSize;
3440 uint32_t maxTessellationControlPerVertexInputComponents;
3441 uint32_t maxTessellationControlPerVertexOutputComponents;
3442 uint32_t maxTessellationControlPerPatchOutputComponents;
3443 uint32_t maxTessellationControlTotalOutputComponents;
3444 uint32_t maxTessellationEvaluationInputComponents;
3445 uint32_t maxTessellationEvaluationOutputComponents;
3446 uint32_t maxGeometryShaderInvocations;
3447 uint32_t maxGeometryInputComponents;
3448 uint32_t maxGeometryOutputComponents;
3449 uint32_t maxGeometryOutputVertices;
3450 uint32_t maxGeometryTotalOutputComponents;
3451 uint32_t maxFragmentInputComponents;
3452 uint32_t maxFragmentOutputAttachments;
3453 uint32_t maxFragmentDualSrcAttachments;
3454 uint32_t maxFragmentCombinedOutputResources;
3455 uint32_t maxComputeSharedMemorySize;
3456 uint32_t maxComputeWorkGroupCount [3];
3457 uint32_t maxComputeWorkGroupInvocations;
3458 uint32_t maxComputeWorkGroupSize [3];
3459 uint32_t subPixelPrecisionBits;
3460 uint32_t subTexelPrecisionBits;
3461 uint32_t mipmapPrecisionBits;
3462 uint32_t maxDrawIndexedIndexValue;
3463 uint32_t maxDrawIndirectCount;
3464 float maxSamplerLodBias;
3465 float maxSamplerAnisotropy;
3466 uint32_t maxViewports;
3467 uint32_t maxViewportDimensions [2];
3468 float viewportBoundsRange [2];
3469 uint32_t viewportSubPixelBits;
3470 size_t minMemoryMapAlignment;
3471 VkDeviceSize minTexelBufferOffsetAlignment;
3472 VkDeviceSize minUniformBufferOffsetAlignment;
3473 VkDeviceSize minStorageBufferOffsetAlignment;
3474 int32_t minTexelOffset;
3475 uint32_t maxTexelOffset;
3476 int32_t minTexelGatherOffset;
3477 uint32_t maxTexelGatherOffset;
3478 float minInterpolationOffset;
3479 float maxInterpolationOffset;
3480 uint32_t subPixelInterpolationOffsetBits;
3481 uint32_t maxFramebufferWidth;
3482 uint32_t maxFramebufferHeight;
3483 uint32_t maxFramebufferLayers;
3484 VkSampleCountFlags framebufferColorSampleCounts;
3485 VkSampleCountFlags framebufferDepthSampleCounts;
3486 VkSampleCountFlags framebufferStencilSampleCounts;
3487 VkSampleCountFlags framebufferNoAttachmentsSampleCounts;
3488 uint32_t maxColorAttachments;
3489 VkSampleCountFlags sampledImageColorSampleCounts;
3490 VkSampleCountFlags sampledImageIntegerSampleCounts;
3491 VkSampleCountFlags sampledImageDepthSampleCounts;
3492 VkSampleCountFlags sampledImageStencilSampleCounts;
3493 VkSampleCountFlags storageImageSampleCounts;
3494 uint32_t maxSampleMaskWords;
3495 VkBool32 timestampComputeAndGraphics;
3496 float timestampPeriod;
3497 uint32_t maxClipDistances;
3498 uint32_t maxCullDistances;
3499 uint32_t maxCombinedClipAndCullDistances;
3500 uint32_t discreteQueuePriorities;
3501 float pointSizeRange [2];
3502 float lineWidthRange [2];
3503 float pointSizeGranularity;
3504 float lineWidthGranularity;
3505 VkBool32 strictLines;
3506 VkBool32 standardSampleLocations;
3507 VkDeviceSize optimalBufferCopyOffsetAlignment;
3508 VkDeviceSize optimalBufferCopyRowPitchAlignment;
3509 VkDeviceSize nonCoherentAtomSize;
3510} VkPhysicalDeviceLimits;
3511
3512typedef struct VkSemaphoreCreateInfo {
3513 VkStructureType sType;
3514 const void * pNext;
3515 VkSemaphoreCreateFlags flags;
3516} VkSemaphoreCreateInfo;
3517
3518typedef struct VkQueryPoolCreateInfo {
3519 VkStructureType sType;
3520 const void * pNext;
3521 VkQueryPoolCreateFlags flags;
3522 VkQueryType queryType;
3523 uint32_t queryCount;
3524 VkQueryPipelineStatisticFlags pipelineStatistics;
3525} VkQueryPoolCreateInfo;
3526
3527typedef struct VkFramebufferCreateInfo {
3528 VkStructureType sType;
3529 const void * pNext;
3530 VkFramebufferCreateFlags flags;
3531 VkRenderPass renderPass;
3532 uint32_t attachmentCount;
3533 const VkImageView * pAttachments;
3534 uint32_t width;
3535 uint32_t height;
3536 uint32_t layers;
3537} VkFramebufferCreateInfo;
3538
3539typedef struct VkSubmitInfo {
3540 VkStructureType sType;
3541 const void * pNext;
3542 uint32_t waitSemaphoreCount;
3543 const VkSemaphore * pWaitSemaphores;
3544 const VkPipelineStageFlags * pWaitDstStageMask;
3545 uint32_t commandBufferCount;
3546 const VkCommandBuffer * pCommandBuffers;
3547 uint32_t signalSemaphoreCount;
3548 const VkSemaphore * pSignalSemaphores;
3549} VkSubmitInfo;
3550
3551typedef struct VkSurfaceCapabilitiesKHR {
3552 uint32_t minImageCount;
3553 uint32_t maxImageCount;
3554 VkExtent2D currentExtent;
3555 VkExtent2D minImageExtent;
3556 VkExtent2D maxImageExtent;
3557 uint32_t maxImageArrayLayers;
3558 VkSurfaceTransformFlagsKHR supportedTransforms;
3559 VkSurfaceTransformFlagBitsKHR currentTransform;
3560 VkCompositeAlphaFlagsKHR supportedCompositeAlpha;
3561 VkImageUsageFlags supportedUsageFlags;
3562} VkSurfaceCapabilitiesKHR;
3563
3564typedef struct VkSwapchainCreateInfoKHR {
3565 VkStructureType sType;
3566 const void * pNext;
3567 VkSwapchainCreateFlagsKHR flags;
3568 VkSurfaceKHR surface;
3569 uint32_t minImageCount;
3570 VkFormat imageFormat;
3571 VkColorSpaceKHR imageColorSpace;
3572 VkExtent2D imageExtent;
3573 uint32_t imageArrayLayers;
3574 VkImageUsageFlags imageUsage;
3575 VkSharingMode imageSharingMode;
3576 uint32_t queueFamilyIndexCount;
3577 const uint32_t * pQueueFamilyIndices;
3578 VkSurfaceTransformFlagBitsKHR preTransform;
3579 VkCompositeAlphaFlagBitsKHR compositeAlpha;
3580 VkPresentModeKHR presentMode;
3581 VkBool32 clipped;
3582 VkSwapchainKHR oldSwapchain;
3583} VkSwapchainCreateInfoKHR;
3584
3585typedef struct VkDebugReportCallbackCreateInfoEXT {
3586 VkStructureType sType;
3587 const void * pNext;
3588 VkDebugReportFlagsEXT flags;
3589 PFN_vkDebugReportCallbackEXT pfnCallback;
3590 void * pUserData;
3591} VkDebugReportCallbackCreateInfoEXT;
3592
3593typedef struct VkPrivateDataSlotCreateInfo {
3594 VkStructureType sType;
3595 const void * pNext;
3596 VkPrivateDataSlotCreateFlags flags;
3597} VkPrivateDataSlotCreateInfo;
3598
3599typedef struct VkPhysicalDevicePrivateDataFeatures {
3600 VkStructureType sType;
3601 void * pNext;
3602 VkBool32 privateData;
3603} VkPhysicalDevicePrivateDataFeatures;
3604
3605typedef struct VkPhysicalDeviceFeatures2 {
3606 VkStructureType sType;
3607 void * pNext;
3608 VkPhysicalDeviceFeatures features;
3609} VkPhysicalDeviceFeatures2;
3610
3611typedef struct VkFormatProperties2 {
3612 VkStructureType sType;
3613 void * pNext;
3614 VkFormatProperties formatProperties;
3615} VkFormatProperties2;
3616
3617typedef struct VkImageFormatProperties2 {
3618 VkStructureType sType;
3619 void * pNext;
3620 VkImageFormatProperties imageFormatProperties;
3621} VkImageFormatProperties2;
3622
3623typedef struct VkPhysicalDeviceImageFormatInfo2 {
3624 VkStructureType sType;
3625 const void * pNext;
3626 VkFormat format;
3627 VkImageType type;
3628 VkImageTiling tiling;
3629 VkImageUsageFlags usage;
3630 VkImageCreateFlags flags;
3631} VkPhysicalDeviceImageFormatInfo2;
3632
3633typedef struct VkQueueFamilyProperties2 {
3634 VkStructureType sType;
3635 void * pNext;
3636 VkQueueFamilyProperties queueFamilyProperties;
3637} VkQueueFamilyProperties2;
3638
3639typedef struct VkSparseImageFormatProperties2 {
3640 VkStructureType sType;
3641 void * pNext;
3642 VkSparseImageFormatProperties properties;
3643} VkSparseImageFormatProperties2;
3644
3645typedef struct VkPhysicalDeviceSparseImageFormatInfo2 {
3646 VkStructureType sType;
3647 const void * pNext;
3648 VkFormat format;
3649 VkImageType type;
3650 VkSampleCountFlagBits samples;
3651 VkImageUsageFlags usage;
3652 VkImageTiling tiling;
3653} VkPhysicalDeviceSparseImageFormatInfo2;
3654
3655typedef struct VkPhysicalDeviceVariablePointersFeatures {
3656 VkStructureType sType;
3657 void * pNext;
3658 VkBool32 variablePointersStorageBuffer;
3659 VkBool32 variablePointers;
3660} VkPhysicalDeviceVariablePointersFeatures;
3661
3662typedef struct VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointerFeatures;
3663
3664typedef struct VkExternalMemoryProperties {
3665 VkExternalMemoryFeatureFlags externalMemoryFeatures;
3666 VkExternalMemoryHandleTypeFlags exportFromImportedHandleTypes;
3667 VkExternalMemoryHandleTypeFlags compatibleHandleTypes;
3668} VkExternalMemoryProperties;
3669
3670typedef struct VkExternalImageFormatProperties {
3671 VkStructureType sType;
3672 void * pNext;
3673 VkExternalMemoryProperties externalMemoryProperties;
3674} VkExternalImageFormatProperties;
3675
3676typedef struct VkPhysicalDeviceExternalBufferInfo {
3677 VkStructureType sType;
3678 const void * pNext;
3679 VkBufferCreateFlags flags;
3680 VkBufferUsageFlags usage;
3681 VkExternalMemoryHandleTypeFlagBits handleType;
3682} VkPhysicalDeviceExternalBufferInfo;
3683
3684typedef struct VkExternalBufferProperties {
3685 VkStructureType sType;
3686 void * pNext;
3687 VkExternalMemoryProperties externalMemoryProperties;
3688} VkExternalBufferProperties;
3689
3690typedef struct VkPhysicalDeviceIDProperties {
3691 VkStructureType sType;
3692 void * pNext;
3693 uint8_t deviceUUID [ VK_UUID_SIZE ];
3694 uint8_t driverUUID [ VK_UUID_SIZE ];
3695 uint8_t deviceLUID [ VK_LUID_SIZE ];
3696 uint32_t deviceNodeMask;
3697 VkBool32 deviceLUIDValid;
3698} VkPhysicalDeviceIDProperties;
3699
3700typedef struct VkExternalMemoryImageCreateInfo {
3701 VkStructureType sType;
3702 const void * pNext;
3703 VkExternalMemoryHandleTypeFlags handleTypes;
3704} VkExternalMemoryImageCreateInfo;
3705
3706typedef struct VkExternalMemoryBufferCreateInfo {
3707 VkStructureType sType;
3708 const void * pNext;
3709 VkExternalMemoryHandleTypeFlags handleTypes;
3710} VkExternalMemoryBufferCreateInfo;
3711
3712typedef struct VkExportMemoryAllocateInfo {
3713 VkStructureType sType;
3714 const void * pNext;
3715 VkExternalMemoryHandleTypeFlags handleTypes;
3716} VkExportMemoryAllocateInfo;
3717
3718typedef struct VkExternalSemaphoreProperties {
3719 VkStructureType sType;
3720 void * pNext;
3721 VkExternalSemaphoreHandleTypeFlags exportFromImportedHandleTypes;
3722 VkExternalSemaphoreHandleTypeFlags compatibleHandleTypes;
3723 VkExternalSemaphoreFeatureFlags externalSemaphoreFeatures;
3724} VkExternalSemaphoreProperties;
3725
3726typedef struct VkExportSemaphoreCreateInfo {
3727 VkStructureType sType;
3728 const void * pNext;
3729 VkExternalSemaphoreHandleTypeFlags handleTypes;
3730} VkExportSemaphoreCreateInfo;
3731
3732typedef struct VkExternalFenceProperties {
3733 VkStructureType sType;
3734 void * pNext;
3735 VkExternalFenceHandleTypeFlags exportFromImportedHandleTypes;
3736 VkExternalFenceHandleTypeFlags compatibleHandleTypes;
3737 VkExternalFenceFeatureFlags externalFenceFeatures;
3738} VkExternalFenceProperties;
3739
3740typedef struct VkExportFenceCreateInfo {
3741 VkStructureType sType;
3742 const void * pNext;
3743 VkExternalFenceHandleTypeFlags handleTypes;
3744} VkExportFenceCreateInfo;
3745
3746typedef struct VkPhysicalDeviceMultiviewFeatures {
3747 VkStructureType sType;
3748 void * pNext;
3749 VkBool32 multiview;
3750 VkBool32 multiviewGeometryShader;
3751 VkBool32 multiviewTessellationShader;
3752} VkPhysicalDeviceMultiviewFeatures;
3753
3754typedef struct VkPhysicalDeviceGroupProperties {
3755 VkStructureType sType;
3756 void * pNext;
3757 uint32_t physicalDeviceCount;
3758 VkPhysicalDevice physicalDevices [ VK_MAX_DEVICE_GROUP_SIZE ];
3759 VkBool32 subsetAllocation;
3760} VkPhysicalDeviceGroupProperties;
3761
3762typedef struct VkMemoryAllocateFlagsInfo {
3763 VkStructureType sType;
3764 const void * pNext;
3765 VkMemoryAllocateFlags flags;
3766 uint32_t deviceMask;
3767} VkMemoryAllocateFlagsInfo;
3768
3769typedef struct VkBindBufferMemoryInfo {
3770 VkStructureType sType;
3771 const void * pNext;
3772 VkBuffer buffer;
3773 VkDeviceMemory memory;
3774 VkDeviceSize memoryOffset;
3775} VkBindBufferMemoryInfo;
3776
3777typedef struct VkBindImageMemoryInfo {
3778 VkStructureType sType;
3779 const void * pNext;
3780 VkImage image;
3781 VkDeviceMemory memory;
3782 VkDeviceSize memoryOffset;
3783} VkBindImageMemoryInfo;
3784
3785typedef struct VkDeviceGroupPresentCapabilitiesKHR {
3786 VkStructureType sType;
3787 void * pNext;
3788 uint32_t presentMask [ VK_MAX_DEVICE_GROUP_SIZE ];
3789 VkDeviceGroupPresentModeFlagsKHR modes;
3790} VkDeviceGroupPresentCapabilitiesKHR;
3791
3792typedef struct VkDeviceGroupSwapchainCreateInfoKHR {
3793 VkStructureType sType;
3794 const void * pNext;
3795 VkDeviceGroupPresentModeFlagsKHR modes;
3796} VkDeviceGroupSwapchainCreateInfoKHR;
3797
3798typedef struct VkDescriptorUpdateTemplateCreateInfo {
3799 VkStructureType sType;
3800 const void * pNext;
3801 VkDescriptorUpdateTemplateCreateFlags flags;
3802 uint32_t descriptorUpdateEntryCount;
3803 const VkDescriptorUpdateTemplateEntry * pDescriptorUpdateEntries;
3804 VkDescriptorUpdateTemplateType templateType;
3805 VkDescriptorSetLayout descriptorSetLayout;
3806 VkPipelineBindPoint pipelineBindPoint;
3807 VkPipelineLayout pipelineLayout;
3808 uint32_t set;
3809} VkDescriptorUpdateTemplateCreateInfo;
3810
3811typedef struct VkInputAttachmentAspectReference {
3812 uint32_t subpass;
3813 uint32_t inputAttachmentIndex;
3814 VkImageAspectFlags aspectMask;
3815} VkInputAttachmentAspectReference;
3816
3817typedef struct VkRenderPassInputAttachmentAspectCreateInfo {
3818 VkStructureType sType;
3819 const void * pNext;
3820 uint32_t aspectReferenceCount;
3821 const VkInputAttachmentAspectReference * pAspectReferences;
3822} VkRenderPassInputAttachmentAspectCreateInfo;
3823
3824typedef struct VkPhysicalDevice16BitStorageFeatures {
3825 VkStructureType sType;
3826 void * pNext;
3827 VkBool32 storageBuffer16BitAccess;
3828 VkBool32 uniformAndStorageBuffer16BitAccess;
3829 VkBool32 storagePushConstant16;
3830 VkBool32 storageInputOutput16;
3831} VkPhysicalDevice16BitStorageFeatures;
3832
3833typedef struct VkPhysicalDeviceSubgroupProperties {
3834 VkStructureType sType;
3835 void * pNext;
3836 uint32_t subgroupSize;
3837 VkShaderStageFlags supportedStages;
3838 VkSubgroupFeatureFlags supportedOperations;
3839 VkBool32 quadOperationsInAllStages;
3840} VkPhysicalDeviceSubgroupProperties;
3841
3842typedef struct VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures {
3843 VkStructureType sType;
3844 void * pNext;
3845 VkBool32 shaderSubgroupExtendedTypes;
3846} VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures;
3847
3848typedef struct VkDeviceBufferMemoryRequirements {
3849 VkStructureType sType;
3850 const void * pNext;
3851 const VkBufferCreateInfo * pCreateInfo;
3852} VkDeviceBufferMemoryRequirements;
3853
3854typedef struct VkDeviceImageMemoryRequirements {
3855 VkStructureType sType;
3856 const void * pNext;
3857 const VkImageCreateInfo * pCreateInfo;
3858 VkImageAspectFlagBits planeAspect;
3859} VkDeviceImageMemoryRequirements;
3860
3861typedef struct VkMemoryRequirements2 {
3862 VkStructureType sType;
3863 void * pNext;
3864 VkMemoryRequirements memoryRequirements;
3865} VkMemoryRequirements2;
3866
3867typedef struct VkSparseImageMemoryRequirements2 {
3868 VkStructureType sType;
3869 void * pNext;
3870 VkSparseImageMemoryRequirements memoryRequirements;
3871} VkSparseImageMemoryRequirements2;
3872
3873typedef struct VkMemoryDedicatedRequirements {
3874 VkStructureType sType;
3875 void * pNext;
3876 VkBool32 prefersDedicatedAllocation;
3877 VkBool32 requiresDedicatedAllocation;
3878} VkMemoryDedicatedRequirements;
3879
3880typedef struct VkImageViewUsageCreateInfo {
3881 VkStructureType sType;
3882 const void * pNext;
3883 VkImageUsageFlags usage;
3884} VkImageViewUsageCreateInfo;
3885
3886typedef struct VkSamplerYcbcrConversionCreateInfo {
3887 VkStructureType sType;
3888 const void * pNext;
3889 VkFormat format;
3890 VkSamplerYcbcrModelConversion ycbcrModel;
3891 VkSamplerYcbcrRange ycbcrRange;
3892 VkComponentMapping components;
3893 VkChromaLocation xChromaOffset;
3894 VkChromaLocation yChromaOffset;
3895 VkFilter chromaFilter;
3896 VkBool32 forceExplicitReconstruction;
3897} VkSamplerYcbcrConversionCreateInfo;
3898
3899typedef struct VkPhysicalDeviceSamplerYcbcrConversionFeatures {
3900 VkStructureType sType;
3901 void * pNext;
3902 VkBool32 samplerYcbcrConversion;
3903} VkPhysicalDeviceSamplerYcbcrConversionFeatures;
3904
3905typedef struct VkProtectedSubmitInfo {
3906 VkStructureType sType;
3907 const void * pNext;
3908 VkBool32 protectedSubmit;
3909} VkProtectedSubmitInfo;
3910
3911typedef struct VkPhysicalDeviceProtectedMemoryFeatures {
3912 VkStructureType sType;
3913 void * pNext;
3914 VkBool32 protectedMemory;
3915} VkPhysicalDeviceProtectedMemoryFeatures;
3916
3917typedef struct VkPhysicalDeviceProtectedMemoryProperties {
3918 VkStructureType sType;
3919 void * pNext;
3920 VkBool32 protectedNoFault;
3921} VkPhysicalDeviceProtectedMemoryProperties;
3922
3923typedef struct VkDeviceQueueInfo2 {
3924 VkStructureType sType;
3925 const void * pNext;
3926 VkDeviceQueueCreateFlags flags;
3927 uint32_t queueFamilyIndex;
3928 uint32_t queueIndex;
3929} VkDeviceQueueInfo2;
3930
3931typedef struct VkPhysicalDeviceSamplerFilterMinmaxProperties {
3932 VkStructureType sType;
3933 void * pNext;
3934 VkBool32 filterMinmaxSingleComponentFormats;
3935 VkBool32 filterMinmaxImageComponentMapping;
3936} VkPhysicalDeviceSamplerFilterMinmaxProperties;
3937
3938typedef struct VkPhysicalDeviceInlineUniformBlockFeatures {
3939 VkStructureType sType;
3940 void * pNext;
3941 VkBool32 inlineUniformBlock;
3942 VkBool32 descriptorBindingInlineUniformBlockUpdateAfterBind;
3943} VkPhysicalDeviceInlineUniformBlockFeatures;
3944
3945typedef struct VkPhysicalDeviceMaintenance3Properties {
3946 VkStructureType sType;
3947 void * pNext;
3948 uint32_t maxPerSetDescriptors;
3949 VkDeviceSize maxMemoryAllocationSize;
3950} VkPhysicalDeviceMaintenance3Properties;
3951
3952typedef struct VkPhysicalDeviceMaintenance4Features {
3953 VkStructureType sType;
3954 void * pNext;
3955 VkBool32 maintenance4;
3956} VkPhysicalDeviceMaintenance4Features;
3957
3958typedef struct VkPhysicalDeviceMaintenance4Properties {
3959 VkStructureType sType;
3960 void * pNext;
3961 VkDeviceSize maxBufferSize;
3962} VkPhysicalDeviceMaintenance4Properties;
3963
3964typedef struct VkDescriptorSetLayoutSupport {
3965 VkStructureType sType;
3966 void * pNext;
3967 VkBool32 supported;
3968} VkDescriptorSetLayoutSupport;
3969
3970typedef struct VkPhysicalDeviceShaderDrawParametersFeatures {
3971 VkStructureType sType;
3972 void * pNext;
3973 VkBool32 shaderDrawParameters;
3974} VkPhysicalDeviceShaderDrawParametersFeatures;
3975
3976typedef struct VkPhysicalDeviceShaderDrawParametersFeatures VkPhysicalDeviceShaderDrawParameterFeatures;
3977
3978typedef struct VkPhysicalDeviceShaderFloat16Int8Features {
3979 VkStructureType sType;
3980 void * pNext;
3981 VkBool32 shaderFloat16;
3982 VkBool32 shaderInt8;
3983} VkPhysicalDeviceShaderFloat16Int8Features;
3984
3985typedef struct VkPhysicalDeviceFloatControlsProperties {
3986 VkStructureType sType;
3987 void * pNext;
3988 VkShaderFloatControlsIndependence denormBehaviorIndependence;
3989 VkShaderFloatControlsIndependence roundingModeIndependence;
3990 VkBool32 shaderSignedZeroInfNanPreserveFloat16;
3991 VkBool32 shaderSignedZeroInfNanPreserveFloat32;
3992 VkBool32 shaderSignedZeroInfNanPreserveFloat64;
3993 VkBool32 shaderDenormPreserveFloat16;
3994 VkBool32 shaderDenormPreserveFloat32;
3995 VkBool32 shaderDenormPreserveFloat64;
3996 VkBool32 shaderDenormFlushToZeroFloat16;
3997 VkBool32 shaderDenormFlushToZeroFloat32;
3998 VkBool32 shaderDenormFlushToZeroFloat64;
3999 VkBool32 shaderRoundingModeRTEFloat16;
4000 VkBool32 shaderRoundingModeRTEFloat32;
4001 VkBool32 shaderRoundingModeRTEFloat64;
4002 VkBool32 shaderRoundingModeRTZFloat16;
4003 VkBool32 shaderRoundingModeRTZFloat32;
4004 VkBool32 shaderRoundingModeRTZFloat64;
4005} VkPhysicalDeviceFloatControlsProperties;
4006
4007typedef struct VkPhysicalDeviceHostQueryResetFeatures {
4008 VkStructureType sType;
4009 void * pNext;
4010 VkBool32 hostQueryReset;
4011} VkPhysicalDeviceHostQueryResetFeatures;
4012
4013typedef struct VkPhysicalDeviceDescriptorIndexingFeatures {
4014 VkStructureType sType;
4015 void * pNext;
4016 VkBool32 shaderInputAttachmentArrayDynamicIndexing;
4017 VkBool32 shaderUniformTexelBufferArrayDynamicIndexing;
4018 VkBool32 shaderStorageTexelBufferArrayDynamicIndexing;
4019 VkBool32 shaderUniformBufferArrayNonUniformIndexing;
4020 VkBool32 shaderSampledImageArrayNonUniformIndexing;
4021 VkBool32 shaderStorageBufferArrayNonUniformIndexing;
4022 VkBool32 shaderStorageImageArrayNonUniformIndexing;
4023 VkBool32 shaderInputAttachmentArrayNonUniformIndexing;
4024 VkBool32 shaderUniformTexelBufferArrayNonUniformIndexing;
4025 VkBool32 shaderStorageTexelBufferArrayNonUniformIndexing;
4026 VkBool32 descriptorBindingUniformBufferUpdateAfterBind;
4027 VkBool32 descriptorBindingSampledImageUpdateAfterBind;
4028 VkBool32 descriptorBindingStorageImageUpdateAfterBind;
4029 VkBool32 descriptorBindingStorageBufferUpdateAfterBind;
4030 VkBool32 descriptorBindingUniformTexelBufferUpdateAfterBind;
4031 VkBool32 descriptorBindingStorageTexelBufferUpdateAfterBind;
4032 VkBool32 descriptorBindingUpdateUnusedWhilePending;
4033 VkBool32 descriptorBindingPartiallyBound;
4034 VkBool32 descriptorBindingVariableDescriptorCount;
4035 VkBool32 runtimeDescriptorArray;
4036} VkPhysicalDeviceDescriptorIndexingFeatures;
4037
4038typedef struct VkPhysicalDeviceDescriptorIndexingProperties {
4039 VkStructureType sType;
4040 void * pNext;
4041 uint32_t maxUpdateAfterBindDescriptorsInAllPools;
4042 VkBool32 shaderUniformBufferArrayNonUniformIndexingNative;
4043 VkBool32 shaderSampledImageArrayNonUniformIndexingNative;
4044 VkBool32 shaderStorageBufferArrayNonUniformIndexingNative;
4045 VkBool32 shaderStorageImageArrayNonUniformIndexingNative;
4046 VkBool32 shaderInputAttachmentArrayNonUniformIndexingNative;
4047 VkBool32 robustBufferAccessUpdateAfterBind;
4048 VkBool32 quadDivergentImplicitLod;
4049 uint32_t maxPerStageDescriptorUpdateAfterBindSamplers;
4050 uint32_t maxPerStageDescriptorUpdateAfterBindUniformBuffers;
4051 uint32_t maxPerStageDescriptorUpdateAfterBindStorageBuffers;
4052 uint32_t maxPerStageDescriptorUpdateAfterBindSampledImages;
4053 uint32_t maxPerStageDescriptorUpdateAfterBindStorageImages;
4054 uint32_t maxPerStageDescriptorUpdateAfterBindInputAttachments;
4055 uint32_t maxPerStageUpdateAfterBindResources;
4056 uint32_t maxDescriptorSetUpdateAfterBindSamplers;
4057 uint32_t maxDescriptorSetUpdateAfterBindUniformBuffers;
4058 uint32_t maxDescriptorSetUpdateAfterBindUniformBuffersDynamic;
4059 uint32_t maxDescriptorSetUpdateAfterBindStorageBuffers;
4060 uint32_t maxDescriptorSetUpdateAfterBindStorageBuffersDynamic;
4061 uint32_t maxDescriptorSetUpdateAfterBindSampledImages;
4062 uint32_t maxDescriptorSetUpdateAfterBindStorageImages;
4063 uint32_t maxDescriptorSetUpdateAfterBindInputAttachments;
4064} VkPhysicalDeviceDescriptorIndexingProperties;
4065
4066typedef struct VkDescriptorSetLayoutBindingFlagsCreateInfo {
4067 VkStructureType sType;
4068 const void * pNext;
4069 uint32_t bindingCount;
4070 const VkDescriptorBindingFlags * pBindingFlags;
4071} VkDescriptorSetLayoutBindingFlagsCreateInfo;
4072
4073typedef struct VkAttachmentDescription2 {
4074 VkStructureType sType;
4075 const void * pNext;
4076 VkAttachmentDescriptionFlags flags;
4077 VkFormat format;
4078 VkSampleCountFlagBits samples;
4079 VkAttachmentLoadOp loadOp;
4080 VkAttachmentStoreOp storeOp;
4081 VkAttachmentLoadOp stencilLoadOp;
4082 VkAttachmentStoreOp stencilStoreOp;
4083 VkImageLayout initialLayout;
4084 VkImageLayout finalLayout;
4085} VkAttachmentDescription2;
4086
4087typedef struct VkAttachmentReference2 {
4088 VkStructureType sType;
4089 const void * pNext;
4090 uint32_t attachment;
4091 VkImageLayout layout;
4092 VkImageAspectFlags aspectMask;
4093} VkAttachmentReference2;
4094
4095typedef struct VkSubpassDescription2 {
4096 VkStructureType sType;
4097 const void * pNext;
4098 VkSubpassDescriptionFlags flags;
4099 VkPipelineBindPoint pipelineBindPoint;
4100 uint32_t viewMask;
4101 uint32_t inputAttachmentCount;
4102 const VkAttachmentReference2 * pInputAttachments;
4103 uint32_t colorAttachmentCount;
4104 const VkAttachmentReference2 * pColorAttachments;
4105 const VkAttachmentReference2 * pResolveAttachments;
4106 const VkAttachmentReference2 * pDepthStencilAttachment;
4107 uint32_t preserveAttachmentCount;
4108 const uint32_t * pPreserveAttachments;
4109} VkSubpassDescription2;
4110
4111typedef struct VkSubpassDependency2 {
4112 VkStructureType sType;
4113 const void * pNext;
4114 uint32_t srcSubpass;
4115 uint32_t dstSubpass;
4116 VkPipelineStageFlags srcStageMask;
4117 VkPipelineStageFlags dstStageMask;
4118 VkAccessFlags srcAccessMask;
4119 VkAccessFlags dstAccessMask;
4120 VkDependencyFlags dependencyFlags;
4121 int32_t viewOffset;
4122} VkSubpassDependency2;
4123
4124typedef struct VkRenderPassCreateInfo2 {
4125 VkStructureType sType;
4126 const void * pNext;
4127 VkRenderPassCreateFlags flags;
4128 uint32_t attachmentCount;
4129 const VkAttachmentDescription2 * pAttachments;
4130 uint32_t subpassCount;
4131 const VkSubpassDescription2 * pSubpasses;
4132 uint32_t dependencyCount;
4133 const VkSubpassDependency2 * pDependencies;
4134 uint32_t correlatedViewMaskCount;
4135 const uint32_t * pCorrelatedViewMasks;
4136} VkRenderPassCreateInfo2;
4137
4138typedef struct VkPhysicalDeviceTimelineSemaphoreFeatures {
4139 VkStructureType sType;
4140 void * pNext;
4141 VkBool32 timelineSemaphore;
4142} VkPhysicalDeviceTimelineSemaphoreFeatures;
4143
4144typedef struct VkSemaphoreWaitInfo {
4145 VkStructureType sType;
4146 const void * pNext;
4147 VkSemaphoreWaitFlags flags;
4148 uint32_t semaphoreCount;
4149 const VkSemaphore * pSemaphores;
4150 const uint64_t * pValues;
4151} VkSemaphoreWaitInfo;
4152
4153typedef struct VkPhysicalDevice8BitStorageFeatures {
4154 VkStructureType sType;
4155 void * pNext;
4156 VkBool32 storageBuffer8BitAccess;
4157 VkBool32 uniformAndStorageBuffer8BitAccess;
4158 VkBool32 storagePushConstant8;
4159} VkPhysicalDevice8BitStorageFeatures;
4160
4161typedef struct VkPhysicalDeviceVulkanMemoryModelFeatures {
4162 VkStructureType sType;
4163 void * pNext;
4164 VkBool32 vulkanMemoryModel;
4165 VkBool32 vulkanMemoryModelDeviceScope;
4166 VkBool32 vulkanMemoryModelAvailabilityVisibilityChains;
4167} VkPhysicalDeviceVulkanMemoryModelFeatures;
4168
4169typedef struct VkPhysicalDeviceShaderAtomicInt64Features {
4170 VkStructureType sType;
4171 void * pNext;
4172 VkBool32 shaderBufferInt64Atomics;
4173 VkBool32 shaderSharedInt64Atomics;
4174} VkPhysicalDeviceShaderAtomicInt64Features;
4175
4176typedef struct VkPhysicalDeviceDepthStencilResolveProperties {
4177 VkStructureType sType;
4178 void * pNext;
4179 VkResolveModeFlags supportedDepthResolveModes;
4180 VkResolveModeFlags supportedStencilResolveModes;
4181 VkBool32 independentResolveNone;
4182 VkBool32 independentResolve;
4183} VkPhysicalDeviceDepthStencilResolveProperties;
4184
4185typedef struct VkSubpassDescriptionDepthStencilResolve {
4186 VkStructureType sType;
4187 const void * pNext;
4188 VkResolveModeFlagBits depthResolveMode;
4189 VkResolveModeFlagBits stencilResolveMode;
4190 const VkAttachmentReference2 * pDepthStencilResolveAttachment;
4191} VkSubpassDescriptionDepthStencilResolve;
4192
4193typedef struct VkImageStencilUsageCreateInfo {
4194 VkStructureType sType;
4195 const void * pNext;
4196 VkImageUsageFlags stencilUsage;
4197} VkImageStencilUsageCreateInfo;
4198
4199typedef struct VkPhysicalDeviceScalarBlockLayoutFeatures {
4200 VkStructureType sType;
4201 void * pNext;
4202 VkBool32 scalarBlockLayout;
4203} VkPhysicalDeviceScalarBlockLayoutFeatures;
4204
4205typedef struct VkPhysicalDeviceUniformBufferStandardLayoutFeatures {
4206 VkStructureType sType;
4207 void * pNext;
4208 VkBool32 uniformBufferStandardLayout;
4209} VkPhysicalDeviceUniformBufferStandardLayoutFeatures;
4210
4211typedef struct VkPhysicalDeviceBufferDeviceAddressFeatures {
4212 VkStructureType sType;
4213 void * pNext;
4214 VkBool32 bufferDeviceAddress;
4215 VkBool32 bufferDeviceAddressCaptureReplay;
4216 VkBool32 bufferDeviceAddressMultiDevice;
4217} VkPhysicalDeviceBufferDeviceAddressFeatures;
4218
4219typedef struct VkPhysicalDeviceImagelessFramebufferFeatures {
4220 VkStructureType sType;
4221 void * pNext;
4222 VkBool32 imagelessFramebuffer;
4223} VkPhysicalDeviceImagelessFramebufferFeatures;
4224
4225typedef struct VkFramebufferAttachmentImageInfo {
4226 VkStructureType sType;
4227 const void * pNext;
4228 VkImageCreateFlags flags;
4229 VkImageUsageFlags usage;
4230 uint32_t width;
4231 uint32_t height;
4232 uint32_t layerCount;
4233 uint32_t viewFormatCount;
4234 const VkFormat * pViewFormats;
4235} VkFramebufferAttachmentImageInfo;
4236
4237typedef struct VkPhysicalDeviceTextureCompressionASTCHDRFeatures {
4238 VkStructureType sType;
4239 void * pNext;
4240 VkBool32 textureCompressionASTC_HDR;
4241} VkPhysicalDeviceTextureCompressionASTCHDRFeatures;
4242
4243typedef struct VkPipelineCreationFeedback {
4244 VkPipelineCreationFeedbackFlags flags;
4245 uint64_t duration;
4246} VkPipelineCreationFeedback;
4247
4248typedef struct VkPipelineCreationFeedbackCreateInfo {
4249 VkStructureType sType;
4250 const void * pNext;
4251 VkPipelineCreationFeedback * pPipelineCreationFeedback;
4252 uint32_t pipelineStageCreationFeedbackCount;
4253 VkPipelineCreationFeedback * pPipelineStageCreationFeedbacks;
4254} VkPipelineCreationFeedbackCreateInfo;
4255
4256typedef struct VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures {
4257 VkStructureType sType;
4258 void * pNext;
4259 VkBool32 separateDepthStencilLayouts;
4260} VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures;
4261
4262typedef struct VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures {
4263 VkStructureType sType;
4264 void * pNext;
4265 VkBool32 shaderDemoteToHelperInvocation;
4266} VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures;
4267
4268typedef struct VkPhysicalDeviceTexelBufferAlignmentProperties {
4269 VkStructureType sType;
4270 void * pNext;
4271 VkDeviceSize storageTexelBufferOffsetAlignmentBytes;
4272 VkBool32 storageTexelBufferOffsetSingleTexelAlignment;
4273 VkDeviceSize uniformTexelBufferOffsetAlignmentBytes;
4274 VkBool32 uniformTexelBufferOffsetSingleTexelAlignment;
4275} VkPhysicalDeviceTexelBufferAlignmentProperties;
4276
4277typedef struct VkPhysicalDeviceSubgroupSizeControlFeatures {
4278 VkStructureType sType;
4279 void * pNext;
4280 VkBool32 subgroupSizeControl;
4281 VkBool32 computeFullSubgroups;
4282} VkPhysicalDeviceSubgroupSizeControlFeatures;
4283
4284typedef struct VkPhysicalDeviceSubgroupSizeControlProperties {
4285 VkStructureType sType;
4286 void * pNext;
4287 uint32_t minSubgroupSize;
4288 uint32_t maxSubgroupSize;
4289 uint32_t maxComputeWorkgroupSubgroups;
4290 VkShaderStageFlags requiredSubgroupSizeStages;
4291} VkPhysicalDeviceSubgroupSizeControlProperties;
4292
4293typedef struct VkPhysicalDevicePipelineCreationCacheControlFeatures {
4294 VkStructureType sType;
4295 void * pNext;
4296 VkBool32 pipelineCreationCacheControl;
4297} VkPhysicalDevicePipelineCreationCacheControlFeatures;
4298
4299typedef struct VkPhysicalDeviceVulkan11Features {
4300 VkStructureType sType;
4301 void * pNext;
4302 VkBool32 storageBuffer16BitAccess;
4303 VkBool32 uniformAndStorageBuffer16BitAccess;
4304 VkBool32 storagePushConstant16;
4305 VkBool32 storageInputOutput16;
4306 VkBool32 multiview;
4307 VkBool32 multiviewGeometryShader;
4308 VkBool32 multiviewTessellationShader;
4309 VkBool32 variablePointersStorageBuffer;
4310 VkBool32 variablePointers;
4311 VkBool32 protectedMemory;
4312 VkBool32 samplerYcbcrConversion;
4313 VkBool32 shaderDrawParameters;
4314} VkPhysicalDeviceVulkan11Features;
4315
4316typedef struct VkPhysicalDeviceVulkan11Properties {
4317 VkStructureType sType;
4318 void * pNext;
4319 uint8_t deviceUUID [ VK_UUID_SIZE ];
4320 uint8_t driverUUID [ VK_UUID_SIZE ];
4321 uint8_t deviceLUID [ VK_LUID_SIZE ];
4322 uint32_t deviceNodeMask;
4323 VkBool32 deviceLUIDValid;
4324 uint32_t subgroupSize;
4325 VkShaderStageFlags subgroupSupportedStages;
4326 VkSubgroupFeatureFlags subgroupSupportedOperations;
4327 VkBool32 subgroupQuadOperationsInAllStages;
4328 VkPointClippingBehavior pointClippingBehavior;
4329 uint32_t maxMultiviewViewCount;
4330 uint32_t maxMultiviewInstanceIndex;
4331 VkBool32 protectedNoFault;
4332 uint32_t maxPerSetDescriptors;
4333 VkDeviceSize maxMemoryAllocationSize;
4334} VkPhysicalDeviceVulkan11Properties;
4335
4336typedef struct VkPhysicalDeviceVulkan12Features {
4337 VkStructureType sType;
4338 void * pNext;
4339 VkBool32 samplerMirrorClampToEdge;
4340 VkBool32 drawIndirectCount;
4341 VkBool32 storageBuffer8BitAccess;
4342 VkBool32 uniformAndStorageBuffer8BitAccess;
4343 VkBool32 storagePushConstant8;
4344 VkBool32 shaderBufferInt64Atomics;
4345 VkBool32 shaderSharedInt64Atomics;
4346 VkBool32 shaderFloat16;
4347 VkBool32 shaderInt8;
4348 VkBool32 descriptorIndexing;
4349 VkBool32 shaderInputAttachmentArrayDynamicIndexing;
4350 VkBool32 shaderUniformTexelBufferArrayDynamicIndexing;
4351 VkBool32 shaderStorageTexelBufferArrayDynamicIndexing;
4352 VkBool32 shaderUniformBufferArrayNonUniformIndexing;
4353 VkBool32 shaderSampledImageArrayNonUniformIndexing;
4354 VkBool32 shaderStorageBufferArrayNonUniformIndexing;
4355 VkBool32 shaderStorageImageArrayNonUniformIndexing;
4356 VkBool32 shaderInputAttachmentArrayNonUniformIndexing;
4357 VkBool32 shaderUniformTexelBufferArrayNonUniformIndexing;
4358 VkBool32 shaderStorageTexelBufferArrayNonUniformIndexing;
4359 VkBool32 descriptorBindingUniformBufferUpdateAfterBind;
4360 VkBool32 descriptorBindingSampledImageUpdateAfterBind;
4361 VkBool32 descriptorBindingStorageImageUpdateAfterBind;
4362 VkBool32 descriptorBindingStorageBufferUpdateAfterBind;
4363 VkBool32 descriptorBindingUniformTexelBufferUpdateAfterBind;
4364 VkBool32 descriptorBindingStorageTexelBufferUpdateAfterBind;
4365 VkBool32 descriptorBindingUpdateUnusedWhilePending;
4366 VkBool32 descriptorBindingPartiallyBound;
4367 VkBool32 descriptorBindingVariableDescriptorCount;
4368 VkBool32 runtimeDescriptorArray;
4369 VkBool32 samplerFilterMinmax;
4370 VkBool32 scalarBlockLayout;
4371 VkBool32 imagelessFramebuffer;
4372 VkBool32 uniformBufferStandardLayout;
4373 VkBool32 shaderSubgroupExtendedTypes;
4374 VkBool32 separateDepthStencilLayouts;
4375 VkBool32 hostQueryReset;
4376 VkBool32 timelineSemaphore;
4377 VkBool32 bufferDeviceAddress;
4378 VkBool32 bufferDeviceAddressCaptureReplay;
4379 VkBool32 bufferDeviceAddressMultiDevice;
4380 VkBool32 vulkanMemoryModel;
4381 VkBool32 vulkanMemoryModelDeviceScope;
4382 VkBool32 vulkanMemoryModelAvailabilityVisibilityChains;
4383 VkBool32 shaderOutputViewportIndex;
4384 VkBool32 shaderOutputLayer;
4385 VkBool32 subgroupBroadcastDynamicId;
4386} VkPhysicalDeviceVulkan12Features;
4387
4388typedef struct VkPhysicalDeviceVulkan12Properties {
4389 VkStructureType sType;
4390 void * pNext;
4391 VkDriverId driverID;
4392 char driverName [ VK_MAX_DRIVER_NAME_SIZE ];
4393 char driverInfo [ VK_MAX_DRIVER_INFO_SIZE ];
4394 VkConformanceVersion conformanceVersion;
4395 VkShaderFloatControlsIndependence denormBehaviorIndependence;
4396 VkShaderFloatControlsIndependence roundingModeIndependence;
4397 VkBool32 shaderSignedZeroInfNanPreserveFloat16;
4398 VkBool32 shaderSignedZeroInfNanPreserveFloat32;
4399 VkBool32 shaderSignedZeroInfNanPreserveFloat64;
4400 VkBool32 shaderDenormPreserveFloat16;
4401 VkBool32 shaderDenormPreserveFloat32;
4402 VkBool32 shaderDenormPreserveFloat64;
4403 VkBool32 shaderDenormFlushToZeroFloat16;
4404 VkBool32 shaderDenormFlushToZeroFloat32;
4405 VkBool32 shaderDenormFlushToZeroFloat64;
4406 VkBool32 shaderRoundingModeRTEFloat16;
4407 VkBool32 shaderRoundingModeRTEFloat32;
4408 VkBool32 shaderRoundingModeRTEFloat64;
4409 VkBool32 shaderRoundingModeRTZFloat16;
4410 VkBool32 shaderRoundingModeRTZFloat32;
4411 VkBool32 shaderRoundingModeRTZFloat64;
4412 uint32_t maxUpdateAfterBindDescriptorsInAllPools;
4413 VkBool32 shaderUniformBufferArrayNonUniformIndexingNative;
4414 VkBool32 shaderSampledImageArrayNonUniformIndexingNative;
4415 VkBool32 shaderStorageBufferArrayNonUniformIndexingNative;
4416 VkBool32 shaderStorageImageArrayNonUniformIndexingNative;
4417 VkBool32 shaderInputAttachmentArrayNonUniformIndexingNative;
4418 VkBool32 robustBufferAccessUpdateAfterBind;
4419 VkBool32 quadDivergentImplicitLod;
4420 uint32_t maxPerStageDescriptorUpdateAfterBindSamplers;
4421 uint32_t maxPerStageDescriptorUpdateAfterBindUniformBuffers;
4422 uint32_t maxPerStageDescriptorUpdateAfterBindStorageBuffers;
4423 uint32_t maxPerStageDescriptorUpdateAfterBindSampledImages;
4424 uint32_t maxPerStageDescriptorUpdateAfterBindStorageImages;
4425 uint32_t maxPerStageDescriptorUpdateAfterBindInputAttachments;
4426 uint32_t maxPerStageUpdateAfterBindResources;
4427 uint32_t maxDescriptorSetUpdateAfterBindSamplers;
4428 uint32_t maxDescriptorSetUpdateAfterBindUniformBuffers;
4429 uint32_t maxDescriptorSetUpdateAfterBindUniformBuffersDynamic;
4430 uint32_t maxDescriptorSetUpdateAfterBindStorageBuffers;
4431 uint32_t maxDescriptorSetUpdateAfterBindStorageBuffersDynamic;
4432 uint32_t maxDescriptorSetUpdateAfterBindSampledImages;
4433 uint32_t maxDescriptorSetUpdateAfterBindStorageImages;
4434 uint32_t maxDescriptorSetUpdateAfterBindInputAttachments;
4435 VkResolveModeFlags supportedDepthResolveModes;
4436 VkResolveModeFlags supportedStencilResolveModes;
4437 VkBool32 independentResolveNone;
4438 VkBool32 independentResolve;
4439 VkBool32 filterMinmaxSingleComponentFormats;
4440 VkBool32 filterMinmaxImageComponentMapping;
4441 uint64_t maxTimelineSemaphoreValueDifference;
4442 VkSampleCountFlags framebufferIntegerColorSampleCounts;
4443} VkPhysicalDeviceVulkan12Properties;
4444
4445typedef struct VkPhysicalDeviceVulkan13Features {
4446 VkStructureType sType;
4447 void * pNext;
4448 VkBool32 robustImageAccess;
4449 VkBool32 inlineUniformBlock;
4450 VkBool32 descriptorBindingInlineUniformBlockUpdateAfterBind;
4451 VkBool32 pipelineCreationCacheControl;
4452 VkBool32 privateData;
4453 VkBool32 shaderDemoteToHelperInvocation;
4454 VkBool32 shaderTerminateInvocation;
4455 VkBool32 subgroupSizeControl;
4456 VkBool32 computeFullSubgroups;
4457 VkBool32 synchronization2;
4458 VkBool32 textureCompressionASTC_HDR;
4459 VkBool32 shaderZeroInitializeWorkgroupMemory;
4460 VkBool32 dynamicRendering;
4461 VkBool32 shaderIntegerDotProduct;
4462 VkBool32 maintenance4;
4463} VkPhysicalDeviceVulkan13Features;
4464
4465typedef struct VkPhysicalDeviceVulkan13Properties {
4466 VkStructureType sType;
4467 void * pNext;
4468 uint32_t minSubgroupSize;
4469 uint32_t maxSubgroupSize;
4470 uint32_t maxComputeWorkgroupSubgroups;
4471 VkShaderStageFlags requiredSubgroupSizeStages;
4472 uint32_t maxInlineUniformBlockSize;
4473 uint32_t maxPerStageDescriptorInlineUniformBlocks;
4474 uint32_t maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks;
4475 uint32_t maxDescriptorSetInlineUniformBlocks;
4476 uint32_t maxDescriptorSetUpdateAfterBindInlineUniformBlocks;
4477 uint32_t maxInlineUniformTotalSize;
4478 VkBool32 integerDotProduct8BitUnsignedAccelerated;
4479 VkBool32 integerDotProduct8BitSignedAccelerated;
4480 VkBool32 integerDotProduct8BitMixedSignednessAccelerated;
4481 VkBool32 integerDotProduct4x8BitPackedUnsignedAccelerated;
4482 VkBool32 integerDotProduct4x8BitPackedSignedAccelerated;
4483 VkBool32 integerDotProduct4x8BitPackedMixedSignednessAccelerated;
4484 VkBool32 integerDotProduct16BitUnsignedAccelerated;
4485 VkBool32 integerDotProduct16BitSignedAccelerated;
4486 VkBool32 integerDotProduct16BitMixedSignednessAccelerated;
4487 VkBool32 integerDotProduct32BitUnsignedAccelerated;
4488 VkBool32 integerDotProduct32BitSignedAccelerated;
4489 VkBool32 integerDotProduct32BitMixedSignednessAccelerated;
4490 VkBool32 integerDotProduct64BitUnsignedAccelerated;
4491 VkBool32 integerDotProduct64BitSignedAccelerated;
4492 VkBool32 integerDotProduct64BitMixedSignednessAccelerated;
4493 VkBool32 integerDotProductAccumulatingSaturating8BitUnsignedAccelerated;
4494 VkBool32 integerDotProductAccumulatingSaturating8BitSignedAccelerated;
4495 VkBool32 integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated;
4496 VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated;
4497 VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated;
4498 VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated;
4499 VkBool32 integerDotProductAccumulatingSaturating16BitUnsignedAccelerated;
4500 VkBool32 integerDotProductAccumulatingSaturating16BitSignedAccelerated;
4501 VkBool32 integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated;
4502 VkBool32 integerDotProductAccumulatingSaturating32BitUnsignedAccelerated;
4503 VkBool32 integerDotProductAccumulatingSaturating32BitSignedAccelerated;
4504 VkBool32 integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated;
4505 VkBool32 integerDotProductAccumulatingSaturating64BitUnsignedAccelerated;
4506 VkBool32 integerDotProductAccumulatingSaturating64BitSignedAccelerated;
4507 VkBool32 integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated;
4508 VkDeviceSize storageTexelBufferOffsetAlignmentBytes;
4509 VkBool32 storageTexelBufferOffsetSingleTexelAlignment;
4510 VkDeviceSize uniformTexelBufferOffsetAlignmentBytes;
4511 VkBool32 uniformTexelBufferOffsetSingleTexelAlignment;
4512 VkDeviceSize maxBufferSize;
4513} VkPhysicalDeviceVulkan13Properties;
4514
4515typedef struct VkPhysicalDeviceToolProperties {
4516 VkStructureType sType;
4517 void * pNext;
4518 char name [ VK_MAX_EXTENSION_NAME_SIZE ];
4519 char version [ VK_MAX_EXTENSION_NAME_SIZE ];
4520 VkToolPurposeFlags purposes;
4521 char description [ VK_MAX_DESCRIPTION_SIZE ];
4522 char layer [ VK_MAX_EXTENSION_NAME_SIZE ];
4523} VkPhysicalDeviceToolProperties;
4524
4525typedef struct VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures {
4526 VkStructureType sType;
4527 void * pNext;
4528 VkBool32 shaderZeroInitializeWorkgroupMemory;
4529} VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures;
4530
4531typedef struct VkPhysicalDeviceImageRobustnessFeatures {
4532 VkStructureType sType;
4533 void * pNext;
4534 VkBool32 robustImageAccess;
4535} VkPhysicalDeviceImageRobustnessFeatures;
4536
4537typedef struct VkBufferCopy2 {
4538 VkStructureType sType;
4539 const void * pNext;
4540 VkDeviceSize srcOffset;
4541 VkDeviceSize dstOffset;
4542 VkDeviceSize size;
4543} VkBufferCopy2;
4544
4545typedef struct VkImageCopy2 {
4546 VkStructureType sType;
4547 const void * pNext;
4548 VkImageSubresourceLayers srcSubresource;
4549 VkOffset3D srcOffset;
4550 VkImageSubresourceLayers dstSubresource;
4551 VkOffset3D dstOffset;
4552 VkExtent3D extent;
4553} VkImageCopy2;
4554
4555typedef struct VkImageBlit2 {
4556 VkStructureType sType;
4557 const void * pNext;
4558 VkImageSubresourceLayers srcSubresource;
4559 VkOffset3D srcOffsets [2];
4560 VkImageSubresourceLayers dstSubresource;
4561 VkOffset3D dstOffsets [2];
4562} VkImageBlit2;
4563
4564typedef struct VkBufferImageCopy2 {
4565 VkStructureType sType;
4566 const void * pNext;
4567 VkDeviceSize bufferOffset;
4568 uint32_t bufferRowLength;
4569 uint32_t bufferImageHeight;
4570 VkImageSubresourceLayers imageSubresource;
4571 VkOffset3D imageOffset;
4572 VkExtent3D imageExtent;
4573} VkBufferImageCopy2;
4574
4575typedef struct VkImageResolve2 {
4576 VkStructureType sType;
4577 const void * pNext;
4578 VkImageSubresourceLayers srcSubresource;
4579 VkOffset3D srcOffset;
4580 VkImageSubresourceLayers dstSubresource;
4581 VkOffset3D dstOffset;
4582 VkExtent3D extent;
4583} VkImageResolve2;
4584
4585typedef struct VkCopyBufferInfo2 {
4586 VkStructureType sType;
4587 const void * pNext;
4588 VkBuffer srcBuffer;
4589 VkBuffer dstBuffer;
4590 uint32_t regionCount;
4591 const VkBufferCopy2 * pRegions;
4592} VkCopyBufferInfo2;
4593
4594typedef struct VkCopyImageInfo2 {
4595 VkStructureType sType;
4596 const void * pNext;
4597 VkImage srcImage;
4598 VkImageLayout srcImageLayout;
4599 VkImage dstImage;
4600 VkImageLayout dstImageLayout;
4601 uint32_t regionCount;
4602 const VkImageCopy2 * pRegions;
4603} VkCopyImageInfo2;
4604
4605typedef struct VkBlitImageInfo2 {
4606 VkStructureType sType;
4607 const void * pNext;
4608 VkImage srcImage;
4609 VkImageLayout srcImageLayout;
4610 VkImage dstImage;
4611 VkImageLayout dstImageLayout;
4612 uint32_t regionCount;
4613 const VkImageBlit2 * pRegions;
4614 VkFilter filter;
4615} VkBlitImageInfo2;
4616
4617typedef struct VkCopyBufferToImageInfo2 {
4618 VkStructureType sType;
4619 const void * pNext;
4620 VkBuffer srcBuffer;
4621 VkImage dstImage;
4622 VkImageLayout dstImageLayout;
4623 uint32_t regionCount;
4624 const VkBufferImageCopy2 * pRegions;
4625} VkCopyBufferToImageInfo2;
4626
4627typedef struct VkCopyImageToBufferInfo2 {
4628 VkStructureType sType;
4629 const void * pNext;
4630 VkImage srcImage;
4631 VkImageLayout srcImageLayout;
4632 VkBuffer dstBuffer;
4633 uint32_t regionCount;
4634 const VkBufferImageCopy2 * pRegions;
4635} VkCopyImageToBufferInfo2;
4636
4637typedef struct VkResolveImageInfo2 {
4638 VkStructureType sType;
4639 const void * pNext;
4640 VkImage srcImage;
4641 VkImageLayout srcImageLayout;
4642 VkImage dstImage;
4643 VkImageLayout dstImageLayout;
4644 uint32_t regionCount;
4645 const VkImageResolve2 * pRegions;
4646} VkResolveImageInfo2;
4647
4648typedef struct VkPhysicalDeviceShaderTerminateInvocationFeatures {
4649 VkStructureType sType;
4650 void * pNext;
4651 VkBool32 shaderTerminateInvocation;
4652} VkPhysicalDeviceShaderTerminateInvocationFeatures;
4653
4654typedef struct VkMemoryBarrier2 {
4655 VkStructureType sType;
4656 const void * pNext;
4657 VkPipelineStageFlags2 srcStageMask;
4658 VkAccessFlags2 srcAccessMask;
4659 VkPipelineStageFlags2 dstStageMask;
4660 VkAccessFlags2 dstAccessMask;
4661} VkMemoryBarrier2;
4662
4663typedef struct VkImageMemoryBarrier2 {
4664 VkStructureType sType;
4665 const void * pNext;
4666 VkPipelineStageFlags2 srcStageMask;
4667 VkAccessFlags2 srcAccessMask;
4668 VkPipelineStageFlags2 dstStageMask;
4669 VkAccessFlags2 dstAccessMask;
4670 VkImageLayout oldLayout;
4671 VkImageLayout newLayout;
4672 uint32_t srcQueueFamilyIndex;
4673 uint32_t dstQueueFamilyIndex;
4674 VkImage image;
4675 VkImageSubresourceRange subresourceRange;
4676} VkImageMemoryBarrier2;
4677
4678typedef struct VkBufferMemoryBarrier2 {
4679 VkStructureType sType;
4680 const void * pNext;
4681 VkPipelineStageFlags2 srcStageMask;
4682 VkAccessFlags2 srcAccessMask;
4683 VkPipelineStageFlags2 dstStageMask;
4684 VkAccessFlags2 dstAccessMask;
4685 uint32_t srcQueueFamilyIndex;
4686 uint32_t dstQueueFamilyIndex;
4687 VkBuffer buffer;
4688 VkDeviceSize offset;
4689 VkDeviceSize size;
4690} VkBufferMemoryBarrier2;
4691
4692typedef struct VkDependencyInfo {
4693 VkStructureType sType;
4694 const void * pNext;
4695 VkDependencyFlags dependencyFlags;
4696 uint32_t memoryBarrierCount;
4697 const VkMemoryBarrier2 * pMemoryBarriers;
4698 uint32_t bufferMemoryBarrierCount;
4699 const VkBufferMemoryBarrier2 * pBufferMemoryBarriers;
4700 uint32_t imageMemoryBarrierCount;
4701 const VkImageMemoryBarrier2 * pImageMemoryBarriers;
4702} VkDependencyInfo;
4703
4704typedef struct VkSemaphoreSubmitInfo {
4705 VkStructureType sType;
4706 const void * pNext;
4707 VkSemaphore semaphore;
4708 uint64_t value;
4709 VkPipelineStageFlags2 stageMask;
4710 uint32_t deviceIndex;
4711} VkSemaphoreSubmitInfo;
4712
4713typedef struct VkSubmitInfo2 {
4714 VkStructureType sType;
4715 const void * pNext;
4716 VkSubmitFlags flags;
4717 uint32_t waitSemaphoreInfoCount;
4718 const VkSemaphoreSubmitInfo * pWaitSemaphoreInfos;
4719 uint32_t commandBufferInfoCount;
4720 const VkCommandBufferSubmitInfo * pCommandBufferInfos;
4721 uint32_t signalSemaphoreInfoCount;
4722 const VkSemaphoreSubmitInfo * pSignalSemaphoreInfos;
4723} VkSubmitInfo2;
4724
4725typedef struct VkPhysicalDeviceSynchronization2Features {
4726 VkStructureType sType;
4727 void * pNext;
4728 VkBool32 synchronization2;
4729} VkPhysicalDeviceSynchronization2Features;
4730
4731typedef struct VkPhysicalDeviceShaderIntegerDotProductFeatures {
4732 VkStructureType sType;
4733 void * pNext;
4734 VkBool32 shaderIntegerDotProduct;
4735} VkPhysicalDeviceShaderIntegerDotProductFeatures;
4736
4737typedef struct VkPhysicalDeviceShaderIntegerDotProductProperties {
4738 VkStructureType sType;
4739 void * pNext;
4740 VkBool32 integerDotProduct8BitUnsignedAccelerated;
4741 VkBool32 integerDotProduct8BitSignedAccelerated;
4742 VkBool32 integerDotProduct8BitMixedSignednessAccelerated;
4743 VkBool32 integerDotProduct4x8BitPackedUnsignedAccelerated;
4744 VkBool32 integerDotProduct4x8BitPackedSignedAccelerated;
4745 VkBool32 integerDotProduct4x8BitPackedMixedSignednessAccelerated;
4746 VkBool32 integerDotProduct16BitUnsignedAccelerated;
4747 VkBool32 integerDotProduct16BitSignedAccelerated;
4748 VkBool32 integerDotProduct16BitMixedSignednessAccelerated;
4749 VkBool32 integerDotProduct32BitUnsignedAccelerated;
4750 VkBool32 integerDotProduct32BitSignedAccelerated;
4751 VkBool32 integerDotProduct32BitMixedSignednessAccelerated;
4752 VkBool32 integerDotProduct64BitUnsignedAccelerated;
4753 VkBool32 integerDotProduct64BitSignedAccelerated;
4754 VkBool32 integerDotProduct64BitMixedSignednessAccelerated;
4755 VkBool32 integerDotProductAccumulatingSaturating8BitUnsignedAccelerated;
4756 VkBool32 integerDotProductAccumulatingSaturating8BitSignedAccelerated;
4757 VkBool32 integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated;
4758 VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated;
4759 VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated;
4760 VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated;
4761 VkBool32 integerDotProductAccumulatingSaturating16BitUnsignedAccelerated;
4762 VkBool32 integerDotProductAccumulatingSaturating16BitSignedAccelerated;
4763 VkBool32 integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated;
4764 VkBool32 integerDotProductAccumulatingSaturating32BitUnsignedAccelerated;
4765 VkBool32 integerDotProductAccumulatingSaturating32BitSignedAccelerated;
4766 VkBool32 integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated;
4767 VkBool32 integerDotProductAccumulatingSaturating64BitUnsignedAccelerated;
4768 VkBool32 integerDotProductAccumulatingSaturating64BitSignedAccelerated;
4769 VkBool32 integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated;
4770} VkPhysicalDeviceShaderIntegerDotProductProperties;
4771
4772typedef struct VkFormatProperties3 {
4773 VkStructureType sType;
4774 void * pNext;
4775 VkFormatFeatureFlags2 linearTilingFeatures;
4776 VkFormatFeatureFlags2 optimalTilingFeatures;
4777 VkFormatFeatureFlags2 bufferFeatures;
4778} VkFormatProperties3;
4779
4780typedef struct VkRenderingInfo {
4781 VkStructureType sType;
4782 const void * pNext;
4783 VkRenderingFlags flags;
4784 VkRect2D renderArea;
4785 uint32_t layerCount;
4786 uint32_t viewMask;
4787 uint32_t colorAttachmentCount;
4788 const VkRenderingAttachmentInfo * pColorAttachments;
4789 const VkRenderingAttachmentInfo * pDepthAttachment;
4790 const VkRenderingAttachmentInfo * pStencilAttachment;
4791} VkRenderingInfo;
4792
4793typedef struct VkPhysicalDeviceDynamicRenderingFeatures {
4794 VkStructureType sType;
4795 void * pNext;
4796 VkBool32 dynamicRendering;
4797} VkPhysicalDeviceDynamicRenderingFeatures;
4798
4799typedef struct VkCommandBufferInheritanceRenderingInfo {
4800 VkStructureType sType;
4801 const void * pNext;
4802 VkRenderingFlags flags;
4803 uint32_t viewMask;
4804 uint32_t colorAttachmentCount;
4805 const VkFormat * pColorAttachmentFormats;
4806 VkFormat depthAttachmentFormat;
4807 VkFormat stencilAttachmentFormat;
4808 VkSampleCountFlagBits rasterizationSamples;
4809} VkCommandBufferInheritanceRenderingInfo;
4810
4811typedef struct VkPhysicalDeviceProperties {
4812 uint32_t apiVersion;
4813 uint32_t driverVersion;
4814 uint32_t vendorID;
4815 uint32_t deviceID;
4816 VkPhysicalDeviceType deviceType;
4817 char deviceName [ VK_MAX_PHYSICAL_DEVICE_NAME_SIZE ];
4818 uint8_t pipelineCacheUUID [ VK_UUID_SIZE ];
4819 VkPhysicalDeviceLimits limits;
4820 VkPhysicalDeviceSparseProperties sparseProperties;
4821} VkPhysicalDeviceProperties;
4822
4823typedef struct VkDeviceCreateInfo {
4824 VkStructureType sType;
4825 const void * pNext;
4826 VkDeviceCreateFlags flags;
4827 uint32_t queueCreateInfoCount;
4828 const VkDeviceQueueCreateInfo * pQueueCreateInfos;
4829 uint32_t enabledLayerCount;
4830 const char * const* ppEnabledLayerNames;
4831 uint32_t enabledExtensionCount;
4832 const char * const* ppEnabledExtensionNames;
4833 const VkPhysicalDeviceFeatures * pEnabledFeatures;
4834} VkDeviceCreateInfo;
4835
4836typedef struct VkPhysicalDeviceMemoryProperties {
4837 uint32_t memoryTypeCount;
4838 VkMemoryType memoryTypes [ VK_MAX_MEMORY_TYPES ];
4839 uint32_t memoryHeapCount;
4840 VkMemoryHeap memoryHeaps [ VK_MAX_MEMORY_HEAPS ];
4841} VkPhysicalDeviceMemoryProperties;
4842
4843typedef struct VkPhysicalDeviceProperties2 {
4844 VkStructureType sType;
4845 void * pNext;
4846 VkPhysicalDeviceProperties properties;
4847} VkPhysicalDeviceProperties2;
4848
4849typedef struct VkPhysicalDeviceMemoryProperties2 {
4850 VkStructureType sType;
4851 void * pNext;
4852 VkPhysicalDeviceMemoryProperties memoryProperties;
4853} VkPhysicalDeviceMemoryProperties2;
4854
4855typedef struct VkFramebufferAttachmentsCreateInfo {
4856 VkStructureType sType;
4857 const void * pNext;
4858 uint32_t attachmentImageInfoCount;
4859 const VkFramebufferAttachmentImageInfo * pAttachmentImageInfos;
4860} VkFramebufferAttachmentsCreateInfo;
4861
4862
4863
4864#define VK_VERSION_1_0 1
4865GLAD_API_CALL int GLAD_VK_VERSION_1_0;
4866#define VK_VERSION_1_1 1
4867GLAD_API_CALL int GLAD_VK_VERSION_1_1;
4868#define VK_VERSION_1_2 1
4869GLAD_API_CALL int GLAD_VK_VERSION_1_2;
4870#define VK_VERSION_1_3 1
4871GLAD_API_CALL int GLAD_VK_VERSION_1_3;
4872#define VK_EXT_debug_report 1
4873GLAD_API_CALL int GLAD_VK_EXT_debug_report;
4874#define VK_KHR_portability_enumeration 1
4875GLAD_API_CALL int GLAD_VK_KHR_portability_enumeration;
4876#define VK_KHR_surface 1
4877GLAD_API_CALL int GLAD_VK_KHR_surface;
4878#define VK_KHR_swapchain 1
4879GLAD_API_CALL int GLAD_VK_KHR_swapchain;
4880
4881
4882typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImage2KHR)(VkDevice device, const VkAcquireNextImageInfoKHR * pAcquireInfo, uint32_t * pImageIndex);
4883typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t * pImageIndex);
4884typedef VkResult (GLAD_API_PTR *PFN_vkAllocateCommandBuffers)(VkDevice device, const VkCommandBufferAllocateInfo * pAllocateInfo, VkCommandBuffer * pCommandBuffers);
4885typedef VkResult (GLAD_API_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo * pAllocateInfo, VkDescriptorSet * pDescriptorSets);
4886typedef VkResult (GLAD_API_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo * pAllocateInfo, const VkAllocationCallbacks * pAllocator, VkDeviceMemory * pMemory);
4887typedef VkResult (GLAD_API_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo * pBeginInfo);
4888typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset);
4889typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo * pBindInfos);
4890typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset);
4891typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo * pBindInfos);
4892typedef void (GLAD_API_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags);
4893typedef void (GLAD_API_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo * pRenderPassBegin, VkSubpassContents contents);
4894typedef void (GLAD_API_PTR *PFN_vkCmdBeginRenderPass2)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo * pRenderPassBegin, const VkSubpassBeginInfo * pSubpassBeginInfo);
4895typedef void (GLAD_API_PTR *PFN_vkCmdBeginRendering)(VkCommandBuffer commandBuffer, const VkRenderingInfo * pRenderingInfo);
4896typedef void (GLAD_API_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet * pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t * pDynamicOffsets);
4897typedef void (GLAD_API_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType);
4898typedef void (GLAD_API_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline);
4899typedef void (GLAD_API_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer * pBuffers, const VkDeviceSize * pOffsets);
4900typedef void (GLAD_API_PTR *PFN_vkCmdBindVertexBuffers2)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer * pBuffers, const VkDeviceSize * pOffsets, const VkDeviceSize * pSizes, const VkDeviceSize * pStrides);
4901typedef void (GLAD_API_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit * pRegions, VkFilter filter);
4902typedef void (GLAD_API_PTR *PFN_vkCmdBlitImage2)(VkCommandBuffer commandBuffer, const VkBlitImageInfo2 * pBlitImageInfo);
4903typedef void (GLAD_API_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment * pAttachments, uint32_t rectCount, const VkClearRect * pRects);
4904typedef void (GLAD_API_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue * pColor, uint32_t rangeCount, const VkImageSubresourceRange * pRanges);
4905typedef void (GLAD_API_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue * pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange * pRanges);
4906typedef void (GLAD_API_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy * pRegions);
4907typedef void (GLAD_API_PTR *PFN_vkCmdCopyBuffer2)(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2 * pCopyBufferInfo);
4908typedef void (GLAD_API_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy * pRegions);
4909typedef void (GLAD_API_PTR *PFN_vkCmdCopyBufferToImage2)(VkCommandBuffer commandBuffer, const VkCopyBufferToImageInfo2 * pCopyBufferToImageInfo);
4910typedef void (GLAD_API_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy * pRegions);
4911typedef void (GLAD_API_PTR *PFN_vkCmdCopyImage2)(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 * pCopyImageInfo);
4912typedef void (GLAD_API_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy * pRegions);
4913typedef void (GLAD_API_PTR *PFN_vkCmdCopyImageToBuffer2)(VkCommandBuffer commandBuffer, const VkCopyImageToBufferInfo2 * pCopyImageToBufferInfo);
4914typedef void (GLAD_API_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags);
4915typedef void (GLAD_API_PTR *PFN_vkCmdDispatch)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
4916typedef void (GLAD_API_PTR *PFN_vkCmdDispatchBase)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
4917typedef void (GLAD_API_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset);
4918typedef void (GLAD_API_PTR *PFN_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance);
4919typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance);
4920typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride);
4921typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexedIndirectCount)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride);
4922typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride);
4923typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndirectCount)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride);
4924typedef void (GLAD_API_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query);
4925typedef void (GLAD_API_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer commandBuffer);
4926typedef void (GLAD_API_PTR *PFN_vkCmdEndRenderPass2)(VkCommandBuffer commandBuffer, const VkSubpassEndInfo * pSubpassEndInfo);
4927typedef void (GLAD_API_PTR *PFN_vkCmdEndRendering)(VkCommandBuffer commandBuffer);
4928typedef void (GLAD_API_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer * pCommandBuffers);
4929typedef void (GLAD_API_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data);
4930typedef void (GLAD_API_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer commandBuffer, VkSubpassContents contents);
4931typedef void (GLAD_API_PTR *PFN_vkCmdNextSubpass2)(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo * pSubpassBeginInfo, const VkSubpassEndInfo * pSubpassEndInfo);
4932typedef void (GLAD_API_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier * pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier * pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier * pImageMemoryBarriers);
4933typedef void (GLAD_API_PTR *PFN_vkCmdPipelineBarrier2)(VkCommandBuffer commandBuffer, const VkDependencyInfo * pDependencyInfo);
4934typedef void (GLAD_API_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void * pValues);
4935typedef void (GLAD_API_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask);
4936typedef void (GLAD_API_PTR *PFN_vkCmdResetEvent2)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags2 stageMask);
4937typedef void (GLAD_API_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
4938typedef void (GLAD_API_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve * pRegions);
4939typedef void (GLAD_API_PTR *PFN_vkCmdResolveImage2)(VkCommandBuffer commandBuffer, const VkResolveImageInfo2 * pResolveImageInfo);
4940typedef void (GLAD_API_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants [4]);
4941typedef void (GLAD_API_PTR *PFN_vkCmdSetCullMode)(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode);
4942typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor);
4943typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBiasEnable)(VkCommandBuffer commandBuffer, VkBool32 depthBiasEnable);
4944typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds);
4945typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBoundsTestEnable)(VkCommandBuffer commandBuffer, VkBool32 depthBoundsTestEnable);
4946typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthCompareOp)(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp);
4947typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthTestEnable)(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable);
4948typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthWriteEnable)(VkCommandBuffer commandBuffer, VkBool32 depthWriteEnable);
4949typedef void (GLAD_API_PTR *PFN_vkCmdSetDeviceMask)(VkCommandBuffer commandBuffer, uint32_t deviceMask);
4950typedef void (GLAD_API_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask);
4951typedef void (GLAD_API_PTR *PFN_vkCmdSetEvent2)(VkCommandBuffer commandBuffer, VkEvent event, const VkDependencyInfo * pDependencyInfo);
4952typedef void (GLAD_API_PTR *PFN_vkCmdSetFrontFace)(VkCommandBuffer commandBuffer, VkFrontFace frontFace);
4953typedef void (GLAD_API_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth);
4954typedef void (GLAD_API_PTR *PFN_vkCmdSetPrimitiveRestartEnable)(VkCommandBuffer commandBuffer, VkBool32 primitiveRestartEnable);
4955typedef void (GLAD_API_PTR *PFN_vkCmdSetPrimitiveTopology)(VkCommandBuffer commandBuffer, VkPrimitiveTopology primitiveTopology);
4956typedef void (GLAD_API_PTR *PFN_vkCmdSetRasterizerDiscardEnable)(VkCommandBuffer commandBuffer, VkBool32 rasterizerDiscardEnable);
4957typedef void (GLAD_API_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D * pScissors);
4958typedef void (GLAD_API_PTR *PFN_vkCmdSetScissorWithCount)(VkCommandBuffer commandBuffer, uint32_t scissorCount, const VkRect2D * pScissors);
4959typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask);
4960typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilOp)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp);
4961typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference);
4962typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilTestEnable)(VkCommandBuffer commandBuffer, VkBool32 stencilTestEnable);
4963typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask);
4964typedef void (GLAD_API_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport * pViewports);
4965typedef void (GLAD_API_PTR *PFN_vkCmdSetViewportWithCount)(VkCommandBuffer commandBuffer, uint32_t viewportCount, const VkViewport * pViewports);
4966typedef void (GLAD_API_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void * pData);
4967typedef void (GLAD_API_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent * pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier * pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier * pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier * pImageMemoryBarriers);
4968typedef void (GLAD_API_PTR *PFN_vkCmdWaitEvents2)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent * pEvents, const VkDependencyInfo * pDependencyInfos);
4969typedef void (GLAD_API_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query);
4970typedef void (GLAD_API_PTR *PFN_vkCmdWriteTimestamp2)(VkCommandBuffer commandBuffer, VkPipelineStageFlags2 stage, VkQueryPool queryPool, uint32_t query);
4971typedef VkResult (GLAD_API_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkBuffer * pBuffer);
4972typedef VkResult (GLAD_API_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkBufferView * pView);
4973typedef VkResult (GLAD_API_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkCommandPool * pCommandPool);
4974typedef VkResult (GLAD_API_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo * pCreateInfos, const VkAllocationCallbacks * pAllocator, VkPipeline * pPipelines);
4975typedef VkResult (GLAD_API_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDebugReportCallbackEXT * pCallback);
4976typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorPool * pDescriptorPool);
4977typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorSetLayout * pSetLayout);
4978typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorUpdateTemplate)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorUpdateTemplate * pDescriptorUpdateTemplate);
4979typedef VkResult (GLAD_API_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDevice * pDevice);
4980typedef VkResult (GLAD_API_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkEvent * pEvent);
4981typedef VkResult (GLAD_API_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkFence * pFence);
4982typedef VkResult (GLAD_API_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkFramebuffer * pFramebuffer);
4983typedef VkResult (GLAD_API_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo * pCreateInfos, const VkAllocationCallbacks * pAllocator, VkPipeline * pPipelines);
4984typedef VkResult (GLAD_API_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkImage * pImage);
4985typedef VkResult (GLAD_API_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkImageView * pView);
4986typedef VkResult (GLAD_API_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkInstance * pInstance);
4987typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkPipelineCache * pPipelineCache);
4988typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkPipelineLayout * pPipelineLayout);
4989typedef VkResult (GLAD_API_PTR *PFN_vkCreatePrivateDataSlot)(VkDevice device, const VkPrivateDataSlotCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkPrivateDataSlot * pPrivateDataSlot);
4990typedef VkResult (GLAD_API_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkQueryPool * pQueryPool);
4991typedef VkResult (GLAD_API_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkRenderPass * pRenderPass);
4992typedef VkResult (GLAD_API_PTR *PFN_vkCreateRenderPass2)(VkDevice device, const VkRenderPassCreateInfo2 * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkRenderPass * pRenderPass);
4993typedef VkResult (GLAD_API_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSampler * pSampler);
4994typedef VkResult (GLAD_API_PTR *PFN_vkCreateSamplerYcbcrConversion)(VkDevice device, const VkSamplerYcbcrConversionCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSamplerYcbcrConversion * pYcbcrConversion);
4995typedef VkResult (GLAD_API_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSemaphore * pSemaphore);
4996typedef VkResult (GLAD_API_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkShaderModule * pShaderModule);
4997typedef VkResult (GLAD_API_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSwapchainKHR * pSwapchain);
4998typedef void (GLAD_API_PTR *PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char * pLayerPrefix, const char * pMessage);
4999typedef void (GLAD_API_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks * pAllocator);
5000typedef void (GLAD_API_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks * pAllocator);
5001typedef void (GLAD_API_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks * pAllocator);
5002typedef void (GLAD_API_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks * pAllocator);
5003typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks * pAllocator);
5004typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks * pAllocator);
5005typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorUpdateTemplate)(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks * pAllocator);
5006typedef void (GLAD_API_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks * pAllocator);
5007typedef void (GLAD_API_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks * pAllocator);
5008typedef void (GLAD_API_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks * pAllocator);
5009typedef void (GLAD_API_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks * pAllocator);
5010typedef void (GLAD_API_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks * pAllocator);
5011typedef void (GLAD_API_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks * pAllocator);
5012typedef void (GLAD_API_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks * pAllocator);
5013typedef void (GLAD_API_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks * pAllocator);
5014typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks * pAllocator);
5015typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks * pAllocator);
5016typedef void (GLAD_API_PTR *PFN_vkDestroyPrivateDataSlot)(VkDevice device, VkPrivateDataSlot privateDataSlot, const VkAllocationCallbacks * pAllocator);
5017typedef void (GLAD_API_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks * pAllocator);
5018typedef void (GLAD_API_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks * pAllocator);
5019typedef void (GLAD_API_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks * pAllocator);
5020typedef void (GLAD_API_PTR *PFN_vkDestroySamplerYcbcrConversion)(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks * pAllocator);
5021typedef void (GLAD_API_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks * pAllocator);
5022typedef void (GLAD_API_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks * pAllocator);
5023typedef void (GLAD_API_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks * pAllocator);
5024typedef void (GLAD_API_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks * pAllocator);
5025typedef VkResult (GLAD_API_PTR *PFN_vkDeviceWaitIdle)(VkDevice device);
5026typedef VkResult (GLAD_API_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer commandBuffer);
5027typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char * pLayerName, uint32_t * pPropertyCount, VkExtensionProperties * pProperties);
5028typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t * pPropertyCount, VkLayerProperties * pProperties);
5029typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char * pLayerName, uint32_t * pPropertyCount, VkExtensionProperties * pProperties);
5030typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t * pPropertyCount, VkLayerProperties * pProperties);
5031typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t * pApiVersion);
5032typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance instance, uint32_t * pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties * pPhysicalDeviceGroupProperties);
5033typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t * pPhysicalDeviceCount, VkPhysicalDevice * pPhysicalDevices);
5034typedef VkResult (GLAD_API_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange * pMemoryRanges);
5035typedef void (GLAD_API_PTR *PFN_vkFreeCommandBuffers)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer * pCommandBuffers);
5036typedef VkResult (GLAD_API_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet * pDescriptorSets);
5037typedef void (GLAD_API_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks * pAllocator);
5038typedef VkDeviceAddress (GLAD_API_PTR *PFN_vkGetBufferDeviceAddress)(VkDevice device, const VkBufferDeviceAddressInfo * pInfo);
5039typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements * pMemoryRequirements);
5040typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements2)(VkDevice device, const VkBufferMemoryRequirementsInfo2 * pInfo, VkMemoryRequirements2 * pMemoryRequirements);
5041typedef uint64_t (GLAD_API_PTR *PFN_vkGetBufferOpaqueCaptureAddress)(VkDevice device, const VkBufferDeviceAddressInfo * pInfo);
5042typedef void (GLAD_API_PTR *PFN_vkGetDescriptorSetLayoutSupport)(VkDevice device, const VkDescriptorSetLayoutCreateInfo * pCreateInfo, VkDescriptorSetLayoutSupport * pSupport);
5043typedef void (GLAD_API_PTR *PFN_vkGetDeviceBufferMemoryRequirements)(VkDevice device, const VkDeviceBufferMemoryRequirements * pInfo, VkMemoryRequirements2 * pMemoryRequirements);
5044typedef void (GLAD_API_PTR *PFN_vkGetDeviceGroupPeerMemoryFeatures)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags * pPeerMemoryFeatures);
5045typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHR)(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR * pDeviceGroupPresentCapabilities);
5046typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR * pModes);
5047typedef void (GLAD_API_PTR *PFN_vkGetDeviceImageMemoryRequirements)(VkDevice device, const VkDeviceImageMemoryRequirements * pInfo, VkMemoryRequirements2 * pMemoryRequirements);
5048typedef void (GLAD_API_PTR *PFN_vkGetDeviceImageSparseMemoryRequirements)(VkDevice device, const VkDeviceImageMemoryRequirements * pInfo, uint32_t * pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 * pSparseMemoryRequirements);
5049typedef void (GLAD_API_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize * pCommittedMemoryInBytes);
5050typedef uint64_t (GLAD_API_PTR *PFN_vkGetDeviceMemoryOpaqueCaptureAddress)(VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfo * pInfo);
5051typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char * pName);
5052typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue * pQueue);
5053typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue2)(VkDevice device, const VkDeviceQueueInfo2 * pQueueInfo, VkQueue * pQueue);
5054typedef VkResult (GLAD_API_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event);
5055typedef VkResult (GLAD_API_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence);
5056typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements * pMemoryRequirements);
5057typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements2)(VkDevice device, const VkImageMemoryRequirementsInfo2 * pInfo, VkMemoryRequirements2 * pMemoryRequirements);
5058typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t * pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements * pSparseMemoryRequirements);
5059typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements2)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2 * pInfo, uint32_t * pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 * pSparseMemoryRequirements);
5060typedef void (GLAD_API_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource * pSubresource, VkSubresourceLayout * pLayout);
5061typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char * pName);
5062typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalBufferProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo * pExternalBufferInfo, VkExternalBufferProperties * pExternalBufferProperties);
5063typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalFenceProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo * pExternalFenceInfo, VkExternalFenceProperties * pExternalFenceProperties);
5064typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo * pExternalSemaphoreInfo, VkExternalSemaphoreProperties * pExternalSemaphoreProperties);
5065typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures * pFeatures);
5066typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 * pFeatures);
5067typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties * pFormatProperties);
5068typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties2)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2 * pFormatProperties);
5069typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties * pImageFormatProperties);
5070typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 * pImageFormatInfo, VkImageFormatProperties2 * pImageFormatProperties);
5071typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties * pMemoryProperties);
5072typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2 * pMemoryProperties);
5073typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pRectCount, VkRect2D * pRects);
5074typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties * pProperties);
5075typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 * pProperties);
5076typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t * pQueueFamilyPropertyCount, VkQueueFamilyProperties * pQueueFamilyProperties);
5077typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2)(VkPhysicalDevice physicalDevice, uint32_t * pQueueFamilyPropertyCount, VkQueueFamilyProperties2 * pQueueFamilyProperties);
5078typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t * pPropertyCount, VkSparseImageFormatProperties * pProperties);
5079typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2 * pFormatInfo, uint32_t * pPropertyCount, VkSparseImageFormatProperties2 * pProperties);
5080typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR * pSurfaceCapabilities);
5081typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pSurfaceFormatCount, VkSurfaceFormatKHR * pSurfaceFormats);
5082typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pPresentModeCount, VkPresentModeKHR * pPresentModes);
5083typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 * pSupported);
5084typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceToolProperties)(VkPhysicalDevice physicalDevice, uint32_t * pToolCount, VkPhysicalDeviceToolProperties * pToolProperties);
5085typedef VkResult (GLAD_API_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t * pDataSize, void * pData);
5086typedef void (GLAD_API_PTR *PFN_vkGetPrivateData)(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t * pData);
5087typedef VkResult (GLAD_API_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void * pData, VkDeviceSize stride, VkQueryResultFlags flags);
5088typedef void (GLAD_API_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D * pGranularity);
5089typedef VkResult (GLAD_API_PTR *PFN_vkGetSemaphoreCounterValue)(VkDevice device, VkSemaphore semaphore, uint64_t * pValue);
5090typedef VkResult (GLAD_API_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t * pSwapchainImageCount, VkImage * pSwapchainImages);
5091typedef VkResult (GLAD_API_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange * pMemoryRanges);
5092typedef VkResult (GLAD_API_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void ** ppData);
5093typedef VkResult (GLAD_API_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache * pSrcCaches);
5094typedef VkResult (GLAD_API_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo * pBindInfo, VkFence fence);
5095typedef VkResult (GLAD_API_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR * pPresentInfo);
5096typedef VkResult (GLAD_API_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo * pSubmits, VkFence fence);
5097typedef VkResult (GLAD_API_PTR *PFN_vkQueueSubmit2)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2 * pSubmits, VkFence fence);
5098typedef VkResult (GLAD_API_PTR *PFN_vkQueueWaitIdle)(VkQueue queue);
5099typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags);
5100typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags);
5101typedef VkResult (GLAD_API_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags);
5102typedef VkResult (GLAD_API_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event);
5103typedef VkResult (GLAD_API_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence * pFences);
5104typedef void (GLAD_API_PTR *PFN_vkResetQueryPool)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
5105typedef VkResult (GLAD_API_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event);
5106typedef VkResult (GLAD_API_PTR *PFN_vkSetPrivateData)(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t data);
5107typedef VkResult (GLAD_API_PTR *PFN_vkSignalSemaphore)(VkDevice device, const VkSemaphoreSignalInfo * pSignalInfo);
5108typedef void (GLAD_API_PTR *PFN_vkTrimCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags);
5109typedef void (GLAD_API_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory);
5110typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSetWithTemplate)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void * pData);
5111typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet * pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet * pDescriptorCopies);
5112typedef VkResult (GLAD_API_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence * pFences, VkBool32 waitAll, uint64_t timeout);
5113typedef VkResult (GLAD_API_PTR *PFN_vkWaitSemaphores)(VkDevice device, const VkSemaphoreWaitInfo * pWaitInfo, uint64_t timeout);
5114
5115GLAD_API_CALL PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR;
5116#define vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR
5117GLAD_API_CALL PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR;
5118#define vkAcquireNextImageKHR glad_vkAcquireNextImageKHR
5119GLAD_API_CALL PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers;
5120#define vkAllocateCommandBuffers glad_vkAllocateCommandBuffers
5121GLAD_API_CALL PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets;
5122#define vkAllocateDescriptorSets glad_vkAllocateDescriptorSets
5123GLAD_API_CALL PFN_vkAllocateMemory glad_vkAllocateMemory;
5124#define vkAllocateMemory glad_vkAllocateMemory
5125GLAD_API_CALL PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer;
5126#define vkBeginCommandBuffer glad_vkBeginCommandBuffer
5127GLAD_API_CALL PFN_vkBindBufferMemory glad_vkBindBufferMemory;
5128#define vkBindBufferMemory glad_vkBindBufferMemory
5129GLAD_API_CALL PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2;
5130#define vkBindBufferMemory2 glad_vkBindBufferMemory2
5131GLAD_API_CALL PFN_vkBindImageMemory glad_vkBindImageMemory;
5132#define vkBindImageMemory glad_vkBindImageMemory
5133GLAD_API_CALL PFN_vkBindImageMemory2 glad_vkBindImageMemory2;
5134#define vkBindImageMemory2 glad_vkBindImageMemory2
5135GLAD_API_CALL PFN_vkCmdBeginQuery glad_vkCmdBeginQuery;
5136#define vkCmdBeginQuery glad_vkCmdBeginQuery
5137GLAD_API_CALL PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass;
5138#define vkCmdBeginRenderPass glad_vkCmdBeginRenderPass
5139GLAD_API_CALL PFN_vkCmdBeginRenderPass2 glad_vkCmdBeginRenderPass2;
5140#define vkCmdBeginRenderPass2 glad_vkCmdBeginRenderPass2
5141GLAD_API_CALL PFN_vkCmdBeginRendering glad_vkCmdBeginRendering;
5142#define vkCmdBeginRendering glad_vkCmdBeginRendering
5143GLAD_API_CALL PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets;
5144#define vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets
5145GLAD_API_CALL PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer;
5146#define vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer
5147GLAD_API_CALL PFN_vkCmdBindPipeline glad_vkCmdBindPipeline;
5148#define vkCmdBindPipeline glad_vkCmdBindPipeline
5149GLAD_API_CALL PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers;
5150#define vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers
5151GLAD_API_CALL PFN_vkCmdBindVertexBuffers2 glad_vkCmdBindVertexBuffers2;
5152#define vkCmdBindVertexBuffers2 glad_vkCmdBindVertexBuffers2
5153GLAD_API_CALL PFN_vkCmdBlitImage glad_vkCmdBlitImage;
5154#define vkCmdBlitImage glad_vkCmdBlitImage
5155GLAD_API_CALL PFN_vkCmdBlitImage2 glad_vkCmdBlitImage2;
5156#define vkCmdBlitImage2 glad_vkCmdBlitImage2
5157GLAD_API_CALL PFN_vkCmdClearAttachments glad_vkCmdClearAttachments;
5158#define vkCmdClearAttachments glad_vkCmdClearAttachments
5159GLAD_API_CALL PFN_vkCmdClearColorImage glad_vkCmdClearColorImage;
5160#define vkCmdClearColorImage glad_vkCmdClearColorImage
5161GLAD_API_CALL PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage;
5162#define vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage
5163GLAD_API_CALL PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer;
5164#define vkCmdCopyBuffer glad_vkCmdCopyBuffer
5165GLAD_API_CALL PFN_vkCmdCopyBuffer2 glad_vkCmdCopyBuffer2;
5166#define vkCmdCopyBuffer2 glad_vkCmdCopyBuffer2
5167GLAD_API_CALL PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage;
5168#define vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage
5169GLAD_API_CALL PFN_vkCmdCopyBufferToImage2 glad_vkCmdCopyBufferToImage2;
5170#define vkCmdCopyBufferToImage2 glad_vkCmdCopyBufferToImage2
5171GLAD_API_CALL PFN_vkCmdCopyImage glad_vkCmdCopyImage;
5172#define vkCmdCopyImage glad_vkCmdCopyImage
5173GLAD_API_CALL PFN_vkCmdCopyImage2 glad_vkCmdCopyImage2;
5174#define vkCmdCopyImage2 glad_vkCmdCopyImage2
5175GLAD_API_CALL PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer;
5176#define vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer
5177GLAD_API_CALL PFN_vkCmdCopyImageToBuffer2 glad_vkCmdCopyImageToBuffer2;
5178#define vkCmdCopyImageToBuffer2 glad_vkCmdCopyImageToBuffer2
5179GLAD_API_CALL PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults;
5180#define vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults
5181GLAD_API_CALL PFN_vkCmdDispatch glad_vkCmdDispatch;
5182#define vkCmdDispatch glad_vkCmdDispatch
5183GLAD_API_CALL PFN_vkCmdDispatchBase glad_vkCmdDispatchBase;
5184#define vkCmdDispatchBase glad_vkCmdDispatchBase
5185GLAD_API_CALL PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect;
5186#define vkCmdDispatchIndirect glad_vkCmdDispatchIndirect
5187GLAD_API_CALL PFN_vkCmdDraw glad_vkCmdDraw;
5188#define vkCmdDraw glad_vkCmdDraw
5189GLAD_API_CALL PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed;
5190#define vkCmdDrawIndexed glad_vkCmdDrawIndexed
5191GLAD_API_CALL PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect;
5192#define vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect
5193GLAD_API_CALL PFN_vkCmdDrawIndexedIndirectCount glad_vkCmdDrawIndexedIndirectCount;
5194#define vkCmdDrawIndexedIndirectCount glad_vkCmdDrawIndexedIndirectCount
5195GLAD_API_CALL PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect;
5196#define vkCmdDrawIndirect glad_vkCmdDrawIndirect
5197GLAD_API_CALL PFN_vkCmdDrawIndirectCount glad_vkCmdDrawIndirectCount;
5198#define vkCmdDrawIndirectCount glad_vkCmdDrawIndirectCount
5199GLAD_API_CALL PFN_vkCmdEndQuery glad_vkCmdEndQuery;
5200#define vkCmdEndQuery glad_vkCmdEndQuery
5201GLAD_API_CALL PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass;
5202#define vkCmdEndRenderPass glad_vkCmdEndRenderPass
5203GLAD_API_CALL PFN_vkCmdEndRenderPass2 glad_vkCmdEndRenderPass2;
5204#define vkCmdEndRenderPass2 glad_vkCmdEndRenderPass2
5205GLAD_API_CALL PFN_vkCmdEndRendering glad_vkCmdEndRendering;
5206#define vkCmdEndRendering glad_vkCmdEndRendering
5207GLAD_API_CALL PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands;
5208#define vkCmdExecuteCommands glad_vkCmdExecuteCommands
5209GLAD_API_CALL PFN_vkCmdFillBuffer glad_vkCmdFillBuffer;
5210#define vkCmdFillBuffer glad_vkCmdFillBuffer
5211GLAD_API_CALL PFN_vkCmdNextSubpass glad_vkCmdNextSubpass;
5212#define vkCmdNextSubpass glad_vkCmdNextSubpass
5213GLAD_API_CALL PFN_vkCmdNextSubpass2 glad_vkCmdNextSubpass2;
5214#define vkCmdNextSubpass2 glad_vkCmdNextSubpass2
5215GLAD_API_CALL PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier;
5216#define vkCmdPipelineBarrier glad_vkCmdPipelineBarrier
5217GLAD_API_CALL PFN_vkCmdPipelineBarrier2 glad_vkCmdPipelineBarrier2;
5218#define vkCmdPipelineBarrier2 glad_vkCmdPipelineBarrier2
5219GLAD_API_CALL PFN_vkCmdPushConstants glad_vkCmdPushConstants;
5220#define vkCmdPushConstants glad_vkCmdPushConstants
5221GLAD_API_CALL PFN_vkCmdResetEvent glad_vkCmdResetEvent;
5222#define vkCmdResetEvent glad_vkCmdResetEvent
5223GLAD_API_CALL PFN_vkCmdResetEvent2 glad_vkCmdResetEvent2;
5224#define vkCmdResetEvent2 glad_vkCmdResetEvent2
5225GLAD_API_CALL PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool;
5226#define vkCmdResetQueryPool glad_vkCmdResetQueryPool
5227GLAD_API_CALL PFN_vkCmdResolveImage glad_vkCmdResolveImage;
5228#define vkCmdResolveImage glad_vkCmdResolveImage
5229GLAD_API_CALL PFN_vkCmdResolveImage2 glad_vkCmdResolveImage2;
5230#define vkCmdResolveImage2 glad_vkCmdResolveImage2
5231GLAD_API_CALL PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants;
5232#define vkCmdSetBlendConstants glad_vkCmdSetBlendConstants
5233GLAD_API_CALL PFN_vkCmdSetCullMode glad_vkCmdSetCullMode;
5234#define vkCmdSetCullMode glad_vkCmdSetCullMode
5235GLAD_API_CALL PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias;
5236#define vkCmdSetDepthBias glad_vkCmdSetDepthBias
5237GLAD_API_CALL PFN_vkCmdSetDepthBiasEnable glad_vkCmdSetDepthBiasEnable;
5238#define vkCmdSetDepthBiasEnable glad_vkCmdSetDepthBiasEnable
5239GLAD_API_CALL PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds;
5240#define vkCmdSetDepthBounds glad_vkCmdSetDepthBounds
5241GLAD_API_CALL PFN_vkCmdSetDepthBoundsTestEnable glad_vkCmdSetDepthBoundsTestEnable;
5242#define vkCmdSetDepthBoundsTestEnable glad_vkCmdSetDepthBoundsTestEnable
5243GLAD_API_CALL PFN_vkCmdSetDepthCompareOp glad_vkCmdSetDepthCompareOp;
5244#define vkCmdSetDepthCompareOp glad_vkCmdSetDepthCompareOp
5245GLAD_API_CALL PFN_vkCmdSetDepthTestEnable glad_vkCmdSetDepthTestEnable;
5246#define vkCmdSetDepthTestEnable glad_vkCmdSetDepthTestEnable
5247GLAD_API_CALL PFN_vkCmdSetDepthWriteEnable glad_vkCmdSetDepthWriteEnable;
5248#define vkCmdSetDepthWriteEnable glad_vkCmdSetDepthWriteEnable
5249GLAD_API_CALL PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask;
5250#define vkCmdSetDeviceMask glad_vkCmdSetDeviceMask
5251GLAD_API_CALL PFN_vkCmdSetEvent glad_vkCmdSetEvent;
5252#define vkCmdSetEvent glad_vkCmdSetEvent
5253GLAD_API_CALL PFN_vkCmdSetEvent2 glad_vkCmdSetEvent2;
5254#define vkCmdSetEvent2 glad_vkCmdSetEvent2
5255GLAD_API_CALL PFN_vkCmdSetFrontFace glad_vkCmdSetFrontFace;
5256#define vkCmdSetFrontFace glad_vkCmdSetFrontFace
5257GLAD_API_CALL PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth;
5258#define vkCmdSetLineWidth glad_vkCmdSetLineWidth
5259GLAD_API_CALL PFN_vkCmdSetPrimitiveRestartEnable glad_vkCmdSetPrimitiveRestartEnable;
5260#define vkCmdSetPrimitiveRestartEnable glad_vkCmdSetPrimitiveRestartEnable
5261GLAD_API_CALL PFN_vkCmdSetPrimitiveTopology glad_vkCmdSetPrimitiveTopology;
5262#define vkCmdSetPrimitiveTopology glad_vkCmdSetPrimitiveTopology
5263GLAD_API_CALL PFN_vkCmdSetRasterizerDiscardEnable glad_vkCmdSetRasterizerDiscardEnable;
5264#define vkCmdSetRasterizerDiscardEnable glad_vkCmdSetRasterizerDiscardEnable
5265GLAD_API_CALL PFN_vkCmdSetScissor glad_vkCmdSetScissor;
5266#define vkCmdSetScissor glad_vkCmdSetScissor
5267GLAD_API_CALL PFN_vkCmdSetScissorWithCount glad_vkCmdSetScissorWithCount;
5268#define vkCmdSetScissorWithCount glad_vkCmdSetScissorWithCount
5269GLAD_API_CALL PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask;
5270#define vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask
5271GLAD_API_CALL PFN_vkCmdSetStencilOp glad_vkCmdSetStencilOp;
5272#define vkCmdSetStencilOp glad_vkCmdSetStencilOp
5273GLAD_API_CALL PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference;
5274#define vkCmdSetStencilReference glad_vkCmdSetStencilReference
5275GLAD_API_CALL PFN_vkCmdSetStencilTestEnable glad_vkCmdSetStencilTestEnable;
5276#define vkCmdSetStencilTestEnable glad_vkCmdSetStencilTestEnable
5277GLAD_API_CALL PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask;
5278#define vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask
5279GLAD_API_CALL PFN_vkCmdSetViewport glad_vkCmdSetViewport;
5280#define vkCmdSetViewport glad_vkCmdSetViewport
5281GLAD_API_CALL PFN_vkCmdSetViewportWithCount glad_vkCmdSetViewportWithCount;
5282#define vkCmdSetViewportWithCount glad_vkCmdSetViewportWithCount
5283GLAD_API_CALL PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer;
5284#define vkCmdUpdateBuffer glad_vkCmdUpdateBuffer
5285GLAD_API_CALL PFN_vkCmdWaitEvents glad_vkCmdWaitEvents;
5286#define vkCmdWaitEvents glad_vkCmdWaitEvents
5287GLAD_API_CALL PFN_vkCmdWaitEvents2 glad_vkCmdWaitEvents2;
5288#define vkCmdWaitEvents2 glad_vkCmdWaitEvents2
5289GLAD_API_CALL PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp;
5290#define vkCmdWriteTimestamp glad_vkCmdWriteTimestamp
5291GLAD_API_CALL PFN_vkCmdWriteTimestamp2 glad_vkCmdWriteTimestamp2;
5292#define vkCmdWriteTimestamp2 glad_vkCmdWriteTimestamp2
5293GLAD_API_CALL PFN_vkCreateBuffer glad_vkCreateBuffer;
5294#define vkCreateBuffer glad_vkCreateBuffer
5295GLAD_API_CALL PFN_vkCreateBufferView glad_vkCreateBufferView;
5296#define vkCreateBufferView glad_vkCreateBufferView
5297GLAD_API_CALL PFN_vkCreateCommandPool glad_vkCreateCommandPool;
5298#define vkCreateCommandPool glad_vkCreateCommandPool
5299GLAD_API_CALL PFN_vkCreateComputePipelines glad_vkCreateComputePipelines;
5300#define vkCreateComputePipelines glad_vkCreateComputePipelines
5301GLAD_API_CALL PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT;
5302#define vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT
5303GLAD_API_CALL PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool;
5304#define vkCreateDescriptorPool glad_vkCreateDescriptorPool
5305GLAD_API_CALL PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout;
5306#define vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout
5307GLAD_API_CALL PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate;
5308#define vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate
5309GLAD_API_CALL PFN_vkCreateDevice glad_vkCreateDevice;
5310#define vkCreateDevice glad_vkCreateDevice
5311GLAD_API_CALL PFN_vkCreateEvent glad_vkCreateEvent;
5312#define vkCreateEvent glad_vkCreateEvent
5313GLAD_API_CALL PFN_vkCreateFence glad_vkCreateFence;
5314#define vkCreateFence glad_vkCreateFence
5315GLAD_API_CALL PFN_vkCreateFramebuffer glad_vkCreateFramebuffer;
5316#define vkCreateFramebuffer glad_vkCreateFramebuffer
5317GLAD_API_CALL PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines;
5318#define vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines
5319GLAD_API_CALL PFN_vkCreateImage glad_vkCreateImage;
5320#define vkCreateImage glad_vkCreateImage
5321GLAD_API_CALL PFN_vkCreateImageView glad_vkCreateImageView;
5322#define vkCreateImageView glad_vkCreateImageView
5323GLAD_API_CALL PFN_vkCreateInstance glad_vkCreateInstance;
5324#define vkCreateInstance glad_vkCreateInstance
5325GLAD_API_CALL PFN_vkCreatePipelineCache glad_vkCreatePipelineCache;
5326#define vkCreatePipelineCache glad_vkCreatePipelineCache
5327GLAD_API_CALL PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout;
5328#define vkCreatePipelineLayout glad_vkCreatePipelineLayout
5329GLAD_API_CALL PFN_vkCreatePrivateDataSlot glad_vkCreatePrivateDataSlot;
5330#define vkCreatePrivateDataSlot glad_vkCreatePrivateDataSlot
5331GLAD_API_CALL PFN_vkCreateQueryPool glad_vkCreateQueryPool;
5332#define vkCreateQueryPool glad_vkCreateQueryPool
5333GLAD_API_CALL PFN_vkCreateRenderPass glad_vkCreateRenderPass;
5334#define vkCreateRenderPass glad_vkCreateRenderPass
5335GLAD_API_CALL PFN_vkCreateRenderPass2 glad_vkCreateRenderPass2;
5336#define vkCreateRenderPass2 glad_vkCreateRenderPass2
5337GLAD_API_CALL PFN_vkCreateSampler glad_vkCreateSampler;
5338#define vkCreateSampler glad_vkCreateSampler
5339GLAD_API_CALL PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion;
5340#define vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion
5341GLAD_API_CALL PFN_vkCreateSemaphore glad_vkCreateSemaphore;
5342#define vkCreateSemaphore glad_vkCreateSemaphore
5343GLAD_API_CALL PFN_vkCreateShaderModule glad_vkCreateShaderModule;
5344#define vkCreateShaderModule glad_vkCreateShaderModule
5345GLAD_API_CALL PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR;
5346#define vkCreateSwapchainKHR glad_vkCreateSwapchainKHR
5347GLAD_API_CALL PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT;
5348#define vkDebugReportMessageEXT glad_vkDebugReportMessageEXT
5349GLAD_API_CALL PFN_vkDestroyBuffer glad_vkDestroyBuffer;
5350#define vkDestroyBuffer glad_vkDestroyBuffer
5351GLAD_API_CALL PFN_vkDestroyBufferView glad_vkDestroyBufferView;
5352#define vkDestroyBufferView glad_vkDestroyBufferView
5353GLAD_API_CALL PFN_vkDestroyCommandPool glad_vkDestroyCommandPool;
5354#define vkDestroyCommandPool glad_vkDestroyCommandPool
5355GLAD_API_CALL PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT;
5356#define vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT
5357GLAD_API_CALL PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool;
5358#define vkDestroyDescriptorPool glad_vkDestroyDescriptorPool
5359GLAD_API_CALL PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout;
5360#define vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout
5361GLAD_API_CALL PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate;
5362#define vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate
5363GLAD_API_CALL PFN_vkDestroyDevice glad_vkDestroyDevice;
5364#define vkDestroyDevice glad_vkDestroyDevice
5365GLAD_API_CALL PFN_vkDestroyEvent glad_vkDestroyEvent;
5366#define vkDestroyEvent glad_vkDestroyEvent
5367GLAD_API_CALL PFN_vkDestroyFence glad_vkDestroyFence;
5368#define vkDestroyFence glad_vkDestroyFence
5369GLAD_API_CALL PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer;
5370#define vkDestroyFramebuffer glad_vkDestroyFramebuffer
5371GLAD_API_CALL PFN_vkDestroyImage glad_vkDestroyImage;
5372#define vkDestroyImage glad_vkDestroyImage
5373GLAD_API_CALL PFN_vkDestroyImageView glad_vkDestroyImageView;
5374#define vkDestroyImageView glad_vkDestroyImageView
5375GLAD_API_CALL PFN_vkDestroyInstance glad_vkDestroyInstance;
5376#define vkDestroyInstance glad_vkDestroyInstance
5377GLAD_API_CALL PFN_vkDestroyPipeline glad_vkDestroyPipeline;
5378#define vkDestroyPipeline glad_vkDestroyPipeline
5379GLAD_API_CALL PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache;
5380#define vkDestroyPipelineCache glad_vkDestroyPipelineCache
5381GLAD_API_CALL PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout;
5382#define vkDestroyPipelineLayout glad_vkDestroyPipelineLayout
5383GLAD_API_CALL PFN_vkDestroyPrivateDataSlot glad_vkDestroyPrivateDataSlot;
5384#define vkDestroyPrivateDataSlot glad_vkDestroyPrivateDataSlot
5385GLAD_API_CALL PFN_vkDestroyQueryPool glad_vkDestroyQueryPool;
5386#define vkDestroyQueryPool glad_vkDestroyQueryPool
5387GLAD_API_CALL PFN_vkDestroyRenderPass glad_vkDestroyRenderPass;
5388#define vkDestroyRenderPass glad_vkDestroyRenderPass
5389GLAD_API_CALL PFN_vkDestroySampler glad_vkDestroySampler;
5390#define vkDestroySampler glad_vkDestroySampler
5391GLAD_API_CALL PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion;
5392#define vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion
5393GLAD_API_CALL PFN_vkDestroySemaphore glad_vkDestroySemaphore;
5394#define vkDestroySemaphore glad_vkDestroySemaphore
5395GLAD_API_CALL PFN_vkDestroyShaderModule glad_vkDestroyShaderModule;
5396#define vkDestroyShaderModule glad_vkDestroyShaderModule
5397GLAD_API_CALL PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR;
5398#define vkDestroySurfaceKHR glad_vkDestroySurfaceKHR
5399GLAD_API_CALL PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR;
5400#define vkDestroySwapchainKHR glad_vkDestroySwapchainKHR
5401GLAD_API_CALL PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle;
5402#define vkDeviceWaitIdle glad_vkDeviceWaitIdle
5403GLAD_API_CALL PFN_vkEndCommandBuffer glad_vkEndCommandBuffer;
5404#define vkEndCommandBuffer glad_vkEndCommandBuffer
5405GLAD_API_CALL PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties;
5406#define vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties
5407GLAD_API_CALL PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties;
5408#define vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties
5409GLAD_API_CALL PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties;
5410#define vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties
5411GLAD_API_CALL PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties;
5412#define vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties
5413GLAD_API_CALL PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion;
5414#define vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion
5415GLAD_API_CALL PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups;
5416#define vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups
5417GLAD_API_CALL PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices;
5418#define vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices
5419GLAD_API_CALL PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges;
5420#define vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges
5421GLAD_API_CALL PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers;
5422#define vkFreeCommandBuffers glad_vkFreeCommandBuffers
5423GLAD_API_CALL PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets;
5424#define vkFreeDescriptorSets glad_vkFreeDescriptorSets
5425GLAD_API_CALL PFN_vkFreeMemory glad_vkFreeMemory;
5426#define vkFreeMemory glad_vkFreeMemory
5427GLAD_API_CALL PFN_vkGetBufferDeviceAddress glad_vkGetBufferDeviceAddress;
5428#define vkGetBufferDeviceAddress glad_vkGetBufferDeviceAddress
5429GLAD_API_CALL PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements;
5430#define vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements
5431GLAD_API_CALL PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2;
5432#define vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2
5433GLAD_API_CALL PFN_vkGetBufferOpaqueCaptureAddress glad_vkGetBufferOpaqueCaptureAddress;
5434#define vkGetBufferOpaqueCaptureAddress glad_vkGetBufferOpaqueCaptureAddress
5435GLAD_API_CALL PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport;
5436#define vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport
5437GLAD_API_CALL PFN_vkGetDeviceBufferMemoryRequirements glad_vkGetDeviceBufferMemoryRequirements;
5438#define vkGetDeviceBufferMemoryRequirements glad_vkGetDeviceBufferMemoryRequirements
5439GLAD_API_CALL PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures;
5440#define vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures
5441GLAD_API_CALL PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR;
5442#define vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR
5443GLAD_API_CALL PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR;
5444#define vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR
5445GLAD_API_CALL PFN_vkGetDeviceImageMemoryRequirements glad_vkGetDeviceImageMemoryRequirements;
5446#define vkGetDeviceImageMemoryRequirements glad_vkGetDeviceImageMemoryRequirements
5447GLAD_API_CALL PFN_vkGetDeviceImageSparseMemoryRequirements glad_vkGetDeviceImageSparseMemoryRequirements;
5448#define vkGetDeviceImageSparseMemoryRequirements glad_vkGetDeviceImageSparseMemoryRequirements
5449GLAD_API_CALL PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment;
5450#define vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment
5451GLAD_API_CALL PFN_vkGetDeviceMemoryOpaqueCaptureAddress glad_vkGetDeviceMemoryOpaqueCaptureAddress;
5452#define vkGetDeviceMemoryOpaqueCaptureAddress glad_vkGetDeviceMemoryOpaqueCaptureAddress
5453GLAD_API_CALL PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr;
5454#define vkGetDeviceProcAddr glad_vkGetDeviceProcAddr
5455GLAD_API_CALL PFN_vkGetDeviceQueue glad_vkGetDeviceQueue;
5456#define vkGetDeviceQueue glad_vkGetDeviceQueue
5457GLAD_API_CALL PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2;
5458#define vkGetDeviceQueue2 glad_vkGetDeviceQueue2
5459GLAD_API_CALL PFN_vkGetEventStatus glad_vkGetEventStatus;
5460#define vkGetEventStatus glad_vkGetEventStatus
5461GLAD_API_CALL PFN_vkGetFenceStatus glad_vkGetFenceStatus;
5462#define vkGetFenceStatus glad_vkGetFenceStatus
5463GLAD_API_CALL PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements;
5464#define vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements
5465GLAD_API_CALL PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2;
5466#define vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2
5467GLAD_API_CALL PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements;
5468#define vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements
5469GLAD_API_CALL PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2;
5470#define vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2
5471GLAD_API_CALL PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout;
5472#define vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout
5473GLAD_API_CALL PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr;
5474#define vkGetInstanceProcAddr glad_vkGetInstanceProcAddr
5475GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties;
5476#define vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties
5477GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties;
5478#define vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties
5479GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties;
5480#define vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties
5481GLAD_API_CALL PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures;
5482#define vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures
5483GLAD_API_CALL PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2;
5484#define vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2
5485GLAD_API_CALL PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties;
5486#define vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties
5487GLAD_API_CALL PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2;
5488#define vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2
5489GLAD_API_CALL PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties;
5490#define vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties
5491GLAD_API_CALL PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2;
5492#define vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2
5493GLAD_API_CALL PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties;
5494#define vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties
5495GLAD_API_CALL PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2;
5496#define vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2
5497GLAD_API_CALL PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR;
5498#define vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR
5499GLAD_API_CALL PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties;
5500#define vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties
5501GLAD_API_CALL PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2;
5502#define vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2
5503GLAD_API_CALL PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties;
5504#define vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties
5505GLAD_API_CALL PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2;
5506#define vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2
5507GLAD_API_CALL PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties;
5508#define vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties
5509GLAD_API_CALL PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2;
5510#define vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2
5511GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
5512#define vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
5513GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR;
5514#define vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR
5515GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR;
5516#define vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR
5517GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR;
5518#define vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR
5519GLAD_API_CALL PFN_vkGetPhysicalDeviceToolProperties glad_vkGetPhysicalDeviceToolProperties;
5520#define vkGetPhysicalDeviceToolProperties glad_vkGetPhysicalDeviceToolProperties
5521GLAD_API_CALL PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData;
5522#define vkGetPipelineCacheData glad_vkGetPipelineCacheData
5523GLAD_API_CALL PFN_vkGetPrivateData glad_vkGetPrivateData;
5524#define vkGetPrivateData glad_vkGetPrivateData
5525GLAD_API_CALL PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults;
5526#define vkGetQueryPoolResults glad_vkGetQueryPoolResults
5527GLAD_API_CALL PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity;
5528#define vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity
5529GLAD_API_CALL PFN_vkGetSemaphoreCounterValue glad_vkGetSemaphoreCounterValue;
5530#define vkGetSemaphoreCounterValue glad_vkGetSemaphoreCounterValue
5531GLAD_API_CALL PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR;
5532#define vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR
5533GLAD_API_CALL PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges;
5534#define vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges
5535GLAD_API_CALL PFN_vkMapMemory glad_vkMapMemory;
5536#define vkMapMemory glad_vkMapMemory
5537GLAD_API_CALL PFN_vkMergePipelineCaches glad_vkMergePipelineCaches;
5538#define vkMergePipelineCaches glad_vkMergePipelineCaches
5539GLAD_API_CALL PFN_vkQueueBindSparse glad_vkQueueBindSparse;
5540#define vkQueueBindSparse glad_vkQueueBindSparse
5541GLAD_API_CALL PFN_vkQueuePresentKHR glad_vkQueuePresentKHR;
5542#define vkQueuePresentKHR glad_vkQueuePresentKHR
5543GLAD_API_CALL PFN_vkQueueSubmit glad_vkQueueSubmit;
5544#define vkQueueSubmit glad_vkQueueSubmit
5545GLAD_API_CALL PFN_vkQueueSubmit2 glad_vkQueueSubmit2;
5546#define vkQueueSubmit2 glad_vkQueueSubmit2
5547GLAD_API_CALL PFN_vkQueueWaitIdle glad_vkQueueWaitIdle;
5548#define vkQueueWaitIdle glad_vkQueueWaitIdle
5549GLAD_API_CALL PFN_vkResetCommandBuffer glad_vkResetCommandBuffer;
5550#define vkResetCommandBuffer glad_vkResetCommandBuffer
5551GLAD_API_CALL PFN_vkResetCommandPool glad_vkResetCommandPool;
5552#define vkResetCommandPool glad_vkResetCommandPool
5553GLAD_API_CALL PFN_vkResetDescriptorPool glad_vkResetDescriptorPool;
5554#define vkResetDescriptorPool glad_vkResetDescriptorPool
5555GLAD_API_CALL PFN_vkResetEvent glad_vkResetEvent;
5556#define vkResetEvent glad_vkResetEvent
5557GLAD_API_CALL PFN_vkResetFences glad_vkResetFences;
5558#define vkResetFences glad_vkResetFences
5559GLAD_API_CALL PFN_vkResetQueryPool glad_vkResetQueryPool;
5560#define vkResetQueryPool glad_vkResetQueryPool
5561GLAD_API_CALL PFN_vkSetEvent glad_vkSetEvent;
5562#define vkSetEvent glad_vkSetEvent
5563GLAD_API_CALL PFN_vkSetPrivateData glad_vkSetPrivateData;
5564#define vkSetPrivateData glad_vkSetPrivateData
5565GLAD_API_CALL PFN_vkSignalSemaphore glad_vkSignalSemaphore;
5566#define vkSignalSemaphore glad_vkSignalSemaphore
5567GLAD_API_CALL PFN_vkTrimCommandPool glad_vkTrimCommandPool;
5568#define vkTrimCommandPool glad_vkTrimCommandPool
5569GLAD_API_CALL PFN_vkUnmapMemory glad_vkUnmapMemory;
5570#define vkUnmapMemory glad_vkUnmapMemory
5571GLAD_API_CALL PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate;
5572#define vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate
5573GLAD_API_CALL PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets;
5574#define vkUpdateDescriptorSets glad_vkUpdateDescriptorSets
5575GLAD_API_CALL PFN_vkWaitForFences glad_vkWaitForFences;
5576#define vkWaitForFences glad_vkWaitForFences
5577GLAD_API_CALL PFN_vkWaitSemaphores glad_vkWaitSemaphores;
5578#define vkWaitSemaphores glad_vkWaitSemaphores
5579
5580
5581
5582
5583
5584GLAD_API_CALL int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr);
5585GLAD_API_CALL int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load);
5586
5587
5588
5589#ifdef __cplusplus
5590}
5591#endif
5592#endif
5593
5594/* Source */
5595#ifdef GLAD_VULKAN_IMPLEMENTATION
5596#include <stdio.h>
5597#include <stdlib.h>
5598#include <string.h>
5599
5600#ifndef GLAD_IMPL_UTIL_C_
5601#define GLAD_IMPL_UTIL_C_
5602
5603#ifdef _MSC_VER
5604#define GLAD_IMPL_UTIL_SSCANF sscanf_s
5605#else
5606#define GLAD_IMPL_UTIL_SSCANF sscanf
5607#endif
5608
5609#endif /* GLAD_IMPL_UTIL_C_ */
5610
5611#ifdef __cplusplus
5612extern "C" {
5613#endif
5614
5615
5616
5617int GLAD_VK_VERSION_1_0 = 0;
5618int GLAD_VK_VERSION_1_1 = 0;
5619int GLAD_VK_VERSION_1_2 = 0;
5620int GLAD_VK_VERSION_1_3 = 0;
5621int GLAD_VK_EXT_debug_report = 0;
5622int GLAD_VK_KHR_portability_enumeration = 0;
5623int GLAD_VK_KHR_surface = 0;
5624int GLAD_VK_KHR_swapchain = 0;
5625
5626
5627
5628PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR = NULL;
5629PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR = NULL;
5630PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers = NULL;
5631PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets = NULL;
5632PFN_vkAllocateMemory glad_vkAllocateMemory = NULL;
5633PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer = NULL;
5634PFN_vkBindBufferMemory glad_vkBindBufferMemory = NULL;
5635PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2 = NULL;
5636PFN_vkBindImageMemory glad_vkBindImageMemory = NULL;
5637PFN_vkBindImageMemory2 glad_vkBindImageMemory2 = NULL;
5638PFN_vkCmdBeginQuery glad_vkCmdBeginQuery = NULL;
5639PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass = NULL;
5640PFN_vkCmdBeginRenderPass2 glad_vkCmdBeginRenderPass2 = NULL;
5641PFN_vkCmdBeginRendering glad_vkCmdBeginRendering = NULL;
5642PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets = NULL;
5643PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer = NULL;
5644PFN_vkCmdBindPipeline glad_vkCmdBindPipeline = NULL;
5645PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers = NULL;
5646PFN_vkCmdBindVertexBuffers2 glad_vkCmdBindVertexBuffers2 = NULL;
5647PFN_vkCmdBlitImage glad_vkCmdBlitImage = NULL;
5648PFN_vkCmdBlitImage2 glad_vkCmdBlitImage2 = NULL;
5649PFN_vkCmdClearAttachments glad_vkCmdClearAttachments = NULL;
5650PFN_vkCmdClearColorImage glad_vkCmdClearColorImage = NULL;
5651PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage = NULL;
5652PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer = NULL;
5653PFN_vkCmdCopyBuffer2 glad_vkCmdCopyBuffer2 = NULL;
5654PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage = NULL;
5655PFN_vkCmdCopyBufferToImage2 glad_vkCmdCopyBufferToImage2 = NULL;
5656PFN_vkCmdCopyImage glad_vkCmdCopyImage = NULL;
5657PFN_vkCmdCopyImage2 glad_vkCmdCopyImage2 = NULL;
5658PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer = NULL;
5659PFN_vkCmdCopyImageToBuffer2 glad_vkCmdCopyImageToBuffer2 = NULL;
5660PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults = NULL;
5661PFN_vkCmdDispatch glad_vkCmdDispatch = NULL;
5662PFN_vkCmdDispatchBase glad_vkCmdDispatchBase = NULL;
5663PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect = NULL;
5664PFN_vkCmdDraw glad_vkCmdDraw = NULL;
5665PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed = NULL;
5666PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect = NULL;
5667PFN_vkCmdDrawIndexedIndirectCount glad_vkCmdDrawIndexedIndirectCount = NULL;
5668PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect = NULL;
5669PFN_vkCmdDrawIndirectCount glad_vkCmdDrawIndirectCount = NULL;
5670PFN_vkCmdEndQuery glad_vkCmdEndQuery = NULL;
5671PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass = NULL;
5672PFN_vkCmdEndRenderPass2 glad_vkCmdEndRenderPass2 = NULL;
5673PFN_vkCmdEndRendering glad_vkCmdEndRendering = NULL;
5674PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands = NULL;
5675PFN_vkCmdFillBuffer glad_vkCmdFillBuffer = NULL;
5676PFN_vkCmdNextSubpass glad_vkCmdNextSubpass = NULL;
5677PFN_vkCmdNextSubpass2 glad_vkCmdNextSubpass2 = NULL;
5678PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier = NULL;
5679PFN_vkCmdPipelineBarrier2 glad_vkCmdPipelineBarrier2 = NULL;
5680PFN_vkCmdPushConstants glad_vkCmdPushConstants = NULL;
5681PFN_vkCmdResetEvent glad_vkCmdResetEvent = NULL;
5682PFN_vkCmdResetEvent2 glad_vkCmdResetEvent2 = NULL;
5683PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool = NULL;
5684PFN_vkCmdResolveImage glad_vkCmdResolveImage = NULL;
5685PFN_vkCmdResolveImage2 glad_vkCmdResolveImage2 = NULL;
5686PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants = NULL;
5687PFN_vkCmdSetCullMode glad_vkCmdSetCullMode = NULL;
5688PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias = NULL;
5689PFN_vkCmdSetDepthBiasEnable glad_vkCmdSetDepthBiasEnable = NULL;
5690PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds = NULL;
5691PFN_vkCmdSetDepthBoundsTestEnable glad_vkCmdSetDepthBoundsTestEnable = NULL;
5692PFN_vkCmdSetDepthCompareOp glad_vkCmdSetDepthCompareOp = NULL;
5693PFN_vkCmdSetDepthTestEnable glad_vkCmdSetDepthTestEnable = NULL;
5694PFN_vkCmdSetDepthWriteEnable glad_vkCmdSetDepthWriteEnable = NULL;
5695PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask = NULL;
5696PFN_vkCmdSetEvent glad_vkCmdSetEvent = NULL;
5697PFN_vkCmdSetEvent2 glad_vkCmdSetEvent2 = NULL;
5698PFN_vkCmdSetFrontFace glad_vkCmdSetFrontFace = NULL;
5699PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth = NULL;
5700PFN_vkCmdSetPrimitiveRestartEnable glad_vkCmdSetPrimitiveRestartEnable = NULL;
5701PFN_vkCmdSetPrimitiveTopology glad_vkCmdSetPrimitiveTopology = NULL;
5702PFN_vkCmdSetRasterizerDiscardEnable glad_vkCmdSetRasterizerDiscardEnable = NULL;
5703PFN_vkCmdSetScissor glad_vkCmdSetScissor = NULL;
5704PFN_vkCmdSetScissorWithCount glad_vkCmdSetScissorWithCount = NULL;
5705PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask = NULL;
5706PFN_vkCmdSetStencilOp glad_vkCmdSetStencilOp = NULL;
5707PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference = NULL;
5708PFN_vkCmdSetStencilTestEnable glad_vkCmdSetStencilTestEnable = NULL;
5709PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask = NULL;
5710PFN_vkCmdSetViewport glad_vkCmdSetViewport = NULL;
5711PFN_vkCmdSetViewportWithCount glad_vkCmdSetViewportWithCount = NULL;
5712PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer = NULL;
5713PFN_vkCmdWaitEvents glad_vkCmdWaitEvents = NULL;
5714PFN_vkCmdWaitEvents2 glad_vkCmdWaitEvents2 = NULL;
5715PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp = NULL;
5716PFN_vkCmdWriteTimestamp2 glad_vkCmdWriteTimestamp2 = NULL;
5717PFN_vkCreateBuffer glad_vkCreateBuffer = NULL;
5718PFN_vkCreateBufferView glad_vkCreateBufferView = NULL;
5719PFN_vkCreateCommandPool glad_vkCreateCommandPool = NULL;
5720PFN_vkCreateComputePipelines glad_vkCreateComputePipelines = NULL;
5721PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT = NULL;
5722PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool = NULL;
5723PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout = NULL;
5724PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate = NULL;
5725PFN_vkCreateDevice glad_vkCreateDevice = NULL;
5726PFN_vkCreateEvent glad_vkCreateEvent = NULL;
5727PFN_vkCreateFence glad_vkCreateFence = NULL;
5728PFN_vkCreateFramebuffer glad_vkCreateFramebuffer = NULL;
5729PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines = NULL;
5730PFN_vkCreateImage glad_vkCreateImage = NULL;
5731PFN_vkCreateImageView glad_vkCreateImageView = NULL;
5732PFN_vkCreateInstance glad_vkCreateInstance = NULL;
5733PFN_vkCreatePipelineCache glad_vkCreatePipelineCache = NULL;
5734PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout = NULL;
5735PFN_vkCreatePrivateDataSlot glad_vkCreatePrivateDataSlot = NULL;
5736PFN_vkCreateQueryPool glad_vkCreateQueryPool = NULL;
5737PFN_vkCreateRenderPass glad_vkCreateRenderPass = NULL;
5738PFN_vkCreateRenderPass2 glad_vkCreateRenderPass2 = NULL;
5739PFN_vkCreateSampler glad_vkCreateSampler = NULL;
5740PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion = NULL;
5741PFN_vkCreateSemaphore glad_vkCreateSemaphore = NULL;
5742PFN_vkCreateShaderModule glad_vkCreateShaderModule = NULL;
5743PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR = NULL;
5744PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT = NULL;
5745PFN_vkDestroyBuffer glad_vkDestroyBuffer = NULL;
5746PFN_vkDestroyBufferView glad_vkDestroyBufferView = NULL;
5747PFN_vkDestroyCommandPool glad_vkDestroyCommandPool = NULL;
5748PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT = NULL;
5749PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool = NULL;
5750PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout = NULL;
5751PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate = NULL;
5752PFN_vkDestroyDevice glad_vkDestroyDevice = NULL;
5753PFN_vkDestroyEvent glad_vkDestroyEvent = NULL;
5754PFN_vkDestroyFence glad_vkDestroyFence = NULL;
5755PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer = NULL;
5756PFN_vkDestroyImage glad_vkDestroyImage = NULL;
5757PFN_vkDestroyImageView glad_vkDestroyImageView = NULL;
5758PFN_vkDestroyInstance glad_vkDestroyInstance = NULL;
5759PFN_vkDestroyPipeline glad_vkDestroyPipeline = NULL;
5760PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache = NULL;
5761PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout = NULL;
5762PFN_vkDestroyPrivateDataSlot glad_vkDestroyPrivateDataSlot = NULL;
5763PFN_vkDestroyQueryPool glad_vkDestroyQueryPool = NULL;
5764PFN_vkDestroyRenderPass glad_vkDestroyRenderPass = NULL;
5765PFN_vkDestroySampler glad_vkDestroySampler = NULL;
5766PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion = NULL;
5767PFN_vkDestroySemaphore glad_vkDestroySemaphore = NULL;
5768PFN_vkDestroyShaderModule glad_vkDestroyShaderModule = NULL;
5769PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR = NULL;
5770PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR = NULL;
5771PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle = NULL;
5772PFN_vkEndCommandBuffer glad_vkEndCommandBuffer = NULL;
5773PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties = NULL;
5774PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties = NULL;
5775PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties = NULL;
5776PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties = NULL;
5777PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion = NULL;
5778PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups = NULL;
5779PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices = NULL;
5780PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges = NULL;
5781PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers = NULL;
5782PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets = NULL;
5783PFN_vkFreeMemory glad_vkFreeMemory = NULL;
5784PFN_vkGetBufferDeviceAddress glad_vkGetBufferDeviceAddress = NULL;
5785PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements = NULL;
5786PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2 = NULL;
5787PFN_vkGetBufferOpaqueCaptureAddress glad_vkGetBufferOpaqueCaptureAddress = NULL;
5788PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport = NULL;
5789PFN_vkGetDeviceBufferMemoryRequirements glad_vkGetDeviceBufferMemoryRequirements = NULL;
5790PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures = NULL;
5791PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR = NULL;
5792PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR = NULL;
5793PFN_vkGetDeviceImageMemoryRequirements glad_vkGetDeviceImageMemoryRequirements = NULL;
5794PFN_vkGetDeviceImageSparseMemoryRequirements glad_vkGetDeviceImageSparseMemoryRequirements = NULL;
5795PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment = NULL;
5796PFN_vkGetDeviceMemoryOpaqueCaptureAddress glad_vkGetDeviceMemoryOpaqueCaptureAddress = NULL;
5797PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr = NULL;
5798PFN_vkGetDeviceQueue glad_vkGetDeviceQueue = NULL;
5799PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2 = NULL;
5800PFN_vkGetEventStatus glad_vkGetEventStatus = NULL;
5801PFN_vkGetFenceStatus glad_vkGetFenceStatus = NULL;
5802PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements = NULL;
5803PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2 = NULL;
5804PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements = NULL;
5805PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2 = NULL;
5806PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout = NULL;
5807PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr = NULL;
5808PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties = NULL;
5809PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties = NULL;
5810PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties = NULL;
5811PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures = NULL;
5812PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2 = NULL;
5813PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties = NULL;
5814PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2 = NULL;
5815PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties = NULL;
5816PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2 = NULL;
5817PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties = NULL;
5818PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2 = NULL;
5819PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR = NULL;
5820PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties = NULL;
5821PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2 = NULL;
5822PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties = NULL;
5823PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = NULL;
5824PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties = NULL;
5825PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = NULL;
5826PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = NULL;
5827PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR = NULL;
5828PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR = NULL;
5829PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR = NULL;
5830PFN_vkGetPhysicalDeviceToolProperties glad_vkGetPhysicalDeviceToolProperties = NULL;
5831PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData = NULL;
5832PFN_vkGetPrivateData glad_vkGetPrivateData = NULL;
5833PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults = NULL;
5834PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity = NULL;
5835PFN_vkGetSemaphoreCounterValue glad_vkGetSemaphoreCounterValue = NULL;
5836PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR = NULL;
5837PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges = NULL;
5838PFN_vkMapMemory glad_vkMapMemory = NULL;
5839PFN_vkMergePipelineCaches glad_vkMergePipelineCaches = NULL;
5840PFN_vkQueueBindSparse glad_vkQueueBindSparse = NULL;
5841PFN_vkQueuePresentKHR glad_vkQueuePresentKHR = NULL;
5842PFN_vkQueueSubmit glad_vkQueueSubmit = NULL;
5843PFN_vkQueueSubmit2 glad_vkQueueSubmit2 = NULL;
5844PFN_vkQueueWaitIdle glad_vkQueueWaitIdle = NULL;
5845PFN_vkResetCommandBuffer glad_vkResetCommandBuffer = NULL;
5846PFN_vkResetCommandPool glad_vkResetCommandPool = NULL;
5847PFN_vkResetDescriptorPool glad_vkResetDescriptorPool = NULL;
5848PFN_vkResetEvent glad_vkResetEvent = NULL;
5849PFN_vkResetFences glad_vkResetFences = NULL;
5850PFN_vkResetQueryPool glad_vkResetQueryPool = NULL;
5851PFN_vkSetEvent glad_vkSetEvent = NULL;
5852PFN_vkSetPrivateData glad_vkSetPrivateData = NULL;
5853PFN_vkSignalSemaphore glad_vkSignalSemaphore = NULL;
5854PFN_vkTrimCommandPool glad_vkTrimCommandPool = NULL;
5855PFN_vkUnmapMemory glad_vkUnmapMemory = NULL;
5856PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate = NULL;
5857PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets = NULL;
5858PFN_vkWaitForFences glad_vkWaitForFences = NULL;
5859PFN_vkWaitSemaphores glad_vkWaitSemaphores = NULL;
5860
5861
5862static void glad_vk_load_VK_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
5863 if(!GLAD_VK_VERSION_1_0) return;
5864 glad_vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers) load(userptr, "vkAllocateCommandBuffers");
5865 glad_vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets) load(userptr, "vkAllocateDescriptorSets");
5866 glad_vkAllocateMemory = (PFN_vkAllocateMemory) load(userptr, "vkAllocateMemory");
5867 glad_vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer) load(userptr, "vkBeginCommandBuffer");
5868 glad_vkBindBufferMemory = (PFN_vkBindBufferMemory) load(userptr, "vkBindBufferMemory");
5869 glad_vkBindImageMemory = (PFN_vkBindImageMemory) load(userptr, "vkBindImageMemory");
5870 glad_vkCmdBeginQuery = (PFN_vkCmdBeginQuery) load(userptr, "vkCmdBeginQuery");
5871 glad_vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) load(userptr, "vkCmdBeginRenderPass");
5872 glad_vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) load(userptr, "vkCmdBindDescriptorSets");
5873 glad_vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) load(userptr, "vkCmdBindIndexBuffer");
5874 glad_vkCmdBindPipeline = (PFN_vkCmdBindPipeline) load(userptr, "vkCmdBindPipeline");
5875 glad_vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) load(userptr, "vkCmdBindVertexBuffers");
5876 glad_vkCmdBlitImage = (PFN_vkCmdBlitImage) load(userptr, "vkCmdBlitImage");
5877 glad_vkCmdClearAttachments = (PFN_vkCmdClearAttachments) load(userptr, "vkCmdClearAttachments");
5878 glad_vkCmdClearColorImage = (PFN_vkCmdClearColorImage) load(userptr, "vkCmdClearColorImage");
5879 glad_vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) load(userptr, "vkCmdClearDepthStencilImage");
5880 glad_vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer) load(userptr, "vkCmdCopyBuffer");
5881 glad_vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) load(userptr, "vkCmdCopyBufferToImage");
5882 glad_vkCmdCopyImage = (PFN_vkCmdCopyImage) load(userptr, "vkCmdCopyImage");
5883 glad_vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) load(userptr, "vkCmdCopyImageToBuffer");
5884 glad_vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) load(userptr, "vkCmdCopyQueryPoolResults");
5885 glad_vkCmdDispatch = (PFN_vkCmdDispatch) load(userptr, "vkCmdDispatch");
5886 glad_vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) load(userptr, "vkCmdDispatchIndirect");
5887 glad_vkCmdDraw = (PFN_vkCmdDraw) load(userptr, "vkCmdDraw");
5888 glad_vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed) load(userptr, "vkCmdDrawIndexed");
5889 glad_vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) load(userptr, "vkCmdDrawIndexedIndirect");
5890 glad_vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect) load(userptr, "vkCmdDrawIndirect");
5891 glad_vkCmdEndQuery = (PFN_vkCmdEndQuery) load(userptr, "vkCmdEndQuery");
5892 glad_vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass) load(userptr, "vkCmdEndRenderPass");
5893 glad_vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands) load(userptr, "vkCmdExecuteCommands");
5894 glad_vkCmdFillBuffer = (PFN_vkCmdFillBuffer) load(userptr, "vkCmdFillBuffer");
5895 glad_vkCmdNextSubpass = (PFN_vkCmdNextSubpass) load(userptr, "vkCmdNextSubpass");
5896 glad_vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) load(userptr, "vkCmdPipelineBarrier");
5897 glad_vkCmdPushConstants = (PFN_vkCmdPushConstants) load(userptr, "vkCmdPushConstants");
5898 glad_vkCmdResetEvent = (PFN_vkCmdResetEvent) load(userptr, "vkCmdResetEvent");
5899 glad_vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) load(userptr, "vkCmdResetQueryPool");
5900 glad_vkCmdResolveImage = (PFN_vkCmdResolveImage) load(userptr, "vkCmdResolveImage");
5901 glad_vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants) load(userptr, "vkCmdSetBlendConstants");
5902 glad_vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias) load(userptr, "vkCmdSetDepthBias");
5903 glad_vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds) load(userptr, "vkCmdSetDepthBounds");
5904 glad_vkCmdSetEvent = (PFN_vkCmdSetEvent) load(userptr, "vkCmdSetEvent");
5905 glad_vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth) load(userptr, "vkCmdSetLineWidth");
5906 glad_vkCmdSetScissor = (PFN_vkCmdSetScissor) load(userptr, "vkCmdSetScissor");
5907 glad_vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask) load(userptr, "vkCmdSetStencilCompareMask");
5908 glad_vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference) load(userptr, "vkCmdSetStencilReference");
5909 glad_vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask) load(userptr, "vkCmdSetStencilWriteMask");
5910 glad_vkCmdSetViewport = (PFN_vkCmdSetViewport) load(userptr, "vkCmdSetViewport");
5911 glad_vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) load(userptr, "vkCmdUpdateBuffer");
5912 glad_vkCmdWaitEvents = (PFN_vkCmdWaitEvents) load(userptr, "vkCmdWaitEvents");
5913 glad_vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) load(userptr, "vkCmdWriteTimestamp");
5914 glad_vkCreateBuffer = (PFN_vkCreateBuffer) load(userptr, "vkCreateBuffer");
5915 glad_vkCreateBufferView = (PFN_vkCreateBufferView) load(userptr, "vkCreateBufferView");
5916 glad_vkCreateCommandPool = (PFN_vkCreateCommandPool) load(userptr, "vkCreateCommandPool");
5917 glad_vkCreateComputePipelines = (PFN_vkCreateComputePipelines) load(userptr, "vkCreateComputePipelines");
5918 glad_vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool) load(userptr, "vkCreateDescriptorPool");
5919 glad_vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) load(userptr, "vkCreateDescriptorSetLayout");
5920 glad_vkCreateDevice = (PFN_vkCreateDevice) load(userptr, "vkCreateDevice");
5921 glad_vkCreateEvent = (PFN_vkCreateEvent) load(userptr, "vkCreateEvent");
5922 glad_vkCreateFence = (PFN_vkCreateFence) load(userptr, "vkCreateFence");
5923 glad_vkCreateFramebuffer = (PFN_vkCreateFramebuffer) load(userptr, "vkCreateFramebuffer");
5924 glad_vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines) load(userptr, "vkCreateGraphicsPipelines");
5925 glad_vkCreateImage = (PFN_vkCreateImage) load(userptr, "vkCreateImage");
5926 glad_vkCreateImageView = (PFN_vkCreateImageView) load(userptr, "vkCreateImageView");
5927 glad_vkCreateInstance = (PFN_vkCreateInstance) load(userptr, "vkCreateInstance");
5928 glad_vkCreatePipelineCache = (PFN_vkCreatePipelineCache) load(userptr, "vkCreatePipelineCache");
5929 glad_vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout) load(userptr, "vkCreatePipelineLayout");
5930 glad_vkCreateQueryPool = (PFN_vkCreateQueryPool) load(userptr, "vkCreateQueryPool");
5931 glad_vkCreateRenderPass = (PFN_vkCreateRenderPass) load(userptr, "vkCreateRenderPass");
5932 glad_vkCreateSampler = (PFN_vkCreateSampler) load(userptr, "vkCreateSampler");
5933 glad_vkCreateSemaphore = (PFN_vkCreateSemaphore) load(userptr, "vkCreateSemaphore");
5934 glad_vkCreateShaderModule = (PFN_vkCreateShaderModule) load(userptr, "vkCreateShaderModule");
5935 glad_vkDestroyBuffer = (PFN_vkDestroyBuffer) load(userptr, "vkDestroyBuffer");
5936 glad_vkDestroyBufferView = (PFN_vkDestroyBufferView) load(userptr, "vkDestroyBufferView");
5937 glad_vkDestroyCommandPool = (PFN_vkDestroyCommandPool) load(userptr, "vkDestroyCommandPool");
5938 glad_vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool) load(userptr, "vkDestroyDescriptorPool");
5939 glad_vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout) load(userptr, "vkDestroyDescriptorSetLayout");
5940 glad_vkDestroyDevice = (PFN_vkDestroyDevice) load(userptr, "vkDestroyDevice");
5941 glad_vkDestroyEvent = (PFN_vkDestroyEvent) load(userptr, "vkDestroyEvent");
5942 glad_vkDestroyFence = (PFN_vkDestroyFence) load(userptr, "vkDestroyFence");
5943 glad_vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer) load(userptr, "vkDestroyFramebuffer");
5944 glad_vkDestroyImage = (PFN_vkDestroyImage) load(userptr, "vkDestroyImage");
5945 glad_vkDestroyImageView = (PFN_vkDestroyImageView) load(userptr, "vkDestroyImageView");
5946 glad_vkDestroyInstance = (PFN_vkDestroyInstance) load(userptr, "vkDestroyInstance");
5947 glad_vkDestroyPipeline = (PFN_vkDestroyPipeline) load(userptr, "vkDestroyPipeline");
5948 glad_vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache) load(userptr, "vkDestroyPipelineCache");
5949 glad_vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout) load(userptr, "vkDestroyPipelineLayout");
5950 glad_vkDestroyQueryPool = (PFN_vkDestroyQueryPool) load(userptr, "vkDestroyQueryPool");
5951 glad_vkDestroyRenderPass = (PFN_vkDestroyRenderPass) load(userptr, "vkDestroyRenderPass");
5952 glad_vkDestroySampler = (PFN_vkDestroySampler) load(userptr, "vkDestroySampler");
5953 glad_vkDestroySemaphore = (PFN_vkDestroySemaphore) load(userptr, "vkDestroySemaphore");
5954 glad_vkDestroyShaderModule = (PFN_vkDestroyShaderModule) load(userptr, "vkDestroyShaderModule");
5955 glad_vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle) load(userptr, "vkDeviceWaitIdle");
5956 glad_vkEndCommandBuffer = (PFN_vkEndCommandBuffer) load(userptr, "vkEndCommandBuffer");
5957 glad_vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties) load(userptr, "vkEnumerateDeviceExtensionProperties");
5958 glad_vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties) load(userptr, "vkEnumerateDeviceLayerProperties");
5959 glad_vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) load(userptr, "vkEnumerateInstanceExtensionProperties");
5960 glad_vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties) load(userptr, "vkEnumerateInstanceLayerProperties");
5961 glad_vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) load(userptr, "vkEnumeratePhysicalDevices");
5962 glad_vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) load(userptr, "vkFlushMappedMemoryRanges");
5963 glad_vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers) load(userptr, "vkFreeCommandBuffers");
5964 glad_vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets) load(userptr, "vkFreeDescriptorSets");
5965 glad_vkFreeMemory = (PFN_vkFreeMemory) load(userptr, "vkFreeMemory");
5966 glad_vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements) load(userptr, "vkGetBufferMemoryRequirements");
5967 glad_vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment) load(userptr, "vkGetDeviceMemoryCommitment");
5968 glad_vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) load(userptr, "vkGetDeviceProcAddr");
5969 glad_vkGetDeviceQueue = (PFN_vkGetDeviceQueue) load(userptr, "vkGetDeviceQueue");
5970 glad_vkGetEventStatus = (PFN_vkGetEventStatus) load(userptr, "vkGetEventStatus");
5971 glad_vkGetFenceStatus = (PFN_vkGetFenceStatus) load(userptr, "vkGetFenceStatus");
5972 glad_vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements) load(userptr, "vkGetImageMemoryRequirements");
5973 glad_vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements) load(userptr, "vkGetImageSparseMemoryRequirements");
5974 glad_vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) load(userptr, "vkGetImageSubresourceLayout");
5975 glad_vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) load(userptr, "vkGetInstanceProcAddr");
5976 glad_vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) load(userptr, "vkGetPhysicalDeviceFeatures");
5977 glad_vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties) load(userptr, "vkGetPhysicalDeviceFormatProperties");
5978 glad_vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) load(userptr, "vkGetPhysicalDeviceImageFormatProperties");
5979 glad_vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) load(userptr, "vkGetPhysicalDeviceMemoryProperties");
5980 glad_vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) load(userptr, "vkGetPhysicalDeviceProperties");
5981 glad_vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties) load(userptr, "vkGetPhysicalDeviceQueueFamilyProperties");
5982 glad_vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties) load(userptr, "vkGetPhysicalDeviceSparseImageFormatProperties");
5983 glad_vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData) load(userptr, "vkGetPipelineCacheData");
5984 glad_vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults) load(userptr, "vkGetQueryPoolResults");
5985 glad_vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity) load(userptr, "vkGetRenderAreaGranularity");
5986 glad_vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) load(userptr, "vkInvalidateMappedMemoryRanges");
5987 glad_vkMapMemory = (PFN_vkMapMemory) load(userptr, "vkMapMemory");
5988 glad_vkMergePipelineCaches = (PFN_vkMergePipelineCaches) load(userptr, "vkMergePipelineCaches");
5989 glad_vkQueueBindSparse = (PFN_vkQueueBindSparse) load(userptr, "vkQueueBindSparse");
5990 glad_vkQueueSubmit = (PFN_vkQueueSubmit) load(userptr, "vkQueueSubmit");
5991 glad_vkQueueWaitIdle = (PFN_vkQueueWaitIdle) load(userptr, "vkQueueWaitIdle");
5992 glad_vkResetCommandBuffer = (PFN_vkResetCommandBuffer) load(userptr, "vkResetCommandBuffer");
5993 glad_vkResetCommandPool = (PFN_vkResetCommandPool) load(userptr, "vkResetCommandPool");
5994 glad_vkResetDescriptorPool = (PFN_vkResetDescriptorPool) load(userptr, "vkResetDescriptorPool");
5995 glad_vkResetEvent = (PFN_vkResetEvent) load(userptr, "vkResetEvent");
5996 glad_vkResetFences = (PFN_vkResetFences) load(userptr, "vkResetFences");
5997 glad_vkSetEvent = (PFN_vkSetEvent) load(userptr, "vkSetEvent");
5998 glad_vkUnmapMemory = (PFN_vkUnmapMemory) load(userptr, "vkUnmapMemory");
5999 glad_vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) load(userptr, "vkUpdateDescriptorSets");
6000 glad_vkWaitForFences = (PFN_vkWaitForFences) load(userptr, "vkWaitForFences");
6001}
6002static void glad_vk_load_VK_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
6003 if(!GLAD_VK_VERSION_1_1) return;
6004 glad_vkBindBufferMemory2 = (PFN_vkBindBufferMemory2) load(userptr, "vkBindBufferMemory2");
6005 glad_vkBindImageMemory2 = (PFN_vkBindImageMemory2) load(userptr, "vkBindImageMemory2");
6006 glad_vkCmdDispatchBase = (PFN_vkCmdDispatchBase) load(userptr, "vkCmdDispatchBase");
6007 glad_vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask) load(userptr, "vkCmdSetDeviceMask");
6008 glad_vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate) load(userptr, "vkCreateDescriptorUpdateTemplate");
6009 glad_vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion) load(userptr, "vkCreateSamplerYcbcrConversion");
6010 glad_vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate) load(userptr, "vkDestroyDescriptorUpdateTemplate");
6011 glad_vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion) load(userptr, "vkDestroySamplerYcbcrConversion");
6012 glad_vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load(userptr, "vkEnumerateInstanceVersion");
6013 glad_vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups) load(userptr, "vkEnumeratePhysicalDeviceGroups");
6014 glad_vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2) load(userptr, "vkGetBufferMemoryRequirements2");
6015 glad_vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport) load(userptr, "vkGetDescriptorSetLayoutSupport");
6016 glad_vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures) load(userptr, "vkGetDeviceGroupPeerMemoryFeatures");
6017 glad_vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2) load(userptr, "vkGetDeviceQueue2");
6018 glad_vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2) load(userptr, "vkGetImageMemoryRequirements2");
6019 glad_vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2) load(userptr, "vkGetImageSparseMemoryRequirements2");
6020 glad_vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties) load(userptr, "vkGetPhysicalDeviceExternalBufferProperties");
6021 glad_vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties) load(userptr, "vkGetPhysicalDeviceExternalFenceProperties");
6022 glad_vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties) load(userptr, "vkGetPhysicalDeviceExternalSemaphoreProperties");
6023 glad_vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2) load(userptr, "vkGetPhysicalDeviceFeatures2");
6024 glad_vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2) load(userptr, "vkGetPhysicalDeviceFormatProperties2");
6025 glad_vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2) load(userptr, "vkGetPhysicalDeviceImageFormatProperties2");
6026 glad_vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2) load(userptr, "vkGetPhysicalDeviceMemoryProperties2");
6027 glad_vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) load(userptr, "vkGetPhysicalDeviceProperties2");
6028 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) load(userptr, "vkGetPhysicalDeviceQueueFamilyProperties2");
6029 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2) load(userptr, "vkGetPhysicalDeviceSparseImageFormatProperties2");
6030 glad_vkTrimCommandPool = (PFN_vkTrimCommandPool) load(userptr, "vkTrimCommandPool");
6031 glad_vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate) load(userptr, "vkUpdateDescriptorSetWithTemplate");
6032}
6033static void glad_vk_load_VK_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) {
6034 if(!GLAD_VK_VERSION_1_2) return;
6035 glad_vkCmdBeginRenderPass2 = (PFN_vkCmdBeginRenderPass2) load(userptr, "vkCmdBeginRenderPass2");
6036 glad_vkCmdDrawIndexedIndirectCount = (PFN_vkCmdDrawIndexedIndirectCount) load(userptr, "vkCmdDrawIndexedIndirectCount");
6037 glad_vkCmdDrawIndirectCount = (PFN_vkCmdDrawIndirectCount) load(userptr, "vkCmdDrawIndirectCount");
6038 glad_vkCmdEndRenderPass2 = (PFN_vkCmdEndRenderPass2) load(userptr, "vkCmdEndRenderPass2");
6039 glad_vkCmdNextSubpass2 = (PFN_vkCmdNextSubpass2) load(userptr, "vkCmdNextSubpass2");
6040 glad_vkCreateRenderPass2 = (PFN_vkCreateRenderPass2) load(userptr, "vkCreateRenderPass2");
6041 glad_vkGetBufferDeviceAddress = (PFN_vkGetBufferDeviceAddress) load(userptr, "vkGetBufferDeviceAddress");
6042 glad_vkGetBufferOpaqueCaptureAddress = (PFN_vkGetBufferOpaqueCaptureAddress) load(userptr, "vkGetBufferOpaqueCaptureAddress");
6043 glad_vkGetDeviceMemoryOpaqueCaptureAddress = (PFN_vkGetDeviceMemoryOpaqueCaptureAddress) load(userptr, "vkGetDeviceMemoryOpaqueCaptureAddress");
6044 glad_vkGetSemaphoreCounterValue = (PFN_vkGetSemaphoreCounterValue) load(userptr, "vkGetSemaphoreCounterValue");
6045 glad_vkResetQueryPool = (PFN_vkResetQueryPool) load(userptr, "vkResetQueryPool");
6046 glad_vkSignalSemaphore = (PFN_vkSignalSemaphore) load(userptr, "vkSignalSemaphore");
6047 glad_vkWaitSemaphores = (PFN_vkWaitSemaphores) load(userptr, "vkWaitSemaphores");
6048}
6049static void glad_vk_load_VK_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) {
6050 if(!GLAD_VK_VERSION_1_3) return;
6051 glad_vkCmdBeginRendering = (PFN_vkCmdBeginRendering) load(userptr, "vkCmdBeginRendering");
6052 glad_vkCmdBindVertexBuffers2 = (PFN_vkCmdBindVertexBuffers2) load(userptr, "vkCmdBindVertexBuffers2");
6053 glad_vkCmdBlitImage2 = (PFN_vkCmdBlitImage2) load(userptr, "vkCmdBlitImage2");
6054 glad_vkCmdCopyBuffer2 = (PFN_vkCmdCopyBuffer2) load(userptr, "vkCmdCopyBuffer2");
6055 glad_vkCmdCopyBufferToImage2 = (PFN_vkCmdCopyBufferToImage2) load(userptr, "vkCmdCopyBufferToImage2");
6056 glad_vkCmdCopyImage2 = (PFN_vkCmdCopyImage2) load(userptr, "vkCmdCopyImage2");
6057 glad_vkCmdCopyImageToBuffer2 = (PFN_vkCmdCopyImageToBuffer2) load(userptr, "vkCmdCopyImageToBuffer2");
6058 glad_vkCmdEndRendering = (PFN_vkCmdEndRendering) load(userptr, "vkCmdEndRendering");
6059 glad_vkCmdPipelineBarrier2 = (PFN_vkCmdPipelineBarrier2) load(userptr, "vkCmdPipelineBarrier2");
6060 glad_vkCmdResetEvent2 = (PFN_vkCmdResetEvent2) load(userptr, "vkCmdResetEvent2");
6061 glad_vkCmdResolveImage2 = (PFN_vkCmdResolveImage2) load(userptr, "vkCmdResolveImage2");
6062 glad_vkCmdSetCullMode = (PFN_vkCmdSetCullMode) load(userptr, "vkCmdSetCullMode");
6063 glad_vkCmdSetDepthBiasEnable = (PFN_vkCmdSetDepthBiasEnable) load(userptr, "vkCmdSetDepthBiasEnable");
6064 glad_vkCmdSetDepthBoundsTestEnable = (PFN_vkCmdSetDepthBoundsTestEnable) load(userptr, "vkCmdSetDepthBoundsTestEnable");
6065 glad_vkCmdSetDepthCompareOp = (PFN_vkCmdSetDepthCompareOp) load(userptr, "vkCmdSetDepthCompareOp");
6066 glad_vkCmdSetDepthTestEnable = (PFN_vkCmdSetDepthTestEnable) load(userptr, "vkCmdSetDepthTestEnable");
6067 glad_vkCmdSetDepthWriteEnable = (PFN_vkCmdSetDepthWriteEnable) load(userptr, "vkCmdSetDepthWriteEnable");
6068 glad_vkCmdSetEvent2 = (PFN_vkCmdSetEvent2) load(userptr, "vkCmdSetEvent2");
6069 glad_vkCmdSetFrontFace = (PFN_vkCmdSetFrontFace) load(userptr, "vkCmdSetFrontFace");
6070 glad_vkCmdSetPrimitiveRestartEnable = (PFN_vkCmdSetPrimitiveRestartEnable) load(userptr, "vkCmdSetPrimitiveRestartEnable");
6071 glad_vkCmdSetPrimitiveTopology = (PFN_vkCmdSetPrimitiveTopology) load(userptr, "vkCmdSetPrimitiveTopology");
6072 glad_vkCmdSetRasterizerDiscardEnable = (PFN_vkCmdSetRasterizerDiscardEnable) load(userptr, "vkCmdSetRasterizerDiscardEnable");
6073 glad_vkCmdSetScissorWithCount = (PFN_vkCmdSetScissorWithCount) load(userptr, "vkCmdSetScissorWithCount");
6074 glad_vkCmdSetStencilOp = (PFN_vkCmdSetStencilOp) load(userptr, "vkCmdSetStencilOp");
6075 glad_vkCmdSetStencilTestEnable = (PFN_vkCmdSetStencilTestEnable) load(userptr, "vkCmdSetStencilTestEnable");
6076 glad_vkCmdSetViewportWithCount = (PFN_vkCmdSetViewportWithCount) load(userptr, "vkCmdSetViewportWithCount");
6077 glad_vkCmdWaitEvents2 = (PFN_vkCmdWaitEvents2) load(userptr, "vkCmdWaitEvents2");
6078 glad_vkCmdWriteTimestamp2 = (PFN_vkCmdWriteTimestamp2) load(userptr, "vkCmdWriteTimestamp2");
6079 glad_vkCreatePrivateDataSlot = (PFN_vkCreatePrivateDataSlot) load(userptr, "vkCreatePrivateDataSlot");
6080 glad_vkDestroyPrivateDataSlot = (PFN_vkDestroyPrivateDataSlot) load(userptr, "vkDestroyPrivateDataSlot");
6081 glad_vkGetDeviceBufferMemoryRequirements = (PFN_vkGetDeviceBufferMemoryRequirements) load(userptr, "vkGetDeviceBufferMemoryRequirements");
6082 glad_vkGetDeviceImageMemoryRequirements = (PFN_vkGetDeviceImageMemoryRequirements) load(userptr, "vkGetDeviceImageMemoryRequirements");
6083 glad_vkGetDeviceImageSparseMemoryRequirements = (PFN_vkGetDeviceImageSparseMemoryRequirements) load(userptr, "vkGetDeviceImageSparseMemoryRequirements");
6084 glad_vkGetPhysicalDeviceToolProperties = (PFN_vkGetPhysicalDeviceToolProperties) load(userptr, "vkGetPhysicalDeviceToolProperties");
6085 glad_vkGetPrivateData = (PFN_vkGetPrivateData) load(userptr, "vkGetPrivateData");
6086 glad_vkQueueSubmit2 = (PFN_vkQueueSubmit2) load(userptr, "vkQueueSubmit2");
6087 glad_vkSetPrivateData = (PFN_vkSetPrivateData) load(userptr, "vkSetPrivateData");
6088}
6089static void glad_vk_load_VK_EXT_debug_report( GLADuserptrloadfunc load, void* userptr) {
6090 if(!GLAD_VK_EXT_debug_report) return;
6091 glad_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT) load(userptr, "vkCreateDebugReportCallbackEXT");
6092 glad_vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT) load(userptr, "vkDebugReportMessageEXT");
6093 glad_vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT) load(userptr, "vkDestroyDebugReportCallbackEXT");
6094}
6095static void glad_vk_load_VK_KHR_surface( GLADuserptrloadfunc load, void* userptr) {
6096 if(!GLAD_VK_KHR_surface) return;
6097 glad_vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) load(userptr, "vkDestroySurfaceKHR");
6098 glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) load(userptr, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
6099 glad_vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) load(userptr, "vkGetPhysicalDeviceSurfaceFormatsKHR");
6100 glad_vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) load(userptr, "vkGetPhysicalDeviceSurfacePresentModesKHR");
6101 glad_vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) load(userptr, "vkGetPhysicalDeviceSurfaceSupportKHR");
6102}
6103static void glad_vk_load_VK_KHR_swapchain( GLADuserptrloadfunc load, void* userptr) {
6104 if(!GLAD_VK_KHR_swapchain) return;
6105 glad_vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR) load(userptr, "vkAcquireNextImage2KHR");
6106 glad_vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) load(userptr, "vkAcquireNextImageKHR");
6107 glad_vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) load(userptr, "vkCreateSwapchainKHR");
6108 glad_vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) load(userptr, "vkDestroySwapchainKHR");
6109 glad_vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR) load(userptr, "vkGetDeviceGroupPresentCapabilitiesKHR");
6110 glad_vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR) load(userptr, "vkGetDeviceGroupSurfacePresentModesKHR");
6111 glad_vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR) load(userptr, "vkGetPhysicalDevicePresentRectanglesKHR");
6112 glad_vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) load(userptr, "vkGetSwapchainImagesKHR");
6113 glad_vkQueuePresentKHR = (PFN_vkQueuePresentKHR) load(userptr, "vkQueuePresentKHR");
6114}
6115
6116
6117
6118static int glad_vk_get_extensions( VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) {
6119 uint32_t i;
6120 uint32_t instance_extension_count = 0;
6121 uint32_t device_extension_count = 0;
6122 uint32_t max_extension_count = 0;
6123 uint32_t total_extension_count = 0;
6124 char **extensions = NULL;
6125 VkExtensionProperties *ext_properties = NULL;
6126 VkResult result;
6127
6128 if (glad_vkEnumerateInstanceExtensionProperties == NULL || (physical_device != NULL && glad_vkEnumerateDeviceExtensionProperties == NULL)) {
6129 return 0;
6130 }
6131
6132 result = glad_vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
6133 if (result != VK_SUCCESS) {
6134 return 0;
6135 }
6136
6137 if (physical_device != NULL) {
6138 result = glad_vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, NULL);
6139 if (result != VK_SUCCESS) {
6140 return 0;
6141 }
6142 }
6143
6144 total_extension_count = instance_extension_count + device_extension_count;
6145 if (total_extension_count <= 0) {
6146 return 0;
6147 }
6148
6149 max_extension_count = instance_extension_count > device_extension_count
6150 ? instance_extension_count : device_extension_count;
6151
6152 ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties));
6153 if (ext_properties == NULL) {
6154 goto glad_vk_get_extensions_error;
6155 }
6156
6157 result = glad_vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, ext_properties);
6158 if (result != VK_SUCCESS) {
6159 goto glad_vk_get_extensions_error;
6160 }
6161
6162 extensions = (char**) calloc(total_extension_count, sizeof(char*));
6163 if (extensions == NULL) {
6164 goto glad_vk_get_extensions_error;
6165 }
6166
6167 for (i = 0; i < instance_extension_count; ++i) {
6168 VkExtensionProperties ext = ext_properties[i];
6169
6170 size_t extension_name_length = strlen(ext.extensionName) + 1;
6171 extensions[i] = (char*) malloc(extension_name_length * sizeof(char));
6172 if (extensions[i] == NULL) {
6173 goto glad_vk_get_extensions_error;
6174 }
6175 memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char));
6176 }
6177
6178 if (physical_device != NULL) {
6179 result = glad_vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, ext_properties);
6180 if (result != VK_SUCCESS) {
6181 goto glad_vk_get_extensions_error;
6182 }
6183
6184 for (i = 0; i < device_extension_count; ++i) {
6185 VkExtensionProperties ext = ext_properties[i];
6186
6187 size_t extension_name_length = strlen(ext.extensionName) + 1;
6188 extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char));
6189 if (extensions[instance_extension_count + i] == NULL) {
6190 goto glad_vk_get_extensions_error;
6191 }
6192 memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char));
6193 }
6194 }
6195
6196 free((void*) ext_properties);
6197
6198 *out_extension_count = total_extension_count;
6199 *out_extensions = extensions;
6200
6201 return 1;
6202
6203glad_vk_get_extensions_error:
6204 free((void*) ext_properties);
6205 if (extensions != NULL) {
6206 for (i = 0; i < total_extension_count; ++i) {
6207 free((void*) extensions[i]);
6208 }
6209 free(extensions);
6210 }
6211 return 0;
6212}
6213
6214static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) {
6215 uint32_t i;
6216
6217 for(i = 0; i < extension_count ; ++i) {
6218 free((void*) (extensions[i]));
6219 }
6220
6221 free((void*) extensions);
6222}
6223
6224static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) {
6225 uint32_t i;
6226
6227 for (i = 0; i < extension_count; ++i) {
6228 if(extensions[i] != NULL && strcmp(name, extensions[i]) == 0) {
6229 return 1;
6230 }
6231 }
6232
6233 return 0;
6234}
6235
6236static GLADapiproc glad_vk_get_proc_from_userptr(void *userptr, const char* name) {
6237 return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
6238}
6239
6240static int glad_vk_find_extensions_vulkan( VkPhysicalDevice physical_device) {
6241 uint32_t extension_count = 0;
6242 char **extensions = NULL;
6243 if (!glad_vk_get_extensions(physical_device, &extension_count, &extensions)) return 0;
6244
6245 GLAD_VK_EXT_debug_report = glad_vk_has_extension("VK_EXT_debug_report", extension_count, extensions);
6246 GLAD_VK_KHR_portability_enumeration = glad_vk_has_extension("VK_KHR_portability_enumeration", extension_count, extensions);
6247 GLAD_VK_KHR_surface = glad_vk_has_extension("VK_KHR_surface", extension_count, extensions);
6248 GLAD_VK_KHR_swapchain = glad_vk_has_extension("VK_KHR_swapchain", extension_count, extensions);
6249
6250 (void) glad_vk_has_extension;
6251
6252 glad_vk_free_extensions(extension_count, extensions);
6253
6254 return 1;
6255}
6256
6257static int glad_vk_find_core_vulkan( VkPhysicalDevice physical_device) {
6258 int major = 1;
6259 int minor = 0;
6260
6261#ifdef VK_VERSION_1_1
6262 if (glad_vkEnumerateInstanceVersion != NULL) {
6263 uint32_t version;
6264 VkResult result;
6265
6266 result = glad_vkEnumerateInstanceVersion(&version);
6267 if (result == VK_SUCCESS) {
6268 major = (int) VK_VERSION_MAJOR(version);
6269 minor = (int) VK_VERSION_MINOR(version);
6270 }
6271 }
6272#endif
6273
6274 if (physical_device != NULL && glad_vkGetPhysicalDeviceProperties != NULL) {
6275 VkPhysicalDeviceProperties properties;
6276 glad_vkGetPhysicalDeviceProperties(physical_device, &properties);
6277
6278 major = (int) VK_VERSION_MAJOR(properties.apiVersion);
6279 minor = (int) VK_VERSION_MINOR(properties.apiVersion);
6280 }
6281
6282 GLAD_VK_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
6283 GLAD_VK_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
6284 GLAD_VK_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
6285 GLAD_VK_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
6286
6287 return GLAD_MAKE_VERSION(major, minor);
6288}
6289
6290int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) {
6291 int version;
6292
6293#ifdef VK_VERSION_1_1
6294 glad_vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load(userptr, "vkEnumerateInstanceVersion");
6295#endif
6296 version = glad_vk_find_core_vulkan( physical_device);
6297 if (!version) {
6298 return 0;
6299 }
6300
6301 glad_vk_load_VK_VERSION_1_0(load, userptr);
6302 glad_vk_load_VK_VERSION_1_1(load, userptr);
6303 glad_vk_load_VK_VERSION_1_2(load, userptr);
6304 glad_vk_load_VK_VERSION_1_3(load, userptr);
6305
6306 if (!glad_vk_find_extensions_vulkan( physical_device)) return 0;
6307 glad_vk_load_VK_EXT_debug_report(load, userptr);
6308 glad_vk_load_VK_KHR_surface(load, userptr);
6309 glad_vk_load_VK_KHR_swapchain(load, userptr);
6310
6311
6312 return version;
6313}
6314
6315
6316int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load) {
6317 return gladLoadVulkanUserPtr( physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
6318}
6319
6320
6321
6322
6323
6324
6325#ifdef __cplusplus
6326}
6327#endif
6328
6329#endif /* GLAD_VULKAN_IMPLEMENTATION */
6330
diff --git a/raylib/src/external/glfw/deps/mingw/_mingw_dxhelper.h b/raylib/src/external/glfw/deps/mingw/_mingw_dxhelper.h
new file mode 100644
index 0000000..849e291
--- /dev/null
+++ b/raylib/src/external/glfw/deps/mingw/_mingw_dxhelper.h
@@ -0,0 +1,117 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
5 */
6
7#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
8#define NONAMELESSUNION 1
9#endif
10#if defined(NONAMELESSSTRUCT) && \
11 !defined(NONAMELESSUNION)
12#define NONAMELESSUNION 1
13#endif
14#if defined(NONAMELESSUNION) && \
15 !defined(NONAMELESSSTRUCT)
16#define NONAMELESSSTRUCT 1
17#endif
18#if !defined(__GNU_EXTENSION)
19#if defined(__GNUC__) || defined(__GNUG__)
20#define __GNU_EXTENSION __extension__
21#else
22#define __GNU_EXTENSION
23#endif
24#endif /* __extension__ */
25
26#ifndef __ANONYMOUS_DEFINED
27#define __ANONYMOUS_DEFINED
28#if defined(__GNUC__) || defined(__GNUG__)
29#define _ANONYMOUS_UNION __extension__
30#define _ANONYMOUS_STRUCT __extension__
31#else
32#define _ANONYMOUS_UNION
33#define _ANONYMOUS_STRUCT
34#endif
35#ifndef NONAMELESSUNION
36#define _UNION_NAME(x)
37#define _STRUCT_NAME(x)
38#else /* NONAMELESSUNION */
39#define _UNION_NAME(x) x
40#define _STRUCT_NAME(x) x
41#endif
42#endif /* __ANONYMOUS_DEFINED */
43
44#ifndef DUMMYUNIONNAME
45# ifdef NONAMELESSUNION
46# define DUMMYUNIONNAME u
47# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
48# define DUMMYUNIONNAME2 u2
49# define DUMMYUNIONNAME3 u3
50# define DUMMYUNIONNAME4 u4
51# define DUMMYUNIONNAME5 u5
52# define DUMMYUNIONNAME6 u6
53# define DUMMYUNIONNAME7 u7
54# define DUMMYUNIONNAME8 u8
55# define DUMMYUNIONNAME9 u9
56# else /* NONAMELESSUNION */
57# define DUMMYUNIONNAME
58# define DUMMYUNIONNAME1 /* Wine uses this variant */
59# define DUMMYUNIONNAME2
60# define DUMMYUNIONNAME3
61# define DUMMYUNIONNAME4
62# define DUMMYUNIONNAME5
63# define DUMMYUNIONNAME6
64# define DUMMYUNIONNAME7
65# define DUMMYUNIONNAME8
66# define DUMMYUNIONNAME9
67# endif
68#endif /* DUMMYUNIONNAME */
69
70#if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */
71# ifdef NONAMELESSUNION
72# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
73# else
74# define DUMMYUNIONNAME1 /* Wine uses this variant */
75# endif
76#endif /* DUMMYUNIONNAME1 */
77
78#ifndef DUMMYSTRUCTNAME
79# ifdef NONAMELESSUNION
80# define DUMMYSTRUCTNAME s
81# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */
82# define DUMMYSTRUCTNAME2 s2
83# define DUMMYSTRUCTNAME3 s3
84# define DUMMYSTRUCTNAME4 s4
85# define DUMMYSTRUCTNAME5 s5
86# else
87# define DUMMYSTRUCTNAME
88# define DUMMYSTRUCTNAME1 /* Wine uses this variant */
89# define DUMMYSTRUCTNAME2
90# define DUMMYSTRUCTNAME3
91# define DUMMYSTRUCTNAME4
92# define DUMMYSTRUCTNAME5
93# endif
94#endif /* DUMMYSTRUCTNAME */
95
96/* These are for compatibility with the Wine source tree */
97
98#ifndef WINELIB_NAME_AW
99# ifdef __MINGW_NAME_AW
100# define WINELIB_NAME_AW __MINGW_NAME_AW
101# else
102# ifdef UNICODE
103# define WINELIB_NAME_AW(func) func##W
104# else
105# define WINELIB_NAME_AW(func) func##A
106# endif
107# endif
108#endif /* WINELIB_NAME_AW */
109
110#ifndef DECL_WINELIB_TYPE_AW
111# ifdef __MINGW_TYPEDEF_AW
112# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW
113# else
114# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
115# endif
116#endif /* DECL_WINELIB_TYPE_AW */
117
diff --git a/raylib/src/external/glfw/deps/mingw/dinput.h b/raylib/src/external/glfw/deps/mingw/dinput.h
new file mode 100644
index 0000000..b575480
--- /dev/null
+++ b/raylib/src/external/glfw/deps/mingw/dinput.h
@@ -0,0 +1,2467 @@
1/*
2 * Copyright (C) the Wine project
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#ifndef __DINPUT_INCLUDED__
20#define __DINPUT_INCLUDED__
21
22#define COM_NO_WINDOWS_H
23#include <objbase.h>
24#include <_mingw_dxhelper.h>
25
26#ifndef DIRECTINPUT_VERSION
27#define DIRECTINPUT_VERSION 0x0800
28#endif
29
30/* Classes */
31DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
32DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
33
34DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
35DEFINE_GUID(CLSID_DirectInputDevice8, 0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
36
37/* Interfaces */
38DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
39DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
40DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
41DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
42DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
43DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
44DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
45DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
46DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
47DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
48DEFINE_GUID(IID_IDirectInputDevice2A, 0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
49DEFINE_GUID(IID_IDirectInputDevice2W, 0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
50DEFINE_GUID(IID_IDirectInputDevice7A, 0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
51DEFINE_GUID(IID_IDirectInputDevice7W, 0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
52DEFINE_GUID(IID_IDirectInputDevice8A, 0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
53DEFINE_GUID(IID_IDirectInputDevice8W, 0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
54DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
55
56/* Predefined object types */
57DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
58DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
59DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
60DEFINE_GUID(GUID_RxAxis,0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
61DEFINE_GUID(GUID_RyAxis,0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
62DEFINE_GUID(GUID_RzAxis,0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
63DEFINE_GUID(GUID_Slider,0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
64DEFINE_GUID(GUID_Button,0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
65DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
66DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
67DEFINE_GUID(GUID_Unknown,0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
68
69/* Predefined product GUIDs */
70DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
71DEFINE_GUID(GUID_SysKeyboard, 0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
72DEFINE_GUID(GUID_Joystick, 0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
73DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
74DEFINE_GUID(GUID_SysMouseEm2, 0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
75DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
76DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
77
78/* predefined forcefeedback effects */
79DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
80DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
81DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
82DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
83DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
84DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
85DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
86DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
87DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
88DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
89DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
90DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
91
92typedef struct IDirectInputA *LPDIRECTINPUTA;
93typedef struct IDirectInputW *LPDIRECTINPUTW;
94typedef struct IDirectInput2A *LPDIRECTINPUT2A;
95typedef struct IDirectInput2W *LPDIRECTINPUT2W;
96typedef struct IDirectInput7A *LPDIRECTINPUT7A;
97typedef struct IDirectInput7W *LPDIRECTINPUT7W;
98#if DIRECTINPUT_VERSION >= 0x0800
99typedef struct IDirectInput8A *LPDIRECTINPUT8A;
100typedef struct IDirectInput8W *LPDIRECTINPUT8W;
101#endif /* DI8 */
102typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA;
103typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW;
104#if DIRECTINPUT_VERSION >= 0x0500
105typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A;
106typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W;
107#endif /* DI5 */
108#if DIRECTINPUT_VERSION >= 0x0700
109typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A;
110typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W;
111#endif /* DI7 */
112#if DIRECTINPUT_VERSION >= 0x0800
113typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A;
114typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W;
115#endif /* DI8 */
116#if DIRECTINPUT_VERSION >= 0x0500
117typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT;
118#endif /* DI5 */
119typedef struct SysKeyboardA *LPSYSKEYBOARDA;
120typedef struct SysMouseA *LPSYSMOUSEA;
121
122#define IID_IDirectInput WINELIB_NAME_AW(IID_IDirectInput)
123#define IDirectInput WINELIB_NAME_AW(IDirectInput)
124DECL_WINELIB_TYPE_AW(LPDIRECTINPUT)
125#define IID_IDirectInput2 WINELIB_NAME_AW(IID_IDirectInput2)
126#define IDirectInput2 WINELIB_NAME_AW(IDirectInput2)
127DECL_WINELIB_TYPE_AW(LPDIRECTINPUT2)
128#define IID_IDirectInput7 WINELIB_NAME_AW(IID_IDirectInput7)
129#define IDirectInput7 WINELIB_NAME_AW(IDirectInput7)
130DECL_WINELIB_TYPE_AW(LPDIRECTINPUT7)
131#if DIRECTINPUT_VERSION >= 0x0800
132#define IID_IDirectInput8 WINELIB_NAME_AW(IID_IDirectInput8)
133#define IDirectInput8 WINELIB_NAME_AW(IDirectInput8)
134DECL_WINELIB_TYPE_AW(LPDIRECTINPUT8)
135#endif /* DI8 */
136#define IID_IDirectInputDevice WINELIB_NAME_AW(IID_IDirectInputDevice)
137#define IDirectInputDevice WINELIB_NAME_AW(IDirectInputDevice)
138DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE)
139#if DIRECTINPUT_VERSION >= 0x0500
140#define IID_IDirectInputDevice2 WINELIB_NAME_AW(IID_IDirectInputDevice2)
141#define IDirectInputDevice2 WINELIB_NAME_AW(IDirectInputDevice2)
142DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE2)
143#endif /* DI5 */
144#if DIRECTINPUT_VERSION >= 0x0700
145#define IID_IDirectInputDevice7 WINELIB_NAME_AW(IID_IDirectInputDevice7)
146#define IDirectInputDevice7 WINELIB_NAME_AW(IDirectInputDevice7)
147DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE7)
148#endif /* DI7 */
149#if DIRECTINPUT_VERSION >= 0x0800
150#define IID_IDirectInputDevice8 WINELIB_NAME_AW(IID_IDirectInputDevice8)
151#define IDirectInputDevice8 WINELIB_NAME_AW(IDirectInputDevice8)
152DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE8)
153#endif /* DI8 */
154
155#define DI_OK S_OK
156#define DI_NOTATTACHED S_FALSE
157#define DI_BUFFEROVERFLOW S_FALSE
158#define DI_PROPNOEFFECT S_FALSE
159#define DI_NOEFFECT S_FALSE
160#define DI_POLLEDDEVICE ((HRESULT)0x00000002L)
161#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L)
162#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L)
163#define DI_TRUNCATED ((HRESULT)0x00000008L)
164#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL)
165#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL)
166#define DI_WRITEPROTECT ((HRESULT)0x00000013L)
167
168#define DIERR_OLDDIRECTINPUTVERSION \
169 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION)
170#define DIERR_BETADIRECTINPUTVERSION \
171 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP)
172#define DIERR_BADDRIVERVER \
173 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL)
174#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG
175#define DIERR_NOTFOUND \
176 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
177#define DIERR_OBJECTNOTFOUND \
178 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
179#define DIERR_INVALIDPARAM E_INVALIDARG
180#define DIERR_NOINTERFACE E_NOINTERFACE
181#define DIERR_GENERIC E_FAIL
182#define DIERR_OUTOFMEMORY E_OUTOFMEMORY
183#define DIERR_UNSUPPORTED E_NOTIMPL
184#define DIERR_NOTINITIALIZED \
185 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY)
186#define DIERR_ALREADYINITIALIZED \
187 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED)
188#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION
189#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED
190#define DIERR_INPUTLOST \
191 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT)
192#define DIERR_ACQUIRED \
193 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY)
194#define DIERR_NOTACQUIRED \
195 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS)
196#define DIERR_READONLY E_ACCESSDENIED
197#define DIERR_HANDLEEXISTS E_ACCESSDENIED
198#ifndef E_PENDING
199#define E_PENDING 0x8000000AL
200#endif
201#define DIERR_INSUFFICIENTPRIVS 0x80040200L
202#define DIERR_DEVICEFULL 0x80040201L
203#define DIERR_MOREDATA 0x80040202L
204#define DIERR_NOTDOWNLOADED 0x80040203L
205#define DIERR_HASEFFECTS 0x80040204L
206#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L
207#define DIERR_INCOMPLETEEFFECT 0x80040206L
208#define DIERR_NOTBUFFERED 0x80040207L
209#define DIERR_EFFECTPLAYING 0x80040208L
210#define DIERR_UNPLUGGED 0x80040209L
211#define DIERR_REPORTFULL 0x8004020AL
212#define DIERR_MAPFILEFAIL 0x8004020BL
213
214#define DIENUM_STOP 0
215#define DIENUM_CONTINUE 1
216
217#define DIEDFL_ALLDEVICES 0x00000000
218#define DIEDFL_ATTACHEDONLY 0x00000001
219#define DIEDFL_FORCEFEEDBACK 0x00000100
220#define DIEDFL_INCLUDEALIASES 0x00010000
221#define DIEDFL_INCLUDEPHANTOMS 0x00020000
222#define DIEDFL_INCLUDEHIDDEN 0x00040000
223
224#define DIDEVTYPE_DEVICE 1
225#define DIDEVTYPE_MOUSE 2
226#define DIDEVTYPE_KEYBOARD 3
227#define DIDEVTYPE_JOYSTICK 4
228#define DIDEVTYPE_HID 0x00010000
229
230#define DI8DEVCLASS_ALL 0
231#define DI8DEVCLASS_DEVICE 1
232#define DI8DEVCLASS_POINTER 2
233#define DI8DEVCLASS_KEYBOARD 3
234#define DI8DEVCLASS_GAMECTRL 4
235
236#define DI8DEVTYPE_DEVICE 0x11
237#define DI8DEVTYPE_MOUSE 0x12
238#define DI8DEVTYPE_KEYBOARD 0x13
239#define DI8DEVTYPE_JOYSTICK 0x14
240#define DI8DEVTYPE_GAMEPAD 0x15
241#define DI8DEVTYPE_DRIVING 0x16
242#define DI8DEVTYPE_FLIGHT 0x17
243#define DI8DEVTYPE_1STPERSON 0x18
244#define DI8DEVTYPE_DEVICECTRL 0x19
245#define DI8DEVTYPE_SCREENPOINTER 0x1A
246#define DI8DEVTYPE_REMOTE 0x1B
247#define DI8DEVTYPE_SUPPLEMENTAL 0x1C
248
249#define DIDEVTYPEMOUSE_UNKNOWN 1
250#define DIDEVTYPEMOUSE_TRADITIONAL 2
251#define DIDEVTYPEMOUSE_FINGERSTICK 3
252#define DIDEVTYPEMOUSE_TOUCHPAD 4
253#define DIDEVTYPEMOUSE_TRACKBALL 5
254
255#define DIDEVTYPEKEYBOARD_UNKNOWN 0
256#define DIDEVTYPEKEYBOARD_PCXT 1
257#define DIDEVTYPEKEYBOARD_OLIVETTI 2
258#define DIDEVTYPEKEYBOARD_PCAT 3
259#define DIDEVTYPEKEYBOARD_PCENH 4
260#define DIDEVTYPEKEYBOARD_NOKIA1050 5
261#define DIDEVTYPEKEYBOARD_NOKIA9140 6
262#define DIDEVTYPEKEYBOARD_NEC98 7
263#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8
264#define DIDEVTYPEKEYBOARD_NEC98106 9
265#define DIDEVTYPEKEYBOARD_JAPAN106 10
266#define DIDEVTYPEKEYBOARD_JAPANAX 11
267#define DIDEVTYPEKEYBOARD_J3100 12
268
269#define DIDEVTYPEJOYSTICK_UNKNOWN 1
270#define DIDEVTYPEJOYSTICK_TRADITIONAL 2
271#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3
272#define DIDEVTYPEJOYSTICK_GAMEPAD 4
273#define DIDEVTYPEJOYSTICK_RUDDER 5
274#define DIDEVTYPEJOYSTICK_WHEEL 6
275#define DIDEVTYPEJOYSTICK_HEADTRACKER 7
276
277#define DI8DEVTYPEMOUSE_UNKNOWN 1
278#define DI8DEVTYPEMOUSE_TRADITIONAL 2
279#define DI8DEVTYPEMOUSE_FINGERSTICK 3
280#define DI8DEVTYPEMOUSE_TOUCHPAD 4
281#define DI8DEVTYPEMOUSE_TRACKBALL 5
282#define DI8DEVTYPEMOUSE_ABSOLUTE 6
283
284#define DI8DEVTYPEKEYBOARD_UNKNOWN 0
285#define DI8DEVTYPEKEYBOARD_PCXT 1
286#define DI8DEVTYPEKEYBOARD_OLIVETTI 2
287#define DI8DEVTYPEKEYBOARD_PCAT 3
288#define DI8DEVTYPEKEYBOARD_PCENH 4
289#define DI8DEVTYPEKEYBOARD_NOKIA1050 5
290#define DI8DEVTYPEKEYBOARD_NOKIA9140 6
291#define DI8DEVTYPEKEYBOARD_NEC98 7
292#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8
293#define DI8DEVTYPEKEYBOARD_NEC98106 9
294#define DI8DEVTYPEKEYBOARD_JAPAN106 10
295#define DI8DEVTYPEKEYBOARD_JAPANAX 11
296#define DI8DEVTYPEKEYBOARD_J3100 12
297
298#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1
299
300#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
301#define DI8DEVTYPEJOYSTICK_STANDARD 2
302
303#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
304#define DI8DEVTYPEGAMEPAD_STANDARD 2
305#define DI8DEVTYPEGAMEPAD_TILT 3
306
307#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
308#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2
309#define DI8DEVTYPEDRIVING_DUALPEDALS 3
310#define DI8DEVTYPEDRIVING_THREEPEDALS 4
311#define DI8DEVTYPEDRIVING_HANDHELD 5
312
313#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
314#define DI8DEVTYPEFLIGHT_STICK 2
315#define DI8DEVTYPEFLIGHT_YOKE 3
316#define DI8DEVTYPEFLIGHT_RC 4
317
318#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
319#define DI8DEVTYPE1STPERSON_UNKNOWN 2
320#define DI8DEVTYPE1STPERSON_SIXDOF 3
321#define DI8DEVTYPE1STPERSON_SHOOTER 4
322
323#define DI8DEVTYPESCREENPTR_UNKNOWN 2
324#define DI8DEVTYPESCREENPTR_LIGHTGUN 3
325#define DI8DEVTYPESCREENPTR_LIGHTPEN 4
326#define DI8DEVTYPESCREENPTR_TOUCH 5
327
328#define DI8DEVTYPEREMOTE_UNKNOWN 2
329
330#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2
331#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3
332#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4
333
334#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2
335#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3
336#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4
337#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5
338#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6
339#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7
340#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8
341#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9
342#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10
343#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11
344#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12
345#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13
346
347#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType)
348#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType)
349
350typedef struct DIDEVICEOBJECTINSTANCE_DX3A {
351 DWORD dwSize;
352 GUID guidType;
353 DWORD dwOfs;
354 DWORD dwType;
355 DWORD dwFlags;
356 CHAR tszName[MAX_PATH];
357} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A;
358typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A;
359typedef struct DIDEVICEOBJECTINSTANCE_DX3W {
360 DWORD dwSize;
361 GUID guidType;
362 DWORD dwOfs;
363 DWORD dwType;
364 DWORD dwFlags;
365 WCHAR tszName[MAX_PATH];
366} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W;
367typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W;
368
369DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE_DX3)
370DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE_DX3)
371DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE_DX3)
372
373typedef struct DIDEVICEOBJECTINSTANCEA {
374 DWORD dwSize;
375 GUID guidType;
376 DWORD dwOfs;
377 DWORD dwType;
378 DWORD dwFlags;
379 CHAR tszName[MAX_PATH];
380#if(DIRECTINPUT_VERSION >= 0x0500)
381 DWORD dwFFMaxForce;
382 DWORD dwFFForceResolution;
383 WORD wCollectionNumber;
384 WORD wDesignatorIndex;
385 WORD wUsagePage;
386 WORD wUsage;
387 DWORD dwDimension;
388 WORD wExponent;
389 WORD wReserved;
390#endif /* DIRECTINPUT_VERSION >= 0x0500 */
391} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA;
392typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA;
393
394typedef struct DIDEVICEOBJECTINSTANCEW {
395 DWORD dwSize;
396 GUID guidType;
397 DWORD dwOfs;
398 DWORD dwType;
399 DWORD dwFlags;
400 WCHAR tszName[MAX_PATH];
401#if(DIRECTINPUT_VERSION >= 0x0500)
402 DWORD dwFFMaxForce;
403 DWORD dwFFForceResolution;
404 WORD wCollectionNumber;
405 WORD wDesignatorIndex;
406 WORD wUsagePage;
407 WORD wUsage;
408 DWORD dwDimension;
409 WORD wExponent;
410 WORD wReserved;
411#endif /* DIRECTINPUT_VERSION >= 0x0500 */
412} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW;
413typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW;
414
415DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE)
416DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE)
417DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE)
418
419typedef struct DIDEVICEINSTANCE_DX3A {
420 DWORD dwSize;
421 GUID guidInstance;
422 GUID guidProduct;
423 DWORD dwDevType;
424 CHAR tszInstanceName[MAX_PATH];
425 CHAR tszProductName[MAX_PATH];
426} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A;
427typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A;
428typedef struct DIDEVICEINSTANCE_DX3W {
429 DWORD dwSize;
430 GUID guidInstance;
431 GUID guidProduct;
432 DWORD dwDevType;
433 WCHAR tszInstanceName[MAX_PATH];
434 WCHAR tszProductName[MAX_PATH];
435} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W;
436typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W;
437
438DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE_DX3)
439DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE_DX3)
440DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE_DX3)
441
442typedef struct DIDEVICEINSTANCEA {
443 DWORD dwSize;
444 GUID guidInstance;
445 GUID guidProduct;
446 DWORD dwDevType;
447 CHAR tszInstanceName[MAX_PATH];
448 CHAR tszProductName[MAX_PATH];
449#if(DIRECTINPUT_VERSION >= 0x0500)
450 GUID guidFFDriver;
451 WORD wUsagePage;
452 WORD wUsage;
453#endif /* DIRECTINPUT_VERSION >= 0x0500 */
454} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA;
455typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA;
456
457typedef struct DIDEVICEINSTANCEW {
458 DWORD dwSize;
459 GUID guidInstance;
460 GUID guidProduct;
461 DWORD dwDevType;
462 WCHAR tszInstanceName[MAX_PATH];
463 WCHAR tszProductName[MAX_PATH];
464#if(DIRECTINPUT_VERSION >= 0x0500)
465 GUID guidFFDriver;
466 WORD wUsagePage;
467 WORD wUsage;
468#endif /* DIRECTINPUT_VERSION >= 0x0500 */
469} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW;
470typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW;
471
472DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE)
473DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE)
474DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE)
475
476typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID);
477typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID);
478DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK)
479
480#define DIEDBS_MAPPEDPRI1 0x00000001
481#define DIEDBS_MAPPEDPRI2 0x00000002
482#define DIEDBS_RECENTDEVICE 0x00000010
483#define DIEDBS_NEWDEVICE 0x00000020
484
485#define DIEDBSFL_ATTACHEDONLY 0x00000000
486#define DIEDBSFL_THISUSER 0x00000010
487#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK
488#define DIEDBSFL_AVAILABLEDEVICES 0x00001000
489#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000
490#define DIEDBSFL_NONGAMINGDEVICES 0x00004000
491#define DIEDBSFL_VALID 0x00007110
492
493#if DIRECTINPUT_VERSION >= 0x0800
494typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA,LPDIRECTINPUTDEVICE8A,DWORD,DWORD,LPVOID);
495typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW,LPDIRECTINPUTDEVICE8W,DWORD,DWORD,LPVOID);
496DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESBYSEMANTICSCB)
497#endif
498
499typedef BOOL (CALLBACK *LPDICONFIGUREDEVICESCALLBACK)(LPUNKNOWN,LPVOID);
500
501typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA,LPVOID);
502typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW,LPVOID);
503DECL_WINELIB_TYPE_AW(LPDIENUMDEVICEOBJECTSCALLBACK)
504
505#if DIRECTINPUT_VERSION >= 0x0500
506typedef BOOL (CALLBACK *LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID);
507#endif
508
509#define DIK_ESCAPE 0x01
510#define DIK_1 0x02
511#define DIK_2 0x03
512#define DIK_3 0x04
513#define DIK_4 0x05
514#define DIK_5 0x06
515#define DIK_6 0x07
516#define DIK_7 0x08
517#define DIK_8 0x09
518#define DIK_9 0x0A
519#define DIK_0 0x0B
520#define DIK_MINUS 0x0C /* - on main keyboard */
521#define DIK_EQUALS 0x0D
522#define DIK_BACK 0x0E /* backspace */
523#define DIK_TAB 0x0F
524#define DIK_Q 0x10
525#define DIK_W 0x11
526#define DIK_E 0x12
527#define DIK_R 0x13
528#define DIK_T 0x14
529#define DIK_Y 0x15
530#define DIK_U 0x16
531#define DIK_I 0x17
532#define DIK_O 0x18
533#define DIK_P 0x19
534#define DIK_LBRACKET 0x1A
535#define DIK_RBRACKET 0x1B
536#define DIK_RETURN 0x1C /* Enter on main keyboard */
537#define DIK_LCONTROL 0x1D
538#define DIK_A 0x1E
539#define DIK_S 0x1F
540#define DIK_D 0x20
541#define DIK_F 0x21
542#define DIK_G 0x22
543#define DIK_H 0x23
544#define DIK_J 0x24
545#define DIK_K 0x25
546#define DIK_L 0x26
547#define DIK_SEMICOLON 0x27
548#define DIK_APOSTROPHE 0x28
549#define DIK_GRAVE 0x29 /* accent grave */
550#define DIK_LSHIFT 0x2A
551#define DIK_BACKSLASH 0x2B
552#define DIK_Z 0x2C
553#define DIK_X 0x2D
554#define DIK_C 0x2E
555#define DIK_V 0x2F
556#define DIK_B 0x30
557#define DIK_N 0x31
558#define DIK_M 0x32
559#define DIK_COMMA 0x33
560#define DIK_PERIOD 0x34 /* . on main keyboard */
561#define DIK_SLASH 0x35 /* / on main keyboard */
562#define DIK_RSHIFT 0x36
563#define DIK_MULTIPLY 0x37 /* * on numeric keypad */
564#define DIK_LMENU 0x38 /* left Alt */
565#define DIK_SPACE 0x39
566#define DIK_CAPITAL 0x3A
567#define DIK_F1 0x3B
568#define DIK_F2 0x3C
569#define DIK_F3 0x3D
570#define DIK_F4 0x3E
571#define DIK_F5 0x3F
572#define DIK_F6 0x40
573#define DIK_F7 0x41
574#define DIK_F8 0x42
575#define DIK_F9 0x43
576#define DIK_F10 0x44
577#define DIK_NUMLOCK 0x45
578#define DIK_SCROLL 0x46 /* Scroll Lock */
579#define DIK_NUMPAD7 0x47
580#define DIK_NUMPAD8 0x48
581#define DIK_NUMPAD9 0x49
582#define DIK_SUBTRACT 0x4A /* - on numeric keypad */
583#define DIK_NUMPAD4 0x4B
584#define DIK_NUMPAD5 0x4C
585#define DIK_NUMPAD6 0x4D
586#define DIK_ADD 0x4E /* + on numeric keypad */
587#define DIK_NUMPAD1 0x4F
588#define DIK_NUMPAD2 0x50
589#define DIK_NUMPAD3 0x51
590#define DIK_NUMPAD0 0x52
591#define DIK_DECIMAL 0x53 /* . on numeric keypad */
592#define DIK_OEM_102 0x56 /* < > | on UK/Germany keyboards */
593#define DIK_F11 0x57
594#define DIK_F12 0x58
595#define DIK_F13 0x64 /* (NEC PC98) */
596#define DIK_F14 0x65 /* (NEC PC98) */
597#define DIK_F15 0x66 /* (NEC PC98) */
598#define DIK_KANA 0x70 /* (Japanese keyboard) */
599#define DIK_ABNT_C1 0x73 /* / ? on Portugese (Brazilian) keyboards */
600#define DIK_CONVERT 0x79 /* (Japanese keyboard) */
601#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */
602#define DIK_YEN 0x7D /* (Japanese keyboard) */
603#define DIK_ABNT_C2 0x7E /* Numpad . on Portugese (Brazilian) keyboards */
604#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */
605#define DIK_CIRCUMFLEX 0x90 /* (Japanese keyboard) */
606#define DIK_AT 0x91 /* (NEC PC98) */
607#define DIK_COLON 0x92 /* (NEC PC98) */
608#define DIK_UNDERLINE 0x93 /* (NEC PC98) */
609#define DIK_KANJI 0x94 /* (Japanese keyboard) */
610#define DIK_STOP 0x95 /* (NEC PC98) */
611#define DIK_AX 0x96 /* (Japan AX) */
612#define DIK_UNLABELED 0x97 /* (J3100) */
613#define DIK_NEXTTRACK 0x99 /* Next Track */
614#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */
615#define DIK_RCONTROL 0x9D
616#define DIK_MUTE 0xA0 /* Mute */
617#define DIK_CALCULATOR 0xA1 /* Calculator */
618#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */
619#define DIK_MEDIASTOP 0xA4 /* Media Stop */
620#define DIK_VOLUMEDOWN 0xAE /* Volume - */
621#define DIK_VOLUMEUP 0xB0 /* Volume + */
622#define DIK_WEBHOME 0xB2 /* Web home */
623#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */
624#define DIK_DIVIDE 0xB5 /* / on numeric keypad */
625#define DIK_SYSRQ 0xB7
626#define DIK_RMENU 0xB8 /* right Alt */
627#define DIK_PAUSE 0xC5 /* Pause */
628#define DIK_HOME 0xC7 /* Home on arrow keypad */
629#define DIK_UP 0xC8 /* UpArrow on arrow keypad */
630#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */
631#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */
632#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */
633#define DIK_END 0xCF /* End on arrow keypad */
634#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */
635#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */
636#define DIK_INSERT 0xD2 /* Insert on arrow keypad */
637#define DIK_DELETE 0xD3 /* Delete on arrow keypad */
638#define DIK_LWIN 0xDB /* Left Windows key */
639#define DIK_RWIN 0xDC /* Right Windows key */
640#define DIK_APPS 0xDD /* AppMenu key */
641#define DIK_POWER 0xDE
642#define DIK_SLEEP 0xDF
643#define DIK_WAKE 0xE3 /* System Wake */
644#define DIK_WEBSEARCH 0xE5 /* Web Search */
645#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */
646#define DIK_WEBREFRESH 0xE7 /* Web Refresh */
647#define DIK_WEBSTOP 0xE8 /* Web Stop */
648#define DIK_WEBFORWARD 0xE9 /* Web Forward */
649#define DIK_WEBBACK 0xEA /* Web Back */
650#define DIK_MYCOMPUTER 0xEB /* My Computer */
651#define DIK_MAIL 0xEC /* Mail */
652#define DIK_MEDIASELECT 0xED /* Media Select */
653
654#define DIK_BACKSPACE DIK_BACK /* backspace */
655#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */
656#define DIK_LALT DIK_LMENU /* left Alt */
657#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */
658#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */
659#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */
660#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */
661#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */
662#define DIK_RALT DIK_RMENU /* right Alt */
663#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */
664#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */
665#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */
666#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */
667#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */
668#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */
669
670#define DIDFT_ALL 0x00000000
671#define DIDFT_RELAXIS 0x00000001
672#define DIDFT_ABSAXIS 0x00000002
673#define DIDFT_AXIS 0x00000003
674#define DIDFT_PSHBUTTON 0x00000004
675#define DIDFT_TGLBUTTON 0x00000008
676#define DIDFT_BUTTON 0x0000000C
677#define DIDFT_POV 0x00000010
678#define DIDFT_COLLECTION 0x00000040
679#define DIDFT_NODATA 0x00000080
680#define DIDFT_ANYINSTANCE 0x00FFFF00
681#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE
682#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8)
683#define DIDFT_GETTYPE(n) LOBYTE(n)
684#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8)
685#define DIDFT_FFACTUATOR 0x01000000
686#define DIDFT_FFEFFECTTRIGGER 0x02000000
687#if DIRECTINPUT_VERSION >= 0x050a
688#define DIDFT_OUTPUT 0x10000000
689#define DIDFT_VENDORDEFINED 0x04000000
690#define DIDFT_ALIAS 0x08000000
691#endif /* DI5a */
692#ifndef DIDFT_OPTIONAL
693#define DIDFT_OPTIONAL 0x80000000
694#endif
695#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8)
696#define DIDFT_NOCOLLECTION 0x00FFFF00
697
698#define DIDF_ABSAXIS 0x00000001
699#define DIDF_RELAXIS 0x00000002
700
701#define DIGDD_PEEK 0x00000001
702
703#define DISEQUENCE_COMPARE(dwSq1,cmp,dwSq2) ((int)((dwSq1) - (dwSq2)) cmp 0)
704
705typedef struct DIDEVICEOBJECTDATA_DX3 {
706 DWORD dwOfs;
707 DWORD dwData;
708 DWORD dwTimeStamp;
709 DWORD dwSequence;
710} DIDEVICEOBJECTDATA_DX3,*LPDIDEVICEOBJECTDATA_DX3;
711typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX3;
712
713typedef struct DIDEVICEOBJECTDATA {
714 DWORD dwOfs;
715 DWORD dwData;
716 DWORD dwTimeStamp;
717 DWORD dwSequence;
718#if(DIRECTINPUT_VERSION >= 0x0800)
719 UINT_PTR uAppData;
720#endif /* DIRECTINPUT_VERSION >= 0x0800 */
721} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA;
722typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA;
723
724typedef struct _DIOBJECTDATAFORMAT {
725 const GUID *pguid;
726 DWORD dwOfs;
727 DWORD dwType;
728 DWORD dwFlags;
729} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT;
730typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT;
731
732typedef struct _DIDATAFORMAT {
733 DWORD dwSize;
734 DWORD dwObjSize;
735 DWORD dwFlags;
736 DWORD dwDataSize;
737 DWORD dwNumObjs;
738 LPDIOBJECTDATAFORMAT rgodf;
739} DIDATAFORMAT, *LPDIDATAFORMAT;
740typedef const DIDATAFORMAT *LPCDIDATAFORMAT;
741
742#if DIRECTINPUT_VERSION >= 0x0500
743#define DIDOI_FFACTUATOR 0x00000001
744#define DIDOI_FFEFFECTTRIGGER 0x00000002
745#define DIDOI_POLLED 0x00008000
746#define DIDOI_ASPECTPOSITION 0x00000100
747#define DIDOI_ASPECTVELOCITY 0x00000200
748#define DIDOI_ASPECTACCEL 0x00000300
749#define DIDOI_ASPECTFORCE 0x00000400
750#define DIDOI_ASPECTMASK 0x00000F00
751#endif /* DI5 */
752#if DIRECTINPUT_VERSION >= 0x050a
753#define DIDOI_GUIDISUSAGE 0x00010000
754#endif /* DI5a */
755
756typedef struct DIPROPHEADER {
757 DWORD dwSize;
758 DWORD dwHeaderSize;
759 DWORD dwObj;
760 DWORD dwHow;
761} DIPROPHEADER,*LPDIPROPHEADER;
762typedef const DIPROPHEADER *LPCDIPROPHEADER;
763
764#define DIPH_DEVICE 0
765#define DIPH_BYOFFSET 1
766#define DIPH_BYID 2
767#if DIRECTINPUT_VERSION >= 0x050a
768#define DIPH_BYUSAGE 3
769
770#define DIMAKEUSAGEDWORD(UsagePage, Usage) (DWORD)MAKELONG(Usage, UsagePage)
771#endif /* DI5a */
772
773typedef struct DIPROPDWORD {
774 DIPROPHEADER diph;
775 DWORD dwData;
776} DIPROPDWORD, *LPDIPROPDWORD;
777typedef const DIPROPDWORD *LPCDIPROPDWORD;
778
779typedef struct DIPROPRANGE {
780 DIPROPHEADER diph;
781 LONG lMin;
782 LONG lMax;
783} DIPROPRANGE, *LPDIPROPRANGE;
784typedef const DIPROPRANGE *LPCDIPROPRANGE;
785
786#define DIPROPRANGE_NOMIN ((LONG)0x80000000)
787#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF)
788
789#if DIRECTINPUT_VERSION >= 0x050a
790typedef struct DIPROPCAL {
791 DIPROPHEADER diph;
792 LONG lMin;
793 LONG lCenter;
794 LONG lMax;
795} DIPROPCAL, *LPDIPROPCAL;
796typedef const DIPROPCAL *LPCDIPROPCAL;
797
798typedef struct DIPROPCALPOV {
799 DIPROPHEADER diph;
800 LONG lMin[5];
801 LONG lMax[5];
802} DIPROPCALPOV, *LPDIPROPCALPOV;
803typedef const DIPROPCALPOV *LPCDIPROPCALPOV;
804
805typedef struct DIPROPGUIDANDPATH {
806 DIPROPHEADER diph;
807 GUID guidClass;
808 WCHAR wszPath[MAX_PATH];
809} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH;
810typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH;
811
812typedef struct DIPROPSTRING {
813 DIPROPHEADER diph;
814 WCHAR wsz[MAX_PATH];
815} DIPROPSTRING, *LPDIPROPSTRING;
816typedef const DIPROPSTRING *LPCDIPROPSTRING;
817#endif /* DI5a */
818
819#if DIRECTINPUT_VERSION >= 0x0800
820typedef struct DIPROPPOINTER {
821 DIPROPHEADER diph;
822 UINT_PTR uData;
823} DIPROPPOINTER, *LPDIPROPPOINTER;
824typedef const DIPROPPOINTER *LPCDIPROPPOINTER;
825#endif /* DI8 */
826
827/* special property GUIDs */
828#ifdef __cplusplus
829#define MAKEDIPROP(prop) (*(const GUID *)(prop))
830#else
831#define MAKEDIPROP(prop) ((REFGUID)(prop))
832#endif
833#define DIPROP_BUFFERSIZE MAKEDIPROP(1)
834#define DIPROP_AXISMODE MAKEDIPROP(2)
835
836#define DIPROPAXISMODE_ABS 0
837#define DIPROPAXISMODE_REL 1
838
839#define DIPROP_GRANULARITY MAKEDIPROP(3)
840#define DIPROP_RANGE MAKEDIPROP(4)
841#define DIPROP_DEADZONE MAKEDIPROP(5)
842#define DIPROP_SATURATION MAKEDIPROP(6)
843#define DIPROP_FFGAIN MAKEDIPROP(7)
844#define DIPROP_FFLOAD MAKEDIPROP(8)
845#define DIPROP_AUTOCENTER MAKEDIPROP(9)
846
847#define DIPROPAUTOCENTER_OFF 0
848#define DIPROPAUTOCENTER_ON 1
849
850#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10)
851
852#define DIPROPCALIBRATIONMODE_COOKED 0
853#define DIPROPCALIBRATIONMODE_RAW 1
854
855#if DIRECTINPUT_VERSION >= 0x050a
856#define DIPROP_CALIBRATION MAKEDIPROP(11)
857#define DIPROP_GUIDANDPATH MAKEDIPROP(12)
858#define DIPROP_INSTANCENAME MAKEDIPROP(13)
859#define DIPROP_PRODUCTNAME MAKEDIPROP(14)
860#endif
861
862#if DIRECTINPUT_VERSION >= 0x5B2
863#define DIPROP_JOYSTICKID MAKEDIPROP(15)
864#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16)
865#endif
866
867#if DIRECTINPUT_VERSION >= 0x0700
868#define DIPROP_PHYSICALRANGE MAKEDIPROP(18)
869#define DIPROP_LOGICALRANGE MAKEDIPROP(19)
870#endif
871
872#if(DIRECTINPUT_VERSION >= 0x0800)
873#define DIPROP_KEYNAME MAKEDIPROP(20)
874#define DIPROP_CPOINTS MAKEDIPROP(21)
875#define DIPROP_APPDATA MAKEDIPROP(22)
876#define DIPROP_SCANCODE MAKEDIPROP(23)
877#define DIPROP_VIDPID MAKEDIPROP(24)
878#define DIPROP_USERNAME MAKEDIPROP(25)
879#define DIPROP_TYPENAME MAKEDIPROP(26)
880
881#define MAXCPOINTSNUM 8
882
883typedef struct _CPOINT {
884 LONG lP;
885 DWORD dwLog;
886} CPOINT, *PCPOINT;
887
888typedef struct DIPROPCPOINTS {
889 DIPROPHEADER diph;
890 DWORD dwCPointsNum;
891 CPOINT cp[MAXCPOINTSNUM];
892} DIPROPCPOINTS, *LPDIPROPCPOINTS;
893typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS;
894#endif /* DI8 */
895
896
897typedef struct DIDEVCAPS_DX3 {
898 DWORD dwSize;
899 DWORD dwFlags;
900 DWORD dwDevType;
901 DWORD dwAxes;
902 DWORD dwButtons;
903 DWORD dwPOVs;
904} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3;
905
906typedef struct DIDEVCAPS {
907 DWORD dwSize;
908 DWORD dwFlags;
909 DWORD dwDevType;
910 DWORD dwAxes;
911 DWORD dwButtons;
912 DWORD dwPOVs;
913#if(DIRECTINPUT_VERSION >= 0x0500)
914 DWORD dwFFSamplePeriod;
915 DWORD dwFFMinTimeResolution;
916 DWORD dwFirmwareRevision;
917 DWORD dwHardwareRevision;
918 DWORD dwFFDriverVersion;
919#endif /* DIRECTINPUT_VERSION >= 0x0500 */
920} DIDEVCAPS,*LPDIDEVCAPS;
921
922#define DIDC_ATTACHED 0x00000001
923#define DIDC_POLLEDDEVICE 0x00000002
924#define DIDC_EMULATED 0x00000004
925#define DIDC_POLLEDDATAFORMAT 0x00000008
926#define DIDC_FORCEFEEDBACK 0x00000100
927#define DIDC_FFATTACK 0x00000200
928#define DIDC_FFFADE 0x00000400
929#define DIDC_SATURATION 0x00000800
930#define DIDC_POSNEGCOEFFICIENTS 0x00001000
931#define DIDC_POSNEGSATURATION 0x00002000
932#define DIDC_DEADBAND 0x00004000
933#define DIDC_STARTDELAY 0x00008000
934#define DIDC_ALIAS 0x00010000
935#define DIDC_PHANTOM 0x00020000
936#define DIDC_HIDDEN 0x00040000
937
938
939/* SetCooperativeLevel dwFlags */
940#define DISCL_EXCLUSIVE 0x00000001
941#define DISCL_NONEXCLUSIVE 0x00000002
942#define DISCL_FOREGROUND 0x00000004
943#define DISCL_BACKGROUND 0x00000008
944#define DISCL_NOWINKEY 0x00000010
945
946#if (DIRECTINPUT_VERSION >= 0x0500)
947/* Device FF flags */
948#define DISFFC_RESET 0x00000001
949#define DISFFC_STOPALL 0x00000002
950#define DISFFC_PAUSE 0x00000004
951#define DISFFC_CONTINUE 0x00000008
952#define DISFFC_SETACTUATORSON 0x00000010
953#define DISFFC_SETACTUATORSOFF 0x00000020
954
955#define DIGFFS_EMPTY 0x00000001
956#define DIGFFS_STOPPED 0x00000002
957#define DIGFFS_PAUSED 0x00000004
958#define DIGFFS_ACTUATORSON 0x00000010
959#define DIGFFS_ACTUATORSOFF 0x00000020
960#define DIGFFS_POWERON 0x00000040
961#define DIGFFS_POWEROFF 0x00000080
962#define DIGFFS_SAFETYSWITCHON 0x00000100
963#define DIGFFS_SAFETYSWITCHOFF 0x00000200
964#define DIGFFS_USERFFSWITCHON 0x00000400
965#define DIGFFS_USERFFSWITCHOFF 0x00000800
966#define DIGFFS_DEVICELOST 0x80000000
967
968/* Effect flags */
969#define DIEFT_ALL 0x00000000
970
971#define DIEFT_CONSTANTFORCE 0x00000001
972#define DIEFT_RAMPFORCE 0x00000002
973#define DIEFT_PERIODIC 0x00000003
974#define DIEFT_CONDITION 0x00000004
975#define DIEFT_CUSTOMFORCE 0x00000005
976#define DIEFT_HARDWARE 0x000000FF
977#define DIEFT_FFATTACK 0x00000200
978#define DIEFT_FFFADE 0x00000400
979#define DIEFT_SATURATION 0x00000800
980#define DIEFT_POSNEGCOEFFICIENTS 0x00001000
981#define DIEFT_POSNEGSATURATION 0x00002000
982#define DIEFT_DEADBAND 0x00004000
983#define DIEFT_STARTDELAY 0x00008000
984#define DIEFT_GETTYPE(n) LOBYTE(n)
985
986#define DIEFF_OBJECTIDS 0x00000001
987#define DIEFF_OBJECTOFFSETS 0x00000002
988#define DIEFF_CARTESIAN 0x00000010
989#define DIEFF_POLAR 0x00000020
990#define DIEFF_SPHERICAL 0x00000040
991
992#define DIEP_DURATION 0x00000001
993#define DIEP_SAMPLEPERIOD 0x00000002
994#define DIEP_GAIN 0x00000004
995#define DIEP_TRIGGERBUTTON 0x00000008
996#define DIEP_TRIGGERREPEATINTERVAL 0x00000010
997#define DIEP_AXES 0x00000020
998#define DIEP_DIRECTION 0x00000040
999#define DIEP_ENVELOPE 0x00000080
1000#define DIEP_TYPESPECIFICPARAMS 0x00000100
1001#if(DIRECTINPUT_VERSION >= 0x0600)
1002#define DIEP_STARTDELAY 0x00000200
1003#define DIEP_ALLPARAMS_DX5 0x000001FF
1004#define DIEP_ALLPARAMS 0x000003FF
1005#else
1006#define DIEP_ALLPARAMS 0x000001FF
1007#endif /* DIRECTINPUT_VERSION >= 0x0600 */
1008#define DIEP_START 0x20000000
1009#define DIEP_NORESTART 0x40000000
1010#define DIEP_NODOWNLOAD 0x80000000
1011#define DIEB_NOTRIGGER 0xFFFFFFFF
1012
1013#define DIES_SOLO 0x00000001
1014#define DIES_NODOWNLOAD 0x80000000
1015
1016#define DIEGES_PLAYING 0x00000001
1017#define DIEGES_EMULATED 0x00000002
1018
1019#define DI_DEGREES 100
1020#define DI_FFNOMINALMAX 10000
1021#define DI_SECONDS 1000000
1022
1023typedef struct DICONSTANTFORCE {
1024 LONG lMagnitude;
1025} DICONSTANTFORCE, *LPDICONSTANTFORCE;
1026typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE;
1027
1028typedef struct DIRAMPFORCE {
1029 LONG lStart;
1030 LONG lEnd;
1031} DIRAMPFORCE, *LPDIRAMPFORCE;
1032typedef const DIRAMPFORCE *LPCDIRAMPFORCE;
1033
1034typedef struct DIPERIODIC {
1035 DWORD dwMagnitude;
1036 LONG lOffset;
1037 DWORD dwPhase;
1038 DWORD dwPeriod;
1039} DIPERIODIC, *LPDIPERIODIC;
1040typedef const DIPERIODIC *LPCDIPERIODIC;
1041
1042typedef struct DICONDITION {
1043 LONG lOffset;
1044 LONG lPositiveCoefficient;
1045 LONG lNegativeCoefficient;
1046 DWORD dwPositiveSaturation;
1047 DWORD dwNegativeSaturation;
1048 LONG lDeadBand;
1049} DICONDITION, *LPDICONDITION;
1050typedef const DICONDITION *LPCDICONDITION;
1051
1052typedef struct DICUSTOMFORCE {
1053 DWORD cChannels;
1054 DWORD dwSamplePeriod;
1055 DWORD cSamples;
1056 LPLONG rglForceData;
1057} DICUSTOMFORCE, *LPDICUSTOMFORCE;
1058typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE;
1059
1060typedef struct DIENVELOPE {
1061 DWORD dwSize;
1062 DWORD dwAttackLevel;
1063 DWORD dwAttackTime;
1064 DWORD dwFadeLevel;
1065 DWORD dwFadeTime;
1066} DIENVELOPE, *LPDIENVELOPE;
1067typedef const DIENVELOPE *LPCDIENVELOPE;
1068
1069typedef struct DIEFFECT_DX5 {
1070 DWORD dwSize;
1071 DWORD dwFlags;
1072 DWORD dwDuration;
1073 DWORD dwSamplePeriod;
1074 DWORD dwGain;
1075 DWORD dwTriggerButton;
1076 DWORD dwTriggerRepeatInterval;
1077 DWORD cAxes;
1078 LPDWORD rgdwAxes;
1079 LPLONG rglDirection;
1080 LPDIENVELOPE lpEnvelope;
1081 DWORD cbTypeSpecificParams;
1082 LPVOID lpvTypeSpecificParams;
1083} DIEFFECT_DX5, *LPDIEFFECT_DX5;
1084typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5;
1085
1086typedef struct DIEFFECT {
1087 DWORD dwSize;
1088 DWORD dwFlags;
1089 DWORD dwDuration;
1090 DWORD dwSamplePeriod;
1091 DWORD dwGain;
1092 DWORD dwTriggerButton;
1093 DWORD dwTriggerRepeatInterval;
1094 DWORD cAxes;
1095 LPDWORD rgdwAxes;
1096 LPLONG rglDirection;
1097 LPDIENVELOPE lpEnvelope;
1098 DWORD cbTypeSpecificParams;
1099 LPVOID lpvTypeSpecificParams;
1100#if(DIRECTINPUT_VERSION >= 0x0600)
1101 DWORD dwStartDelay;
1102#endif /* DIRECTINPUT_VERSION >= 0x0600 */
1103} DIEFFECT, *LPDIEFFECT;
1104typedef const DIEFFECT *LPCDIEFFECT;
1105typedef DIEFFECT DIEFFECT_DX6;
1106typedef LPDIEFFECT LPDIEFFECT_DX6;
1107
1108typedef struct DIEFFECTINFOA {
1109 DWORD dwSize;
1110 GUID guid;
1111 DWORD dwEffType;
1112 DWORD dwStaticParams;
1113 DWORD dwDynamicParams;
1114 CHAR tszName[MAX_PATH];
1115} DIEFFECTINFOA, *LPDIEFFECTINFOA;
1116typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA;
1117
1118typedef struct DIEFFECTINFOW {
1119 DWORD dwSize;
1120 GUID guid;
1121 DWORD dwEffType;
1122 DWORD dwStaticParams;
1123 DWORD dwDynamicParams;
1124 WCHAR tszName[MAX_PATH];
1125} DIEFFECTINFOW, *LPDIEFFECTINFOW;
1126typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW;
1127
1128DECL_WINELIB_TYPE_AW(DIEFFECTINFO)
1129DECL_WINELIB_TYPE_AW(LPDIEFFECTINFO)
1130DECL_WINELIB_TYPE_AW(LPCDIEFFECTINFO)
1131
1132typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID);
1133typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID);
1134
1135typedef struct DIEFFESCAPE {
1136 DWORD dwSize;
1137 DWORD dwCommand;
1138 LPVOID lpvInBuffer;
1139 DWORD cbInBuffer;
1140 LPVOID lpvOutBuffer;
1141 DWORD cbOutBuffer;
1142} DIEFFESCAPE, *LPDIEFFESCAPE;
1143
1144typedef struct DIJOYSTATE {
1145 LONG lX;
1146 LONG lY;
1147 LONG lZ;
1148 LONG lRx;
1149 LONG lRy;
1150 LONG lRz;
1151 LONG rglSlider[2];
1152 DWORD rgdwPOV[4];
1153 BYTE rgbButtons[32];
1154} DIJOYSTATE, *LPDIJOYSTATE;
1155
1156typedef struct DIJOYSTATE2 {
1157 LONG lX;
1158 LONG lY;
1159 LONG lZ;
1160 LONG lRx;
1161 LONG lRy;
1162 LONG lRz;
1163 LONG rglSlider[2];
1164 DWORD rgdwPOV[4];
1165 BYTE rgbButtons[128];
1166 LONG lVX; /* 'v' as in velocity */
1167 LONG lVY;
1168 LONG lVZ;
1169 LONG lVRx;
1170 LONG lVRy;
1171 LONG lVRz;
1172 LONG rglVSlider[2];
1173 LONG lAX; /* 'a' as in acceleration */
1174 LONG lAY;
1175 LONG lAZ;
1176 LONG lARx;
1177 LONG lARy;
1178 LONG lARz;
1179 LONG rglASlider[2];
1180 LONG lFX; /* 'f' as in force */
1181 LONG lFY;
1182 LONG lFZ;
1183 LONG lFRx; /* 'fr' as in rotational force aka torque */
1184 LONG lFRy;
1185 LONG lFRz;
1186 LONG rglFSlider[2];
1187} DIJOYSTATE2, *LPDIJOYSTATE2;
1188
1189#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX)
1190#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY)
1191#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ)
1192#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx)
1193#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy)
1194#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz)
1195#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \
1196 (n) * sizeof(LONG))
1197#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \
1198 (n) * sizeof(DWORD))
1199#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n))
1200#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0)
1201#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1)
1202#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2)
1203#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3)
1204#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4)
1205#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5)
1206#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6)
1207#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7)
1208#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8)
1209#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9)
1210#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10)
1211#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11)
1212#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12)
1213#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13)
1214#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14)
1215#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15)
1216#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16)
1217#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17)
1218#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18)
1219#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19)
1220#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20)
1221#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21)
1222#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22)
1223#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23)
1224#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24)
1225#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25)
1226#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26)
1227#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27)
1228#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28)
1229#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29)
1230#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30)
1231#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31)
1232#endif /* DIRECTINPUT_VERSION >= 0x0500 */
1233
1234/* DInput 7 structures, types */
1235#if(DIRECTINPUT_VERSION >= 0x0700)
1236typedef struct DIFILEEFFECT {
1237 DWORD dwSize;
1238 GUID GuidEffect;
1239 LPCDIEFFECT lpDiEffect;
1240 CHAR szFriendlyName[MAX_PATH];
1241} DIFILEEFFECT, *LPDIFILEEFFECT;
1242
1243typedef const DIFILEEFFECT *LPCDIFILEEFFECT;
1244typedef BOOL (CALLBACK *LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID);
1245#endif /* DIRECTINPUT_VERSION >= 0x0700 */
1246
1247/* DInput 8 structures and types */
1248#if DIRECTINPUT_VERSION >= 0x0800
1249typedef struct _DIACTIONA {
1250 UINT_PTR uAppData;
1251 DWORD dwSemantic;
1252 DWORD dwFlags;
1253 __GNU_EXTENSION union {
1254 LPCSTR lptszActionName;
1255 UINT uResIdString;
1256 } DUMMYUNIONNAME;
1257 GUID guidInstance;
1258 DWORD dwObjID;
1259 DWORD dwHow;
1260} DIACTIONA, *LPDIACTIONA;
1261typedef const DIACTIONA *LPCDIACTIONA;
1262
1263typedef struct _DIACTIONW {
1264 UINT_PTR uAppData;
1265 DWORD dwSemantic;
1266 DWORD dwFlags;
1267 __GNU_EXTENSION union {
1268 LPCWSTR lptszActionName;
1269 UINT uResIdString;
1270 } DUMMYUNIONNAME;
1271 GUID guidInstance;
1272 DWORD dwObjID;
1273 DWORD dwHow;
1274} DIACTIONW, *LPDIACTIONW;
1275typedef const DIACTIONW *LPCDIACTIONW;
1276
1277DECL_WINELIB_TYPE_AW(DIACTION)
1278DECL_WINELIB_TYPE_AW(LPDIACTION)
1279DECL_WINELIB_TYPE_AW(LPCDIACTION)
1280
1281#define DIA_FORCEFEEDBACK 0x00000001
1282#define DIA_APPMAPPED 0x00000002
1283#define DIA_APPNOMAP 0x00000004
1284#define DIA_NORANGE 0x00000008
1285#define DIA_APPFIXED 0x00000010
1286
1287#define DIAH_UNMAPPED 0x00000000
1288#define DIAH_USERCONFIG 0x00000001
1289#define DIAH_APPREQUESTED 0x00000002
1290#define DIAH_HWAPP 0x00000004
1291#define DIAH_HWDEFAULT 0x00000008
1292#define DIAH_DEFAULT 0x00000020
1293#define DIAH_ERROR 0x80000000
1294
1295typedef struct _DIACTIONFORMATA {
1296 DWORD dwSize;
1297 DWORD dwActionSize;
1298 DWORD dwDataSize;
1299 DWORD dwNumActions;
1300 LPDIACTIONA rgoAction;
1301 GUID guidActionMap;
1302 DWORD dwGenre;
1303 DWORD dwBufferSize;
1304 LONG lAxisMin;
1305 LONG lAxisMax;
1306 HINSTANCE hInstString;
1307 FILETIME ftTimeStamp;
1308 DWORD dwCRC;
1309 CHAR tszActionMap[MAX_PATH];
1310} DIACTIONFORMATA, *LPDIACTIONFORMATA;
1311typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA;
1312
1313typedef struct _DIACTIONFORMATW {
1314 DWORD dwSize;
1315 DWORD dwActionSize;
1316 DWORD dwDataSize;
1317 DWORD dwNumActions;
1318 LPDIACTIONW rgoAction;
1319 GUID guidActionMap;
1320 DWORD dwGenre;
1321 DWORD dwBufferSize;
1322 LONG lAxisMin;
1323 LONG lAxisMax;
1324 HINSTANCE hInstString;
1325 FILETIME ftTimeStamp;
1326 DWORD dwCRC;
1327 WCHAR tszActionMap[MAX_PATH];
1328} DIACTIONFORMATW, *LPDIACTIONFORMATW;
1329typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW;
1330
1331DECL_WINELIB_TYPE_AW(DIACTIONFORMAT)
1332DECL_WINELIB_TYPE_AW(LPDIACTIONFORMAT)
1333DECL_WINELIB_TYPE_AW(LPCDIACTIONFORMAT)
1334
1335#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF
1336#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF
1337#define DIAFTS_UNUSEDDEVICELOW 0x00000000
1338#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000
1339
1340#define DIDBAM_DEFAULT 0x00000000
1341#define DIDBAM_PRESERVE 0x00000001
1342#define DIDBAM_INITIALIZE 0x00000002
1343#define DIDBAM_HWDEFAULTS 0x00000004
1344
1345#define DIDSAM_DEFAULT 0x00000000
1346#define DIDSAM_NOUSER 0x00000001
1347#define DIDSAM_FORCESAVE 0x00000002
1348
1349#define DICD_DEFAULT 0x00000000
1350#define DICD_EDIT 0x00000001
1351
1352#ifndef D3DCOLOR_DEFINED
1353typedef DWORD D3DCOLOR;
1354#define D3DCOLOR_DEFINED
1355#endif
1356
1357typedef struct _DICOLORSET {
1358 DWORD dwSize;
1359 D3DCOLOR cTextFore;
1360 D3DCOLOR cTextHighlight;
1361 D3DCOLOR cCalloutLine;
1362 D3DCOLOR cCalloutHighlight;
1363 D3DCOLOR cBorder;
1364 D3DCOLOR cControlFill;
1365 D3DCOLOR cHighlightFill;
1366 D3DCOLOR cAreaFill;
1367} DICOLORSET, *LPDICOLORSET;
1368typedef const DICOLORSET *LPCDICOLORSET;
1369
1370typedef struct _DICONFIGUREDEVICESPARAMSA {
1371 DWORD dwSize;
1372 DWORD dwcUsers;
1373 LPSTR lptszUserNames;
1374 DWORD dwcFormats;
1375 LPDIACTIONFORMATA lprgFormats;
1376 HWND hwnd;
1377 DICOLORSET dics;
1378 LPUNKNOWN lpUnkDDSTarget;
1379} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA;
1380typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA;
1381
1382typedef struct _DICONFIGUREDEVICESPARAMSW {
1383 DWORD dwSize;
1384 DWORD dwcUsers;
1385 LPWSTR lptszUserNames;
1386 DWORD dwcFormats;
1387 LPDIACTIONFORMATW lprgFormats;
1388 HWND hwnd;
1389 DICOLORSET dics;
1390 LPUNKNOWN lpUnkDDSTarget;
1391} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW;
1392typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW;
1393
1394DECL_WINELIB_TYPE_AW(DICONFIGUREDEVICESPARAMS)
1395DECL_WINELIB_TYPE_AW(LPDICONFIGUREDEVICESPARAMS)
1396DECL_WINELIB_TYPE_AW(LPCDICONFIGUREDEVICESPARAMS)
1397
1398#define DIDIFT_CONFIGURATION 0x00000001
1399#define DIDIFT_OVERLAY 0x00000002
1400
1401#define DIDAL_CENTERED 0x00000000
1402#define DIDAL_LEFTALIGNED 0x00000001
1403#define DIDAL_RIGHTALIGNED 0x00000002
1404#define DIDAL_MIDDLE 0x00000000
1405#define DIDAL_TOPALIGNED 0x00000004
1406#define DIDAL_BOTTOMALIGNED 0x00000008
1407
1408typedef struct _DIDEVICEIMAGEINFOA {
1409 CHAR tszImagePath[MAX_PATH];
1410 DWORD dwFlags;
1411 DWORD dwViewID;
1412 RECT rcOverlay;
1413 DWORD dwObjID;
1414 DWORD dwcValidPts;
1415 POINT rgptCalloutLine[5];
1416 RECT rcCalloutRect;
1417 DWORD dwTextAlign;
1418} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA;
1419typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA;
1420
1421typedef struct _DIDEVICEIMAGEINFOW {
1422 WCHAR tszImagePath[MAX_PATH];
1423 DWORD dwFlags;
1424 DWORD dwViewID;
1425 RECT rcOverlay;
1426 DWORD dwObjID;
1427 DWORD dwcValidPts;
1428 POINT rgptCalloutLine[5];
1429 RECT rcCalloutRect;
1430 DWORD dwTextAlign;
1431} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW;
1432typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW;
1433
1434DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFO)
1435DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFO)
1436DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFO)
1437
1438typedef struct _DIDEVICEIMAGEINFOHEADERA {
1439 DWORD dwSize;
1440 DWORD dwSizeImageInfo;
1441 DWORD dwcViews;
1442 DWORD dwcButtons;
1443 DWORD dwcAxes;
1444 DWORD dwcPOVs;
1445 DWORD dwBufferSize;
1446 DWORD dwBufferUsed;
1447 LPDIDEVICEIMAGEINFOA lprgImageInfoArray;
1448} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA;
1449typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA;
1450
1451typedef struct _DIDEVICEIMAGEINFOHEADERW {
1452 DWORD dwSize;
1453 DWORD dwSizeImageInfo;
1454 DWORD dwcViews;
1455 DWORD dwcButtons;
1456 DWORD dwcAxes;
1457 DWORD dwcPOVs;
1458 DWORD dwBufferSize;
1459 DWORD dwBufferUsed;
1460 LPDIDEVICEIMAGEINFOW lprgImageInfoArray;
1461} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW;
1462typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW;
1463
1464DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFOHEADER)
1465DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFOHEADER)
1466DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFOHEADER)
1467
1468#endif /* DI8 */
1469
1470
1471/*****************************************************************************
1472 * IDirectInputEffect interface
1473 */
1474#if (DIRECTINPUT_VERSION >= 0x0500)
1475#undef INTERFACE
1476#define INTERFACE IDirectInputEffect
1477DECLARE_INTERFACE_(IDirectInputEffect,IUnknown)
1478{
1479 /*** IUnknown methods ***/
1480 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1481 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1482 STDMETHOD_(ULONG,Release)(THIS) PURE;
1483 /*** IDirectInputEffect methods ***/
1484 STDMETHOD(Initialize)(THIS_ HINSTANCE, DWORD, REFGUID) PURE;
1485 STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE;
1486 STDMETHOD(GetParameters)(THIS_ LPDIEFFECT, DWORD) PURE;
1487 STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT, DWORD) PURE;
1488 STDMETHOD(Start)(THIS_ DWORD, DWORD) PURE;
1489 STDMETHOD(Stop)(THIS) PURE;
1490 STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE;
1491 STDMETHOD(Download)(THIS) PURE;
1492 STDMETHOD(Unload)(THIS) PURE;
1493 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
1494};
1495
1496#if !defined(__cplusplus) || defined(CINTERFACE)
1497/*** IUnknown methods ***/
1498#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1499#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p)
1500#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p)
1501/*** IDirectInputEffect methods ***/
1502#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
1503#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a)
1504#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b)
1505#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b)
1506#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b)
1507#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p)
1508#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a)
1509#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p)
1510#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p)
1511#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a)
1512#else
1513/*** IUnknown methods ***/
1514#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
1515#define IDirectInputEffect_AddRef(p) (p)->AddRef()
1516#define IDirectInputEffect_Release(p) (p)->Release()
1517/*** IDirectInputEffect methods ***/
1518#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
1519#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a)
1520#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b)
1521#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b)
1522#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b)
1523#define IDirectInputEffect_Stop(p) (p)->Stop()
1524#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a)
1525#define IDirectInputEffect_Download(p) (p)->Download()
1526#define IDirectInputEffect_Unload(p) (p)->Unload()
1527#define IDirectInputEffect_Escape(p,a) (p)->Escape(a)
1528#endif
1529
1530#endif /* DI5 */
1531
1532
1533/*****************************************************************************
1534 * IDirectInputDeviceA interface
1535 */
1536#undef INTERFACE
1537#define INTERFACE IDirectInputDeviceA
1538DECLARE_INTERFACE_(IDirectInputDeviceA,IUnknown)
1539{
1540 /*** IUnknown methods ***/
1541 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1542 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1543 STDMETHOD_(ULONG,Release)(THIS) PURE;
1544 /*** IDirectInputDeviceA methods ***/
1545 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1546 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1547 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1548 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
1549 STDMETHOD(Acquire)(THIS) PURE;
1550 STDMETHOD(Unacquire)(THIS) PURE;
1551 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
1552 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
1553 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
1554 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
1555 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
1556 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
1557 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
1558 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
1559 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
1560};
1561
1562/*****************************************************************************
1563 * IDirectInputDeviceW interface
1564 */
1565#undef INTERFACE
1566#define INTERFACE IDirectInputDeviceW
1567DECLARE_INTERFACE_(IDirectInputDeviceW,IUnknown)
1568{
1569 /*** IUnknown methods ***/
1570 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1571 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1572 STDMETHOD_(ULONG,Release)(THIS) PURE;
1573 /*** IDirectInputDeviceW methods ***/
1574 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1575 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1576 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1577 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
1578 STDMETHOD(Acquire)(THIS) PURE;
1579 STDMETHOD(Unacquire)(THIS) PURE;
1580 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
1581 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
1582 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
1583 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
1584 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
1585 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
1586 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
1587 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
1588 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
1589};
1590
1591#if !defined(__cplusplus) || defined(CINTERFACE)
1592/*** IUnknown methods ***/
1593#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1594#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p)
1595#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p)
1596/*** IDirectInputDevice methods ***/
1597#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
1598#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
1599#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
1600#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
1601#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p)
1602#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p)
1603#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
1604#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
1605#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
1606#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
1607#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
1608#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
1609#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
1610#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
1611#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
1612#else
1613/*** IUnknown methods ***/
1614#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
1615#define IDirectInputDevice_AddRef(p) (p)->AddRef()
1616#define IDirectInputDevice_Release(p) (p)->Release()
1617/*** IDirectInputDevice methods ***/
1618#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a)
1619#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
1620#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b)
1621#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b)
1622#define IDirectInputDevice_Acquire(p) (p)->Acquire()
1623#define IDirectInputDevice_Unacquire(p) (p)->Unacquire()
1624#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
1625#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
1626#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a)
1627#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a)
1628#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
1629#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
1630#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
1631#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
1632#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
1633#endif
1634
1635
1636#if (DIRECTINPUT_VERSION >= 0x0500)
1637/*****************************************************************************
1638 * IDirectInputDevice2A interface
1639 */
1640#undef INTERFACE
1641#define INTERFACE IDirectInputDevice2A
1642DECLARE_INTERFACE_(IDirectInputDevice2A,IDirectInputDeviceA)
1643{
1644 /*** IUnknown methods ***/
1645 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1646 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1647 STDMETHOD_(ULONG,Release)(THIS) PURE;
1648 /*** IDirectInputDeviceA methods ***/
1649 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1650 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1651 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1652 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
1653 STDMETHOD(Acquire)(THIS) PURE;
1654 STDMETHOD(Unacquire)(THIS) PURE;
1655 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
1656 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
1657 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
1658 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
1659 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
1660 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
1661 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
1662 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
1663 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
1664 /*** IDirectInputDevice2A methods ***/
1665 STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
1666 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
1667 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
1668 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
1669 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
1670 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
1671 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
1672 STDMETHOD(Poll)(THIS) PURE;
1673 STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
1674};
1675
1676/*****************************************************************************
1677 * IDirectInputDevice2W interface
1678 */
1679#undef INTERFACE
1680#define INTERFACE IDirectInputDevice2W
1681DECLARE_INTERFACE_(IDirectInputDevice2W,IDirectInputDeviceW)
1682{
1683 /*** IUnknown methods ***/
1684 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1685 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1686 STDMETHOD_(ULONG,Release)(THIS) PURE;
1687 /*** IDirectInputDeviceW methods ***/
1688 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1689 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1690 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1691 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
1692 STDMETHOD(Acquire)(THIS) PURE;
1693 STDMETHOD(Unacquire)(THIS) PURE;
1694 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
1695 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
1696 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
1697 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
1698 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
1699 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
1700 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
1701 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
1702 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
1703 /*** IDirectInputDevice2W methods ***/
1704 STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
1705 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
1706 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
1707 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
1708 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
1709 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
1710 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
1711 STDMETHOD(Poll)(THIS) PURE;
1712 STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
1713};
1714
1715#if !defined(__cplusplus) || defined(CINTERFACE)
1716/*** IUnknown methods ***/
1717#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1718#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p)
1719#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p)
1720/*** IDirectInputDevice methods ***/
1721#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
1722#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
1723#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
1724#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
1725#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p)
1726#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p)
1727#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
1728#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
1729#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
1730#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
1731#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
1732#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
1733#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
1734#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
1735#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
1736/*** IDirectInputDevice2 methods ***/
1737#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d)
1738#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c)
1739#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b)
1740#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a)
1741#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a)
1742#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
1743#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a)
1744#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p)
1745#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
1746#else
1747/*** IUnknown methods ***/
1748#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
1749#define IDirectInputDevice2_AddRef(p) (p)->AddRef()
1750#define IDirectInputDevice2_Release(p) (p)->Release()
1751/*** IDirectInputDevice methods ***/
1752#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a)
1753#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
1754#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b)
1755#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b)
1756#define IDirectInputDevice2_Acquire(p) (p)->Acquire()
1757#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire()
1758#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
1759#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
1760#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a)
1761#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a)
1762#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
1763#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
1764#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
1765#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
1766#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
1767/*** IDirectInputDevice2 methods ***/
1768#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d)
1769#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c)
1770#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b)
1771#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a)
1772#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a)
1773#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
1774#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a)
1775#define IDirectInputDevice2_Poll(p) (p)->Poll()
1776#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d)
1777#endif
1778#endif /* DI5 */
1779
1780#if DIRECTINPUT_VERSION >= 0x0700
1781/*****************************************************************************
1782 * IDirectInputDevice7A interface
1783 */
1784#undef INTERFACE
1785#define INTERFACE IDirectInputDevice7A
1786DECLARE_INTERFACE_(IDirectInputDevice7A,IDirectInputDevice2A)
1787{
1788 /*** IUnknown methods ***/
1789 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1790 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1791 STDMETHOD_(ULONG,Release)(THIS) PURE;
1792 /*** IDirectInputDeviceA methods ***/
1793 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1794 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1795 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1796 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
1797 STDMETHOD(Acquire)(THIS) PURE;
1798 STDMETHOD(Unacquire)(THIS) PURE;
1799 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
1800 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
1801 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
1802 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
1803 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
1804 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
1805 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
1806 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
1807 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
1808 /*** IDirectInputDevice2A methods ***/
1809 STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
1810 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
1811 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
1812 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
1813 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
1814 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
1815 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
1816 STDMETHOD(Poll)(THIS) PURE;
1817 STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
1818 /*** IDirectInputDevice7A methods ***/
1819 STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
1820 STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
1821};
1822
1823/*****************************************************************************
1824 * IDirectInputDevice7W interface
1825 */
1826#undef INTERFACE
1827#define INTERFACE IDirectInputDevice7W
1828DECLARE_INTERFACE_(IDirectInputDevice7W,IDirectInputDevice2W)
1829{
1830 /*** IUnknown methods ***/
1831 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1832 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1833 STDMETHOD_(ULONG,Release)(THIS) PURE;
1834 /*** IDirectInputDeviceW methods ***/
1835 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1836 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1837 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1838 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
1839 STDMETHOD(Acquire)(THIS) PURE;
1840 STDMETHOD(Unacquire)(THIS) PURE;
1841 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
1842 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
1843 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
1844 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
1845 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
1846 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
1847 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
1848 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
1849 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
1850 /*** IDirectInputDevice2W methods ***/
1851 STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
1852 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
1853 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
1854 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
1855 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
1856 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
1857 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
1858 STDMETHOD(Poll)(THIS) PURE;
1859 STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
1860 /*** IDirectInputDevice7W methods ***/
1861 STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
1862 STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
1863};
1864
1865#if !defined(__cplusplus) || defined(CINTERFACE)
1866/*** IUnknown methods ***/
1867#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1868#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p)
1869#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p)
1870/*** IDirectInputDevice methods ***/
1871#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
1872#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
1873#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
1874#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
1875#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p)
1876#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p)
1877#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
1878#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
1879#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
1880#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
1881#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
1882#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
1883#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
1884#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
1885#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
1886/*** IDirectInputDevice2 methods ***/
1887#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d)
1888#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c)
1889#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b)
1890#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a)
1891#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a)
1892#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
1893#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a)
1894#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p)
1895#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
1896/*** IDirectInputDevice7 methods ***/
1897#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
1898#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
1899#else
1900/*** IUnknown methods ***/
1901#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
1902#define IDirectInputDevice7_AddRef(p) (p)->AddRef()
1903#define IDirectInputDevice7_Release(p) (p)->Release()
1904/*** IDirectInputDevice methods ***/
1905#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a)
1906#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
1907#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b)
1908#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b)
1909#define IDirectInputDevice7_Acquire(p) (p)->Acquire()
1910#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire()
1911#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
1912#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
1913#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a)
1914#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a)
1915#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
1916#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
1917#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
1918#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
1919#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
1920/*** IDirectInputDevice2 methods ***/
1921#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d)
1922#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c)
1923#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b)
1924#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a)
1925#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a)
1926#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
1927#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a)
1928#define IDirectInputDevice7_Poll(p) (p)->Poll()
1929#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d)
1930/*** IDirectInputDevice7 methods ***/
1931#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
1932#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
1933#endif
1934
1935#endif /* DI7 */
1936
1937#if DIRECTINPUT_VERSION >= 0x0800
1938/*****************************************************************************
1939 * IDirectInputDevice8A interface
1940 */
1941#undef INTERFACE
1942#define INTERFACE IDirectInputDevice8A
1943DECLARE_INTERFACE_(IDirectInputDevice8A,IDirectInputDevice7A)
1944{
1945 /*** IUnknown methods ***/
1946 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1947 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1948 STDMETHOD_(ULONG,Release)(THIS) PURE;
1949 /*** IDirectInputDeviceA methods ***/
1950 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1951 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1952 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1953 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
1954 STDMETHOD(Acquire)(THIS) PURE;
1955 STDMETHOD(Unacquire)(THIS) PURE;
1956 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
1957 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
1958 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
1959 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
1960 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
1961 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
1962 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
1963 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
1964 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
1965 /*** IDirectInputDevice2A methods ***/
1966 STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
1967 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
1968 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
1969 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
1970 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
1971 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
1972 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
1973 STDMETHOD(Poll)(THIS) PURE;
1974 STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
1975 /*** IDirectInputDevice7A methods ***/
1976 STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
1977 STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
1978 /*** IDirectInputDevice8A methods ***/
1979 STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE;
1980 STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE;
1981 STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) PURE;
1982};
1983
1984/*****************************************************************************
1985 * IDirectInputDevice8W interface
1986 */
1987#undef INTERFACE
1988#define INTERFACE IDirectInputDevice8W
1989DECLARE_INTERFACE_(IDirectInputDevice8W,IDirectInputDevice7W)
1990{
1991 /*** IUnknown methods ***/
1992 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
1993 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
1994 STDMETHOD_(ULONG,Release)(THIS) PURE;
1995 /*** IDirectInputDeviceW methods ***/
1996 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
1997 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
1998 STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
1999 STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
2000 STDMETHOD(Acquire)(THIS) PURE;
2001 STDMETHOD(Unacquire)(THIS) PURE;
2002 STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
2003 STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
2004 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
2005 STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
2006 STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
2007 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
2008 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
2009 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2010 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
2011 /*** IDirectInputDevice2W methods ***/
2012 STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
2013 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
2014 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
2015 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
2016 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
2017 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
2018 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
2019 STDMETHOD(Poll)(THIS) PURE;
2020 STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
2021 /*** IDirectInputDevice7W methods ***/
2022 STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
2023 STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
2024 /*** IDirectInputDevice8W methods ***/
2025 STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE;
2026 STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE;
2027 STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) PURE;
2028};
2029
2030#if !defined(__cplusplus) || defined(CINTERFACE)
2031/*** IUnknown methods ***/
2032#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
2033#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p)
2034#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p)
2035/*** IDirectInputDevice methods ***/
2036#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
2037#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
2038#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
2039#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
2040#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p)
2041#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p)
2042#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
2043#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
2044#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
2045#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
2046#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
2047#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
2048#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
2049#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
2050#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
2051/*** IDirectInputDevice2 methods ***/
2052#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d)
2053#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c)
2054#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b)
2055#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a)
2056#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a)
2057#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
2058#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a)
2059#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p)
2060#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
2061/*** IDirectInputDevice7 methods ***/
2062#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
2063#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
2064/*** IDirectInputDevice8 methods ***/
2065#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c)
2066#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c)
2067#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a)
2068#else
2069/*** IUnknown methods ***/
2070#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
2071#define IDirectInputDevice8_AddRef(p) (p)->AddRef()
2072#define IDirectInputDevice8_Release(p) (p)->Release()
2073/*** IDirectInputDevice methods ***/
2074#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a)
2075#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
2076#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b)
2077#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b)
2078#define IDirectInputDevice8_Acquire(p) (p)->Acquire()
2079#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire()
2080#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
2081#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
2082#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a)
2083#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a)
2084#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
2085#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
2086#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
2087#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
2088#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
2089/*** IDirectInputDevice2 methods ***/
2090#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d)
2091#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c)
2092#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b)
2093#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a)
2094#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a)
2095#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
2096#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a)
2097#define IDirectInputDevice8_Poll(p) (p)->Poll()
2098#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d)
2099/*** IDirectInputDevice7 methods ***/
2100#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
2101#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
2102/*** IDirectInputDevice8 methods ***/
2103#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c)
2104#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c)
2105#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a)
2106#endif
2107
2108#endif /* DI8 */
2109
2110/* "Standard" Mouse report... */
2111typedef struct DIMOUSESTATE {
2112 LONG lX;
2113 LONG lY;
2114 LONG lZ;
2115 BYTE rgbButtons[4];
2116} DIMOUSESTATE;
2117
2118#if DIRECTINPUT_VERSION >= 0x0700
2119/* "Standard" Mouse report for DInput 7... */
2120typedef struct DIMOUSESTATE2 {
2121 LONG lX;
2122 LONG lY;
2123 LONG lZ;
2124 BYTE rgbButtons[8];
2125} DIMOUSESTATE2;
2126#endif /* DI7 */
2127
2128#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX)
2129#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY)
2130#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ)
2131#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0)
2132#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1)
2133#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2)
2134#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3)
2135#if DIRECTINPUT_VERSION >= 0x0700
2136#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4)
2137#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5)
2138#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6)
2139#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7)
2140#endif /* DI7 */
2141
2142#ifdef __cplusplus
2143extern "C" {
2144#endif
2145extern const DIDATAFORMAT c_dfDIMouse;
2146#if DIRECTINPUT_VERSION >= 0x0700
2147extern const DIDATAFORMAT c_dfDIMouse2; /* DX 7 */
2148#endif /* DI7 */
2149extern const DIDATAFORMAT c_dfDIKeyboard;
2150#if DIRECTINPUT_VERSION >= 0x0500
2151extern const DIDATAFORMAT c_dfDIJoystick;
2152extern const DIDATAFORMAT c_dfDIJoystick2;
2153#endif /* DI5 */
2154#ifdef __cplusplus
2155};
2156#endif
2157
2158/*****************************************************************************
2159 * IDirectInputA interface
2160 */
2161#undef INTERFACE
2162#define INTERFACE IDirectInputA
2163DECLARE_INTERFACE_(IDirectInputA,IUnknown)
2164{
2165 /*** IUnknown methods ***/
2166 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2167 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2168 STDMETHOD_(ULONG,Release)(THIS) PURE;
2169 /*** IDirectInputA methods ***/
2170 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2171 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2172 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2173 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2174 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2175};
2176
2177/*****************************************************************************
2178 * IDirectInputW interface
2179 */
2180#undef INTERFACE
2181#define INTERFACE IDirectInputW
2182DECLARE_INTERFACE_(IDirectInputW,IUnknown)
2183{
2184 /*** IUnknown methods ***/
2185 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2186 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2187 STDMETHOD_(ULONG,Release)(THIS) PURE;
2188 /*** IDirectInputW methods ***/
2189 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2190 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2191 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2192 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2193 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2194};
2195
2196#if !defined(__cplusplus) || defined(CINTERFACE)
2197/*** IUnknown methods ***/
2198#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
2199#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p)
2200#define IDirectInput_Release(p) (p)->lpVtbl->Release(p)
2201/*** IDirectInput methods ***/
2202#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
2203#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
2204#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
2205#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
2206#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
2207#else
2208/*** IUnknown methods ***/
2209#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
2210#define IDirectInput_AddRef(p) (p)->AddRef()
2211#define IDirectInput_Release(p) (p)->Release()
2212/*** IDirectInput methods ***/
2213#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
2214#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
2215#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
2216#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
2217#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b)
2218#endif
2219
2220/*****************************************************************************
2221 * IDirectInput2A interface
2222 */
2223#undef INTERFACE
2224#define INTERFACE IDirectInput2A
2225DECLARE_INTERFACE_(IDirectInput2A,IDirectInputA)
2226{
2227 /*** IUnknown methods ***/
2228 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2229 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2230 STDMETHOD_(ULONG,Release)(THIS) PURE;
2231 /*** IDirectInputA methods ***/
2232 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2233 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2234 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2235 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2236 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2237 /*** IDirectInput2A methods ***/
2238 STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
2239};
2240
2241/*****************************************************************************
2242 * IDirectInput2W interface
2243 */
2244#undef INTERFACE
2245#define INTERFACE IDirectInput2W
2246DECLARE_INTERFACE_(IDirectInput2W,IDirectInputW)
2247{
2248 /*** IUnknown methods ***/
2249 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2250 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2251 STDMETHOD_(ULONG,Release)(THIS) PURE;
2252 /*** IDirectInputW methods ***/
2253 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2254 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2255 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2256 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2257 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2258 /*** IDirectInput2W methods ***/
2259 STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
2260};
2261
2262#if !defined(__cplusplus) || defined(CINTERFACE)
2263/*** IUnknown methods ***/
2264#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
2265#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p)
2266#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p)
2267/*** IDirectInput methods ***/
2268#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
2269#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
2270#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
2271#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
2272#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
2273/*** IDirectInput2 methods ***/
2274#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
2275#else
2276/*** IUnknown methods ***/
2277#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
2278#define IDirectInput2_AddRef(p) (p)->AddRef()
2279#define IDirectInput2_Release(p) (p)->Release()
2280/*** IDirectInput methods ***/
2281#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
2282#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
2283#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
2284#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
2285#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b)
2286/*** IDirectInput2 methods ***/
2287#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c)
2288#endif
2289
2290/*****************************************************************************
2291 * IDirectInput7A interface
2292 */
2293#undef INTERFACE
2294#define INTERFACE IDirectInput7A
2295DECLARE_INTERFACE_(IDirectInput7A,IDirectInput2A)
2296{
2297 /*** IUnknown methods ***/
2298 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2299 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2300 STDMETHOD_(ULONG,Release)(THIS) PURE;
2301 /*** IDirectInputA methods ***/
2302 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2303 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2304 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2305 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2306 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2307 /*** IDirectInput2A methods ***/
2308 STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
2309 /*** IDirectInput7A methods ***/
2310 STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE;
2311};
2312
2313/*****************************************************************************
2314 * IDirectInput7W interface
2315 */
2316#undef INTERFACE
2317#define INTERFACE IDirectInput7W
2318DECLARE_INTERFACE_(IDirectInput7W,IDirectInput2W)
2319{
2320 /*** IUnknown methods ***/
2321 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2322 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2323 STDMETHOD_(ULONG,Release)(THIS) PURE;
2324 /*** IDirectInputW methods ***/
2325 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2326 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2327 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2328 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2329 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2330 /*** IDirectInput2W methods ***/
2331 STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
2332 /*** IDirectInput7W methods ***/
2333 STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE;
2334};
2335
2336#if !defined(__cplusplus) || defined(CINTERFACE)
2337/*** IUnknown methods ***/
2338#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
2339#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p)
2340#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p)
2341/*** IDirectInput methods ***/
2342#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
2343#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
2344#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
2345#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
2346#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
2347/*** IDirectInput2 methods ***/
2348#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
2349/*** IDirectInput7 methods ***/
2350#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d)
2351#else
2352/*** IUnknown methods ***/
2353#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
2354#define IDirectInput7_AddRef(p) (p)->AddRef()
2355#define IDirectInput7_Release(p) (p)->Release()
2356/*** IDirectInput methods ***/
2357#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
2358#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
2359#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
2360#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
2361#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b)
2362/*** IDirectInput2 methods ***/
2363#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c)
2364/*** IDirectInput7 methods ***/
2365#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d)
2366#endif
2367
2368
2369#if DIRECTINPUT_VERSION >= 0x0800
2370/*****************************************************************************
2371 * IDirectInput8A interface
2372 */
2373#undef INTERFACE
2374#define INTERFACE IDirectInput8A
2375DECLARE_INTERFACE_(IDirectInput8A,IUnknown)
2376{
2377 /*** IUnknown methods ***/
2378 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2379 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2380 STDMETHOD_(ULONG,Release)(THIS) PURE;
2381 /*** IDirectInput8A methods ***/
2382 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8A *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2383 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2384 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2385 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2386 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2387 STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
2388 STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2389 STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
2390};
2391
2392/*****************************************************************************
2393 * IDirectInput8W interface
2394 */
2395#undef INTERFACE
2396#define INTERFACE IDirectInput8W
2397DECLARE_INTERFACE_(IDirectInput8W,IUnknown)
2398{
2399 /*** IUnknown methods ***/
2400 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
2401 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
2402 STDMETHOD_(ULONG,Release)(THIS) PURE;
2403 /*** IDirectInput8W methods ***/
2404 STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
2405 STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2406 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
2407 STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
2408 STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
2409 STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
2410 STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
2411 STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
2412};
2413#undef INTERFACE
2414
2415#if !defined(__cplusplus) || defined(CINTERFACE)
2416/*** IUnknown methods ***/
2417#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
2418#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p)
2419#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p)
2420/*** IDirectInput8 methods ***/
2421#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
2422#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
2423#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
2424#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
2425#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
2426#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
2427#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e)
2428#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
2429#else
2430/*** IUnknown methods ***/
2431#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
2432#define IDirectInput8_AddRef(p) (p)->AddRef()
2433#define IDirectInput8_Release(p) (p)->Release()
2434/*** IDirectInput8 methods ***/
2435#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
2436#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
2437#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
2438#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
2439#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b)
2440#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c)
2441#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e)
2442#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d)
2443#endif
2444
2445#endif /* DI8 */
2446
2447/* Export functions */
2448
2449#ifdef __cplusplus
2450extern "C" {
2451#endif
2452
2453#if DIRECTINPUT_VERSION >= 0x0800
2454HRESULT WINAPI DirectInput8Create(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
2455#else /* DI < 8 */
2456HRESULT WINAPI DirectInputCreateA(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN);
2457HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTW *,LPUNKNOWN);
2458#define DirectInputCreate WINELIB_NAME_AW(DirectInputCreate)
2459
2460HRESULT WINAPI DirectInputCreateEx(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
2461#endif /* DI8 */
2462
2463#ifdef __cplusplus
2464};
2465#endif
2466
2467#endif /* __DINPUT_INCLUDED__ */
diff --git a/raylib/src/external/glfw/deps/mingw/xinput.h b/raylib/src/external/glfw/deps/mingw/xinput.h
new file mode 100644
index 0000000..d3ca726
--- /dev/null
+++ b/raylib/src/external/glfw/deps/mingw/xinput.h
@@ -0,0 +1,239 @@
1/*
2 * The Wine project - Xinput Joystick Library
3 * Copyright 2008 Andrew Fenn
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#ifndef __WINE_XINPUT_H
21#define __WINE_XINPUT_H
22
23#include <windef.h>
24
25/*
26 * Bitmasks for the joysticks buttons, determines what has
27 * been pressed on the joystick, these need to be mapped
28 * to whatever device you're using instead of an xbox 360
29 * joystick
30 */
31
32#define XINPUT_GAMEPAD_DPAD_UP 0x0001
33#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
34#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
35#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
36#define XINPUT_GAMEPAD_START 0x0010
37#define XINPUT_GAMEPAD_BACK 0x0020
38#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
39#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
40#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
41#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
42#define XINPUT_GAMEPAD_A 0x1000
43#define XINPUT_GAMEPAD_B 0x2000
44#define XINPUT_GAMEPAD_X 0x4000
45#define XINPUT_GAMEPAD_Y 0x8000
46
47/*
48 * Defines the flags used to determine if the user is pushing
49 * down on a button, not holding a button, etc
50 */
51
52#define XINPUT_KEYSTROKE_KEYDOWN 0x0001
53#define XINPUT_KEYSTROKE_KEYUP 0x0002
54#define XINPUT_KEYSTROKE_REPEAT 0x0004
55
56/*
57 * Defines the codes which are returned by XInputGetKeystroke
58 */
59
60#define VK_PAD_A 0x5800
61#define VK_PAD_B 0x5801
62#define VK_PAD_X 0x5802
63#define VK_PAD_Y 0x5803
64#define VK_PAD_RSHOULDER 0x5804
65#define VK_PAD_LSHOULDER 0x5805
66#define VK_PAD_LTRIGGER 0x5806
67#define VK_PAD_RTRIGGER 0x5807
68#define VK_PAD_DPAD_UP 0x5810
69#define VK_PAD_DPAD_DOWN 0x5811
70#define VK_PAD_DPAD_LEFT 0x5812
71#define VK_PAD_DPAD_RIGHT 0x5813
72#define VK_PAD_START 0x5814
73#define VK_PAD_BACK 0x5815
74#define VK_PAD_LTHUMB_PRESS 0x5816
75#define VK_PAD_RTHUMB_PRESS 0x5817
76#define VK_PAD_LTHUMB_UP 0x5820
77#define VK_PAD_LTHUMB_DOWN 0x5821
78#define VK_PAD_LTHUMB_RIGHT 0x5822
79#define VK_PAD_LTHUMB_LEFT 0x5823
80#define VK_PAD_LTHUMB_UPLEFT 0x5824
81#define VK_PAD_LTHUMB_UPRIGHT 0x5825
82#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
83#define VK_PAD_LTHUMB_DOWNLEFT 0x5827
84#define VK_PAD_RTHUMB_UP 0x5830
85#define VK_PAD_RTHUMB_DOWN 0x5831
86#define VK_PAD_RTHUMB_RIGHT 0x5832
87#define VK_PAD_RTHUMB_LEFT 0x5833
88#define VK_PAD_RTHUMB_UPLEFT 0x5834
89#define VK_PAD_RTHUMB_UPRIGHT 0x5835
90#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
91#define VK_PAD_RTHUMB_DOWNLEFT 0x5837
92
93/*
94 * Deadzones are for analogue joystick controls on the joypad
95 * which determine when input should be assumed to be in the
96 * middle of the pad. This is a threshold to stop a joypad
97 * controlling the game when the player isn't touching the
98 * controls.
99 */
100
101#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
102#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
103#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
104
105
106/*
107 * Defines what type of abilities the type of joystick has
108 * DEVTYPE_GAMEPAD is available for all joysticks, however
109 * there may be more specific identifiers for other joysticks
110 * which are being used.
111 */
112
113#define XINPUT_DEVTYPE_GAMEPAD 0x01
114#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
115#define XINPUT_DEVSUBTYPE_WHEEL 0x02
116#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
117#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
118#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
119#define XINPUT_DEVSUBTYPE_GUITAR 0x06
120#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
121
122/*
123 * These are used with the XInputGetCapabilities function to
124 * determine the abilities to the joystick which has been
125 * plugged in.
126 */
127
128#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
129#define XINPUT_FLAG_GAMEPAD 0x00000001
130
131/*
132 * Defines the status of the battery if one is used in the
133 * attached joystick. The first two define if the joystick
134 * supports a battery. Disconnected means that the joystick
135 * isn't connected. Wired shows that the joystick is a wired
136 * joystick.
137 */
138
139#define BATTERY_DEVTYPE_GAMEPAD 0x00
140#define BATTERY_DEVTYPE_HEADSET 0x01
141#define BATTERY_TYPE_DISCONNECTED 0x00
142#define BATTERY_TYPE_WIRED 0x01
143#define BATTERY_TYPE_ALKALINE 0x02
144#define BATTERY_TYPE_NIMH 0x03
145#define BATTERY_TYPE_UNKNOWN 0xFF
146#define BATTERY_LEVEL_EMPTY 0x00
147#define BATTERY_LEVEL_LOW 0x01
148#define BATTERY_LEVEL_MEDIUM 0x02
149#define BATTERY_LEVEL_FULL 0x03
150
151/*
152 * How many joysticks can be used with this library. Games that
153 * use the xinput library will not go over this number.
154 */
155
156#define XUSER_MAX_COUNT 4
157#define XUSER_INDEX_ANY 0x000000FF
158
159/*
160 * Defines the structure of an xbox 360 joystick.
161 */
162
163typedef struct _XINPUT_GAMEPAD {
164 WORD wButtons;
165 BYTE bLeftTrigger;
166 BYTE bRightTrigger;
167 SHORT sThumbLX;
168 SHORT sThumbLY;
169 SHORT sThumbRX;
170 SHORT sThumbRY;
171} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
172
173typedef struct _XINPUT_STATE {
174 DWORD dwPacketNumber;
175 XINPUT_GAMEPAD Gamepad;
176} XINPUT_STATE, *PXINPUT_STATE;
177
178/*
179 * Defines the structure of how much vibration is set on both the
180 * right and left motors in a joystick. If you're not using a 360
181 * joystick you will have to map these to your device.
182 */
183
184typedef struct _XINPUT_VIBRATION {
185 WORD wLeftMotorSpeed;
186 WORD wRightMotorSpeed;
187} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
188
189/*
190 * Defines the structure for what kind of abilities the joystick has
191 * such abilities are things such as if the joystick has the ability
192 * to send and receive audio, if the joystick is in fact a driving
193 * wheel or perhaps if the joystick is some kind of dance pad or
194 * guitar.
195 */
196
197typedef struct _XINPUT_CAPABILITIES {
198 BYTE Type;
199 BYTE SubType;
200 WORD Flags;
201 XINPUT_GAMEPAD Gamepad;
202 XINPUT_VIBRATION Vibration;
203} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
204
205/*
206 * Defines the structure for a joystick input event which is
207 * retrieved using the function XInputGetKeystroke
208 */
209typedef struct _XINPUT_KEYSTROKE {
210 WORD VirtualKey;
211 WCHAR Unicode;
212 WORD Flags;
213 BYTE UserIndex;
214 BYTE HidCode;
215} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
216
217typedef struct _XINPUT_BATTERY_INFORMATION
218{
219 BYTE BatteryType;
220 BYTE BatteryLevel;
221} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
222
223#ifdef __cplusplus
224extern "C" {
225#endif
226
227void WINAPI XInputEnable(WINBOOL);
228DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
229DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
230DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
231DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
232DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
233DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
234
235#ifdef __cplusplus
236}
237#endif
238
239#endif /* __WINE_XINPUT_H */
diff --git a/raylib/src/external/glfw/deps/wayland/fractional-scale-v1.xml b/raylib/src/external/glfw/deps/wayland/fractional-scale-v1.xml
new file mode 100644
index 0000000..350bfc0
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/fractional-scale-v1.xml
@@ -0,0 +1,102 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="fractional_scale_v1">
3 <copyright>
4 Copyright © 2022 Kenny Levinsen
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
15 Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 DEALINGS IN THE SOFTWARE.
24 </copyright>
25
26 <description summary="Protocol for requesting fractional surface scales">
27 This protocol allows a compositor to suggest for surfaces to render at
28 fractional scales.
29
30 A client can submit scaled content by utilizing wp_viewport. This is done by
31 creating a wp_viewport object for the surface and setting the destination
32 rectangle to the surface size before the scale factor is applied.
33
34 The buffer size is calculated by multiplying the surface size by the
35 intended scale.
36
37 The wl_surface buffer scale should remain set to 1.
38
39 If a surface has a surface-local size of 100 px by 50 px and wishes to
40 submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should
41 be used and the wp_viewport destination rectangle should be 100 px by 50 px.
42
43 For toplevel surfaces, the size is rounded halfway away from zero. The
44 rounding algorithm for subsurface position and size is not defined.
45 </description>
46
47 <interface name="wp_fractional_scale_manager_v1" version="1">
48 <description summary="fractional surface scale information">
49 A global interface for requesting surfaces to use fractional scales.
50 </description>
51
52 <request name="destroy" type="destructor">
53 <description summary="unbind the fractional surface scale interface">
54 Informs the server that the client will not be using this protocol
55 object anymore. This does not affect any other objects,
56 wp_fractional_scale_v1 objects included.
57 </description>
58 </request>
59
60 <enum name="error">
61 <entry name="fractional_scale_exists" value="0"
62 summary="the surface already has a fractional_scale object associated"/>
63 </enum>
64
65 <request name="get_fractional_scale">
66 <description summary="extend surface interface for scale information">
67 Create an add-on object for the the wl_surface to let the compositor
68 request fractional scales. If the given wl_surface already has a
69 wp_fractional_scale_v1 object associated, the fractional_scale_exists
70 protocol error is raised.
71 </description>
72 <arg name="id" type="new_id" interface="wp_fractional_scale_v1"
73 summary="the new surface scale info interface id"/>
74 <arg name="surface" type="object" interface="wl_surface"
75 summary="the surface"/>
76 </request>
77 </interface>
78
79 <interface name="wp_fractional_scale_v1" version="1">
80 <description summary="fractional scale interface to a wl_surface">
81 An additional interface to a wl_surface object which allows the compositor
82 to inform the client of the preferred scale.
83 </description>
84
85 <request name="destroy" type="destructor">
86 <description summary="remove surface scale information for surface">
87 Destroy the fractional scale object. When this object is destroyed,
88 preferred_scale events will no longer be sent.
89 </description>
90 </request>
91
92 <event name="preferred_scale">
93 <description summary="notify of new preferred scale">
94 Notification of a new preferred scale for this surface that the
95 compositor suggests that the client should use.
96
97 The sent scale is the numerator of a fraction with a denominator of 120.
98 </description>
99 <arg name="scale" type="uint" summary="the new preferred scale"/>
100 </event>
101 </interface>
102</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/idle-inhibit-unstable-v1.xml b/raylib/src/external/glfw/deps/wayland/idle-inhibit-unstable-v1.xml
new file mode 100644
index 0000000..9c06cdc
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/idle-inhibit-unstable-v1.xml
@@ -0,0 +1,83 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="idle_inhibit_unstable_v1">
3
4 <copyright>
5 Copyright © 2015 Samsung Electronics Co., Ltd
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 and/or sell copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
16 Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25 </copyright>
26
27 <interface name="zwp_idle_inhibit_manager_v1" version="1">
28 <description summary="control behavior when display idles">
29 This interface permits inhibiting the idle behavior such as screen
30 blanking, locking, and screensaving. The client binds the idle manager
31 globally, then creates idle-inhibitor objects for each surface.
32
33 Warning! The protocol described in this file is experimental and
34 backward incompatible changes may be made. Backward compatible changes
35 may be added together with the corresponding interface version bump.
36 Backward incompatible changes are done by bumping the version number in
37 the protocol and interface names and resetting the interface version.
38 Once the protocol is to be declared stable, the 'z' prefix and the
39 version number in the protocol and interface names are removed and the
40 interface version number is reset.
41 </description>
42
43 <request name="destroy" type="destructor">
44 <description summary="destroy the idle inhibitor object">
45 Destroy the inhibit manager.
46 </description>
47 </request>
48
49 <request name="create_inhibitor">
50 <description summary="create a new inhibitor object">
51 Create a new inhibitor object associated with the given surface.
52 </description>
53 <arg name="id" type="new_id" interface="zwp_idle_inhibitor_v1"/>
54 <arg name="surface" type="object" interface="wl_surface"
55 summary="the surface that inhibits the idle behavior"/>
56 </request>
57
58 </interface>
59
60 <interface name="zwp_idle_inhibitor_v1" version="1">
61 <description summary="context object for inhibiting idle behavior">
62 An idle inhibitor prevents the output that the associated surface is
63 visible on from being set to a state where it is not visually usable due
64 to lack of user interaction (e.g. blanked, dimmed, locked, set to power
65 save, etc.) Any screensaver processes are also blocked from displaying.
66
67 If the surface is destroyed, unmapped, becomes occluded, loses
68 visibility, or otherwise becomes not visually relevant for the user, the
69 idle inhibitor will not be honored by the compositor; if the surface
70 subsequently regains visibility the inhibitor takes effect once again.
71 Likewise, the inhibitor isn't honored if the system was already idled at
72 the time the inhibitor was established, although if the system later
73 de-idles and re-idles the inhibitor will take effect.
74 </description>
75
76 <request name="destroy" type="destructor">
77 <description summary="destroy the idle inhibitor object">
78 Remove the inhibitor effect from the associated wl_surface.
79 </description>
80 </request>
81
82 </interface>
83</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/pointer-constraints-unstable-v1.xml b/raylib/src/external/glfw/deps/wayland/pointer-constraints-unstable-v1.xml
new file mode 100644
index 0000000..efd64b6
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/pointer-constraints-unstable-v1.xml
@@ -0,0 +1,339 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="pointer_constraints_unstable_v1">
3
4 <copyright>
5 Copyright © 2014 Jonas Ådahl
6 Copyright © 2015 Red Hat Inc.
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
17 Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 </copyright>
27
28 <description summary="protocol for constraining pointer motions">
29 This protocol specifies a set of interfaces used for adding constraints to
30 the motion of a pointer. Possible constraints include confining pointer
31 motions to a given region, or locking it to its current position.
32
33 In order to constrain the pointer, a client must first bind the global
34 interface "wp_pointer_constraints" which, if a compositor supports pointer
35 constraints, is exposed by the registry. Using the bound global object, the
36 client uses the request that corresponds to the type of constraint it wants
37 to make. See wp_pointer_constraints for more details.
38
39 Warning! The protocol described in this file is experimental and backward
40 incompatible changes may be made. Backward compatible changes may be added
41 together with the corresponding interface version bump. Backward
42 incompatible changes are done by bumping the version number in the protocol
43 and interface names and resetting the interface version. Once the protocol
44 is to be declared stable, the 'z' prefix and the version number in the
45 protocol and interface names are removed and the interface version number is
46 reset.
47 </description>
48
49 <interface name="zwp_pointer_constraints_v1" version="1">
50 <description summary="constrain the movement of a pointer">
51 The global interface exposing pointer constraining functionality. It
52 exposes two requests: lock_pointer for locking the pointer to its
53 position, and confine_pointer for locking the pointer to a region.
54
55 The lock_pointer and confine_pointer requests create the objects
56 wp_locked_pointer and wp_confined_pointer respectively, and the client can
57 use these objects to interact with the lock.
58
59 For any surface, only one lock or confinement may be active across all
60 wl_pointer objects of the same seat. If a lock or confinement is requested
61 when another lock or confinement is active or requested on the same surface
62 and with any of the wl_pointer objects of the same seat, an
63 'already_constrained' error will be raised.
64 </description>
65
66 <enum name="error">
67 <description summary="wp_pointer_constraints error values">
68 These errors can be emitted in response to wp_pointer_constraints
69 requests.
70 </description>
71 <entry name="already_constrained" value="1"
72 summary="pointer constraint already requested on that surface"/>
73 </enum>
74
75 <enum name="lifetime">
76 <description summary="constraint lifetime">
77 These values represent different lifetime semantics. They are passed
78 as arguments to the factory requests to specify how the constraint
79 lifetimes should be managed.
80 </description>
81 <entry name="oneshot" value="1">
82 <description summary="the pointer constraint is defunct once deactivated">
83 A oneshot pointer constraint will never reactivate once it has been
84 deactivated. See the corresponding deactivation event
85 (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
86 details.
87 </description>
88 </entry>
89 <entry name="persistent" value="2">
90 <description summary="the pointer constraint may reactivate">
91 A persistent pointer constraint may again reactivate once it has
92 been deactivated. See the corresponding deactivation event
93 (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
94 details.
95 </description>
96 </entry>
97 </enum>
98
99 <request name="destroy" type="destructor">
100 <description summary="destroy the pointer constraints manager object">
101 Used by the client to notify the server that it will no longer use this
102 pointer constraints object.
103 </description>
104 </request>
105
106 <request name="lock_pointer">
107 <description summary="lock pointer to a position">
108 The lock_pointer request lets the client request to disable movements of
109 the virtual pointer (i.e. the cursor), effectively locking the pointer
110 to a position. This request may not take effect immediately; in the
111 future, when the compositor deems implementation-specific constraints
112 are satisfied, the pointer lock will be activated and the compositor
113 sends a locked event.
114
115 The protocol provides no guarantee that the constraints are ever
116 satisfied, and does not require the compositor to send an error if the
117 constraints cannot ever be satisfied. It is thus possible to request a
118 lock that will never activate.
119
120 There may not be another pointer constraint of any kind requested or
121 active on the surface for any of the wl_pointer objects of the seat of
122 the passed pointer when requesting a lock. If there is, an error will be
123 raised. See general pointer lock documentation for more details.
124
125 The intersection of the region passed with this request and the input
126 region of the surface is used to determine where the pointer must be
127 in order for the lock to activate. It is up to the compositor whether to
128 warp the pointer or require some kind of user interaction for the lock
129 to activate. If the region is null the surface input region is used.
130
131 A surface may receive pointer focus without the lock being activated.
132
133 The request creates a new object wp_locked_pointer which is used to
134 interact with the lock as well as receive updates about its state. See
135 the the description of wp_locked_pointer for further information.
136
137 Note that while a pointer is locked, the wl_pointer objects of the
138 corresponding seat will not emit any wl_pointer.motion events, but
139 relative motion events will still be emitted via wp_relative_pointer
140 objects of the same seat. wl_pointer.axis and wl_pointer.button events
141 are unaffected.
142 </description>
143 <arg name="id" type="new_id" interface="zwp_locked_pointer_v1"/>
144 <arg name="surface" type="object" interface="wl_surface"
145 summary="surface to lock pointer to"/>
146 <arg name="pointer" type="object" interface="wl_pointer"
147 summary="the pointer that should be locked"/>
148 <arg name="region" type="object" interface="wl_region" allow-null="true"
149 summary="region of surface"/>
150 <arg name="lifetime" type="uint" enum="lifetime" summary="lock lifetime"/>
151 </request>
152
153 <request name="confine_pointer">
154 <description summary="confine pointer to a region">
155 The confine_pointer request lets the client request to confine the
156 pointer cursor to a given region. This request may not take effect
157 immediately; in the future, when the compositor deems implementation-
158 specific constraints are satisfied, the pointer confinement will be
159 activated and the compositor sends a confined event.
160
161 The intersection of the region passed with this request and the input
162 region of the surface is used to determine where the pointer must be
163 in order for the confinement to activate. It is up to the compositor
164 whether to warp the pointer or require some kind of user interaction for
165 the confinement to activate. If the region is null the surface input
166 region is used.
167
168 The request will create a new object wp_confined_pointer which is used
169 to interact with the confinement as well as receive updates about its
170 state. See the the description of wp_confined_pointer for further
171 information.
172 </description>
173 <arg name="id" type="new_id" interface="zwp_confined_pointer_v1"/>
174 <arg name="surface" type="object" interface="wl_surface"
175 summary="surface to lock pointer to"/>
176 <arg name="pointer" type="object" interface="wl_pointer"
177 summary="the pointer that should be confined"/>
178 <arg name="region" type="object" interface="wl_region" allow-null="true"
179 summary="region of surface"/>
180 <arg name="lifetime" type="uint" enum="lifetime" summary="confinement lifetime"/>
181 </request>
182 </interface>
183
184 <interface name="zwp_locked_pointer_v1" version="1">
185 <description summary="receive relative pointer motion events">
186 The wp_locked_pointer interface represents a locked pointer state.
187
188 While the lock of this object is active, the wl_pointer objects of the
189 associated seat will not emit any wl_pointer.motion events.
190
191 This object will send the event 'locked' when the lock is activated.
192 Whenever the lock is activated, it is guaranteed that the locked surface
193 will already have received pointer focus and that the pointer will be
194 within the region passed to the request creating this object.
195
196 To unlock the pointer, send the destroy request. This will also destroy
197 the wp_locked_pointer object.
198
199 If the compositor decides to unlock the pointer the unlocked event is
200 sent. See wp_locked_pointer.unlock for details.
201
202 When unlocking, the compositor may warp the cursor position to the set
203 cursor position hint. If it does, it will not result in any relative
204 motion events emitted via wp_relative_pointer.
205
206 If the surface the lock was requested on is destroyed and the lock is not
207 yet activated, the wp_locked_pointer object is now defunct and must be
208 destroyed.
209 </description>
210
211 <request name="destroy" type="destructor">
212 <description summary="destroy the locked pointer object">
213 Destroy the locked pointer object. If applicable, the compositor will
214 unlock the pointer.
215 </description>
216 </request>
217
218 <request name="set_cursor_position_hint">
219 <description summary="set the pointer cursor position hint">
220 Set the cursor position hint relative to the top left corner of the
221 surface.
222
223 If the client is drawing its own cursor, it should update the position
224 hint to the position of its own cursor. A compositor may use this
225 information to warp the pointer upon unlock in order to avoid pointer
226 jumps.
227
228 The cursor position hint is double buffered. The new hint will only take
229 effect when the associated surface gets it pending state applied. See
230 wl_surface.commit for details.
231 </description>
232 <arg name="surface_x" type="fixed"
233 summary="surface-local x coordinate"/>
234 <arg name="surface_y" type="fixed"
235 summary="surface-local y coordinate"/>
236 </request>
237
238 <request name="set_region">
239 <description summary="set a new lock region">
240 Set a new region used to lock the pointer.
241
242 The new lock region is double-buffered. The new lock region will
243 only take effect when the associated surface gets its pending state
244 applied. See wl_surface.commit for details.
245
246 For details about the lock region, see wp_locked_pointer.
247 </description>
248 <arg name="region" type="object" interface="wl_region" allow-null="true"
249 summary="region of surface"/>
250 </request>
251
252 <event name="locked">
253 <description summary="lock activation event">
254 Notification that the pointer lock of the seat's pointer is activated.
255 </description>
256 </event>
257
258 <event name="unlocked">
259 <description summary="lock deactivation event">
260 Notification that the pointer lock of the seat's pointer is no longer
261 active. If this is a oneshot pointer lock (see
262 wp_pointer_constraints.lifetime) this object is now defunct and should
263 be destroyed. If this is a persistent pointer lock (see
264 wp_pointer_constraints.lifetime) this pointer lock may again
265 reactivate in the future.
266 </description>
267 </event>
268 </interface>
269
270 <interface name="zwp_confined_pointer_v1" version="1">
271 <description summary="confined pointer object">
272 The wp_confined_pointer interface represents a confined pointer state.
273
274 This object will send the event 'confined' when the confinement is
275 activated. Whenever the confinement is activated, it is guaranteed that
276 the surface the pointer is confined to will already have received pointer
277 focus and that the pointer will be within the region passed to the request
278 creating this object. It is up to the compositor to decide whether this
279 requires some user interaction and if the pointer will warp to within the
280 passed region if outside.
281
282 To unconfine the pointer, send the destroy request. This will also destroy
283 the wp_confined_pointer object.
284
285 If the compositor decides to unconfine the pointer the unconfined event is
286 sent. The wp_confined_pointer object is at this point defunct and should
287 be destroyed.
288 </description>
289
290 <request name="destroy" type="destructor">
291 <description summary="destroy the confined pointer object">
292 Destroy the confined pointer object. If applicable, the compositor will
293 unconfine the pointer.
294 </description>
295 </request>
296
297 <request name="set_region">
298 <description summary="set a new confine region">
299 Set a new region used to confine the pointer.
300
301 The new confine region is double-buffered. The new confine region will
302 only take effect when the associated surface gets its pending state
303 applied. See wl_surface.commit for details.
304
305 If the confinement is active when the new confinement region is applied
306 and the pointer ends up outside of newly applied region, the pointer may
307 warped to a position within the new confinement region. If warped, a
308 wl_pointer.motion event will be emitted, but no
309 wp_relative_pointer.relative_motion event.
310
311 The compositor may also, instead of using the new region, unconfine the
312 pointer.
313
314 For details about the confine region, see wp_confined_pointer.
315 </description>
316 <arg name="region" type="object" interface="wl_region" allow-null="true"
317 summary="region of surface"/>
318 </request>
319
320 <event name="confined">
321 <description summary="pointer confined">
322 Notification that the pointer confinement of the seat's pointer is
323 activated.
324 </description>
325 </event>
326
327 <event name="unconfined">
328 <description summary="pointer unconfined">
329 Notification that the pointer confinement of the seat's pointer is no
330 longer active. If this is a oneshot pointer confinement (see
331 wp_pointer_constraints.lifetime) this object is now defunct and should
332 be destroyed. If this is a persistent pointer confinement (see
333 wp_pointer_constraints.lifetime) this pointer confinement may again
334 reactivate in the future.
335 </description>
336 </event>
337 </interface>
338
339</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/relative-pointer-unstable-v1.xml b/raylib/src/external/glfw/deps/wayland/relative-pointer-unstable-v1.xml
new file mode 100644
index 0000000..ca6f81d
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/relative-pointer-unstable-v1.xml
@@ -0,0 +1,136 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="relative_pointer_unstable_v1">
3
4 <copyright>
5 Copyright © 2014 Jonas Ådahl
6 Copyright © 2015 Red Hat Inc.
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
17 Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 </copyright>
27
28 <description summary="protocol for relative pointer motion events">
29 This protocol specifies a set of interfaces used for making clients able to
30 receive relative pointer events not obstructed by barriers (such as the
31 monitor edge or other pointer barriers).
32
33 To start receiving relative pointer events, a client must first bind the
34 global interface "wp_relative_pointer_manager" which, if a compositor
35 supports relative pointer motion events, is exposed by the registry. After
36 having created the relative pointer manager proxy object, the client uses
37 it to create the actual relative pointer object using the
38 "get_relative_pointer" request given a wl_pointer. The relative pointer
39 motion events will then, when applicable, be transmitted via the proxy of
40 the newly created relative pointer object. See the documentation of the
41 relative pointer interface for more details.
42
43 Warning! The protocol described in this file is experimental and backward
44 incompatible changes may be made. Backward compatible changes may be added
45 together with the corresponding interface version bump. Backward
46 incompatible changes are done by bumping the version number in the protocol
47 and interface names and resetting the interface version. Once the protocol
48 is to be declared stable, the 'z' prefix and the version number in the
49 protocol and interface names are removed and the interface version number is
50 reset.
51 </description>
52
53 <interface name="zwp_relative_pointer_manager_v1" version="1">
54 <description summary="get relative pointer objects">
55 A global interface used for getting the relative pointer object for a
56 given pointer.
57 </description>
58
59 <request name="destroy" type="destructor">
60 <description summary="destroy the relative pointer manager object">
61 Used by the client to notify the server that it will no longer use this
62 relative pointer manager object.
63 </description>
64 </request>
65
66 <request name="get_relative_pointer">
67 <description summary="get a relative pointer object">
68 Create a relative pointer interface given a wl_pointer object. See the
69 wp_relative_pointer interface for more details.
70 </description>
71 <arg name="id" type="new_id" interface="zwp_relative_pointer_v1"/>
72 <arg name="pointer" type="object" interface="wl_pointer"/>
73 </request>
74 </interface>
75
76 <interface name="zwp_relative_pointer_v1" version="1">
77 <description summary="relative pointer object">
78 A wp_relative_pointer object is an extension to the wl_pointer interface
79 used for emitting relative pointer events. It shares the same focus as
80 wl_pointer objects of the same seat and will only emit events when it has
81 focus.
82 </description>
83
84 <request name="destroy" type="destructor">
85 <description summary="release the relative pointer object"/>
86 </request>
87
88 <event name="relative_motion">
89 <description summary="relative pointer motion">
90 Relative x/y pointer motion from the pointer of the seat associated with
91 this object.
92
93 A relative motion is in the same dimension as regular wl_pointer motion
94 events, except they do not represent an absolute position. For example,
95 moving a pointer from (x, y) to (x', y') would have the equivalent
96 relative motion (x' - x, y' - y). If a pointer motion caused the
97 absolute pointer position to be clipped by for example the edge of the
98 monitor, the relative motion is unaffected by the clipping and will
99 represent the unclipped motion.
100
101 This event also contains non-accelerated motion deltas. The
102 non-accelerated delta is, when applicable, the regular pointer motion
103 delta as it was before having applied motion acceleration and other
104 transformations such as normalization.
105
106 Note that the non-accelerated delta does not represent 'raw' events as
107 they were read from some device. Pointer motion acceleration is device-
108 and configuration-specific and non-accelerated deltas and accelerated
109 deltas may have the same value on some devices.
110
111 Relative motions are not coupled to wl_pointer.motion events, and can be
112 sent in combination with such events, but also independently. There may
113 also be scenarios where wl_pointer.motion is sent, but there is no
114 relative motion. The order of an absolute and relative motion event
115 originating from the same physical motion is not guaranteed.
116
117 If the client needs button events or focus state, it can receive them
118 from a wl_pointer object of the same seat that the wp_relative_pointer
119 object is associated with.
120 </description>
121 <arg name="utime_hi" type="uint"
122 summary="high 32 bits of a 64 bit timestamp with microsecond granularity"/>
123 <arg name="utime_lo" type="uint"
124 summary="low 32 bits of a 64 bit timestamp with microsecond granularity"/>
125 <arg name="dx" type="fixed"
126 summary="the x component of the motion vector"/>
127 <arg name="dy" type="fixed"
128 summary="the y component of the motion vector"/>
129 <arg name="dx_unaccel" type="fixed"
130 summary="the x component of the unaccelerated motion vector"/>
131 <arg name="dy_unaccel" type="fixed"
132 summary="the y component of the unaccelerated motion vector"/>
133 </event>
134 </interface>
135
136</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/viewporter.xml b/raylib/src/external/glfw/deps/wayland/viewporter.xml
new file mode 100644
index 0000000..d1048d1
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/viewporter.xml
@@ -0,0 +1,180 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="viewporter">
3
4 <copyright>
5 Copyright © 2013-2016 Collabora, Ltd.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 and/or sell copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
16 Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25 </copyright>
26
27 <interface name="wp_viewporter" version="1">
28 <description summary="surface cropping and scaling">
29 The global interface exposing surface cropping and scaling
30 capabilities is used to instantiate an interface extension for a
31 wl_surface object. This extended interface will then allow
32 cropping and scaling the surface contents, effectively
33 disconnecting the direct relationship between the buffer and the
34 surface size.
35 </description>
36
37 <request name="destroy" type="destructor">
38 <description summary="unbind from the cropping and scaling interface">
39 Informs the server that the client will not be using this
40 protocol object anymore. This does not affect any other objects,
41 wp_viewport objects included.
42 </description>
43 </request>
44
45 <enum name="error">
46 <entry name="viewport_exists" value="0"
47 summary="the surface already has a viewport object associated"/>
48 </enum>
49
50 <request name="get_viewport">
51 <description summary="extend surface interface for crop and scale">
52 Instantiate an interface extension for the given wl_surface to
53 crop and scale its content. If the given wl_surface already has
54 a wp_viewport object associated, the viewport_exists
55 protocol error is raised.
56 </description>
57 <arg name="id" type="new_id" interface="wp_viewport"
58 summary="the new viewport interface id"/>
59 <arg name="surface" type="object" interface="wl_surface"
60 summary="the surface"/>
61 </request>
62 </interface>
63
64 <interface name="wp_viewport" version="1">
65 <description summary="crop and scale interface to a wl_surface">
66 An additional interface to a wl_surface object, which allows the
67 client to specify the cropping and scaling of the surface
68 contents.
69
70 This interface works with two concepts: the source rectangle (src_x,
71 src_y, src_width, src_height), and the destination size (dst_width,
72 dst_height). The contents of the source rectangle are scaled to the
73 destination size, and content outside the source rectangle is ignored.
74 This state is double-buffered, and is applied on the next
75 wl_surface.commit.
76
77 The two parts of crop and scale state are independent: the source
78 rectangle, and the destination size. Initially both are unset, that
79 is, no scaling is applied. The whole of the current wl_buffer is
80 used as the source, and the surface size is as defined in
81 wl_surface.attach.
82
83 If the destination size is set, it causes the surface size to become
84 dst_width, dst_height. The source (rectangle) is scaled to exactly
85 this size. This overrides whatever the attached wl_buffer size is,
86 unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
87 has no content and therefore no size. Otherwise, the size is always
88 at least 1x1 in surface local coordinates.
89
90 If the source rectangle is set, it defines what area of the wl_buffer is
91 taken as the source. If the source rectangle is set and the destination
92 size is not set, then src_width and src_height must be integers, and the
93 surface size becomes the source rectangle size. This results in cropping
94 without scaling. If src_width or src_height are not integers and
95 destination size is not set, the bad_size protocol error is raised when
96 the surface state is applied.
97
98 The coordinate transformations from buffer pixel coordinates up to
99 the surface-local coordinates happen in the following order:
100 1. buffer_transform (wl_surface.set_buffer_transform)
101 2. buffer_scale (wl_surface.set_buffer_scale)
102 3. crop and scale (wp_viewport.set*)
103 This means, that the source rectangle coordinates of crop and scale
104 are given in the coordinates after the buffer transform and scale,
105 i.e. in the coordinates that would be the surface-local coordinates
106 if the crop and scale was not applied.
107
108 If src_x or src_y are negative, the bad_value protocol error is raised.
109 Otherwise, if the source rectangle is partially or completely outside of
110 the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
111 when the surface state is applied. A NULL wl_buffer does not raise the
112 out_of_buffer error.
113
114 If the wl_surface associated with the wp_viewport is destroyed,
115 all wp_viewport requests except 'destroy' raise the protocol error
116 no_surface.
117
118 If the wp_viewport object is destroyed, the crop and scale
119 state is removed from the wl_surface. The change will be applied
120 on the next wl_surface.commit.
121 </description>
122
123 <request name="destroy" type="destructor">
124 <description summary="remove scaling and cropping from the surface">
125 The associated wl_surface's crop and scale state is removed.
126 The change is applied on the next wl_surface.commit.
127 </description>
128 </request>
129
130 <enum name="error">
131 <entry name="bad_value" value="0"
132 summary="negative or zero values in width or height"/>
133 <entry name="bad_size" value="1"
134 summary="destination size is not integer"/>
135 <entry name="out_of_buffer" value="2"
136 summary="source rectangle extends outside of the content area"/>
137 <entry name="no_surface" value="3"
138 summary="the wl_surface was destroyed"/>
139 </enum>
140
141 <request name="set_source">
142 <description summary="set the source rectangle for cropping">
143 Set the source rectangle of the associated wl_surface. See
144 wp_viewport for the description, and relation to the wl_buffer
145 size.
146
147 If all of x, y, width and height are -1.0, the source rectangle is
148 unset instead. Any other set of values where width or height are zero
149 or negative, or x or y are negative, raise the bad_value protocol
150 error.
151
152 The crop and scale state is double-buffered state, and will be
153 applied on the next wl_surface.commit.
154 </description>
155 <arg name="x" type="fixed" summary="source rectangle x"/>
156 <arg name="y" type="fixed" summary="source rectangle y"/>
157 <arg name="width" type="fixed" summary="source rectangle width"/>
158 <arg name="height" type="fixed" summary="source rectangle height"/>
159 </request>
160
161 <request name="set_destination">
162 <description summary="set the surface size for scaling">
163 Set the destination size of the associated wl_surface. See
164 wp_viewport for the description, and relation to the wl_buffer
165 size.
166
167 If width is -1 and height is -1, the destination size is unset
168 instead. Any other pair of values for width and height that
169 contains zero or negative values raises the bad_value protocol
170 error.
171
172 The crop and scale state is double-buffered state, and will be
173 applied on the next wl_surface.commit.
174 </description>
175 <arg name="width" type="int" summary="surface width"/>
176 <arg name="height" type="int" summary="surface height"/>
177 </request>
178 </interface>
179
180</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/wayland.xml b/raylib/src/external/glfw/deps/wayland/wayland.xml
new file mode 100644
index 0000000..10e039d
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/wayland.xml
@@ -0,0 +1,3151 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="wayland">
3
4 <copyright>
5 Copyright © 2008-2011 Kristian Høgsberg
6 Copyright © 2010-2011 Intel Corporation
7 Copyright © 2012-2013 Collabora, Ltd.
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation files
11 (the "Software"), to deal in the Software without restriction,
12 including without limitation the rights to use, copy, modify, merge,
13 publish, distribute, sublicense, and/or sell copies of the Software,
14 and to permit persons to whom the Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial
19 portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29 </copyright>
30
31 <interface name="wl_display" version="1">
32 <description summary="core global object">
33 The core global object. This is a special singleton object. It
34 is used for internal Wayland protocol features.
35 </description>
36
37 <request name="sync">
38 <description summary="asynchronous roundtrip">
39 The sync request asks the server to emit the 'done' event
40 on the returned wl_callback object. Since requests are
41 handled in-order and events are delivered in-order, this can
42 be used as a barrier to ensure all previous requests and the
43 resulting events have been handled.
44
45 The object returned by this request will be destroyed by the
46 compositor after the callback is fired and as such the client must not
47 attempt to use it after that point.
48
49 The callback_data passed in the callback is the event serial.
50 </description>
51 <arg name="callback" type="new_id" interface="wl_callback"
52 summary="callback object for the sync request"/>
53 </request>
54
55 <request name="get_registry">
56 <description summary="get global registry object">
57 This request creates a registry object that allows the client
58 to list and bind the global objects available from the
59 compositor.
60
61 It should be noted that the server side resources consumed in
62 response to a get_registry request can only be released when the
63 client disconnects, not when the client side proxy is destroyed.
64 Therefore, clients should invoke get_registry as infrequently as
65 possible to avoid wasting memory.
66 </description>
67 <arg name="registry" type="new_id" interface="wl_registry"
68 summary="global registry object"/>
69 </request>
70
71 <event name="error">
72 <description summary="fatal error event">
73 The error event is sent out when a fatal (non-recoverable)
74 error has occurred. The object_id argument is the object
75 where the error occurred, most often in response to a request
76 to that object. The code identifies the error and is defined
77 by the object interface. As such, each interface defines its
78 own set of error codes. The message is a brief description
79 of the error, for (debugging) convenience.
80 </description>
81 <arg name="object_id" type="object" summary="object where the error occurred"/>
82 <arg name="code" type="uint" summary="error code"/>
83 <arg name="message" type="string" summary="error description"/>
84 </event>
85
86 <enum name="error">
87 <description summary="global error values">
88 These errors are global and can be emitted in response to any
89 server request.
90 </description>
91 <entry name="invalid_object" value="0"
92 summary="server couldn't find object"/>
93 <entry name="invalid_method" value="1"
94 summary="method doesn't exist on the specified interface or malformed request"/>
95 <entry name="no_memory" value="2"
96 summary="server is out of memory"/>
97 <entry name="implementation" value="3"
98 summary="implementation error in compositor"/>
99 </enum>
100
101 <event name="delete_id">
102 <description summary="acknowledge object ID deletion">
103 This event is used internally by the object ID management
104 logic. When a client deletes an object that it had created,
105 the server will send this event to acknowledge that it has
106 seen the delete request. When the client receives this event,
107 it will know that it can safely reuse the object ID.
108 </description>
109 <arg name="id" type="uint" summary="deleted object ID"/>
110 </event>
111 </interface>
112
113 <interface name="wl_registry" version="1">
114 <description summary="global registry object">
115 The singleton global registry object. The server has a number of
116 global objects that are available to all clients. These objects
117 typically represent an actual object in the server (for example,
118 an input device) or they are singleton objects that provide
119 extension functionality.
120
121 When a client creates a registry object, the registry object
122 will emit a global event for each global currently in the
123 registry. Globals come and go as a result of device or
124 monitor hotplugs, reconfiguration or other events, and the
125 registry will send out global and global_remove events to
126 keep the client up to date with the changes. To mark the end
127 of the initial burst of events, the client can use the
128 wl_display.sync request immediately after calling
129 wl_display.get_registry.
130
131 A client can bind to a global object by using the bind
132 request. This creates a client-side handle that lets the object
133 emit events to the client and lets the client invoke requests on
134 the object.
135 </description>
136
137 <request name="bind">
138 <description summary="bind an object to the display">
139 Binds a new, client-created object to the server using the
140 specified name as the identifier.
141 </description>
142 <arg name="name" type="uint" summary="unique numeric name of the object"/>
143 <arg name="id" type="new_id" summary="bounded object"/>
144 </request>
145
146 <event name="global">
147 <description summary="announce global object">
148 Notify the client of global objects.
149
150 The event notifies the client that a global object with
151 the given name is now available, and it implements the
152 given version of the given interface.
153 </description>
154 <arg name="name" type="uint" summary="numeric name of the global object"/>
155 <arg name="interface" type="string" summary="interface implemented by the object"/>
156 <arg name="version" type="uint" summary="interface version"/>
157 </event>
158
159 <event name="global_remove">
160 <description summary="announce removal of global object">
161 Notify the client of removed global objects.
162
163 This event notifies the client that the global identified
164 by name is no longer available. If the client bound to
165 the global using the bind request, the client should now
166 destroy that object.
167
168 The object remains valid and requests to the object will be
169 ignored until the client destroys it, to avoid races between
170 the global going away and a client sending a request to it.
171 </description>
172 <arg name="name" type="uint" summary="numeric name of the global object"/>
173 </event>
174 </interface>
175
176 <interface name="wl_callback" version="1">
177 <description summary="callback object">
178 Clients can handle the 'done' event to get notified when
179 the related request is done.
180
181 Note, because wl_callback objects are created from multiple independent
182 factory interfaces, the wl_callback interface is frozen at version 1.
183 </description>
184
185 <event name="done" type="destructor">
186 <description summary="done event">
187 Notify the client when the related request is done.
188 </description>
189 <arg name="callback_data" type="uint" summary="request-specific data for the callback"/>
190 </event>
191 </interface>
192
193 <interface name="wl_compositor" version="6">
194 <description summary="the compositor singleton">
195 A compositor. This object is a singleton global. The
196 compositor is in charge of combining the contents of multiple
197 surfaces into one displayable output.
198 </description>
199
200 <request name="create_surface">
201 <description summary="create new surface">
202 Ask the compositor to create a new surface.
203 </description>
204 <arg name="id" type="new_id" interface="wl_surface" summary="the new surface"/>
205 </request>
206
207 <request name="create_region">
208 <description summary="create new region">
209 Ask the compositor to create a new region.
210 </description>
211 <arg name="id" type="new_id" interface="wl_region" summary="the new region"/>
212 </request>
213 </interface>
214
215 <interface name="wl_shm_pool" version="1">
216 <description summary="a shared memory pool">
217 The wl_shm_pool object encapsulates a piece of memory shared
218 between the compositor and client. Through the wl_shm_pool
219 object, the client can allocate shared memory wl_buffer objects.
220 All objects created through the same pool share the same
221 underlying mapped memory. Reusing the mapped memory avoids the
222 setup/teardown overhead and is useful when interactively resizing
223 a surface or for many small buffers.
224 </description>
225
226 <request name="create_buffer">
227 <description summary="create a buffer from the pool">
228 Create a wl_buffer object from the pool.
229
230 The buffer is created offset bytes into the pool and has
231 width and height as specified. The stride argument specifies
232 the number of bytes from the beginning of one row to the beginning
233 of the next. The format is the pixel format of the buffer and
234 must be one of those advertised through the wl_shm.format event.
235
236 A buffer will keep a reference to the pool it was created from
237 so it is valid to destroy the pool immediately after creating
238 a buffer from it.
239 </description>
240 <arg name="id" type="new_id" interface="wl_buffer" summary="buffer to create"/>
241 <arg name="offset" type="int" summary="buffer byte offset within the pool"/>
242 <arg name="width" type="int" summary="buffer width, in pixels"/>
243 <arg name="height" type="int" summary="buffer height, in pixels"/>
244 <arg name="stride" type="int" summary="number of bytes from the beginning of one row to the beginning of the next row"/>
245 <arg name="format" type="uint" enum="wl_shm.format" summary="buffer pixel format"/>
246 </request>
247
248 <request name="destroy" type="destructor">
249 <description summary="destroy the pool">
250 Destroy the shared memory pool.
251
252 The mmapped memory will be released when all
253 buffers that have been created from this pool
254 are gone.
255 </description>
256 </request>
257
258 <request name="resize">
259 <description summary="change the size of the pool mapping">
260 This request will cause the server to remap the backing memory
261 for the pool from the file descriptor passed when the pool was
262 created, but using the new size. This request can only be
263 used to make the pool bigger.
264
265 This request only changes the amount of bytes that are mmapped
266 by the server and does not touch the file corresponding to the
267 file descriptor passed at creation time. It is the client's
268 responsibility to ensure that the file is at least as big as
269 the new pool size.
270 </description>
271 <arg name="size" type="int" summary="new size of the pool, in bytes"/>
272 </request>
273 </interface>
274
275 <interface name="wl_shm" version="1">
276 <description summary="shared memory support">
277 A singleton global object that provides support for shared
278 memory.
279
280 Clients can create wl_shm_pool objects using the create_pool
281 request.
282
283 On binding the wl_shm object one or more format events
284 are emitted to inform clients about the valid pixel formats
285 that can be used for buffers.
286 </description>
287
288 <enum name="error">
289 <description summary="wl_shm error values">
290 These errors can be emitted in response to wl_shm requests.
291 </description>
292 <entry name="invalid_format" value="0" summary="buffer format is not known"/>
293 <entry name="invalid_stride" value="1" summary="invalid size or stride during pool or buffer creation"/>
294 <entry name="invalid_fd" value="2" summary="mmapping the file descriptor failed"/>
295 </enum>
296
297 <enum name="format">
298 <description summary="pixel formats">
299 This describes the memory layout of an individual pixel.
300
301 All renderers should support argb8888 and xrgb8888 but any other
302 formats are optional and may not be supported by the particular
303 renderer in use.
304
305 The drm format codes match the macros defined in drm_fourcc.h, except
306 argb8888 and xrgb8888. The formats actually supported by the compositor
307 will be reported by the format event.
308
309 For all wl_shm formats and unless specified in another protocol
310 extension, pre-multiplied alpha is used for pixel values.
311 </description>
312 <!-- Note to protocol writers: don't update this list manually, instead
313 run the automated script that keeps it in sync with drm_fourcc.h. -->
314 <entry name="argb8888" value="0" summary="32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian"/>
315 <entry name="xrgb8888" value="1" summary="32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian"/>
316 <entry name="c8" value="0x20203843" summary="8-bit color index format, [7:0] C"/>
317 <entry name="rgb332" value="0x38424752" summary="8-bit RGB format, [7:0] R:G:B 3:3:2"/>
318 <entry name="bgr233" value="0x38524742" summary="8-bit BGR format, [7:0] B:G:R 2:3:3"/>
319 <entry name="xrgb4444" value="0x32315258" summary="16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian"/>
320 <entry name="xbgr4444" value="0x32314258" summary="16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian"/>
321 <entry name="rgbx4444" value="0x32315852" summary="16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian"/>
322 <entry name="bgrx4444" value="0x32315842" summary="16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian"/>
323 <entry name="argb4444" value="0x32315241" summary="16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian"/>
324 <entry name="abgr4444" value="0x32314241" summary="16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian"/>
325 <entry name="rgba4444" value="0x32314152" summary="16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian"/>
326 <entry name="bgra4444" value="0x32314142" summary="16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian"/>
327 <entry name="xrgb1555" value="0x35315258" summary="16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian"/>
328 <entry name="xbgr1555" value="0x35314258" summary="16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian"/>
329 <entry name="rgbx5551" value="0x35315852" summary="16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian"/>
330 <entry name="bgrx5551" value="0x35315842" summary="16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian"/>
331 <entry name="argb1555" value="0x35315241" summary="16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian"/>
332 <entry name="abgr1555" value="0x35314241" summary="16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian"/>
333 <entry name="rgba5551" value="0x35314152" summary="16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian"/>
334 <entry name="bgra5551" value="0x35314142" summary="16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian"/>
335 <entry name="rgb565" value="0x36314752" summary="16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian"/>
336 <entry name="bgr565" value="0x36314742" summary="16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian"/>
337 <entry name="rgb888" value="0x34324752" summary="24-bit RGB format, [23:0] R:G:B little endian"/>
338 <entry name="bgr888" value="0x34324742" summary="24-bit BGR format, [23:0] B:G:R little endian"/>
339 <entry name="xbgr8888" value="0x34324258" summary="32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian"/>
340 <entry name="rgbx8888" value="0x34325852" summary="32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian"/>
341 <entry name="bgrx8888" value="0x34325842" summary="32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian"/>
342 <entry name="abgr8888" value="0x34324241" summary="32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian"/>
343 <entry name="rgba8888" value="0x34324152" summary="32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian"/>
344 <entry name="bgra8888" value="0x34324142" summary="32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian"/>
345 <entry name="xrgb2101010" value="0x30335258" summary="32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian"/>
346 <entry name="xbgr2101010" value="0x30334258" summary="32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian"/>
347 <entry name="rgbx1010102" value="0x30335852" summary="32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian"/>
348 <entry name="bgrx1010102" value="0x30335842" summary="32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian"/>
349 <entry name="argb2101010" value="0x30335241" summary="32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian"/>
350 <entry name="abgr2101010" value="0x30334241" summary="32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian"/>
351 <entry name="rgba1010102" value="0x30334152" summary="32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian"/>
352 <entry name="bgra1010102" value="0x30334142" summary="32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian"/>
353 <entry name="yuyv" value="0x56595559" summary="packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian"/>
354 <entry name="yvyu" value="0x55595659" summary="packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian"/>
355 <entry name="uyvy" value="0x59565955" summary="packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian"/>
356 <entry name="vyuy" value="0x59555956" summary="packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian"/>
357 <entry name="ayuv" value="0x56555941" summary="packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian"/>
358 <entry name="nv12" value="0x3231564e" summary="2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane"/>
359 <entry name="nv21" value="0x3132564e" summary="2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane"/>
360 <entry name="nv16" value="0x3631564e" summary="2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane"/>
361 <entry name="nv61" value="0x3136564e" summary="2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane"/>
362 <entry name="yuv410" value="0x39565559" summary="3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes"/>
363 <entry name="yvu410" value="0x39555659" summary="3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes"/>
364 <entry name="yuv411" value="0x31315559" summary="3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes"/>
365 <entry name="yvu411" value="0x31315659" summary="3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes"/>
366 <entry name="yuv420" value="0x32315559" summary="3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes"/>
367 <entry name="yvu420" value="0x32315659" summary="3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes"/>
368 <entry name="yuv422" value="0x36315559" summary="3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes"/>
369 <entry name="yvu422" value="0x36315659" summary="3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes"/>
370 <entry name="yuv444" value="0x34325559" summary="3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes"/>
371 <entry name="yvu444" value="0x34325659" summary="3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes"/>
372 <entry name="r8" value="0x20203852" summary="[7:0] R"/>
373 <entry name="r16" value="0x20363152" summary="[15:0] R little endian"/>
374 <entry name="rg88" value="0x38384752" summary="[15:0] R:G 8:8 little endian"/>
375 <entry name="gr88" value="0x38385247" summary="[15:0] G:R 8:8 little endian"/>
376 <entry name="rg1616" value="0x32334752" summary="[31:0] R:G 16:16 little endian"/>
377 <entry name="gr1616" value="0x32335247" summary="[31:0] G:R 16:16 little endian"/>
378 <entry name="xrgb16161616f" value="0x48345258" summary="[63:0] x:R:G:B 16:16:16:16 little endian"/>
379 <entry name="xbgr16161616f" value="0x48344258" summary="[63:0] x:B:G:R 16:16:16:16 little endian"/>
380 <entry name="argb16161616f" value="0x48345241" summary="[63:0] A:R:G:B 16:16:16:16 little endian"/>
381 <entry name="abgr16161616f" value="0x48344241" summary="[63:0] A:B:G:R 16:16:16:16 little endian"/>
382 <entry name="xyuv8888" value="0x56555958" summary="[31:0] X:Y:Cb:Cr 8:8:8:8 little endian"/>
383 <entry name="vuy888" value="0x34325556" summary="[23:0] Cr:Cb:Y 8:8:8 little endian"/>
384 <entry name="vuy101010" value="0x30335556" summary="Y followed by U then V, 10:10:10. Non-linear modifier only"/>
385 <entry name="y210" value="0x30313259" summary="[63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels"/>
386 <entry name="y212" value="0x32313259" summary="[63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels"/>
387 <entry name="y216" value="0x36313259" summary="[63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels"/>
388 <entry name="y410" value="0x30313459" summary="[31:0] A:Cr:Y:Cb 2:10:10:10 little endian"/>
389 <entry name="y412" value="0x32313459" summary="[63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian"/>
390 <entry name="y416" value="0x36313459" summary="[63:0] A:Cr:Y:Cb 16:16:16:16 little endian"/>
391 <entry name="xvyu2101010" value="0x30335658" summary="[31:0] X:Cr:Y:Cb 2:10:10:10 little endian"/>
392 <entry name="xvyu12_16161616" value="0x36335658" summary="[63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian"/>
393 <entry name="xvyu16161616" value="0x38345658" summary="[63:0] X:Cr:Y:Cb 16:16:16:16 little endian"/>
394 <entry name="y0l0" value="0x304c3059" summary="[63:0] A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian"/>
395 <entry name="x0l0" value="0x304c3058" summary="[63:0] X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian"/>
396 <entry name="y0l2" value="0x324c3059" summary="[63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian"/>
397 <entry name="x0l2" value="0x324c3058" summary="[63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian"/>
398 <entry name="yuv420_8bit" value="0x38305559"/>
399 <entry name="yuv420_10bit" value="0x30315559"/>
400 <entry name="xrgb8888_a8" value="0x38415258"/>
401 <entry name="xbgr8888_a8" value="0x38414258"/>
402 <entry name="rgbx8888_a8" value="0x38415852"/>
403 <entry name="bgrx8888_a8" value="0x38415842"/>
404 <entry name="rgb888_a8" value="0x38413852"/>
405 <entry name="bgr888_a8" value="0x38413842"/>
406 <entry name="rgb565_a8" value="0x38413552"/>
407 <entry name="bgr565_a8" value="0x38413542"/>
408 <entry name="nv24" value="0x3432564e" summary="non-subsampled Cr:Cb plane"/>
409 <entry name="nv42" value="0x3234564e" summary="non-subsampled Cb:Cr plane"/>
410 <entry name="p210" value="0x30313250" summary="2x1 subsampled Cr:Cb plane, 10 bit per channel"/>
411 <entry name="p010" value="0x30313050" summary="2x2 subsampled Cr:Cb plane 10 bits per channel"/>
412 <entry name="p012" value="0x32313050" summary="2x2 subsampled Cr:Cb plane 12 bits per channel"/>
413 <entry name="p016" value="0x36313050" summary="2x2 subsampled Cr:Cb plane 16 bits per channel"/>
414 <entry name="axbxgxrx106106106106" value="0x30314241" summary="[63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian"/>
415 <entry name="nv15" value="0x3531564e" summary="2x2 subsampled Cr:Cb plane"/>
416 <entry name="q410" value="0x30313451"/>
417 <entry name="q401" value="0x31303451"/>
418 <entry name="xrgb16161616" value="0x38345258" summary="[63:0] x:R:G:B 16:16:16:16 little endian"/>
419 <entry name="xbgr16161616" value="0x38344258" summary="[63:0] x:B:G:R 16:16:16:16 little endian"/>
420 <entry name="argb16161616" value="0x38345241" summary="[63:0] A:R:G:B 16:16:16:16 little endian"/>
421 <entry name="abgr16161616" value="0x38344241" summary="[63:0] A:B:G:R 16:16:16:16 little endian"/>
422 </enum>
423
424 <request name="create_pool">
425 <description summary="create a shm pool">
426 Create a new wl_shm_pool object.
427
428 The pool can be used to create shared memory based buffer
429 objects. The server will mmap size bytes of the passed file
430 descriptor, to use as backing memory for the pool.
431 </description>
432 <arg name="id" type="new_id" interface="wl_shm_pool" summary="pool to create"/>
433 <arg name="fd" type="fd" summary="file descriptor for the pool"/>
434 <arg name="size" type="int" summary="pool size, in bytes"/>
435 </request>
436
437 <event name="format">
438 <description summary="pixel format description">
439 Informs the client about a valid pixel format that
440 can be used for buffers. Known formats include
441 argb8888 and xrgb8888.
442 </description>
443 <arg name="format" type="uint" enum="format" summary="buffer pixel format"/>
444 </event>
445 </interface>
446
447 <interface name="wl_buffer" version="1">
448 <description summary="content for a wl_surface">
449 A buffer provides the content for a wl_surface. Buffers are
450 created through factory interfaces such as wl_shm, wp_linux_buffer_params
451 (from the linux-dmabuf protocol extension) or similar. It has a width and
452 a height and can be attached to a wl_surface, but the mechanism by which a
453 client provides and updates the contents is defined by the buffer factory
454 interface.
455
456 If the buffer uses a format that has an alpha channel, the alpha channel
457 is assumed to be premultiplied in the color channels unless otherwise
458 specified.
459
460 Note, because wl_buffer objects are created from multiple independent
461 factory interfaces, the wl_buffer interface is frozen at version 1.
462 </description>
463
464 <request name="destroy" type="destructor">
465 <description summary="destroy a buffer">
466 Destroy a buffer. If and how you need to release the backing
467 storage is defined by the buffer factory interface.
468
469 For possible side-effects to a surface, see wl_surface.attach.
470 </description>
471 </request>
472
473 <event name="release">
474 <description summary="compositor releases buffer">
475 Sent when this wl_buffer is no longer used by the compositor.
476 The client is now free to reuse or destroy this buffer and its
477 backing storage.
478
479 If a client receives a release event before the frame callback
480 requested in the same wl_surface.commit that attaches this
481 wl_buffer to a surface, then the client is immediately free to
482 reuse the buffer and its backing storage, and does not need a
483 second buffer for the next surface content update. Typically
484 this is possible, when the compositor maintains a copy of the
485 wl_surface contents, e.g. as a GL texture. This is an important
486 optimization for GL(ES) compositors with wl_shm clients.
487 </description>
488 </event>
489 </interface>
490
491 <interface name="wl_data_offer" version="3">
492 <description summary="offer to transfer data">
493 A wl_data_offer represents a piece of data offered for transfer
494 by another client (the source client). It is used by the
495 copy-and-paste and drag-and-drop mechanisms. The offer
496 describes the different mime types that the data can be
497 converted to and provides the mechanism for transferring the
498 data directly from the source client.
499 </description>
500
501 <enum name="error">
502 <entry name="invalid_finish" value="0"
503 summary="finish request was called untimely"/>
504 <entry name="invalid_action_mask" value="1"
505 summary="action mask contains invalid values"/>
506 <entry name="invalid_action" value="2"
507 summary="action argument has an invalid value"/>
508 <entry name="invalid_offer" value="3"
509 summary="offer doesn't accept this request"/>
510 </enum>
511
512 <request name="accept">
513 <description summary="accept one of the offered mime types">
514 Indicate that the client can accept the given mime type, or
515 NULL for not accepted.
516
517 For objects of version 2 or older, this request is used by the
518 client to give feedback whether the client can receive the given
519 mime type, or NULL if none is accepted; the feedback does not
520 determine whether the drag-and-drop operation succeeds or not.
521
522 For objects of version 3 or newer, this request determines the
523 final result of the drag-and-drop operation. If the end result
524 is that no mime types were accepted, the drag-and-drop operation
525 will be cancelled and the corresponding drag source will receive
526 wl_data_source.cancelled. Clients may still use this event in
527 conjunction with wl_data_source.action for feedback.
528 </description>
529 <arg name="serial" type="uint" summary="serial number of the accept request"/>
530 <arg name="mime_type" type="string" allow-null="true" summary="mime type accepted by the client"/>
531 </request>
532
533 <request name="receive">
534 <description summary="request that the data is transferred">
535 To transfer the offered data, the client issues this request
536 and indicates the mime type it wants to receive. The transfer
537 happens through the passed file descriptor (typically created
538 with the pipe system call). The source client writes the data
539 in the mime type representation requested and then closes the
540 file descriptor.
541
542 The receiving client reads from the read end of the pipe until
543 EOF and then closes its end, at which point the transfer is
544 complete.
545
546 This request may happen multiple times for different mime types,
547 both before and after wl_data_device.drop. Drag-and-drop destination
548 clients may preemptively fetch data or examine it more closely to
549 determine acceptance.
550 </description>
551 <arg name="mime_type" type="string" summary="mime type desired by receiver"/>
552 <arg name="fd" type="fd" summary="file descriptor for data transfer"/>
553 </request>
554
555 <request name="destroy" type="destructor">
556 <description summary="destroy data offer">
557 Destroy the data offer.
558 </description>
559 </request>
560
561 <event name="offer">
562 <description summary="advertise offered mime type">
563 Sent immediately after creating the wl_data_offer object. One
564 event per offered mime type.
565 </description>
566 <arg name="mime_type" type="string" summary="offered mime type"/>
567 </event>
568
569 <!-- Version 3 additions -->
570
571 <request name="finish" since="3">
572 <description summary="the offer will no longer be used">
573 Notifies the compositor that the drag destination successfully
574 finished the drag-and-drop operation.
575
576 Upon receiving this request, the compositor will emit
577 wl_data_source.dnd_finished on the drag source client.
578
579 It is a client error to perform other requests than
580 wl_data_offer.destroy after this one. It is also an error to perform
581 this request after a NULL mime type has been set in
582 wl_data_offer.accept or no action was received through
583 wl_data_offer.action.
584
585 If wl_data_offer.finish request is received for a non drag and drop
586 operation, the invalid_finish protocol error is raised.
587 </description>
588 </request>
589
590 <request name="set_actions" since="3">
591 <description summary="set the available/preferred drag-and-drop actions">
592 Sets the actions that the destination side client supports for
593 this operation. This request may trigger the emission of
594 wl_data_source.action and wl_data_offer.action events if the compositor
595 needs to change the selected action.
596
597 This request can be called multiple times throughout the
598 drag-and-drop operation, typically in response to wl_data_device.enter
599 or wl_data_device.motion events.
600
601 This request determines the final result of the drag-and-drop
602 operation. If the end result is that no action is accepted,
603 the drag source will receive wl_data_source.cancelled.
604
605 The dnd_actions argument must contain only values expressed in the
606 wl_data_device_manager.dnd_actions enum, and the preferred_action
607 argument must only contain one of those values set, otherwise it
608 will result in a protocol error.
609
610 While managing an "ask" action, the destination drag-and-drop client
611 may perform further wl_data_offer.receive requests, and is expected
612 to perform one last wl_data_offer.set_actions request with a preferred
613 action other than "ask" (and optionally wl_data_offer.accept) before
614 requesting wl_data_offer.finish, in order to convey the action selected
615 by the user. If the preferred action is not in the
616 wl_data_offer.source_actions mask, an error will be raised.
617
618 If the "ask" action is dismissed (e.g. user cancellation), the client
619 is expected to perform wl_data_offer.destroy right away.
620
621 This request can only be made on drag-and-drop offers, a protocol error
622 will be raised otherwise.
623 </description>
624 <arg name="dnd_actions" type="uint" summary="actions supported by the destination client"
625 enum="wl_data_device_manager.dnd_action"/>
626 <arg name="preferred_action" type="uint" summary="action preferred by the destination client"
627 enum="wl_data_device_manager.dnd_action"/>
628 </request>
629
630 <event name="source_actions" since="3">
631 <description summary="notify the source-side available actions">
632 This event indicates the actions offered by the data source. It
633 will be sent immediately after creating the wl_data_offer object,
634 or anytime the source side changes its offered actions through
635 wl_data_source.set_actions.
636 </description>
637 <arg name="source_actions" type="uint" summary="actions offered by the data source"
638 enum="wl_data_device_manager.dnd_action"/>
639 </event>
640
641 <event name="action" since="3">
642 <description summary="notify the selected action">
643 This event indicates the action selected by the compositor after
644 matching the source/destination side actions. Only one action (or
645 none) will be offered here.
646
647 This event can be emitted multiple times during the drag-and-drop
648 operation in response to destination side action changes through
649 wl_data_offer.set_actions.
650
651 This event will no longer be emitted after wl_data_device.drop
652 happened on the drag-and-drop destination, the client must
653 honor the last action received, or the last preferred one set
654 through wl_data_offer.set_actions when handling an "ask" action.
655
656 Compositors may also change the selected action on the fly, mainly
657 in response to keyboard modifier changes during the drag-and-drop
658 operation.
659
660 The most recent action received is always the valid one. Prior to
661 receiving wl_data_device.drop, the chosen action may change (e.g.
662 due to keyboard modifiers being pressed). At the time of receiving
663 wl_data_device.drop the drag-and-drop destination must honor the
664 last action received.
665
666 Action changes may still happen after wl_data_device.drop,
667 especially on "ask" actions, where the drag-and-drop destination
668 may choose another action afterwards. Action changes happening
669 at this stage are always the result of inter-client negotiation, the
670 compositor shall no longer be able to induce a different action.
671
672 Upon "ask" actions, it is expected that the drag-and-drop destination
673 may potentially choose a different action and/or mime type,
674 based on wl_data_offer.source_actions and finally chosen by the
675 user (e.g. popping up a menu with the available options). The
676 final wl_data_offer.set_actions and wl_data_offer.accept requests
677 must happen before the call to wl_data_offer.finish.
678 </description>
679 <arg name="dnd_action" type="uint" summary="action selected by the compositor"
680 enum="wl_data_device_manager.dnd_action"/>
681 </event>
682 </interface>
683
684 <interface name="wl_data_source" version="3">
685 <description summary="offer to transfer data">
686 The wl_data_source object is the source side of a wl_data_offer.
687 It is created by the source client in a data transfer and
688 provides a way to describe the offered data and a way to respond
689 to requests to transfer the data.
690 </description>
691
692 <enum name="error">
693 <entry name="invalid_action_mask" value="0"
694 summary="action mask contains invalid values"/>
695 <entry name="invalid_source" value="1"
696 summary="source doesn't accept this request"/>
697 </enum>
698
699 <request name="offer">
700 <description summary="add an offered mime type">
701 This request adds a mime type to the set of mime types
702 advertised to targets. Can be called several times to offer
703 multiple types.
704 </description>
705 <arg name="mime_type" type="string" summary="mime type offered by the data source"/>
706 </request>
707
708 <request name="destroy" type="destructor">
709 <description summary="destroy the data source">
710 Destroy the data source.
711 </description>
712 </request>
713
714 <event name="target">
715 <description summary="a target accepts an offered mime type">
716 Sent when a target accepts pointer_focus or motion events. If
717 a target does not accept any of the offered types, type is NULL.
718
719 Used for feedback during drag-and-drop.
720 </description>
721 <arg name="mime_type" type="string" allow-null="true" summary="mime type accepted by the target"/>
722 </event>
723
724 <event name="send">
725 <description summary="send the data">
726 Request for data from the client. Send the data as the
727 specified mime type over the passed file descriptor, then
728 close it.
729 </description>
730 <arg name="mime_type" type="string" summary="mime type for the data"/>
731 <arg name="fd" type="fd" summary="file descriptor for the data"/>
732 </event>
733
734 <event name="cancelled">
735 <description summary="selection was cancelled">
736 This data source is no longer valid. There are several reasons why
737 this could happen:
738
739 - The data source has been replaced by another data source.
740 - The drag-and-drop operation was performed, but the drop destination
741 did not accept any of the mime types offered through
742 wl_data_source.target.
743 - The drag-and-drop operation was performed, but the drop destination
744 did not select any of the actions present in the mask offered through
745 wl_data_source.action.
746 - The drag-and-drop operation was performed but didn't happen over a
747 surface.
748 - The compositor cancelled the drag-and-drop operation (e.g. compositor
749 dependent timeouts to avoid stale drag-and-drop transfers).
750
751 The client should clean up and destroy this data source.
752
753 For objects of version 2 or older, wl_data_source.cancelled will
754 only be emitted if the data source was replaced by another data
755 source.
756 </description>
757 </event>
758
759 <!-- Version 3 additions -->
760
761 <request name="set_actions" since="3">
762 <description summary="set the available drag-and-drop actions">
763 Sets the actions that the source side client supports for this
764 operation. This request may trigger wl_data_source.action and
765 wl_data_offer.action events if the compositor needs to change the
766 selected action.
767
768 The dnd_actions argument must contain only values expressed in the
769 wl_data_device_manager.dnd_actions enum, otherwise it will result
770 in a protocol error.
771
772 This request must be made once only, and can only be made on sources
773 used in drag-and-drop, so it must be performed before
774 wl_data_device.start_drag. Attempting to use the source other than
775 for drag-and-drop will raise a protocol error.
776 </description>
777 <arg name="dnd_actions" type="uint" summary="actions supported by the data source"
778 enum="wl_data_device_manager.dnd_action"/>
779 </request>
780
781 <event name="dnd_drop_performed" since="3">
782 <description summary="the drag-and-drop operation physically finished">
783 The user performed the drop action. This event does not indicate
784 acceptance, wl_data_source.cancelled may still be emitted afterwards
785 if the drop destination does not accept any mime type.
786
787 However, this event might however not be received if the compositor
788 cancelled the drag-and-drop operation before this event could happen.
789
790 Note that the data_source may still be used in the future and should
791 not be destroyed here.
792 </description>
793 </event>
794
795 <event name="dnd_finished" since="3">
796 <description summary="the drag-and-drop operation concluded">
797 The drop destination finished interoperating with this data
798 source, so the client is now free to destroy this data source and
799 free all associated data.
800
801 If the action used to perform the operation was "move", the
802 source can now delete the transferred data.
803 </description>
804 </event>
805
806 <event name="action" since="3">
807 <description summary="notify the selected action">
808 This event indicates the action selected by the compositor after
809 matching the source/destination side actions. Only one action (or
810 none) will be offered here.
811
812 This event can be emitted multiple times during the drag-and-drop
813 operation, mainly in response to destination side changes through
814 wl_data_offer.set_actions, and as the data device enters/leaves
815 surfaces.
816
817 It is only possible to receive this event after
818 wl_data_source.dnd_drop_performed if the drag-and-drop operation
819 ended in an "ask" action, in which case the final wl_data_source.action
820 event will happen immediately before wl_data_source.dnd_finished.
821
822 Compositors may also change the selected action on the fly, mainly
823 in response to keyboard modifier changes during the drag-and-drop
824 operation.
825
826 The most recent action received is always the valid one. The chosen
827 action may change alongside negotiation (e.g. an "ask" action can turn
828 into a "move" operation), so the effects of the final action must
829 always be applied in wl_data_offer.dnd_finished.
830
831 Clients can trigger cursor surface changes from this point, so
832 they reflect the current action.
833 </description>
834 <arg name="dnd_action" type="uint" summary="action selected by the compositor"
835 enum="wl_data_device_manager.dnd_action"/>
836 </event>
837 </interface>
838
839 <interface name="wl_data_device" version="3">
840 <description summary="data transfer device">
841 There is one wl_data_device per seat which can be obtained
842 from the global wl_data_device_manager singleton.
843
844 A wl_data_device provides access to inter-client data transfer
845 mechanisms such as copy-and-paste and drag-and-drop.
846 </description>
847
848 <enum name="error">
849 <entry name="role" value="0" summary="given wl_surface has another role"/>
850 </enum>
851
852 <request name="start_drag">
853 <description summary="start drag-and-drop operation">
854 This request asks the compositor to start a drag-and-drop
855 operation on behalf of the client.
856
857 The source argument is the data source that provides the data
858 for the eventual data transfer. If source is NULL, enter, leave
859 and motion events are sent only to the client that initiated the
860 drag and the client is expected to handle the data passing
861 internally. If source is destroyed, the drag-and-drop session will be
862 cancelled.
863
864 The origin surface is the surface where the drag originates and
865 the client must have an active implicit grab that matches the
866 serial.
867
868 The icon surface is an optional (can be NULL) surface that
869 provides an icon to be moved around with the cursor. Initially,
870 the top-left corner of the icon surface is placed at the cursor
871 hotspot, but subsequent wl_surface.attach request can move the
872 relative position. Attach requests must be confirmed with
873 wl_surface.commit as usual. The icon surface is given the role of
874 a drag-and-drop icon. If the icon surface already has another role,
875 it raises a protocol error.
876
877 The input region is ignored for wl_surfaces with the role of a
878 drag-and-drop icon.
879 </description>
880 <arg name="source" type="object" interface="wl_data_source" allow-null="true" summary="data source for the eventual transfer"/>
881 <arg name="origin" type="object" interface="wl_surface" summary="surface where the drag originates"/>
882 <arg name="icon" type="object" interface="wl_surface" allow-null="true" summary="drag-and-drop icon surface"/>
883 <arg name="serial" type="uint" summary="serial number of the implicit grab on the origin"/>
884 </request>
885
886 <request name="set_selection">
887 <description summary="copy data to the selection">
888 This request asks the compositor to set the selection
889 to the data from the source on behalf of the client.
890
891 To unset the selection, set the source to NULL.
892 </description>
893 <arg name="source" type="object" interface="wl_data_source" allow-null="true" summary="data source for the selection"/>
894 <arg name="serial" type="uint" summary="serial number of the event that triggered this request"/>
895 </request>
896
897 <event name="data_offer">
898 <description summary="introduce a new wl_data_offer">
899 The data_offer event introduces a new wl_data_offer object,
900 which will subsequently be used in either the
901 data_device.enter event (for drag-and-drop) or the
902 data_device.selection event (for selections). Immediately
903 following the data_device.data_offer event, the new data_offer
904 object will send out data_offer.offer events to describe the
905 mime types it offers.
906 </description>
907 <arg name="id" type="new_id" interface="wl_data_offer" summary="the new data_offer object"/>
908 </event>
909
910 <event name="enter">
911 <description summary="initiate drag-and-drop session">
912 This event is sent when an active drag-and-drop pointer enters
913 a surface owned by the client. The position of the pointer at
914 enter time is provided by the x and y arguments, in surface-local
915 coordinates.
916 </description>
917 <arg name="serial" type="uint" summary="serial number of the enter event"/>
918 <arg name="surface" type="object" interface="wl_surface" summary="client surface entered"/>
919 <arg name="x" type="fixed" summary="surface-local x coordinate"/>
920 <arg name="y" type="fixed" summary="surface-local y coordinate"/>
921 <arg name="id" type="object" interface="wl_data_offer" allow-null="true"
922 summary="source data_offer object"/>
923 </event>
924
925 <event name="leave">
926 <description summary="end drag-and-drop session">
927 This event is sent when the drag-and-drop pointer leaves the
928 surface and the session ends. The client must destroy the
929 wl_data_offer introduced at enter time at this point.
930 </description>
931 </event>
932
933 <event name="motion">
934 <description summary="drag-and-drop session motion">
935 This event is sent when the drag-and-drop pointer moves within
936 the currently focused surface. The new position of the pointer
937 is provided by the x and y arguments, in surface-local
938 coordinates.
939 </description>
940 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
941 <arg name="x" type="fixed" summary="surface-local x coordinate"/>
942 <arg name="y" type="fixed" summary="surface-local y coordinate"/>
943 </event>
944
945 <event name="drop">
946 <description summary="end drag-and-drop session successfully">
947 The event is sent when a drag-and-drop operation is ended
948 because the implicit grab is removed.
949
950 The drag-and-drop destination is expected to honor the last action
951 received through wl_data_offer.action, if the resulting action is
952 "copy" or "move", the destination can still perform
953 wl_data_offer.receive requests, and is expected to end all
954 transfers with a wl_data_offer.finish request.
955
956 If the resulting action is "ask", the action will not be considered
957 final. The drag-and-drop destination is expected to perform one last
958 wl_data_offer.set_actions request, or wl_data_offer.destroy in order
959 to cancel the operation.
960 </description>
961 </event>
962
963 <event name="selection">
964 <description summary="advertise new selection">
965 The selection event is sent out to notify the client of a new
966 wl_data_offer for the selection for this device. The
967 data_device.data_offer and the data_offer.offer events are
968 sent out immediately before this event to introduce the data
969 offer object. The selection event is sent to a client
970 immediately before receiving keyboard focus and when a new
971 selection is set while the client has keyboard focus. The
972 data_offer is valid until a new data_offer or NULL is received
973 or until the client loses keyboard focus. Switching surface with
974 keyboard focus within the same client doesn't mean a new selection
975 will be sent. The client must destroy the previous selection
976 data_offer, if any, upon receiving this event.
977 </description>
978 <arg name="id" type="object" interface="wl_data_offer" allow-null="true"
979 summary="selection data_offer object"/>
980 </event>
981
982 <!-- Version 2 additions -->
983
984 <request name="release" type="destructor" since="2">
985 <description summary="destroy data device">
986 This request destroys the data device.
987 </description>
988 </request>
989 </interface>
990
991 <interface name="wl_data_device_manager" version="3">
992 <description summary="data transfer interface">
993 The wl_data_device_manager is a singleton global object that
994 provides access to inter-client data transfer mechanisms such as
995 copy-and-paste and drag-and-drop. These mechanisms are tied to
996 a wl_seat and this interface lets a client get a wl_data_device
997 corresponding to a wl_seat.
998
999 Depending on the version bound, the objects created from the bound
1000 wl_data_device_manager object will have different requirements for
1001 functioning properly. See wl_data_source.set_actions,
1002 wl_data_offer.accept and wl_data_offer.finish for details.
1003 </description>
1004
1005 <request name="create_data_source">
1006 <description summary="create a new data source">
1007 Create a new data source.
1008 </description>
1009 <arg name="id" type="new_id" interface="wl_data_source" summary="data source to create"/>
1010 </request>
1011
1012 <request name="get_data_device">
1013 <description summary="create a new data device">
1014 Create a new data device for a given seat.
1015 </description>
1016 <arg name="id" type="new_id" interface="wl_data_device" summary="data device to create"/>
1017 <arg name="seat" type="object" interface="wl_seat" summary="seat associated with the data device"/>
1018 </request>
1019
1020 <!-- Version 3 additions -->
1021
1022 <enum name="dnd_action" bitfield="true" since="3">
1023 <description summary="drag and drop actions">
1024 This is a bitmask of the available/preferred actions in a
1025 drag-and-drop operation.
1026
1027 In the compositor, the selected action is a result of matching the
1028 actions offered by the source and destination sides. "action" events
1029 with a "none" action will be sent to both source and destination if
1030 there is no match. All further checks will effectively happen on
1031 (source actions ∩ destination actions).
1032
1033 In addition, compositors may also pick different actions in
1034 reaction to key modifiers being pressed. One common design that
1035 is used in major toolkits (and the behavior recommended for
1036 compositors) is:
1037
1038 - If no modifiers are pressed, the first match (in bit order)
1039 will be used.
1040 - Pressing Shift selects "move", if enabled in the mask.
1041 - Pressing Control selects "copy", if enabled in the mask.
1042
1043 Behavior beyond that is considered implementation-dependent.
1044 Compositors may for example bind other modifiers (like Alt/Meta)
1045 or drags initiated with other buttons than BTN_LEFT to specific
1046 actions (e.g. "ask").
1047 </description>
1048 <entry name="none" value="0" summary="no action"/>
1049 <entry name="copy" value="1" summary="copy action"/>
1050 <entry name="move" value="2" summary="move action"/>
1051 <entry name="ask" value="4" summary="ask action"/>
1052 </enum>
1053 </interface>
1054
1055 <interface name="wl_shell" version="1">
1056 <description summary="create desktop-style surfaces">
1057 This interface is implemented by servers that provide
1058 desktop-style user interfaces.
1059
1060 It allows clients to associate a wl_shell_surface with
1061 a basic surface.
1062
1063 Note! This protocol is deprecated and not intended for production use.
1064 For desktop-style user interfaces, use xdg_shell. Compositors and clients
1065 should not implement this interface.
1066 </description>
1067
1068 <enum name="error">
1069 <entry name="role" value="0" summary="given wl_surface has another role"/>
1070 </enum>
1071
1072 <request name="get_shell_surface">
1073 <description summary="create a shell surface from a surface">
1074 Create a shell surface for an existing surface. This gives
1075 the wl_surface the role of a shell surface. If the wl_surface
1076 already has another role, it raises a protocol error.
1077
1078 Only one shell surface can be associated with a given surface.
1079 </description>
1080 <arg name="id" type="new_id" interface="wl_shell_surface" summary="shell surface to create"/>
1081 <arg name="surface" type="object" interface="wl_surface" summary="surface to be given the shell surface role"/>
1082 </request>
1083 </interface>
1084
1085 <interface name="wl_shell_surface" version="1">
1086 <description summary="desktop-style metadata interface">
1087 An interface that may be implemented by a wl_surface, for
1088 implementations that provide a desktop-style user interface.
1089
1090 It provides requests to treat surfaces like toplevel, fullscreen
1091 or popup windows, move, resize or maximize them, associate
1092 metadata like title and class, etc.
1093
1094 On the server side the object is automatically destroyed when
1095 the related wl_surface is destroyed. On the client side,
1096 wl_shell_surface_destroy() must be called before destroying
1097 the wl_surface object.
1098 </description>
1099
1100 <request name="pong">
1101 <description summary="respond to a ping event">
1102 A client must respond to a ping event with a pong request or
1103 the client may be deemed unresponsive.
1104 </description>
1105 <arg name="serial" type="uint" summary="serial number of the ping event"/>
1106 </request>
1107
1108 <request name="move">
1109 <description summary="start an interactive move">
1110 Start a pointer-driven move of the surface.
1111
1112 This request must be used in response to a button press event.
1113 The server may ignore move requests depending on the state of
1114 the surface (e.g. fullscreen or maximized).
1115 </description>
1116 <arg name="seat" type="object" interface="wl_seat" summary="seat whose pointer is used"/>
1117 <arg name="serial" type="uint" summary="serial number of the implicit grab on the pointer"/>
1118 </request>
1119
1120 <enum name="resize" bitfield="true">
1121 <description summary="edge values for resizing">
1122 These values are used to indicate which edge of a surface
1123 is being dragged in a resize operation. The server may
1124 use this information to adapt its behavior, e.g. choose
1125 an appropriate cursor image.
1126 </description>
1127 <entry name="none" value="0" summary="no edge"/>
1128 <entry name="top" value="1" summary="top edge"/>
1129 <entry name="bottom" value="2" summary="bottom edge"/>
1130 <entry name="left" value="4" summary="left edge"/>
1131 <entry name="top_left" value="5" summary="top and left edges"/>
1132 <entry name="bottom_left" value="6" summary="bottom and left edges"/>
1133 <entry name="right" value="8" summary="right edge"/>
1134 <entry name="top_right" value="9" summary="top and right edges"/>
1135 <entry name="bottom_right" value="10" summary="bottom and right edges"/>
1136 </enum>
1137
1138 <request name="resize">
1139 <description summary="start an interactive resize">
1140 Start a pointer-driven resizing of the surface.
1141
1142 This request must be used in response to a button press event.
1143 The server may ignore resize requests depending on the state of
1144 the surface (e.g. fullscreen or maximized).
1145 </description>
1146 <arg name="seat" type="object" interface="wl_seat" summary="seat whose pointer is used"/>
1147 <arg name="serial" type="uint" summary="serial number of the implicit grab on the pointer"/>
1148 <arg name="edges" type="uint" enum="resize" summary="which edge or corner is being dragged"/>
1149 </request>
1150
1151 <request name="set_toplevel">
1152 <description summary="make the surface a toplevel surface">
1153 Map the surface as a toplevel surface.
1154
1155 A toplevel surface is not fullscreen, maximized or transient.
1156 </description>
1157 </request>
1158
1159 <enum name="transient" bitfield="true">
1160 <description summary="details of transient behaviour">
1161 These flags specify details of the expected behaviour
1162 of transient surfaces. Used in the set_transient request.
1163 </description>
1164 <entry name="inactive" value="0x1" summary="do not set keyboard focus"/>
1165 </enum>
1166
1167 <request name="set_transient">
1168 <description summary="make the surface a transient surface">
1169 Map the surface relative to an existing surface.
1170
1171 The x and y arguments specify the location of the upper left
1172 corner of the surface relative to the upper left corner of the
1173 parent surface, in surface-local coordinates.
1174
1175 The flags argument controls details of the transient behaviour.
1176 </description>
1177 <arg name="parent" type="object" interface="wl_surface" summary="parent surface"/>
1178 <arg name="x" type="int" summary="surface-local x coordinate"/>
1179 <arg name="y" type="int" summary="surface-local y coordinate"/>
1180 <arg name="flags" type="uint" enum="transient" summary="transient surface behavior"/>
1181 </request>
1182
1183 <enum name="fullscreen_method">
1184 <description summary="different method to set the surface fullscreen">
1185 Hints to indicate to the compositor how to deal with a conflict
1186 between the dimensions of the surface and the dimensions of the
1187 output. The compositor is free to ignore this parameter.
1188 </description>
1189 <entry name="default" value="0" summary="no preference, apply default policy"/>
1190 <entry name="scale" value="1" summary="scale, preserve the surface's aspect ratio and center on output"/>
1191 <entry name="driver" value="2" summary="switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch"/>
1192 <entry name="fill" value="3" summary="no upscaling, center on output and add black borders to compensate size mismatch"/>
1193 </enum>
1194
1195 <request name="set_fullscreen">
1196 <description summary="make the surface a fullscreen surface">
1197 Map the surface as a fullscreen surface.
1198
1199 If an output parameter is given then the surface will be made
1200 fullscreen on that output. If the client does not specify the
1201 output then the compositor will apply its policy - usually
1202 choosing the output on which the surface has the biggest surface
1203 area.
1204
1205 The client may specify a method to resolve a size conflict
1206 between the output size and the surface size - this is provided
1207 through the method parameter.
1208
1209 The framerate parameter is used only when the method is set
1210 to "driver", to indicate the preferred framerate. A value of 0
1211 indicates that the client does not care about framerate. The
1212 framerate is specified in mHz, that is framerate of 60000 is 60Hz.
1213
1214 A method of "scale" or "driver" implies a scaling operation of
1215 the surface, either via a direct scaling operation or a change of
1216 the output mode. This will override any kind of output scaling, so
1217 that mapping a surface with a buffer size equal to the mode can
1218 fill the screen independent of buffer_scale.
1219
1220 A method of "fill" means we don't scale up the buffer, however
1221 any output scale is applied. This means that you may run into
1222 an edge case where the application maps a buffer with the same
1223 size of the output mode but buffer_scale 1 (thus making a
1224 surface larger than the output). In this case it is allowed to
1225 downscale the results to fit the screen.
1226
1227 The compositor must reply to this request with a configure event
1228 with the dimensions for the output on which the surface will
1229 be made fullscreen.
1230 </description>
1231 <arg name="method" type="uint" enum="fullscreen_method" summary="method for resolving size conflict"/>
1232 <arg name="framerate" type="uint" summary="framerate in mHz"/>
1233 <arg name="output" type="object" interface="wl_output" allow-null="true"
1234 summary="output on which the surface is to be fullscreen"/>
1235 </request>
1236
1237 <request name="set_popup">
1238 <description summary="make the surface a popup surface">
1239 Map the surface as a popup.
1240
1241 A popup surface is a transient surface with an added pointer
1242 grab.
1243
1244 An existing implicit grab will be changed to owner-events mode,
1245 and the popup grab will continue after the implicit grab ends
1246 (i.e. releasing the mouse button does not cause the popup to
1247 be unmapped).
1248
1249 The popup grab continues until the window is destroyed or a
1250 mouse button is pressed in any other client's window. A click
1251 in any of the client's surfaces is reported as normal, however,
1252 clicks in other clients' surfaces will be discarded and trigger
1253 the callback.
1254
1255 The x and y arguments specify the location of the upper left
1256 corner of the surface relative to the upper left corner of the
1257 parent surface, in surface-local coordinates.
1258 </description>
1259 <arg name="seat" type="object" interface="wl_seat" summary="seat whose pointer is used"/>
1260 <arg name="serial" type="uint" summary="serial number of the implicit grab on the pointer"/>
1261 <arg name="parent" type="object" interface="wl_surface" summary="parent surface"/>
1262 <arg name="x" type="int" summary="surface-local x coordinate"/>
1263 <arg name="y" type="int" summary="surface-local y coordinate"/>
1264 <arg name="flags" type="uint" enum="transient" summary="transient surface behavior"/>
1265 </request>
1266
1267 <request name="set_maximized">
1268 <description summary="make the surface a maximized surface">
1269 Map the surface as a maximized surface.
1270
1271 If an output parameter is given then the surface will be
1272 maximized on that output. If the client does not specify the
1273 output then the compositor will apply its policy - usually
1274 choosing the output on which the surface has the biggest surface
1275 area.
1276
1277 The compositor will reply with a configure event telling
1278 the expected new surface size. The operation is completed
1279 on the next buffer attach to this surface.
1280
1281 A maximized surface typically fills the entire output it is
1282 bound to, except for desktop elements such as panels. This is
1283 the main difference between a maximized shell surface and a
1284 fullscreen shell surface.
1285
1286 The details depend on the compositor implementation.
1287 </description>
1288 <arg name="output" type="object" interface="wl_output" allow-null="true"
1289 summary="output on which the surface is to be maximized"/>
1290 </request>
1291
1292 <request name="set_title">
1293 <description summary="set surface title">
1294 Set a short title for the surface.
1295
1296 This string may be used to identify the surface in a task bar,
1297 window list, or other user interface elements provided by the
1298 compositor.
1299
1300 The string must be encoded in UTF-8.
1301 </description>
1302 <arg name="title" type="string" summary="surface title"/>
1303 </request>
1304
1305 <request name="set_class">
1306 <description summary="set surface class">
1307 Set a class for the surface.
1308
1309 The surface class identifies the general class of applications
1310 to which the surface belongs. A common convention is to use the
1311 file name (or the full path if it is a non-standard location) of
1312 the application's .desktop file as the class.
1313 </description>
1314 <arg name="class_" type="string" summary="surface class"/>
1315 </request>
1316
1317 <event name="ping">
1318 <description summary="ping client">
1319 Ping a client to check if it is receiving events and sending
1320 requests. A client is expected to reply with a pong request.
1321 </description>
1322 <arg name="serial" type="uint" summary="serial number of the ping"/>
1323 </event>
1324
1325 <event name="configure">
1326 <description summary="suggest resize">
1327 The configure event asks the client to resize its surface.
1328
1329 The size is a hint, in the sense that the client is free to
1330 ignore it if it doesn't resize, pick a smaller size (to
1331 satisfy aspect ratio or resize in steps of NxM pixels).
1332
1333 The edges parameter provides a hint about how the surface
1334 was resized. The client may use this information to decide
1335 how to adjust its content to the new size (e.g. a scrolling
1336 area might adjust its content position to leave the viewable
1337 content unmoved).
1338
1339 The client is free to dismiss all but the last configure
1340 event it received.
1341
1342 The width and height arguments specify the size of the window
1343 in surface-local coordinates.
1344 </description>
1345 <arg name="edges" type="uint" enum="resize" summary="how the surface was resized"/>
1346 <arg name="width" type="int" summary="new width of the surface"/>
1347 <arg name="height" type="int" summary="new height of the surface"/>
1348 </event>
1349
1350 <event name="popup_done">
1351 <description summary="popup interaction is done">
1352 The popup_done event is sent out when a popup grab is broken,
1353 that is, when the user clicks a surface that doesn't belong
1354 to the client owning the popup surface.
1355 </description>
1356 </event>
1357 </interface>
1358
1359 <interface name="wl_surface" version="6">
1360 <description summary="an onscreen surface">
1361 A surface is a rectangular area that may be displayed on zero
1362 or more outputs, and shown any number of times at the compositor's
1363 discretion. They can present wl_buffers, receive user input, and
1364 define a local coordinate system.
1365
1366 The size of a surface (and relative positions on it) is described
1367 in surface-local coordinates, which may differ from the buffer
1368 coordinates of the pixel content, in case a buffer_transform
1369 or a buffer_scale is used.
1370
1371 A surface without a "role" is fairly useless: a compositor does
1372 not know where, when or how to present it. The role is the
1373 purpose of a wl_surface. Examples of roles are a cursor for a
1374 pointer (as set by wl_pointer.set_cursor), a drag icon
1375 (wl_data_device.start_drag), a sub-surface
1376 (wl_subcompositor.get_subsurface), and a window as defined by a
1377 shell protocol (e.g. wl_shell.get_shell_surface).
1378
1379 A surface can have only one role at a time. Initially a
1380 wl_surface does not have a role. Once a wl_surface is given a
1381 role, it is set permanently for the whole lifetime of the
1382 wl_surface object. Giving the current role again is allowed,
1383 unless explicitly forbidden by the relevant interface
1384 specification.
1385
1386 Surface roles are given by requests in other interfaces such as
1387 wl_pointer.set_cursor. The request should explicitly mention
1388 that this request gives a role to a wl_surface. Often, this
1389 request also creates a new protocol object that represents the
1390 role and adds additional functionality to wl_surface. When a
1391 client wants to destroy a wl_surface, they must destroy this role
1392 object before the wl_surface, otherwise a defunct_role_object error is
1393 sent.
1394
1395 Destroying the role object does not remove the role from the
1396 wl_surface, but it may stop the wl_surface from "playing the role".
1397 For instance, if a wl_subsurface object is destroyed, the wl_surface
1398 it was created for will be unmapped and forget its position and
1399 z-order. It is allowed to create a wl_subsurface for the same
1400 wl_surface again, but it is not allowed to use the wl_surface as
1401 a cursor (cursor is a different role than sub-surface, and role
1402 switching is not allowed).
1403 </description>
1404
1405 <enum name="error">
1406 <description summary="wl_surface error values">
1407 These errors can be emitted in response to wl_surface requests.
1408 </description>
1409 <entry name="invalid_scale" value="0" summary="buffer scale value is invalid"/>
1410 <entry name="invalid_transform" value="1" summary="buffer transform value is invalid"/>
1411 <entry name="invalid_size" value="2" summary="buffer size is invalid"/>
1412 <entry name="invalid_offset" value="3" summary="buffer offset is invalid"/>
1413 <entry name="defunct_role_object" value="4"
1414 summary="surface was destroyed before its role object"/>
1415 </enum>
1416
1417 <request name="destroy" type="destructor">
1418 <description summary="delete surface">
1419 Deletes the surface and invalidates its object ID.
1420 </description>
1421 </request>
1422
1423 <request name="attach">
1424 <description summary="set the surface contents">
1425 Set a buffer as the content of this surface.
1426
1427 The new size of the surface is calculated based on the buffer
1428 size transformed by the inverse buffer_transform and the
1429 inverse buffer_scale. This means that at commit time the supplied
1430 buffer size must be an integer multiple of the buffer_scale. If
1431 that's not the case, an invalid_size error is sent.
1432
1433 The x and y arguments specify the location of the new pending
1434 buffer's upper left corner, relative to the current buffer's upper
1435 left corner, in surface-local coordinates. In other words, the
1436 x and y, combined with the new surface size define in which
1437 directions the surface's size changes. Setting anything other than 0
1438 as x and y arguments is discouraged, and should instead be replaced
1439 with using the separate wl_surface.offset request.
1440
1441 When the bound wl_surface version is 5 or higher, passing any
1442 non-zero x or y is a protocol violation, and will result in an
1443 'invalid_offset' error being raised. The x and y arguments are ignored
1444 and do not change the pending state. To achieve equivalent semantics,
1445 use wl_surface.offset.
1446
1447 Surface contents are double-buffered state, see wl_surface.commit.
1448
1449 The initial surface contents are void; there is no content.
1450 wl_surface.attach assigns the given wl_buffer as the pending
1451 wl_buffer. wl_surface.commit makes the pending wl_buffer the new
1452 surface contents, and the size of the surface becomes the size
1453 calculated from the wl_buffer, as described above. After commit,
1454 there is no pending buffer until the next attach.
1455
1456 Committing a pending wl_buffer allows the compositor to read the
1457 pixels in the wl_buffer. The compositor may access the pixels at
1458 any time after the wl_surface.commit request. When the compositor
1459 will not access the pixels anymore, it will send the
1460 wl_buffer.release event. Only after receiving wl_buffer.release,
1461 the client may reuse the wl_buffer. A wl_buffer that has been
1462 attached and then replaced by another attach instead of committed
1463 will not receive a release event, and is not used by the
1464 compositor.
1465
1466 If a pending wl_buffer has been committed to more than one wl_surface,
1467 the delivery of wl_buffer.release events becomes undefined. A well
1468 behaved client should not rely on wl_buffer.release events in this
1469 case. Alternatively, a client could create multiple wl_buffer objects
1470 from the same backing storage or use wp_linux_buffer_release.
1471
1472 Destroying the wl_buffer after wl_buffer.release does not change
1473 the surface contents. Destroying the wl_buffer before wl_buffer.release
1474 is allowed as long as the underlying buffer storage isn't re-used (this
1475 can happen e.g. on client process termination). However, if the client
1476 destroys the wl_buffer before receiving the wl_buffer.release event and
1477 mutates the underlying buffer storage, the surface contents become
1478 undefined immediately.
1479
1480 If wl_surface.attach is sent with a NULL wl_buffer, the
1481 following wl_surface.commit will remove the surface content.
1482 </description>
1483 <arg name="buffer" type="object" interface="wl_buffer" allow-null="true"
1484 summary="buffer of surface contents"/>
1485 <arg name="x" type="int" summary="surface-local x coordinate"/>
1486 <arg name="y" type="int" summary="surface-local y coordinate"/>
1487 </request>
1488
1489 <request name="damage">
1490 <description summary="mark part of the surface damaged">
1491 This request is used to describe the regions where the pending
1492 buffer is different from the current surface contents, and where
1493 the surface therefore needs to be repainted. The compositor
1494 ignores the parts of the damage that fall outside of the surface.
1495
1496 Damage is double-buffered state, see wl_surface.commit.
1497
1498 The damage rectangle is specified in surface-local coordinates,
1499 where x and y specify the upper left corner of the damage rectangle.
1500
1501 The initial value for pending damage is empty: no damage.
1502 wl_surface.damage adds pending damage: the new pending damage
1503 is the union of old pending damage and the given rectangle.
1504
1505 wl_surface.commit assigns pending damage as the current damage,
1506 and clears pending damage. The server will clear the current
1507 damage as it repaints the surface.
1508
1509 Note! New clients should not use this request. Instead damage can be
1510 posted with wl_surface.damage_buffer which uses buffer coordinates
1511 instead of surface coordinates.
1512 </description>
1513 <arg name="x" type="int" summary="surface-local x coordinate"/>
1514 <arg name="y" type="int" summary="surface-local y coordinate"/>
1515 <arg name="width" type="int" summary="width of damage rectangle"/>
1516 <arg name="height" type="int" summary="height of damage rectangle"/>
1517 </request>
1518
1519 <request name="frame">
1520 <description summary="request a frame throttling hint">
1521 Request a notification when it is a good time to start drawing a new
1522 frame, by creating a frame callback. This is useful for throttling
1523 redrawing operations, and driving animations.
1524
1525 When a client is animating on a wl_surface, it can use the 'frame'
1526 request to get notified when it is a good time to draw and commit the
1527 next frame of animation. If the client commits an update earlier than
1528 that, it is likely that some updates will not make it to the display,
1529 and the client is wasting resources by drawing too often.
1530
1531 The frame request will take effect on the next wl_surface.commit.
1532 The notification will only be posted for one frame unless
1533 requested again. For a wl_surface, the notifications are posted in
1534 the order the frame requests were committed.
1535
1536 The server must send the notifications so that a client
1537 will not send excessive updates, while still allowing
1538 the highest possible update rate for clients that wait for the reply
1539 before drawing again. The server should give some time for the client
1540 to draw and commit after sending the frame callback events to let it
1541 hit the next output refresh.
1542
1543 A server should avoid signaling the frame callbacks if the
1544 surface is not visible in any way, e.g. the surface is off-screen,
1545 or completely obscured by other opaque surfaces.
1546
1547 The object returned by this request will be destroyed by the
1548 compositor after the callback is fired and as such the client must not
1549 attempt to use it after that point.
1550
1551 The callback_data passed in the callback is the current time, in
1552 milliseconds, with an undefined base.
1553 </description>
1554 <arg name="callback" type="new_id" interface="wl_callback" summary="callback object for the frame request"/>
1555 </request>
1556
1557 <request name="set_opaque_region">
1558 <description summary="set opaque region">
1559 This request sets the region of the surface that contains
1560 opaque content.
1561
1562 The opaque region is an optimization hint for the compositor
1563 that lets it optimize the redrawing of content behind opaque
1564 regions. Setting an opaque region is not required for correct
1565 behaviour, but marking transparent content as opaque will result
1566 in repaint artifacts.
1567
1568 The opaque region is specified in surface-local coordinates.
1569
1570 The compositor ignores the parts of the opaque region that fall
1571 outside of the surface.
1572
1573 Opaque region is double-buffered state, see wl_surface.commit.
1574
1575 wl_surface.set_opaque_region changes the pending opaque region.
1576 wl_surface.commit copies the pending region to the current region.
1577 Otherwise, the pending and current regions are never changed.
1578
1579 The initial value for an opaque region is empty. Setting the pending
1580 opaque region has copy semantics, and the wl_region object can be
1581 destroyed immediately. A NULL wl_region causes the pending opaque
1582 region to be set to empty.
1583 </description>
1584 <arg name="region" type="object" interface="wl_region" allow-null="true"
1585 summary="opaque region of the surface"/>
1586 </request>
1587
1588 <request name="set_input_region">
1589 <description summary="set input region">
1590 This request sets the region of the surface that can receive
1591 pointer and touch events.
1592
1593 Input events happening outside of this region will try the next
1594 surface in the server surface stack. The compositor ignores the
1595 parts of the input region that fall outside of the surface.
1596
1597 The input region is specified in surface-local coordinates.
1598
1599 Input region is double-buffered state, see wl_surface.commit.
1600
1601 wl_surface.set_input_region changes the pending input region.
1602 wl_surface.commit copies the pending region to the current region.
1603 Otherwise the pending and current regions are never changed,
1604 except cursor and icon surfaces are special cases, see
1605 wl_pointer.set_cursor and wl_data_device.start_drag.
1606
1607 The initial value for an input region is infinite. That means the
1608 whole surface will accept input. Setting the pending input region
1609 has copy semantics, and the wl_region object can be destroyed
1610 immediately. A NULL wl_region causes the input region to be set
1611 to infinite.
1612 </description>
1613 <arg name="region" type="object" interface="wl_region" allow-null="true"
1614 summary="input region of the surface"/>
1615 </request>
1616
1617 <request name="commit">
1618 <description summary="commit pending surface state">
1619 Surface state (input, opaque, and damage regions, attached buffers,
1620 etc.) is double-buffered. Protocol requests modify the pending state,
1621 as opposed to the current state in use by the compositor. A commit
1622 request atomically applies all pending state, replacing the current
1623 state. After commit, the new pending state is as documented for each
1624 related request.
1625
1626 On commit, a pending wl_buffer is applied first, and all other state
1627 second. This means that all coordinates in double-buffered state are
1628 relative to the new wl_buffer coming into use, except for
1629 wl_surface.attach itself. If there is no pending wl_buffer, the
1630 coordinates are relative to the current surface contents.
1631
1632 All requests that need a commit to become effective are documented
1633 to affect double-buffered state.
1634
1635 Other interfaces may add further double-buffered surface state.
1636 </description>
1637 </request>
1638
1639 <event name="enter">
1640 <description summary="surface enters an output">
1641 This is emitted whenever a surface's creation, movement, or resizing
1642 results in some part of it being within the scanout region of an
1643 output.
1644
1645 Note that a surface may be overlapping with zero or more outputs.
1646 </description>
1647 <arg name="output" type="object" interface="wl_output" summary="output entered by the surface"/>
1648 </event>
1649
1650 <event name="leave">
1651 <description summary="surface leaves an output">
1652 This is emitted whenever a surface's creation, movement, or resizing
1653 results in it no longer having any part of it within the scanout region
1654 of an output.
1655
1656 Clients should not use the number of outputs the surface is on for frame
1657 throttling purposes. The surface might be hidden even if no leave event
1658 has been sent, and the compositor might expect new surface content
1659 updates even if no enter event has been sent. The frame event should be
1660 used instead.
1661 </description>
1662 <arg name="output" type="object" interface="wl_output" summary="output left by the surface"/>
1663 </event>
1664
1665 <!-- Version 2 additions -->
1666
1667 <request name="set_buffer_transform" since="2">
1668 <description summary="sets the buffer transformation">
1669 This request sets an optional transformation on how the compositor
1670 interprets the contents of the buffer attached to the surface. The
1671 accepted values for the transform parameter are the values for
1672 wl_output.transform.
1673
1674 Buffer transform is double-buffered state, see wl_surface.commit.
1675
1676 A newly created surface has its buffer transformation set to normal.
1677
1678 wl_surface.set_buffer_transform changes the pending buffer
1679 transformation. wl_surface.commit copies the pending buffer
1680 transformation to the current one. Otherwise, the pending and current
1681 values are never changed.
1682
1683 The purpose of this request is to allow clients to render content
1684 according to the output transform, thus permitting the compositor to
1685 use certain optimizations even if the display is rotated. Using
1686 hardware overlays and scanning out a client buffer for fullscreen
1687 surfaces are examples of such optimizations. Those optimizations are
1688 highly dependent on the compositor implementation, so the use of this
1689 request should be considered on a case-by-case basis.
1690
1691 Note that if the transform value includes 90 or 270 degree rotation,
1692 the width of the buffer will become the surface height and the height
1693 of the buffer will become the surface width.
1694
1695 If transform is not one of the values from the
1696 wl_output.transform enum the invalid_transform protocol error
1697 is raised.
1698 </description>
1699 <arg name="transform" type="int" enum="wl_output.transform"
1700 summary="transform for interpreting buffer contents"/>
1701 </request>
1702
1703 <!-- Version 3 additions -->
1704
1705 <request name="set_buffer_scale" since="3">
1706 <description summary="sets the buffer scaling factor">
1707 This request sets an optional scaling factor on how the compositor
1708 interprets the contents of the buffer attached to the window.
1709
1710 Buffer scale is double-buffered state, see wl_surface.commit.
1711
1712 A newly created surface has its buffer scale set to 1.
1713
1714 wl_surface.set_buffer_scale changes the pending buffer scale.
1715 wl_surface.commit copies the pending buffer scale to the current one.
1716 Otherwise, the pending and current values are never changed.
1717
1718 The purpose of this request is to allow clients to supply higher
1719 resolution buffer data for use on high resolution outputs. It is
1720 intended that you pick the same buffer scale as the scale of the
1721 output that the surface is displayed on. This means the compositor
1722 can avoid scaling when rendering the surface on that output.
1723
1724 Note that if the scale is larger than 1, then you have to attach
1725 a buffer that is larger (by a factor of scale in each dimension)
1726 than the desired surface size.
1727
1728 If scale is not positive the invalid_scale protocol error is
1729 raised.
1730 </description>
1731 <arg name="scale" type="int"
1732 summary="positive scale for interpreting buffer contents"/>
1733 </request>
1734
1735 <!-- Version 4 additions -->
1736 <request name="damage_buffer" since="4">
1737 <description summary="mark part of the surface damaged using buffer coordinates">
1738 This request is used to describe the regions where the pending
1739 buffer is different from the current surface contents, and where
1740 the surface therefore needs to be repainted. The compositor
1741 ignores the parts of the damage that fall outside of the surface.
1742
1743 Damage is double-buffered state, see wl_surface.commit.
1744
1745 The damage rectangle is specified in buffer coordinates,
1746 where x and y specify the upper left corner of the damage rectangle.
1747
1748 The initial value for pending damage is empty: no damage.
1749 wl_surface.damage_buffer adds pending damage: the new pending
1750 damage is the union of old pending damage and the given rectangle.
1751
1752 wl_surface.commit assigns pending damage as the current damage,
1753 and clears pending damage. The server will clear the current
1754 damage as it repaints the surface.
1755
1756 This request differs from wl_surface.damage in only one way - it
1757 takes damage in buffer coordinates instead of surface-local
1758 coordinates. While this generally is more intuitive than surface
1759 coordinates, it is especially desirable when using wp_viewport
1760 or when a drawing library (like EGL) is unaware of buffer scale
1761 and buffer transform.
1762
1763 Note: Because buffer transformation changes and damage requests may
1764 be interleaved in the protocol stream, it is impossible to determine
1765 the actual mapping between surface and buffer damage until
1766 wl_surface.commit time. Therefore, compositors wishing to take both
1767 kinds of damage into account will have to accumulate damage from the
1768 two requests separately and only transform from one to the other
1769 after receiving the wl_surface.commit.
1770 </description>
1771 <arg name="x" type="int" summary="buffer-local x coordinate"/>
1772 <arg name="y" type="int" summary="buffer-local y coordinate"/>
1773 <arg name="width" type="int" summary="width of damage rectangle"/>
1774 <arg name="height" type="int" summary="height of damage rectangle"/>
1775 </request>
1776
1777 <!-- Version 5 additions -->
1778
1779 <request name="offset" since="5">
1780 <description summary="set the surface contents offset">
1781 The x and y arguments specify the location of the new pending
1782 buffer's upper left corner, relative to the current buffer's upper
1783 left corner, in surface-local coordinates. In other words, the
1784 x and y, combined with the new surface size define in which
1785 directions the surface's size changes.
1786
1787 Surface location offset is double-buffered state, see
1788 wl_surface.commit.
1789
1790 This request is semantically equivalent to and the replaces the x and y
1791 arguments in the wl_surface.attach request in wl_surface versions prior
1792 to 5. See wl_surface.attach for details.
1793 </description>
1794 <arg name="x" type="int" summary="surface-local x coordinate"/>
1795 <arg name="y" type="int" summary="surface-local y coordinate"/>
1796 </request>
1797
1798 <!-- Version 6 additions -->
1799
1800 <event name="preferred_buffer_scale" since="6">
1801 <description summary="preferred buffer scale for the surface">
1802 This event indicates the preferred buffer scale for this surface. It is
1803 sent whenever the compositor's preference changes.
1804
1805 It is intended that scaling aware clients use this event to scale their
1806 content and use wl_surface.set_buffer_scale to indicate the scale they
1807 have rendered with. This allows clients to supply a higher detail
1808 buffer.
1809 </description>
1810 <arg name="factor" type="int" summary="preferred scaling factor"/>
1811 </event>
1812
1813 <event name="preferred_buffer_transform" since="6">
1814 <description summary="preferred buffer transform for the surface">
1815 This event indicates the preferred buffer transform for this surface.
1816 It is sent whenever the compositor's preference changes.
1817
1818 It is intended that transform aware clients use this event to apply the
1819 transform to their content and use wl_surface.set_buffer_transform to
1820 indicate the transform they have rendered with.
1821 </description>
1822 <arg name="transform" type="uint" enum="wl_output.transform"
1823 summary="preferred transform"/>
1824 </event>
1825 </interface>
1826
1827 <interface name="wl_seat" version="9">
1828 <description summary="group of input devices">
1829 A seat is a group of keyboards, pointer and touch devices. This
1830 object is published as a global during start up, or when such a
1831 device is hot plugged. A seat typically has a pointer and
1832 maintains a keyboard focus and a pointer focus.
1833 </description>
1834
1835 <enum name="capability" bitfield="true">
1836 <description summary="seat capability bitmask">
1837 This is a bitmask of capabilities this seat has; if a member is
1838 set, then it is present on the seat.
1839 </description>
1840 <entry name="pointer" value="1" summary="the seat has pointer devices"/>
1841 <entry name="keyboard" value="2" summary="the seat has one or more keyboards"/>
1842 <entry name="touch" value="4" summary="the seat has touch devices"/>
1843 </enum>
1844
1845 <enum name="error">
1846 <description summary="wl_seat error values">
1847 These errors can be emitted in response to wl_seat requests.
1848 </description>
1849 <entry name="missing_capability" value="0"
1850 summary="get_pointer, get_keyboard or get_touch called on seat without the matching capability"/>
1851 </enum>
1852
1853 <event name="capabilities">
1854 <description summary="seat capabilities changed">
1855 This is emitted whenever a seat gains or loses the pointer,
1856 keyboard or touch capabilities. The argument is a capability
1857 enum containing the complete set of capabilities this seat has.
1858
1859 When the pointer capability is added, a client may create a
1860 wl_pointer object using the wl_seat.get_pointer request. This object
1861 will receive pointer events until the capability is removed in the
1862 future.
1863
1864 When the pointer capability is removed, a client should destroy the
1865 wl_pointer objects associated with the seat where the capability was
1866 removed, using the wl_pointer.release request. No further pointer
1867 events will be received on these objects.
1868
1869 In some compositors, if a seat regains the pointer capability and a
1870 client has a previously obtained wl_pointer object of version 4 or
1871 less, that object may start sending pointer events again. This
1872 behavior is considered a misinterpretation of the intended behavior
1873 and must not be relied upon by the client. wl_pointer objects of
1874 version 5 or later must not send events if created before the most
1875 recent event notifying the client of an added pointer capability.
1876
1877 The above behavior also applies to wl_keyboard and wl_touch with the
1878 keyboard and touch capabilities, respectively.
1879 </description>
1880 <arg name="capabilities" type="uint" enum="capability" summary="capabilities of the seat"/>
1881 </event>
1882
1883 <request name="get_pointer">
1884 <description summary="return pointer object">
1885 The ID provided will be initialized to the wl_pointer interface
1886 for this seat.
1887
1888 This request only takes effect if the seat has the pointer
1889 capability, or has had the pointer capability in the past.
1890 It is a protocol violation to issue this request on a seat that has
1891 never had the pointer capability. The missing_capability error will
1892 be sent in this case.
1893 </description>
1894 <arg name="id" type="new_id" interface="wl_pointer" summary="seat pointer"/>
1895 </request>
1896
1897 <request name="get_keyboard">
1898 <description summary="return keyboard object">
1899 The ID provided will be initialized to the wl_keyboard interface
1900 for this seat.
1901
1902 This request only takes effect if the seat has the keyboard
1903 capability, or has had the keyboard capability in the past.
1904 It is a protocol violation to issue this request on a seat that has
1905 never had the keyboard capability. The missing_capability error will
1906 be sent in this case.
1907 </description>
1908 <arg name="id" type="new_id" interface="wl_keyboard" summary="seat keyboard"/>
1909 </request>
1910
1911 <request name="get_touch">
1912 <description summary="return touch object">
1913 The ID provided will be initialized to the wl_touch interface
1914 for this seat.
1915
1916 This request only takes effect if the seat has the touch
1917 capability, or has had the touch capability in the past.
1918 It is a protocol violation to issue this request on a seat that has
1919 never had the touch capability. The missing_capability error will
1920 be sent in this case.
1921 </description>
1922 <arg name="id" type="new_id" interface="wl_touch" summary="seat touch interface"/>
1923 </request>
1924
1925 <!-- Version 2 additions -->
1926
1927 <event name="name" since="2">
1928 <description summary="unique identifier for this seat">
1929 In a multi-seat configuration the seat name can be used by clients to
1930 help identify which physical devices the seat represents.
1931
1932 The seat name is a UTF-8 string with no convention defined for its
1933 contents. Each name is unique among all wl_seat globals. The name is
1934 only guaranteed to be unique for the current compositor instance.
1935
1936 The same seat names are used for all clients. Thus, the name can be
1937 shared across processes to refer to a specific wl_seat global.
1938
1939 The name event is sent after binding to the seat global. This event is
1940 only sent once per seat object, and the name does not change over the
1941 lifetime of the wl_seat global.
1942
1943 Compositors may re-use the same seat name if the wl_seat global is
1944 destroyed and re-created later.
1945 </description>
1946 <arg name="name" type="string" summary="seat identifier"/>
1947 </event>
1948
1949 <!-- Version 5 additions -->
1950
1951 <request name="release" type="destructor" since="5">
1952 <description summary="release the seat object">
1953 Using this request a client can tell the server that it is not going to
1954 use the seat object anymore.
1955 </description>
1956 </request>
1957
1958 </interface>
1959
1960 <interface name="wl_pointer" version="9">
1961 <description summary="pointer input device">
1962 The wl_pointer interface represents one or more input devices,
1963 such as mice, which control the pointer location and pointer_focus
1964 of a seat.
1965
1966 The wl_pointer interface generates motion, enter and leave
1967 events for the surfaces that the pointer is located over,
1968 and button and axis events for button presses, button releases
1969 and scrolling.
1970 </description>
1971
1972 <enum name="error">
1973 <entry name="role" value="0" summary="given wl_surface has another role"/>
1974 </enum>
1975
1976 <request name="set_cursor">
1977 <description summary="set the pointer surface">
1978 Set the pointer surface, i.e., the surface that contains the
1979 pointer image (cursor). This request gives the surface the role
1980 of a cursor. If the surface already has another role, it raises
1981 a protocol error.
1982
1983 The cursor actually changes only if the pointer
1984 focus for this device is one of the requesting client's surfaces
1985 or the surface parameter is the current pointer surface. If
1986 there was a previous surface set with this request it is
1987 replaced. If surface is NULL, the pointer image is hidden.
1988
1989 The parameters hotspot_x and hotspot_y define the position of
1990 the pointer surface relative to the pointer location. Its
1991 top-left corner is always at (x, y) - (hotspot_x, hotspot_y),
1992 where (x, y) are the coordinates of the pointer location, in
1993 surface-local coordinates.
1994
1995 On surface.attach requests to the pointer surface, hotspot_x
1996 and hotspot_y are decremented by the x and y parameters
1997 passed to the request. Attach must be confirmed by
1998 wl_surface.commit as usual.
1999
2000 The hotspot can also be updated by passing the currently set
2001 pointer surface to this request with new values for hotspot_x
2002 and hotspot_y.
2003
2004 The input region is ignored for wl_surfaces with the role of
2005 a cursor. When the use as a cursor ends, the wl_surface is
2006 unmapped.
2007
2008 The serial parameter must match the latest wl_pointer.enter
2009 serial number sent to the client. Otherwise the request will be
2010 ignored.
2011 </description>
2012 <arg name="serial" type="uint" summary="serial number of the enter event"/>
2013 <arg name="surface" type="object" interface="wl_surface" allow-null="true"
2014 summary="pointer surface"/>
2015 <arg name="hotspot_x" type="int" summary="surface-local x coordinate"/>
2016 <arg name="hotspot_y" type="int" summary="surface-local y coordinate"/>
2017 </request>
2018
2019 <event name="enter">
2020 <description summary="enter event">
2021 Notification that this seat's pointer is focused on a certain
2022 surface.
2023
2024 When a seat's focus enters a surface, the pointer image
2025 is undefined and a client should respond to this event by setting
2026 an appropriate pointer image with the set_cursor request.
2027 </description>
2028 <arg name="serial" type="uint" summary="serial number of the enter event"/>
2029 <arg name="surface" type="object" interface="wl_surface" summary="surface entered by the pointer"/>
2030 <arg name="surface_x" type="fixed" summary="surface-local x coordinate"/>
2031 <arg name="surface_y" type="fixed" summary="surface-local y coordinate"/>
2032 </event>
2033
2034 <event name="leave">
2035 <description summary="leave event">
2036 Notification that this seat's pointer is no longer focused on
2037 a certain surface.
2038
2039 The leave notification is sent before the enter notification
2040 for the new focus.
2041 </description>
2042 <arg name="serial" type="uint" summary="serial number of the leave event"/>
2043 <arg name="surface" type="object" interface="wl_surface" summary="surface left by the pointer"/>
2044 </event>
2045
2046 <event name="motion">
2047 <description summary="pointer motion event">
2048 Notification of pointer location change. The arguments
2049 surface_x and surface_y are the location relative to the
2050 focused surface.
2051 </description>
2052 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2053 <arg name="surface_x" type="fixed" summary="surface-local x coordinate"/>
2054 <arg name="surface_y" type="fixed" summary="surface-local y coordinate"/>
2055 </event>
2056
2057 <enum name="button_state">
2058 <description summary="physical button state">
2059 Describes the physical state of a button that produced the button
2060 event.
2061 </description>
2062 <entry name="released" value="0" summary="the button is not pressed"/>
2063 <entry name="pressed" value="1" summary="the button is pressed"/>
2064 </enum>
2065
2066 <event name="button">
2067 <description summary="pointer button event">
2068 Mouse button click and release notifications.
2069
2070 The location of the click is given by the last motion or
2071 enter event.
2072 The time argument is a timestamp with millisecond
2073 granularity, with an undefined base.
2074
2075 The button is a button code as defined in the Linux kernel's
2076 linux/input-event-codes.h header file, e.g. BTN_LEFT.
2077
2078 Any 16-bit button code value is reserved for future additions to the
2079 kernel's event code list. All other button codes above 0xFFFF are
2080 currently undefined but may be used in future versions of this
2081 protocol.
2082 </description>
2083 <arg name="serial" type="uint" summary="serial number of the button event"/>
2084 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2085 <arg name="button" type="uint" summary="button that produced the event"/>
2086 <arg name="state" type="uint" enum="button_state" summary="physical state of the button"/>
2087 </event>
2088
2089 <enum name="axis">
2090 <description summary="axis types">
2091 Describes the axis types of scroll events.
2092 </description>
2093 <entry name="vertical_scroll" value="0" summary="vertical axis"/>
2094 <entry name="horizontal_scroll" value="1" summary="horizontal axis"/>
2095 </enum>
2096
2097 <event name="axis">
2098 <description summary="axis event">
2099 Scroll and other axis notifications.
2100
2101 For scroll events (vertical and horizontal scroll axes), the
2102 value parameter is the length of a vector along the specified
2103 axis in a coordinate space identical to those of motion events,
2104 representing a relative movement along the specified axis.
2105
2106 For devices that support movements non-parallel to axes multiple
2107 axis events will be emitted.
2108
2109 When applicable, for example for touch pads, the server can
2110 choose to emit scroll events where the motion vector is
2111 equivalent to a motion event vector.
2112
2113 When applicable, a client can transform its content relative to the
2114 scroll distance.
2115 </description>
2116 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2117 <arg name="axis" type="uint" enum="axis" summary="axis type"/>
2118 <arg name="value" type="fixed" summary="length of vector in surface-local coordinate space"/>
2119 </event>
2120
2121 <!-- Version 3 additions -->
2122
2123 <request name="release" type="destructor" since="3">
2124 <description summary="release the pointer object">
2125 Using this request a client can tell the server that it is not going to
2126 use the pointer object anymore.
2127
2128 This request destroys the pointer proxy object, so clients must not call
2129 wl_pointer_destroy() after using this request.
2130 </description>
2131 </request>
2132
2133 <!-- Version 5 additions -->
2134
2135 <event name="frame" since="5">
2136 <description summary="end of a pointer event sequence">
2137 Indicates the end of a set of events that logically belong together.
2138 A client is expected to accumulate the data in all events within the
2139 frame before proceeding.
2140
2141 All wl_pointer events before a wl_pointer.frame event belong
2142 logically together. For example, in a diagonal scroll motion the
2143 compositor will send an optional wl_pointer.axis_source event, two
2144 wl_pointer.axis events (horizontal and vertical) and finally a
2145 wl_pointer.frame event. The client may use this information to
2146 calculate a diagonal vector for scrolling.
2147
2148 When multiple wl_pointer.axis events occur within the same frame,
2149 the motion vector is the combined motion of all events.
2150 When a wl_pointer.axis and a wl_pointer.axis_stop event occur within
2151 the same frame, this indicates that axis movement in one axis has
2152 stopped but continues in the other axis.
2153 When multiple wl_pointer.axis_stop events occur within the same
2154 frame, this indicates that these axes stopped in the same instance.
2155
2156 A wl_pointer.frame event is sent for every logical event group,
2157 even if the group only contains a single wl_pointer event.
2158 Specifically, a client may get a sequence: motion, frame, button,
2159 frame, axis, frame, axis_stop, frame.
2160
2161 The wl_pointer.enter and wl_pointer.leave events are logical events
2162 generated by the compositor and not the hardware. These events are
2163 also grouped by a wl_pointer.frame. When a pointer moves from one
2164 surface to another, a compositor should group the
2165 wl_pointer.leave event within the same wl_pointer.frame.
2166 However, a client must not rely on wl_pointer.leave and
2167 wl_pointer.enter being in the same wl_pointer.frame.
2168 Compositor-specific policies may require the wl_pointer.leave and
2169 wl_pointer.enter event being split across multiple wl_pointer.frame
2170 groups.
2171 </description>
2172 </event>
2173
2174 <enum name="axis_source">
2175 <description summary="axis source types">
2176 Describes the source types for axis events. This indicates to the
2177 client how an axis event was physically generated; a client may
2178 adjust the user interface accordingly. For example, scroll events
2179 from a "finger" source may be in a smooth coordinate space with
2180 kinetic scrolling whereas a "wheel" source may be in discrete steps
2181 of a number of lines.
2182
2183 The "continuous" axis source is a device generating events in a
2184 continuous coordinate space, but using something other than a
2185 finger. One example for this source is button-based scrolling where
2186 the vertical motion of a device is converted to scroll events while
2187 a button is held down.
2188
2189 The "wheel tilt" axis source indicates that the actual device is a
2190 wheel but the scroll event is not caused by a rotation but a
2191 (usually sideways) tilt of the wheel.
2192 </description>
2193 <entry name="wheel" value="0" summary="a physical wheel rotation" />
2194 <entry name="finger" value="1" summary="finger on a touch surface" />
2195 <entry name="continuous" value="2" summary="continuous coordinate space"/>
2196 <entry name="wheel_tilt" value="3" summary="a physical wheel tilt" since="6"/>
2197 </enum>
2198
2199 <event name="axis_source" since="5">
2200 <description summary="axis source event">
2201 Source information for scroll and other axes.
2202
2203 This event does not occur on its own. It is sent before a
2204 wl_pointer.frame event and carries the source information for
2205 all events within that frame.
2206
2207 The source specifies how this event was generated. If the source is
2208 wl_pointer.axis_source.finger, a wl_pointer.axis_stop event will be
2209 sent when the user lifts the finger off the device.
2210
2211 If the source is wl_pointer.axis_source.wheel,
2212 wl_pointer.axis_source.wheel_tilt or
2213 wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event may
2214 or may not be sent. Whether a compositor sends an axis_stop event
2215 for these sources is hardware-specific and implementation-dependent;
2216 clients must not rely on receiving an axis_stop event for these
2217 scroll sources and should treat scroll sequences from these scroll
2218 sources as unterminated by default.
2219
2220 This event is optional. If the source is unknown for a particular
2221 axis event sequence, no event is sent.
2222 Only one wl_pointer.axis_source event is permitted per frame.
2223
2224 The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
2225 not guaranteed.
2226 </description>
2227 <arg name="axis_source" type="uint" enum="axis_source" summary="source of the axis event"/>
2228 </event>
2229
2230 <event name="axis_stop" since="5">
2231 <description summary="axis stop event">
2232 Stop notification for scroll and other axes.
2233
2234 For some wl_pointer.axis_source types, a wl_pointer.axis_stop event
2235 is sent to notify a client that the axis sequence has terminated.
2236 This enables the client to implement kinetic scrolling.
2237 See the wl_pointer.axis_source documentation for information on when
2238 this event may be generated.
2239
2240 Any wl_pointer.axis events with the same axis_source after this
2241 event should be considered as the start of a new axis motion.
2242
2243 The timestamp is to be interpreted identical to the timestamp in the
2244 wl_pointer.axis event. The timestamp value may be the same as a
2245 preceding wl_pointer.axis event.
2246 </description>
2247 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2248 <arg name="axis" type="uint" enum="axis" summary="the axis stopped with this event"/>
2249 </event>
2250
2251 <event name="axis_discrete" since="5">
2252 <description summary="axis click event">
2253 Discrete step information for scroll and other axes.
2254
2255 This event carries the axis value of the wl_pointer.axis event in
2256 discrete steps (e.g. mouse wheel clicks).
2257
2258 This event is deprecated with wl_pointer version 8 - this event is not
2259 sent to clients supporting version 8 or later.
2260
2261 This event does not occur on its own, it is coupled with a
2262 wl_pointer.axis event that represents this axis value on a
2263 continuous scale. The protocol guarantees that each axis_discrete
2264 event is always followed by exactly one axis event with the same
2265 axis number within the same wl_pointer.frame. Note that the protocol
2266 allows for other events to occur between the axis_discrete and
2267 its coupled axis event, including other axis_discrete or axis
2268 events. A wl_pointer.frame must not contain more than one axis_discrete
2269 event per axis type.
2270
2271 This event is optional; continuous scrolling devices
2272 like two-finger scrolling on touchpads do not have discrete
2273 steps and do not generate this event.
2274
2275 The discrete value carries the directional information. e.g. a value
2276 of -2 is two steps towards the negative direction of this axis.
2277
2278 The axis number is identical to the axis number in the associated
2279 axis event.
2280
2281 The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
2282 not guaranteed.
2283 </description>
2284 <arg name="axis" type="uint" enum="axis" summary="axis type"/>
2285 <arg name="discrete" type="int" summary="number of steps"/>
2286 </event>
2287
2288 <event name="axis_value120" since="8">
2289 <description summary="axis high-resolution scroll event">
2290 Discrete high-resolution scroll information.
2291
2292 This event carries high-resolution wheel scroll information,
2293 with each multiple of 120 representing one logical scroll step
2294 (a wheel detent). For example, an axis_value120 of 30 is one quarter of
2295 a logical scroll step in the positive direction, a value120 of
2296 -240 are two logical scroll steps in the negative direction within the
2297 same hardware event.
2298 Clients that rely on discrete scrolling should accumulate the
2299 value120 to multiples of 120 before processing the event.
2300
2301 The value120 must not be zero.
2302
2303 This event replaces the wl_pointer.axis_discrete event in clients
2304 supporting wl_pointer version 8 or later.
2305
2306 Where a wl_pointer.axis_source event occurs in the same
2307 wl_pointer.frame, the axis source applies to this event.
2308
2309 The order of wl_pointer.axis_value120 and wl_pointer.axis_source is
2310 not guaranteed.
2311 </description>
2312 <arg name="axis" type="uint" enum="axis" summary="axis type"/>
2313 <arg name="value120" type="int" summary="scroll distance as fraction of 120"/>
2314 </event>
2315
2316 <!-- Version 9 additions -->
2317
2318 <enum name="axis_relative_direction">
2319 <description summary="axis relative direction">
2320 This specifies the direction of the physical motion that caused a
2321 wl_pointer.axis event, relative to the wl_pointer.axis direction.
2322 </description>
2323 <entry name="identical" value="0"
2324 summary="physical motion matches axis direction"/>
2325 <entry name="inverted" value="1"
2326 summary="physical motion is the inverse of the axis direction"/>
2327 </enum>
2328
2329 <event name="axis_relative_direction" since="9">
2330 <description summary="axis relative physical direction event">
2331 Relative directional information of the entity causing the axis
2332 motion.
2333
2334 For a wl_pointer.axis event, the wl_pointer.axis_relative_direction
2335 event specifies the movement direction of the entity causing the
2336 wl_pointer.axis event. For example:
2337 - if a user's fingers on a touchpad move down and this
2338 causes a wl_pointer.axis vertical_scroll down event, the physical
2339 direction is 'identical'
2340 - if a user's fingers on a touchpad move down and this causes a
2341 wl_pointer.axis vertical_scroll up scroll up event ('natural
2342 scrolling'), the physical direction is 'inverted'.
2343
2344 A client may use this information to adjust scroll motion of
2345 components. Specifically, enabling natural scrolling causes the
2346 content to change direction compared to traditional scrolling.
2347 Some widgets like volume control sliders should usually match the
2348 physical direction regardless of whether natural scrolling is
2349 active. This event enables clients to match the scroll direction of
2350 a widget to the physical direction.
2351
2352 This event does not occur on its own, it is coupled with a
2353 wl_pointer.axis event that represents this axis value.
2354 The protocol guarantees that each axis_relative_direction event is
2355 always followed by exactly one axis event with the same
2356 axis number within the same wl_pointer.frame. Note that the protocol
2357 allows for other events to occur between the axis_relative_direction
2358 and its coupled axis event.
2359
2360 The axis number is identical to the axis number in the associated
2361 axis event.
2362
2363 The order of wl_pointer.axis_relative_direction,
2364 wl_pointer.axis_discrete and wl_pointer.axis_source is not
2365 guaranteed.
2366 </description>
2367 <arg name="axis" type="uint" enum="axis" summary="axis type"/>
2368 <arg name="direction" type="uint" enum="axis_relative_direction"
2369 summary="physical direction relative to axis motion"/>
2370 </event>
2371 </interface>
2372
2373 <interface name="wl_keyboard" version="9">
2374 <description summary="keyboard input device">
2375 The wl_keyboard interface represents one or more keyboards
2376 associated with a seat.
2377 </description>
2378
2379 <enum name="keymap_format">
2380 <description summary="keyboard mapping format">
2381 This specifies the format of the keymap provided to the
2382 client with the wl_keyboard.keymap event.
2383 </description>
2384 <entry name="no_keymap" value="0"
2385 summary="no keymap; client must understand how to interpret the raw keycode"/>
2386 <entry name="xkb_v1" value="1"
2387 summary="libxkbcommon compatible, null-terminated string; to determine the xkb keycode, clients must add 8 to the key event keycode"/>
2388 </enum>
2389
2390 <event name="keymap">
2391 <description summary="keyboard mapping">
2392 This event provides a file descriptor to the client which can be
2393 memory-mapped in read-only mode to provide a keyboard mapping
2394 description.
2395
2396 From version 7 onwards, the fd must be mapped with MAP_PRIVATE by
2397 the recipient, as MAP_SHARED may fail.
2398 </description>
2399 <arg name="format" type="uint" enum="keymap_format" summary="keymap format"/>
2400 <arg name="fd" type="fd" summary="keymap file descriptor"/>
2401 <arg name="size" type="uint" summary="keymap size, in bytes"/>
2402 </event>
2403
2404 <event name="enter">
2405 <description summary="enter event">
2406 Notification that this seat's keyboard focus is on a certain
2407 surface.
2408
2409 The compositor must send the wl_keyboard.modifiers event after this
2410 event.
2411 </description>
2412 <arg name="serial" type="uint" summary="serial number of the enter event"/>
2413 <arg name="surface" type="object" interface="wl_surface" summary="surface gaining keyboard focus"/>
2414 <arg name="keys" type="array" summary="the currently pressed keys"/>
2415 </event>
2416
2417 <event name="leave">
2418 <description summary="leave event">
2419 Notification that this seat's keyboard focus is no longer on
2420 a certain surface.
2421
2422 The leave notification is sent before the enter notification
2423 for the new focus.
2424
2425 After this event client must assume that all keys, including modifiers,
2426 are lifted and also it must stop key repeating if there's some going on.
2427 </description>
2428 <arg name="serial" type="uint" summary="serial number of the leave event"/>
2429 <arg name="surface" type="object" interface="wl_surface" summary="surface that lost keyboard focus"/>
2430 </event>
2431
2432 <enum name="key_state">
2433 <description summary="physical key state">
2434 Describes the physical state of a key that produced the key event.
2435 </description>
2436 <entry name="released" value="0" summary="key is not pressed"/>
2437 <entry name="pressed" value="1" summary="key is pressed"/>
2438 </enum>
2439
2440 <event name="key">
2441 <description summary="key event">
2442 A key was pressed or released.
2443 The time argument is a timestamp with millisecond
2444 granularity, with an undefined base.
2445
2446 The key is a platform-specific key code that can be interpreted
2447 by feeding it to the keyboard mapping (see the keymap event).
2448
2449 If this event produces a change in modifiers, then the resulting
2450 wl_keyboard.modifiers event must be sent after this event.
2451 </description>
2452 <arg name="serial" type="uint" summary="serial number of the key event"/>
2453 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2454 <arg name="key" type="uint" summary="key that produced the event"/>
2455 <arg name="state" type="uint" enum="key_state" summary="physical state of the key"/>
2456 </event>
2457
2458 <event name="modifiers">
2459 <description summary="modifier and group state">
2460 Notifies clients that the modifier and/or group state has
2461 changed, and it should update its local state.
2462 </description>
2463 <arg name="serial" type="uint" summary="serial number of the modifiers event"/>
2464 <arg name="mods_depressed" type="uint" summary="depressed modifiers"/>
2465 <arg name="mods_latched" type="uint" summary="latched modifiers"/>
2466 <arg name="mods_locked" type="uint" summary="locked modifiers"/>
2467 <arg name="group" type="uint" summary="keyboard layout"/>
2468 </event>
2469
2470 <!-- Version 3 additions -->
2471
2472 <request name="release" type="destructor" since="3">
2473 <description summary="release the keyboard object"/>
2474 </request>
2475
2476 <!-- Version 4 additions -->
2477
2478 <event name="repeat_info" since="4">
2479 <description summary="repeat rate and delay">
2480 Informs the client about the keyboard's repeat rate and delay.
2481
2482 This event is sent as soon as the wl_keyboard object has been created,
2483 and is guaranteed to be received by the client before any key press
2484 event.
2485
2486 Negative values for either rate or delay are illegal. A rate of zero
2487 will disable any repeating (regardless of the value of delay).
2488
2489 This event can be sent later on as well with a new value if necessary,
2490 so clients should continue listening for the event past the creation
2491 of wl_keyboard.
2492 </description>
2493 <arg name="rate" type="int"
2494 summary="the rate of repeating keys in characters per second"/>
2495 <arg name="delay" type="int"
2496 summary="delay in milliseconds since key down until repeating starts"/>
2497 </event>
2498 </interface>
2499
2500 <interface name="wl_touch" version="9">
2501 <description summary="touchscreen input device">
2502 The wl_touch interface represents a touchscreen
2503 associated with a seat.
2504
2505 Touch interactions can consist of one or more contacts.
2506 For each contact, a series of events is generated, starting
2507 with a down event, followed by zero or more motion events,
2508 and ending with an up event. Events relating to the same
2509 contact point can be identified by the ID of the sequence.
2510 </description>
2511
2512 <event name="down">
2513 <description summary="touch down event and beginning of a touch sequence">
2514 A new touch point has appeared on the surface. This touch point is
2515 assigned a unique ID. Future events from this touch point reference
2516 this ID. The ID ceases to be valid after a touch up event and may be
2517 reused in the future.
2518 </description>
2519 <arg name="serial" type="uint" summary="serial number of the touch down event"/>
2520 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2521 <arg name="surface" type="object" interface="wl_surface" summary="surface touched"/>
2522 <arg name="id" type="int" summary="the unique ID of this touch point"/>
2523 <arg name="x" type="fixed" summary="surface-local x coordinate"/>
2524 <arg name="y" type="fixed" summary="surface-local y coordinate"/>
2525 </event>
2526
2527 <event name="up">
2528 <description summary="end of a touch event sequence">
2529 The touch point has disappeared. No further events will be sent for
2530 this touch point and the touch point's ID is released and may be
2531 reused in a future touch down event.
2532 </description>
2533 <arg name="serial" type="uint" summary="serial number of the touch up event"/>
2534 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2535 <arg name="id" type="int" summary="the unique ID of this touch point"/>
2536 </event>
2537
2538 <event name="motion">
2539 <description summary="update of touch point coordinates">
2540 A touch point has changed coordinates.
2541 </description>
2542 <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
2543 <arg name="id" type="int" summary="the unique ID of this touch point"/>
2544 <arg name="x" type="fixed" summary="surface-local x coordinate"/>
2545 <arg name="y" type="fixed" summary="surface-local y coordinate"/>
2546 </event>
2547
2548 <event name="frame">
2549 <description summary="end of touch frame event">
2550 Indicates the end of a set of events that logically belong together.
2551 A client is expected to accumulate the data in all events within the
2552 frame before proceeding.
2553
2554 A wl_touch.frame terminates at least one event but otherwise no
2555 guarantee is provided about the set of events within a frame. A client
2556 must assume that any state not updated in a frame is unchanged from the
2557 previously known state.
2558 </description>
2559 </event>
2560
2561 <event name="cancel">
2562 <description summary="touch session cancelled">
2563 Sent if the compositor decides the touch stream is a global
2564 gesture. No further events are sent to the clients from that
2565 particular gesture. Touch cancellation applies to all touch points
2566 currently active on this client's surface. The client is
2567 responsible for finalizing the touch points, future touch points on
2568 this surface may reuse the touch point ID.
2569 </description>
2570 </event>
2571
2572 <!-- Version 3 additions -->
2573
2574 <request name="release" type="destructor" since="3">
2575 <description summary="release the touch object"/>
2576 </request>
2577
2578 <!-- Version 6 additions -->
2579
2580 <event name="shape" since="6">
2581 <description summary="update shape of touch point">
2582 Sent when a touchpoint has changed its shape.
2583
2584 This event does not occur on its own. It is sent before a
2585 wl_touch.frame event and carries the new shape information for
2586 any previously reported, or new touch points of that frame.
2587
2588 Other events describing the touch point such as wl_touch.down,
2589 wl_touch.motion or wl_touch.orientation may be sent within the
2590 same wl_touch.frame. A client should treat these events as a single
2591 logical touch point update. The order of wl_touch.shape,
2592 wl_touch.orientation and wl_touch.motion is not guaranteed.
2593 A wl_touch.down event is guaranteed to occur before the first
2594 wl_touch.shape event for this touch ID but both events may occur within
2595 the same wl_touch.frame.
2596
2597 A touchpoint shape is approximated by an ellipse through the major and
2598 minor axis length. The major axis length describes the longer diameter
2599 of the ellipse, while the minor axis length describes the shorter
2600 diameter. Major and minor are orthogonal and both are specified in
2601 surface-local coordinates. The center of the ellipse is always at the
2602 touchpoint location as reported by wl_touch.down or wl_touch.move.
2603
2604 This event is only sent by the compositor if the touch device supports
2605 shape reports. The client has to make reasonable assumptions about the
2606 shape if it did not receive this event.
2607 </description>
2608 <arg name="id" type="int" summary="the unique ID of this touch point"/>
2609 <arg name="major" type="fixed" summary="length of the major axis in surface-local coordinates"/>
2610 <arg name="minor" type="fixed" summary="length of the minor axis in surface-local coordinates"/>
2611 </event>
2612
2613 <event name="orientation" since="6">
2614 <description summary="update orientation of touch point">
2615 Sent when a touchpoint has changed its orientation.
2616
2617 This event does not occur on its own. It is sent before a
2618 wl_touch.frame event and carries the new shape information for
2619 any previously reported, or new touch points of that frame.
2620
2621 Other events describing the touch point such as wl_touch.down,
2622 wl_touch.motion or wl_touch.shape may be sent within the
2623 same wl_touch.frame. A client should treat these events as a single
2624 logical touch point update. The order of wl_touch.shape,
2625 wl_touch.orientation and wl_touch.motion is not guaranteed.
2626 A wl_touch.down event is guaranteed to occur before the first
2627 wl_touch.orientation event for this touch ID but both events may occur
2628 within the same wl_touch.frame.
2629
2630 The orientation describes the clockwise angle of a touchpoint's major
2631 axis to the positive surface y-axis and is normalized to the -180 to
2632 +180 degree range. The granularity of orientation depends on the touch
2633 device, some devices only support binary rotation values between 0 and
2634 90 degrees.
2635
2636 This event is only sent by the compositor if the touch device supports
2637 orientation reports.
2638 </description>
2639 <arg name="id" type="int" summary="the unique ID of this touch point"/>
2640 <arg name="orientation" type="fixed" summary="angle between major axis and positive surface y-axis in degrees"/>
2641 </event>
2642 </interface>
2643
2644 <interface name="wl_output" version="4">
2645 <description summary="compositor output region">
2646 An output describes part of the compositor geometry. The
2647 compositor works in the 'compositor coordinate system' and an
2648 output corresponds to a rectangular area in that space that is
2649 actually visible. This typically corresponds to a monitor that
2650 displays part of the compositor space. This object is published
2651 as global during start up, or when a monitor is hotplugged.
2652 </description>
2653
2654 <enum name="subpixel">
2655 <description summary="subpixel geometry information">
2656 This enumeration describes how the physical
2657 pixels on an output are laid out.
2658 </description>
2659 <entry name="unknown" value="0" summary="unknown geometry"/>
2660 <entry name="none" value="1" summary="no geometry"/>
2661 <entry name="horizontal_rgb" value="2" summary="horizontal RGB"/>
2662 <entry name="horizontal_bgr" value="3" summary="horizontal BGR"/>
2663 <entry name="vertical_rgb" value="4" summary="vertical RGB"/>
2664 <entry name="vertical_bgr" value="5" summary="vertical BGR"/>
2665 </enum>
2666
2667 <enum name="transform">
2668 <description summary="transform from framebuffer to output">
2669 This describes the transform that a compositor will apply to a
2670 surface to compensate for the rotation or mirroring of an
2671 output device.
2672
2673 The flipped values correspond to an initial flip around a
2674 vertical axis followed by rotation.
2675
2676 The purpose is mainly to allow clients to render accordingly and
2677 tell the compositor, so that for fullscreen surfaces, the
2678 compositor will still be able to scan out directly from client
2679 surfaces.
2680 </description>
2681 <entry name="normal" value="0" summary="no transform"/>
2682 <entry name="90" value="1" summary="90 degrees counter-clockwise"/>
2683 <entry name="180" value="2" summary="180 degrees counter-clockwise"/>
2684 <entry name="270" value="3" summary="270 degrees counter-clockwise"/>
2685 <entry name="flipped" value="4" summary="180 degree flip around a vertical axis"/>
2686 <entry name="flipped_90" value="5" summary="flip and rotate 90 degrees counter-clockwise"/>
2687 <entry name="flipped_180" value="6" summary="flip and rotate 180 degrees counter-clockwise"/>
2688 <entry name="flipped_270" value="7" summary="flip and rotate 270 degrees counter-clockwise"/>
2689 </enum>
2690
2691 <event name="geometry">
2692 <description summary="properties of the output">
2693 The geometry event describes geometric properties of the output.
2694 The event is sent when binding to the output object and whenever
2695 any of the properties change.
2696
2697 The physical size can be set to zero if it doesn't make sense for this
2698 output (e.g. for projectors or virtual outputs).
2699
2700 The geometry event will be followed by a done event (starting from
2701 version 2).
2702
2703 Note: wl_output only advertises partial information about the output
2704 position and identification. Some compositors, for instance those not
2705 implementing a desktop-style output layout or those exposing virtual
2706 outputs, might fake this information. Instead of using x and y, clients
2707 should use xdg_output.logical_position. Instead of using make and model,
2708 clients should use name and description.
2709 </description>
2710 <arg name="x" type="int"
2711 summary="x position within the global compositor space"/>
2712 <arg name="y" type="int"
2713 summary="y position within the global compositor space"/>
2714 <arg name="physical_width" type="int"
2715 summary="width in millimeters of the output"/>
2716 <arg name="physical_height" type="int"
2717 summary="height in millimeters of the output"/>
2718 <arg name="subpixel" type="int" enum="subpixel"
2719 summary="subpixel orientation of the output"/>
2720 <arg name="make" type="string"
2721 summary="textual description of the manufacturer"/>
2722 <arg name="model" type="string"
2723 summary="textual description of the model"/>
2724 <arg name="transform" type="int" enum="transform"
2725 summary="transform that maps framebuffer to output"/>
2726 </event>
2727
2728 <enum name="mode" bitfield="true">
2729 <description summary="mode information">
2730 These flags describe properties of an output mode.
2731 They are used in the flags bitfield of the mode event.
2732 </description>
2733 <entry name="current" value="0x1"
2734 summary="indicates this is the current mode"/>
2735 <entry name="preferred" value="0x2"
2736 summary="indicates this is the preferred mode"/>
2737 </enum>
2738
2739 <event name="mode">
2740 <description summary="advertise available modes for the output">
2741 The mode event describes an available mode for the output.
2742
2743 The event is sent when binding to the output object and there
2744 will always be one mode, the current mode. The event is sent
2745 again if an output changes mode, for the mode that is now
2746 current. In other words, the current mode is always the last
2747 mode that was received with the current flag set.
2748
2749 Non-current modes are deprecated. A compositor can decide to only
2750 advertise the current mode and never send other modes. Clients
2751 should not rely on non-current modes.
2752
2753 The size of a mode is given in physical hardware units of
2754 the output device. This is not necessarily the same as
2755 the output size in the global compositor space. For instance,
2756 the output may be scaled, as described in wl_output.scale,
2757 or transformed, as described in wl_output.transform. Clients
2758 willing to retrieve the output size in the global compositor
2759 space should use xdg_output.logical_size instead.
2760
2761 The vertical refresh rate can be set to zero if it doesn't make
2762 sense for this output (e.g. for virtual outputs).
2763
2764 The mode event will be followed by a done event (starting from
2765 version 2).
2766
2767 Clients should not use the refresh rate to schedule frames. Instead,
2768 they should use the wl_surface.frame event or the presentation-time
2769 protocol.
2770
2771 Note: this information is not always meaningful for all outputs. Some
2772 compositors, such as those exposing virtual outputs, might fake the
2773 refresh rate or the size.
2774 </description>
2775 <arg name="flags" type="uint" enum="mode" summary="bitfield of mode flags"/>
2776 <arg name="width" type="int" summary="width of the mode in hardware units"/>
2777 <arg name="height" type="int" summary="height of the mode in hardware units"/>
2778 <arg name="refresh" type="int" summary="vertical refresh rate in mHz"/>
2779 </event>
2780
2781 <!-- Version 2 additions -->
2782
2783 <event name="done" since="2">
2784 <description summary="sent all information about output">
2785 This event is sent after all other properties have been
2786 sent after binding to the output object and after any
2787 other property changes done after that. This allows
2788 changes to the output properties to be seen as
2789 atomic, even if they happen via multiple events.
2790 </description>
2791 </event>
2792
2793 <event name="scale" since="2">
2794 <description summary="output scaling properties">
2795 This event contains scaling geometry information
2796 that is not in the geometry event. It may be sent after
2797 binding the output object or if the output scale changes
2798 later. If it is not sent, the client should assume a
2799 scale of 1.
2800
2801 A scale larger than 1 means that the compositor will
2802 automatically scale surface buffers by this amount
2803 when rendering. This is used for very high resolution
2804 displays where applications rendering at the native
2805 resolution would be too small to be legible.
2806
2807 It is intended that scaling aware clients track the
2808 current output of a surface, and if it is on a scaled
2809 output it should use wl_surface.set_buffer_scale with
2810 the scale of the output. That way the compositor can
2811 avoid scaling the surface, and the client can supply
2812 a higher detail image.
2813
2814 The scale event will be followed by a done event.
2815 </description>
2816 <arg name="factor" type="int" summary="scaling factor of output"/>
2817 </event>
2818
2819 <!-- Version 3 additions -->
2820
2821 <request name="release" type="destructor" since="3">
2822 <description summary="release the output object">
2823 Using this request a client can tell the server that it is not going to
2824 use the output object anymore.
2825 </description>
2826 </request>
2827
2828 <!-- Version 4 additions -->
2829
2830 <event name="name" since="4">
2831 <description summary="name of this output">
2832 Many compositors will assign user-friendly names to their outputs, show
2833 them to the user, allow the user to refer to an output, etc. The client
2834 may wish to know this name as well to offer the user similar behaviors.
2835
2836 The name is a UTF-8 string with no convention defined for its contents.
2837 Each name is unique among all wl_output globals. The name is only
2838 guaranteed to be unique for the compositor instance.
2839
2840 The same output name is used for all clients for a given wl_output
2841 global. Thus, the name can be shared across processes to refer to a
2842 specific wl_output global.
2843
2844 The name is not guaranteed to be persistent across sessions, thus cannot
2845 be used to reliably identify an output in e.g. configuration files.
2846
2847 Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do
2848 not assume that the name is a reflection of an underlying DRM connector,
2849 X11 connection, etc.
2850
2851 The name event is sent after binding the output object. This event is
2852 only sent once per output object, and the name does not change over the
2853 lifetime of the wl_output global.
2854
2855 Compositors may re-use the same output name if the wl_output global is
2856 destroyed and re-created later. Compositors should avoid re-using the
2857 same name if possible.
2858
2859 The name event will be followed by a done event.
2860 </description>
2861 <arg name="name" type="string" summary="output name"/>
2862 </event>
2863
2864 <event name="description" since="4">
2865 <description summary="human-readable description of this output">
2866 Many compositors can produce human-readable descriptions of their
2867 outputs. The client may wish to know this description as well, e.g. for
2868 output selection purposes.
2869
2870 The description is a UTF-8 string with no convention defined for its
2871 contents. The description is not guaranteed to be unique among all
2872 wl_output globals. Examples might include 'Foocorp 11" Display' or
2873 'Virtual X11 output via :1'.
2874
2875 The description event is sent after binding the output object and
2876 whenever the description changes. The description is optional, and may
2877 not be sent at all.
2878
2879 The description event will be followed by a done event.
2880 </description>
2881 <arg name="description" type="string" summary="output description"/>
2882 </event>
2883 </interface>
2884
2885 <interface name="wl_region" version="1">
2886 <description summary="region interface">
2887 A region object describes an area.
2888
2889 Region objects are used to describe the opaque and input
2890 regions of a surface.
2891 </description>
2892
2893 <request name="destroy" type="destructor">
2894 <description summary="destroy region">
2895 Destroy the region. This will invalidate the object ID.
2896 </description>
2897 </request>
2898
2899 <request name="add">
2900 <description summary="add rectangle to region">
2901 Add the specified rectangle to the region.
2902 </description>
2903 <arg name="x" type="int" summary="region-local x coordinate"/>
2904 <arg name="y" type="int" summary="region-local y coordinate"/>
2905 <arg name="width" type="int" summary="rectangle width"/>
2906 <arg name="height" type="int" summary="rectangle height"/>
2907 </request>
2908
2909 <request name="subtract">
2910 <description summary="subtract rectangle from region">
2911 Subtract the specified rectangle from the region.
2912 </description>
2913 <arg name="x" type="int" summary="region-local x coordinate"/>
2914 <arg name="y" type="int" summary="region-local y coordinate"/>
2915 <arg name="width" type="int" summary="rectangle width"/>
2916 <arg name="height" type="int" summary="rectangle height"/>
2917 </request>
2918 </interface>
2919
2920 <interface name="wl_subcompositor" version="1">
2921 <description summary="sub-surface compositing">
2922 The global interface exposing sub-surface compositing capabilities.
2923 A wl_surface, that has sub-surfaces associated, is called the
2924 parent surface. Sub-surfaces can be arbitrarily nested and create
2925 a tree of sub-surfaces.
2926
2927 The root surface in a tree of sub-surfaces is the main
2928 surface. The main surface cannot be a sub-surface, because
2929 sub-surfaces must always have a parent.
2930
2931 A main surface with its sub-surfaces forms a (compound) window.
2932 For window management purposes, this set of wl_surface objects is
2933 to be considered as a single window, and it should also behave as
2934 such.
2935
2936 The aim of sub-surfaces is to offload some of the compositing work
2937 within a window from clients to the compositor. A prime example is
2938 a video player with decorations and video in separate wl_surface
2939 objects. This should allow the compositor to pass YUV video buffer
2940 processing to dedicated overlay hardware when possible.
2941 </description>
2942
2943 <request name="destroy" type="destructor">
2944 <description summary="unbind from the subcompositor interface">
2945 Informs the server that the client will not be using this
2946 protocol object anymore. This does not affect any other
2947 objects, wl_subsurface objects included.
2948 </description>
2949 </request>
2950
2951 <enum name="error">
2952 <entry name="bad_surface" value="0"
2953 summary="the to-be sub-surface is invalid"/>
2954 <entry name="bad_parent" value="1"
2955 summary="the to-be sub-surface parent is invalid"/>
2956 </enum>
2957
2958 <request name="get_subsurface">
2959 <description summary="give a surface the role sub-surface">
2960 Create a sub-surface interface for the given surface, and
2961 associate it with the given parent surface. This turns a
2962 plain wl_surface into a sub-surface.
2963
2964 The to-be sub-surface must not already have another role, and it
2965 must not have an existing wl_subsurface object. Otherwise the
2966 bad_surface protocol error is raised.
2967
2968 Adding sub-surfaces to a parent is a double-buffered operation on the
2969 parent (see wl_surface.commit). The effect of adding a sub-surface
2970 becomes visible on the next time the state of the parent surface is
2971 applied.
2972
2973 The parent surface must not be one of the child surface's descendants,
2974 and the parent must be different from the child surface, otherwise the
2975 bad_parent protocol error is raised.
2976
2977 This request modifies the behaviour of wl_surface.commit request on
2978 the sub-surface, see the documentation on wl_subsurface interface.
2979 </description>
2980 <arg name="id" type="new_id" interface="wl_subsurface"
2981 summary="the new sub-surface object ID"/>
2982 <arg name="surface" type="object" interface="wl_surface"
2983 summary="the surface to be turned into a sub-surface"/>
2984 <arg name="parent" type="object" interface="wl_surface"
2985 summary="the parent surface"/>
2986 </request>
2987 </interface>
2988
2989 <interface name="wl_subsurface" version="1">
2990 <description summary="sub-surface interface to a wl_surface">
2991 An additional interface to a wl_surface object, which has been
2992 made a sub-surface. A sub-surface has one parent surface. A
2993 sub-surface's size and position are not limited to that of the parent.
2994 Particularly, a sub-surface is not automatically clipped to its
2995 parent's area.
2996
2997 A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
2998 and the parent surface is mapped. The order of which one happens
2999 first is irrelevant. A sub-surface is hidden if the parent becomes
3000 hidden, or if a NULL wl_buffer is applied. These rules apply
3001 recursively through the tree of surfaces.
3002
3003 The behaviour of a wl_surface.commit request on a sub-surface
3004 depends on the sub-surface's mode. The possible modes are
3005 synchronized and desynchronized, see methods
3006 wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized
3007 mode caches the wl_surface state to be applied when the parent's
3008 state gets applied, and desynchronized mode applies the pending
3009 wl_surface state directly. A sub-surface is initially in the
3010 synchronized mode.
3011
3012 Sub-surfaces also have another kind of state, which is managed by
3013 wl_subsurface requests, as opposed to wl_surface requests. This
3014 state includes the sub-surface position relative to the parent
3015 surface (wl_subsurface.set_position), and the stacking order of
3016 the parent and its sub-surfaces (wl_subsurface.place_above and
3017 .place_below). This state is applied when the parent surface's
3018 wl_surface state is applied, regardless of the sub-surface's mode.
3019 As the exception, set_sync and set_desync are effective immediately.
3020
3021 The main surface can be thought to be always in desynchronized mode,
3022 since it does not have a parent in the sub-surfaces sense.
3023
3024 Even if a sub-surface is in desynchronized mode, it will behave as
3025 in synchronized mode, if its parent surface behaves as in
3026 synchronized mode. This rule is applied recursively throughout the
3027 tree of surfaces. This means, that one can set a sub-surface into
3028 synchronized mode, and then assume that all its child and grand-child
3029 sub-surfaces are synchronized, too, without explicitly setting them.
3030
3031 Destroying a sub-surface takes effect immediately. If you need to
3032 synchronize the removal of a sub-surface to the parent surface update,
3033 unmap the sub-surface first by attaching a NULL wl_buffer, update parent,
3034 and then destroy the sub-surface.
3035
3036 If the parent wl_surface object is destroyed, the sub-surface is
3037 unmapped.
3038 </description>
3039
3040 <request name="destroy" type="destructor">
3041 <description summary="remove sub-surface interface">
3042 The sub-surface interface is removed from the wl_surface object
3043 that was turned into a sub-surface with a
3044 wl_subcompositor.get_subsurface request. The wl_surface's association
3045 to the parent is deleted. The wl_surface is unmapped immediately.
3046 </description>
3047 </request>
3048
3049 <enum name="error">
3050 <entry name="bad_surface" value="0"
3051 summary="wl_surface is not a sibling or the parent"/>
3052 </enum>
3053
3054 <request name="set_position">
3055 <description summary="reposition the sub-surface">
3056 This schedules a sub-surface position change.
3057 The sub-surface will be moved so that its origin (top left
3058 corner pixel) will be at the location x, y of the parent surface
3059 coordinate system. The coordinates are not restricted to the parent
3060 surface area. Negative values are allowed.
3061
3062 The scheduled coordinates will take effect whenever the state of the
3063 parent surface is applied. When this happens depends on whether the
3064 parent surface is in synchronized mode or not. See
3065 wl_subsurface.set_sync and wl_subsurface.set_desync for details.
3066
3067 If more than one set_position request is invoked by the client before
3068 the commit of the parent surface, the position of a new request always
3069 replaces the scheduled position from any previous request.
3070
3071 The initial position is 0, 0.
3072 </description>
3073 <arg name="x" type="int" summary="x coordinate in the parent surface"/>
3074 <arg name="y" type="int" summary="y coordinate in the parent surface"/>
3075 </request>
3076
3077 <request name="place_above">
3078 <description summary="restack the sub-surface">
3079 This sub-surface is taken from the stack, and put back just
3080 above the reference surface, changing the z-order of the sub-surfaces.
3081 The reference surface must be one of the sibling surfaces, or the
3082 parent surface. Using any other surface, including this sub-surface,
3083 will cause a protocol error.
3084
3085 The z-order is double-buffered. Requests are handled in order and
3086 applied immediately to a pending state. The final pending state is
3087 copied to the active state the next time the state of the parent
3088 surface is applied. When this happens depends on whether the parent
3089 surface is in synchronized mode or not. See wl_subsurface.set_sync and
3090 wl_subsurface.set_desync for details.
3091
3092 A new sub-surface is initially added as the top-most in the stack
3093 of its siblings and parent.
3094 </description>
3095 <arg name="sibling" type="object" interface="wl_surface"
3096 summary="the reference surface"/>
3097 </request>
3098
3099 <request name="place_below">
3100 <description summary="restack the sub-surface">
3101 The sub-surface is placed just below the reference surface.
3102 See wl_subsurface.place_above.
3103 </description>
3104 <arg name="sibling" type="object" interface="wl_surface"
3105 summary="the reference surface"/>
3106 </request>
3107
3108 <request name="set_sync">
3109 <description summary="set sub-surface to synchronized mode">
3110 Change the commit behaviour of the sub-surface to synchronized
3111 mode, also described as the parent dependent mode.
3112
3113 In synchronized mode, wl_surface.commit on a sub-surface will
3114 accumulate the committed state in a cache, but the state will
3115 not be applied and hence will not change the compositor output.
3116 The cached state is applied to the sub-surface immediately after
3117 the parent surface's state is applied. This ensures atomic
3118 updates of the parent and all its synchronized sub-surfaces.
3119 Applying the cached state will invalidate the cache, so further
3120 parent surface commits do not (re-)apply old state.
3121
3122 See wl_subsurface for the recursive effect of this mode.
3123 </description>
3124 </request>
3125
3126 <request name="set_desync">
3127 <description summary="set sub-surface to desynchronized mode">
3128 Change the commit behaviour of the sub-surface to desynchronized
3129 mode, also described as independent or freely running mode.
3130
3131 In desynchronized mode, wl_surface.commit on a sub-surface will
3132 apply the pending state directly, without caching, as happens
3133 normally with a wl_surface. Calling wl_surface.commit on the
3134 parent surface has no effect on the sub-surface's wl_surface
3135 state. This mode allows a sub-surface to be updated on its own.
3136
3137 If cached state exists when wl_surface.commit is called in
3138 desynchronized mode, the pending state is added to the cached
3139 state, and applied as a whole. This invalidates the cache.
3140
3141 Note: even if a sub-surface is set to desynchronized, a parent
3142 sub-surface may override it to behave as synchronized. For details,
3143 see wl_subsurface.
3144
3145 If a surface's parent surface behaves as desynchronized, then
3146 the cached state is applied on set_desync.
3147 </description>
3148 </request>
3149 </interface>
3150
3151</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/xdg-activation-v1.xml b/raylib/src/external/glfw/deps/wayland/xdg-activation-v1.xml
new file mode 100644
index 0000000..9adcc27
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/xdg-activation-v1.xml
@@ -0,0 +1,200 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="xdg_activation_v1">
3
4 <copyright>
5 Copyright © 2020 Aleix Pol Gonzalez &lt;aleixpol@kde.org&gt;
6 Copyright © 2020 Carlos Garnacho &lt;carlosg@gnome.org&gt;
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
17 Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 </copyright>
27
28 <description summary="Protocol for requesting activation of surfaces">
29 The way for a client to pass focus to another toplevel is as follows.
30
31 The client that intends to activate another toplevel uses the
32 xdg_activation_v1.get_activation_token request to get an activation token.
33 This token is then forwarded to the client, which is supposed to activate
34 one of its surfaces, through a separate band of communication.
35
36 One established way of doing this is through the XDG_ACTIVATION_TOKEN
37 environment variable of a newly launched child process. The child process
38 should unset the environment variable again right after reading it out in
39 order to avoid propagating it to other child processes.
40
41 Another established way exists for Applications implementing the D-Bus
42 interface org.freedesktop.Application, which should get their token under
43 activation-token on their platform_data.
44
45 In general activation tokens may be transferred across clients through
46 means not described in this protocol.
47
48 The client to be activated will then pass the token
49 it received to the xdg_activation_v1.activate request. The compositor can
50 then use this token to decide how to react to the activation request.
51
52 The token the activating client gets may be ineffective either already at
53 the time it receives it, for example if it was not focused, for focus
54 stealing prevention. The activating client will have no way to discover
55 the validity of the token, and may still forward it to the to be activated
56 client.
57
58 The created activation token may optionally get information attached to it
59 that can be used by the compositor to identify the application that we
60 intend to activate. This can for example be used to display a visual hint
61 about what application is being started.
62
63 Warning! The protocol described in this file is currently in the testing
64 phase. Backward compatible changes may be added together with the
65 corresponding interface version bump. Backward incompatible changes can
66 only be done by creating a new major version of the extension.
67 </description>
68
69 <interface name="xdg_activation_v1" version="1">
70 <description summary="interface for activating surfaces">
71 A global interface used for informing the compositor about applications
72 being activated or started, or for applications to request to be
73 activated.
74 </description>
75
76 <request name="destroy" type="destructor">
77 <description summary="destroy the xdg_activation object">
78 Notify the compositor that the xdg_activation object will no longer be
79 used.
80
81 The child objects created via this interface are unaffected and should
82 be destroyed separately.
83 </description>
84 </request>
85
86 <request name="get_activation_token">
87 <description summary="requests a token">
88 Creates an xdg_activation_token_v1 object that will provide
89 the initiating client with a unique token for this activation. This
90 token should be offered to the clients to be activated.
91 </description>
92
93 <arg name="id" type="new_id" interface="xdg_activation_token_v1"/>
94 </request>
95
96 <request name="activate">
97 <description summary="notify new interaction being available">
98 Requests surface activation. It's up to the compositor to display
99 this information as desired, for example by placing the surface above
100 the rest.
101
102 The compositor may know who requested this by checking the activation
103 token and might decide not to follow through with the activation if it's
104 considered unwanted.
105
106 Compositors can ignore unknown activation tokens when an invalid
107 token is passed.
108 </description>
109 <arg name="token" type="string" summary="the activation token of the initiating client"/>
110 <arg name="surface" type="object" interface="wl_surface"
111 summary="the wl_surface to activate"/>
112 </request>
113 </interface>
114
115 <interface name="xdg_activation_token_v1" version="1">
116 <description summary="an exported activation handle">
117 An object for setting up a token and receiving a token handle that can
118 be passed as an activation token to another client.
119
120 The object is created using the xdg_activation_v1.get_activation_token
121 request. This object should then be populated with the app_id, surface
122 and serial information and committed. The compositor shall then issue a
123 done event with the token. In case the request's parameters are invalid,
124 the compositor will provide an invalid token.
125 </description>
126
127 <enum name="error">
128 <entry name="already_used" value="0"
129 summary="The token has already been used previously"/>
130 </enum>
131
132 <request name="set_serial">
133 <description summary="specifies the seat and serial of the activating event">
134 Provides information about the seat and serial event that requested the
135 token.
136
137 The serial can come from an input or focus event. For instance, if a
138 click triggers the launch of a third-party client, the launcher client
139 should send a set_serial request with the serial and seat from the
140 wl_pointer.button event.
141
142 Some compositors might refuse to activate toplevels when the token
143 doesn't have a valid and recent enough event serial.
144
145 Must be sent before commit. This information is optional.
146 </description>
147 <arg name="serial" type="uint"
148 summary="the serial of the event that triggered the activation"/>
149 <arg name="seat" type="object" interface="wl_seat"
150 summary="the wl_seat of the event"/>
151 </request>
152
153 <request name="set_app_id">
154 <description summary="specifies the application being activated">
155 The requesting client can specify an app_id to associate the token
156 being created with it.
157
158 Must be sent before commit. This information is optional.
159 </description>
160 <arg name="app_id" type="string"
161 summary="the application id of the client being activated."/>
162 </request>
163
164 <request name="set_surface">
165 <description summary="specifies the surface requesting activation">
166 This request sets the surface requesting the activation. Note, this is
167 different from the surface that will be activated.
168
169 Some compositors might refuse to activate toplevels when the token
170 doesn't have a requesting surface.
171
172 Must be sent before commit. This information is optional.
173 </description>
174 <arg name="surface" type="object" interface="wl_surface"
175 summary="the requesting surface"/>
176 </request>
177
178 <request name="commit">
179 <description summary="issues the token request">
180 Requests an activation token based on the different parameters that
181 have been offered through set_serial, set_surface and set_app_id.
182 </description>
183 </request>
184
185 <event name="done">
186 <description summary="the exported activation token">
187 The 'done' event contains the unique token of this activation request
188 and notifies that the provider is done.
189 </description>
190 <arg name="token" type="string" summary="the exported activation token"/>
191 </event>
192
193 <request name="destroy" type="destructor">
194 <description summary="destroy the xdg_activation_token_v1 object">
195 Notify the compositor that the xdg_activation_token_v1 object will no
196 longer be used. The received token stays valid.
197 </description>
198 </request>
199 </interface>
200</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/xdg-decoration-unstable-v1.xml b/raylib/src/external/glfw/deps/wayland/xdg-decoration-unstable-v1.xml
new file mode 100644
index 0000000..e596775
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/xdg-decoration-unstable-v1.xml
@@ -0,0 +1,156 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="xdg_decoration_unstable_v1">
3 <copyright>
4 Copyright © 2018 Simon Ser
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
15 Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 DEALINGS IN THE SOFTWARE.
24 </copyright>
25
26 <interface name="zxdg_decoration_manager_v1" version="1">
27 <description summary="window decoration manager">
28 This interface allows a compositor to announce support for server-side
29 decorations.
30
31 A window decoration is a set of window controls as deemed appropriate by
32 the party managing them, such as user interface components used to move,
33 resize and change a window's state.
34
35 A client can use this protocol to request being decorated by a supporting
36 compositor.
37
38 If compositor and client do not negotiate the use of a server-side
39 decoration using this protocol, clients continue to self-decorate as they
40 see fit.
41
42 Warning! The protocol described in this file is experimental and
43 backward incompatible changes may be made. Backward compatible changes
44 may be added together with the corresponding interface version bump.
45 Backward incompatible changes are done by bumping the version number in
46 the protocol and interface names and resetting the interface version.
47 Once the protocol is to be declared stable, the 'z' prefix and the
48 version number in the protocol and interface names are removed and the
49 interface version number is reset.
50 </description>
51
52 <request name="destroy" type="destructor">
53 <description summary="destroy the decoration manager object">
54 Destroy the decoration manager. This doesn't destroy objects created
55 with the manager.
56 </description>
57 </request>
58
59 <request name="get_toplevel_decoration">
60 <description summary="create a new toplevel decoration object">
61 Create a new decoration object associated with the given toplevel.
62
63 Creating an xdg_toplevel_decoration from an xdg_toplevel which has a
64 buffer attached or committed is a client error, and any attempts by a
65 client to attach or manipulate a buffer prior to the first
66 xdg_toplevel_decoration.configure event must also be treated as
67 errors.
68 </description>
69 <arg name="id" type="new_id" interface="zxdg_toplevel_decoration_v1"/>
70 <arg name="toplevel" type="object" interface="xdg_toplevel"/>
71 </request>
72 </interface>
73
74 <interface name="zxdg_toplevel_decoration_v1" version="1">
75 <description summary="decoration object for a toplevel surface">
76 The decoration object allows the compositor to toggle server-side window
77 decorations for a toplevel surface. The client can request to switch to
78 another mode.
79
80 The xdg_toplevel_decoration object must be destroyed before its
81 xdg_toplevel.
82 </description>
83
84 <enum name="error">
85 <entry name="unconfigured_buffer" value="0"
86 summary="xdg_toplevel has a buffer attached before configure"/>
87 <entry name="already_constructed" value="1"
88 summary="xdg_toplevel already has a decoration object"/>
89 <entry name="orphaned" value="2"
90 summary="xdg_toplevel destroyed before the decoration object"/>
91 </enum>
92
93 <request name="destroy" type="destructor">
94 <description summary="destroy the decoration object">
95 Switch back to a mode without any server-side decorations at the next
96 commit.
97 </description>
98 </request>
99
100 <enum name="mode">
101 <description summary="window decoration modes">
102 These values describe window decoration modes.
103 </description>
104 <entry name="client_side" value="1"
105 summary="no server-side window decoration"/>
106 <entry name="server_side" value="2"
107 summary="server-side window decoration"/>
108 </enum>
109
110 <request name="set_mode">
111 <description summary="set the decoration mode">
112 Set the toplevel surface decoration mode. This informs the compositor
113 that the client prefers the provided decoration mode.
114
115 After requesting a decoration mode, the compositor will respond by
116 emitting an xdg_surface.configure event. The client should then update
117 its content, drawing it without decorations if the received mode is
118 server-side decorations. The client must also acknowledge the configure
119 when committing the new content (see xdg_surface.ack_configure).
120
121 The compositor can decide not to use the client's mode and enforce a
122 different mode instead.
123
124 Clients whose decoration mode depend on the xdg_toplevel state may send
125 a set_mode request in response to an xdg_surface.configure event and wait
126 for the next xdg_surface.configure event to prevent unwanted state.
127 Such clients are responsible for preventing configure loops and must
128 make sure not to send multiple successive set_mode requests with the
129 same decoration mode.
130 </description>
131 <arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
132 </request>
133
134 <request name="unset_mode">
135 <description summary="unset the decoration mode">
136 Unset the toplevel surface decoration mode. This informs the compositor
137 that the client doesn't prefer a particular decoration mode.
138
139 This request has the same semantics as set_mode.
140 </description>
141 </request>
142
143 <event name="configure">
144 <description summary="suggest a surface change">
145 The configure event asks the client to change its decoration mode. The
146 configured state should not be applied immediately. Clients must send an
147 ack_configure in response to this event. See xdg_surface.configure and
148 xdg_surface.ack_configure for details.
149
150 A configure event can be sent at any time. The specified mode must be
151 obeyed by the client.
152 </description>
153 <arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
154 </event>
155 </interface>
156</protocol>
diff --git a/raylib/src/external/glfw/deps/wayland/xdg-shell.xml b/raylib/src/external/glfw/deps/wayland/xdg-shell.xml
new file mode 100644
index 0000000..777eaa7
--- /dev/null
+++ b/raylib/src/external/glfw/deps/wayland/xdg-shell.xml
@@ -0,0 +1,1370 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="xdg_shell">
3
4 <copyright>
5 Copyright © 2008-2013 Kristian Høgsberg
6 Copyright © 2013 Rafael Antognolli
7 Copyright © 2013 Jasper St. Pierre
8 Copyright © 2010-2013 Intel Corporation
9 Copyright © 2015-2017 Samsung Electronics Co., Ltd
10 Copyright © 2015-2017 Red Hat Inc.
11
12 Permission is hereby granted, free of charge, to any person obtaining a
13 copy of this software and associated documentation files (the "Software"),
14 to deal in the Software without restriction, including without limitation
15 the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 and/or sell copies of the Software, and to permit persons to whom the
17 Software is furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice (including the next
20 paragraph) shall be included in all copies or substantial portions of the
21 Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 DEALINGS IN THE SOFTWARE.
30 </copyright>
31
32 <interface name="xdg_wm_base" version="6">
33 <description summary="create desktop-style surfaces">
34 The xdg_wm_base interface is exposed as a global object enabling clients
35 to turn their wl_surfaces into windows in a desktop environment. It
36 defines the basic functionality needed for clients and the compositor to
37 create windows that can be dragged, resized, maximized, etc, as well as
38 creating transient windows such as popup menus.
39 </description>
40
41 <enum name="error">
42 <entry name="role" value="0" summary="given wl_surface has another role"/>
43 <entry name="defunct_surfaces" value="1"
44 summary="xdg_wm_base was destroyed before children"/>
45 <entry name="not_the_topmost_popup" value="2"
46 summary="the client tried to map or destroy a non-topmost popup"/>
47 <entry name="invalid_popup_parent" value="3"
48 summary="the client specified an invalid popup parent surface"/>
49 <entry name="invalid_surface_state" value="4"
50 summary="the client provided an invalid surface state"/>
51 <entry name="invalid_positioner" value="5"
52 summary="the client provided an invalid positioner"/>
53 <entry name="unresponsive" value="6"
54 summary="the client didn’t respond to a ping event in time"/>
55 </enum>
56
57 <request name="destroy" type="destructor">
58 <description summary="destroy xdg_wm_base">
59 Destroy this xdg_wm_base object.
60
61 Destroying a bound xdg_wm_base object while there are surfaces
62 still alive created by this xdg_wm_base object instance is illegal
63 and will result in a defunct_surfaces error.
64 </description>
65 </request>
66
67 <request name="create_positioner">
68 <description summary="create a positioner object">
69 Create a positioner object. A positioner object is used to position
70 surfaces relative to some parent surface. See the interface description
71 and xdg_surface.get_popup for details.
72 </description>
73 <arg name="id" type="new_id" interface="xdg_positioner"/>
74 </request>
75
76 <request name="get_xdg_surface">
77 <description summary="create a shell surface from a surface">
78 This creates an xdg_surface for the given surface. While xdg_surface
79 itself is not a role, the corresponding surface may only be assigned
80 a role extending xdg_surface, such as xdg_toplevel or xdg_popup. It is
81 illegal to create an xdg_surface for a wl_surface which already has an
82 assigned role and this will result in a role error.
83
84 This creates an xdg_surface for the given surface. An xdg_surface is
85 used as basis to define a role to a given surface, such as xdg_toplevel
86 or xdg_popup. It also manages functionality shared between xdg_surface
87 based surface roles.
88
89 See the documentation of xdg_surface for more details about what an
90 xdg_surface is and how it is used.
91 </description>
92 <arg name="id" type="new_id" interface="xdg_surface"/>
93 <arg name="surface" type="object" interface="wl_surface"/>
94 </request>
95
96 <request name="pong">
97 <description summary="respond to a ping event">
98 A client must respond to a ping event with a pong request or
99 the client may be deemed unresponsive. See xdg_wm_base.ping
100 and xdg_wm_base.error.unresponsive.
101 </description>
102 <arg name="serial" type="uint" summary="serial of the ping event"/>
103 </request>
104
105 <event name="ping">
106 <description summary="check if the client is alive">
107 The ping event asks the client if it's still alive. Pass the
108 serial specified in the event back to the compositor by sending
109 a "pong" request back with the specified serial. See xdg_wm_base.pong.
110
111 Compositors can use this to determine if the client is still
112 alive. It's unspecified what will happen if the client doesn't
113 respond to the ping request, or in what timeframe. Clients should
114 try to respond in a reasonable amount of time. The “unresponsive”
115 error is provided for compositors that wish to disconnect unresponsive
116 clients.
117
118 A compositor is free to ping in any way it wants, but a client must
119 always respond to any xdg_wm_base object it created.
120 </description>
121 <arg name="serial" type="uint" summary="pass this to the pong request"/>
122 </event>
123 </interface>
124
125 <interface name="xdg_positioner" version="6">
126 <description summary="child surface positioner">
127 The xdg_positioner provides a collection of rules for the placement of a
128 child surface relative to a parent surface. Rules can be defined to ensure
129 the child surface remains within the visible area's borders, and to
130 specify how the child surface changes its position, such as sliding along
131 an axis, or flipping around a rectangle. These positioner-created rules are
132 constrained by the requirement that a child surface must intersect with or
133 be at least partially adjacent to its parent surface.
134
135 See the various requests for details about possible rules.
136
137 At the time of the request, the compositor makes a copy of the rules
138 specified by the xdg_positioner. Thus, after the request is complete the
139 xdg_positioner object can be destroyed or reused; further changes to the
140 object will have no effect on previous usages.
141
142 For an xdg_positioner object to be considered complete, it must have a
143 non-zero size set by set_size, and a non-zero anchor rectangle set by
144 set_anchor_rect. Passing an incomplete xdg_positioner object when
145 positioning a surface raises an invalid_positioner error.
146 </description>
147
148 <enum name="error">
149 <entry name="invalid_input" value="0" summary="invalid input provided"/>
150 </enum>
151
152 <request name="destroy" type="destructor">
153 <description summary="destroy the xdg_positioner object">
154 Notify the compositor that the xdg_positioner will no longer be used.
155 </description>
156 </request>
157
158 <request name="set_size">
159 <description summary="set the size of the to-be positioned rectangle">
160 Set the size of the surface that is to be positioned with the positioner
161 object. The size is in surface-local coordinates and corresponds to the
162 window geometry. See xdg_surface.set_window_geometry.
163
164 If a zero or negative size is set the invalid_input error is raised.
165 </description>
166 <arg name="width" type="int" summary="width of positioned rectangle"/>
167 <arg name="height" type="int" summary="height of positioned rectangle"/>
168 </request>
169
170 <request name="set_anchor_rect">
171 <description summary="set the anchor rectangle within the parent surface">
172 Specify the anchor rectangle within the parent surface that the child
173 surface will be placed relative to. The rectangle is relative to the
174 window geometry as defined by xdg_surface.set_window_geometry of the
175 parent surface.
176
177 When the xdg_positioner object is used to position a child surface, the
178 anchor rectangle may not extend outside the window geometry of the
179 positioned child's parent surface.
180
181 If a negative size is set the invalid_input error is raised.
182 </description>
183 <arg name="x" type="int" summary="x position of anchor rectangle"/>
184 <arg name="y" type="int" summary="y position of anchor rectangle"/>
185 <arg name="width" type="int" summary="width of anchor rectangle"/>
186 <arg name="height" type="int" summary="height of anchor rectangle"/>
187 </request>
188
189 <enum name="anchor">
190 <entry name="none" value="0"/>
191 <entry name="top" value="1"/>
192 <entry name="bottom" value="2"/>
193 <entry name="left" value="3"/>
194 <entry name="right" value="4"/>
195 <entry name="top_left" value="5"/>
196 <entry name="bottom_left" value="6"/>
197 <entry name="top_right" value="7"/>
198 <entry name="bottom_right" value="8"/>
199 </enum>
200
201 <request name="set_anchor">
202 <description summary="set anchor rectangle anchor">
203 Defines the anchor point for the anchor rectangle. The specified anchor
204 is used derive an anchor point that the child surface will be
205 positioned relative to. If a corner anchor is set (e.g. 'top_left' or
206 'bottom_right'), the anchor point will be at the specified corner;
207 otherwise, the derived anchor point will be centered on the specified
208 edge, or in the center of the anchor rectangle if no edge is specified.
209 </description>
210 <arg name="anchor" type="uint" enum="anchor"
211 summary="anchor"/>
212 </request>
213
214 <enum name="gravity">
215 <entry name="none" value="0"/>
216 <entry name="top" value="1"/>
217 <entry name="bottom" value="2"/>
218 <entry name="left" value="3"/>
219 <entry name="right" value="4"/>
220 <entry name="top_left" value="5"/>
221 <entry name="bottom_left" value="6"/>
222 <entry name="top_right" value="7"/>
223 <entry name="bottom_right" value="8"/>
224 </enum>
225
226 <request name="set_gravity">
227 <description summary="set child surface gravity">
228 Defines in what direction a surface should be positioned, relative to
229 the anchor point of the parent surface. If a corner gravity is
230 specified (e.g. 'bottom_right' or 'top_left'), then the child surface
231 will be placed towards the specified gravity; otherwise, the child
232 surface will be centered over the anchor point on any axis that had no
233 gravity specified. If the gravity is not in the ‘gravity’ enum, an
234 invalid_input error is raised.
235 </description>
236 <arg name="gravity" type="uint" enum="gravity"
237 summary="gravity direction"/>
238 </request>
239
240 <enum name="constraint_adjustment" bitfield="true">
241 <description summary="constraint adjustments">
242 The constraint adjustment value define ways the compositor will adjust
243 the position of the surface, if the unadjusted position would result
244 in the surface being partly constrained.
245
246 Whether a surface is considered 'constrained' is left to the compositor
247 to determine. For example, the surface may be partly outside the
248 compositor's defined 'work area', thus necessitating the child surface's
249 position be adjusted until it is entirely inside the work area.
250
251 The adjustments can be combined, according to a defined precedence: 1)
252 Flip, 2) Slide, 3) Resize.
253 </description>
254 <entry name="none" value="0">
255 <description summary="don't move the child surface when constrained">
256 Don't alter the surface position even if it is constrained on some
257 axis, for example partially outside the edge of an output.
258 </description>
259 </entry>
260 <entry name="slide_x" value="1">
261 <description summary="move along the x axis until unconstrained">
262 Slide the surface along the x axis until it is no longer constrained.
263
264 First try to slide towards the direction of the gravity on the x axis
265 until either the edge in the opposite direction of the gravity is
266 unconstrained or the edge in the direction of the gravity is
267 constrained.
268
269 Then try to slide towards the opposite direction of the gravity on the
270 x axis until either the edge in the direction of the gravity is
271 unconstrained or the edge in the opposite direction of the gravity is
272 constrained.
273 </description>
274 </entry>
275 <entry name="slide_y" value="2">
276 <description summary="move along the y axis until unconstrained">
277 Slide the surface along the y axis until it is no longer constrained.
278
279 First try to slide towards the direction of the gravity on the y axis
280 until either the edge in the opposite direction of the gravity is
281 unconstrained or the edge in the direction of the gravity is
282 constrained.
283
284 Then try to slide towards the opposite direction of the gravity on the
285 y axis until either the edge in the direction of the gravity is
286 unconstrained or the edge in the opposite direction of the gravity is
287 constrained.
288 </description>
289 </entry>
290 <entry name="flip_x" value="4">
291 <description summary="invert the anchor and gravity on the x axis">
292 Invert the anchor and gravity on the x axis if the surface is
293 constrained on the x axis. For example, if the left edge of the
294 surface is constrained, the gravity is 'left' and the anchor is
295 'left', change the gravity to 'right' and the anchor to 'right'.
296
297 If the adjusted position also ends up being constrained, the resulting
298 position of the flip_x adjustment will be the one before the
299 adjustment.
300 </description>
301 </entry>
302 <entry name="flip_y" value="8">
303 <description summary="invert the anchor and gravity on the y axis">
304 Invert the anchor and gravity on the y axis if the surface is
305 constrained on the y axis. For example, if the bottom edge of the
306 surface is constrained, the gravity is 'bottom' and the anchor is
307 'bottom', change the gravity to 'top' and the anchor to 'top'.
308
309 The adjusted position is calculated given the original anchor
310 rectangle and offset, but with the new flipped anchor and gravity
311 values.
312
313 If the adjusted position also ends up being constrained, the resulting
314 position of the flip_y adjustment will be the one before the
315 adjustment.
316 </description>
317 </entry>
318 <entry name="resize_x" value="16">
319 <description summary="horizontally resize the surface">
320 Resize the surface horizontally so that it is completely
321 unconstrained.
322 </description>
323 </entry>
324 <entry name="resize_y" value="32">
325 <description summary="vertically resize the surface">
326 Resize the surface vertically so that it is completely unconstrained.
327 </description>
328 </entry>
329 </enum>
330
331 <request name="set_constraint_adjustment">
332 <description summary="set the adjustment to be done when constrained">
333 Specify how the window should be positioned if the originally intended
334 position caused the surface to be constrained, meaning at least
335 partially outside positioning boundaries set by the compositor. The
336 adjustment is set by constructing a bitmask describing the adjustment to
337 be made when the surface is constrained on that axis.
338
339 If no bit for one axis is set, the compositor will assume that the child
340 surface should not change its position on that axis when constrained.
341
342 If more than one bit for one axis is set, the order of how adjustments
343 are applied is specified in the corresponding adjustment descriptions.
344
345 The default adjustment is none.
346 </description>
347 <arg name="constraint_adjustment" type="uint"
348 summary="bit mask of constraint adjustments"/>
349 </request>
350
351 <request name="set_offset">
352 <description summary="set surface position offset">
353 Specify the surface position offset relative to the position of the
354 anchor on the anchor rectangle and the anchor on the surface. For
355 example if the anchor of the anchor rectangle is at (x, y), the surface
356 has the gravity bottom|right, and the offset is (ox, oy), the calculated
357 surface position will be (x + ox, y + oy). The offset position of the
358 surface is the one used for constraint testing. See
359 set_constraint_adjustment.
360
361 An example use case is placing a popup menu on top of a user interface
362 element, while aligning the user interface element of the parent surface
363 with some user interface element placed somewhere in the popup surface.
364 </description>
365 <arg name="x" type="int" summary="surface position x offset"/>
366 <arg name="y" type="int" summary="surface position y offset"/>
367 </request>
368
369 <!-- Version 3 additions -->
370
371 <request name="set_reactive" since="3">
372 <description summary="continuously reconstrain the surface">
373 When set reactive, the surface is reconstrained if the conditions used
374 for constraining changed, e.g. the parent window moved.
375
376 If the conditions changed and the popup was reconstrained, an
377 xdg_popup.configure event is sent with updated geometry, followed by an
378 xdg_surface.configure event.
379 </description>
380 </request>
381
382 <request name="set_parent_size" since="3">
383 <description summary="">
384 Set the parent window geometry the compositor should use when
385 positioning the popup. The compositor may use this information to
386 determine the future state the popup should be constrained using. If
387 this doesn't match the dimension of the parent the popup is eventually
388 positioned against, the behavior is undefined.
389
390 The arguments are given in the surface-local coordinate space.
391 </description>
392 <arg name="parent_width" type="int"
393 summary="future window geometry width of parent"/>
394 <arg name="parent_height" type="int"
395 summary="future window geometry height of parent"/>
396 </request>
397
398 <request name="set_parent_configure" since="3">
399 <description summary="set parent configure this is a response to">
400 Set the serial of an xdg_surface.configure event this positioner will be
401 used in response to. The compositor may use this information together
402 with set_parent_size to determine what future state the popup should be
403 constrained using.
404 </description>
405 <arg name="serial" type="uint"
406 summary="serial of parent configure event"/>
407 </request>
408 </interface>
409
410 <interface name="xdg_surface" version="6">
411 <description summary="desktop user interface surface base interface">
412 An interface that may be implemented by a wl_surface, for
413 implementations that provide a desktop-style user interface.
414
415 It provides a base set of functionality required to construct user
416 interface elements requiring management by the compositor, such as
417 toplevel windows, menus, etc. The types of functionality are split into
418 xdg_surface roles.
419
420 Creating an xdg_surface does not set the role for a wl_surface. In order
421 to map an xdg_surface, the client must create a role-specific object
422 using, e.g., get_toplevel, get_popup. The wl_surface for any given
423 xdg_surface can have at most one role, and may not be assigned any role
424 not based on xdg_surface.
425
426 A role must be assigned before any other requests are made to the
427 xdg_surface object.
428
429 The client must call wl_surface.commit on the corresponding wl_surface
430 for the xdg_surface state to take effect.
431
432 Creating an xdg_surface from a wl_surface which has a buffer attached or
433 committed is a client error, and any attempts by a client to attach or
434 manipulate a buffer prior to the first xdg_surface.configure call must
435 also be treated as errors.
436
437 After creating a role-specific object and setting it up, the client must
438 perform an initial commit without any buffer attached. The compositor
439 will reply with initial wl_surface state such as
440 wl_surface.preferred_buffer_scale followed by an xdg_surface.configure
441 event. The client must acknowledge it and is then allowed to attach a
442 buffer to map the surface.
443
444 Mapping an xdg_surface-based role surface is defined as making it
445 possible for the surface to be shown by the compositor. Note that
446 a mapped surface is not guaranteed to be visible once it is mapped.
447
448 For an xdg_surface to be mapped by the compositor, the following
449 conditions must be met:
450 (1) the client has assigned an xdg_surface-based role to the surface
451 (2) the client has set and committed the xdg_surface state and the
452 role-dependent state to the surface
453 (3) the client has committed a buffer to the surface
454
455 A newly-unmapped surface is considered to have met condition (1) out
456 of the 3 required conditions for mapping a surface if its role surface
457 has not been destroyed, i.e. the client must perform the initial commit
458 again before attaching a buffer.
459 </description>
460
461 <enum name="error">
462 <entry name="not_constructed" value="1"
463 summary="Surface was not fully constructed"/>
464 <entry name="already_constructed" value="2"
465 summary="Surface was already constructed"/>
466 <entry name="unconfigured_buffer" value="3"
467 summary="Attaching a buffer to an unconfigured surface"/>
468 <entry name="invalid_serial" value="4"
469 summary="Invalid serial number when acking a configure event"/>
470 <entry name="invalid_size" value="5"
471 summary="Width or height was zero or negative"/>
472 <entry name="defunct_role_object" value="6"
473 summary="Surface was destroyed before its role object"/>
474 </enum>
475
476 <request name="destroy" type="destructor">
477 <description summary="destroy the xdg_surface">
478 Destroy the xdg_surface object. An xdg_surface must only be destroyed
479 after its role object has been destroyed, otherwise
480 a defunct_role_object error is raised.
481 </description>
482 </request>
483
484 <request name="get_toplevel">
485 <description summary="assign the xdg_toplevel surface role">
486 This creates an xdg_toplevel object for the given xdg_surface and gives
487 the associated wl_surface the xdg_toplevel role.
488
489 See the documentation of xdg_toplevel for more details about what an
490 xdg_toplevel is and how it is used.
491 </description>
492 <arg name="id" type="new_id" interface="xdg_toplevel"/>
493 </request>
494
495 <request name="get_popup">
496 <description summary="assign the xdg_popup surface role">
497 This creates an xdg_popup object for the given xdg_surface and gives
498 the associated wl_surface the xdg_popup role.
499
500 If null is passed as a parent, a parent surface must be specified using
501 some other protocol, before committing the initial state.
502
503 See the documentation of xdg_popup for more details about what an
504 xdg_popup is and how it is used.
505 </description>
506 <arg name="id" type="new_id" interface="xdg_popup"/>
507 <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/>
508 <arg name="positioner" type="object" interface="xdg_positioner"/>
509 </request>
510
511 <request name="set_window_geometry">
512 <description summary="set the new window geometry">
513 The window geometry of a surface is its "visible bounds" from the
514 user's perspective. Client-side decorations often have invisible
515 portions like drop-shadows which should be ignored for the
516 purposes of aligning, placing and constraining windows.
517
518 The window geometry is double buffered, and will be applied at the
519 time wl_surface.commit of the corresponding wl_surface is called.
520
521 When maintaining a position, the compositor should treat the (x, y)
522 coordinate of the window geometry as the top left corner of the window.
523 A client changing the (x, y) window geometry coordinate should in
524 general not alter the position of the window.
525
526 Once the window geometry of the surface is set, it is not possible to
527 unset it, and it will remain the same until set_window_geometry is
528 called again, even if a new subsurface or buffer is attached.
529
530 If never set, the value is the full bounds of the surface,
531 including any subsurfaces. This updates dynamically on every
532 commit. This unset is meant for extremely simple clients.
533
534 The arguments are given in the surface-local coordinate space of
535 the wl_surface associated with this xdg_surface, and may extend outside
536 of the wl_surface itself to mark parts of the subsurface tree as part of
537 the window geometry.
538
539 When applied, the effective window geometry will be the set window
540 geometry clamped to the bounding rectangle of the combined
541 geometry of the surface of the xdg_surface and the associated
542 subsurfaces.
543
544 The effective geometry will not be recalculated unless a new call to
545 set_window_geometry is done and the new pending surface state is
546 subsequently applied.
547
548 The width and height of the effective window geometry must be
549 greater than zero. Setting an invalid size will raise an
550 invalid_size error.
551 </description>
552 <arg name="x" type="int"/>
553 <arg name="y" type="int"/>
554 <arg name="width" type="int"/>
555 <arg name="height" type="int"/>
556 </request>
557
558 <request name="ack_configure">
559 <description summary="ack a configure event">
560 When a configure event is received, if a client commits the
561 surface in response to the configure event, then the client
562 must make an ack_configure request sometime before the commit
563 request, passing along the serial of the configure event.
564
565 For instance, for toplevel surfaces the compositor might use this
566 information to move a surface to the top left only when the client has
567 drawn itself for the maximized or fullscreen state.
568
569 If the client receives multiple configure events before it
570 can respond to one, it only has to ack the last configure event.
571 Acking a configure event that was never sent raises an invalid_serial
572 error.
573
574 A client is not required to commit immediately after sending
575 an ack_configure request - it may even ack_configure several times
576 before its next surface commit.
577
578 A client may send multiple ack_configure requests before committing, but
579 only the last request sent before a commit indicates which configure
580 event the client really is responding to.
581
582 Sending an ack_configure request consumes the serial number sent with
583 the request, as well as serial numbers sent by all configure events
584 sent on this xdg_surface prior to the configure event referenced by
585 the committed serial.
586
587 It is an error to issue multiple ack_configure requests referencing a
588 serial from the same configure event, or to issue an ack_configure
589 request referencing a serial from a configure event issued before the
590 event identified by the last ack_configure request for the same
591 xdg_surface. Doing so will raise an invalid_serial error.
592 </description>
593 <arg name="serial" type="uint" summary="the serial from the configure event"/>
594 </request>
595
596 <event name="configure">
597 <description summary="suggest a surface change">
598 The configure event marks the end of a configure sequence. A configure
599 sequence is a set of one or more events configuring the state of the
600 xdg_surface, including the final xdg_surface.configure event.
601
602 Where applicable, xdg_surface surface roles will during a configure
603 sequence extend this event as a latched state sent as events before the
604 xdg_surface.configure event. Such events should be considered to make up
605 a set of atomically applied configuration states, where the
606 xdg_surface.configure commits the accumulated state.
607
608 Clients should arrange their surface for the new states, and then send
609 an ack_configure request with the serial sent in this configure event at
610 some point before committing the new surface.
611
612 If the client receives multiple configure events before it can respond
613 to one, it is free to discard all but the last event it received.
614 </description>
615 <arg name="serial" type="uint" summary="serial of the configure event"/>
616 </event>
617
618 </interface>
619
620 <interface name="xdg_toplevel" version="6">
621 <description summary="toplevel surface">
622 This interface defines an xdg_surface role which allows a surface to,
623 among other things, set window-like properties such as maximize,
624 fullscreen, and minimize, set application-specific metadata like title and
625 id, and well as trigger user interactive operations such as interactive
626 resize and move.
627
628 Unmapping an xdg_toplevel means that the surface cannot be shown
629 by the compositor until it is explicitly mapped again.
630 All active operations (e.g., move, resize) are canceled and all
631 attributes (e.g. title, state, stacking, ...) are discarded for
632 an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to
633 the state it had right after xdg_surface.get_toplevel. The client
634 can re-map the toplevel by perfoming a commit without any buffer
635 attached, waiting for a configure event and handling it as usual (see
636 xdg_surface description).
637
638 Attaching a null buffer to a toplevel unmaps the surface.
639 </description>
640
641 <request name="destroy" type="destructor">
642 <description summary="destroy the xdg_toplevel">
643 This request destroys the role surface and unmaps the surface;
644 see "Unmapping" behavior in interface section for details.
645 </description>
646 </request>
647
648 <enum name="error">
649 <entry name="invalid_resize_edge" value="0" summary="provided value is
650 not a valid variant of the resize_edge enum"/>
651 <entry name="invalid_parent" value="1"
652 summary="invalid parent toplevel"/>
653 <entry name="invalid_size" value="2"
654 summary="client provided an invalid min or max size"/>
655 </enum>
656
657 <request name="set_parent">
658 <description summary="set the parent of this surface">
659 Set the "parent" of this surface. This surface should be stacked
660 above the parent surface and all other ancestor surfaces.
661
662 Parent surfaces should be set on dialogs, toolboxes, or other
663 "auxiliary" surfaces, so that the parent is raised when the dialog
664 is raised.
665
666 Setting a null parent for a child surface unsets its parent. Setting
667 a null parent for a surface which currently has no parent is a no-op.
668
669 Only mapped surfaces can have child surfaces. Setting a parent which
670 is not mapped is equivalent to setting a null parent. If a surface
671 becomes unmapped, its children's parent is set to the parent of
672 the now-unmapped surface. If the now-unmapped surface has no parent,
673 its children's parent is unset. If the now-unmapped surface becomes
674 mapped again, its parent-child relationship is not restored.
675
676 The parent toplevel must not be one of the child toplevel's
677 descendants, and the parent must be different from the child toplevel,
678 otherwise the invalid_parent protocol error is raised.
679 </description>
680 <arg name="parent" type="object" interface="xdg_toplevel" allow-null="true"/>
681 </request>
682
683 <request name="set_title">
684 <description summary="set surface title">
685 Set a short title for the surface.
686
687 This string may be used to identify the surface in a task bar,
688 window list, or other user interface elements provided by the
689 compositor.
690
691 The string must be encoded in UTF-8.
692 </description>
693 <arg name="title" type="string"/>
694 </request>
695
696 <request name="set_app_id">
697 <description summary="set application ID">
698 Set an application identifier for the surface.
699
700 The app ID identifies the general class of applications to which
701 the surface belongs. The compositor can use this to group multiple
702 surfaces together, or to determine how to launch a new application.
703
704 For D-Bus activatable applications, the app ID is used as the D-Bus
705 service name.
706
707 The compositor shell will try to group application surfaces together
708 by their app ID. As a best practice, it is suggested to select app
709 ID's that match the basename of the application's .desktop file.
710 For example, "org.freedesktop.FooViewer" where the .desktop file is
711 "org.freedesktop.FooViewer.desktop".
712
713 Like other properties, a set_app_id request can be sent after the
714 xdg_toplevel has been mapped to update the property.
715
716 See the desktop-entry specification [0] for more details on
717 application identifiers and how they relate to well-known D-Bus
718 names and .desktop files.
719
720 [0] https://standards.freedesktop.org/desktop-entry-spec/
721 </description>
722 <arg name="app_id" type="string"/>
723 </request>
724
725 <request name="show_window_menu">
726 <description summary="show the window menu">
727 Clients implementing client-side decorations might want to show
728 a context menu when right-clicking on the decorations, giving the
729 user a menu that they can use to maximize or minimize the window.
730
731 This request asks the compositor to pop up such a window menu at
732 the given position, relative to the local surface coordinates of
733 the parent surface. There are no guarantees as to what menu items
734 the window menu contains, or even if a window menu will be drawn
735 at all.
736
737 This request must be used in response to some sort of user action
738 like a button press, key press, or touch down event.
739 </description>
740 <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
741 <arg name="serial" type="uint" summary="the serial of the user event"/>
742 <arg name="x" type="int" summary="the x position to pop up the window menu at"/>
743 <arg name="y" type="int" summary="the y position to pop up the window menu at"/>
744 </request>
745
746 <request name="move">
747 <description summary="start an interactive move">
748 Start an interactive, user-driven move of the surface.
749
750 This request must be used in response to some sort of user action
751 like a button press, key press, or touch down event. The passed
752 serial is used to determine the type of interactive move (touch,
753 pointer, etc).
754
755 The server may ignore move requests depending on the state of
756 the surface (e.g. fullscreen or maximized), or if the passed serial
757 is no longer valid.
758
759 If triggered, the surface will lose the focus of the device
760 (wl_pointer, wl_touch, etc) used for the move. It is up to the
761 compositor to visually indicate that the move is taking place, such as
762 updating a pointer cursor, during the move. There is no guarantee
763 that the device focus will return when the move is completed.
764 </description>
765 <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
766 <arg name="serial" type="uint" summary="the serial of the user event"/>
767 </request>
768
769 <enum name="resize_edge">
770 <description summary="edge values for resizing">
771 These values are used to indicate which edge of a surface
772 is being dragged in a resize operation.
773 </description>
774 <entry name="none" value="0"/>
775 <entry name="top" value="1"/>
776 <entry name="bottom" value="2"/>
777 <entry name="left" value="4"/>
778 <entry name="top_left" value="5"/>
779 <entry name="bottom_left" value="6"/>
780 <entry name="right" value="8"/>
781 <entry name="top_right" value="9"/>
782 <entry name="bottom_right" value="10"/>
783 </enum>
784
785 <request name="resize">
786 <description summary="start an interactive resize">
787 Start a user-driven, interactive resize of the surface.
788
789 This request must be used in response to some sort of user action
790 like a button press, key press, or touch down event. The passed
791 serial is used to determine the type of interactive resize (touch,
792 pointer, etc).
793
794 The server may ignore resize requests depending on the state of
795 the surface (e.g. fullscreen or maximized).
796
797 If triggered, the client will receive configure events with the
798 "resize" state enum value and the expected sizes. See the "resize"
799 enum value for more details about what is required. The client
800 must also acknowledge configure events using "ack_configure". After
801 the resize is completed, the client will receive another "configure"
802 event without the resize state.
803
804 If triggered, the surface also will lose the focus of the device
805 (wl_pointer, wl_touch, etc) used for the resize. It is up to the
806 compositor to visually indicate that the resize is taking place,
807 such as updating a pointer cursor, during the resize. There is no
808 guarantee that the device focus will return when the resize is
809 completed.
810
811 The edges parameter specifies how the surface should be resized, and
812 is one of the values of the resize_edge enum. Values not matching
813 a variant of the enum will cause the invalid_resize_edge protocol error.
814 The compositor may use this information to update the surface position
815 for example when dragging the top left corner. The compositor may also
816 use this information to adapt its behavior, e.g. choose an appropriate
817 cursor image.
818 </description>
819 <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
820 <arg name="serial" type="uint" summary="the serial of the user event"/>
821 <arg name="edges" type="uint" enum="resize_edge" summary="which edge or corner is being dragged"/>
822 </request>
823
824 <enum name="state">
825 <description summary="types of state on the surface">
826 The different state values used on the surface. This is designed for
827 state values like maximized, fullscreen. It is paired with the
828 configure event to ensure that both the client and the compositor
829 setting the state can be synchronized.
830
831 States set in this way are double-buffered. They will get applied on
832 the next commit.
833 </description>
834 <entry name="maximized" value="1" summary="the surface is maximized">
835 <description summary="the surface is maximized">
836 The surface is maximized. The window geometry specified in the configure
837 event must be obeyed by the client, or the xdg_wm_base.invalid_surface_state
838 error is raised.
839
840 The client should draw without shadow or other
841 decoration outside of the window geometry.
842 </description>
843 </entry>
844 <entry name="fullscreen" value="2" summary="the surface is fullscreen">
845 <description summary="the surface is fullscreen">
846 The surface is fullscreen. The window geometry specified in the
847 configure event is a maximum; the client cannot resize beyond it. For
848 a surface to cover the whole fullscreened area, the geometry
849 dimensions must be obeyed by the client. For more details, see
850 xdg_toplevel.set_fullscreen.
851 </description>
852 </entry>
853 <entry name="resizing" value="3" summary="the surface is being resized">
854 <description summary="the surface is being resized">
855 The surface is being resized. The window geometry specified in the
856 configure event is a maximum; the client cannot resize beyond it.
857 Clients that have aspect ratio or cell sizing configuration can use
858 a smaller size, however.
859 </description>
860 </entry>
861 <entry name="activated" value="4" summary="the surface is now activated">
862 <description summary="the surface is now activated">
863 Client window decorations should be painted as if the window is
864 active. Do not assume this means that the window actually has
865 keyboard or pointer focus.
866 </description>
867 </entry>
868 <entry name="tiled_left" value="5" since="2">
869 <description summary="the surface’s left edge is tiled">
870 The window is currently in a tiled layout and the left edge is
871 considered to be adjacent to another part of the tiling grid.
872 </description>
873 </entry>
874 <entry name="tiled_right" value="6" since="2">
875 <description summary="the surface’s right edge is tiled">
876 The window is currently in a tiled layout and the right edge is
877 considered to be adjacent to another part of the tiling grid.
878 </description>
879 </entry>
880 <entry name="tiled_top" value="7" since="2">
881 <description summary="the surface’s top edge is tiled">
882 The window is currently in a tiled layout and the top edge is
883 considered to be adjacent to another part of the tiling grid.
884 </description>
885 </entry>
886 <entry name="tiled_bottom" value="8" since="2">
887 <description summary="the surface’s bottom edge is tiled">
888 The window is currently in a tiled layout and the bottom edge is
889 considered to be adjacent to another part of the tiling grid.
890 </description>
891 </entry>
892 <entry name="suspended" value="9" since="6">
893 <description summary="surface repaint is suspended">
894 The surface is currently not ordinarily being repainted; for
895 example because its content is occluded by another window, or its
896 outputs are switched off due to screen locking.
897 </description>
898 </entry>
899 </enum>
900
901 <request name="set_max_size">
902 <description summary="set the maximum size">
903 Set a maximum size for the window.
904
905 The client can specify a maximum size so that the compositor does
906 not try to configure the window beyond this size.
907
908 The width and height arguments are in window geometry coordinates.
909 See xdg_surface.set_window_geometry.
910
911 Values set in this way are double-buffered. They will get applied
912 on the next commit.
913
914 The compositor can use this information to allow or disallow
915 different states like maximize or fullscreen and draw accurate
916 animations.
917
918 Similarly, a tiling window manager may use this information to
919 place and resize client windows in a more effective way.
920
921 The client should not rely on the compositor to obey the maximum
922 size. The compositor may decide to ignore the values set by the
923 client and request a larger size.
924
925 If never set, or a value of zero in the request, means that the
926 client has no expected maximum size in the given dimension.
927 As a result, a client wishing to reset the maximum size
928 to an unspecified state can use zero for width and height in the
929 request.
930
931 Requesting a maximum size to be smaller than the minimum size of
932 a surface is illegal and will result in an invalid_size error.
933
934 The width and height must be greater than or equal to zero. Using
935 strictly negative values for width or height will result in a
936 invalid_size error.
937 </description>
938 <arg name="width" type="int"/>
939 <arg name="height" type="int"/>
940 </request>
941
942 <request name="set_min_size">
943 <description summary="set the minimum size">
944 Set a minimum size for the window.
945
946 The client can specify a minimum size so that the compositor does
947 not try to configure the window below this size.
948
949 The width and height arguments are in window geometry coordinates.
950 See xdg_surface.set_window_geometry.
951
952 Values set in this way are double-buffered. They will get applied
953 on the next commit.
954
955 The compositor can use this information to allow or disallow
956 different states like maximize or fullscreen and draw accurate
957 animations.
958
959 Similarly, a tiling window manager may use this information to
960 place and resize client windows in a more effective way.
961
962 The client should not rely on the compositor to obey the minimum
963 size. The compositor may decide to ignore the values set by the
964 client and request a smaller size.
965
966 If never set, or a value of zero in the request, means that the
967 client has no expected minimum size in the given dimension.
968 As a result, a client wishing to reset the minimum size
969 to an unspecified state can use zero for width and height in the
970 request.
971
972 Requesting a minimum size to be larger than the maximum size of
973 a surface is illegal and will result in an invalid_size error.
974
975 The width and height must be greater than or equal to zero. Using
976 strictly negative values for width and height will result in a
977 invalid_size error.
978 </description>
979 <arg name="width" type="int"/>
980 <arg name="height" type="int"/>
981 </request>
982
983 <request name="set_maximized">
984 <description summary="maximize the window">
985 Maximize the surface.
986
987 After requesting that the surface should be maximized, the compositor
988 will respond by emitting a configure event. Whether this configure
989 actually sets the window maximized is subject to compositor policies.
990 The client must then update its content, drawing in the configured
991 state. The client must also acknowledge the configure when committing
992 the new content (see ack_configure).
993
994 It is up to the compositor to decide how and where to maximize the
995 surface, for example which output and what region of the screen should
996 be used.
997
998 If the surface was already maximized, the compositor will still emit
999 a configure event with the "maximized" state.
1000
1001 If the surface is in a fullscreen state, this request has no direct
1002 effect. It may alter the state the surface is returned to when
1003 unmaximized unless overridden by the compositor.
1004 </description>
1005 </request>
1006
1007 <request name="unset_maximized">
1008 <description summary="unmaximize the window">
1009 Unmaximize the surface.
1010
1011 After requesting that the surface should be unmaximized, the compositor
1012 will respond by emitting a configure event. Whether this actually
1013 un-maximizes the window is subject to compositor policies.
1014 If available and applicable, the compositor will include the window
1015 geometry dimensions the window had prior to being maximized in the
1016 configure event. The client must then update its content, drawing it in
1017 the configured state. The client must also acknowledge the configure
1018 when committing the new content (see ack_configure).
1019
1020 It is up to the compositor to position the surface after it was
1021 unmaximized; usually the position the surface had before maximizing, if
1022 applicable.
1023
1024 If the surface was already not maximized, the compositor will still
1025 emit a configure event without the "maximized" state.
1026
1027 If the surface is in a fullscreen state, this request has no direct
1028 effect. It may alter the state the surface is returned to when
1029 unmaximized unless overridden by the compositor.
1030 </description>
1031 </request>
1032
1033 <request name="set_fullscreen">
1034 <description summary="set the window as fullscreen on an output">
1035 Make the surface fullscreen.
1036
1037 After requesting that the surface should be fullscreened, the
1038 compositor will respond by emitting a configure event. Whether the
1039 client is actually put into a fullscreen state is subject to compositor
1040 policies. The client must also acknowledge the configure when
1041 committing the new content (see ack_configure).
1042
1043 The output passed by the request indicates the client's preference as
1044 to which display it should be set fullscreen on. If this value is NULL,
1045 it's up to the compositor to choose which display will be used to map
1046 this surface.
1047
1048 If the surface doesn't cover the whole output, the compositor will
1049 position the surface in the center of the output and compensate with
1050 with border fill covering the rest of the output. The content of the
1051 border fill is undefined, but should be assumed to be in some way that
1052 attempts to blend into the surrounding area (e.g. solid black).
1053
1054 If the fullscreened surface is not opaque, the compositor must make
1055 sure that other screen content not part of the same surface tree (made
1056 up of subsurfaces, popups or similarly coupled surfaces) are not
1057 visible below the fullscreened surface.
1058 </description>
1059 <arg name="output" type="object" interface="wl_output" allow-null="true"/>
1060 </request>
1061
1062 <request name="unset_fullscreen">
1063 <description summary="unset the window as fullscreen">
1064 Make the surface no longer fullscreen.
1065
1066 After requesting that the surface should be unfullscreened, the
1067 compositor will respond by emitting a configure event.
1068 Whether this actually removes the fullscreen state of the client is
1069 subject to compositor policies.
1070
1071 Making a surface unfullscreen sets states for the surface based on the following:
1072 * the state(s) it may have had before becoming fullscreen
1073 * any state(s) decided by the compositor
1074 * any state(s) requested by the client while the surface was fullscreen
1075
1076 The compositor may include the previous window geometry dimensions in
1077 the configure event, if applicable.
1078
1079 The client must also acknowledge the configure when committing the new
1080 content (see ack_configure).
1081 </description>
1082 </request>
1083
1084 <request name="set_minimized">
1085 <description summary="set the window as minimized">
1086 Request that the compositor minimize your surface. There is no
1087 way to know if the surface is currently minimized, nor is there
1088 any way to unset minimization on this surface.
1089
1090 If you are looking to throttle redrawing when minimized, please
1091 instead use the wl_surface.frame event for this, as this will
1092 also work with live previews on windows in Alt-Tab, Expose or
1093 similar compositor features.
1094 </description>
1095 </request>
1096
1097 <event name="configure">
1098 <description summary="suggest a surface change">
1099 This configure event asks the client to resize its toplevel surface or
1100 to change its state. The configured state should not be applied
1101 immediately. See xdg_surface.configure for details.
1102
1103 The width and height arguments specify a hint to the window
1104 about how its surface should be resized in window geometry
1105 coordinates. See set_window_geometry.
1106
1107 If the width or height arguments are zero, it means the client
1108 should decide its own window dimension. This may happen when the
1109 compositor needs to configure the state of the surface but doesn't
1110 have any information about any previous or expected dimension.
1111
1112 The states listed in the event specify how the width/height
1113 arguments should be interpreted, and possibly how it should be
1114 drawn.
1115
1116 Clients must send an ack_configure in response to this event. See
1117 xdg_surface.configure and xdg_surface.ack_configure for details.
1118 </description>
1119 <arg name="width" type="int"/>
1120 <arg name="height" type="int"/>
1121 <arg name="states" type="array"/>
1122 </event>
1123
1124 <event name="close">
1125 <description summary="surface wants to be closed">
1126 The close event is sent by the compositor when the user
1127 wants the surface to be closed. This should be equivalent to
1128 the user clicking the close button in client-side decorations,
1129 if your application has any.
1130
1131 This is only a request that the user intends to close the
1132 window. The client may choose to ignore this request, or show
1133 a dialog to ask the user to save their data, etc.
1134 </description>
1135 </event>
1136
1137 <!-- Version 4 additions -->
1138
1139 <event name="configure_bounds" since="4">
1140 <description summary="recommended window geometry bounds">
1141 The configure_bounds event may be sent prior to a xdg_toplevel.configure
1142 event to communicate the bounds a window geometry size is recommended
1143 to constrain to.
1144
1145 The passed width and height are in surface coordinate space. If width
1146 and height are 0, it means bounds is unknown and equivalent to as if no
1147 configure_bounds event was ever sent for this surface.
1148
1149 The bounds can for example correspond to the size of a monitor excluding
1150 any panels or other shell components, so that a surface isn't created in
1151 a way that it cannot fit.
1152
1153 The bounds may change at any point, and in such a case, a new
1154 xdg_toplevel.configure_bounds will be sent, followed by
1155 xdg_toplevel.configure and xdg_surface.configure.
1156 </description>
1157 <arg name="width" type="int"/>
1158 <arg name="height" type="int"/>
1159 </event>
1160
1161 <!-- Version 5 additions -->
1162
1163 <enum name="wm_capabilities" since="5">
1164 <entry name="window_menu" value="1" summary="show_window_menu is available"/>
1165 <entry name="maximize" value="2" summary="set_maximized and unset_maximized are available"/>
1166 <entry name="fullscreen" value="3" summary="set_fullscreen and unset_fullscreen are available"/>
1167 <entry name="minimize" value="4" summary="set_minimized is available"/>
1168 </enum>
1169
1170 <event name="wm_capabilities" since="5">
1171 <description summary="compositor capabilities">
1172 This event advertises the capabilities supported by the compositor. If
1173 a capability isn't supported, clients should hide or disable the UI
1174 elements that expose this functionality. For instance, if the
1175 compositor doesn't advertise support for minimized toplevels, a button
1176 triggering the set_minimized request should not be displayed.
1177
1178 The compositor will ignore requests it doesn't support. For instance,
1179 a compositor which doesn't advertise support for minimized will ignore
1180 set_minimized requests.
1181
1182 Compositors must send this event once before the first
1183 xdg_surface.configure event. When the capabilities change, compositors
1184 must send this event again and then send an xdg_surface.configure
1185 event.
1186
1187 The configured state should not be applied immediately. See
1188 xdg_surface.configure for details.
1189
1190 The capabilities are sent as an array of 32-bit unsigned integers in
1191 native endianness.
1192 </description>
1193 <arg name="capabilities" type="array" summary="array of 32-bit capabilities"/>
1194 </event>
1195 </interface>
1196
1197 <interface name="xdg_popup" version="6">
1198 <description summary="short-lived, popup surfaces for menus">
1199 A popup surface is a short-lived, temporary surface. It can be used to
1200 implement for example menus, popovers, tooltips and other similar user
1201 interface concepts.
1202
1203 A popup can be made to take an explicit grab. See xdg_popup.grab for
1204 details.
1205
1206 When the popup is dismissed, a popup_done event will be sent out, and at
1207 the same time the surface will be unmapped. See the xdg_popup.popup_done
1208 event for details.
1209
1210 Explicitly destroying the xdg_popup object will also dismiss the popup and
1211 unmap the surface. Clients that want to dismiss the popup when another
1212 surface of their own is clicked should dismiss the popup using the destroy
1213 request.
1214
1215 A newly created xdg_popup will be stacked on top of all previously created
1216 xdg_popup surfaces associated with the same xdg_toplevel.
1217
1218 The parent of an xdg_popup must be mapped (see the xdg_surface
1219 description) before the xdg_popup itself.
1220
1221 The client must call wl_surface.commit on the corresponding wl_surface
1222 for the xdg_popup state to take effect.
1223 </description>
1224
1225 <enum name="error">
1226 <entry name="invalid_grab" value="0"
1227 summary="tried to grab after being mapped"/>
1228 </enum>
1229
1230 <request name="destroy" type="destructor">
1231 <description summary="remove xdg_popup interface">
1232 This destroys the popup. Explicitly destroying the xdg_popup
1233 object will also dismiss the popup, and unmap the surface.
1234
1235 If this xdg_popup is not the "topmost" popup, the
1236 xdg_wm_base.not_the_topmost_popup protocol error will be sent.
1237 </description>
1238 </request>
1239
1240 <request name="grab">
1241 <description summary="make the popup take an explicit grab">
1242 This request makes the created popup take an explicit grab. An explicit
1243 grab will be dismissed when the user dismisses the popup, or when the
1244 client destroys the xdg_popup. This can be done by the user clicking
1245 outside the surface, using the keyboard, or even locking the screen
1246 through closing the lid or a timeout.
1247
1248 If the compositor denies the grab, the popup will be immediately
1249 dismissed.
1250
1251 This request must be used in response to some sort of user action like a
1252 button press, key press, or touch down event. The serial number of the
1253 event should be passed as 'serial'.
1254
1255 The parent of a grabbing popup must either be an xdg_toplevel surface or
1256 another xdg_popup with an explicit grab. If the parent is another
1257 xdg_popup it means that the popups are nested, with this popup now being
1258 the topmost popup.
1259
1260 Nested popups must be destroyed in the reverse order they were created
1261 in, e.g. the only popup you are allowed to destroy at all times is the
1262 topmost one.
1263
1264 When compositors choose to dismiss a popup, they may dismiss every
1265 nested grabbing popup as well. When a compositor dismisses popups, it
1266 will follow the same dismissing order as required from the client.
1267
1268 If the topmost grabbing popup is destroyed, the grab will be returned to
1269 the parent of the popup, if that parent previously had an explicit grab.
1270
1271 If the parent is a grabbing popup which has already been dismissed, this
1272 popup will be immediately dismissed. If the parent is a popup that did
1273 not take an explicit grab, an error will be raised.
1274
1275 During a popup grab, the client owning the grab will receive pointer
1276 and touch events for all their surfaces as normal (similar to an
1277 "owner-events" grab in X11 parlance), while the top most grabbing popup
1278 will always have keyboard focus.
1279 </description>
1280 <arg name="seat" type="object" interface="wl_seat"
1281 summary="the wl_seat of the user event"/>
1282 <arg name="serial" type="uint" summary="the serial of the user event"/>
1283 </request>
1284
1285 <event name="configure">
1286 <description summary="configure the popup surface">
1287 This event asks the popup surface to configure itself given the
1288 configuration. The configured state should not be applied immediately.
1289 See xdg_surface.configure for details.
1290
1291 The x and y arguments represent the position the popup was placed at
1292 given the xdg_positioner rule, relative to the upper left corner of the
1293 window geometry of the parent surface.
1294
1295 For version 2 or older, the configure event for an xdg_popup is only
1296 ever sent once for the initial configuration. Starting with version 3,
1297 it may be sent again if the popup is setup with an xdg_positioner with
1298 set_reactive requested, or in response to xdg_popup.reposition requests.
1299 </description>
1300 <arg name="x" type="int"
1301 summary="x position relative to parent surface window geometry"/>
1302 <arg name="y" type="int"
1303 summary="y position relative to parent surface window geometry"/>
1304 <arg name="width" type="int" summary="window geometry width"/>
1305 <arg name="height" type="int" summary="window geometry height"/>
1306 </event>
1307
1308 <event name="popup_done">
1309 <description summary="popup interaction is done">
1310 The popup_done event is sent out when a popup is dismissed by the
1311 compositor. The client should destroy the xdg_popup object at this
1312 point.
1313 </description>
1314 </event>
1315
1316 <!-- Version 3 additions -->
1317
1318 <request name="reposition" since="3">
1319 <description summary="recalculate the popup's location">
1320 Reposition an already-mapped popup. The popup will be placed given the
1321 details in the passed xdg_positioner object, and a
1322 xdg_popup.repositioned followed by xdg_popup.configure and
1323 xdg_surface.configure will be emitted in response. Any parameters set
1324 by the previous positioner will be discarded.
1325
1326 The passed token will be sent in the corresponding
1327 xdg_popup.repositioned event. The new popup position will not take
1328 effect until the corresponding configure event is acknowledged by the
1329 client. See xdg_popup.repositioned for details. The token itself is
1330 opaque, and has no other special meaning.
1331
1332 If multiple reposition requests are sent, the compositor may skip all
1333 but the last one.
1334
1335 If the popup is repositioned in response to a configure event for its
1336 parent, the client should send an xdg_positioner.set_parent_configure
1337 and possibly an xdg_positioner.set_parent_size request to allow the
1338 compositor to properly constrain the popup.
1339
1340 If the popup is repositioned together with a parent that is being
1341 resized, but not in response to a configure event, the client should
1342 send an xdg_positioner.set_parent_size request.
1343 </description>
1344 <arg name="positioner" type="object" interface="xdg_positioner"/>
1345 <arg name="token" type="uint" summary="reposition request token"/>
1346 </request>
1347
1348 <event name="repositioned" since="3">
1349 <description summary="signal the completion of a repositioned request">
1350 The repositioned event is sent as part of a popup configuration
1351 sequence, together with xdg_popup.configure and lastly
1352 xdg_surface.configure to notify the completion of a reposition request.
1353
1354 The repositioned event is to notify about the completion of a
1355 xdg_popup.reposition request. The token argument is the token passed
1356 in the xdg_popup.reposition request.
1357
1358 Immediately after this event is emitted, xdg_popup.configure and
1359 xdg_surface.configure will be sent with the updated size and position,
1360 as well as a new configure serial.
1361
1362 The client should optionally update the content of the popup, but must
1363 acknowledge the new popup configuration for the new position to take
1364 effect. See xdg_surface.ack_configure for details.
1365 </description>
1366 <arg name="token" type="uint" summary="reposition request token"/>
1367 </event>
1368
1369 </interface>
1370</protocol>
diff --git a/raylib/src/external/glfw/include/GLFW/glfw3.h b/raylib/src/external/glfw/include/GLFW/glfw3.h
new file mode 100644
index 0000000..9c55ac9
--- /dev/null
+++ b/raylib/src/external/glfw/include/GLFW/glfw3.h
@@ -0,0 +1,6547 @@
1/*************************************************************************
2 * GLFW 3.4 - www.glfw.org
3 * A library for OpenGL, window and input
4 *------------------------------------------------------------------------
5 * Copyright (c) 2002-2006 Marcus Geelnard
6 * Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
7 *
8 * This software is provided 'as-is', without any express or implied
9 * warranty. In no event will the authors be held liable for any damages
10 * arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose,
13 * including commercial applications, and to alter it and redistribute it
14 * freely, subject to the following restrictions:
15 *
16 * 1. The origin of this software must not be misrepresented; you must not
17 * claim that you wrote the original software. If you use this software
18 * in a product, an acknowledgment in the product documentation would
19 * be appreciated but is not required.
20 *
21 * 2. Altered source versions must be plainly marked as such, and must not
22 * be misrepresented as being the original software.
23 *
24 * 3. This notice may not be removed or altered from any source
25 * distribution.
26 *
27 *************************************************************************/
28
29#ifndef _glfw3_h_
30#define _glfw3_h_
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36
37/*************************************************************************
38 * Doxygen documentation
39 *************************************************************************/
40
41/*! @file glfw3.h
42 * @brief The header of the GLFW 3 API.
43 *
44 * This is the header file of the GLFW 3 API. It defines all its types and
45 * declares all its functions.
46 *
47 * For more information about how to use this file, see @ref build_include.
48 */
49/*! @defgroup context Context reference
50 * @brief Functions and types related to OpenGL and OpenGL ES contexts.
51 *
52 * This is the reference documentation for OpenGL and OpenGL ES context related
53 * functions. For more task-oriented information, see the @ref context_guide.
54 */
55/*! @defgroup vulkan Vulkan support reference
56 * @brief Functions and types related to Vulkan.
57 *
58 * This is the reference documentation for Vulkan related functions and types.
59 * For more task-oriented information, see the @ref vulkan_guide.
60 */
61/*! @defgroup init Initialization, version and error reference
62 * @brief Functions and types related to initialization and error handling.
63 *
64 * This is the reference documentation for initialization and termination of
65 * the library, version management and error handling. For more task-oriented
66 * information, see the @ref intro_guide.
67 */
68/*! @defgroup input Input reference
69 * @brief Functions and types related to input handling.
70 *
71 * This is the reference documentation for input related functions and types.
72 * For more task-oriented information, see the @ref input_guide.
73 */
74/*! @defgroup monitor Monitor reference
75 * @brief Functions and types related to monitors.
76 *
77 * This is the reference documentation for monitor related functions and types.
78 * For more task-oriented information, see the @ref monitor_guide.
79 */
80/*! @defgroup window Window reference
81 * @brief Functions and types related to windows.
82 *
83 * This is the reference documentation for window related functions and types,
84 * including creation, deletion and event polling. For more task-oriented
85 * information, see the @ref window_guide.
86 */
87
88
89/*************************************************************************
90 * Compiler- and platform-specific preprocessor work
91 *************************************************************************/
92
93/* If we are we on Windows, we want a single define for it.
94 */
95#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
96 #define _WIN32
97#endif /* _WIN32 */
98
99/* Include because most Windows GLU headers need wchar_t and
100 * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
101 * Include it unconditionally to avoid surprising side-effects.
102 */
103#include <stddef.h>
104
105/* Include because it is needed by Vulkan and related functions.
106 * Include it unconditionally to avoid surprising side-effects.
107 */
108#include <stdint.h>
109
110#if defined(GLFW_INCLUDE_VULKAN)
111 #include <vulkan/vulkan.h>
112#endif /* Vulkan header */
113
114/* The Vulkan header may have indirectly included windows.h (because of
115 * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it.
116 */
117
118/* It is customary to use APIENTRY for OpenGL function pointer declarations on
119 * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
120 */
121#if !defined(APIENTRY)
122 #if defined(_WIN32)
123 #define APIENTRY __stdcall
124 #else
125 #define APIENTRY
126 #endif
127 #define GLFW_APIENTRY_DEFINED
128#endif /* APIENTRY */
129
130/* Some Windows OpenGL headers need this.
131 */
132#if !defined(WINGDIAPI) && defined(_WIN32)
133 #define WINGDIAPI __declspec(dllimport)
134 #define GLFW_WINGDIAPI_DEFINED
135#endif /* WINGDIAPI */
136
137/* Some Windows GLU headers need this.
138 */
139#if !defined(CALLBACK) && defined(_WIN32)
140 #define CALLBACK __stdcall
141 #define GLFW_CALLBACK_DEFINED
142#endif /* CALLBACK */
143
144/* Include the chosen OpenGL or OpenGL ES headers.
145 */
146#if defined(GLFW_INCLUDE_ES1)
147
148 #include <GLES/gl.h>
149 #if defined(GLFW_INCLUDE_GLEXT)
150 #include <GLES/glext.h>
151 #endif
152
153#elif defined(GLFW_INCLUDE_ES2)
154
155 #include <GLES2/gl2.h>
156 #if defined(GLFW_INCLUDE_GLEXT)
157 #include <GLES2/gl2ext.h>
158 #endif
159
160#elif defined(GLFW_INCLUDE_ES3)
161
162 #include <GLES3/gl3.h>
163 #if defined(GLFW_INCLUDE_GLEXT)
164 #include <GLES2/gl2ext.h>
165 #endif
166
167#elif defined(GLFW_INCLUDE_ES31)
168
169 #include <GLES3/gl31.h>
170 #if defined(GLFW_INCLUDE_GLEXT)
171 #include <GLES2/gl2ext.h>
172 #endif
173
174#elif defined(GLFW_INCLUDE_ES32)
175
176 #include <GLES3/gl32.h>
177 #if defined(GLFW_INCLUDE_GLEXT)
178 #include <GLES2/gl2ext.h>
179 #endif
180
181#elif defined(GLFW_INCLUDE_GLCOREARB)
182
183 #if defined(__APPLE__)
184
185 #include <OpenGL/gl3.h>
186 #if defined(GLFW_INCLUDE_GLEXT)
187 #include <OpenGL/gl3ext.h>
188 #endif /*GLFW_INCLUDE_GLEXT*/
189
190 #else /*__APPLE__*/
191
192 #include <GL/glcorearb.h>
193 #if defined(GLFW_INCLUDE_GLEXT)
194 #include <GL/glext.h>
195 #endif
196
197 #endif /*__APPLE__*/
198
199#elif defined(GLFW_INCLUDE_GLU)
200
201 #if defined(__APPLE__)
202
203 #if defined(GLFW_INCLUDE_GLU)
204 #include <OpenGL/glu.h>
205 #endif
206
207 #else /*__APPLE__*/
208
209 #if defined(GLFW_INCLUDE_GLU)
210 #include <GL/glu.h>
211 #endif
212
213 #endif /*__APPLE__*/
214
215#elif !defined(GLFW_INCLUDE_NONE) && \
216 !defined(__gl_h_) && \
217 !defined(__gles1_gl_h_) && \
218 !defined(__gles2_gl2_h_) && \
219 !defined(__gles2_gl3_h_) && \
220 !defined(__gles2_gl31_h_) && \
221 !defined(__gles2_gl32_h_) && \
222 !defined(__gl_glcorearb_h_) && \
223 !defined(__gl2_h_) /*legacy*/ && \
224 !defined(__gl3_h_) /*legacy*/ && \
225 !defined(__gl31_h_) /*legacy*/ && \
226 !defined(__gl32_h_) /*legacy*/ && \
227 !defined(__glcorearb_h_) /*legacy*/ && \
228 !defined(__GL_H__) /*non-standard*/ && \
229 !defined(__gltypes_h_) /*non-standard*/ && \
230 !defined(__glee_h_) /*non-standard*/
231
232 #if defined(__APPLE__)
233
234 #if !defined(GLFW_INCLUDE_GLEXT)
235 #define GL_GLEXT_LEGACY
236 #endif
237 #include <OpenGL/gl.h>
238
239 #else /*__APPLE__*/
240
241 #include <GL/gl.h>
242 #if defined(GLFW_INCLUDE_GLEXT)
243 #include <GL/glext.h>
244 #endif
245
246 #endif /*__APPLE__*/
247
248#endif /* OpenGL and OpenGL ES headers */
249
250#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
251 /* GLFW_DLL must be defined by applications that are linking against the DLL
252 * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
253 * configuration header when compiling the DLL version of the library.
254 */
255 #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
256#endif
257
258/* GLFWAPI is used to declare public API functions for export
259 * from the DLL / shared library / dynamic library.
260 */
261#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
262 /* We are building GLFW as a Win32 DLL */
263 #define GLFWAPI __declspec(dllexport)
264#elif defined(_WIN32) && defined(GLFW_DLL)
265 /* We are calling a GLFW Win32 DLL */
266 #define GLFWAPI __declspec(dllimport)
267#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
268 /* We are building GLFW as a Unix shared library */
269 #define GLFWAPI __attribute__((visibility("default")))
270#else
271 #define GLFWAPI
272#endif
273
274
275/*************************************************************************
276 * GLFW API tokens
277 *************************************************************************/
278
279/*! @name GLFW version macros
280 * @{ */
281/*! @brief The major version number of the GLFW header.
282 *
283 * The major version number of the GLFW header. This is incremented when the
284 * API is changed in non-compatible ways.
285 * @ingroup init
286 */
287#define GLFW_VERSION_MAJOR 3
288/*! @brief The minor version number of the GLFW header.
289 *
290 * The minor version number of the GLFW header. This is incremented when
291 * features are added to the API but it remains backward-compatible.
292 * @ingroup init
293 */
294#define GLFW_VERSION_MINOR 4
295/*! @brief The revision number of the GLFW header.
296 *
297 * The revision number of the GLFW header. This is incremented when a bug fix
298 * release is made that does not contain any API changes.
299 * @ingroup init
300 */
301#define GLFW_VERSION_REVISION 0
302/*! @} */
303
304/*! @brief One.
305 *
306 * This is only semantic sugar for the number 1. You can instead use `1` or
307 * `true` or `_True` or `GL_TRUE` or `VK_TRUE` or anything else that is equal
308 * to one.
309 *
310 * @ingroup init
311 */
312#define GLFW_TRUE 1
313/*! @brief Zero.
314 *
315 * This is only semantic sugar for the number 0. You can instead use `0` or
316 * `false` or `_False` or `GL_FALSE` or `VK_FALSE` or anything else that is
317 * equal to zero.
318 *
319 * @ingroup init
320 */
321#define GLFW_FALSE 0
322
323/*! @name Key and button actions
324 * @{ */
325/*! @brief The key or mouse button was released.
326 *
327 * The key or mouse button was released.
328 *
329 * @ingroup input
330 */
331#define GLFW_RELEASE 0
332/*! @brief The key or mouse button was pressed.
333 *
334 * The key or mouse button was pressed.
335 *
336 * @ingroup input
337 */
338#define GLFW_PRESS 1
339/*! @brief The key was held down until it repeated.
340 *
341 * The key was held down until it repeated.
342 *
343 * @ingroup input
344 */
345#define GLFW_REPEAT 2
346/*! @} */
347
348/*! @defgroup hat_state Joystick hat states
349 * @brief Joystick hat states.
350 *
351 * See [joystick hat input](@ref joystick_hat) for how these are used.
352 *
353 * @ingroup input
354 * @{ */
355#define GLFW_HAT_CENTERED 0
356#define GLFW_HAT_UP 1
357#define GLFW_HAT_RIGHT 2
358#define GLFW_HAT_DOWN 4
359#define GLFW_HAT_LEFT 8
360#define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP)
361#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
362#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
363#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
364
365/*! @ingroup input
366 */
367#define GLFW_KEY_UNKNOWN -1
368
369/*! @} */
370
371/*! @defgroup keys Keyboard key tokens
372 * @brief Keyboard key tokens.
373 *
374 * See [key input](@ref input_key) for how these are used.
375 *
376 * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
377 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
378 * put in the 256+ range).
379 *
380 * The naming of the key codes follow these rules:
381 * - The US keyboard layout is used
382 * - Names of printable alphanumeric characters are used (e.g. "A", "R",
383 * "3", etc.)
384 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
385 * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
386 * correspond to the Unicode standard (usually for brevity)
387 * - Keys that lack a clear US mapping are named "WORLD_x"
388 * - For non-printable keys, custom names are used (e.g. "F4",
389 * "BACKSPACE", etc.)
390 *
391 * @ingroup input
392 * @{
393 */
394
395/* Printable keys */
396#define GLFW_KEY_SPACE 32
397#define GLFW_KEY_APOSTROPHE 39 /* ' */
398#define GLFW_KEY_COMMA 44 /* , */
399#define GLFW_KEY_MINUS 45 /* - */
400#define GLFW_KEY_PERIOD 46 /* . */
401#define GLFW_KEY_SLASH 47 /* / */
402#define GLFW_KEY_0 48
403#define GLFW_KEY_1 49
404#define GLFW_KEY_2 50
405#define GLFW_KEY_3 51
406#define GLFW_KEY_4 52
407#define GLFW_KEY_5 53
408#define GLFW_KEY_6 54
409#define GLFW_KEY_7 55
410#define GLFW_KEY_8 56
411#define GLFW_KEY_9 57
412#define GLFW_KEY_SEMICOLON 59 /* ; */
413#define GLFW_KEY_EQUAL 61 /* = */
414#define GLFW_KEY_A 65
415#define GLFW_KEY_B 66
416#define GLFW_KEY_C 67
417#define GLFW_KEY_D 68
418#define GLFW_KEY_E 69
419#define GLFW_KEY_F 70
420#define GLFW_KEY_G 71
421#define GLFW_KEY_H 72
422#define GLFW_KEY_I 73
423#define GLFW_KEY_J 74
424#define GLFW_KEY_K 75
425#define GLFW_KEY_L 76
426#define GLFW_KEY_M 77
427#define GLFW_KEY_N 78
428#define GLFW_KEY_O 79
429#define GLFW_KEY_P 80
430#define GLFW_KEY_Q 81
431#define GLFW_KEY_R 82
432#define GLFW_KEY_S 83
433#define GLFW_KEY_T 84
434#define GLFW_KEY_U 85
435#define GLFW_KEY_V 86
436#define GLFW_KEY_W 87
437#define GLFW_KEY_X 88
438#define GLFW_KEY_Y 89
439#define GLFW_KEY_Z 90
440#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
441#define GLFW_KEY_BACKSLASH 92 /* \ */
442#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
443#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
444#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
445#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
446
447/* Function keys */
448#define GLFW_KEY_ESCAPE 256
449#define GLFW_KEY_ENTER 257
450#define GLFW_KEY_TAB 258
451#define GLFW_KEY_BACKSPACE 259
452#define GLFW_KEY_INSERT 260
453#define GLFW_KEY_DELETE 261
454#define GLFW_KEY_RIGHT 262
455#define GLFW_KEY_LEFT 263
456#define GLFW_KEY_DOWN 264
457#define GLFW_KEY_UP 265
458#define GLFW_KEY_PAGE_UP 266
459#define GLFW_KEY_PAGE_DOWN 267
460#define GLFW_KEY_HOME 268
461#define GLFW_KEY_END 269
462#define GLFW_KEY_CAPS_LOCK 280
463#define GLFW_KEY_SCROLL_LOCK 281
464#define GLFW_KEY_NUM_LOCK 282
465#define GLFW_KEY_PRINT_SCREEN 283
466#define GLFW_KEY_PAUSE 284
467#define GLFW_KEY_F1 290
468#define GLFW_KEY_F2 291
469#define GLFW_KEY_F3 292
470#define GLFW_KEY_F4 293
471#define GLFW_KEY_F5 294
472#define GLFW_KEY_F6 295
473#define GLFW_KEY_F7 296
474#define GLFW_KEY_F8 297
475#define GLFW_KEY_F9 298
476#define GLFW_KEY_F10 299
477#define GLFW_KEY_F11 300
478#define GLFW_KEY_F12 301
479#define GLFW_KEY_F13 302
480#define GLFW_KEY_F14 303
481#define GLFW_KEY_F15 304
482#define GLFW_KEY_F16 305
483#define GLFW_KEY_F17 306
484#define GLFW_KEY_F18 307
485#define GLFW_KEY_F19 308
486#define GLFW_KEY_F20 309
487#define GLFW_KEY_F21 310
488#define GLFW_KEY_F22 311
489#define GLFW_KEY_F23 312
490#define GLFW_KEY_F24 313
491#define GLFW_KEY_F25 314
492#define GLFW_KEY_KP_0 320
493#define GLFW_KEY_KP_1 321
494#define GLFW_KEY_KP_2 322
495#define GLFW_KEY_KP_3 323
496#define GLFW_KEY_KP_4 324
497#define GLFW_KEY_KP_5 325
498#define GLFW_KEY_KP_6 326
499#define GLFW_KEY_KP_7 327
500#define GLFW_KEY_KP_8 328
501#define GLFW_KEY_KP_9 329
502#define GLFW_KEY_KP_DECIMAL 330
503#define GLFW_KEY_KP_DIVIDE 331
504#define GLFW_KEY_KP_MULTIPLY 332
505#define GLFW_KEY_KP_SUBTRACT 333
506#define GLFW_KEY_KP_ADD 334
507#define GLFW_KEY_KP_ENTER 335
508#define GLFW_KEY_KP_EQUAL 336
509#define GLFW_KEY_LEFT_SHIFT 340
510#define GLFW_KEY_LEFT_CONTROL 341
511#define GLFW_KEY_LEFT_ALT 342
512#define GLFW_KEY_LEFT_SUPER 343
513#define GLFW_KEY_RIGHT_SHIFT 344
514#define GLFW_KEY_RIGHT_CONTROL 345
515#define GLFW_KEY_RIGHT_ALT 346
516#define GLFW_KEY_RIGHT_SUPER 347
517#define GLFW_KEY_MENU 348
518
519#define GLFW_KEY_LAST GLFW_KEY_MENU
520
521/*! @} */
522
523/*! @defgroup mods Modifier key flags
524 * @brief Modifier key flags.
525 *
526 * See [key input](@ref input_key) for how these are used.
527 *
528 * @ingroup input
529 * @{ */
530
531/*! @brief If this bit is set one or more Shift keys were held down.
532 *
533 * If this bit is set one or more Shift keys were held down.
534 */
535#define GLFW_MOD_SHIFT 0x0001
536/*! @brief If this bit is set one or more Control keys were held down.
537 *
538 * If this bit is set one or more Control keys were held down.
539 */
540#define GLFW_MOD_CONTROL 0x0002
541/*! @brief If this bit is set one or more Alt keys were held down.
542 *
543 * If this bit is set one or more Alt keys were held down.
544 */
545#define GLFW_MOD_ALT 0x0004
546/*! @brief If this bit is set one or more Super keys were held down.
547 *
548 * If this bit is set one or more Super keys were held down.
549 */
550#define GLFW_MOD_SUPER 0x0008
551/*! @brief If this bit is set the Caps Lock key is enabled.
552 *
553 * If this bit is set the Caps Lock key is enabled and the @ref
554 * GLFW_LOCK_KEY_MODS input mode is set.
555 */
556#define GLFW_MOD_CAPS_LOCK 0x0010
557/*! @brief If this bit is set the Num Lock key is enabled.
558 *
559 * If this bit is set the Num Lock key is enabled and the @ref
560 * GLFW_LOCK_KEY_MODS input mode is set.
561 */
562#define GLFW_MOD_NUM_LOCK 0x0020
563
564/*! @} */
565
566/*! @defgroup buttons Mouse buttons
567 * @brief Mouse button IDs.
568 *
569 * See [mouse button input](@ref input_mouse_button) for how these are used.
570 *
571 * @ingroup input
572 * @{ */
573#define GLFW_MOUSE_BUTTON_1 0
574#define GLFW_MOUSE_BUTTON_2 1
575#define GLFW_MOUSE_BUTTON_3 2
576#define GLFW_MOUSE_BUTTON_4 3
577#define GLFW_MOUSE_BUTTON_5 4
578#define GLFW_MOUSE_BUTTON_6 5
579#define GLFW_MOUSE_BUTTON_7 6
580#define GLFW_MOUSE_BUTTON_8 7
581#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
582#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
583#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
584#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
585/*! @} */
586
587/*! @defgroup joysticks Joysticks
588 * @brief Joystick IDs.
589 *
590 * See [joystick input](@ref joystick) for how these are used.
591 *
592 * @ingroup input
593 * @{ */
594#define GLFW_JOYSTICK_1 0
595#define GLFW_JOYSTICK_2 1
596#define GLFW_JOYSTICK_3 2
597#define GLFW_JOYSTICK_4 3
598#define GLFW_JOYSTICK_5 4
599#define GLFW_JOYSTICK_6 5
600#define GLFW_JOYSTICK_7 6
601#define GLFW_JOYSTICK_8 7
602#define GLFW_JOYSTICK_9 8
603#define GLFW_JOYSTICK_10 9
604#define GLFW_JOYSTICK_11 10
605#define GLFW_JOYSTICK_12 11
606#define GLFW_JOYSTICK_13 12
607#define GLFW_JOYSTICK_14 13
608#define GLFW_JOYSTICK_15 14
609#define GLFW_JOYSTICK_16 15
610#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
611/*! @} */
612
613/*! @defgroup gamepad_buttons Gamepad buttons
614 * @brief Gamepad buttons.
615 *
616 * See @ref gamepad for how these are used.
617 *
618 * @ingroup input
619 * @{ */
620#define GLFW_GAMEPAD_BUTTON_A 0
621#define GLFW_GAMEPAD_BUTTON_B 1
622#define GLFW_GAMEPAD_BUTTON_X 2
623#define GLFW_GAMEPAD_BUTTON_Y 3
624#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
625#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
626#define GLFW_GAMEPAD_BUTTON_BACK 6
627#define GLFW_GAMEPAD_BUTTON_START 7
628#define GLFW_GAMEPAD_BUTTON_GUIDE 8
629#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
630#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
631#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
632#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
633#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
634#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
635#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
636
637#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
638#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
639#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
640#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
641/*! @} */
642
643/*! @defgroup gamepad_axes Gamepad axes
644 * @brief Gamepad axes.
645 *
646 * See @ref gamepad for how these are used.
647 *
648 * @ingroup input
649 * @{ */
650#define GLFW_GAMEPAD_AXIS_LEFT_X 0
651#define GLFW_GAMEPAD_AXIS_LEFT_Y 1
652#define GLFW_GAMEPAD_AXIS_RIGHT_X 2
653#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
654#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
655#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
656#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
657/*! @} */
658
659/*! @defgroup errors Error codes
660 * @brief Error codes.
661 *
662 * See [error handling](@ref error_handling) for how these are used.
663 *
664 * @ingroup init
665 * @{ */
666/*! @brief No error has occurred.
667 *
668 * No error has occurred.
669 *
670 * @analysis Yay.
671 */
672#define GLFW_NO_ERROR 0
673/*! @brief GLFW has not been initialized.
674 *
675 * This occurs if a GLFW function was called that must not be called unless the
676 * library is [initialized](@ref intro_init).
677 *
678 * @analysis Application programmer error. Initialize GLFW before calling any
679 * function that requires initialization.
680 */
681#define GLFW_NOT_INITIALIZED 0x00010001
682/*! @brief No context is current for this thread.
683 *
684 * This occurs if a GLFW function was called that needs and operates on the
685 * current OpenGL or OpenGL ES context but no context is current on the calling
686 * thread. One such function is @ref glfwSwapInterval.
687 *
688 * @analysis Application programmer error. Ensure a context is current before
689 * calling functions that require a current context.
690 */
691#define GLFW_NO_CURRENT_CONTEXT 0x00010002
692/*! @brief One of the arguments to the function was an invalid enum value.
693 *
694 * One of the arguments to the function was an invalid enum value, for example
695 * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
696 *
697 * @analysis Application programmer error. Fix the offending call.
698 */
699#define GLFW_INVALID_ENUM 0x00010003
700/*! @brief One of the arguments to the function was an invalid value.
701 *
702 * One of the arguments to the function was an invalid value, for example
703 * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
704 *
705 * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
706 * result in a @ref GLFW_VERSION_UNAVAILABLE error.
707 *
708 * @analysis Application programmer error. Fix the offending call.
709 */
710#define GLFW_INVALID_VALUE 0x00010004
711/*! @brief A memory allocation failed.
712 *
713 * A memory allocation failed.
714 *
715 * @analysis A bug in GLFW or the underlying operating system. Report the bug
716 * to our [issue tracker](https://github.com/glfw/glfw/issues).
717 */
718#define GLFW_OUT_OF_MEMORY 0x00010005
719/*! @brief GLFW could not find support for the requested API on the system.
720 *
721 * GLFW could not find support for the requested API on the system.
722 *
723 * @analysis The installed graphics driver does not support the requested
724 * API, or does not support it via the chosen context creation API.
725 * Below are a few examples.
726 *
727 * @par
728 * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
729 * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
730 * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
731 * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
732 * driver. Older graphics drivers do not support Vulkan.
733 */
734#define GLFW_API_UNAVAILABLE 0x00010006
735/*! @brief The requested OpenGL or OpenGL ES version is not available.
736 *
737 * The requested OpenGL or OpenGL ES version (including any requested context
738 * or framebuffer hints) is not available on this machine.
739 *
740 * @analysis The machine does not support your requirements. If your
741 * application is sufficiently flexible, downgrade your requirements and try
742 * again. Otherwise, inform the user that their machine does not match your
743 * requirements.
744 *
745 * @par
746 * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
747 * comes out before the 4.x series gets that far, also fail with this error and
748 * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
749 * will exist.
750 */
751#define GLFW_VERSION_UNAVAILABLE 0x00010007
752/*! @brief A platform-specific error occurred that does not match any of the
753 * more specific categories.
754 *
755 * A platform-specific error occurred that does not match any of the more
756 * specific categories.
757 *
758 * @analysis A bug or configuration error in GLFW, the underlying operating
759 * system or its drivers, or a lack of required resources. Report the issue to
760 * our [issue tracker](https://github.com/glfw/glfw/issues).
761 */
762#define GLFW_PLATFORM_ERROR 0x00010008
763/*! @brief The requested format is not supported or available.
764 *
765 * If emitted during window creation, the requested pixel format is not
766 * supported.
767 *
768 * If emitted when querying the clipboard, the contents of the clipboard could
769 * not be converted to the requested format.
770 *
771 * @analysis If emitted during window creation, one or more
772 * [hard constraints](@ref window_hints_hard) did not match any of the
773 * available pixel formats. If your application is sufficiently flexible,
774 * downgrade your requirements and try again. Otherwise, inform the user that
775 * their machine does not match your requirements.
776 *
777 * @par
778 * If emitted when querying the clipboard, ignore the error or report it to
779 * the user, as appropriate.
780 */
781#define GLFW_FORMAT_UNAVAILABLE 0x00010009
782/*! @brief The specified window does not have an OpenGL or OpenGL ES context.
783 *
784 * A window that does not have an OpenGL or OpenGL ES context was passed to
785 * a function that requires it to have one.
786 *
787 * @analysis Application programmer error. Fix the offending call.
788 */
789#define GLFW_NO_WINDOW_CONTEXT 0x0001000A
790/*! @brief The specified cursor shape is not available.
791 *
792 * The specified standard cursor shape is not available, either because the
793 * current platform cursor theme does not provide it or because it is not
794 * available on the platform.
795 *
796 * @analysis Platform or system settings limitation. Pick another
797 * [standard cursor shape](@ref shapes) or create a
798 * [custom cursor](@ref cursor_custom).
799 */
800#define GLFW_CURSOR_UNAVAILABLE 0x0001000B
801/*! @brief The requested feature is not provided by the platform.
802 *
803 * The requested feature is not provided by the platform, so GLFW is unable to
804 * implement it. The documentation for each function notes if it could emit
805 * this error.
806 *
807 * @analysis Platform or platform version limitation. The error can be ignored
808 * unless the feature is critical to the application.
809 *
810 * @par
811 * A function call that emits this error has no effect other than the error and
812 * updating any existing out parameters.
813 */
814#define GLFW_FEATURE_UNAVAILABLE 0x0001000C
815/*! @brief The requested feature is not implemented for the platform.
816 *
817 * The requested feature has not yet been implemented in GLFW for this platform.
818 *
819 * @analysis An incomplete implementation of GLFW for this platform, hopefully
820 * fixed in a future release. The error can be ignored unless the feature is
821 * critical to the application.
822 *
823 * @par
824 * A function call that emits this error has no effect other than the error and
825 * updating any existing out parameters.
826 */
827#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
828/*! @brief Platform unavailable or no matching platform was found.
829 *
830 * If emitted during initialization, no matching platform was found. If the @ref
831 * GLFW_PLATFORM init hint was set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of
832 * the platforms supported by this library binary, except for the Null platform. If the
833 * init hint was set to a specific platform, it is either not supported by this library
834 * binary or GLFW was not able to detect it.
835 *
836 * If emitted by a native access function, GLFW was initialized for a different platform
837 * than the function is for.
838 *
839 * @analysis Failure to detect any platform usually only happens on non-macOS Unix
840 * systems, either when no window system is running or the program was run from
841 * a terminal that does not have the necessary environment variables. Fall back to
842 * a different platform if possible or notify the user that no usable platform was
843 * detected.
844 *
845 * Failure to detect a specific platform may have the same cause as above or be because
846 * support for that platform was not compiled in. Call @ref glfwPlatformSupported to
847 * check whether a specific platform is supported by a library binary.
848 */
849#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E
850/*! @} */
851
852/*! @addtogroup window
853 * @{ */
854/*! @brief Input focus window hint and attribute
855 *
856 * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
857 * [window attribute](@ref GLFW_FOCUSED_attrib).
858 */
859#define GLFW_FOCUSED 0x00020001
860/*! @brief Window iconification window attribute
861 *
862 * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
863 */
864#define GLFW_ICONIFIED 0x00020002
865/*! @brief Window resize-ability window hint and attribute
866 *
867 * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
868 * [window attribute](@ref GLFW_RESIZABLE_attrib).
869 */
870#define GLFW_RESIZABLE 0x00020003
871/*! @brief Window visibility window hint and attribute
872 *
873 * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
874 * [window attribute](@ref GLFW_VISIBLE_attrib).
875 */
876#define GLFW_VISIBLE 0x00020004
877/*! @brief Window decoration window hint and attribute
878 *
879 * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
880 * [window attribute](@ref GLFW_DECORATED_attrib).
881 */
882#define GLFW_DECORATED 0x00020005
883/*! @brief Window auto-iconification window hint and attribute
884 *
885 * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
886 * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
887 */
888#define GLFW_AUTO_ICONIFY 0x00020006
889/*! @brief Window decoration window hint and attribute
890 *
891 * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
892 * [window attribute](@ref GLFW_FLOATING_attrib).
893 */
894#define GLFW_FLOATING 0x00020007
895/*! @brief Window maximization window hint and attribute
896 *
897 * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
898 * [window attribute](@ref GLFW_MAXIMIZED_attrib).
899 */
900#define GLFW_MAXIMIZED 0x00020008
901/*! @brief Cursor centering window hint
902 *
903 * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
904 */
905#define GLFW_CENTER_CURSOR 0x00020009
906/*! @brief Window framebuffer transparency hint and attribute
907 *
908 * Window framebuffer transparency
909 * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
910 * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
911 */
912#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
913/*! @brief Mouse cursor hover window attribute.
914 *
915 * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
916 */
917#define GLFW_HOVERED 0x0002000B
918/*! @brief Input focus on calling show window hint and attribute
919 *
920 * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
921 * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
922 */
923#define GLFW_FOCUS_ON_SHOW 0x0002000C
924
925/*! @brief Mouse input transparency window hint and attribute
926 *
927 * Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or
928 * [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
929 */
930#define GLFW_MOUSE_PASSTHROUGH 0x0002000D
931
932/*! @brief Initial position x-coordinate window hint.
933 *
934 * Initial position x-coordinate [window hint](@ref GLFW_POSITION_X).
935 */
936#define GLFW_POSITION_X 0x0002000E
937
938/*! @brief Initial position y-coordinate window hint.
939 *
940 * Initial position y-coordinate [window hint](@ref GLFW_POSITION_Y).
941 */
942#define GLFW_POSITION_Y 0x0002000F
943
944/*! @brief Framebuffer bit depth hint.
945 *
946 * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
947 */
948#define GLFW_RED_BITS 0x00021001
949/*! @brief Framebuffer bit depth hint.
950 *
951 * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
952 */
953#define GLFW_GREEN_BITS 0x00021002
954/*! @brief Framebuffer bit depth hint.
955 *
956 * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
957 */
958#define GLFW_BLUE_BITS 0x00021003
959/*! @brief Framebuffer bit depth hint.
960 *
961 * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
962 */
963#define GLFW_ALPHA_BITS 0x00021004
964/*! @brief Framebuffer bit depth hint.
965 *
966 * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
967 */
968#define GLFW_DEPTH_BITS 0x00021005
969/*! @brief Framebuffer bit depth hint.
970 *
971 * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
972 */
973#define GLFW_STENCIL_BITS 0x00021006
974/*! @brief Framebuffer bit depth hint.
975 *
976 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
977 */
978#define GLFW_ACCUM_RED_BITS 0x00021007
979/*! @brief Framebuffer bit depth hint.
980 *
981 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
982 */
983#define GLFW_ACCUM_GREEN_BITS 0x00021008
984/*! @brief Framebuffer bit depth hint.
985 *
986 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
987 */
988#define GLFW_ACCUM_BLUE_BITS 0x00021009
989/*! @brief Framebuffer bit depth hint.
990 *
991 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
992 */
993#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
994/*! @brief Framebuffer auxiliary buffer hint.
995 *
996 * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
997 */
998#define GLFW_AUX_BUFFERS 0x0002100B
999/*! @brief OpenGL stereoscopic rendering hint.
1000 *
1001 * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
1002 */
1003#define GLFW_STEREO 0x0002100C
1004/*! @brief Framebuffer MSAA samples hint.
1005 *
1006 * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
1007 */
1008#define GLFW_SAMPLES 0x0002100D
1009/*! @brief Framebuffer sRGB hint.
1010 *
1011 * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
1012 */
1013#define GLFW_SRGB_CAPABLE 0x0002100E
1014/*! @brief Monitor refresh rate hint.
1015 *
1016 * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
1017 */
1018#define GLFW_REFRESH_RATE 0x0002100F
1019/*! @brief Framebuffer double buffering hint and attribute.
1020 *
1021 * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
1022 * [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
1023 */
1024#define GLFW_DOUBLEBUFFER 0x00021010
1025
1026/*! @brief Context client API hint and attribute.
1027 *
1028 * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
1029 * [attribute](@ref GLFW_CLIENT_API_attrib).
1030 */
1031#define GLFW_CLIENT_API 0x00022001
1032/*! @brief Context client API major version hint and attribute.
1033 *
1034 * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint)
1035 * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib).
1036 */
1037#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
1038/*! @brief Context client API minor version hint and attribute.
1039 *
1040 * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint)
1041 * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
1042 */
1043#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
1044/*! @brief Context client API revision number attribute.
1045 *
1046 * Context client API revision number
1047 * [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
1048 */
1049#define GLFW_CONTEXT_REVISION 0x00022004
1050/*! @brief Context robustness hint and attribute.
1051 *
1052 * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint)
1053 * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib).
1054 */
1055#define GLFW_CONTEXT_ROBUSTNESS 0x00022005
1056/*! @brief OpenGL forward-compatibility hint and attribute.
1057 *
1058 * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
1059 * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
1060 */
1061#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
1062/*! @brief Debug mode context hint and attribute.
1063 *
1064 * Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and
1065 * [attribute](@ref GLFW_CONTEXT_DEBUG_attrib).
1066 */
1067#define GLFW_CONTEXT_DEBUG 0x00022007
1068/*! @brief Legacy name for compatibility.
1069 *
1070 * This is an alias for compatibility with earlier versions.
1071 */
1072#define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG
1073/*! @brief OpenGL profile hint and attribute.
1074 *
1075 * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
1076 * [attribute](@ref GLFW_OPENGL_PROFILE_attrib).
1077 */
1078#define GLFW_OPENGL_PROFILE 0x00022008
1079/*! @brief Context flush-on-release hint and attribute.
1080 *
1081 * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and
1082 * [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib).
1083 */
1084#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
1085/*! @brief Context error suppression hint and attribute.
1086 *
1087 * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and
1088 * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib).
1089 */
1090#define GLFW_CONTEXT_NO_ERROR 0x0002200A
1091/*! @brief Context creation API hint and attribute.
1092 *
1093 * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and
1094 * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
1095 */
1096#define GLFW_CONTEXT_CREATION_API 0x0002200B
1097/*! @brief Window content area scaling window
1098 * [window hint](@ref GLFW_SCALE_TO_MONITOR).
1099 */
1100#define GLFW_SCALE_TO_MONITOR 0x0002200C
1101/*! @brief Window framebuffer scaling
1102 * [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint).
1103 */
1104#define GLFW_SCALE_FRAMEBUFFER 0x0002200D
1105/*! @brief Legacy name for compatibility.
1106 *
1107 * This is an alias for the
1108 * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for
1109 * compatibility with earlier versions.
1110 */
1111#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
1112/*! @brief macOS specific
1113 * [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
1114 */
1115#define GLFW_COCOA_FRAME_NAME 0x00023002
1116/*! @brief macOS specific
1117 * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint).
1118 */
1119#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
1120/*! @brief X11 specific
1121 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1122 */
1123#define GLFW_X11_CLASS_NAME 0x00024001
1124/*! @brief X11 specific
1125 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1126 */
1127#define GLFW_X11_INSTANCE_NAME 0x00024002
1128#define GLFW_WIN32_KEYBOARD_MENU 0x00025001
1129/*! @brief Win32 specific [window hint](@ref GLFW_WIN32_SHOWDEFAULT_hint).
1130 */
1131#define GLFW_WIN32_SHOWDEFAULT 0x00025002
1132/*! @brief Wayland specific
1133 * [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
1134 *
1135 * Allows specification of the Wayland app_id.
1136 */
1137#define GLFW_WAYLAND_APP_ID 0x00026001
1138/*! @} */
1139
1140#define GLFW_NO_API 0
1141#define GLFW_OPENGL_API 0x00030001
1142#define GLFW_OPENGL_ES_API 0x00030002
1143
1144#define GLFW_NO_ROBUSTNESS 0
1145#define GLFW_NO_RESET_NOTIFICATION 0x00031001
1146#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
1147
1148#define GLFW_OPENGL_ANY_PROFILE 0
1149#define GLFW_OPENGL_CORE_PROFILE 0x00032001
1150#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
1151
1152#define GLFW_CURSOR 0x00033001
1153#define GLFW_STICKY_KEYS 0x00033002
1154#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
1155#define GLFW_LOCK_KEY_MODS 0x00033004
1156#define GLFW_RAW_MOUSE_MOTION 0x00033005
1157
1158#define GLFW_CURSOR_NORMAL 0x00034001
1159#define GLFW_CURSOR_HIDDEN 0x00034002
1160#define GLFW_CURSOR_DISABLED 0x00034003
1161#define GLFW_CURSOR_CAPTURED 0x00034004
1162
1163#define GLFW_ANY_RELEASE_BEHAVIOR 0
1164#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
1165#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
1166
1167#define GLFW_NATIVE_CONTEXT_API 0x00036001
1168#define GLFW_EGL_CONTEXT_API 0x00036002
1169#define GLFW_OSMESA_CONTEXT_API 0x00036003
1170
1171#define GLFW_ANGLE_PLATFORM_TYPE_NONE 0x00037001
1172#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL 0x00037002
1173#define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
1174#define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004
1175#define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005
1176#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007
1177#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008
1178
1179#define GLFW_WAYLAND_PREFER_LIBDECOR 0x00038001
1180#define GLFW_WAYLAND_DISABLE_LIBDECOR 0x00038002
1181
1182#define GLFW_ANY_POSITION 0x80000000
1183
1184/*! @defgroup shapes Standard cursor shapes
1185 * @brief Standard system cursor shapes.
1186 *
1187 * These are the [standard cursor shapes](@ref cursor_standard) that can be
1188 * requested from the platform (window system).
1189 *
1190 * @ingroup input
1191 * @{ */
1192
1193/*! @brief The regular arrow cursor shape.
1194 *
1195 * The regular arrow cursor shape.
1196 */
1197#define GLFW_ARROW_CURSOR 0x00036001
1198/*! @brief The text input I-beam cursor shape.
1199 *
1200 * The text input I-beam cursor shape.
1201 */
1202#define GLFW_IBEAM_CURSOR 0x00036002
1203/*! @brief The crosshair cursor shape.
1204 *
1205 * The crosshair cursor shape.
1206 */
1207#define GLFW_CROSSHAIR_CURSOR 0x00036003
1208/*! @brief The pointing hand cursor shape.
1209 *
1210 * The pointing hand cursor shape.
1211 */
1212#define GLFW_POINTING_HAND_CURSOR 0x00036004
1213/*! @brief The horizontal resize/move arrow shape.
1214 *
1215 * The horizontal resize/move arrow shape. This is usually a horizontal
1216 * double-headed arrow.
1217 */
1218#define GLFW_RESIZE_EW_CURSOR 0x00036005
1219/*! @brief The vertical resize/move arrow shape.
1220 *
1221 * The vertical resize/move shape. This is usually a vertical double-headed
1222 * arrow.
1223 */
1224#define GLFW_RESIZE_NS_CURSOR 0x00036006
1225/*! @brief The top-left to bottom-right diagonal resize/move arrow shape.
1226 *
1227 * The top-left to bottom-right diagonal resize/move shape. This is usually
1228 * a diagonal double-headed arrow.
1229 *
1230 * @note @macos This shape is provided by a private system API and may fail
1231 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1232 *
1233 * @note @wayland This shape is provided by a newer standard not supported by
1234 * all cursor themes.
1235 *
1236 * @note @x11 This shape is provided by a newer standard not supported by all
1237 * cursor themes.
1238 */
1239#define GLFW_RESIZE_NWSE_CURSOR 0x00036007
1240/*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
1241 *
1242 * The top-right to bottom-left diagonal resize/move shape. This is usually
1243 * a diagonal double-headed arrow.
1244 *
1245 * @note @macos This shape is provided by a private system API and may fail
1246 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1247 *
1248 * @note @wayland This shape is provided by a newer standard not supported by
1249 * all cursor themes.
1250 *
1251 * @note @x11 This shape is provided by a newer standard not supported by all
1252 * cursor themes.
1253 */
1254#define GLFW_RESIZE_NESW_CURSOR 0x00036008
1255/*! @brief The omni-directional resize/move cursor shape.
1256 *
1257 * The omni-directional resize cursor/move shape. This is usually either
1258 * a combined horizontal and vertical double-headed arrow or a grabbing hand.
1259 */
1260#define GLFW_RESIZE_ALL_CURSOR 0x00036009
1261/*! @brief The operation-not-allowed shape.
1262 *
1263 * The operation-not-allowed shape. This is usually a circle with a diagonal
1264 * line through it.
1265 *
1266 * @note @wayland This shape is provided by a newer standard not supported by
1267 * all cursor themes.
1268 *
1269 * @note @x11 This shape is provided by a newer standard not supported by all
1270 * cursor themes.
1271 */
1272#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
1273/*! @brief Legacy name for compatibility.
1274 *
1275 * This is an alias for compatibility with earlier versions.
1276 */
1277#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR
1278/*! @brief Legacy name for compatibility.
1279 *
1280 * This is an alias for compatibility with earlier versions.
1281 */
1282#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR
1283/*! @brief Legacy name for compatibility.
1284 *
1285 * This is an alias for compatibility with earlier versions.
1286 */
1287#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR
1288/*! @} */
1289
1290#define GLFW_CONNECTED 0x00040001
1291#define GLFW_DISCONNECTED 0x00040002
1292
1293/*! @addtogroup init
1294 * @{ */
1295/*! @brief Joystick hat buttons init hint.
1296 *
1297 * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
1298 */
1299#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
1300/*! @brief ANGLE rendering backend init hint.
1301 *
1302 * ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
1303 */
1304#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
1305/*! @brief Platform selection init hint.
1306 *
1307 * Platform selection [init hint](@ref GLFW_PLATFORM).
1308 */
1309#define GLFW_PLATFORM 0x00050003
1310/*! @brief macOS specific init hint.
1311 *
1312 * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
1313 */
1314#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
1315/*! @brief macOS specific init hint.
1316 *
1317 * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
1318 */
1319#define GLFW_COCOA_MENUBAR 0x00051002
1320/*! @brief X11 specific init hint.
1321 *
1322 * X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
1323 */
1324#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
1325/*! @brief Wayland specific init hint.
1326 *
1327 * Wayland specific [init hint](@ref GLFW_WAYLAND_LIBDECOR_hint).
1328 */
1329#define GLFW_WAYLAND_LIBDECOR 0x00053001
1330/*! @} */
1331
1332/*! @addtogroup init
1333 * @{ */
1334/*! @brief Hint value that enables automatic platform selection.
1335 *
1336 * Hint value for @ref GLFW_PLATFORM that enables automatic platform selection.
1337 */
1338#define GLFW_ANY_PLATFORM 0x00060000
1339#define GLFW_PLATFORM_WIN32 0x00060001
1340#define GLFW_PLATFORM_COCOA 0x00060002
1341#define GLFW_PLATFORM_WAYLAND 0x00060003
1342#define GLFW_PLATFORM_X11 0x00060004
1343#define GLFW_PLATFORM_NULL 0x00060005
1344/*! @} */
1345
1346#define GLFW_DONT_CARE -1
1347
1348
1349/*************************************************************************
1350 * GLFW API types
1351 *************************************************************************/
1352
1353/*! @brief Client API function pointer type.
1354 *
1355 * Generic function pointer used for returning client API function pointers
1356 * without forcing a cast from a regular pointer.
1357 *
1358 * @sa @ref context_glext
1359 * @sa @ref glfwGetProcAddress
1360 *
1361 * @since Added in version 3.0.
1362 *
1363 * @ingroup context
1364 */
1365typedef void (*GLFWglproc)(void);
1366
1367/*! @brief Vulkan API function pointer type.
1368 *
1369 * Generic function pointer used for returning Vulkan API function pointers
1370 * without forcing a cast from a regular pointer.
1371 *
1372 * @sa @ref vulkan_proc
1373 * @sa @ref glfwGetInstanceProcAddress
1374 *
1375 * @since Added in version 3.2.
1376 *
1377 * @ingroup vulkan
1378 */
1379typedef void (*GLFWvkproc)(void);
1380
1381/*! @brief Opaque monitor object.
1382 *
1383 * Opaque monitor object.
1384 *
1385 * @see @ref monitor_object
1386 *
1387 * @since Added in version 3.0.
1388 *
1389 * @ingroup monitor
1390 */
1391typedef struct GLFWmonitor GLFWmonitor;
1392
1393/*! @brief Opaque window object.
1394 *
1395 * Opaque window object.
1396 *
1397 * @see @ref window_object
1398 *
1399 * @since Added in version 3.0.
1400 *
1401 * @ingroup window
1402 */
1403typedef struct GLFWwindow GLFWwindow;
1404
1405/*! @brief Opaque cursor object.
1406 *
1407 * Opaque cursor object.
1408 *
1409 * @see @ref cursor_object
1410 *
1411 * @since Added in version 3.1.
1412 *
1413 * @ingroup input
1414 */
1415typedef struct GLFWcursor GLFWcursor;
1416
1417/*! @brief The function pointer type for memory allocation callbacks.
1418 *
1419 * This is the function pointer type for memory allocation callbacks. A memory
1420 * allocation callback function has the following signature:
1421 * @code
1422 * void* function_name(size_t size, void* user)
1423 * @endcode
1424 *
1425 * This function must return either a memory block at least `size` bytes long,
1426 * or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
1427 * failures gracefully yet.
1428 *
1429 * This function must support being called during @ref glfwInit but before the library is
1430 * flagged as initialized, as well as during @ref glfwTerminate after the library is no
1431 * longer flagged as initialized.
1432 *
1433 * Any memory allocated via this function will be deallocated via the same allocator
1434 * during library termination or earlier.
1435 *
1436 * Any memory allocated via this function must be suitably aligned for any object type.
1437 * If you are using C99 or earlier, this alignment is platform-dependent but will be the
1438 * same as what `malloc` provides. If you are using C11 or later, this is the value of
1439 * `alignof(max_align_t)`.
1440 *
1441 * The size will always be greater than zero. Allocations of size zero are filtered out
1442 * before reaching the custom allocator.
1443 *
1444 * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
1445 *
1446 * This function must not call any GLFW function.
1447 *
1448 * @param[in] size The minimum size, in bytes, of the memory block.
1449 * @param[in] user The user-defined pointer from the allocator.
1450 * @return The address of the newly allocated memory block, or `NULL` if an
1451 * error occurred.
1452 *
1453 * @pointer_lifetime The returned memory block must be valid at least until it
1454 * is deallocated.
1455 *
1456 * @reentrancy This function should not call any GLFW function.
1457 *
1458 * @thread_safety This function must support being called from any thread that calls GLFW
1459 * functions.
1460 *
1461 * @sa @ref init_allocator
1462 * @sa @ref GLFWallocator
1463 *
1464 * @since Added in version 3.4.
1465 *
1466 * @ingroup init
1467 */
1468typedef void* (* GLFWallocatefun)(size_t size, void* user);
1469
1470/*! @brief The function pointer type for memory reallocation callbacks.
1471 *
1472 * This is the function pointer type for memory reallocation callbacks.
1473 * A memory reallocation callback function has the following signature:
1474 * @code
1475 * void* function_name(void* block, size_t size, void* user)
1476 * @endcode
1477 *
1478 * This function must return a memory block at least `size` bytes long, or
1479 * `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
1480 * failures gracefully yet.
1481 *
1482 * This function must support being called during @ref glfwInit but before the library is
1483 * flagged as initialized, as well as during @ref glfwTerminate after the library is no
1484 * longer flagged as initialized.
1485 *
1486 * Any memory allocated via this function will be deallocated via the same allocator
1487 * during library termination or earlier.
1488 *
1489 * Any memory allocated via this function must be suitably aligned for any object type.
1490 * If you are using C99 or earlier, this alignment is platform-dependent but will be the
1491 * same as what `realloc` provides. If you are using C11 or later, this is the value of
1492 * `alignof(max_align_t)`.
1493 *
1494 * The block address will never be `NULL` and the size will always be greater than zero.
1495 * Reallocations of a block to size zero are converted into deallocations before reaching
1496 * the custom allocator. Reallocations of `NULL` to a non-zero size are converted into
1497 * regular allocations before reaching the custom allocator.
1498 *
1499 * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
1500 *
1501 * This function must not call any GLFW function.
1502 *
1503 * @param[in] block The address of the memory block to reallocate.
1504 * @param[in] size The new minimum size, in bytes, of the memory block.
1505 * @param[in] user The user-defined pointer from the allocator.
1506 * @return The address of the newly allocated or resized memory block, or
1507 * `NULL` if an error occurred.
1508 *
1509 * @pointer_lifetime The returned memory block must be valid at least until it
1510 * is deallocated.
1511 *
1512 * @reentrancy This function should not call any GLFW function.
1513 *
1514 * @thread_safety This function must support being called from any thread that calls GLFW
1515 * functions.
1516 *
1517 * @sa @ref init_allocator
1518 * @sa @ref GLFWallocator
1519 *
1520 * @since Added in version 3.4.
1521 *
1522 * @ingroup init
1523 */
1524typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
1525
1526/*! @brief The function pointer type for memory deallocation callbacks.
1527 *
1528 * This is the function pointer type for memory deallocation callbacks.
1529 * A memory deallocation callback function has the following signature:
1530 * @code
1531 * void function_name(void* block, void* user)
1532 * @endcode
1533 *
1534 * This function may deallocate the specified memory block. This memory block
1535 * will have been allocated with the same allocator.
1536 *
1537 * This function must support being called during @ref glfwInit but before the library is
1538 * flagged as initialized, as well as during @ref glfwTerminate after the library is no
1539 * longer flagged as initialized.
1540 *
1541 * The block address will never be `NULL`. Deallocations of `NULL` are filtered out
1542 * before reaching the custom allocator.
1543 *
1544 * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
1545 *
1546 * This function must not call any GLFW function.
1547 *
1548 * @param[in] block The address of the memory block to deallocate.
1549 * @param[in] user The user-defined pointer from the allocator.
1550 *
1551 * @pointer_lifetime The specified memory block will not be accessed by GLFW
1552 * after this function is called.
1553 *
1554 * @reentrancy This function should not call any GLFW function.
1555 *
1556 * @thread_safety This function must support being called from any thread that calls GLFW
1557 * functions.
1558 *
1559 * @sa @ref init_allocator
1560 * @sa @ref GLFWallocator
1561 *
1562 * @since Added in version 3.4.
1563 *
1564 * @ingroup init
1565 */
1566typedef void (* GLFWdeallocatefun)(void* block, void* user);
1567
1568/*! @brief The function pointer type for error callbacks.
1569 *
1570 * This is the function pointer type for error callbacks. An error callback
1571 * function has the following signature:
1572 * @code
1573 * void callback_name(int error_code, const char* description)
1574 * @endcode
1575 *
1576 * @param[in] error_code An [error code](@ref errors). Future releases may add
1577 * more error codes.
1578 * @param[in] description A UTF-8 encoded string describing the error.
1579 *
1580 * @pointer_lifetime The error description string is valid until the callback
1581 * function returns.
1582 *
1583 * @sa @ref error_handling
1584 * @sa @ref glfwSetErrorCallback
1585 *
1586 * @since Added in version 3.0.
1587 *
1588 * @ingroup init
1589 */
1590typedef void (* GLFWerrorfun)(int error_code, const char* description);
1591
1592/*! @brief The function pointer type for window position callbacks.
1593 *
1594 * This is the function pointer type for window position callbacks. A window
1595 * position callback function has the following signature:
1596 * @code
1597 * void callback_name(GLFWwindow* window, int xpos, int ypos)
1598 * @endcode
1599 *
1600 * @param[in] window The window that was moved.
1601 * @param[in] xpos The new x-coordinate, in screen coordinates, of the
1602 * upper-left corner of the content area of the window.
1603 * @param[in] ypos The new y-coordinate, in screen coordinates, of the
1604 * upper-left corner of the content area of the window.
1605 *
1606 * @sa @ref window_pos
1607 * @sa @ref glfwSetWindowPosCallback
1608 *
1609 * @since Added in version 3.0.
1610 *
1611 * @ingroup window
1612 */
1613typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
1614
1615/*! @brief The function pointer type for window size callbacks.
1616 *
1617 * This is the function pointer type for window size callbacks. A window size
1618 * callback function has the following signature:
1619 * @code
1620 * void callback_name(GLFWwindow* window, int width, int height)
1621 * @endcode
1622 *
1623 * @param[in] window The window that was resized.
1624 * @param[in] width The new width, in screen coordinates, of the window.
1625 * @param[in] height The new height, in screen coordinates, of the window.
1626 *
1627 * @sa @ref window_size
1628 * @sa @ref glfwSetWindowSizeCallback
1629 *
1630 * @since Added in version 1.0.
1631 * @glfw3 Added window handle parameter.
1632 *
1633 * @ingroup window
1634 */
1635typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
1636
1637/*! @brief The function pointer type for window close callbacks.
1638 *
1639 * This is the function pointer type for window close callbacks. A window
1640 * close callback function has the following signature:
1641 * @code
1642 * void function_name(GLFWwindow* window)
1643 * @endcode
1644 *
1645 * @param[in] window The window that the user attempted to close.
1646 *
1647 * @sa @ref window_close
1648 * @sa @ref glfwSetWindowCloseCallback
1649 *
1650 * @since Added in version 2.5.
1651 * @glfw3 Added window handle parameter.
1652 *
1653 * @ingroup window
1654 */
1655typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
1656
1657/*! @brief The function pointer type for window content refresh callbacks.
1658 *
1659 * This is the function pointer type for window content refresh callbacks.
1660 * A window content refresh callback function has the following signature:
1661 * @code
1662 * void function_name(GLFWwindow* window);
1663 * @endcode
1664 *
1665 * @param[in] window The window whose content needs to be refreshed.
1666 *
1667 * @sa @ref window_refresh
1668 * @sa @ref glfwSetWindowRefreshCallback
1669 *
1670 * @since Added in version 2.5.
1671 * @glfw3 Added window handle parameter.
1672 *
1673 * @ingroup window
1674 */
1675typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window);
1676
1677/*! @brief The function pointer type for window focus callbacks.
1678 *
1679 * This is the function pointer type for window focus callbacks. A window
1680 * focus callback function has the following signature:
1681 * @code
1682 * void function_name(GLFWwindow* window, int focused)
1683 * @endcode
1684 *
1685 * @param[in] window The window that gained or lost input focus.
1686 * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
1687 * `GLFW_FALSE` if it lost it.
1688 *
1689 * @sa @ref window_focus
1690 * @sa @ref glfwSetWindowFocusCallback
1691 *
1692 * @since Added in version 3.0.
1693 *
1694 * @ingroup window
1695 */
1696typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused);
1697
1698/*! @brief The function pointer type for window iconify callbacks.
1699 *
1700 * This is the function pointer type for window iconify callbacks. A window
1701 * iconify callback function has the following signature:
1702 * @code
1703 * void function_name(GLFWwindow* window, int iconified)
1704 * @endcode
1705 *
1706 * @param[in] window The window that was iconified or restored.
1707 * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
1708 * `GLFW_FALSE` if it was restored.
1709 *
1710 * @sa @ref window_iconify
1711 * @sa @ref glfwSetWindowIconifyCallback
1712 *
1713 * @since Added in version 3.0.
1714 *
1715 * @ingroup window
1716 */
1717typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified);
1718
1719/*! @brief The function pointer type for window maximize callbacks.
1720 *
1721 * This is the function pointer type for window maximize callbacks. A window
1722 * maximize callback function has the following signature:
1723 * @code
1724 * void function_name(GLFWwindow* window, int maximized)
1725 * @endcode
1726 *
1727 * @param[in] window The window that was maximized or restored.
1728 * @param[in] maximized `GLFW_TRUE` if the window was maximized, or
1729 * `GLFW_FALSE` if it was restored.
1730 *
1731 * @sa @ref window_maximize
1732 * @sa glfwSetWindowMaximizeCallback
1733 *
1734 * @since Added in version 3.3.
1735 *
1736 * @ingroup window
1737 */
1738typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized);
1739
1740/*! @brief The function pointer type for framebuffer size callbacks.
1741 *
1742 * This is the function pointer type for framebuffer size callbacks.
1743 * A framebuffer size callback function has the following signature:
1744 * @code
1745 * void function_name(GLFWwindow* window, int width, int height)
1746 * @endcode
1747 *
1748 * @param[in] window The window whose framebuffer was resized.
1749 * @param[in] width The new width, in pixels, of the framebuffer.
1750 * @param[in] height The new height, in pixels, of the framebuffer.
1751 *
1752 * @sa @ref window_fbsize
1753 * @sa @ref glfwSetFramebufferSizeCallback
1754 *
1755 * @since Added in version 3.0.
1756 *
1757 * @ingroup window
1758 */
1759typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height);
1760
1761/*! @brief The function pointer type for window content scale callbacks.
1762 *
1763 * This is the function pointer type for window content scale callbacks.
1764 * A window content scale callback function has the following signature:
1765 * @code
1766 * void function_name(GLFWwindow* window, float xscale, float yscale)
1767 * @endcode
1768 *
1769 * @param[in] window The window whose content scale changed.
1770 * @param[in] xscale The new x-axis content scale of the window.
1771 * @param[in] yscale The new y-axis content scale of the window.
1772 *
1773 * @sa @ref window_scale
1774 * @sa @ref glfwSetWindowContentScaleCallback
1775 *
1776 * @since Added in version 3.3.
1777 *
1778 * @ingroup window
1779 */
1780typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale);
1781
1782/*! @brief The function pointer type for mouse button callbacks.
1783 *
1784 * This is the function pointer type for mouse button callback functions.
1785 * A mouse button callback function has the following signature:
1786 * @code
1787 * void function_name(GLFWwindow* window, int button, int action, int mods)
1788 * @endcode
1789 *
1790 * @param[in] window The window that received the event.
1791 * @param[in] button The [mouse button](@ref buttons) that was pressed or
1792 * released.
1793 * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases
1794 * may add more actions.
1795 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1796 * held down.
1797 *
1798 * @sa @ref input_mouse_button
1799 * @sa @ref glfwSetMouseButtonCallback
1800 *
1801 * @since Added in version 1.0.
1802 * @glfw3 Added window handle and modifier mask parameters.
1803 *
1804 * @ingroup input
1805 */
1806typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
1807
1808/*! @brief The function pointer type for cursor position callbacks.
1809 *
1810 * This is the function pointer type for cursor position callbacks. A cursor
1811 * position callback function has the following signature:
1812 * @code
1813 * void function_name(GLFWwindow* window, double xpos, double ypos);
1814 * @endcode
1815 *
1816 * @param[in] window The window that received the event.
1817 * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
1818 * the content area.
1819 * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
1820 * content area.
1821 *
1822 * @sa @ref cursor_pos
1823 * @sa @ref glfwSetCursorPosCallback
1824 *
1825 * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
1826 *
1827 * @ingroup input
1828 */
1829typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos);
1830
1831/*! @brief The function pointer type for cursor enter/leave callbacks.
1832 *
1833 * This is the function pointer type for cursor enter/leave callbacks.
1834 * A cursor enter/leave callback function has the following signature:
1835 * @code
1836 * void function_name(GLFWwindow* window, int entered)
1837 * @endcode
1838 *
1839 * @param[in] window The window that received the event.
1840 * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
1841 * area, or `GLFW_FALSE` if it left it.
1842 *
1843 * @sa @ref cursor_enter
1844 * @sa @ref glfwSetCursorEnterCallback
1845 *
1846 * @since Added in version 3.0.
1847 *
1848 * @ingroup input
1849 */
1850typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered);
1851
1852/*! @brief The function pointer type for scroll callbacks.
1853 *
1854 * This is the function pointer type for scroll callbacks. A scroll callback
1855 * function has the following signature:
1856 * @code
1857 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
1858 * @endcode
1859 *
1860 * @param[in] window The window that received the event.
1861 * @param[in] xoffset The scroll offset along the x-axis.
1862 * @param[in] yoffset The scroll offset along the y-axis.
1863 *
1864 * @sa @ref scrolling
1865 * @sa @ref glfwSetScrollCallback
1866 *
1867 * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
1868 *
1869 * @ingroup input
1870 */
1871typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset);
1872
1873/*! @brief The function pointer type for keyboard key callbacks.
1874 *
1875 * This is the function pointer type for keyboard key callbacks. A keyboard
1876 * key callback function has the following signature:
1877 * @code
1878 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
1879 * @endcode
1880 *
1881 * @param[in] window The window that received the event.
1882 * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
1883 * @param[in] scancode The platform-specific scancode of the key.
1884 * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
1885 * releases may add more actions.
1886 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1887 * held down.
1888 *
1889 * @sa @ref input_key
1890 * @sa @ref glfwSetKeyCallback
1891 *
1892 * @since Added in version 1.0.
1893 * @glfw3 Added window handle, scancode and modifier mask parameters.
1894 *
1895 * @ingroup input
1896 */
1897typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods);
1898
1899/*! @brief The function pointer type for Unicode character callbacks.
1900 *
1901 * This is the function pointer type for Unicode character callbacks.
1902 * A Unicode character callback function has the following signature:
1903 * @code
1904 * void function_name(GLFWwindow* window, unsigned int codepoint)
1905 * @endcode
1906 *
1907 * @param[in] window The window that received the event.
1908 * @param[in] codepoint The Unicode code point of the character.
1909 *
1910 * @sa @ref input_char
1911 * @sa @ref glfwSetCharCallback
1912 *
1913 * @since Added in version 2.4.
1914 * @glfw3 Added window handle parameter.
1915 *
1916 * @ingroup input
1917 */
1918typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
1919
1920/*! @brief The function pointer type for Unicode character with modifiers
1921 * callbacks.
1922 *
1923 * This is the function pointer type for Unicode character with modifiers
1924 * callbacks. It is called for each input character, regardless of what
1925 * modifier keys are held down. A Unicode character with modifiers callback
1926 * function has the following signature:
1927 * @code
1928 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
1929 * @endcode
1930 *
1931 * @param[in] window The window that received the event.
1932 * @param[in] codepoint The Unicode code point of the character.
1933 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1934 * held down.
1935 *
1936 * @sa @ref input_char
1937 * @sa @ref glfwSetCharModsCallback
1938 *
1939 * @deprecated Scheduled for removal in version 4.0.
1940 *
1941 * @since Added in version 3.1.
1942 *
1943 * @ingroup input
1944 */
1945typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
1946
1947/*! @brief The function pointer type for path drop callbacks.
1948 *
1949 * This is the function pointer type for path drop callbacks. A path drop
1950 * callback function has the following signature:
1951 * @code
1952 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
1953 * @endcode
1954 *
1955 * @param[in] window The window that received the event.
1956 * @param[in] path_count The number of dropped paths.
1957 * @param[in] paths The UTF-8 encoded file and/or directory path names.
1958 *
1959 * @pointer_lifetime The path array and its strings are valid until the
1960 * callback function returns.
1961 *
1962 * @sa @ref path_drop
1963 * @sa @ref glfwSetDropCallback
1964 *
1965 * @since Added in version 3.1.
1966 *
1967 * @ingroup input
1968 */
1969typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
1970
1971/*! @brief The function pointer type for monitor configuration callbacks.
1972 *
1973 * This is the function pointer type for monitor configuration callbacks.
1974 * A monitor callback function has the following signature:
1975 * @code
1976 * void function_name(GLFWmonitor* monitor, int event)
1977 * @endcode
1978 *
1979 * @param[in] monitor The monitor that was connected or disconnected.
1980 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
1981 * releases may add more events.
1982 *
1983 * @sa @ref monitor_event
1984 * @sa @ref glfwSetMonitorCallback
1985 *
1986 * @since Added in version 3.0.
1987 *
1988 * @ingroup monitor
1989 */
1990typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event);
1991
1992/*! @brief The function pointer type for joystick configuration callbacks.
1993 *
1994 * This is the function pointer type for joystick configuration callbacks.
1995 * A joystick configuration callback function has the following signature:
1996 * @code
1997 * void function_name(int jid, int event)
1998 * @endcode
1999 *
2000 * @param[in] jid The joystick that was connected or disconnected.
2001 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
2002 * releases may add more events.
2003 *
2004 * @sa @ref joystick_event
2005 * @sa @ref glfwSetJoystickCallback
2006 *
2007 * @since Added in version 3.2.
2008 *
2009 * @ingroup input
2010 */
2011typedef void (* GLFWjoystickfun)(int jid, int event);
2012
2013/*! @brief Video mode type.
2014 *
2015 * This describes a single video mode.
2016 *
2017 * @sa @ref monitor_modes
2018 * @sa @ref glfwGetVideoMode
2019 * @sa @ref glfwGetVideoModes
2020 *
2021 * @since Added in version 1.0.
2022 * @glfw3 Added refresh rate member.
2023 *
2024 * @ingroup monitor
2025 */
2026typedef struct GLFWvidmode
2027{
2028 /*! The width, in screen coordinates, of the video mode.
2029 */
2030 int width;
2031 /*! The height, in screen coordinates, of the video mode.
2032 */
2033 int height;
2034 /*! The bit depth of the red channel of the video mode.
2035 */
2036 int redBits;
2037 /*! The bit depth of the green channel of the video mode.
2038 */
2039 int greenBits;
2040 /*! The bit depth of the blue channel of the video mode.
2041 */
2042 int blueBits;
2043 /*! The refresh rate, in Hz, of the video mode.
2044 */
2045 int refreshRate;
2046} GLFWvidmode;
2047
2048/*! @brief Gamma ramp.
2049 *
2050 * This describes the gamma ramp for a monitor.
2051 *
2052 * @sa @ref monitor_gamma
2053 * @sa @ref glfwGetGammaRamp
2054 * @sa @ref glfwSetGammaRamp
2055 *
2056 * @since Added in version 3.0.
2057 *
2058 * @ingroup monitor
2059 */
2060typedef struct GLFWgammaramp
2061{
2062 /*! An array of value describing the response of the red channel.
2063 */
2064 unsigned short* red;
2065 /*! An array of value describing the response of the green channel.
2066 */
2067 unsigned short* green;
2068 /*! An array of value describing the response of the blue channel.
2069 */
2070 unsigned short* blue;
2071 /*! The number of elements in each array.
2072 */
2073 unsigned int size;
2074} GLFWgammaramp;
2075
2076/*! @brief Image data.
2077 *
2078 * This describes a single 2D image. See the documentation for each related
2079 * function what the expected pixel format is.
2080 *
2081 * @sa @ref cursor_custom
2082 * @sa @ref window_icon
2083 *
2084 * @since Added in version 2.1.
2085 * @glfw3 Removed format and bytes-per-pixel members.
2086 *
2087 * @ingroup window
2088 */
2089typedef struct GLFWimage
2090{
2091 /*! The width, in pixels, of this image.
2092 */
2093 int width;
2094 /*! The height, in pixels, of this image.
2095 */
2096 int height;
2097 /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
2098 */
2099 unsigned char* pixels;
2100} GLFWimage;
2101
2102/*! @brief Gamepad input state
2103 *
2104 * This describes the input state of a gamepad.
2105 *
2106 * @sa @ref gamepad
2107 * @sa @ref glfwGetGamepadState
2108 *
2109 * @since Added in version 3.3.
2110 *
2111 * @ingroup input
2112 */
2113typedef struct GLFWgamepadstate
2114{
2115 /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
2116 * or `GLFW_RELEASE`.
2117 */
2118 unsigned char buttons[15];
2119 /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
2120 * to 1.0 inclusive.
2121 */
2122 float axes[6];
2123} GLFWgamepadstate;
2124
2125/*! @brief Custom heap memory allocator.
2126 *
2127 * This describes a custom heap memory allocator for GLFW. To set an allocator, pass it
2128 * to @ref glfwInitAllocator before initializing the library.
2129 *
2130 * @sa @ref init_allocator
2131 * @sa @ref glfwInitAllocator
2132 *
2133 * @since Added in version 3.4.
2134 *
2135 * @ingroup init
2136 */
2137typedef struct GLFWallocator
2138{
2139 /*! The memory allocation function. See @ref GLFWallocatefun for details about
2140 * allocation function.
2141 */
2142 GLFWallocatefun allocate;
2143 /*! The memory reallocation function. See @ref GLFWreallocatefun for details about
2144 * reallocation function.
2145 */
2146 GLFWreallocatefun reallocate;
2147 /*! The memory deallocation function. See @ref GLFWdeallocatefun for details about
2148 * deallocation function.
2149 */
2150 GLFWdeallocatefun deallocate;
2151 /*! The user pointer for this custom allocator. This value will be passed to the
2152 * allocator functions.
2153 */
2154 void* user;
2155} GLFWallocator;
2156
2157
2158/*************************************************************************
2159 * GLFW API functions
2160 *************************************************************************/
2161
2162/*! @brief Initializes the GLFW library.
2163 *
2164 * This function initializes the GLFW library. Before most GLFW functions can
2165 * be used, GLFW must be initialized, and before an application terminates GLFW
2166 * should be terminated in order to free any resources allocated during or
2167 * after initialization.
2168 *
2169 * If this function fails, it calls @ref glfwTerminate before returning. If it
2170 * succeeds, you should call @ref glfwTerminate before the application exits.
2171 *
2172 * Additional calls to this function after successful initialization but before
2173 * termination will return `GLFW_TRUE` immediately.
2174 *
2175 * The @ref GLFW_PLATFORM init hint controls which platforms are considered during
2176 * initialization. This also depends on which platforms the library was compiled to
2177 * support.
2178 *
2179 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
2180 * [error](@ref error_handling) occurred.
2181 *
2182 * @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref
2183 * GLFW_PLATFORM_ERROR.
2184 *
2185 * @remark @macos This function will change the current directory of the
2186 * application to the `Contents/Resources` subdirectory of the application's
2187 * bundle, if present. This can be disabled with the @ref
2188 * GLFW_COCOA_CHDIR_RESOURCES init hint.
2189 *
2190 * @remark @macos This function will create the main menu and dock icon for the
2191 * application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to
2192 * contain a menu bar. Otherwise a minimal menu bar is created manually with
2193 * common commands like Hide, Quit and About. The About entry opens a minimal
2194 * about dialog with information from the application's bundle. The menu bar
2195 * and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
2196 * hint.
2197 *
2198 * @remark __Wayland, X11:__ If the library was compiled with support for both
2199 * Wayland and X11, and the @ref GLFW_PLATFORM init hint is set to
2200 * `GLFW_ANY_PLATFORM`, the `XDG_SESSION_TYPE` environment variable affects
2201 * which platform is picked. If the environment variable is not set, or is set
2202 * to something other than `wayland` or `x11`, the regular detection mechanism
2203 * will be used instead.
2204 *
2205 * @remark @x11 This function will set the `LC_CTYPE` category of the
2206 * application locale according to the current environment if that category is
2207 * still "C". This is because the "C" locale breaks Unicode text input.
2208 *
2209 * @thread_safety This function must only be called from the main thread.
2210 *
2211 * @sa @ref intro_init
2212 * @sa @ref glfwInitHint
2213 * @sa @ref glfwInitAllocator
2214 * @sa @ref glfwTerminate
2215 *
2216 * @since Added in version 1.0.
2217 *
2218 * @ingroup init
2219 */
2220GLFWAPI int glfwInit(void);
2221
2222/*! @brief Terminates the GLFW library.
2223 *
2224 * This function destroys all remaining windows and cursors, restores any
2225 * modified gamma ramps and frees any other allocated resources. Once this
2226 * function is called, you must again call @ref glfwInit successfully before
2227 * you will be able to use most GLFW functions.
2228 *
2229 * If GLFW has been successfully initialized, this function should be called
2230 * before the application exits. If initialization fails, there is no need to
2231 * call this function, as it is called by @ref glfwInit before it returns
2232 * failure.
2233 *
2234 * This function has no effect if GLFW is not initialized.
2235 *
2236 * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
2237 *
2238 * @remark This function may be called before @ref glfwInit.
2239 *
2240 * @warning The contexts of any remaining windows must not be current on any
2241 * other thread when this function is called.
2242 *
2243 * @reentrancy This function must not be called from a callback.
2244 *
2245 * @thread_safety This function must only be called from the main thread.
2246 *
2247 * @sa @ref intro_init
2248 * @sa @ref glfwInit
2249 *
2250 * @since Added in version 1.0.
2251 *
2252 * @ingroup init
2253 */
2254GLFWAPI void glfwTerminate(void);
2255
2256/*! @brief Sets the specified init hint to the desired value.
2257 *
2258 * This function sets hints for the next initialization of GLFW.
2259 *
2260 * The values you set hints to are never reset by GLFW, but they only take
2261 * effect during initialization. Once GLFW has been initialized, any values
2262 * you set will be ignored until the library is terminated and initialized
2263 * again.
2264 *
2265 * Some hints are platform specific. These may be set on any platform but they
2266 * will only affect their specific platform. Other platforms will ignore them.
2267 * Setting these hints requires no platform specific headers or functions.
2268 *
2269 * @param[in] hint The [init hint](@ref init_hints) to set.
2270 * @param[in] value The new value of the init hint.
2271 *
2272 * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
2273 * GLFW_INVALID_VALUE.
2274 *
2275 * @remarks This function may be called before @ref glfwInit.
2276 *
2277 * @thread_safety This function must only be called from the main thread.
2278 *
2279 * @sa init_hints
2280 * @sa glfwInit
2281 *
2282 * @since Added in version 3.3.
2283 *
2284 * @ingroup init
2285 */
2286GLFWAPI void glfwInitHint(int hint, int value);
2287
2288/*! @brief Sets the init allocator to the desired value.
2289 *
2290 * To use the default allocator, call this function with a `NULL` argument.
2291 *
2292 * If you specify an allocator struct, every member must be a valid function
2293 * pointer. If any member is `NULL`, this function will emit @ref
2294 * GLFW_INVALID_VALUE and the init allocator will be unchanged.
2295 *
2296 * The functions in the allocator must fulfil a number of requirements. See the
2297 * documentation for @ref GLFWallocatefun, @ref GLFWreallocatefun and @ref
2298 * GLFWdeallocatefun for details.
2299 *
2300 * @param[in] allocator The allocator to use at the next initialization, or
2301 * `NULL` to use the default one.
2302 *
2303 * @errors Possible errors include @ref GLFW_INVALID_VALUE.
2304 *
2305 * @pointer_lifetime The specified allocator is copied before this function
2306 * returns.
2307 *
2308 * @thread_safety This function must only be called from the main thread.
2309 *
2310 * @sa @ref init_allocator
2311 * @sa @ref glfwInit
2312 *
2313 * @since Added in version 3.4.
2314 *
2315 * @ingroup init
2316 */
2317GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator);
2318
2319#if defined(VK_VERSION_1_0)
2320
2321/*! @brief Sets the desired Vulkan `vkGetInstanceProcAddr` function.
2322 *
2323 * This function sets the `vkGetInstanceProcAddr` function that GLFW will use for all
2324 * Vulkan related entry point queries.
2325 *
2326 * This feature is mostly useful on macOS, if your copy of the Vulkan loader is in
2327 * a location where GLFW cannot find it through dynamic loading, or if you are still
2328 * using the static library version of the loader.
2329 *
2330 * If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its standard
2331 * name and get this function from there. This is the default behavior.
2332 *
2333 * The standard name of the loader is `vulkan-1.dll` on Windows, `libvulkan.so.1` on
2334 * Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. If your code is
2335 * also loading it via these names then you probably don't need to use this function.
2336 *
2337 * The function address you set is never reset by GLFW, but it only takes effect during
2338 * initialization. Once GLFW has been initialized, any updates will be ignored until the
2339 * library is terminated and initialized again.
2340 *
2341 * @param[in] loader The address of the function to use, or `NULL`.
2342 *
2343 * @par Loader function signature
2344 * @code
2345 * PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* name)
2346 * @endcode
2347 * For more information about this function, see the
2348 * [Vulkan Registry](https://www.khronos.org/registry/vulkan/).
2349 *
2350 * @errors None.
2351 *
2352 * @remark This function may be called before @ref glfwInit.
2353 *
2354 * @thread_safety This function must only be called from the main thread.
2355 *
2356 * @sa @ref vulkan_loader
2357 * @sa @ref glfwInit
2358 *
2359 * @since Added in version 3.4.
2360 *
2361 * @ingroup init
2362 */
2363GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader);
2364
2365#endif /*VK_VERSION_1_0*/
2366
2367/*! @brief Retrieves the version of the GLFW library.
2368 *
2369 * This function retrieves the major, minor and revision numbers of the GLFW
2370 * library. It is intended for when you are using GLFW as a shared library and
2371 * want to ensure that you are using the minimum required version.
2372 *
2373 * Any or all of the version arguments may be `NULL`.
2374 *
2375 * @param[out] major Where to store the major version number, or `NULL`.
2376 * @param[out] minor Where to store the minor version number, or `NULL`.
2377 * @param[out] rev Where to store the revision number, or `NULL`.
2378 *
2379 * @errors None.
2380 *
2381 * @remark This function may be called before @ref glfwInit.
2382 *
2383 * @thread_safety This function may be called from any thread.
2384 *
2385 * @sa @ref intro_version
2386 * @sa @ref glfwGetVersionString
2387 *
2388 * @since Added in version 1.0.
2389 *
2390 * @ingroup init
2391 */
2392GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
2393
2394/*! @brief Returns a string describing the compile-time configuration.
2395 *
2396 * This function returns the compile-time generated
2397 * [version string](@ref intro_version_string) of the GLFW library binary. It describes
2398 * the version, platforms, compiler and any platform or operating system specific
2399 * compile-time options. It should not be confused with the OpenGL or OpenGL ES version
2400 * string, queried with `glGetString`.
2401 *
2402 * __Do not use the version string__ to parse the GLFW library version. The
2403 * @ref glfwGetVersion function provides the version of the running library
2404 * binary in numerical format.
2405 *
2406 * __Do not use the version string__ to parse what platforms are supported. The @ref
2407 * glfwPlatformSupported function lets you query platform support.
2408 *
2409 * @return The ASCII encoded GLFW version string.
2410 *
2411 * @errors None.
2412 *
2413 * @remark This function may be called before @ref glfwInit.
2414 *
2415 * @pointer_lifetime The returned string is static and compile-time generated.
2416 *
2417 * @thread_safety This function may be called from any thread.
2418 *
2419 * @sa @ref intro_version
2420 * @sa @ref glfwGetVersion
2421 *
2422 * @since Added in version 3.0.
2423 *
2424 * @ingroup init
2425 */
2426GLFWAPI const char* glfwGetVersionString(void);
2427
2428/*! @brief Returns and clears the last error for the calling thread.
2429 *
2430 * This function returns and clears the [error code](@ref errors) of the last
2431 * error that occurred on the calling thread, and optionally a UTF-8 encoded
2432 * human-readable description of it. If no error has occurred since the last
2433 * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
2434 * set to `NULL`.
2435 *
2436 * @param[in] description Where to store the error description pointer, or `NULL`.
2437 * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
2438 * (zero).
2439 *
2440 * @errors None.
2441 *
2442 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2443 * should not free it yourself. It is guaranteed to be valid only until the
2444 * next error occurs or the library is terminated.
2445 *
2446 * @remark This function may be called before @ref glfwInit.
2447 *
2448 * @thread_safety This function may be called from any thread.
2449 *
2450 * @sa @ref error_handling
2451 * @sa @ref glfwSetErrorCallback
2452 *
2453 * @since Added in version 3.3.
2454 *
2455 * @ingroup init
2456 */
2457GLFWAPI int glfwGetError(const char** description);
2458
2459/*! @brief Sets the error callback.
2460 *
2461 * This function sets the error callback, which is called with an error code
2462 * and a human-readable description each time a GLFW error occurs.
2463 *
2464 * The error code is set before the callback is called. Calling @ref
2465 * glfwGetError from the error callback will return the same value as the error
2466 * code argument.
2467 *
2468 * The error callback is called on the thread where the error occurred. If you
2469 * are using GLFW from multiple threads, your error callback needs to be
2470 * written accordingly.
2471 *
2472 * Because the description string may have been generated specifically for that
2473 * error, it is not guaranteed to be valid after the callback has returned. If
2474 * you wish to use it after the callback returns, you need to make a copy.
2475 *
2476 * Once set, the error callback remains set even after the library has been
2477 * terminated.
2478 *
2479 * @param[in] callback The new callback, or `NULL` to remove the currently set
2480 * callback.
2481 * @return The previously set callback, or `NULL` if no callback was set.
2482 *
2483 * @callback_signature
2484 * @code
2485 * void callback_name(int error_code, const char* description)
2486 * @endcode
2487 * For more information about the callback parameters, see the
2488 * [callback pointer type](@ref GLFWerrorfun).
2489 *
2490 * @errors None.
2491 *
2492 * @remark This function may be called before @ref glfwInit.
2493 *
2494 * @thread_safety This function must only be called from the main thread.
2495 *
2496 * @sa @ref error_handling
2497 * @sa @ref glfwGetError
2498 *
2499 * @since Added in version 3.0.
2500 *
2501 * @ingroup init
2502 */
2503GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
2504
2505/*! @brief Returns the currently selected platform.
2506 *
2507 * This function returns the platform that was selected during initialization. The
2508 * returned value will be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
2509 * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
2510 *
2511 * @return The currently selected platform, or zero if an error occurred.
2512 *
2513 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2514 *
2515 * @thread_safety This function may be called from any thread.
2516 *
2517 * @sa @ref platform
2518 * @sa @ref glfwPlatformSupported
2519 *
2520 * @since Added in version 3.4.
2521 *
2522 * @ingroup init
2523 */
2524GLFWAPI int glfwGetPlatform(void);
2525
2526/*! @brief Returns whether the library includes support for the specified platform.
2527 *
2528 * This function returns whether the library was compiled with support for the specified
2529 * platform. The platform must be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
2530 * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
2531 *
2532 * @param[in] platform The platform to query.
2533 * @return `GLFW_TRUE` if the platform is supported, or `GLFW_FALSE` otherwise.
2534 *
2535 * @errors Possible errors include @ref GLFW_INVALID_ENUM.
2536 *
2537 * @remark This function may be called before @ref glfwInit.
2538 *
2539 * @thread_safety This function may be called from any thread.
2540 *
2541 * @sa @ref platform
2542 * @sa @ref glfwGetPlatform
2543 *
2544 * @since Added in version 3.4.
2545 *
2546 * @ingroup init
2547 */
2548GLFWAPI int glfwPlatformSupported(int platform);
2549
2550/*! @brief Returns the currently connected monitors.
2551 *
2552 * This function returns an array of handles for all currently connected
2553 * monitors. The primary monitor is always first in the returned array. If no
2554 * monitors were found, this function returns `NULL`.
2555 *
2556 * @param[out] count Where to store the number of monitors in the returned
2557 * array. This is set to zero if an error occurred.
2558 * @return An array of monitor handles, or `NULL` if no monitors were found or
2559 * if an [error](@ref error_handling) occurred.
2560 *
2561 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2562 *
2563 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2564 * should not free it yourself. It is guaranteed to be valid only until the
2565 * monitor configuration changes or the library is terminated.
2566 *
2567 * @thread_safety This function must only be called from the main thread.
2568 *
2569 * @sa @ref monitor_monitors
2570 * @sa @ref monitor_event
2571 * @sa @ref glfwGetPrimaryMonitor
2572 *
2573 * @since Added in version 3.0.
2574 *
2575 * @ingroup monitor
2576 */
2577GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
2578
2579/*! @brief Returns the primary monitor.
2580 *
2581 * This function returns the primary monitor. This is usually the monitor
2582 * where elements like the task bar or global menu bar are located.
2583 *
2584 * @return The primary monitor, or `NULL` if no monitors were found or if an
2585 * [error](@ref error_handling) occurred.
2586 *
2587 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2588 *
2589 * @thread_safety This function must only be called from the main thread.
2590 *
2591 * @remark The primary monitor is always first in the array returned by @ref
2592 * glfwGetMonitors.
2593 *
2594 * @sa @ref monitor_monitors
2595 * @sa @ref glfwGetMonitors
2596 *
2597 * @since Added in version 3.0.
2598 *
2599 * @ingroup monitor
2600 */
2601GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
2602
2603/*! @brief Returns the position of the monitor's viewport on the virtual screen.
2604 *
2605 * This function returns the position, in screen coordinates, of the upper-left
2606 * corner of the specified monitor.
2607 *
2608 * Any or all of the position arguments may be `NULL`. If an error occurs, all
2609 * non-`NULL` position arguments will be set to zero.
2610 *
2611 * @param[in] monitor The monitor to query.
2612 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2613 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
2614 *
2615 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2616 * GLFW_PLATFORM_ERROR.
2617 *
2618 * @thread_safety This function must only be called from the main thread.
2619 *
2620 * @sa @ref monitor_properties
2621 *
2622 * @since Added in version 3.0.
2623 *
2624 * @ingroup monitor
2625 */
2626GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
2627
2628/*! @brief Retrieves the work area of the monitor.
2629 *
2630 * This function returns the position, in screen coordinates, of the upper-left
2631 * corner of the work area of the specified monitor along with the work area
2632 * size in screen coordinates. The work area is defined as the area of the
2633 * monitor not occluded by the window system task bar where present. If no
2634 * task bar exists then the work area is the monitor resolution in screen
2635 * coordinates.
2636 *
2637 * Any or all of the position and size arguments may be `NULL`. If an error
2638 * occurs, all non-`NULL` position and size arguments will be set to zero.
2639 *
2640 * @param[in] monitor The monitor to query.
2641 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2642 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
2643 * @param[out] width Where to store the monitor width, or `NULL`.
2644 * @param[out] height Where to store the monitor height, or `NULL`.
2645 *
2646 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2647 * GLFW_PLATFORM_ERROR.
2648 *
2649 * @thread_safety This function must only be called from the main thread.
2650 *
2651 * @sa @ref monitor_workarea
2652 *
2653 * @since Added in version 3.3.
2654 *
2655 * @ingroup monitor
2656 */
2657GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
2658
2659/*! @brief Returns the physical size of the monitor.
2660 *
2661 * This function returns the size, in millimetres, of the display area of the
2662 * specified monitor.
2663 *
2664 * Some platforms do not provide accurate monitor size information, either
2665 * because the monitor [EDID][] data is incorrect or because the driver does
2666 * not report it accurately.
2667 *
2668 * [EDID]: https://en.wikipedia.org/wiki/Extended_display_identification_data
2669 *
2670 * Any or all of the size arguments may be `NULL`. If an error occurs, all
2671 * non-`NULL` size arguments will be set to zero.
2672 *
2673 * @param[in] monitor The monitor to query.
2674 * @param[out] widthMM Where to store the width, in millimetres, of the
2675 * monitor's display area, or `NULL`.
2676 * @param[out] heightMM Where to store the height, in millimetres, of the
2677 * monitor's display area, or `NULL`.
2678 *
2679 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2680 *
2681 * @remark @win32 On Windows 8 and earlier the physical size is calculated from
2682 * the current resolution and system DPI instead of querying the monitor EDID data.
2683 *
2684 * @thread_safety This function must only be called from the main thread.
2685 *
2686 * @sa @ref monitor_properties
2687 *
2688 * @since Added in version 3.0.
2689 *
2690 * @ingroup monitor
2691 */
2692GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
2693
2694/*! @brief Retrieves the content scale for the specified monitor.
2695 *
2696 * This function retrieves the content scale for the specified monitor. The
2697 * content scale is the ratio between the current DPI and the platform's
2698 * default DPI. This is especially important for text and any UI elements. If
2699 * the pixel dimensions of your UI scaled by this look appropriate on your
2700 * machine then it should appear at a reasonable size on other machines
2701 * regardless of their DPI and scaling settings. This relies on the system DPI
2702 * and scaling settings being somewhat correct.
2703 *
2704 * The content scale may depend on both the monitor resolution and pixel
2705 * density and on user settings. It may be very different from the raw DPI
2706 * calculated from the physical size and current resolution.
2707 *
2708 * @param[in] monitor The monitor to query.
2709 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
2710 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
2711 *
2712 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2713 * GLFW_PLATFORM_ERROR.
2714 *
2715 * @remark @wayland Fractional scaling information is not yet available for
2716 * monitors, so this function only returns integer content scales.
2717 *
2718 * @thread_safety This function must only be called from the main thread.
2719 *
2720 * @sa @ref monitor_scale
2721 * @sa @ref glfwGetWindowContentScale
2722 *
2723 * @since Added in version 3.3.
2724 *
2725 * @ingroup monitor
2726 */
2727GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
2728
2729/*! @brief Returns the name of the specified monitor.
2730 *
2731 * This function returns a human-readable name, encoded as UTF-8, of the
2732 * specified monitor. The name typically reflects the make and model of the
2733 * monitor and is not guaranteed to be unique among the connected monitors.
2734 *
2735 * @param[in] monitor The monitor to query.
2736 * @return The UTF-8 encoded name of the monitor, or `NULL` if an
2737 * [error](@ref error_handling) occurred.
2738 *
2739 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2740 *
2741 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2742 * should not free it yourself. It is valid until the specified monitor is
2743 * disconnected or the library is terminated.
2744 *
2745 * @thread_safety This function must only be called from the main thread.
2746 *
2747 * @sa @ref monitor_properties
2748 *
2749 * @since Added in version 3.0.
2750 *
2751 * @ingroup monitor
2752 */
2753GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
2754
2755/*! @brief Sets the user pointer of the specified monitor.
2756 *
2757 * This function sets the user-defined pointer of the specified monitor. The
2758 * current value is retained until the monitor is disconnected. The initial
2759 * value is `NULL`.
2760 *
2761 * This function may be called from the monitor callback, even for a monitor
2762 * that is being disconnected.
2763 *
2764 * @param[in] monitor The monitor whose pointer to set.
2765 * @param[in] pointer The new value.
2766 *
2767 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2768 *
2769 * @thread_safety This function may be called from any thread. Access is not
2770 * synchronized.
2771 *
2772 * @sa @ref monitor_userptr
2773 * @sa @ref glfwGetMonitorUserPointer
2774 *
2775 * @since Added in version 3.3.
2776 *
2777 * @ingroup monitor
2778 */
2779GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
2780
2781/*! @brief Returns the user pointer of the specified monitor.
2782 *
2783 * This function returns the current value of the user-defined pointer of the
2784 * specified monitor. The initial value is `NULL`.
2785 *
2786 * This function may be called from the monitor callback, even for a monitor
2787 * that is being disconnected.
2788 *
2789 * @param[in] monitor The monitor whose pointer to return.
2790 *
2791 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2792 *
2793 * @thread_safety This function may be called from any thread. Access is not
2794 * synchronized.
2795 *
2796 * @sa @ref monitor_userptr
2797 * @sa @ref glfwSetMonitorUserPointer
2798 *
2799 * @since Added in version 3.3.
2800 *
2801 * @ingroup monitor
2802 */
2803GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
2804
2805/*! @brief Sets the monitor configuration callback.
2806 *
2807 * This function sets the monitor configuration callback, or removes the
2808 * currently set callback. This is called when a monitor is connected to or
2809 * disconnected from the system.
2810 *
2811 * @param[in] callback The new callback, or `NULL` to remove the currently set
2812 * callback.
2813 * @return The previously set callback, or `NULL` if no callback was set or the
2814 * library had not been [initialized](@ref intro_init).
2815 *
2816 * @callback_signature
2817 * @code
2818 * void function_name(GLFWmonitor* monitor, int event)
2819 * @endcode
2820 * For more information about the callback parameters, see the
2821 * [function pointer type](@ref GLFWmonitorfun).
2822 *
2823 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2824 *
2825 * @thread_safety This function must only be called from the main thread.
2826 *
2827 * @sa @ref monitor_event
2828 *
2829 * @since Added in version 3.0.
2830 *
2831 * @ingroup monitor
2832 */
2833GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
2834
2835/*! @brief Returns the available video modes for the specified monitor.
2836 *
2837 * This function returns an array of all video modes supported by the specified
2838 * monitor. The returned array is sorted in ascending order, first by color
2839 * bit depth (the sum of all channel depths), then by resolution area (the
2840 * product of width and height), then resolution width and finally by refresh
2841 * rate.
2842 *
2843 * @param[in] monitor The monitor to query.
2844 * @param[out] count Where to store the number of video modes in the returned
2845 * array. This is set to zero if an error occurred.
2846 * @return An array of video modes, or `NULL` if an
2847 * [error](@ref error_handling) occurred.
2848 *
2849 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2850 * GLFW_PLATFORM_ERROR.
2851 *
2852 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2853 * should not free it yourself. It is valid until the specified monitor is
2854 * disconnected, this function is called again for that monitor or the library
2855 * is terminated.
2856 *
2857 * @thread_safety This function must only be called from the main thread.
2858 *
2859 * @sa @ref monitor_modes
2860 * @sa @ref glfwGetVideoMode
2861 *
2862 * @since Added in version 1.0.
2863 * @glfw3 Changed to return an array of modes for a specific monitor.
2864 *
2865 * @ingroup monitor
2866 */
2867GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
2868
2869/*! @brief Returns the current mode of the specified monitor.
2870 *
2871 * This function returns the current video mode of the specified monitor. If
2872 * you have created a full screen window for that monitor, the return value
2873 * will depend on whether that window is iconified.
2874 *
2875 * @param[in] monitor The monitor to query.
2876 * @return The current mode of the monitor, or `NULL` if an
2877 * [error](@ref error_handling) occurred.
2878 *
2879 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2880 * GLFW_PLATFORM_ERROR.
2881 *
2882 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2883 * should not free it yourself. It is valid until the specified monitor is
2884 * disconnected or the library is terminated.
2885 *
2886 * @thread_safety This function must only be called from the main thread.
2887 *
2888 * @sa @ref monitor_modes
2889 * @sa @ref glfwGetVideoModes
2890 *
2891 * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
2892 *
2893 * @ingroup monitor
2894 */
2895GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
2896
2897/*! @brief Generates a gamma ramp and sets it for the specified monitor.
2898 *
2899 * This function generates an appropriately sized gamma ramp from the specified
2900 * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
2901 * a finite number greater than zero.
2902 *
2903 * The software controlled gamma ramp is applied _in addition_ to the hardware
2904 * gamma correction, which today is usually an approximation of sRGB gamma.
2905 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2906 * the default (usually sRGB-like) behavior.
2907 *
2908 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2909 * GLFW_SRGB_CAPABLE hint.
2910 *
2911 * @param[in] monitor The monitor whose gamma ramp to set.
2912 * @param[in] gamma The desired exponent.
2913 *
2914 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
2915 * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
2916 *
2917 * @remark @wayland Gamma handling is a privileged protocol, this function
2918 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
2919 *
2920 * @thread_safety This function must only be called from the main thread.
2921 *
2922 * @sa @ref monitor_gamma
2923 *
2924 * @since Added in version 3.0.
2925 *
2926 * @ingroup monitor
2927 */
2928GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
2929
2930/*! @brief Returns the current gamma ramp for the specified monitor.
2931 *
2932 * This function returns the current gamma ramp of the specified monitor.
2933 *
2934 * @param[in] monitor The monitor to query.
2935 * @return The current gamma ramp, or `NULL` if an
2936 * [error](@ref error_handling) occurred.
2937 *
2938 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
2939 * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
2940 *
2941 * @remark @wayland Gamma handling is a privileged protocol, this function
2942 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
2943 * returning `NULL`.
2944 *
2945 * @pointer_lifetime The returned structure and its arrays are allocated and
2946 * freed by GLFW. You should not free them yourself. They are valid until the
2947 * specified monitor is disconnected, this function is called again for that
2948 * monitor or the library is terminated.
2949 *
2950 * @thread_safety This function must only be called from the main thread.
2951 *
2952 * @sa @ref monitor_gamma
2953 *
2954 * @since Added in version 3.0.
2955 *
2956 * @ingroup monitor
2957 */
2958GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
2959
2960/*! @brief Sets the current gamma ramp for the specified monitor.
2961 *
2962 * This function sets the current gamma ramp for the specified monitor. The
2963 * original gamma ramp for that monitor is saved by GLFW the first time this
2964 * function is called and is restored by @ref glfwTerminate.
2965 *
2966 * The software controlled gamma ramp is applied _in addition_ to the hardware
2967 * gamma correction, which today is usually an approximation of sRGB gamma.
2968 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2969 * the default (usually sRGB-like) behavior.
2970 *
2971 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2972 * GLFW_SRGB_CAPABLE hint.
2973 *
2974 * @param[in] monitor The monitor whose gamma ramp to set.
2975 * @param[in] ramp The gamma ramp to use.
2976 *
2977 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
2978 * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
2979 *
2980 * @remark The size of the specified gamma ramp should match the size of the
2981 * current ramp for that monitor.
2982 *
2983 * @remark @win32 The gamma ramp size must be 256.
2984 *
2985 * @remark @wayland Gamma handling is a privileged protocol, this function
2986 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
2987 *
2988 * @pointer_lifetime The specified gamma ramp is copied before this function
2989 * returns.
2990 *
2991 * @thread_safety This function must only be called from the main thread.
2992 *
2993 * @sa @ref monitor_gamma
2994 *
2995 * @since Added in version 3.0.
2996 *
2997 * @ingroup monitor
2998 */
2999GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
3000
3001/*! @brief Resets all window hints to their default values.
3002 *
3003 * This function resets all window hints to their
3004 * [default values](@ref window_hints_values).
3005 *
3006 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3007 *
3008 * @thread_safety This function must only be called from the main thread.
3009 *
3010 * @sa @ref window_hints
3011 * @sa @ref glfwWindowHint
3012 * @sa @ref glfwWindowHintString
3013 *
3014 * @since Added in version 3.0.
3015 *
3016 * @ingroup window
3017 */
3018GLFWAPI void glfwDefaultWindowHints(void);
3019
3020/*! @brief Sets the specified window hint to the desired value.
3021 *
3022 * This function sets hints for the next call to @ref glfwCreateWindow. The
3023 * hints, once set, retain their values until changed by a call to this
3024 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
3025 *
3026 * Only integer value hints can be set with this function. String value hints
3027 * are set with @ref glfwWindowHintString.
3028 *
3029 * This function does not check whether the specified hint values are valid.
3030 * If you set hints to invalid values this will instead be reported by the next
3031 * call to @ref glfwCreateWindow.
3032 *
3033 * Some hints are platform specific. These may be set on any platform but they
3034 * will only affect their specific platform. Other platforms will ignore them.
3035 * Setting these hints requires no platform specific headers or functions.
3036 *
3037 * @param[in] hint The [window hint](@ref window_hints) to set.
3038 * @param[in] value The new value of the window hint.
3039 *
3040 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3041 * GLFW_INVALID_ENUM.
3042 *
3043 * @thread_safety This function must only be called from the main thread.
3044 *
3045 * @sa @ref window_hints
3046 * @sa @ref glfwWindowHintString
3047 * @sa @ref glfwDefaultWindowHints
3048 *
3049 * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
3050 *
3051 * @ingroup window
3052 */
3053GLFWAPI void glfwWindowHint(int hint, int value);
3054
3055/*! @brief Sets the specified window hint to the desired value.
3056 *
3057 * This function sets hints for the next call to @ref glfwCreateWindow. The
3058 * hints, once set, retain their values until changed by a call to this
3059 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
3060 *
3061 * Only string type hints can be set with this function. Integer value hints
3062 * are set with @ref glfwWindowHint.
3063 *
3064 * This function does not check whether the specified hint values are valid.
3065 * If you set hints to invalid values this will instead be reported by the next
3066 * call to @ref glfwCreateWindow.
3067 *
3068 * Some hints are platform specific. These may be set on any platform but they
3069 * will only affect their specific platform. Other platforms will ignore them.
3070 * Setting these hints requires no platform specific headers or functions.
3071 *
3072 * @param[in] hint The [window hint](@ref window_hints) to set.
3073 * @param[in] value The new value of the window hint.
3074 *
3075 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3076 * GLFW_INVALID_ENUM.
3077 *
3078 * @pointer_lifetime The specified string is copied before this function
3079 * returns.
3080 *
3081 * @thread_safety This function must only be called from the main thread.
3082 *
3083 * @sa @ref window_hints
3084 * @sa @ref glfwWindowHint
3085 * @sa @ref glfwDefaultWindowHints
3086 *
3087 * @since Added in version 3.3.
3088 *
3089 * @ingroup window
3090 */
3091GLFWAPI void glfwWindowHintString(int hint, const char* value);
3092
3093/*! @brief Creates a window and its associated context.
3094 *
3095 * This function creates a window and its associated OpenGL or OpenGL ES
3096 * context. Most of the options controlling how the window and its context
3097 * should be created are specified with [window hints](@ref window_hints).
3098 *
3099 * Successful creation does not change which context is current. Before you
3100 * can use the newly created context, you need to
3101 * [make it current](@ref context_current). For information about the `share`
3102 * parameter, see @ref context_sharing.
3103 *
3104 * The created window, framebuffer and context may differ from what you
3105 * requested, as not all parameters and hints are
3106 * [hard constraints](@ref window_hints_hard). This includes the size of the
3107 * window, especially for full screen windows. To query the actual attributes
3108 * of the created window, framebuffer and context, see @ref
3109 * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
3110 *
3111 * To create a full screen window, you need to specify the monitor the window
3112 * will cover. If no monitor is specified, the window will be windowed mode.
3113 * Unless you have a way for the user to choose a specific monitor, it is
3114 * recommended that you pick the primary monitor. For more information on how
3115 * to query connected monitors, see @ref monitor_monitors.
3116 *
3117 * For full screen windows, the specified size becomes the resolution of the
3118 * window's _desired video mode_. As long as a full screen window is not
3119 * iconified, the supported video mode most closely matching the desired video
3120 * mode is set for the specified monitor. For more information about full
3121 * screen windows, including the creation of so called _windowed full screen_
3122 * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
3123 *
3124 * Once you have created the window, you can switch it between windowed and
3125 * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
3126 * OpenGL or OpenGL ES context.
3127 *
3128 * By default, newly created windows use the placement recommended by the
3129 * window system. To create the window at a specific position, set the @ref
3130 * GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints before creation. To
3131 * restore the default behavior, set either or both hints back to
3132 * `GLFW_ANY_POSITION`.
3133 *
3134 * As long as at least one full screen window is not iconified, the screensaver
3135 * is prohibited from starting.
3136 *
3137 * Window systems put limits on window sizes. Very large or very small window
3138 * dimensions may be overridden by the window system on creation. Check the
3139 * actual [size](@ref window_size) after creation.
3140 *
3141 * The [swap interval](@ref buffer_swap) is not set during window creation and
3142 * the initial value may vary depending on driver settings and defaults.
3143 *
3144 * @param[in] width The desired width, in screen coordinates, of the window.
3145 * This must be greater than zero.
3146 * @param[in] height The desired height, in screen coordinates, of the window.
3147 * This must be greater than zero.
3148 * @param[in] title The initial, UTF-8 encoded window title.
3149 * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
3150 * windowed mode.
3151 * @param[in] share The window whose context to share resources with, or `NULL`
3152 * to not share resources.
3153 * @return The handle of the created window, or `NULL` if an
3154 * [error](@ref error_handling) occurred.
3155 *
3156 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3157 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
3158 * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
3159 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
3160 *
3161 * @remark @win32 Window creation will fail if the Microsoft GDI software
3162 * OpenGL implementation is the only one available.
3163 *
3164 * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
3165 * will be set as the initial icon for the window. If no such icon is present,
3166 * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
3167 * see @ref glfwSetWindowIcon.
3168 *
3169 * @remark @win32 The context to share resources with must not be current on
3170 * any other thread.
3171 *
3172 * @remark @macos The OS only supports core profile contexts for OpenGL
3173 * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or
3174 * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
3175 * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all
3176 * on macOS.
3177 *
3178 * @remark @macos The GLFW window has no icon, as it is not a document
3179 * window, but the dock icon will be the same as the application bundle's icon.
3180 * For more information on bundles, see the
3181 * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
3182 *
3183 * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
3184 *
3185 * @remark @macos On OS X 10.10 and later the window frame will not be rendered
3186 * at full resolution on Retina displays unless the
3187 * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint)
3188 * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
3189 * application bundle's `Info.plist`. For more information, see
3190 * [High Resolution Guidelines for OS X][hidpi-guide] in the Mac Developer
3191 * Library. The GLFW test and example programs use a custom `Info.plist`
3192 * template for this, which can be found as `CMake/Info.plist.in` in the source
3193 * tree.
3194 *
3195 * [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
3196 *
3197 * @remark @macos When activating frame autosaving with
3198 * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
3199 * window size and position may be overridden by previously saved values.
3200 *
3201 * @remark @wayland GLFW uses [libdecor][] where available to create its window
3202 * decorations. This in turn uses server-side XDG decorations where available
3203 * and provides high quality client-side decorations on compositors like GNOME.
3204 * If both XDG decorations and libdecor are unavailable, GLFW falls back to
3205 * a very simple set of window decorations that only support moving, resizing
3206 * and the window manager's right-click menu.
3207 *
3208 * [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor
3209 *
3210 * @remark @x11 Some window managers will not respect the placement of
3211 * initially hidden windows.
3212 *
3213 * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
3214 * a window to reach its requested state. This means you may not be able to
3215 * query the final size, position or other attributes directly after window
3216 * creation.
3217 *
3218 * @remark @x11 The class part of the `WM_CLASS` window property will by
3219 * default be set to the window title passed to this function. The instance
3220 * part will use the contents of the `RESOURCE_NAME` environment variable, if
3221 * present and not empty, or fall back to the window title. Set the
3222 * [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
3223 * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
3224 * override this.
3225 *
3226 * @thread_safety This function must only be called from the main thread.
3227 *
3228 * @sa @ref window_creation
3229 * @sa @ref glfwDestroyWindow
3230 *
3231 * @since Added in version 3.0. Replaces `glfwOpenWindow`.
3232 *
3233 * @ingroup window
3234 */
3235GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
3236
3237/*! @brief Destroys the specified window and its context.
3238 *
3239 * This function destroys the specified window and its context. On calling
3240 * this function, no further callbacks will be called for that window.
3241 *
3242 * If the context of the specified window is current on the main thread, it is
3243 * detached before being destroyed.
3244 *
3245 * @param[in] window The window to destroy.
3246 *
3247 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3248 * GLFW_PLATFORM_ERROR.
3249 *
3250 * @note The context of the specified window must not be current on any other
3251 * thread when this function is called.
3252 *
3253 * @reentrancy This function must not be called from a callback.
3254 *
3255 * @thread_safety This function must only be called from the main thread.
3256 *
3257 * @sa @ref window_creation
3258 * @sa @ref glfwCreateWindow
3259 *
3260 * @since Added in version 3.0. Replaces `glfwCloseWindow`.
3261 *
3262 * @ingroup window
3263 */
3264GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
3265
3266/*! @brief Checks the close flag of the specified window.
3267 *
3268 * This function returns the value of the close flag of the specified window.
3269 *
3270 * @param[in] window The window to query.
3271 * @return The value of the close flag.
3272 *
3273 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3274 *
3275 * @thread_safety This function may be called from any thread. Access is not
3276 * synchronized.
3277 *
3278 * @sa @ref window_close
3279 *
3280 * @since Added in version 3.0.
3281 *
3282 * @ingroup window
3283 */
3284GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
3285
3286/*! @brief Sets the close flag of the specified window.
3287 *
3288 * This function sets the value of the close flag of the specified window.
3289 * This can be used to override the user's attempt to close the window, or
3290 * to signal that it should be closed.
3291 *
3292 * @param[in] window The window whose flag to change.
3293 * @param[in] value The new value.
3294 *
3295 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3296 *
3297 * @thread_safety This function may be called from any thread. Access is not
3298 * synchronized.
3299 *
3300 * @sa @ref window_close
3301 *
3302 * @since Added in version 3.0.
3303 *
3304 * @ingroup window
3305 */
3306GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
3307
3308/*! @brief Returns the title of the specified window.
3309 *
3310 * This function returns the window title, encoded as UTF-8, of the specified
3311 * window. This is the title set previously by @ref glfwCreateWindow
3312 * or @ref glfwSetWindowTitle.
3313 *
3314 * @param[in] window The window to query.
3315 * @return The UTF-8 encoded window title, or `NULL` if an
3316 * [error](@ref error_handling) occurred.
3317 *
3318 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3319 *
3320 * @remark The returned title is currently a copy of the title last set by @ref
3321 * glfwCreateWindow or @ref glfwSetWindowTitle. It does not include any
3322 * additional text which may be appended by the platform or another program.
3323 *
3324 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
3325 * should not free it yourself. It is valid until the next call to @ref
3326 * glfwGetWindowTitle or @ref glfwSetWindowTitle, or until the library is
3327 * terminated.
3328 *
3329 * @thread_safety This function must only be called from the main thread.
3330 *
3331 * @sa @ref window_title
3332 * @sa @ref glfwSetWindowTitle
3333 *
3334 * @since Added in version 3.4.
3335 *
3336 * @ingroup window
3337 */
3338GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window);
3339
3340/*! @brief Sets the title of the specified window.
3341 *
3342 * This function sets the window title, encoded as UTF-8, of the specified
3343 * window.
3344 *
3345 * @param[in] window The window whose title to change.
3346 * @param[in] title The UTF-8 encoded window title.
3347 *
3348 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3349 * GLFW_PLATFORM_ERROR.
3350 *
3351 * @remark @macos The window title will not be updated until the next time you
3352 * process events.
3353 *
3354 * @thread_safety This function must only be called from the main thread.
3355 *
3356 * @sa @ref window_title
3357 * @sa @ref glfwGetWindowTitle
3358 *
3359 * @since Added in version 1.0.
3360 * @glfw3 Added window handle parameter.
3361 *
3362 * @ingroup window
3363 */
3364GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
3365
3366/*! @brief Sets the icon for the specified window.
3367 *
3368 * This function sets the icon of the specified window. If passed an array of
3369 * candidate images, those of or closest to the sizes desired by the system are
3370 * selected. If no images are specified, the window reverts to its default
3371 * icon.
3372 *
3373 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
3374 * bits per channel with the red channel first. They are arranged canonically
3375 * as packed sequential rows, starting from the top-left corner.
3376 *
3377 * The desired image sizes varies depending on platform and system settings.
3378 * The selected images will be rescaled as needed. Good sizes include 16x16,
3379 * 32x32 and 48x48.
3380 *
3381 * @param[in] window The window whose icon to set.
3382 * @param[in] count The number of images in the specified array, or zero to
3383 * revert to the default window icon.
3384 * @param[in] images The images to create the icon from. This is ignored if
3385 * count is zero.
3386 *
3387 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3388 * GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
3389 * GLFW_FEATURE_UNAVAILABLE (see remarks).
3390 *
3391 * @pointer_lifetime The specified image data is copied before this function
3392 * returns.
3393 *
3394 * @remark @macos Regular windows do not have icons on macOS. This function
3395 * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
3396 * the application bundle's icon. For more information on bundles, see the
3397 * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
3398 *
3399 * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
3400 *
3401 * @remark @wayland There is no existing protocol to change an icon, the
3402 * window will thus inherit the one defined in the application's desktop file.
3403 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
3404 *
3405 * @thread_safety This function must only be called from the main thread.
3406 *
3407 * @sa @ref window_icon
3408 *
3409 * @since Added in version 3.2.
3410 *
3411 * @ingroup window
3412 */
3413GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
3414
3415/*! @brief Retrieves the position of the content area of the specified window.
3416 *
3417 * This function retrieves the position, in screen coordinates, of the
3418 * upper-left corner of the content area of the specified window.
3419 *
3420 * Any or all of the position arguments may be `NULL`. If an error occurs, all
3421 * non-`NULL` position arguments will be set to zero.
3422 *
3423 * @param[in] window The window to query.
3424 * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
3425 * the content area, or `NULL`.
3426 * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
3427 * the content area, or `NULL`.
3428 *
3429 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3430 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3431 *
3432 * @remark @wayland There is no way for an application to retrieve the global
3433 * position of its windows. This function will emit @ref
3434 * GLFW_FEATURE_UNAVAILABLE.
3435 *
3436 * @thread_safety This function must only be called from the main thread.
3437 *
3438 * @sa @ref window_pos
3439 * @sa @ref glfwSetWindowPos
3440 *
3441 * @since Added in version 3.0.
3442 *
3443 * @ingroup window
3444 */
3445GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
3446
3447/*! @brief Sets the position of the content area of the specified window.
3448 *
3449 * This function sets the position, in screen coordinates, of the upper-left
3450 * corner of the content area of the specified windowed mode window. If the
3451 * window is a full screen window, this function does nothing.
3452 *
3453 * __Do not use this function__ to move an already visible window unless you
3454 * have very good reasons for doing so, as it will confuse and annoy the user.
3455 *
3456 * The window manager may put limits on what positions are allowed. GLFW
3457 * cannot and should not override these limits.
3458 *
3459 * @param[in] window The window to query.
3460 * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
3461 * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
3462 *
3463 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3464 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3465 *
3466 * @remark @wayland There is no way for an application to set the global
3467 * position of its windows. This function will emit @ref
3468 * GLFW_FEATURE_UNAVAILABLE.
3469 *
3470 * @thread_safety This function must only be called from the main thread.
3471 *
3472 * @sa @ref window_pos
3473 * @sa @ref glfwGetWindowPos
3474 *
3475 * @since Added in version 1.0.
3476 * @glfw3 Added window handle parameter.
3477 *
3478 * @ingroup window
3479 */
3480GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
3481
3482/*! @brief Retrieves the size of the content area of the specified window.
3483 *
3484 * This function retrieves the size, in screen coordinates, of the content area
3485 * of the specified window. If you wish to retrieve the size of the
3486 * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
3487 *
3488 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3489 * non-`NULL` size arguments will be set to zero.
3490 *
3491 * @param[in] window The window whose size to retrieve.
3492 * @param[out] width Where to store the width, in screen coordinates, of the
3493 * content area, or `NULL`.
3494 * @param[out] height Where to store the height, in screen coordinates, of the
3495 * content area, or `NULL`.
3496 *
3497 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3498 * GLFW_PLATFORM_ERROR.
3499 *
3500 * @thread_safety This function must only be called from the main thread.
3501 *
3502 * @sa @ref window_size
3503 * @sa @ref glfwSetWindowSize
3504 *
3505 * @since Added in version 1.0.
3506 * @glfw3 Added window handle parameter.
3507 *
3508 * @ingroup window
3509 */
3510GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
3511
3512/*! @brief Sets the size limits of the specified window.
3513 *
3514 * This function sets the size limits of the content area of the specified
3515 * window. If the window is full screen, the size limits only take effect
3516 * once it is made windowed. If the window is not resizable, this function
3517 * does nothing.
3518 *
3519 * The size limits are applied immediately to a windowed mode window and may
3520 * cause it to be resized.
3521 *
3522 * The maximum dimensions must be greater than or equal to the minimum
3523 * dimensions and all must be greater than or equal to zero.
3524 *
3525 * @param[in] window The window to set limits for.
3526 * @param[in] minwidth The minimum width, in screen coordinates, of the content
3527 * area, or `GLFW_DONT_CARE`.
3528 * @param[in] minheight The minimum height, in screen coordinates, of the
3529 * content area, or `GLFW_DONT_CARE`.
3530 * @param[in] maxwidth The maximum width, in screen coordinates, of the content
3531 * area, or `GLFW_DONT_CARE`.
3532 * @param[in] maxheight The maximum height, in screen coordinates, of the
3533 * content area, or `GLFW_DONT_CARE`.
3534 *
3535 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3536 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3537 *
3538 * @remark If you set size limits and an aspect ratio that conflict, the
3539 * results are undefined.
3540 *
3541 * @remark @wayland The size limits will not be applied until the window is
3542 * actually resized, either by the user or by the compositor.
3543 *
3544 * @thread_safety This function must only be called from the main thread.
3545 *
3546 * @sa @ref window_sizelimits
3547 * @sa @ref glfwSetWindowAspectRatio
3548 *
3549 * @since Added in version 3.2.
3550 *
3551 * @ingroup window
3552 */
3553GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
3554
3555/*! @brief Sets the aspect ratio of the specified window.
3556 *
3557 * This function sets the required aspect ratio of the content area of the
3558 * specified window. If the window is full screen, the aspect ratio only takes
3559 * effect once it is made windowed. If the window is not resizable, this
3560 * function does nothing.
3561 *
3562 * The aspect ratio is specified as a numerator and a denominator and both
3563 * values must be greater than zero. For example, the common 16:9 aspect ratio
3564 * is specified as 16 and 9, respectively.
3565 *
3566 * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
3567 * ratio limit is disabled.
3568 *
3569 * The aspect ratio is applied immediately to a windowed mode window and may
3570 * cause it to be resized.
3571 *
3572 * @param[in] window The window to set limits for.
3573 * @param[in] numer The numerator of the desired aspect ratio, or
3574 * `GLFW_DONT_CARE`.
3575 * @param[in] denom The denominator of the desired aspect ratio, or
3576 * `GLFW_DONT_CARE`.
3577 *
3578 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3579 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3580 *
3581 * @remark If you set size limits and an aspect ratio that conflict, the
3582 * results are undefined.
3583 *
3584 * @remark @wayland The aspect ratio will not be applied until the window is
3585 * actually resized, either by the user or by the compositor.
3586 *
3587 * @thread_safety This function must only be called from the main thread.
3588 *
3589 * @sa @ref window_sizelimits
3590 * @sa @ref glfwSetWindowSizeLimits
3591 *
3592 * @since Added in version 3.2.
3593 *
3594 * @ingroup window
3595 */
3596GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
3597
3598/*! @brief Sets the size of the content area of the specified window.
3599 *
3600 * This function sets the size, in screen coordinates, of the content area of
3601 * the specified window.
3602 *
3603 * For full screen windows, this function updates the resolution of its desired
3604 * video mode and switches to the video mode closest to it, without affecting
3605 * the window's context. As the context is unaffected, the bit depths of the
3606 * framebuffer remain unchanged.
3607 *
3608 * If you wish to update the refresh rate of the desired video mode in addition
3609 * to its resolution, see @ref glfwSetWindowMonitor.
3610 *
3611 * The window manager may put limits on what sizes are allowed. GLFW cannot
3612 * and should not override these limits.
3613 *
3614 * @param[in] window The window to resize.
3615 * @param[in] width The desired width, in screen coordinates, of the window
3616 * content area.
3617 * @param[in] height The desired height, in screen coordinates, of the window
3618 * content area.
3619 *
3620 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3621 * GLFW_PLATFORM_ERROR.
3622 *
3623 * @thread_safety This function must only be called from the main thread.
3624 *
3625 * @sa @ref window_size
3626 * @sa @ref glfwGetWindowSize
3627 * @sa @ref glfwSetWindowMonitor
3628 *
3629 * @since Added in version 1.0.
3630 * @glfw3 Added window handle parameter.
3631 *
3632 * @ingroup window
3633 */
3634GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
3635
3636/*! @brief Retrieves the size of the framebuffer of the specified window.
3637 *
3638 * This function retrieves the size, in pixels, of the framebuffer of the
3639 * specified window. If you wish to retrieve the size of the window in screen
3640 * coordinates, see @ref glfwGetWindowSize.
3641 *
3642 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3643 * non-`NULL` size arguments will be set to zero.
3644 *
3645 * @param[in] window The window whose framebuffer to query.
3646 * @param[out] width Where to store the width, in pixels, of the framebuffer,
3647 * or `NULL`.
3648 * @param[out] height Where to store the height, in pixels, of the framebuffer,
3649 * or `NULL`.
3650 *
3651 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3652 * GLFW_PLATFORM_ERROR.
3653 *
3654 * @thread_safety This function must only be called from the main thread.
3655 *
3656 * @sa @ref window_fbsize
3657 * @sa @ref glfwSetFramebufferSizeCallback
3658 *
3659 * @since Added in version 3.0.
3660 *
3661 * @ingroup window
3662 */
3663GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
3664
3665/*! @brief Retrieves the size of the frame of the window.
3666 *
3667 * This function retrieves the size, in screen coordinates, of each edge of the
3668 * frame of the specified window. This size includes the title bar, if the
3669 * window has one. The size of the frame may vary depending on the
3670 * [window-related hints](@ref window_hints_wnd) used to create it.
3671 *
3672 * Because this function retrieves the size of each window frame edge and not
3673 * the offset along a particular coordinate axis, the retrieved values will
3674 * always be zero or positive.
3675 *
3676 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3677 * non-`NULL` size arguments will be set to zero.
3678 *
3679 * @param[in] window The window whose frame size to query.
3680 * @param[out] left Where to store the size, in screen coordinates, of the left
3681 * edge of the window frame, or `NULL`.
3682 * @param[out] top Where to store the size, in screen coordinates, of the top
3683 * edge of the window frame, or `NULL`.
3684 * @param[out] right Where to store the size, in screen coordinates, of the
3685 * right edge of the window frame, or `NULL`.
3686 * @param[out] bottom Where to store the size, in screen coordinates, of the
3687 * bottom edge of the window frame, or `NULL`.
3688 *
3689 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3690 * GLFW_PLATFORM_ERROR.
3691 *
3692 * @thread_safety This function must only be called from the main thread.
3693 *
3694 * @sa @ref window_size
3695 *
3696 * @since Added in version 3.1.
3697 *
3698 * @ingroup window
3699 */
3700GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
3701
3702/*! @brief Retrieves the content scale for the specified window.
3703 *
3704 * This function retrieves the content scale for the specified window. The
3705 * content scale is the ratio between the current DPI and the platform's
3706 * default DPI. This is especially important for text and any UI elements. If
3707 * the pixel dimensions of your UI scaled by this look appropriate on your
3708 * machine then it should appear at a reasonable size on other machines
3709 * regardless of their DPI and scaling settings. This relies on the system DPI
3710 * and scaling settings being somewhat correct.
3711 *
3712 * On platforms where each monitors can have its own content scale, the window
3713 * content scale will depend on which monitor the system considers the window
3714 * to be on.
3715 *
3716 * @param[in] window The window to query.
3717 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
3718 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
3719 *
3720 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3721 * GLFW_PLATFORM_ERROR.
3722 *
3723 * @thread_safety This function must only be called from the main thread.
3724 *
3725 * @sa @ref window_scale
3726 * @sa @ref glfwSetWindowContentScaleCallback
3727 * @sa @ref glfwGetMonitorContentScale
3728 *
3729 * @since Added in version 3.3.
3730 *
3731 * @ingroup window
3732 */
3733GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
3734
3735/*! @brief Returns the opacity of the whole window.
3736 *
3737 * This function returns the opacity of the window, including any decorations.
3738 *
3739 * The opacity (or alpha) value is a positive finite number between zero and
3740 * one, where zero is fully transparent and one is fully opaque. If the system
3741 * does not support whole window transparency, this function always returns one.
3742 *
3743 * The initial opacity value for newly created windows is one.
3744 *
3745 * @param[in] window The window to query.
3746 * @return The opacity value of the specified window.
3747 *
3748 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3749 * GLFW_PLATFORM_ERROR.
3750 *
3751 * @thread_safety This function must only be called from the main thread.
3752 *
3753 * @sa @ref window_transparency
3754 * @sa @ref glfwSetWindowOpacity
3755 *
3756 * @since Added in version 3.3.
3757 *
3758 * @ingroup window
3759 */
3760GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
3761
3762/*! @brief Sets the opacity of the whole window.
3763 *
3764 * This function sets the opacity of the window, including any decorations.
3765 *
3766 * The opacity (or alpha) value is a positive finite number between zero and
3767 * one, where zero is fully transparent and one is fully opaque.
3768 *
3769 * The initial opacity value for newly created windows is one.
3770 *
3771 * A window created with framebuffer transparency may not use whole window
3772 * transparency. The results of doing this are undefined.
3773 *
3774 * @param[in] window The window to set the opacity for.
3775 * @param[in] opacity The desired opacity of the specified window.
3776 *
3777 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3778 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3779 *
3780 * @remark @wayland There is no way to set an opacity factor for a window.
3781 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
3782 *
3783 * @thread_safety This function must only be called from the main thread.
3784 *
3785 * @sa @ref window_transparency
3786 * @sa @ref glfwGetWindowOpacity
3787 *
3788 * @since Added in version 3.3.
3789 *
3790 * @ingroup window
3791 */
3792GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
3793
3794/*! @brief Iconifies the specified window.
3795 *
3796 * This function iconifies (minimizes) the specified window if it was
3797 * previously restored. If the window is already iconified, this function does
3798 * nothing.
3799 *
3800 * If the specified window is a full screen window, GLFW restores the original
3801 * video mode of the monitor. The window's desired video mode is set again
3802 * when the window is restored.
3803 *
3804 * @param[in] window The window to iconify.
3805 *
3806 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3807 * GLFW_PLATFORM_ERROR.
3808 *
3809 * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
3810 * be able to restore it. This is a design decision of the xdg-shell
3811 * protocol.
3812 *
3813 * @thread_safety This function must only be called from the main thread.
3814 *
3815 * @sa @ref window_iconify
3816 * @sa @ref glfwRestoreWindow
3817 * @sa @ref glfwMaximizeWindow
3818 *
3819 * @since Added in version 2.1.
3820 * @glfw3 Added window handle parameter.
3821 *
3822 * @ingroup window
3823 */
3824GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
3825
3826/*! @brief Restores the specified window.
3827 *
3828 * This function restores the specified window if it was previously iconified
3829 * (minimized) or maximized. If the window is already restored, this function
3830 * does nothing.
3831 *
3832 * If the specified window is an iconified full screen window, its desired
3833 * video mode is set again for its monitor when the window is restored.
3834 *
3835 * @param[in] window The window to restore.
3836 *
3837 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3838 * GLFW_PLATFORM_ERROR.
3839 *
3840 * @thread_safety This function must only be called from the main thread.
3841 *
3842 * @sa @ref window_iconify
3843 * @sa @ref glfwIconifyWindow
3844 * @sa @ref glfwMaximizeWindow
3845 *
3846 * @since Added in version 2.1.
3847 * @glfw3 Added window handle parameter.
3848 *
3849 * @ingroup window
3850 */
3851GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
3852
3853/*! @brief Maximizes the specified window.
3854 *
3855 * This function maximizes the specified window if it was previously not
3856 * maximized. If the window is already maximized, this function does nothing.
3857 *
3858 * If the specified window is a full screen window, this function does nothing.
3859 *
3860 * @param[in] window The window to maximize.
3861 *
3862 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3863 * GLFW_PLATFORM_ERROR.
3864 *
3865 * @par Thread Safety
3866 * This function may only be called from the main thread.
3867 *
3868 * @sa @ref window_iconify
3869 * @sa @ref glfwIconifyWindow
3870 * @sa @ref glfwRestoreWindow
3871 *
3872 * @since Added in GLFW 3.2.
3873 *
3874 * @ingroup window
3875 */
3876GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
3877
3878/*! @brief Makes the specified window visible.
3879 *
3880 * This function makes the specified window visible if it was previously
3881 * hidden. If the window is already visible or is in full screen mode, this
3882 * function does nothing.
3883 *
3884 * By default, windowed mode windows are focused when shown
3885 * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
3886 * to change this behavior for all newly created windows, or change the
3887 * behavior for an existing window with @ref glfwSetWindowAttrib.
3888 *
3889 * @param[in] window The window to make visible.
3890 *
3891 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3892 * GLFW_PLATFORM_ERROR.
3893 *
3894 * @remark @wayland Because Wayland wants every frame of the desktop to be
3895 * complete, this function does not immediately make the window visible.
3896 * Instead it will become visible the next time the window framebuffer is
3897 * updated after this call.
3898 *
3899 * @thread_safety This function must only be called from the main thread.
3900 *
3901 * @sa @ref window_hide
3902 * @sa @ref glfwHideWindow
3903 *
3904 * @since Added in version 3.0.
3905 *
3906 * @ingroup window
3907 */
3908GLFWAPI void glfwShowWindow(GLFWwindow* window);
3909
3910/*! @brief Hides the specified window.
3911 *
3912 * This function hides the specified window if it was previously visible. If
3913 * the window is already hidden or is in full screen mode, this function does
3914 * nothing.
3915 *
3916 * @param[in] window The window to hide.
3917 *
3918 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3919 * GLFW_PLATFORM_ERROR.
3920 *
3921 * @thread_safety This function must only be called from the main thread.
3922 *
3923 * @sa @ref window_hide
3924 * @sa @ref glfwShowWindow
3925 *
3926 * @since Added in version 3.0.
3927 *
3928 * @ingroup window
3929 */
3930GLFWAPI void glfwHideWindow(GLFWwindow* window);
3931
3932/*! @brief Brings the specified window to front and sets input focus.
3933 *
3934 * This function brings the specified window to front and sets input focus.
3935 * The window should already be visible and not iconified.
3936 *
3937 * By default, both windowed and full screen mode windows are focused when
3938 * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
3939 * disable this behavior.
3940 *
3941 * Also by default, windowed mode windows are focused when shown
3942 * with @ref glfwShowWindow. Set the
3943 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
3944 *
3945 * __Do not use this function__ to steal focus from other applications unless
3946 * you are certain that is what the user wants. Focus stealing can be
3947 * extremely disruptive.
3948 *
3949 * For a less disruptive way of getting the user's attention, see
3950 * [attention requests](@ref window_attention).
3951 *
3952 * @param[in] window The window to give input focus.
3953 *
3954 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3955 * GLFW_PLATFORM_ERROR.
3956 *
3957 * @remark @wayland The compositor will likely ignore focus requests unless
3958 * another window created by the same application already has input focus.
3959 *
3960 * @thread_safety This function must only be called from the main thread.
3961 *
3962 * @sa @ref window_focus
3963 * @sa @ref window_attention
3964 *
3965 * @since Added in version 3.2.
3966 *
3967 * @ingroup window
3968 */
3969GLFWAPI void glfwFocusWindow(GLFWwindow* window);
3970
3971/*! @brief Requests user attention to the specified window.
3972 *
3973 * This function requests user attention to the specified window. On
3974 * platforms where this is not supported, attention is requested to the
3975 * application as a whole.
3976 *
3977 * Once the user has given attention, usually by focusing the window or
3978 * application, the system will end the request automatically.
3979 *
3980 * @param[in] window The window to request attention to.
3981 *
3982 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3983 * GLFW_PLATFORM_ERROR.
3984 *
3985 * @remark @macos Attention is requested to the application as a whole, not the
3986 * specific window.
3987 *
3988 * @thread_safety This function must only be called from the main thread.
3989 *
3990 * @sa @ref window_attention
3991 *
3992 * @since Added in version 3.3.
3993 *
3994 * @ingroup window
3995 */
3996GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
3997
3998/*! @brief Returns the monitor that the window uses for full screen mode.
3999 *
4000 * This function returns the handle of the monitor that the specified window is
4001 * in full screen on.
4002 *
4003 * @param[in] window The window to query.
4004 * @return The monitor, or `NULL` if the window is in windowed mode or an
4005 * [error](@ref error_handling) occurred.
4006 *
4007 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4008 *
4009 * @thread_safety This function must only be called from the main thread.
4010 *
4011 * @sa @ref window_monitor
4012 * @sa @ref glfwSetWindowMonitor
4013 *
4014 * @since Added in version 3.0.
4015 *
4016 * @ingroup window
4017 */
4018GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
4019
4020/*! @brief Sets the mode, monitor, video mode and placement of a window.
4021 *
4022 * This function sets the monitor that the window uses for full screen mode or,
4023 * if the monitor is `NULL`, makes it windowed mode.
4024 *
4025 * When setting a monitor, this function updates the width, height and refresh
4026 * rate of the desired video mode and switches to the video mode closest to it.
4027 * The window position is ignored when setting a monitor.
4028 *
4029 * When the monitor is `NULL`, the position, width and height are used to
4030 * place the window content area. The refresh rate is ignored when no monitor
4031 * is specified.
4032 *
4033 * If you only wish to update the resolution of a full screen window or the
4034 * size of a windowed mode window, see @ref glfwSetWindowSize.
4035 *
4036 * When a window transitions from full screen to windowed mode, this function
4037 * restores any previous window settings such as whether it is decorated,
4038 * floating, resizable, has size or aspect ratio limits, etc.
4039 *
4040 * @param[in] window The window whose monitor, size or video mode to set.
4041 * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
4042 * @param[in] xpos The desired x-coordinate of the upper-left corner of the
4043 * content area.
4044 * @param[in] ypos The desired y-coordinate of the upper-left corner of the
4045 * content area.
4046 * @param[in] width The desired with, in screen coordinates, of the content
4047 * area or video mode.
4048 * @param[in] height The desired height, in screen coordinates, of the content
4049 * area or video mode.
4050 * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
4051 * or `GLFW_DONT_CARE`.
4052 *
4053 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4054 * GLFW_PLATFORM_ERROR.
4055 *
4056 * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
4057 * affected by any resizing or mode switching, although you may need to update
4058 * your viewport if the framebuffer size has changed.
4059 *
4060 * @remark @wayland The desired window position is ignored, as there is no way
4061 * for an application to set this property.
4062 *
4063 * @thread_safety This function must only be called from the main thread.
4064 *
4065 * @sa @ref window_monitor
4066 * @sa @ref window_full_screen
4067 * @sa @ref glfwGetWindowMonitor
4068 * @sa @ref glfwSetWindowSize
4069 *
4070 * @since Added in version 3.2.
4071 *
4072 * @ingroup window
4073 */
4074GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
4075
4076/*! @brief Returns an attribute of the specified window.
4077 *
4078 * This function returns the value of an attribute of the specified window or
4079 * its OpenGL or OpenGL ES context.
4080 *
4081 * @param[in] window The window to query.
4082 * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
4083 * return.
4084 * @return The value of the attribute, or zero if an
4085 * [error](@ref error_handling) occurred.
4086 *
4087 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4088 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4089 *
4090 * @remark Framebuffer related hints are not window attributes. See @ref
4091 * window_attribs_fb for more information.
4092 *
4093 * @remark Zero is a valid value for many window and context related
4094 * attributes so you cannot use a return value of zero as an indication of
4095 * errors. However, this function should not fail as long as it is passed
4096 * valid arguments and the library has been [initialized](@ref intro_init).
4097 *
4098 * @remark @wayland The Wayland protocol provides no way to check whether a
4099 * window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`.
4100 *
4101 * @thread_safety This function must only be called from the main thread.
4102 *
4103 * @sa @ref window_attribs
4104 * @sa @ref glfwSetWindowAttrib
4105 *
4106 * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
4107 * `glfwGetGLVersion`.
4108 *
4109 * @ingroup window
4110 */
4111GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
4112
4113/*! @brief Sets an attribute of the specified window.
4114 *
4115 * This function sets the value of an attribute of the specified window.
4116 *
4117 * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
4118 * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
4119 * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
4120 * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
4121 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
4122 * [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
4123 *
4124 * Some of these attributes are ignored for full screen windows. The new
4125 * value will take effect if the window is later made windowed.
4126 *
4127 * Some of these attributes are ignored for windowed mode windows. The new
4128 * value will take effect if the window is later made full screen.
4129 *
4130 * @param[in] window The window to set the attribute for.
4131 * @param[in] attrib A supported window attribute.
4132 * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
4133 *
4134 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4135 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
4136 * GLFW_FEATURE_UNAVAILABLE (see remarks).
4137 *
4138 * @remark Calling @ref glfwGetWindowAttrib will always return the latest
4139 * value, even if that value is ignored by the current mode of the window.
4140 *
4141 * @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is
4142 * not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE.
4143 *
4144 * @thread_safety This function must only be called from the main thread.
4145 *
4146 * @sa @ref window_attribs
4147 * @sa @ref glfwGetWindowAttrib
4148 *
4149 * @since Added in version 3.3.
4150 *
4151 * @ingroup window
4152 */
4153GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
4154
4155/*! @brief Sets the user pointer of the specified window.
4156 *
4157 * This function sets the user-defined pointer of the specified window. The
4158 * current value is retained until the window is destroyed. The initial value
4159 * is `NULL`.
4160 *
4161 * @param[in] window The window whose pointer to set.
4162 * @param[in] pointer The new value.
4163 *
4164 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4165 *
4166 * @thread_safety This function may be called from any thread. Access is not
4167 * synchronized.
4168 *
4169 * @sa @ref window_userptr
4170 * @sa @ref glfwGetWindowUserPointer
4171 *
4172 * @since Added in version 3.0.
4173 *
4174 * @ingroup window
4175 */
4176GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
4177
4178/*! @brief Returns the user pointer of the specified window.
4179 *
4180 * This function returns the current value of the user-defined pointer of the
4181 * specified window. The initial value is `NULL`.
4182 *
4183 * @param[in] window The window whose pointer to return.
4184 *
4185 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4186 *
4187 * @thread_safety This function may be called from any thread. Access is not
4188 * synchronized.
4189 *
4190 * @sa @ref window_userptr
4191 * @sa @ref glfwSetWindowUserPointer
4192 *
4193 * @since Added in version 3.0.
4194 *
4195 * @ingroup window
4196 */
4197GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
4198
4199/*! @brief Sets the position callback for the specified window.
4200 *
4201 * This function sets the position callback of the specified window, which is
4202 * called when the window is moved. The callback is provided with the
4203 * position, in screen coordinates, of the upper-left corner of the content
4204 * area of the window.
4205 *
4206 * @param[in] window The window whose callback to set.
4207 * @param[in] callback The new callback, or `NULL` to remove the currently set
4208 * callback.
4209 * @return The previously set callback, or `NULL` if no callback was set or the
4210 * library had not been [initialized](@ref intro_init).
4211 *
4212 * @callback_signature
4213 * @code
4214 * void function_name(GLFWwindow* window, int xpos, int ypos)
4215 * @endcode
4216 * For more information about the callback parameters, see the
4217 * [function pointer type](@ref GLFWwindowposfun).
4218 *
4219 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4220 *
4221 * @remark @wayland This callback will never be called, as there is no way for
4222 * an application to know its global position.
4223 *
4224 * @thread_safety This function must only be called from the main thread.
4225 *
4226 * @sa @ref window_pos
4227 *
4228 * @since Added in version 3.0.
4229 *
4230 * @ingroup window
4231 */
4232GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
4233
4234/*! @brief Sets the size callback for the specified window.
4235 *
4236 * This function sets the size callback of the specified window, which is
4237 * called when the window is resized. The callback is provided with the size,
4238 * in screen coordinates, of the content area of the window.
4239 *
4240 * @param[in] window The window whose callback to set.
4241 * @param[in] callback The new callback, or `NULL` to remove the currently set
4242 * callback.
4243 * @return The previously set callback, or `NULL` if no callback was set or the
4244 * library had not been [initialized](@ref intro_init).
4245 *
4246 * @callback_signature
4247 * @code
4248 * void function_name(GLFWwindow* window, int width, int height)
4249 * @endcode
4250 * For more information about the callback parameters, see the
4251 * [function pointer type](@ref GLFWwindowsizefun).
4252 *
4253 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4254 *
4255 * @thread_safety This function must only be called from the main thread.
4256 *
4257 * @sa @ref window_size
4258 *
4259 * @since Added in version 1.0.
4260 * @glfw3 Added window handle parameter and return value.
4261 *
4262 * @ingroup window
4263 */
4264GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
4265
4266/*! @brief Sets the close callback for the specified window.
4267 *
4268 * This function sets the close callback of the specified window, which is
4269 * called when the user attempts to close the window, for example by clicking
4270 * the close widget in the title bar.
4271 *
4272 * The close flag is set before this callback is called, but you can modify it
4273 * at any time with @ref glfwSetWindowShouldClose.
4274 *
4275 * The close callback is not triggered by @ref glfwDestroyWindow.
4276 *
4277 * @param[in] window The window whose callback to set.
4278 * @param[in] callback The new callback, or `NULL` to remove the currently set
4279 * callback.
4280 * @return The previously set callback, or `NULL` if no callback was set or the
4281 * library had not been [initialized](@ref intro_init).
4282 *
4283 * @callback_signature
4284 * @code
4285 * void function_name(GLFWwindow* window)
4286 * @endcode
4287 * For more information about the callback parameters, see the
4288 * [function pointer type](@ref GLFWwindowclosefun).
4289 *
4290 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4291 *
4292 * @remark @macos Selecting Quit from the application menu will trigger the
4293 * close callback for all windows.
4294 *
4295 * @thread_safety This function must only be called from the main thread.
4296 *
4297 * @sa @ref window_close
4298 *
4299 * @since Added in version 2.5.
4300 * @glfw3 Added window handle parameter and return value.
4301 *
4302 * @ingroup window
4303 */
4304GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
4305
4306/*! @brief Sets the refresh callback for the specified window.
4307 *
4308 * This function sets the refresh callback of the specified window, which is
4309 * called when the content area of the window needs to be redrawn, for example
4310 * if the window has been exposed after having been covered by another window.
4311 *
4312 * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
4313 * the window contents are saved off-screen, this callback may be called only
4314 * very infrequently or never at all.
4315 *
4316 * @param[in] window The window whose callback to set.
4317 * @param[in] callback The new callback, or `NULL` to remove the currently set
4318 * callback.
4319 * @return The previously set callback, or `NULL` if no callback was set or the
4320 * library had not been [initialized](@ref intro_init).
4321 *
4322 * @callback_signature
4323 * @code
4324 * void function_name(GLFWwindow* window);
4325 * @endcode
4326 * For more information about the callback parameters, see the
4327 * [function pointer type](@ref GLFWwindowrefreshfun).
4328 *
4329 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4330 *
4331 * @thread_safety This function must only be called from the main thread.
4332 *
4333 * @sa @ref window_refresh
4334 *
4335 * @since Added in version 2.5.
4336 * @glfw3 Added window handle parameter and return value.
4337 *
4338 * @ingroup window
4339 */
4340GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
4341
4342/*! @brief Sets the focus callback for the specified window.
4343 *
4344 * This function sets the focus callback of the specified window, which is
4345 * called when the window gains or loses input focus.
4346 *
4347 * After the focus callback is called for a window that lost input focus,
4348 * synthetic key and mouse button release events will be generated for all such
4349 * that had been pressed. For more information, see @ref glfwSetKeyCallback
4350 * and @ref glfwSetMouseButtonCallback.
4351 *
4352 * @param[in] window The window whose callback to set.
4353 * @param[in] callback The new callback, or `NULL` to remove the currently set
4354 * callback.
4355 * @return The previously set callback, or `NULL` if no callback was set or the
4356 * library had not been [initialized](@ref intro_init).
4357 *
4358 * @callback_signature
4359 * @code
4360 * void function_name(GLFWwindow* window, int focused)
4361 * @endcode
4362 * For more information about the callback parameters, see the
4363 * [function pointer type](@ref GLFWwindowfocusfun).
4364 *
4365 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4366 *
4367 * @thread_safety This function must only be called from the main thread.
4368 *
4369 * @sa @ref window_focus
4370 *
4371 * @since Added in version 3.0.
4372 *
4373 * @ingroup window
4374 */
4375GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
4376
4377/*! @brief Sets the iconify callback for the specified window.
4378 *
4379 * This function sets the iconification callback of the specified window, which
4380 * is called when the window is iconified or restored.
4381 *
4382 * @param[in] window The window whose callback to set.
4383 * @param[in] callback The new callback, or `NULL` to remove the currently set
4384 * callback.
4385 * @return The previously set callback, or `NULL` if no callback was set or the
4386 * library had not been [initialized](@ref intro_init).
4387 *
4388 * @callback_signature
4389 * @code
4390 * void function_name(GLFWwindow* window, int iconified)
4391 * @endcode
4392 * For more information about the callback parameters, see the
4393 * [function pointer type](@ref GLFWwindowiconifyfun).
4394 *
4395 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4396 *
4397 * @thread_safety This function must only be called from the main thread.
4398 *
4399 * @sa @ref window_iconify
4400 *
4401 * @since Added in version 3.0.
4402 *
4403 * @ingroup window
4404 */
4405GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
4406
4407/*! @brief Sets the maximize callback for the specified window.
4408 *
4409 * This function sets the maximization callback of the specified window, which
4410 * is called when the window is maximized or restored.
4411 *
4412 * @param[in] window The window whose callback to set.
4413 * @param[in] callback The new callback, or `NULL` to remove the currently set
4414 * callback.
4415 * @return The previously set callback, or `NULL` if no callback was set or the
4416 * library had not been [initialized](@ref intro_init).
4417 *
4418 * @callback_signature
4419 * @code
4420 * void function_name(GLFWwindow* window, int maximized)
4421 * @endcode
4422 * For more information about the callback parameters, see the
4423 * [function pointer type](@ref GLFWwindowmaximizefun).
4424 *
4425 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4426 *
4427 * @thread_safety This function must only be called from the main thread.
4428 *
4429 * @sa @ref window_maximize
4430 *
4431 * @since Added in version 3.3.
4432 *
4433 * @ingroup window
4434 */
4435GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
4436
4437/*! @brief Sets the framebuffer resize callback for the specified window.
4438 *
4439 * This function sets the framebuffer resize callback of the specified window,
4440 * which is called when the framebuffer of the specified window is resized.
4441 *
4442 * @param[in] window The window whose callback to set.
4443 * @param[in] callback The new callback, or `NULL` to remove the currently set
4444 * callback.
4445 * @return The previously set callback, or `NULL` if no callback was set or the
4446 * library had not been [initialized](@ref intro_init).
4447 *
4448 * @callback_signature
4449 * @code
4450 * void function_name(GLFWwindow* window, int width, int height)
4451 * @endcode
4452 * For more information about the callback parameters, see the
4453 * [function pointer type](@ref GLFWframebuffersizefun).
4454 *
4455 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4456 *
4457 * @thread_safety This function must only be called from the main thread.
4458 *
4459 * @sa @ref window_fbsize
4460 *
4461 * @since Added in version 3.0.
4462 *
4463 * @ingroup window
4464 */
4465GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
4466
4467/*! @brief Sets the window content scale callback for the specified window.
4468 *
4469 * This function sets the window content scale callback of the specified window,
4470 * which is called when the content scale of the specified window changes.
4471 *
4472 * @param[in] window The window whose callback to set.
4473 * @param[in] callback The new callback, or `NULL` to remove the currently set
4474 * callback.
4475 * @return The previously set callback, or `NULL` if no callback was set or the
4476 * library had not been [initialized](@ref intro_init).
4477 *
4478 * @callback_signature
4479 * @code
4480 * void function_name(GLFWwindow* window, float xscale, float yscale)
4481 * @endcode
4482 * For more information about the callback parameters, see the
4483 * [function pointer type](@ref GLFWwindowcontentscalefun).
4484 *
4485 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4486 *
4487 * @thread_safety This function must only be called from the main thread.
4488 *
4489 * @sa @ref window_scale
4490 * @sa @ref glfwGetWindowContentScale
4491 *
4492 * @since Added in version 3.3.
4493 *
4494 * @ingroup window
4495 */
4496GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
4497
4498/*! @brief Processes all pending events.
4499 *
4500 * This function processes only those events that are already in the event
4501 * queue and then returns immediately. Processing events will cause the window
4502 * and input callbacks associated with those events to be called.
4503 *
4504 * On some platforms, a window move, resize or menu operation will cause event
4505 * processing to block. This is due to how event processing is designed on
4506 * those platforms. You can use the
4507 * [window refresh callback](@ref window_refresh) to redraw the contents of
4508 * your window when necessary during such operations.
4509 *
4510 * Do not assume that callbacks you set will _only_ be called in response to
4511 * event processing functions like this one. While it is necessary to poll for
4512 * events, window systems that require GLFW to register callbacks of its own
4513 * can pass events to GLFW in response to many window system function calls.
4514 * GLFW will pass those events on to the application callbacks before
4515 * returning.
4516 *
4517 * Event processing is not required for joystick input to work.
4518 *
4519 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4520 * GLFW_PLATFORM_ERROR.
4521 *
4522 * @reentrancy This function must not be called from a callback.
4523 *
4524 * @thread_safety This function must only be called from the main thread.
4525 *
4526 * @sa @ref events
4527 * @sa @ref glfwWaitEvents
4528 * @sa @ref glfwWaitEventsTimeout
4529 *
4530 * @since Added in version 1.0.
4531 *
4532 * @ingroup window
4533 */
4534GLFWAPI void glfwPollEvents(void);
4535
4536/*! @brief Waits until events are queued and processes them.
4537 *
4538 * This function puts the calling thread to sleep until at least one event is
4539 * available in the event queue. Once one or more events are available,
4540 * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
4541 * are processed and the function then returns immediately. Processing events
4542 * will cause the window and input callbacks associated with those events to be
4543 * called.
4544 *
4545 * Since not all events are associated with callbacks, this function may return
4546 * without a callback having been called even if you are monitoring all
4547 * callbacks.
4548 *
4549 * On some platforms, a window move, resize or menu operation will cause event
4550 * processing to block. This is due to how event processing is designed on
4551 * those platforms. You can use the
4552 * [window refresh callback](@ref window_refresh) to redraw the contents of
4553 * your window when necessary during such operations.
4554 *
4555 * Do not assume that callbacks you set will _only_ be called in response to
4556 * event processing functions like this one. While it is necessary to poll for
4557 * events, window systems that require GLFW to register callbacks of its own
4558 * can pass events to GLFW in response to many window system function calls.
4559 * GLFW will pass those events on to the application callbacks before
4560 * returning.
4561 *
4562 * Event processing is not required for joystick input to work.
4563 *
4564 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4565 * GLFW_PLATFORM_ERROR.
4566 *
4567 * @reentrancy This function must not be called from a callback.
4568 *
4569 * @thread_safety This function must only be called from the main thread.
4570 *
4571 * @sa @ref events
4572 * @sa @ref glfwPollEvents
4573 * @sa @ref glfwWaitEventsTimeout
4574 *
4575 * @since Added in version 2.5.
4576 *
4577 * @ingroup window
4578 */
4579GLFWAPI void glfwWaitEvents(void);
4580
4581/*! @brief Waits with timeout until events are queued and processes them.
4582 *
4583 * This function puts the calling thread to sleep until at least one event is
4584 * available in the event queue, or until the specified timeout is reached. If
4585 * one or more events are available, it behaves exactly like @ref
4586 * glfwPollEvents, i.e. the events in the queue are processed and the function
4587 * then returns immediately. Processing events will cause the window and input
4588 * callbacks associated with those events to be called.
4589 *
4590 * The timeout value must be a positive finite number.
4591 *
4592 * Since not all events are associated with callbacks, this function may return
4593 * without a callback having been called even if you are monitoring all
4594 * callbacks.
4595 *
4596 * On some platforms, a window move, resize or menu operation will cause event
4597 * processing to block. This is due to how event processing is designed on
4598 * those platforms. You can use the
4599 * [window refresh callback](@ref window_refresh) to redraw the contents of
4600 * your window when necessary during such operations.
4601 *
4602 * Do not assume that callbacks you set will _only_ be called in response to
4603 * event processing functions like this one. While it is necessary to poll for
4604 * events, window systems that require GLFW to register callbacks of its own
4605 * can pass events to GLFW in response to many window system function calls.
4606 * GLFW will pass those events on to the application callbacks before
4607 * returning.
4608 *
4609 * Event processing is not required for joystick input to work.
4610 *
4611 * @param[in] timeout The maximum amount of time, in seconds, to wait.
4612 *
4613 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4614 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
4615 *
4616 * @reentrancy This function must not be called from a callback.
4617 *
4618 * @thread_safety This function must only be called from the main thread.
4619 *
4620 * @sa @ref events
4621 * @sa @ref glfwPollEvents
4622 * @sa @ref glfwWaitEvents
4623 *
4624 * @since Added in version 3.2.
4625 *
4626 * @ingroup window
4627 */
4628GLFWAPI void glfwWaitEventsTimeout(double timeout);
4629
4630/*! @brief Posts an empty event to the event queue.
4631 *
4632 * This function posts an empty event from the current thread to the event
4633 * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
4634 *
4635 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4636 * GLFW_PLATFORM_ERROR.
4637 *
4638 * @thread_safety This function may be called from any thread.
4639 *
4640 * @sa @ref events
4641 * @sa @ref glfwWaitEvents
4642 * @sa @ref glfwWaitEventsTimeout
4643 *
4644 * @since Added in version 3.1.
4645 *
4646 * @ingroup window
4647 */
4648GLFWAPI void glfwPostEmptyEvent(void);
4649
4650/*! @brief Returns the value of an input option for the specified window.
4651 *
4652 * This function returns the value of an input option for the specified window.
4653 * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
4654 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
4655 * @ref GLFW_RAW_MOUSE_MOTION.
4656 *
4657 * @param[in] window The window to query.
4658 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
4659 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4660 * `GLFW_RAW_MOUSE_MOTION`.
4661 *
4662 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4663 * GLFW_INVALID_ENUM.
4664 *
4665 * @thread_safety This function must only be called from the main thread.
4666 *
4667 * @sa @ref glfwSetInputMode
4668 *
4669 * @since Added in version 3.0.
4670 *
4671 * @ingroup input
4672 */
4673GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
4674
4675/*! @brief Sets an input option for the specified window.
4676 *
4677 * This function sets an input mode option for the specified window. The mode
4678 * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
4679 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
4680 * @ref GLFW_RAW_MOUSE_MOTION.
4681 *
4682 * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
4683 * modes:
4684 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
4685 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
4686 * content area of the window but does not restrict the cursor from leaving.
4687 * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
4688 * and unlimited cursor movement. This is useful for implementing for
4689 * example 3D camera controls.
4690 * - `GLFW_CURSOR_CAPTURED` makes the cursor visible and confines it to the
4691 * content area of the window.
4692 *
4693 * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
4694 * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
4695 * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
4696 * the next time it is called even if the key had been released before the
4697 * call. This is useful when you are only interested in whether keys have been
4698 * pressed but not when or in which order.
4699 *
4700 * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
4701 * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
4702 * If sticky mouse buttons are enabled, a mouse button press will ensure that
4703 * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
4704 * if the mouse button had been released before the call. This is useful when
4705 * you are only interested in whether mouse buttons have been pressed but not
4706 * when or in which order.
4707 *
4708 * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
4709 * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
4710 * callbacks that receive modifier bits will also have the @ref
4711 * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
4712 * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
4713 *
4714 * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
4715 * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
4716 * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
4717 * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
4718 * glfwRawMouseMotionSupported to check for support.
4719 *
4720 * @param[in] window The window whose input mode to set.
4721 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
4722 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4723 * `GLFW_RAW_MOUSE_MOTION`.
4724 * @param[in] value The new value of the specified input mode.
4725 *
4726 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4727 * GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
4728 * GLFW_FEATURE_UNAVAILABLE (see above).
4729 *
4730 * @thread_safety This function must only be called from the main thread.
4731 *
4732 * @sa @ref glfwGetInputMode
4733 *
4734 * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
4735 *
4736 * @ingroup input
4737 */
4738GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
4739
4740/*! @brief Returns whether raw mouse motion is supported.
4741 *
4742 * This function returns whether raw mouse motion is supported on the current
4743 * system. This status does not change after GLFW has been initialized so you
4744 * only need to check this once. If you attempt to enable raw motion on
4745 * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
4746 *
4747 * Raw mouse motion is closer to the actual motion of the mouse across
4748 * a surface. It is not affected by the scaling and acceleration applied to
4749 * the motion of the desktop cursor. That processing is suitable for a cursor
4750 * while raw motion is better for controlling for example a 3D camera. Because
4751 * of this, raw mouse motion is only provided when the cursor is disabled.
4752 *
4753 * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
4754 * or `GLFW_FALSE` otherwise.
4755 *
4756 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4757 *
4758 * @thread_safety This function must only be called from the main thread.
4759 *
4760 * @sa @ref raw_mouse_motion
4761 * @sa @ref glfwSetInputMode
4762 *
4763 * @since Added in version 3.3.
4764 *
4765 * @ingroup input
4766 */
4767GLFWAPI int glfwRawMouseMotionSupported(void);
4768
4769/*! @brief Returns the layout-specific name of the specified printable key.
4770 *
4771 * This function returns the name of the specified printable key, encoded as
4772 * UTF-8. This is typically the character that key would produce without any
4773 * modifier keys, intended for displaying key bindings to the user. For dead
4774 * keys, it is typically the diacritic it would add to a character.
4775 *
4776 * __Do not use this function__ for [text input](@ref input_char). You will
4777 * break text input for many languages even if it happens to work for yours.
4778 *
4779 * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
4780 * otherwise the scancode is ignored. If you specify a non-printable key, or
4781 * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
4782 * function returns `NULL` but does not emit an error.
4783 *
4784 * This behavior allows you to always pass in the arguments in the
4785 * [key callback](@ref input_key) without modification.
4786 *
4787 * The printable keys are:
4788 * - `GLFW_KEY_APOSTROPHE`
4789 * - `GLFW_KEY_COMMA`
4790 * - `GLFW_KEY_MINUS`
4791 * - `GLFW_KEY_PERIOD`
4792 * - `GLFW_KEY_SLASH`
4793 * - `GLFW_KEY_SEMICOLON`
4794 * - `GLFW_KEY_EQUAL`
4795 * - `GLFW_KEY_LEFT_BRACKET`
4796 * - `GLFW_KEY_RIGHT_BRACKET`
4797 * - `GLFW_KEY_BACKSLASH`
4798 * - `GLFW_KEY_WORLD_1`
4799 * - `GLFW_KEY_WORLD_2`
4800 * - `GLFW_KEY_0` to `GLFW_KEY_9`
4801 * - `GLFW_KEY_A` to `GLFW_KEY_Z`
4802 * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
4803 * - `GLFW_KEY_KP_DECIMAL`
4804 * - `GLFW_KEY_KP_DIVIDE`
4805 * - `GLFW_KEY_KP_MULTIPLY`
4806 * - `GLFW_KEY_KP_SUBTRACT`
4807 * - `GLFW_KEY_KP_ADD`
4808 * - `GLFW_KEY_KP_EQUAL`
4809 *
4810 * Names for printable keys depend on keyboard layout, while names for
4811 * non-printable keys are the same across layouts but depend on the application
4812 * language and should be localized along with other user interface text.
4813 *
4814 * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
4815 * @param[in] scancode The scancode of the key to query.
4816 * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
4817 *
4818 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4819 * GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4820 *
4821 * @remark The contents of the returned string may change when a keyboard
4822 * layout change event is received.
4823 *
4824 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
4825 * should not free it yourself. It is valid until the library is terminated.
4826 *
4827 * @thread_safety This function must only be called from the main thread.
4828 *
4829 * @sa @ref input_key_name
4830 *
4831 * @since Added in version 3.2.
4832 *
4833 * @ingroup input
4834 */
4835GLFWAPI const char* glfwGetKeyName(int key, int scancode);
4836
4837/*! @brief Returns the platform-specific scancode of the specified key.
4838 *
4839 * This function returns the platform-specific scancode of the specified key.
4840 *
4841 * If the specified [key token](@ref keys) corresponds to a physical key not
4842 * supported on the current platform then this method will return `-1`.
4843 * Calling this function with anything other than a key token will return `-1`
4844 * and generate a @ref GLFW_INVALID_ENUM error.
4845 *
4846 * @param[in] key Any [key token](@ref keys).
4847 * @return The platform-specific scancode for the key, or `-1` if the key is
4848 * not supported on the current platform or an [error](@ref error_handling)
4849 * occurred.
4850 *
4851 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4852 * GLFW_INVALID_ENUM.
4853 *
4854 * @thread_safety This function may be called from any thread.
4855 *
4856 * @sa @ref input_key
4857 *
4858 * @since Added in version 3.3.
4859 *
4860 * @ingroup input
4861 */
4862GLFWAPI int glfwGetKeyScancode(int key);
4863
4864/*! @brief Returns the last reported state of a keyboard key for the specified
4865 * window.
4866 *
4867 * This function returns the last state reported for the specified key to the
4868 * specified window. The returned state is one of `GLFW_PRESS` or
4869 * `GLFW_RELEASE`. The action `GLFW_REPEAT` is only reported to the key callback.
4870 *
4871 * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
4872 * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
4873 * that key has already been released.
4874 *
4875 * The key functions deal with physical keys, with [key tokens](@ref keys)
4876 * named after their use on the standard US keyboard layout. If you want to
4877 * input text, use the Unicode character callback instead.
4878 *
4879 * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
4880 * used with this function.
4881 *
4882 * __Do not use this function__ to implement [text input](@ref input_char).
4883 *
4884 * @param[in] window The desired window.
4885 * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
4886 * not a valid key for this function.
4887 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
4888 *
4889 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4890 * GLFW_INVALID_ENUM.
4891 *
4892 * @thread_safety This function must only be called from the main thread.
4893 *
4894 * @sa @ref input_key
4895 *
4896 * @since Added in version 1.0.
4897 * @glfw3 Added window handle parameter.
4898 *
4899 * @ingroup input
4900 */
4901GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
4902
4903/*! @brief Returns the last reported state of a mouse button for the specified
4904 * window.
4905 *
4906 * This function returns the last state reported for the specified mouse button
4907 * to the specified window. The returned state is one of `GLFW_PRESS` or
4908 * `GLFW_RELEASE`.
4909 *
4910 * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
4911 * returns `GLFW_PRESS` the first time you call it for a mouse button that was
4912 * pressed, even if that mouse button has already been released.
4913 *
4914 * @param[in] window The desired window.
4915 * @param[in] button The desired [mouse button](@ref buttons).
4916 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
4917 *
4918 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4919 * GLFW_INVALID_ENUM.
4920 *
4921 * @thread_safety This function must only be called from the main thread.
4922 *
4923 * @sa @ref input_mouse_button
4924 *
4925 * @since Added in version 1.0.
4926 * @glfw3 Added window handle parameter.
4927 *
4928 * @ingroup input
4929 */
4930GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
4931
4932/*! @brief Retrieves the position of the cursor relative to the content area of
4933 * the window.
4934 *
4935 * This function returns the position of the cursor, in screen coordinates,
4936 * relative to the upper-left corner of the content area of the specified
4937 * window.
4938 *
4939 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
4940 * position is unbounded and limited only by the minimum and maximum values of
4941 * a `double`.
4942 *
4943 * The coordinate can be converted to their integer equivalents with the
4944 * `floor` function. Casting directly to an integer type works for positive
4945 * coordinates, but fails for negative ones.
4946 *
4947 * Any or all of the position arguments may be `NULL`. If an error occurs, all
4948 * non-`NULL` position arguments will be set to zero.
4949 *
4950 * @param[in] window The desired window.
4951 * @param[out] xpos Where to store the cursor x-coordinate, relative to the
4952 * left edge of the content area, or `NULL`.
4953 * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
4954 * top edge of the content area, or `NULL`.
4955 *
4956 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4957 * GLFW_PLATFORM_ERROR.
4958 *
4959 * @thread_safety This function must only be called from the main thread.
4960 *
4961 * @sa @ref cursor_pos
4962 * @sa @ref glfwSetCursorPos
4963 *
4964 * @since Added in version 3.0. Replaces `glfwGetMousePos`.
4965 *
4966 * @ingroup input
4967 */
4968GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
4969
4970/*! @brief Sets the position of the cursor, relative to the content area of the
4971 * window.
4972 *
4973 * This function sets the position, in screen coordinates, of the cursor
4974 * relative to the upper-left corner of the content area of the specified
4975 * window. The window must have input focus. If the window does not have
4976 * input focus when this function is called, it fails silently.
4977 *
4978 * __Do not use this function__ to implement things like camera controls. GLFW
4979 * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
4980 * cursor, transparently re-centers it and provides unconstrained cursor
4981 * motion. See @ref glfwSetInputMode for more information.
4982 *
4983 * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
4984 * unconstrained and limited only by the minimum and maximum values of
4985 * a `double`.
4986 *
4987 * @param[in] window The desired window.
4988 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
4989 * content area.
4990 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
4991 * content area.
4992 *
4993 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4994 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
4995 *
4996 * @remark @wayland This function will only work when the cursor mode is
4997 * `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE.
4998 *
4999 * @thread_safety This function must only be called from the main thread.
5000 *
5001 * @sa @ref cursor_pos
5002 * @sa @ref glfwGetCursorPos
5003 *
5004 * @since Added in version 3.0. Replaces `glfwSetMousePos`.
5005 *
5006 * @ingroup input
5007 */
5008GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
5009
5010/*! @brief Creates a custom cursor.
5011 *
5012 * Creates a new custom cursor image that can be set for a window with @ref
5013 * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
5014 * Any remaining cursors are destroyed by @ref glfwTerminate.
5015 *
5016 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
5017 * bits per channel with the red channel first. They are arranged canonically
5018 * as packed sequential rows, starting from the top-left corner.
5019 *
5020 * The cursor hotspot is specified in pixels, relative to the upper-left corner
5021 * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
5022 * points to the right and the Y-axis points down.
5023 *
5024 * @param[in] image The desired cursor image.
5025 * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
5026 * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
5027 * @return The handle of the created cursor, or `NULL` if an
5028 * [error](@ref error_handling) occurred.
5029 *
5030 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5031 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
5032 *
5033 * @pointer_lifetime The specified image data is copied before this function
5034 * returns.
5035 *
5036 * @thread_safety This function must only be called from the main thread.
5037 *
5038 * @sa @ref cursor_object
5039 * @sa @ref glfwDestroyCursor
5040 * @sa @ref glfwCreateStandardCursor
5041 *
5042 * @since Added in version 3.1.
5043 *
5044 * @ingroup input
5045 */
5046GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
5047
5048/*! @brief Creates a cursor with a standard shape.
5049 *
5050 * Returns a cursor with a standard shape, that can be set for a window with
5051 * @ref glfwSetCursor. The images for these cursors come from the system
5052 * cursor theme and their exact appearance will vary between platforms.
5053 *
5054 * Most of these shapes are guaranteed to exist on every supported platform but
5055 * a few may not be present. See the table below for details.
5056 *
5057 * Cursor shape | Windows | macOS | X11 | Wayland
5058 * ------------------------------ | ------- | ----- | ------ | -------
5059 * @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes
5060 * @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes
5061 * @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes
5062 * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes
5063 * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes
5064 * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes
5065 * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
5066 * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
5067 * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes
5068 * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe<sup>2</sup> | Maybe<sup>2</sup>
5069 *
5070 * 1) This uses a private system API and may fail in the future.
5071 *
5072 * 2) This uses a newer standard that not all cursor themes support.
5073 *
5074 * If the requested shape is not available, this function emits a @ref
5075 * GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
5076 *
5077 * @param[in] shape One of the [standard shapes](@ref shapes).
5078 * @return A new cursor ready to use or `NULL` if an
5079 * [error](@ref error_handling) occurred.
5080 *
5081 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5082 * GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
5083 * GLFW_PLATFORM_ERROR.
5084 *
5085 * @thread_safety This function must only be called from the main thread.
5086 *
5087 * @sa @ref cursor_standard
5088 * @sa @ref glfwCreateCursor
5089 *
5090 * @since Added in version 3.1.
5091 *
5092 * @ingroup input
5093 */
5094GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
5095
5096/*! @brief Destroys a cursor.
5097 *
5098 * This function destroys a cursor previously created with @ref
5099 * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
5100 * glfwTerminate.
5101 *
5102 * If the specified cursor is current for any window, that window will be
5103 * reverted to the default cursor. This does not affect the cursor mode.
5104 *
5105 * @param[in] cursor The cursor object to destroy.
5106 *
5107 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5108 * GLFW_PLATFORM_ERROR.
5109 *
5110 * @reentrancy This function must not be called from a callback.
5111 *
5112 * @thread_safety This function must only be called from the main thread.
5113 *
5114 * @sa @ref cursor_object
5115 * @sa @ref glfwCreateCursor
5116 *
5117 * @since Added in version 3.1.
5118 *
5119 * @ingroup input
5120 */
5121GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
5122
5123/*! @brief Sets the cursor for the window.
5124 *
5125 * This function sets the cursor image to be used when the cursor is over the
5126 * content area of the specified window. The set cursor will only be visible
5127 * when the [cursor mode](@ref cursor_mode) of the window is
5128 * `GLFW_CURSOR_NORMAL`.
5129 *
5130 * On some platforms, the set cursor may not be visible unless the window also
5131 * has input focus.
5132 *
5133 * @param[in] window The window to set the cursor for.
5134 * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
5135 * arrow cursor.
5136 *
5137 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5138 * GLFW_PLATFORM_ERROR.
5139 *
5140 * @thread_safety This function must only be called from the main thread.
5141 *
5142 * @sa @ref cursor_object
5143 *
5144 * @since Added in version 3.1.
5145 *
5146 * @ingroup input
5147 */
5148GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
5149
5150/*! @brief Sets the key callback.
5151 *
5152 * This function sets the key callback of the specified window, which is called
5153 * when a key is pressed, repeated or released.
5154 *
5155 * The key functions deal with physical keys, with layout independent
5156 * [key tokens](@ref keys) named after their values in the standard US keyboard
5157 * layout. If you want to input text, use the
5158 * [character callback](@ref glfwSetCharCallback) instead.
5159 *
5160 * When a window loses input focus, it will generate synthetic key release
5161 * events for all pressed keys with associated key tokens. You can tell these
5162 * events from user-generated events by the fact that the synthetic ones are
5163 * generated after the focus loss event has been processed, i.e. after the
5164 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
5165 *
5166 * The scancode of a key is specific to that platform or sometimes even to that
5167 * machine. Scancodes are intended to allow users to bind keys that don't have
5168 * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
5169 * state is not saved and so it cannot be queried with @ref glfwGetKey.
5170 *
5171 * Sometimes GLFW needs to generate synthetic key events, in which case the
5172 * scancode may be zero.
5173 *
5174 * @param[in] window The window whose callback to set.
5175 * @param[in] callback The new key callback, or `NULL` to remove the currently
5176 * set callback.
5177 * @return The previously set callback, or `NULL` if no callback was set or the
5178 * library had not been [initialized](@ref intro_init).
5179 *
5180 * @callback_signature
5181 * @code
5182 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
5183 * @endcode
5184 * For more information about the callback parameters, see the
5185 * [function pointer type](@ref GLFWkeyfun).
5186 *
5187 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5188 *
5189 * @thread_safety This function must only be called from the main thread.
5190 *
5191 * @sa @ref input_key
5192 *
5193 * @since Added in version 1.0.
5194 * @glfw3 Added window handle parameter and return value.
5195 *
5196 * @ingroup input
5197 */
5198GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
5199
5200/*! @brief Sets the Unicode character callback.
5201 *
5202 * This function sets the character callback of the specified window, which is
5203 * called when a Unicode character is input.
5204 *
5205 * The character callback is intended for Unicode text input. As it deals with
5206 * characters, it is keyboard layout dependent, whereas the
5207 * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
5208 * to physical keys, as a key may produce zero, one or more characters. If you
5209 * want to know whether a specific physical key was pressed or released, see
5210 * the key callback instead.
5211 *
5212 * The character callback behaves as system text input normally does and will
5213 * not be called if modifier keys are held down that would prevent normal text
5214 * input on that platform, for example a Super (Command) key on macOS or Alt key
5215 * on Windows.
5216 *
5217 * @param[in] window The window whose callback to set.
5218 * @param[in] callback The new callback, or `NULL` to remove the currently set
5219 * callback.
5220 * @return The previously set callback, or `NULL` if no callback was set or the
5221 * library had not been [initialized](@ref intro_init).
5222 *
5223 * @callback_signature
5224 * @code
5225 * void function_name(GLFWwindow* window, unsigned int codepoint)
5226 * @endcode
5227 * For more information about the callback parameters, see the
5228 * [function pointer type](@ref GLFWcharfun).
5229 *
5230 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5231 *
5232 * @thread_safety This function must only be called from the main thread.
5233 *
5234 * @sa @ref input_char
5235 *
5236 * @since Added in version 2.4.
5237 * @glfw3 Added window handle parameter and return value.
5238 *
5239 * @ingroup input
5240 */
5241GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
5242
5243/*! @brief Sets the Unicode character with modifiers callback.
5244 *
5245 * This function sets the character with modifiers callback of the specified
5246 * window, which is called when a Unicode character is input regardless of what
5247 * modifier keys are used.
5248 *
5249 * The character with modifiers callback is intended for implementing custom
5250 * Unicode character input. For regular Unicode text input, see the
5251 * [character callback](@ref glfwSetCharCallback). Like the character
5252 * callback, the character with modifiers callback deals with characters and is
5253 * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
5254 * a key may produce zero, one or more characters. If you want to know whether
5255 * a specific physical key was pressed or released, see the
5256 * [key callback](@ref glfwSetKeyCallback) instead.
5257 *
5258 * @param[in] window The window whose callback to set.
5259 * @param[in] callback The new callback, or `NULL` to remove the currently set
5260 * callback.
5261 * @return The previously set callback, or `NULL` if no callback was set or an
5262 * [error](@ref error_handling) occurred.
5263 *
5264 * @callback_signature
5265 * @code
5266 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
5267 * @endcode
5268 * For more information about the callback parameters, see the
5269 * [function pointer type](@ref GLFWcharmodsfun).
5270 *
5271 * @deprecated Scheduled for removal in version 4.0.
5272 *
5273 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5274 *
5275 * @thread_safety This function must only be called from the main thread.
5276 *
5277 * @sa @ref input_char
5278 *
5279 * @since Added in version 3.1.
5280 *
5281 * @ingroup input
5282 */
5283GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
5284
5285/*! @brief Sets the mouse button callback.
5286 *
5287 * This function sets the mouse button callback of the specified window, which
5288 * is called when a mouse button is pressed or released.
5289 *
5290 * When a window loses input focus, it will generate synthetic mouse button
5291 * release events for all pressed mouse buttons. You can tell these events
5292 * from user-generated events by the fact that the synthetic ones are generated
5293 * after the focus loss event has been processed, i.e. after the
5294 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
5295 *
5296 * @param[in] window The window whose callback to set.
5297 * @param[in] callback The new callback, or `NULL` to remove the currently set
5298 * callback.
5299 * @return The previously set callback, or `NULL` if no callback was set or the
5300 * library had not been [initialized](@ref intro_init).
5301 *
5302 * @callback_signature
5303 * @code
5304 * void function_name(GLFWwindow* window, int button, int action, int mods)
5305 * @endcode
5306 * For more information about the callback parameters, see the
5307 * [function pointer type](@ref GLFWmousebuttonfun).
5308 *
5309 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5310 *
5311 * @thread_safety This function must only be called from the main thread.
5312 *
5313 * @sa @ref input_mouse_button
5314 *
5315 * @since Added in version 1.0.
5316 * @glfw3 Added window handle parameter and return value.
5317 *
5318 * @ingroup input
5319 */
5320GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
5321
5322/*! @brief Sets the cursor position callback.
5323 *
5324 * This function sets the cursor position callback of the specified window,
5325 * which is called when the cursor is moved. The callback is provided with the
5326 * position, in screen coordinates, relative to the upper-left corner of the
5327 * content area of the window.
5328 *
5329 * @param[in] window The window whose callback to set.
5330 * @param[in] callback The new callback, or `NULL` to remove the currently set
5331 * callback.
5332 * @return The previously set callback, or `NULL` if no callback was set or the
5333 * library had not been [initialized](@ref intro_init).
5334 *
5335 * @callback_signature
5336 * @code
5337 * void function_name(GLFWwindow* window, double xpos, double ypos);
5338 * @endcode
5339 * For more information about the callback parameters, see the
5340 * [function pointer type](@ref GLFWcursorposfun).
5341 *
5342 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5343 *
5344 * @thread_safety This function must only be called from the main thread.
5345 *
5346 * @sa @ref cursor_pos
5347 *
5348 * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
5349 *
5350 * @ingroup input
5351 */
5352GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
5353
5354/*! @brief Sets the cursor enter/leave callback.
5355 *
5356 * This function sets the cursor boundary crossing callback of the specified
5357 * window, which is called when the cursor enters or leaves the content area of
5358 * the window.
5359 *
5360 * @param[in] window The window whose callback to set.
5361 * @param[in] callback The new callback, or `NULL` to remove the currently set
5362 * callback.
5363 * @return The previously set callback, or `NULL` if no callback was set or the
5364 * library had not been [initialized](@ref intro_init).
5365 *
5366 * @callback_signature
5367 * @code
5368 * void function_name(GLFWwindow* window, int entered)
5369 * @endcode
5370 * For more information about the callback parameters, see the
5371 * [function pointer type](@ref GLFWcursorenterfun).
5372 *
5373 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5374 *
5375 * @thread_safety This function must only be called from the main thread.
5376 *
5377 * @sa @ref cursor_enter
5378 *
5379 * @since Added in version 3.0.
5380 *
5381 * @ingroup input
5382 */
5383GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
5384
5385/*! @brief Sets the scroll callback.
5386 *
5387 * This function sets the scroll callback of the specified window, which is
5388 * called when a scrolling device is used, such as a mouse wheel or scrolling
5389 * area of a touchpad.
5390 *
5391 * The scroll callback receives all scrolling input, like that from a mouse
5392 * wheel or a touchpad scrolling area.
5393 *
5394 * @param[in] window The window whose callback to set.
5395 * @param[in] callback The new scroll callback, or `NULL` to remove the
5396 * currently set callback.
5397 * @return The previously set callback, or `NULL` if no callback was set or the
5398 * library had not been [initialized](@ref intro_init).
5399 *
5400 * @callback_signature
5401 * @code
5402 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
5403 * @endcode
5404 * For more information about the callback parameters, see the
5405 * [function pointer type](@ref GLFWscrollfun).
5406 *
5407 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5408 *
5409 * @thread_safety This function must only be called from the main thread.
5410 *
5411 * @sa @ref scrolling
5412 *
5413 * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
5414 *
5415 * @ingroup input
5416 */
5417GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
5418
5419/*! @brief Sets the path drop callback.
5420 *
5421 * This function sets the path drop callback of the specified window, which is
5422 * called when one or more dragged paths are dropped on the window.
5423 *
5424 * Because the path array and its strings may have been generated specifically
5425 * for that event, they are not guaranteed to be valid after the callback has
5426 * returned. If you wish to use them after the callback returns, you need to
5427 * make a deep copy.
5428 *
5429 * @param[in] window The window whose callback to set.
5430 * @param[in] callback The new file drop callback, or `NULL` to remove the
5431 * currently set callback.
5432 * @return The previously set callback, or `NULL` if no callback was set or the
5433 * library had not been [initialized](@ref intro_init).
5434 *
5435 * @callback_signature
5436 * @code
5437 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
5438 * @endcode
5439 * For more information about the callback parameters, see the
5440 * [function pointer type](@ref GLFWdropfun).
5441 *
5442 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5443 *
5444 * @thread_safety This function must only be called from the main thread.
5445 *
5446 * @sa @ref path_drop
5447 *
5448 * @since Added in version 3.1.
5449 *
5450 * @ingroup input
5451 */
5452GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
5453
5454/*! @brief Returns whether the specified joystick is present.
5455 *
5456 * This function returns whether the specified joystick is present.
5457 *
5458 * There is no need to call this function before other functions that accept
5459 * a joystick ID, as they all check for presence before performing any other
5460 * work.
5461 *
5462 * @param[in] jid The [joystick](@ref joysticks) to query.
5463 * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
5464 *
5465 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5466 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5467 *
5468 * @thread_safety This function must only be called from the main thread.
5469 *
5470 * @sa @ref joystick
5471 *
5472 * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
5473 *
5474 * @ingroup input
5475 */
5476GLFWAPI int glfwJoystickPresent(int jid);
5477
5478/*! @brief Returns the values of all axes of the specified joystick.
5479 *
5480 * This function returns the values of all axes of the specified joystick.
5481 * Each element in the array is a value between -1.0 and 1.0.
5482 *
5483 * If the specified joystick is not present this function will return `NULL`
5484 * but will not generate an error. This can be used instead of first calling
5485 * @ref glfwJoystickPresent.
5486 *
5487 * @param[in] jid The [joystick](@ref joysticks) to query.
5488 * @param[out] count Where to store the number of axis values in the returned
5489 * array. This is set to zero if the joystick is not present or an error
5490 * occurred.
5491 * @return An array of axis values, or `NULL` if the joystick is not present or
5492 * an [error](@ref error_handling) occurred.
5493 *
5494 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5495 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5496 *
5497 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5498 * should not free it yourself. It is valid until the specified joystick is
5499 * disconnected or the library is terminated.
5500 *
5501 * @thread_safety This function must only be called from the main thread.
5502 *
5503 * @sa @ref joystick_axis
5504 *
5505 * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
5506 *
5507 * @ingroup input
5508 */
5509GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
5510
5511/*! @brief Returns the state of all buttons of the specified joystick.
5512 *
5513 * This function returns the state of all buttons of the specified joystick.
5514 * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
5515 *
5516 * For backward compatibility with earlier versions that did not have @ref
5517 * glfwGetJoystickHats, the button array also includes all hats, each
5518 * represented as four buttons. The hats are in the same order as returned by
5519 * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
5520 * _left_. To disable these extra buttons, set the @ref
5521 * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
5522 *
5523 * If the specified joystick is not present this function will return `NULL`
5524 * but will not generate an error. This can be used instead of first calling
5525 * @ref glfwJoystickPresent.
5526 *
5527 * @param[in] jid The [joystick](@ref joysticks) to query.
5528 * @param[out] count Where to store the number of button states in the returned
5529 * array. This is set to zero if the joystick is not present or an error
5530 * occurred.
5531 * @return An array of button states, or `NULL` if the joystick is not present
5532 * or an [error](@ref error_handling) occurred.
5533 *
5534 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5535 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5536 *
5537 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5538 * should not free it yourself. It is valid until the specified joystick is
5539 * disconnected or the library is terminated.
5540 *
5541 * @thread_safety This function must only be called from the main thread.
5542 *
5543 * @sa @ref joystick_button
5544 *
5545 * @since Added in version 2.2.
5546 * @glfw3 Changed to return a dynamic array.
5547 *
5548 * @ingroup input
5549 */
5550GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
5551
5552/*! @brief Returns the state of all hats of the specified joystick.
5553 *
5554 * This function returns the state of all hats of the specified joystick.
5555 * Each element in the array is one of the following values:
5556 *
5557 * Name | Value
5558 * ---- | -----
5559 * `GLFW_HAT_CENTERED` | 0
5560 * `GLFW_HAT_UP` | 1
5561 * `GLFW_HAT_RIGHT` | 2
5562 * `GLFW_HAT_DOWN` | 4
5563 * `GLFW_HAT_LEFT` | 8
5564 * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
5565 * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
5566 * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
5567 * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
5568 *
5569 * The diagonal directions are bitwise combinations of the primary (up, right,
5570 * down and left) directions and you can test for these individually by ANDing
5571 * it with the corresponding direction.
5572 *
5573 * @code
5574 * if (hats[2] & GLFW_HAT_RIGHT)
5575 * {
5576 * // State of hat 2 could be right-up, right or right-down
5577 * }
5578 * @endcode
5579 *
5580 * If the specified joystick is not present this function will return `NULL`
5581 * but will not generate an error. This can be used instead of first calling
5582 * @ref glfwJoystickPresent.
5583 *
5584 * @param[in] jid The [joystick](@ref joysticks) to query.
5585 * @param[out] count Where to store the number of hat states in the returned
5586 * array. This is set to zero if the joystick is not present or an error
5587 * occurred.
5588 * @return An array of hat states, or `NULL` if the joystick is not present
5589 * or an [error](@ref error_handling) occurred.
5590 *
5591 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5592 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5593 *
5594 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5595 * should not free it yourself. It is valid until the specified joystick is
5596 * disconnected, this function is called again for that joystick or the library
5597 * is terminated.
5598 *
5599 * @thread_safety This function must only be called from the main thread.
5600 *
5601 * @sa @ref joystick_hat
5602 *
5603 * @since Added in version 3.3.
5604 *
5605 * @ingroup input
5606 */
5607GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
5608
5609/*! @brief Returns the name of the specified joystick.
5610 *
5611 * This function returns the name, encoded as UTF-8, of the specified joystick.
5612 * The returned string is allocated and freed by GLFW. You should not free it
5613 * yourself.
5614 *
5615 * If the specified joystick is not present this function will return `NULL`
5616 * but will not generate an error. This can be used instead of first calling
5617 * @ref glfwJoystickPresent.
5618 *
5619 * @param[in] jid The [joystick](@ref joysticks) to query.
5620 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
5621 * is not present or an [error](@ref error_handling) occurred.
5622 *
5623 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5624 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5625 *
5626 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5627 * should not free it yourself. It is valid until the specified joystick is
5628 * disconnected or the library is terminated.
5629 *
5630 * @thread_safety This function must only be called from the main thread.
5631 *
5632 * @sa @ref joystick_name
5633 *
5634 * @since Added in version 3.0.
5635 *
5636 * @ingroup input
5637 */
5638GLFWAPI const char* glfwGetJoystickName(int jid);
5639
5640/*! @brief Returns the SDL compatible GUID of the specified joystick.
5641 *
5642 * This function returns the SDL compatible GUID, as a UTF-8 encoded
5643 * hexadecimal string, of the specified joystick. The returned string is
5644 * allocated and freed by GLFW. You should not free it yourself.
5645 *
5646 * The GUID is what connects a joystick to a gamepad mapping. A connected
5647 * joystick will always have a GUID even if there is no gamepad mapping
5648 * assigned to it.
5649 *
5650 * If the specified joystick is not present this function will return `NULL`
5651 * but will not generate an error. This can be used instead of first calling
5652 * @ref glfwJoystickPresent.
5653 *
5654 * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
5655 * uniquely identify the make and model of a joystick but does not identify
5656 * a specific unit, e.g. all wired Xbox 360 controllers will have the same
5657 * GUID on that platform. The GUID for a unit may vary between platforms
5658 * depending on what hardware information the platform specific APIs provide.
5659 *
5660 * @param[in] jid The [joystick](@ref joysticks) to query.
5661 * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
5662 * is not present or an [error](@ref error_handling) occurred.
5663 *
5664 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5665 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5666 *
5667 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5668 * should not free it yourself. It is valid until the specified joystick is
5669 * disconnected or the library is terminated.
5670 *
5671 * @thread_safety This function must only be called from the main thread.
5672 *
5673 * @sa @ref gamepad
5674 *
5675 * @since Added in version 3.3.
5676 *
5677 * @ingroup input
5678 */
5679GLFWAPI const char* glfwGetJoystickGUID(int jid);
5680
5681/*! @brief Sets the user pointer of the specified joystick.
5682 *
5683 * This function sets the user-defined pointer of the specified joystick. The
5684 * current value is retained until the joystick is disconnected. The initial
5685 * value is `NULL`.
5686 *
5687 * This function may be called from the joystick callback, even for a joystick
5688 * that is being disconnected.
5689 *
5690 * @param[in] jid The joystick whose pointer to set.
5691 * @param[in] pointer The new value.
5692 *
5693 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5694 *
5695 * @thread_safety This function may be called from any thread. Access is not
5696 * synchronized.
5697 *
5698 * @sa @ref joystick_userptr
5699 * @sa @ref glfwGetJoystickUserPointer
5700 *
5701 * @since Added in version 3.3.
5702 *
5703 * @ingroup input
5704 */
5705GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
5706
5707/*! @brief Returns the user pointer of the specified joystick.
5708 *
5709 * This function returns the current value of the user-defined pointer of the
5710 * specified joystick. The initial value is `NULL`.
5711 *
5712 * This function may be called from the joystick callback, even for a joystick
5713 * that is being disconnected.
5714 *
5715 * @param[in] jid The joystick whose pointer to return.
5716 *
5717 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5718 *
5719 * @thread_safety This function may be called from any thread. Access is not
5720 * synchronized.
5721 *
5722 * @sa @ref joystick_userptr
5723 * @sa @ref glfwSetJoystickUserPointer
5724 *
5725 * @since Added in version 3.3.
5726 *
5727 * @ingroup input
5728 */
5729GLFWAPI void* glfwGetJoystickUserPointer(int jid);
5730
5731/*! @brief Returns whether the specified joystick has a gamepad mapping.
5732 *
5733 * This function returns whether the specified joystick is both present and has
5734 * a gamepad mapping.
5735 *
5736 * If the specified joystick is present but does not have a gamepad mapping
5737 * this function will return `GLFW_FALSE` but will not generate an error. Call
5738 * @ref glfwJoystickPresent to check if a joystick is present regardless of
5739 * whether it has a mapping.
5740 *
5741 * @param[in] jid The [joystick](@ref joysticks) to query.
5742 * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
5743 * or `GLFW_FALSE` otherwise.
5744 *
5745 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5746 * GLFW_INVALID_ENUM.
5747 *
5748 * @thread_safety This function must only be called from the main thread.
5749 *
5750 * @sa @ref gamepad
5751 * @sa @ref glfwGetGamepadState
5752 *
5753 * @since Added in version 3.3.
5754 *
5755 * @ingroup input
5756 */
5757GLFWAPI int glfwJoystickIsGamepad(int jid);
5758
5759/*! @brief Sets the joystick configuration callback.
5760 *
5761 * This function sets the joystick configuration callback, or removes the
5762 * currently set callback. This is called when a joystick is connected to or
5763 * disconnected from the system.
5764 *
5765 * For joystick connection and disconnection events to be delivered on all
5766 * platforms, you need to call one of the [event processing](@ref events)
5767 * functions. Joystick disconnection may also be detected and the callback
5768 * called by joystick functions. The function will then return whatever it
5769 * returns if the joystick is not present.
5770 *
5771 * @param[in] callback The new callback, or `NULL` to remove the currently set
5772 * callback.
5773 * @return The previously set callback, or `NULL` if no callback was set or the
5774 * library had not been [initialized](@ref intro_init).
5775 *
5776 * @callback_signature
5777 * @code
5778 * void function_name(int jid, int event)
5779 * @endcode
5780 * For more information about the callback parameters, see the
5781 * [function pointer type](@ref GLFWjoystickfun).
5782 *
5783 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5784 *
5785 * @thread_safety This function must only be called from the main thread.
5786 *
5787 * @sa @ref joystick_event
5788 *
5789 * @since Added in version 3.2.
5790 *
5791 * @ingroup input
5792 */
5793GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
5794
5795/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
5796 *
5797 * This function parses the specified ASCII encoded string and updates the
5798 * internal list with any gamepad mappings it finds. This string may
5799 * contain either a single gamepad mapping or many mappings separated by
5800 * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
5801 * source file including empty lines and comments.
5802 *
5803 * See @ref gamepad_mapping for a description of the format.
5804 *
5805 * If there is already a gamepad mapping for a given GUID in the internal list,
5806 * it will be replaced by the one passed to this function. If the library is
5807 * terminated and re-initialized the internal list will revert to the built-in
5808 * default.
5809 *
5810 * @param[in] string The string containing the gamepad mappings.
5811 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
5812 * [error](@ref error_handling) occurred.
5813 *
5814 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5815 * GLFW_INVALID_VALUE.
5816 *
5817 * @thread_safety This function must only be called from the main thread.
5818 *
5819 * @sa @ref gamepad
5820 * @sa @ref glfwJoystickIsGamepad
5821 * @sa @ref glfwGetGamepadName
5822 *
5823 * @since Added in version 3.3.
5824 *
5825 * @ingroup input
5826 */
5827GLFWAPI int glfwUpdateGamepadMappings(const char* string);
5828
5829/*! @brief Returns the human-readable gamepad name for the specified joystick.
5830 *
5831 * This function returns the human-readable name of the gamepad from the
5832 * gamepad mapping assigned to the specified joystick.
5833 *
5834 * If the specified joystick is not present or does not have a gamepad mapping
5835 * this function will return `NULL` but will not generate an error. Call
5836 * @ref glfwJoystickPresent to check whether it is present regardless of
5837 * whether it has a mapping.
5838 *
5839 * @param[in] jid The [joystick](@ref joysticks) to query.
5840 * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
5841 * joystick is not present, does not have a mapping or an
5842 * [error](@ref error_handling) occurred.
5843 *
5844 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
5845 *
5846 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5847 * should not free it yourself. It is valid until the specified joystick is
5848 * disconnected, the gamepad mappings are updated or the library is terminated.
5849 *
5850 * @thread_safety This function must only be called from the main thread.
5851 *
5852 * @sa @ref gamepad
5853 * @sa @ref glfwJoystickIsGamepad
5854 *
5855 * @since Added in version 3.3.
5856 *
5857 * @ingroup input
5858 */
5859GLFWAPI const char* glfwGetGamepadName(int jid);
5860
5861/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
5862 *
5863 * This function retrieves the state of the specified joystick remapped to
5864 * an Xbox-like gamepad.
5865 *
5866 * If the specified joystick is not present or does not have a gamepad mapping
5867 * this function will return `GLFW_FALSE` but will not generate an error. Call
5868 * @ref glfwJoystickPresent to check whether it is present regardless of
5869 * whether it has a mapping.
5870 *
5871 * The Guide button may not be available for input as it is often hooked by the
5872 * system or the Steam client.
5873 *
5874 * Not all devices have all the buttons or axes provided by @ref
5875 * GLFWgamepadstate. Unavailable buttons and axes will always report
5876 * `GLFW_RELEASE` and 0.0 respectively.
5877 *
5878 * @param[in] jid The [joystick](@ref joysticks) to query.
5879 * @param[out] state The gamepad input state of the joystick.
5880 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
5881 * connected, it has no gamepad mapping or an [error](@ref error_handling)
5882 * occurred.
5883 *
5884 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5885 * GLFW_INVALID_ENUM.
5886 *
5887 * @thread_safety This function must only be called from the main thread.
5888 *
5889 * @sa @ref gamepad
5890 * @sa @ref glfwUpdateGamepadMappings
5891 * @sa @ref glfwJoystickIsGamepad
5892 *
5893 * @since Added in version 3.3.
5894 *
5895 * @ingroup input
5896 */
5897GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
5898
5899/*! @brief Sets the clipboard to the specified string.
5900 *
5901 * This function sets the system clipboard to the specified, UTF-8 encoded
5902 * string.
5903 *
5904 * @param[in] window Deprecated. Any valid window or `NULL`.
5905 * @param[in] string A UTF-8 encoded string.
5906 *
5907 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5908 * GLFW_PLATFORM_ERROR.
5909 *
5910 * @remark @win32 The clipboard on Windows has a single global lock for reading and
5911 * writing. GLFW tries to acquire it a few times, which is almost always enough. If it
5912 * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
5913 * It is safe to try this multiple times.
5914 *
5915 * @pointer_lifetime The specified string is copied before this function
5916 * returns.
5917 *
5918 * @thread_safety This function must only be called from the main thread.
5919 *
5920 * @sa @ref clipboard
5921 * @sa @ref glfwGetClipboardString
5922 *
5923 * @since Added in version 3.0.
5924 *
5925 * @ingroup input
5926 */
5927GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
5928
5929/*! @brief Returns the contents of the clipboard as a string.
5930 *
5931 * This function returns the contents of the system clipboard, if it contains
5932 * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
5933 * if its contents cannot be converted, `NULL` is returned and a @ref
5934 * GLFW_FORMAT_UNAVAILABLE error is generated.
5935 *
5936 * @param[in] window Deprecated. Any valid window or `NULL`.
5937 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
5938 * if an [error](@ref error_handling) occurred.
5939 *
5940 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5941 * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
5942 *
5943 * @remark @win32 The clipboard on Windows has a single global lock for reading and
5944 * writing. GLFW tries to acquire it a few times, which is almost always enough. If it
5945 * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
5946 * It is safe to try this multiple times.
5947 *
5948 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5949 * should not free it yourself. It is valid until the next call to @ref
5950 * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
5951 * is terminated.
5952 *
5953 * @thread_safety This function must only be called from the main thread.
5954 *
5955 * @sa @ref clipboard
5956 * @sa @ref glfwSetClipboardString
5957 *
5958 * @since Added in version 3.0.
5959 *
5960 * @ingroup input
5961 */
5962GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
5963
5964/*! @brief Returns the GLFW time.
5965 *
5966 * This function returns the current GLFW time, in seconds. Unless the time
5967 * has been set using @ref glfwSetTime it measures time elapsed since GLFW was
5968 * initialized.
5969 *
5970 * This function and @ref glfwSetTime are helper functions on top of @ref
5971 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
5972 *
5973 * The resolution of the timer is system dependent, but is usually on the order
5974 * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
5975 * time source on each operating system.
5976 *
5977 * @return The current time, in seconds, or zero if an
5978 * [error](@ref error_handling) occurred.
5979 *
5980 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5981 *
5982 * @thread_safety This function may be called from any thread. Reading and
5983 * writing of the internal base time is not atomic, so it needs to be
5984 * externally synchronized with calls to @ref glfwSetTime.
5985 *
5986 * @sa @ref time
5987 *
5988 * @since Added in version 1.0.
5989 *
5990 * @ingroup input
5991 */
5992GLFWAPI double glfwGetTime(void);
5993
5994/*! @brief Sets the GLFW time.
5995 *
5996 * This function sets the current GLFW time, in seconds. The value must be
5997 * a positive finite number less than or equal to 18446744073.0, which is
5998 * approximately 584.5 years.
5999 *
6000 * This function and @ref glfwGetTime are helper functions on top of @ref
6001 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
6002 *
6003 * @param[in] time The new value, in seconds.
6004 *
6005 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6006 * GLFW_INVALID_VALUE.
6007 *
6008 * @remark The upper limit of GLFW time is calculated as
6009 * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
6010 * storing nanoseconds in 64 bits. The limit may be increased in the future.
6011 *
6012 * @thread_safety This function may be called from any thread. Reading and
6013 * writing of the internal base time is not atomic, so it needs to be
6014 * externally synchronized with calls to @ref glfwGetTime.
6015 *
6016 * @sa @ref time
6017 *
6018 * @since Added in version 2.2.
6019 *
6020 * @ingroup input
6021 */
6022GLFWAPI void glfwSetTime(double time);
6023
6024/*! @brief Returns the current value of the raw timer.
6025 *
6026 * This function returns the current value of the raw timer, measured in
6027 * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
6028 * glfwGetTimerFrequency.
6029 *
6030 * @return The value of the timer, or zero if an
6031 * [error](@ref error_handling) occurred.
6032 *
6033 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
6034 *
6035 * @thread_safety This function may be called from any thread.
6036 *
6037 * @sa @ref time
6038 * @sa @ref glfwGetTimerFrequency
6039 *
6040 * @since Added in version 3.2.
6041 *
6042 * @ingroup input
6043 */
6044GLFWAPI uint64_t glfwGetTimerValue(void);
6045
6046/*! @brief Returns the frequency, in Hz, of the raw timer.
6047 *
6048 * This function returns the frequency, in Hz, of the raw timer.
6049 *
6050 * @return The frequency of the timer, in Hz, or zero if an
6051 * [error](@ref error_handling) occurred.
6052 *
6053 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
6054 *
6055 * @thread_safety This function may be called from any thread.
6056 *
6057 * @sa @ref time
6058 * @sa @ref glfwGetTimerValue
6059 *
6060 * @since Added in version 3.2.
6061 *
6062 * @ingroup input
6063 */
6064GLFWAPI uint64_t glfwGetTimerFrequency(void);
6065
6066/*! @brief Makes the context of the specified window current for the calling
6067 * thread.
6068 *
6069 * This function makes the OpenGL or OpenGL ES context of the specified window
6070 * current on the calling thread. It can also detach the current context from
6071 * the calling thread without making a new one current by passing in `NULL`.
6072 *
6073 * A context must only be made current on a single thread at a time and each
6074 * thread can have only a single current context at a time. Making a context
6075 * current detaches any previously current context on the calling thread.
6076 *
6077 * When moving a context between threads, you must detach it (make it
6078 * non-current) on the old thread before making it current on the new one.
6079 *
6080 * By default, making a context non-current implicitly forces a pipeline flush.
6081 * On machines that support `GL_KHR_context_flush_control`, you can control
6082 * whether a context performs this flush by setting the
6083 * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
6084 * hint.
6085 *
6086 * The specified window must have an OpenGL or OpenGL ES context. Specifying
6087 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
6088 * error.
6089 *
6090 * @param[in] window The window whose context to make current, or `NULL` to
6091 * detach the current context.
6092 *
6093 * @remarks If the previously current context was created via a different
6094 * context creation API than the one passed to this function, GLFW will still
6095 * detach the previous one from its API before making the new one current.
6096 *
6097 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6098 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6099 *
6100 * @thread_safety This function may be called from any thread.
6101 *
6102 * @sa @ref context_current
6103 * @sa @ref glfwGetCurrentContext
6104 *
6105 * @since Added in version 3.0.
6106 *
6107 * @ingroup context
6108 */
6109GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
6110
6111/*! @brief Returns the window whose context is current on the calling thread.
6112 *
6113 * This function returns the window whose OpenGL or OpenGL ES context is
6114 * current on the calling thread.
6115 *
6116 * @return The window whose context is current, or `NULL` if no window's
6117 * context is current.
6118 *
6119 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
6120 *
6121 * @thread_safety This function may be called from any thread.
6122 *
6123 * @sa @ref context_current
6124 * @sa @ref glfwMakeContextCurrent
6125 *
6126 * @since Added in version 3.0.
6127 *
6128 * @ingroup context
6129 */
6130GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
6131
6132/*! @brief Swaps the front and back buffers of the specified window.
6133 *
6134 * This function swaps the front and back buffers of the specified window when
6135 * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
6136 * zero, the GPU driver waits the specified number of screen updates before
6137 * swapping the buffers.
6138 *
6139 * The specified window must have an OpenGL or OpenGL ES context. Specifying
6140 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
6141 * error.
6142 *
6143 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6144 * see `vkQueuePresentKHR` instead.
6145 *
6146 * @param[in] window The window whose buffers to swap.
6147 *
6148 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6149 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6150 *
6151 * @remark __EGL:__ The context of the specified window must be current on the
6152 * calling thread.
6153 *
6154 * @thread_safety This function may be called from any thread.
6155 *
6156 * @sa @ref buffer_swap
6157 * @sa @ref glfwSwapInterval
6158 *
6159 * @since Added in version 1.0.
6160 * @glfw3 Added window handle parameter.
6161 *
6162 * @ingroup window
6163 */
6164GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
6165
6166/*! @brief Sets the swap interval for the current context.
6167 *
6168 * This function sets the swap interval for the current OpenGL or OpenGL ES
6169 * context, i.e. the number of screen updates to wait from the time @ref
6170 * glfwSwapBuffers was called before swapping the buffers and returning. This
6171 * is sometimes called _vertical synchronization_, _vertical retrace
6172 * synchronization_ or just _vsync_.
6173 *
6174 * A context that supports either of the `WGL_EXT_swap_control_tear` and
6175 * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
6176 * intervals, which allows the driver to swap immediately even if a frame
6177 * arrives a little bit late. You can check for these extensions with @ref
6178 * glfwExtensionSupported.
6179 *
6180 * A context must be current on the calling thread. Calling this function
6181 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
6182 *
6183 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6184 * see the present mode of your swapchain instead.
6185 *
6186 * @param[in] interval The minimum number of screen updates to wait for
6187 * until the buffers are swapped by @ref glfwSwapBuffers.
6188 *
6189 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6190 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6191 *
6192 * @remark This function is not called during context creation, leaving the
6193 * swap interval set to whatever is the default for that API. This is done
6194 * because some swap interval extensions used by GLFW do not allow the swap
6195 * interval to be reset to zero once it has been set to a non-zero value.
6196 *
6197 * @remark Some GPU drivers do not honor the requested swap interval, either
6198 * because of a user setting that overrides the application's request or due to
6199 * bugs in the driver.
6200 *
6201 * @thread_safety This function may be called from any thread.
6202 *
6203 * @sa @ref buffer_swap
6204 * @sa @ref glfwSwapBuffers
6205 *
6206 * @since Added in version 1.0.
6207 *
6208 * @ingroup context
6209 */
6210GLFWAPI void glfwSwapInterval(int interval);
6211
6212/*! @brief Returns whether the specified extension is available.
6213 *
6214 * This function returns whether the specified
6215 * [API extension](@ref context_glext) is supported by the current OpenGL or
6216 * OpenGL ES context. It searches both for client API extension and context
6217 * creation API extensions.
6218 *
6219 * A context must be current on the calling thread. Calling this function
6220 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
6221 *
6222 * As this functions retrieves and searches one or more extension strings each
6223 * call, it is recommended that you cache its results if it is going to be used
6224 * frequently. The extension strings will not change during the lifetime of
6225 * a context, so there is no danger in doing this.
6226 *
6227 * This function does not apply to Vulkan. If you are using Vulkan, see @ref
6228 * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
6229 * and `vkEnumerateDeviceExtensionProperties` instead.
6230 *
6231 * @param[in] extension The ASCII encoded name of the extension.
6232 * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
6233 * otherwise.
6234 *
6235 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6236 * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
6237 * GLFW_PLATFORM_ERROR.
6238 *
6239 * @thread_safety This function may be called from any thread.
6240 *
6241 * @sa @ref context_glext
6242 * @sa @ref glfwGetProcAddress
6243 *
6244 * @since Added in version 1.0.
6245 *
6246 * @ingroup context
6247 */
6248GLFWAPI int glfwExtensionSupported(const char* extension);
6249
6250/*! @brief Returns the address of the specified function for the current
6251 * context.
6252 *
6253 * This function returns the address of the specified OpenGL or OpenGL ES
6254 * [core or extension function](@ref context_glext), if it is supported
6255 * by the current context.
6256 *
6257 * A context must be current on the calling thread. Calling this function
6258 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
6259 *
6260 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6261 * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
6262 * `vkGetDeviceProcAddr` instead.
6263 *
6264 * @param[in] procname The ASCII encoded name of the function.
6265 * @return The address of the function, or `NULL` if an
6266 * [error](@ref error_handling) occurred.
6267 *
6268 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6269 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6270 *
6271 * @remark The address of a given function is not guaranteed to be the same
6272 * between contexts.
6273 *
6274 * @remark This function may return a non-`NULL` address despite the
6275 * associated version or extension not being available. Always check the
6276 * context version or extension string first.
6277 *
6278 * @pointer_lifetime The returned function pointer is valid until the context
6279 * is destroyed or the library is terminated.
6280 *
6281 * @thread_safety This function may be called from any thread.
6282 *
6283 * @sa @ref context_glext
6284 * @sa @ref glfwExtensionSupported
6285 *
6286 * @since Added in version 1.0.
6287 *
6288 * @ingroup context
6289 */
6290GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
6291
6292/*! @brief Returns whether the Vulkan loader and an ICD have been found.
6293 *
6294 * This function returns whether the Vulkan loader and any minimally functional
6295 * ICD have been found.
6296 *
6297 * The availability of a Vulkan loader and even an ICD does not by itself guarantee that
6298 * surface creation or even instance creation is possible. Call @ref
6299 * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
6300 * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
6301 * check whether a queue family of a physical device supports image presentation.
6302 *
6303 * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
6304 * otherwise.
6305 *
6306 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
6307 *
6308 * @thread_safety This function may be called from any thread.
6309 *
6310 * @sa @ref vulkan_support
6311 *
6312 * @since Added in version 3.2.
6313 *
6314 * @ingroup vulkan
6315 */
6316GLFWAPI int glfwVulkanSupported(void);
6317
6318/*! @brief Returns the Vulkan instance extensions required by GLFW.
6319 *
6320 * This function returns an array of names of Vulkan instance extensions required
6321 * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
6322 * list will always contain `VK_KHR_surface`, so if you don't require any
6323 * additional extensions you can pass this list directly to the
6324 * `VkInstanceCreateInfo` struct.
6325 *
6326 * If Vulkan is not available on the machine, this function returns `NULL` and
6327 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
6328 * to check whether Vulkan is at least minimally available.
6329 *
6330 * If Vulkan is available but no set of extensions allowing window surface
6331 * creation was found, this function returns `NULL`. You may still use Vulkan
6332 * for off-screen rendering and compute work.
6333 *
6334 * @param[out] count Where to store the number of extensions in the returned
6335 * array. This is set to zero if an error occurred.
6336 * @return An array of ASCII encoded extension names, or `NULL` if an
6337 * [error](@ref error_handling) occurred.
6338 *
6339 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6340 * GLFW_API_UNAVAILABLE.
6341 *
6342 * @remark Additional extensions may be required by future versions of GLFW.
6343 * You should check if any extensions you wish to enable are already in the
6344 * returned array, as it is an error to specify an extension more than once in
6345 * the `VkInstanceCreateInfo` struct.
6346 *
6347 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
6348 * should not free it yourself. It is guaranteed to be valid only until the
6349 * library is terminated.
6350 *
6351 * @thread_safety This function may be called from any thread.
6352 *
6353 * @sa @ref vulkan_ext
6354 * @sa @ref glfwCreateWindowSurface
6355 *
6356 * @since Added in version 3.2.
6357 *
6358 * @ingroup vulkan
6359 */
6360GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
6361
6362#if defined(VK_VERSION_1_0)
6363
6364/*! @brief Returns the address of the specified Vulkan instance function.
6365 *
6366 * This function returns the address of the specified Vulkan core or extension
6367 * function for the specified instance. If instance is set to `NULL` it can
6368 * return any function exported from the Vulkan loader, including at least the
6369 * following functions:
6370 *
6371 * - `vkEnumerateInstanceExtensionProperties`
6372 * - `vkEnumerateInstanceLayerProperties`
6373 * - `vkCreateInstance`
6374 * - `vkGetInstanceProcAddr`
6375 *
6376 * If Vulkan is not available on the machine, this function returns `NULL` and
6377 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
6378 * to check whether Vulkan is at least minimally available.
6379 *
6380 * This function is equivalent to calling `vkGetInstanceProcAddr` with
6381 * a platform-specific query of the Vulkan loader as a fallback.
6382 *
6383 * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
6384 * functions related to instance creation.
6385 * @param[in] procname The ASCII encoded name of the function.
6386 * @return The address of the function, or `NULL` if an
6387 * [error](@ref error_handling) occurred.
6388 *
6389 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6390 * GLFW_API_UNAVAILABLE.
6391 *
6392 * @pointer_lifetime The returned function pointer is valid until the library
6393 * is terminated.
6394 *
6395 * @thread_safety This function may be called from any thread.
6396 *
6397 * @sa @ref vulkan_proc
6398 *
6399 * @since Added in version 3.2.
6400 *
6401 * @ingroup vulkan
6402 */
6403GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
6404
6405/*! @brief Returns whether the specified queue family can present images.
6406 *
6407 * This function returns whether the specified queue family of the specified
6408 * physical device supports presentation to the platform GLFW was built for.
6409 *
6410 * If Vulkan or the required window surface creation instance extensions are
6411 * not available on the machine, or if the specified instance was not created
6412 * with the required extensions, this function returns `GLFW_FALSE` and
6413 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
6414 * to check whether Vulkan is at least minimally available and @ref
6415 * glfwGetRequiredInstanceExtensions to check what instance extensions are
6416 * required.
6417 *
6418 * @param[in] instance The instance that the physical device belongs to.
6419 * @param[in] device The physical device that the queue family belongs to.
6420 * @param[in] queuefamily The index of the queue family to query.
6421 * @return `GLFW_TRUE` if the queue family supports presentation, or
6422 * `GLFW_FALSE` otherwise.
6423 *
6424 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6425 * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
6426 *
6427 * @remark @macos This function currently always returns `GLFW_TRUE`, as the
6428 * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
6429 * a `vkGetPhysicalDevice*PresentationSupport` type function.
6430 *
6431 * @thread_safety This function may be called from any thread. For
6432 * synchronization details of Vulkan objects, see the Vulkan specification.
6433 *
6434 * @sa @ref vulkan_present
6435 *
6436 * @since Added in version 3.2.
6437 *
6438 * @ingroup vulkan
6439 */
6440GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
6441
6442/*! @brief Creates a Vulkan surface for the specified window.
6443 *
6444 * This function creates a Vulkan surface for the specified window.
6445 *
6446 * If the Vulkan loader or at least one minimally functional ICD were not found,
6447 * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
6448 * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
6449 * Vulkan is at least minimally available.
6450 *
6451 * If the required window surface creation instance extensions are not
6452 * available or if the specified instance was not created with these extensions
6453 * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
6454 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
6455 * glfwGetRequiredInstanceExtensions to check what instance extensions are
6456 * required.
6457 *
6458 * The window surface cannot be shared with another API so the window must
6459 * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
6460 * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
6461 * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
6462 *
6463 * The window surface must be destroyed before the specified Vulkan instance.
6464 * It is the responsibility of the caller to destroy the window surface. GLFW
6465 * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
6466 * surface.
6467 *
6468 * @param[in] instance The Vulkan instance to create the surface in.
6469 * @param[in] window The window to create the surface for.
6470 * @param[in] allocator The allocator to use, or `NULL` to use the default
6471 * allocator.
6472 * @param[out] surface Where to store the handle of the surface. This is set
6473 * to `VK_NULL_HANDLE` if an error occurred.
6474 * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
6475 * [error](@ref error_handling) occurred.
6476 *
6477 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6478 * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
6479 *
6480 * @remark If an error occurs before the creation call is made, GLFW returns
6481 * the Vulkan error code most appropriate for the error. Appropriate use of
6482 * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
6483 * eliminate almost all occurrences of these errors.
6484 *
6485 * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
6486 * `VK_MVK_macos_surface` extension as a fallback. The name of the selected
6487 * extension, if any, is included in the array returned by @ref
6488 * glfwGetRequiredInstanceExtensions.
6489 *
6490 * @remark @macos This function creates and sets a `CAMetalLayer` instance for
6491 * the window content view, which is required for MoltenVK to function.
6492 *
6493 * @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension,
6494 * with the `VK_KHR_xlib_surface` extension as a fallback. You can make
6495 * `VK_KHR_xlib_surface` the preferred extension by setting the
6496 * [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
6497 * hint. The name of the selected extension, if any, is included in the array
6498 * returned by @ref glfwGetRequiredInstanceExtensions.
6499 *
6500 * @thread_safety This function may be called from any thread. For
6501 * synchronization details of Vulkan objects, see the Vulkan specification.
6502 *
6503 * @sa @ref vulkan_surface
6504 * @sa @ref glfwGetRequiredInstanceExtensions
6505 *
6506 * @since Added in version 3.2.
6507 *
6508 * @ingroup vulkan
6509 */
6510GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
6511
6512#endif /*VK_VERSION_1_0*/
6513
6514
6515/*************************************************************************
6516 * Global definition cleanup
6517 *************************************************************************/
6518
6519/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
6520
6521#ifdef GLFW_WINGDIAPI_DEFINED
6522 #undef WINGDIAPI
6523 #undef GLFW_WINGDIAPI_DEFINED
6524#endif
6525
6526#ifdef GLFW_CALLBACK_DEFINED
6527 #undef CALLBACK
6528 #undef GLFW_CALLBACK_DEFINED
6529#endif
6530
6531/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
6532 * defined by some gl.h variants (OpenBSD) so define it after if needed.
6533 */
6534#ifndef GLAPIENTRY
6535 #define GLAPIENTRY APIENTRY
6536 #define GLFW_GLAPIENTRY_DEFINED
6537#endif
6538
6539/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
6540
6541
6542#ifdef __cplusplus
6543}
6544#endif
6545
6546#endif /* _glfw3_h_ */
6547
diff --git a/raylib/src/external/glfw/include/GLFW/glfw3native.h b/raylib/src/external/glfw/include/GLFW/glfw3native.h
new file mode 100644
index 0000000..92f0d32
--- /dev/null
+++ b/raylib/src/external/glfw/include/GLFW/glfw3native.h
@@ -0,0 +1,663 @@
1/*************************************************************************
2 * GLFW 3.4 - www.glfw.org
3 * A library for OpenGL, window and input
4 *------------------------------------------------------------------------
5 * Copyright (c) 2002-2006 Marcus Geelnard
6 * Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
7 *
8 * This software is provided 'as-is', without any express or implied
9 * warranty. In no event will the authors be held liable for any damages
10 * arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose,
13 * including commercial applications, and to alter it and redistribute it
14 * freely, subject to the following restrictions:
15 *
16 * 1. The origin of this software must not be misrepresented; you must not
17 * claim that you wrote the original software. If you use this software
18 * in a product, an acknowledgment in the product documentation would
19 * be appreciated but is not required.
20 *
21 * 2. Altered source versions must be plainly marked as such, and must not
22 * be misrepresented as being the original software.
23 *
24 * 3. This notice may not be removed or altered from any source
25 * distribution.
26 *
27 *************************************************************************/
28
29#ifndef _glfw3_native_h_
30#define _glfw3_native_h_
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36
37/*************************************************************************
38 * Doxygen documentation
39 *************************************************************************/
40
41/*! @file glfw3native.h
42 * @brief The header of the native access functions.
43 *
44 * This is the header file of the native access functions. See @ref native for
45 * more information.
46 */
47/*! @defgroup native Native access
48 * @brief Functions related to accessing native handles.
49 *
50 * **By using the native access functions you assert that you know what you're
51 * doing and how to fix problems caused by using them. If you don't, you
52 * shouldn't be using them.**
53 *
54 * Before the inclusion of @ref glfw3native.h, you may define zero or more
55 * window system API macro and zero or more context creation API macros.
56 *
57 * The chosen backends must match those the library was compiled for. Failure
58 * to do this will cause a link-time error.
59 *
60 * The available window API macros are:
61 * * `GLFW_EXPOSE_NATIVE_WIN32`
62 * * `GLFW_EXPOSE_NATIVE_COCOA`
63 * * `GLFW_EXPOSE_NATIVE_X11`
64 * * `GLFW_EXPOSE_NATIVE_WAYLAND`
65 *
66 * The available context API macros are:
67 * * `GLFW_EXPOSE_NATIVE_WGL`
68 * * `GLFW_EXPOSE_NATIVE_NSGL`
69 * * `GLFW_EXPOSE_NATIVE_GLX`
70 * * `GLFW_EXPOSE_NATIVE_EGL`
71 * * `GLFW_EXPOSE_NATIVE_OSMESA`
72 *
73 * These macros select which of the native access functions that are declared
74 * and which platform-specific headers to include. It is then up your (by
75 * definition platform-specific) code to handle which of these should be
76 * defined.
77 *
78 * If you do not want the platform-specific headers to be included, define
79 * `GLFW_NATIVE_INCLUDE_NONE` before including the @ref glfw3native.h header.
80 *
81 * @code
82 * #define GLFW_EXPOSE_NATIVE_WIN32
83 * #define GLFW_EXPOSE_NATIVE_WGL
84 * #define GLFW_NATIVE_INCLUDE_NONE
85 * #include <GLFW/glfw3native.h>
86 * @endcode
87 */
88
89
90/*************************************************************************
91 * System headers and types
92 *************************************************************************/
93
94#if !defined(GLFW_NATIVE_INCLUDE_NONE)
95
96 #if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
97 /* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
98 * example to allow applications to correctly declare a GL_KHR_debug callback)
99 * but windows.h assumes no one will define APIENTRY before it does
100 */
101 #if defined(GLFW_APIENTRY_DEFINED)
102 #undef APIENTRY
103 #undef GLFW_APIENTRY_DEFINED
104 #endif
105 #include <windows.h>
106 #endif
107
108 #if defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
109 #if defined(__OBJC__)
110 #import <Cocoa/Cocoa.h>
111 #else
112 #include <ApplicationServices/ApplicationServices.h>
113 #include <objc/objc.h>
114 #endif
115 #endif
116
117 #if defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
118 #include <X11/Xlib.h>
119 #include <X11/extensions/Xrandr.h>
120 #endif
121
122 #if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
123 #include <wayland-client.h>
124 #endif
125
126 #if defined(GLFW_EXPOSE_NATIVE_WGL)
127 /* WGL is declared by windows.h */
128 #endif
129 #if defined(GLFW_EXPOSE_NATIVE_NSGL)
130 /* NSGL is declared by Cocoa.h */
131 #endif
132 #if defined(GLFW_EXPOSE_NATIVE_GLX)
133 /* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
134 * default it also acts as an OpenGL header
135 * However, glx.h will include gl.h, which will define it unconditionally
136 */
137 #if defined(GLFW_GLAPIENTRY_DEFINED)
138 #undef GLAPIENTRY
139 #undef GLFW_GLAPIENTRY_DEFINED
140 #endif
141 #include <GL/glx.h>
142 #endif
143 #if defined(GLFW_EXPOSE_NATIVE_EGL)
144 #include <EGL/egl.h>
145 #endif
146 #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
147 /* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
148 * default it also acts as an OpenGL header
149 * However, osmesa.h will include gl.h, which will define it unconditionally
150 */
151 #if defined(GLFW_GLAPIENTRY_DEFINED)
152 #undef GLAPIENTRY
153 #undef GLFW_GLAPIENTRY_DEFINED
154 #endif
155 #include <GL/osmesa.h>
156 #endif
157
158#endif /*GLFW_NATIVE_INCLUDE_NONE*/
159
160
161/*************************************************************************
162 * Functions
163 *************************************************************************/
164
165#if defined(GLFW_EXPOSE_NATIVE_WIN32)
166/*! @brief Returns the adapter device name of the specified monitor.
167 *
168 * @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
169 * of the specified monitor, or `NULL` if an [error](@ref error_handling)
170 * occurred.
171 *
172 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
173 * GLFW_PLATFORM_UNAVAILABLE.
174 *
175 * @thread_safety This function may be called from any thread. Access is not
176 * synchronized.
177 *
178 * @since Added in version 3.1.
179 *
180 * @ingroup native
181 */
182GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
183
184/*! @brief Returns the display device name of the specified monitor.
185 *
186 * @return The UTF-8 encoded display device name (for example
187 * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
188 * [error](@ref error_handling) occurred.
189 *
190 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
191 * GLFW_PLATFORM_UNAVAILABLE.
192 *
193 * @thread_safety This function may be called from any thread. Access is not
194 * synchronized.
195 *
196 * @since Added in version 3.1.
197 *
198 * @ingroup native
199 */
200GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
201
202/*! @brief Returns the `HWND` of the specified window.
203 *
204 * @return The `HWND` of the specified window, or `NULL` if an
205 * [error](@ref error_handling) occurred.
206 *
207 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
208 * GLFW_PLATFORM_UNAVAILABLE.
209 *
210 * @remark The `HDC` associated with the window can be queried with the
211 * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
212 * function.
213 * @code
214 * HDC dc = GetDC(glfwGetWin32Window(window));
215 * @endcode
216 * This DC is private and does not need to be released.
217 *
218 * @thread_safety This function may be called from any thread. Access is not
219 * synchronized.
220 *
221 * @since Added in version 3.0.
222 *
223 * @ingroup native
224 */
225GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
226#endif
227
228#if defined(GLFW_EXPOSE_NATIVE_WGL)
229/*! @brief Returns the `HGLRC` of the specified window.
230 *
231 * @return The `HGLRC` of the specified window, or `NULL` if an
232 * [error](@ref error_handling) occurred.
233 *
234 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
235 * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
236 *
237 * @remark The `HDC` associated with the window can be queried with the
238 * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
239 * function.
240 * @code
241 * HDC dc = GetDC(glfwGetWin32Window(window));
242 * @endcode
243 * This DC is private and does not need to be released.
244 *
245 * @thread_safety This function may be called from any thread. Access is not
246 * synchronized.
247 *
248 * @since Added in version 3.0.
249 *
250 * @ingroup native
251 */
252GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
253#endif
254
255#if defined(GLFW_EXPOSE_NATIVE_COCOA)
256/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
257 *
258 * @return The `CGDirectDisplayID` of the specified monitor, or
259 * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
260 *
261 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
262 * GLFW_PLATFORM_UNAVAILABLE.
263 *
264 * @thread_safety This function may be called from any thread. Access is not
265 * synchronized.
266 *
267 * @since Added in version 3.1.
268 *
269 * @ingroup native
270 */
271GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
272
273/*! @brief Returns the `NSWindow` of the specified window.
274 *
275 * @return The `NSWindow` of the specified window, or `nil` if an
276 * [error](@ref error_handling) occurred.
277 *
278 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
279 * GLFW_PLATFORM_UNAVAILABLE.
280 *
281 * @thread_safety This function may be called from any thread. Access is not
282 * synchronized.
283 *
284 * @since Added in version 3.0.
285 *
286 * @ingroup native
287 */
288GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
289
290/*! @brief Returns the `NSView` of the specified window.
291 *
292 * @return The `NSView` of the specified window, or `nil` if an
293 * [error](@ref error_handling) occurred.
294 *
295 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
296 * GLFW_PLATFORM_UNAVAILABLE.
297 *
298 * @thread_safety This function may be called from any thread. Access is not
299 * synchronized.
300 *
301 * @since Added in version 3.4.
302 *
303 * @ingroup native
304 */
305GLFWAPI id glfwGetCocoaView(GLFWwindow* window);
306#endif
307
308#if defined(GLFW_EXPOSE_NATIVE_NSGL)
309/*! @brief Returns the `NSOpenGLContext` of the specified window.
310 *
311 * @return The `NSOpenGLContext` of the specified window, or `nil` if an
312 * [error](@ref error_handling) occurred.
313 *
314 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
315 * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
316 *
317 * @thread_safety This function may be called from any thread. Access is not
318 * synchronized.
319 *
320 * @since Added in version 3.0.
321 *
322 * @ingroup native
323 */
324GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
325#endif
326
327#if defined(GLFW_EXPOSE_NATIVE_X11)
328/*! @brief Returns the `Display` used by GLFW.
329 *
330 * @return The `Display` used by GLFW, or `NULL` if an
331 * [error](@ref error_handling) occurred.
332 *
333 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
334 * GLFW_PLATFORM_UNAVAILABLE.
335 *
336 * @thread_safety This function may be called from any thread. Access is not
337 * synchronized.
338 *
339 * @since Added in version 3.0.
340 *
341 * @ingroup native
342 */
343GLFWAPI Display* glfwGetX11Display(void);
344
345/*! @brief Returns the `RRCrtc` of the specified monitor.
346 *
347 * @return The `RRCrtc` of the specified monitor, or `None` if an
348 * [error](@ref error_handling) occurred.
349 *
350 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
351 * GLFW_PLATFORM_UNAVAILABLE.
352 *
353 * @thread_safety This function may be called from any thread. Access is not
354 * synchronized.
355 *
356 * @since Added in version 3.1.
357 *
358 * @ingroup native
359 */
360GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
361
362/*! @brief Returns the `RROutput` of the specified monitor.
363 *
364 * @return The `RROutput` of the specified monitor, or `None` if an
365 * [error](@ref error_handling) occurred.
366 *
367 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
368 * GLFW_PLATFORM_UNAVAILABLE.
369 *
370 * @thread_safety This function may be called from any thread. Access is not
371 * synchronized.
372 *
373 * @since Added in version 3.1.
374 *
375 * @ingroup native
376 */
377GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
378
379/*! @brief Returns the `Window` of the specified window.
380 *
381 * @return The `Window` of the specified window, or `None` if an
382 * [error](@ref error_handling) occurred.
383 *
384 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
385 * GLFW_PLATFORM_UNAVAILABLE.
386 *
387 * @thread_safety This function may be called from any thread. Access is not
388 * synchronized.
389 *
390 * @since Added in version 3.0.
391 *
392 * @ingroup native
393 */
394GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
395
396/*! @brief Sets the current primary selection to the specified string.
397 *
398 * @param[in] string A UTF-8 encoded string.
399 *
400 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
401 * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
402 *
403 * @pointer_lifetime The specified string is copied before this function
404 * returns.
405 *
406 * @thread_safety This function must only be called from the main thread.
407 *
408 * @sa @ref clipboard
409 * @sa glfwGetX11SelectionString
410 * @sa glfwSetClipboardString
411 *
412 * @since Added in version 3.3.
413 *
414 * @ingroup native
415 */
416GLFWAPI void glfwSetX11SelectionString(const char* string);
417
418/*! @brief Returns the contents of the current primary selection as a string.
419 *
420 * If the selection is empty or if its contents cannot be converted, `NULL`
421 * is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
422 *
423 * @return The contents of the selection as a UTF-8 encoded string, or `NULL`
424 * if an [error](@ref error_handling) occurred.
425 *
426 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
427 * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
428 *
429 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
430 * should not free it yourself. It is valid until the next call to @ref
431 * glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
432 * library is terminated.
433 *
434 * @thread_safety This function must only be called from the main thread.
435 *
436 * @sa @ref clipboard
437 * @sa glfwSetX11SelectionString
438 * @sa glfwGetClipboardString
439 *
440 * @since Added in version 3.3.
441 *
442 * @ingroup native
443 */
444GLFWAPI const char* glfwGetX11SelectionString(void);
445#endif
446
447#if defined(GLFW_EXPOSE_NATIVE_GLX)
448/*! @brief Returns the `GLXContext` of the specified window.
449 *
450 * @return The `GLXContext` of the specified window, or `NULL` if an
451 * [error](@ref error_handling) occurred.
452 *
453 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
454 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
455 *
456 * @thread_safety This function may be called from any thread. Access is not
457 * synchronized.
458 *
459 * @since Added in version 3.0.
460 *
461 * @ingroup native
462 */
463GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
464
465/*! @brief Returns the `GLXWindow` of the specified window.
466 *
467 * @return The `GLXWindow` of the specified window, or `None` if an
468 * [error](@ref error_handling) occurred.
469 *
470 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
471 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
472 *
473 * @thread_safety This function may be called from any thread. Access is not
474 * synchronized.
475 *
476 * @since Added in version 3.2.
477 *
478 * @ingroup native
479 */
480GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
481#endif
482
483#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
484/*! @brief Returns the `struct wl_display*` used by GLFW.
485 *
486 * @return The `struct wl_display*` used by GLFW, or `NULL` if an
487 * [error](@ref error_handling) occurred.
488 *
489 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
490 * GLFW_PLATFORM_UNAVAILABLE.
491 *
492 * @thread_safety This function may be called from any thread. Access is not
493 * synchronized.
494 *
495 * @since Added in version 3.2.
496 *
497 * @ingroup native
498 */
499GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
500
501/*! @brief Returns the `struct wl_output*` of the specified monitor.
502 *
503 * @return The `struct wl_output*` of the specified monitor, or `NULL` if an
504 * [error](@ref error_handling) occurred.
505 *
506 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
507 * GLFW_PLATFORM_UNAVAILABLE.
508 *
509 * @thread_safety This function may be called from any thread. Access is not
510 * synchronized.
511 *
512 * @since Added in version 3.2.
513 *
514 * @ingroup native
515 */
516GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
517
518/*! @brief Returns the main `struct wl_surface*` of the specified window.
519 *
520 * @return The main `struct wl_surface*` of the specified window, or `NULL` if
521 * an [error](@ref error_handling) occurred.
522 *
523 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
524 * GLFW_PLATFORM_UNAVAILABLE.
525 *
526 * @thread_safety This function may be called from any thread. Access is not
527 * synchronized.
528 *
529 * @since Added in version 3.2.
530 *
531 * @ingroup native
532 */
533GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
534#endif
535
536#if defined(GLFW_EXPOSE_NATIVE_EGL)
537/*! @brief Returns the `EGLDisplay` used by GLFW.
538 *
539 * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
540 * [error](@ref error_handling) occurred.
541 *
542 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
543 *
544 * @remark Because EGL is initialized on demand, this function will return
545 * `EGL_NO_DISPLAY` until the first context has been created via EGL.
546 *
547 * @thread_safety This function may be called from any thread. Access is not
548 * synchronized.
549 *
550 * @since Added in version 3.0.
551 *
552 * @ingroup native
553 */
554GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
555
556/*! @brief Returns the `EGLContext` of the specified window.
557 *
558 * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
559 * [error](@ref error_handling) occurred.
560 *
561 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
562 * GLFW_NO_WINDOW_CONTEXT.
563 *
564 * @thread_safety This function may be called from any thread. Access is not
565 * synchronized.
566 *
567 * @since Added in version 3.0.
568 *
569 * @ingroup native
570 */
571GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
572
573/*! @brief Returns the `EGLSurface` of the specified window.
574 *
575 * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
576 * [error](@ref error_handling) occurred.
577 *
578 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
579 * GLFW_NO_WINDOW_CONTEXT.
580 *
581 * @thread_safety This function may be called from any thread. Access is not
582 * synchronized.
583 *
584 * @since Added in version 3.0.
585 *
586 * @ingroup native
587 */
588GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
589#endif
590
591#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
592/*! @brief Retrieves the color buffer associated with the specified window.
593 *
594 * @param[in] window The window whose color buffer to retrieve.
595 * @param[out] width Where to store the width of the color buffer, or `NULL`.
596 * @param[out] height Where to store the height of the color buffer, or `NULL`.
597 * @param[out] format Where to store the OSMesa pixel format of the color
598 * buffer, or `NULL`.
599 * @param[out] buffer Where to store the address of the color buffer, or
600 * `NULL`.
601 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
602 * [error](@ref error_handling) occurred.
603 *
604 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
605 * GLFW_NO_WINDOW_CONTEXT.
606 *
607 * @thread_safety This function may be called from any thread. Access is not
608 * synchronized.
609 *
610 * @since Added in version 3.3.
611 *
612 * @ingroup native
613 */
614GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
615
616/*! @brief Retrieves the depth buffer associated with the specified window.
617 *
618 * @param[in] window The window whose depth buffer to retrieve.
619 * @param[out] width Where to store the width of the depth buffer, or `NULL`.
620 * @param[out] height Where to store the height of the depth buffer, or `NULL`.
621 * @param[out] bytesPerValue Where to store the number of bytes per depth
622 * buffer element, or `NULL`.
623 * @param[out] buffer Where to store the address of the depth buffer, or
624 * `NULL`.
625 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
626 * [error](@ref error_handling) occurred.
627 *
628 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
629 * GLFW_NO_WINDOW_CONTEXT.
630 *
631 * @thread_safety This function may be called from any thread. Access is not
632 * synchronized.
633 *
634 * @since Added in version 3.3.
635 *
636 * @ingroup native
637 */
638GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
639
640/*! @brief Returns the `OSMesaContext` of the specified window.
641 *
642 * @return The `OSMesaContext` of the specified window, or `NULL` if an
643 * [error](@ref error_handling) occurred.
644 *
645 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
646 * GLFW_NO_WINDOW_CONTEXT.
647 *
648 * @thread_safety This function may be called from any thread. Access is not
649 * synchronized.
650 *
651 * @since Added in version 3.3.
652 *
653 * @ingroup native
654 */
655GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
656#endif
657
658#ifdef __cplusplus
659}
660#endif
661
662#endif /* _glfw3_native_h_ */
663
diff --git a/raylib/src/external/glfw/src/CMakeLists.txt b/raylib/src/external/glfw/src/CMakeLists.txt
new file mode 100644
index 0000000..1057a6f
--- /dev/null
+++ b/raylib/src/external/glfw/src/CMakeLists.txt
@@ -0,0 +1,368 @@
1
2add_library(glfw ${GLFW_LIBRARY_TYPE}
3 "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
4 "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
5 internal.h platform.h mappings.h
6 context.c init.c input.c monitor.c platform.c vulkan.c window.c
7 egl_context.c osmesa_context.c null_platform.h null_joystick.h
8 null_init.c null_monitor.c null_window.c null_joystick.c)
9
10# The time, thread and module code is shared between all backends on a given OS,
11# including the null backend, which still needs those bits to be functional
12if (APPLE)
13 target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h
14 posix_module.c posix_thread.c)
15elseif (WIN32)
16 target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c
17 win32_time.c win32_thread.c)
18else()
19 target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c
20 posix_time.c posix_thread.c)
21endif()
22
23add_custom_target(update_mappings
24 COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h
25 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
26 COMMENT "Updating gamepad mappings from upstream repository"
27 SOURCES mappings.h.in "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake"
28 VERBATIM)
29
30set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
31
32if (GLFW_BUILD_COCOA)
33 target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
34 target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
35 cocoa_joystick.m cocoa_monitor.m cocoa_window.m
36 nsgl_context.m)
37endif()
38
39if (GLFW_BUILD_WIN32)
40 target_compile_definitions(glfw PRIVATE _GLFW_WIN32)
41 target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_init.c
42 win32_joystick.c win32_monitor.c win32_window.c
43 wgl_context.c)
44endif()
45
46if (GLFW_BUILD_X11)
47 target_compile_definitions(glfw PRIVATE _GLFW_X11)
48 target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c
49 x11_monitor.c x11_window.c xkb_unicode.c
50 glx_context.c)
51endif()
52
53if (GLFW_BUILD_WAYLAND)
54 target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND)
55 target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c
56 wl_monitor.c wl_window.c xkb_unicode.c)
57endif()
58
59if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
60 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
61 target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
62 endif()
63 target_sources(glfw PRIVATE posix_poll.h posix_poll.c)
64endif()
65
66if (GLFW_BUILD_WAYLAND)
67 include(CheckIncludeFiles)
68 include(CheckFunctionExists)
69 check_function_exists(memfd_create HAVE_MEMFD_CREATE)
70 if (HAVE_MEMFD_CREATE)
71 target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE)
72 endif()
73
74 find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
75 if (NOT WAYLAND_SCANNER_EXECUTABLE)
76 message(FATAL_ERROR "Failed to find wayland-scanner")
77 endif()
78
79 macro(generate_wayland_protocol protocol_file)
80 set(protocol_path "${GLFW_SOURCE_DIR}/deps/wayland/${protocol_file}")
81
82 string(REGEX REPLACE "\\.xml$" "-client-protocol.h" header_file ${protocol_file})
83 string(REGEX REPLACE "\\.xml$" "-client-protocol-code.h" code_file ${protocol_file})
84
85 add_custom_command(OUTPUT ${header_file}
86 COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_path}" ${header_file}
87 DEPENDS "${protocol_path}"
88 VERBATIM)
89
90 add_custom_command(OUTPUT ${code_file}
91 COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_path}" ${code_file}
92 DEPENDS "${protocol_path}"
93 VERBATIM)
94
95 target_sources(glfw PRIVATE ${header_file} ${code_file})
96 endmacro()
97
98 generate_wayland_protocol("wayland.xml")
99 generate_wayland_protocol("viewporter.xml")
100 generate_wayland_protocol("xdg-shell.xml")
101 generate_wayland_protocol("idle-inhibit-unstable-v1.xml")
102 generate_wayland_protocol("pointer-constraints-unstable-v1.xml")
103 generate_wayland_protocol("relative-pointer-unstable-v1.xml")
104 generate_wayland_protocol("fractional-scale-v1.xml")
105 generate_wayland_protocol("xdg-activation-v1.xml")
106 generate_wayland_protocol("xdg-decoration-unstable-v1.xml")
107endif()
108
109if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
110 configure_file(glfw.rc.in glfw.rc @ONLY)
111 target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
112endif()
113
114if (UNIX AND GLFW_BUILD_SHARED_LIBRARY)
115 # On Unix-like systems, shared libraries can use the soname system.
116 set(GLFW_LIB_NAME glfw)
117else()
118 set(GLFW_LIB_NAME glfw3)
119endif()
120set(GLFW_LIB_NAME_SUFFIX "")
121
122set_target_properties(glfw PROPERTIES
123 OUTPUT_NAME ${GLFW_LIB_NAME}
124 VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
125 SOVERSION ${GLFW_VERSION_MAJOR}
126 POSITION_INDEPENDENT_CODE ON
127 C_STANDARD 99
128 C_EXTENSIONS OFF
129 DEFINE_SYMBOL _GLFW_BUILD_DLL
130 FOLDER "GLFW3")
131
132target_include_directories(glfw PUBLIC
133 "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
134 "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
135target_include_directories(glfw PRIVATE
136 "${GLFW_SOURCE_DIR}/src"
137 "${GLFW_BINARY_DIR}/src")
138target_link_libraries(glfw PRIVATE Threads::Threads)
139
140# Workaround for CMake not knowing about .m files before version 3.16
141if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
142 set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
143 cocoa_window.m nsgl_context.m PROPERTIES
144 LANGUAGE C)
145endif()
146
147if (GLFW_BUILD_WIN32)
148 list(APPEND glfw_PKG_LIBS "-lgdi32")
149endif()
150
151if (GLFW_BUILD_COCOA)
152 target_link_libraries(glfw PRIVATE "-framework Cocoa"
153 "-framework IOKit"
154 "-framework CoreFoundation")
155
156 set(glfw_PKG_DEPS "")
157 set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
158endif()
159
160if (GLFW_BUILD_WAYLAND)
161 include(FindPkgConfig)
162
163 pkg_check_modules(Wayland REQUIRED
164 wayland-client>=0.2.7
165 wayland-cursor>=0.2.7
166 wayland-egl>=0.2.7
167 xkbcommon>=0.5.0)
168
169 target_include_directories(glfw PRIVATE ${Wayland_INCLUDE_DIRS})
170
171 if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
172 find_package(EpollShim)
173 if (EPOLLSHIM_FOUND)
174 target_include_directories(glfw PRIVATE ${EPOLLSHIM_INCLUDE_DIRS})
175 target_link_libraries(glfw PRIVATE ${EPOLLSHIM_LIBRARIES})
176 endif()
177 endif()
178endif()
179
180if (GLFW_BUILD_X11)
181 find_package(X11 REQUIRED)
182 target_include_directories(glfw PRIVATE "${X11_X11_INCLUDE_PATH}")
183
184 # Check for XRandR (modern resolution switching and gamma control)
185 if (NOT X11_Xrandr_INCLUDE_PATH)
186 message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
187 endif()
188 target_include_directories(glfw PRIVATE "${X11_Xrandr_INCLUDE_PATH}")
189
190 # Check for Xinerama (legacy multi-monitor support)
191 if (NOT X11_Xinerama_INCLUDE_PATH)
192 message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
193 endif()
194 target_include_directories(glfw PRIVATE "${X11_Xinerama_INCLUDE_PATH}")
195
196 # Check for Xkb (X keyboard extension)
197 if (NOT X11_Xkb_INCLUDE_PATH)
198 message(FATAL_ERROR "XKB headers not found; install X11 development package")
199 endif()
200 target_include_directories(glfw PRIVATE "${X11_Xkb_INCLUDE_PATH}")
201
202 # Check for Xcursor (cursor creation from RGBA images)
203 if (NOT X11_Xcursor_INCLUDE_PATH)
204 message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
205 endif()
206 target_include_directories(glfw PRIVATE "${X11_Xcursor_INCLUDE_PATH}")
207
208 # Check for XInput (modern HID input)
209 if (NOT X11_Xi_INCLUDE_PATH)
210 message(FATAL_ERROR "XInput headers not found; install libxi development package")
211 endif()
212 target_include_directories(glfw PRIVATE "${X11_Xi_INCLUDE_PATH}")
213
214 # Check for X Shape (custom window input shape)
215 if (NOT X11_Xshape_INCLUDE_PATH)
216 message(FATAL_ERROR "X Shape headers not found; install libxext development package")
217 endif()
218 target_include_directories(glfw PRIVATE "${X11_Xshape_INCLUDE_PATH}")
219endif()
220
221if (UNIX AND NOT APPLE)
222 find_library(RT_LIBRARY rt)
223 mark_as_advanced(RT_LIBRARY)
224 if (RT_LIBRARY)
225 target_link_libraries(glfw PRIVATE "${RT_LIBRARY}")
226 list(APPEND glfw_PKG_LIBS "-lrt")
227 endif()
228
229 find_library(MATH_LIBRARY m)
230 mark_as_advanced(MATH_LIBRARY)
231 if (MATH_LIBRARY)
232 target_link_libraries(glfw PRIVATE "${MATH_LIBRARY}")
233 list(APPEND glfw_PKG_LIBS "-lm")
234 endif()
235
236 if (CMAKE_DL_LIBS)
237 target_link_libraries(glfw PRIVATE "${CMAKE_DL_LIBS}")
238 list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
239 endif()
240endif()
241
242if (WIN32)
243 if (GLFW_USE_HYBRID_HPG)
244 target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG)
245 endif()
246endif()
247
248# Enable a reasonable set of warnings
249# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
250if (MSVC)
251 target_compile_options(glfw PRIVATE "/W3")
252elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
253 CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
254 CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
255
256 target_compile_options(glfw PRIVATE "-Wall")
257endif()
258
259if (GLFW_BUILD_WIN32)
260 target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
261endif()
262
263# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
264# the inclusion of stddef.h (by glfw3.h), which is itself included before
265# win32_platform.h. We define them here until a saner solution can be found
266# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
267if (MINGW)
268 target_compile_definitions(glfw PRIVATE WINVER=0x0501)
269endif()
270
271# Workaround for legacy MinGW not providing XInput and DirectInput
272if (MINGW)
273 include(CheckIncludeFile)
274 check_include_file(dinput.h DINPUT_H_FOUND)
275 check_include_file(xinput.h XINPUT_H_FOUND)
276 if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
277 target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
278 endif()
279endif()
280
281# Workaround for the MS CRT deprecating parts of the standard library
282if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
283 target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
284endif()
285
286# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
287if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
288 target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
289endif()
290
291if (GLFW_BUILD_SHARED_LIBRARY)
292 if (WIN32)
293 if (MINGW)
294 # Remove the dependency on the shared version of libgcc
295 # NOTE: MinGW-w64 has the correct default but MinGW needs this
296 target_link_libraries(glfw PRIVATE "-static-libgcc")
297
298 # Remove the lib prefix on the DLL (but not the import library)
299 set_target_properties(glfw PROPERTIES PREFIX "")
300
301 # Add a suffix to the import library to avoid naming conflicts
302 set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a")
303 else()
304 # Add a suffix to the import library to avoid naming conflicts
305 set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
306 endif()
307 set (GLFW_LIB_NAME_SUFFIX "dll")
308
309 target_compile_definitions(glfw INTERFACE GLFW_DLL)
310 endif()
311
312 if (MINGW)
313 # Enable link-time exploit mitigation features enabled by default on MSVC
314 include(CheckCCompilerFlag)
315
316 # Compatibility with data execution prevention (DEP)
317 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
318 check_c_compiler_flag("" _GLFW_HAS_DEP)
319 if (_GLFW_HAS_DEP)
320 target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
321 endif()
322
323 # Compatibility with address space layout randomization (ASLR)
324 set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
325 check_c_compiler_flag("" _GLFW_HAS_ASLR)
326 if (_GLFW_HAS_ASLR)
327 target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
328 endif()
329
330 # Compatibility with 64-bit address space layout randomization (ASLR)
331 set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
332 check_c_compiler_flag("" _GLFW_HAS_64ASLR)
333 if (_GLFW_HAS_64ASLR)
334 target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
335 endif()
336
337 # Clear flags again to avoid breaking later tests
338 set(CMAKE_REQUIRED_FLAGS)
339 endif()
340
341 if (UNIX)
342 # Hide symbols not explicitly tagged for export from the shared library
343 target_compile_options(glfw PRIVATE "-fvisibility=hidden")
344 endif()
345endif()
346
347foreach(arg ${glfw_PKG_DEPS})
348 string(APPEND deps " ${arg}")
349endforeach()
350foreach(arg ${glfw_PKG_LIBS})
351 string(APPEND libs " ${arg}")
352endforeach()
353
354set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
355 "GLFW pkg-config Requires.private")
356set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL
357 "GLFW pkg-config Libs.private")
358
359configure_file("${GLFW_SOURCE_DIR}/CMake/glfw3.pc.in" glfw3.pc @ONLY)
360
361if (GLFW_INSTALL)
362 install(TARGETS glfw
363 EXPORT glfwTargets
364 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
365 ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
366 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
367endif()
368
diff --git a/raylib/src/external/glfw/src/cocoa_init.m b/raylib/src/external/glfw/src/cocoa_init.m
new file mode 100644
index 0000000..f34d985
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_init.m
@@ -0,0 +1,696 @@
1//========================================================================
2// GLFW 3.4 macOS (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
5// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_COCOA)
31
32#include <sys/param.h> // For MAXPATHLEN
33
34// Needed for _NSGetProgname
35#include <crt_externs.h>
36
37// Change to our application bundle's resources directory, if present
38//
39static void changeToResourcesDirectory(void)
40{
41 char resourcesPath[MAXPATHLEN];
42
43 CFBundleRef bundle = CFBundleGetMainBundle();
44 if (!bundle)
45 return;
46
47 CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
48
49 CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
50 if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo)
51 {
52 CFRelease(last);
53 CFRelease(resourcesURL);
54 return;
55 }
56
57 CFRelease(last);
58
59 if (!CFURLGetFileSystemRepresentation(resourcesURL,
60 true,
61 (UInt8*) resourcesPath,
62 MAXPATHLEN))
63 {
64 CFRelease(resourcesURL);
65 return;
66 }
67
68 CFRelease(resourcesURL);
69
70 chdir(resourcesPath);
71}
72
73// Set up the menu bar (manually)
74// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
75// could go away at any moment, lots of stuff that really should be
76// localize(d|able), etc. Add a nib to save us this horror.
77//
78static void createMenuBar(void)
79{
80 NSString* appName = nil;
81 NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
82 NSString* nameKeys[] =
83 {
84 @"CFBundleDisplayName",
85 @"CFBundleName",
86 @"CFBundleExecutable",
87 };
88
89 // Try to figure out what the calling application is called
90
91 for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
92 {
93 id name = bundleInfo[nameKeys[i]];
94 if (name &&
95 [name isKindOfClass:[NSString class]] &&
96 ![name isEqualToString:@""])
97 {
98 appName = name;
99 break;
100 }
101 }
102
103 if (!appName)
104 {
105 char** progname = _NSGetProgname();
106 if (progname && *progname)
107 appName = @(*progname);
108 else
109 appName = @"GLFW Application";
110 }
111
112 NSMenu* bar = [[NSMenu alloc] init];
113 [NSApp setMainMenu:bar];
114
115 NSMenuItem* appMenuItem =
116 [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
117 NSMenu* appMenu = [[NSMenu alloc] init];
118 [appMenuItem setSubmenu:appMenu];
119
120 [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
121 action:@selector(orderFrontStandardAboutPanel:)
122 keyEquivalent:@""];
123 [appMenu addItem:[NSMenuItem separatorItem]];
124 NSMenu* servicesMenu = [[NSMenu alloc] init];
125 [NSApp setServicesMenu:servicesMenu];
126 [[appMenu addItemWithTitle:@"Services"
127 action:NULL
128 keyEquivalent:@""] setSubmenu:servicesMenu];
129 [servicesMenu release];
130 [appMenu addItem:[NSMenuItem separatorItem]];
131 [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
132 action:@selector(hide:)
133 keyEquivalent:@"h"];
134 [[appMenu addItemWithTitle:@"Hide Others"
135 action:@selector(hideOtherApplications:)
136 keyEquivalent:@"h"]
137 setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
138 [appMenu addItemWithTitle:@"Show All"
139 action:@selector(unhideAllApplications:)
140 keyEquivalent:@""];
141 [appMenu addItem:[NSMenuItem separatorItem]];
142 [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
143 action:@selector(terminate:)
144 keyEquivalent:@"q"];
145
146 NSMenuItem* windowMenuItem =
147 [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
148 [bar release];
149 NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
150 [NSApp setWindowsMenu:windowMenu];
151 [windowMenuItem setSubmenu:windowMenu];
152
153 [windowMenu addItemWithTitle:@"Minimize"
154 action:@selector(performMiniaturize:)
155 keyEquivalent:@"m"];
156 [windowMenu addItemWithTitle:@"Zoom"
157 action:@selector(performZoom:)
158 keyEquivalent:@""];
159 [windowMenu addItem:[NSMenuItem separatorItem]];
160 [windowMenu addItemWithTitle:@"Bring All to Front"
161 action:@selector(arrangeInFront:)
162 keyEquivalent:@""];
163
164 // TODO: Make this appear at the bottom of the menu (for consistency)
165 [windowMenu addItem:[NSMenuItem separatorItem]];
166 [[windowMenu addItemWithTitle:@"Enter Full Screen"
167 action:@selector(toggleFullScreen:)
168 keyEquivalent:@"f"]
169 setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
170
171 // Prior to Snow Leopard, we need to use this oddly-named semi-private API
172 // to get the application menu working properly.
173 SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
174 [NSApp performSelector:setAppleMenuSelector withObject:appMenu];
175}
176
177// Create key code translation tables
178//
179static void createKeyTablesCocoa(void)
180{
181 memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
182 memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
183
184 _glfw.ns.keycodes[0x1D] = GLFW_KEY_0;
185 _glfw.ns.keycodes[0x12] = GLFW_KEY_1;
186 _glfw.ns.keycodes[0x13] = GLFW_KEY_2;
187 _glfw.ns.keycodes[0x14] = GLFW_KEY_3;
188 _glfw.ns.keycodes[0x15] = GLFW_KEY_4;
189 _glfw.ns.keycodes[0x17] = GLFW_KEY_5;
190 _glfw.ns.keycodes[0x16] = GLFW_KEY_6;
191 _glfw.ns.keycodes[0x1A] = GLFW_KEY_7;
192 _glfw.ns.keycodes[0x1C] = GLFW_KEY_8;
193 _glfw.ns.keycodes[0x19] = GLFW_KEY_9;
194 _glfw.ns.keycodes[0x00] = GLFW_KEY_A;
195 _glfw.ns.keycodes[0x0B] = GLFW_KEY_B;
196 _glfw.ns.keycodes[0x08] = GLFW_KEY_C;
197 _glfw.ns.keycodes[0x02] = GLFW_KEY_D;
198 _glfw.ns.keycodes[0x0E] = GLFW_KEY_E;
199 _glfw.ns.keycodes[0x03] = GLFW_KEY_F;
200 _glfw.ns.keycodes[0x05] = GLFW_KEY_G;
201 _glfw.ns.keycodes[0x04] = GLFW_KEY_H;
202 _glfw.ns.keycodes[0x22] = GLFW_KEY_I;
203 _glfw.ns.keycodes[0x26] = GLFW_KEY_J;
204 _glfw.ns.keycodes[0x28] = GLFW_KEY_K;
205 _glfw.ns.keycodes[0x25] = GLFW_KEY_L;
206 _glfw.ns.keycodes[0x2E] = GLFW_KEY_M;
207 _glfw.ns.keycodes[0x2D] = GLFW_KEY_N;
208 _glfw.ns.keycodes[0x1F] = GLFW_KEY_O;
209 _glfw.ns.keycodes[0x23] = GLFW_KEY_P;
210 _glfw.ns.keycodes[0x0C] = GLFW_KEY_Q;
211 _glfw.ns.keycodes[0x0F] = GLFW_KEY_R;
212 _glfw.ns.keycodes[0x01] = GLFW_KEY_S;
213 _glfw.ns.keycodes[0x11] = GLFW_KEY_T;
214 _glfw.ns.keycodes[0x20] = GLFW_KEY_U;
215 _glfw.ns.keycodes[0x09] = GLFW_KEY_V;
216 _glfw.ns.keycodes[0x0D] = GLFW_KEY_W;
217 _glfw.ns.keycodes[0x07] = GLFW_KEY_X;
218 _glfw.ns.keycodes[0x10] = GLFW_KEY_Y;
219 _glfw.ns.keycodes[0x06] = GLFW_KEY_Z;
220
221 _glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE;
222 _glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH;
223 _glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA;
224 _glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL;
225 _glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT;
226 _glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET;
227 _glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS;
228 _glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD;
229 _glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET;
230 _glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON;
231 _glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH;
232 _glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1;
233
234 _glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE;
235 _glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK;
236 _glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE;
237 _glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN;
238 _glfw.ns.keycodes[0x77] = GLFW_KEY_END;
239 _glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER;
240 _glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE;
241 _glfw.ns.keycodes[0x7A] = GLFW_KEY_F1;
242 _glfw.ns.keycodes[0x78] = GLFW_KEY_F2;
243 _glfw.ns.keycodes[0x63] = GLFW_KEY_F3;
244 _glfw.ns.keycodes[0x76] = GLFW_KEY_F4;
245 _glfw.ns.keycodes[0x60] = GLFW_KEY_F5;
246 _glfw.ns.keycodes[0x61] = GLFW_KEY_F6;
247 _glfw.ns.keycodes[0x62] = GLFW_KEY_F7;
248 _glfw.ns.keycodes[0x64] = GLFW_KEY_F8;
249 _glfw.ns.keycodes[0x65] = GLFW_KEY_F9;
250 _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
251 _glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
252 _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
253 _glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN;
254 _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
255 _glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
256 _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
257 _glfw.ns.keycodes[0x40] = GLFW_KEY_F17;
258 _glfw.ns.keycodes[0x4F] = GLFW_KEY_F18;
259 _glfw.ns.keycodes[0x50] = GLFW_KEY_F19;
260 _glfw.ns.keycodes[0x5A] = GLFW_KEY_F20;
261 _glfw.ns.keycodes[0x73] = GLFW_KEY_HOME;
262 _glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT;
263 _glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT;
264 _glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT;
265 _glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL;
266 _glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT;
267 _glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER;
268 _glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU;
269 _glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK;
270 _glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN;
271 _glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP;
272 _glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT;
273 _glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT;
274 _glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL;
275 _glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT;
276 _glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER;
277 _glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE;
278 _glfw.ns.keycodes[0x30] = GLFW_KEY_TAB;
279 _glfw.ns.keycodes[0x7E] = GLFW_KEY_UP;
280
281 _glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0;
282 _glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1;
283 _glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2;
284 _glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3;
285 _glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4;
286 _glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5;
287 _glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6;
288 _glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7;
289 _glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8;
290 _glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9;
291 _glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD;
292 _glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL;
293 _glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE;
294 _glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER;
295 _glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL;
296 _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
297 _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
298
299 for (int scancode = 0; scancode < 256; scancode++)
300 {
301 // Store the reverse translation for faster key name lookup
302 if (_glfw.ns.keycodes[scancode] >= 0)
303 _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
304 }
305}
306
307// Retrieve Unicode data for the current keyboard layout
308//
309static GLFWbool updateUnicodeData(void)
310{
311 if (_glfw.ns.inputSource)
312 {
313 CFRelease(_glfw.ns.inputSource);
314 _glfw.ns.inputSource = NULL;
315 _glfw.ns.unicodeData = nil;
316 }
317
318 _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
319 if (!_glfw.ns.inputSource)
320 {
321 _glfwInputError(GLFW_PLATFORM_ERROR,
322 "Cocoa: Failed to retrieve keyboard layout input source");
323 return GLFW_FALSE;
324 }
325
326 _glfw.ns.unicodeData =
327 TISGetInputSourceProperty(_glfw.ns.inputSource,
328 kTISPropertyUnicodeKeyLayoutData);
329 if (!_glfw.ns.unicodeData)
330 {
331 _glfwInputError(GLFW_PLATFORM_ERROR,
332 "Cocoa: Failed to retrieve keyboard layout Unicode data");
333 return GLFW_FALSE;
334 }
335
336 return GLFW_TRUE;
337}
338
339// Load HIToolbox.framework and the TIS symbols we need from it
340//
341static GLFWbool initializeTIS(void)
342{
343 // This works only because Cocoa has already loaded it properly
344 _glfw.ns.tis.bundle =
345 CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
346 if (!_glfw.ns.tis.bundle)
347 {
348 _glfwInputError(GLFW_PLATFORM_ERROR,
349 "Cocoa: Failed to load HIToolbox.framework");
350 return GLFW_FALSE;
351 }
352
353 CFStringRef* kPropertyUnicodeKeyLayoutData =
354 CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
355 CFSTR("kTISPropertyUnicodeKeyLayoutData"));
356 _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
357 CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
358 CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
359 _glfw.ns.tis.GetInputSourceProperty =
360 CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
361 CFSTR("TISGetInputSourceProperty"));
362 _glfw.ns.tis.GetKbdType =
363 CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
364 CFSTR("LMGetKbdType"));
365
366 if (!kPropertyUnicodeKeyLayoutData ||
367 !TISCopyCurrentKeyboardLayoutInputSource ||
368 !TISGetInputSourceProperty ||
369 !LMGetKbdType)
370 {
371 _glfwInputError(GLFW_PLATFORM_ERROR,
372 "Cocoa: Failed to load TIS API symbols");
373 return GLFW_FALSE;
374 }
375
376 _glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
377 *kPropertyUnicodeKeyLayoutData;
378
379 return updateUnicodeData();
380}
381
382@interface GLFWHelper : NSObject
383@end
384
385@implementation GLFWHelper
386
387- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
388{
389 updateUnicodeData();
390}
391
392- (void)doNothing:(id)object
393{
394}
395
396@end // GLFWHelper
397
398@interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
399@end
400
401@implementation GLFWApplicationDelegate
402
403- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
404{
405 for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
406 _glfwInputWindowCloseRequest(window);
407
408 return NSTerminateCancel;
409}
410
411- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
412{
413 for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
414 {
415 if (window->context.client != GLFW_NO_API)
416 [window->context.nsgl.object update];
417 }
418
419 _glfwPollMonitorsCocoa();
420}
421
422- (void)applicationWillFinishLaunching:(NSNotification *)notification
423{
424 if (_glfw.hints.init.ns.menubar)
425 {
426 // Menu bar setup must go between sharedApplication and finishLaunching
427 // in order to properly emulate the behavior of NSApplicationMain
428
429 if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
430 {
431 [[NSBundle mainBundle] loadNibNamed:@"MainMenu"
432 owner:NSApp
433 topLevelObjects:&_glfw.ns.nibObjects];
434 }
435 else
436 createMenuBar();
437 }
438}
439
440- (void)applicationDidFinishLaunching:(NSNotification *)notification
441{
442 _glfwPostEmptyEventCocoa();
443 [NSApp stop:nil];
444}
445
446- (void)applicationDidHide:(NSNotification *)notification
447{
448 for (int i = 0; i < _glfw.monitorCount; i++)
449 _glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
450}
451
452@end // GLFWApplicationDelegate
453
454
455//////////////////////////////////////////////////////////////////////////
456////// GLFW internal API //////
457//////////////////////////////////////////////////////////////////////////
458
459void* _glfwLoadLocalVulkanLoaderCocoa(void)
460{
461 CFBundleRef bundle = CFBundleGetMainBundle();
462 if (!bundle)
463 return NULL;
464
465 CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle);
466 if (!frameworksUrl)
467 return NULL;
468
469 CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent(
470 kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false);
471 if (!loaderUrl)
472 {
473 CFRelease(frameworksUrl);
474 return NULL;
475 }
476
477 char path[PATH_MAX];
478 void* handle = NULL;
479
480 if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1))
481 handle = _glfwPlatformLoadModule(path);
482
483 CFRelease(loaderUrl);
484 CFRelease(frameworksUrl);
485 return handle;
486}
487
488
489//////////////////////////////////////////////////////////////////////////
490////// GLFW platform API //////
491//////////////////////////////////////////////////////////////////////////
492
493GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
494{
495 const _GLFWplatform cocoa =
496 {
497 .platformID = GLFW_PLATFORM_COCOA,
498 .init = _glfwInitCocoa,
499 .terminate = _glfwTerminateCocoa,
500 .getCursorPos = _glfwGetCursorPosCocoa,
501 .setCursorPos = _glfwSetCursorPosCocoa,
502 .setCursorMode = _glfwSetCursorModeCocoa,
503 .setRawMouseMotion = _glfwSetRawMouseMotionCocoa,
504 .rawMouseMotionSupported = _glfwRawMouseMotionSupportedCocoa,
505 .createCursor = _glfwCreateCursorCocoa,
506 .createStandardCursor = _glfwCreateStandardCursorCocoa,
507 .destroyCursor = _glfwDestroyCursorCocoa,
508 .setCursor = _glfwSetCursorCocoa,
509 .getScancodeName = _glfwGetScancodeNameCocoa,
510 .getKeyScancode = _glfwGetKeyScancodeCocoa,
511 .setClipboardString = _glfwSetClipboardStringCocoa,
512 .getClipboardString = _glfwGetClipboardStringCocoa,
513 .initJoysticks = _glfwInitJoysticksCocoa,
514 .terminateJoysticks = _glfwTerminateJoysticksCocoa,
515 .pollJoystick = _glfwPollJoystickCocoa,
516 .getMappingName = _glfwGetMappingNameCocoa,
517 .updateGamepadGUID = _glfwUpdateGamepadGUIDCocoa,
518 .freeMonitor = _glfwFreeMonitorCocoa,
519 .getMonitorPos = _glfwGetMonitorPosCocoa,
520 .getMonitorContentScale = _glfwGetMonitorContentScaleCocoa,
521 .getMonitorWorkarea = _glfwGetMonitorWorkareaCocoa,
522 .getVideoModes = _glfwGetVideoModesCocoa,
523 .getVideoMode = _glfwGetVideoModeCocoa,
524 .getGammaRamp = _glfwGetGammaRampCocoa,
525 .setGammaRamp = _glfwSetGammaRampCocoa,
526 .createWindow = _glfwCreateWindowCocoa,
527 .destroyWindow = _glfwDestroyWindowCocoa,
528 .setWindowTitle = _glfwSetWindowTitleCocoa,
529 .setWindowIcon = _glfwSetWindowIconCocoa,
530 .getWindowPos = _glfwGetWindowPosCocoa,
531 .setWindowPos = _glfwSetWindowPosCocoa,
532 .getWindowSize = _glfwGetWindowSizeCocoa,
533 .setWindowSize = _glfwSetWindowSizeCocoa,
534 .setWindowSizeLimits = _glfwSetWindowSizeLimitsCocoa,
535 .setWindowAspectRatio = _glfwSetWindowAspectRatioCocoa,
536 .getFramebufferSize = _glfwGetFramebufferSizeCocoa,
537 .getWindowFrameSize = _glfwGetWindowFrameSizeCocoa,
538 .getWindowContentScale = _glfwGetWindowContentScaleCocoa,
539 .iconifyWindow = _glfwIconifyWindowCocoa,
540 .restoreWindow = _glfwRestoreWindowCocoa,
541 .maximizeWindow = _glfwMaximizeWindowCocoa,
542 .showWindow = _glfwShowWindowCocoa,
543 .hideWindow = _glfwHideWindowCocoa,
544 .requestWindowAttention = _glfwRequestWindowAttentionCocoa,
545 .focusWindow = _glfwFocusWindowCocoa,
546 .setWindowMonitor = _glfwSetWindowMonitorCocoa,
547 .windowFocused = _glfwWindowFocusedCocoa,
548 .windowIconified = _glfwWindowIconifiedCocoa,
549 .windowVisible = _glfwWindowVisibleCocoa,
550 .windowMaximized = _glfwWindowMaximizedCocoa,
551 .windowHovered = _glfwWindowHoveredCocoa,
552 .framebufferTransparent = _glfwFramebufferTransparentCocoa,
553 .getWindowOpacity = _glfwGetWindowOpacityCocoa,
554 .setWindowResizable = _glfwSetWindowResizableCocoa,
555 .setWindowDecorated = _glfwSetWindowDecoratedCocoa,
556 .setWindowFloating = _glfwSetWindowFloatingCocoa,
557 .setWindowOpacity = _glfwSetWindowOpacityCocoa,
558 .setWindowMousePassthrough = _glfwSetWindowMousePassthroughCocoa,
559 .pollEvents = _glfwPollEventsCocoa,
560 .waitEvents = _glfwWaitEventsCocoa,
561 .waitEventsTimeout = _glfwWaitEventsTimeoutCocoa,
562 .postEmptyEvent = _glfwPostEmptyEventCocoa,
563 .getEGLPlatform = _glfwGetEGLPlatformCocoa,
564 .getEGLNativeDisplay = _glfwGetEGLNativeDisplayCocoa,
565 .getEGLNativeWindow = _glfwGetEGLNativeWindowCocoa,
566 .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsCocoa,
567 .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportCocoa,
568 .createWindowSurface = _glfwCreateWindowSurfaceCocoa
569 };
570
571 *platform = cocoa;
572 return GLFW_TRUE;
573}
574
575int _glfwInitCocoa(void)
576{
577 @autoreleasepool {
578
579 _glfw.ns.helper = [[GLFWHelper alloc] init];
580
581 [NSThread detachNewThreadSelector:@selector(doNothing:)
582 toTarget:_glfw.ns.helper
583 withObject:nil];
584
585 [NSApplication sharedApplication];
586
587 _glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
588 if (_glfw.ns.delegate == nil)
589 {
590 _glfwInputError(GLFW_PLATFORM_ERROR,
591 "Cocoa: Failed to create application delegate");
592 return GLFW_FALSE;
593 }
594
595 [NSApp setDelegate:_glfw.ns.delegate];
596
597 NSEvent* (^block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
598 {
599 if ([event modifierFlags] & NSEventModifierFlagCommand)
600 [[NSApp keyWindow] sendEvent:event];
601
602 return event;
603 };
604
605 _glfw.ns.keyUpMonitor =
606 [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp
607 handler:block];
608
609 if (_glfw.hints.init.ns.chdir)
610 changeToResourcesDirectory();
611
612 // Press and Hold prevents some keys from emitting repeated characters
613 NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO};
614 [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
615
616 [[NSNotificationCenter defaultCenter]
617 addObserver:_glfw.ns.helper
618 selector:@selector(selectedKeyboardInputSourceChanged:)
619 name:NSTextInputContextKeyboardSelectionDidChangeNotification
620 object:nil];
621
622 createKeyTablesCocoa();
623
624 _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
625 if (!_glfw.ns.eventSource)
626 return GLFW_FALSE;
627
628 CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
629
630 if (!initializeTIS())
631 return GLFW_FALSE;
632
633 _glfwPollMonitorsCocoa();
634
635 if (![[NSRunningApplication currentApplication] isFinishedLaunching])
636 [NSApp run];
637
638 // In case we are unbundled, make us a proper UI application
639 if (_glfw.hints.init.ns.menubar)
640 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
641
642 return GLFW_TRUE;
643
644 } // autoreleasepool
645}
646
647void _glfwTerminateCocoa(void)
648{
649 @autoreleasepool {
650
651 if (_glfw.ns.inputSource)
652 {
653 CFRelease(_glfw.ns.inputSource);
654 _glfw.ns.inputSource = NULL;
655 _glfw.ns.unicodeData = nil;
656 }
657
658 if (_glfw.ns.eventSource)
659 {
660 CFRelease(_glfw.ns.eventSource);
661 _glfw.ns.eventSource = NULL;
662 }
663
664 if (_glfw.ns.delegate)
665 {
666 [NSApp setDelegate:nil];
667 [_glfw.ns.delegate release];
668 _glfw.ns.delegate = nil;
669 }
670
671 if (_glfw.ns.helper)
672 {
673 [[NSNotificationCenter defaultCenter]
674 removeObserver:_glfw.ns.helper
675 name:NSTextInputContextKeyboardSelectionDidChangeNotification
676 object:nil];
677 [[NSNotificationCenter defaultCenter]
678 removeObserver:_glfw.ns.helper];
679 [_glfw.ns.helper release];
680 _glfw.ns.helper = nil;
681 }
682
683 if (_glfw.ns.keyUpMonitor)
684 [NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
685
686 _glfw_free(_glfw.ns.clipboardString);
687
688 _glfwTerminateNSGL();
689 _glfwTerminateEGL();
690 _glfwTerminateOSMesa();
691
692 } // autoreleasepool
693}
694
695#endif // _GLFW_COCOA
696
diff --git a/raylib/src/external/glfw/src/cocoa_joystick.h b/raylib/src/external/glfw/src/cocoa_joystick.h
new file mode 100644
index 0000000..2f46dfc
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_joystick.h
@@ -0,0 +1,49 @@
1//========================================================================
2// GLFW 3.4 Cocoa - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include <IOKit/IOKitLib.h>
28#include <IOKit/IOCFPlugIn.h>
29#include <IOKit/hid/IOHIDKeys.h>
30
31#define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns;
32#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
33
34// Cocoa-specific per-joystick data
35//
36typedef struct _GLFWjoystickNS
37{
38 IOHIDDeviceRef device;
39 CFMutableArrayRef axes;
40 CFMutableArrayRef buttons;
41 CFMutableArrayRef hats;
42} _GLFWjoystickNS;
43
44GLFWbool _glfwInitJoysticksCocoa(void);
45void _glfwTerminateJoysticksCocoa(void);
46GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode);
47const char* _glfwGetMappingNameCocoa(void);
48void _glfwUpdateGamepadGUIDCocoa(char* guid);
49
diff --git a/raylib/src/external/glfw/src/cocoa_joystick.m b/raylib/src/external/glfw/src/cocoa_joystick.m
new file mode 100644
index 0000000..d5de479
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_joystick.m
@@ -0,0 +1,485 @@
1//========================================================================
2// GLFW 3.4 Cocoa - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
5// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_COCOA)
31
32#include <unistd.h>
33#include <ctype.h>
34#include <string.h>
35
36#include <mach/mach.h>
37#include <mach/mach_error.h>
38
39#include <CoreFoundation/CoreFoundation.h>
40#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
41
42
43// Joystick element information
44//
45typedef struct _GLFWjoyelementNS
46{
47 IOHIDElementRef native;
48 uint32_t usage;
49 int index;
50 long minimum;
51 long maximum;
52
53} _GLFWjoyelementNS;
54
55
56// Returns the value of the specified element of the specified joystick
57//
58static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element)
59{
60 IOHIDValueRef valueRef;
61 long value = 0;
62
63 if (js->ns.device)
64 {
65 if (IOHIDDeviceGetValue(js->ns.device,
66 element->native,
67 &valueRef) == kIOReturnSuccess)
68 {
69 value = IOHIDValueGetIntegerValue(valueRef);
70 }
71 }
72
73 return value;
74}
75
76// Comparison function for matching the SDL element order
77//
78static CFComparisonResult compareElements(const void* fp,
79 const void* sp,
80 void* user)
81{
82 const _GLFWjoyelementNS* fe = fp;
83 const _GLFWjoyelementNS* se = sp;
84 if (fe->usage < se->usage)
85 return kCFCompareLessThan;
86 if (fe->usage > se->usage)
87 return kCFCompareGreaterThan;
88 if (fe->index < se->index)
89 return kCFCompareLessThan;
90 if (fe->index > se->index)
91 return kCFCompareGreaterThan;
92 return kCFCompareEqualTo;
93}
94
95// Removes the specified joystick
96//
97static void closeJoystick(_GLFWjoystick* js)
98{
99 _glfwInputJoystick(js, GLFW_DISCONNECTED);
100
101 for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++)
102 _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
103 CFRelease(js->ns.axes);
104
105 for (int i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
106 _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
107 CFRelease(js->ns.buttons);
108
109 for (int i = 0; i < CFArrayGetCount(js->ns.hats); i++)
110 _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
111 CFRelease(js->ns.hats);
112
113 _glfwFreeJoystick(js);
114}
115
116// Callback for user-initiated joystick addition
117//
118static void matchCallback(void* context,
119 IOReturn result,
120 void* sender,
121 IOHIDDeviceRef device)
122{
123 int jid;
124 char name[256];
125 char guid[33];
126 CFTypeRef property;
127 uint32_t vendor = 0, product = 0, version = 0;
128 _GLFWjoystick* js;
129 CFMutableArrayRef axes, buttons, hats;
130
131 for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
132 {
133 if (_glfw.joysticks[jid].ns.device == device)
134 return;
135 }
136
137 CFArrayRef elements =
138 IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
139
140 // It is reportedly possible for this to fail on macOS 13 Ventura
141 // if the application does not have input monitoring permissions
142 if (!elements)
143 return;
144
145 axes = CFArrayCreateMutable(NULL, 0, NULL);
146 buttons = CFArrayCreateMutable(NULL, 0, NULL);
147 hats = CFArrayCreateMutable(NULL, 0, NULL);
148
149 property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
150 if (property)
151 {
152 CFStringGetCString(property,
153 name,
154 sizeof(name),
155 kCFStringEncodingUTF8);
156 }
157 else
158 strncpy(name, "Unknown", sizeof(name));
159
160 property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey));
161 if (property)
162 CFNumberGetValue(property, kCFNumberSInt32Type, &vendor);
163
164 property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey));
165 if (property)
166 CFNumberGetValue(property, kCFNumberSInt32Type, &product);
167
168 property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVersionNumberKey));
169 if (property)
170 CFNumberGetValue(property, kCFNumberSInt32Type, &version);
171
172 // Generate a joystick GUID that matches the SDL 2.0.5+ one
173 if (vendor && product)
174 {
175 sprintf(guid, "03000000%02x%02x0000%02x%02x0000%02x%02x0000",
176 (uint8_t) vendor, (uint8_t) (vendor >> 8),
177 (uint8_t) product, (uint8_t) (product >> 8),
178 (uint8_t) version, (uint8_t) (version >> 8));
179 }
180 else
181 {
182 sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
183 name[0], name[1], name[2], name[3],
184 name[4], name[5], name[6], name[7],
185 name[8], name[9], name[10]);
186 }
187
188 for (CFIndex i = 0; i < CFArrayGetCount(elements); i++)
189 {
190 IOHIDElementRef native = (IOHIDElementRef)
191 CFArrayGetValueAtIndex(elements, i);
192 if (CFGetTypeID(native) != IOHIDElementGetTypeID())
193 continue;
194
195 const IOHIDElementType type = IOHIDElementGetType(native);
196 if ((type != kIOHIDElementTypeInput_Axis) &&
197 (type != kIOHIDElementTypeInput_Button) &&
198 (type != kIOHIDElementTypeInput_Misc))
199 {
200 continue;
201 }
202
203 CFMutableArrayRef target = NULL;
204
205 const uint32_t usage = IOHIDElementGetUsage(native);
206 const uint32_t page = IOHIDElementGetUsagePage(native);
207 if (page == kHIDPage_GenericDesktop)
208 {
209 switch (usage)
210 {
211 case kHIDUsage_GD_X:
212 case kHIDUsage_GD_Y:
213 case kHIDUsage_GD_Z:
214 case kHIDUsage_GD_Rx:
215 case kHIDUsage_GD_Ry:
216 case kHIDUsage_GD_Rz:
217 case kHIDUsage_GD_Slider:
218 case kHIDUsage_GD_Dial:
219 case kHIDUsage_GD_Wheel:
220 target = axes;
221 break;
222 case kHIDUsage_GD_Hatswitch:
223 target = hats;
224 break;
225 case kHIDUsage_GD_DPadUp:
226 case kHIDUsage_GD_DPadRight:
227 case kHIDUsage_GD_DPadDown:
228 case kHIDUsage_GD_DPadLeft:
229 case kHIDUsage_GD_SystemMainMenu:
230 case kHIDUsage_GD_Select:
231 case kHIDUsage_GD_Start:
232 target = buttons;
233 break;
234 }
235 }
236 else if (page == kHIDPage_Simulation)
237 {
238 switch (usage)
239 {
240 case kHIDUsage_Sim_Accelerator:
241 case kHIDUsage_Sim_Brake:
242 case kHIDUsage_Sim_Throttle:
243 case kHIDUsage_Sim_Rudder:
244 case kHIDUsage_Sim_Steering:
245 target = axes;
246 break;
247 }
248 }
249 else if (page == kHIDPage_Button || page == kHIDPage_Consumer)
250 target = buttons;
251
252 if (target)
253 {
254 _GLFWjoyelementNS* element = _glfw_calloc(1, sizeof(_GLFWjoyelementNS));
255 element->native = native;
256 element->usage = usage;
257 element->index = (int) CFArrayGetCount(target);
258 element->minimum = IOHIDElementGetLogicalMin(native);
259 element->maximum = IOHIDElementGetLogicalMax(native);
260 CFArrayAppendValue(target, element);
261 }
262 }
263
264 CFRelease(elements);
265
266 CFArraySortValues(axes, CFRangeMake(0, CFArrayGetCount(axes)),
267 compareElements, NULL);
268 CFArraySortValues(buttons, CFRangeMake(0, CFArrayGetCount(buttons)),
269 compareElements, NULL);
270 CFArraySortValues(hats, CFRangeMake(0, CFArrayGetCount(hats)),
271 compareElements, NULL);
272
273 js = _glfwAllocJoystick(name, guid,
274 (int) CFArrayGetCount(axes),
275 (int) CFArrayGetCount(buttons),
276 (int) CFArrayGetCount(hats));
277
278 js->ns.device = device;
279 js->ns.axes = axes;
280 js->ns.buttons = buttons;
281 js->ns.hats = hats;
282
283 _glfwInputJoystick(js, GLFW_CONNECTED);
284}
285
286// Callback for user-initiated joystick removal
287//
288static void removeCallback(void* context,
289 IOReturn result,
290 void* sender,
291 IOHIDDeviceRef device)
292{
293 for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
294 {
295 if (_glfw.joysticks[jid].connected && _glfw.joysticks[jid].ns.device == device)
296 {
297 closeJoystick(&_glfw.joysticks[jid]);
298 break;
299 }
300 }
301}
302
303
304//////////////////////////////////////////////////////////////////////////
305////// GLFW platform API //////
306//////////////////////////////////////////////////////////////////////////
307
308GLFWbool _glfwInitJoysticksCocoa(void)
309{
310 CFMutableArrayRef matching;
311 const long usages[] =
312 {
313 kHIDUsage_GD_Joystick,
314 kHIDUsage_GD_GamePad,
315 kHIDUsage_GD_MultiAxisController
316 };
317
318 _glfw.ns.hidManager = IOHIDManagerCreate(kCFAllocatorDefault,
319 kIOHIDOptionsTypeNone);
320
321 matching = CFArrayCreateMutable(kCFAllocatorDefault,
322 0,
323 &kCFTypeArrayCallBacks);
324 if (!matching)
325 {
326 _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
327 return GLFW_FALSE;
328 }
329
330 for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++)
331 {
332 const long page = kHIDPage_GenericDesktop;
333
334 CFMutableDictionaryRef dict =
335 CFDictionaryCreateMutable(kCFAllocatorDefault,
336 0,
337 &kCFTypeDictionaryKeyCallBacks,
338 &kCFTypeDictionaryValueCallBacks);
339 if (!dict)
340 continue;
341
342 CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault,
343 kCFNumberLongType,
344 &page);
345 CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault,
346 kCFNumberLongType,
347 &usages[i]);
348 if (pageRef && usageRef)
349 {
350 CFDictionarySetValue(dict,
351 CFSTR(kIOHIDDeviceUsagePageKey),
352 pageRef);
353 CFDictionarySetValue(dict,
354 CFSTR(kIOHIDDeviceUsageKey),
355 usageRef);
356 CFArrayAppendValue(matching, dict);
357 }
358
359 if (pageRef)
360 CFRelease(pageRef);
361 if (usageRef)
362 CFRelease(usageRef);
363
364 CFRelease(dict);
365 }
366
367 IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns.hidManager, matching);
368 CFRelease(matching);
369
370 IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns.hidManager,
371 &matchCallback, NULL);
372 IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns.hidManager,
373 &removeCallback, NULL);
374 IOHIDManagerScheduleWithRunLoop(_glfw.ns.hidManager,
375 CFRunLoopGetMain(),
376 kCFRunLoopDefaultMode);
377 IOHIDManagerOpen(_glfw.ns.hidManager, kIOHIDOptionsTypeNone);
378
379 // Execute the run loop once in order to register any initially-attached
380 // joysticks
381 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
382 return GLFW_TRUE;
383}
384
385void _glfwTerminateJoysticksCocoa(void)
386{
387 for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
388 {
389 if (_glfw.joysticks[jid].connected)
390 closeJoystick(&_glfw.joysticks[jid]);
391 }
392
393 if (_glfw.ns.hidManager)
394 {
395 CFRelease(_glfw.ns.hidManager);
396 _glfw.ns.hidManager = NULL;
397 }
398}
399
400
401GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
402{
403 if (mode & _GLFW_POLL_AXES)
404 {
405 for (CFIndex i = 0; i < CFArrayGetCount(js->ns.axes); i++)
406 {
407 _GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
408 CFArrayGetValueAtIndex(js->ns.axes, i);
409
410 const long raw = getElementValue(js, axis);
411 // Perform auto calibration
412 if (raw < axis->minimum)
413 axis->minimum = raw;
414 if (raw > axis->maximum)
415 axis->maximum = raw;
416
417 const long size = axis->maximum - axis->minimum;
418 if (size == 0)
419 _glfwInputJoystickAxis(js, (int) i, 0.f);
420 else
421 {
422 const float value = (2.f * (raw - axis->minimum) / size) - 1.f;
423 _glfwInputJoystickAxis(js, (int) i, value);
424 }
425 }
426 }
427
428 if (mode & _GLFW_POLL_BUTTONS)
429 {
430 for (CFIndex i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
431 {
432 _GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
433 CFArrayGetValueAtIndex(js->ns.buttons, i);
434 const char value = getElementValue(js, button) - button->minimum;
435 const int state = (value > 0) ? GLFW_PRESS : GLFW_RELEASE;
436 _glfwInputJoystickButton(js, (int) i, state);
437 }
438
439 for (CFIndex i = 0; i < CFArrayGetCount(js->ns.hats); i++)
440 {
441 const int states[9] =
442 {
443 GLFW_HAT_UP,
444 GLFW_HAT_RIGHT_UP,
445 GLFW_HAT_RIGHT,
446 GLFW_HAT_RIGHT_DOWN,
447 GLFW_HAT_DOWN,
448 GLFW_HAT_LEFT_DOWN,
449 GLFW_HAT_LEFT,
450 GLFW_HAT_LEFT_UP,
451 GLFW_HAT_CENTERED
452 };
453
454 _GLFWjoyelementNS* hat = (_GLFWjoyelementNS*)
455 CFArrayGetValueAtIndex(js->ns.hats, i);
456 long state = getElementValue(js, hat) - hat->minimum;
457 if (state < 0 || state > 8)
458 state = 8;
459
460 _glfwInputJoystickHat(js, (int) i, states[state]);
461 }
462 }
463
464 return js->connected;
465}
466
467const char* _glfwGetMappingNameCocoa(void)
468{
469 return "Mac OS X";
470}
471
472void _glfwUpdateGamepadGUIDCocoa(char* guid)
473{
474 if ((strncmp(guid + 4, "000000000000", 12) == 0) &&
475 (strncmp(guid + 20, "000000000000", 12) == 0))
476 {
477 char original[33];
478 strncpy(original, guid, sizeof(original) - 1);
479 sprintf(guid, "03000000%.4s0000%.4s000000000000",
480 original, original + 16);
481 }
482}
483
484#endif // _GLFW_COCOA
485
diff --git a/raylib/src/external/glfw/src/cocoa_monitor.m b/raylib/src/external/glfw/src/cocoa_monitor.m
new file mode 100644
index 0000000..a2bcc2f
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_monitor.m
@@ -0,0 +1,644 @@
1//========================================================================
2// GLFW 3.4 macOS (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#if defined(_GLFW_COCOA)
32
33#include <stdlib.h>
34#include <limits.h>
35#include <math.h>
36
37#include <IOKit/graphics/IOGraphicsLib.h>
38#include <ApplicationServices/ApplicationServices.h>
39
40
41// Get the name of the specified display, or NULL
42//
43static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
44{
45 // IOKit doesn't work on Apple Silicon anymore
46 // Luckily, 10.15 introduced -[NSScreen localizedName].
47 // Use it if available, and fall back to IOKit otherwise.
48 if (screen)
49 {
50 if ([screen respondsToSelector:@selector(localizedName)])
51 {
52 NSString* name = [screen valueForKey:@"localizedName"];
53 if (name)
54 return _glfw_strdup([name UTF8String]);
55 }
56 }
57
58 io_iterator_t it;
59 io_service_t service;
60 CFDictionaryRef info;
61
62 if (IOServiceGetMatchingServices(MACH_PORT_NULL,
63 IOServiceMatching("IODisplayConnect"),
64 &it) != 0)
65 {
66 // This may happen if a desktop Mac is running headless
67 return _glfw_strdup("Display");
68 }
69
70 while ((service = IOIteratorNext(it)) != 0)
71 {
72 info = IODisplayCreateInfoDictionary(service,
73 kIODisplayOnlyPreferredName);
74
75 CFNumberRef vendorIDRef =
76 CFDictionaryGetValue(info, CFSTR(kDisplayVendorID));
77 CFNumberRef productIDRef =
78 CFDictionaryGetValue(info, CFSTR(kDisplayProductID));
79 if (!vendorIDRef || !productIDRef)
80 {
81 CFRelease(info);
82 continue;
83 }
84
85 unsigned int vendorID, productID;
86 CFNumberGetValue(vendorIDRef, kCFNumberIntType, &vendorID);
87 CFNumberGetValue(productIDRef, kCFNumberIntType, &productID);
88
89 if (CGDisplayVendorNumber(displayID) == vendorID &&
90 CGDisplayModelNumber(displayID) == productID)
91 {
92 // Info dictionary is used and freed below
93 break;
94 }
95
96 CFRelease(info);
97 }
98
99 IOObjectRelease(it);
100
101 if (!service)
102 return _glfw_strdup("Display");
103
104 CFDictionaryRef names =
105 CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
106
107 CFStringRef nameRef;
108
109 if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
110 (const void**) &nameRef))
111 {
112 // This may happen if a desktop Mac is running headless
113 CFRelease(info);
114 return _glfw_strdup("Display");
115 }
116
117 const CFIndex size =
118 CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef),
119 kCFStringEncodingUTF8);
120 char* name = _glfw_calloc(size + 1, 1);
121 CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8);
122
123 CFRelease(info);
124 return name;
125}
126
127// Check whether the display mode should be included in enumeration
128//
129static GLFWbool modeIsGood(CGDisplayModeRef mode)
130{
131 uint32_t flags = CGDisplayModeGetIOFlags(mode);
132
133 if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
134 return GLFW_FALSE;
135 if (flags & kDisplayModeInterlacedFlag)
136 return GLFW_FALSE;
137 if (flags & kDisplayModeStretchedFlag)
138 return GLFW_FALSE;
139
140#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
141 CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
142 if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
143 CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
144 {
145 CFRelease(format);
146 return GLFW_FALSE;
147 }
148
149 CFRelease(format);
150#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
151 return GLFW_TRUE;
152}
153
154// Convert Core Graphics display mode to GLFW video mode
155//
156static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
157 double fallbackRefreshRate)
158{
159 GLFWvidmode result;
160 result.width = (int) CGDisplayModeGetWidth(mode);
161 result.height = (int) CGDisplayModeGetHeight(mode);
162 result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
163
164 if (result.refreshRate == 0)
165 result.refreshRate = (int) round(fallbackRefreshRate);
166
167#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
168 CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
169 if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
170 {
171 result.redBits = 5;
172 result.greenBits = 5;
173 result.blueBits = 5;
174 }
175 else
176#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
177 {
178 result.redBits = 8;
179 result.greenBits = 8;
180 result.blueBits = 8;
181 }
182
183#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
184 CFRelease(format);
185#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
186 return result;
187}
188
189// Starts reservation for display fading
190//
191static CGDisplayFadeReservationToken beginFadeReservation(void)
192{
193 CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken;
194
195 if (CGAcquireDisplayFadeReservation(5, &token) == kCGErrorSuccess)
196 {
197 CGDisplayFade(token, 0.3,
198 kCGDisplayBlendNormal,
199 kCGDisplayBlendSolidColor,
200 0.0, 0.0, 0.0,
201 TRUE);
202 }
203
204 return token;
205}
206
207// Ends reservation for display fading
208//
209static void endFadeReservation(CGDisplayFadeReservationToken token)
210{
211 if (token != kCGDisplayFadeReservationInvalidToken)
212 {
213 CGDisplayFade(token, 0.5,
214 kCGDisplayBlendSolidColor,
215 kCGDisplayBlendNormal,
216 0.0, 0.0, 0.0,
217 FALSE);
218 CGReleaseDisplayFadeReservation(token);
219 }
220}
221
222// Returns the display refresh rate queried from the I/O registry
223//
224static double getFallbackRefreshRate(CGDirectDisplayID displayID)
225{
226 double refreshRate = 60.0;
227
228 io_iterator_t it;
229 io_service_t service;
230
231 if (IOServiceGetMatchingServices(MACH_PORT_NULL,
232 IOServiceMatching("IOFramebuffer"),
233 &it) != 0)
234 {
235 return refreshRate;
236 }
237
238 while ((service = IOIteratorNext(it)) != 0)
239 {
240 const CFNumberRef indexRef =
241 IORegistryEntryCreateCFProperty(service,
242 CFSTR("IOFramebufferOpenGLIndex"),
243 kCFAllocatorDefault,
244 kNilOptions);
245 if (!indexRef)
246 continue;
247
248 uint32_t index = 0;
249 CFNumberGetValue(indexRef, kCFNumberIntType, &index);
250 CFRelease(indexRef);
251
252 if (CGOpenGLDisplayMaskToDisplayID(1 << index) != displayID)
253 continue;
254
255 const CFNumberRef clockRef =
256 IORegistryEntryCreateCFProperty(service,
257 CFSTR("IOFBCurrentPixelClock"),
258 kCFAllocatorDefault,
259 kNilOptions);
260 const CFNumberRef countRef =
261 IORegistryEntryCreateCFProperty(service,
262 CFSTR("IOFBCurrentPixelCount"),
263 kCFAllocatorDefault,
264 kNilOptions);
265
266 uint32_t clock = 0, count = 0;
267
268 if (clockRef)
269 {
270 CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
271 CFRelease(clockRef);
272 }
273
274 if (countRef)
275 {
276 CFNumberGetValue(countRef, kCFNumberIntType, &count);
277 CFRelease(countRef);
278 }
279
280 if (clock > 0 && count > 0)
281 refreshRate = clock / (double) count;
282
283 break;
284 }
285
286 IOObjectRelease(it);
287 return refreshRate;
288}
289
290
291//////////////////////////////////////////////////////////////////////////
292////// GLFW internal API //////
293//////////////////////////////////////////////////////////////////////////
294
295// Poll for changes in the set of connected monitors
296//
297void _glfwPollMonitorsCocoa(void)
298{
299 uint32_t displayCount;
300 CGGetOnlineDisplayList(0, NULL, &displayCount);
301 CGDirectDisplayID* displays = _glfw_calloc(displayCount, sizeof(CGDirectDisplayID));
302 CGGetOnlineDisplayList(displayCount, displays, &displayCount);
303
304 for (int i = 0; i < _glfw.monitorCount; i++)
305 _glfw.monitors[i]->ns.screen = nil;
306
307 _GLFWmonitor** disconnected = NULL;
308 uint32_t disconnectedCount = _glfw.monitorCount;
309 if (disconnectedCount)
310 {
311 disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
312 memcpy(disconnected,
313 _glfw.monitors,
314 _glfw.monitorCount * sizeof(_GLFWmonitor*));
315 }
316
317 for (uint32_t i = 0; i < displayCount; i++)
318 {
319 if (CGDisplayIsAsleep(displays[i]))
320 continue;
321
322 const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
323 NSScreen* screen = nil;
324
325 for (screen in [NSScreen screens])
326 {
327 NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
328
329 // HACK: Compare unit numbers instead of display IDs to work around
330 // display replacement on machines with automatic graphics
331 // switching
332 if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber)
333 break;
334 }
335
336 // HACK: Compare unit numbers instead of display IDs to work around
337 // display replacement on machines with automatic graphics
338 // switching
339 uint32_t j;
340 for (j = 0; j < disconnectedCount; j++)
341 {
342 if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
343 {
344 disconnected[j]->ns.screen = screen;
345 disconnected[j] = NULL;
346 break;
347 }
348 }
349
350 if (j < disconnectedCount)
351 continue;
352
353 const CGSize size = CGDisplayScreenSize(displays[i]);
354 char* name = getMonitorName(displays[i], screen);
355 if (!name)
356 continue;
357
358 _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
359 monitor->ns.displayID = displays[i];
360 monitor->ns.unitNumber = unitNumber;
361 monitor->ns.screen = screen;
362
363 _glfw_free(name);
364
365 CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
366 if (CGDisplayModeGetRefreshRate(mode) == 0.0)
367 monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]);
368 CGDisplayModeRelease(mode);
369
370 _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
371 }
372
373 for (uint32_t i = 0; i < disconnectedCount; i++)
374 {
375 if (disconnected[i])
376 _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
377 }
378
379 _glfw_free(disconnected);
380 _glfw_free(displays);
381}
382
383// Change the current video mode
384//
385void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired)
386{
387 GLFWvidmode current;
388 _glfwGetVideoModeCocoa(monitor, &current);
389
390 const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
391 if (_glfwCompareVideoModes(&current, best) == 0)
392 return;
393
394 CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
395 const CFIndex count = CFArrayGetCount(modes);
396 CGDisplayModeRef native = NULL;
397
398 for (CFIndex i = 0; i < count; i++)
399 {
400 CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
401 if (!modeIsGood(dm))
402 continue;
403
404 const GLFWvidmode mode =
405 vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
406 if (_glfwCompareVideoModes(best, &mode) == 0)
407 {
408 native = dm;
409 break;
410 }
411 }
412
413 if (native)
414 {
415 if (monitor->ns.previousMode == NULL)
416 monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
417
418 CGDisplayFadeReservationToken token = beginFadeReservation();
419 CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);
420 endFadeReservation(token);
421 }
422
423 CFRelease(modes);
424}
425
426// Restore the previously saved (original) video mode
427//
428void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor)
429{
430 if (monitor->ns.previousMode)
431 {
432 CGDisplayFadeReservationToken token = beginFadeReservation();
433 CGDisplaySetDisplayMode(monitor->ns.displayID,
434 monitor->ns.previousMode, NULL);
435 endFadeReservation(token);
436
437 CGDisplayModeRelease(monitor->ns.previousMode);
438 monitor->ns.previousMode = NULL;
439 }
440}
441
442
443//////////////////////////////////////////////////////////////////////////
444////// GLFW platform API //////
445//////////////////////////////////////////////////////////////////////////
446
447void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor)
448{
449}
450
451void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos)
452{
453 @autoreleasepool {
454
455 const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);
456
457 if (xpos)
458 *xpos = (int) bounds.origin.x;
459 if (ypos)
460 *ypos = (int) bounds.origin.y;
461
462 } // autoreleasepool
463}
464
465void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor,
466 float* xscale, float* yscale)
467{
468 @autoreleasepool {
469
470 if (!monitor->ns.screen)
471 {
472 _glfwInputError(GLFW_PLATFORM_ERROR,
473 "Cocoa: Cannot query content scale without screen");
474 }
475
476 const NSRect points = [monitor->ns.screen frame];
477 const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
478
479 if (xscale)
480 *xscale = (float) (pixels.size.width / points.size.width);
481 if (yscale)
482 *yscale = (float) (pixels.size.height / points.size.height);
483
484 } // autoreleasepool
485}
486
487void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor,
488 int* xpos, int* ypos,
489 int* width, int* height)
490{
491 @autoreleasepool {
492
493 if (!monitor->ns.screen)
494 {
495 _glfwInputError(GLFW_PLATFORM_ERROR,
496 "Cocoa: Cannot query workarea without screen");
497 }
498
499 const NSRect frameRect = [monitor->ns.screen visibleFrame];
500
501 if (xpos)
502 *xpos = frameRect.origin.x;
503 if (ypos)
504 *ypos = _glfwTransformYCocoa(frameRect.origin.y + frameRect.size.height - 1);
505 if (width)
506 *width = frameRect.size.width;
507 if (height)
508 *height = frameRect.size.height;
509
510 } // autoreleasepool
511}
512
513GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
514{
515 @autoreleasepool {
516
517 *count = 0;
518
519 CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
520 const CFIndex found = CFArrayGetCount(modes);
521 GLFWvidmode* result = _glfw_calloc(found, sizeof(GLFWvidmode));
522
523 for (CFIndex i = 0; i < found; i++)
524 {
525 CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
526 if (!modeIsGood(dm))
527 continue;
528
529 const GLFWvidmode mode =
530 vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
531 CFIndex j;
532
533 for (j = 0; j < *count; j++)
534 {
535 if (_glfwCompareVideoModes(result + j, &mode) == 0)
536 break;
537 }
538
539 // Skip duplicate modes
540 if (j < *count)
541 continue;
542
543 (*count)++;
544 result[*count - 1] = mode;
545 }
546
547 CFRelease(modes);
548 return result;
549
550 } // autoreleasepool
551}
552
553GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
554{
555 @autoreleasepool {
556
557 CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
558 if (!native)
559 {
560 _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to query display mode");
561 return GLFW_FALSE;
562 }
563
564 *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
565 CGDisplayModeRelease(native);
566 return GLFW_TRUE;
567
568 } // autoreleasepool
569}
570
571GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
572{
573 @autoreleasepool {
574
575 uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
576 CGGammaValue* values = _glfw_calloc(size * 3, sizeof(CGGammaValue));
577
578 CGGetDisplayTransferByTable(monitor->ns.displayID,
579 size,
580 values,
581 values + size,
582 values + size * 2,
583 &size);
584
585 _glfwAllocGammaArrays(ramp, size);
586
587 for (uint32_t i = 0; i < size; i++)
588 {
589 ramp->red[i] = (unsigned short) (values[i] * 65535);
590 ramp->green[i] = (unsigned short) (values[i + size] * 65535);
591 ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
592 }
593
594 _glfw_free(values);
595 return GLFW_TRUE;
596
597 } // autoreleasepool
598}
599
600void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
601{
602 @autoreleasepool {
603
604 CGGammaValue* values = _glfw_calloc(ramp->size * 3, sizeof(CGGammaValue));
605
606 for (unsigned int i = 0; i < ramp->size; i++)
607 {
608 values[i] = ramp->red[i] / 65535.f;
609 values[i + ramp->size] = ramp->green[i] / 65535.f;
610 values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
611 }
612
613 CGSetDisplayTransferByTable(monitor->ns.displayID,
614 ramp->size,
615 values,
616 values + ramp->size,
617 values + ramp->size * 2);
618
619 _glfw_free(values);
620
621 } // autoreleasepool
622}
623
624
625//////////////////////////////////////////////////////////////////////////
626////// GLFW native API //////
627//////////////////////////////////////////////////////////////////////////
628
629GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
630{
631 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
632 _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
633
634 if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
635 {
636 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Cocoa: Platform not initialized");
637 return kCGNullDirectDisplay;
638 }
639
640 return monitor->ns.displayID;
641}
642
643#endif // _GLFW_COCOA
644
diff --git a/raylib/src/external/glfw/src/cocoa_platform.h b/raylib/src/external/glfw/src/cocoa_platform.h
new file mode 100644
index 0000000..3991455
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_platform.h
@@ -0,0 +1,302 @@
1//========================================================================
2// GLFW 3.4 macOS - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include <stdint.h>
28
29#include <Carbon/Carbon.h>
30#include <IOKit/hid/IOHIDLib.h>
31
32// NOTE: All of NSGL was deprecated in the 10.14 SDK
33// This disables the pointless warnings for every symbol we use
34#ifndef GL_SILENCE_DEPRECATION
35#define GL_SILENCE_DEPRECATION
36#endif
37
38#if defined(__OBJC__)
39#import <Cocoa/Cocoa.h>
40#else
41typedef void* id;
42#endif
43
44// NOTE: Many Cocoa enum values have been renamed and we need to build across
45// SDK versions where one is unavailable or deprecated.
46// We use the newer names in code and replace them with the older names if
47// the base SDK does not provide the newer names.
48
49#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
50 #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
51 #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
52#endif
53
54#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
55 #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
56 #define NSEventMaskAny NSAnyEventMask
57 #define NSEventMaskKeyUp NSKeyUpMask
58 #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
59 #define NSEventModifierFlagCommand NSCommandKeyMask
60 #define NSEventModifierFlagControl NSControlKeyMask
61 #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
62 #define NSEventModifierFlagOption NSAlternateKeyMask
63 #define NSEventModifierFlagShift NSShiftKeyMask
64 #define NSEventTypeApplicationDefined NSApplicationDefined
65 #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
66 #define NSWindowStyleMaskClosable NSClosableWindowMask
67 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
68 #define NSWindowStyleMaskResizable NSResizableWindowMask
69 #define NSWindowStyleMaskTitled NSTitledWindowMask
70#endif
71
72// NOTE: Many Cocoa dynamically linked constants have been renamed and we need
73// to build across SDK versions where one is unavailable or deprecated.
74// We use the newer names in code and replace them with the older names if
75// the deployment target is older than the newer names.
76
77#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
78 #define NSPasteboardTypeURL NSURLPboardType
79#endif
80
81typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
82typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
83
84typedef struct VkMacOSSurfaceCreateInfoMVK
85{
86 VkStructureType sType;
87 const void* pNext;
88 VkMacOSSurfaceCreateFlagsMVK flags;
89 const void* pView;
90} VkMacOSSurfaceCreateInfoMVK;
91
92typedef struct VkMetalSurfaceCreateInfoEXT
93{
94 VkStructureType sType;
95 const void* pNext;
96 VkMetalSurfaceCreateFlagsEXT flags;
97 const void* pLayer;
98} VkMetalSurfaceCreateInfoEXT;
99
100typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
101typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
102
103#define GLFW_COCOA_WINDOW_STATE _GLFWwindowNS ns;
104#define GLFW_COCOA_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns;
105#define GLFW_COCOA_MONITOR_STATE _GLFWmonitorNS ns;
106#define GLFW_COCOA_CURSOR_STATE _GLFWcursorNS ns;
107
108#define GLFW_NSGL_CONTEXT_STATE _GLFWcontextNSGL nsgl;
109#define GLFW_NSGL_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl;
110
111// HIToolbox.framework pointer typedefs
112#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
113typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
114#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
115typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
116#define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty
117typedef UInt8 (*PFN_LMGetKbdType)(void);
118#define LMGetKbdType _glfw.ns.tis.GetKbdType
119
120
121// NSGL-specific per-context data
122//
123typedef struct _GLFWcontextNSGL
124{
125 id pixelFormat;
126 id object;
127} _GLFWcontextNSGL;
128
129// NSGL-specific global data
130//
131typedef struct _GLFWlibraryNSGL
132{
133 // dlopen handle for OpenGL.framework (for glfwGetProcAddress)
134 CFBundleRef framework;
135} _GLFWlibraryNSGL;
136
137// Cocoa-specific per-window data
138//
139typedef struct _GLFWwindowNS
140{
141 id object;
142 id delegate;
143 id view;
144 id layer;
145
146 GLFWbool maximized;
147 GLFWbool occluded;
148 GLFWbool scaleFramebuffer;
149
150 // Cached window properties to filter out duplicate events
151 int width, height;
152 int fbWidth, fbHeight;
153 float xscale, yscale;
154
155 // The total sum of the distances the cursor has been warped
156 // since the last cursor motion event was processed
157 // This is kept to counteract Cocoa doing the same internally
158 double cursorWarpDeltaX, cursorWarpDeltaY;
159} _GLFWwindowNS;
160
161// Cocoa-specific global data
162//
163typedef struct _GLFWlibraryNS
164{
165 CGEventSourceRef eventSource;
166 id delegate;
167 GLFWbool cursorHidden;
168 TISInputSourceRef inputSource;
169 IOHIDManagerRef hidManager;
170 id unicodeData;
171 id helper;
172 id keyUpMonitor;
173 id nibObjects;
174
175 char keynames[GLFW_KEY_LAST + 1][17];
176 short int keycodes[256];
177 short int scancodes[GLFW_KEY_LAST + 1];
178 char* clipboardString;
179 CGPoint cascadePoint;
180 // Where to place the cursor when re-enabled
181 double restoreCursorPosX, restoreCursorPosY;
182 // The window whose disabled cursor mode is active
183 _GLFWwindow* disabledCursorWindow;
184
185 struct {
186 CFBundleRef bundle;
187 PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
188 PFN_TISGetInputSourceProperty GetInputSourceProperty;
189 PFN_LMGetKbdType GetKbdType;
190 CFStringRef kPropertyUnicodeKeyLayoutData;
191 } tis;
192} _GLFWlibraryNS;
193
194// Cocoa-specific per-monitor data
195//
196typedef struct _GLFWmonitorNS
197{
198 CGDirectDisplayID displayID;
199 CGDisplayModeRef previousMode;
200 uint32_t unitNumber;
201 id screen;
202 double fallbackRefreshRate;
203} _GLFWmonitorNS;
204
205// Cocoa-specific per-cursor data
206//
207typedef struct _GLFWcursorNS
208{
209 id object;
210} _GLFWcursorNS;
211
212
213GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform);
214int _glfwInitCocoa(void);
215void _glfwTerminateCocoa(void);
216
217GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
218void _glfwDestroyWindowCocoa(_GLFWwindow* window);
219void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
220void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
221void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
222void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos);
223void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height);
224void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height);
225void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
226void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom);
227void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height);
228void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
229void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window, float* xscale, float* yscale);
230void _glfwIconifyWindowCocoa(_GLFWwindow* window);
231void _glfwRestoreWindowCocoa(_GLFWwindow* window);
232void _glfwMaximizeWindowCocoa(_GLFWwindow* window);
233void _glfwShowWindowCocoa(_GLFWwindow* window);
234void _glfwHideWindowCocoa(_GLFWwindow* window);
235void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window);
236void _glfwFocusWindowCocoa(_GLFWwindow* window);
237void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
238GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window);
239GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window);
240GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window);
241GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow* window);
242GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window);
243GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window);
244void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled);
245void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled);
246void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
247float _glfwGetWindowOpacityCocoa(_GLFWwindow* window);
248void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity);
249void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled);
250
251void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled);
252GLFWbool _glfwRawMouseMotionSupportedCocoa(void);
253
254void _glfwPollEventsCocoa(void);
255void _glfwWaitEventsCocoa(void);
256void _glfwWaitEventsTimeoutCocoa(double timeout);
257void _glfwPostEmptyEventCocoa(void);
258
259void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos);
260void _glfwSetCursorPosCocoa(_GLFWwindow* window, double xpos, double ypos);
261void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode);
262const char* _glfwGetScancodeNameCocoa(int scancode);
263int _glfwGetKeyScancodeCocoa(int key);
264GLFWbool _glfwCreateCursorCocoa(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
265GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape);
266void _glfwDestroyCursorCocoa(_GLFWcursor* cursor);
267void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor);
268void _glfwSetClipboardStringCocoa(const char* string);
269const char* _glfwGetClipboardStringCocoa(void);
270
271EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs);
272EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void);
273EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window);
274
275void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions);
276GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
277VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
278
279void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
280void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
281void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
282void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
283GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count);
284GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode);
285GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
286void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
287
288void _glfwPollMonitorsCocoa(void);
289void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired);
290void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor);
291
292float _glfwTransformYCocoa(float y);
293
294void* _glfwLoadLocalVulkanLoaderCocoa(void);
295
296GLFWbool _glfwInitNSGL(void);
297void _glfwTerminateNSGL(void);
298GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
299 const _GLFWctxconfig* ctxconfig,
300 const _GLFWfbconfig* fbconfig);
301void _glfwDestroyContextNSGL(_GLFWwindow* window);
302
diff --git a/raylib/src/external/glfw/src/cocoa_time.c b/raylib/src/external/glfw/src/cocoa_time.c
new file mode 100644
index 0000000..d56f145
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_time.c
@@ -0,0 +1,57 @@
1//========================================================================
2// GLFW 3.4 macOS - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include "internal.h"
28
29#if defined(GLFW_BUILD_COCOA_TIMER)
30
31#include <mach/mach_time.h>
32
33
34//////////////////////////////////////////////////////////////////////////
35////// GLFW platform API //////
36//////////////////////////////////////////////////////////////////////////
37
38void _glfwPlatformInitTimer(void)
39{
40 mach_timebase_info_data_t info;
41 mach_timebase_info(&info);
42
43 _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
44}
45
46uint64_t _glfwPlatformGetTimerValue(void)
47{
48 return mach_absolute_time();
49}
50
51uint64_t _glfwPlatformGetTimerFrequency(void)
52{
53 return _glfw.timer.ns.frequency;
54}
55
56#endif // GLFW_BUILD_COCOA_TIMER
57
diff --git a/raylib/src/external/glfw/src/cocoa_time.h b/raylib/src/external/glfw/src/cocoa_time.h
new file mode 100644
index 0000000..3512e8b
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_time.h
@@ -0,0 +1,35 @@
1//========================================================================
2// GLFW 3.4 macOS - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2021 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#define GLFW_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns;
28
29// Cocoa-specific global timer data
30//
31typedef struct _GLFWtimerNS
32{
33 uint64_t frequency;
34} _GLFWtimerNS;
35
diff --git a/raylib/src/external/glfw/src/cocoa_window.m b/raylib/src/external/glfw/src/cocoa_window.m
new file mode 100644
index 0000000..949cace
--- /dev/null
+++ b/raylib/src/external/glfw/src/cocoa_window.m
@@ -0,0 +1,2072 @@
1//========================================================================
2// GLFW 3.4 macOS - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include "internal.h"
28
29#if defined(_GLFW_COCOA)
30
31#include <float.h>
32#include <string.h>
33
34// HACK: This enum value is missing from framework headers on OS X 10.11 despite
35// having been (according to documentation) added in Mac OS X 10.7
36#define NSWindowCollectionBehaviorFullScreenNone (1 << 9)
37
38// Returns whether the cursor is in the content area of the specified window
39//
40static GLFWbool cursorInContentArea(_GLFWwindow* window)
41{
42 const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
43 return [window->ns.view mouse:pos inRect:[window->ns.view frame]];
44}
45
46// Hides the cursor if not already hidden
47//
48static void hideCursor(_GLFWwindow* window)
49{
50 if (!_glfw.ns.cursorHidden)
51 {
52 [NSCursor hide];
53 _glfw.ns.cursorHidden = GLFW_TRUE;
54 }
55}
56
57// Shows the cursor if not already shown
58//
59static void showCursor(_GLFWwindow* window)
60{
61 if (_glfw.ns.cursorHidden)
62 {
63 [NSCursor unhide];
64 _glfw.ns.cursorHidden = GLFW_FALSE;
65 }
66}
67
68// Updates the cursor image according to its cursor mode
69//
70static void updateCursorImage(_GLFWwindow* window)
71{
72 if (window->cursorMode == GLFW_CURSOR_NORMAL)
73 {
74 showCursor(window);
75
76 if (window->cursor)
77 [(NSCursor*) window->cursor->ns.object set];
78 else
79 [[NSCursor arrowCursor] set];
80 }
81 else
82 hideCursor(window);
83}
84
85// Apply chosen cursor mode to a focused window
86//
87static void updateCursorMode(_GLFWwindow* window)
88{
89 if (window->cursorMode == GLFW_CURSOR_DISABLED)
90 {
91 _glfw.ns.disabledCursorWindow = window;
92 _glfwGetCursorPosCocoa(window,
93 &_glfw.ns.restoreCursorPosX,
94 &_glfw.ns.restoreCursorPosY);
95 _glfwCenterCursorInContentArea(window);
96 CGAssociateMouseAndMouseCursorPosition(false);
97 }
98 else if (_glfw.ns.disabledCursorWindow == window)
99 {
100 _glfw.ns.disabledCursorWindow = NULL;
101 _glfwSetCursorPosCocoa(window,
102 _glfw.ns.restoreCursorPosX,
103 _glfw.ns.restoreCursorPosY);
104 // NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is
105 // made in _glfwSetCursorPosCocoa as part of a workaround
106 }
107
108 if (cursorInContentArea(window))
109 updateCursorImage(window);
110}
111
112// Make the specified window and its video mode active on its monitor
113//
114static void acquireMonitorCocoa(_GLFWwindow* window)
115{
116 _glfwSetVideoModeCocoa(window->monitor, &window->videoMode);
117 const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
118 const NSRect frame = NSMakeRect(bounds.origin.x,
119 _glfwTransformYCocoa(bounds.origin.y + bounds.size.height - 1),
120 bounds.size.width,
121 bounds.size.height);
122
123 [window->ns.object setFrame:frame display:YES];
124
125 _glfwInputMonitorWindow(window->monitor, window);
126}
127
128// Remove the window and restore the original video mode
129//
130static void releaseMonitorCocoa(_GLFWwindow* window)
131{
132 if (window->monitor->window != window)
133 return;
134
135 _glfwInputMonitorWindow(window->monitor, NULL);
136 _glfwRestoreVideoModeCocoa(window->monitor);
137}
138
139// Translates macOS key modifiers into GLFW ones
140//
141static int translateFlags(NSUInteger flags)
142{
143 int mods = 0;
144
145 if (flags & NSEventModifierFlagShift)
146 mods |= GLFW_MOD_SHIFT;
147 if (flags & NSEventModifierFlagControl)
148 mods |= GLFW_MOD_CONTROL;
149 if (flags & NSEventModifierFlagOption)
150 mods |= GLFW_MOD_ALT;
151 if (flags & NSEventModifierFlagCommand)
152 mods |= GLFW_MOD_SUPER;
153 if (flags & NSEventModifierFlagCapsLock)
154 mods |= GLFW_MOD_CAPS_LOCK;
155
156 return mods;
157}
158
159// Translates a macOS keycode to a GLFW keycode
160//
161static int translateKeyCocoa(unsigned int key)
162{
163 if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0]))
164 return GLFW_KEY_UNKNOWN;
165
166 return _glfw.ns.keycodes[key];
167}
168
169// Translate a GLFW keycode to a Cocoa modifier flag
170//
171static NSUInteger translateKeyToModifierFlag(int key)
172{
173 switch (key)
174 {
175 case GLFW_KEY_LEFT_SHIFT:
176 case GLFW_KEY_RIGHT_SHIFT:
177 return NSEventModifierFlagShift;
178 case GLFW_KEY_LEFT_CONTROL:
179 case GLFW_KEY_RIGHT_CONTROL:
180 return NSEventModifierFlagControl;
181 case GLFW_KEY_LEFT_ALT:
182 case GLFW_KEY_RIGHT_ALT:
183 return NSEventModifierFlagOption;
184 case GLFW_KEY_LEFT_SUPER:
185 case GLFW_KEY_RIGHT_SUPER:
186 return NSEventModifierFlagCommand;
187 case GLFW_KEY_CAPS_LOCK:
188 return NSEventModifierFlagCapsLock;
189 }
190
191 return 0;
192}
193
194// Defines a constant for empty ranges in NSTextInputClient
195//
196static const NSRange kEmptyRange = { NSNotFound, 0 };
197
198
199//------------------------------------------------------------------------
200// Delegate for window related notifications
201//------------------------------------------------------------------------
202
203@interface GLFWWindowDelegate : NSObject
204{
205 _GLFWwindow* window;
206}
207
208- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
209
210@end
211
212@implementation GLFWWindowDelegate
213
214- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
215{
216 self = [super init];
217 if (self != nil)
218 window = initWindow;
219
220 return self;
221}
222
223- (BOOL)windowShouldClose:(id)sender
224{
225 _glfwInputWindowCloseRequest(window);
226 return NO;
227}
228
229- (void)windowDidResize:(NSNotification *)notification
230{
231 if (window->context.source == GLFW_NATIVE_CONTEXT_API)
232 [window->context.nsgl.object update];
233
234 if (_glfw.ns.disabledCursorWindow == window)
235 _glfwCenterCursorInContentArea(window);
236
237 const int maximized = [window->ns.object isZoomed];
238 if (window->ns.maximized != maximized)
239 {
240 window->ns.maximized = maximized;
241 _glfwInputWindowMaximize(window, maximized);
242 }
243
244 const NSRect contentRect = [window->ns.view frame];
245 const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
246
247 if (fbRect.size.width != window->ns.fbWidth ||
248 fbRect.size.height != window->ns.fbHeight)
249 {
250 window->ns.fbWidth = fbRect.size.width;
251 window->ns.fbHeight = fbRect.size.height;
252 _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
253 }
254
255 if (contentRect.size.width != window->ns.width ||
256 contentRect.size.height != window->ns.height)
257 {
258 window->ns.width = contentRect.size.width;
259 window->ns.height = contentRect.size.height;
260 _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
261 }
262}
263
264- (void)windowDidMove:(NSNotification *)notification
265{
266 if (window->context.source == GLFW_NATIVE_CONTEXT_API)
267 [window->context.nsgl.object update];
268
269 if (_glfw.ns.disabledCursorWindow == window)
270 _glfwCenterCursorInContentArea(window);
271
272 int x, y;
273 _glfwGetWindowPosCocoa(window, &x, &y);
274 _glfwInputWindowPos(window, x, y);
275}
276
277- (void)windowDidMiniaturize:(NSNotification *)notification
278{
279 if (window->monitor)
280 releaseMonitorCocoa(window);
281
282 _glfwInputWindowIconify(window, GLFW_TRUE);
283}
284
285- (void)windowDidDeminiaturize:(NSNotification *)notification
286{
287 if (window->monitor)
288 acquireMonitorCocoa(window);
289
290 _glfwInputWindowIconify(window, GLFW_FALSE);
291}
292
293- (void)windowDidBecomeKey:(NSNotification *)notification
294{
295 if (_glfw.ns.disabledCursorWindow == window)
296 _glfwCenterCursorInContentArea(window);
297
298 _glfwInputWindowFocus(window, GLFW_TRUE);
299 updateCursorMode(window);
300}
301
302- (void)windowDidResignKey:(NSNotification *)notification
303{
304 if (window->monitor && window->autoIconify)
305 _glfwIconifyWindowCocoa(window);
306
307 _glfwInputWindowFocus(window, GLFW_FALSE);
308}
309
310- (void)windowDidChangeOcclusionState:(NSNotification* )notification
311{
312#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
313 if ([window->ns.object respondsToSelector:@selector(occlusionState)])
314 {
315 if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
316 window->ns.occluded = GLFW_FALSE;
317 else
318 window->ns.occluded = GLFW_TRUE;
319 }
320#endif
321}
322
323@end
324
325
326//------------------------------------------------------------------------
327// Content view class for the GLFW window
328//------------------------------------------------------------------------
329
330@interface GLFWContentView : NSView <NSTextInputClient>
331{
332 _GLFWwindow* window;
333 NSTrackingArea* trackingArea;
334 NSMutableAttributedString* markedText;
335}
336
337- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
338
339@end
340
341@implementation GLFWContentView
342
343- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
344{
345 self = [super init];
346 if (self != nil)
347 {
348 window = initWindow;
349 trackingArea = nil;
350 markedText = [[NSMutableAttributedString alloc] init];
351
352 [self updateTrackingAreas];
353 [self registerForDraggedTypes:@[NSPasteboardTypeURL]];
354 }
355
356 return self;
357}
358
359- (void)dealloc
360{
361 [trackingArea release];
362 [markedText release];
363 [super dealloc];
364}
365
366- (BOOL)isOpaque
367{
368 return [window->ns.object isOpaque];
369}
370
371- (BOOL)canBecomeKeyView
372{
373 return YES;
374}
375
376- (BOOL)acceptsFirstResponder
377{
378 return YES;
379}
380
381- (BOOL)wantsUpdateLayer
382{
383 return YES;
384}
385
386- (void)updateLayer
387{
388 if (window->context.source == GLFW_NATIVE_CONTEXT_API)
389 [window->context.nsgl.object update];
390
391 _glfwInputWindowDamage(window);
392}
393
394- (void)cursorUpdate:(NSEvent *)event
395{
396 updateCursorImage(window);
397}
398
399- (BOOL)acceptsFirstMouse:(NSEvent *)event
400{
401 return YES;
402}
403
404- (void)mouseDown:(NSEvent *)event
405{
406 _glfwInputMouseClick(window,
407 GLFW_MOUSE_BUTTON_LEFT,
408 GLFW_PRESS,
409 translateFlags([event modifierFlags]));
410}
411
412- (void)mouseDragged:(NSEvent *)event
413{
414 [self mouseMoved:event];
415}
416
417- (void)mouseUp:(NSEvent *)event
418{
419 _glfwInputMouseClick(window,
420 GLFW_MOUSE_BUTTON_LEFT,
421 GLFW_RELEASE,
422 translateFlags([event modifierFlags]));
423}
424
425- (void)mouseMoved:(NSEvent *)event
426{
427 if (window->cursorMode == GLFW_CURSOR_DISABLED)
428 {
429 const double dx = [event deltaX] - window->ns.cursorWarpDeltaX;
430 const double dy = [event deltaY] - window->ns.cursorWarpDeltaY;
431
432 _glfwInputCursorPos(window,
433 window->virtualCursorPosX + dx,
434 window->virtualCursorPosY + dy);
435 }
436 else
437 {
438 const NSRect contentRect = [window->ns.view frame];
439 // NOTE: The returned location uses base 0,1 not 0,0
440 const NSPoint pos = [event locationInWindow];
441
442 _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
443 }
444
445 window->ns.cursorWarpDeltaX = 0;
446 window->ns.cursorWarpDeltaY = 0;
447}
448
449- (void)rightMouseDown:(NSEvent *)event
450{
451 _glfwInputMouseClick(window,
452 GLFW_MOUSE_BUTTON_RIGHT,
453 GLFW_PRESS,
454 translateFlags([event modifierFlags]));
455}
456
457- (void)rightMouseDragged:(NSEvent *)event
458{
459 [self mouseMoved:event];
460}
461
462- (void)rightMouseUp:(NSEvent *)event
463{
464 _glfwInputMouseClick(window,
465 GLFW_MOUSE_BUTTON_RIGHT,
466 GLFW_RELEASE,
467 translateFlags([event modifierFlags]));
468}
469
470- (void)otherMouseDown:(NSEvent *)event
471{
472 _glfwInputMouseClick(window,
473 (int) [event buttonNumber],
474 GLFW_PRESS,
475 translateFlags([event modifierFlags]));
476}
477
478- (void)otherMouseDragged:(NSEvent *)event
479{
480 [self mouseMoved:event];
481}
482
483- (void)otherMouseUp:(NSEvent *)event
484{
485 _glfwInputMouseClick(window,
486 (int) [event buttonNumber],
487 GLFW_RELEASE,
488 translateFlags([event modifierFlags]));
489}
490
491- (void)mouseExited:(NSEvent *)event
492{
493 if (window->cursorMode == GLFW_CURSOR_HIDDEN)
494 showCursor(window);
495
496 _glfwInputCursorEnter(window, GLFW_FALSE);
497}
498
499- (void)mouseEntered:(NSEvent *)event
500{
501 if (window->cursorMode == GLFW_CURSOR_HIDDEN)
502 hideCursor(window);
503
504 _glfwInputCursorEnter(window, GLFW_TRUE);
505}
506
507- (void)viewDidChangeBackingProperties
508{
509 const NSRect contentRect = [window->ns.view frame];
510 const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
511 const float xscale = fbRect.size.width / contentRect.size.width;
512 const float yscale = fbRect.size.height / contentRect.size.height;
513
514 if (xscale != window->ns.xscale || yscale != window->ns.yscale)
515 {
516 if (window->ns.scaleFramebuffer && window->ns.layer)
517 [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
518
519 window->ns.xscale = xscale;
520 window->ns.yscale = yscale;
521 _glfwInputWindowContentScale(window, xscale, yscale);
522 }
523
524 if (fbRect.size.width != window->ns.fbWidth ||
525 fbRect.size.height != window->ns.fbHeight)
526 {
527 window->ns.fbWidth = fbRect.size.width;
528 window->ns.fbHeight = fbRect.size.height;
529 _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
530 }
531}
532
533- (void)drawRect:(NSRect)rect
534{
535 _glfwInputWindowDamage(window);
536}
537
538- (void)updateTrackingAreas
539{
540 if (trackingArea != nil)
541 {
542 [self removeTrackingArea:trackingArea];
543 [trackingArea release];
544 }
545
546 const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
547 NSTrackingActiveInKeyWindow |
548 NSTrackingEnabledDuringMouseDrag |
549 NSTrackingCursorUpdate |
550 NSTrackingInVisibleRect |
551 NSTrackingAssumeInside;
552
553 trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
554 options:options
555 owner:self
556 userInfo:nil];
557
558 [self addTrackingArea:trackingArea];
559 [super updateTrackingAreas];
560}
561
562- (void)keyDown:(NSEvent *)event
563{
564 const int key = translateKeyCocoa([event keyCode]);
565 const int mods = translateFlags([event modifierFlags]);
566
567 _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
568
569 [self interpretKeyEvents:@[event]];
570}
571
572- (void)flagsChanged:(NSEvent *)event
573{
574 int action;
575 const unsigned int modifierFlags =
576 [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
577 const int key = translateKeyCocoa([event keyCode]);
578 const int mods = translateFlags(modifierFlags);
579 const NSUInteger keyFlag = translateKeyToModifierFlag(key);
580
581 if (keyFlag & modifierFlags)
582 {
583 if (window->keys[key] == GLFW_PRESS)
584 action = GLFW_RELEASE;
585 else
586 action = GLFW_PRESS;
587 }
588 else
589 action = GLFW_RELEASE;
590
591 _glfwInputKey(window, key, [event keyCode], action, mods);
592}
593
594- (void)keyUp:(NSEvent *)event
595{
596 const int key = translateKeyCocoa([event keyCode]);
597 const int mods = translateFlags([event modifierFlags]);
598 _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
599}
600
601- (void)scrollWheel:(NSEvent *)event
602{
603 double deltaX = [event scrollingDeltaX];
604 double deltaY = [event scrollingDeltaY];
605
606 if ([event hasPreciseScrollingDeltas])
607 {
608 deltaX *= 0.1;
609 deltaY *= 0.1;
610 }
611
612 if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
613 _glfwInputScroll(window, deltaX, deltaY);
614}
615
616- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
617{
618 // HACK: We don't know what to say here because we don't know what the
619 // application wants to do with the paths
620 return NSDragOperationGeneric;
621}
622
623- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
624{
625 const NSRect contentRect = [window->ns.view frame];
626 // NOTE: The returned location uses base 0,1 not 0,0
627 const NSPoint pos = [sender draggingLocation];
628 _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
629
630 NSPasteboard* pasteboard = [sender draggingPasteboard];
631 NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
632 NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
633 options:options];
634 const NSUInteger count = [urls count];
635 if (count)
636 {
637 char** paths = _glfw_calloc(count, sizeof(char*));
638
639 for (NSUInteger i = 0; i < count; i++)
640 paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]);
641
642 _glfwInputDrop(window, (int) count, (const char**) paths);
643
644 for (NSUInteger i = 0; i < count; i++)
645 _glfw_free(paths[i]);
646 _glfw_free(paths);
647 }
648
649 return YES;
650}
651
652- (BOOL)hasMarkedText
653{
654 return [markedText length] > 0;
655}
656
657- (NSRange)markedRange
658{
659 if ([markedText length] > 0)
660 return NSMakeRange(0, [markedText length] - 1);
661 else
662 return kEmptyRange;
663}
664
665- (NSRange)selectedRange
666{
667 return kEmptyRange;
668}
669
670- (void)setMarkedText:(id)string
671 selectedRange:(NSRange)selectedRange
672 replacementRange:(NSRange)replacementRange
673{
674 [markedText release];
675 if ([string isKindOfClass:[NSAttributedString class]])
676 markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string];
677 else
678 markedText = [[NSMutableAttributedString alloc] initWithString:string];
679}
680
681- (void)unmarkText
682{
683 [[markedText mutableString] setString:@""];
684}
685
686- (NSArray*)validAttributesForMarkedText
687{
688 return [NSArray array];
689}
690
691- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
692 actualRange:(NSRangePointer)actualRange
693{
694 return nil;
695}
696
697- (NSUInteger)characterIndexForPoint:(NSPoint)point
698{
699 return 0;
700}
701
702- (NSRect)firstRectForCharacterRange:(NSRange)range
703 actualRange:(NSRangePointer)actualRange
704{
705 const NSRect frame = [window->ns.view frame];
706 return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0);
707}
708
709- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
710{
711 NSString* characters;
712 NSEvent* event = [NSApp currentEvent];
713 const int mods = translateFlags([event modifierFlags]);
714 const int plain = !(mods & GLFW_MOD_SUPER);
715
716 if ([string isKindOfClass:[NSAttributedString class]])
717 characters = [string string];
718 else
719 characters = (NSString*) string;
720
721 NSRange range = NSMakeRange(0, [characters length]);
722 while (range.length)
723 {
724 uint32_t codepoint = 0;
725
726 if ([characters getBytes:&codepoint
727 maxLength:sizeof(codepoint)
728 usedLength:NULL
729 encoding:NSUTF32StringEncoding
730 options:0
731 range:range
732 remainingRange:&range])
733 {
734 if (codepoint >= 0xf700 && codepoint <= 0xf7ff)
735 continue;
736
737 _glfwInputChar(window, codepoint, mods, plain);
738 }
739 }
740}
741
742- (void)doCommandBySelector:(SEL)selector
743{
744}
745
746@end
747
748
749//------------------------------------------------------------------------
750// GLFW window class
751//------------------------------------------------------------------------
752
753@interface GLFWWindow : NSWindow {}
754@end
755
756@implementation GLFWWindow
757
758- (BOOL)canBecomeKeyWindow
759{
760 // Required for NSWindowStyleMaskBorderless windows
761 return YES;
762}
763
764- (BOOL)canBecomeMainWindow
765{
766 return YES;
767}
768
769@end
770
771
772// Create the Cocoa window
773//
774static GLFWbool createNativeWindow(_GLFWwindow* window,
775 const _GLFWwndconfig* wndconfig,
776 const _GLFWfbconfig* fbconfig)
777{
778 window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
779 if (window->ns.delegate == nil)
780 {
781 _glfwInputError(GLFW_PLATFORM_ERROR,
782 "Cocoa: Failed to create window delegate");
783 return GLFW_FALSE;
784 }
785
786 NSRect contentRect;
787
788 if (window->monitor)
789 {
790 GLFWvidmode mode;
791 int xpos, ypos;
792
793 _glfwGetVideoModeCocoa(window->monitor, &mode);
794 _glfwGetMonitorPosCocoa(window->monitor, &xpos, &ypos);
795
796 contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
797 }
798 else
799 {
800 if (wndconfig->xpos == GLFW_ANY_POSITION ||
801 wndconfig->ypos == GLFW_ANY_POSITION)
802 {
803 contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
804 }
805 else
806 {
807 const int xpos = wndconfig->xpos;
808 const int ypos = _glfwTransformYCocoa(wndconfig->ypos + wndconfig->height - 1);
809 contentRect = NSMakeRect(xpos, ypos, wndconfig->width, wndconfig->height);
810 }
811 }
812
813 NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;
814
815 if (window->monitor || !window->decorated)
816 styleMask |= NSWindowStyleMaskBorderless;
817 else
818 {
819 styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
820
821 if (window->resizable)
822 styleMask |= NSWindowStyleMaskResizable;
823 }
824
825 window->ns.object = [[GLFWWindow alloc]
826 initWithContentRect:contentRect
827 styleMask:styleMask
828 backing:NSBackingStoreBuffered
829 defer:NO];
830
831 if (window->ns.object == nil)
832 {
833 _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create window");
834 return GLFW_FALSE;
835 }
836
837 if (window->monitor)
838 [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
839 else
840 {
841 if (wndconfig->xpos == GLFW_ANY_POSITION ||
842 wndconfig->ypos == GLFW_ANY_POSITION)
843 {
844 [(NSWindow*) window->ns.object center];
845 _glfw.ns.cascadePoint =
846 NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
847 NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
848 }
849
850 if (wndconfig->resizable)
851 {
852 const NSWindowCollectionBehavior behavior =
853 NSWindowCollectionBehaviorFullScreenPrimary |
854 NSWindowCollectionBehaviorManaged;
855 [window->ns.object setCollectionBehavior:behavior];
856 }
857 else
858 {
859 const NSWindowCollectionBehavior behavior =
860 NSWindowCollectionBehaviorFullScreenNone;
861 [window->ns.object setCollectionBehavior:behavior];
862 }
863
864 if (wndconfig->floating)
865 [window->ns.object setLevel:NSFloatingWindowLevel];
866
867 if (wndconfig->maximized)
868 [window->ns.object zoom:nil];
869 }
870
871 if (strlen(wndconfig->ns.frameName))
872 [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)];
873
874 window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
875 window->ns.scaleFramebuffer = wndconfig->scaleFramebuffer;
876
877 if (fbconfig->transparent)
878 {
879 [window->ns.object setOpaque:NO];
880 [window->ns.object setHasShadow:NO];
881 [window->ns.object setBackgroundColor:[NSColor clearColor]];
882 }
883
884 [window->ns.object setContentView:window->ns.view];
885 [window->ns.object makeFirstResponder:window->ns.view];
886 [window->ns.object setTitle:@(wndconfig->title)];
887 [window->ns.object setDelegate:window->ns.delegate];
888 [window->ns.object setAcceptsMouseMovedEvents:YES];
889 [window->ns.object setRestorable:NO];
890
891#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
892 if ([window->ns.object respondsToSelector:@selector(setTabbingMode:)])
893 [window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed];
894#endif
895
896 _glfwGetWindowSizeCocoa(window, &window->ns.width, &window->ns.height);
897 _glfwGetFramebufferSizeCocoa(window, &window->ns.fbWidth, &window->ns.fbHeight);
898
899 return GLFW_TRUE;
900}
901
902
903//////////////////////////////////////////////////////////////////////////
904////// GLFW internal API //////
905//////////////////////////////////////////////////////////////////////////
906
907// Transforms a y-coordinate between the CG display and NS screen spaces
908//
909float _glfwTransformYCocoa(float y)
910{
911 return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
912}
913
914
915//////////////////////////////////////////////////////////////////////////
916////// GLFW platform API //////
917//////////////////////////////////////////////////////////////////////////
918
919GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window,
920 const _GLFWwndconfig* wndconfig,
921 const _GLFWctxconfig* ctxconfig,
922 const _GLFWfbconfig* fbconfig)
923{
924 @autoreleasepool {
925
926 if (!createNativeWindow(window, wndconfig, fbconfig))
927 return GLFW_FALSE;
928
929 if (ctxconfig->client != GLFW_NO_API)
930 {
931 if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
932 {
933 if (!_glfwInitNSGL())
934 return GLFW_FALSE;
935 if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
936 return GLFW_FALSE;
937 }
938 else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
939 {
940 // EGL implementation on macOS use CALayer* EGLNativeWindowType so we
941 // need to get the layer for EGL window surface creation.
942 [window->ns.view setWantsLayer:YES];
943 window->ns.layer = [window->ns.view layer];
944
945 if (!_glfwInitEGL())
946 return GLFW_FALSE;
947 if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
948 return GLFW_FALSE;
949 }
950 else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
951 {
952 if (!_glfwInitOSMesa())
953 return GLFW_FALSE;
954 if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
955 return GLFW_FALSE;
956 }
957
958 if (!_glfwRefreshContextAttribs(window, ctxconfig))
959 return GLFW_FALSE;
960 }
961
962 if (wndconfig->mousePassthrough)
963 _glfwSetWindowMousePassthroughCocoa(window, GLFW_TRUE);
964
965 if (window->monitor)
966 {
967 _glfwShowWindowCocoa(window);
968 _glfwFocusWindowCocoa(window);
969 acquireMonitorCocoa(window);
970
971 if (wndconfig->centerCursor)
972 _glfwCenterCursorInContentArea(window);
973 }
974 else
975 {
976 if (wndconfig->visible)
977 {
978 _glfwShowWindowCocoa(window);
979 if (wndconfig->focused)
980 _glfwFocusWindowCocoa(window);
981 }
982 }
983
984 return GLFW_TRUE;
985
986 } // autoreleasepool
987}
988
989void _glfwDestroyWindowCocoa(_GLFWwindow* window)
990{
991 @autoreleasepool {
992
993 if (_glfw.ns.disabledCursorWindow == window)
994 _glfw.ns.disabledCursorWindow = NULL;
995
996 [window->ns.object orderOut:nil];
997
998 if (window->monitor)
999 releaseMonitorCocoa(window);
1000
1001 if (window->context.destroy)
1002 window->context.destroy(window);
1003
1004 [window->ns.object setDelegate:nil];
1005 [window->ns.delegate release];
1006 window->ns.delegate = nil;
1007
1008 [window->ns.view release];
1009 window->ns.view = nil;
1010
1011 [window->ns.object close];
1012 window->ns.object = nil;
1013
1014 // HACK: Allow Cocoa to catch up before returning
1015 _glfwPollEventsCocoa();
1016
1017 } // autoreleasepool
1018}
1019
1020void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title)
1021{
1022 @autoreleasepool {
1023 NSString* string = @(title);
1024 [window->ns.object setTitle:string];
1025 // HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
1026 // if the window lacks NSWindowStyleMaskTitled
1027 [window->ns.object setMiniwindowTitle:string];
1028 } // autoreleasepool
1029}
1030
1031void _glfwSetWindowIconCocoa(_GLFWwindow* window,
1032 int count, const GLFWimage* images)
1033{
1034 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
1035 "Cocoa: Regular windows do not have icons on macOS");
1036}
1037
1038void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos)
1039{
1040 @autoreleasepool {
1041
1042 const NSRect contentRect =
1043 [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
1044
1045 if (xpos)
1046 *xpos = contentRect.origin.x;
1047 if (ypos)
1048 *ypos = _glfwTransformYCocoa(contentRect.origin.y + contentRect.size.height - 1);
1049
1050 } // autoreleasepool
1051}
1052
1053void _glfwSetWindowPosCocoa(_GLFWwindow* window, int x, int y)
1054{
1055 @autoreleasepool {
1056
1057 const NSRect contentRect = [window->ns.view frame];
1058 const NSRect dummyRect = NSMakeRect(x, _glfwTransformYCocoa(y + contentRect.size.height - 1), 0, 0);
1059 const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
1060 [window->ns.object setFrameOrigin:frameRect.origin];
1061
1062 } // autoreleasepool
1063}
1064
1065void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height)
1066{
1067 @autoreleasepool {
1068
1069 const NSRect contentRect = [window->ns.view frame];
1070
1071 if (width)
1072 *width = contentRect.size.width;
1073 if (height)
1074 *height = contentRect.size.height;
1075
1076 } // autoreleasepool
1077}
1078
1079void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height)
1080{
1081 @autoreleasepool {
1082
1083 if (window->monitor)
1084 {
1085 if (window->monitor->window == window)
1086 acquireMonitorCocoa(window);
1087 }
1088 else
1089 {
1090 NSRect contentRect =
1091 [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
1092 contentRect.origin.y += contentRect.size.height - height;
1093 contentRect.size = NSMakeSize(width, height);
1094 [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect]
1095 display:YES];
1096 }
1097
1098 } // autoreleasepool
1099}
1100
1101void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window,
1102 int minwidth, int minheight,
1103 int maxwidth, int maxheight)
1104{
1105 @autoreleasepool {
1106
1107 if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
1108 [window->ns.object setContentMinSize:NSMakeSize(0, 0)];
1109 else
1110 [window->ns.object setContentMinSize:NSMakeSize(minwidth, minheight)];
1111
1112 if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
1113 [window->ns.object setContentMaxSize:NSMakeSize(DBL_MAX, DBL_MAX)];
1114 else
1115 [window->ns.object setContentMaxSize:NSMakeSize(maxwidth, maxheight)];
1116
1117 } // autoreleasepool
1118}
1119
1120void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom)
1121{
1122 @autoreleasepool {
1123 if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
1124 [window->ns.object setResizeIncrements:NSMakeSize(1.0, 1.0)];
1125 else
1126 [window->ns.object setContentAspectRatio:NSMakeSize(numer, denom)];
1127 } // autoreleasepool
1128}
1129
1130void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height)
1131{
1132 @autoreleasepool {
1133
1134 const NSRect contentRect = [window->ns.view frame];
1135 const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
1136
1137 if (width)
1138 *width = (int) fbRect.size.width;
1139 if (height)
1140 *height = (int) fbRect.size.height;
1141
1142 } // autoreleasepool
1143}
1144
1145void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window,
1146 int* left, int* top,
1147 int* right, int* bottom)
1148{
1149 @autoreleasepool {
1150
1151 const NSRect contentRect = [window->ns.view frame];
1152 const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect];
1153
1154 if (left)
1155 *left = contentRect.origin.x - frameRect.origin.x;
1156 if (top)
1157 *top = frameRect.origin.y + frameRect.size.height -
1158 contentRect.origin.y - contentRect.size.height;
1159 if (right)
1160 *right = frameRect.origin.x + frameRect.size.width -
1161 contentRect.origin.x - contentRect.size.width;
1162 if (bottom)
1163 *bottom = contentRect.origin.y - frameRect.origin.y;
1164
1165 } // autoreleasepool
1166}
1167
1168void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window,
1169 float* xscale, float* yscale)
1170{
1171 @autoreleasepool {
1172
1173 const NSRect points = [window->ns.view frame];
1174 const NSRect pixels = [window->ns.view convertRectToBacking:points];
1175
1176 if (xscale)
1177 *xscale = (float) (pixels.size.width / points.size.width);
1178 if (yscale)
1179 *yscale = (float) (pixels.size.height / points.size.height);
1180
1181 } // autoreleasepool
1182}
1183
1184void _glfwIconifyWindowCocoa(_GLFWwindow* window)
1185{
1186 @autoreleasepool {
1187 [window->ns.object miniaturize:nil];
1188 } // autoreleasepool
1189}
1190
1191void _glfwRestoreWindowCocoa(_GLFWwindow* window)
1192{
1193 @autoreleasepool {
1194 if ([window->ns.object isMiniaturized])
1195 [window->ns.object deminiaturize:nil];
1196 else if ([window->ns.object isZoomed])
1197 [window->ns.object zoom:nil];
1198 } // autoreleasepool
1199}
1200
1201void _glfwMaximizeWindowCocoa(_GLFWwindow* window)
1202{
1203 @autoreleasepool {
1204 if (![window->ns.object isZoomed])
1205 [window->ns.object zoom:nil];
1206 } // autoreleasepool
1207}
1208
1209void _glfwShowWindowCocoa(_GLFWwindow* window)
1210{
1211 @autoreleasepool {
1212 [window->ns.object orderFront:nil];
1213 } // autoreleasepool
1214}
1215
1216void _glfwHideWindowCocoa(_GLFWwindow* window)
1217{
1218 @autoreleasepool {
1219 [window->ns.object orderOut:nil];
1220 } // autoreleasepool
1221}
1222
1223void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window)
1224{
1225 @autoreleasepool {
1226 [NSApp requestUserAttention:NSInformationalRequest];
1227 } // autoreleasepool
1228}
1229
1230void _glfwFocusWindowCocoa(_GLFWwindow* window)
1231{
1232 @autoreleasepool {
1233 // Make us the active application
1234 // HACK: This is here to prevent applications using only hidden windows from
1235 // being activated, but should probably not be done every time any
1236 // window is shown
1237 [NSApp activateIgnoringOtherApps:YES];
1238 [window->ns.object makeKeyAndOrderFront:nil];
1239 } // autoreleasepool
1240}
1241
1242void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
1243 _GLFWmonitor* monitor,
1244 int xpos, int ypos,
1245 int width, int height,
1246 int refreshRate)
1247{
1248 @autoreleasepool {
1249
1250 if (window->monitor == monitor)
1251 {
1252 if (monitor)
1253 {
1254 if (monitor->window == window)
1255 acquireMonitorCocoa(window);
1256 }
1257 else
1258 {
1259 const NSRect contentRect =
1260 NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height);
1261 const NSUInteger styleMask = [window->ns.object styleMask];
1262 const NSRect frameRect =
1263 [window->ns.object frameRectForContentRect:contentRect
1264 styleMask:styleMask];
1265
1266 [window->ns.object setFrame:frameRect display:YES];
1267 }
1268
1269 return;
1270 }
1271
1272 if (window->monitor)
1273 releaseMonitorCocoa(window);
1274
1275 _glfwInputWindowMonitor(window, monitor);
1276
1277 // HACK: Allow the state cached in Cocoa to catch up to reality
1278 // TODO: Solve this in a less terrible way
1279 _glfwPollEventsCocoa();
1280
1281 NSUInteger styleMask = [window->ns.object styleMask];
1282
1283 if (window->monitor)
1284 {
1285 styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable);
1286 styleMask |= NSWindowStyleMaskBorderless;
1287 }
1288 else
1289 {
1290 if (window->decorated)
1291 {
1292 styleMask &= ~NSWindowStyleMaskBorderless;
1293 styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
1294 }
1295
1296 if (window->resizable)
1297 styleMask |= NSWindowStyleMaskResizable;
1298 else
1299 styleMask &= ~NSWindowStyleMaskResizable;
1300 }
1301
1302 [window->ns.object setStyleMask:styleMask];
1303 // HACK: Changing the style mask can cause the first responder to be cleared
1304 [window->ns.object makeFirstResponder:window->ns.view];
1305
1306 if (window->monitor)
1307 {
1308 [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
1309 [window->ns.object setHasShadow:NO];
1310
1311 acquireMonitorCocoa(window);
1312 }
1313 else
1314 {
1315 NSRect contentRect = NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1),
1316 width, height);
1317 NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
1318 styleMask:styleMask];
1319 [window->ns.object setFrame:frameRect display:YES];
1320
1321 if (window->numer != GLFW_DONT_CARE &&
1322 window->denom != GLFW_DONT_CARE)
1323 {
1324 [window->ns.object setContentAspectRatio:NSMakeSize(window->numer,
1325 window->denom)];
1326 }
1327
1328 if (window->minwidth != GLFW_DONT_CARE &&
1329 window->minheight != GLFW_DONT_CARE)
1330 {
1331 [window->ns.object setContentMinSize:NSMakeSize(window->minwidth,
1332 window->minheight)];
1333 }
1334
1335 if (window->maxwidth != GLFW_DONT_CARE &&
1336 window->maxheight != GLFW_DONT_CARE)
1337 {
1338 [window->ns.object setContentMaxSize:NSMakeSize(window->maxwidth,
1339 window->maxheight)];
1340 }
1341
1342 if (window->floating)
1343 [window->ns.object setLevel:NSFloatingWindowLevel];
1344 else
1345 [window->ns.object setLevel:NSNormalWindowLevel];
1346
1347 if (window->resizable)
1348 {
1349 const NSWindowCollectionBehavior behavior =
1350 NSWindowCollectionBehaviorFullScreenPrimary |
1351 NSWindowCollectionBehaviorManaged;
1352 [window->ns.object setCollectionBehavior:behavior];
1353 }
1354 else
1355 {
1356 const NSWindowCollectionBehavior behavior =
1357 NSWindowCollectionBehaviorFullScreenNone;
1358 [window->ns.object setCollectionBehavior:behavior];
1359 }
1360
1361 [window->ns.object setHasShadow:YES];
1362 // HACK: Clearing NSWindowStyleMaskTitled resets and disables the window
1363 // title property but the miniwindow title property is unaffected
1364 [window->ns.object setTitle:[window->ns.object miniwindowTitle]];
1365 }
1366
1367 } // autoreleasepool
1368}
1369
1370GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window)
1371{
1372 @autoreleasepool {
1373 return [window->ns.object isKeyWindow];
1374 } // autoreleasepool
1375}
1376
1377GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window)
1378{
1379 @autoreleasepool {
1380 return [window->ns.object isMiniaturized];
1381 } // autoreleasepool
1382}
1383
1384GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window)
1385{
1386 @autoreleasepool {
1387 return [window->ns.object isVisible];
1388 } // autoreleasepool
1389}
1390
1391GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow* window)
1392{
1393 @autoreleasepool {
1394
1395 if (window->resizable)
1396 return [window->ns.object isZoomed];
1397 else
1398 return GLFW_FALSE;
1399
1400 } // autoreleasepool
1401}
1402
1403GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window)
1404{
1405 @autoreleasepool {
1406
1407 const NSPoint point = [NSEvent mouseLocation];
1408
1409 if ([NSWindow windowNumberAtPoint:point belowWindowWithWindowNumber:0] !=
1410 [window->ns.object windowNumber])
1411 {
1412 return GLFW_FALSE;
1413 }
1414
1415 return NSMouseInRect(point,
1416 [window->ns.object convertRectToScreen:[window->ns.view frame]], NO);
1417
1418 } // autoreleasepool
1419}
1420
1421GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window)
1422{
1423 @autoreleasepool {
1424 return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
1425 } // autoreleasepool
1426}
1427
1428void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled)
1429{
1430 @autoreleasepool {
1431
1432 const NSUInteger styleMask = [window->ns.object styleMask];
1433 if (enabled)
1434 {
1435 [window->ns.object setStyleMask:(styleMask | NSWindowStyleMaskResizable)];
1436 const NSWindowCollectionBehavior behavior =
1437 NSWindowCollectionBehaviorFullScreenPrimary |
1438 NSWindowCollectionBehaviorManaged;
1439 [window->ns.object setCollectionBehavior:behavior];
1440 }
1441 else
1442 {
1443 [window->ns.object setStyleMask:(styleMask & ~NSWindowStyleMaskResizable)];
1444 const NSWindowCollectionBehavior behavior =
1445 NSWindowCollectionBehaviorFullScreenNone;
1446 [window->ns.object setCollectionBehavior:behavior];
1447 }
1448
1449 } // autoreleasepool
1450}
1451
1452void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled)
1453{
1454 @autoreleasepool {
1455
1456 NSUInteger styleMask = [window->ns.object styleMask];
1457 if (enabled)
1458 {
1459 styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
1460 styleMask &= ~NSWindowStyleMaskBorderless;
1461 }
1462 else
1463 {
1464 styleMask |= NSWindowStyleMaskBorderless;
1465 styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
1466 }
1467
1468 [window->ns.object setStyleMask:styleMask];
1469 [window->ns.object makeFirstResponder:window->ns.view];
1470
1471 } // autoreleasepool
1472}
1473
1474void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled)
1475{
1476 @autoreleasepool {
1477 if (enabled)
1478 [window->ns.object setLevel:NSFloatingWindowLevel];
1479 else
1480 [window->ns.object setLevel:NSNormalWindowLevel];
1481 } // autoreleasepool
1482}
1483
1484void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled)
1485{
1486 @autoreleasepool {
1487 [window->ns.object setIgnoresMouseEvents:enabled];
1488 }
1489}
1490
1491float _glfwGetWindowOpacityCocoa(_GLFWwindow* window)
1492{
1493 @autoreleasepool {
1494 return (float) [window->ns.object alphaValue];
1495 } // autoreleasepool
1496}
1497
1498void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity)
1499{
1500 @autoreleasepool {
1501 [window->ns.object setAlphaValue:opacity];
1502 } // autoreleasepool
1503}
1504
1505void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled)
1506{
1507 _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
1508 "Cocoa: Raw mouse motion not yet implemented");
1509}
1510
1511GLFWbool _glfwRawMouseMotionSupportedCocoa(void)
1512{
1513 return GLFW_FALSE;
1514}
1515
1516void _glfwPollEventsCocoa(void)
1517{
1518 @autoreleasepool {
1519
1520 for (;;)
1521 {
1522 NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
1523 untilDate:[NSDate distantPast]
1524 inMode:NSDefaultRunLoopMode
1525 dequeue:YES];
1526 if (event == nil)
1527 break;
1528
1529 [NSApp sendEvent:event];
1530 }
1531
1532 } // autoreleasepool
1533}
1534
1535void _glfwWaitEventsCocoa(void)
1536{
1537 @autoreleasepool {
1538
1539 // I wanted to pass NO to dequeue:, and rely on PollEvents to
1540 // dequeue and send. For reasons not at all clear to me, passing
1541 // NO to dequeue: causes this method never to return.
1542 NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny
1543 untilDate:[NSDate distantFuture]
1544 inMode:NSDefaultRunLoopMode
1545 dequeue:YES];
1546 [NSApp sendEvent:event];
1547
1548 _glfwPollEventsCocoa();
1549
1550 } // autoreleasepool
1551}
1552
1553void _glfwWaitEventsTimeoutCocoa(double timeout)
1554{
1555 @autoreleasepool {
1556
1557 NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
1558 NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
1559 untilDate:date
1560 inMode:NSDefaultRunLoopMode
1561 dequeue:YES];
1562 if (event)
1563 [NSApp sendEvent:event];
1564
1565 _glfwPollEventsCocoa();
1566
1567 } // autoreleasepool
1568}
1569
1570void _glfwPostEmptyEventCocoa(void)
1571{
1572 @autoreleasepool {
1573
1574 NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
1575 location:NSMakePoint(0, 0)
1576 modifierFlags:0
1577 timestamp:0
1578 windowNumber:0
1579 context:nil
1580 subtype:0
1581 data1:0
1582 data2:0];
1583 [NSApp postEvent:event atStart:YES];
1584
1585 } // autoreleasepool
1586}
1587
1588void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos)
1589{
1590 @autoreleasepool {
1591
1592 const NSRect contentRect = [window->ns.view frame];
1593 // NOTE: The returned location uses base 0,1 not 0,0
1594 const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
1595
1596 if (xpos)
1597 *xpos = pos.x;
1598 if (ypos)
1599 *ypos = contentRect.size.height - pos.y;
1600
1601 } // autoreleasepool
1602}
1603
1604void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y)
1605{
1606 @autoreleasepool {
1607
1608 updateCursorImage(window);
1609
1610 const NSRect contentRect = [window->ns.view frame];
1611 // NOTE: The returned location uses base 0,1 not 0,0
1612 const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
1613
1614 window->ns.cursorWarpDeltaX += x - pos.x;
1615 window->ns.cursorWarpDeltaY += y - contentRect.size.height + pos.y;
1616
1617 if (window->monitor)
1618 {
1619 CGDisplayMoveCursorToPoint(window->monitor->ns.displayID,
1620 CGPointMake(x, y));
1621 }
1622 else
1623 {
1624 const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0);
1625 const NSRect globalRect = [window->ns.object convertRectToScreen:localRect];
1626 const NSPoint globalPoint = globalRect.origin;
1627
1628 CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
1629 _glfwTransformYCocoa(globalPoint.y)));
1630 }
1631
1632 // HACK: Calling this right after setting the cursor position prevents macOS
1633 // from freezing the cursor for a fraction of a second afterwards
1634 if (window->cursorMode != GLFW_CURSOR_DISABLED)
1635 CGAssociateMouseAndMouseCursorPosition(true);
1636
1637 } // autoreleasepool
1638}
1639
1640void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode)
1641{
1642 @autoreleasepool {
1643
1644 if (mode == GLFW_CURSOR_CAPTURED)
1645 {
1646 _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
1647 "Cocoa: Captured cursor mode not yet implemented");
1648 }
1649
1650 if (_glfwWindowFocusedCocoa(window))
1651 updateCursorMode(window);
1652
1653 } // autoreleasepool
1654}
1655
1656const char* _glfwGetScancodeNameCocoa(int scancode)
1657{
1658 @autoreleasepool {
1659
1660 if (scancode < 0 || scancode > 0xff)
1661 {
1662 _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
1663 return NULL;
1664 }
1665
1666 const int key = _glfw.ns.keycodes[scancode];
1667 if (key == GLFW_KEY_UNKNOWN)
1668 return NULL;
1669
1670 UInt32 deadKeyState = 0;
1671 UniChar characters[4];
1672 UniCharCount characterCount = 0;
1673
1674 if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes],
1675 scancode,
1676 kUCKeyActionDisplay,
1677 0,
1678 LMGetKbdType(),
1679 kUCKeyTranslateNoDeadKeysBit,
1680 &deadKeyState,
1681 sizeof(characters) / sizeof(characters[0]),
1682 &characterCount,
1683 characters) != noErr)
1684 {
1685 return NULL;
1686 }
1687
1688 if (!characterCount)
1689 return NULL;
1690
1691 CFStringRef string = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
1692 characters,
1693 characterCount,
1694 kCFAllocatorNull);
1695 CFStringGetCString(string,
1696 _glfw.ns.keynames[key],
1697 sizeof(_glfw.ns.keynames[key]),
1698 kCFStringEncodingUTF8);
1699 CFRelease(string);
1700
1701 return _glfw.ns.keynames[key];
1702
1703 } // autoreleasepool
1704}
1705
1706int _glfwGetKeyScancodeCocoa(int key)
1707{
1708 return _glfw.ns.scancodes[key];
1709}
1710
1711GLFWbool _glfwCreateCursorCocoa(_GLFWcursor* cursor,
1712 const GLFWimage* image,
1713 int xhot, int yhot)
1714{
1715 @autoreleasepool {
1716
1717 NSImage* native;
1718 NSBitmapImageRep* rep;
1719
1720 rep = [[NSBitmapImageRep alloc]
1721 initWithBitmapDataPlanes:NULL
1722 pixelsWide:image->width
1723 pixelsHigh:image->height
1724 bitsPerSample:8
1725 samplesPerPixel:4
1726 hasAlpha:YES
1727 isPlanar:NO
1728 colorSpaceName:NSCalibratedRGBColorSpace
1729 bitmapFormat:NSBitmapFormatAlphaNonpremultiplied
1730 bytesPerRow:image->width * 4
1731 bitsPerPixel:32];
1732
1733 if (rep == nil)
1734 return GLFW_FALSE;
1735
1736 memcpy([rep bitmapData], image->pixels, image->width * image->height * 4);
1737
1738 native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];
1739 [native addRepresentation:rep];
1740
1741 cursor->ns.object = [[NSCursor alloc] initWithImage:native
1742 hotSpot:NSMakePoint(xhot, yhot)];
1743
1744 [native release];
1745 [rep release];
1746
1747 if (cursor->ns.object == nil)
1748 return GLFW_FALSE;
1749
1750 return GLFW_TRUE;
1751
1752 } // autoreleasepool
1753}
1754
1755GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape)
1756{
1757 @autoreleasepool {
1758
1759 SEL cursorSelector = NULL;
1760
1761 // HACK: Try to use a private message
1762 switch (shape)
1763 {
1764 case GLFW_RESIZE_EW_CURSOR:
1765 cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
1766 break;
1767 case GLFW_RESIZE_NS_CURSOR:
1768 cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
1769 break;
1770 case GLFW_RESIZE_NWSE_CURSOR:
1771 cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
1772 break;
1773 case GLFW_RESIZE_NESW_CURSOR:
1774 cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
1775 break;
1776 }
1777
1778 if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
1779 {
1780 id object = [NSCursor performSelector:cursorSelector];
1781 if ([object isKindOfClass:[NSCursor class]])
1782 cursor->ns.object = object;
1783 }
1784
1785 if (!cursor->ns.object)
1786 {
1787 switch (shape)
1788 {
1789 case GLFW_ARROW_CURSOR:
1790 cursor->ns.object = [NSCursor arrowCursor];
1791 break;
1792 case GLFW_IBEAM_CURSOR:
1793 cursor->ns.object = [NSCursor IBeamCursor];
1794 break;
1795 case GLFW_CROSSHAIR_CURSOR:
1796 cursor->ns.object = [NSCursor crosshairCursor];
1797 break;
1798 case GLFW_POINTING_HAND_CURSOR:
1799 cursor->ns.object = [NSCursor pointingHandCursor];
1800 break;
1801 case GLFW_RESIZE_EW_CURSOR:
1802 cursor->ns.object = [NSCursor resizeLeftRightCursor];
1803 break;
1804 case GLFW_RESIZE_NS_CURSOR:
1805 cursor->ns.object = [NSCursor resizeUpDownCursor];
1806 break;
1807 case GLFW_RESIZE_ALL_CURSOR:
1808 cursor->ns.object = [NSCursor closedHandCursor];
1809 break;
1810 case GLFW_NOT_ALLOWED_CURSOR:
1811 cursor->ns.object = [NSCursor operationNotAllowedCursor];
1812 break;
1813 }
1814 }
1815
1816 if (!cursor->ns.object)
1817 {
1818 _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
1819 "Cocoa: Standard cursor shape unavailable");
1820 return GLFW_FALSE;
1821 }
1822
1823 [cursor->ns.object retain];
1824 return GLFW_TRUE;
1825
1826 } // autoreleasepool
1827}
1828
1829void _glfwDestroyCursorCocoa(_GLFWcursor* cursor)
1830{
1831 @autoreleasepool {
1832 if (cursor->ns.object)
1833 [(NSCursor*) cursor->ns.object release];
1834 } // autoreleasepool
1835}
1836
1837void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor)
1838{
1839 @autoreleasepool {
1840 if (cursorInContentArea(window))
1841 updateCursorImage(window);
1842 } // autoreleasepool
1843}
1844
1845void _glfwSetClipboardStringCocoa(const char* string)
1846{
1847 @autoreleasepool {
1848 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
1849 [pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil];
1850 [pasteboard setString:@(string) forType:NSPasteboardTypeString];
1851 } // autoreleasepool
1852}
1853
1854const char* _glfwGetClipboardStringCocoa(void)
1855{
1856 @autoreleasepool {
1857
1858 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
1859
1860 if (![[pasteboard types] containsObject:NSPasteboardTypeString])
1861 {
1862 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
1863 "Cocoa: Failed to retrieve string from pasteboard");
1864 return NULL;
1865 }
1866
1867 NSString* object = [pasteboard stringForType:NSPasteboardTypeString];
1868 if (!object)
1869 {
1870 _glfwInputError(GLFW_PLATFORM_ERROR,
1871 "Cocoa: Failed to retrieve object from pasteboard");
1872 return NULL;
1873 }
1874
1875 _glfw_free(_glfw.ns.clipboardString);
1876 _glfw.ns.clipboardString = _glfw_strdup([object UTF8String]);
1877
1878 return _glfw.ns.clipboardString;
1879
1880 } // autoreleasepool
1881}
1882
1883EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs)
1884{
1885 if (_glfw.egl.ANGLE_platform_angle)
1886 {
1887 int type = 0;
1888
1889 if (_glfw.egl.ANGLE_platform_angle_opengl)
1890 {
1891 if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
1892 type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
1893 }
1894
1895 if (_glfw.egl.ANGLE_platform_angle_metal)
1896 {
1897 if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_METAL)
1898 type = EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE;
1899 }
1900
1901 if (type)
1902 {
1903 *attribs = _glfw_calloc(3, sizeof(EGLint));
1904 (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
1905 (*attribs)[1] = type;
1906 (*attribs)[2] = EGL_NONE;
1907 return EGL_PLATFORM_ANGLE_ANGLE;
1908 }
1909 }
1910
1911 return 0;
1912}
1913
1914EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void)
1915{
1916 return EGL_DEFAULT_DISPLAY;
1917}
1918
1919EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window)
1920{
1921 return window->ns.layer;
1922}
1923
1924void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions)
1925{
1926 if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
1927 {
1928 extensions[0] = "VK_KHR_surface";
1929 extensions[1] = "VK_EXT_metal_surface";
1930 }
1931 else if (_glfw.vk.KHR_surface && _glfw.vk.MVK_macos_surface)
1932 {
1933 extensions[0] = "VK_KHR_surface";
1934 extensions[1] = "VK_MVK_macos_surface";
1935 }
1936}
1937
1938GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance,
1939 VkPhysicalDevice device,
1940 uint32_t queuefamily)
1941{
1942 return GLFW_TRUE;
1943}
1944
1945VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
1946 _GLFWwindow* window,
1947 const VkAllocationCallbacks* allocator,
1948 VkSurfaceKHR* surface)
1949{
1950 @autoreleasepool {
1951
1952#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
1953 // HACK: Dynamically load Core Animation to avoid adding an extra
1954 // dependency for the majority who don't use MoltenVK
1955 NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
1956 if (!bundle)
1957 {
1958 _glfwInputError(GLFW_PLATFORM_ERROR,
1959 "Cocoa: Failed to find QuartzCore.framework");
1960 return VK_ERROR_EXTENSION_NOT_PRESENT;
1961 }
1962
1963 // NOTE: Create the layer here as makeBackingLayer should not return nil
1964 window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer];
1965 if (!window->ns.layer)
1966 {
1967 _glfwInputError(GLFW_PLATFORM_ERROR,
1968 "Cocoa: Failed to create layer for view");
1969 return VK_ERROR_EXTENSION_NOT_PRESENT;
1970 }
1971
1972 if (window->ns.scaleFramebuffer)
1973 [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
1974
1975 [window->ns.view setLayer:window->ns.layer];
1976 [window->ns.view setWantsLayer:YES];
1977
1978 VkResult err;
1979
1980 if (_glfw.vk.EXT_metal_surface)
1981 {
1982 VkMetalSurfaceCreateInfoEXT sci;
1983
1984 PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
1985 vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT)
1986 vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT");
1987 if (!vkCreateMetalSurfaceEXT)
1988 {
1989 _glfwInputError(GLFW_API_UNAVAILABLE,
1990 "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension");
1991 return VK_ERROR_EXTENSION_NOT_PRESENT;
1992 }
1993
1994 memset(&sci, 0, sizeof(sci));
1995 sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
1996 sci.pLayer = window->ns.layer;
1997
1998 err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface);
1999 }
2000 else
2001 {
2002 VkMacOSSurfaceCreateInfoMVK sci;
2003
2004 PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
2005 vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)
2006 vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK");
2007 if (!vkCreateMacOSSurfaceMVK)
2008 {
2009 _glfwInputError(GLFW_API_UNAVAILABLE,
2010 "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension");
2011 return VK_ERROR_EXTENSION_NOT_PRESENT;
2012 }
2013
2014 memset(&sci, 0, sizeof(sci));
2015 sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
2016 sci.pView = window->ns.view;
2017
2018 err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface);
2019 }
2020
2021 if (err)
2022 {
2023 _glfwInputError(GLFW_PLATFORM_ERROR,
2024 "Cocoa: Failed to create Vulkan surface: %s",
2025 _glfwGetVulkanResultString(err));
2026 }
2027
2028 return err;
2029#else
2030 return VK_ERROR_EXTENSION_NOT_PRESENT;
2031#endif
2032
2033 } // autoreleasepool
2034}
2035
2036
2037//////////////////////////////////////////////////////////////////////////
2038////// GLFW native API //////
2039//////////////////////////////////////////////////////////////////////////
2040
2041GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
2042{
2043 _GLFWwindow* window = (_GLFWwindow*) handle;
2044 _GLFW_REQUIRE_INIT_OR_RETURN(nil);
2045
2046 if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
2047 {
2048 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
2049 "Cocoa: Platform not initialized");
2050 return nil;
2051 }
2052
2053 return window->ns.object;
2054}
2055
2056GLFWAPI id glfwGetCocoaView(GLFWwindow* handle)
2057{
2058 _GLFWwindow* window = (_GLFWwindow*) handle;
2059 _GLFW_REQUIRE_INIT_OR_RETURN(nil);
2060
2061 if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
2062 {
2063 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
2064 "Cocoa: Platform not initialized");
2065 return nil;
2066 }
2067
2068 return window->ns.view;
2069}
2070
2071#endif // _GLFW_COCOA
2072
diff --git a/raylib/src/external/glfw/src/context.c b/raylib/src/external/glfw/src/context.c
new file mode 100644
index 0000000..cc1fac4
--- /dev/null
+++ b/raylib/src/external/glfw/src/context.c
@@ -0,0 +1,765 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <assert.h>
31#include <stdio.h>
32#include <string.h>
33#include <limits.h>
34#include <stdio.h>
35
36
37//////////////////////////////////////////////////////////////////////////
38////// GLFW internal API //////
39//////////////////////////////////////////////////////////////////////////
40
41// Checks whether the desired context attributes are valid
42//
43// This function checks things like whether the specified client API version
44// exists and whether all relevant options have supported and non-conflicting
45// values
46//
47GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
48{
49 if (ctxconfig->source != GLFW_NATIVE_CONTEXT_API &&
50 ctxconfig->source != GLFW_EGL_CONTEXT_API &&
51 ctxconfig->source != GLFW_OSMESA_CONTEXT_API)
52 {
53 _glfwInputError(GLFW_INVALID_ENUM,
54 "Invalid context creation API 0x%08X",
55 ctxconfig->source);
56 return GLFW_FALSE;
57 }
58
59 if (ctxconfig->client != GLFW_NO_API &&
60 ctxconfig->client != GLFW_OPENGL_API &&
61 ctxconfig->client != GLFW_OPENGL_ES_API)
62 {
63 _glfwInputError(GLFW_INVALID_ENUM,
64 "Invalid client API 0x%08X",
65 ctxconfig->client);
66 return GLFW_FALSE;
67 }
68
69 if (ctxconfig->share)
70 {
71 if (ctxconfig->client == GLFW_NO_API ||
72 ctxconfig->share->context.client == GLFW_NO_API)
73 {
74 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
75 return GLFW_FALSE;
76 }
77
78 if (ctxconfig->source != ctxconfig->share->context.source)
79 {
80 _glfwInputError(GLFW_INVALID_ENUM,
81 "Context creation APIs do not match between contexts");
82 return GLFW_FALSE;
83 }
84 }
85
86 if (ctxconfig->client == GLFW_OPENGL_API)
87 {
88 if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
89 (ctxconfig->major == 1 && ctxconfig->minor > 5) ||
90 (ctxconfig->major == 2 && ctxconfig->minor > 1) ||
91 (ctxconfig->major == 3 && ctxconfig->minor > 3))
92 {
93 // OpenGL 1.0 is the smallest valid version
94 // OpenGL 1.x series ended with version 1.5
95 // OpenGL 2.x series ended with version 2.1
96 // OpenGL 3.x series ended with version 3.3
97 // For now, let everything else through
98
99 _glfwInputError(GLFW_INVALID_VALUE,
100 "Invalid OpenGL version %i.%i",
101 ctxconfig->major, ctxconfig->minor);
102 return GLFW_FALSE;
103 }
104
105 if (ctxconfig->profile)
106 {
107 if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
108 ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
109 {
110 _glfwInputError(GLFW_INVALID_ENUM,
111 "Invalid OpenGL profile 0x%08X",
112 ctxconfig->profile);
113 return GLFW_FALSE;
114 }
115
116 if (ctxconfig->major <= 2 ||
117 (ctxconfig->major == 3 && ctxconfig->minor < 2))
118 {
119 // Desktop OpenGL context profiles are only defined for version 3.2
120 // and above
121
122 _glfwInputError(GLFW_INVALID_VALUE,
123 "Context profiles are only defined for OpenGL version 3.2 and above");
124 return GLFW_FALSE;
125 }
126 }
127
128 if (ctxconfig->forward && ctxconfig->major <= 2)
129 {
130 // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
131 _glfwInputError(GLFW_INVALID_VALUE,
132 "Forward-compatibility is only defined for OpenGL version 3.0 and above");
133 return GLFW_FALSE;
134 }
135 }
136 else if (ctxconfig->client == GLFW_OPENGL_ES_API)
137 {
138 if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
139 (ctxconfig->major == 1 && ctxconfig->minor > 1) ||
140 (ctxconfig->major == 2 && ctxconfig->minor > 0))
141 {
142 // OpenGL ES 1.0 is the smallest valid version
143 // OpenGL ES 1.x series ended with version 1.1
144 // OpenGL ES 2.x series ended with version 2.0
145 // For now, let everything else through
146
147 _glfwInputError(GLFW_INVALID_VALUE,
148 "Invalid OpenGL ES version %i.%i",
149 ctxconfig->major, ctxconfig->minor);
150 return GLFW_FALSE;
151 }
152 }
153
154 if (ctxconfig->robustness)
155 {
156 if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
157 ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
158 {
159 _glfwInputError(GLFW_INVALID_ENUM,
160 "Invalid context robustness mode 0x%08X",
161 ctxconfig->robustness);
162 return GLFW_FALSE;
163 }
164 }
165
166 if (ctxconfig->release)
167 {
168 if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
169 ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
170 {
171 _glfwInputError(GLFW_INVALID_ENUM,
172 "Invalid context release behavior 0x%08X",
173 ctxconfig->release);
174 return GLFW_FALSE;
175 }
176 }
177
178 return GLFW_TRUE;
179}
180
181// Chooses the framebuffer config that best matches the desired one
182//
183const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
184 const _GLFWfbconfig* alternatives,
185 unsigned int count)
186{
187 unsigned int i;
188 unsigned int missing, leastMissing = UINT_MAX;
189 unsigned int colorDiff, leastColorDiff = UINT_MAX;
190 unsigned int extraDiff, leastExtraDiff = UINT_MAX;
191 const _GLFWfbconfig* current;
192 const _GLFWfbconfig* closest = NULL;
193
194 for (i = 0; i < count; i++)
195 {
196 current = alternatives + i;
197
198 if (desired->stereo > 0 && current->stereo == 0)
199 {
200 // Stereo is a hard constraint
201 continue;
202 }
203
204 // Count number of missing buffers
205 {
206 missing = 0;
207
208 if (desired->alphaBits > 0 && current->alphaBits == 0)
209 missing++;
210
211 if (desired->depthBits > 0 && current->depthBits == 0)
212 missing++;
213
214 if (desired->stencilBits > 0 && current->stencilBits == 0)
215 missing++;
216
217 if (desired->auxBuffers > 0 &&
218 current->auxBuffers < desired->auxBuffers)
219 {
220 missing += desired->auxBuffers - current->auxBuffers;
221 }
222
223 if (desired->samples > 0 && current->samples == 0)
224 {
225 // Technically, several multisampling buffers could be
226 // involved, but that's a lower level implementation detail and
227 // not important to us here, so we count them as one
228 missing++;
229 }
230
231 if (desired->transparent != current->transparent)
232 missing++;
233 }
234
235 // These polynomials make many small channel size differences matter
236 // less than one large channel size difference
237
238 // Calculate color channel size difference value
239 {
240 colorDiff = 0;
241
242 if (desired->redBits != GLFW_DONT_CARE)
243 {
244 colorDiff += (desired->redBits - current->redBits) *
245 (desired->redBits - current->redBits);
246 }
247
248 if (desired->greenBits != GLFW_DONT_CARE)
249 {
250 colorDiff += (desired->greenBits - current->greenBits) *
251 (desired->greenBits - current->greenBits);
252 }
253
254 if (desired->blueBits != GLFW_DONT_CARE)
255 {
256 colorDiff += (desired->blueBits - current->blueBits) *
257 (desired->blueBits - current->blueBits);
258 }
259 }
260
261 // Calculate non-color channel size difference value
262 {
263 extraDiff = 0;
264
265 if (desired->alphaBits != GLFW_DONT_CARE)
266 {
267 extraDiff += (desired->alphaBits - current->alphaBits) *
268 (desired->alphaBits - current->alphaBits);
269 }
270
271 if (desired->depthBits != GLFW_DONT_CARE)
272 {
273 extraDiff += (desired->depthBits - current->depthBits) *
274 (desired->depthBits - current->depthBits);
275 }
276
277 if (desired->stencilBits != GLFW_DONT_CARE)
278 {
279 extraDiff += (desired->stencilBits - current->stencilBits) *
280 (desired->stencilBits - current->stencilBits);
281 }
282
283 if (desired->accumRedBits != GLFW_DONT_CARE)
284 {
285 extraDiff += (desired->accumRedBits - current->accumRedBits) *
286 (desired->accumRedBits - current->accumRedBits);
287 }
288
289 if (desired->accumGreenBits != GLFW_DONT_CARE)
290 {
291 extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
292 (desired->accumGreenBits - current->accumGreenBits);
293 }
294
295 if (desired->accumBlueBits != GLFW_DONT_CARE)
296 {
297 extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
298 (desired->accumBlueBits - current->accumBlueBits);
299 }
300
301 if (desired->accumAlphaBits != GLFW_DONT_CARE)
302 {
303 extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
304 (desired->accumAlphaBits - current->accumAlphaBits);
305 }
306
307 if (desired->samples != GLFW_DONT_CARE)
308 {
309 extraDiff += (desired->samples - current->samples) *
310 (desired->samples - current->samples);
311 }
312
313 if (desired->sRGB && !current->sRGB)
314 extraDiff++;
315 }
316
317 // Figure out if the current one is better than the best one found so far
318 // Least number of missing buffers is the most important heuristic,
319 // then color buffer size match and lastly size match for other buffers
320
321 if (missing < leastMissing)
322 closest = current;
323 else if (missing == leastMissing)
324 {
325 if ((colorDiff < leastColorDiff) ||
326 (colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
327 {
328 closest = current;
329 }
330 }
331
332 if (current == closest)
333 {
334 leastMissing = missing;
335 leastColorDiff = colorDiff;
336 leastExtraDiff = extraDiff;
337 }
338 }
339
340 return closest;
341}
342
343// Retrieves the attributes of the current context
344//
345GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
346 const _GLFWctxconfig* ctxconfig)
347{
348 int i;
349 _GLFWwindow* previous;
350 const char* version;
351 const char* prefixes[] =
352 {
353 "OpenGL ES-CM ",
354 "OpenGL ES-CL ",
355 "OpenGL ES ",
356 NULL
357 };
358
359 window->context.source = ctxconfig->source;
360 window->context.client = GLFW_OPENGL_API;
361
362 previous = _glfwPlatformGetTls(&_glfw.contextSlot);
363 glfwMakeContextCurrent((GLFWwindow*) window);
364 if (_glfwPlatformGetTls(&_glfw.contextSlot) != window)
365 return GLFW_FALSE;
366
367 window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
368 window->context.getProcAddress("glGetIntegerv");
369 window->context.GetString = (PFNGLGETSTRINGPROC)
370 window->context.getProcAddress("glGetString");
371 if (!window->context.GetIntegerv || !window->context.GetString)
372 {
373 _glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
374 glfwMakeContextCurrent((GLFWwindow*) previous);
375 return GLFW_FALSE;
376 }
377
378 version = (const char*) window->context.GetString(GL_VERSION);
379 if (!version)
380 {
381 if (ctxconfig->client == GLFW_OPENGL_API)
382 {
383 _glfwInputError(GLFW_PLATFORM_ERROR,
384 "OpenGL version string retrieval is broken");
385 }
386 else
387 {
388 _glfwInputError(GLFW_PLATFORM_ERROR,
389 "OpenGL ES version string retrieval is broken");
390 }
391
392 glfwMakeContextCurrent((GLFWwindow*) previous);
393 return GLFW_FALSE;
394 }
395
396 for (i = 0; prefixes[i]; i++)
397 {
398 const size_t length = strlen(prefixes[i]);
399
400 if (strncmp(version, prefixes[i], length) == 0)
401 {
402 version += length;
403 window->context.client = GLFW_OPENGL_ES_API;
404 break;
405 }
406 }
407
408 if (!sscanf(version, "%d.%d.%d",
409 &window->context.major,
410 &window->context.minor,
411 &window->context.revision))
412 {
413 if (window->context.client == GLFW_OPENGL_API)
414 {
415 _glfwInputError(GLFW_PLATFORM_ERROR,
416 "No version found in OpenGL version string");
417 }
418 else
419 {
420 _glfwInputError(GLFW_PLATFORM_ERROR,
421 "No version found in OpenGL ES version string");
422 }
423
424 glfwMakeContextCurrent((GLFWwindow*) previous);
425 return GLFW_FALSE;
426 }
427
428 if (window->context.major < ctxconfig->major ||
429 (window->context.major == ctxconfig->major &&
430 window->context.minor < ctxconfig->minor))
431 {
432 // The desired OpenGL version is greater than the actual version
433 // This only happens if the machine lacks {GLX|WGL}_ARB_create_context
434 // /and/ the user has requested an OpenGL version greater than 1.0
435
436 // For API consistency, we emulate the behavior of the
437 // {GLX|WGL}_ARB_create_context extension and fail here
438
439 if (window->context.client == GLFW_OPENGL_API)
440 {
441 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
442 "Requested OpenGL version %i.%i, got version %i.%i",
443 ctxconfig->major, ctxconfig->minor,
444 window->context.major, window->context.minor);
445 }
446 else
447 {
448 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
449 "Requested OpenGL ES version %i.%i, got version %i.%i",
450 ctxconfig->major, ctxconfig->minor,
451 window->context.major, window->context.minor);
452 }
453
454 glfwMakeContextCurrent((GLFWwindow*) previous);
455 return GLFW_FALSE;
456 }
457
458 if (window->context.major >= 3)
459 {
460 // OpenGL 3.0+ uses a different function for extension string retrieval
461 // We cache it here instead of in glfwExtensionSupported mostly to alert
462 // users as early as possible that their build may be broken
463
464 window->context.GetStringi = (PFNGLGETSTRINGIPROC)
465 window->context.getProcAddress("glGetStringi");
466 if (!window->context.GetStringi)
467 {
468 _glfwInputError(GLFW_PLATFORM_ERROR,
469 "Entry point retrieval is broken");
470 glfwMakeContextCurrent((GLFWwindow*) previous);
471 return GLFW_FALSE;
472 }
473 }
474
475 if (window->context.client == GLFW_OPENGL_API)
476 {
477 // Read back context flags (OpenGL 3.0 and above)
478 if (window->context.major >= 3)
479 {
480 GLint flags;
481 window->context.GetIntegerv(GL_CONTEXT_FLAGS, &flags);
482
483 if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
484 window->context.forward = GLFW_TRUE;
485
486 if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
487 window->context.debug = GLFW_TRUE;
488 else if (glfwExtensionSupported("GL_ARB_debug_output") &&
489 ctxconfig->debug)
490 {
491 // HACK: This is a workaround for older drivers (pre KHR_debug)
492 // not setting the debug bit in the context flags for
493 // debug contexts
494 window->context.debug = GLFW_TRUE;
495 }
496
497 if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
498 window->context.noerror = GLFW_TRUE;
499 }
500
501 // Read back OpenGL context profile (OpenGL 3.2 and above)
502 if (window->context.major >= 4 ||
503 (window->context.major == 3 && window->context.minor >= 2))
504 {
505 GLint mask;
506 window->context.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
507
508 if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
509 window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
510 else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
511 window->context.profile = GLFW_OPENGL_CORE_PROFILE;
512 else if (glfwExtensionSupported("GL_ARB_compatibility"))
513 {
514 // HACK: This is a workaround for the compatibility profile bit
515 // not being set in the context flags if an OpenGL 3.2+
516 // context was created without having requested a specific
517 // version
518 window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
519 }
520 }
521
522 // Read back robustness strategy
523 if (glfwExtensionSupported("GL_ARB_robustness"))
524 {
525 // NOTE: We avoid using the context flags for detection, as they are
526 // only present from 3.0 while the extension applies from 1.1
527
528 GLint strategy;
529 window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
530 &strategy);
531
532 if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
533 window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
534 else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
535 window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
536 }
537 }
538 else
539 {
540 // Read back robustness strategy
541 if (glfwExtensionSupported("GL_EXT_robustness"))
542 {
543 // NOTE: The values of these constants match those of the OpenGL ARB
544 // one, so we can reuse them here
545
546 GLint strategy;
547 window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
548 &strategy);
549
550 if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
551 window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
552 else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
553 window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
554 }
555 }
556
557 if (glfwExtensionSupported("GL_KHR_context_flush_control"))
558 {
559 GLint behavior;
560 window->context.GetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
561
562 if (behavior == GL_NONE)
563 window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
564 else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
565 window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;
566 }
567
568 // Clearing the front buffer to black to avoid garbage pixels left over from
569 // previous uses of our bit of VRAM
570 {
571 PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
572 window->context.getProcAddress("glClear");
573 glClear(GL_COLOR_BUFFER_BIT);
574
575 if (window->doublebuffer)
576 window->context.swapBuffers(window);
577 }
578
579 glfwMakeContextCurrent((GLFWwindow*) previous);
580 return GLFW_TRUE;
581}
582
583// Searches an extension string for the specified extension
584//
585GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
586{
587 const char* start = extensions;
588
589 for (;;)
590 {
591 const char* where;
592 const char* terminator;
593
594 where = strstr(start, string);
595 if (!where)
596 return GLFW_FALSE;
597
598 terminator = where + strlen(string);
599 if (where == start || *(where - 1) == ' ')
600 {
601 if (*terminator == ' ' || *terminator == '\0')
602 break;
603 }
604
605 start = terminator;
606 }
607
608 return GLFW_TRUE;
609}
610
611
612//////////////////////////////////////////////////////////////////////////
613////// GLFW public API //////
614//////////////////////////////////////////////////////////////////////////
615
616GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
617{
618 _GLFWwindow* window = (_GLFWwindow*) handle;
619 _GLFWwindow* previous;
620
621 _GLFW_REQUIRE_INIT();
622
623 previous = _glfwPlatformGetTls(&_glfw.contextSlot);
624
625 if (window && window->context.client == GLFW_NO_API)
626 {
627 _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
628 "Cannot make current with a window that has no OpenGL or OpenGL ES context");
629 return;
630 }
631
632 if (previous)
633 {
634 if (!window || window->context.source != previous->context.source)
635 previous->context.makeCurrent(NULL);
636 }
637
638 if (window)
639 window->context.makeCurrent(window);
640}
641
642GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
643{
644 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
645 return _glfwPlatformGetTls(&_glfw.contextSlot);
646}
647
648GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
649{
650 _GLFWwindow* window = (_GLFWwindow*) handle;
651 assert(window != NULL);
652
653 _GLFW_REQUIRE_INIT();
654
655 if (window->context.client == GLFW_NO_API)
656 {
657 _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
658 "Cannot swap buffers of a window that has no OpenGL or OpenGL ES context");
659 return;
660 }
661
662 window->context.swapBuffers(window);
663}
664
665GLFWAPI void glfwSwapInterval(int interval)
666{
667 _GLFWwindow* window;
668
669 _GLFW_REQUIRE_INIT();
670
671 window = _glfwPlatformGetTls(&_glfw.contextSlot);
672 if (!window)
673 {
674 _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
675 "Cannot set swap interval without a current OpenGL or OpenGL ES context");
676 return;
677 }
678
679 window->context.swapInterval(interval);
680}
681
682GLFWAPI int glfwExtensionSupported(const char* extension)
683{
684 _GLFWwindow* window;
685 assert(extension != NULL);
686
687 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
688
689 window = _glfwPlatformGetTls(&_glfw.contextSlot);
690 if (!window)
691 {
692 _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
693 "Cannot query extension without a current OpenGL or OpenGL ES context");
694 return GLFW_FALSE;
695 }
696
697 if (*extension == '\0')
698 {
699 _glfwInputError(GLFW_INVALID_VALUE, "Extension name cannot be an empty string");
700 return GLFW_FALSE;
701 }
702
703 if (window->context.major >= 3)
704 {
705 int i;
706 GLint count;
707
708 // Check if extension is in the modern OpenGL extensions string list
709
710 window->context.GetIntegerv(GL_NUM_EXTENSIONS, &count);
711
712 for (i = 0; i < count; i++)
713 {
714 const char* en = (const char*)
715 window->context.GetStringi(GL_EXTENSIONS, i);
716 if (!en)
717 {
718 _glfwInputError(GLFW_PLATFORM_ERROR,
719 "Extension string retrieval is broken");
720 return GLFW_FALSE;
721 }
722
723 if (strcmp(en, extension) == 0)
724 return GLFW_TRUE;
725 }
726 }
727 else
728 {
729 // Check if extension is in the old style OpenGL extensions string
730
731 const char* extensions = (const char*)
732 window->context.GetString(GL_EXTENSIONS);
733 if (!extensions)
734 {
735 _glfwInputError(GLFW_PLATFORM_ERROR,
736 "Extension string retrieval is broken");
737 return GLFW_FALSE;
738 }
739
740 if (_glfwStringInExtensionString(extension, extensions))
741 return GLFW_TRUE;
742 }
743
744 // Check if extension is in the platform-specific string
745 return window->context.extensionSupported(extension);
746}
747
748GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
749{
750 _GLFWwindow* window;
751 assert(procname != NULL);
752
753 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
754
755 window = _glfwPlatformGetTls(&_glfw.contextSlot);
756 if (!window)
757 {
758 _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
759 "Cannot query entry point without a current OpenGL or OpenGL ES context");
760 return NULL;
761 }
762
763 return window->context.getProcAddress(procname);
764}
765
diff --git a/raylib/src/external/glfw/src/egl_context.c b/raylib/src/external/glfw/src/egl_context.c
new file mode 100644
index 0000000..ef65dd3
--- /dev/null
+++ b/raylib/src/external/glfw/src/egl_context.c
@@ -0,0 +1,911 @@
1//========================================================================
2// GLFW 3.4 EGL - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <stdio.h>
31#include <string.h>
32#include <stdlib.h>
33#include <assert.h>
34
35
36// Return a description of the specified EGL error
37//
38static const char* getEGLErrorString(EGLint error)
39{
40 switch (error)
41 {
42 case EGL_SUCCESS:
43 return "Success";
44 case EGL_NOT_INITIALIZED:
45 return "EGL is not or could not be initialized";
46 case EGL_BAD_ACCESS:
47 return "EGL cannot access a requested resource";
48 case EGL_BAD_ALLOC:
49 return "EGL failed to allocate resources for the requested operation";
50 case EGL_BAD_ATTRIBUTE:
51 return "An unrecognized attribute or attribute value was passed in the attribute list";
52 case EGL_BAD_CONTEXT:
53 return "An EGLContext argument does not name a valid EGL rendering context";
54 case EGL_BAD_CONFIG:
55 return "An EGLConfig argument does not name a valid EGL frame buffer configuration";
56 case EGL_BAD_CURRENT_SURFACE:
57 return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid";
58 case EGL_BAD_DISPLAY:
59 return "An EGLDisplay argument does not name a valid EGL display connection";
60 case EGL_BAD_SURFACE:
61 return "An EGLSurface argument does not name a valid surface configured for GL rendering";
62 case EGL_BAD_MATCH:
63 return "Arguments are inconsistent";
64 case EGL_BAD_PARAMETER:
65 return "One or more argument values are invalid";
66 case EGL_BAD_NATIVE_PIXMAP:
67 return "A NativePixmapType argument does not refer to a valid native pixmap";
68 case EGL_BAD_NATIVE_WINDOW:
69 return "A NativeWindowType argument does not refer to a valid native window";
70 case EGL_CONTEXT_LOST:
71 return "The application must destroy all contexts and reinitialise";
72 default:
73 return "ERROR: UNKNOWN EGL ERROR";
74 }
75}
76
77// Returns the specified attribute of the specified EGLConfig
78//
79static int getEGLConfigAttrib(EGLConfig config, int attrib)
80{
81 int value;
82 eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
83 return value;
84}
85
86// Return the EGLConfig most closely matching the specified hints
87//
88static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
89 const _GLFWfbconfig* fbconfig,
90 EGLConfig* result)
91{
92 EGLConfig* nativeConfigs;
93 _GLFWfbconfig* usableConfigs;
94 const _GLFWfbconfig* closest;
95 int i, nativeCount, usableCount, apiBit;
96 GLFWbool wrongApiAvailable = GLFW_FALSE;
97
98 if (ctxconfig->client == GLFW_OPENGL_ES_API)
99 {
100 if (ctxconfig->major == 1)
101 apiBit = EGL_OPENGL_ES_BIT;
102 else
103 apiBit = EGL_OPENGL_ES2_BIT;
104 }
105 else
106 apiBit = EGL_OPENGL_BIT;
107
108 if (fbconfig->stereo)
109 {
110 _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Stereo rendering not supported");
111 return GLFW_FALSE;
112 }
113
114 eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);
115 if (!nativeCount)
116 {
117 _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: No EGLConfigs returned");
118 return GLFW_FALSE;
119 }
120
121 nativeConfigs = _glfw_calloc(nativeCount, sizeof(EGLConfig));
122 eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
123
124 usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
125 usableCount = 0;
126
127 for (i = 0; i < nativeCount; i++)
128 {
129 const EGLConfig n = nativeConfigs[i];
130 _GLFWfbconfig* u = usableConfigs + usableCount;
131
132 // Only consider RGB(A) EGLConfigs
133 if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
134 continue;
135
136 // Only consider window EGLConfigs
137 if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
138 continue;
139
140#if defined(_GLFW_X11)
141 if (_glfw.platform.platformID == GLFW_PLATFORM_X11)
142 {
143 XVisualInfo vi = {0};
144
145 // Only consider EGLConfigs with associated Visuals
146 vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
147 if (!vi.visualid)
148 continue;
149
150 if (fbconfig->transparent)
151 {
152 int count;
153 XVisualInfo* vis =
154 XGetVisualInfo(_glfw.x11.display, VisualIDMask, &vi, &count);
155 if (vis)
156 {
157 u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
158 XFree(vis);
159 }
160 }
161 }
162#endif // _GLFW_X11
163
164 if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & apiBit))
165 {
166 wrongApiAvailable = GLFW_TRUE;
167 continue;
168 }
169
170 u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
171 u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE);
172 u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE);
173
174 u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE);
175 u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE);
176 u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
177
178#if defined(_GLFW_WAYLAND)
179 if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
180 {
181 // NOTE: The wl_surface opaque region is no guarantee that its buffer
182 // is presented as opaque, if it also has an alpha channel
183 // HACK: If EGL_EXT_present_opaque is unavailable, ignore any config
184 // with an alpha channel to ensure the buffer is opaque
185 if (!_glfw.egl.EXT_present_opaque)
186 {
187 if (!fbconfig->transparent && u->alphaBits > 0)
188 continue;
189 }
190 }
191#endif // _GLFW_WAYLAND
192
193 u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
194 u->doublebuffer = fbconfig->doublebuffer;
195
196 u->handle = (uintptr_t) n;
197 usableCount++;
198 }
199
200 closest = _glfwChooseFBConfig(fbconfig, usableConfigs, usableCount);
201 if (closest)
202 *result = (EGLConfig) closest->handle;
203 else
204 {
205 if (wrongApiAvailable)
206 {
207 if (ctxconfig->client == GLFW_OPENGL_ES_API)
208 {
209 if (ctxconfig->major == 1)
210 {
211 _glfwInputError(GLFW_API_UNAVAILABLE,
212 "EGL: Failed to find support for OpenGL ES 1.x");
213 }
214 else
215 {
216 _glfwInputError(GLFW_API_UNAVAILABLE,
217 "EGL: Failed to find support for OpenGL ES 2 or later");
218 }
219 }
220 else
221 {
222 _glfwInputError(GLFW_API_UNAVAILABLE,
223 "EGL: Failed to find support for OpenGL");
224 }
225 }
226 else
227 {
228 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
229 "EGL: Failed to find a suitable EGLConfig");
230 }
231 }
232
233 _glfw_free(nativeConfigs);
234 _glfw_free(usableConfigs);
235
236 return closest != NULL;
237}
238
239static void makeContextCurrentEGL(_GLFWwindow* window)
240{
241 if (window)
242 {
243 if (!eglMakeCurrent(_glfw.egl.display,
244 window->context.egl.surface,
245 window->context.egl.surface,
246 window->context.egl.handle))
247 {
248 _glfwInputError(GLFW_PLATFORM_ERROR,
249 "EGL: Failed to make context current: %s",
250 getEGLErrorString(eglGetError()));
251 return;
252 }
253 }
254 else
255 {
256 if (!eglMakeCurrent(_glfw.egl.display,
257 EGL_NO_SURFACE,
258 EGL_NO_SURFACE,
259 EGL_NO_CONTEXT))
260 {
261 _glfwInputError(GLFW_PLATFORM_ERROR,
262 "EGL: Failed to clear current context: %s",
263 getEGLErrorString(eglGetError()));
264 return;
265 }
266 }
267
268 _glfwPlatformSetTls(&_glfw.contextSlot, window);
269}
270
271static void swapBuffersEGL(_GLFWwindow* window)
272{
273 if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
274 {
275 _glfwInputError(GLFW_PLATFORM_ERROR,
276 "EGL: The context must be current on the calling thread when swapping buffers");
277 return;
278 }
279
280#if defined(_GLFW_WAYLAND)
281 if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
282 {
283 // NOTE: Swapping buffers on a hidden window on Wayland makes it visible
284 if (!window->wl.visible)
285 return;
286 }
287#endif
288
289 eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
290}
291
292static void swapIntervalEGL(int interval)
293{
294 eglSwapInterval(_glfw.egl.display, interval);
295}
296
297static int extensionSupportedEGL(const char* extension)
298{
299 const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
300 if (extensions)
301 {
302 if (_glfwStringInExtensionString(extension, extensions))
303 return GLFW_TRUE;
304 }
305
306 return GLFW_FALSE;
307}
308
309static GLFWglproc getProcAddressEGL(const char* procname)
310{
311 _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
312 assert(window != NULL);
313
314 if (window->context.egl.client)
315 {
316 GLFWglproc proc = (GLFWglproc)
317 _glfwPlatformGetModuleSymbol(window->context.egl.client, procname);
318 if (proc)
319 return proc;
320 }
321
322 return eglGetProcAddress(procname);
323}
324
325static void destroyContextEGL(_GLFWwindow* window)
326{
327 // NOTE: Do not unload libGL.so.1 while the X11 display is still open,
328 // as it will make XCloseDisplay segfault
329 if (_glfw.platform.platformID != GLFW_PLATFORM_X11 ||
330 window->context.client != GLFW_OPENGL_API)
331 {
332 if (window->context.egl.client)
333 {
334 _glfwPlatformFreeModule(window->context.egl.client);
335 window->context.egl.client = NULL;
336 }
337 }
338
339 if (window->context.egl.surface)
340 {
341 eglDestroySurface(_glfw.egl.display, window->context.egl.surface);
342 window->context.egl.surface = EGL_NO_SURFACE;
343 }
344
345 if (window->context.egl.handle)
346 {
347 eglDestroyContext(_glfw.egl.display, window->context.egl.handle);
348 window->context.egl.handle = EGL_NO_CONTEXT;
349 }
350}
351
352
353//////////////////////////////////////////////////////////////////////////
354////// GLFW internal API //////
355//////////////////////////////////////////////////////////////////////////
356
357// Initialize EGL
358//
359GLFWbool _glfwInitEGL(void)
360{
361 int i;
362 EGLint* attribs = NULL;
363 const char* extensions;
364 const char* sonames[] =
365 {
366#if defined(_GLFW_EGL_LIBRARY)
367 _GLFW_EGL_LIBRARY,
368#elif defined(_GLFW_WIN32)
369 "libEGL.dll",
370 "EGL.dll",
371#elif defined(_GLFW_COCOA)
372 "libEGL.dylib",
373#elif defined(__CYGWIN__)
374 "libEGL-1.so",
375#elif defined(__OpenBSD__) || defined(__NetBSD__)
376 "libEGL.so",
377#else
378 "libEGL.so.1",
379#endif
380 NULL
381 };
382
383 if (_glfw.egl.handle)
384 return GLFW_TRUE;
385
386 for (i = 0; sonames[i]; i++)
387 {
388 _glfw.egl.handle = _glfwPlatformLoadModule(sonames[i]);
389 if (_glfw.egl.handle)
390 break;
391 }
392
393 if (!_glfw.egl.handle)
394 {
395 _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Library not found");
396 return GLFW_FALSE;
397 }
398
399 _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
400
401 _glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
402 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigAttrib");
403 _glfw.egl.GetConfigs = (PFN_eglGetConfigs)
404 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigs");
405 _glfw.egl.GetDisplay = (PFN_eglGetDisplay)
406 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetDisplay");
407 _glfw.egl.GetError = (PFN_eglGetError)
408 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetError");
409 _glfw.egl.Initialize = (PFN_eglInitialize)
410 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglInitialize");
411 _glfw.egl.Terminate = (PFN_eglTerminate)
412 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglTerminate");
413 _glfw.egl.BindAPI = (PFN_eglBindAPI)
414 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglBindAPI");
415 _glfw.egl.CreateContext = (PFN_eglCreateContext)
416 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateContext");
417 _glfw.egl.DestroySurface = (PFN_eglDestroySurface)
418 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroySurface");
419 _glfw.egl.DestroyContext = (PFN_eglDestroyContext)
420 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext");
421 _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
422 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface");
423 _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
424 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent");
425 _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
426 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapBuffers");
427 _glfw.egl.SwapInterval = (PFN_eglSwapInterval)
428 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapInterval");
429 _glfw.egl.QueryString = (PFN_eglQueryString)
430 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglQueryString");
431 _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
432 _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetProcAddress");
433
434 if (!_glfw.egl.GetConfigAttrib ||
435 !_glfw.egl.GetConfigs ||
436 !_glfw.egl.GetDisplay ||
437 !_glfw.egl.GetError ||
438 !_glfw.egl.Initialize ||
439 !_glfw.egl.Terminate ||
440 !_glfw.egl.BindAPI ||
441 !_glfw.egl.CreateContext ||
442 !_glfw.egl.DestroySurface ||
443 !_glfw.egl.DestroyContext ||
444 !_glfw.egl.CreateWindowSurface ||
445 !_glfw.egl.MakeCurrent ||
446 !_glfw.egl.SwapBuffers ||
447 !_glfw.egl.SwapInterval ||
448 !_glfw.egl.QueryString ||
449 !_glfw.egl.GetProcAddress)
450 {
451 _glfwInputError(GLFW_PLATFORM_ERROR,
452 "EGL: Failed to load required entry points");
453
454 _glfwTerminateEGL();
455 return GLFW_FALSE;
456 }
457
458 extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
459 if (extensions && eglGetError() == EGL_SUCCESS)
460 _glfw.egl.EXT_client_extensions = GLFW_TRUE;
461
462 if (_glfw.egl.EXT_client_extensions)
463 {
464 _glfw.egl.EXT_platform_base =
465 _glfwStringInExtensionString("EGL_EXT_platform_base", extensions);
466 _glfw.egl.EXT_platform_x11 =
467 _glfwStringInExtensionString("EGL_EXT_platform_x11", extensions);
468 _glfw.egl.EXT_platform_wayland =
469 _glfwStringInExtensionString("EGL_EXT_platform_wayland", extensions);
470 _glfw.egl.ANGLE_platform_angle =
471 _glfwStringInExtensionString("EGL_ANGLE_platform_angle", extensions);
472 _glfw.egl.ANGLE_platform_angle_opengl =
473 _glfwStringInExtensionString("EGL_ANGLE_platform_angle_opengl", extensions);
474 _glfw.egl.ANGLE_platform_angle_d3d =
475 _glfwStringInExtensionString("EGL_ANGLE_platform_angle_d3d", extensions);
476 _glfw.egl.ANGLE_platform_angle_vulkan =
477 _glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
478 _glfw.egl.ANGLE_platform_angle_metal =
479 _glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
480 }
481
482 if (_glfw.egl.EXT_platform_base)
483 {
484 _glfw.egl.GetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
485 eglGetProcAddress("eglGetPlatformDisplayEXT");
486 _glfw.egl.CreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
487 eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
488 }
489
490 _glfw.egl.platform = _glfw.platform.getEGLPlatform(&attribs);
491 if (_glfw.egl.platform)
492 {
493 _glfw.egl.display =
494 eglGetPlatformDisplayEXT(_glfw.egl.platform,
495 _glfw.platform.getEGLNativeDisplay(),
496 attribs);
497 }
498 else
499 _glfw.egl.display = eglGetDisplay(_glfw.platform.getEGLNativeDisplay());
500
501 _glfw_free(attribs);
502
503 if (_glfw.egl.display == EGL_NO_DISPLAY)
504 {
505 _glfwInputError(GLFW_API_UNAVAILABLE,
506 "EGL: Failed to get EGL display: %s",
507 getEGLErrorString(eglGetError()));
508
509 _glfwTerminateEGL();
510 return GLFW_FALSE;
511 }
512
513 if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor))
514 {
515 _glfwInputError(GLFW_API_UNAVAILABLE,
516 "EGL: Failed to initialize EGL: %s",
517 getEGLErrorString(eglGetError()));
518
519 _glfwTerminateEGL();
520 return GLFW_FALSE;
521 }
522
523 _glfw.egl.KHR_create_context =
524 extensionSupportedEGL("EGL_KHR_create_context");
525 _glfw.egl.KHR_create_context_no_error =
526 extensionSupportedEGL("EGL_KHR_create_context_no_error");
527 _glfw.egl.KHR_gl_colorspace =
528 extensionSupportedEGL("EGL_KHR_gl_colorspace");
529 _glfw.egl.KHR_get_all_proc_addresses =
530 extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
531 _glfw.egl.KHR_context_flush_control =
532 extensionSupportedEGL("EGL_KHR_context_flush_control");
533 _glfw.egl.EXT_present_opaque =
534 extensionSupportedEGL("EGL_EXT_present_opaque");
535
536 return GLFW_TRUE;
537}
538
539// Terminate EGL
540//
541void _glfwTerminateEGL(void)
542{
543 if (_glfw.egl.display)
544 {
545 eglTerminate(_glfw.egl.display);
546 _glfw.egl.display = EGL_NO_DISPLAY;
547 }
548
549 if (_glfw.egl.handle)
550 {
551 _glfwPlatformFreeModule(_glfw.egl.handle);
552 _glfw.egl.handle = NULL;
553 }
554}
555
556#define SET_ATTRIB(a, v) \
557{ \
558 assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
559 attribs[index++] = a; \
560 attribs[index++] = v; \
561}
562
563// Create the OpenGL or OpenGL ES context
564//
565GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
566 const _GLFWctxconfig* ctxconfig,
567 const _GLFWfbconfig* fbconfig)
568{
569 EGLint attribs[40];
570 EGLConfig config;
571 EGLContext share = NULL;
572 EGLNativeWindowType native;
573 int index = 0;
574
575 if (!_glfw.egl.display)
576 {
577 _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: API not available");
578 return GLFW_FALSE;
579 }
580
581 if (ctxconfig->share)
582 share = ctxconfig->share->context.egl.handle;
583
584 if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
585 return GLFW_FALSE;
586
587 if (ctxconfig->client == GLFW_OPENGL_ES_API)
588 {
589 if (!eglBindAPI(EGL_OPENGL_ES_API))
590 {
591 _glfwInputError(GLFW_API_UNAVAILABLE,
592 "EGL: Failed to bind OpenGL ES: %s",
593 getEGLErrorString(eglGetError()));
594 return GLFW_FALSE;
595 }
596 }
597 else
598 {
599 if (!eglBindAPI(EGL_OPENGL_API))
600 {
601 _glfwInputError(GLFW_API_UNAVAILABLE,
602 "EGL: Failed to bind OpenGL: %s",
603 getEGLErrorString(eglGetError()));
604 return GLFW_FALSE;
605 }
606 }
607
608 if (_glfw.egl.KHR_create_context)
609 {
610 int mask = 0, flags = 0;
611
612 if (ctxconfig->client == GLFW_OPENGL_API)
613 {
614 if (ctxconfig->forward)
615 flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
616
617 if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
618 mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
619 else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
620 mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
621 }
622
623 if (ctxconfig->debug)
624 flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
625
626 if (ctxconfig->robustness)
627 {
628 if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
629 {
630 SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
631 EGL_NO_RESET_NOTIFICATION_KHR);
632 }
633 else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
634 {
635 SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
636 EGL_LOSE_CONTEXT_ON_RESET_KHR);
637 }
638
639 flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
640 }
641
642 if (ctxconfig->major != 1 || ctxconfig->minor != 0)
643 {
644 SET_ATTRIB(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
645 SET_ATTRIB(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
646 }
647
648 if (ctxconfig->noerror)
649 {
650 if (_glfw.egl.KHR_create_context_no_error)
651 SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
652 }
653
654 if (mask)
655 SET_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
656
657 if (flags)
658 SET_ATTRIB(EGL_CONTEXT_FLAGS_KHR, flags);
659 }
660 else
661 {
662 if (ctxconfig->client == GLFW_OPENGL_ES_API)
663 SET_ATTRIB(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
664 }
665
666 if (_glfw.egl.KHR_context_flush_control)
667 {
668 if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
669 {
670 SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
671 EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
672 }
673 else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
674 {
675 SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
676 EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
677 }
678 }
679
680 SET_ATTRIB(EGL_NONE, EGL_NONE);
681
682 window->context.egl.handle = eglCreateContext(_glfw.egl.display,
683 config, share, attribs);
684
685 if (window->context.egl.handle == EGL_NO_CONTEXT)
686 {
687 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
688 "EGL: Failed to create context: %s",
689 getEGLErrorString(eglGetError()));
690 return GLFW_FALSE;
691 }
692
693 // Set up attributes for surface creation
694 index = 0;
695
696 if (fbconfig->sRGB)
697 {
698 if (_glfw.egl.KHR_gl_colorspace)
699 SET_ATTRIB(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
700 }
701
702 if (!fbconfig->doublebuffer)
703 SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
704
705 if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
706 {
707 if (_glfw.egl.EXT_present_opaque)
708 SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
709 }
710
711 SET_ATTRIB(EGL_NONE, EGL_NONE);
712
713 native = _glfw.platform.getEGLNativeWindow(window);
714 // HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
715 // despite reporting EGL_EXT_platform_base
716 if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
717 {
718 window->context.egl.surface =
719 eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
720 }
721 else
722 {
723 window->context.egl.surface =
724 eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
725 }
726
727 if (window->context.egl.surface == EGL_NO_SURFACE)
728 {
729 _glfwInputError(GLFW_PLATFORM_ERROR,
730 "EGL: Failed to create window surface: %s",
731 getEGLErrorString(eglGetError()));
732 return GLFW_FALSE;
733 }
734
735 window->context.egl.config = config;
736
737 // Load the appropriate client library
738 if (!_glfw.egl.KHR_get_all_proc_addresses)
739 {
740 int i;
741 const char** sonames;
742 const char* es1sonames[] =
743 {
744#if defined(_GLFW_GLESV1_LIBRARY)
745 _GLFW_GLESV1_LIBRARY,
746#elif defined(_GLFW_WIN32)
747 "GLESv1_CM.dll",
748 "libGLES_CM.dll",
749#elif defined(_GLFW_COCOA)
750 "libGLESv1_CM.dylib",
751#elif defined(__OpenBSD__) || defined(__NetBSD__)
752 "libGLESv1_CM.so",
753#else
754 "libGLESv1_CM.so.1",
755 "libGLES_CM.so.1",
756#endif
757 NULL
758 };
759 const char* es2sonames[] =
760 {
761#if defined(_GLFW_GLESV2_LIBRARY)
762 _GLFW_GLESV2_LIBRARY,
763#elif defined(_GLFW_WIN32)
764 "GLESv2.dll",
765 "libGLESv2.dll",
766#elif defined(_GLFW_COCOA)
767 "libGLESv2.dylib",
768#elif defined(__CYGWIN__)
769 "libGLESv2-2.so",
770#elif defined(__OpenBSD__) || defined(__NetBSD__)
771 "libGLESv2.so",
772#else
773 "libGLESv2.so.2",
774#endif
775 NULL
776 };
777 const char* glsonames[] =
778 {
779#if defined(_GLFW_OPENGL_LIBRARY)
780 _GLFW_OPENGL_LIBRARY,
781#elif defined(_GLFW_WIN32)
782#elif defined(_GLFW_COCOA)
783#elif defined(__OpenBSD__) || defined(__NetBSD__)
784 "libGL.so",
785#else
786 "libOpenGL.so.0",
787 "libGL.so.1",
788#endif
789 NULL
790 };
791
792 if (ctxconfig->client == GLFW_OPENGL_ES_API)
793 {
794 if (ctxconfig->major == 1)
795 sonames = es1sonames;
796 else
797 sonames = es2sonames;
798 }
799 else
800 sonames = glsonames;
801
802 for (i = 0; sonames[i]; i++)
803 {
804 // HACK: Match presence of lib prefix to increase chance of finding
805 // a matching pair in the jungle that is Win32 EGL/GLES
806 if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
807 continue;
808
809 window->context.egl.client = _glfwPlatformLoadModule(sonames[i]);
810 if (window->context.egl.client)
811 break;
812 }
813
814 if (!window->context.egl.client)
815 {
816 _glfwInputError(GLFW_API_UNAVAILABLE,
817 "EGL: Failed to load client library");
818 return GLFW_FALSE;
819 }
820 }
821
822 window->context.makeCurrent = makeContextCurrentEGL;
823 window->context.swapBuffers = swapBuffersEGL;
824 window->context.swapInterval = swapIntervalEGL;
825 window->context.extensionSupported = extensionSupportedEGL;
826 window->context.getProcAddress = getProcAddressEGL;
827 window->context.destroy = destroyContextEGL;
828
829 return GLFW_TRUE;
830}
831
832#undef SET_ATTRIB
833
834// Returns the Visual and depth of the chosen EGLConfig
835//
836#if defined(_GLFW_X11)
837GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
838 const _GLFWctxconfig* ctxconfig,
839 const _GLFWfbconfig* fbconfig,
840 Visual** visual, int* depth)
841{
842 XVisualInfo* result;
843 XVisualInfo desired;
844 EGLConfig native;
845 EGLint visualID = 0, count = 0;
846 const long vimask = VisualScreenMask | VisualIDMask;
847
848 if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
849 return GLFW_FALSE;
850
851 eglGetConfigAttrib(_glfw.egl.display, native,
852 EGL_NATIVE_VISUAL_ID, &visualID);
853
854 desired.screen = _glfw.x11.screen;
855 desired.visualid = visualID;
856
857 result = XGetVisualInfo(_glfw.x11.display, vimask, &desired, &count);
858 if (!result)
859 {
860 _glfwInputError(GLFW_PLATFORM_ERROR,
861 "EGL: Failed to retrieve Visual for EGLConfig");
862 return GLFW_FALSE;
863 }
864
865 *visual = result->visual;
866 *depth = result->depth;
867
868 XFree(result);
869 return GLFW_TRUE;
870}
871#endif // _GLFW_X11
872
873
874//////////////////////////////////////////////////////////////////////////
875////// GLFW native API //////
876//////////////////////////////////////////////////////////////////////////
877
878GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
879{
880 _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_DISPLAY);
881 return _glfw.egl.display;
882}
883
884GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
885{
886 _GLFWwindow* window = (_GLFWwindow*) handle;
887 _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
888
889 if (window->context.source != GLFW_EGL_CONTEXT_API)
890 {
891 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
892 return EGL_NO_CONTEXT;
893 }
894
895 return window->context.egl.handle;
896}
897
898GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
899{
900 _GLFWwindow* window = (_GLFWwindow*) handle;
901 _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
902
903 if (window->context.source != GLFW_EGL_CONTEXT_API)
904 {
905 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
906 return EGL_NO_SURFACE;
907 }
908
909 return window->context.egl.surface;
910}
911
diff --git a/raylib/src/external/glfw/src/glfw.rc.in b/raylib/src/external/glfw/src/glfw.rc.in
new file mode 100644
index 0000000..ac3460a
--- /dev/null
+++ b/raylib/src/external/glfw/src/glfw.rc.in
@@ -0,0 +1,30 @@
1
2#include <winver.h>
3
4VS_VERSION_INFO VERSIONINFO
5FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
6PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
7FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8FILEFLAGS 0
9FILEOS VOS_NT_WINDOWS32
10FILETYPE VFT_DLL
11FILESUBTYPE 0
12{
13 BLOCK "StringFileInfo"
14 {
15 BLOCK "040904B0"
16 {
17 VALUE "CompanyName", "GLFW"
18 VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL"
19 VALUE "FileVersion", "@GLFW_VERSION@"
20 VALUE "OriginalFilename", "glfw3.dll"
21 VALUE "ProductName", "GLFW"
22 VALUE "ProductVersion", "@GLFW_VERSION@"
23 }
24 }
25 BLOCK "VarFileInfo"
26 {
27 VALUE "Translation", 0x409, 1200
28 }
29}
30
diff --git a/raylib/src/external/glfw/src/glx_context.c b/raylib/src/external/glfw/src/glx_context.c
new file mode 100644
index 0000000..7082682
--- /dev/null
+++ b/raylib/src/external/glfw/src/glx_context.c
@@ -0,0 +1,719 @@
1//========================================================================
2// GLFW 3.4 GLX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_X11)
31
32#include <string.h>
33#include <stdlib.h>
34#include <assert.h>
35
36#ifndef GLXBadProfileARB
37 #define GLXBadProfileARB 13
38#endif
39
40
41// Returns the specified attribute of the specified GLXFBConfig
42//
43static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
44{
45 int value;
46 glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
47 return value;
48}
49
50// Return the GLXFBConfig most closely matching the specified hints
51//
52static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
53 GLXFBConfig* result)
54{
55 GLXFBConfig* nativeConfigs;
56 _GLFWfbconfig* usableConfigs;
57 const _GLFWfbconfig* closest;
58 int nativeCount, usableCount;
59 const char* vendor;
60 GLFWbool trustWindowBit = GLFW_TRUE;
61
62 // HACK: This is a (hopefully temporary) workaround for Chromium
63 // (VirtualBox GL) not setting the window bit on any GLXFBConfigs
64 vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
65 if (vendor && strcmp(vendor, "Chromium") == 0)
66 trustWindowBit = GLFW_FALSE;
67
68 nativeConfigs =
69 glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
70 if (!nativeConfigs || !nativeCount)
71 {
72 _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
73 return GLFW_FALSE;
74 }
75
76 usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
77 usableCount = 0;
78
79 for (int i = 0; i < nativeCount; i++)
80 {
81 const GLXFBConfig n = nativeConfigs[i];
82 _GLFWfbconfig* u = usableConfigs + usableCount;
83
84 // Only consider RGBA GLXFBConfigs
85 if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
86 continue;
87
88 // Only consider window GLXFBConfigs
89 if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
90 {
91 if (trustWindowBit)
92 continue;
93 }
94
95 if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
96 continue;
97
98 if (desired->transparent)
99 {
100 XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
101 if (vi)
102 {
103 u->transparent = _glfwIsVisualTransparentX11(vi->visual);
104 XFree(vi);
105 }
106 }
107
108 u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
109 u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
110 u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
111
112 u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
113 u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
114 u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
115
116 u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
117 u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
118 u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
119 u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
120
121 u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
122
123 if (getGLXFBConfigAttrib(n, GLX_STEREO))
124 u->stereo = GLFW_TRUE;
125
126 if (_glfw.glx.ARB_multisample)
127 u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
128
129 if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
130 u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
131
132 u->handle = (uintptr_t) n;
133 usableCount++;
134 }
135
136 closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
137 if (closest)
138 *result = (GLXFBConfig) closest->handle;
139
140 XFree(nativeConfigs);
141 _glfw_free(usableConfigs);
142
143 return closest != NULL;
144}
145
146// Create the OpenGL context using legacy API
147//
148static GLXContext createLegacyContextGLX(_GLFWwindow* window,
149 GLXFBConfig fbconfig,
150 GLXContext share)
151{
152 return glXCreateNewContext(_glfw.x11.display,
153 fbconfig,
154 GLX_RGBA_TYPE,
155 share,
156 True);
157}
158
159static void makeContextCurrentGLX(_GLFWwindow* window)
160{
161 if (window)
162 {
163 if (!glXMakeCurrent(_glfw.x11.display,
164 window->context.glx.window,
165 window->context.glx.handle))
166 {
167 _glfwInputError(GLFW_PLATFORM_ERROR,
168 "GLX: Failed to make context current");
169 return;
170 }
171 }
172 else
173 {
174 if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
175 {
176 _glfwInputError(GLFW_PLATFORM_ERROR,
177 "GLX: Failed to clear current context");
178 return;
179 }
180 }
181
182 _glfwPlatformSetTls(&_glfw.contextSlot, window);
183}
184
185static void swapBuffersGLX(_GLFWwindow* window)
186{
187 glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
188}
189
190static void swapIntervalGLX(int interval)
191{
192 _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
193 assert(window != NULL);
194
195 if (_glfw.glx.EXT_swap_control)
196 {
197 _glfw.glx.SwapIntervalEXT(_glfw.x11.display,
198 window->context.glx.window,
199 interval);
200 }
201 else if (_glfw.glx.MESA_swap_control)
202 _glfw.glx.SwapIntervalMESA(interval);
203 else if (_glfw.glx.SGI_swap_control)
204 {
205 if (interval > 0)
206 _glfw.glx.SwapIntervalSGI(interval);
207 }
208}
209
210static int extensionSupportedGLX(const char* extension)
211{
212 const char* extensions =
213 glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
214 if (extensions)
215 {
216 if (_glfwStringInExtensionString(extension, extensions))
217 return GLFW_TRUE;
218 }
219
220 return GLFW_FALSE;
221}
222
223static GLFWglproc getProcAddressGLX(const char* procname)
224{
225 if (_glfw.glx.GetProcAddress)
226 return _glfw.glx.GetProcAddress((const GLubyte*) procname);
227 else if (_glfw.glx.GetProcAddressARB)
228 return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
229 else
230 {
231 // NOTE: glvnd provides GLX 1.4, so this can only happen with libGL
232 return _glfwPlatformGetModuleSymbol(_glfw.glx.handle, procname);
233 }
234}
235
236static void destroyContextGLX(_GLFWwindow* window)
237{
238 if (window->context.glx.window)
239 {
240 glXDestroyWindow(_glfw.x11.display, window->context.glx.window);
241 window->context.glx.window = None;
242 }
243
244 if (window->context.glx.handle)
245 {
246 glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
247 window->context.glx.handle = NULL;
248 }
249}
250
251
252//////////////////////////////////////////////////////////////////////////
253////// GLFW internal API //////
254//////////////////////////////////////////////////////////////////////////
255
256// Initialize GLX
257//
258GLFWbool _glfwInitGLX(void)
259{
260 const char* sonames[] =
261 {
262#if defined(_GLFW_GLX_LIBRARY)
263 _GLFW_GLX_LIBRARY,
264#elif defined(__CYGWIN__)
265 "libGL-1.so",
266#elif defined(__OpenBSD__) || defined(__NetBSD__)
267 "libGL.so",
268#else
269 "libGLX.so.0",
270 "libGL.so.1",
271 "libGL.so",
272#endif
273 NULL
274 };
275
276 if (_glfw.glx.handle)
277 return GLFW_TRUE;
278
279 for (int i = 0; sonames[i]; i++)
280 {
281 _glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]);
282 if (_glfw.glx.handle)
283 break;
284 }
285
286 if (!_glfw.glx.handle)
287 {
288 _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
289 return GLFW_FALSE;
290 }
291
292 _glfw.glx.GetFBConfigs = (PFNGLXGETFBCONFIGSPROC)
293 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigs");
294 _glfw.glx.GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)
295 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigAttrib");
296 _glfw.glx.GetClientString = (PFNGLXGETCLIENTSTRINGPROC)
297 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetClientString");
298 _glfw.glx.QueryExtension = (PFNGLXQUERYEXTENSIONPROC)
299 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtension");
300 _glfw.glx.QueryVersion = (PFNGLXQUERYVERSIONPROC)
301 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryVersion");
302 _glfw.glx.DestroyContext = (PFNGLXDESTROYCONTEXTPROC)
303 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyContext");
304 _glfw.glx.MakeCurrent = (PFNGLXMAKECURRENTPROC)
305 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXMakeCurrent");
306 _glfw.glx.SwapBuffers = (PFNGLXSWAPBUFFERSPROC)
307 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXSwapBuffers");
308 _glfw.glx.QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)
309 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtensionsString");
310 _glfw.glx.CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)
311 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateNewContext");
312 _glfw.glx.CreateWindow = (PFNGLXCREATEWINDOWPROC)
313 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateWindow");
314 _glfw.glx.DestroyWindow = (PFNGLXDESTROYWINDOWPROC)
315 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyWindow");
316 _glfw.glx.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)
317 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig");
318
319 if (!_glfw.glx.GetFBConfigs ||
320 !_glfw.glx.GetFBConfigAttrib ||
321 !_glfw.glx.GetClientString ||
322 !_glfw.glx.QueryExtension ||
323 !_glfw.glx.QueryVersion ||
324 !_glfw.glx.DestroyContext ||
325 !_glfw.glx.MakeCurrent ||
326 !_glfw.glx.SwapBuffers ||
327 !_glfw.glx.QueryExtensionsString ||
328 !_glfw.glx.CreateNewContext ||
329 !_glfw.glx.CreateWindow ||
330 !_glfw.glx.DestroyWindow ||
331 !_glfw.glx.GetVisualFromFBConfig)
332 {
333 _glfwInputError(GLFW_PLATFORM_ERROR,
334 "GLX: Failed to load required entry points");
335 return GLFW_FALSE;
336 }
337
338 // NOTE: Unlike GLX 1.3 entry points these are not required to be present
339 _glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC)
340 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress");
341 _glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC)
342 _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB");
343
344 if (!glXQueryExtension(_glfw.x11.display,
345 &_glfw.glx.errorBase,
346 &_glfw.glx.eventBase))
347 {
348 _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
349 return GLFW_FALSE;
350 }
351
352 if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
353 {
354 _glfwInputError(GLFW_API_UNAVAILABLE,
355 "GLX: Failed to query GLX version");
356 return GLFW_FALSE;
357 }
358
359 if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
360 {
361 _glfwInputError(GLFW_API_UNAVAILABLE,
362 "GLX: GLX version 1.3 is required");
363 return GLFW_FALSE;
364 }
365
366 if (extensionSupportedGLX("GLX_EXT_swap_control"))
367 {
368 _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
369 getProcAddressGLX("glXSwapIntervalEXT");
370
371 if (_glfw.glx.SwapIntervalEXT)
372 _glfw.glx.EXT_swap_control = GLFW_TRUE;
373 }
374
375 if (extensionSupportedGLX("GLX_SGI_swap_control"))
376 {
377 _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
378 getProcAddressGLX("glXSwapIntervalSGI");
379
380 if (_glfw.glx.SwapIntervalSGI)
381 _glfw.glx.SGI_swap_control = GLFW_TRUE;
382 }
383
384 if (extensionSupportedGLX("GLX_MESA_swap_control"))
385 {
386 _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
387 getProcAddressGLX("glXSwapIntervalMESA");
388
389 if (_glfw.glx.SwapIntervalMESA)
390 _glfw.glx.MESA_swap_control = GLFW_TRUE;
391 }
392
393 if (extensionSupportedGLX("GLX_ARB_multisample"))
394 _glfw.glx.ARB_multisample = GLFW_TRUE;
395
396 if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
397 _glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
398
399 if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
400 _glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
401
402 if (extensionSupportedGLX("GLX_ARB_create_context"))
403 {
404 _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
405 getProcAddressGLX("glXCreateContextAttribsARB");
406
407 if (_glfw.glx.CreateContextAttribsARB)
408 _glfw.glx.ARB_create_context = GLFW_TRUE;
409 }
410
411 if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
412 _glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
413
414 if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
415 _glfw.glx.ARB_create_context_profile = GLFW_TRUE;
416
417 if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
418 _glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
419
420 if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
421 _glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
422
423 if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
424 _glfw.glx.ARB_context_flush_control = GLFW_TRUE;
425
426 return GLFW_TRUE;
427}
428
429// Terminate GLX
430//
431void _glfwTerminateGLX(void)
432{
433 // NOTE: This function must not call any X11 functions, as it is called
434 // after XCloseDisplay (see _glfwTerminateX11 for details)
435
436 if (_glfw.glx.handle)
437 {
438 _glfwPlatformFreeModule(_glfw.glx.handle);
439 _glfw.glx.handle = NULL;
440 }
441}
442
443#define SET_ATTRIB(a, v) \
444{ \
445 assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
446 attribs[index++] = a; \
447 attribs[index++] = v; \
448}
449
450// Create the OpenGL or OpenGL ES context
451//
452GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
453 const _GLFWctxconfig* ctxconfig,
454 const _GLFWfbconfig* fbconfig)
455{
456 int attribs[40];
457 GLXFBConfig native = NULL;
458 GLXContext share = NULL;
459
460 if (ctxconfig->share)
461 share = ctxconfig->share->context.glx.handle;
462
463 if (!chooseGLXFBConfig(fbconfig, &native))
464 {
465 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
466 "GLX: Failed to find a suitable GLXFBConfig");
467 return GLFW_FALSE;
468 }
469
470 if (ctxconfig->client == GLFW_OPENGL_ES_API)
471 {
472 if (!_glfw.glx.ARB_create_context ||
473 !_glfw.glx.ARB_create_context_profile ||
474 !_glfw.glx.EXT_create_context_es2_profile)
475 {
476 _glfwInputError(GLFW_API_UNAVAILABLE,
477 "GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
478 return GLFW_FALSE;
479 }
480 }
481
482 if (ctxconfig->forward)
483 {
484 if (!_glfw.glx.ARB_create_context)
485 {
486 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
487 "GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
488 return GLFW_FALSE;
489 }
490 }
491
492 if (ctxconfig->profile)
493 {
494 if (!_glfw.glx.ARB_create_context ||
495 !_glfw.glx.ARB_create_context_profile)
496 {
497 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
498 "GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
499 return GLFW_FALSE;
500 }
501 }
502
503 _glfwGrabErrorHandlerX11();
504
505 if (_glfw.glx.ARB_create_context)
506 {
507 int index = 0, mask = 0, flags = 0;
508
509 if (ctxconfig->client == GLFW_OPENGL_API)
510 {
511 if (ctxconfig->forward)
512 flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
513
514 if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
515 mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
516 else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
517 mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
518 }
519 else
520 mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
521
522 if (ctxconfig->debug)
523 flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
524
525 if (ctxconfig->robustness)
526 {
527 if (_glfw.glx.ARB_create_context_robustness)
528 {
529 if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
530 {
531 SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
532 GLX_NO_RESET_NOTIFICATION_ARB);
533 }
534 else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
535 {
536 SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
537 GLX_LOSE_CONTEXT_ON_RESET_ARB);
538 }
539
540 flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
541 }
542 }
543
544 if (ctxconfig->release)
545 {
546 if (_glfw.glx.ARB_context_flush_control)
547 {
548 if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
549 {
550 SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
551 GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
552 }
553 else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
554 {
555 SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
556 GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
557 }
558 }
559 }
560
561 if (ctxconfig->noerror)
562 {
563 if (_glfw.glx.ARB_create_context_no_error)
564 SET_ATTRIB(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
565 }
566
567 // NOTE: Only request an explicitly versioned context when necessary, as
568 // explicitly requesting version 1.0 does not always return the
569 // highest version supported by the driver
570 if (ctxconfig->major != 1 || ctxconfig->minor != 0)
571 {
572 SET_ATTRIB(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
573 SET_ATTRIB(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
574 }
575
576 if (mask)
577 SET_ATTRIB(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
578
579 if (flags)
580 SET_ATTRIB(GLX_CONTEXT_FLAGS_ARB, flags);
581
582 SET_ATTRIB(None, None);
583
584 window->context.glx.handle =
585 _glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
586 native,
587 share,
588 True,
589 attribs);
590
591 // HACK: This is a fallback for broken versions of the Mesa
592 // implementation of GLX_ARB_create_context_profile that fail
593 // default 1.0 context creation with a GLXBadProfileARB error in
594 // violation of the extension spec
595 if (!window->context.glx.handle)
596 {
597 if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
598 ctxconfig->client == GLFW_OPENGL_API &&
599 ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
600 ctxconfig->forward == GLFW_FALSE)
601 {
602 window->context.glx.handle =
603 createLegacyContextGLX(window, native, share);
604 }
605 }
606 }
607 else
608 {
609 window->context.glx.handle =
610 createLegacyContextGLX(window, native, share);
611 }
612
613 _glfwReleaseErrorHandlerX11();
614
615 if (!window->context.glx.handle)
616 {
617 _glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
618 return GLFW_FALSE;
619 }
620
621 window->context.glx.window =
622 glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
623 if (!window->context.glx.window)
624 {
625 _glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
626 return GLFW_FALSE;
627 }
628
629 window->context.makeCurrent = makeContextCurrentGLX;
630 window->context.swapBuffers = swapBuffersGLX;
631 window->context.swapInterval = swapIntervalGLX;
632 window->context.extensionSupported = extensionSupportedGLX;
633 window->context.getProcAddress = getProcAddressGLX;
634 window->context.destroy = destroyContextGLX;
635
636 return GLFW_TRUE;
637}
638
639#undef SET_ATTRIB
640
641// Returns the Visual and depth of the chosen GLXFBConfig
642//
643GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
644 const _GLFWctxconfig* ctxconfig,
645 const _GLFWfbconfig* fbconfig,
646 Visual** visual, int* depth)
647{
648 GLXFBConfig native;
649 XVisualInfo* result;
650
651 if (!chooseGLXFBConfig(fbconfig, &native))
652 {
653 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
654 "GLX: Failed to find a suitable GLXFBConfig");
655 return GLFW_FALSE;
656 }
657
658 result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
659 if (!result)
660 {
661 _glfwInputError(GLFW_PLATFORM_ERROR,
662 "GLX: Failed to retrieve Visual for GLXFBConfig");
663 return GLFW_FALSE;
664 }
665
666 *visual = result->visual;
667 *depth = result->depth;
668
669 XFree(result);
670 return GLFW_TRUE;
671}
672
673
674//////////////////////////////////////////////////////////////////////////
675////// GLFW native API //////
676//////////////////////////////////////////////////////////////////////////
677
678GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
679{
680 _GLFWwindow* window = (_GLFWwindow*) handle;
681 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
682
683 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
684 {
685 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized");
686 return NULL;
687 }
688
689 if (window->context.source != GLFW_NATIVE_CONTEXT_API)
690 {
691 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
692 return NULL;
693 }
694
695 return window->context.glx.handle;
696}
697
698GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
699{
700 _GLFWwindow* window = (_GLFWwindow*) handle;
701 _GLFW_REQUIRE_INIT_OR_RETURN(None);
702
703 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
704 {
705 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized");
706 return None;
707 }
708
709 if (window->context.source != GLFW_NATIVE_CONTEXT_API)
710 {
711 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
712 return None;
713 }
714
715 return window->context.glx.window;
716}
717
718#endif // _GLFW_X11
719
diff --git a/raylib/src/external/glfw/src/init.c b/raylib/src/external/glfw/src/init.c
new file mode 100644
index 0000000..532264e
--- /dev/null
+++ b/raylib/src/external/glfw/src/init.c
@@ -0,0 +1,528 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <string.h>
31#include <stdlib.h>
32#include <stdio.h>
33#include <stdarg.h>
34#include <assert.h>
35
36
37// NOTE: The global variables below comprise all mutable global data in GLFW
38// Any other mutable global variable is a bug
39
40// This contains all mutable state shared between compilation units of GLFW
41//
42_GLFWlibrary _glfw = { GLFW_FALSE };
43
44// These are outside of _glfw so they can be used before initialization and
45// after termination without special handling when _glfw is cleared to zero
46//
47static _GLFWerror _glfwMainThreadError;
48static GLFWerrorfun _glfwErrorCallback;
49static GLFWallocator _glfwInitAllocator;
50static _GLFWinitconfig _glfwInitHints =
51{
52 .hatButtons = GLFW_TRUE,
53 .angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE,
54 .platformID = GLFW_ANY_PLATFORM,
55 .vulkanLoader = NULL,
56 .ns =
57 {
58 .menubar = GLFW_TRUE,
59 .chdir = GLFW_TRUE
60 },
61 .x11 =
62 {
63 .xcbVulkanSurface = GLFW_TRUE,
64 },
65 .wl =
66 {
67 .libdecorMode = GLFW_WAYLAND_PREFER_LIBDECOR
68 },
69};
70
71// The allocation function used when no custom allocator is set
72//
73static void* defaultAllocate(size_t size, void* user)
74{
75 return malloc(size);
76}
77
78// The deallocation function used when no custom allocator is set
79//
80static void defaultDeallocate(void* block, void* user)
81{
82 free(block);
83}
84
85// The reallocation function used when no custom allocator is set
86//
87static void* defaultReallocate(void* block, size_t size, void* user)
88{
89 return realloc(block, size);
90}
91
92// Terminate the library
93//
94static void terminate(void)
95{
96 int i;
97
98 memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
99
100 while (_glfw.windowListHead)
101 glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
102
103 while (_glfw.cursorListHead)
104 glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead);
105
106 for (i = 0; i < _glfw.monitorCount; i++)
107 {
108 _GLFWmonitor* monitor = _glfw.monitors[i];
109 if (monitor->originalRamp.size)
110 _glfw.platform.setGammaRamp(monitor, &monitor->originalRamp);
111 _glfwFreeMonitor(monitor);
112 }
113
114 _glfw_free(_glfw.monitors);
115 _glfw.monitors = NULL;
116 _glfw.monitorCount = 0;
117
118 _glfw_free(_glfw.mappings);
119 _glfw.mappings = NULL;
120 _glfw.mappingCount = 0;
121
122 _glfwTerminateVulkan();
123 _glfw.platform.terminateJoysticks();
124 _glfw.platform.terminate();
125
126 _glfw.initialized = GLFW_FALSE;
127
128 while (_glfw.errorListHead)
129 {
130 _GLFWerror* error = _glfw.errorListHead;
131 _glfw.errorListHead = error->next;
132 _glfw_free(error);
133 }
134
135 _glfwPlatformDestroyTls(&_glfw.contextSlot);
136 _glfwPlatformDestroyTls(&_glfw.errorSlot);
137 _glfwPlatformDestroyMutex(&_glfw.errorLock);
138
139 memset(&_glfw, 0, sizeof(_glfw));
140}
141
142
143//////////////////////////////////////////////////////////////////////////
144////// GLFW internal API //////
145//////////////////////////////////////////////////////////////////////////
146
147// Encode a Unicode code point to a UTF-8 stream
148// Based on cutef8 by Jeff Bezanson (Public Domain)
149//
150size_t _glfwEncodeUTF8(char* s, uint32_t codepoint)
151{
152 size_t count = 0;
153
154 if (codepoint < 0x80)
155 s[count++] = (char) codepoint;
156 else if (codepoint < 0x800)
157 {
158 s[count++] = (codepoint >> 6) | 0xc0;
159 s[count++] = (codepoint & 0x3f) | 0x80;
160 }
161 else if (codepoint < 0x10000)
162 {
163 s[count++] = (codepoint >> 12) | 0xe0;
164 s[count++] = ((codepoint >> 6) & 0x3f) | 0x80;
165 s[count++] = (codepoint & 0x3f) | 0x80;
166 }
167 else if (codepoint < 0x110000)
168 {
169 s[count++] = (codepoint >> 18) | 0xf0;
170 s[count++] = ((codepoint >> 12) & 0x3f) | 0x80;
171 s[count++] = ((codepoint >> 6) & 0x3f) | 0x80;
172 s[count++] = (codepoint & 0x3f) | 0x80;
173 }
174
175 return count;
176}
177
178// Splits and translates a text/uri-list into separate file paths
179// NOTE: This function destroys the provided string
180//
181char** _glfwParseUriList(char* text, int* count)
182{
183 const char* prefix = "file://";
184 char** paths = NULL;
185 char* line;
186
187 *count = 0;
188
189 while ((line = strtok(text, "\r\n")))
190 {
191 char* path;
192
193 text = NULL;
194
195 if (line[0] == '#')
196 continue;
197
198 if (strncmp(line, prefix, strlen(prefix)) == 0)
199 {
200 line += strlen(prefix);
201 // TODO: Validate hostname
202 while (*line != '/')
203 line++;
204 }
205
206 (*count)++;
207
208 path = _glfw_calloc(strlen(line) + 1, 1);
209 paths = _glfw_realloc(paths, *count * sizeof(char*));
210 paths[*count - 1] = path;
211
212 while (*line)
213 {
214 if (line[0] == '%' && line[1] && line[2])
215 {
216 const char digits[3] = { line[1], line[2], '\0' };
217 *path = (char) strtol(digits, NULL, 16);
218 line += 2;
219 }
220 else
221 *path = *line;
222
223 path++;
224 line++;
225 }
226 }
227
228 return paths;
229}
230
231char* _glfw_strdup(const char* source)
232{
233 const size_t length = strlen(source);
234 char* result = _glfw_calloc(length + 1, 1);
235 strcpy(result, source);
236 return result;
237}
238
239int _glfw_min(int a, int b)
240{
241 return a < b ? a : b;
242}
243
244int _glfw_max(int a, int b)
245{
246 return a > b ? a : b;
247}
248
249void* _glfw_calloc(size_t count, size_t size)
250{
251 if (count && size)
252 {
253 void* block;
254
255 if (count > SIZE_MAX / size)
256 {
257 _glfwInputError(GLFW_INVALID_VALUE, "Allocation size overflow");
258 return NULL;
259 }
260
261 block = _glfw.allocator.allocate(count * size, _glfw.allocator.user);
262 if (block)
263 return memset(block, 0, count * size);
264 else
265 {
266 _glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
267 return NULL;
268 }
269 }
270 else
271 return NULL;
272}
273
274void* _glfw_realloc(void* block, size_t size)
275{
276 if (block && size)
277 {
278 void* resized = _glfw.allocator.reallocate(block, size, _glfw.allocator.user);
279 if (resized)
280 return resized;
281 else
282 {
283 _glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
284 return NULL;
285 }
286 }
287 else if (block)
288 {
289 _glfw_free(block);
290 return NULL;
291 }
292 else
293 return _glfw_calloc(1, size);
294}
295
296void _glfw_free(void* block)
297{
298 if (block)
299 _glfw.allocator.deallocate(block, _glfw.allocator.user);
300}
301
302
303//////////////////////////////////////////////////////////////////////////
304////// GLFW event API //////
305//////////////////////////////////////////////////////////////////////////
306
307// Notifies shared code of an error
308//
309void _glfwInputError(int code, const char* format, ...)
310{
311 _GLFWerror* error;
312 char description[_GLFW_MESSAGE_SIZE];
313
314 if (format)
315 {
316 va_list vl;
317
318 va_start(vl, format);
319 vsnprintf(description, sizeof(description), format, vl);
320 va_end(vl);
321
322 description[sizeof(description) - 1] = '\0';
323 }
324 else
325 {
326 if (code == GLFW_NOT_INITIALIZED)
327 strcpy(description, "The GLFW library is not initialized");
328 else if (code == GLFW_NO_CURRENT_CONTEXT)
329 strcpy(description, "There is no current context");
330 else if (code == GLFW_INVALID_ENUM)
331 strcpy(description, "Invalid argument for enum parameter");
332 else if (code == GLFW_INVALID_VALUE)
333 strcpy(description, "Invalid value for parameter");
334 else if (code == GLFW_OUT_OF_MEMORY)
335 strcpy(description, "Out of memory");
336 else if (code == GLFW_API_UNAVAILABLE)
337 strcpy(description, "The requested API is unavailable");
338 else if (code == GLFW_VERSION_UNAVAILABLE)
339 strcpy(description, "The requested API version is unavailable");
340 else if (code == GLFW_PLATFORM_ERROR)
341 strcpy(description, "A platform-specific error occurred");
342 else if (code == GLFW_FORMAT_UNAVAILABLE)
343 strcpy(description, "The requested format is unavailable");
344 else if (code == GLFW_NO_WINDOW_CONTEXT)
345 strcpy(description, "The specified window has no context");
346 else if (code == GLFW_CURSOR_UNAVAILABLE)
347 strcpy(description, "The specified cursor shape is unavailable");
348 else if (code == GLFW_FEATURE_UNAVAILABLE)
349 strcpy(description, "The requested feature cannot be implemented for this platform");
350 else if (code == GLFW_FEATURE_UNIMPLEMENTED)
351 strcpy(description, "The requested feature has not yet been implemented for this platform");
352 else if (code == GLFW_PLATFORM_UNAVAILABLE)
353 strcpy(description, "The requested platform is unavailable");
354 else
355 strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
356 }
357
358 if (_glfw.initialized)
359 {
360 error = _glfwPlatformGetTls(&_glfw.errorSlot);
361 if (!error)
362 {
363 error = _glfw_calloc(1, sizeof(_GLFWerror));
364 _glfwPlatformSetTls(&_glfw.errorSlot, error);
365 _glfwPlatformLockMutex(&_glfw.errorLock);
366 error->next = _glfw.errorListHead;
367 _glfw.errorListHead = error;
368 _glfwPlatformUnlockMutex(&_glfw.errorLock);
369 }
370 }
371 else
372 error = &_glfwMainThreadError;
373
374 error->code = code;
375 strcpy(error->description, description);
376
377 if (_glfwErrorCallback)
378 _glfwErrorCallback(code, description);
379}
380
381
382//////////////////////////////////////////////////////////////////////////
383////// GLFW public API //////
384//////////////////////////////////////////////////////////////////////////
385
386GLFWAPI int glfwInit(void)
387{
388 if (_glfw.initialized)
389 return GLFW_TRUE;
390
391 memset(&_glfw, 0, sizeof(_glfw));
392 _glfw.hints.init = _glfwInitHints;
393
394 _glfw.allocator = _glfwInitAllocator;
395 if (!_glfw.allocator.allocate)
396 {
397 _glfw.allocator.allocate = defaultAllocate;
398 _glfw.allocator.reallocate = defaultReallocate;
399 _glfw.allocator.deallocate = defaultDeallocate;
400 }
401
402 if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform))
403 return GLFW_FALSE;
404
405 if (!_glfw.platform.init())
406 {
407 terminate();
408 return GLFW_FALSE;
409 }
410
411 if (!_glfwPlatformCreateMutex(&_glfw.errorLock) ||
412 !_glfwPlatformCreateTls(&_glfw.errorSlot) ||
413 !_glfwPlatformCreateTls(&_glfw.contextSlot))
414 {
415 terminate();
416 return GLFW_FALSE;
417 }
418
419 _glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
420
421 _glfwInitGamepadMappings();
422
423 _glfwPlatformInitTimer();
424 _glfw.timer.offset = _glfwPlatformGetTimerValue();
425
426 _glfw.initialized = GLFW_TRUE;
427
428 glfwDefaultWindowHints();
429 return GLFW_TRUE;
430}
431
432GLFWAPI void glfwTerminate(void)
433{
434 if (!_glfw.initialized)
435 return;
436
437 terminate();
438}
439
440GLFWAPI void glfwInitHint(int hint, int value)
441{
442 switch (hint)
443 {
444 case GLFW_JOYSTICK_HAT_BUTTONS:
445 _glfwInitHints.hatButtons = value;
446 return;
447 case GLFW_ANGLE_PLATFORM_TYPE:
448 _glfwInitHints.angleType = value;
449 return;
450 case GLFW_PLATFORM:
451 _glfwInitHints.platformID = value;
452 return;
453 case GLFW_COCOA_CHDIR_RESOURCES:
454 _glfwInitHints.ns.chdir = value;
455 return;
456 case GLFW_COCOA_MENUBAR:
457 _glfwInitHints.ns.menubar = value;
458 return;
459 case GLFW_X11_XCB_VULKAN_SURFACE:
460 _glfwInitHints.x11.xcbVulkanSurface = value;
461 return;
462 case GLFW_WAYLAND_LIBDECOR:
463 _glfwInitHints.wl.libdecorMode = value;
464 return;
465 }
466
467 _glfwInputError(GLFW_INVALID_ENUM,
468 "Invalid init hint 0x%08X", hint);
469}
470
471GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator)
472{
473 if (allocator)
474 {
475 if (allocator->allocate && allocator->reallocate && allocator->deallocate)
476 _glfwInitAllocator = *allocator;
477 else
478 _glfwInputError(GLFW_INVALID_VALUE, "Missing function in allocator");
479 }
480 else
481 memset(&_glfwInitAllocator, 0, sizeof(GLFWallocator));
482}
483
484GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader)
485{
486 _glfwInitHints.vulkanLoader = loader;
487}
488
489GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
490{
491 if (major != NULL)
492 *major = GLFW_VERSION_MAJOR;
493 if (minor != NULL)
494 *minor = GLFW_VERSION_MINOR;
495 if (rev != NULL)
496 *rev = GLFW_VERSION_REVISION;
497}
498
499GLFWAPI int glfwGetError(const char** description)
500{
501 _GLFWerror* error;
502 int code = GLFW_NO_ERROR;
503
504 if (description)
505 *description = NULL;
506
507 if (_glfw.initialized)
508 error = _glfwPlatformGetTls(&_glfw.errorSlot);
509 else
510 error = &_glfwMainThreadError;
511
512 if (error)
513 {
514 code = error->code;
515 error->code = GLFW_NO_ERROR;
516 if (description && code)
517 *description = error->description;
518 }
519
520 return code;
521}
522
523GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
524{
525 _GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun);
526 return cbfun;
527}
528
diff --git a/raylib/src/external/glfw/src/input.c b/raylib/src/external/glfw/src/input.c
new file mode 100644
index 0000000..7b3b340
--- /dev/null
+++ b/raylib/src/external/glfw/src/input.c
@@ -0,0 +1,1505 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29#include "mappings.h"
30
31#include <assert.h>
32#include <float.h>
33#include <math.h>
34#include <stdlib.h>
35#include <string.h>
36
37// Internal key state used for sticky keys
38#define _GLFW_STICK 3
39
40// Internal constants for gamepad mapping source types
41#define _GLFW_JOYSTICK_AXIS 1
42#define _GLFW_JOYSTICK_BUTTON 2
43#define _GLFW_JOYSTICK_HATBIT 3
44
45#define GLFW_MOD_MASK (GLFW_MOD_SHIFT | \
46 GLFW_MOD_CONTROL | \
47 GLFW_MOD_ALT | \
48 GLFW_MOD_SUPER | \
49 GLFW_MOD_CAPS_LOCK | \
50 GLFW_MOD_NUM_LOCK)
51
52// Initializes the platform joystick API if it has not been already
53//
54static GLFWbool initJoysticks(void)
55{
56 if (!_glfw.joysticksInitialized)
57 {
58 if (!_glfw.platform.initJoysticks())
59 {
60 _glfw.platform.terminateJoysticks();
61 return GLFW_FALSE;
62 }
63 }
64
65 return _glfw.joysticksInitialized = GLFW_TRUE;
66}
67
68// Finds a mapping based on joystick GUID
69//
70static _GLFWmapping* findMapping(const char* guid)
71{
72 int i;
73
74 for (i = 0; i < _glfw.mappingCount; i++)
75 {
76 if (strcmp(_glfw.mappings[i].guid, guid) == 0)
77 return _glfw.mappings + i;
78 }
79
80 return NULL;
81}
82
83// Checks whether a gamepad mapping element is present in the hardware
84//
85static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e,
86 const _GLFWjoystick* js)
87{
88 if (e->type == _GLFW_JOYSTICK_HATBIT && (e->index >> 4) >= js->hatCount)
89 return GLFW_FALSE;
90 else if (e->type == _GLFW_JOYSTICK_BUTTON && e->index >= js->buttonCount)
91 return GLFW_FALSE;
92 else if (e->type == _GLFW_JOYSTICK_AXIS && e->index >= js->axisCount)
93 return GLFW_FALSE;
94
95 return GLFW_TRUE;
96}
97
98// Finds a mapping based on joystick GUID and verifies element indices
99//
100static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
101{
102 _GLFWmapping* mapping = findMapping(js->guid);
103 if (mapping)
104 {
105 int i;
106
107 for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
108 {
109 if (!isValidElementForJoystick(mapping->buttons + i, js))
110 return NULL;
111 }
112
113 for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
114 {
115 if (!isValidElementForJoystick(mapping->axes + i, js))
116 return NULL;
117 }
118 }
119
120 return mapping;
121}
122
123// Parses an SDL_GameControllerDB line and adds it to the mapping list
124//
125static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
126{
127 const char* c = string;
128 size_t i, length;
129 struct
130 {
131 const char* name;
132 _GLFWmapelement* element;
133 } fields[] =
134 {
135 { "platform", NULL },
136 { "a", mapping->buttons + GLFW_GAMEPAD_BUTTON_A },
137 { "b", mapping->buttons + GLFW_GAMEPAD_BUTTON_B },
138 { "x", mapping->buttons + GLFW_GAMEPAD_BUTTON_X },
139 { "y", mapping->buttons + GLFW_GAMEPAD_BUTTON_Y },
140 { "back", mapping->buttons + GLFW_GAMEPAD_BUTTON_BACK },
141 { "start", mapping->buttons + GLFW_GAMEPAD_BUTTON_START },
142 { "guide", mapping->buttons + GLFW_GAMEPAD_BUTTON_GUIDE },
143 { "leftshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_BUMPER },
144 { "rightshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER },
145 { "leftstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_THUMB },
146 { "rightstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_THUMB },
147 { "dpup", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_UP },
148 { "dpright", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_RIGHT },
149 { "dpdown", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_DOWN },
150 { "dpleft", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_LEFT },
151 { "lefttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_TRIGGER },
152 { "righttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER },
153 { "leftx", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_X },
154 { "lefty", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_Y },
155 { "rightx", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_X },
156 { "righty", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_Y }
157 };
158
159 length = strcspn(c, ",");
160 if (length != 32 || c[length] != ',')
161 {
162 _glfwInputError(GLFW_INVALID_VALUE, NULL);
163 return GLFW_FALSE;
164 }
165
166 memcpy(mapping->guid, c, length);
167 c += length + 1;
168
169 length = strcspn(c, ",");
170 if (length >= sizeof(mapping->name) || c[length] != ',')
171 {
172 _glfwInputError(GLFW_INVALID_VALUE, NULL);
173 return GLFW_FALSE;
174 }
175
176 memcpy(mapping->name, c, length);
177 c += length + 1;
178
179 while (*c)
180 {
181 // TODO: Implement output modifiers
182 if (*c == '+' || *c == '-')
183 return GLFW_FALSE;
184
185 for (i = 0; i < sizeof(fields) / sizeof(fields[0]); i++)
186 {
187 length = strlen(fields[i].name);
188 if (strncmp(c, fields[i].name, length) != 0 || c[length] != ':')
189 continue;
190
191 c += length + 1;
192
193 if (fields[i].element)
194 {
195 _GLFWmapelement* e = fields[i].element;
196 int8_t minimum = -1;
197 int8_t maximum = 1;
198
199 if (*c == '+')
200 {
201 minimum = 0;
202 c += 1;
203 }
204 else if (*c == '-')
205 {
206 maximum = 0;
207 c += 1;
208 }
209
210 if (*c == 'a')
211 e->type = _GLFW_JOYSTICK_AXIS;
212 else if (*c == 'b')
213 e->type = _GLFW_JOYSTICK_BUTTON;
214 else if (*c == 'h')
215 e->type = _GLFW_JOYSTICK_HATBIT;
216 else
217 break;
218
219 if (e->type == _GLFW_JOYSTICK_HATBIT)
220 {
221 const unsigned long hat = strtoul(c + 1, (char**) &c, 10);
222 const unsigned long bit = strtoul(c + 1, (char**) &c, 10);
223 e->index = (uint8_t) ((hat << 4) | bit);
224 }
225 else
226 e->index = (uint8_t) strtoul(c + 1, (char**) &c, 10);
227
228 if (e->type == _GLFW_JOYSTICK_AXIS)
229 {
230 e->axisScale = 2 / (maximum - minimum);
231 e->axisOffset = -(maximum + minimum);
232
233 if (*c == '~')
234 {
235 e->axisScale = -e->axisScale;
236 e->axisOffset = -e->axisOffset;
237 }
238 }
239 }
240 else
241 {
242 const char* name = _glfw.platform.getMappingName();
243 length = strlen(name);
244 if (strncmp(c, name, length) != 0)
245 return GLFW_FALSE;
246 }
247
248 break;
249 }
250
251 c += strcspn(c, ",");
252 c += strspn(c, ",");
253 }
254
255 for (i = 0; i < 32; i++)
256 {
257 if (mapping->guid[i] >= 'A' && mapping->guid[i] <= 'F')
258 mapping->guid[i] += 'a' - 'A';
259 }
260
261 _glfw.platform.updateGamepadGUID(mapping->guid);
262 return GLFW_TRUE;
263}
264
265
266//////////////////////////////////////////////////////////////////////////
267////// GLFW event API //////
268//////////////////////////////////////////////////////////////////////////
269
270// Notifies shared code of a physical key event
271//
272void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
273{
274 assert(window != NULL);
275 assert(key >= 0 || key == GLFW_KEY_UNKNOWN);
276 assert(key <= GLFW_KEY_LAST);
277 assert(action == GLFW_PRESS || action == GLFW_RELEASE);
278 assert(mods == (mods & GLFW_MOD_MASK));
279
280 if (key >= 0 && key <= GLFW_KEY_LAST)
281 {
282 GLFWbool repeated = GLFW_FALSE;
283
284 if (action == GLFW_RELEASE && window->keys[key] == GLFW_RELEASE)
285 return;
286
287 if (action == GLFW_PRESS && window->keys[key] == GLFW_PRESS)
288 repeated = GLFW_TRUE;
289
290 if (action == GLFW_RELEASE && window->stickyKeys)
291 window->keys[key] = _GLFW_STICK;
292 else
293 window->keys[key] = (char) action;
294
295 if (repeated)
296 action = GLFW_REPEAT;
297 }
298
299 if (!window->lockKeyMods)
300 mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
301
302 if (window->callbacks.key)
303 window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
304}
305
306// Notifies shared code of a Unicode codepoint input event
307// The 'plain' parameter determines whether to emit a regular character event
308//
309void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool plain)
310{
311 assert(window != NULL);
312 assert(mods == (mods & GLFW_MOD_MASK));
313 assert(plain == GLFW_TRUE || plain == GLFW_FALSE);
314
315 if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
316 return;
317
318 if (!window->lockKeyMods)
319 mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
320
321 if (window->callbacks.charmods)
322 window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
323
324 if (plain)
325 {
326 if (window->callbacks.character)
327 window->callbacks.character((GLFWwindow*) window, codepoint);
328 }
329}
330
331// Notifies shared code of a scroll event
332//
333void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
334{
335 assert(window != NULL);
336 assert(xoffset > -FLT_MAX);
337 assert(xoffset < FLT_MAX);
338 assert(yoffset > -FLT_MAX);
339 assert(yoffset < FLT_MAX);
340
341 if (window->callbacks.scroll)
342 window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
343}
344
345// Notifies shared code of a mouse button click event
346//
347void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
348{
349 assert(window != NULL);
350 assert(button >= 0);
351 assert(button <= GLFW_MOUSE_BUTTON_LAST);
352 assert(action == GLFW_PRESS || action == GLFW_RELEASE);
353 assert(mods == (mods & GLFW_MOD_MASK));
354
355 if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
356 return;
357
358 if (!window->lockKeyMods)
359 mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
360
361 if (action == GLFW_RELEASE && window->stickyMouseButtons)
362 window->mouseButtons[button] = _GLFW_STICK;
363 else
364 window->mouseButtons[button] = (char) action;
365
366 if (window->callbacks.mouseButton)
367 window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
368}
369
370// Notifies shared code of a cursor motion event
371// The position is specified in content area relative screen coordinates
372//
373void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
374{
375 assert(window != NULL);
376 assert(xpos > -FLT_MAX);
377 assert(xpos < FLT_MAX);
378 assert(ypos > -FLT_MAX);
379 assert(ypos < FLT_MAX);
380
381 if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
382 return;
383
384 window->virtualCursorPosX = xpos;
385 window->virtualCursorPosY = ypos;
386
387 if (window->callbacks.cursorPos)
388 window->callbacks.cursorPos((GLFWwindow*) window, xpos, ypos);
389}
390
391// Notifies shared code of a cursor enter/leave event
392//
393void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
394{
395 assert(window != NULL);
396 assert(entered == GLFW_TRUE || entered == GLFW_FALSE);
397
398 if (window->callbacks.cursorEnter)
399 window->callbacks.cursorEnter((GLFWwindow*) window, entered);
400}
401
402// Notifies shared code of files or directories dropped on a window
403//
404void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
405{
406 assert(window != NULL);
407 assert(count > 0);
408 assert(paths != NULL);
409
410 if (window->callbacks.drop)
411 window->callbacks.drop((GLFWwindow*) window, count, paths);
412}
413
414// Notifies shared code of a joystick connection or disconnection
415//
416void _glfwInputJoystick(_GLFWjoystick* js, int event)
417{
418 assert(js != NULL);
419 assert(event == GLFW_CONNECTED || event == GLFW_DISCONNECTED);
420
421 if (event == GLFW_CONNECTED)
422 js->connected = GLFW_TRUE;
423 else if (event == GLFW_DISCONNECTED)
424 js->connected = GLFW_FALSE;
425
426 if (_glfw.callbacks.joystick)
427 _glfw.callbacks.joystick((int) (js - _glfw.joysticks), event);
428}
429
430// Notifies shared code of the new value of a joystick axis
431//
432void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
433{
434 assert(js != NULL);
435 assert(axis >= 0);
436 assert(axis < js->axisCount);
437
438 js->axes[axis] = value;
439}
440
441// Notifies shared code of the new value of a joystick button
442//
443void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
444{
445 assert(js != NULL);
446 assert(button >= 0);
447 assert(button < js->buttonCount);
448 assert(value == GLFW_PRESS || value == GLFW_RELEASE);
449
450 js->buttons[button] = value;
451}
452
453// Notifies shared code of the new value of a joystick hat
454//
455void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
456{
457 int base;
458
459 assert(js != NULL);
460 assert(hat >= 0);
461 assert(hat < js->hatCount);
462
463 // Valid hat values only use the least significant nibble
464 assert((value & 0xf0) == 0);
465 // Valid hat values do not have both bits of an axis set
466 assert((value & GLFW_HAT_LEFT) == 0 || (value & GLFW_HAT_RIGHT) == 0);
467 assert((value & GLFW_HAT_UP) == 0 || (value & GLFW_HAT_DOWN) == 0);
468
469 base = js->buttonCount + hat * 4;
470
471 js->buttons[base + 0] = (value & 0x01) ? GLFW_PRESS : GLFW_RELEASE;
472 js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
473 js->buttons[base + 2] = (value & 0x04) ? GLFW_PRESS : GLFW_RELEASE;
474 js->buttons[base + 3] = (value & 0x08) ? GLFW_PRESS : GLFW_RELEASE;
475
476 js->hats[hat] = value;
477}
478
479
480//////////////////////////////////////////////////////////////////////////
481////// GLFW internal API //////
482//////////////////////////////////////////////////////////////////////////
483
484// Adds the built-in set of gamepad mappings
485//
486void _glfwInitGamepadMappings(void)
487{
488 size_t i;
489 const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
490 _glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping));
491
492 for (i = 0; i < count; i++)
493 {
494 if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i]))
495 _glfw.mappingCount++;
496 }
497}
498
499// Returns an available joystick object with arrays and name allocated
500//
501_GLFWjoystick* _glfwAllocJoystick(const char* name,
502 const char* guid,
503 int axisCount,
504 int buttonCount,
505 int hatCount)
506{
507 int jid;
508 _GLFWjoystick* js;
509
510 for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
511 {
512 if (!_glfw.joysticks[jid].allocated)
513 break;
514 }
515
516 if (jid > GLFW_JOYSTICK_LAST)
517 return NULL;
518
519 js = _glfw.joysticks + jid;
520 js->allocated = GLFW_TRUE;
521 js->axes = _glfw_calloc(axisCount, sizeof(float));
522 js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
523 js->hats = _glfw_calloc(hatCount, 1);
524 js->axisCount = axisCount;
525 js->buttonCount = buttonCount;
526 js->hatCount = hatCount;
527
528 strncpy(js->name, name, sizeof(js->name) - 1);
529 strncpy(js->guid, guid, sizeof(js->guid) - 1);
530 js->mapping = findValidMapping(js);
531
532 return js;
533}
534
535// Frees arrays and name and flags the joystick object as unused
536//
537void _glfwFreeJoystick(_GLFWjoystick* js)
538{
539 _glfw_free(js->axes);
540 _glfw_free(js->buttons);
541 _glfw_free(js->hats);
542 memset(js, 0, sizeof(_GLFWjoystick));
543}
544
545// Center the cursor in the content area of the specified window
546//
547void _glfwCenterCursorInContentArea(_GLFWwindow* window)
548{
549 int width, height;
550
551 _glfw.platform.getWindowSize(window, &width, &height);
552 _glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);
553}
554
555
556//////////////////////////////////////////////////////////////////////////
557////// GLFW public API //////
558//////////////////////////////////////////////////////////////////////////
559
560GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
561{
562 _GLFWwindow* window = (_GLFWwindow*) handle;
563 assert(window != NULL);
564
565 _GLFW_REQUIRE_INIT_OR_RETURN(0);
566
567 switch (mode)
568 {
569 case GLFW_CURSOR:
570 return window->cursorMode;
571 case GLFW_STICKY_KEYS:
572 return window->stickyKeys;
573 case GLFW_STICKY_MOUSE_BUTTONS:
574 return window->stickyMouseButtons;
575 case GLFW_LOCK_KEY_MODS:
576 return window->lockKeyMods;
577 case GLFW_RAW_MOUSE_MOTION:
578 return window->rawMouseMotion;
579 }
580
581 _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
582 return 0;
583}
584
585GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
586{
587 _GLFWwindow* window = (_GLFWwindow*) handle;
588 assert(window != NULL);
589
590 _GLFW_REQUIRE_INIT();
591
592 switch (mode)
593 {
594 case GLFW_CURSOR:
595 {
596 if (value != GLFW_CURSOR_NORMAL &&
597 value != GLFW_CURSOR_HIDDEN &&
598 value != GLFW_CURSOR_DISABLED &&
599 value != GLFW_CURSOR_CAPTURED)
600 {
601 _glfwInputError(GLFW_INVALID_ENUM,
602 "Invalid cursor mode 0x%08X",
603 value);
604 return;
605 }
606
607 if (window->cursorMode == value)
608 return;
609
610 window->cursorMode = value;
611
612 _glfw.platform.getCursorPos(window,
613 &window->virtualCursorPosX,
614 &window->virtualCursorPosY);
615 _glfw.platform.setCursorMode(window, value);
616 return;
617 }
618
619 case GLFW_STICKY_KEYS:
620 {
621 value = value ? GLFW_TRUE : GLFW_FALSE;
622 if (window->stickyKeys == value)
623 return;
624
625 if (!value)
626 {
627 int i;
628
629 // Release all sticky keys
630 for (i = 0; i <= GLFW_KEY_LAST; i++)
631 {
632 if (window->keys[i] == _GLFW_STICK)
633 window->keys[i] = GLFW_RELEASE;
634 }
635 }
636
637 window->stickyKeys = value;
638 return;
639 }
640
641 case GLFW_STICKY_MOUSE_BUTTONS:
642 {
643 value = value ? GLFW_TRUE : GLFW_FALSE;
644 if (window->stickyMouseButtons == value)
645 return;
646
647 if (!value)
648 {
649 int i;
650
651 // Release all sticky mouse buttons
652 for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
653 {
654 if (window->mouseButtons[i] == _GLFW_STICK)
655 window->mouseButtons[i] = GLFW_RELEASE;
656 }
657 }
658
659 window->stickyMouseButtons = value;
660 return;
661 }
662
663 case GLFW_LOCK_KEY_MODS:
664 {
665 window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
666 return;
667 }
668
669 case GLFW_RAW_MOUSE_MOTION:
670 {
671 if (!_glfw.platform.rawMouseMotionSupported())
672 {
673 _glfwInputError(GLFW_PLATFORM_ERROR,
674 "Raw mouse motion is not supported on this system");
675 return;
676 }
677
678 value = value ? GLFW_TRUE : GLFW_FALSE;
679 if (window->rawMouseMotion == value)
680 return;
681
682 window->rawMouseMotion = value;
683 _glfw.platform.setRawMouseMotion(window, value);
684 return;
685 }
686 }
687
688 _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
689}
690
691GLFWAPI int glfwRawMouseMotionSupported(void)
692{
693 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
694 return _glfw.platform.rawMouseMotionSupported();
695}
696
697GLFWAPI const char* glfwGetKeyName(int key, int scancode)
698{
699 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
700
701 if (key != GLFW_KEY_UNKNOWN)
702 {
703 if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
704 {
705 _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
706 return NULL;
707 }
708
709 if (key != GLFW_KEY_KP_EQUAL &&
710 (key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) &&
711 (key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2))
712 {
713 return NULL;
714 }
715
716 scancode = _glfw.platform.getKeyScancode(key);
717 }
718
719 return _glfw.platform.getScancodeName(scancode);
720}
721
722GLFWAPI int glfwGetKeyScancode(int key)
723{
724 _GLFW_REQUIRE_INIT_OR_RETURN(0);
725
726 if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
727 {
728 _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
729 return -1;
730 }
731
732 return _glfw.platform.getKeyScancode(key);
733}
734
735GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
736{
737 _GLFWwindow* window = (_GLFWwindow*) handle;
738 assert(window != NULL);
739
740 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
741
742 if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
743 {
744 _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
745 return GLFW_RELEASE;
746 }
747
748 if (window->keys[key] == _GLFW_STICK)
749 {
750 // Sticky mode: release key now
751 window->keys[key] = GLFW_RELEASE;
752 return GLFW_PRESS;
753 }
754
755 return (int) window->keys[key];
756}
757
758GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
759{
760 _GLFWwindow* window = (_GLFWwindow*) handle;
761 assert(window != NULL);
762
763 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
764
765 if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST)
766 {
767 _glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button);
768 return GLFW_RELEASE;
769 }
770
771 if (window->mouseButtons[button] == _GLFW_STICK)
772 {
773 // Sticky mode: release mouse button now
774 window->mouseButtons[button] = GLFW_RELEASE;
775 return GLFW_PRESS;
776 }
777
778 return (int) window->mouseButtons[button];
779}
780
781GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
782{
783 _GLFWwindow* window = (_GLFWwindow*) handle;
784 assert(window != NULL);
785
786 if (xpos)
787 *xpos = 0;
788 if (ypos)
789 *ypos = 0;
790
791 _GLFW_REQUIRE_INIT();
792
793 if (window->cursorMode == GLFW_CURSOR_DISABLED)
794 {
795 if (xpos)
796 *xpos = window->virtualCursorPosX;
797 if (ypos)
798 *ypos = window->virtualCursorPosY;
799 }
800 else
801 _glfw.platform.getCursorPos(window, xpos, ypos);
802}
803
804GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
805{
806 _GLFWwindow* window = (_GLFWwindow*) handle;
807 assert(window != NULL);
808
809 _GLFW_REQUIRE_INIT();
810
811 if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX ||
812 ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX)
813 {
814 _glfwInputError(GLFW_INVALID_VALUE,
815 "Invalid cursor position %f %f",
816 xpos, ypos);
817 return;
818 }
819
820 if (!_glfw.platform.windowFocused(window))
821 return;
822
823 if (window->cursorMode == GLFW_CURSOR_DISABLED)
824 {
825 // Only update the accumulated position if the cursor is disabled
826 window->virtualCursorPosX = xpos;
827 window->virtualCursorPosY = ypos;
828 }
829 else
830 {
831 // Update system cursor position
832 _glfw.platform.setCursorPos(window, xpos, ypos);
833 }
834}
835
836GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
837{
838 _GLFWcursor* cursor;
839
840 assert(image != NULL);
841 assert(image->pixels != NULL);
842
843 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
844
845 if (image->width <= 0 || image->height <= 0)
846 {
847 _glfwInputError(GLFW_INVALID_VALUE, "Invalid image dimensions for cursor");
848 return NULL;
849 }
850
851 cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
852 cursor->next = _glfw.cursorListHead;
853 _glfw.cursorListHead = cursor;
854
855 if (!_glfw.platform.createCursor(cursor, image, xhot, yhot))
856 {
857 glfwDestroyCursor((GLFWcursor*) cursor);
858 return NULL;
859 }
860
861 return (GLFWcursor*) cursor;
862}
863
864GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
865{
866 _GLFWcursor* cursor;
867
868 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
869
870 if (shape != GLFW_ARROW_CURSOR &&
871 shape != GLFW_IBEAM_CURSOR &&
872 shape != GLFW_CROSSHAIR_CURSOR &&
873 shape != GLFW_POINTING_HAND_CURSOR &&
874 shape != GLFW_RESIZE_EW_CURSOR &&
875 shape != GLFW_RESIZE_NS_CURSOR &&
876 shape != GLFW_RESIZE_NWSE_CURSOR &&
877 shape != GLFW_RESIZE_NESW_CURSOR &&
878 shape != GLFW_RESIZE_ALL_CURSOR &&
879 shape != GLFW_NOT_ALLOWED_CURSOR)
880 {
881 _glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape);
882 return NULL;
883 }
884
885 cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
886 cursor->next = _glfw.cursorListHead;
887 _glfw.cursorListHead = cursor;
888
889 if (!_glfw.platform.createStandardCursor(cursor, shape))
890 {
891 glfwDestroyCursor((GLFWcursor*) cursor);
892 return NULL;
893 }
894
895 return (GLFWcursor*) cursor;
896}
897
898GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
899{
900 _GLFWcursor* cursor = (_GLFWcursor*) handle;
901
902 _GLFW_REQUIRE_INIT();
903
904 if (cursor == NULL)
905 return;
906
907 // Make sure the cursor is not being used by any window
908 {
909 _GLFWwindow* window;
910
911 for (window = _glfw.windowListHead; window; window = window->next)
912 {
913 if (window->cursor == cursor)
914 glfwSetCursor((GLFWwindow*) window, NULL);
915 }
916 }
917
918 _glfw.platform.destroyCursor(cursor);
919
920 // Unlink cursor from global linked list
921 {
922 _GLFWcursor** prev = &_glfw.cursorListHead;
923
924 while (*prev != cursor)
925 prev = &((*prev)->next);
926
927 *prev = cursor->next;
928 }
929
930 _glfw_free(cursor);
931}
932
933GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
934{
935 _GLFWwindow* window = (_GLFWwindow*) windowHandle;
936 _GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;
937 assert(window != NULL);
938
939 _GLFW_REQUIRE_INIT();
940
941 window->cursor = cursor;
942
943 _glfw.platform.setCursor(window, cursor);
944}
945
946GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
947{
948 _GLFWwindow* window = (_GLFWwindow*) handle;
949 assert(window != NULL);
950
951 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
952 _GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun);
953 return cbfun;
954}
955
956GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
957{
958 _GLFWwindow* window = (_GLFWwindow*) handle;
959 assert(window != NULL);
960
961 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
962 _GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun);
963 return cbfun;
964}
965
966GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
967{
968 _GLFWwindow* window = (_GLFWwindow*) handle;
969 assert(window != NULL);
970
971 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
972 _GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun);
973 return cbfun;
974}
975
976GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
977 GLFWmousebuttonfun cbfun)
978{
979 _GLFWwindow* window = (_GLFWwindow*) handle;
980 assert(window != NULL);
981
982 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
983 _GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun);
984 return cbfun;
985}
986
987GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
988 GLFWcursorposfun cbfun)
989{
990 _GLFWwindow* window = (_GLFWwindow*) handle;
991 assert(window != NULL);
992
993 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
994 _GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun);
995 return cbfun;
996}
997
998GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
999 GLFWcursorenterfun cbfun)
1000{
1001 _GLFWwindow* window = (_GLFWwindow*) handle;
1002 assert(window != NULL);
1003
1004 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1005 _GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun);
1006 return cbfun;
1007}
1008
1009GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
1010 GLFWscrollfun cbfun)
1011{
1012 _GLFWwindow* window = (_GLFWwindow*) handle;
1013 assert(window != NULL);
1014
1015 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1016 _GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun);
1017 return cbfun;
1018}
1019
1020GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
1021{
1022 _GLFWwindow* window = (_GLFWwindow*) handle;
1023 assert(window != NULL);
1024
1025 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1026 _GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun);
1027 return cbfun;
1028}
1029
1030GLFWAPI int glfwJoystickPresent(int jid)
1031{
1032 _GLFWjoystick* js;
1033
1034 assert(jid >= GLFW_JOYSTICK_1);
1035 assert(jid <= GLFW_JOYSTICK_LAST);
1036
1037 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
1038
1039 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1040 {
1041 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1042 return GLFW_FALSE;
1043 }
1044
1045 if (!initJoysticks())
1046 return GLFW_FALSE;
1047
1048 js = _glfw.joysticks + jid;
1049 if (!js->connected)
1050 return GLFW_FALSE;
1051
1052 return _glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE);
1053}
1054
1055GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
1056{
1057 _GLFWjoystick* js;
1058
1059 assert(jid >= GLFW_JOYSTICK_1);
1060 assert(jid <= GLFW_JOYSTICK_LAST);
1061 assert(count != NULL);
1062
1063 *count = 0;
1064
1065 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1066
1067 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1068 {
1069 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1070 return NULL;
1071 }
1072
1073 if (!initJoysticks())
1074 return NULL;
1075
1076 js = _glfw.joysticks + jid;
1077 if (!js->connected)
1078 return NULL;
1079
1080 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_AXES))
1081 return NULL;
1082
1083 *count = js->axisCount;
1084 return js->axes;
1085}
1086
1087GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
1088{
1089 _GLFWjoystick* js;
1090
1091 assert(jid >= GLFW_JOYSTICK_1);
1092 assert(jid <= GLFW_JOYSTICK_LAST);
1093 assert(count != NULL);
1094
1095 *count = 0;
1096
1097 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1098
1099 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1100 {
1101 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1102 return NULL;
1103 }
1104
1105 if (!initJoysticks())
1106 return NULL;
1107
1108 js = _glfw.joysticks + jid;
1109 if (!js->connected)
1110 return NULL;
1111
1112 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
1113 return NULL;
1114
1115 if (_glfw.hints.init.hatButtons)
1116 *count = js->buttonCount + js->hatCount * 4;
1117 else
1118 *count = js->buttonCount;
1119
1120 return js->buttons;
1121}
1122
1123GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
1124{
1125 _GLFWjoystick* js;
1126
1127 assert(jid >= GLFW_JOYSTICK_1);
1128 assert(jid <= GLFW_JOYSTICK_LAST);
1129 assert(count != NULL);
1130
1131 *count = 0;
1132
1133 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1134
1135 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1136 {
1137 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1138 return NULL;
1139 }
1140
1141 if (!initJoysticks())
1142 return NULL;
1143
1144 js = _glfw.joysticks + jid;
1145 if (!js->connected)
1146 return NULL;
1147
1148 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
1149 return NULL;
1150
1151 *count = js->hatCount;
1152 return js->hats;
1153}
1154
1155GLFWAPI const char* glfwGetJoystickName(int jid)
1156{
1157 _GLFWjoystick* js;
1158
1159 assert(jid >= GLFW_JOYSTICK_1);
1160 assert(jid <= GLFW_JOYSTICK_LAST);
1161
1162 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1163
1164 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1165 {
1166 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1167 return NULL;
1168 }
1169
1170 if (!initJoysticks())
1171 return NULL;
1172
1173 js = _glfw.joysticks + jid;
1174 if (!js->connected)
1175 return NULL;
1176
1177 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
1178 return NULL;
1179
1180 return js->name;
1181}
1182
1183GLFWAPI const char* glfwGetJoystickGUID(int jid)
1184{
1185 _GLFWjoystick* js;
1186
1187 assert(jid >= GLFW_JOYSTICK_1);
1188 assert(jid <= GLFW_JOYSTICK_LAST);
1189
1190 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1191
1192 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1193 {
1194 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1195 return NULL;
1196 }
1197
1198 if (!initJoysticks())
1199 return NULL;
1200
1201 js = _glfw.joysticks + jid;
1202 if (!js->connected)
1203 return NULL;
1204
1205 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
1206 return NULL;
1207
1208 return js->guid;
1209}
1210
1211GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
1212{
1213 _GLFWjoystick* js;
1214
1215 assert(jid >= GLFW_JOYSTICK_1);
1216 assert(jid <= GLFW_JOYSTICK_LAST);
1217
1218 _GLFW_REQUIRE_INIT();
1219
1220 js = _glfw.joysticks + jid;
1221 if (!js->allocated)
1222 return;
1223
1224 js->userPointer = pointer;
1225}
1226
1227GLFWAPI void* glfwGetJoystickUserPointer(int jid)
1228{
1229 _GLFWjoystick* js;
1230
1231 assert(jid >= GLFW_JOYSTICK_1);
1232 assert(jid <= GLFW_JOYSTICK_LAST);
1233
1234 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1235
1236 js = _glfw.joysticks + jid;
1237 if (!js->allocated)
1238 return NULL;
1239
1240 return js->userPointer;
1241}
1242
1243GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
1244{
1245 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1246
1247 if (!initJoysticks())
1248 return NULL;
1249
1250 _GLFW_SWAP(GLFWjoystickfun, _glfw.callbacks.joystick, cbfun);
1251 return cbfun;
1252}
1253
1254GLFWAPI int glfwUpdateGamepadMappings(const char* string)
1255{
1256 int jid;
1257 const char* c = string;
1258
1259 assert(string != NULL);
1260
1261 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
1262
1263 while (*c)
1264 {
1265 if ((*c >= '0' && *c <= '9') ||
1266 (*c >= 'a' && *c <= 'f') ||
1267 (*c >= 'A' && *c <= 'F'))
1268 {
1269 char line[1024];
1270
1271 const size_t length = strcspn(c, "\r\n");
1272 if (length < sizeof(line))
1273 {
1274 _GLFWmapping mapping = {{0}};
1275
1276 memcpy(line, c, length);
1277 line[length] = '\0';
1278
1279 if (parseMapping(&mapping, line))
1280 {
1281 _GLFWmapping* previous = findMapping(mapping.guid);
1282 if (previous)
1283 *previous = mapping;
1284 else
1285 {
1286 _glfw.mappingCount++;
1287 _glfw.mappings =
1288 _glfw_realloc(_glfw.mappings,
1289 sizeof(_GLFWmapping) * _glfw.mappingCount);
1290 _glfw.mappings[_glfw.mappingCount - 1] = mapping;
1291 }
1292 }
1293 }
1294
1295 c += length;
1296 }
1297 else
1298 {
1299 c += strcspn(c, "\r\n");
1300 c += strspn(c, "\r\n");
1301 }
1302 }
1303
1304 for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
1305 {
1306 _GLFWjoystick* js = _glfw.joysticks + jid;
1307 if (js->connected)
1308 js->mapping = findValidMapping(js);
1309 }
1310
1311 return GLFW_TRUE;
1312}
1313
1314GLFWAPI int glfwJoystickIsGamepad(int jid)
1315{
1316 _GLFWjoystick* js;
1317
1318 assert(jid >= GLFW_JOYSTICK_1);
1319 assert(jid <= GLFW_JOYSTICK_LAST);
1320
1321 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
1322
1323 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1324 {
1325 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1326 return GLFW_FALSE;
1327 }
1328
1329 if (!initJoysticks())
1330 return GLFW_FALSE;
1331
1332 js = _glfw.joysticks + jid;
1333 if (!js->connected)
1334 return GLFW_FALSE;
1335
1336 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
1337 return GLFW_FALSE;
1338
1339 return js->mapping != NULL;
1340}
1341
1342GLFWAPI const char* glfwGetGamepadName(int jid)
1343{
1344 _GLFWjoystick* js;
1345
1346 assert(jid >= GLFW_JOYSTICK_1);
1347 assert(jid <= GLFW_JOYSTICK_LAST);
1348
1349 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1350
1351 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1352 {
1353 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1354 return NULL;
1355 }
1356
1357 if (!initJoysticks())
1358 return NULL;
1359
1360 js = _glfw.joysticks + jid;
1361 if (!js->connected)
1362 return NULL;
1363
1364 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
1365 return NULL;
1366
1367 if (!js->mapping)
1368 return NULL;
1369
1370 return js->mapping->name;
1371}
1372
1373GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
1374{
1375 int i;
1376 _GLFWjoystick* js;
1377
1378 assert(jid >= GLFW_JOYSTICK_1);
1379 assert(jid <= GLFW_JOYSTICK_LAST);
1380 assert(state != NULL);
1381
1382 memset(state, 0, sizeof(GLFWgamepadstate));
1383
1384 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
1385
1386 if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
1387 {
1388 _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
1389 return GLFW_FALSE;
1390 }
1391
1392 if (!initJoysticks())
1393 return GLFW_FALSE;
1394
1395 js = _glfw.joysticks + jid;
1396 if (!js->connected)
1397 return GLFW_FALSE;
1398
1399 if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_ALL))
1400 return GLFW_FALSE;
1401
1402 if (!js->mapping)
1403 return GLFW_FALSE;
1404
1405 for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
1406 {
1407 const _GLFWmapelement* e = js->mapping->buttons + i;
1408 if (e->type == _GLFW_JOYSTICK_AXIS)
1409 {
1410 const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
1411 // HACK: This should be baked into the value transform
1412 // TODO: Bake into transform when implementing output modifiers
1413 if (e->axisOffset < 0 || (e->axisOffset == 0 && e->axisScale > 0))
1414 {
1415 if (value >= 0.f)
1416 state->buttons[i] = GLFW_PRESS;
1417 }
1418 else
1419 {
1420 if (value <= 0.f)
1421 state->buttons[i] = GLFW_PRESS;
1422 }
1423 }
1424 else if (e->type == _GLFW_JOYSTICK_HATBIT)
1425 {
1426 const unsigned int hat = e->index >> 4;
1427 const unsigned int bit = e->index & 0xf;
1428 if (js->hats[hat] & bit)
1429 state->buttons[i] = GLFW_PRESS;
1430 }
1431 else if (e->type == _GLFW_JOYSTICK_BUTTON)
1432 state->buttons[i] = js->buttons[e->index];
1433 }
1434
1435 for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
1436 {
1437 const _GLFWmapelement* e = js->mapping->axes + i;
1438 if (e->type == _GLFW_JOYSTICK_AXIS)
1439 {
1440 const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
1441 state->axes[i] = fminf(fmaxf(value, -1.f), 1.f);
1442 }
1443 else if (e->type == _GLFW_JOYSTICK_HATBIT)
1444 {
1445 const unsigned int hat = e->index >> 4;
1446 const unsigned int bit = e->index & 0xf;
1447 if (js->hats[hat] & bit)
1448 state->axes[i] = 1.f;
1449 else
1450 state->axes[i] = -1.f;
1451 }
1452 else if (e->type == _GLFW_JOYSTICK_BUTTON)
1453 state->axes[i] = js->buttons[e->index] * 2.f - 1.f;
1454 }
1455
1456 return GLFW_TRUE;
1457}
1458
1459GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
1460{
1461 assert(string != NULL);
1462
1463 _GLFW_REQUIRE_INIT();
1464 _glfw.platform.setClipboardString(string);
1465}
1466
1467GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
1468{
1469 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1470 return _glfw.platform.getClipboardString();
1471}
1472
1473GLFWAPI double glfwGetTime(void)
1474{
1475 _GLFW_REQUIRE_INIT_OR_RETURN(0.0);
1476 return (double) (_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
1477 _glfwPlatformGetTimerFrequency();
1478}
1479
1480GLFWAPI void glfwSetTime(double time)
1481{
1482 _GLFW_REQUIRE_INIT();
1483
1484 if (time != time || time < 0.0 || time > 18446744073.0)
1485 {
1486 _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
1487 return;
1488 }
1489
1490 _glfw.timer.offset = _glfwPlatformGetTimerValue() -
1491 (uint64_t) (time * _glfwPlatformGetTimerFrequency());
1492}
1493
1494GLFWAPI uint64_t glfwGetTimerValue(void)
1495{
1496 _GLFW_REQUIRE_INIT_OR_RETURN(0);
1497 return _glfwPlatformGetTimerValue();
1498}
1499
1500GLFWAPI uint64_t glfwGetTimerFrequency(void)
1501{
1502 _GLFW_REQUIRE_INIT_OR_RETURN(0);
1503 return _glfwPlatformGetTimerFrequency();
1504}
1505
diff --git a/raylib/src/external/glfw/src/internal.h b/raylib/src/external/glfw/src/internal.h
new file mode 100644
index 0000000..8873359
--- /dev/null
+++ b/raylib/src/external/glfw/src/internal.h
@@ -0,0 +1,1009 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#pragma once
29
30#if defined(_GLFW_USE_CONFIG_H)
31 #include "glfw_config.h"
32#endif
33
34#if defined(GLFW_INCLUDE_GLCOREARB) || \
35 defined(GLFW_INCLUDE_ES1) || \
36 defined(GLFW_INCLUDE_ES2) || \
37 defined(GLFW_INCLUDE_ES3) || \
38 defined(GLFW_INCLUDE_ES31) || \
39 defined(GLFW_INCLUDE_ES32) || \
40 defined(GLFW_INCLUDE_NONE) || \
41 defined(GLFW_INCLUDE_GLEXT) || \
42 defined(GLFW_INCLUDE_GLU) || \
43 defined(GLFW_INCLUDE_VULKAN) || \
44 defined(GLFW_DLL)
45 #error "You must not define any header option macros when compiling GLFW"
46#endif
47
48#define GLFW_INCLUDE_NONE
49#include "../include/GLFW/glfw3.h"
50
51#define _GLFW_INSERT_FIRST 0
52#define _GLFW_INSERT_LAST 1
53
54#define _GLFW_POLL_PRESENCE 0
55#define _GLFW_POLL_AXES 1
56#define _GLFW_POLL_BUTTONS 2
57#define _GLFW_POLL_ALL (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS)
58
59#define _GLFW_MESSAGE_SIZE 1024
60
61typedef int GLFWbool;
62typedef void (*GLFWproc)(void);
63
64typedef struct _GLFWerror _GLFWerror;
65typedef struct _GLFWinitconfig _GLFWinitconfig;
66typedef struct _GLFWwndconfig _GLFWwndconfig;
67typedef struct _GLFWctxconfig _GLFWctxconfig;
68typedef struct _GLFWfbconfig _GLFWfbconfig;
69typedef struct _GLFWcontext _GLFWcontext;
70typedef struct _GLFWwindow _GLFWwindow;
71typedef struct _GLFWplatform _GLFWplatform;
72typedef struct _GLFWlibrary _GLFWlibrary;
73typedef struct _GLFWmonitor _GLFWmonitor;
74typedef struct _GLFWcursor _GLFWcursor;
75typedef struct _GLFWmapelement _GLFWmapelement;
76typedef struct _GLFWmapping _GLFWmapping;
77typedef struct _GLFWjoystick _GLFWjoystick;
78typedef struct _GLFWtls _GLFWtls;
79typedef struct _GLFWmutex _GLFWmutex;
80
81#define GL_VERSION 0x1f02
82#define GL_NONE 0
83#define GL_COLOR_BUFFER_BIT 0x00004000
84#define GL_UNSIGNED_BYTE 0x1401
85#define GL_EXTENSIONS 0x1f03
86#define GL_NUM_EXTENSIONS 0x821d
87#define GL_CONTEXT_FLAGS 0x821e
88#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
89#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
90#define GL_CONTEXT_PROFILE_MASK 0x9126
91#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
92#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
93#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
94#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
95#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
96#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82fb
97#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc
98#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
99
100typedef int GLint;
101typedef unsigned int GLuint;
102typedef unsigned int GLenum;
103typedef unsigned int GLbitfield;
104typedef unsigned char GLubyte;
105
106typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);
107typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
108typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
109typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
110
111#define EGL_SUCCESS 0x3000
112#define EGL_NOT_INITIALIZED 0x3001
113#define EGL_BAD_ACCESS 0x3002
114#define EGL_BAD_ALLOC 0x3003
115#define EGL_BAD_ATTRIBUTE 0x3004
116#define EGL_BAD_CONFIG 0x3005
117#define EGL_BAD_CONTEXT 0x3006
118#define EGL_BAD_CURRENT_SURFACE 0x3007
119#define EGL_BAD_DISPLAY 0x3008
120#define EGL_BAD_MATCH 0x3009
121#define EGL_BAD_NATIVE_PIXMAP 0x300a
122#define EGL_BAD_NATIVE_WINDOW 0x300b
123#define EGL_BAD_PARAMETER 0x300c
124#define EGL_BAD_SURFACE 0x300d
125#define EGL_CONTEXT_LOST 0x300e
126#define EGL_COLOR_BUFFER_TYPE 0x303f
127#define EGL_RGB_BUFFER 0x308e
128#define EGL_SURFACE_TYPE 0x3033
129#define EGL_WINDOW_BIT 0x0004
130#define EGL_RENDERABLE_TYPE 0x3040
131#define EGL_OPENGL_ES_BIT 0x0001
132#define EGL_OPENGL_ES2_BIT 0x0004
133#define EGL_OPENGL_BIT 0x0008
134#define EGL_ALPHA_SIZE 0x3021
135#define EGL_BLUE_SIZE 0x3022
136#define EGL_GREEN_SIZE 0x3023
137#define EGL_RED_SIZE 0x3024
138#define EGL_DEPTH_SIZE 0x3025
139#define EGL_STENCIL_SIZE 0x3026
140#define EGL_SAMPLES 0x3031
141#define EGL_OPENGL_ES_API 0x30a0
142#define EGL_OPENGL_API 0x30a2
143#define EGL_NONE 0x3038
144#define EGL_RENDER_BUFFER 0x3086
145#define EGL_SINGLE_BUFFER 0x3085
146#define EGL_EXTENSIONS 0x3055
147#define EGL_CONTEXT_CLIENT_VERSION 0x3098
148#define EGL_NATIVE_VISUAL_ID 0x302e
149#define EGL_NO_SURFACE ((EGLSurface) 0)
150#define EGL_NO_DISPLAY ((EGLDisplay) 0)
151#define EGL_NO_CONTEXT ((EGLContext) 0)
152#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
153
154#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
155#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
156#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
157#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
158#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
159#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
160#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
161#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
162#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
163#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
164#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
165#define EGL_CONTEXT_FLAGS_KHR 0x30fc
166#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
167#define EGL_GL_COLORSPACE_KHR 0x309d
168#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
169#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
170#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
171#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
172#define EGL_PLATFORM_X11_EXT 0x31d5
173#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
174#define EGL_PRESENT_OPAQUE_EXT 0x31df
175#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
176#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
177#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
178#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
179#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
180#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
181#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
182#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
183#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
184
185typedef int EGLint;
186typedef unsigned int EGLBoolean;
187typedef unsigned int EGLenum;
188typedef void* EGLConfig;
189typedef void* EGLContext;
190typedef void* EGLDisplay;
191typedef void* EGLSurface;
192
193typedef void* EGLNativeDisplayType;
194typedef void* EGLNativeWindowType;
195
196// EGL function pointer typedefs
197typedef EGLBoolean (APIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
198typedef EGLBoolean (APIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
199typedef EGLDisplay (APIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
200typedef EGLint (APIENTRY * PFN_eglGetError)(void);
201typedef EGLBoolean (APIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
202typedef EGLBoolean (APIENTRY * PFN_eglTerminate)(EGLDisplay);
203typedef EGLBoolean (APIENTRY * PFN_eglBindAPI)(EGLenum);
204typedef EGLContext (APIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
205typedef EGLBoolean (APIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
206typedef EGLBoolean (APIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
207typedef EGLSurface (APIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
208typedef EGLBoolean (APIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
209typedef EGLBoolean (APIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
210typedef EGLBoolean (APIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
211typedef const char* (APIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
212typedef GLFWglproc (APIENTRY * PFN_eglGetProcAddress)(const char*);
213#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
214#define eglGetConfigs _glfw.egl.GetConfigs
215#define eglGetDisplay _glfw.egl.GetDisplay
216#define eglGetError _glfw.egl.GetError
217#define eglInitialize _glfw.egl.Initialize
218#define eglTerminate _glfw.egl.Terminate
219#define eglBindAPI _glfw.egl.BindAPI
220#define eglCreateContext _glfw.egl.CreateContext
221#define eglDestroySurface _glfw.egl.DestroySurface
222#define eglDestroyContext _glfw.egl.DestroyContext
223#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
224#define eglMakeCurrent _glfw.egl.MakeCurrent
225#define eglSwapBuffers _glfw.egl.SwapBuffers
226#define eglSwapInterval _glfw.egl.SwapInterval
227#define eglQueryString _glfw.egl.QueryString
228#define eglGetProcAddress _glfw.egl.GetProcAddress
229
230typedef EGLDisplay (APIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
231typedef EGLSurface (APIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
232#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
233#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
234
235#define OSMESA_RGBA 0x1908
236#define OSMESA_FORMAT 0x22
237#define OSMESA_DEPTH_BITS 0x30
238#define OSMESA_STENCIL_BITS 0x31
239#define OSMESA_ACCUM_BITS 0x32
240#define OSMESA_PROFILE 0x33
241#define OSMESA_CORE_PROFILE 0x34
242#define OSMESA_COMPAT_PROFILE 0x35
243#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
244#define OSMESA_CONTEXT_MINOR_VERSION 0x37
245
246typedef void* OSMesaContext;
247typedef void (*OSMESAproc)(void);
248
249typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
250typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
251typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
252typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
253typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
254typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
255typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
256#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
257#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
258#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
259#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
260#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
261#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
262#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
263
264#define VK_NULL_HANDLE 0
265
266typedef void* VkInstance;
267typedef void* VkPhysicalDevice;
268typedef uint64_t VkSurfaceKHR;
269typedef uint32_t VkFlags;
270typedef uint32_t VkBool32;
271
272typedef enum VkStructureType
273{
274 VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
275 VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
276 VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
277 VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
278 VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
279 VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
280 VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
281} VkStructureType;
282
283typedef enum VkResult
284{
285 VK_SUCCESS = 0,
286 VK_NOT_READY = 1,
287 VK_TIMEOUT = 2,
288 VK_EVENT_SET = 3,
289 VK_EVENT_RESET = 4,
290 VK_INCOMPLETE = 5,
291 VK_ERROR_OUT_OF_HOST_MEMORY = -1,
292 VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
293 VK_ERROR_INITIALIZATION_FAILED = -3,
294 VK_ERROR_DEVICE_LOST = -4,
295 VK_ERROR_MEMORY_MAP_FAILED = -5,
296 VK_ERROR_LAYER_NOT_PRESENT = -6,
297 VK_ERROR_EXTENSION_NOT_PRESENT = -7,
298 VK_ERROR_FEATURE_NOT_PRESENT = -8,
299 VK_ERROR_INCOMPATIBLE_DRIVER = -9,
300 VK_ERROR_TOO_MANY_OBJECTS = -10,
301 VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
302 VK_ERROR_SURFACE_LOST_KHR = -1000000000,
303 VK_SUBOPTIMAL_KHR = 1000001003,
304 VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
305 VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
306 VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
307 VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
308 VK_RESULT_MAX_ENUM = 0x7FFFFFFF
309} VkResult;
310
311typedef struct VkAllocationCallbacks VkAllocationCallbacks;
312
313typedef struct VkExtensionProperties
314{
315 char extensionName[256];
316 uint32_t specVersion;
317} VkExtensionProperties;
318
319typedef void (APIENTRY * PFN_vkVoidFunction)(void);
320
321typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
322typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
323#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
324
325#include "platform.h"
326
327#define GLFW_NATIVE_INCLUDE_NONE
328#include "../include/GLFW/glfw3native.h"
329
330// Checks for whether the library has been initialized
331#define _GLFW_REQUIRE_INIT() \
332 if (!_glfw.initialized) \
333 { \
334 _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
335 return; \
336 }
337#define _GLFW_REQUIRE_INIT_OR_RETURN(x) \
338 if (!_glfw.initialized) \
339 { \
340 _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
341 return x; \
342 }
343
344// Swaps the provided pointers
345#define _GLFW_SWAP(type, x, y) \
346 { \
347 type t; \
348 t = x; \
349 x = y; \
350 y = t; \
351 }
352
353// Per-thread error structure
354//
355struct _GLFWerror
356{
357 _GLFWerror* next;
358 int code;
359 char description[_GLFW_MESSAGE_SIZE];
360};
361
362// Initialization configuration
363//
364// Parameters relating to the initialization of the library
365//
366struct _GLFWinitconfig
367{
368 GLFWbool hatButtons;
369 int angleType;
370 int platformID;
371 PFN_vkGetInstanceProcAddr vulkanLoader;
372 struct {
373 GLFWbool menubar;
374 GLFWbool chdir;
375 } ns;
376 struct {
377 GLFWbool xcbVulkanSurface;
378 } x11;
379 struct {
380 int libdecorMode;
381 } wl;
382};
383
384// Window configuration
385//
386// Parameters relating to the creation of the window but not directly related
387// to the framebuffer. This is used to pass window creation parameters from
388// shared code to the platform API.
389//
390struct _GLFWwndconfig
391{
392 int xpos;
393 int ypos;
394 int width;
395 int height;
396 const char* title;
397 GLFWbool resizable;
398 GLFWbool visible;
399 GLFWbool decorated;
400 GLFWbool focused;
401 GLFWbool autoIconify;
402 GLFWbool floating;
403 GLFWbool maximized;
404 GLFWbool centerCursor;
405 GLFWbool focusOnShow;
406 GLFWbool mousePassthrough;
407 GLFWbool scaleToMonitor;
408 GLFWbool scaleFramebuffer;
409 struct {
410 char frameName[256];
411 } ns;
412 struct {
413 char className[256];
414 char instanceName[256];
415 } x11;
416 struct {
417 GLFWbool keymenu;
418 GLFWbool showDefault;
419 } win32;
420 struct {
421 char appId[256];
422 } wl;
423};
424
425// Context configuration
426//
427// Parameters relating to the creation of the context but not directly related
428// to the framebuffer. This is used to pass context creation parameters from
429// shared code to the platform API.
430//
431struct _GLFWctxconfig
432{
433 int client;
434 int source;
435 int major;
436 int minor;
437 GLFWbool forward;
438 GLFWbool debug;
439 GLFWbool noerror;
440 int profile;
441 int robustness;
442 int release;
443 _GLFWwindow* share;
444 struct {
445 GLFWbool offline;
446 } nsgl;
447};
448
449// Framebuffer configuration
450//
451// This describes buffers and their sizes. It also contains
452// a platform-specific ID used to map back to the backend API object.
453//
454// It is used to pass framebuffer parameters from shared code to the platform
455// API and also to enumerate and select available framebuffer configs.
456//
457struct _GLFWfbconfig
458{
459 int redBits;
460 int greenBits;
461 int blueBits;
462 int alphaBits;
463 int depthBits;
464 int stencilBits;
465 int accumRedBits;
466 int accumGreenBits;
467 int accumBlueBits;
468 int accumAlphaBits;
469 int auxBuffers;
470 GLFWbool stereo;
471 int samples;
472 GLFWbool sRGB;
473 GLFWbool doublebuffer;
474 GLFWbool transparent;
475 uintptr_t handle;
476};
477
478// Context structure
479//
480struct _GLFWcontext
481{
482 int client;
483 int source;
484 int major, minor, revision;
485 GLFWbool forward, debug, noerror;
486 int profile;
487 int robustness;
488 int release;
489
490 PFNGLGETSTRINGIPROC GetStringi;
491 PFNGLGETINTEGERVPROC GetIntegerv;
492 PFNGLGETSTRINGPROC GetString;
493
494 void (*makeCurrent)(_GLFWwindow*);
495 void (*swapBuffers)(_GLFWwindow*);
496 void (*swapInterval)(int);
497 int (*extensionSupported)(const char*);
498 GLFWglproc (*getProcAddress)(const char*);
499 void (*destroy)(_GLFWwindow*);
500
501 struct {
502 EGLConfig config;
503 EGLContext handle;
504 EGLSurface surface;
505 void* client;
506 } egl;
507
508 struct {
509 OSMesaContext handle;
510 int width;
511 int height;
512 void* buffer;
513 } osmesa;
514
515 // This is defined in platform.h
516 GLFW_PLATFORM_CONTEXT_STATE
517};
518
519// Window and context structure
520//
521struct _GLFWwindow
522{
523 struct _GLFWwindow* next;
524
525 // Window settings and state
526 GLFWbool resizable;
527 GLFWbool decorated;
528 GLFWbool autoIconify;
529 GLFWbool floating;
530 GLFWbool focusOnShow;
531 GLFWbool mousePassthrough;
532 GLFWbool shouldClose;
533 void* userPointer;
534 GLFWbool doublebuffer;
535 GLFWvidmode videoMode;
536 _GLFWmonitor* monitor;
537 _GLFWcursor* cursor;
538 char* title;
539
540 int minwidth, minheight;
541 int maxwidth, maxheight;
542 int numer, denom;
543
544 GLFWbool stickyKeys;
545 GLFWbool stickyMouseButtons;
546 GLFWbool lockKeyMods;
547 int cursorMode;
548 char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
549 char keys[GLFW_KEY_LAST + 1];
550 // Virtual cursor position when cursor is disabled
551 double virtualCursorPosX, virtualCursorPosY;
552 GLFWbool rawMouseMotion;
553
554 _GLFWcontext context;
555
556 struct {
557 GLFWwindowposfun pos;
558 GLFWwindowsizefun size;
559 GLFWwindowclosefun close;
560 GLFWwindowrefreshfun refresh;
561 GLFWwindowfocusfun focus;
562 GLFWwindowiconifyfun iconify;
563 GLFWwindowmaximizefun maximize;
564 GLFWframebuffersizefun fbsize;
565 GLFWwindowcontentscalefun scale;
566 GLFWmousebuttonfun mouseButton;
567 GLFWcursorposfun cursorPos;
568 GLFWcursorenterfun cursorEnter;
569 GLFWscrollfun scroll;
570 GLFWkeyfun key;
571 GLFWcharfun character;
572 GLFWcharmodsfun charmods;
573 GLFWdropfun drop;
574 } callbacks;
575
576 // This is defined in platform.h
577 GLFW_PLATFORM_WINDOW_STATE
578};
579
580// Monitor structure
581//
582struct _GLFWmonitor
583{
584 char name[128];
585 void* userPointer;
586
587 // Physical dimensions in millimeters.
588 int widthMM, heightMM;
589
590 // The window whose video mode is current on this monitor
591 _GLFWwindow* window;
592
593 GLFWvidmode* modes;
594 int modeCount;
595 GLFWvidmode currentMode;
596
597 GLFWgammaramp originalRamp;
598 GLFWgammaramp currentRamp;
599
600 // This is defined in platform.h
601 GLFW_PLATFORM_MONITOR_STATE
602};
603
604// Cursor structure
605//
606struct _GLFWcursor
607{
608 _GLFWcursor* next;
609 // This is defined in platform.h
610 GLFW_PLATFORM_CURSOR_STATE
611};
612
613// Gamepad mapping element structure
614//
615struct _GLFWmapelement
616{
617 uint8_t type;
618 uint8_t index;
619 int8_t axisScale;
620 int8_t axisOffset;
621};
622
623// Gamepad mapping structure
624//
625struct _GLFWmapping
626{
627 char name[128];
628 char guid[33];
629 _GLFWmapelement buttons[15];
630 _GLFWmapelement axes[6];
631};
632
633// Joystick structure
634//
635struct _GLFWjoystick
636{
637 GLFWbool allocated;
638 GLFWbool connected;
639 float* axes;
640 int axisCount;
641 unsigned char* buttons;
642 int buttonCount;
643 unsigned char* hats;
644 int hatCount;
645 char name[128];
646 void* userPointer;
647 char guid[33];
648 _GLFWmapping* mapping;
649
650 // This is defined in platform.h
651 GLFW_PLATFORM_JOYSTICK_STATE
652};
653
654// Thread local storage structure
655//
656struct _GLFWtls
657{
658 // This is defined in platform.h
659 GLFW_PLATFORM_TLS_STATE
660};
661
662// Mutex structure
663//
664struct _GLFWmutex
665{
666 // This is defined in platform.h
667 GLFW_PLATFORM_MUTEX_STATE
668};
669
670// Platform API structure
671//
672struct _GLFWplatform
673{
674 int platformID;
675 // init
676 GLFWbool (*init)(void);
677 void (*terminate)(void);
678 // input
679 void (*getCursorPos)(_GLFWwindow*,double*,double*);
680 void (*setCursorPos)(_GLFWwindow*,double,double);
681 void (*setCursorMode)(_GLFWwindow*,int);
682 void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool);
683 GLFWbool (*rawMouseMotionSupported)(void);
684 GLFWbool (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int);
685 GLFWbool (*createStandardCursor)(_GLFWcursor*,int);
686 void (*destroyCursor)(_GLFWcursor*);
687 void (*setCursor)(_GLFWwindow*,_GLFWcursor*);
688 const char* (*getScancodeName)(int);
689 int (*getKeyScancode)(int);
690 void (*setClipboardString)(const char*);
691 const char* (*getClipboardString)(void);
692 GLFWbool (*initJoysticks)(void);
693 void (*terminateJoysticks)(void);
694 GLFWbool (*pollJoystick)(_GLFWjoystick*,int);
695 const char* (*getMappingName)(void);
696 void (*updateGamepadGUID)(char*);
697 // monitor
698 void (*freeMonitor)(_GLFWmonitor*);
699 void (*getMonitorPos)(_GLFWmonitor*,int*,int*);
700 void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*);
701 void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*);
702 GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*);
703 GLFWbool (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*);
704 GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
705 void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
706 // window
707 GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
708 void (*destroyWindow)(_GLFWwindow*);
709 void (*setWindowTitle)(_GLFWwindow*,const char*);
710 void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
711 void (*getWindowPos)(_GLFWwindow*,int*,int*);
712 void (*setWindowPos)(_GLFWwindow*,int,int);
713 void (*getWindowSize)(_GLFWwindow*,int*,int*);
714 void (*setWindowSize)(_GLFWwindow*,int,int);
715 void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int);
716 void (*setWindowAspectRatio)(_GLFWwindow*,int,int);
717 void (*getFramebufferSize)(_GLFWwindow*,int*,int*);
718 void (*getWindowFrameSize)(_GLFWwindow*,int*,int*,int*,int*);
719 void (*getWindowContentScale)(_GLFWwindow*,float*,float*);
720 void (*iconifyWindow)(_GLFWwindow*);
721 void (*restoreWindow)(_GLFWwindow*);
722 void (*maximizeWindow)(_GLFWwindow*);
723 void (*showWindow)(_GLFWwindow*);
724 void (*hideWindow)(_GLFWwindow*);
725 void (*requestWindowAttention)(_GLFWwindow*);
726 void (*focusWindow)(_GLFWwindow*);
727 void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int);
728 GLFWbool (*windowFocused)(_GLFWwindow*);
729 GLFWbool (*windowIconified)(_GLFWwindow*);
730 GLFWbool (*windowVisible)(_GLFWwindow*);
731 GLFWbool (*windowMaximized)(_GLFWwindow*);
732 GLFWbool (*windowHovered)(_GLFWwindow*);
733 GLFWbool (*framebufferTransparent)(_GLFWwindow*);
734 float (*getWindowOpacity)(_GLFWwindow*);
735 void (*setWindowResizable)(_GLFWwindow*,GLFWbool);
736 void (*setWindowDecorated)(_GLFWwindow*,GLFWbool);
737 void (*setWindowFloating)(_GLFWwindow*,GLFWbool);
738 void (*setWindowOpacity)(_GLFWwindow*,float);
739 void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool);
740 void (*pollEvents)(void);
741 void (*waitEvents)(void);
742 void (*waitEventsTimeout)(double);
743 void (*postEmptyEvent)(void);
744 // EGL
745 EGLenum (*getEGLPlatform)(EGLint**);
746 EGLNativeDisplayType (*getEGLNativeDisplay)(void);
747 EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*);
748 // vulkan
749 void (*getRequiredInstanceExtensions)(char**);
750 GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
751 VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
752};
753
754// Library global data
755//
756struct _GLFWlibrary
757{
758 GLFWbool initialized;
759 GLFWallocator allocator;
760
761 _GLFWplatform platform;
762
763 struct {
764 _GLFWinitconfig init;
765 _GLFWfbconfig framebuffer;
766 _GLFWwndconfig window;
767 _GLFWctxconfig context;
768 int refreshRate;
769 } hints;
770
771 _GLFWerror* errorListHead;
772 _GLFWcursor* cursorListHead;
773 _GLFWwindow* windowListHead;
774
775 _GLFWmonitor** monitors;
776 int monitorCount;
777
778 GLFWbool joysticksInitialized;
779 _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
780 _GLFWmapping* mappings;
781 int mappingCount;
782
783 _GLFWtls errorSlot;
784 _GLFWtls contextSlot;
785 _GLFWmutex errorLock;
786
787 struct {
788 uint64_t offset;
789 // This is defined in platform.h
790 GLFW_PLATFORM_LIBRARY_TIMER_STATE
791 } timer;
792
793 struct {
794 EGLenum platform;
795 EGLDisplay display;
796 EGLint major, minor;
797 GLFWbool prefix;
798
799 GLFWbool KHR_create_context;
800 GLFWbool KHR_create_context_no_error;
801 GLFWbool KHR_gl_colorspace;
802 GLFWbool KHR_get_all_proc_addresses;
803 GLFWbool KHR_context_flush_control;
804 GLFWbool EXT_client_extensions;
805 GLFWbool EXT_platform_base;
806 GLFWbool EXT_platform_x11;
807 GLFWbool EXT_platform_wayland;
808 GLFWbool EXT_present_opaque;
809 GLFWbool ANGLE_platform_angle;
810 GLFWbool ANGLE_platform_angle_opengl;
811 GLFWbool ANGLE_platform_angle_d3d;
812 GLFWbool ANGLE_platform_angle_vulkan;
813 GLFWbool ANGLE_platform_angle_metal;
814
815 void* handle;
816
817 PFN_eglGetConfigAttrib GetConfigAttrib;
818 PFN_eglGetConfigs GetConfigs;
819 PFN_eglGetDisplay GetDisplay;
820 PFN_eglGetError GetError;
821 PFN_eglInitialize Initialize;
822 PFN_eglTerminate Terminate;
823 PFN_eglBindAPI BindAPI;
824 PFN_eglCreateContext CreateContext;
825 PFN_eglDestroySurface DestroySurface;
826 PFN_eglDestroyContext DestroyContext;
827 PFN_eglCreateWindowSurface CreateWindowSurface;
828 PFN_eglMakeCurrent MakeCurrent;
829 PFN_eglSwapBuffers SwapBuffers;
830 PFN_eglSwapInterval SwapInterval;
831 PFN_eglQueryString QueryString;
832 PFN_eglGetProcAddress GetProcAddress;
833
834 PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
835 PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
836 } egl;
837
838 struct {
839 void* handle;
840
841 PFN_OSMesaCreateContextExt CreateContextExt;
842 PFN_OSMesaCreateContextAttribs CreateContextAttribs;
843 PFN_OSMesaDestroyContext DestroyContext;
844 PFN_OSMesaMakeCurrent MakeCurrent;
845 PFN_OSMesaGetColorBuffer GetColorBuffer;
846 PFN_OSMesaGetDepthBuffer GetDepthBuffer;
847 PFN_OSMesaGetProcAddress GetProcAddress;
848
849 } osmesa;
850
851 struct {
852 GLFWbool available;
853 void* handle;
854 char* extensions[2];
855 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
856 GLFWbool KHR_surface;
857 GLFWbool KHR_win32_surface;
858 GLFWbool MVK_macos_surface;
859 GLFWbool EXT_metal_surface;
860 GLFWbool KHR_xlib_surface;
861 GLFWbool KHR_xcb_surface;
862 GLFWbool KHR_wayland_surface;
863 } vk;
864
865 struct {
866 GLFWmonitorfun monitor;
867 GLFWjoystickfun joystick;
868 } callbacks;
869
870 // These are defined in platform.h
871 GLFW_PLATFORM_LIBRARY_WINDOW_STATE
872 GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
873 GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
874};
875
876// Global state shared between compilation units of GLFW
877//
878extern _GLFWlibrary _glfw;
879
880
881//////////////////////////////////////////////////////////////////////////
882////// GLFW platform API //////
883//////////////////////////////////////////////////////////////////////////
884
885void _glfwPlatformInitTimer(void);
886uint64_t _glfwPlatformGetTimerValue(void);
887uint64_t _glfwPlatformGetTimerFrequency(void);
888
889GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
890void _glfwPlatformDestroyTls(_GLFWtls* tls);
891void* _glfwPlatformGetTls(_GLFWtls* tls);
892void _glfwPlatformSetTls(_GLFWtls* tls, void* value);
893
894GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
895void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
896void _glfwPlatformLockMutex(_GLFWmutex* mutex);
897void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
898
899void* _glfwPlatformLoadModule(const char* path);
900void _glfwPlatformFreeModule(void* module);
901GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name);
902
903
904//////////////////////////////////////////////////////////////////////////
905////// GLFW event API //////
906//////////////////////////////////////////////////////////////////////////
907
908void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused);
909void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
910void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
911void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
912void _glfwInputWindowContentScale(_GLFWwindow* window,
913 float xscale, float yscale);
914void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
915void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
916void _glfwInputWindowDamage(_GLFWwindow* window);
917void _glfwInputWindowCloseRequest(_GLFWwindow* window);
918void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
919
920void _glfwInputKey(_GLFWwindow* window,
921 int key, int scancode, int action, int mods);
922void _glfwInputChar(_GLFWwindow* window,
923 uint32_t codepoint, int mods, GLFWbool plain);
924void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
925void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
926void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
927void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
928void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
929void _glfwInputJoystick(_GLFWjoystick* js, int event);
930void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
931void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);
932void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value);
933
934void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement);
935void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window);
936
937#if defined(__GNUC__)
938void _glfwInputError(int code, const char* format, ...)
939 __attribute__((format(printf, 2, 3)));
940#else
941void _glfwInputError(int code, const char* format, ...);
942#endif
943
944
945//////////////////////////////////////////////////////////////////////////
946////// GLFW internal API //////
947//////////////////////////////////////////////////////////////////////////
948
949GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform);
950
951GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
952const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
953 const _GLFWfbconfig* alternatives,
954 unsigned int count);
955GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
956 const _GLFWctxconfig* ctxconfig);
957GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
958
959const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
960 const GLFWvidmode* desired);
961int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);
962_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
963void _glfwFreeMonitor(_GLFWmonitor* monitor);
964void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
965void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
966void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
967
968void _glfwInitGamepadMappings(void);
969_GLFWjoystick* _glfwAllocJoystick(const char* name,
970 const char* guid,
971 int axisCount,
972 int buttonCount,
973 int hatCount);
974void _glfwFreeJoystick(_GLFWjoystick* js);
975void _glfwCenterCursorInContentArea(_GLFWwindow* window);
976
977GLFWbool _glfwInitEGL(void);
978void _glfwTerminateEGL(void);
979GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
980 const _GLFWctxconfig* ctxconfig,
981 const _GLFWfbconfig* fbconfig);
982#if defined(_GLFW_X11)
983GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
984 const _GLFWctxconfig* ctxconfig,
985 const _GLFWfbconfig* fbconfig,
986 Visual** visual, int* depth);
987#endif /*_GLFW_X11*/
988
989GLFWbool _glfwInitOSMesa(void);
990void _glfwTerminateOSMesa(void);
991GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
992 const _GLFWctxconfig* ctxconfig,
993 const _GLFWfbconfig* fbconfig);
994
995GLFWbool _glfwInitVulkan(int mode);
996void _glfwTerminateVulkan(void);
997const char* _glfwGetVulkanResultString(VkResult result);
998
999size_t _glfwEncodeUTF8(char* s, uint32_t codepoint);
1000char** _glfwParseUriList(char* text, int* count);
1001
1002char* _glfw_strdup(const char* source);
1003int _glfw_min(int a, int b);
1004int _glfw_max(int a, int b);
1005
1006void* _glfw_calloc(size_t count, size_t size);
1007void* _glfw_realloc(void* pointer, size_t size);
1008void _glfw_free(void* pointer);
1009
diff --git a/raylib/src/external/glfw/src/linux_joystick.c b/raylib/src/external/glfw/src/linux_joystick.c
new file mode 100644
index 0000000..07d41d3
--- /dev/null
+++ b/raylib/src/external/glfw/src/linux_joystick.c
@@ -0,0 +1,436 @@
1//========================================================================
2// GLFW 3.4 Linux - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(GLFW_BUILD_LINUX_JOYSTICK)
31
32#include <sys/types.h>
33#include <sys/stat.h>
34#include <sys/inotify.h>
35#include <fcntl.h>
36#include <errno.h>
37#include <dirent.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>
41#include <unistd.h>
42
43#ifndef SYN_DROPPED // < v2.6.39 kernel headers
44// Workaround for CentOS-6, which is supported till 2020-11-30, but still on v2.6.32
45#define SYN_DROPPED 3
46#endif
47
48// Apply an EV_KEY event to the specified joystick
49//
50static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
51{
52 _glfwInputJoystickButton(js,
53 js->linjs.keyMap[code - BTN_MISC],
54 value ? GLFW_PRESS : GLFW_RELEASE);
55}
56
57// Apply an EV_ABS event to the specified joystick
58//
59static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
60{
61 const int index = js->linjs.absMap[code];
62
63 if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
64 {
65 static const char stateMap[3][3] =
66 {
67 { GLFW_HAT_CENTERED, GLFW_HAT_UP, GLFW_HAT_DOWN },
68 { GLFW_HAT_LEFT, GLFW_HAT_LEFT_UP, GLFW_HAT_LEFT_DOWN },
69 { GLFW_HAT_RIGHT, GLFW_HAT_RIGHT_UP, GLFW_HAT_RIGHT_DOWN },
70 };
71
72 const int hat = (code - ABS_HAT0X) / 2;
73 const int axis = (code - ABS_HAT0X) % 2;
74 int* state = js->linjs.hats[hat];
75
76 // NOTE: Looking at several input drivers, it seems all hat events use
77 // -1 for left / up, 0 for centered and 1 for right / down
78 if (value == 0)
79 state[axis] = 0;
80 else if (value < 0)
81 state[axis] = 1;
82 else if (value > 0)
83 state[axis] = 2;
84
85 _glfwInputJoystickHat(js, index, stateMap[state[0]][state[1]]);
86 }
87 else
88 {
89 const struct input_absinfo* info = &js->linjs.absInfo[code];
90 float normalized = value;
91
92 const int range = info->maximum - info->minimum;
93 if (range)
94 {
95 // Normalize to 0.0 -> 1.0
96 normalized = (normalized - info->minimum) / range;
97 // Normalize to -1.0 -> 1.0
98 normalized = normalized * 2.0f - 1.0f;
99 }
100
101 _glfwInputJoystickAxis(js, index, normalized);
102 }
103}
104
105// Poll state of absolute axes
106//
107static void pollAbsState(_GLFWjoystick* js)
108{
109 for (int code = 0; code < ABS_CNT; code++)
110 {
111 if (js->linjs.absMap[code] < 0)
112 continue;
113
114 struct input_absinfo* info = &js->linjs.absInfo[code];
115
116 if (ioctl(js->linjs.fd, EVIOCGABS(code), info) < 0)
117 continue;
118
119 handleAbsEvent(js, code, info->value);
120 }
121}
122
123#define isBitSet(bit, arr) (arr[(bit) / 8] & (1 << ((bit) % 8)))
124
125// Attempt to open the specified joystick device
126//
127static GLFWbool openJoystickDevice(const char* path)
128{
129 for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
130 {
131 if (!_glfw.joysticks[jid].connected)
132 continue;
133 if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
134 return GLFW_FALSE;
135 }
136
137 _GLFWjoystickLinux linjs = {0};
138 linjs.fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
139 if (linjs.fd == -1)
140 return GLFW_FALSE;
141
142 char evBits[(EV_CNT + 7) / 8] = {0};
143 char keyBits[(KEY_CNT + 7) / 8] = {0};
144 char absBits[(ABS_CNT + 7) / 8] = {0};
145 struct input_id id;
146
147 if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
148 ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
149 ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
150 ioctl(linjs.fd, EVIOCGID, &id) < 0)
151 {
152 _glfwInputError(GLFW_PLATFORM_ERROR,
153 "Linux: Failed to query input device: %s",
154 strerror(errno));
155 close(linjs.fd);
156 return GLFW_FALSE;
157 }
158
159 // Ensure this device supports the events expected of a joystick
160 if (!isBitSet(EV_ABS, evBits))
161 {
162 close(linjs.fd);
163 return GLFW_FALSE;
164 }
165
166 char name[256] = "";
167
168 if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
169 strncpy(name, "Unknown", sizeof(name));
170
171 char guid[33] = "";
172
173 // Generate a joystick GUID that matches the SDL 2.0.5+ one
174 if (id.vendor && id.product && id.version)
175 {
176 sprintf(guid, "%02x%02x0000%02x%02x0000%02x%02x0000%02x%02x0000",
177 id.bustype & 0xff, id.bustype >> 8,
178 id.vendor & 0xff, id.vendor >> 8,
179 id.product & 0xff, id.product >> 8,
180 id.version & 0xff, id.version >> 8);
181 }
182 else
183 {
184 sprintf(guid, "%02x%02x0000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
185 id.bustype & 0xff, id.bustype >> 8,
186 name[0], name[1], name[2], name[3],
187 name[4], name[5], name[6], name[7],
188 name[8], name[9], name[10]);
189 }
190
191 int axisCount = 0, buttonCount = 0, hatCount = 0;
192
193 for (int code = BTN_MISC; code < KEY_CNT; code++)
194 {
195 if (!isBitSet(code, keyBits))
196 continue;
197
198 linjs.keyMap[code - BTN_MISC] = buttonCount;
199 buttonCount++;
200 }
201
202 for (int code = 0; code < ABS_CNT; code++)
203 {
204 linjs.absMap[code] = -1;
205 if (!isBitSet(code, absBits))
206 continue;
207
208 if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
209 {
210 linjs.absMap[code] = hatCount;
211 hatCount++;
212 // Skip the Y axis
213 code++;
214 }
215 else
216 {
217 if (ioctl(linjs.fd, EVIOCGABS(code), &linjs.absInfo[code]) < 0)
218 continue;
219
220 linjs.absMap[code] = axisCount;
221 axisCount++;
222 }
223 }
224
225 _GLFWjoystick* js =
226 _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
227 if (!js)
228 {
229 close(linjs.fd);
230 return GLFW_FALSE;
231 }
232
233 strncpy(linjs.path, path, sizeof(linjs.path) - 1);
234 memcpy(&js->linjs, &linjs, sizeof(linjs));
235
236 pollAbsState(js);
237
238 _glfwInputJoystick(js, GLFW_CONNECTED);
239 return GLFW_TRUE;
240}
241
242#undef isBitSet
243
244// Frees all resources associated with the specified joystick
245//
246static void closeJoystick(_GLFWjoystick* js)
247{
248 _glfwInputJoystick(js, GLFW_DISCONNECTED);
249 close(js->linjs.fd);
250 _glfwFreeJoystick(js);
251}
252
253// Lexically compare joysticks by name; used by qsort
254//
255static int compareJoysticks(const void* fp, const void* sp)
256{
257 const _GLFWjoystick* fj = fp;
258 const _GLFWjoystick* sj = sp;
259 return strcmp(fj->linjs.path, sj->linjs.path);
260}
261
262
263//////////////////////////////////////////////////////////////////////////
264////// GLFW internal API //////
265//////////////////////////////////////////////////////////////////////////
266
267void _glfwDetectJoystickConnectionLinux(void)
268{
269 if (_glfw.linjs.inotify <= 0)
270 return;
271
272 ssize_t offset = 0;
273 char buffer[16384];
274 const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
275
276 while (size > offset)
277 {
278 regmatch_t match;
279 const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
280
281 offset += sizeof(struct inotify_event) + e->len;
282
283 if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
284 continue;
285
286 char path[PATH_MAX];
287 snprintf(path, sizeof(path), "/dev/input/%s", e->name);
288
289 if (e->mask & (IN_CREATE | IN_ATTRIB))
290 openJoystickDevice(path);
291 else if (e->mask & IN_DELETE)
292 {
293 for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
294 {
295 if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
296 {
297 closeJoystick(_glfw.joysticks + jid);
298 break;
299 }
300 }
301 }
302 }
303}
304
305
306//////////////////////////////////////////////////////////////////////////
307////// GLFW platform API //////
308//////////////////////////////////////////////////////////////////////////
309
310GLFWbool _glfwInitJoysticksLinux(void)
311{
312 const char* dirname = "/dev/input";
313
314 _glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
315 if (_glfw.linjs.inotify > 0)
316 {
317 // HACK: Register for IN_ATTRIB to get notified when udev is done
318 // This works well in practice but the true way is libudev
319
320 _glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify,
321 dirname,
322 IN_CREATE | IN_ATTRIB | IN_DELETE);
323 }
324
325 // Continue without device connection notifications if inotify fails
326
327 _glfw.linjs.regexCompiled = (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) == 0);
328 if (!_glfw.linjs.regexCompiled)
329 {
330 _glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
331 return GLFW_FALSE;
332 }
333
334 int count = 0;
335
336 DIR* dir = opendir(dirname);
337 if (dir)
338 {
339 struct dirent* entry;
340
341 while ((entry = readdir(dir)))
342 {
343 regmatch_t match;
344
345 if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0)
346 continue;
347
348 char path[PATH_MAX];
349
350 snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
351
352 if (openJoystickDevice(path))
353 count++;
354 }
355
356 closedir(dir);
357 }
358
359 // Continue with no joysticks if enumeration fails
360
361 qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
362 return GLFW_TRUE;
363}
364
365void _glfwTerminateJoysticksLinux(void)
366{
367 for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
368 {
369 _GLFWjoystick* js = _glfw.joysticks + jid;
370 if (js->connected)
371 closeJoystick(js);
372 }
373
374 if (_glfw.linjs.inotify > 0)
375 {
376 if (_glfw.linjs.watch > 0)
377 inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
378
379 close(_glfw.linjs.inotify);
380 }
381
382 if (_glfw.linjs.regexCompiled)
383 regfree(&_glfw.linjs.regex);
384}
385
386GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
387{
388 // Read all queued events (non-blocking)
389 for (;;)
390 {
391 struct input_event e;
392
393 errno = 0;
394 if (read(js->linjs.fd, &e, sizeof(e)) < 0)
395 {
396 // Reset the joystick slot if the device was disconnected
397 if (errno == ENODEV)
398 closeJoystick(js);
399
400 break;
401 }
402
403 if (e.type == EV_SYN)
404 {
405 if (e.code == SYN_DROPPED)
406 _glfw.linjs.dropped = GLFW_TRUE;
407 else if (e.code == SYN_REPORT)
408 {
409 _glfw.linjs.dropped = GLFW_FALSE;
410 pollAbsState(js);
411 }
412 }
413
414 if (_glfw.linjs.dropped)
415 continue;
416
417 if (e.type == EV_KEY)
418 handleKeyEvent(js, e.code, e.value);
419 else if (e.type == EV_ABS)
420 handleAbsEvent(js, e.code, e.value);
421 }
422
423 return js->connected;
424}
425
426const char* _glfwGetMappingNameLinux(void)
427{
428 return "Linux";
429}
430
431void _glfwUpdateGamepadGUIDLinux(char* guid)
432{
433}
434
435#endif // GLFW_BUILD_LINUX_JOYSTICK
436
diff --git a/raylib/src/external/glfw/src/linux_joystick.h b/raylib/src/external/glfw/src/linux_joystick.h
new file mode 100644
index 0000000..64462b0
--- /dev/null
+++ b/raylib/src/external/glfw/src/linux_joystick.h
@@ -0,0 +1,64 @@
1//========================================================================
2// GLFW 3.4 Linux - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include <linux/input.h>
28#include <linux/limits.h>
29#include <regex.h>
30
31#define GLFW_LINUX_JOYSTICK_STATE _GLFWjoystickLinux linjs;
32#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs;
33
34// Linux-specific joystick data
35//
36typedef struct _GLFWjoystickLinux
37{
38 int fd;
39 char path[PATH_MAX];
40 int keyMap[KEY_CNT - BTN_MISC];
41 int absMap[ABS_CNT];
42 struct input_absinfo absInfo[ABS_CNT];
43 int hats[4][2];
44} _GLFWjoystickLinux;
45
46// Linux-specific joystick API data
47//
48typedef struct _GLFWlibraryLinux
49{
50 int inotify;
51 int watch;
52 regex_t regex;
53 GLFWbool regexCompiled;
54 GLFWbool dropped;
55} _GLFWlibraryLinux;
56
57void _glfwDetectJoystickConnectionLinux(void);
58
59GLFWbool _glfwInitJoysticksLinux(void);
60void _glfwTerminateJoysticksLinux(void);
61GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode);
62const char* _glfwGetMappingNameLinux(void);
63void _glfwUpdateGamepadGUIDLinux(char* guid);
64
diff --git a/raylib/src/external/glfw/src/mappings.h b/raylib/src/external/glfw/src/mappings.h
new file mode 100644
index 0000000..7b0f35a
--- /dev/null
+++ b/raylib/src/external/glfw/src/mappings.h
@@ -0,0 +1,1002 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26// As mappings.h.in, this file is used by CMake to produce the mappings.h
27// header file. If you are adding a GLFW specific gamepad mapping, this is
28// where to put it.
29//========================================================================
30// As mappings.h, this provides all pre-defined gamepad mappings, including
31// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
32// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
33// This file can be re-generated from mappings.h.in and the upstream
34// gamecontrollerdb.txt with the 'update_mappings' CMake target.
35//========================================================================
36
37// All gamepad mappings not labeled GLFW are copied from the
38// SDL_GameControllerDB project under the following license:
39//
40// Simple DirectMedia Layer
41// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
42//
43// This software is provided 'as-is', without any express or implied warranty.
44// In no event will the authors be held liable for any damages arising from the
45// use of this software.
46//
47// Permission is granted to anyone to use this software for any purpose,
48// including commercial applications, and to alter it and redistribute it
49// freely, subject to the following restrictions:
50//
51// 1. The origin of this software must not be misrepresented; you must not
52// claim that you wrote the original software. If you use this software
53// in a product, an acknowledgment in the product documentation would
54// be appreciated but is not required.
55//
56// 2. Altered source versions must be plainly marked as such, and must not be
57// misrepresented as being the original software.
58//
59// 3. This notice may not be removed or altered from any source distribution.
60
61const char* _glfwDefaultMappings[] =
62{
63#if defined(_GLFW_WIN32)
64"03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,",
65"03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
66"03000000c82d00000951000000000000,8BitDo Dogbone Modkit,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b11,platform:Windows,",
67"03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
68"03000000c82d00001038000000000000,8BitDo F30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
69"03000000c82d00000090000000000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
70"03000000c82d00000650000000000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:a4,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows,",
71"03000000c82d00005106000000000000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,start:b11,x:b4,y:b3,platform:Windows,",
72"03000000c82d00000151000000000000,8BitDo M30 ModKit,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows,",
73"03000000c82d00000310000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
74"03000000c82d00002028000000000000,8BitDo N30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
75"03000000c82d00008010000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
76"03000000c82d00000451000000000000,8BitDo N30 Modkit,a:b1,b:b0,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,start:b11,platform:Windows,",
77"03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
78"03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
79"03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
80"03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
81"03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
82"03000000c82d00000360000000000000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
83"03000000c82d00002867000000000000,8BitDo S30 Modkit,a:b0,b:b1,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b8,lefttrigger:b9,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows,",
84"03000000c82d00000130000000000000,8BitDo SF30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
85"03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
86"03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
87"03000000c82d000021ab000000000000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
88"03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
89"03000000c82d00003028000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
90"03000000c82d00000030000000000000,8BitDo SN30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
91"03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
92"03000000c82d000020ab000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
93"03000000c82d00004028000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
94"03000000c82d00006228000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
95"03000000c82d00000351000000000000,8BitDo SN30 Modkit,a:b1,b:b0,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
96"03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
97"03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
98"03000000c82d00000121000000000000,8BitDo SN30 Pro for Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
99"03000000c82d00000260000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
100"03000000c82d00000261000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
101"03000000c82d00000031000000000000,8BitDo Wireless Adapter,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
102"03000000c82d00001890000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
103"03000000c82d00003032000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
104"03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
105"03000000a30c00002700000000000000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,",
106"03000000a30c00002800000000000000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,",
107"030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
108"03000000c01100000355000011010000,ACRUX USB GAME PAD,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
109"03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
110"030000006f0e00001413000000000000,Afterglow,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
111"03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
112"030000006f0e00000263000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
113"030000006f0e00001101000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
114"030000006f0e00001401000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
115"030000006f0e00001402000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
116"030000006f0e00001901000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
117"030000006f0e00001a01000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
118"03000000d62000001d57000000000000,Airflo PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
119"03000000491900001904000000000000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Windows,",
120"03000000710100001904000000000000,Amazon Luna Controller,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b8,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b4,rightstick:b7,rightx:a3,righty:a4,start:b6,x:b3,y:b2,platform:Windows,",
121"03000000ef0500000300000000000000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows,",
122"03000000d6200000e557000000000000,Batarang,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
123"03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,platform:Windows,",
124"030000006f0e00003201000000000000,Battlefield 4 PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
125"03000000d62000002a79000000000000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
126"03000000bc2000006012000000000000,Betop 2126F,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
127"03000000bc2000000055000000000000,Betop BFM Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
128"03000000bc2000006312000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
129"03000000bc2000006321000000000000,BETOP CONTROLLER,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
130"03000000bc2000006412000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
131"03000000c01100000555000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
132"03000000c01100000655000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
133"03000000790000000700000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
134"03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
135"030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
136"030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
137"03000000120c0000210e000000000000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
138"0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
139"03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows,",
140"03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
141"03000000457500000401000000000000,Cobra,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
142"030000005e0400008e02000000000000,Controller (XBOX 360 For Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
143"030000005e040000a102000000000000,Controller (Xbox 360 Wireless Receiver for Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
144"030000005e040000ff02000000000000,Controller (Xbox One For Windows) - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
145"030000005e040000ea02000000000000,Controller (Xbox One For Windows) - Wireless,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
146"03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Windows,",
147"03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
148"03000000451300000830000000000000,Defender Game Racer X7,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
149"030000007d0400000840000000000000,Destroyer Tiltpad,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b1,b:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,x:b0,y:b3,platform:Windows,",
150"03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
151"03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,",
152"030000008f0e00000910000000000000,DualShock 2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,",
153"030000006f0e00003001000000000000,EA SPORTS PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
154"03000000b80500000410000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
155"03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
156"03000000120c0000f61c000000000000,Elite,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
157"030000008f0e00000f31000000000000,EXEQ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
158"03000000341a00000108000000000000,EXEQ RF USB Gamepad 8206,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
159"030000006f0e00008401000000000000,Faceoff Deluxe+ Audio Wired Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
160"030000006f0e00008001000000000000,Faceoff Wired Pro Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
161"03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
162"030000000d0f00008500000000000000,Fighting Commander 2016 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
163"030000000d0f00008400000000000000,Fighting Commander 5,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
164"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
165"030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
166"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
167"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
168"03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
169"0300000066f700000100000000000000,Game VIB Joystick,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows,",
170"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
171"03000000790000004618000000000000,GameCube Controller Adapter,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
172"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
173"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
174"03000000ac0500003d03000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
175"03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
176"03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
177"03000000c01100000140000000000000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
178"030000009b2800003200000000000000,GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,",
179"030000009b2800006000000000000000,GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,",
180"030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
181"030000008305000031b0000000000000,Genius Maxfire Blaze 3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
182"03000000451300000010000000000000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
183"030000005c1a00003330000000000000,Genius MaxFire Grandias 12V,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
184"03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
185"03000000f0250000c283000000000000,Gioteck,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
186"03000000f025000021c1000000000000,Gioteck PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
187"03000000f0250000c383000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
188"03000000f0250000c483000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
189"030000007d0400000540000000000000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
190"03000000341a00000302000000000000,Hama Scorpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
191"030000000d0f00004900000000000000,Hatsune Miku Sho Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
192"030000001008000001e1000000000000,Havit HV-G60,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b0,platform:Windows,",
193"03000000d81400000862000000000000,HitBox Edition Cthulhu+,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
194"03000000632500002605000000000000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
195"030000000d0f00002d00000000000000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
196"030000000d0f00005f00000000000000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
197"030000000d0f00005e00000000000000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
198"030000000d0f00004000000000000000,Hori Fighting Stick Mini 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
199"030000000d0f00005400000000000000,Hori Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
200"030000000d0f00000900000000000000,Hori Pad 3 Turbo,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
201"030000000d0f00004d00000000000000,Hori Pad A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
202"030000000d0f00009200000000000000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
203"030000000d0f00001600000000007803,HORI Real Arcade Pro EX-SE (Xbox 360),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
204"030000000d0f00009c00000000000000,Hori TAC Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
205"030000000d0f0000c100000000000000,Horipad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
206"030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
207"030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
208"030000000d0f00005500000000000000,Horipad 4 FPS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
209"030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
210"03000000250900000017000000000000,HRAP2 on PS/SS/N64 Joypad to USB BOX,a:b2,b:b1,back:b9,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b8,x:b3,y:b0,platform:Windows,",
211"030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Windows,",
212"03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
213"03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
214"03000000830500006020000000000000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Windows,",
215"03000000b50700001403000000000000,Impact Black,a:b2,b:b3,back:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
216"030000006f0e00002401000000000000,INJUSTICE FightStick PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
217"03000000ac0500002c02000000000000,IPEGA,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
218"03000000491900000204000000000000,Ipega PG-9023,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
219"03000000491900000304000000000000,Ipega PG-9087 - Bluetooth Gamepad,+righty:+a5,-righty:-a4,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,start:b11,x:b3,y:b4,platform:Windows,",
220"030000006e0500000a20000000000000,JC-DUX60 ELECOM MMO Gamepad,a:b2,b:b3,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b14,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b15,righttrigger:b13,rightx:a3,righty:a4,start:b20,x:b0,y:b1,platform:Windows,",
221"030000006e0500000520000000000000,JC-P301U,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,",
222"030000006e0500000320000000000000,JC-U3613M (DInput),a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,",
223"030000006e0500000720000000000000,JC-W01U,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
224"030000007e0500000620000000000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,",
225"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,",
226"030000007e0500000720000000000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
227"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
228"03000000bd12000003c0000010010000,Joypad Alpha Shock,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
229"03000000bd12000003c0000000000000,JY-P70UR,a:b1,b:b0,back:b5,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b11,righttrigger:b9,rightx:a3,righty:a2,start:b4,x:b3,y:b2,platform:Windows,",
230"03000000242f00002d00000000000000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
231"03000000242f00008a00000000000000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
232"03000000790000000200000000000000,King PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
233"030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
234"030000006d040000d2ca000000000000,Logitech Cordless Precision,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
235"030000006d04000011c2000000000000,Logitech Cordless Wingman,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b5,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b2,righttrigger:b7,rightx:a3,righty:a4,x:b4,platform:Windows,",
236"030000006d04000016c2000000000000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
237"030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
238"030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
239"030000006d0400001ac2000000000000,Logitech Precision Gamepad,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
240"030000006d0400000ac2000000000000,Logitech WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Windows,",
241"03000000380700006652000000000000,Mad Catz C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
242"03000000380700005032000000000000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
243"03000000380700005082000000000000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
244"03000000380700008433000000000000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
245"03000000380700008483000000000000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
246"03000000380700008134000000000000,Mad Catz FightStick TE2+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
247"03000000380700008184000000000000,Mad Catz FightStick TE2+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,leftstick:b10,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
248"03000000380700006252000000000000,Mad Catz Micro C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
249"03000000380700008034000000000000,Mad Catz TE2 PS3 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
250"03000000380700008084000000000000,Mad Catz TE2 PS4 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
251"03000000380700008532000000000000,Madcatz Arcade Fightstick TE S PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
252"03000000380700003888000000000000,Madcatz Arcade Fightstick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
253"03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
254"03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
255"030000002a0600001024000000000000,Matricom,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,",
256"030000009f000000adbb000000000000,MaxJoypad Virtual Controller,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
257"03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,platform:Windows,",
258"03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
259"03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
260"03000000242f00007300000000000000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
261"0300000079000000d218000000000000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
262"03000000d620000010a7000000000000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
263"030000008f0e00001030000000000000,Mayflash USB Adapter for original Sega Saturn controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,rightshoulder:b2,righttrigger:b7,start:b9,x:b3,y:b4,platform:Windows,",
264"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
265"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
266"03000000790000002418000000000000,Mega Drive,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b2,start:b9,x:b3,y:b4,platform:Windows,",
267"03000000380700006382000000000000,MLG GamePad PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
268"03000000c62400002a89000000000000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
269"03000000c62400002b89000000000000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
270"03000000c62400001a89000000000000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
271"03000000c62400001b89000000000000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
272"03000000efbe0000edfe000000000000,Monect Virtual Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
273"03000000250900006688000000000000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
274"030000006b140000010c000000000000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
275"03000000921200004b46000000000000,NES 2-port Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b11,platform:Windows,",
276"03000000790000004518000000000000,NEXILUX GAMECUBE Controller Adapter,platform:Windows,a:b1,b:b0,x:b2,y:b3,start:b9,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a5,righty:a2,lefttrigger:a3,righttrigger:a4,",
277"030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,righttrigger:b6,start:b9,x:b3,y:b0,platform:Windows,",
278"03000000152000000182000000000000,NGDS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
279"03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
280"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
281"030000000d0500000308000000000000,Nostromo N45,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Windows,",
282"03000000550900001472000000000000,NVIDIA Controller v01.04,a:b11,b:b10,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b5,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b4,righttrigger:a5,rightx:a3,righty:a6,start:b3,x:b9,y:b8,platform:Windows,",
283"030000004b120000014d000000000000,NYKO AIRFLO,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a3,leftstick:a0,lefttrigger:b6,rightshoulder:b5,rightstick:a2,righttrigger:b7,start:b9,x:b2,y:b3,platform:Windows,",
284"03000000d620000013a7000000000000,NSW wired controller,platform:Windows,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,",
285"03000000782300000a10000000000000,Onlive Wireless Controller,a:b15,b:b14,back:b7,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b11,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b13,y:b12,platform:Windows,",
286"03000000d62000006d57000000000000,OPP PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
287"030000006b14000001a1000000000000,Orange Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
288"03000000362800000100000000000000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a3,righty:a4,x:b1,y:b2,platform:Windows,",
289"03000000120c0000f60e000000000000,P4 Wired Gamepad,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
290"030000006f0e00000901000000000000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
291"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
292"030000004c050000da0c000000000000,PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,",
293"030000004c0500003713000000000000,PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
294"03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
295"03000000d62000009557000000000000,Pro Elite PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
296"03000000d62000009f31000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
297"03000000d6200000c757000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
298"03000000632500002306000000000000,PS Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,",
299"03000000e30500009605000000000000,PS to USB convert cable,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
300"03000000100800000100000000000000,PS1 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
301"030000008f0e00007530000000000000,PS1 Controller,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b1,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
302"03000000100800000300000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
303"03000000250900008888000000000000,PS2 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
304"03000000666600006706000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Windows,",
305"030000006b1400000303000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
306"030000009d0d00001330000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
307"03000000250900000500000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,",
308"030000004c0500006802000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b10,lefttrigger:a3~,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:a4~,rightx:a2,righty:a5,start:b8,x:b3,y:b0,platform:Windows,",
309"03000000632500007505000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
310"03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
311"030000008f0e00001431000000000000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
312"030000003807000056a8000000000000,PS3 RF pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
313"03000000100000008200000000000000,PS360+ v1.66,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:h0.4,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
314"030000004c050000a00b000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
315"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
316"030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
317"030000004c050000e60c000000000000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
318"03000000ff000000cb01000000000000,PSP,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Windows,",
319"03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,platform:Windows,",
320"03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
321"03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,platform:Windows,",
322"03000000300f00001210000000000000,QanBa Joystick Plus,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
323"03000000341a00000104000000000000,QanBa Joystick Q4RAF,a:b5,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b1,y:b2,platform:Windows,",
324"03000000222c00000223000000000000,Qanba Obsidian Arcade Joystick PS3 Mode,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
325"03000000222c00000023000000000000,Qanba Obsidian Arcade Joystick PS4 Mode,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
326"03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
327"03000000321500000204000000000000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
328"03000000321500000104000000000000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
329"03000000321500000507000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
330"03000000321500000707000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
331"03000000321500000011000000000000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
332"03000000321500000009000000000000,Razer Serval,+lefty:+a2,-lefty:-a1,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,leftx:a0,rightshoulder:b5,rightstick:b9,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
333"030000000d0f00001100000000000000,REAL ARCADE PRO.3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
334"030000000d0f00006a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
335"030000000d0f00006b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
336"030000000d0f00008a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
337"030000000d0f00008b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
338"030000000d0f00007000000000000000,REAL ARCADE PRO.4 VLX,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
339"030000000d0f00002200000000000000,REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
340"030000000d0f00005b00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
341"030000000d0f00005c00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
342"03000000790000001100000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
343"03000000bd12000013d0000000000000,Retrolink USB SEGA Saturn Classic,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,lefttrigger:b6,rightshoulder:b2,righttrigger:b7,start:b8,x:b3,y:b4,platform:Windows,",
344"0300000000f000000300000000000000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
345"0300000000f00000f100000000000000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
346"030000006b140000010d000000000000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
347"030000006b140000020d000000000000,Revolution Pro Controller 2(1/2),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
348"030000006b140000130d000000000000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
349"030000006f0e00001e01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
350"030000006f0e00002801000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
351"030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
352"030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
353"03000000a30600001af5000000000000,Saitek Cyborg,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
354"03000000a306000023f6000000000000,Saitek Cyborg V.1 Game pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
355"03000000300f00001201000000000000,Saitek Dual Analog Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
356"03000000a30600000701000000000000,Saitek P220,a:b2,b:b3,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b7,rightshoulder:b4,righttrigger:b5,x:b0,y:b1,platform:Windows,",
357"03000000a30600000cff000000000000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b0,y:b1,platform:Windows,",
358"03000000a30600000c04000000000000,Saitek P2900,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
359"03000000300f00001001000000000000,Saitek P480 Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
360"03000000a30600000b04000000000000,Saitek P990,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
361"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Windows,",
362"03000000a30600002106000000000000,Saitek PS1000,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
363"03000000a306000020f6000000000000,Saitek PS2700,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
364"03000000300f00001101000000000000,Saitek Rumble Pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
365"03000000730700000401000000000000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Windows,",
366"0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
367"030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
368"03000000a30c00002500000000000000,Sega Genesis Mini 3B controller,a:b2,b:b1,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,righttrigger:b5,start:b9,platform:Windows,",
369"03000000a30c00002400000000000000,Sega Mega Drive Mini 6B controller,a:b2,b:b1,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,",
370"03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows,",
371"03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
372"030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
373"03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
374"03000000d11800000094000000000000,Stadia Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b11,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,",
375"03000000110100001914000000000000,SteelSeries,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
376"03000000381000001214000000000000,SteelSeries Free,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,",
377"03000000110100003114000000000000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
378"03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,platform:Windows,",
379"03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
380"03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,platform:Windows,",
381"03000000d620000011a7000000000000,Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
382"03000000457500002211000000000000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
383"030000004f04000007d0000000000000,T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
384"030000004f0400000ab1000000000000,T.16000M,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b10,x:b2,y:b3,platform:Windows,",
385"03000000fa1900000706000000000000,Team 5,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
386"03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
387"030000004f04000015b3000000000000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
388"030000004f04000023b3000000000000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
389"030000004f0400000ed0000000000000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
390"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Windows,",
391"030000004f04000004b3000000000000,Thrustmaster Firestorm Dual Power 3,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
392"03000000666600000488000000000000,TigerGame PS/PS2 Game Controller Adapter,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
393"03000000d62000006000000000000000,Tournament PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
394"030000005f140000c501000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
395"03000000b80500000210000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
396"030000004f04000087b6000000000000,TWCS Throttle,dpdown:b8,dpleft:b9,dpright:b7,dpup:b6,leftstick:b5,lefttrigger:-a5,leftx:a0,lefty:a1,righttrigger:+a5,platform:Windows,",
397"03000000d90400000200000000000000,TwinShock PS2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
398"030000006e0500001320000000000000,U4113,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
399"03000000101c0000171c000000000000,uRage Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
400"03000000300f00000701000000000000,USB 4-Axis 12-Button Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
401"03000000341a00002308000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
402"030000005509000000b4000000000000,USB gamepad,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,platform:Windows,",
403"030000006b1400000203000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
404"03000000790000000a00000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
405"03000000f0250000c183000000000000,USB gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
406"03000000ff1100004133000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
407"03000000632500002305000000000000,USB Vibration Joystick (BM),a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
408"03000000790000001a18000000000000,Venom,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
409"03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
410"030000006f0e00000302000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
411"030000006f0e00000702000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
412"0300000034120000adbe000000000000,vJoy Device,a:b0,b:b1,back:b15,dpdown:b6,dpleft:b7,dpright:b8,dpup:b5,guide:b16,leftshoulder:b9,leftstick:b13,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b14,righttrigger:b12,rightx:a3,righty:a4,start:b4,x:b2,y:b3,platform:Windows,",
413"030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
414"030000005e040000130b000000000000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
415"03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
416"03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
417"03000000ac0500005b05000000000000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
418"03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,",
419"03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
420"03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
421"03000000120c0000101e000000000000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
422"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
423"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
424"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
425"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
426"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
427"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
428"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
429#endif // _GLFW_WIN32
430
431#if defined(_GLFW_COCOA)
432"030000008f0e00000300000009010000,2In1 USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
433"03000000c82d00000090000001000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
434"03000000c82d00001038000000010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
435"03000000c82d00000650000001000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
436"03000000c82d00005106000000010000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,start:b11,x:b4,y:b3,platform:Mac OS X,",
437"03000000c82d00001590000001000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
438"03000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
439"030000003512000012ab000001000000,8BitDo NES30 Gamepad,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
440"03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
441"03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
442"03000000c82d00000190000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
443"03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
444"03000000c82d00001290000001000000,8BitDo SN30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
445"03000000c82d00004028000000010000,8Bitdo SN30 GamePad,a:b1,b:b0,x:b4,y:b3,back:b10,start:b11,leftshoulder:b6,rightshoulder:b7,dpup:-a1,dpdown:+a1,dpleft:-a0,dpright:+a0,platform:Mac OS X,",
446"03000000c82d00000160000001000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
447"03000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Mac OS X,",
448"03000000c82d00000260000001000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
449"03000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
450"03000000c82d00000031000001000000,8BitDo Wireless Adapter,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
451"03000000c82d00001890000001000000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
452"03000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a31,start:b11,x:b4,y:b3,platform:Mac OS X,",
453"03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
454"03000000a00500003232000009010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
455"03000000a30c00002700000003030000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
456"03000000a30c00002800000003030000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
457"03000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
458"03000000ef0500000300000000020000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Mac OS X,",
459"03000000491900001904000001010000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Mac OS X,",
460"03000000710100001904000000010000,Amazon Luna Controller,a:b0,b:b1,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X,",
461"03000000c62400001a89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b14,leftshoulder:b6,leftstick:b15,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b16,righttrigger:a4,rightx:a2,righty:a3,start:b13,x:b3,y:b4,platform:Mac OS X,",
462"03000000c62400001b89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
463"03000000d62000002a79000000010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
464"03000000120c0000200e000000010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
465"03000000120c0000210e000000010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
466"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
467"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
468"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
469"03000000790000004618000000010000,GameCube Controller Adapter,a:b4,b:b0,dpdown:b56,dpleft:b60,dpright:b52,dpup:b48,lefttrigger:a12,leftx:a0,lefty:a4,rightshoulder:b28,righttrigger:a16,rightx:a20,righty:a8,start:b36,x:b8,y:b12,platform:Mac OS X,",
470"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
471"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
472"03000000c01100000140000000010000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
473"030000006f0e00000102000000000000,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
474"030000007d0400000540000001010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
475"03000000280400000140000000020000,Gravis Gamepad Pro,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
476"030000008f0e00000300000007010000,GreenAsia Inc. USB Joystick,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Mac OS X,",
477"030000000d0f00002d00000000100000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
478"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
479"030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
480"030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
481"030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
482"030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
483"030000000d0f00009200000000010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
484"030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
485"030000000d0f00006600000000010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
486"030000000d0f00006600000000000000,HORIPAD FPS PLUS 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
487"030000000d0f0000ee00000000010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
488"030000008f0e00001330000011010000,HuiJia SNES Controller,a:b4,b:b2,back:b16,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b12,rightshoulder:b14,start:b18,x:b6,y:b0,platform:Mac OS X,",
489"03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
490"03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
491"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Mac OS X,",
492"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Mac OS X,",
493"03000000242f00002d00000007010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
494"030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
495"030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
496"030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
497"030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
498"030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
499"030000006d04000019c2000005030000,Logitech F710,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
500"030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
501"030000006d04000018c2000000010000,Logitech RumblePad 2 USB,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3~,start:b9,x:b0,y:b3,platform:Mac OS X,",
502"030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
503"03000000380700005032000000010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
504"03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
505"03000000380700008433000000010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
506"03000000380700008483000000010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
507"03000000790000000600000007010000,Marvo GT-004,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Mac OS X,",
508"03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X,",
509"03000000242f00007300000000020000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Mac OS X,",
510"0300000079000000d218000026010000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
511"03000000d620000010a7000003010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
512"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Mac OS X,",
513"03000000790000000018000000010000,Mayflash Wii U Pro Controller Adapter,a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X,",
514"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X,",
515"03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
516"030000005e0400002700000001010000,Microsoft SideWinder Plug & Play Game Pad,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,lefttrigger:b4,leftx:a0,lefty:a1,righttrigger:b5,x:b2,y:b3,platform:Mac OS X,",
517"03000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X,",
518"03000000c62400002a89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
519"03000000c62400002b89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
520"03000000632500007505000000020000,NEOGEO mini PAD Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b9,x:b2,y:b3,platform:Mac OS X,",
521"03000000921200004b46000003020000,NES 2-port Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b11,platform:Mac OS X,",
522"030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,righttrigger:b6,start:b9,x:b3,y:b0,platform:Mac OS X,",
523"03000000d620000011a7000000020000,Nintendo Switch Core (Plus) Wired Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
524"03000000d620000011a7000010050000,Nintendo Switch PowerA Wired Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
525"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
526"030000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
527"03000000550900001472000025050000,NVIDIA Controller v01.04,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Mac OS X,",
528"030000006f0e00000901000002010000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
529"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X,",
530"030000004c050000da0c000000010000,Playstation Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
531"030000004c0500003713000000010000,PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
532"03000000d62000006dca000000010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
533"03000000100800000300000006010000,PS2 Adapter,a:b2,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
534"030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
535"030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
536"030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
537"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
538"030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
539"030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
540"050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
541"030000008916000000fd000000000000,Razer Onza TE,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
542"03000000321500000204000000010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
543"03000000321500000104000000010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
544"03000000321500000010000000010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
545"03000000321500000507000001010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
546"03000000321500000011000000010000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
547"03000000321500000009000000020000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
548"030000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
549"0300000032150000030a000000000000,Razer Wildcat,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
550"03000000790000001100000000000000,Retrolink Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a3,lefty:a4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
551"03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
552"030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
553"030000006b140000130d000000010000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
554"03000000c6240000fefa000000000000,Rock Candy Gamepad for PS3,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
555"03000000730700000401000000010000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Mac OS X,",
556"03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,platform:Mac OS X,",
557"03000000b40400000a01000000000000,Sega Saturn USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Mac OS X,",
558"030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
559"0300000000f00000f100000000000000,SNES RetroPort,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,rightshoulder:b7,start:b6,x:b0,y:b1,platform:Mac OS X,",
560"030000004c050000e60c000000010000,Sony DualSense,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
561"030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
562"030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
563"03000000d11800000094000000010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
564"030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
565"03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,platform:Mac OS X,",
566"03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
567"03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
568"050000004e696d6275732b0000000000,SteelSeries Nimbus Plus,a:b0,b:b1,back:b15,dpdown:b11,dpleft:b13,dpright:b12,dpup:b10,guide:b16,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3~,start:b14,x:b2,y:b3,platform:Mac OS X,",
569"03000000110100001714000000000000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
570"03000000110100001714000020010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
571"03000000457500002211000000010000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
572"030000004f04000015b3000000000000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Mac OS X,",
573"030000004f0400000ed0000000020000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
574"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Mac OS X,",
575"03000000bd12000015d0000000000000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
576"03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
577"03000000100800000100000000000000,Twin USB Joystick,a:b4,b:b2,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b12,leftstick:b20,lefttrigger:b8,leftx:a0,lefty:a2,rightshoulder:b14,rightstick:b22,righttrigger:b10,rightx:a6,righty:a4,start:b18,x:b6,y:b0,platform:Mac OS X,",
578"030000006f0e00000302000025040000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
579"030000006f0e00000702000003060000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
580"03000000791d00000103000009010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
581"050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,platform:Mac OS X,",
582"050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,platform:Mac OS X,",
583"030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
584"030000006f0e00000104000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
585"03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
586"030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
587"030000005e040000050b000003090000,Xbox Elite Wireless Controller Series 2,a:b0,b:b1,back:b31,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b53,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
588"03000000c62400003a54000000000000,Xbox One PowerA Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
589"030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
590"030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
591"030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
592"030000005e040000130b000001050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
593"030000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
594"030000005e040000e002000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
595"030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
596"030000005e040000ea02000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
597"030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
598"03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X,",
599"03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
600"03000000120c0000101e000000010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
601#endif // _GLFW_COCOA
602
603#if defined(GLFW_BUILD_LINUX_JOYSTICK)
604"03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
605"05000000c82d00001038000000010000,8Bitdo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
606"05000000c82d00005106000000010000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Linux,",
607"03000000c82d00001590000011010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
608"05000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
609"03000000c82d00000310000011010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,",
610"05000000c82d00008010000000010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,",
611"03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
612"05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
613"05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
614"03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
615"05000000c82d00000060000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
616"05000000c82d00000061000000010000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
617"03000000c82d000021ab000010010000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
618"030000003512000012ab000010010000,8Bitdo SFC30 GamePad,a:b2,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b0,platform:Linux,",
619"05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
620"05000000c82d00003028000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
621"03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
622"03000000c82d00000160000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
623"03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
624"03000000c82d00001290000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
625"05000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
626"05000000c82d00006228000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
627"03000000c82d00000260000011010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
628"05000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
629"05000000202800000900000000010000,8BitDo SNES30 Gamepad,a:b1,b:b0,back:b10,dpdown:b122,dpleft:b119,dpright:b120,dpup:b117,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
630"03000000c82d00000031000011010000,8BitDo Wireless Adapter (DInput),a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
631"030000005e0400008e02000020010000,8BitDo Wireless Adapter (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
632"03000000c82d00001890000011010000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
633"05000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
634"050000005e040000e002000030110000,8BitDo Zero 2 (XInput),a:b0,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Linux,",
635"05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
636"05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
637"03000000c01100000355000011010000,ACRUX USB GAME PAD,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
638"030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
639"030000006f0e00003901000020060000,Afterglow Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
640"030000006f0e00003901000000430000,Afterglow Prismatic Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
641"030000006f0e00003901000013020000,Afterglow Prismatic Wired Controller 048-007-NA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
642"03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
643"030000007c1800000006000010010000,Alienware Dual Compatible Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
644"05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
645"03000000491900001904000011010000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Linux,",
646"05000000710100001904000000010000,Amazon Luna Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
647"03000000790000003018000011010000,Arcade Fightstick F300,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
648"03000000a30c00002700000011010000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
649"03000000a30c00002800000011010000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
650"05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,",
651"05000000050b00000045000040000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,",
652"03000000503200000110000000000000,Atari Classic Controller,a:b0,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b4,start:b3,x:b1,platform:Linux,",
653"05000000503200000110000000000000,Atari Classic Controller,a:b0,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b4,start:b3,x:b1,platform:Linux,",
654"03000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,platform:Linux,",
655"05000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,platform:Linux,",
656"03000000120c00000500000010010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux,",
657"03000000ef0500000300000000010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux,",
658"03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
659"03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
660"03000000c21100000791000011010000,Be1 GC101 Controller 1.03 mode,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
661"03000000c31100000791000011010000,Be1 GC101 GAMEPAD 1.03 mode,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
662"030000005e0400008e02000003030000,Be1 GC101 Xbox 360 Controller mode,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
663"05000000bc2000000055000001000000,BETOP AX1 BFM,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
664"03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux,",
665"03000000120c0000200e000011010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
666"03000000120c0000210e000011010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
667"03000000120c0000f70e000011010000,Brook Universal Fighting Board,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
668"03000000ffff0000ffff000000010000,Chinese-made Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
669"03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
670"030000000b0400003365000000010000,Competition Pro,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Linux,",
671"03000000260900008888000000010000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Linux,",
672"03000000a306000022f6000011010000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
673"03000000b40400000a01000000010000,CYPRESS USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,",
674"03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,",
675"030000004f04000004b3000010010000,Dual Power 2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
676"030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
677"03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
678"03000000bc2000000055000011010000,GameSir G3w,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
679"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
680"030000006f0e00000104000000010000,Gamestop Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
681"030000008f0e00000800000010010000,Gasia Co. Ltd PS(R) Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
682"030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
683"03000000451300000010000010010000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
684"03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
685"0300000079000000d418000000010000,GPD Win 2 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
686"030000007d0400000540000000010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
687"03000000280400000140000000010000,Gravis GamePad Pro USB ,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
688"030000008f0e00000610000000010000,GreenAsia Electronics 4Axes 12Keys GamePad ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Linux,",
689"030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
690"0500000047532067616d657061640000,GS gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
691"03000000f0250000c383000010010000,GT VX2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
692"06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
693"03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,platform:Linux,",
694"03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
695"03000000632500002605000010010000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
696"030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,platform:Linux,",
697"030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
698"030000000d0f0000c100000011010000,HORI CO. LTD. HORIPAD S,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
699"030000000d0f00006a00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
700"030000000d0f00006b00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
701"030000000d0f00002200000011010000,HORI CO. LTD. REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
702"030000000d0f00008500000010010000,HORI Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
703"030000000d0f00008600000002010000,Hori Fighting Commander,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
704"030000000d0f00005f00000011010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
705"030000000d0f00005e00000011010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
706"03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
707"030000000d0f00009200000011010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
708"030000000d0f0000aa00000011010000,HORI Real Arcade Pro,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
709"030000000d0f0000d800000072056800,HORI Real Arcade Pro S,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
710"030000000d0f00001600000000010000,Hori Real Arcade Pro.EX-SE (Xbox 360),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b2,y:b3,platform:Linux,",
711"030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
712"030000000d0f00006600000011010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
713"030000000d0f0000ee00000011010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
714"030000000d0f00006700000001010000,HORIPAD ONE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
715"030000008f0e00001330000010010000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Linux,",
716"03000000242e00008816000001010000,Hyperkin X91,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
717"03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,",
718"050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
719"03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
720"03000000d80400008200000003000000,IMS PCU#0 Gamepad Interface,a:b1,b:b0,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b5,x:b3,y:b2,platform:Linux,",
721"03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,platform:Linux,",
722"0500000049190000020400001b010000,Ipega PG-9069 - Bluetooth Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b161,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
723"03000000632500007505000011010000,Ipega PG-9099 - Bluetooth Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
724"030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Linux,",
725"03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
726"03000000300f00000b01000010010000,Jess Tech GGE909 PC Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
727"03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
728"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,",
729"050000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,",
730"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,",
731"050000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,",
732"03000000bd12000003c0000010010000,Joypad Alpha Shock,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
733"03000000242f00002d00000011010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
734"03000000242f00008a00000011010000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,",
735"030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
736"030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
737"030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
738"030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
739"030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
740"030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
741"030000006d0400001ec2000019200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
742"030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
743"030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
744"030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
745"030000006d0400000ac2000010010000,Logitech Inc. WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Linux,",
746"030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
747"030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b6,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b10,rightx:a3,righty:a4,start:b8,x:b3,y:b4,platform:Linux,",
748"050000004d4f435554452d3035305800,M54-PC,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
749"05000000380700006652000025010000,Mad Catz C.T.R.L.R ,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
750"03000000380700005032000011010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
751"03000000380700005082000011010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
752"03000000ad1b00002ef0000090040000,Mad Catz Fightpad SFxT,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Linux,",
753"03000000380700008034000011010000,Mad Catz fightstick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
754"03000000380700008084000011010000,Mad Catz fightstick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
755"03000000380700008433000011010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
756"03000000380700008483000011010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
757"03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
758"03000000380700003847000090040000,Mad Catz Wired Xbox 360 Controller (SFIV),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
759"03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
760"03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
761"03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
762"03000000242f0000f700000001010000,Magic-S Pro,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
763"03000000120c00000500000000010000,Manta Dualshock 2,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
764"03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b0,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
765"03000000790000004318000010010000,Mayflash GameCube Controller Adapter,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
766"03000000242f00007300000011010000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,",
767"0300000079000000d218000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
768"03000000d620000010a7000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
769"0300000025090000e803000001010000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:a5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
770"03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
771"030000005e0400000e00000000010000,Microsoft SideWinder,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,",
772"030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
773"030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
774"050000005e040000050b000003090000,Microsoft X-Box One Elite 2 pad,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
775"030000005e040000e302000003020000,Microsoft X-Box One Elite pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
776"030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
777"030000005e040000dd02000003020000,Microsoft X-Box One pad (Firmware 2015),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
778"030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
779"030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
780"030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
781"030000005e040000000b000008040000,Microsoft Xbox One Elite 2 pad - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
782"030000005e040000ea02000008040000,Microsoft Xbox One S pad - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
783"03000000c62400001a53000000010000,Mini PE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
784"03000000030000000300000002000000,Miroof,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,",
785"05000000d6200000e589000001000000,Moga 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
786"05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
787"05000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
788"03000000c62400002b89000011010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
789"05000000c62400002a89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b22,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
790"05000000c62400001a89000000010000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
791"03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
792"030000006b140000010c000010010000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
793"030000000d0f00000900000010010000,Natec Genesis P44,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
794"03000000790000004518000010010000,NEXILUX GAMECUBE Controller Adapter,a:b1,b:b0,x:b2,y:b3,start:b9,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a5,righty:a2,lefttrigger:a3,righttrigger:a4,platform:Linux,",
795"030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,righttrigger:b6,start:b9,x:b3,y:b0,platform:Linux,",
796"060000007e0500003713000000000000,Nintendo 3DS,a:b0,b:b1,back:b8,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
797"060000007e0500000820000000000000,Nintendo Combined Joy-Cons (joycond),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
798"030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux,",
799"03000000790000004618000010010000,Nintendo GameCube Controller Adapter,a:b1,b:b0,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5~,righty:a2~,start:b9,x:b2,y:b3,platform:Linux,",
800"050000007e0500000620000001800000,Nintendo Switch Left Joy-Con,a:b9,b:b8,back:b5,leftshoulder:b2,leftstick:b6,leftx:a1,lefty:a0~,rightshoulder:b4,start:b0,x:b7,y:b10,platform:Linux,",
801"030000007e0500000920000011810000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
802"050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
803"050000007e0500000920000001800000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
804"050000007e0500000720000001800000,Nintendo Switch Right Joy-Con,a:b1,b:b2,back:b9,leftshoulder:b4,leftstick:b10,leftx:a1~,lefty:a0~,rightshoulder:b6,start:b8,x:b0,y:b3,platform:Linux,",
805"050000007e0500001720000001000000,Nintendo Switch SNES Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,",
806"050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
807"05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
808"030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux,",
809"03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
810"03000000550900001472000011010000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,",
811"05000000550900001472000001000000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,",
812"03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
813"19000000010000000100000001010000,odroidgo2_joypad,a:b1,b:b0,dpdown:b7,dpleft:b8,dpright:b9,dpup:b6,guide:b10,leftshoulder:b4,leftstick:b12,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b13,righttrigger:b14,start:b15,x:b2,y:b3,platform:Linux,",
814"19000000010000000200000011000000,odroidgo2_joypad_v11,a:b1,b:b0,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b12,leftshoulder:b4,leftstick:b14,lefttrigger:b13,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b15,righttrigger:b16,start:b17,x:b2,y:b3,platform:Linux,",
815"030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
816"03000000c0160000dc27000001010000,OnyxSoft Dual JoyDivision,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:Linux,",
817"05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
818"05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
819"03000000830500005020000010010000,Padix Co. Ltd. Rockfire PSX/USB Bridge,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b2,y:b3,platform:Linux,",
820"03000000790000001c18000011010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
821"03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
822"030000006f0e0000b802000001010000,PDP AFTERGLOW Wired Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
823"030000006f0e0000b802000013020000,PDP AFTERGLOW Wired Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
824"030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
825"030000006f0e00008001000011010000,PDP CO. LTD. Faceoff Wired Pro Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
826"030000006f0e00003101000000010000,PDP EA Sports Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
827"030000006f0e0000c802000012010000,PDP Kingdom Hearts Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
828"030000006f0e00008701000011010000,PDP Rock Candy Wired Controller for Nintendo Switch,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
829"030000006f0e00000901000011010000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
830"030000006f0e0000a802000023020000,PDP Wired Controller for Xbox One,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
831"030000006f0e00008501000011010000,PDP Wired Fight Pad Pro for Nintendo Switch,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
832"0500000049190000030400001b010000,PG-9099,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
833"05000000491900000204000000000000,PG-9118,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
834"030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
835"030000004c0500003713000011010000,PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
836"03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
837"03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
838"03000000d62000006dca000011010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
839"03000000d62000000228000001010000,PowerA Wired Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
840"03000000c62400001a58000001010000,PowerA Xbox One Cabled,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
841"03000000c62400001a54000001010000,PowerA Xbox One Mini Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
842"030000006d040000d2ca000011010000,Precision Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
843"03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
844"03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
845"030000004c0500006802000010010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
846"030000004c0500006802000010810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
847"030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
848"030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
849"030000006f0e00001402000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
850"030000008f0e00000300000010010000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
851"050000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
852"050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
853"050000004c0500006802000000800000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
854"050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
855"05000000504c415953544154494f4e00,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
856"060000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
857"030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
858"030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
859"030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
860"030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
861"030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
862"030000004c050000cc09000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
863"030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
864"03000000c01100000140000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
865"050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
866"050000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
867"050000004c050000c405000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
868"050000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
869"050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
870"050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
871"030000004c050000e60c000011010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
872"050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
873"03000000ff000000cb01000010010000,PSP,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Linux,",
874"03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux,",
875"030000009b2800004200000001010000,Raphnet Technologies Dual NES to USB v2.0,a:b0,b:b1,back:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b3,platform:Linux,",
876"030000009b2800003200000001010000,Raphnet Technologies GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,",
877"030000009b2800006000000001010000,Raphnet Technologies GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,",
878"030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux,",
879"030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
880"030000008916000000fd000024010000,Razer Onza Tournament Edition,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
881"03000000321500000204000011010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
882"03000000321500000104000011010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
883"03000000321500000810000011010000,Razer Panthera Evo Arcade Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
884"03000000321500000010000011010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
885"03000000321500000507000000010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
886"03000000321500000011000011010000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
887"030000008916000000fe000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
888"03000000c6240000045d000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
889"03000000c6240000045d000025010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
890"03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
891"050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
892"0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
893"03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
894"0300000081170000990a000001010000,Retronic Adapter,a:b0,leftx:a0,lefty:a1,platform:Linux,",
895"0300000000f000000300000000010000,RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
896"030000006b140000010d000011010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
897"030000006b140000130d000011010000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
898"030000006f0e00001f01000000010000,Rock Candy,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
899"030000006f0e00001e01000011010000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
900"030000006f0e00004601000001010000,Rock Candy Xbox One Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
901"03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
902"03000000a30600001005000000010000,Saitek P150,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b2,righttrigger:b5,x:b3,y:b4,platform:Linux,",
903"03000000a30600000701000000010000,Saitek P220,a:b2,b:b3,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b7,rightshoulder:b4,righttrigger:b5,x:b0,y:b1,platform:Linux,",
904"03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b0,y:b1,platform:Linux,",
905"03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,platform:Linux,",
906"03000000300f00001201000010010000,Saitek P380,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
907"03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,",
908"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Linux,",
909"03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
910"03000000a306000020f6000011010000,Saitek PS2700 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
911"03000000d81d00000e00000010010000,Savior,a:b0,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b11,righttrigger:b3,start:b9,x:b4,y:b5,platform:Linux,",
912"03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
913"03000000632500007505000010010000,SHANWAN PS3/PC Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
914"03000000bc2000000055000010010000,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
915"030000005f140000c501000010010000,SHANWAN Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
916"03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
917"03000000341a00000908000010010000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
918"030000004c050000e60c000011810000,Sony DualSense,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
919"050000004c050000e60c000000810000,Sony DualSense ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
920"03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
921"030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
922"030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
923"03000000d11800000094000011010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
924"03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
925"03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
926"03000000de2800000211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux,",
927"03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
928"03000000de2800004211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux,",
929"03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
930"05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
931"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
932"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
933"03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
934"03000000381000003014000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
935"03000000381000003114000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
936"0500000011010000311400001b010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b32,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
937"05000000110100001914000009010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
938"03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
939"030000003b07000004a1000000010000,Suncom SFX Plus for USB,a:b0,b:b2,back:b7,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:b5,start:b8,x:b1,y:b3,platform:Linux,",
940"03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
941"0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
942"03000000457500002211000010010000,SZMY-POWER CO. LTD. GAMEPAD,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
943"030000008f0e00000d31000010010000,SZMY-POWER CO. LTD. GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
944"030000008f0e00001431000010010000,SZMY-POWER CO. LTD. PS3 gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
945"030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
946"030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
947"030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
948"030000004f0400000ed0000011010000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
949"03000000b50700000399000000010000,Thrustmaster Firestorm Digital 2,a:b2,b:b4,back:b11,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b0,righttrigger:b9,start:b1,x:b3,y:b5,platform:Linux,",
950"030000004f04000003b3000010010000,Thrustmaster Firestorm Dual Analog 2,a:b0,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b9,rightx:a2,righty:a3,x:b1,y:b3,platform:Linux,",
951"030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Linux,",
952"030000004f04000026b3000002040000,Thrustmaster Gamepad GP XID,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
953"03000000c6240000025b000002020000,Thrustmaster GPX Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
954"030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
955"030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
956"030000004f04000007d0000000010000,Thrustmaster T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
957"030000004f04000012b3000010010000,Thrustmaster vibrating gamepad,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
958"03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
959"03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,platform:Linux,",
960"030000005e0400008e02000070050000,Torid,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
961"03000000c01100000591000011010000,Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
962"03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
963"03000000100800000300000010010000,USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
964"03000000790000000600000007010000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,",
965"03000000790000001100000000010000,USB Gamepad1,a:b2,b:b1,back:b8,dpdown:a0,dpleft:a1,dpright:a2,dpup:a4,start:b9,platform:Linux,",
966"030000006f0e00000302000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
967"030000006f0e00000702000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
968"05000000ac0500003232000001000000,VR-BOX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
969"03000000791d00000103000010010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
970"050000000d0f0000f600000001000000,Wireless HORIPAD Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
971"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
972"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
973"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
974"030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
975"030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
976"030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
977"0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Linux,",
978"030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
979"0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
980"030000005e040000d102000002010000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
981"050000005e040000fd02000030110000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
982"050000005e040000050b000002090000,Xbox One Elite Series 2,a:b0,b:b1,back:b136,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
983"030000005e040000ea02000000000000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
984"050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
985"050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
986"030000005e040000ea02000001030000,Xbox One Wireless Controller (Model 1708),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
987"030000005e040000120b000001050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
988"030000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
989"050000005e040000130b000001050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
990"050000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
991"030000005e040000120b000005050000,XBox Series pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
992"030000005e0400008e02000000010000,xbox360 Wireless EasySMX,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
993"03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
994"03000000ac0500005b05000010010000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
995"05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux,",
996"03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,",
997"03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
998"03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
999"03000000af1e00002400000010010000,Clockwork Pi DevTerm,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b9,x:b3,y:b0,platform:Linux,",
1000#endif // GLFW_BUILD_LINUX_JOYSTICK
1001};
1002
diff --git a/raylib/src/external/glfw/src/mappings.h.in b/raylib/src/external/glfw/src/mappings.h.in
new file mode 100644
index 0000000..ed62368
--- /dev/null
+++ b/raylib/src/external/glfw/src/mappings.h.in
@@ -0,0 +1,82 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26// As mappings.h.in, this file is used by CMake to produce the mappings.h
27// header file. If you are adding a GLFW specific gamepad mapping, this is
28// where to put it.
29//========================================================================
30// As mappings.h, this provides all pre-defined gamepad mappings, including
31// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
32// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
33// This file can be re-generated from mappings.h.in and the upstream
34// gamecontrollerdb.txt with the 'update_mappings' CMake target.
35//========================================================================
36
37// All gamepad mappings not labeled GLFW are copied from the
38// SDL_GameControllerDB project under the following license:
39//
40// Simple DirectMedia Layer
41// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
42//
43// This software is provided 'as-is', without any express or implied warranty.
44// In no event will the authors be held liable for any damages arising from the
45// use of this software.
46//
47// Permission is granted to anyone to use this software for any purpose,
48// including commercial applications, and to alter it and redistribute it
49// freely, subject to the following restrictions:
50//
51// 1. The origin of this software must not be misrepresented; you must not
52// claim that you wrote the original software. If you use this software
53// in a product, an acknowledgment in the product documentation would
54// be appreciated but is not required.
55//
56// 2. Altered source versions must be plainly marked as such, and must not be
57// misrepresented as being the original software.
58//
59// 3. This notice may not be removed or altered from any source distribution.
60
61const char* _glfwDefaultMappings[] =
62{
63#if defined(_GLFW_WIN32)
64@GLFW_WIN32_MAPPINGS@
65"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
66"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
67"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
68"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
69"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
70"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
71"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
72#endif // _GLFW_WIN32
73
74#if defined(_GLFW_COCOA)
75@GLFW_COCOA_MAPPINGS@
76#endif // _GLFW_COCOA
77
78#if defined(GLFW_BUILD_LINUX_JOYSTICK)
79@GLFW_LINUX_MAPPINGS@
80#endif // GLFW_BUILD_LINUX_JOYSTICK
81};
82
diff --git a/raylib/src/external/glfw/src/monitor.c b/raylib/src/external/glfw/src/monitor.c
new file mode 100644
index 0000000..efc286d
--- /dev/null
+++ b/raylib/src/external/glfw/src/monitor.c
@@ -0,0 +1,548 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <assert.h>
31#include <math.h>
32#include <float.h>
33#include <string.h>
34#include <stdlib.h>
35#include <limits.h>
36
37
38// Lexically compare video modes, used by qsort
39//
40static int compareVideoModes(const void* fp, const void* sp)
41{
42 const GLFWvidmode* fm = fp;
43 const GLFWvidmode* sm = sp;
44 const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
45 const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
46 const int farea = fm->width * fm->height;
47 const int sarea = sm->width * sm->height;
48
49 // First sort on color bits per pixel
50 if (fbpp != sbpp)
51 return fbpp - sbpp;
52
53 // Then sort on screen area
54 if (farea != sarea)
55 return farea - sarea;
56
57 // Then sort on width
58 if (fm->width != sm->width)
59 return fm->width - sm->width;
60
61 // Lastly sort on refresh rate
62 return fm->refreshRate - sm->refreshRate;
63}
64
65// Retrieves the available modes for the specified monitor
66//
67static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
68{
69 int modeCount;
70 GLFWvidmode* modes;
71
72 if (monitor->modes)
73 return GLFW_TRUE;
74
75 modes = _glfw.platform.getVideoModes(monitor, &modeCount);
76 if (!modes)
77 return GLFW_FALSE;
78
79 qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
80
81 _glfw_free(monitor->modes);
82 monitor->modes = modes;
83 monitor->modeCount = modeCount;
84
85 return GLFW_TRUE;
86}
87
88
89//////////////////////////////////////////////////////////////////////////
90////// GLFW event API //////
91//////////////////////////////////////////////////////////////////////////
92
93// Notifies shared code of a monitor connection or disconnection
94//
95void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
96{
97 assert(monitor != NULL);
98 assert(action == GLFW_CONNECTED || action == GLFW_DISCONNECTED);
99 assert(placement == _GLFW_INSERT_FIRST || placement == _GLFW_INSERT_LAST);
100
101 if (action == GLFW_CONNECTED)
102 {
103 _glfw.monitorCount++;
104 _glfw.monitors =
105 _glfw_realloc(_glfw.monitors,
106 sizeof(_GLFWmonitor*) * _glfw.monitorCount);
107
108 if (placement == _GLFW_INSERT_FIRST)
109 {
110 memmove(_glfw.monitors + 1,
111 _glfw.monitors,
112 ((size_t) _glfw.monitorCount - 1) * sizeof(_GLFWmonitor*));
113 _glfw.monitors[0] = monitor;
114 }
115 else
116 _glfw.monitors[_glfw.monitorCount - 1] = monitor;
117 }
118 else if (action == GLFW_DISCONNECTED)
119 {
120 int i;
121 _GLFWwindow* window;
122
123 for (window = _glfw.windowListHead; window; window = window->next)
124 {
125 if (window->monitor == monitor)
126 {
127 int width, height, xoff, yoff;
128 _glfw.platform.getWindowSize(window, &width, &height);
129 _glfw.platform.setWindowMonitor(window, NULL, 0, 0, width, height, 0);
130 _glfw.platform.getWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
131 _glfw.platform.setWindowPos(window, xoff, yoff);
132 }
133 }
134
135 for (i = 0; i < _glfw.monitorCount; i++)
136 {
137 if (_glfw.monitors[i] == monitor)
138 {
139 _glfw.monitorCount--;
140 memmove(_glfw.monitors + i,
141 _glfw.monitors + i + 1,
142 ((size_t) _glfw.monitorCount - i) * sizeof(_GLFWmonitor*));
143 break;
144 }
145 }
146 }
147
148 if (_glfw.callbacks.monitor)
149 _glfw.callbacks.monitor((GLFWmonitor*) monitor, action);
150
151 if (action == GLFW_DISCONNECTED)
152 _glfwFreeMonitor(monitor);
153}
154
155// Notifies shared code that a full screen window has acquired or released
156// a monitor
157//
158void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
159{
160 assert(monitor != NULL);
161 monitor->window = window;
162}
163
164
165//////////////////////////////////////////////////////////////////////////
166////// GLFW internal API //////
167//////////////////////////////////////////////////////////////////////////
168
169// Allocates and returns a monitor object with the specified name and dimensions
170//
171_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
172{
173 _GLFWmonitor* monitor = _glfw_calloc(1, sizeof(_GLFWmonitor));
174 monitor->widthMM = widthMM;
175 monitor->heightMM = heightMM;
176
177 strncpy(monitor->name, name, sizeof(monitor->name) - 1);
178
179 return monitor;
180}
181
182// Frees a monitor object and any data associated with it
183//
184void _glfwFreeMonitor(_GLFWmonitor* monitor)
185{
186 if (monitor == NULL)
187 return;
188
189 _glfw.platform.freeMonitor(monitor);
190
191 _glfwFreeGammaArrays(&monitor->originalRamp);
192 _glfwFreeGammaArrays(&monitor->currentRamp);
193
194 _glfw_free(monitor->modes);
195 _glfw_free(monitor);
196}
197
198// Allocates red, green and blue value arrays of the specified size
199//
200void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
201{
202 ramp->red = _glfw_calloc(size, sizeof(unsigned short));
203 ramp->green = _glfw_calloc(size, sizeof(unsigned short));
204 ramp->blue = _glfw_calloc(size, sizeof(unsigned short));
205 ramp->size = size;
206}
207
208// Frees the red, green and blue value arrays and clears the struct
209//
210void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
211{
212 _glfw_free(ramp->red);
213 _glfw_free(ramp->green);
214 _glfw_free(ramp->blue);
215
216 memset(ramp, 0, sizeof(GLFWgammaramp));
217}
218
219// Chooses the video mode most closely matching the desired one
220//
221const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
222 const GLFWvidmode* desired)
223{
224 int i;
225 unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
226 unsigned int rateDiff, leastRateDiff = UINT_MAX;
227 unsigned int colorDiff, leastColorDiff = UINT_MAX;
228 const GLFWvidmode* current;
229 const GLFWvidmode* closest = NULL;
230
231 if (!refreshVideoModes(monitor))
232 return NULL;
233
234 for (i = 0; i < monitor->modeCount; i++)
235 {
236 current = monitor->modes + i;
237
238 colorDiff = 0;
239
240 if (desired->redBits != GLFW_DONT_CARE)
241 colorDiff += abs(current->redBits - desired->redBits);
242 if (desired->greenBits != GLFW_DONT_CARE)
243 colorDiff += abs(current->greenBits - desired->greenBits);
244 if (desired->blueBits != GLFW_DONT_CARE)
245 colorDiff += abs(current->blueBits - desired->blueBits);
246
247 sizeDiff = abs((current->width - desired->width) *
248 (current->width - desired->width) +
249 (current->height - desired->height) *
250 (current->height - desired->height));
251
252 if (desired->refreshRate != GLFW_DONT_CARE)
253 rateDiff = abs(current->refreshRate - desired->refreshRate);
254 else
255 rateDiff = UINT_MAX - current->refreshRate;
256
257 if ((colorDiff < leastColorDiff) ||
258 (colorDiff == leastColorDiff && sizeDiff < leastSizeDiff) ||
259 (colorDiff == leastColorDiff && sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
260 {
261 closest = current;
262 leastSizeDiff = sizeDiff;
263 leastRateDiff = rateDiff;
264 leastColorDiff = colorDiff;
265 }
266 }
267
268 return closest;
269}
270
271// Performs lexical comparison between two @ref GLFWvidmode structures
272//
273int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm)
274{
275 return compareVideoModes(fm, sm);
276}
277
278// Splits a color depth into red, green and blue bit depths
279//
280void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
281{
282 int delta;
283
284 // We assume that by 32 the user really meant 24
285 if (bpp == 32)
286 bpp = 24;
287
288 // Convert "bits per pixel" to red, green & blue sizes
289
290 *red = *green = *blue = bpp / 3;
291 delta = bpp - (*red * 3);
292 if (delta >= 1)
293 *green = *green + 1;
294
295 if (delta == 2)
296 *red = *red + 1;
297}
298
299
300//////////////////////////////////////////////////////////////////////////
301////// GLFW public API //////
302//////////////////////////////////////////////////////////////////////////
303
304GLFWAPI GLFWmonitor** glfwGetMonitors(int* count)
305{
306 assert(count != NULL);
307
308 *count = 0;
309
310 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
311
312 *count = _glfw.monitorCount;
313 return (GLFWmonitor**) _glfw.monitors;
314}
315
316GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
317{
318 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
319
320 if (!_glfw.monitorCount)
321 return NULL;
322
323 return (GLFWmonitor*) _glfw.monitors[0];
324}
325
326GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
327{
328 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
329 assert(monitor != NULL);
330
331 if (xpos)
332 *xpos = 0;
333 if (ypos)
334 *ypos = 0;
335
336 _GLFW_REQUIRE_INIT();
337
338 _glfw.platform.getMonitorPos(monitor, xpos, ypos);
339}
340
341GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
342 int* xpos, int* ypos,
343 int* width, int* height)
344{
345 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
346 assert(monitor != NULL);
347
348 if (xpos)
349 *xpos = 0;
350 if (ypos)
351 *ypos = 0;
352 if (width)
353 *width = 0;
354 if (height)
355 *height = 0;
356
357 _GLFW_REQUIRE_INIT();
358
359 _glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height);
360}
361
362GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
363{
364 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
365 assert(monitor != NULL);
366
367 if (widthMM)
368 *widthMM = 0;
369 if (heightMM)
370 *heightMM = 0;
371
372 _GLFW_REQUIRE_INIT();
373
374 if (widthMM)
375 *widthMM = monitor->widthMM;
376 if (heightMM)
377 *heightMM = monitor->heightMM;
378}
379
380GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
381 float* xscale, float* yscale)
382{
383 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
384 assert(monitor != NULL);
385
386 if (xscale)
387 *xscale = 0.f;
388 if (yscale)
389 *yscale = 0.f;
390
391 _GLFW_REQUIRE_INIT();
392 _glfw.platform.getMonitorContentScale(monitor, xscale, yscale);
393}
394
395GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
396{
397 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
398 assert(monitor != NULL);
399
400 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
401 return monitor->name;
402}
403
404GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
405{
406 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
407 assert(monitor != NULL);
408
409 _GLFW_REQUIRE_INIT();
410 monitor->userPointer = pointer;
411}
412
413GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
414{
415 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
416 assert(monitor != NULL);
417
418 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
419 return monitor->userPointer;
420}
421
422GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
423{
424 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
425 _GLFW_SWAP(GLFWmonitorfun, _glfw.callbacks.monitor, cbfun);
426 return cbfun;
427}
428
429GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
430{
431 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
432 assert(monitor != NULL);
433 assert(count != NULL);
434
435 *count = 0;
436
437 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
438
439 if (!refreshVideoModes(monitor))
440 return NULL;
441
442 *count = monitor->modeCount;
443 return monitor->modes;
444}
445
446GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
447{
448 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
449 assert(monitor != NULL);
450
451 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
452
453 if (!_glfw.platform.getVideoMode(monitor, &monitor->currentMode))
454 return NULL;
455
456 return &monitor->currentMode;
457}
458
459GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
460{
461 unsigned int i;
462 unsigned short* values;
463 GLFWgammaramp ramp;
464 const GLFWgammaramp* original;
465 assert(handle != NULL);
466 assert(gamma > 0.f);
467 assert(gamma <= FLT_MAX);
468
469 _GLFW_REQUIRE_INIT();
470
471 if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
472 {
473 _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
474 return;
475 }
476
477 original = glfwGetGammaRamp(handle);
478 if (!original)
479 return;
480
481 values = _glfw_calloc(original->size, sizeof(unsigned short));
482
483 for (i = 0; i < original->size; i++)
484 {
485 float value;
486
487 // Calculate intensity
488 value = i / (float) (original->size - 1);
489 // Apply gamma curve
490 value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
491 // Clamp to value range
492 value = fminf(value, 65535.f);
493
494 values[i] = (unsigned short) value;
495 }
496
497 ramp.red = values;
498 ramp.green = values;
499 ramp.blue = values;
500 ramp.size = original->size;
501
502 glfwSetGammaRamp(handle, &ramp);
503 _glfw_free(values);
504}
505
506GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
507{
508 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
509 assert(monitor != NULL);
510
511 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
512
513 _glfwFreeGammaArrays(&monitor->currentRamp);
514 if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp))
515 return NULL;
516
517 return &monitor->currentRamp;
518}
519
520GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
521{
522 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
523 assert(monitor != NULL);
524 assert(ramp != NULL);
525 assert(ramp->size > 0);
526 assert(ramp->red != NULL);
527 assert(ramp->green != NULL);
528 assert(ramp->blue != NULL);
529
530 _GLFW_REQUIRE_INIT();
531
532 if (ramp->size <= 0)
533 {
534 _glfwInputError(GLFW_INVALID_VALUE,
535 "Invalid gamma ramp size %i",
536 ramp->size);
537 return;
538 }
539
540 if (!monitor->originalRamp.size)
541 {
542 if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp))
543 return;
544 }
545
546 _glfw.platform.setGammaRamp(monitor, ramp);
547}
548
diff --git a/raylib/src/external/glfw/src/nsgl_context.m b/raylib/src/external/glfw/src/nsgl_context.m
new file mode 100644
index 0000000..daa8367
--- /dev/null
+++ b/raylib/src/external/glfw/src/nsgl_context.m
@@ -0,0 +1,384 @@
1//========================================================================
2// GLFW 3.4 macOS - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include "internal.h"
28
29#if defined(_GLFW_COCOA)
30
31#include <unistd.h>
32#include <math.h>
33
34static void makeContextCurrentNSGL(_GLFWwindow* window)
35{
36 @autoreleasepool {
37
38 if (window)
39 [window->context.nsgl.object makeCurrentContext];
40 else
41 [NSOpenGLContext clearCurrentContext];
42
43 _glfwPlatformSetTls(&_glfw.contextSlot, window);
44
45 } // autoreleasepool
46}
47
48static void swapBuffersNSGL(_GLFWwindow* window)
49{
50 @autoreleasepool {
51
52 // HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
53 // windows with a non-visible occlusion state
54 if (window->ns.occluded)
55 {
56 int interval = 0;
57 [window->context.nsgl.object getValues:&interval
58 forParameter:NSOpenGLContextParameterSwapInterval];
59
60 if (interval > 0)
61 {
62 const double framerate = 60.0;
63 const uint64_t frequency = _glfwPlatformGetTimerFrequency();
64 const uint64_t value = _glfwPlatformGetTimerValue();
65
66 const double elapsed = value / (double) frequency;
67 const double period = 1.0 / framerate;
68 const double delay = period - fmod(elapsed, period);
69
70 usleep(floorl(delay * 1e6));
71 }
72 }
73
74 [window->context.nsgl.object flushBuffer];
75
76 } // autoreleasepool
77}
78
79static void swapIntervalNSGL(int interval)
80{
81 @autoreleasepool {
82
83 _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
84 assert(window != NULL);
85
86 [window->context.nsgl.object setValues:&interval
87 forParameter:NSOpenGLContextParameterSwapInterval];
88
89 } // autoreleasepool
90}
91
92static int extensionSupportedNSGL(const char* extension)
93{
94 // There are no NSGL extensions
95 return GLFW_FALSE;
96}
97
98static GLFWglproc getProcAddressNSGL(const char* procname)
99{
100 CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault,
101 procname,
102 kCFStringEncodingASCII);
103
104 GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,
105 symbolName);
106
107 CFRelease(symbolName);
108
109 return symbol;
110}
111
112static void destroyContextNSGL(_GLFWwindow* window)
113{
114 @autoreleasepool {
115
116 [window->context.nsgl.pixelFormat release];
117 window->context.nsgl.pixelFormat = nil;
118
119 [window->context.nsgl.object release];
120 window->context.nsgl.object = nil;
121
122 } // autoreleasepool
123}
124
125
126//////////////////////////////////////////////////////////////////////////
127////// GLFW internal API //////
128//////////////////////////////////////////////////////////////////////////
129
130// Initialize OpenGL support
131//
132GLFWbool _glfwInitNSGL(void)
133{
134 if (_glfw.nsgl.framework)
135 return GLFW_TRUE;
136
137 _glfw.nsgl.framework =
138 CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
139 if (_glfw.nsgl.framework == NULL)
140 {
141 _glfwInputError(GLFW_API_UNAVAILABLE,
142 "NSGL: Failed to locate OpenGL framework");
143 return GLFW_FALSE;
144 }
145
146 return GLFW_TRUE;
147}
148
149// Terminate OpenGL support
150//
151void _glfwTerminateNSGL(void)
152{
153}
154
155// Create the OpenGL context
156//
157GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
158 const _GLFWctxconfig* ctxconfig,
159 const _GLFWfbconfig* fbconfig)
160{
161 if (ctxconfig->client == GLFW_OPENGL_ES_API)
162 {
163 _glfwInputError(GLFW_API_UNAVAILABLE,
164 "NSGL: OpenGL ES is not available via NSGL");
165 return GLFW_FALSE;
166 }
167
168 if (ctxconfig->major > 2)
169 {
170 if (ctxconfig->major == 3 && ctxconfig->minor < 2)
171 {
172 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
173 "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above");
174 return GLFW_FALSE;
175 }
176 }
177
178 if (ctxconfig->major >= 3 && ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
179 {
180 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
181 "NSGL: The compatibility profile is not available on macOS");
182 return GLFW_FALSE;
183 }
184
185 // Context robustness modes (GL_KHR_robustness) are not yet supported by
186 // macOS but are not a hard constraint, so ignore and continue
187
188 // Context release behaviors (GL_KHR_context_flush_control) are not yet
189 // supported by macOS but are not a hard constraint, so ignore and continue
190
191 // Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not
192 // a hard constraint, so ignore and continue
193
194 // No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
195 // are not a hard constraint, so ignore and continue
196
197#define ADD_ATTRIB(a) \
198{ \
199 assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
200 attribs[index++] = a; \
201}
202#define SET_ATTRIB(a, v) { ADD_ATTRIB(a); ADD_ATTRIB(v); }
203
204 NSOpenGLPixelFormatAttribute attribs[40];
205 int index = 0;
206
207 ADD_ATTRIB(NSOpenGLPFAAccelerated);
208 ADD_ATTRIB(NSOpenGLPFAClosestPolicy);
209
210 if (ctxconfig->nsgl.offline)
211 {
212 ADD_ATTRIB(NSOpenGLPFAAllowOfflineRenderers);
213 // NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
214 // Info.plist for unbundled applications
215 // HACK: This assumes that NSOpenGLPixelFormat will remain
216 // a straightforward wrapper of its CGL counterpart
217 ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching);
218 }
219
220#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
221 if (ctxconfig->major >= 4)
222 {
223 SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
224 }
225 else
226#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
227 if (ctxconfig->major >= 3)
228 {
229 SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
230 }
231
232 if (ctxconfig->major <= 2)
233 {
234 if (fbconfig->auxBuffers != GLFW_DONT_CARE)
235 SET_ATTRIB(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
236
237 if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
238 fbconfig->accumGreenBits != GLFW_DONT_CARE &&
239 fbconfig->accumBlueBits != GLFW_DONT_CARE &&
240 fbconfig->accumAlphaBits != GLFW_DONT_CARE)
241 {
242 const int accumBits = fbconfig->accumRedBits +
243 fbconfig->accumGreenBits +
244 fbconfig->accumBlueBits +
245 fbconfig->accumAlphaBits;
246
247 SET_ATTRIB(NSOpenGLPFAAccumSize, accumBits);
248 }
249 }
250
251 if (fbconfig->redBits != GLFW_DONT_CARE &&
252 fbconfig->greenBits != GLFW_DONT_CARE &&
253 fbconfig->blueBits != GLFW_DONT_CARE)
254 {
255 int colorBits = fbconfig->redBits +
256 fbconfig->greenBits +
257 fbconfig->blueBits;
258
259 // macOS needs non-zero color size, so set reasonable values
260 if (colorBits == 0)
261 colorBits = 24;
262 else if (colorBits < 15)
263 colorBits = 15;
264
265 SET_ATTRIB(NSOpenGLPFAColorSize, colorBits);
266 }
267
268 if (fbconfig->alphaBits != GLFW_DONT_CARE)
269 SET_ATTRIB(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
270
271 if (fbconfig->depthBits != GLFW_DONT_CARE)
272 SET_ATTRIB(NSOpenGLPFADepthSize, fbconfig->depthBits);
273
274 if (fbconfig->stencilBits != GLFW_DONT_CARE)
275 SET_ATTRIB(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
276
277 if (fbconfig->stereo)
278 {
279#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
280 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
281 "NSGL: Stereo rendering is deprecated");
282 return GLFW_FALSE;
283#else
284 ADD_ATTRIB(NSOpenGLPFAStereo);
285#endif
286 }
287
288 if (fbconfig->doublebuffer)
289 ADD_ATTRIB(NSOpenGLPFADoubleBuffer);
290
291 if (fbconfig->samples != GLFW_DONT_CARE)
292 {
293 if (fbconfig->samples == 0)
294 {
295 SET_ATTRIB(NSOpenGLPFASampleBuffers, 0);
296 }
297 else
298 {
299 SET_ATTRIB(NSOpenGLPFASampleBuffers, 1);
300 SET_ATTRIB(NSOpenGLPFASamples, fbconfig->samples);
301 }
302 }
303
304 // NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
305 // framebuffer, so there's no need (and no way) to request it
306
307 ADD_ATTRIB(0);
308
309#undef ADD_ATTRIB
310#undef SET_ATTRIB
311
312 window->context.nsgl.pixelFormat =
313 [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
314 if (window->context.nsgl.pixelFormat == nil)
315 {
316 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
317 "NSGL: Failed to find a suitable pixel format");
318 return GLFW_FALSE;
319 }
320
321 NSOpenGLContext* share = nil;
322
323 if (ctxconfig->share)
324 share = ctxconfig->share->context.nsgl.object;
325
326 window->context.nsgl.object =
327 [[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
328 shareContext:share];
329 if (window->context.nsgl.object == nil)
330 {
331 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
332 "NSGL: Failed to create OpenGL context");
333 return GLFW_FALSE;
334 }
335
336 if (fbconfig->transparent)
337 {
338 GLint opaque = 0;
339 [window->context.nsgl.object setValues:&opaque
340 forParameter:NSOpenGLContextParameterSurfaceOpacity];
341 }
342
343 [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.scaleFramebuffer];
344
345 [window->context.nsgl.object setView:window->ns.view];
346
347 window->context.makeCurrent = makeContextCurrentNSGL;
348 window->context.swapBuffers = swapBuffersNSGL;
349 window->context.swapInterval = swapIntervalNSGL;
350 window->context.extensionSupported = extensionSupportedNSGL;
351 window->context.getProcAddress = getProcAddressNSGL;
352 window->context.destroy = destroyContextNSGL;
353
354 return GLFW_TRUE;
355}
356
357
358//////////////////////////////////////////////////////////////////////////
359////// GLFW native API //////
360//////////////////////////////////////////////////////////////////////////
361
362GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
363{
364 _GLFWwindow* window = (_GLFWwindow*) handle;
365 _GLFW_REQUIRE_INIT_OR_RETURN(nil);
366
367 if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
368 {
369 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
370 "NSGL: Platform not initialized");
371 return nil;
372 }
373
374 if (window->context.source != GLFW_NATIVE_CONTEXT_API)
375 {
376 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
377 return nil;
378 }
379
380 return window->context.nsgl.object;
381}
382
383#endif // _GLFW_COCOA
384
diff --git a/raylib/src/external/glfw/src/null_init.c b/raylib/src/external/glfw/src/null_init.c
new file mode 100644
index 0000000..88940fc
--- /dev/null
+++ b/raylib/src/external/glfw/src/null_init.c
@@ -0,0 +1,264 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2016 Google Inc.
5// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <stdlib.h>
31#include <string.h>
32
33
34//////////////////////////////////////////////////////////////////////////
35////// GLFW platform API //////
36//////////////////////////////////////////////////////////////////////////
37
38GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
39{
40 const _GLFWplatform null =
41 {
42 .platformID = GLFW_PLATFORM_NULL,
43 .init = _glfwInitNull,
44 .terminate = _glfwTerminateNull,
45 .getCursorPos = _glfwGetCursorPosNull,
46 .setCursorPos = _glfwSetCursorPosNull,
47 .setCursorMode = _glfwSetCursorModeNull,
48 .setRawMouseMotion = _glfwSetRawMouseMotionNull,
49 .rawMouseMotionSupported = _glfwRawMouseMotionSupportedNull,
50 .createCursor = _glfwCreateCursorNull,
51 .createStandardCursor = _glfwCreateStandardCursorNull,
52 .destroyCursor = _glfwDestroyCursorNull,
53 .setCursor = _glfwSetCursorNull,
54 .getScancodeName = _glfwGetScancodeNameNull,
55 .getKeyScancode = _glfwGetKeyScancodeNull,
56 .setClipboardString = _glfwSetClipboardStringNull,
57 .getClipboardString = _glfwGetClipboardStringNull,
58 .initJoysticks = _glfwInitJoysticksNull,
59 .terminateJoysticks = _glfwTerminateJoysticksNull,
60 .pollJoystick = _glfwPollJoystickNull,
61 .getMappingName = _glfwGetMappingNameNull,
62 .updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
63 .freeMonitor = _glfwFreeMonitorNull,
64 .getMonitorPos = _glfwGetMonitorPosNull,
65 .getMonitorContentScale = _glfwGetMonitorContentScaleNull,
66 .getMonitorWorkarea = _glfwGetMonitorWorkareaNull,
67 .getVideoModes = _glfwGetVideoModesNull,
68 .getVideoMode = _glfwGetVideoModeNull,
69 .getGammaRamp = _glfwGetGammaRampNull,
70 .setGammaRamp = _glfwSetGammaRampNull,
71 .createWindow = _glfwCreateWindowNull,
72 .destroyWindow = _glfwDestroyWindowNull,
73 .setWindowTitle = _glfwSetWindowTitleNull,
74 .setWindowIcon = _glfwSetWindowIconNull,
75 .getWindowPos = _glfwGetWindowPosNull,
76 .setWindowPos = _glfwSetWindowPosNull,
77 .getWindowSize = _glfwGetWindowSizeNull,
78 .setWindowSize = _glfwSetWindowSizeNull,
79 .setWindowSizeLimits = _glfwSetWindowSizeLimitsNull,
80 .setWindowAspectRatio = _glfwSetWindowAspectRatioNull,
81 .getFramebufferSize = _glfwGetFramebufferSizeNull,
82 .getWindowFrameSize = _glfwGetWindowFrameSizeNull,
83 .getWindowContentScale = _glfwGetWindowContentScaleNull,
84 .iconifyWindow = _glfwIconifyWindowNull,
85 .restoreWindow = _glfwRestoreWindowNull,
86 .maximizeWindow = _glfwMaximizeWindowNull,
87 .showWindow = _glfwShowWindowNull,
88 .hideWindow = _glfwHideWindowNull,
89 .requestWindowAttention = _glfwRequestWindowAttentionNull,
90 .focusWindow = _glfwFocusWindowNull,
91 .setWindowMonitor = _glfwSetWindowMonitorNull,
92 .windowFocused = _glfwWindowFocusedNull,
93 .windowIconified = _glfwWindowIconifiedNull,
94 .windowVisible = _glfwWindowVisibleNull,
95 .windowMaximized = _glfwWindowMaximizedNull,
96 .windowHovered = _glfwWindowHoveredNull,
97 .framebufferTransparent = _glfwFramebufferTransparentNull,
98 .getWindowOpacity = _glfwGetWindowOpacityNull,
99 .setWindowResizable = _glfwSetWindowResizableNull,
100 .setWindowDecorated = _glfwSetWindowDecoratedNull,
101 .setWindowFloating = _glfwSetWindowFloatingNull,
102 .setWindowOpacity = _glfwSetWindowOpacityNull,
103 .setWindowMousePassthrough = _glfwSetWindowMousePassthroughNull,
104 .pollEvents = _glfwPollEventsNull,
105 .waitEvents = _glfwWaitEventsNull,
106 .waitEventsTimeout = _glfwWaitEventsTimeoutNull,
107 .postEmptyEvent = _glfwPostEmptyEventNull,
108 .getEGLPlatform = _glfwGetEGLPlatformNull,
109 .getEGLNativeDisplay = _glfwGetEGLNativeDisplayNull,
110 .getEGLNativeWindow = _glfwGetEGLNativeWindowNull,
111 .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsNull,
112 .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportNull,
113 .createWindowSurface = _glfwCreateWindowSurfaceNull
114 };
115
116 *platform = null;
117 return GLFW_TRUE;
118}
119
120int _glfwInitNull(void)
121{
122 int scancode;
123
124 memset(_glfw.null.keycodes, -1, sizeof(_glfw.null.keycodes));
125 memset(_glfw.null.scancodes, -1, sizeof(_glfw.null.scancodes));
126
127 _glfw.null.keycodes[GLFW_NULL_SC_SPACE] = GLFW_KEY_SPACE;
128 _glfw.null.keycodes[GLFW_NULL_SC_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
129 _glfw.null.keycodes[GLFW_NULL_SC_COMMA] = GLFW_KEY_COMMA;
130 _glfw.null.keycodes[GLFW_NULL_SC_MINUS] = GLFW_KEY_MINUS;
131 _glfw.null.keycodes[GLFW_NULL_SC_PERIOD] = GLFW_KEY_PERIOD;
132 _glfw.null.keycodes[GLFW_NULL_SC_SLASH] = GLFW_KEY_SLASH;
133 _glfw.null.keycodes[GLFW_NULL_SC_0] = GLFW_KEY_0;
134 _glfw.null.keycodes[GLFW_NULL_SC_1] = GLFW_KEY_1;
135 _glfw.null.keycodes[GLFW_NULL_SC_2] = GLFW_KEY_2;
136 _glfw.null.keycodes[GLFW_NULL_SC_3] = GLFW_KEY_3;
137 _glfw.null.keycodes[GLFW_NULL_SC_4] = GLFW_KEY_4;
138 _glfw.null.keycodes[GLFW_NULL_SC_5] = GLFW_KEY_5;
139 _glfw.null.keycodes[GLFW_NULL_SC_6] = GLFW_KEY_6;
140 _glfw.null.keycodes[GLFW_NULL_SC_7] = GLFW_KEY_7;
141 _glfw.null.keycodes[GLFW_NULL_SC_8] = GLFW_KEY_8;
142 _glfw.null.keycodes[GLFW_NULL_SC_9] = GLFW_KEY_9;
143 _glfw.null.keycodes[GLFW_NULL_SC_SEMICOLON] = GLFW_KEY_SEMICOLON;
144 _glfw.null.keycodes[GLFW_NULL_SC_EQUAL] = GLFW_KEY_EQUAL;
145 _glfw.null.keycodes[GLFW_NULL_SC_A] = GLFW_KEY_A;
146 _glfw.null.keycodes[GLFW_NULL_SC_B] = GLFW_KEY_B;
147 _glfw.null.keycodes[GLFW_NULL_SC_C] = GLFW_KEY_C;
148 _glfw.null.keycodes[GLFW_NULL_SC_D] = GLFW_KEY_D;
149 _glfw.null.keycodes[GLFW_NULL_SC_E] = GLFW_KEY_E;
150 _glfw.null.keycodes[GLFW_NULL_SC_F] = GLFW_KEY_F;
151 _glfw.null.keycodes[GLFW_NULL_SC_G] = GLFW_KEY_G;
152 _glfw.null.keycodes[GLFW_NULL_SC_H] = GLFW_KEY_H;
153 _glfw.null.keycodes[GLFW_NULL_SC_I] = GLFW_KEY_I;
154 _glfw.null.keycodes[GLFW_NULL_SC_J] = GLFW_KEY_J;
155 _glfw.null.keycodes[GLFW_NULL_SC_K] = GLFW_KEY_K;
156 _glfw.null.keycodes[GLFW_NULL_SC_L] = GLFW_KEY_L;
157 _glfw.null.keycodes[GLFW_NULL_SC_M] = GLFW_KEY_M;
158 _glfw.null.keycodes[GLFW_NULL_SC_N] = GLFW_KEY_N;
159 _glfw.null.keycodes[GLFW_NULL_SC_O] = GLFW_KEY_O;
160 _glfw.null.keycodes[GLFW_NULL_SC_P] = GLFW_KEY_P;
161 _glfw.null.keycodes[GLFW_NULL_SC_Q] = GLFW_KEY_Q;
162 _glfw.null.keycodes[GLFW_NULL_SC_R] = GLFW_KEY_R;
163 _glfw.null.keycodes[GLFW_NULL_SC_S] = GLFW_KEY_S;
164 _glfw.null.keycodes[GLFW_NULL_SC_T] = GLFW_KEY_T;
165 _glfw.null.keycodes[GLFW_NULL_SC_U] = GLFW_KEY_U;
166 _glfw.null.keycodes[GLFW_NULL_SC_V] = GLFW_KEY_V;
167 _glfw.null.keycodes[GLFW_NULL_SC_W] = GLFW_KEY_W;
168 _glfw.null.keycodes[GLFW_NULL_SC_X] = GLFW_KEY_X;
169 _glfw.null.keycodes[GLFW_NULL_SC_Y] = GLFW_KEY_Y;
170 _glfw.null.keycodes[GLFW_NULL_SC_Z] = GLFW_KEY_Z;
171 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_BRACKET] = GLFW_KEY_LEFT_BRACKET;
172 _glfw.null.keycodes[GLFW_NULL_SC_BACKSLASH] = GLFW_KEY_BACKSLASH;
173 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_BRACKET] = GLFW_KEY_RIGHT_BRACKET;
174 _glfw.null.keycodes[GLFW_NULL_SC_GRAVE_ACCENT] = GLFW_KEY_GRAVE_ACCENT;
175 _glfw.null.keycodes[GLFW_NULL_SC_WORLD_1] = GLFW_KEY_WORLD_1;
176 _glfw.null.keycodes[GLFW_NULL_SC_WORLD_2] = GLFW_KEY_WORLD_2;
177 _glfw.null.keycodes[GLFW_NULL_SC_ESCAPE] = GLFW_KEY_ESCAPE;
178 _glfw.null.keycodes[GLFW_NULL_SC_ENTER] = GLFW_KEY_ENTER;
179 _glfw.null.keycodes[GLFW_NULL_SC_TAB] = GLFW_KEY_TAB;
180 _glfw.null.keycodes[GLFW_NULL_SC_BACKSPACE] = GLFW_KEY_BACKSPACE;
181 _glfw.null.keycodes[GLFW_NULL_SC_INSERT] = GLFW_KEY_INSERT;
182 _glfw.null.keycodes[GLFW_NULL_SC_DELETE] = GLFW_KEY_DELETE;
183 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT] = GLFW_KEY_RIGHT;
184 _glfw.null.keycodes[GLFW_NULL_SC_LEFT] = GLFW_KEY_LEFT;
185 _glfw.null.keycodes[GLFW_NULL_SC_DOWN] = GLFW_KEY_DOWN;
186 _glfw.null.keycodes[GLFW_NULL_SC_UP] = GLFW_KEY_UP;
187 _glfw.null.keycodes[GLFW_NULL_SC_PAGE_UP] = GLFW_KEY_PAGE_UP;
188 _glfw.null.keycodes[GLFW_NULL_SC_PAGE_DOWN] = GLFW_KEY_PAGE_DOWN;
189 _glfw.null.keycodes[GLFW_NULL_SC_HOME] = GLFW_KEY_HOME;
190 _glfw.null.keycodes[GLFW_NULL_SC_END] = GLFW_KEY_END;
191 _glfw.null.keycodes[GLFW_NULL_SC_CAPS_LOCK] = GLFW_KEY_CAPS_LOCK;
192 _glfw.null.keycodes[GLFW_NULL_SC_SCROLL_LOCK] = GLFW_KEY_SCROLL_LOCK;
193 _glfw.null.keycodes[GLFW_NULL_SC_NUM_LOCK] = GLFW_KEY_NUM_LOCK;
194 _glfw.null.keycodes[GLFW_NULL_SC_PRINT_SCREEN] = GLFW_KEY_PRINT_SCREEN;
195 _glfw.null.keycodes[GLFW_NULL_SC_PAUSE] = GLFW_KEY_PAUSE;
196 _glfw.null.keycodes[GLFW_NULL_SC_F1] = GLFW_KEY_F1;
197 _glfw.null.keycodes[GLFW_NULL_SC_F2] = GLFW_KEY_F2;
198 _glfw.null.keycodes[GLFW_NULL_SC_F3] = GLFW_KEY_F3;
199 _glfw.null.keycodes[GLFW_NULL_SC_F4] = GLFW_KEY_F4;
200 _glfw.null.keycodes[GLFW_NULL_SC_F5] = GLFW_KEY_F5;
201 _glfw.null.keycodes[GLFW_NULL_SC_F6] = GLFW_KEY_F6;
202 _glfw.null.keycodes[GLFW_NULL_SC_F7] = GLFW_KEY_F7;
203 _glfw.null.keycodes[GLFW_NULL_SC_F8] = GLFW_KEY_F8;
204 _glfw.null.keycodes[GLFW_NULL_SC_F9] = GLFW_KEY_F9;
205 _glfw.null.keycodes[GLFW_NULL_SC_F10] = GLFW_KEY_F10;
206 _glfw.null.keycodes[GLFW_NULL_SC_F11] = GLFW_KEY_F11;
207 _glfw.null.keycodes[GLFW_NULL_SC_F12] = GLFW_KEY_F12;
208 _glfw.null.keycodes[GLFW_NULL_SC_F13] = GLFW_KEY_F13;
209 _glfw.null.keycodes[GLFW_NULL_SC_F14] = GLFW_KEY_F14;
210 _glfw.null.keycodes[GLFW_NULL_SC_F15] = GLFW_KEY_F15;
211 _glfw.null.keycodes[GLFW_NULL_SC_F16] = GLFW_KEY_F16;
212 _glfw.null.keycodes[GLFW_NULL_SC_F17] = GLFW_KEY_F17;
213 _glfw.null.keycodes[GLFW_NULL_SC_F18] = GLFW_KEY_F18;
214 _glfw.null.keycodes[GLFW_NULL_SC_F19] = GLFW_KEY_F19;
215 _glfw.null.keycodes[GLFW_NULL_SC_F20] = GLFW_KEY_F20;
216 _glfw.null.keycodes[GLFW_NULL_SC_F21] = GLFW_KEY_F21;
217 _glfw.null.keycodes[GLFW_NULL_SC_F22] = GLFW_KEY_F22;
218 _glfw.null.keycodes[GLFW_NULL_SC_F23] = GLFW_KEY_F23;
219 _glfw.null.keycodes[GLFW_NULL_SC_F24] = GLFW_KEY_F24;
220 _glfw.null.keycodes[GLFW_NULL_SC_F25] = GLFW_KEY_F25;
221 _glfw.null.keycodes[GLFW_NULL_SC_KP_0] = GLFW_KEY_KP_0;
222 _glfw.null.keycodes[GLFW_NULL_SC_KP_1] = GLFW_KEY_KP_1;
223 _glfw.null.keycodes[GLFW_NULL_SC_KP_2] = GLFW_KEY_KP_2;
224 _glfw.null.keycodes[GLFW_NULL_SC_KP_3] = GLFW_KEY_KP_3;
225 _glfw.null.keycodes[GLFW_NULL_SC_KP_4] = GLFW_KEY_KP_4;
226 _glfw.null.keycodes[GLFW_NULL_SC_KP_5] = GLFW_KEY_KP_5;
227 _glfw.null.keycodes[GLFW_NULL_SC_KP_6] = GLFW_KEY_KP_6;
228 _glfw.null.keycodes[GLFW_NULL_SC_KP_7] = GLFW_KEY_KP_7;
229 _glfw.null.keycodes[GLFW_NULL_SC_KP_8] = GLFW_KEY_KP_8;
230 _glfw.null.keycodes[GLFW_NULL_SC_KP_9] = GLFW_KEY_KP_9;
231 _glfw.null.keycodes[GLFW_NULL_SC_KP_DECIMAL] = GLFW_KEY_KP_DECIMAL;
232 _glfw.null.keycodes[GLFW_NULL_SC_KP_DIVIDE] = GLFW_KEY_KP_DIVIDE;
233 _glfw.null.keycodes[GLFW_NULL_SC_KP_MULTIPLY] = GLFW_KEY_KP_MULTIPLY;
234 _glfw.null.keycodes[GLFW_NULL_SC_KP_SUBTRACT] = GLFW_KEY_KP_SUBTRACT;
235 _glfw.null.keycodes[GLFW_NULL_SC_KP_ADD] = GLFW_KEY_KP_ADD;
236 _glfw.null.keycodes[GLFW_NULL_SC_KP_ENTER] = GLFW_KEY_KP_ENTER;
237 _glfw.null.keycodes[GLFW_NULL_SC_KP_EQUAL] = GLFW_KEY_KP_EQUAL;
238 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_SHIFT] = GLFW_KEY_LEFT_SHIFT;
239 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_CONTROL] = GLFW_KEY_LEFT_CONTROL;
240 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_ALT] = GLFW_KEY_LEFT_ALT;
241 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_SUPER] = GLFW_KEY_LEFT_SUPER;
242 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SHIFT] = GLFW_KEY_RIGHT_SHIFT;
243 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_CONTROL] = GLFW_KEY_RIGHT_CONTROL;
244 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_ALT] = GLFW_KEY_RIGHT_ALT;
245 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SUPER] = GLFW_KEY_RIGHT_SUPER;
246 _glfw.null.keycodes[GLFW_NULL_SC_MENU] = GLFW_KEY_MENU;
247
248 for (scancode = GLFW_NULL_SC_FIRST; scancode < GLFW_NULL_SC_LAST; scancode++)
249 {
250 if (_glfw.null.keycodes[scancode] > 0)
251 _glfw.null.scancodes[_glfw.null.keycodes[scancode]] = scancode;
252 }
253
254 _glfwPollMonitorsNull();
255 return GLFW_TRUE;
256}
257
258void _glfwTerminateNull(void)
259{
260 free(_glfw.null.clipboardString);
261 _glfwTerminateOSMesa();
262 _glfwTerminateEGL();
263}
264
diff --git a/raylib/src/external/glfw/src/null_joystick.c b/raylib/src/external/glfw/src/null_joystick.c
new file mode 100644
index 0000000..ec1f6b5
--- /dev/null
+++ b/raylib/src/external/glfw/src/null_joystick.c
@@ -0,0 +1,56 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include "internal.h"
28
29
30//////////////////////////////////////////////////////////////////////////
31////// GLFW platform API //////
32//////////////////////////////////////////////////////////////////////////
33
34GLFWbool _glfwInitJoysticksNull(void)
35{
36 return GLFW_TRUE;
37}
38
39void _glfwTerminateJoysticksNull(void)
40{
41}
42
43GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode)
44{
45 return GLFW_FALSE;
46}
47
48const char* _glfwGetMappingNameNull(void)
49{
50 return "";
51}
52
53void _glfwUpdateGamepadGUIDNull(char* guid)
54{
55}
56
diff --git a/raylib/src/external/glfw/src/null_joystick.h b/raylib/src/external/glfw/src/null_joystick.h
new file mode 100644
index 0000000..a2199c5
--- /dev/null
+++ b/raylib/src/external/glfw/src/null_joystick.h
@@ -0,0 +1,32 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27GLFWbool _glfwInitJoysticksNull(void);
28void _glfwTerminateJoysticksNull(void);
29GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode);
30const char* _glfwGetMappingNameNull(void);
31void _glfwUpdateGamepadGUIDNull(char* guid);
32
diff --git a/raylib/src/external/glfw/src/null_monitor.c b/raylib/src/external/glfw/src/null_monitor.c
new file mode 100644
index 0000000..d818f45
--- /dev/null
+++ b/raylib/src/external/glfw/src/null_monitor.c
@@ -0,0 +1,160 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2016 Google Inc.
5// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <stdlib.h>
31#include <string.h>
32#include <math.h>
33
34// The the sole (fake) video mode of our (sole) fake monitor
35//
36static GLFWvidmode getVideoMode(void)
37{
38 GLFWvidmode mode;
39 mode.width = 1920;
40 mode.height = 1080;
41 mode.redBits = 8;
42 mode.greenBits = 8;
43 mode.blueBits = 8;
44 mode.refreshRate = 60;
45 return mode;
46}
47
48//////////////////////////////////////////////////////////////////////////
49////// GLFW internal API //////
50//////////////////////////////////////////////////////////////////////////
51
52void _glfwPollMonitorsNull(void)
53{
54 const float dpi = 141.f;
55 const GLFWvidmode mode = getVideoMode();
56 _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
57 (int) (mode.width * 25.4f / dpi),
58 (int) (mode.height * 25.4f / dpi));
59 _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
60}
61
62//////////////////////////////////////////////////////////////////////////
63////// GLFW platform API //////
64//////////////////////////////////////////////////////////////////////////
65
66void _glfwFreeMonitorNull(_GLFWmonitor* monitor)
67{
68 _glfwFreeGammaArrays(&monitor->null.ramp);
69}
70
71void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos)
72{
73 if (xpos)
74 *xpos = 0;
75 if (ypos)
76 *ypos = 0;
77}
78
79void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor,
80 float* xscale, float* yscale)
81{
82 if (xscale)
83 *xscale = 1.f;
84 if (yscale)
85 *yscale = 1.f;
86}
87
88void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
89 int* xpos, int* ypos,
90 int* width, int* height)
91{
92 const GLFWvidmode mode = getVideoMode();
93
94 if (xpos)
95 *xpos = 0;
96 if (ypos)
97 *ypos = 10;
98 if (width)
99 *width = mode.width;
100 if (height)
101 *height = mode.height - 10;
102}
103
104GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
105{
106 GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
107 *mode = getVideoMode();
108 *found = 1;
109 return mode;
110}
111
112GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
113{
114 *mode = getVideoMode();
115 return GLFW_TRUE;
116}
117
118GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
119{
120 if (!monitor->null.ramp.size)
121 {
122 unsigned int i;
123
124 _glfwAllocGammaArrays(&monitor->null.ramp, 256);
125
126 for (i = 0; i < monitor->null.ramp.size; i++)
127 {
128 const float gamma = 2.2f;
129 float value;
130 value = i / (float) (monitor->null.ramp.size - 1);
131 value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
132 value = fminf(value, 65535.f);
133
134 monitor->null.ramp.red[i] = (unsigned short) value;
135 monitor->null.ramp.green[i] = (unsigned short) value;
136 monitor->null.ramp.blue[i] = (unsigned short) value;
137 }
138 }
139
140 _glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
141 memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size);
142 memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
143 memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size);
144 return GLFW_TRUE;
145}
146
147void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
148{
149 if (monitor->null.ramp.size != ramp->size)
150 {
151 _glfwInputError(GLFW_PLATFORM_ERROR,
152 "Null: Gamma ramp size must match current ramp size");
153 return;
154 }
155
156 memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size);
157 memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
158 memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size);
159}
160
diff --git a/raylib/src/external/glfw/src/null_platform.h b/raylib/src/external/glfw/src/null_platform.h
new file mode 100644
index 0000000..4843a76
--- /dev/null
+++ b/raylib/src/external/glfw/src/null_platform.h
@@ -0,0 +1,271 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2016 Google Inc.
5// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#define GLFW_NULL_WINDOW_STATE _GLFWwindowNull null;
29#define GLFW_NULL_LIBRARY_WINDOW_STATE _GLFWlibraryNull null;
30#define GLFW_NULL_MONITOR_STATE _GLFWmonitorNull null;
31
32#define GLFW_NULL_CONTEXT_STATE
33#define GLFW_NULL_CURSOR_STATE
34#define GLFW_NULL_LIBRARY_CONTEXT_STATE
35
36#define GLFW_NULL_SC_FIRST GLFW_NULL_SC_SPACE
37#define GLFW_NULL_SC_SPACE 1
38#define GLFW_NULL_SC_APOSTROPHE 2
39#define GLFW_NULL_SC_COMMA 3
40#define GLFW_NULL_SC_MINUS 4
41#define GLFW_NULL_SC_PERIOD 5
42#define GLFW_NULL_SC_SLASH 6
43#define GLFW_NULL_SC_0 7
44#define GLFW_NULL_SC_1 8
45#define GLFW_NULL_SC_2 9
46#define GLFW_NULL_SC_3 10
47#define GLFW_NULL_SC_4 11
48#define GLFW_NULL_SC_5 12
49#define GLFW_NULL_SC_6 13
50#define GLFW_NULL_SC_7 14
51#define GLFW_NULL_SC_8 15
52#define GLFW_NULL_SC_9 16
53#define GLFW_NULL_SC_SEMICOLON 17
54#define GLFW_NULL_SC_EQUAL 18
55#define GLFW_NULL_SC_LEFT_BRACKET 19
56#define GLFW_NULL_SC_BACKSLASH 20
57#define GLFW_NULL_SC_RIGHT_BRACKET 21
58#define GLFW_NULL_SC_GRAVE_ACCENT 22
59#define GLFW_NULL_SC_WORLD_1 23
60#define GLFW_NULL_SC_WORLD_2 24
61#define GLFW_NULL_SC_ESCAPE 25
62#define GLFW_NULL_SC_ENTER 26
63#define GLFW_NULL_SC_TAB 27
64#define GLFW_NULL_SC_BACKSPACE 28
65#define GLFW_NULL_SC_INSERT 29
66#define GLFW_NULL_SC_DELETE 30
67#define GLFW_NULL_SC_RIGHT 31
68#define GLFW_NULL_SC_LEFT 32
69#define GLFW_NULL_SC_DOWN 33
70#define GLFW_NULL_SC_UP 34
71#define GLFW_NULL_SC_PAGE_UP 35
72#define GLFW_NULL_SC_PAGE_DOWN 36
73#define GLFW_NULL_SC_HOME 37
74#define GLFW_NULL_SC_END 38
75#define GLFW_NULL_SC_CAPS_LOCK 39
76#define GLFW_NULL_SC_SCROLL_LOCK 40
77#define GLFW_NULL_SC_NUM_LOCK 41
78#define GLFW_NULL_SC_PRINT_SCREEN 42
79#define GLFW_NULL_SC_PAUSE 43
80#define GLFW_NULL_SC_A 44
81#define GLFW_NULL_SC_B 45
82#define GLFW_NULL_SC_C 46
83#define GLFW_NULL_SC_D 47
84#define GLFW_NULL_SC_E 48
85#define GLFW_NULL_SC_F 49
86#define GLFW_NULL_SC_G 50
87#define GLFW_NULL_SC_H 51
88#define GLFW_NULL_SC_I 52
89#define GLFW_NULL_SC_J 53
90#define GLFW_NULL_SC_K 54
91#define GLFW_NULL_SC_L 55
92#define GLFW_NULL_SC_M 56
93#define GLFW_NULL_SC_N 57
94#define GLFW_NULL_SC_O 58
95#define GLFW_NULL_SC_P 59
96#define GLFW_NULL_SC_Q 60
97#define GLFW_NULL_SC_R 61
98#define GLFW_NULL_SC_S 62
99#define GLFW_NULL_SC_T 63
100#define GLFW_NULL_SC_U 64
101#define GLFW_NULL_SC_V 65
102#define GLFW_NULL_SC_W 66
103#define GLFW_NULL_SC_X 67
104#define GLFW_NULL_SC_Y 68
105#define GLFW_NULL_SC_Z 69
106#define GLFW_NULL_SC_F1 70
107#define GLFW_NULL_SC_F2 71
108#define GLFW_NULL_SC_F3 72
109#define GLFW_NULL_SC_F4 73
110#define GLFW_NULL_SC_F5 74
111#define GLFW_NULL_SC_F6 75
112#define GLFW_NULL_SC_F7 76
113#define GLFW_NULL_SC_F8 77
114#define GLFW_NULL_SC_F9 78
115#define GLFW_NULL_SC_F10 79
116#define GLFW_NULL_SC_F11 80
117#define GLFW_NULL_SC_F12 81
118#define GLFW_NULL_SC_F13 82
119#define GLFW_NULL_SC_F14 83
120#define GLFW_NULL_SC_F15 84
121#define GLFW_NULL_SC_F16 85
122#define GLFW_NULL_SC_F17 86
123#define GLFW_NULL_SC_F18 87
124#define GLFW_NULL_SC_F19 88
125#define GLFW_NULL_SC_F20 89
126#define GLFW_NULL_SC_F21 90
127#define GLFW_NULL_SC_F22 91
128#define GLFW_NULL_SC_F23 92
129#define GLFW_NULL_SC_F24 93
130#define GLFW_NULL_SC_F25 94
131#define GLFW_NULL_SC_KP_0 95
132#define GLFW_NULL_SC_KP_1 96
133#define GLFW_NULL_SC_KP_2 97
134#define GLFW_NULL_SC_KP_3 98
135#define GLFW_NULL_SC_KP_4 99
136#define GLFW_NULL_SC_KP_5 100
137#define GLFW_NULL_SC_KP_6 101
138#define GLFW_NULL_SC_KP_7 102
139#define GLFW_NULL_SC_KP_8 103
140#define GLFW_NULL_SC_KP_9 104
141#define GLFW_NULL_SC_KP_DECIMAL 105
142#define GLFW_NULL_SC_KP_DIVIDE 106
143#define GLFW_NULL_SC_KP_MULTIPLY 107
144#define GLFW_NULL_SC_KP_SUBTRACT 108
145#define GLFW_NULL_SC_KP_ADD 109
146#define GLFW_NULL_SC_KP_ENTER 110
147#define GLFW_NULL_SC_KP_EQUAL 111
148#define GLFW_NULL_SC_LEFT_SHIFT 112
149#define GLFW_NULL_SC_LEFT_CONTROL 113
150#define GLFW_NULL_SC_LEFT_ALT 114
151#define GLFW_NULL_SC_LEFT_SUPER 115
152#define GLFW_NULL_SC_RIGHT_SHIFT 116
153#define GLFW_NULL_SC_RIGHT_CONTROL 117
154#define GLFW_NULL_SC_RIGHT_ALT 118
155#define GLFW_NULL_SC_RIGHT_SUPER 119
156#define GLFW_NULL_SC_MENU 120
157#define GLFW_NULL_SC_LAST GLFW_NULL_SC_MENU
158
159// Null-specific per-window data
160//
161typedef struct _GLFWwindowNull
162{
163 int xpos;
164 int ypos;
165 int width;
166 int height;
167 GLFWbool visible;
168 GLFWbool iconified;
169 GLFWbool maximized;
170 GLFWbool resizable;
171 GLFWbool decorated;
172 GLFWbool floating;
173 GLFWbool transparent;
174 float opacity;
175} _GLFWwindowNull;
176
177// Null-specific per-monitor data
178//
179typedef struct _GLFWmonitorNull
180{
181 GLFWgammaramp ramp;
182} _GLFWmonitorNull;
183
184// Null-specific global data
185//
186typedef struct _GLFWlibraryNull
187{
188 int xcursor;
189 int ycursor;
190 char* clipboardString;
191 _GLFWwindow* focusedWindow;
192 uint16_t keycodes[GLFW_NULL_SC_LAST + 1];
193 uint8_t scancodes[GLFW_KEY_LAST + 1];
194} _GLFWlibraryNull;
195
196void _glfwPollMonitorsNull(void);
197
198GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform);
199int _glfwInitNull(void);
200void _glfwTerminateNull(void);
201
202void _glfwFreeMonitorNull(_GLFWmonitor* monitor);
203void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
204void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
205void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
206GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
207GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
208GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
209void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
210
211GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
212void _glfwDestroyWindowNull(_GLFWwindow* window);
213void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
214void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
215void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
216void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
217void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
218void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height);
219void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height);
220void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
221void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d);
222void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height);
223void _glfwGetWindowFrameSizeNull(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
224void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale);
225void _glfwIconifyWindowNull(_GLFWwindow* window);
226void _glfwRestoreWindowNull(_GLFWwindow* window);
227void _glfwMaximizeWindowNull(_GLFWwindow* window);
228GLFWbool _glfwWindowMaximizedNull(_GLFWwindow* window);
229GLFWbool _glfwWindowHoveredNull(_GLFWwindow* window);
230GLFWbool _glfwFramebufferTransparentNull(_GLFWwindow* window);
231void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled);
232void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
233void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
234void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled);
235float _glfwGetWindowOpacityNull(_GLFWwindow* window);
236void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity);
237void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled);
238GLFWbool _glfwRawMouseMotionSupportedNull(void);
239void _glfwShowWindowNull(_GLFWwindow* window);
240void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
241void _glfwHideWindowNull(_GLFWwindow* window);
242void _glfwFocusWindowNull(_GLFWwindow* window);
243GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window);
244GLFWbool _glfwWindowIconifiedNull(_GLFWwindow* window);
245GLFWbool _glfwWindowVisibleNull(_GLFWwindow* window);
246void _glfwPollEventsNull(void);
247void _glfwWaitEventsNull(void);
248void _glfwWaitEventsTimeoutNull(double timeout);
249void _glfwPostEmptyEventNull(void);
250void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos);
251void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y);
252void _glfwSetCursorModeNull(_GLFWwindow* window, int mode);
253GLFWbool _glfwCreateCursorNull(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
254GLFWbool _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape);
255void _glfwDestroyCursorNull(_GLFWcursor* cursor);
256void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor);
257void _glfwSetClipboardStringNull(const char* string);
258const char* _glfwGetClipboardStringNull(void);
259const char* _glfwGetScancodeNameNull(int scancode);
260int _glfwGetKeyScancodeNull(int key);
261
262EGLenum _glfwGetEGLPlatformNull(EGLint** attribs);
263EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void);
264EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window);
265
266void _glfwGetRequiredInstanceExtensionsNull(char** extensions);
267GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
268VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
269
270void _glfwPollMonitorsNull(void);
271
diff --git a/raylib/src/external/glfw/src/null_window.c b/raylib/src/external/glfw/src/null_window.c
new file mode 100644
index 0000000..cd23ae0
--- /dev/null
+++ b/raylib/src/external/glfw/src/null_window.c
@@ -0,0 +1,720 @@
1//========================================================================
2// GLFW 3.4 (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2016 Google Inc.
5// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#include <stdlib.h>
32
33static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
34{
35 if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
36 {
37 const float ratio = (float) window->numer / (float) window->denom;
38 *height = (int) (*width / ratio);
39 }
40
41 if (window->minwidth != GLFW_DONT_CARE)
42 *width = _glfw_max(*width, window->minwidth);
43 else if (window->maxwidth != GLFW_DONT_CARE)
44 *width = _glfw_min(*width, window->maxwidth);
45
46 if (window->minheight != GLFW_DONT_CARE)
47 *height = _glfw_min(*height, window->minheight);
48 else if (window->maxheight != GLFW_DONT_CARE)
49 *height = _glfw_max(*height, window->maxheight);
50}
51
52static void fitToMonitor(_GLFWwindow* window)
53{
54 GLFWvidmode mode;
55 _glfwGetVideoModeNull(window->monitor, &mode);
56 _glfwGetMonitorPosNull(window->monitor,
57 &window->null.xpos,
58 &window->null.ypos);
59 window->null.width = mode.width;
60 window->null.height = mode.height;
61}
62
63static void acquireMonitorNull(_GLFWwindow* window)
64{
65 _glfwInputMonitorWindow(window->monitor, window);
66}
67
68static void releaseMonitorNull(_GLFWwindow* window)
69{
70 if (window->monitor->window != window)
71 return;
72
73 _glfwInputMonitorWindow(window->monitor, NULL);
74}
75
76static int createNativeWindow(_GLFWwindow* window,
77 const _GLFWwndconfig* wndconfig,
78 const _GLFWfbconfig* fbconfig)
79{
80 if (window->monitor)
81 fitToMonitor(window);
82 else
83 {
84 if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
85 {
86 window->null.xpos = 17;
87 window->null.ypos = 17;
88 }
89 else
90 {
91 window->null.xpos = wndconfig->xpos;
92 window->null.ypos = wndconfig->ypos;
93 }
94
95 window->null.width = wndconfig->width;
96 window->null.height = wndconfig->height;
97 }
98
99 window->null.visible = wndconfig->visible;
100 window->null.decorated = wndconfig->decorated;
101 window->null.maximized = wndconfig->maximized;
102 window->null.floating = wndconfig->floating;
103 window->null.transparent = fbconfig->transparent;
104 window->null.opacity = 1.f;
105
106 return GLFW_TRUE;
107}
108
109
110//////////////////////////////////////////////////////////////////////////
111////// GLFW platform API //////
112//////////////////////////////////////////////////////////////////////////
113
114GLFWbool _glfwCreateWindowNull(_GLFWwindow* window,
115 const _GLFWwndconfig* wndconfig,
116 const _GLFWctxconfig* ctxconfig,
117 const _GLFWfbconfig* fbconfig)
118{
119 if (!createNativeWindow(window, wndconfig, fbconfig))
120 return GLFW_FALSE;
121
122 if (ctxconfig->client != GLFW_NO_API)
123 {
124 if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
125 ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
126 {
127 if (!_glfwInitOSMesa())
128 return GLFW_FALSE;
129 if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
130 return GLFW_FALSE;
131 }
132 else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
133 {
134 if (!_glfwInitEGL())
135 return GLFW_FALSE;
136 if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
137 return GLFW_FALSE;
138 }
139
140 if (!_glfwRefreshContextAttribs(window, ctxconfig))
141 return GLFW_FALSE;
142 }
143
144 if (wndconfig->mousePassthrough)
145 _glfwSetWindowMousePassthroughNull(window, GLFW_TRUE);
146
147 if (window->monitor)
148 {
149 _glfwShowWindowNull(window);
150 _glfwFocusWindowNull(window);
151 acquireMonitorNull(window);
152
153 if (wndconfig->centerCursor)
154 _glfwCenterCursorInContentArea(window);
155 }
156 else
157 {
158 if (wndconfig->visible)
159 {
160 _glfwShowWindowNull(window);
161 if (wndconfig->focused)
162 _glfwFocusWindowNull(window);
163 }
164 }
165
166 return GLFW_TRUE;
167}
168
169void _glfwDestroyWindowNull(_GLFWwindow* window)
170{
171 if (window->monitor)
172 releaseMonitorNull(window);
173
174 if (_glfw.null.focusedWindow == window)
175 _glfw.null.focusedWindow = NULL;
176
177 if (window->context.destroy)
178 window->context.destroy(window);
179}
180
181void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title)
182{
183}
184
185void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images)
186{
187}
188
189void _glfwSetWindowMonitorNull(_GLFWwindow* window,
190 _GLFWmonitor* monitor,
191 int xpos, int ypos,
192 int width, int height,
193 int refreshRate)
194{
195 if (window->monitor == monitor)
196 {
197 if (!monitor)
198 {
199 _glfwSetWindowPosNull(window, xpos, ypos);
200 _glfwSetWindowSizeNull(window, width, height);
201 }
202
203 return;
204 }
205
206 if (window->monitor)
207 releaseMonitorNull(window);
208
209 _glfwInputWindowMonitor(window, monitor);
210
211 if (window->monitor)
212 {
213 window->null.visible = GLFW_TRUE;
214 acquireMonitorNull(window);
215 fitToMonitor(window);
216 }
217 else
218 {
219 _glfwSetWindowPosNull(window, xpos, ypos);
220 _glfwSetWindowSizeNull(window, width, height);
221 }
222}
223
224void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos)
225{
226 if (xpos)
227 *xpos = window->null.xpos;
228 if (ypos)
229 *ypos = window->null.ypos;
230}
231
232void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos)
233{
234 if (window->monitor)
235 return;
236
237 if (window->null.xpos != xpos || window->null.ypos != ypos)
238 {
239 window->null.xpos = xpos;
240 window->null.ypos = ypos;
241 _glfwInputWindowPos(window, xpos, ypos);
242 }
243}
244
245void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height)
246{
247 if (width)
248 *width = window->null.width;
249 if (height)
250 *height = window->null.height;
251}
252
253void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height)
254{
255 if (window->monitor)
256 return;
257
258 if (window->null.width != width || window->null.height != height)
259 {
260 window->null.width = width;
261 window->null.height = height;
262 _glfwInputFramebufferSize(window, width, height);
263 _glfwInputWindowDamage(window);
264 _glfwInputWindowSize(window, width, height);
265 }
266}
267
268void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window,
269 int minwidth, int minheight,
270 int maxwidth, int maxheight)
271{
272 int width = window->null.width;
273 int height = window->null.height;
274 applySizeLimits(window, &width, &height);
275 _glfwSetWindowSizeNull(window, width, height);
276}
277
278void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d)
279{
280 int width = window->null.width;
281 int height = window->null.height;
282 applySizeLimits(window, &width, &height);
283 _glfwSetWindowSizeNull(window, width, height);
284}
285
286void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height)
287{
288 if (width)
289 *width = window->null.width;
290 if (height)
291 *height = window->null.height;
292}
293
294void _glfwGetWindowFrameSizeNull(_GLFWwindow* window,
295 int* left, int* top,
296 int* right, int* bottom)
297{
298 if (window->null.decorated && !window->monitor)
299 {
300 if (left)
301 *left = 1;
302 if (top)
303 *top = 10;
304 if (right)
305 *right = 1;
306 if (bottom)
307 *bottom = 1;
308 }
309 else
310 {
311 if (left)
312 *left = 0;
313 if (top)
314 *top = 0;
315 if (right)
316 *right = 0;
317 if (bottom)
318 *bottom = 0;
319 }
320}
321
322void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale)
323{
324 if (xscale)
325 *xscale = 1.f;
326 if (yscale)
327 *yscale = 1.f;
328}
329
330void _glfwIconifyWindowNull(_GLFWwindow* window)
331{
332 if (_glfw.null.focusedWindow == window)
333 {
334 _glfw.null.focusedWindow = NULL;
335 _glfwInputWindowFocus(window, GLFW_FALSE);
336 }
337
338 if (!window->null.iconified)
339 {
340 window->null.iconified = GLFW_TRUE;
341 _glfwInputWindowIconify(window, GLFW_TRUE);
342
343 if (window->monitor)
344 releaseMonitorNull(window);
345 }
346}
347
348void _glfwRestoreWindowNull(_GLFWwindow* window)
349{
350 if (window->null.iconified)
351 {
352 window->null.iconified = GLFW_FALSE;
353 _glfwInputWindowIconify(window, GLFW_FALSE);
354
355 if (window->monitor)
356 acquireMonitorNull(window);
357 }
358 else if (window->null.maximized)
359 {
360 window->null.maximized = GLFW_FALSE;
361 _glfwInputWindowMaximize(window, GLFW_FALSE);
362 }
363}
364
365void _glfwMaximizeWindowNull(_GLFWwindow* window)
366{
367 if (!window->null.maximized)
368 {
369 window->null.maximized = GLFW_TRUE;
370 _glfwInputWindowMaximize(window, GLFW_TRUE);
371 }
372}
373
374GLFWbool _glfwWindowMaximizedNull(_GLFWwindow* window)
375{
376 return window->null.maximized;
377}
378
379GLFWbool _glfwWindowHoveredNull(_GLFWwindow* window)
380{
381 return _glfw.null.xcursor >= window->null.xpos &&
382 _glfw.null.ycursor >= window->null.ypos &&
383 _glfw.null.xcursor <= window->null.xpos + window->null.width - 1 &&
384 _glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
385}
386
387GLFWbool _glfwFramebufferTransparentNull(_GLFWwindow* window)
388{
389 return window->null.transparent;
390}
391
392void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled)
393{
394 window->null.resizable = enabled;
395}
396
397void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled)
398{
399 window->null.decorated = enabled;
400}
401
402void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled)
403{
404 window->null.floating = enabled;
405}
406
407void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled)
408{
409}
410
411float _glfwGetWindowOpacityNull(_GLFWwindow* window)
412{
413 return window->null.opacity;
414}
415
416void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity)
417{
418 window->null.opacity = opacity;
419}
420
421void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled)
422{
423}
424
425GLFWbool _glfwRawMouseMotionSupportedNull(void)
426{
427 return GLFW_TRUE;
428}
429
430void _glfwShowWindowNull(_GLFWwindow* window)
431{
432 window->null.visible = GLFW_TRUE;
433}
434
435void _glfwRequestWindowAttentionNull(_GLFWwindow* window)
436{
437}
438
439void _glfwHideWindowNull(_GLFWwindow* window)
440{
441 if (_glfw.null.focusedWindow == window)
442 {
443 _glfw.null.focusedWindow = NULL;
444 _glfwInputWindowFocus(window, GLFW_FALSE);
445 }
446
447 window->null.visible = GLFW_FALSE;
448}
449
450void _glfwFocusWindowNull(_GLFWwindow* window)
451{
452 _GLFWwindow* previous;
453
454 if (_glfw.null.focusedWindow == window)
455 return;
456
457 if (!window->null.visible)
458 return;
459
460 previous = _glfw.null.focusedWindow;
461 _glfw.null.focusedWindow = window;
462
463 if (previous)
464 {
465 _glfwInputWindowFocus(previous, GLFW_FALSE);
466 if (previous->monitor && previous->autoIconify)
467 _glfwIconifyWindowNull(previous);
468 }
469
470 _glfwInputWindowFocus(window, GLFW_TRUE);
471}
472
473GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window)
474{
475 return _glfw.null.focusedWindow == window;
476}
477
478GLFWbool _glfwWindowIconifiedNull(_GLFWwindow* window)
479{
480 return window->null.iconified;
481}
482
483GLFWbool _glfwWindowVisibleNull(_GLFWwindow* window)
484{
485 return window->null.visible;
486}
487
488void _glfwPollEventsNull(void)
489{
490}
491
492void _glfwWaitEventsNull(void)
493{
494}
495
496void _glfwWaitEventsTimeoutNull(double timeout)
497{
498}
499
500void _glfwPostEmptyEventNull(void)
501{
502}
503
504void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos)
505{
506 if (xpos)
507 *xpos = _glfw.null.xcursor - window->null.xpos;
508 if (ypos)
509 *ypos = _glfw.null.ycursor - window->null.ypos;
510}
511
512void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y)
513{
514 _glfw.null.xcursor = window->null.xpos + (int) x;
515 _glfw.null.ycursor = window->null.ypos + (int) y;
516}
517
518void _glfwSetCursorModeNull(_GLFWwindow* window, int mode)
519{
520}
521
522GLFWbool _glfwCreateCursorNull(_GLFWcursor* cursor,
523 const GLFWimage* image,
524 int xhot, int yhot)
525{
526 return GLFW_TRUE;
527}
528
529GLFWbool _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape)
530{
531 return GLFW_TRUE;
532}
533
534void _glfwDestroyCursorNull(_GLFWcursor* cursor)
535{
536}
537
538void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor)
539{
540}
541
542void _glfwSetClipboardStringNull(const char* string)
543{
544 char* copy = _glfw_strdup(string);
545 _glfw_free(_glfw.null.clipboardString);
546 _glfw.null.clipboardString = copy;
547}
548
549const char* _glfwGetClipboardStringNull(void)
550{
551 return _glfw.null.clipboardString;
552}
553
554EGLenum _glfwGetEGLPlatformNull(EGLint** attribs)
555{
556 return 0;
557}
558
559EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void)
560{
561 return 0;
562}
563
564EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
565{
566 return 0;
567}
568
569const char* _glfwGetScancodeNameNull(int scancode)
570{
571 if (scancode < GLFW_NULL_SC_FIRST || scancode > GLFW_NULL_SC_LAST)
572 {
573 _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
574 return NULL;
575 }
576
577 switch (scancode)
578 {
579 case GLFW_NULL_SC_APOSTROPHE:
580 return "'";
581 case GLFW_NULL_SC_COMMA:
582 return ",";
583 case GLFW_NULL_SC_MINUS:
584 case GLFW_NULL_SC_KP_SUBTRACT:
585 return "-";
586 case GLFW_NULL_SC_PERIOD:
587 case GLFW_NULL_SC_KP_DECIMAL:
588 return ".";
589 case GLFW_NULL_SC_SLASH:
590 case GLFW_NULL_SC_KP_DIVIDE:
591 return "/";
592 case GLFW_NULL_SC_SEMICOLON:
593 return ";";
594 case GLFW_NULL_SC_EQUAL:
595 case GLFW_NULL_SC_KP_EQUAL:
596 return "=";
597 case GLFW_NULL_SC_LEFT_BRACKET:
598 return "[";
599 case GLFW_NULL_SC_RIGHT_BRACKET:
600 return "]";
601 case GLFW_NULL_SC_KP_MULTIPLY:
602 return "*";
603 case GLFW_NULL_SC_KP_ADD:
604 return "+";
605 case GLFW_NULL_SC_BACKSLASH:
606 case GLFW_NULL_SC_WORLD_1:
607 case GLFW_NULL_SC_WORLD_2:
608 return "\\";
609 case GLFW_NULL_SC_0:
610 case GLFW_NULL_SC_KP_0:
611 return "0";
612 case GLFW_NULL_SC_1:
613 case GLFW_NULL_SC_KP_1:
614 return "1";
615 case GLFW_NULL_SC_2:
616 case GLFW_NULL_SC_KP_2:
617 return "2";
618 case GLFW_NULL_SC_3:
619 case GLFW_NULL_SC_KP_3:
620 return "3";
621 case GLFW_NULL_SC_4:
622 case GLFW_NULL_SC_KP_4:
623 return "4";
624 case GLFW_NULL_SC_5:
625 case GLFW_NULL_SC_KP_5:
626 return "5";
627 case GLFW_NULL_SC_6:
628 case GLFW_NULL_SC_KP_6:
629 return "6";
630 case GLFW_NULL_SC_7:
631 case GLFW_NULL_SC_KP_7:
632 return "7";
633 case GLFW_NULL_SC_8:
634 case GLFW_NULL_SC_KP_8:
635 return "8";
636 case GLFW_NULL_SC_9:
637 case GLFW_NULL_SC_KP_9:
638 return "9";
639 case GLFW_NULL_SC_A:
640 return "a";
641 case GLFW_NULL_SC_B:
642 return "b";
643 case GLFW_NULL_SC_C:
644 return "c";
645 case GLFW_NULL_SC_D:
646 return "d";
647 case GLFW_NULL_SC_E:
648 return "e";
649 case GLFW_NULL_SC_F:
650 return "f";
651 case GLFW_NULL_SC_G:
652 return "g";
653 case GLFW_NULL_SC_H:
654 return "h";
655 case GLFW_NULL_SC_I:
656 return "i";
657 case GLFW_NULL_SC_J:
658 return "j";
659 case GLFW_NULL_SC_K:
660 return "k";
661 case GLFW_NULL_SC_L:
662 return "l";
663 case GLFW_NULL_SC_M:
664 return "m";
665 case GLFW_NULL_SC_N:
666 return "n";
667 case GLFW_NULL_SC_O:
668 return "o";
669 case GLFW_NULL_SC_P:
670 return "p";
671 case GLFW_NULL_SC_Q:
672 return "q";
673 case GLFW_NULL_SC_R:
674 return "r";
675 case GLFW_NULL_SC_S:
676 return "s";
677 case GLFW_NULL_SC_T:
678 return "t";
679 case GLFW_NULL_SC_U:
680 return "u";
681 case GLFW_NULL_SC_V:
682 return "v";
683 case GLFW_NULL_SC_W:
684 return "w";
685 case GLFW_NULL_SC_X:
686 return "x";
687 case GLFW_NULL_SC_Y:
688 return "y";
689 case GLFW_NULL_SC_Z:
690 return "z";
691 }
692
693 return NULL;
694}
695
696int _glfwGetKeyScancodeNull(int key)
697{
698 return _glfw.null.scancodes[key];
699}
700
701void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
702{
703}
704
705GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
706 VkPhysicalDevice device,
707 uint32_t queuefamily)
708{
709 return GLFW_FALSE;
710}
711
712VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
713 _GLFWwindow* window,
714 const VkAllocationCallbacks* allocator,
715 VkSurfaceKHR* surface)
716{
717 // This seems like the most appropriate error to return here
718 return VK_ERROR_EXTENSION_NOT_PRESENT;
719}
720
diff --git a/raylib/src/external/glfw/src/osmesa_context.c b/raylib/src/external/glfw/src/osmesa_context.c
new file mode 100644
index 0000000..2f12adf
--- /dev/null
+++ b/raylib/src/external/glfw/src/osmesa_context.c
@@ -0,0 +1,383 @@
1//========================================================================
2// GLFW 3.4 OSMesa - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2016 Google Inc.
5// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <stdlib.h>
31#include <string.h>
32#include <assert.h>
33
34static void makeContextCurrentOSMesa(_GLFWwindow* window)
35{
36 if (window)
37 {
38 int width, height;
39 _glfw.platform.getFramebufferSize(window, &width, &height);
40
41 // Check to see if we need to allocate a new buffer
42 if ((window->context.osmesa.buffer == NULL) ||
43 (width != window->context.osmesa.width) ||
44 (height != window->context.osmesa.height))
45 {
46 _glfw_free(window->context.osmesa.buffer);
47
48 // Allocate the new buffer (width * height * 8-bit RGBA)
49 window->context.osmesa.buffer = _glfw_calloc(4, (size_t) width * height);
50 window->context.osmesa.width = width;
51 window->context.osmesa.height = height;
52 }
53
54 if (!OSMesaMakeCurrent(window->context.osmesa.handle,
55 window->context.osmesa.buffer,
56 GL_UNSIGNED_BYTE,
57 width, height))
58 {
59 _glfwInputError(GLFW_PLATFORM_ERROR,
60 "OSMesa: Failed to make context current");
61 return;
62 }
63 }
64
65 _glfwPlatformSetTls(&_glfw.contextSlot, window);
66}
67
68static GLFWglproc getProcAddressOSMesa(const char* procname)
69{
70 return (GLFWglproc) OSMesaGetProcAddress(procname);
71}
72
73static void destroyContextOSMesa(_GLFWwindow* window)
74{
75 if (window->context.osmesa.handle)
76 {
77 OSMesaDestroyContext(window->context.osmesa.handle);
78 window->context.osmesa.handle = NULL;
79 }
80
81 if (window->context.osmesa.buffer)
82 {
83 _glfw_free(window->context.osmesa.buffer);
84 window->context.osmesa.width = 0;
85 window->context.osmesa.height = 0;
86 }
87}
88
89static void swapBuffersOSMesa(_GLFWwindow* window)
90{
91 // No double buffering on OSMesa
92}
93
94static void swapIntervalOSMesa(int interval)
95{
96 // No swap interval on OSMesa
97}
98
99static int extensionSupportedOSMesa(const char* extension)
100{
101 // OSMesa does not have extensions
102 return GLFW_FALSE;
103}
104
105
106//////////////////////////////////////////////////////////////////////////
107////// GLFW internal API //////
108//////////////////////////////////////////////////////////////////////////
109
110GLFWbool _glfwInitOSMesa(void)
111{
112 int i;
113 const char* sonames[] =
114 {
115#if defined(_GLFW_OSMESA_LIBRARY)
116 _GLFW_OSMESA_LIBRARY,
117#elif defined(_WIN32)
118 "libOSMesa.dll",
119 "OSMesa.dll",
120#elif defined(__APPLE__)
121 "libOSMesa.8.dylib",
122#elif defined(__CYGWIN__)
123 "libOSMesa-8.so",
124#elif defined(__OpenBSD__) || defined(__NetBSD__)
125 "libOSMesa.so",
126#else
127 "libOSMesa.so.8",
128 "libOSMesa.so.6",
129#endif
130 NULL
131 };
132
133 if (_glfw.osmesa.handle)
134 return GLFW_TRUE;
135
136 for (i = 0; sonames[i]; i++)
137 {
138 _glfw.osmesa.handle = _glfwPlatformLoadModule(sonames[i]);
139 if (_glfw.osmesa.handle)
140 break;
141 }
142
143 if (!_glfw.osmesa.handle)
144 {
145 _glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa: Library not found");
146 return GLFW_FALSE;
147 }
148
149 _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
150 _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextExt");
151 _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
152 _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
153 _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
154 _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaDestroyContext");
155 _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
156 _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaMakeCurrent");
157 _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
158 _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
159 _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
160 _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
161 _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
162 _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetProcAddress");
163
164 if (!_glfw.osmesa.CreateContextExt ||
165 !_glfw.osmesa.DestroyContext ||
166 !_glfw.osmesa.MakeCurrent ||
167 !_glfw.osmesa.GetColorBuffer ||
168 !_glfw.osmesa.GetDepthBuffer ||
169 !_glfw.osmesa.GetProcAddress)
170 {
171 _glfwInputError(GLFW_PLATFORM_ERROR,
172 "OSMesa: Failed to load required entry points");
173
174 _glfwTerminateOSMesa();
175 return GLFW_FALSE;
176 }
177
178 return GLFW_TRUE;
179}
180
181void _glfwTerminateOSMesa(void)
182{
183 if (_glfw.osmesa.handle)
184 {
185 _glfwPlatformFreeModule(_glfw.osmesa.handle);
186 _glfw.osmesa.handle = NULL;
187 }
188}
189
190#define SET_ATTRIB(a, v) \
191{ \
192 assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
193 attribs[index++] = a; \
194 attribs[index++] = v; \
195}
196
197GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
198 const _GLFWctxconfig* ctxconfig,
199 const _GLFWfbconfig* fbconfig)
200{
201 OSMesaContext share = NULL;
202 const int accumBits = fbconfig->accumRedBits +
203 fbconfig->accumGreenBits +
204 fbconfig->accumBlueBits +
205 fbconfig->accumAlphaBits;
206
207 if (ctxconfig->client == GLFW_OPENGL_ES_API)
208 {
209 _glfwInputError(GLFW_API_UNAVAILABLE,
210 "OSMesa: OpenGL ES is not available on OSMesa");
211 return GLFW_FALSE;
212 }
213
214 if (ctxconfig->share)
215 share = ctxconfig->share->context.osmesa.handle;
216
217 if (OSMesaCreateContextAttribs)
218 {
219 int index = 0, attribs[40];
220
221 SET_ATTRIB(OSMESA_FORMAT, OSMESA_RGBA);
222 SET_ATTRIB(OSMESA_DEPTH_BITS, fbconfig->depthBits);
223 SET_ATTRIB(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
224 SET_ATTRIB(OSMESA_ACCUM_BITS, accumBits);
225
226 if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
227 {
228 SET_ATTRIB(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
229 }
230 else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
231 {
232 SET_ATTRIB(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
233 }
234
235 if (ctxconfig->major != 1 || ctxconfig->minor != 0)
236 {
237 SET_ATTRIB(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
238 SET_ATTRIB(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
239 }
240
241 if (ctxconfig->forward)
242 {
243 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
244 "OSMesa: Forward-compatible contexts not supported");
245 return GLFW_FALSE;
246 }
247
248 SET_ATTRIB(0, 0);
249
250 window->context.osmesa.handle =
251 OSMesaCreateContextAttribs(attribs, share);
252 }
253 else
254 {
255 if (ctxconfig->profile)
256 {
257 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
258 "OSMesa: OpenGL profiles unavailable");
259 return GLFW_FALSE;
260 }
261
262 window->context.osmesa.handle =
263 OSMesaCreateContextExt(OSMESA_RGBA,
264 fbconfig->depthBits,
265 fbconfig->stencilBits,
266 accumBits,
267 share);
268 }
269
270 if (window->context.osmesa.handle == NULL)
271 {
272 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
273 "OSMesa: Failed to create context");
274 return GLFW_FALSE;
275 }
276
277 window->context.makeCurrent = makeContextCurrentOSMesa;
278 window->context.swapBuffers = swapBuffersOSMesa;
279 window->context.swapInterval = swapIntervalOSMesa;
280 window->context.extensionSupported = extensionSupportedOSMesa;
281 window->context.getProcAddress = getProcAddressOSMesa;
282 window->context.destroy = destroyContextOSMesa;
283
284 return GLFW_TRUE;
285}
286
287#undef SET_ATTRIB
288
289
290//////////////////////////////////////////////////////////////////////////
291////// GLFW native API //////
292//////////////////////////////////////////////////////////////////////////
293
294GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
295 int* height, int* format, void** buffer)
296{
297 void* mesaBuffer;
298 GLint mesaWidth, mesaHeight, mesaFormat;
299 _GLFWwindow* window = (_GLFWwindow*) handle;
300 assert(window != NULL);
301
302 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
303
304 if (window->context.source != GLFW_OSMESA_CONTEXT_API)
305 {
306 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
307 return GLFW_FALSE;
308 }
309
310 if (!OSMesaGetColorBuffer(window->context.osmesa.handle,
311 &mesaWidth, &mesaHeight,
312 &mesaFormat, &mesaBuffer))
313 {
314 _glfwInputError(GLFW_PLATFORM_ERROR,
315 "OSMesa: Failed to retrieve color buffer");
316 return GLFW_FALSE;
317 }
318
319 if (width)
320 *width = mesaWidth;
321 if (height)
322 *height = mesaHeight;
323 if (format)
324 *format = mesaFormat;
325 if (buffer)
326 *buffer = mesaBuffer;
327
328 return GLFW_TRUE;
329}
330
331GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
332 int* width, int* height,
333 int* bytesPerValue,
334 void** buffer)
335{
336 void* mesaBuffer;
337 GLint mesaWidth, mesaHeight, mesaBytes;
338 _GLFWwindow* window = (_GLFWwindow*) handle;
339 assert(window != NULL);
340
341 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
342
343 if (window->context.source != GLFW_OSMESA_CONTEXT_API)
344 {
345 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
346 return GLFW_FALSE;
347 }
348
349 if (!OSMesaGetDepthBuffer(window->context.osmesa.handle,
350 &mesaWidth, &mesaHeight,
351 &mesaBytes, &mesaBuffer))
352 {
353 _glfwInputError(GLFW_PLATFORM_ERROR,
354 "OSMesa: Failed to retrieve depth buffer");
355 return GLFW_FALSE;
356 }
357
358 if (width)
359 *width = mesaWidth;
360 if (height)
361 *height = mesaHeight;
362 if (bytesPerValue)
363 *bytesPerValue = mesaBytes;
364 if (buffer)
365 *buffer = mesaBuffer;
366
367 return GLFW_TRUE;
368}
369
370GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
371{
372 _GLFWwindow* window = (_GLFWwindow*) handle;
373 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
374
375 if (window->context.source != GLFW_OSMESA_CONTEXT_API)
376 {
377 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
378 return NULL;
379 }
380
381 return window->context.osmesa.handle;
382}
383
diff --git a/raylib/src/external/glfw/src/platform.c b/raylib/src/external/glfw/src/platform.c
new file mode 100644
index 0000000..c4b0a36
--- /dev/null
+++ b/raylib/src/external/glfw/src/platform.c
@@ -0,0 +1,204 @@
1//========================================================================
2// GLFW 3.4 (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#include <string.h>
32#include <stdlib.h>
33
34// These construct a string literal from individual numeric constants
35#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
36#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
37
38//////////////////////////////////////////////////////////////////////////
39////// GLFW internal API //////
40//////////////////////////////////////////////////////////////////////////
41
42static const struct
43{
44 int ID;
45 GLFWbool (*connect)(int,_GLFWplatform*);
46} supportedPlatforms[] =
47{
48#if defined(_GLFW_WIN32)
49 { GLFW_PLATFORM_WIN32, _glfwConnectWin32 },
50#endif
51#if defined(_GLFW_COCOA)
52 { GLFW_PLATFORM_COCOA, _glfwConnectCocoa },
53#endif
54#if defined(_GLFW_WAYLAND)
55 { GLFW_PLATFORM_WAYLAND, _glfwConnectWayland },
56#endif
57#if defined(_GLFW_X11)
58 { GLFW_PLATFORM_X11, _glfwConnectX11 },
59#endif
60};
61
62GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
63{
64 const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]);
65 size_t i;
66
67 if (desiredID != GLFW_ANY_PLATFORM &&
68 desiredID != GLFW_PLATFORM_WIN32 &&
69 desiredID != GLFW_PLATFORM_COCOA &&
70 desiredID != GLFW_PLATFORM_WAYLAND &&
71 desiredID != GLFW_PLATFORM_X11 &&
72 desiredID != GLFW_PLATFORM_NULL)
73 {
74 _glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", desiredID);
75 return GLFW_FALSE;
76 }
77
78#if defined(_GLFW_WAYLAND) && defined(_GLFW_X11)
79 if (desiredID == GLFW_ANY_PLATFORM)
80 {
81 const char* const session = getenv("XDG_SESSION_TYPE");
82 if (session)
83 {
84 // Only follow XDG_SESSION_TYPE if it is set correctly and the
85 // environment looks plausble; otherwise fall back to detection
86 if (strcmp(session, "wayland") == 0 && getenv("WAYLAND_DISPLAY"))
87 desiredID = GLFW_PLATFORM_WAYLAND;
88 else if (strcmp(session, "x11") == 0 && getenv("DISPLAY"))
89 desiredID = GLFW_PLATFORM_X11;
90 }
91 }
92#endif
93
94 if (desiredID == GLFW_ANY_PLATFORM)
95 {
96 // If there is exactly one platform available for auto-selection, let it emit the
97 // error on failure as the platform-specific error description may be more helpful
98 if (count == 1)
99 return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform);
100
101 for (i = 0; i < count; i++)
102 {
103 if (supportedPlatforms[i].connect(desiredID, platform))
104 return GLFW_TRUE;
105 }
106
107 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform");
108 }
109 else
110 {
111 for (i = 0; i < count; i++)
112 {
113 if (supportedPlatforms[i].ID == desiredID)
114 return supportedPlatforms[i].connect(desiredID, platform);
115 }
116
117 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "The requested platform is not supported");
118 }
119
120 return GLFW_FALSE;
121}
122
123//////////////////////////////////////////////////////////////////////////
124////// GLFW public API //////
125//////////////////////////////////////////////////////////////////////////
126
127GLFWAPI int glfwGetPlatform(void)
128{
129 _GLFW_REQUIRE_INIT_OR_RETURN(0);
130 return _glfw.platform.platformID;
131}
132
133GLFWAPI int glfwPlatformSupported(int platformID)
134{
135 const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]);
136 size_t i;
137
138 if (platformID != GLFW_PLATFORM_WIN32 &&
139 platformID != GLFW_PLATFORM_COCOA &&
140 platformID != GLFW_PLATFORM_WAYLAND &&
141 platformID != GLFW_PLATFORM_X11 &&
142 platformID != GLFW_PLATFORM_NULL)
143 {
144 _glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", platformID);
145 return GLFW_FALSE;
146 }
147
148 if (platformID == GLFW_PLATFORM_NULL)
149 return GLFW_TRUE;
150
151 for (i = 0; i < count; i++)
152 {
153 if (platformID == supportedPlatforms[i].ID)
154 return GLFW_TRUE;
155 }
156
157 return GLFW_FALSE;
158}
159
160GLFWAPI const char* glfwGetVersionString(void)
161{
162 return _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR,
163 GLFW_VERSION_MINOR,
164 GLFW_VERSION_REVISION)
165#if defined(_GLFW_WIN32)
166 " Win32 WGL"
167#endif
168#if defined(_GLFW_COCOA)
169 " Cocoa NSGL"
170#endif
171#if defined(_GLFW_WAYLAND)
172 " Wayland"
173#endif
174#if defined(_GLFW_X11)
175 " X11 GLX"
176#endif
177 " Null"
178 " EGL"
179 " OSMesa"
180#if defined(__MINGW64_VERSION_MAJOR)
181 " MinGW-w64"
182#elif defined(__MINGW32__)
183 " MinGW"
184#elif defined(_MSC_VER)
185 " VisualC"
186#endif
187#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
188 " hybrid-GPU"
189#endif
190#if defined(_POSIX_MONOTONIC_CLOCK)
191 " monotonic"
192#endif
193#if defined(_GLFW_BUILD_DLL)
194#if defined(_WIN32)
195 " DLL"
196#elif defined(__APPLE__)
197 " dynamic"
198#else
199 " shared"
200#endif
201#endif
202 ;
203}
204
diff --git a/raylib/src/external/glfw/src/platform.h b/raylib/src/external/glfw/src/platform.h
new file mode 100644
index 0000000..75652dc
--- /dev/null
+++ b/raylib/src/external/glfw/src/platform.h
@@ -0,0 +1,212 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#if defined(GLFW_BUILD_WIN32_TIMER) || \
29 defined(GLFW_BUILD_WIN32_MODULE) || \
30 defined(GLFW_BUILD_WIN32_THREAD) || \
31 defined(GLFW_BUILD_COCOA_TIMER) || \
32 defined(GLFW_BUILD_POSIX_TIMER) || \
33 defined(GLFW_BUILD_POSIX_MODULE) || \
34 defined(GLFW_BUILD_POSIX_THREAD) || \
35 defined(GLFW_BUILD_POSIX_POLL) || \
36 defined(GLFW_BUILD_LINUX_JOYSTICK)
37 #error "You must not define these; define zero or more _GLFW_<platform> macros instead"
38#endif
39
40#include "null_platform.h"
41#define GLFW_EXPOSE_NATIVE_EGL
42#define GLFW_EXPOSE_NATIVE_OSMESA
43
44#if defined(_GLFW_WIN32)
45 #include "win32_platform.h"
46 #define GLFW_EXPOSE_NATIVE_WIN32
47 #define GLFW_EXPOSE_NATIVE_WGL
48#else
49 #define GLFW_WIN32_WINDOW_STATE
50 #define GLFW_WIN32_MONITOR_STATE
51 #define GLFW_WIN32_CURSOR_STATE
52 #define GLFW_WIN32_LIBRARY_WINDOW_STATE
53 #define GLFW_WGL_CONTEXT_STATE
54 #define GLFW_WGL_LIBRARY_CONTEXT_STATE
55#endif
56
57#if defined(_GLFW_COCOA)
58 #include "cocoa_platform.h"
59 #define GLFW_EXPOSE_NATIVE_COCOA
60 #define GLFW_EXPOSE_NATIVE_NSGL
61#else
62 #define GLFW_COCOA_WINDOW_STATE
63 #define GLFW_COCOA_MONITOR_STATE
64 #define GLFW_COCOA_CURSOR_STATE
65 #define GLFW_COCOA_LIBRARY_WINDOW_STATE
66 #define GLFW_NSGL_CONTEXT_STATE
67 #define GLFW_NSGL_LIBRARY_CONTEXT_STATE
68#endif
69
70#if defined(_GLFW_WAYLAND)
71 #include "wl_platform.h"
72 #define GLFW_EXPOSE_NATIVE_WAYLAND
73#else
74 #define GLFW_WAYLAND_WINDOW_STATE
75 #define GLFW_WAYLAND_MONITOR_STATE
76 #define GLFW_WAYLAND_CURSOR_STATE
77 #define GLFW_WAYLAND_LIBRARY_WINDOW_STATE
78#endif
79
80#if defined(_GLFW_X11)
81 #include "x11_platform.h"
82 #define GLFW_EXPOSE_NATIVE_X11
83 #define GLFW_EXPOSE_NATIVE_GLX
84#else
85 #define GLFW_X11_WINDOW_STATE
86 #define GLFW_X11_MONITOR_STATE
87 #define GLFW_X11_CURSOR_STATE
88 #define GLFW_X11_LIBRARY_WINDOW_STATE
89 #define GLFW_GLX_CONTEXT_STATE
90 #define GLFW_GLX_LIBRARY_CONTEXT_STATE
91#endif
92
93#include "null_joystick.h"
94
95#if defined(_GLFW_WIN32)
96 #include "win32_joystick.h"
97#else
98 #define GLFW_WIN32_JOYSTICK_STATE
99 #define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
100#endif
101
102#if defined(_GLFW_COCOA)
103 #include "cocoa_joystick.h"
104#else
105 #define GLFW_COCOA_JOYSTICK_STATE
106 #define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
107#endif
108
109#if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__)
110 #define GLFW_BUILD_LINUX_JOYSTICK
111#endif
112
113#if defined(GLFW_BUILD_LINUX_JOYSTICK)
114 #include "linux_joystick.h"
115#else
116 #define GLFW_LINUX_JOYSTICK_STATE
117 #define GLFW_LINUX_LIBRARY_JOYSTICK_STATE
118#endif
119
120#define GLFW_PLATFORM_WINDOW_STATE \
121 GLFW_WIN32_WINDOW_STATE \
122 GLFW_COCOA_WINDOW_STATE \
123 GLFW_WAYLAND_WINDOW_STATE \
124 GLFW_X11_WINDOW_STATE \
125 GLFW_NULL_WINDOW_STATE \
126
127#define GLFW_PLATFORM_MONITOR_STATE \
128 GLFW_WIN32_MONITOR_STATE \
129 GLFW_COCOA_MONITOR_STATE \
130 GLFW_WAYLAND_MONITOR_STATE \
131 GLFW_X11_MONITOR_STATE \
132 GLFW_NULL_MONITOR_STATE \
133
134#define GLFW_PLATFORM_CURSOR_STATE \
135 GLFW_WIN32_CURSOR_STATE \
136 GLFW_COCOA_CURSOR_STATE \
137 GLFW_WAYLAND_CURSOR_STATE \
138 GLFW_X11_CURSOR_STATE \
139 GLFW_NULL_CURSOR_STATE \
140
141#define GLFW_PLATFORM_JOYSTICK_STATE \
142 GLFW_WIN32_JOYSTICK_STATE \
143 GLFW_COCOA_JOYSTICK_STATE \
144 GLFW_LINUX_JOYSTICK_STATE
145
146#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
147 GLFW_WIN32_LIBRARY_WINDOW_STATE \
148 GLFW_COCOA_LIBRARY_WINDOW_STATE \
149 GLFW_WAYLAND_LIBRARY_WINDOW_STATE \
150 GLFW_X11_LIBRARY_WINDOW_STATE \
151 GLFW_NULL_LIBRARY_WINDOW_STATE \
152
153#define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
154 GLFW_WIN32_LIBRARY_JOYSTICK_STATE \
155 GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
156 GLFW_LINUX_LIBRARY_JOYSTICK_STATE
157
158#define GLFW_PLATFORM_CONTEXT_STATE \
159 GLFW_WGL_CONTEXT_STATE \
160 GLFW_NSGL_CONTEXT_STATE \
161 GLFW_GLX_CONTEXT_STATE
162
163#define GLFW_PLATFORM_LIBRARY_CONTEXT_STATE \
164 GLFW_WGL_LIBRARY_CONTEXT_STATE \
165 GLFW_NSGL_LIBRARY_CONTEXT_STATE \
166 GLFW_GLX_LIBRARY_CONTEXT_STATE
167
168#if defined(_WIN32)
169 #define GLFW_BUILD_WIN32_THREAD
170#else
171 #define GLFW_BUILD_POSIX_THREAD
172#endif
173
174#if defined(GLFW_BUILD_WIN32_THREAD)
175 #include "win32_thread.h"
176 #define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE
177 #define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE
178#elif defined(GLFW_BUILD_POSIX_THREAD)
179 #include "posix_thread.h"
180 #define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE
181 #define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE
182#endif
183
184#if defined(_WIN32)
185 #define GLFW_BUILD_WIN32_TIMER
186#elif defined(__APPLE__)
187 #define GLFW_BUILD_COCOA_TIMER
188#else
189 #define GLFW_BUILD_POSIX_TIMER
190#endif
191
192#if defined(GLFW_BUILD_WIN32_TIMER)
193 #include "win32_time.h"
194 #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE
195#elif defined(GLFW_BUILD_COCOA_TIMER)
196 #include "cocoa_time.h"
197 #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE
198#elif defined(GLFW_BUILD_POSIX_TIMER)
199 #include "posix_time.h"
200 #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
201#endif
202
203#if defined(_WIN32)
204 #define GLFW_BUILD_WIN32_MODULE
205#else
206 #define GLFW_BUILD_POSIX_MODULE
207#endif
208
209#if defined(_GLFW_WAYLAND) || defined(_GLFW_X11)
210 #define GLFW_BUILD_POSIX_POLL
211#endif
212
diff --git a/raylib/src/external/glfw/src/posix_module.c b/raylib/src/external/glfw/src/posix_module.c
new file mode 100644
index 0000000..7d81c67
--- /dev/null
+++ b/raylib/src/external/glfw/src/posix_module.c
@@ -0,0 +1,53 @@
1//========================================================================
2// GLFW 3.4 POSIX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include "internal.h"
28
29#if defined(GLFW_BUILD_POSIX_MODULE)
30
31#include <dlfcn.h>
32
33//////////////////////////////////////////////////////////////////////////
34////// GLFW platform API //////
35//////////////////////////////////////////////////////////////////////////
36
37void* _glfwPlatformLoadModule(const char* path)
38{
39 return dlopen(path, RTLD_LAZY | RTLD_LOCAL);
40}
41
42void _glfwPlatformFreeModule(void* module)
43{
44 dlclose(module);
45}
46
47GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
48{
49 return dlsym(module, name);
50}
51
52#endif // GLFW_BUILD_POSIX_MODULE
53
diff --git a/raylib/src/external/glfw/src/posix_poll.c b/raylib/src/external/glfw/src/posix_poll.c
new file mode 100644
index 0000000..b53e36e
--- /dev/null
+++ b/raylib/src/external/glfw/src/posix_poll.c
@@ -0,0 +1,83 @@
1//========================================================================
2// GLFW 3.4 POSIX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#define _GNU_SOURCE
28
29#include "internal.h"
30
31#if defined(GLFW_BUILD_POSIX_POLL)
32
33#include <signal.h>
34#include <time.h>
35#include <errno.h>
36
37GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout)
38{
39 for (;;)
40 {
41 if (timeout)
42 {
43 const uint64_t base = _glfwPlatformGetTimerValue();
44
45#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
46 const time_t seconds = (time_t) *timeout;
47 const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
48 const struct timespec ts = { seconds, nanoseconds };
49 const int result = ppoll(fds, count, &ts, NULL);
50#elif defined(__NetBSD__)
51 const time_t seconds = (time_t) *timeout;
52 const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
53 const struct timespec ts = { seconds, nanoseconds };
54 const int result = pollts(fds, count, &ts, NULL);
55#else
56 const int milliseconds = (int) (*timeout * 1e3);
57 const int result = poll(fds, count, milliseconds);
58#endif
59 const int error = errno; // clock_gettime may overwrite our error
60
61 *timeout -= (_glfwPlatformGetTimerValue() - base) /
62 (double) _glfwPlatformGetTimerFrequency();
63
64 if (result > 0)
65 return GLFW_TRUE;
66 else if (result == -1 && error != EINTR && error != EAGAIN)
67 return GLFW_FALSE;
68 else if (*timeout <= 0.0)
69 return GLFW_FALSE;
70 }
71 else
72 {
73 const int result = poll(fds, count, -1);
74 if (result > 0)
75 return GLFW_TRUE;
76 else if (result == -1 && errno != EINTR && errno != EAGAIN)
77 return GLFW_FALSE;
78 }
79 }
80}
81
82#endif // GLFW_BUILD_POSIX_POLL
83
diff --git a/raylib/src/external/glfw/src/posix_poll.h b/raylib/src/external/glfw/src/posix_poll.h
new file mode 100644
index 0000000..4bdd244
--- /dev/null
+++ b/raylib/src/external/glfw/src/posix_poll.h
@@ -0,0 +1,30 @@
1//========================================================================
2// GLFW 3.4 POSIX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include <poll.h>
28
29GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout);
30
diff --git a/raylib/src/external/glfw/src/posix_thread.c b/raylib/src/external/glfw/src/posix_thread.c
new file mode 100644
index 0000000..3c355a5
--- /dev/null
+++ b/raylib/src/external/glfw/src/posix_thread.c
@@ -0,0 +1,107 @@
1//========================================================================
2// GLFW 3.4 POSIX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(GLFW_BUILD_POSIX_THREAD)
31
32#include <assert.h>
33#include <string.h>
34
35
36//////////////////////////////////////////////////////////////////////////
37////// GLFW platform API //////
38//////////////////////////////////////////////////////////////////////////
39
40GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
41{
42 assert(tls->posix.allocated == GLFW_FALSE);
43
44 if (pthread_key_create(&tls->posix.key, NULL) != 0)
45 {
46 _glfwInputError(GLFW_PLATFORM_ERROR,
47 "POSIX: Failed to create context TLS");
48 return GLFW_FALSE;
49 }
50
51 tls->posix.allocated = GLFW_TRUE;
52 return GLFW_TRUE;
53}
54
55void _glfwPlatformDestroyTls(_GLFWtls* tls)
56{
57 if (tls->posix.allocated)
58 pthread_key_delete(tls->posix.key);
59 memset(tls, 0, sizeof(_GLFWtls));
60}
61
62void* _glfwPlatformGetTls(_GLFWtls* tls)
63{
64 assert(tls->posix.allocated == GLFW_TRUE);
65 return pthread_getspecific(tls->posix.key);
66}
67
68void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
69{
70 assert(tls->posix.allocated == GLFW_TRUE);
71 pthread_setspecific(tls->posix.key, value);
72}
73
74GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
75{
76 assert(mutex->posix.allocated == GLFW_FALSE);
77
78 if (pthread_mutex_init(&mutex->posix.handle, NULL) != 0)
79 {
80 _glfwInputError(GLFW_PLATFORM_ERROR, "POSIX: Failed to create mutex");
81 return GLFW_FALSE;
82 }
83
84 return mutex->posix.allocated = GLFW_TRUE;
85}
86
87void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
88{
89 if (mutex->posix.allocated)
90 pthread_mutex_destroy(&mutex->posix.handle);
91 memset(mutex, 0, sizeof(_GLFWmutex));
92}
93
94void _glfwPlatformLockMutex(_GLFWmutex* mutex)
95{
96 assert(mutex->posix.allocated == GLFW_TRUE);
97 pthread_mutex_lock(&mutex->posix.handle);
98}
99
100void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
101{
102 assert(mutex->posix.allocated == GLFW_TRUE);
103 pthread_mutex_unlock(&mutex->posix.handle);
104}
105
106#endif // GLFW_BUILD_POSIX_THREAD
107
diff --git a/raylib/src/external/glfw/src/posix_thread.h b/raylib/src/external/glfw/src/posix_thread.h
new file mode 100644
index 0000000..5a5d7b7
--- /dev/null
+++ b/raylib/src/external/glfw/src/posix_thread.h
@@ -0,0 +1,49 @@
1//========================================================================
2// GLFW 3.4 POSIX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include <pthread.h>
29
30#define GLFW_POSIX_TLS_STATE _GLFWtlsPOSIX posix;
31#define GLFW_POSIX_MUTEX_STATE _GLFWmutexPOSIX posix;
32
33
34// POSIX-specific thread local storage data
35//
36typedef struct _GLFWtlsPOSIX
37{
38 GLFWbool allocated;
39 pthread_key_t key;
40} _GLFWtlsPOSIX;
41
42// POSIX-specific mutex data
43//
44typedef struct _GLFWmutexPOSIX
45{
46 GLFWbool allocated;
47 pthread_mutex_t handle;
48} _GLFWmutexPOSIX;
49
diff --git a/raylib/src/external/glfw/src/posix_time.c b/raylib/src/external/glfw/src/posix_time.c
new file mode 100644
index 0000000..a172408
--- /dev/null
+++ b/raylib/src/external/glfw/src/posix_time.c
@@ -0,0 +1,65 @@
1//========================================================================
2// GLFW 3.4 POSIX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(GLFW_BUILD_POSIX_TIMER)
31
32#include <unistd.h>
33#include <sys/time.h>
34
35
36//////////////////////////////////////////////////////////////////////////
37////// GLFW platform API //////
38//////////////////////////////////////////////////////////////////////////
39
40void _glfwPlatformInitTimer(void)
41{
42 _glfw.timer.posix.clock = CLOCK_REALTIME;
43 _glfw.timer.posix.frequency = 1000000000;
44
45#if defined(_POSIX_MONOTONIC_CLOCK)
46 struct timespec ts;
47 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
48 _glfw.timer.posix.clock = CLOCK_MONOTONIC;
49#endif
50}
51
52uint64_t _glfwPlatformGetTimerValue(void)
53{
54 struct timespec ts;
55 clock_gettime(_glfw.timer.posix.clock, &ts);
56 return (uint64_t) ts.tv_sec * _glfw.timer.posix.frequency + (uint64_t) ts.tv_nsec;
57}
58
59uint64_t _glfwPlatformGetTimerFrequency(void)
60{
61 return _glfw.timer.posix.frequency;
62}
63
64#endif // GLFW_BUILD_POSIX_TIMER
65
diff --git a/raylib/src/external/glfw/src/posix_time.h b/raylib/src/external/glfw/src/posix_time.h
new file mode 100644
index 0000000..94374ad
--- /dev/null
+++ b/raylib/src/external/glfw/src/posix_time.h
@@ -0,0 +1,41 @@
1//========================================================================
2// GLFW 3.4 POSIX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#define GLFW_POSIX_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix;
29
30#include <stdint.h>
31#include <time.h>
32
33
34// POSIX-specific global timer data
35//
36typedef struct _GLFWtimerPOSIX
37{
38 clockid_t clock;
39 uint64_t frequency;
40} _GLFWtimerPOSIX;
41
diff --git a/raylib/src/external/glfw/src/vulkan.c b/raylib/src/external/glfw/src/vulkan.c
new file mode 100644
index 0000000..d9fabde
--- /dev/null
+++ b/raylib/src/external/glfw/src/vulkan.c
@@ -0,0 +1,328 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#include <assert.h>
31#include <string.h>
32#include <stdlib.h>
33
34#define _GLFW_FIND_LOADER 1
35#define _GLFW_REQUIRE_LOADER 2
36
37
38//////////////////////////////////////////////////////////////////////////
39////// GLFW internal API //////
40//////////////////////////////////////////////////////////////////////////
41
42GLFWbool _glfwInitVulkan(int mode)
43{
44 VkResult err;
45 VkExtensionProperties* ep;
46 PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
47 uint32_t i, count;
48
49 if (_glfw.vk.available)
50 return GLFW_TRUE;
51
52 if (_glfw.hints.init.vulkanLoader)
53 _glfw.vk.GetInstanceProcAddr = _glfw.hints.init.vulkanLoader;
54 else
55 {
56#if defined(_GLFW_VULKAN_LIBRARY)
57 _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY);
58#elif defined(_GLFW_WIN32)
59 _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll");
60#elif defined(_GLFW_COCOA)
61 _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib");
62 if (!_glfw.vk.handle)
63 _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa();
64#elif defined(__OpenBSD__) || defined(__NetBSD__)
65 _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so");
66#else
67 _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1");
68#endif
69 if (!_glfw.vk.handle)
70 {
71 if (mode == _GLFW_REQUIRE_LOADER)
72 _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
73
74 return GLFW_FALSE;
75 }
76
77 _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
78 _glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr");
79 if (!_glfw.vk.GetInstanceProcAddr)
80 {
81 _glfwInputError(GLFW_API_UNAVAILABLE,
82 "Vulkan: Loader does not export vkGetInstanceProcAddr");
83
84 _glfwTerminateVulkan();
85 return GLFW_FALSE;
86 }
87 }
88
89 vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
90 vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
91 if (!vkEnumerateInstanceExtensionProperties)
92 {
93 _glfwInputError(GLFW_API_UNAVAILABLE,
94 "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
95
96 _glfwTerminateVulkan();
97 return GLFW_FALSE;
98 }
99
100 err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
101 if (err)
102 {
103 // NOTE: This happens on systems with a loader but without any Vulkan ICD
104 if (mode == _GLFW_REQUIRE_LOADER)
105 {
106 _glfwInputError(GLFW_API_UNAVAILABLE,
107 "Vulkan: Failed to query instance extension count: %s",
108 _glfwGetVulkanResultString(err));
109 }
110
111 _glfwTerminateVulkan();
112 return GLFW_FALSE;
113 }
114
115 ep = _glfw_calloc(count, sizeof(VkExtensionProperties));
116
117 err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
118 if (err)
119 {
120 _glfwInputError(GLFW_API_UNAVAILABLE,
121 "Vulkan: Failed to query instance extensions: %s",
122 _glfwGetVulkanResultString(err));
123
124 _glfw_free(ep);
125 _glfwTerminateVulkan();
126 return GLFW_FALSE;
127 }
128
129 for (i = 0; i < count; i++)
130 {
131 if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
132 _glfw.vk.KHR_surface = GLFW_TRUE;
133 else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
134 _glfw.vk.KHR_win32_surface = GLFW_TRUE;
135 else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
136 _glfw.vk.MVK_macos_surface = GLFW_TRUE;
137 else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0)
138 _glfw.vk.EXT_metal_surface = GLFW_TRUE;
139 else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
140 _glfw.vk.KHR_xlib_surface = GLFW_TRUE;
141 else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
142 _glfw.vk.KHR_xcb_surface = GLFW_TRUE;
143 else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
144 _glfw.vk.KHR_wayland_surface = GLFW_TRUE;
145 }
146
147 _glfw_free(ep);
148
149 _glfw.vk.available = GLFW_TRUE;
150
151 _glfw.platform.getRequiredInstanceExtensions(_glfw.vk.extensions);
152
153 return GLFW_TRUE;
154}
155
156void _glfwTerminateVulkan(void)
157{
158 if (_glfw.vk.handle)
159 _glfwPlatformFreeModule(_glfw.vk.handle);
160}
161
162const char* _glfwGetVulkanResultString(VkResult result)
163{
164 switch (result)
165 {
166 case VK_SUCCESS:
167 return "Success";
168 case VK_NOT_READY:
169 return "A fence or query has not yet completed";
170 case VK_TIMEOUT:
171 return "A wait operation has not completed in the specified time";
172 case VK_EVENT_SET:
173 return "An event is signaled";
174 case VK_EVENT_RESET:
175 return "An event is unsignaled";
176 case VK_INCOMPLETE:
177 return "A return array was too small for the result";
178 case VK_ERROR_OUT_OF_HOST_MEMORY:
179 return "A host memory allocation has failed";
180 case VK_ERROR_OUT_OF_DEVICE_MEMORY:
181 return "A device memory allocation has failed";
182 case VK_ERROR_INITIALIZATION_FAILED:
183 return "Initialization of an object could not be completed for implementation-specific reasons";
184 case VK_ERROR_DEVICE_LOST:
185 return "The logical or physical device has been lost";
186 case VK_ERROR_MEMORY_MAP_FAILED:
187 return "Mapping of a memory object has failed";
188 case VK_ERROR_LAYER_NOT_PRESENT:
189 return "A requested layer is not present or could not be loaded";
190 case VK_ERROR_EXTENSION_NOT_PRESENT:
191 return "A requested extension is not supported";
192 case VK_ERROR_FEATURE_NOT_PRESENT:
193 return "A requested feature is not supported";
194 case VK_ERROR_INCOMPATIBLE_DRIVER:
195 return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible";
196 case VK_ERROR_TOO_MANY_OBJECTS:
197 return "Too many objects of the type have already been created";
198 case VK_ERROR_FORMAT_NOT_SUPPORTED:
199 return "A requested format is not supported on this device";
200 case VK_ERROR_SURFACE_LOST_KHR:
201 return "A surface is no longer available";
202 case VK_SUBOPTIMAL_KHR:
203 return "A swapchain no longer matches the surface properties exactly, but can still be used";
204 case VK_ERROR_OUT_OF_DATE_KHR:
205 return "A surface has changed in such a way that it is no longer compatible with the swapchain";
206 case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
207 return "The display used by a swapchain does not use the same presentable image layout";
208 case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
209 return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API";
210 case VK_ERROR_VALIDATION_FAILED_EXT:
211 return "A validation layer found an error";
212 default:
213 return "ERROR: UNKNOWN VULKAN ERROR";
214 }
215}
216
217
218//////////////////////////////////////////////////////////////////////////
219////// GLFW public API //////
220//////////////////////////////////////////////////////////////////////////
221
222GLFWAPI int glfwVulkanSupported(void)
223{
224 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
225 return _glfwInitVulkan(_GLFW_FIND_LOADER);
226}
227
228GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
229{
230 assert(count != NULL);
231
232 *count = 0;
233
234 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
235
236 if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
237 return NULL;
238
239 if (!_glfw.vk.extensions[0])
240 return NULL;
241
242 *count = 2;
243 return (const char**) _glfw.vk.extensions;
244}
245
246GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
247 const char* procname)
248{
249 GLFWvkproc proc;
250 assert(procname != NULL);
251
252 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
253
254 if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
255 return NULL;
256
257 // NOTE: Vulkan 1.0 and 1.1 vkGetInstanceProcAddr cannot return itself
258 if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
259 return (GLFWvkproc) vkGetInstanceProcAddr;
260
261 proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
262 if (!proc)
263 {
264 if (_glfw.vk.handle)
265 proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname);
266 }
267
268 return proc;
269}
270
271GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
272 VkPhysicalDevice device,
273 uint32_t queuefamily)
274{
275 assert(instance != VK_NULL_HANDLE);
276 assert(device != VK_NULL_HANDLE);
277
278 _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
279
280 if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
281 return GLFW_FALSE;
282
283 if (!_glfw.vk.extensions[0])
284 {
285 _glfwInputError(GLFW_API_UNAVAILABLE,
286 "Vulkan: Window surface creation extensions not found");
287 return GLFW_FALSE;
288 }
289
290 return _glfw.platform.getPhysicalDevicePresentationSupport(instance,
291 device,
292 queuefamily);
293}
294
295GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
296 GLFWwindow* handle,
297 const VkAllocationCallbacks* allocator,
298 VkSurfaceKHR* surface)
299{
300 _GLFWwindow* window = (_GLFWwindow*) handle;
301 assert(instance != VK_NULL_HANDLE);
302 assert(window != NULL);
303 assert(surface != NULL);
304
305 *surface = VK_NULL_HANDLE;
306
307 _GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED);
308
309 if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
310 return VK_ERROR_INITIALIZATION_FAILED;
311
312 if (!_glfw.vk.extensions[0])
313 {
314 _glfwInputError(GLFW_API_UNAVAILABLE,
315 "Vulkan: Window surface creation extensions not found");
316 return VK_ERROR_EXTENSION_NOT_PRESENT;
317 }
318
319 if (window->context.client != GLFW_NO_API)
320 {
321 _glfwInputError(GLFW_INVALID_VALUE,
322 "Vulkan: Window surface creation requires the window to have the client API set to GLFW_NO_API");
323 return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
324 }
325
326 return _glfw.platform.createWindowSurface(instance, window, allocator, surface);
327}
328
diff --git a/raylib/src/external/glfw/src/wgl_context.c b/raylib/src/external/glfw/src/wgl_context.c
new file mode 100644
index 0000000..8a23ffc
--- /dev/null
+++ b/raylib/src/external/glfw/src/wgl_context.c
@@ -0,0 +1,798 @@
1//========================================================================
2// GLFW 3.4 WGL - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_WIN32)
31
32#include <stdlib.h>
33#include <assert.h>
34
35// Return the value corresponding to the specified attribute
36//
37static int findPixelFormatAttribValueWGL(const int* attribs,
38 int attribCount,
39 const int* values,
40 int attrib)
41{
42 int i;
43
44 for (i = 0; i < attribCount; i++)
45 {
46 if (attribs[i] == attrib)
47 return values[i];
48 }
49
50 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
51 "WGL: Unknown pixel format attribute requested");
52 return 0;
53}
54
55#define ADD_ATTRIB(a) \
56{ \
57 assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \
58 attribs[attribCount++] = a; \
59}
60#define FIND_ATTRIB_VALUE(a) \
61 findPixelFormatAttribValueWGL(attribs, attribCount, values, a)
62
63// Return a list of available and usable framebuffer configs
64//
65static int choosePixelFormatWGL(_GLFWwindow* window,
66 const _GLFWctxconfig* ctxconfig,
67 const _GLFWfbconfig* fbconfig)
68{
69 _GLFWfbconfig* usableConfigs;
70 const _GLFWfbconfig* closest;
71 int i, pixelFormat, nativeCount, usableCount = 0, attribCount = 0;
72 int attribs[40];
73 int values[sizeof(attribs) / sizeof(attribs[0])];
74
75 nativeCount = DescribePixelFormat(window->context.wgl.dc,
76 1,
77 sizeof(PIXELFORMATDESCRIPTOR),
78 NULL);
79
80 if (_glfw.wgl.ARB_pixel_format)
81 {
82 ADD_ATTRIB(WGL_SUPPORT_OPENGL_ARB);
83 ADD_ATTRIB(WGL_DRAW_TO_WINDOW_ARB);
84 ADD_ATTRIB(WGL_PIXEL_TYPE_ARB);
85 ADD_ATTRIB(WGL_ACCELERATION_ARB);
86 ADD_ATTRIB(WGL_RED_BITS_ARB);
87 ADD_ATTRIB(WGL_RED_SHIFT_ARB);
88 ADD_ATTRIB(WGL_GREEN_BITS_ARB);
89 ADD_ATTRIB(WGL_GREEN_SHIFT_ARB);
90 ADD_ATTRIB(WGL_BLUE_BITS_ARB);
91 ADD_ATTRIB(WGL_BLUE_SHIFT_ARB);
92 ADD_ATTRIB(WGL_ALPHA_BITS_ARB);
93 ADD_ATTRIB(WGL_ALPHA_SHIFT_ARB);
94 ADD_ATTRIB(WGL_DEPTH_BITS_ARB);
95 ADD_ATTRIB(WGL_STENCIL_BITS_ARB);
96 ADD_ATTRIB(WGL_ACCUM_BITS_ARB);
97 ADD_ATTRIB(WGL_ACCUM_RED_BITS_ARB);
98 ADD_ATTRIB(WGL_ACCUM_GREEN_BITS_ARB);
99 ADD_ATTRIB(WGL_ACCUM_BLUE_BITS_ARB);
100 ADD_ATTRIB(WGL_ACCUM_ALPHA_BITS_ARB);
101 ADD_ATTRIB(WGL_AUX_BUFFERS_ARB);
102 ADD_ATTRIB(WGL_STEREO_ARB);
103 ADD_ATTRIB(WGL_DOUBLE_BUFFER_ARB);
104
105 if (_glfw.wgl.ARB_multisample)
106 ADD_ATTRIB(WGL_SAMPLES_ARB);
107
108 if (ctxconfig->client == GLFW_OPENGL_API)
109 {
110 if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
111 ADD_ATTRIB(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
112 }
113 else
114 {
115 if (_glfw.wgl.EXT_colorspace)
116 ADD_ATTRIB(WGL_COLORSPACE_EXT);
117 }
118
119 // NOTE: In a Parallels VM WGL_ARB_pixel_format returns fewer pixel formats than
120 // DescribePixelFormat, violating the guarantees of the extension spec
121 // HACK: Iterate through the minimum of both counts
122
123 const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
124 int extensionCount;
125
126 if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
127 1, 0, 1, &attrib, &extensionCount))
128 {
129 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
130 "WGL: Failed to retrieve pixel format attribute");
131 return 0;
132 }
133
134 nativeCount = _glfw_min(nativeCount, extensionCount);
135 }
136
137 usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
138
139 for (i = 0; i < nativeCount; i++)
140 {
141 _GLFWfbconfig* u = usableConfigs + usableCount;
142 pixelFormat = i + 1;
143
144 if (_glfw.wgl.ARB_pixel_format)
145 {
146 // Get pixel format attributes through "modern" extension
147
148 if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
149 pixelFormat, 0,
150 attribCount,
151 attribs, values))
152 {
153 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
154 "WGL: Failed to retrieve pixel format attributes");
155
156 _glfw_free(usableConfigs);
157 return 0;
158 }
159
160 if (!FIND_ATTRIB_VALUE(WGL_SUPPORT_OPENGL_ARB) ||
161 !FIND_ATTRIB_VALUE(WGL_DRAW_TO_WINDOW_ARB))
162 {
163 continue;
164 }
165
166 if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
167 continue;
168
169 if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
170 continue;
171
172 if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
173 continue;
174
175 u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB);
176 u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB);
177 u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB);
178 u->alphaBits = FIND_ATTRIB_VALUE(WGL_ALPHA_BITS_ARB);
179
180 u->depthBits = FIND_ATTRIB_VALUE(WGL_DEPTH_BITS_ARB);
181 u->stencilBits = FIND_ATTRIB_VALUE(WGL_STENCIL_BITS_ARB);
182
183 u->accumRedBits = FIND_ATTRIB_VALUE(WGL_ACCUM_RED_BITS_ARB);
184 u->accumGreenBits = FIND_ATTRIB_VALUE(WGL_ACCUM_GREEN_BITS_ARB);
185 u->accumBlueBits = FIND_ATTRIB_VALUE(WGL_ACCUM_BLUE_BITS_ARB);
186 u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB);
187
188 u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB);
189
190 if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB))
191 u->stereo = GLFW_TRUE;
192
193 if (_glfw.wgl.ARB_multisample)
194 u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB);
195
196 if (ctxconfig->client == GLFW_OPENGL_API)
197 {
198 if (_glfw.wgl.ARB_framebuffer_sRGB ||
199 _glfw.wgl.EXT_framebuffer_sRGB)
200 {
201 if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
202 u->sRGB = GLFW_TRUE;
203 }
204 }
205 else
206 {
207 if (_glfw.wgl.EXT_colorspace)
208 {
209 if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
210 u->sRGB = GLFW_TRUE;
211 }
212 }
213 }
214 else
215 {
216 // Get pixel format attributes through legacy PFDs
217
218 PIXELFORMATDESCRIPTOR pfd;
219
220 if (!DescribePixelFormat(window->context.wgl.dc,
221 pixelFormat,
222 sizeof(PIXELFORMATDESCRIPTOR),
223 &pfd))
224 {
225 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
226 "WGL: Failed to describe pixel format");
227
228 _glfw_free(usableConfigs);
229 return 0;
230 }
231
232 if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
233 !(pfd.dwFlags & PFD_SUPPORT_OPENGL))
234 {
235 continue;
236 }
237
238 if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
239 (pfd.dwFlags & PFD_GENERIC_FORMAT))
240 {
241 continue;
242 }
243
244 if (pfd.iPixelType != PFD_TYPE_RGBA)
245 continue;
246
247 if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
248 continue;
249
250 u->redBits = pfd.cRedBits;
251 u->greenBits = pfd.cGreenBits;
252 u->blueBits = pfd.cBlueBits;
253 u->alphaBits = pfd.cAlphaBits;
254
255 u->depthBits = pfd.cDepthBits;
256 u->stencilBits = pfd.cStencilBits;
257
258 u->accumRedBits = pfd.cAccumRedBits;
259 u->accumGreenBits = pfd.cAccumGreenBits;
260 u->accumBlueBits = pfd.cAccumBlueBits;
261 u->accumAlphaBits = pfd.cAccumAlphaBits;
262
263 u->auxBuffers = pfd.cAuxBuffers;
264
265 if (pfd.dwFlags & PFD_STEREO)
266 u->stereo = GLFW_TRUE;
267 }
268
269 u->handle = pixelFormat;
270 usableCount++;
271 }
272
273 if (!usableCount)
274 {
275 _glfwInputError(GLFW_API_UNAVAILABLE,
276 "WGL: The driver does not appear to support OpenGL");
277
278 _glfw_free(usableConfigs);
279 return 0;
280 }
281
282 closest = _glfwChooseFBConfig(fbconfig, usableConfigs, usableCount);
283 if (!closest)
284 {
285 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
286 "WGL: Failed to find a suitable pixel format");
287
288 _glfw_free(usableConfigs);
289 return 0;
290 }
291
292 pixelFormat = (int) closest->handle;
293 _glfw_free(usableConfigs);
294
295 return pixelFormat;
296}
297
298#undef ADD_ATTRIB
299#undef FIND_ATTRIB_VALUE
300
301static void makeContextCurrentWGL(_GLFWwindow* window)
302{
303 if (window)
304 {
305 if (wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle))
306 _glfwPlatformSetTls(&_glfw.contextSlot, window);
307 else
308 {
309 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
310 "WGL: Failed to make context current");
311 _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
312 }
313 }
314 else
315 {
316 if (!wglMakeCurrent(NULL, NULL))
317 {
318 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
319 "WGL: Failed to clear current context");
320 }
321
322 _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
323 }
324}
325
326static void swapBuffersWGL(_GLFWwindow* window)
327{
328 if (!window->monitor)
329 {
330 // HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7
331 if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
332 {
333 BOOL enabled = FALSE;
334
335 if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
336 {
337 int count = abs(window->context.wgl.interval);
338 while (count--)
339 DwmFlush();
340 }
341 }
342 }
343
344 SwapBuffers(window->context.wgl.dc);
345}
346
347static void swapIntervalWGL(int interval)
348{
349 _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
350 assert(window != NULL);
351
352 window->context.wgl.interval = interval;
353
354 if (!window->monitor)
355 {
356 // HACK: Disable WGL swap interval when desktop composition is enabled on Windows
357 // Vista and 7 to avoid interfering with DWM vsync
358 if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
359 {
360 BOOL enabled = FALSE;
361
362 if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
363 interval = 0;
364 }
365 }
366
367 if (_glfw.wgl.EXT_swap_control)
368 wglSwapIntervalEXT(interval);
369}
370
371static int extensionSupportedWGL(const char* extension)
372{
373 const char* extensions = NULL;
374
375 if (_glfw.wgl.GetExtensionsStringARB)
376 extensions = wglGetExtensionsStringARB(wglGetCurrentDC());
377 else if (_glfw.wgl.GetExtensionsStringEXT)
378 extensions = wglGetExtensionsStringEXT();
379
380 if (!extensions)
381 return GLFW_FALSE;
382
383 return _glfwStringInExtensionString(extension, extensions);
384}
385
386static GLFWglproc getProcAddressWGL(const char* procname)
387{
388 const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname);
389 if (proc)
390 return proc;
391
392 return (GLFWglproc) _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, procname);
393}
394
395static void destroyContextWGL(_GLFWwindow* window)
396{
397 if (window->context.wgl.handle)
398 {
399 wglDeleteContext(window->context.wgl.handle);
400 window->context.wgl.handle = NULL;
401 }
402}
403
404// Initialize WGL
405//
406GLFWbool _glfwInitWGL(void)
407{
408 PIXELFORMATDESCRIPTOR pfd;
409 HGLRC prc, rc;
410 HDC pdc, dc;
411
412 if (_glfw.wgl.instance)
413 return GLFW_TRUE;
414
415 _glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll");
416 if (!_glfw.wgl.instance)
417 {
418 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
419 "WGL: Failed to load opengl32.dll");
420 return GLFW_FALSE;
421 }
422
423 _glfw.wgl.CreateContext = (PFN_wglCreateContext)
424 _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglCreateContext");
425 _glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
426 _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglDeleteContext");
427 _glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
428 _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetProcAddress");
429 _glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
430 _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentDC");
431 _glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
432 _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentContext");
433 _glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
434 _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglMakeCurrent");
435 _glfw.wgl.ShareLists = (PFN_wglShareLists)
436 _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglShareLists");
437
438 // NOTE: A dummy context has to be created for opengl32.dll to load the
439 // OpenGL ICD, from which we can then query WGL extensions
440 // NOTE: This code will accept the Microsoft GDI ICD; accelerated context
441 // creation failure occurs during manual pixel format enumeration
442
443 dc = GetDC(_glfw.win32.helperWindowHandle);
444
445 ZeroMemory(&pfd, sizeof(pfd));
446 pfd.nSize = sizeof(pfd);
447 pfd.nVersion = 1;
448 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
449 pfd.iPixelType = PFD_TYPE_RGBA;
450 pfd.cColorBits = 24;
451
452 if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
453 {
454 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
455 "WGL: Failed to set pixel format for dummy context");
456 return GLFW_FALSE;
457 }
458
459 rc = wglCreateContext(dc);
460 if (!rc)
461 {
462 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
463 "WGL: Failed to create dummy context");
464 return GLFW_FALSE;
465 }
466
467 pdc = wglGetCurrentDC();
468 prc = wglGetCurrentContext();
469
470 if (!wglMakeCurrent(dc, rc))
471 {
472 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
473 "WGL: Failed to make dummy context current");
474 wglMakeCurrent(pdc, prc);
475 wglDeleteContext(rc);
476 return GLFW_FALSE;
477 }
478
479 // NOTE: Functions must be loaded first as they're needed to retrieve the
480 // extension string that tells us whether the functions are supported
481 _glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
482 wglGetProcAddress("wglGetExtensionsStringEXT");
483 _glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
484 wglGetProcAddress("wglGetExtensionsStringARB");
485 _glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
486 wglGetProcAddress("wglCreateContextAttribsARB");
487 _glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
488 wglGetProcAddress("wglSwapIntervalEXT");
489 _glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
490 wglGetProcAddress("wglGetPixelFormatAttribivARB");
491
492 // NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
493 // checked below as we are already using them
494 _glfw.wgl.ARB_multisample =
495 extensionSupportedWGL("WGL_ARB_multisample");
496 _glfw.wgl.ARB_framebuffer_sRGB =
497 extensionSupportedWGL("WGL_ARB_framebuffer_sRGB");
498 _glfw.wgl.EXT_framebuffer_sRGB =
499 extensionSupportedWGL("WGL_EXT_framebuffer_sRGB");
500 _glfw.wgl.ARB_create_context =
501 extensionSupportedWGL("WGL_ARB_create_context");
502 _glfw.wgl.ARB_create_context_profile =
503 extensionSupportedWGL("WGL_ARB_create_context_profile");
504 _glfw.wgl.EXT_create_context_es2_profile =
505 extensionSupportedWGL("WGL_EXT_create_context_es2_profile");
506 _glfw.wgl.ARB_create_context_robustness =
507 extensionSupportedWGL("WGL_ARB_create_context_robustness");
508 _glfw.wgl.ARB_create_context_no_error =
509 extensionSupportedWGL("WGL_ARB_create_context_no_error");
510 _glfw.wgl.EXT_swap_control =
511 extensionSupportedWGL("WGL_EXT_swap_control");
512 _glfw.wgl.EXT_colorspace =
513 extensionSupportedWGL("WGL_EXT_colorspace");
514 _glfw.wgl.ARB_pixel_format =
515 extensionSupportedWGL("WGL_ARB_pixel_format");
516 _glfw.wgl.ARB_context_flush_control =
517 extensionSupportedWGL("WGL_ARB_context_flush_control");
518
519 wglMakeCurrent(pdc, prc);
520 wglDeleteContext(rc);
521 return GLFW_TRUE;
522}
523
524// Terminate WGL
525//
526void _glfwTerminateWGL(void)
527{
528 if (_glfw.wgl.instance)
529 _glfwPlatformFreeModule(_glfw.wgl.instance);
530}
531
532#define SET_ATTRIB(a, v) \
533{ \
534 assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
535 attribs[index++] = a; \
536 attribs[index++] = v; \
537}
538
539// Create the OpenGL or OpenGL ES context
540//
541GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
542 const _GLFWctxconfig* ctxconfig,
543 const _GLFWfbconfig* fbconfig)
544{
545 int attribs[40];
546 int pixelFormat;
547 PIXELFORMATDESCRIPTOR pfd;
548 HGLRC share = NULL;
549
550 if (ctxconfig->share)
551 share = ctxconfig->share->context.wgl.handle;
552
553 window->context.wgl.dc = GetDC(window->win32.handle);
554 if (!window->context.wgl.dc)
555 {
556 _glfwInputError(GLFW_PLATFORM_ERROR,
557 "WGL: Failed to retrieve DC for window");
558 return GLFW_FALSE;
559 }
560
561 pixelFormat = choosePixelFormatWGL(window, ctxconfig, fbconfig);
562 if (!pixelFormat)
563 return GLFW_FALSE;
564
565 if (!DescribePixelFormat(window->context.wgl.dc,
566 pixelFormat, sizeof(pfd), &pfd))
567 {
568 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
569 "WGL: Failed to retrieve PFD for selected pixel format");
570 return GLFW_FALSE;
571 }
572
573 if (!SetPixelFormat(window->context.wgl.dc, pixelFormat, &pfd))
574 {
575 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
576 "WGL: Failed to set selected pixel format");
577 return GLFW_FALSE;
578 }
579
580 if (ctxconfig->client == GLFW_OPENGL_API)
581 {
582 if (ctxconfig->forward)
583 {
584 if (!_glfw.wgl.ARB_create_context)
585 {
586 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
587 "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
588 return GLFW_FALSE;
589 }
590 }
591
592 if (ctxconfig->profile)
593 {
594 if (!_glfw.wgl.ARB_create_context_profile)
595 {
596 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
597 "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
598 return GLFW_FALSE;
599 }
600 }
601 }
602 else
603 {
604 if (!_glfw.wgl.ARB_create_context ||
605 !_glfw.wgl.ARB_create_context_profile ||
606 !_glfw.wgl.EXT_create_context_es2_profile)
607 {
608 _glfwInputError(GLFW_API_UNAVAILABLE,
609 "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
610 return GLFW_FALSE;
611 }
612 }
613
614 if (_glfw.wgl.ARB_create_context)
615 {
616 int index = 0, mask = 0, flags = 0;
617
618 if (ctxconfig->client == GLFW_OPENGL_API)
619 {
620 if (ctxconfig->forward)
621 flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
622
623 if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
624 mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
625 else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
626 mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
627 }
628 else
629 mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
630
631 if (ctxconfig->debug)
632 flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
633
634 if (ctxconfig->robustness)
635 {
636 if (_glfw.wgl.ARB_create_context_robustness)
637 {
638 if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
639 {
640 SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
641 WGL_NO_RESET_NOTIFICATION_ARB);
642 }
643 else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
644 {
645 SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
646 WGL_LOSE_CONTEXT_ON_RESET_ARB);
647 }
648
649 flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
650 }
651 }
652
653 if (ctxconfig->release)
654 {
655 if (_glfw.wgl.ARB_context_flush_control)
656 {
657 if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
658 {
659 SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
660 WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
661 }
662 else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
663 {
664 SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
665 WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
666 }
667 }
668 }
669
670 if (ctxconfig->noerror)
671 {
672 if (_glfw.wgl.ARB_create_context_no_error)
673 SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
674 }
675
676 // NOTE: Only request an explicitly versioned context when necessary, as
677 // explicitly requesting version 1.0 does not always return the
678 // highest version supported by the driver
679 if (ctxconfig->major != 1 || ctxconfig->minor != 0)
680 {
681 SET_ATTRIB(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
682 SET_ATTRIB(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
683 }
684
685 if (flags)
686 SET_ATTRIB(WGL_CONTEXT_FLAGS_ARB, flags);
687
688 if (mask)
689 SET_ATTRIB(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
690
691 SET_ATTRIB(0, 0);
692
693 window->context.wgl.handle =
694 wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
695 if (!window->context.wgl.handle)
696 {
697 const DWORD error = GetLastError();
698
699 if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB))
700 {
701 if (ctxconfig->client == GLFW_OPENGL_API)
702 {
703 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
704 "WGL: Driver does not support OpenGL version %i.%i",
705 ctxconfig->major,
706 ctxconfig->minor);
707 }
708 else
709 {
710 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
711 "WGL: Driver does not support OpenGL ES version %i.%i",
712 ctxconfig->major,
713 ctxconfig->minor);
714 }
715 }
716 else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB))
717 {
718 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
719 "WGL: Driver does not support the requested OpenGL profile");
720 }
721 else if (error == (0xc0070000 | ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB))
722 {
723 _glfwInputError(GLFW_INVALID_VALUE,
724 "WGL: The share context is not compatible with the requested context");
725 }
726 else
727 {
728 if (ctxconfig->client == GLFW_OPENGL_API)
729 {
730 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
731 "WGL: Failed to create OpenGL context");
732 }
733 else
734 {
735 _glfwInputError(GLFW_VERSION_UNAVAILABLE,
736 "WGL: Failed to create OpenGL ES context");
737 }
738 }
739
740 return GLFW_FALSE;
741 }
742 }
743 else
744 {
745 window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
746 if (!window->context.wgl.handle)
747 {
748 _glfwInputErrorWin32(GLFW_VERSION_UNAVAILABLE,
749 "WGL: Failed to create OpenGL context");
750 return GLFW_FALSE;
751 }
752
753 if (share)
754 {
755 if (!wglShareLists(share, window->context.wgl.handle))
756 {
757 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
758 "WGL: Failed to enable sharing with specified OpenGL context");
759 return GLFW_FALSE;
760 }
761 }
762 }
763
764 window->context.makeCurrent = makeContextCurrentWGL;
765 window->context.swapBuffers = swapBuffersWGL;
766 window->context.swapInterval = swapIntervalWGL;
767 window->context.extensionSupported = extensionSupportedWGL;
768 window->context.getProcAddress = getProcAddressWGL;
769 window->context.destroy = destroyContextWGL;
770
771 return GLFW_TRUE;
772}
773
774#undef SET_ATTRIB
775
776GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
777{
778 _GLFWwindow* window = (_GLFWwindow*) handle;
779 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
780
781 if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
782 {
783 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
784 "WGL: Platform not initialized");
785 return NULL;
786 }
787
788 if (window->context.source != GLFW_NATIVE_CONTEXT_API)
789 {
790 _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
791 return NULL;
792 }
793
794 return window->context.wgl.handle;
795}
796
797#endif // _GLFW_WIN32
798
diff --git a/raylib/src/external/glfw/src/win32_init.c b/raylib/src/external/glfw/src/win32_init.c
new file mode 100644
index 0000000..d86e35e
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_init.c
@@ -0,0 +1,732 @@
1//========================================================================
2// GLFW 3.4 Win32 (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#if defined(_GLFW_WIN32)
32
33#include <stdlib.h>
34
35static const GUID _glfw_GUID_DEVINTERFACE_HID =
36 {0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}};
37
38#define GUID_DEVINTERFACE_HID _glfw_GUID_DEVINTERFACE_HID
39
40#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
41
42#if defined(_GLFW_BUILD_DLL)
43 #pragma message("These symbols must be exported by the executable and have no effect in a DLL")
44#endif
45
46// Executables (but not DLLs) exporting this symbol with this value will be
47// automatically directed to the high-performance GPU on Nvidia Optimus systems
48// with up-to-date drivers
49//
50__declspec(dllexport) DWORD NvOptimusEnablement = 1;
51
52// Executables (but not DLLs) exporting this symbol with this value will be
53// automatically directed to the high-performance GPU on AMD PowerXpress systems
54// with up-to-date drivers
55//
56__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
57
58#endif // _GLFW_USE_HYBRID_HPG
59
60#if defined(_GLFW_BUILD_DLL)
61
62// GLFW DLL entry point
63//
64BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
65{
66 return TRUE;
67}
68
69#endif // _GLFW_BUILD_DLL
70
71// Load necessary libraries (DLLs)
72//
73static GLFWbool loadLibraries(void)
74{
75 if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
76 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
77 (const WCHAR*) &_glfw,
78 (HMODULE*) &_glfw.win32.instance))
79 {
80 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
81 "Win32: Failed to retrieve own module handle");
82 return GLFW_FALSE;
83 }
84
85 _glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
86 if (!_glfw.win32.user32.instance)
87 {
88 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
89 "Win32: Failed to load user32.dll");
90 return GLFW_FALSE;
91 }
92
93 _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
94 _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware");
95 _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
96 _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
97 _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
98 _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
99 _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
100 _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
101 _glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
102 _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetDpiForWindow");
103 _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
104 _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
105 _glfw.win32.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi)
106 _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetSystemMetricsForDpi");
107
108 _glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll");
109 if (_glfw.win32.dinput8.instance)
110 {
111 _glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
112 _glfwPlatformGetModuleSymbol(_glfw.win32.dinput8.instance, "DirectInput8Create");
113 }
114
115 {
116 int i;
117 const char* names[] =
118 {
119 "xinput1_4.dll",
120 "xinput1_3.dll",
121 "xinput9_1_0.dll",
122 "xinput1_2.dll",
123 "xinput1_1.dll",
124 NULL
125 };
126
127 for (i = 0; names[i]; i++)
128 {
129 _glfw.win32.xinput.instance = _glfwPlatformLoadModule(names[i]);
130 if (_glfw.win32.xinput.instance)
131 {
132 _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
133 _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetCapabilities");
134 _glfw.win32.xinput.GetState = (PFN_XInputGetState)
135 _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetState");
136
137 break;
138 }
139 }
140 }
141
142 _glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll");
143 if (_glfw.win32.dwmapi.instance)
144 {
145 _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
146 _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
147 _glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
148 _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmFlush");
149 _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
150 _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
151 _glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
152 _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
153 }
154
155 _glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
156 if (_glfw.win32.shcore.instance)
157 {
158 _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
159 _glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
160 _glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor)
161 _glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "GetDpiForMonitor");
162 }
163
164 _glfw.win32.ntdll.instance = _glfwPlatformLoadModule("ntdll.dll");
165 if (_glfw.win32.ntdll.instance)
166 {
167 _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
168 _glfwPlatformGetModuleSymbol(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
169 }
170
171 return GLFW_TRUE;
172}
173
174// Unload used libraries (DLLs)
175//
176static void freeLibraries(void)
177{
178 if (_glfw.win32.xinput.instance)
179 _glfwPlatformFreeModule(_glfw.win32.xinput.instance);
180
181 if (_glfw.win32.dinput8.instance)
182 _glfwPlatformFreeModule(_glfw.win32.dinput8.instance);
183
184 if (_glfw.win32.user32.instance)
185 _glfwPlatformFreeModule(_glfw.win32.user32.instance);
186
187 if (_glfw.win32.dwmapi.instance)
188 _glfwPlatformFreeModule(_glfw.win32.dwmapi.instance);
189
190 if (_glfw.win32.shcore.instance)
191 _glfwPlatformFreeModule(_glfw.win32.shcore.instance);
192
193 if (_glfw.win32.ntdll.instance)
194 _glfwPlatformFreeModule(_glfw.win32.ntdll.instance);
195}
196
197// Create key code translation tables
198//
199static void createKeyTablesWin32(void)
200{
201 int scancode;
202
203 memset(_glfw.win32.keycodes, -1, sizeof(_glfw.win32.keycodes));
204 memset(_glfw.win32.scancodes, -1, sizeof(_glfw.win32.scancodes));
205
206 _glfw.win32.keycodes[0x00B] = GLFW_KEY_0;
207 _glfw.win32.keycodes[0x002] = GLFW_KEY_1;
208 _glfw.win32.keycodes[0x003] = GLFW_KEY_2;
209 _glfw.win32.keycodes[0x004] = GLFW_KEY_3;
210 _glfw.win32.keycodes[0x005] = GLFW_KEY_4;
211 _glfw.win32.keycodes[0x006] = GLFW_KEY_5;
212 _glfw.win32.keycodes[0x007] = GLFW_KEY_6;
213 _glfw.win32.keycodes[0x008] = GLFW_KEY_7;
214 _glfw.win32.keycodes[0x009] = GLFW_KEY_8;
215 _glfw.win32.keycodes[0x00A] = GLFW_KEY_9;
216 _glfw.win32.keycodes[0x01E] = GLFW_KEY_A;
217 _glfw.win32.keycodes[0x030] = GLFW_KEY_B;
218 _glfw.win32.keycodes[0x02E] = GLFW_KEY_C;
219 _glfw.win32.keycodes[0x020] = GLFW_KEY_D;
220 _glfw.win32.keycodes[0x012] = GLFW_KEY_E;
221 _glfw.win32.keycodes[0x021] = GLFW_KEY_F;
222 _glfw.win32.keycodes[0x022] = GLFW_KEY_G;
223 _glfw.win32.keycodes[0x023] = GLFW_KEY_H;
224 _glfw.win32.keycodes[0x017] = GLFW_KEY_I;
225 _glfw.win32.keycodes[0x024] = GLFW_KEY_J;
226 _glfw.win32.keycodes[0x025] = GLFW_KEY_K;
227 _glfw.win32.keycodes[0x026] = GLFW_KEY_L;
228 _glfw.win32.keycodes[0x032] = GLFW_KEY_M;
229 _glfw.win32.keycodes[0x031] = GLFW_KEY_N;
230 _glfw.win32.keycodes[0x018] = GLFW_KEY_O;
231 _glfw.win32.keycodes[0x019] = GLFW_KEY_P;
232 _glfw.win32.keycodes[0x010] = GLFW_KEY_Q;
233 _glfw.win32.keycodes[0x013] = GLFW_KEY_R;
234 _glfw.win32.keycodes[0x01F] = GLFW_KEY_S;
235 _glfw.win32.keycodes[0x014] = GLFW_KEY_T;
236 _glfw.win32.keycodes[0x016] = GLFW_KEY_U;
237 _glfw.win32.keycodes[0x02F] = GLFW_KEY_V;
238 _glfw.win32.keycodes[0x011] = GLFW_KEY_W;
239 _glfw.win32.keycodes[0x02D] = GLFW_KEY_X;
240 _glfw.win32.keycodes[0x015] = GLFW_KEY_Y;
241 _glfw.win32.keycodes[0x02C] = GLFW_KEY_Z;
242
243 _glfw.win32.keycodes[0x028] = GLFW_KEY_APOSTROPHE;
244 _glfw.win32.keycodes[0x02B] = GLFW_KEY_BACKSLASH;
245 _glfw.win32.keycodes[0x033] = GLFW_KEY_COMMA;
246 _glfw.win32.keycodes[0x00D] = GLFW_KEY_EQUAL;
247 _glfw.win32.keycodes[0x029] = GLFW_KEY_GRAVE_ACCENT;
248 _glfw.win32.keycodes[0x01A] = GLFW_KEY_LEFT_BRACKET;
249 _glfw.win32.keycodes[0x00C] = GLFW_KEY_MINUS;
250 _glfw.win32.keycodes[0x034] = GLFW_KEY_PERIOD;
251 _glfw.win32.keycodes[0x01B] = GLFW_KEY_RIGHT_BRACKET;
252 _glfw.win32.keycodes[0x027] = GLFW_KEY_SEMICOLON;
253 _glfw.win32.keycodes[0x035] = GLFW_KEY_SLASH;
254 _glfw.win32.keycodes[0x056] = GLFW_KEY_WORLD_2;
255
256 _glfw.win32.keycodes[0x00E] = GLFW_KEY_BACKSPACE;
257 _glfw.win32.keycodes[0x153] = GLFW_KEY_DELETE;
258 _glfw.win32.keycodes[0x14F] = GLFW_KEY_END;
259 _glfw.win32.keycodes[0x01C] = GLFW_KEY_ENTER;
260 _glfw.win32.keycodes[0x001] = GLFW_KEY_ESCAPE;
261 _glfw.win32.keycodes[0x147] = GLFW_KEY_HOME;
262 _glfw.win32.keycodes[0x152] = GLFW_KEY_INSERT;
263 _glfw.win32.keycodes[0x15D] = GLFW_KEY_MENU;
264 _glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
265 _glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
266 _glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
267 _glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
268 _glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
269 _glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
270 _glfw.win32.keycodes[0x145] = GLFW_KEY_NUM_LOCK;
271 _glfw.win32.keycodes[0x046] = GLFW_KEY_SCROLL_LOCK;
272 _glfw.win32.keycodes[0x03B] = GLFW_KEY_F1;
273 _glfw.win32.keycodes[0x03C] = GLFW_KEY_F2;
274 _glfw.win32.keycodes[0x03D] = GLFW_KEY_F3;
275 _glfw.win32.keycodes[0x03E] = GLFW_KEY_F4;
276 _glfw.win32.keycodes[0x03F] = GLFW_KEY_F5;
277 _glfw.win32.keycodes[0x040] = GLFW_KEY_F6;
278 _glfw.win32.keycodes[0x041] = GLFW_KEY_F7;
279 _glfw.win32.keycodes[0x042] = GLFW_KEY_F8;
280 _glfw.win32.keycodes[0x043] = GLFW_KEY_F9;
281 _glfw.win32.keycodes[0x044] = GLFW_KEY_F10;
282 _glfw.win32.keycodes[0x057] = GLFW_KEY_F11;
283 _glfw.win32.keycodes[0x058] = GLFW_KEY_F12;
284 _glfw.win32.keycodes[0x064] = GLFW_KEY_F13;
285 _glfw.win32.keycodes[0x065] = GLFW_KEY_F14;
286 _glfw.win32.keycodes[0x066] = GLFW_KEY_F15;
287 _glfw.win32.keycodes[0x067] = GLFW_KEY_F16;
288 _glfw.win32.keycodes[0x068] = GLFW_KEY_F17;
289 _glfw.win32.keycodes[0x069] = GLFW_KEY_F18;
290 _glfw.win32.keycodes[0x06A] = GLFW_KEY_F19;
291 _glfw.win32.keycodes[0x06B] = GLFW_KEY_F20;
292 _glfw.win32.keycodes[0x06C] = GLFW_KEY_F21;
293 _glfw.win32.keycodes[0x06D] = GLFW_KEY_F22;
294 _glfw.win32.keycodes[0x06E] = GLFW_KEY_F23;
295 _glfw.win32.keycodes[0x076] = GLFW_KEY_F24;
296 _glfw.win32.keycodes[0x038] = GLFW_KEY_LEFT_ALT;
297 _glfw.win32.keycodes[0x01D] = GLFW_KEY_LEFT_CONTROL;
298 _glfw.win32.keycodes[0x02A] = GLFW_KEY_LEFT_SHIFT;
299 _glfw.win32.keycodes[0x15B] = GLFW_KEY_LEFT_SUPER;
300 _glfw.win32.keycodes[0x137] = GLFW_KEY_PRINT_SCREEN;
301 _glfw.win32.keycodes[0x138] = GLFW_KEY_RIGHT_ALT;
302 _glfw.win32.keycodes[0x11D] = GLFW_KEY_RIGHT_CONTROL;
303 _glfw.win32.keycodes[0x036] = GLFW_KEY_RIGHT_SHIFT;
304 _glfw.win32.keycodes[0x15C] = GLFW_KEY_RIGHT_SUPER;
305 _glfw.win32.keycodes[0x150] = GLFW_KEY_DOWN;
306 _glfw.win32.keycodes[0x14B] = GLFW_KEY_LEFT;
307 _glfw.win32.keycodes[0x14D] = GLFW_KEY_RIGHT;
308 _glfw.win32.keycodes[0x148] = GLFW_KEY_UP;
309
310 _glfw.win32.keycodes[0x052] = GLFW_KEY_KP_0;
311 _glfw.win32.keycodes[0x04F] = GLFW_KEY_KP_1;
312 _glfw.win32.keycodes[0x050] = GLFW_KEY_KP_2;
313 _glfw.win32.keycodes[0x051] = GLFW_KEY_KP_3;
314 _glfw.win32.keycodes[0x04B] = GLFW_KEY_KP_4;
315 _glfw.win32.keycodes[0x04C] = GLFW_KEY_KP_5;
316 _glfw.win32.keycodes[0x04D] = GLFW_KEY_KP_6;
317 _glfw.win32.keycodes[0x047] = GLFW_KEY_KP_7;
318 _glfw.win32.keycodes[0x048] = GLFW_KEY_KP_8;
319 _glfw.win32.keycodes[0x049] = GLFW_KEY_KP_9;
320 _glfw.win32.keycodes[0x04E] = GLFW_KEY_KP_ADD;
321 _glfw.win32.keycodes[0x053] = GLFW_KEY_KP_DECIMAL;
322 _glfw.win32.keycodes[0x135] = GLFW_KEY_KP_DIVIDE;
323 _glfw.win32.keycodes[0x11C] = GLFW_KEY_KP_ENTER;
324 _glfw.win32.keycodes[0x059] = GLFW_KEY_KP_EQUAL;
325 _glfw.win32.keycodes[0x037] = GLFW_KEY_KP_MULTIPLY;
326 _glfw.win32.keycodes[0x04A] = GLFW_KEY_KP_SUBTRACT;
327
328 for (scancode = 0; scancode < 512; scancode++)
329 {
330 if (_glfw.win32.keycodes[scancode] > 0)
331 _glfw.win32.scancodes[_glfw.win32.keycodes[scancode]] = scancode;
332 }
333}
334
335// Window procedure for the hidden helper window
336//
337static LRESULT CALLBACK helperWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
338{
339 switch (uMsg)
340 {
341 case WM_DISPLAYCHANGE:
342 _glfwPollMonitorsWin32();
343 break;
344
345 case WM_DEVICECHANGE:
346 {
347 if (!_glfw.joysticksInitialized)
348 break;
349
350 if (wParam == DBT_DEVICEARRIVAL)
351 {
352 DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
353 if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
354 _glfwDetectJoystickConnectionWin32();
355 }
356 else if (wParam == DBT_DEVICEREMOVECOMPLETE)
357 {
358 DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
359 if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
360 _glfwDetectJoystickDisconnectionWin32();
361 }
362
363 break;
364 }
365 }
366
367 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
368}
369
370// Creates a dummy window for behind-the-scenes work
371//
372static GLFWbool createHelperWindow(void)
373{
374 MSG msg;
375 WNDCLASSEXW wc = { sizeof(wc) };
376
377 wc.style = CS_OWNDC;
378 wc.lpfnWndProc = (WNDPROC) helperWindowProc;
379 wc.hInstance = _glfw.win32.instance;
380 wc.lpszClassName = L"GLFW3 Helper";
381
382 _glfw.win32.helperWindowClass = RegisterClassExW(&wc);
383 if (!_glfw.win32.helperWindowClass)
384 {
385 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
386 "Win32: Failed to register helper window class");
387 return GLFW_FALSE;
388 }
389
390 _glfw.win32.helperWindowHandle =
391 CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
392 MAKEINTATOM(_glfw.win32.helperWindowClass),
393 L"GLFW message window",
394 WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
395 0, 0, 1, 1,
396 NULL, NULL,
397 _glfw.win32.instance,
398 NULL);
399
400 if (!_glfw.win32.helperWindowHandle)
401 {
402 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
403 "Win32: Failed to create helper window");
404 return GLFW_FALSE;
405 }
406
407 // HACK: The command to the first ShowWindow call is ignored if the parent
408 // process passed along a STARTUPINFO, so clear that with a no-op call
409 ShowWindow(_glfw.win32.helperWindowHandle, SW_HIDE);
410
411 // Register for HID device notifications
412 {
413 DEV_BROADCAST_DEVICEINTERFACE_W dbi;
414 ZeroMemory(&dbi, sizeof(dbi));
415 dbi.dbcc_size = sizeof(dbi);
416 dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
417 dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
418
419 _glfw.win32.deviceNotificationHandle =
420 RegisterDeviceNotificationW(_glfw.win32.helperWindowHandle,
421 (DEV_BROADCAST_HDR*) &dbi,
422 DEVICE_NOTIFY_WINDOW_HANDLE);
423 }
424
425 while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
426 {
427 TranslateMessage(&msg);
428 DispatchMessageW(&msg);
429 }
430
431 return GLFW_TRUE;
432}
433
434//////////////////////////////////////////////////////////////////////////
435////// GLFW internal API //////
436//////////////////////////////////////////////////////////////////////////
437
438// Returns a wide string version of the specified UTF-8 string
439//
440WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
441{
442 WCHAR* target;
443 int count;
444
445 count = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);
446 if (!count)
447 {
448 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
449 "Win32: Failed to convert string from UTF-8");
450 return NULL;
451 }
452
453 target = _glfw_calloc(count, sizeof(WCHAR));
454
455 if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
456 {
457 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
458 "Win32: Failed to convert string from UTF-8");
459 _glfw_free(target);
460 return NULL;
461 }
462
463 return target;
464}
465
466// Returns a UTF-8 string version of the specified wide string
467//
468char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
469{
470 char* target;
471 int size;
472
473 size = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);
474 if (!size)
475 {
476 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
477 "Win32: Failed to convert string to UTF-8");
478 return NULL;
479 }
480
481 target = _glfw_calloc(size, 1);
482
483 if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
484 {
485 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
486 "Win32: Failed to convert string to UTF-8");
487 _glfw_free(target);
488 return NULL;
489 }
490
491 return target;
492}
493
494// Reports the specified error, appending information about the last Win32 error
495//
496void _glfwInputErrorWin32(int error, const char* description)
497{
498 WCHAR buffer[_GLFW_MESSAGE_SIZE] = L"";
499 char message[_GLFW_MESSAGE_SIZE] = "";
500
501 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
502 FORMAT_MESSAGE_IGNORE_INSERTS |
503 FORMAT_MESSAGE_MAX_WIDTH_MASK,
504 NULL,
505 GetLastError() & 0xffff,
506 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
507 buffer,
508 sizeof(buffer) / sizeof(WCHAR),
509 NULL);
510 WideCharToMultiByte(CP_UTF8, 0, buffer, -1, message, sizeof(message), NULL, NULL);
511
512 _glfwInputError(error, "%s: %s", description, message);
513}
514
515// Updates key names according to the current keyboard layout
516//
517void _glfwUpdateKeyNamesWin32(void)
518{
519 int key;
520 BYTE state[256] = {0};
521
522 memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames));
523
524 for (key = GLFW_KEY_SPACE; key <= GLFW_KEY_LAST; key++)
525 {
526 UINT vk;
527 int scancode, length;
528 WCHAR chars[16];
529
530 scancode = _glfw.win32.scancodes[key];
531 if (scancode == -1)
532 continue;
533
534 if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_ADD)
535 {
536 const UINT vks[] = {
537 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
538 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
539 VK_NUMPAD8, VK_NUMPAD9, VK_DECIMAL, VK_DIVIDE,
540 VK_MULTIPLY, VK_SUBTRACT, VK_ADD
541 };
542
543 vk = vks[key - GLFW_KEY_KP_0];
544 }
545 else
546 vk = MapVirtualKeyW(scancode, MAPVK_VSC_TO_VK);
547
548 length = ToUnicode(vk, scancode, state,
549 chars, sizeof(chars) / sizeof(WCHAR),
550 0);
551
552 if (length == -1)
553 {
554 // This is a dead key, so we need a second simulated key press
555 // to make it output its own character (usually a diacritic)
556 length = ToUnicode(vk, scancode, state,
557 chars, sizeof(chars) / sizeof(WCHAR),
558 0);
559 }
560
561 if (length < 1)
562 continue;
563
564 WideCharToMultiByte(CP_UTF8, 0, chars, 1,
565 _glfw.win32.keynames[key],
566 sizeof(_glfw.win32.keynames[key]),
567 NULL, NULL);
568 }
569}
570
571// Replacement for IsWindowsVersionOrGreater, as we cannot rely on the
572// application having a correct embedded manifest
573//
574BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
575{
576 OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, {0}, sp };
577 DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
578 ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
579 cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
580 cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
581 // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
582 // latter lies unless the user knew to embed a non-default manifest
583 // announcing support for Windows 10 via supportedOS GUID
584 return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
585}
586
587// Checks whether we are on at least the specified build of Windows 10
588//
589BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
590{
591 OSVERSIONINFOEXW osvi = { sizeof(osvi), 10, 0, build };
592 DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER;
593 ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
594 cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
595 cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
596 // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
597 // latter lies unless the user knew to embed a non-default manifest
598 // announcing support for Windows 10 via supportedOS GUID
599 return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
600}
601
602GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
603{
604 const _GLFWplatform win32 =
605 {
606 .platformID = GLFW_PLATFORM_WIN32,
607 .init = _glfwInitWin32,
608 .terminate = _glfwTerminateWin32,
609 .getCursorPos = _glfwGetCursorPosWin32,
610 .setCursorPos = _glfwSetCursorPosWin32,
611 .setCursorMode = _glfwSetCursorModeWin32,
612 .setRawMouseMotion = _glfwSetRawMouseMotionWin32,
613 .rawMouseMotionSupported = _glfwRawMouseMotionSupportedWin32,
614 .createCursor = _glfwCreateCursorWin32,
615 .createStandardCursor = _glfwCreateStandardCursorWin32,
616 .destroyCursor = _glfwDestroyCursorWin32,
617 .setCursor = _glfwSetCursorWin32,
618 .getScancodeName = _glfwGetScancodeNameWin32,
619 .getKeyScancode = _glfwGetKeyScancodeWin32,
620 .setClipboardString = _glfwSetClipboardStringWin32,
621 .getClipboardString = _glfwGetClipboardStringWin32,
622 .initJoysticks = _glfwInitJoysticksWin32,
623 .terminateJoysticks = _glfwTerminateJoysticksWin32,
624 .pollJoystick = _glfwPollJoystickWin32,
625 .getMappingName = _glfwGetMappingNameWin32,
626 .updateGamepadGUID = _glfwUpdateGamepadGUIDWin32,
627 .freeMonitor = _glfwFreeMonitorWin32,
628 .getMonitorPos = _glfwGetMonitorPosWin32,
629 .getMonitorContentScale = _glfwGetMonitorContentScaleWin32,
630 .getMonitorWorkarea = _glfwGetMonitorWorkareaWin32,
631 .getVideoModes = _glfwGetVideoModesWin32,
632 .getVideoMode = _glfwGetVideoModeWin32,
633 .getGammaRamp = _glfwGetGammaRampWin32,
634 .setGammaRamp = _glfwSetGammaRampWin32,
635 .createWindow = _glfwCreateWindowWin32,
636 .destroyWindow = _glfwDestroyWindowWin32,
637 .setWindowTitle = _glfwSetWindowTitleWin32,
638 .setWindowIcon = _glfwSetWindowIconWin32,
639 .getWindowPos = _glfwGetWindowPosWin32,
640 .setWindowPos = _glfwSetWindowPosWin32,
641 .getWindowSize = _glfwGetWindowSizeWin32,
642 .setWindowSize = _glfwSetWindowSizeWin32,
643 .setWindowSizeLimits = _glfwSetWindowSizeLimitsWin32,
644 .setWindowAspectRatio = _glfwSetWindowAspectRatioWin32,
645 .getFramebufferSize = _glfwGetFramebufferSizeWin32,
646 .getWindowFrameSize = _glfwGetWindowFrameSizeWin32,
647 .getWindowContentScale = _glfwGetWindowContentScaleWin32,
648 .iconifyWindow = _glfwIconifyWindowWin32,
649 .restoreWindow = _glfwRestoreWindowWin32,
650 .maximizeWindow = _glfwMaximizeWindowWin32,
651 .showWindow = _glfwShowWindowWin32,
652 .hideWindow = _glfwHideWindowWin32,
653 .requestWindowAttention = _glfwRequestWindowAttentionWin32,
654 .focusWindow = _glfwFocusWindowWin32,
655 .setWindowMonitor = _glfwSetWindowMonitorWin32,
656 .windowFocused = _glfwWindowFocusedWin32,
657 .windowIconified = _glfwWindowIconifiedWin32,
658 .windowVisible = _glfwWindowVisibleWin32,
659 .windowMaximized = _glfwWindowMaximizedWin32,
660 .windowHovered = _glfwWindowHoveredWin32,
661 .framebufferTransparent = _glfwFramebufferTransparentWin32,
662 .getWindowOpacity = _glfwGetWindowOpacityWin32,
663 .setWindowResizable = _glfwSetWindowResizableWin32,
664 .setWindowDecorated = _glfwSetWindowDecoratedWin32,
665 .setWindowFloating = _glfwSetWindowFloatingWin32,
666 .setWindowOpacity = _glfwSetWindowOpacityWin32,
667 .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWin32,
668 .pollEvents = _glfwPollEventsWin32,
669 .waitEvents = _glfwWaitEventsWin32,
670 .waitEventsTimeout = _glfwWaitEventsTimeoutWin32,
671 .postEmptyEvent = _glfwPostEmptyEventWin32,
672 .getEGLPlatform = _glfwGetEGLPlatformWin32,
673 .getEGLNativeDisplay = _glfwGetEGLNativeDisplayWin32,
674 .getEGLNativeWindow = _glfwGetEGLNativeWindowWin32,
675 .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWin32,
676 .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWin32,
677 .createWindowSurface = _glfwCreateWindowSurfaceWin32
678 };
679
680 *platform = win32;
681 return GLFW_TRUE;
682}
683
684int _glfwInitWin32(void)
685{
686 if (!loadLibraries())
687 return GLFW_FALSE;
688
689 createKeyTablesWin32();
690 _glfwUpdateKeyNamesWin32();
691
692 if (_glfwIsWindows10Version1703OrGreaterWin32())
693 SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
694 else if (IsWindows8Point1OrGreater())
695 SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
696 else if (IsWindowsVistaOrGreater())
697 SetProcessDPIAware();
698
699 if (!createHelperWindow())
700 return GLFW_FALSE;
701
702 _glfwPollMonitorsWin32();
703 return GLFW_TRUE;
704}
705
706void _glfwTerminateWin32(void)
707{
708 if (_glfw.win32.blankCursor)
709 DestroyIcon((HICON) _glfw.win32.blankCursor);
710
711 if (_glfw.win32.deviceNotificationHandle)
712 UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
713
714 if (_glfw.win32.helperWindowHandle)
715 DestroyWindow(_glfw.win32.helperWindowHandle);
716 if (_glfw.win32.helperWindowClass)
717 UnregisterClassW(MAKEINTATOM(_glfw.win32.helperWindowClass), _glfw.win32.instance);
718 if (_glfw.win32.mainWindowClass)
719 UnregisterClassW(MAKEINTATOM(_glfw.win32.mainWindowClass), _glfw.win32.instance);
720
721 _glfw_free(_glfw.win32.clipboardString);
722 _glfw_free(_glfw.win32.rawInput);
723
724 _glfwTerminateWGL();
725 _glfwTerminateEGL();
726 _glfwTerminateOSMesa();
727
728 freeLibraries();
729}
730
731#endif // _GLFW_WIN32
732
diff --git a/raylib/src/external/glfw/src/win32_joystick.c b/raylib/src/external/glfw/src/win32_joystick.c
new file mode 100644
index 0000000..59389a9
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_joystick.c
@@ -0,0 +1,767 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_WIN32)
31
32#include <stdio.h>
33#include <math.h>
34
35#define _GLFW_TYPE_AXIS 0
36#define _GLFW_TYPE_SLIDER 1
37#define _GLFW_TYPE_BUTTON 2
38#define _GLFW_TYPE_POV 3
39
40// Data produced with DirectInput device object enumeration
41//
42typedef struct _GLFWobjenumWin32
43{
44 IDirectInputDevice8W* device;
45 _GLFWjoyobjectWin32* objects;
46 int objectCount;
47 int axisCount;
48 int sliderCount;
49 int buttonCount;
50 int povCount;
51} _GLFWobjenumWin32;
52
53// Define local copies of the necessary GUIDs
54//
55static const GUID _glfw_IID_IDirectInput8W =
56 {0xbf798031,0x483a,0x4da2,{0xaa,0x99,0x5d,0x64,0xed,0x36,0x97,0x00}};
57static const GUID _glfw_GUID_XAxis =
58 {0xa36d02e0,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
59static const GUID _glfw_GUID_YAxis =
60 {0xa36d02e1,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
61static const GUID _glfw_GUID_ZAxis =
62 {0xa36d02e2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
63static const GUID _glfw_GUID_RxAxis =
64 {0xa36d02f4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
65static const GUID _glfw_GUID_RyAxis =
66 {0xa36d02f5,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
67static const GUID _glfw_GUID_RzAxis =
68 {0xa36d02e3,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
69static const GUID _glfw_GUID_Slider =
70 {0xa36d02e4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
71static const GUID _glfw_GUID_POV =
72 {0xa36d02f2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
73
74#define IID_IDirectInput8W _glfw_IID_IDirectInput8W
75#define GUID_XAxis _glfw_GUID_XAxis
76#define GUID_YAxis _glfw_GUID_YAxis
77#define GUID_ZAxis _glfw_GUID_ZAxis
78#define GUID_RxAxis _glfw_GUID_RxAxis
79#define GUID_RyAxis _glfw_GUID_RyAxis
80#define GUID_RzAxis _glfw_GUID_RzAxis
81#define GUID_Slider _glfw_GUID_Slider
82#define GUID_POV _glfw_GUID_POV
83
84// Object data array for our clone of c_dfDIJoystick
85// Generated with https://github.com/elmindreda/c_dfDIJoystick2
86//
87static DIOBJECTDATAFORMAT _glfwObjectDataFormats[] =
88{
89 { &GUID_XAxis,DIJOFS_X,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
90 { &GUID_YAxis,DIJOFS_Y,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
91 { &GUID_ZAxis,DIJOFS_Z,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
92 { &GUID_RxAxis,DIJOFS_RX,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
93 { &GUID_RyAxis,DIJOFS_RY,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
94 { &GUID_RzAxis,DIJOFS_RZ,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
95 { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
96 { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
97 { &GUID_POV,DIJOFS_POV(0),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
98 { &GUID_POV,DIJOFS_POV(1),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
99 { &GUID_POV,DIJOFS_POV(2),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
100 { &GUID_POV,DIJOFS_POV(3),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
101 { NULL,DIJOFS_BUTTON(0),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
102 { NULL,DIJOFS_BUTTON(1),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
103 { NULL,DIJOFS_BUTTON(2),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
104 { NULL,DIJOFS_BUTTON(3),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
105 { NULL,DIJOFS_BUTTON(4),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
106 { NULL,DIJOFS_BUTTON(5),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
107 { NULL,DIJOFS_BUTTON(6),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
108 { NULL,DIJOFS_BUTTON(7),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
109 { NULL,DIJOFS_BUTTON(8),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
110 { NULL,DIJOFS_BUTTON(9),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
111 { NULL,DIJOFS_BUTTON(10),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
112 { NULL,DIJOFS_BUTTON(11),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
113 { NULL,DIJOFS_BUTTON(12),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
114 { NULL,DIJOFS_BUTTON(13),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
115 { NULL,DIJOFS_BUTTON(14),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
116 { NULL,DIJOFS_BUTTON(15),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
117 { NULL,DIJOFS_BUTTON(16),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
118 { NULL,DIJOFS_BUTTON(17),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
119 { NULL,DIJOFS_BUTTON(18),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
120 { NULL,DIJOFS_BUTTON(19),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
121 { NULL,DIJOFS_BUTTON(20),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
122 { NULL,DIJOFS_BUTTON(21),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
123 { NULL,DIJOFS_BUTTON(22),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
124 { NULL,DIJOFS_BUTTON(23),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
125 { NULL,DIJOFS_BUTTON(24),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
126 { NULL,DIJOFS_BUTTON(25),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
127 { NULL,DIJOFS_BUTTON(26),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
128 { NULL,DIJOFS_BUTTON(27),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
129 { NULL,DIJOFS_BUTTON(28),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
130 { NULL,DIJOFS_BUTTON(29),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
131 { NULL,DIJOFS_BUTTON(30),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
132 { NULL,DIJOFS_BUTTON(31),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
133};
134
135// Our clone of c_dfDIJoystick
136//
137static const DIDATAFORMAT _glfwDataFormat =
138{
139 sizeof(DIDATAFORMAT),
140 sizeof(DIOBJECTDATAFORMAT),
141 DIDFT_ABSAXIS,
142 sizeof(DIJOYSTATE),
143 sizeof(_glfwObjectDataFormats) / sizeof(DIOBJECTDATAFORMAT),
144 _glfwObjectDataFormats
145};
146
147// Returns a description fitting the specified XInput capabilities
148//
149static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
150{
151 switch (xic->SubType)
152 {
153 case XINPUT_DEVSUBTYPE_WHEEL:
154 return "XInput Wheel";
155 case XINPUT_DEVSUBTYPE_ARCADE_STICK:
156 return "XInput Arcade Stick";
157 case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
158 return "XInput Flight Stick";
159 case XINPUT_DEVSUBTYPE_DANCE_PAD:
160 return "XInput Dance Pad";
161 case XINPUT_DEVSUBTYPE_GUITAR:
162 return "XInput Guitar";
163 case XINPUT_DEVSUBTYPE_DRUM_KIT:
164 return "XInput Drum Kit";
165 case XINPUT_DEVSUBTYPE_GAMEPAD:
166 {
167 if (xic->Flags & XINPUT_CAPS_WIRELESS)
168 return "Wireless Xbox Controller";
169 else
170 return "Xbox Controller";
171 }
172 }
173
174 return "Unknown XInput Device";
175}
176
177// Lexically compare device objects
178//
179static int compareJoystickObjects(const void* first, const void* second)
180{
181 const _GLFWjoyobjectWin32* fo = first;
182 const _GLFWjoyobjectWin32* so = second;
183
184 if (fo->type != so->type)
185 return fo->type - so->type;
186
187 return fo->offset - so->offset;
188}
189
190// Checks whether the specified device supports XInput
191// Technique from FDInputJoystickManager::IsXInputDeviceFast in ZDoom
192//
193static GLFWbool supportsXInput(const GUID* guid)
194{
195 UINT i, count = 0;
196 RAWINPUTDEVICELIST* ridl;
197 GLFWbool result = GLFW_FALSE;
198
199 if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
200 return GLFW_FALSE;
201
202 ridl = _glfw_calloc(count, sizeof(RAWINPUTDEVICELIST));
203
204 if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
205 {
206 _glfw_free(ridl);
207 return GLFW_FALSE;
208 }
209
210 for (i = 0; i < count; i++)
211 {
212 RID_DEVICE_INFO rdi;
213 char name[256];
214 UINT size;
215
216 if (ridl[i].dwType != RIM_TYPEHID)
217 continue;
218
219 ZeroMemory(&rdi, sizeof(rdi));
220 rdi.cbSize = sizeof(rdi);
221 size = sizeof(rdi);
222
223 if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
224 RIDI_DEVICEINFO,
225 &rdi, &size) == -1)
226 {
227 continue;
228 }
229
230 if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
231 continue;
232
233 memset(name, 0, sizeof(name));
234 size = sizeof(name);
235
236 if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
237 RIDI_DEVICENAME,
238 name, &size) == -1)
239 {
240 break;
241 }
242
243 name[sizeof(name) - 1] = '\0';
244 if (strstr(name, "IG_"))
245 {
246 result = GLFW_TRUE;
247 break;
248 }
249 }
250
251 _glfw_free(ridl);
252 return result;
253}
254
255// Frees all resources associated with the specified joystick
256//
257static void closeJoystick(_GLFWjoystick* js)
258{
259 _glfwInputJoystick(js, GLFW_DISCONNECTED);
260
261 if (js->win32.device)
262 {
263 IDirectInputDevice8_Unacquire(js->win32.device);
264 IDirectInputDevice8_Release(js->win32.device);
265 }
266
267 _glfw_free(js->win32.objects);
268 _glfwFreeJoystick(js);
269}
270
271// DirectInput device object enumeration callback
272// Insights gleaned from SDL
273//
274static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
275 void* user)
276{
277 _GLFWobjenumWin32* data = user;
278 _GLFWjoyobjectWin32* object = data->objects + data->objectCount;
279
280 if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
281 {
282 DIPROPRANGE dipr;
283
284 if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
285 object->offset = DIJOFS_SLIDER(data->sliderCount);
286 else if (memcmp(&doi->guidType, &GUID_XAxis, sizeof(GUID)) == 0)
287 object->offset = DIJOFS_X;
288 else if (memcmp(&doi->guidType, &GUID_YAxis, sizeof(GUID)) == 0)
289 object->offset = DIJOFS_Y;
290 else if (memcmp(&doi->guidType, &GUID_ZAxis, sizeof(GUID)) == 0)
291 object->offset = DIJOFS_Z;
292 else if (memcmp(&doi->guidType, &GUID_RxAxis, sizeof(GUID)) == 0)
293 object->offset = DIJOFS_RX;
294 else if (memcmp(&doi->guidType, &GUID_RyAxis, sizeof(GUID)) == 0)
295 object->offset = DIJOFS_RY;
296 else if (memcmp(&doi->guidType, &GUID_RzAxis, sizeof(GUID)) == 0)
297 object->offset = DIJOFS_RZ;
298 else
299 return DIENUM_CONTINUE;
300
301 ZeroMemory(&dipr, sizeof(dipr));
302 dipr.diph.dwSize = sizeof(dipr);
303 dipr.diph.dwHeaderSize = sizeof(dipr.diph);
304 dipr.diph.dwObj = doi->dwType;
305 dipr.diph.dwHow = DIPH_BYID;
306 dipr.lMin = -32768;
307 dipr.lMax = 32767;
308
309 if (FAILED(IDirectInputDevice8_SetProperty(data->device,
310 DIPROP_RANGE,
311 &dipr.diph)))
312 {
313 return DIENUM_CONTINUE;
314 }
315
316 if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
317 {
318 object->type = _GLFW_TYPE_SLIDER;
319 data->sliderCount++;
320 }
321 else
322 {
323 object->type = _GLFW_TYPE_AXIS;
324 data->axisCount++;
325 }
326 }
327 else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_BUTTON)
328 {
329 object->offset = DIJOFS_BUTTON(data->buttonCount);
330 object->type = _GLFW_TYPE_BUTTON;
331 data->buttonCount++;
332 }
333 else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_POV)
334 {
335 object->offset = DIJOFS_POV(data->povCount);
336 object->type = _GLFW_TYPE_POV;
337 data->povCount++;
338 }
339
340 data->objectCount++;
341 return DIENUM_CONTINUE;
342}
343
344// DirectInput device enumeration callback
345//
346static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
347{
348 int jid = 0;
349 DIDEVCAPS dc;
350 DIPROPDWORD dipd;
351 IDirectInputDevice8* device;
352 _GLFWobjenumWin32 data;
353 _GLFWjoystick* js;
354 char guid[33];
355 char name[256];
356
357 for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
358 {
359 js = _glfw.joysticks + jid;
360 if (js->connected)
361 {
362 if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
363 return DIENUM_CONTINUE;
364 }
365 }
366
367 if (supportsXInput(&di->guidProduct))
368 return DIENUM_CONTINUE;
369
370 if (FAILED(IDirectInput8_CreateDevice(_glfw.win32.dinput8.api,
371 &di->guidInstance,
372 &device,
373 NULL)))
374 {
375 _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create device");
376 return DIENUM_CONTINUE;
377 }
378
379 if (FAILED(IDirectInputDevice8_SetDataFormat(device, &_glfwDataFormat)))
380 {
381 _glfwInputError(GLFW_PLATFORM_ERROR,
382 "Win32: Failed to set device data format");
383
384 IDirectInputDevice8_Release(device);
385 return DIENUM_CONTINUE;
386 }
387
388 ZeroMemory(&dc, sizeof(dc));
389 dc.dwSize = sizeof(dc);
390
391 if (FAILED(IDirectInputDevice8_GetCapabilities(device, &dc)))
392 {
393 _glfwInputError(GLFW_PLATFORM_ERROR,
394 "Win32: Failed to query device capabilities");
395
396 IDirectInputDevice8_Release(device);
397 return DIENUM_CONTINUE;
398 }
399
400 ZeroMemory(&dipd, sizeof(dipd));
401 dipd.diph.dwSize = sizeof(dipd);
402 dipd.diph.dwHeaderSize = sizeof(dipd.diph);
403 dipd.diph.dwHow = DIPH_DEVICE;
404 dipd.dwData = DIPROPAXISMODE_ABS;
405
406 if (FAILED(IDirectInputDevice8_SetProperty(device,
407 DIPROP_AXISMODE,
408 &dipd.diph)))
409 {
410 _glfwInputError(GLFW_PLATFORM_ERROR,
411 "Win32: Failed to set device axis mode");
412
413 IDirectInputDevice8_Release(device);
414 return DIENUM_CONTINUE;
415 }
416
417 memset(&data, 0, sizeof(data));
418 data.device = device;
419 data.objects = _glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
420 sizeof(_GLFWjoyobjectWin32));
421
422 if (FAILED(IDirectInputDevice8_EnumObjects(device,
423 deviceObjectCallback,
424 &data,
425 DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV)))
426 {
427 _glfwInputError(GLFW_PLATFORM_ERROR,
428 "Win32: Failed to enumerate device objects");
429
430 IDirectInputDevice8_Release(device);
431 _glfw_free(data.objects);
432 return DIENUM_CONTINUE;
433 }
434
435 qsort(data.objects, data.objectCount,
436 sizeof(_GLFWjoyobjectWin32),
437 compareJoystickObjects);
438
439 if (!WideCharToMultiByte(CP_UTF8, 0,
440 di->tszInstanceName, -1,
441 name, sizeof(name),
442 NULL, NULL))
443 {
444 _glfwInputError(GLFW_PLATFORM_ERROR,
445 "Win32: Failed to convert joystick name to UTF-8");
446
447 IDirectInputDevice8_Release(device);
448 _glfw_free(data.objects);
449 return DIENUM_STOP;
450 }
451
452 // Generate a joystick GUID that matches the SDL 2.0.5+ one
453 if (memcmp(&di->guidProduct.Data4[2], "PIDVID", 6) == 0)
454 {
455 sprintf(guid, "03000000%02x%02x0000%02x%02x000000000000",
456 (uint8_t) di->guidProduct.Data1,
457 (uint8_t) (di->guidProduct.Data1 >> 8),
458 (uint8_t) (di->guidProduct.Data1 >> 16),
459 (uint8_t) (di->guidProduct.Data1 >> 24));
460 }
461 else
462 {
463 sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
464 name[0], name[1], name[2], name[3],
465 name[4], name[5], name[6], name[7],
466 name[8], name[9], name[10]);
467 }
468
469 js = _glfwAllocJoystick(name, guid,
470 data.axisCount + data.sliderCount,
471 data.buttonCount,
472 data.povCount);
473 if (!js)
474 {
475 IDirectInputDevice8_Release(device);
476 _glfw_free(data.objects);
477 return DIENUM_STOP;
478 }
479
480 js->win32.device = device;
481 js->win32.guid = di->guidInstance;
482 js->win32.objects = data.objects;
483 js->win32.objectCount = data.objectCount;
484
485 _glfwInputJoystick(js, GLFW_CONNECTED);
486 return DIENUM_CONTINUE;
487}
488
489
490//////////////////////////////////////////////////////////////////////////
491////// GLFW internal API //////
492//////////////////////////////////////////////////////////////////////////
493
494// Checks for new joysticks after DBT_DEVICEARRIVAL
495//
496void _glfwDetectJoystickConnectionWin32(void)
497{
498 if (_glfw.win32.xinput.instance)
499 {
500 DWORD index;
501
502 for (index = 0; index < XUSER_MAX_COUNT; index++)
503 {
504 int jid;
505 char guid[33];
506 XINPUT_CAPABILITIES xic;
507 _GLFWjoystick* js;
508
509 for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
510 {
511 if (_glfw.joysticks[jid].connected &&
512 _glfw.joysticks[jid].win32.device == NULL &&
513 _glfw.joysticks[jid].win32.index == index)
514 {
515 break;
516 }
517 }
518
519 if (jid <= GLFW_JOYSTICK_LAST)
520 continue;
521
522 if (XInputGetCapabilities(index, 0, &xic) != ERROR_SUCCESS)
523 continue;
524
525 // Generate a joystick GUID that matches the SDL 2.0.5+ one
526 sprintf(guid, "78696e707574%02x000000000000000000",
527 xic.SubType & 0xff);
528
529 js = _glfwAllocJoystick(getDeviceDescription(&xic), guid, 6, 10, 1);
530 if (!js)
531 continue;
532
533 js->win32.index = index;
534
535 _glfwInputJoystick(js, GLFW_CONNECTED);
536 }
537 }
538
539 if (_glfw.win32.dinput8.api)
540 {
541 if (FAILED(IDirectInput8_EnumDevices(_glfw.win32.dinput8.api,
542 DI8DEVCLASS_GAMECTRL,
543 deviceCallback,
544 NULL,
545 DIEDFL_ALLDEVICES)))
546 {
547 _glfwInputError(GLFW_PLATFORM_ERROR,
548 "Failed to enumerate DirectInput8 devices");
549 return;
550 }
551 }
552}
553
554// Checks for joystick disconnection after DBT_DEVICEREMOVECOMPLETE
555//
556void _glfwDetectJoystickDisconnectionWin32(void)
557{
558 int jid;
559
560 for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
561 {
562 _GLFWjoystick* js = _glfw.joysticks + jid;
563 if (js->connected)
564 _glfwPollJoystickWin32(js, _GLFW_POLL_PRESENCE);
565 }
566}
567
568
569//////////////////////////////////////////////////////////////////////////
570////// GLFW platform API //////
571//////////////////////////////////////////////////////////////////////////
572
573GLFWbool _glfwInitJoysticksWin32(void)
574{
575 if (_glfw.win32.dinput8.instance)
576 {
577 if (FAILED(DirectInput8Create(_glfw.win32.instance,
578 DIRECTINPUT_VERSION,
579 &IID_IDirectInput8W,
580 (void**) &_glfw.win32.dinput8.api,
581 NULL)))
582 {
583 _glfwInputError(GLFW_PLATFORM_ERROR,
584 "Win32: Failed to create interface");
585 return GLFW_FALSE;
586 }
587 }
588
589 _glfwDetectJoystickConnectionWin32();
590 return GLFW_TRUE;
591}
592
593void _glfwTerminateJoysticksWin32(void)
594{
595 int jid;
596
597 for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
598 closeJoystick(_glfw.joysticks + jid);
599
600 if (_glfw.win32.dinput8.api)
601 IDirectInput8_Release(_glfw.win32.dinput8.api);
602}
603
604GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
605{
606 if (js->win32.device)
607 {
608 int i, ai = 0, bi = 0, pi = 0;
609 HRESULT result;
610 DIJOYSTATE state = {0};
611
612 IDirectInputDevice8_Poll(js->win32.device);
613 result = IDirectInputDevice8_GetDeviceState(js->win32.device,
614 sizeof(state),
615 &state);
616 if (result == DIERR_NOTACQUIRED || result == DIERR_INPUTLOST)
617 {
618 IDirectInputDevice8_Acquire(js->win32.device);
619 IDirectInputDevice8_Poll(js->win32.device);
620 result = IDirectInputDevice8_GetDeviceState(js->win32.device,
621 sizeof(state),
622 &state);
623 }
624
625 if (FAILED(result))
626 {
627 closeJoystick(js);
628 return GLFW_FALSE;
629 }
630
631 if (mode == _GLFW_POLL_PRESENCE)
632 return GLFW_TRUE;
633
634 for (i = 0; i < js->win32.objectCount; i++)
635 {
636 const void* data = (char*) &state + js->win32.objects[i].offset;
637
638 switch (js->win32.objects[i].type)
639 {
640 case _GLFW_TYPE_AXIS:
641 case _GLFW_TYPE_SLIDER:
642 {
643 const float value = (*((LONG*) data) + 0.5f) / 32767.5f;
644 _glfwInputJoystickAxis(js, ai, value);
645 ai++;
646 break;
647 }
648
649 case _GLFW_TYPE_BUTTON:
650 {
651 const char value = (*((BYTE*) data) & 0x80) != 0;
652 _glfwInputJoystickButton(js, bi, value);
653 bi++;
654 break;
655 }
656
657 case _GLFW_TYPE_POV:
658 {
659 const int states[9] =
660 {
661 GLFW_HAT_UP,
662 GLFW_HAT_RIGHT_UP,
663 GLFW_HAT_RIGHT,
664 GLFW_HAT_RIGHT_DOWN,
665 GLFW_HAT_DOWN,
666 GLFW_HAT_LEFT_DOWN,
667 GLFW_HAT_LEFT,
668 GLFW_HAT_LEFT_UP,
669 GLFW_HAT_CENTERED
670 };
671
672 // Screams of horror are appropriate at this point
673 int stateIndex = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES);
674 if (stateIndex < 0 || stateIndex > 8)
675 stateIndex = 8;
676
677 _glfwInputJoystickHat(js, pi, states[stateIndex]);
678 pi++;
679 break;
680 }
681 }
682 }
683 }
684 else
685 {
686 int i, dpad = 0;
687 DWORD result;
688 XINPUT_STATE xis;
689 const WORD buttons[10] =
690 {
691 XINPUT_GAMEPAD_A,
692 XINPUT_GAMEPAD_B,
693 XINPUT_GAMEPAD_X,
694 XINPUT_GAMEPAD_Y,
695 XINPUT_GAMEPAD_LEFT_SHOULDER,
696 XINPUT_GAMEPAD_RIGHT_SHOULDER,
697 XINPUT_GAMEPAD_BACK,
698 XINPUT_GAMEPAD_START,
699 XINPUT_GAMEPAD_LEFT_THUMB,
700 XINPUT_GAMEPAD_RIGHT_THUMB
701 };
702
703 result = XInputGetState(js->win32.index, &xis);
704 if (result != ERROR_SUCCESS)
705 {
706 if (result == ERROR_DEVICE_NOT_CONNECTED)
707 closeJoystick(js);
708
709 return GLFW_FALSE;
710 }
711
712 if (mode == _GLFW_POLL_PRESENCE)
713 return GLFW_TRUE;
714
715 _glfwInputJoystickAxis(js, 0, (xis.Gamepad.sThumbLX + 0.5f) / 32767.5f);
716 _glfwInputJoystickAxis(js, 1, -(xis.Gamepad.sThumbLY + 0.5f) / 32767.5f);
717 _glfwInputJoystickAxis(js, 2, (xis.Gamepad.sThumbRX + 0.5f) / 32767.5f);
718 _glfwInputJoystickAxis(js, 3, -(xis.Gamepad.sThumbRY + 0.5f) / 32767.5f);
719 _glfwInputJoystickAxis(js, 4, xis.Gamepad.bLeftTrigger / 127.5f - 1.f);
720 _glfwInputJoystickAxis(js, 5, xis.Gamepad.bRightTrigger / 127.5f - 1.f);
721
722 for (i = 0; i < 10; i++)
723 {
724 const char value = (xis.Gamepad.wButtons & buttons[i]) ? 1 : 0;
725 _glfwInputJoystickButton(js, i, value);
726 }
727
728 if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
729 dpad |= GLFW_HAT_UP;
730 if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
731 dpad |= GLFW_HAT_RIGHT;
732 if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
733 dpad |= GLFW_HAT_DOWN;
734 if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
735 dpad |= GLFW_HAT_LEFT;
736
737 // Treat invalid combinations as neither being pressed
738 // while preserving what data can be preserved
739 if ((dpad & GLFW_HAT_RIGHT) && (dpad & GLFW_HAT_LEFT))
740 dpad &= ~(GLFW_HAT_RIGHT | GLFW_HAT_LEFT);
741 if ((dpad & GLFW_HAT_UP) && (dpad & GLFW_HAT_DOWN))
742 dpad &= ~(GLFW_HAT_UP | GLFW_HAT_DOWN);
743
744 _glfwInputJoystickHat(js, 0, dpad);
745 }
746
747 return GLFW_TRUE;
748}
749
750const char* _glfwGetMappingNameWin32(void)
751{
752 return "Windows";
753}
754
755void _glfwUpdateGamepadGUIDWin32(char* guid)
756{
757 if (strcmp(guid + 20, "504944564944") == 0)
758 {
759 char original[33];
760 strncpy(original, guid, sizeof(original) - 1);
761 sprintf(guid, "03000000%.4s0000%.4s000000000000",
762 original, original + 4);
763 }
764}
765
766#endif // _GLFW_WIN32
767
diff --git a/raylib/src/external/glfw/src/win32_joystick.h b/raylib/src/external/glfw/src/win32_joystick.h
new file mode 100644
index 0000000..9ab6438
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_joystick.h
@@ -0,0 +1,51 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#define GLFW_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32;
28#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
29
30// Joystick element (axis, button or slider)
31//
32typedef struct _GLFWjoyobjectWin32
33{
34 int offset;
35 int type;
36} _GLFWjoyobjectWin32;
37
38// Win32-specific per-joystick data
39//
40typedef struct _GLFWjoystickWin32
41{
42 _GLFWjoyobjectWin32* objects;
43 int objectCount;
44 IDirectInputDevice8W* device;
45 DWORD index;
46 GUID guid;
47} _GLFWjoystickWin32;
48
49void _glfwDetectJoystickConnectionWin32(void);
50void _glfwDetectJoystickDisconnectionWin32(void);
51
diff --git a/raylib/src/external/glfw/src/win32_module.c b/raylib/src/external/glfw/src/win32_module.c
new file mode 100644
index 0000000..47c8dff
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_module.c
@@ -0,0 +1,51 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include "internal.h"
28
29#if defined(GLFW_BUILD_WIN32_MODULE)
30
31//////////////////////////////////////////////////////////////////////////
32////// GLFW platform API //////
33//////////////////////////////////////////////////////////////////////////
34
35void* _glfwPlatformLoadModule(const char* path)
36{
37 return LoadLibraryA(path);
38}
39
40void _glfwPlatformFreeModule(void* module)
41{
42 FreeLibrary((HMODULE) module);
43}
44
45GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
46{
47 return (GLFWproc) GetProcAddress((HMODULE) module, name);
48}
49
50#endif // GLFW_BUILD_WIN32_MODULE
51
diff --git a/raylib/src/external/glfw/src/win32_monitor.c b/raylib/src/external/glfw/src/win32_monitor.c
new file mode 100644
index 0000000..87c85b9
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_monitor.c
@@ -0,0 +1,569 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_WIN32)
31
32#include <stdlib.h>
33#include <string.h>
34#include <limits.h>
35#include <wchar.h>
36
37
38// Callback for EnumDisplayMonitors in createMonitor
39//
40static BOOL CALLBACK monitorCallback(HMONITOR handle,
41 HDC dc,
42 RECT* rect,
43 LPARAM data)
44{
45 MONITORINFOEXW mi;
46 ZeroMemory(&mi, sizeof(mi));
47 mi.cbSize = sizeof(mi);
48
49 if (GetMonitorInfoW(handle, (MONITORINFO*) &mi))
50 {
51 _GLFWmonitor* monitor = (_GLFWmonitor*) data;
52 if (wcscmp(mi.szDevice, monitor->win32.adapterName) == 0)
53 monitor->win32.handle = handle;
54 }
55
56 return TRUE;
57}
58
59// Create monitor from an adapter and (optionally) a display
60//
61static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter,
62 DISPLAY_DEVICEW* display)
63{
64 _GLFWmonitor* monitor;
65 int widthMM, heightMM;
66 char* name;
67 HDC dc;
68 DEVMODEW dm;
69 RECT rect;
70
71 if (display)
72 name = _glfwCreateUTF8FromWideStringWin32(display->DeviceString);
73 else
74 name = _glfwCreateUTF8FromWideStringWin32(adapter->DeviceString);
75 if (!name)
76 return NULL;
77
78 ZeroMemory(&dm, sizeof(dm));
79 dm.dmSize = sizeof(dm);
80 EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &dm);
81
82 dc = CreateDCW(L"DISPLAY", adapter->DeviceName, NULL, NULL);
83
84 if (IsWindows8Point1OrGreater())
85 {
86 widthMM = GetDeviceCaps(dc, HORZSIZE);
87 heightMM = GetDeviceCaps(dc, VERTSIZE);
88 }
89 else
90 {
91 widthMM = (int) (dm.dmPelsWidth * 25.4f / GetDeviceCaps(dc, LOGPIXELSX));
92 heightMM = (int) (dm.dmPelsHeight * 25.4f / GetDeviceCaps(dc, LOGPIXELSY));
93 }
94
95 DeleteDC(dc);
96
97 monitor = _glfwAllocMonitor(name, widthMM, heightMM);
98 _glfw_free(name);
99
100 if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED)
101 monitor->win32.modesPruned = GLFW_TRUE;
102
103 wcscpy(monitor->win32.adapterName, adapter->DeviceName);
104 WideCharToMultiByte(CP_UTF8, 0,
105 adapter->DeviceName, -1,
106 monitor->win32.publicAdapterName,
107 sizeof(monitor->win32.publicAdapterName),
108 NULL, NULL);
109
110 if (display)
111 {
112 wcscpy(monitor->win32.displayName, display->DeviceName);
113 WideCharToMultiByte(CP_UTF8, 0,
114 display->DeviceName, -1,
115 monitor->win32.publicDisplayName,
116 sizeof(monitor->win32.publicDisplayName),
117 NULL, NULL);
118 }
119
120 rect.left = dm.dmPosition.x;
121 rect.top = dm.dmPosition.y;
122 rect.right = dm.dmPosition.x + dm.dmPelsWidth;
123 rect.bottom = dm.dmPosition.y + dm.dmPelsHeight;
124
125 EnumDisplayMonitors(NULL, &rect, monitorCallback, (LPARAM) monitor);
126 return monitor;
127}
128
129
130//////////////////////////////////////////////////////////////////////////
131////// GLFW internal API //////
132//////////////////////////////////////////////////////////////////////////
133
134// Poll for changes in the set of connected monitors
135//
136void _glfwPollMonitorsWin32(void)
137{
138 int i, disconnectedCount;
139 _GLFWmonitor** disconnected = NULL;
140 DWORD adapterIndex, displayIndex;
141 DISPLAY_DEVICEW adapter, display;
142 _GLFWmonitor* monitor;
143
144 disconnectedCount = _glfw.monitorCount;
145 if (disconnectedCount)
146 {
147 disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
148 memcpy(disconnected,
149 _glfw.monitors,
150 _glfw.monitorCount * sizeof(_GLFWmonitor*));
151 }
152
153 for (adapterIndex = 0; ; adapterIndex++)
154 {
155 int type = _GLFW_INSERT_LAST;
156
157 ZeroMemory(&adapter, sizeof(adapter));
158 adapter.cb = sizeof(adapter);
159
160 if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))
161 break;
162
163 if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
164 continue;
165
166 if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
167 type = _GLFW_INSERT_FIRST;
168
169 for (displayIndex = 0; ; displayIndex++)
170 {
171 ZeroMemory(&display, sizeof(display));
172 display.cb = sizeof(display);
173
174 if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
175 break;
176
177 if (!(display.StateFlags & DISPLAY_DEVICE_ACTIVE))
178 continue;
179
180 for (i = 0; i < disconnectedCount; i++)
181 {
182 if (disconnected[i] &&
183 wcscmp(disconnected[i]->win32.displayName,
184 display.DeviceName) == 0)
185 {
186 disconnected[i] = NULL;
187 // handle may have changed, update
188 EnumDisplayMonitors(NULL, NULL, monitorCallback, (LPARAM) _glfw.monitors[i]);
189 break;
190 }
191 }
192
193 if (i < disconnectedCount)
194 continue;
195
196 monitor = createMonitor(&adapter, &display);
197 if (!monitor)
198 {
199 _glfw_free(disconnected);
200 return;
201 }
202
203 _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
204
205 type = _GLFW_INSERT_LAST;
206 }
207
208 // HACK: If an active adapter does not have any display devices
209 // (as sometimes happens), add it directly as a monitor
210 if (displayIndex == 0)
211 {
212 for (i = 0; i < disconnectedCount; i++)
213 {
214 if (disconnected[i] &&
215 wcscmp(disconnected[i]->win32.adapterName,
216 adapter.DeviceName) == 0)
217 {
218 disconnected[i] = NULL;
219 break;
220 }
221 }
222
223 if (i < disconnectedCount)
224 continue;
225
226 monitor = createMonitor(&adapter, NULL);
227 if (!monitor)
228 {
229 _glfw_free(disconnected);
230 return;
231 }
232
233 _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
234 }
235 }
236
237 for (i = 0; i < disconnectedCount; i++)
238 {
239 if (disconnected[i])
240 _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
241 }
242
243 _glfw_free(disconnected);
244}
245
246// Change the current video mode
247//
248void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
249{
250 GLFWvidmode current;
251 const GLFWvidmode* best;
252 DEVMODEW dm;
253 LONG result;
254
255 best = _glfwChooseVideoMode(monitor, desired);
256 _glfwGetVideoModeWin32(monitor, &current);
257 if (_glfwCompareVideoModes(&current, best) == 0)
258 return;
259
260 ZeroMemory(&dm, sizeof(dm));
261 dm.dmSize = sizeof(dm);
262 dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
263 DM_DISPLAYFREQUENCY;
264 dm.dmPelsWidth = best->width;
265 dm.dmPelsHeight = best->height;
266 dm.dmBitsPerPel = best->redBits + best->greenBits + best->blueBits;
267 dm.dmDisplayFrequency = best->refreshRate;
268
269 if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
270 dm.dmBitsPerPel = 32;
271
272 result = ChangeDisplaySettingsExW(monitor->win32.adapterName,
273 &dm,
274 NULL,
275 CDS_FULLSCREEN,
276 NULL);
277 if (result == DISP_CHANGE_SUCCESSFUL)
278 monitor->win32.modeChanged = GLFW_TRUE;
279 else
280 {
281 const char* description = "Unknown error";
282
283 if (result == DISP_CHANGE_BADDUALVIEW)
284 description = "The system uses DualView";
285 else if (result == DISP_CHANGE_BADFLAGS)
286 description = "Invalid flags";
287 else if (result == DISP_CHANGE_BADMODE)
288 description = "Graphics mode not supported";
289 else if (result == DISP_CHANGE_BADPARAM)
290 description = "Invalid parameter";
291 else if (result == DISP_CHANGE_FAILED)
292 description = "Graphics mode failed";
293 else if (result == DISP_CHANGE_NOTUPDATED)
294 description = "Failed to write to registry";
295 else if (result == DISP_CHANGE_RESTART)
296 description = "Computer restart required";
297
298 _glfwInputError(GLFW_PLATFORM_ERROR,
299 "Win32: Failed to set video mode: %s",
300 description);
301 }
302}
303
304// Restore the previously saved (original) video mode
305//
306void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor)
307{
308 if (monitor->win32.modeChanged)
309 {
310 ChangeDisplaySettingsExW(monitor->win32.adapterName,
311 NULL, NULL, CDS_FULLSCREEN, NULL);
312 monitor->win32.modeChanged = GLFW_FALSE;
313 }
314}
315
316void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
317{
318 UINT xdpi, ydpi;
319
320 if (xscale)
321 *xscale = 0.f;
322 if (yscale)
323 *yscale = 0.f;
324
325 if (IsWindows8Point1OrGreater())
326 {
327 if (GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi) != S_OK)
328 {
329 _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query monitor DPI");
330 return;
331 }
332 }
333 else
334 {
335 const HDC dc = GetDC(NULL);
336 xdpi = GetDeviceCaps(dc, LOGPIXELSX);
337 ydpi = GetDeviceCaps(dc, LOGPIXELSY);
338 ReleaseDC(NULL, dc);
339 }
340
341 if (xscale)
342 *xscale = xdpi / (float) USER_DEFAULT_SCREEN_DPI;
343 if (yscale)
344 *yscale = ydpi / (float) USER_DEFAULT_SCREEN_DPI;
345}
346
347
348//////////////////////////////////////////////////////////////////////////
349////// GLFW platform API //////
350//////////////////////////////////////////////////////////////////////////
351
352void _glfwFreeMonitorWin32(_GLFWmonitor* monitor)
353{
354}
355
356void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos)
357{
358 DEVMODEW dm;
359 ZeroMemory(&dm, sizeof(dm));
360 dm.dmSize = sizeof(dm);
361
362 EnumDisplaySettingsExW(monitor->win32.adapterName,
363 ENUM_CURRENT_SETTINGS,
364 &dm,
365 EDS_ROTATEDMODE);
366
367 if (xpos)
368 *xpos = dm.dmPosition.x;
369 if (ypos)
370 *ypos = dm.dmPosition.y;
371}
372
373void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor,
374 float* xscale, float* yscale)
375{
376 _glfwGetHMONITORContentScaleWin32(monitor->win32.handle, xscale, yscale);
377}
378
379void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor,
380 int* xpos, int* ypos,
381 int* width, int* height)
382{
383 MONITORINFO mi = { sizeof(mi) };
384 GetMonitorInfoW(monitor->win32.handle, &mi);
385
386 if (xpos)
387 *xpos = mi.rcWork.left;
388 if (ypos)
389 *ypos = mi.rcWork.top;
390 if (width)
391 *width = mi.rcWork.right - mi.rcWork.left;
392 if (height)
393 *height = mi.rcWork.bottom - mi.rcWork.top;
394}
395
396GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
397{
398 int modeIndex = 0, size = 0;
399 GLFWvidmode* result = NULL;
400
401 *count = 0;
402
403 for (;;)
404 {
405 int i;
406 GLFWvidmode mode;
407 DEVMODEW dm;
408
409 ZeroMemory(&dm, sizeof(dm));
410 dm.dmSize = sizeof(dm);
411
412 if (!EnumDisplaySettingsW(monitor->win32.adapterName, modeIndex, &dm))
413 break;
414
415 modeIndex++;
416
417 // Skip modes with less than 15 BPP
418 if (dm.dmBitsPerPel < 15)
419 continue;
420
421 mode.width = dm.dmPelsWidth;
422 mode.height = dm.dmPelsHeight;
423 mode.refreshRate = dm.dmDisplayFrequency;
424 _glfwSplitBPP(dm.dmBitsPerPel,
425 &mode.redBits,
426 &mode.greenBits,
427 &mode.blueBits);
428
429 for (i = 0; i < *count; i++)
430 {
431 if (_glfwCompareVideoModes(result + i, &mode) == 0)
432 break;
433 }
434
435 // Skip duplicate modes
436 if (i < *count)
437 continue;
438
439 if (monitor->win32.modesPruned)
440 {
441 // Skip modes not supported by the connected displays
442 if (ChangeDisplaySettingsExW(monitor->win32.adapterName,
443 &dm,
444 NULL,
445 CDS_TEST,
446 NULL) != DISP_CHANGE_SUCCESSFUL)
447 {
448 continue;
449 }
450 }
451
452 if (*count == size)
453 {
454 size += 128;
455 result = (GLFWvidmode*) _glfw_realloc(result, size * sizeof(GLFWvidmode));
456 }
457
458 (*count)++;
459 result[*count - 1] = mode;
460 }
461
462 if (!*count)
463 {
464 // HACK: Report the current mode if no valid modes were found
465 result = _glfw_calloc(1, sizeof(GLFWvidmode));
466 _glfwGetVideoModeWin32(monitor, result);
467 *count = 1;
468 }
469
470 return result;
471}
472
473GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
474{
475 DEVMODEW dm;
476 ZeroMemory(&dm, sizeof(dm));
477 dm.dmSize = sizeof(dm);
478
479 if (!EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm))
480 {
481 _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query display settings");
482 return GLFW_FALSE;
483 }
484
485 mode->width = dm.dmPelsWidth;
486 mode->height = dm.dmPelsHeight;
487 mode->refreshRate = dm.dmDisplayFrequency;
488 _glfwSplitBPP(dm.dmBitsPerPel,
489 &mode->redBits,
490 &mode->greenBits,
491 &mode->blueBits);
492
493 return GLFW_TRUE;
494}
495
496GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
497{
498 HDC dc;
499 WORD values[3][256];
500
501 dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
502 GetDeviceGammaRamp(dc, values);
503 DeleteDC(dc);
504
505 _glfwAllocGammaArrays(ramp, 256);
506
507 memcpy(ramp->red, values[0], sizeof(values[0]));
508 memcpy(ramp->green, values[1], sizeof(values[1]));
509 memcpy(ramp->blue, values[2], sizeof(values[2]));
510
511 return GLFW_TRUE;
512}
513
514void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
515{
516 HDC dc;
517 WORD values[3][256];
518
519 if (ramp->size != 256)
520 {
521 _glfwInputError(GLFW_PLATFORM_ERROR,
522 "Win32: Gamma ramp size must be 256");
523 return;
524 }
525
526 memcpy(values[0], ramp->red, sizeof(values[0]));
527 memcpy(values[1], ramp->green, sizeof(values[1]));
528 memcpy(values[2], ramp->blue, sizeof(values[2]));
529
530 dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
531 SetDeviceGammaRamp(dc, values);
532 DeleteDC(dc);
533}
534
535
536//////////////////////////////////////////////////////////////////////////
537////// GLFW native API //////
538//////////////////////////////////////////////////////////////////////////
539
540GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)
541{
542 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
543 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
544
545 if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
546 {
547 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized");
548 return NULL;
549 }
550
551 return monitor->win32.publicAdapterName;
552}
553
554GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)
555{
556 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
557 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
558
559 if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
560 {
561 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized");
562 return NULL;
563 }
564
565 return monitor->win32.publicDisplayName;
566}
567
568#endif // _GLFW_WIN32
569
diff --git a/raylib/src/external/glfw/src/win32_platform.h b/raylib/src/external/glfw/src/win32_platform.h
new file mode 100644
index 0000000..7e3d884
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_platform.h
@@ -0,0 +1,627 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28// We don't need all the fancy stuff
29#ifndef NOMINMAX
30 #define NOMINMAX
31#endif
32
33#ifndef VC_EXTRALEAN
34 #define VC_EXTRALEAN
35#endif
36
37#ifndef WIN32_LEAN_AND_MEAN
38 #define WIN32_LEAN_AND_MEAN
39#endif
40
41// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
42// example to allow applications to correctly declare a GL_KHR_debug callback)
43// but windows.h assumes no one will define APIENTRY before it does
44#undef APIENTRY
45
46// GLFW on Windows is Unicode only and does not work in MBCS mode
47#ifndef UNICODE
48 #define UNICODE
49#endif
50
51// GLFW requires Windows XP or later
52#if WINVER < 0x0501
53 #undef WINVER
54 #define WINVER 0x0501
55#endif
56#if _WIN32_WINNT < 0x0501
57 #undef _WIN32_WINNT
58 #define _WIN32_WINNT 0x0501
59#endif
60
61// GLFW uses DirectInput8 interfaces
62#define DIRECTINPUT_VERSION 0x0800
63
64// GLFW uses OEM cursor resources
65#define OEMRESOURCE
66
67#include <wctype.h>
68#include <windows.h>
69#include <dinput.h>
70#include <xinput.h>
71#include <dbt.h>
72
73// HACK: Define macros that some windows.h variants don't
74#ifndef WM_MOUSEHWHEEL
75 #define WM_MOUSEHWHEEL 0x020E
76#endif
77#ifndef WM_DWMCOMPOSITIONCHANGED
78 #define WM_DWMCOMPOSITIONCHANGED 0x031E
79#endif
80#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
81 #define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
82#endif
83#ifndef WM_COPYGLOBALDATA
84 #define WM_COPYGLOBALDATA 0x0049
85#endif
86#ifndef WM_UNICHAR
87 #define WM_UNICHAR 0x0109
88#endif
89#ifndef UNICODE_NOCHAR
90 #define UNICODE_NOCHAR 0xFFFF
91#endif
92#ifndef WM_DPICHANGED
93 #define WM_DPICHANGED 0x02E0
94#endif
95#ifndef GET_XBUTTON_WPARAM
96 #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
97#endif
98#ifndef EDS_ROTATEDMODE
99 #define EDS_ROTATEDMODE 0x00000004
100#endif
101#ifndef DISPLAY_DEVICE_ACTIVE
102 #define DISPLAY_DEVICE_ACTIVE 0x00000001
103#endif
104#ifndef _WIN32_WINNT_WINBLUE
105 #define _WIN32_WINNT_WINBLUE 0x0603
106#endif
107#ifndef _WIN32_WINNT_WIN8
108 #define _WIN32_WINNT_WIN8 0x0602
109#endif
110#ifndef WM_GETDPISCALEDSIZE
111 #define WM_GETDPISCALEDSIZE 0x02e4
112#endif
113#ifndef USER_DEFAULT_SCREEN_DPI
114 #define USER_DEFAULT_SCREEN_DPI 96
115#endif
116#ifndef OCR_HAND
117 #define OCR_HAND 32649
118#endif
119
120#if WINVER < 0x0601
121typedef struct
122{
123 DWORD cbSize;
124 DWORD ExtStatus;
125} CHANGEFILTERSTRUCT;
126#ifndef MSGFLT_ALLOW
127 #define MSGFLT_ALLOW 1
128#endif
129#endif /*Windows 7*/
130
131#if WINVER < 0x0600
132#define DWM_BB_ENABLE 0x00000001
133#define DWM_BB_BLURREGION 0x00000002
134typedef struct
135{
136 DWORD dwFlags;
137 BOOL fEnable;
138 HRGN hRgnBlur;
139 BOOL fTransitionOnMaximized;
140} DWM_BLURBEHIND;
141#else
142 #include <dwmapi.h>
143#endif /*Windows Vista*/
144
145#ifndef DPI_ENUMS_DECLARED
146typedef enum
147{
148 PROCESS_DPI_UNAWARE = 0,
149 PROCESS_SYSTEM_DPI_AWARE = 1,
150 PROCESS_PER_MONITOR_DPI_AWARE = 2
151} PROCESS_DPI_AWARENESS;
152typedef enum
153{
154 MDT_EFFECTIVE_DPI = 0,
155 MDT_ANGULAR_DPI = 1,
156 MDT_RAW_DPI = 2,
157 MDT_DEFAULT = MDT_EFFECTIVE_DPI
158} MONITOR_DPI_TYPE;
159#endif /*DPI_ENUMS_DECLARED*/
160
161#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
162#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
163#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
164
165// Replacement for versionhelpers.h macros, as we cannot rely on the
166// application having a correct embedded manifest
167//
168#define IsWindowsVistaOrGreater() \
169 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
170 LOBYTE(_WIN32_WINNT_VISTA), 0)
171#define IsWindows7OrGreater() \
172 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \
173 LOBYTE(_WIN32_WINNT_WIN7), 0)
174#define IsWindows8OrGreater() \
175 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \
176 LOBYTE(_WIN32_WINNT_WIN8), 0)
177#define IsWindows8Point1OrGreater() \
178 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
179 LOBYTE(_WIN32_WINNT_WINBLUE), 0)
180
181// Windows 10 Anniversary Update
182#define _glfwIsWindows10Version1607OrGreaterWin32() \
183 _glfwIsWindows10BuildOrGreaterWin32(14393)
184// Windows 10 Creators Update
185#define _glfwIsWindows10Version1703OrGreaterWin32() \
186 _glfwIsWindows10BuildOrGreaterWin32(15063)
187
188// HACK: Define macros that some xinput.h variants don't
189#ifndef XINPUT_CAPS_WIRELESS
190 #define XINPUT_CAPS_WIRELESS 0x0002
191#endif
192#ifndef XINPUT_DEVSUBTYPE_WHEEL
193 #define XINPUT_DEVSUBTYPE_WHEEL 0x02
194#endif
195#ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK
196 #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
197#endif
198#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
199 #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04
200#endif
201#ifndef XINPUT_DEVSUBTYPE_DANCE_PAD
202 #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
203#endif
204#ifndef XINPUT_DEVSUBTYPE_GUITAR
205 #define XINPUT_DEVSUBTYPE_GUITAR 0x06
206#endif
207#ifndef XINPUT_DEVSUBTYPE_DRUM_KIT
208 #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
209#endif
210#ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD
211 #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
212#endif
213#ifndef XUSER_MAX_COUNT
214 #define XUSER_MAX_COUNT 4
215#endif
216
217// HACK: Define macros that some dinput.h variants don't
218#ifndef DIDFT_OPTIONAL
219 #define DIDFT_OPTIONAL 0x80000000
220#endif
221
222#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
223#define WGL_SUPPORT_OPENGL_ARB 0x2010
224#define WGL_DRAW_TO_WINDOW_ARB 0x2001
225#define WGL_PIXEL_TYPE_ARB 0x2013
226#define WGL_TYPE_RGBA_ARB 0x202b
227#define WGL_ACCELERATION_ARB 0x2003
228#define WGL_NO_ACCELERATION_ARB 0x2025
229#define WGL_RED_BITS_ARB 0x2015
230#define WGL_RED_SHIFT_ARB 0x2016
231#define WGL_GREEN_BITS_ARB 0x2017
232#define WGL_GREEN_SHIFT_ARB 0x2018
233#define WGL_BLUE_BITS_ARB 0x2019
234#define WGL_BLUE_SHIFT_ARB 0x201a
235#define WGL_ALPHA_BITS_ARB 0x201b
236#define WGL_ALPHA_SHIFT_ARB 0x201c
237#define WGL_ACCUM_BITS_ARB 0x201d
238#define WGL_ACCUM_RED_BITS_ARB 0x201e
239#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
240#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
241#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
242#define WGL_DEPTH_BITS_ARB 0x2022
243#define WGL_STENCIL_BITS_ARB 0x2023
244#define WGL_AUX_BUFFERS_ARB 0x2024
245#define WGL_STEREO_ARB 0x2012
246#define WGL_DOUBLE_BUFFER_ARB 0x2011
247#define WGL_SAMPLES_ARB 0x2042
248#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
249#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
250#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
251#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
252#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
253#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
254#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
255#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
256#define WGL_CONTEXT_FLAGS_ARB 0x2094
257#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
258#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
259#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
260#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
261#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
262#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
263#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
264#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
265#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
266#define WGL_COLORSPACE_EXT 0x309d
267#define WGL_COLORSPACE_SRGB_EXT 0x3089
268
269#define ERROR_INVALID_VERSION_ARB 0x2095
270#define ERROR_INVALID_PROFILE_ARB 0x2096
271#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
272
273// xinput.dll function pointer typedefs
274typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
275typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
276#define XInputGetCapabilities _glfw.win32.xinput.GetCapabilities
277#define XInputGetState _glfw.win32.xinput.GetState
278
279// dinput8.dll function pointer typedefs
280typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*,LPUNKNOWN);
281#define DirectInput8Create _glfw.win32.dinput8.Create
282
283// user32.dll function pointer typedefs
284typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
285typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
286typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
287typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
288typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
289typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
290typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
291#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
292#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
293#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
294#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
295#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
296#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
297#define GetSystemMetricsForDpi _glfw.win32.user32.GetSystemMetricsForDpi_
298
299// dwmapi.dll function pointer typedefs
300typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
301typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
302typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
303typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
304#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
305#define DwmFlush _glfw.win32.dwmapi.Flush
306#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
307#define DwmGetColorizationColor _glfw.win32.dwmapi.GetColorizationColor
308
309// shcore.dll function pointer typedefs
310typedef HRESULT (WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
311typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
312#define SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness_
313#define GetDpiForMonitor _glfw.win32.shcore.GetDpiForMonitor_
314
315// ntdll.dll function pointer typedefs
316typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
317#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
318
319// WGL extension pointer typedefs
320typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
321typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
322typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
323typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
324typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
325#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
326#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
327#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
328#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
329#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
330
331// opengl32.dll function pointer typedefs
332typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
333typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
334typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
335typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
336typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
337typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
338typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
339#define wglCreateContext _glfw.wgl.CreateContext
340#define wglDeleteContext _glfw.wgl.DeleteContext
341#define wglGetProcAddress _glfw.wgl.GetProcAddress
342#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
343#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
344#define wglMakeCurrent _glfw.wgl.MakeCurrent
345#define wglShareLists _glfw.wgl.ShareLists
346
347typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
348
349typedef struct VkWin32SurfaceCreateInfoKHR
350{
351 VkStructureType sType;
352 const void* pNext;
353 VkWin32SurfaceCreateFlagsKHR flags;
354 HINSTANCE hinstance;
355 HWND hwnd;
356} VkWin32SurfaceCreateInfoKHR;
357
358typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
359typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
360
361#define GLFW_WIN32_WINDOW_STATE _GLFWwindowWin32 win32;
362#define GLFW_WIN32_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32;
363#define GLFW_WIN32_MONITOR_STATE _GLFWmonitorWin32 win32;
364#define GLFW_WIN32_CURSOR_STATE _GLFWcursorWin32 win32;
365
366#define GLFW_WGL_CONTEXT_STATE _GLFWcontextWGL wgl;
367#define GLFW_WGL_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl;
368
369
370// WGL-specific per-context data
371//
372typedef struct _GLFWcontextWGL
373{
374 HDC dc;
375 HGLRC handle;
376 int interval;
377} _GLFWcontextWGL;
378
379// WGL-specific global data
380//
381typedef struct _GLFWlibraryWGL
382{
383 HINSTANCE instance;
384 PFN_wglCreateContext CreateContext;
385 PFN_wglDeleteContext DeleteContext;
386 PFN_wglGetProcAddress GetProcAddress;
387 PFN_wglGetCurrentDC GetCurrentDC;
388 PFN_wglGetCurrentContext GetCurrentContext;
389 PFN_wglMakeCurrent MakeCurrent;
390 PFN_wglShareLists ShareLists;
391
392 PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
393 PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
394 PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
395 PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
396 PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
397 GLFWbool EXT_swap_control;
398 GLFWbool EXT_colorspace;
399 GLFWbool ARB_multisample;
400 GLFWbool ARB_framebuffer_sRGB;
401 GLFWbool EXT_framebuffer_sRGB;
402 GLFWbool ARB_pixel_format;
403 GLFWbool ARB_create_context;
404 GLFWbool ARB_create_context_profile;
405 GLFWbool EXT_create_context_es2_profile;
406 GLFWbool ARB_create_context_robustness;
407 GLFWbool ARB_create_context_no_error;
408 GLFWbool ARB_context_flush_control;
409} _GLFWlibraryWGL;
410
411// Win32-specific per-window data
412//
413typedef struct _GLFWwindowWin32
414{
415 HWND handle;
416 HICON bigIcon;
417 HICON smallIcon;
418
419 GLFWbool cursorTracked;
420 GLFWbool frameAction;
421 GLFWbool iconified;
422 GLFWbool maximized;
423 // Whether to enable framebuffer transparency on DWM
424 GLFWbool transparent;
425 GLFWbool scaleToMonitor;
426 GLFWbool keymenu;
427 GLFWbool showDefault;
428
429 // Cached size used to filter out duplicate events
430 int width, height;
431
432 // The last received cursor position, regardless of source
433 int lastCursorPosX, lastCursorPosY;
434 // The last received high surrogate when decoding pairs of UTF-16 messages
435 WCHAR highSurrogate;
436} _GLFWwindowWin32;
437
438// Win32-specific global data
439//
440typedef struct _GLFWlibraryWin32
441{
442 HINSTANCE instance;
443 HWND helperWindowHandle;
444 ATOM helperWindowClass;
445 ATOM mainWindowClass;
446 HDEVNOTIFY deviceNotificationHandle;
447 int acquiredMonitorCount;
448 char* clipboardString;
449 short int keycodes[512];
450 short int scancodes[GLFW_KEY_LAST + 1];
451 char keynames[GLFW_KEY_LAST + 1][5];
452 // Where to place the cursor when re-enabled
453 double restoreCursorPosX, restoreCursorPosY;
454 // The window whose disabled cursor mode is active
455 _GLFWwindow* disabledCursorWindow;
456 // The window the cursor is captured in
457 _GLFWwindow* capturedCursorWindow;
458 RAWINPUT* rawInput;
459 int rawInputSize;
460 UINT mouseTrailSize;
461 // The cursor handle to use to hide the cursor (NULL or a transparent cursor)
462 HCURSOR blankCursor;
463
464 struct {
465 HINSTANCE instance;
466 PFN_DirectInput8Create Create;
467 IDirectInput8W* api;
468 } dinput8;
469
470 struct {
471 HINSTANCE instance;
472 PFN_XInputGetCapabilities GetCapabilities;
473 PFN_XInputGetState GetState;
474 } xinput;
475
476 struct {
477 HINSTANCE instance;
478 PFN_SetProcessDPIAware SetProcessDPIAware_;
479 PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
480 PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_;
481 PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
482 PFN_GetDpiForWindow GetDpiForWindow_;
483 PFN_AdjustWindowRectExForDpi AdjustWindowRectExForDpi_;
484 PFN_GetSystemMetricsForDpi GetSystemMetricsForDpi_;
485 } user32;
486
487 struct {
488 HINSTANCE instance;
489 PFN_DwmIsCompositionEnabled IsCompositionEnabled;
490 PFN_DwmFlush Flush;
491 PFN_DwmEnableBlurBehindWindow EnableBlurBehindWindow;
492 PFN_DwmGetColorizationColor GetColorizationColor;
493 } dwmapi;
494
495 struct {
496 HINSTANCE instance;
497 PFN_SetProcessDpiAwareness SetProcessDpiAwareness_;
498 PFN_GetDpiForMonitor GetDpiForMonitor_;
499 } shcore;
500
501 struct {
502 HINSTANCE instance;
503 PFN_RtlVerifyVersionInfo RtlVerifyVersionInfo_;
504 } ntdll;
505} _GLFWlibraryWin32;
506
507// Win32-specific per-monitor data
508//
509typedef struct _GLFWmonitorWin32
510{
511 HMONITOR handle;
512 // This size matches the static size of DISPLAY_DEVICE.DeviceName
513 WCHAR adapterName[32];
514 WCHAR displayName[32];
515 char publicAdapterName[32];
516 char publicDisplayName[32];
517 GLFWbool modesPruned;
518 GLFWbool modeChanged;
519} _GLFWmonitorWin32;
520
521// Win32-specific per-cursor data
522//
523typedef struct _GLFWcursorWin32
524{
525 HCURSOR handle;
526} _GLFWcursorWin32;
527
528
529GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform);
530int _glfwInitWin32(void);
531void _glfwTerminateWin32(void);
532
533WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
534char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
535BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
536BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
537void _glfwInputErrorWin32(int error, const char* description);
538void _glfwUpdateKeyNamesWin32(void);
539
540void _glfwPollMonitorsWin32(void);
541void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
542void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
543void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
544
545GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
546void _glfwDestroyWindowWin32(_GLFWwindow* window);
547void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
548void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
549void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
550void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);
551void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height);
552void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height);
553void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
554void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom);
555void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height);
556void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
557void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale);
558void _glfwIconifyWindowWin32(_GLFWwindow* window);
559void _glfwRestoreWindowWin32(_GLFWwindow* window);
560void _glfwMaximizeWindowWin32(_GLFWwindow* window);
561void _glfwShowWindowWin32(_GLFWwindow* window);
562void _glfwHideWindowWin32(_GLFWwindow* window);
563void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
564void _glfwFocusWindowWin32(_GLFWwindow* window);
565void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
566GLFWbool _glfwWindowFocusedWin32(_GLFWwindow* window);
567GLFWbool _glfwWindowIconifiedWin32(_GLFWwindow* window);
568GLFWbool _glfwWindowVisibleWin32(_GLFWwindow* window);
569GLFWbool _glfwWindowMaximizedWin32(_GLFWwindow* window);
570GLFWbool _glfwWindowHoveredWin32(_GLFWwindow* window);
571GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window);
572void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled);
573void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
574void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
575void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled);
576float _glfwGetWindowOpacityWin32(_GLFWwindow* window);
577void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity);
578
579void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled);
580GLFWbool _glfwRawMouseMotionSupportedWin32(void);
581
582void _glfwPollEventsWin32(void);
583void _glfwWaitEventsWin32(void);
584void _glfwWaitEventsTimeoutWin32(double timeout);
585void _glfwPostEmptyEventWin32(void);
586
587void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos);
588void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos);
589void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode);
590const char* _glfwGetScancodeNameWin32(int scancode);
591int _glfwGetKeyScancodeWin32(int key);
592GLFWbool _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
593GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
594void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
595void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
596void _glfwSetClipboardStringWin32(const char* string);
597const char* _glfwGetClipboardStringWin32(void);
598
599EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs);
600EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void);
601EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window);
602
603void _glfwGetRequiredInstanceExtensionsWin32(char** extensions);
604GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
605VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
606
607void _glfwFreeMonitorWin32(_GLFWmonitor* monitor);
608void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
609void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
610void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
611GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
612GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
613GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
614void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
615
616GLFWbool _glfwInitJoysticksWin32(void);
617void _glfwTerminateJoysticksWin32(void);
618GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode);
619const char* _glfwGetMappingNameWin32(void);
620void _glfwUpdateGamepadGUIDWin32(char* guid);
621
622GLFWbool _glfwInitWGL(void);
623void _glfwTerminateWGL(void);
624GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
625 const _GLFWctxconfig* ctxconfig,
626 const _GLFWfbconfig* fbconfig);
627
diff --git a/raylib/src/external/glfw/src/win32_thread.c b/raylib/src/external/glfw/src/win32_thread.c
new file mode 100644
index 0000000..212e666
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_thread.c
@@ -0,0 +1,100 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(GLFW_BUILD_WIN32_THREAD)
31
32#include <assert.h>
33
34
35//////////////////////////////////////////////////////////////////////////
36////// GLFW platform API //////
37//////////////////////////////////////////////////////////////////////////
38
39GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
40{
41 assert(tls->win32.allocated == GLFW_FALSE);
42
43 tls->win32.index = TlsAlloc();
44 if (tls->win32.index == TLS_OUT_OF_INDEXES)
45 {
46 _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to allocate TLS index");
47 return GLFW_FALSE;
48 }
49
50 tls->win32.allocated = GLFW_TRUE;
51 return GLFW_TRUE;
52}
53
54void _glfwPlatformDestroyTls(_GLFWtls* tls)
55{
56 if (tls->win32.allocated)
57 TlsFree(tls->win32.index);
58 memset(tls, 0, sizeof(_GLFWtls));
59}
60
61void* _glfwPlatformGetTls(_GLFWtls* tls)
62{
63 assert(tls->win32.allocated == GLFW_TRUE);
64 return TlsGetValue(tls->win32.index);
65}
66
67void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
68{
69 assert(tls->win32.allocated == GLFW_TRUE);
70 TlsSetValue(tls->win32.index, value);
71}
72
73GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
74{
75 assert(mutex->win32.allocated == GLFW_FALSE);
76 InitializeCriticalSection(&mutex->win32.section);
77 return mutex->win32.allocated = GLFW_TRUE;
78}
79
80void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
81{
82 if (mutex->win32.allocated)
83 DeleteCriticalSection(&mutex->win32.section);
84 memset(mutex, 0, sizeof(_GLFWmutex));
85}
86
87void _glfwPlatformLockMutex(_GLFWmutex* mutex)
88{
89 assert(mutex->win32.allocated == GLFW_TRUE);
90 EnterCriticalSection(&mutex->win32.section);
91}
92
93void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
94{
95 assert(mutex->win32.allocated == GLFW_TRUE);
96 LeaveCriticalSection(&mutex->win32.section);
97}
98
99#endif // GLFW_BUILD_WIN32_THREAD
100
diff --git a/raylib/src/external/glfw/src/win32_thread.h b/raylib/src/external/glfw/src/win32_thread.h
new file mode 100644
index 0000000..dd5948f
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_thread.h
@@ -0,0 +1,53 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
29// example to allow applications to correctly declare a GL_KHR_debug callback)
30// but windows.h assumes no one will define APIENTRY before it does
31#undef APIENTRY
32
33#include <windows.h>
34
35#define GLFW_WIN32_TLS_STATE _GLFWtlsWin32 win32;
36#define GLFW_WIN32_MUTEX_STATE _GLFWmutexWin32 win32;
37
38// Win32-specific thread local storage data
39//
40typedef struct _GLFWtlsWin32
41{
42 GLFWbool allocated;
43 DWORD index;
44} _GLFWtlsWin32;
45
46// Win32-specific mutex data
47//
48typedef struct _GLFWmutexWin32
49{
50 GLFWbool allocated;
51 CRITICAL_SECTION section;
52} _GLFWmutexWin32;
53
diff --git a/raylib/src/external/glfw/src/win32_time.c b/raylib/src/external/glfw/src/win32_time.c
new file mode 100644
index 0000000..a38e15d
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_time.c
@@ -0,0 +1,54 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(GLFW_BUILD_WIN32_TIMER)
31
32//////////////////////////////////////////////////////////////////////////
33////// GLFW platform API //////
34//////////////////////////////////////////////////////////////////////////
35
36void _glfwPlatformInitTimer(void)
37{
38 QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency);
39}
40
41uint64_t _glfwPlatformGetTimerValue(void)
42{
43 uint64_t value;
44 QueryPerformanceCounter((LARGE_INTEGER*) &value);
45 return value;
46}
47
48uint64_t _glfwPlatformGetTimerFrequency(void)
49{
50 return _glfw.timer.win32.frequency;
51}
52
53#endif // GLFW_BUILD_WIN32_TIMER
54
diff --git a/raylib/src/external/glfw/src/win32_time.h b/raylib/src/external/glfw/src/win32_time.h
new file mode 100644
index 0000000..ef57a5a
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_time.h
@@ -0,0 +1,43 @@
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
29// example to allow applications to correctly declare a GL_KHR_debug callback)
30// but windows.h assumes no one will define APIENTRY before it does
31#undef APIENTRY
32
33#include <windows.h>
34
35#define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32;
36
37// Win32-specific global timer data
38//
39typedef struct _GLFWtimerWin32
40{
41 uint64_t frequency;
42} _GLFWtimerWin32;
43
diff --git a/raylib/src/external/glfw/src/win32_window.c b/raylib/src/external/glfw/src/win32_window.c
new file mode 100644
index 0000000..3762b76
--- /dev/null
+++ b/raylib/src/external/glfw/src/win32_window.c
@@ -0,0 +1,2594 @@
1//========================================================================
2// GLFW 3.4 Win32 (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#if defined(_GLFW_WIN32)
32
33#include <limits.h>
34#include <stdlib.h>
35#include <string.h>
36#include <windowsx.h>
37#include <shellapi.h>
38
39// Returns the window style for the specified window
40//
41static DWORD getWindowStyle(const _GLFWwindow* window)
42{
43 DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
44
45 if (window->monitor)
46 style |= WS_POPUP;
47 else
48 {
49 style |= WS_SYSMENU | WS_MINIMIZEBOX;
50
51 if (window->decorated)
52 {
53 style |= WS_CAPTION;
54
55 if (window->resizable)
56 style |= WS_MAXIMIZEBOX | WS_THICKFRAME;
57 }
58 else
59 style |= WS_POPUP;
60 }
61
62 return style;
63}
64
65// Returns the extended window style for the specified window
66//
67static DWORD getWindowExStyle(const _GLFWwindow* window)
68{
69 DWORD style = WS_EX_APPWINDOW;
70
71 if (window->monitor || window->floating)
72 style |= WS_EX_TOPMOST;
73
74 return style;
75}
76
77// Returns the image whose area most closely matches the desired one
78//
79static const GLFWimage* chooseImage(int count, const GLFWimage* images,
80 int width, int height)
81{
82 int i, leastDiff = INT_MAX;
83 const GLFWimage* closest = NULL;
84
85 for (i = 0; i < count; i++)
86 {
87 const int currDiff = abs(images[i].width * images[i].height -
88 width * height);
89 if (currDiff < leastDiff)
90 {
91 closest = images + i;
92 leastDiff = currDiff;
93 }
94 }
95
96 return closest;
97}
98
99// Creates an RGBA icon or cursor
100//
101static HICON createIcon(const GLFWimage* image, int xhot, int yhot, GLFWbool icon)
102{
103 int i;
104 HDC dc;
105 HICON handle;
106 HBITMAP color, mask;
107 BITMAPV5HEADER bi;
108 ICONINFO ii;
109 unsigned char* target = NULL;
110 unsigned char* source = image->pixels;
111
112 ZeroMemory(&bi, sizeof(bi));
113 bi.bV5Size = sizeof(bi);
114 bi.bV5Width = image->width;
115 bi.bV5Height = -image->height;
116 bi.bV5Planes = 1;
117 bi.bV5BitCount = 32;
118 bi.bV5Compression = BI_BITFIELDS;
119 bi.bV5RedMask = 0x00ff0000;
120 bi.bV5GreenMask = 0x0000ff00;
121 bi.bV5BlueMask = 0x000000ff;
122 bi.bV5AlphaMask = 0xff000000;
123
124 dc = GetDC(NULL);
125 color = CreateDIBSection(dc,
126 (BITMAPINFO*) &bi,
127 DIB_RGB_COLORS,
128 (void**) &target,
129 NULL,
130 (DWORD) 0);
131 ReleaseDC(NULL, dc);
132
133 if (!color)
134 {
135 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
136 "Win32: Failed to create RGBA bitmap");
137 return NULL;
138 }
139
140 mask = CreateBitmap(image->width, image->height, 1, 1, NULL);
141 if (!mask)
142 {
143 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
144 "Win32: Failed to create mask bitmap");
145 DeleteObject(color);
146 return NULL;
147 }
148
149 for (i = 0; i < image->width * image->height; i++)
150 {
151 target[0] = source[2];
152 target[1] = source[1];
153 target[2] = source[0];
154 target[3] = source[3];
155 target += 4;
156 source += 4;
157 }
158
159 ZeroMemory(&ii, sizeof(ii));
160 ii.fIcon = icon;
161 ii.xHotspot = xhot;
162 ii.yHotspot = yhot;
163 ii.hbmMask = mask;
164 ii.hbmColor = color;
165
166 handle = CreateIconIndirect(&ii);
167
168 DeleteObject(color);
169 DeleteObject(mask);
170
171 if (!handle)
172 {
173 if (icon)
174 {
175 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
176 "Win32: Failed to create icon");
177 }
178 else
179 {
180 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
181 "Win32: Failed to create cursor");
182 }
183 }
184
185 return handle;
186}
187
188// Enforce the content area aspect ratio based on which edge is being dragged
189//
190static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
191{
192 RECT frame = {0};
193 const float ratio = (float) window->numer / (float) window->denom;
194 const DWORD style = getWindowStyle(window);
195 const DWORD exStyle = getWindowExStyle(window);
196
197 if (_glfwIsWindows10Version1607OrGreaterWin32())
198 {
199 AdjustWindowRectExForDpi(&frame, style, FALSE, exStyle,
200 GetDpiForWindow(window->win32.handle));
201 }
202 else
203 AdjustWindowRectEx(&frame, style, FALSE, exStyle);
204
205 if (edge == WMSZ_LEFT || edge == WMSZ_BOTTOMLEFT ||
206 edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
207 {
208 area->bottom = area->top + (frame.bottom - frame.top) +
209 (int) (((area->right - area->left) - (frame.right - frame.left)) / ratio);
210 }
211 else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
212 {
213 area->top = area->bottom - (frame.bottom - frame.top) -
214 (int) (((area->right - area->left) - (frame.right - frame.left)) / ratio);
215 }
216 else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
217 {
218 area->right = area->left + (frame.right - frame.left) +
219 (int) (((area->bottom - area->top) - (frame.bottom - frame.top)) * ratio);
220 }
221}
222
223// Updates the cursor image according to its cursor mode
224//
225static void updateCursorImage(_GLFWwindow* window)
226{
227 if (window->cursorMode == GLFW_CURSOR_NORMAL ||
228 window->cursorMode == GLFW_CURSOR_CAPTURED)
229 {
230 if (window->cursor)
231 SetCursor(window->cursor->win32.handle);
232 else
233 SetCursor(LoadCursorW(NULL, IDC_ARROW));
234 }
235 else
236 {
237 // NOTE: Via Remote Desktop, setting the cursor to NULL does not hide it.
238 // HACK: When running locally, it is set to NULL, but when connected via Remote
239 // Desktop, this is a transparent cursor.
240 SetCursor(_glfw.win32.blankCursor);
241 }
242}
243
244// Sets the cursor clip rect to the window content area
245//
246static void captureCursor(_GLFWwindow* window)
247{
248 RECT clipRect;
249 GetClientRect(window->win32.handle, &clipRect);
250 ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
251 ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
252 ClipCursor(&clipRect);
253 _glfw.win32.capturedCursorWindow = window;
254}
255
256// Disabled clip cursor
257//
258static void releaseCursor(void)
259{
260 ClipCursor(NULL);
261 _glfw.win32.capturedCursorWindow = NULL;
262}
263
264// Enables WM_INPUT messages for the mouse for the specified window
265//
266static void enableRawMouseMotion(_GLFWwindow* window)
267{
268 const RAWINPUTDEVICE rid = { 0x01, 0x02, 0, window->win32.handle };
269
270 if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
271 {
272 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
273 "Win32: Failed to register raw input device");
274 }
275}
276
277// Disables WM_INPUT messages for the mouse
278//
279static void disableRawMouseMotion(_GLFWwindow* window)
280{
281 const RAWINPUTDEVICE rid = { 0x01, 0x02, RIDEV_REMOVE, NULL };
282
283 if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
284 {
285 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
286 "Win32: Failed to remove raw input device");
287 }
288}
289
290// Apply disabled cursor mode to a focused window
291//
292static void disableCursor(_GLFWwindow* window)
293{
294 _glfw.win32.disabledCursorWindow = window;
295 _glfwGetCursorPosWin32(window,
296 &_glfw.win32.restoreCursorPosX,
297 &_glfw.win32.restoreCursorPosY);
298 updateCursorImage(window);
299 _glfwCenterCursorInContentArea(window);
300 captureCursor(window);
301
302 if (window->rawMouseMotion)
303 enableRawMouseMotion(window);
304}
305
306// Exit disabled cursor mode for the specified window
307//
308static void enableCursor(_GLFWwindow* window)
309{
310 if (window->rawMouseMotion)
311 disableRawMouseMotion(window);
312
313 _glfw.win32.disabledCursorWindow = NULL;
314 releaseCursor();
315 _glfwSetCursorPosWin32(window,
316 _glfw.win32.restoreCursorPosX,
317 _glfw.win32.restoreCursorPosY);
318 updateCursorImage(window);
319}
320
321// Returns whether the cursor is in the content area of the specified window
322//
323static GLFWbool cursorInContentArea(_GLFWwindow* window)
324{
325 RECT area;
326 POINT pos;
327
328 if (!GetCursorPos(&pos))
329 return GLFW_FALSE;
330
331 if (WindowFromPoint(pos) != window->win32.handle)
332 return GLFW_FALSE;
333
334 GetClientRect(window->win32.handle, &area);
335 ClientToScreen(window->win32.handle, (POINT*) &area.left);
336 ClientToScreen(window->win32.handle, (POINT*) &area.right);
337
338 return PtInRect(&area, pos);
339}
340
341// Update native window styles to match attributes
342//
343static void updateWindowStyles(const _GLFWwindow* window)
344{
345 RECT rect;
346 DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
347 style &= ~(WS_OVERLAPPEDWINDOW | WS_POPUP);
348 style |= getWindowStyle(window);
349
350 GetClientRect(window->win32.handle, &rect);
351
352 if (_glfwIsWindows10Version1607OrGreaterWin32())
353 {
354 AdjustWindowRectExForDpi(&rect, style, FALSE,
355 getWindowExStyle(window),
356 GetDpiForWindow(window->win32.handle));
357 }
358 else
359 AdjustWindowRectEx(&rect, style, FALSE, getWindowExStyle(window));
360
361 ClientToScreen(window->win32.handle, (POINT*) &rect.left);
362 ClientToScreen(window->win32.handle, (POINT*) &rect.right);
363 SetWindowLongW(window->win32.handle, GWL_STYLE, style);
364 SetWindowPos(window->win32.handle, HWND_TOP,
365 rect.left, rect.top,
366 rect.right - rect.left, rect.bottom - rect.top,
367 SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER);
368}
369
370// Update window framebuffer transparency
371//
372static void updateFramebufferTransparency(const _GLFWwindow* window)
373{
374 BOOL composition, opaque;
375 DWORD color;
376
377 if (!IsWindowsVistaOrGreater())
378 return;
379
380 if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
381 return;
382
383 if (IsWindows8OrGreater() ||
384 (SUCCEEDED(DwmGetColorizationColor(&color, &opaque)) && !opaque))
385 {
386 HRGN region = CreateRectRgn(0, 0, -1, -1);
387 DWM_BLURBEHIND bb = {0};
388 bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
389 bb.hRgnBlur = region;
390 bb.fEnable = TRUE;
391
392 DwmEnableBlurBehindWindow(window->win32.handle, &bb);
393 DeleteObject(region);
394 }
395 else
396 {
397 // HACK: Disable framebuffer transparency on Windows 7 when the
398 // colorization color is opaque, because otherwise the window
399 // contents is blended additively with the previous frame instead
400 // of replacing it
401 DWM_BLURBEHIND bb = {0};
402 bb.dwFlags = DWM_BB_ENABLE;
403 DwmEnableBlurBehindWindow(window->win32.handle, &bb);
404 }
405}
406
407// Retrieves and translates modifier keys
408//
409static int getKeyMods(void)
410{
411 int mods = 0;
412
413 if (GetKeyState(VK_SHIFT) & 0x8000)
414 mods |= GLFW_MOD_SHIFT;
415 if (GetKeyState(VK_CONTROL) & 0x8000)
416 mods |= GLFW_MOD_CONTROL;
417 if (GetKeyState(VK_MENU) & 0x8000)
418 mods |= GLFW_MOD_ALT;
419 if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x8000)
420 mods |= GLFW_MOD_SUPER;
421 if (GetKeyState(VK_CAPITAL) & 1)
422 mods |= GLFW_MOD_CAPS_LOCK;
423 if (GetKeyState(VK_NUMLOCK) & 1)
424 mods |= GLFW_MOD_NUM_LOCK;
425
426 return mods;
427}
428
429static void fitToMonitor(_GLFWwindow* window)
430{
431 MONITORINFO mi = { sizeof(mi) };
432 GetMonitorInfoW(window->monitor->win32.handle, &mi);
433 SetWindowPos(window->win32.handle, HWND_TOPMOST,
434 mi.rcMonitor.left,
435 mi.rcMonitor.top,
436 mi.rcMonitor.right - mi.rcMonitor.left,
437 mi.rcMonitor.bottom - mi.rcMonitor.top,
438 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
439}
440
441// Make the specified window and its video mode active on its monitor
442//
443static void acquireMonitorWin32(_GLFWwindow* window)
444{
445 if (!_glfw.win32.acquiredMonitorCount)
446 {
447 SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
448
449 // HACK: When mouse trails are enabled the cursor becomes invisible when
450 // the OpenGL ICD switches to page flipping
451 SystemParametersInfoW(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0);
452 SystemParametersInfoW(SPI_SETMOUSETRAILS, 0, 0, 0);
453 }
454
455 if (!window->monitor->window)
456 _glfw.win32.acquiredMonitorCount++;
457
458 _glfwSetVideoModeWin32(window->monitor, &window->videoMode);
459 _glfwInputMonitorWindow(window->monitor, window);
460}
461
462// Remove the window and restore the original video mode
463//
464static void releaseMonitorWin32(_GLFWwindow* window)
465{
466 if (window->monitor->window != window)
467 return;
468
469 _glfw.win32.acquiredMonitorCount--;
470 if (!_glfw.win32.acquiredMonitorCount)
471 {
472 SetThreadExecutionState(ES_CONTINUOUS);
473
474 // HACK: Restore mouse trail length saved in acquireMonitorWin32
475 SystemParametersInfoW(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0);
476 }
477
478 _glfwInputMonitorWindow(window->monitor, NULL);
479 _glfwRestoreVideoModeWin32(window->monitor);
480}
481
482// Manually maximize the window, for when SW_MAXIMIZE cannot be used
483//
484static void maximizeWindowManually(_GLFWwindow* window)
485{
486 RECT rect;
487 DWORD style;
488 MONITORINFO mi = { sizeof(mi) };
489
490 GetMonitorInfoW(MonitorFromWindow(window->win32.handle,
491 MONITOR_DEFAULTTONEAREST), &mi);
492
493 rect = mi.rcWork;
494
495 if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE)
496 {
497 rect.right = _glfw_min(rect.right, rect.left + window->maxwidth);
498 rect.bottom = _glfw_min(rect.bottom, rect.top + window->maxheight);
499 }
500
501 style = GetWindowLongW(window->win32.handle, GWL_STYLE);
502 style |= WS_MAXIMIZE;
503 SetWindowLongW(window->win32.handle, GWL_STYLE, style);
504
505 if (window->decorated)
506 {
507 const DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
508
509 if (_glfwIsWindows10Version1607OrGreaterWin32())
510 {
511 const UINT dpi = GetDpiForWindow(window->win32.handle);
512 AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
513 OffsetRect(&rect, 0, GetSystemMetricsForDpi(SM_CYCAPTION, dpi));
514 }
515 else
516 {
517 AdjustWindowRectEx(&rect, style, FALSE, exStyle);
518 OffsetRect(&rect, 0, GetSystemMetrics(SM_CYCAPTION));
519 }
520
521 rect.bottom = _glfw_min(rect.bottom, mi.rcWork.bottom);
522 }
523
524 SetWindowPos(window->win32.handle, HWND_TOP,
525 rect.left,
526 rect.top,
527 rect.right - rect.left,
528 rect.bottom - rect.top,
529 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
530}
531
532// Window procedure for user-created windows
533//
534static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
535{
536 _GLFWwindow* window = GetPropW(hWnd, L"GLFW");
537 if (!window)
538 {
539 if (uMsg == WM_NCCREATE)
540 {
541 if (_glfwIsWindows10Version1607OrGreaterWin32())
542 {
543 const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
544 const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
545
546 // On per-monitor DPI aware V1 systems, only enable
547 // non-client scaling for windows that scale the client area
548 // We need WM_GETDPISCALEDSIZE from V2 to keep the client
549 // area static when the non-client area is scaled
550 if (wndconfig && wndconfig->scaleToMonitor)
551 EnableNonClientDpiScaling(hWnd);
552 }
553 }
554
555 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
556 }
557
558 switch (uMsg)
559 {
560 case WM_MOUSEACTIVATE:
561 {
562 // HACK: Postpone cursor disabling when the window was activated by
563 // clicking a caption button
564 if (HIWORD(lParam) == WM_LBUTTONDOWN)
565 {
566 if (LOWORD(lParam) != HTCLIENT)
567 window->win32.frameAction = GLFW_TRUE;
568 }
569
570 break;
571 }
572
573 case WM_CAPTURECHANGED:
574 {
575 // HACK: Disable the cursor once the caption button action has been
576 // completed or cancelled
577 if (lParam == 0 && window->win32.frameAction)
578 {
579 if (window->cursorMode == GLFW_CURSOR_DISABLED)
580 disableCursor(window);
581 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
582 captureCursor(window);
583
584 window->win32.frameAction = GLFW_FALSE;
585 }
586
587 break;
588 }
589
590 case WM_SETFOCUS:
591 {
592 _glfwInputWindowFocus(window, GLFW_TRUE);
593
594 // HACK: Do not disable cursor while the user is interacting with
595 // a caption button
596 if (window->win32.frameAction)
597 break;
598
599 if (window->cursorMode == GLFW_CURSOR_DISABLED)
600 disableCursor(window);
601 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
602 captureCursor(window);
603
604 return 0;
605 }
606
607 case WM_KILLFOCUS:
608 {
609 if (window->cursorMode == GLFW_CURSOR_DISABLED)
610 enableCursor(window);
611 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
612 releaseCursor();
613
614 if (window->monitor && window->autoIconify)
615 _glfwIconifyWindowWin32(window);
616
617 _glfwInputWindowFocus(window, GLFW_FALSE);
618 return 0;
619 }
620
621 case WM_SYSCOMMAND:
622 {
623 switch (wParam & 0xfff0)
624 {
625 case SC_SCREENSAVE:
626 case SC_MONITORPOWER:
627 {
628 if (window->monitor)
629 {
630 // We are running in full screen mode, so disallow
631 // screen saver and screen blanking
632 return 0;
633 }
634 else
635 break;
636 }
637
638 // User trying to access application menu using ALT?
639 case SC_KEYMENU:
640 {
641 if (!window->win32.keymenu)
642 return 0;
643
644 break;
645 }
646 }
647 break;
648 }
649
650 case WM_CLOSE:
651 {
652 _glfwInputWindowCloseRequest(window);
653 return 0;
654 }
655
656 case WM_INPUTLANGCHANGE:
657 {
658 _glfwUpdateKeyNamesWin32();
659 break;
660 }
661
662 case WM_CHAR:
663 case WM_SYSCHAR:
664 {
665 if (wParam >= 0xd800 && wParam <= 0xdbff)
666 window->win32.highSurrogate = (WCHAR) wParam;
667 else
668 {
669 uint32_t codepoint = 0;
670
671 if (wParam >= 0xdc00 && wParam <= 0xdfff)
672 {
673 if (window->win32.highSurrogate)
674 {
675 codepoint += (window->win32.highSurrogate - 0xd800) << 10;
676 codepoint += (WCHAR) wParam - 0xdc00;
677 codepoint += 0x10000;
678 }
679 }
680 else
681 codepoint = (WCHAR) wParam;
682
683 window->win32.highSurrogate = 0;
684 _glfwInputChar(window, codepoint, getKeyMods(), uMsg != WM_SYSCHAR);
685 }
686
687 if (uMsg == WM_SYSCHAR && window->win32.keymenu)
688 break;
689
690 return 0;
691 }
692
693 case WM_UNICHAR:
694 {
695 if (wParam == UNICODE_NOCHAR)
696 {
697 // WM_UNICHAR is not sent by Windows, but is sent by some
698 // third-party input method engine
699 // Returning TRUE here announces support for this message
700 return TRUE;
701 }
702
703 _glfwInputChar(window, (uint32_t) wParam, getKeyMods(), GLFW_TRUE);
704 return 0;
705 }
706
707 case WM_KEYDOWN:
708 case WM_SYSKEYDOWN:
709 case WM_KEYUP:
710 case WM_SYSKEYUP:
711 {
712 int key, scancode;
713 const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS;
714 const int mods = getKeyMods();
715
716 scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff));
717 if (!scancode)
718 {
719 // NOTE: Some synthetic key messages have a scancode of zero
720 // HACK: Map the virtual key back to a usable scancode
721 scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC);
722 }
723
724 // HACK: Alt+PrtSc has a different scancode than just PrtSc
725 if (scancode == 0x54)
726 scancode = 0x137;
727
728 // HACK: Ctrl+Pause has a different scancode than just Pause
729 if (scancode == 0x146)
730 scancode = 0x45;
731
732 // HACK: CJK IME sets the extended bit for right Shift
733 if (scancode == 0x136)
734 scancode = 0x36;
735
736 key = _glfw.win32.keycodes[scancode];
737
738 // The Ctrl keys require special handling
739 if (wParam == VK_CONTROL)
740 {
741 if (HIWORD(lParam) & KF_EXTENDED)
742 {
743 // Right side keys have the extended key bit set
744 key = GLFW_KEY_RIGHT_CONTROL;
745 }
746 else
747 {
748 // NOTE: Alt Gr sends Left Ctrl followed by Right Alt
749 // HACK: We only want one event for Alt Gr, so if we detect
750 // this sequence we discard this Left Ctrl message now
751 // and later report Right Alt normally
752 MSG next;
753 const DWORD time = GetMessageTime();
754
755 if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE))
756 {
757 if (next.message == WM_KEYDOWN ||
758 next.message == WM_SYSKEYDOWN ||
759 next.message == WM_KEYUP ||
760 next.message == WM_SYSKEYUP)
761 {
762 if (next.wParam == VK_MENU &&
763 (HIWORD(next.lParam) & KF_EXTENDED) &&
764 next.time == time)
765 {
766 // Next message is Right Alt down so discard this
767 break;
768 }
769 }
770 }
771
772 // This is a regular Left Ctrl message
773 key = GLFW_KEY_LEFT_CONTROL;
774 }
775 }
776 else if (wParam == VK_PROCESSKEY)
777 {
778 // IME notifies that keys have been filtered by setting the
779 // virtual key-code to VK_PROCESSKEY
780 break;
781 }
782
783 if (action == GLFW_RELEASE && wParam == VK_SHIFT)
784 {
785 // HACK: Release both Shift keys on Shift up event, as when both
786 // are pressed the first release does not emit any event
787 // NOTE: The other half of this is in _glfwPollEventsWin32
788 _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, action, mods);
789 _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, action, mods);
790 }
791 else if (wParam == VK_SNAPSHOT)
792 {
793 // HACK: Key down is not reported for the Print Screen key
794 _glfwInputKey(window, key, scancode, GLFW_PRESS, mods);
795 _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
796 }
797 else
798 _glfwInputKey(window, key, scancode, action, mods);
799
800 break;
801 }
802
803 case WM_LBUTTONDOWN:
804 case WM_RBUTTONDOWN:
805 case WM_MBUTTONDOWN:
806 case WM_XBUTTONDOWN:
807 case WM_LBUTTONUP:
808 case WM_RBUTTONUP:
809 case WM_MBUTTONUP:
810 case WM_XBUTTONUP:
811 {
812 int i, button, action;
813
814 if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
815 button = GLFW_MOUSE_BUTTON_LEFT;
816 else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP)
817 button = GLFW_MOUSE_BUTTON_RIGHT;
818 else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP)
819 button = GLFW_MOUSE_BUTTON_MIDDLE;
820 else if (GET_XBUTTON_WPARAM(wParam) == XBUTTON1)
821 button = GLFW_MOUSE_BUTTON_4;
822 else
823 button = GLFW_MOUSE_BUTTON_5;
824
825 if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN ||
826 uMsg == WM_MBUTTONDOWN || uMsg == WM_XBUTTONDOWN)
827 {
828 action = GLFW_PRESS;
829 }
830 else
831 action = GLFW_RELEASE;
832
833 for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
834 {
835 if (window->mouseButtons[i] == GLFW_PRESS)
836 break;
837 }
838
839 if (i > GLFW_MOUSE_BUTTON_LAST)
840 SetCapture(hWnd);
841
842 _glfwInputMouseClick(window, button, action, getKeyMods());
843
844 for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
845 {
846 if (window->mouseButtons[i] == GLFW_PRESS)
847 break;
848 }
849
850 if (i > GLFW_MOUSE_BUTTON_LAST)
851 ReleaseCapture();
852
853 if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP)
854 return TRUE;
855
856 return 0;
857 }
858
859 case WM_MOUSEMOVE:
860 {
861 const int x = GET_X_LPARAM(lParam);
862 const int y = GET_Y_LPARAM(lParam);
863
864 if (!window->win32.cursorTracked)
865 {
866 TRACKMOUSEEVENT tme;
867 ZeroMemory(&tme, sizeof(tme));
868 tme.cbSize = sizeof(tme);
869 tme.dwFlags = TME_LEAVE;
870 tme.hwndTrack = window->win32.handle;
871 TrackMouseEvent(&tme);
872
873 window->win32.cursorTracked = GLFW_TRUE;
874 _glfwInputCursorEnter(window, GLFW_TRUE);
875 }
876
877 if (window->cursorMode == GLFW_CURSOR_DISABLED)
878 {
879 const int dx = x - window->win32.lastCursorPosX;
880 const int dy = y - window->win32.lastCursorPosY;
881
882 if (_glfw.win32.disabledCursorWindow != window)
883 break;
884 if (window->rawMouseMotion)
885 break;
886
887 _glfwInputCursorPos(window,
888 window->virtualCursorPosX + dx,
889 window->virtualCursorPosY + dy);
890 }
891 else
892 _glfwInputCursorPos(window, x, y);
893
894 window->win32.lastCursorPosX = x;
895 window->win32.lastCursorPosY = y;
896
897 return 0;
898 }
899
900 case WM_INPUT:
901 {
902 UINT size = 0;
903 HRAWINPUT ri = (HRAWINPUT) lParam;
904 RAWINPUT* data = NULL;
905 int dx, dy;
906
907 if (_glfw.win32.disabledCursorWindow != window)
908 break;
909 if (!window->rawMouseMotion)
910 break;
911
912 GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
913 if (size > (UINT) _glfw.win32.rawInputSize)
914 {
915 _glfw_free(_glfw.win32.rawInput);
916 _glfw.win32.rawInput = _glfw_calloc(size, 1);
917 _glfw.win32.rawInputSize = size;
918 }
919
920 size = _glfw.win32.rawInputSize;
921 if (GetRawInputData(ri, RID_INPUT,
922 _glfw.win32.rawInput, &size,
923 sizeof(RAWINPUTHEADER)) == (UINT) -1)
924 {
925 _glfwInputError(GLFW_PLATFORM_ERROR,
926 "Win32: Failed to retrieve raw input data");
927 break;
928 }
929
930 data = _glfw.win32.rawInput;
931 if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
932 {
933 POINT pos = {0};
934 int width, height;
935
936 if (data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP)
937 {
938 pos.x += GetSystemMetrics(SM_XVIRTUALSCREEN);
939 pos.y += GetSystemMetrics(SM_YVIRTUALSCREEN);
940 width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
941 height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
942 }
943 else
944 {
945 width = GetSystemMetrics(SM_CXSCREEN);
946 height = GetSystemMetrics(SM_CYSCREEN);
947 }
948
949 pos.x += (int) ((data->data.mouse.lLastX / 65535.f) * width);
950 pos.y += (int) ((data->data.mouse.lLastY / 65535.f) * height);
951 ScreenToClient(window->win32.handle, &pos);
952
953 dx = pos.x - window->win32.lastCursorPosX;
954 dy = pos.y - window->win32.lastCursorPosY;
955 }
956 else
957 {
958 dx = data->data.mouse.lLastX;
959 dy = data->data.mouse.lLastY;
960 }
961
962 _glfwInputCursorPos(window,
963 window->virtualCursorPosX + dx,
964 window->virtualCursorPosY + dy);
965
966 window->win32.lastCursorPosX += dx;
967 window->win32.lastCursorPosY += dy;
968 break;
969 }
970
971 case WM_MOUSELEAVE:
972 {
973 window->win32.cursorTracked = GLFW_FALSE;
974 _glfwInputCursorEnter(window, GLFW_FALSE);
975 return 0;
976 }
977
978 case WM_MOUSEWHEEL:
979 {
980 _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
981 return 0;
982 }
983
984 case WM_MOUSEHWHEEL:
985 {
986 // This message is only sent on Windows Vista and later
987 // NOTE: The X-axis is inverted for consistency with macOS and X11
988 _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
989 return 0;
990 }
991
992 case WM_ENTERSIZEMOVE:
993 case WM_ENTERMENULOOP:
994 {
995 if (window->win32.frameAction)
996 break;
997
998 // HACK: Enable the cursor while the user is moving or
999 // resizing the window or using the window menu
1000 if (window->cursorMode == GLFW_CURSOR_DISABLED)
1001 enableCursor(window);
1002 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
1003 releaseCursor();
1004
1005 break;
1006 }
1007
1008 case WM_EXITSIZEMOVE:
1009 case WM_EXITMENULOOP:
1010 {
1011 if (window->win32.frameAction)
1012 break;
1013
1014 // HACK: Disable the cursor once the user is done moving or
1015 // resizing the window or using the menu
1016 if (window->cursorMode == GLFW_CURSOR_DISABLED)
1017 disableCursor(window);
1018 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
1019 captureCursor(window);
1020
1021 break;
1022 }
1023
1024 case WM_SIZE:
1025 {
1026 const int width = LOWORD(lParam);
1027 const int height = HIWORD(lParam);
1028 const GLFWbool iconified = wParam == SIZE_MINIMIZED;
1029 const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
1030 (window->win32.maximized &&
1031 wParam != SIZE_RESTORED);
1032
1033 if (_glfw.win32.capturedCursorWindow == window)
1034 captureCursor(window);
1035
1036 if (window->win32.iconified != iconified)
1037 _glfwInputWindowIconify(window, iconified);
1038
1039 if (window->win32.maximized != maximized)
1040 _glfwInputWindowMaximize(window, maximized);
1041
1042 if (width != window->win32.width || height != window->win32.height)
1043 {
1044 window->win32.width = width;
1045 window->win32.height = height;
1046
1047 _glfwInputFramebufferSize(window, width, height);
1048 _glfwInputWindowSize(window, width, height);
1049 }
1050
1051 if (window->monitor && window->win32.iconified != iconified)
1052 {
1053 if (iconified)
1054 releaseMonitorWin32(window);
1055 else
1056 {
1057 acquireMonitorWin32(window);
1058 fitToMonitor(window);
1059 }
1060 }
1061
1062 window->win32.iconified = iconified;
1063 window->win32.maximized = maximized;
1064 return 0;
1065 }
1066
1067 case WM_MOVE:
1068 {
1069 if (_glfw.win32.capturedCursorWindow == window)
1070 captureCursor(window);
1071
1072 // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
1073 // those macros do not handle negative window positions correctly
1074 _glfwInputWindowPos(window,
1075 GET_X_LPARAM(lParam),
1076 GET_Y_LPARAM(lParam));
1077 return 0;
1078 }
1079
1080 case WM_SIZING:
1081 {
1082 if (window->numer == GLFW_DONT_CARE ||
1083 window->denom == GLFW_DONT_CARE)
1084 {
1085 break;
1086 }
1087
1088 applyAspectRatio(window, (int) wParam, (RECT*) lParam);
1089 return TRUE;
1090 }
1091
1092 case WM_GETMINMAXINFO:
1093 {
1094 RECT frame = {0};
1095 MINMAXINFO* mmi = (MINMAXINFO*) lParam;
1096 const DWORD style = getWindowStyle(window);
1097 const DWORD exStyle = getWindowExStyle(window);
1098
1099 if (window->monitor)
1100 break;
1101
1102 if (_glfwIsWindows10Version1607OrGreaterWin32())
1103 {
1104 AdjustWindowRectExForDpi(&frame, style, FALSE, exStyle,
1105 GetDpiForWindow(window->win32.handle));
1106 }
1107 else
1108 AdjustWindowRectEx(&frame, style, FALSE, exStyle);
1109
1110 if (window->minwidth != GLFW_DONT_CARE &&
1111 window->minheight != GLFW_DONT_CARE)
1112 {
1113 mmi->ptMinTrackSize.x = window->minwidth + frame.right - frame.left;
1114 mmi->ptMinTrackSize.y = window->minheight + frame.bottom - frame.top;
1115 }
1116
1117 if (window->maxwidth != GLFW_DONT_CARE &&
1118 window->maxheight != GLFW_DONT_CARE)
1119 {
1120 mmi->ptMaxTrackSize.x = window->maxwidth + frame.right - frame.left;
1121 mmi->ptMaxTrackSize.y = window->maxheight + frame.bottom - frame.top;
1122 }
1123
1124 if (!window->decorated)
1125 {
1126 MONITORINFO mi;
1127 const HMONITOR mh = MonitorFromWindow(window->win32.handle,
1128 MONITOR_DEFAULTTONEAREST);
1129
1130 ZeroMemory(&mi, sizeof(mi));
1131 mi.cbSize = sizeof(mi);
1132 GetMonitorInfoW(mh, &mi);
1133
1134 mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left;
1135 mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top;
1136 mmi->ptMaxSize.x = mi.rcWork.right - mi.rcWork.left;
1137 mmi->ptMaxSize.y = mi.rcWork.bottom - mi.rcWork.top;
1138 }
1139
1140 return 0;
1141 }
1142
1143 case WM_PAINT:
1144 {
1145 _glfwInputWindowDamage(window);
1146 break;
1147 }
1148
1149 case WM_ERASEBKGND:
1150 {
1151 return TRUE;
1152 }
1153
1154 case WM_NCACTIVATE:
1155 case WM_NCPAINT:
1156 {
1157 // Prevent title bar from being drawn after restoring a minimized
1158 // undecorated window
1159 if (!window->decorated)
1160 return TRUE;
1161
1162 break;
1163 }
1164
1165 case WM_DWMCOMPOSITIONCHANGED:
1166 case WM_DWMCOLORIZATIONCOLORCHANGED:
1167 {
1168 if (window->win32.transparent)
1169 updateFramebufferTransparency(window);
1170 return 0;
1171 }
1172
1173 case WM_GETDPISCALEDSIZE:
1174 {
1175 if (window->win32.scaleToMonitor)
1176 break;
1177
1178 // Adjust the window size to keep the content area size constant
1179 if (_glfwIsWindows10Version1703OrGreaterWin32())
1180 {
1181 RECT source = {0}, target = {0};
1182 SIZE* size = (SIZE*) lParam;
1183
1184 AdjustWindowRectExForDpi(&source, getWindowStyle(window),
1185 FALSE, getWindowExStyle(window),
1186 GetDpiForWindow(window->win32.handle));
1187 AdjustWindowRectExForDpi(&target, getWindowStyle(window),
1188 FALSE, getWindowExStyle(window),
1189 LOWORD(wParam));
1190
1191 size->cx += (target.right - target.left) -
1192 (source.right - source.left);
1193 size->cy += (target.bottom - target.top) -
1194 (source.bottom - source.top);
1195 return TRUE;
1196 }
1197
1198 break;
1199 }
1200
1201 case WM_DPICHANGED:
1202 {
1203 const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
1204 const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
1205
1206 // Resize windowed mode windows that either permit rescaling or that
1207 // need it to compensate for non-client area scaling
1208 if (!window->monitor &&
1209 (window->win32.scaleToMonitor ||
1210 _glfwIsWindows10Version1703OrGreaterWin32()))
1211 {
1212 RECT* suggested = (RECT*) lParam;
1213 SetWindowPos(window->win32.handle, HWND_TOP,
1214 suggested->left,
1215 suggested->top,
1216 suggested->right - suggested->left,
1217 suggested->bottom - suggested->top,
1218 SWP_NOACTIVATE | SWP_NOZORDER);
1219 }
1220
1221 _glfwInputWindowContentScale(window, xscale, yscale);
1222 break;
1223 }
1224
1225 case WM_SETCURSOR:
1226 {
1227 if (LOWORD(lParam) == HTCLIENT)
1228 {
1229 updateCursorImage(window);
1230 return TRUE;
1231 }
1232
1233 break;
1234 }
1235
1236 case WM_DROPFILES:
1237 {
1238 HDROP drop = (HDROP) wParam;
1239 POINT pt;
1240 int i;
1241
1242 const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
1243 char** paths = _glfw_calloc(count, sizeof(char*));
1244
1245 // Move the mouse to the position of the drop
1246 DragQueryPoint(drop, &pt);
1247 _glfwInputCursorPos(window, pt.x, pt.y);
1248
1249 for (i = 0; i < count; i++)
1250 {
1251 const UINT length = DragQueryFileW(drop, i, NULL, 0);
1252 WCHAR* buffer = _glfw_calloc((size_t) length + 1, sizeof(WCHAR));
1253
1254 DragQueryFileW(drop, i, buffer, length + 1);
1255 paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
1256
1257 _glfw_free(buffer);
1258 }
1259
1260 _glfwInputDrop(window, count, (const char**) paths);
1261
1262 for (i = 0; i < count; i++)
1263 _glfw_free(paths[i]);
1264 _glfw_free(paths);
1265
1266 DragFinish(drop);
1267 return 0;
1268 }
1269 }
1270
1271 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
1272}
1273
1274// Creates the GLFW window
1275//
1276static int createNativeWindow(_GLFWwindow* window,
1277 const _GLFWwndconfig* wndconfig,
1278 const _GLFWfbconfig* fbconfig)
1279{
1280 int frameX, frameY, frameWidth, frameHeight;
1281 WCHAR* wideTitle;
1282 DWORD style = getWindowStyle(window);
1283 DWORD exStyle = getWindowExStyle(window);
1284
1285 if (!_glfw.win32.mainWindowClass)
1286 {
1287 WNDCLASSEXW wc = { sizeof(wc) };
1288 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
1289 wc.lpfnWndProc = windowProc;
1290 wc.hInstance = _glfw.win32.instance;
1291 wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
1292#if defined(_GLFW_WNDCLASSNAME)
1293 wc.lpszClassName = _GLFW_WNDCLASSNAME;
1294#else
1295 wc.lpszClassName = L"GLFW30";
1296#endif
1297 // Load user-provided icon if available
1298 wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
1299 L"GLFW_ICON", IMAGE_ICON,
1300 0, 0, LR_DEFAULTSIZE | LR_SHARED);
1301 if (!wc.hIcon)
1302 {
1303 // No user-provided icon found, load default icon
1304 wc.hIcon = LoadImageW(NULL,
1305 IDI_APPLICATION, IMAGE_ICON,
1306 0, 0, LR_DEFAULTSIZE | LR_SHARED);
1307 }
1308
1309 _glfw.win32.mainWindowClass = RegisterClassExW(&wc);
1310 if (!_glfw.win32.mainWindowClass)
1311 {
1312 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
1313 "Win32: Failed to register window class");
1314 return GLFW_FALSE;
1315 }
1316 }
1317
1318 if (GetSystemMetrics(SM_REMOTESESSION))
1319 {
1320 // NOTE: On Remote Desktop, setting the cursor to NULL does not hide it
1321 // HACK: Create a transparent cursor and always set that instead of NULL
1322 // When not on Remote Desktop, this handle is NULL and normal hiding is used
1323 if (!_glfw.win32.blankCursor)
1324 {
1325 const int cursorWidth = GetSystemMetrics(SM_CXCURSOR);
1326 const int cursorHeight = GetSystemMetrics(SM_CYCURSOR);
1327
1328 unsigned char* cursorPixels = _glfw_calloc(cursorWidth * cursorHeight, 4);
1329 if (!cursorPixels)
1330 return GLFW_FALSE;
1331
1332 // NOTE: Windows checks whether the image is fully transparent and if so
1333 // just ignores the alpha channel and makes the whole cursor opaque
1334 // HACK: Make one pixel slightly less transparent
1335 cursorPixels[3] = 1;
1336
1337 const GLFWimage cursorImage = { cursorWidth, cursorHeight, cursorPixels };
1338 _glfw.win32.blankCursor = createIcon(&cursorImage, 0, 0, FALSE);
1339 _glfw_free(cursorPixels);
1340
1341 if (!_glfw.win32.blankCursor)
1342 return GLFW_FALSE;
1343 }
1344 }
1345
1346 if (window->monitor)
1347 {
1348 MONITORINFO mi = { sizeof(mi) };
1349 GetMonitorInfoW(window->monitor->win32.handle, &mi);
1350
1351 // NOTE: This window placement is temporary and approximate, as the
1352 // correct position and size cannot be known until the monitor
1353 // video mode has been picked in _glfwSetVideoModeWin32
1354 frameX = mi.rcMonitor.left;
1355 frameY = mi.rcMonitor.top;
1356 frameWidth = mi.rcMonitor.right - mi.rcMonitor.left;
1357 frameHeight = mi.rcMonitor.bottom - mi.rcMonitor.top;
1358 }
1359 else
1360 {
1361 RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
1362
1363 window->win32.maximized = wndconfig->maximized;
1364 if (wndconfig->maximized)
1365 style |= WS_MAXIMIZE;
1366
1367 AdjustWindowRectEx(&rect, style, FALSE, exStyle);
1368
1369 if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
1370 {
1371 frameX = CW_USEDEFAULT;
1372 frameY = CW_USEDEFAULT;
1373 }
1374 else
1375 {
1376 frameX = wndconfig->xpos + rect.left;
1377 frameY = wndconfig->ypos + rect.top;
1378 }
1379
1380 frameWidth = rect.right - rect.left;
1381 frameHeight = rect.bottom - rect.top;
1382 }
1383
1384 wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
1385 if (!wideTitle)
1386 return GLFW_FALSE;
1387
1388 window->win32.handle = CreateWindowExW(exStyle,
1389 MAKEINTATOM(_glfw.win32.mainWindowClass),
1390 wideTitle,
1391 style,
1392 frameX, frameY,
1393 frameWidth, frameHeight,
1394 NULL, // No parent window
1395 NULL, // No window menu
1396 _glfw.win32.instance,
1397 (LPVOID) wndconfig);
1398
1399 _glfw_free(wideTitle);
1400
1401 if (!window->win32.handle)
1402 {
1403 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
1404 "Win32: Failed to create window");
1405 return GLFW_FALSE;
1406 }
1407
1408 SetPropW(window->win32.handle, L"GLFW", window);
1409
1410 if (IsWindows7OrGreater())
1411 {
1412 ChangeWindowMessageFilterEx(window->win32.handle,
1413 WM_DROPFILES, MSGFLT_ALLOW, NULL);
1414 ChangeWindowMessageFilterEx(window->win32.handle,
1415 WM_COPYDATA, MSGFLT_ALLOW, NULL);
1416 ChangeWindowMessageFilterEx(window->win32.handle,
1417 WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
1418 }
1419
1420 window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
1421 window->win32.keymenu = wndconfig->win32.keymenu;
1422 window->win32.showDefault = wndconfig->win32.showDefault;
1423
1424 if (!window->monitor)
1425 {
1426 RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
1427 WINDOWPLACEMENT wp = { sizeof(wp) };
1428 const HMONITOR mh = MonitorFromWindow(window->win32.handle,
1429 MONITOR_DEFAULTTONEAREST);
1430
1431 // Adjust window rect to account for DPI scaling of the window frame and
1432 // (if enabled) DPI scaling of the content area
1433 // This cannot be done until we know what monitor the window was placed on
1434 // Only update the restored window rect as the window may be maximized
1435
1436 if (wndconfig->scaleToMonitor)
1437 {
1438 float xscale, yscale;
1439 _glfwGetHMONITORContentScaleWin32(mh, &xscale, &yscale);
1440
1441 if (xscale > 0.f && yscale > 0.f)
1442 {
1443 rect.right = (int) (rect.right * xscale);
1444 rect.bottom = (int) (rect.bottom * yscale);
1445 }
1446 }
1447
1448 if (_glfwIsWindows10Version1607OrGreaterWin32())
1449 {
1450 AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle,
1451 GetDpiForWindow(window->win32.handle));
1452 }
1453 else
1454 AdjustWindowRectEx(&rect, style, FALSE, exStyle);
1455
1456 GetWindowPlacement(window->win32.handle, &wp);
1457 OffsetRect(&rect,
1458 wp.rcNormalPosition.left - rect.left,
1459 wp.rcNormalPosition.top - rect.top);
1460
1461 wp.rcNormalPosition = rect;
1462 wp.showCmd = SW_HIDE;
1463 SetWindowPlacement(window->win32.handle, &wp);
1464
1465 // Adjust rect of maximized undecorated window, because by default Windows will
1466 // make such a window cover the whole monitor instead of its workarea
1467
1468 if (wndconfig->maximized && !wndconfig->decorated)
1469 {
1470 MONITORINFO mi = { sizeof(mi) };
1471 GetMonitorInfoW(mh, &mi);
1472
1473 SetWindowPos(window->win32.handle, HWND_TOP,
1474 mi.rcWork.left,
1475 mi.rcWork.top,
1476 mi.rcWork.right - mi.rcWork.left,
1477 mi.rcWork.bottom - mi.rcWork.top,
1478 SWP_NOACTIVATE | SWP_NOZORDER);
1479 }
1480 }
1481
1482 DragAcceptFiles(window->win32.handle, TRUE);
1483
1484 if (fbconfig->transparent)
1485 {
1486 updateFramebufferTransparency(window);
1487 window->win32.transparent = GLFW_TRUE;
1488 }
1489
1490 _glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height);
1491
1492 return GLFW_TRUE;
1493}
1494
1495GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window,
1496 const _GLFWwndconfig* wndconfig,
1497 const _GLFWctxconfig* ctxconfig,
1498 const _GLFWfbconfig* fbconfig)
1499{
1500 if (!createNativeWindow(window, wndconfig, fbconfig))
1501 return GLFW_FALSE;
1502
1503 if (ctxconfig->client != GLFW_NO_API)
1504 {
1505 if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
1506 {
1507 if (!_glfwInitWGL())
1508 return GLFW_FALSE;
1509 if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
1510 return GLFW_FALSE;
1511 }
1512 else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
1513 {
1514 if (!_glfwInitEGL())
1515 return GLFW_FALSE;
1516 if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
1517 return GLFW_FALSE;
1518 }
1519 else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
1520 {
1521 if (!_glfwInitOSMesa())
1522 return GLFW_FALSE;
1523 if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
1524 return GLFW_FALSE;
1525 }
1526
1527 if (!_glfwRefreshContextAttribs(window, ctxconfig))
1528 return GLFW_FALSE;
1529 }
1530
1531 if (wndconfig->mousePassthrough)
1532 _glfwSetWindowMousePassthroughWin32(window, GLFW_TRUE);
1533
1534 if (window->monitor)
1535 {
1536 _glfwShowWindowWin32(window);
1537 _glfwFocusWindowWin32(window);
1538 acquireMonitorWin32(window);
1539 fitToMonitor(window);
1540
1541 if (wndconfig->centerCursor)
1542 _glfwCenterCursorInContentArea(window);
1543 }
1544 else
1545 {
1546 if (wndconfig->visible)
1547 {
1548 _glfwShowWindowWin32(window);
1549 if (wndconfig->focused)
1550 _glfwFocusWindowWin32(window);
1551 }
1552 }
1553
1554 return GLFW_TRUE;
1555}
1556
1557void _glfwDestroyWindowWin32(_GLFWwindow* window)
1558{
1559 if (window->monitor)
1560 releaseMonitorWin32(window);
1561
1562 if (window->context.destroy)
1563 window->context.destroy(window);
1564
1565 if (_glfw.win32.disabledCursorWindow == window)
1566 enableCursor(window);
1567
1568 if (_glfw.win32.capturedCursorWindow == window)
1569 releaseCursor();
1570
1571 if (window->win32.handle)
1572 {
1573 RemovePropW(window->win32.handle, L"GLFW");
1574 DestroyWindow(window->win32.handle);
1575 window->win32.handle = NULL;
1576 }
1577
1578 if (window->win32.bigIcon)
1579 DestroyIcon(window->win32.bigIcon);
1580
1581 if (window->win32.smallIcon)
1582 DestroyIcon(window->win32.smallIcon);
1583}
1584
1585void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title)
1586{
1587 WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title);
1588 if (!wideTitle)
1589 return;
1590
1591 SetWindowTextW(window->win32.handle, wideTitle);
1592 _glfw_free(wideTitle);
1593}
1594
1595void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images)
1596{
1597 HICON bigIcon = NULL, smallIcon = NULL;
1598
1599 if (count)
1600 {
1601 const GLFWimage* bigImage = chooseImage(count, images,
1602 GetSystemMetrics(SM_CXICON),
1603 GetSystemMetrics(SM_CYICON));
1604 const GLFWimage* smallImage = chooseImage(count, images,
1605 GetSystemMetrics(SM_CXSMICON),
1606 GetSystemMetrics(SM_CYSMICON));
1607
1608 bigIcon = createIcon(bigImage, 0, 0, GLFW_TRUE);
1609 smallIcon = createIcon(smallImage, 0, 0, GLFW_TRUE);
1610 }
1611 else
1612 {
1613 bigIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICON);
1614 smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
1615 }
1616
1617 SendMessageW(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
1618 SendMessageW(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
1619
1620 if (window->win32.bigIcon)
1621 DestroyIcon(window->win32.bigIcon);
1622
1623 if (window->win32.smallIcon)
1624 DestroyIcon(window->win32.smallIcon);
1625
1626 if (count)
1627 {
1628 window->win32.bigIcon = bigIcon;
1629 window->win32.smallIcon = smallIcon;
1630 }
1631}
1632
1633void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos)
1634{
1635 POINT pos = { 0, 0 };
1636 ClientToScreen(window->win32.handle, &pos);
1637
1638 if (xpos)
1639 *xpos = pos.x;
1640 if (ypos)
1641 *ypos = pos.y;
1642}
1643
1644void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos)
1645{
1646 RECT rect = { xpos, ypos, xpos, ypos };
1647
1648 if (_glfwIsWindows10Version1607OrGreaterWin32())
1649 {
1650 AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
1651 FALSE, getWindowExStyle(window),
1652 GetDpiForWindow(window->win32.handle));
1653 }
1654 else
1655 {
1656 AdjustWindowRectEx(&rect, getWindowStyle(window),
1657 FALSE, getWindowExStyle(window));
1658 }
1659
1660 SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0,
1661 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
1662}
1663
1664void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height)
1665{
1666 RECT area;
1667 GetClientRect(window->win32.handle, &area);
1668
1669 if (width)
1670 *width = area.right;
1671 if (height)
1672 *height = area.bottom;
1673}
1674
1675void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height)
1676{
1677 if (window->monitor)
1678 {
1679 if (window->monitor->window == window)
1680 {
1681 acquireMonitorWin32(window);
1682 fitToMonitor(window);
1683 }
1684 }
1685 else
1686 {
1687 RECT rect = { 0, 0, width, height };
1688
1689 if (_glfwIsWindows10Version1607OrGreaterWin32())
1690 {
1691 AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
1692 FALSE, getWindowExStyle(window),
1693 GetDpiForWindow(window->win32.handle));
1694 }
1695 else
1696 {
1697 AdjustWindowRectEx(&rect, getWindowStyle(window),
1698 FALSE, getWindowExStyle(window));
1699 }
1700
1701 SetWindowPos(window->win32.handle, HWND_TOP,
1702 0, 0, rect.right - rect.left, rect.bottom - rect.top,
1703 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
1704 }
1705}
1706
1707void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window,
1708 int minwidth, int minheight,
1709 int maxwidth, int maxheight)
1710{
1711 RECT area;
1712
1713 if ((minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) &&
1714 (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE))
1715 {
1716 return;
1717 }
1718
1719 GetWindowRect(window->win32.handle, &area);
1720 MoveWindow(window->win32.handle,
1721 area.left, area.top,
1722 area.right - area.left,
1723 area.bottom - area.top, TRUE);
1724}
1725
1726void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom)
1727{
1728 RECT area;
1729
1730 if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
1731 return;
1732
1733 GetWindowRect(window->win32.handle, &area);
1734 applyAspectRatio(window, WMSZ_BOTTOMRIGHT, &area);
1735 MoveWindow(window->win32.handle,
1736 area.left, area.top,
1737 area.right - area.left,
1738 area.bottom - area.top, TRUE);
1739}
1740
1741void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height)
1742{
1743 _glfwGetWindowSizeWin32(window, width, height);
1744}
1745
1746void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window,
1747 int* left, int* top,
1748 int* right, int* bottom)
1749{
1750 RECT rect;
1751 int width, height;
1752
1753 _glfwGetWindowSizeWin32(window, &width, &height);
1754 SetRect(&rect, 0, 0, width, height);
1755
1756 if (_glfwIsWindows10Version1607OrGreaterWin32())
1757 {
1758 AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
1759 FALSE, getWindowExStyle(window),
1760 GetDpiForWindow(window->win32.handle));
1761 }
1762 else
1763 {
1764 AdjustWindowRectEx(&rect, getWindowStyle(window),
1765 FALSE, getWindowExStyle(window));
1766 }
1767
1768 if (left)
1769 *left = -rect.left;
1770 if (top)
1771 *top = -rect.top;
1772 if (right)
1773 *right = rect.right - width;
1774 if (bottom)
1775 *bottom = rect.bottom - height;
1776}
1777
1778void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale)
1779{
1780 const HANDLE handle = MonitorFromWindow(window->win32.handle,
1781 MONITOR_DEFAULTTONEAREST);
1782 _glfwGetHMONITORContentScaleWin32(handle, xscale, yscale);
1783}
1784
1785void _glfwIconifyWindowWin32(_GLFWwindow* window)
1786{
1787 ShowWindow(window->win32.handle, SW_MINIMIZE);
1788}
1789
1790void _glfwRestoreWindowWin32(_GLFWwindow* window)
1791{
1792 ShowWindow(window->win32.handle, SW_RESTORE);
1793}
1794
1795void _glfwMaximizeWindowWin32(_GLFWwindow* window)
1796{
1797 if (IsWindowVisible(window->win32.handle))
1798 ShowWindow(window->win32.handle, SW_MAXIMIZE);
1799 else
1800 maximizeWindowManually(window);
1801}
1802
1803void _glfwShowWindowWin32(_GLFWwindow* window)
1804{
1805 int showCommand = SW_SHOWNA;
1806
1807 if (window->win32.showDefault)
1808 {
1809 // NOTE: GLFW windows currently do not seem to match the Windows 10 definition of
1810 // a main window, so even SW_SHOWDEFAULT does nothing
1811 // This definition is undocumented and can change (source: Raymond Chen)
1812 // HACK: Apply the STARTUPINFO show command manually if available
1813 STARTUPINFOW si = { sizeof(si) };
1814 GetStartupInfoW(&si);
1815 if (si.dwFlags & STARTF_USESHOWWINDOW)
1816 showCommand = si.wShowWindow;
1817
1818 window->win32.showDefault = GLFW_FALSE;
1819 }
1820
1821 ShowWindow(window->win32.handle, showCommand);
1822}
1823
1824void _glfwHideWindowWin32(_GLFWwindow* window)
1825{
1826 ShowWindow(window->win32.handle, SW_HIDE);
1827}
1828
1829void _glfwRequestWindowAttentionWin32(_GLFWwindow* window)
1830{
1831 FlashWindow(window->win32.handle, TRUE);
1832}
1833
1834void _glfwFocusWindowWin32(_GLFWwindow* window)
1835{
1836 BringWindowToTop(window->win32.handle);
1837 SetForegroundWindow(window->win32.handle);
1838 SetFocus(window->win32.handle);
1839}
1840
1841void _glfwSetWindowMonitorWin32(_GLFWwindow* window,
1842 _GLFWmonitor* monitor,
1843 int xpos, int ypos,
1844 int width, int height,
1845 int refreshRate)
1846{
1847 if (window->monitor == monitor)
1848 {
1849 if (monitor)
1850 {
1851 if (monitor->window == window)
1852 {
1853 acquireMonitorWin32(window);
1854 fitToMonitor(window);
1855 }
1856 }
1857 else
1858 {
1859 RECT rect = { xpos, ypos, xpos + width, ypos + height };
1860
1861 if (_glfwIsWindows10Version1607OrGreaterWin32())
1862 {
1863 AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
1864 FALSE, getWindowExStyle(window),
1865 GetDpiForWindow(window->win32.handle));
1866 }
1867 else
1868 {
1869 AdjustWindowRectEx(&rect, getWindowStyle(window),
1870 FALSE, getWindowExStyle(window));
1871 }
1872
1873 SetWindowPos(window->win32.handle, HWND_TOP,
1874 rect.left, rect.top,
1875 rect.right - rect.left, rect.bottom - rect.top,
1876 SWP_NOCOPYBITS | SWP_NOACTIVATE | SWP_NOZORDER);
1877 }
1878
1879 return;
1880 }
1881
1882 if (window->monitor)
1883 releaseMonitorWin32(window);
1884
1885 _glfwInputWindowMonitor(window, monitor);
1886
1887 if (window->monitor)
1888 {
1889 MONITORINFO mi = { sizeof(mi) };
1890 UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
1891
1892 if (window->decorated)
1893 {
1894 DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
1895 style &= ~WS_OVERLAPPEDWINDOW;
1896 style |= getWindowStyle(window);
1897 SetWindowLongW(window->win32.handle, GWL_STYLE, style);
1898 flags |= SWP_FRAMECHANGED;
1899 }
1900
1901 acquireMonitorWin32(window);
1902
1903 GetMonitorInfoW(window->monitor->win32.handle, &mi);
1904 SetWindowPos(window->win32.handle, HWND_TOPMOST,
1905 mi.rcMonitor.left,
1906 mi.rcMonitor.top,
1907 mi.rcMonitor.right - mi.rcMonitor.left,
1908 mi.rcMonitor.bottom - mi.rcMonitor.top,
1909 flags);
1910 }
1911 else
1912 {
1913 HWND after;
1914 RECT rect = { xpos, ypos, xpos + width, ypos + height };
1915 DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
1916 UINT flags = SWP_NOACTIVATE | SWP_NOCOPYBITS;
1917
1918 if (window->decorated)
1919 {
1920 style &= ~WS_POPUP;
1921 style |= getWindowStyle(window);
1922 SetWindowLongW(window->win32.handle, GWL_STYLE, style);
1923
1924 flags |= SWP_FRAMECHANGED;
1925 }
1926
1927 if (window->floating)
1928 after = HWND_TOPMOST;
1929 else
1930 after = HWND_NOTOPMOST;
1931
1932 if (_glfwIsWindows10Version1607OrGreaterWin32())
1933 {
1934 AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
1935 FALSE, getWindowExStyle(window),
1936 GetDpiForWindow(window->win32.handle));
1937 }
1938 else
1939 {
1940 AdjustWindowRectEx(&rect, getWindowStyle(window),
1941 FALSE, getWindowExStyle(window));
1942 }
1943
1944 SetWindowPos(window->win32.handle, after,
1945 rect.left, rect.top,
1946 rect.right - rect.left, rect.bottom - rect.top,
1947 flags);
1948 }
1949}
1950
1951GLFWbool _glfwWindowFocusedWin32(_GLFWwindow* window)
1952{
1953 return window->win32.handle == GetActiveWindow();
1954}
1955
1956GLFWbool _glfwWindowIconifiedWin32(_GLFWwindow* window)
1957{
1958 return IsIconic(window->win32.handle);
1959}
1960
1961GLFWbool _glfwWindowVisibleWin32(_GLFWwindow* window)
1962{
1963 return IsWindowVisible(window->win32.handle);
1964}
1965
1966GLFWbool _glfwWindowMaximizedWin32(_GLFWwindow* window)
1967{
1968 return IsZoomed(window->win32.handle);
1969}
1970
1971GLFWbool _glfwWindowHoveredWin32(_GLFWwindow* window)
1972{
1973 return cursorInContentArea(window);
1974}
1975
1976GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window)
1977{
1978 BOOL composition, opaque;
1979 DWORD color;
1980
1981 if (!window->win32.transparent)
1982 return GLFW_FALSE;
1983
1984 if (!IsWindowsVistaOrGreater())
1985 return GLFW_FALSE;
1986
1987 if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
1988 return GLFW_FALSE;
1989
1990 if (!IsWindows8OrGreater())
1991 {
1992 // HACK: Disable framebuffer transparency on Windows 7 when the
1993 // colorization color is opaque, because otherwise the window
1994 // contents is blended additively with the previous frame instead
1995 // of replacing it
1996 if (FAILED(DwmGetColorizationColor(&color, &opaque)) || opaque)
1997 return GLFW_FALSE;
1998 }
1999
2000 return GLFW_TRUE;
2001}
2002
2003void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled)
2004{
2005 updateWindowStyles(window);
2006}
2007
2008void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled)
2009{
2010 updateWindowStyles(window);
2011}
2012
2013void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled)
2014{
2015 const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST;
2016 SetWindowPos(window->win32.handle, after, 0, 0, 0, 0,
2017 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
2018}
2019
2020void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled)
2021{
2022 COLORREF key = 0;
2023 BYTE alpha = 0;
2024 DWORD flags = 0;
2025 DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
2026
2027 if (exStyle & WS_EX_LAYERED)
2028 GetLayeredWindowAttributes(window->win32.handle, &key, &alpha, &flags);
2029
2030 if (enabled)
2031 exStyle |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
2032 else
2033 {
2034 exStyle &= ~WS_EX_TRANSPARENT;
2035 // NOTE: Window opacity also needs the layered window style so do not
2036 // remove it if the window is alpha blended
2037 if (exStyle & WS_EX_LAYERED)
2038 {
2039 if (!(flags & LWA_ALPHA))
2040 exStyle &= ~WS_EX_LAYERED;
2041 }
2042 }
2043
2044 SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
2045
2046 if (enabled)
2047 SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags);
2048}
2049
2050float _glfwGetWindowOpacityWin32(_GLFWwindow* window)
2051{
2052 BYTE alpha;
2053 DWORD flags;
2054
2055 if ((GetWindowLongW(window->win32.handle, GWL_EXSTYLE) & WS_EX_LAYERED) &&
2056 GetLayeredWindowAttributes(window->win32.handle, NULL, &alpha, &flags))
2057 {
2058 if (flags & LWA_ALPHA)
2059 return alpha / 255.f;
2060 }
2061
2062 return 1.f;
2063}
2064
2065void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity)
2066{
2067 LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
2068 if (opacity < 1.f || (exStyle & WS_EX_TRANSPARENT))
2069 {
2070 const BYTE alpha = (BYTE) (255 * opacity);
2071 exStyle |= WS_EX_LAYERED;
2072 SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
2073 SetLayeredWindowAttributes(window->win32.handle, 0, alpha, LWA_ALPHA);
2074 }
2075 else if (exStyle & WS_EX_TRANSPARENT)
2076 {
2077 SetLayeredWindowAttributes(window->win32.handle, 0, 0, 0);
2078 }
2079 else
2080 {
2081 exStyle &= ~WS_EX_LAYERED;
2082 SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
2083 }
2084}
2085
2086void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled)
2087{
2088 if (_glfw.win32.disabledCursorWindow != window)
2089 return;
2090
2091 if (enabled)
2092 enableRawMouseMotion(window);
2093 else
2094 disableRawMouseMotion(window);
2095}
2096
2097GLFWbool _glfwRawMouseMotionSupportedWin32(void)
2098{
2099 return GLFW_TRUE;
2100}
2101
2102void _glfwPollEventsWin32(void)
2103{
2104 MSG msg;
2105 HWND handle;
2106 _GLFWwindow* window;
2107
2108 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
2109 {
2110 if (msg.message == WM_QUIT)
2111 {
2112 // NOTE: While GLFW does not itself post WM_QUIT, other processes
2113 // may post it to this one, for example Task Manager
2114 // HACK: Treat WM_QUIT as a close on all windows
2115
2116 window = _glfw.windowListHead;
2117 while (window)
2118 {
2119 _glfwInputWindowCloseRequest(window);
2120 window = window->next;
2121 }
2122 }
2123 else
2124 {
2125 TranslateMessage(&msg);
2126 DispatchMessageW(&msg);
2127 }
2128 }
2129
2130 // HACK: Release modifier keys that the system did not emit KEYUP for
2131 // NOTE: Shift keys on Windows tend to "stick" when both are pressed as
2132 // no key up message is generated by the first key release
2133 // NOTE: Windows key is not reported as released by the Win+V hotkey
2134 // Other Win hotkeys are handled implicitly by _glfwInputWindowFocus
2135 // because they change the input focus
2136 // NOTE: The other half of this is in the WM_*KEY* handler in windowProc
2137 handle = GetActiveWindow();
2138 if (handle)
2139 {
2140 window = GetPropW(handle, L"GLFW");
2141 if (window)
2142 {
2143 int i;
2144 const int keys[4][2] =
2145 {
2146 { VK_LSHIFT, GLFW_KEY_LEFT_SHIFT },
2147 { VK_RSHIFT, GLFW_KEY_RIGHT_SHIFT },
2148 { VK_LWIN, GLFW_KEY_LEFT_SUPER },
2149 { VK_RWIN, GLFW_KEY_RIGHT_SUPER }
2150 };
2151
2152 for (i = 0; i < 4; i++)
2153 {
2154 const int vk = keys[i][0];
2155 const int key = keys[i][1];
2156 const int scancode = _glfw.win32.scancodes[key];
2157
2158 if ((GetKeyState(vk) & 0x8000))
2159 continue;
2160 if (window->keys[key] != GLFW_PRESS)
2161 continue;
2162
2163 _glfwInputKey(window, key, scancode, GLFW_RELEASE, getKeyMods());
2164 }
2165 }
2166 }
2167
2168 window = _glfw.win32.disabledCursorWindow;
2169 if (window)
2170 {
2171 int width, height;
2172 _glfwGetWindowSizeWin32(window, &width, &height);
2173
2174 // NOTE: Re-center the cursor only if it has moved since the last call,
2175 // to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
2176 // The re-center is required in order to prevent the mouse cursor stopping at the edges of the screen.
2177 if (window->win32.lastCursorPosX != width / 2 ||
2178 window->win32.lastCursorPosY != height / 2)
2179 {
2180 _glfwSetCursorPosWin32(window, width / 2, height / 2);
2181 }
2182 }
2183}
2184
2185void _glfwWaitEventsWin32(void)
2186{
2187 WaitMessage();
2188
2189 _glfwPollEventsWin32();
2190}
2191
2192void _glfwWaitEventsTimeoutWin32(double timeout)
2193{
2194 MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLINPUT);
2195
2196 _glfwPollEventsWin32();
2197}
2198
2199void _glfwPostEmptyEventWin32(void)
2200{
2201 PostMessageW(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
2202}
2203
2204void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos)
2205{
2206 POINT pos;
2207
2208 if (GetCursorPos(&pos))
2209 {
2210 ScreenToClient(window->win32.handle, &pos);
2211
2212 if (xpos)
2213 *xpos = pos.x;
2214 if (ypos)
2215 *ypos = pos.y;
2216 }
2217}
2218
2219void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos)
2220{
2221 POINT pos = { (int) xpos, (int) ypos };
2222
2223 // Store the new position so it can be recognized later
2224 window->win32.lastCursorPosX = pos.x;
2225 window->win32.lastCursorPosY = pos.y;
2226
2227 ClientToScreen(window->win32.handle, &pos);
2228 SetCursorPos(pos.x, pos.y);
2229}
2230
2231void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode)
2232{
2233 if (_glfwWindowFocusedWin32(window))
2234 {
2235 if (mode == GLFW_CURSOR_DISABLED)
2236 {
2237 _glfwGetCursorPosWin32(window,
2238 &_glfw.win32.restoreCursorPosX,
2239 &_glfw.win32.restoreCursorPosY);
2240 _glfwCenterCursorInContentArea(window);
2241 if (window->rawMouseMotion)
2242 enableRawMouseMotion(window);
2243 }
2244 else if (_glfw.win32.disabledCursorWindow == window)
2245 {
2246 if (window->rawMouseMotion)
2247 disableRawMouseMotion(window);
2248 }
2249
2250 if (mode == GLFW_CURSOR_DISABLED || mode == GLFW_CURSOR_CAPTURED)
2251 captureCursor(window);
2252 else
2253 releaseCursor();
2254
2255 if (mode == GLFW_CURSOR_DISABLED)
2256 _glfw.win32.disabledCursorWindow = window;
2257 else if (_glfw.win32.disabledCursorWindow == window)
2258 {
2259 _glfw.win32.disabledCursorWindow = NULL;
2260 _glfwSetCursorPosWin32(window,
2261 _glfw.win32.restoreCursorPosX,
2262 _glfw.win32.restoreCursorPosY);
2263 }
2264 }
2265
2266 if (cursorInContentArea(window))
2267 updateCursorImage(window);
2268}
2269
2270const char* _glfwGetScancodeNameWin32(int scancode)
2271{
2272 if (scancode < 0 || scancode > (KF_EXTENDED | 0xff))
2273 {
2274 _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
2275 return NULL;
2276 }
2277
2278 const int key = _glfw.win32.keycodes[scancode];
2279 if (key == GLFW_KEY_UNKNOWN)
2280 return NULL;
2281
2282 return _glfw.win32.keynames[key];
2283}
2284
2285int _glfwGetKeyScancodeWin32(int key)
2286{
2287 return _glfw.win32.scancodes[key];
2288}
2289
2290GLFWbool _glfwCreateCursorWin32(_GLFWcursor* cursor,
2291 const GLFWimage* image,
2292 int xhot, int yhot)
2293{
2294 cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
2295 if (!cursor->win32.handle)
2296 return GLFW_FALSE;
2297
2298 return GLFW_TRUE;
2299}
2300
2301GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape)
2302{
2303 int id = 0;
2304
2305 switch (shape)
2306 {
2307 case GLFW_ARROW_CURSOR:
2308 id = OCR_NORMAL;
2309 break;
2310 case GLFW_IBEAM_CURSOR:
2311 id = OCR_IBEAM;
2312 break;
2313 case GLFW_CROSSHAIR_CURSOR:
2314 id = OCR_CROSS;
2315 break;
2316 case GLFW_POINTING_HAND_CURSOR:
2317 id = OCR_HAND;
2318 break;
2319 case GLFW_RESIZE_EW_CURSOR:
2320 id = OCR_SIZEWE;
2321 break;
2322 case GLFW_RESIZE_NS_CURSOR:
2323 id = OCR_SIZENS;
2324 break;
2325 case GLFW_RESIZE_NWSE_CURSOR:
2326 id = OCR_SIZENWSE;
2327 break;
2328 case GLFW_RESIZE_NESW_CURSOR:
2329 id = OCR_SIZENESW;
2330 break;
2331 case GLFW_RESIZE_ALL_CURSOR:
2332 id = OCR_SIZEALL;
2333 break;
2334 case GLFW_NOT_ALLOWED_CURSOR:
2335 id = OCR_NO;
2336 break;
2337 default:
2338 _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
2339 return GLFW_FALSE;
2340 }
2341
2342 cursor->win32.handle = LoadImageW(NULL,
2343 MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0,
2344 LR_DEFAULTSIZE | LR_SHARED);
2345 if (!cursor->win32.handle)
2346 {
2347 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
2348 "Win32: Failed to create standard cursor");
2349 return GLFW_FALSE;
2350 }
2351
2352 return GLFW_TRUE;
2353}
2354
2355void _glfwDestroyCursorWin32(_GLFWcursor* cursor)
2356{
2357 if (cursor->win32.handle)
2358 DestroyIcon((HICON) cursor->win32.handle);
2359}
2360
2361void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor)
2362{
2363 if (cursorInContentArea(window))
2364 updateCursorImage(window);
2365}
2366
2367void _glfwSetClipboardStringWin32(const char* string)
2368{
2369 int characterCount, tries = 0;
2370 HANDLE object;
2371 WCHAR* buffer;
2372
2373 characterCount = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0);
2374 if (!characterCount)
2375 return;
2376
2377 object = GlobalAlloc(GMEM_MOVEABLE, characterCount * sizeof(WCHAR));
2378 if (!object)
2379 {
2380 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
2381 "Win32: Failed to allocate global handle for clipboard");
2382 return;
2383 }
2384
2385 buffer = GlobalLock(object);
2386 if (!buffer)
2387 {
2388 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
2389 "Win32: Failed to lock global handle");
2390 GlobalFree(object);
2391 return;
2392 }
2393
2394 MultiByteToWideChar(CP_UTF8, 0, string, -1, buffer, characterCount);
2395 GlobalUnlock(object);
2396
2397 // NOTE: Retry clipboard opening a few times as some other application may have it
2398 // open and also the Windows Clipboard History reads it after each update
2399 while (!OpenClipboard(_glfw.win32.helperWindowHandle))
2400 {
2401 Sleep(1);
2402 tries++;
2403
2404 if (tries == 3)
2405 {
2406 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
2407 "Win32: Failed to open clipboard");
2408 GlobalFree(object);
2409 return;
2410 }
2411 }
2412
2413 EmptyClipboard();
2414 SetClipboardData(CF_UNICODETEXT, object);
2415 CloseClipboard();
2416}
2417
2418const char* _glfwGetClipboardStringWin32(void)
2419{
2420 HANDLE object;
2421 WCHAR* buffer;
2422 int tries = 0;
2423
2424 // NOTE: Retry clipboard opening a few times as some other application may have it
2425 // open and also the Windows Clipboard History reads it after each update
2426 while (!OpenClipboard(_glfw.win32.helperWindowHandle))
2427 {
2428 Sleep(1);
2429 tries++;
2430
2431 if (tries == 3)
2432 {
2433 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
2434 "Win32: Failed to open clipboard");
2435 return NULL;
2436 }
2437 }
2438
2439 object = GetClipboardData(CF_UNICODETEXT);
2440 if (!object)
2441 {
2442 _glfwInputErrorWin32(GLFW_FORMAT_UNAVAILABLE,
2443 "Win32: Failed to convert clipboard to string");
2444 CloseClipboard();
2445 return NULL;
2446 }
2447
2448 buffer = GlobalLock(object);
2449 if (!buffer)
2450 {
2451 _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
2452 "Win32: Failed to lock global handle");
2453 CloseClipboard();
2454 return NULL;
2455 }
2456
2457 _glfw_free(_glfw.win32.clipboardString);
2458 _glfw.win32.clipboardString = _glfwCreateUTF8FromWideStringWin32(buffer);
2459
2460 GlobalUnlock(object);
2461 CloseClipboard();
2462
2463 return _glfw.win32.clipboardString;
2464}
2465
2466EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
2467{
2468 if (_glfw.egl.ANGLE_platform_angle)
2469 {
2470 int type = 0;
2471
2472 if (_glfw.egl.ANGLE_platform_angle_opengl)
2473 {
2474 if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
2475 type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
2476 else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGLES)
2477 type = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
2478 }
2479
2480 if (_glfw.egl.ANGLE_platform_angle_d3d)
2481 {
2482 if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D9)
2483 type = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE;
2484 else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D11)
2485 type = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
2486 }
2487
2488 if (_glfw.egl.ANGLE_platform_angle_vulkan)
2489 {
2490 if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
2491 type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
2492 }
2493
2494 if (type)
2495 {
2496 *attribs = _glfw_calloc(3, sizeof(EGLint));
2497 (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
2498 (*attribs)[1] = type;
2499 (*attribs)[2] = EGL_NONE;
2500 return EGL_PLATFORM_ANGLE_ANGLE;
2501 }
2502 }
2503
2504 return 0;
2505}
2506
2507EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void)
2508{
2509 return GetDC(_glfw.win32.helperWindowHandle);
2510}
2511
2512EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window)
2513{
2514 return window->win32.handle;
2515}
2516
2517void _glfwGetRequiredInstanceExtensionsWin32(char** extensions)
2518{
2519 if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
2520 return;
2521
2522 extensions[0] = "VK_KHR_surface";
2523 extensions[1] = "VK_KHR_win32_surface";
2524}
2525
2526GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance,
2527 VkPhysicalDevice device,
2528 uint32_t queuefamily)
2529{
2530 PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
2531 vkGetPhysicalDeviceWin32PresentationSupportKHR =
2532 (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)
2533 vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
2534 if (!vkGetPhysicalDeviceWin32PresentationSupportKHR)
2535 {
2536 _glfwInputError(GLFW_API_UNAVAILABLE,
2537 "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
2538 return GLFW_FALSE;
2539 }
2540
2541 return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily);
2542}
2543
2544VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance,
2545 _GLFWwindow* window,
2546 const VkAllocationCallbacks* allocator,
2547 VkSurfaceKHR* surface)
2548{
2549 VkResult err;
2550 VkWin32SurfaceCreateInfoKHR sci;
2551 PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
2552
2553 vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
2554 vkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR");
2555 if (!vkCreateWin32SurfaceKHR)
2556 {
2557 _glfwInputError(GLFW_API_UNAVAILABLE,
2558 "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
2559 return VK_ERROR_EXTENSION_NOT_PRESENT;
2560 }
2561
2562 memset(&sci, 0, sizeof(sci));
2563 sci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
2564 sci.hinstance = _glfw.win32.instance;
2565 sci.hwnd = window->win32.handle;
2566
2567 err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface);
2568 if (err)
2569 {
2570 _glfwInputError(GLFW_PLATFORM_ERROR,
2571 "Win32: Failed to create Vulkan surface: %s",
2572 _glfwGetVulkanResultString(err));
2573 }
2574
2575 return err;
2576}
2577
2578GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
2579{
2580 _GLFWwindow* window = (_GLFWwindow*) handle;
2581 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
2582
2583 if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
2584 {
2585 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
2586 "Win32: Platform not initialized");
2587 return NULL;
2588 }
2589
2590 return window->win32.handle;
2591}
2592
2593#endif // _GLFW_WIN32
2594
diff --git a/raylib/src/external/glfw/src/window.c b/raylib/src/external/glfw/src/window.c
new file mode 100644
index 0000000..1463d16
--- /dev/null
+++ b/raylib/src/external/glfw/src/window.c
@@ -0,0 +1,1172 @@
1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#include <assert.h>
32#include <string.h>
33#include <stdlib.h>
34#include <float.h>
35
36
37//////////////////////////////////////////////////////////////////////////
38////// GLFW event API //////
39//////////////////////////////////////////////////////////////////////////
40
41// Notifies shared code that a window has lost or received input focus
42//
43void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
44{
45 assert(window != NULL);
46 assert(focused == GLFW_TRUE || focused == GLFW_FALSE);
47
48 if (window->callbacks.focus)
49 window->callbacks.focus((GLFWwindow*) window, focused);
50
51 if (!focused)
52 {
53 int key, button;
54
55 for (key = 0; key <= GLFW_KEY_LAST; key++)
56 {
57 if (window->keys[key] == GLFW_PRESS)
58 {
59 const int scancode = _glfw.platform.getKeyScancode(key);
60 _glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
61 }
62 }
63
64 for (button = 0; button <= GLFW_MOUSE_BUTTON_LAST; button++)
65 {
66 if (window->mouseButtons[button] == GLFW_PRESS)
67 _glfwInputMouseClick(window, button, GLFW_RELEASE, 0);
68 }
69 }
70}
71
72// Notifies shared code that a window has moved
73// The position is specified in content area relative screen coordinates
74//
75void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
76{
77 assert(window != NULL);
78
79 if (window->callbacks.pos)
80 window->callbacks.pos((GLFWwindow*) window, x, y);
81}
82
83// Notifies shared code that a window has been resized
84// The size is specified in screen coordinates
85//
86void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
87{
88 assert(window != NULL);
89 assert(width >= 0);
90 assert(height >= 0);
91
92 if (window->callbacks.size)
93 window->callbacks.size((GLFWwindow*) window, width, height);
94}
95
96// Notifies shared code that a window has been iconified or restored
97//
98void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
99{
100 assert(window != NULL);
101 assert(iconified == GLFW_TRUE || iconified == GLFW_FALSE);
102
103 if (window->callbacks.iconify)
104 window->callbacks.iconify((GLFWwindow*) window, iconified);
105}
106
107// Notifies shared code that a window has been maximized or restored
108//
109void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
110{
111 assert(window != NULL);
112 assert(maximized == GLFW_TRUE || maximized == GLFW_FALSE);
113
114 if (window->callbacks.maximize)
115 window->callbacks.maximize((GLFWwindow*) window, maximized);
116}
117
118// Notifies shared code that a window framebuffer has been resized
119// The size is specified in pixels
120//
121void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
122{
123 assert(window != NULL);
124 assert(width >= 0);
125 assert(height >= 0);
126
127 if (window->callbacks.fbsize)
128 window->callbacks.fbsize((GLFWwindow*) window, width, height);
129}
130
131// Notifies shared code that a window content scale has changed
132// The scale is specified as the ratio between the current and default DPI
133//
134void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
135{
136 assert(window != NULL);
137 assert(xscale > 0.f);
138 assert(xscale < FLT_MAX);
139 assert(yscale > 0.f);
140 assert(yscale < FLT_MAX);
141
142 if (window->callbacks.scale)
143 window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
144}
145
146// Notifies shared code that the window contents needs updating
147//
148void _glfwInputWindowDamage(_GLFWwindow* window)
149{
150 assert(window != NULL);
151
152 if (window->callbacks.refresh)
153 window->callbacks.refresh((GLFWwindow*) window);
154}
155
156// Notifies shared code that the user wishes to close a window
157//
158void _glfwInputWindowCloseRequest(_GLFWwindow* window)
159{
160 assert(window != NULL);
161
162 window->shouldClose = GLFW_TRUE;
163
164 if (window->callbacks.close)
165 window->callbacks.close((GLFWwindow*) window);
166}
167
168// Notifies shared code that a window has changed its desired monitor
169//
170void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
171{
172 assert(window != NULL);
173 window->monitor = monitor;
174}
175
176//////////////////////////////////////////////////////////////////////////
177////// GLFW public API //////
178//////////////////////////////////////////////////////////////////////////
179
180GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
181 const char* title,
182 GLFWmonitor* monitor,
183 GLFWwindow* share)
184{
185 _GLFWfbconfig fbconfig;
186 _GLFWctxconfig ctxconfig;
187 _GLFWwndconfig wndconfig;
188 _GLFWwindow* window;
189
190 assert(title != NULL);
191 assert(width >= 0);
192 assert(height >= 0);
193
194 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
195
196 if (width <= 0 || height <= 0)
197 {
198 _glfwInputError(GLFW_INVALID_VALUE,
199 "Invalid window size %ix%i",
200 width, height);
201
202 return NULL;
203 }
204
205 fbconfig = _glfw.hints.framebuffer;
206 ctxconfig = _glfw.hints.context;
207 wndconfig = _glfw.hints.window;
208
209 wndconfig.width = width;
210 wndconfig.height = height;
211 wndconfig.title = title;
212 ctxconfig.share = (_GLFWwindow*) share;
213
214 if (!_glfwIsValidContextConfig(&ctxconfig))
215 return NULL;
216
217 window = _glfw_calloc(1, sizeof(_GLFWwindow));
218 window->next = _glfw.windowListHead;
219 _glfw.windowListHead = window;
220
221 window->videoMode.width = width;
222 window->videoMode.height = height;
223 window->videoMode.redBits = fbconfig.redBits;
224 window->videoMode.greenBits = fbconfig.greenBits;
225 window->videoMode.blueBits = fbconfig.blueBits;
226 window->videoMode.refreshRate = _glfw.hints.refreshRate;
227
228 window->monitor = (_GLFWmonitor*) monitor;
229 window->resizable = wndconfig.resizable;
230 window->decorated = wndconfig.decorated;
231 window->autoIconify = wndconfig.autoIconify;
232 window->floating = wndconfig.floating;
233 window->focusOnShow = wndconfig.focusOnShow;
234 window->mousePassthrough = wndconfig.mousePassthrough;
235 window->cursorMode = GLFW_CURSOR_NORMAL;
236
237 window->doublebuffer = fbconfig.doublebuffer;
238
239 window->minwidth = GLFW_DONT_CARE;
240 window->minheight = GLFW_DONT_CARE;
241 window->maxwidth = GLFW_DONT_CARE;
242 window->maxheight = GLFW_DONT_CARE;
243 window->numer = GLFW_DONT_CARE;
244 window->denom = GLFW_DONT_CARE;
245 window->title = _glfw_strdup(title);
246
247 if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
248 {
249 glfwDestroyWindow((GLFWwindow*) window);
250 return NULL;
251 }
252
253 return (GLFWwindow*) window;
254}
255
256void glfwDefaultWindowHints(void)
257{
258 _GLFW_REQUIRE_INIT();
259
260 // The default is OpenGL with minimum version 1.0
261 memset(&_glfw.hints.context, 0, sizeof(_glfw.hints.context));
262 _glfw.hints.context.client = GLFW_OPENGL_API;
263 _glfw.hints.context.source = GLFW_NATIVE_CONTEXT_API;
264 _glfw.hints.context.major = 1;
265 _glfw.hints.context.minor = 0;
266
267 // The default is a focused, visible, resizable window with decorations
268 memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window));
269 _glfw.hints.window.resizable = GLFW_TRUE;
270 _glfw.hints.window.visible = GLFW_TRUE;
271 _glfw.hints.window.decorated = GLFW_TRUE;
272 _glfw.hints.window.focused = GLFW_TRUE;
273 _glfw.hints.window.autoIconify = GLFW_TRUE;
274 _glfw.hints.window.centerCursor = GLFW_TRUE;
275 _glfw.hints.window.focusOnShow = GLFW_TRUE;
276 _glfw.hints.window.xpos = GLFW_ANY_POSITION;
277 _glfw.hints.window.ypos = GLFW_ANY_POSITION;
278 _glfw.hints.window.scaleFramebuffer = GLFW_TRUE;
279
280 // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
281 // double buffered
282 memset(&_glfw.hints.framebuffer, 0, sizeof(_glfw.hints.framebuffer));
283 _glfw.hints.framebuffer.redBits = 8;
284 _glfw.hints.framebuffer.greenBits = 8;
285 _glfw.hints.framebuffer.blueBits = 8;
286 _glfw.hints.framebuffer.alphaBits = 8;
287 _glfw.hints.framebuffer.depthBits = 24;
288 _glfw.hints.framebuffer.stencilBits = 8;
289 _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
290
291 // The default is to select the highest available refresh rate
292 _glfw.hints.refreshRate = GLFW_DONT_CARE;
293}
294
295GLFWAPI void glfwWindowHint(int hint, int value)
296{
297 _GLFW_REQUIRE_INIT();
298
299 switch (hint)
300 {
301 case GLFW_RED_BITS:
302 _glfw.hints.framebuffer.redBits = value;
303 return;
304 case GLFW_GREEN_BITS:
305 _glfw.hints.framebuffer.greenBits = value;
306 return;
307 case GLFW_BLUE_BITS:
308 _glfw.hints.framebuffer.blueBits = value;
309 return;
310 case GLFW_ALPHA_BITS:
311 _glfw.hints.framebuffer.alphaBits = value;
312 return;
313 case GLFW_DEPTH_BITS:
314 _glfw.hints.framebuffer.depthBits = value;
315 return;
316 case GLFW_STENCIL_BITS:
317 _glfw.hints.framebuffer.stencilBits = value;
318 return;
319 case GLFW_ACCUM_RED_BITS:
320 _glfw.hints.framebuffer.accumRedBits = value;
321 return;
322 case GLFW_ACCUM_GREEN_BITS:
323 _glfw.hints.framebuffer.accumGreenBits = value;
324 return;
325 case GLFW_ACCUM_BLUE_BITS:
326 _glfw.hints.framebuffer.accumBlueBits = value;
327 return;
328 case GLFW_ACCUM_ALPHA_BITS:
329 _glfw.hints.framebuffer.accumAlphaBits = value;
330 return;
331 case GLFW_AUX_BUFFERS:
332 _glfw.hints.framebuffer.auxBuffers = value;
333 return;
334 case GLFW_STEREO:
335 _glfw.hints.framebuffer.stereo = value ? GLFW_TRUE : GLFW_FALSE;
336 return;
337 case GLFW_DOUBLEBUFFER:
338 _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE;
339 return;
340 case GLFW_TRANSPARENT_FRAMEBUFFER:
341 _glfw.hints.framebuffer.transparent = value ? GLFW_TRUE : GLFW_FALSE;
342 return;
343 case GLFW_SAMPLES:
344 _glfw.hints.framebuffer.samples = value;
345 return;
346 case GLFW_SRGB_CAPABLE:
347 _glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
348 return;
349 case GLFW_RESIZABLE:
350 _glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
351 return;
352 case GLFW_DECORATED:
353 _glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE;
354 return;
355 case GLFW_FOCUSED:
356 _glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE;
357 return;
358 case GLFW_AUTO_ICONIFY:
359 _glfw.hints.window.autoIconify = value ? GLFW_TRUE : GLFW_FALSE;
360 return;
361 case GLFW_FLOATING:
362 _glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE;
363 return;
364 case GLFW_MAXIMIZED:
365 _glfw.hints.window.maximized = value ? GLFW_TRUE : GLFW_FALSE;
366 return;
367 case GLFW_VISIBLE:
368 _glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE;
369 return;
370 case GLFW_POSITION_X:
371 _glfw.hints.window.xpos = value;
372 return;
373 case GLFW_POSITION_Y:
374 _glfw.hints.window.ypos = value;
375 return;
376 case GLFW_WIN32_KEYBOARD_MENU:
377 _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
378 return;
379 case GLFW_WIN32_SHOWDEFAULT:
380 _glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE;
381 return;
382 case GLFW_COCOA_GRAPHICS_SWITCHING:
383 _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
384 return;
385 case GLFW_SCALE_TO_MONITOR:
386 _glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE;
387 return;
388 case GLFW_SCALE_FRAMEBUFFER:
389 case GLFW_COCOA_RETINA_FRAMEBUFFER:
390 _glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE;
391 return;
392 case GLFW_CENTER_CURSOR:
393 _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
394 return;
395 case GLFW_FOCUS_ON_SHOW:
396 _glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE;
397 return;
398 case GLFW_MOUSE_PASSTHROUGH:
399 _glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE;
400 return;
401 case GLFW_CLIENT_API:
402 _glfw.hints.context.client = value;
403 return;
404 case GLFW_CONTEXT_CREATION_API:
405 _glfw.hints.context.source = value;
406 return;
407 case GLFW_CONTEXT_VERSION_MAJOR:
408 _glfw.hints.context.major = value;
409 return;
410 case GLFW_CONTEXT_VERSION_MINOR:
411 _glfw.hints.context.minor = value;
412 return;
413 case GLFW_CONTEXT_ROBUSTNESS:
414 _glfw.hints.context.robustness = value;
415 return;
416 case GLFW_OPENGL_FORWARD_COMPAT:
417 _glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE;
418 return;
419 case GLFW_CONTEXT_DEBUG:
420 _glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE;
421 return;
422 case GLFW_CONTEXT_NO_ERROR:
423 _glfw.hints.context.noerror = value ? GLFW_TRUE : GLFW_FALSE;
424 return;
425 case GLFW_OPENGL_PROFILE:
426 _glfw.hints.context.profile = value;
427 return;
428 case GLFW_CONTEXT_RELEASE_BEHAVIOR:
429 _glfw.hints.context.release = value;
430 return;
431 case GLFW_REFRESH_RATE:
432 _glfw.hints.refreshRate = value;
433 return;
434 }
435
436 _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
437}
438
439GLFWAPI void glfwWindowHintString(int hint, const char* value)
440{
441 assert(value != NULL);
442
443 _GLFW_REQUIRE_INIT();
444
445 switch (hint)
446 {
447 case GLFW_COCOA_FRAME_NAME:
448 strncpy(_glfw.hints.window.ns.frameName, value,
449 sizeof(_glfw.hints.window.ns.frameName) - 1);
450 return;
451 case GLFW_X11_CLASS_NAME:
452 strncpy(_glfw.hints.window.x11.className, value,
453 sizeof(_glfw.hints.window.x11.className) - 1);
454 return;
455 case GLFW_X11_INSTANCE_NAME:
456 strncpy(_glfw.hints.window.x11.instanceName, value,
457 sizeof(_glfw.hints.window.x11.instanceName) - 1);
458 return;
459 case GLFW_WAYLAND_APP_ID:
460 strncpy(_glfw.hints.window.wl.appId, value,
461 sizeof(_glfw.hints.window.wl.appId) - 1);
462 return;
463 }
464
465 _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
466}
467
468GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
469{
470 _GLFWwindow* window = (_GLFWwindow*) handle;
471
472 _GLFW_REQUIRE_INIT();
473
474 // Allow closing of NULL (to match the behavior of free)
475 if (window == NULL)
476 return;
477
478 // Clear all callbacks to avoid exposing a half torn-down window object
479 memset(&window->callbacks, 0, sizeof(window->callbacks));
480
481 // The window's context must not be current on another thread when the
482 // window is destroyed
483 if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
484 glfwMakeContextCurrent(NULL);
485
486 _glfw.platform.destroyWindow(window);
487
488 // Unlink window from global linked list
489 {
490 _GLFWwindow** prev = &_glfw.windowListHead;
491
492 while (*prev != window)
493 prev = &((*prev)->next);
494
495 *prev = window->next;
496 }
497
498 _glfw_free(window->title);
499 _glfw_free(window);
500}
501
502GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
503{
504 _GLFWwindow* window = (_GLFWwindow*) handle;
505 assert(window != NULL);
506
507 _GLFW_REQUIRE_INIT_OR_RETURN(0);
508 return window->shouldClose;
509}
510
511GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
512{
513 _GLFWwindow* window = (_GLFWwindow*) handle;
514 assert(window != NULL);
515
516 _GLFW_REQUIRE_INIT();
517 window->shouldClose = value;
518}
519
520GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* handle)
521{
522 _GLFWwindow* window = (_GLFWwindow*) handle;
523 assert(window != NULL);
524
525 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
526
527 return window->title;
528}
529
530GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
531{
532 _GLFWwindow* window = (_GLFWwindow*) handle;
533 assert(window != NULL);
534 assert(title != NULL);
535
536 _GLFW_REQUIRE_INIT();
537
538 char* prev = window->title;
539 window->title = _glfw_strdup(title);
540
541 _glfw.platform.setWindowTitle(window, title);
542 _glfw_free(prev);
543}
544
545GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
546 int count, const GLFWimage* images)
547{
548 int i;
549 _GLFWwindow* window = (_GLFWwindow*) handle;
550
551 assert(window != NULL);
552 assert(count >= 0);
553 assert(count == 0 || images != NULL);
554
555 _GLFW_REQUIRE_INIT();
556
557 if (count < 0)
558 {
559 _glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon");
560 return;
561 }
562
563 for (i = 0; i < count; i++)
564 {
565 assert(images[i].pixels != NULL);
566
567 if (images[i].width <= 0 || images[i].height <= 0)
568 {
569 _glfwInputError(GLFW_INVALID_VALUE,
570 "Invalid image dimensions for window icon");
571 return;
572 }
573 }
574
575 _glfw.platform.setWindowIcon(window, count, images);
576}
577
578GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
579{
580 _GLFWwindow* window = (_GLFWwindow*) handle;
581 assert(window != NULL);
582
583 if (xpos)
584 *xpos = 0;
585 if (ypos)
586 *ypos = 0;
587
588 _GLFW_REQUIRE_INIT();
589 _glfw.platform.getWindowPos(window, xpos, ypos);
590}
591
592GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
593{
594 _GLFWwindow* window = (_GLFWwindow*) handle;
595 assert(window != NULL);
596
597 _GLFW_REQUIRE_INIT();
598
599 if (window->monitor)
600 return;
601
602 _glfw.platform.setWindowPos(window, xpos, ypos);
603}
604
605GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
606{
607 _GLFWwindow* window = (_GLFWwindow*) handle;
608 assert(window != NULL);
609
610 if (width)
611 *width = 0;
612 if (height)
613 *height = 0;
614
615 _GLFW_REQUIRE_INIT();
616 _glfw.platform.getWindowSize(window, width, height);
617}
618
619GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
620{
621 _GLFWwindow* window = (_GLFWwindow*) handle;
622 assert(window != NULL);
623 assert(width >= 0);
624 assert(height >= 0);
625
626 _GLFW_REQUIRE_INIT();
627
628 window->videoMode.width = width;
629 window->videoMode.height = height;
630
631 _glfw.platform.setWindowSize(window, width, height);
632}
633
634GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
635 int minwidth, int minheight,
636 int maxwidth, int maxheight)
637{
638 _GLFWwindow* window = (_GLFWwindow*) handle;
639 assert(window != NULL);
640
641 _GLFW_REQUIRE_INIT();
642
643 if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE)
644 {
645 if (minwidth < 0 || minheight < 0)
646 {
647 _glfwInputError(GLFW_INVALID_VALUE,
648 "Invalid window minimum size %ix%i",
649 minwidth, minheight);
650 return;
651 }
652 }
653
654 if (maxwidth != GLFW_DONT_CARE && maxheight != GLFW_DONT_CARE)
655 {
656 if (maxwidth < 0 || maxheight < 0 ||
657 maxwidth < minwidth || maxheight < minheight)
658 {
659 _glfwInputError(GLFW_INVALID_VALUE,
660 "Invalid window maximum size %ix%i",
661 maxwidth, maxheight);
662 return;
663 }
664 }
665
666 window->minwidth = minwidth;
667 window->minheight = minheight;
668 window->maxwidth = maxwidth;
669 window->maxheight = maxheight;
670
671 if (window->monitor || !window->resizable)
672 return;
673
674 _glfw.platform.setWindowSizeLimits(window,
675 minwidth, minheight,
676 maxwidth, maxheight);
677}
678
679GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
680{
681 _GLFWwindow* window = (_GLFWwindow*) handle;
682 assert(window != NULL);
683 assert(numer != 0);
684 assert(denom != 0);
685
686 _GLFW_REQUIRE_INIT();
687
688 if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
689 {
690 if (numer <= 0 || denom <= 0)
691 {
692 _glfwInputError(GLFW_INVALID_VALUE,
693 "Invalid window aspect ratio %i:%i",
694 numer, denom);
695 return;
696 }
697 }
698
699 window->numer = numer;
700 window->denom = denom;
701
702 if (window->monitor || !window->resizable)
703 return;
704
705 _glfw.platform.setWindowAspectRatio(window, numer, denom);
706}
707
708GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
709{
710 _GLFWwindow* window = (_GLFWwindow*) handle;
711 assert(window != NULL);
712
713 if (width)
714 *width = 0;
715 if (height)
716 *height = 0;
717
718 _GLFW_REQUIRE_INIT();
719 _glfw.platform.getFramebufferSize(window, width, height);
720}
721
722GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
723 int* left, int* top,
724 int* right, int* bottom)
725{
726 _GLFWwindow* window = (_GLFWwindow*) handle;
727 assert(window != NULL);
728
729 if (left)
730 *left = 0;
731 if (top)
732 *top = 0;
733 if (right)
734 *right = 0;
735 if (bottom)
736 *bottom = 0;
737
738 _GLFW_REQUIRE_INIT();
739 _glfw.platform.getWindowFrameSize(window, left, top, right, bottom);
740}
741
742GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
743 float* xscale, float* yscale)
744{
745 _GLFWwindow* window = (_GLFWwindow*) handle;
746 assert(window != NULL);
747
748 if (xscale)
749 *xscale = 0.f;
750 if (yscale)
751 *yscale = 0.f;
752
753 _GLFW_REQUIRE_INIT();
754 _glfw.platform.getWindowContentScale(window, xscale, yscale);
755}
756
757GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
758{
759 _GLFWwindow* window = (_GLFWwindow*) handle;
760 assert(window != NULL);
761
762 _GLFW_REQUIRE_INIT_OR_RETURN(0.f);
763 return _glfw.platform.getWindowOpacity(window);
764}
765
766GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
767{
768 _GLFWwindow* window = (_GLFWwindow*) handle;
769 assert(window != NULL);
770 assert(opacity == opacity);
771 assert(opacity >= 0.f);
772 assert(opacity <= 1.f);
773
774 _GLFW_REQUIRE_INIT();
775
776 if (opacity != opacity || opacity < 0.f || opacity > 1.f)
777 {
778 _glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity);
779 return;
780 }
781
782 _glfw.platform.setWindowOpacity(window, opacity);
783}
784
785GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
786{
787 _GLFWwindow* window = (_GLFWwindow*) handle;
788 assert(window != NULL);
789
790 _GLFW_REQUIRE_INIT();
791 _glfw.platform.iconifyWindow(window);
792}
793
794GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
795{
796 _GLFWwindow* window = (_GLFWwindow*) handle;
797 assert(window != NULL);
798
799 _GLFW_REQUIRE_INIT();
800 _glfw.platform.restoreWindow(window);
801}
802
803GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
804{
805 _GLFWwindow* window = (_GLFWwindow*) handle;
806 assert(window != NULL);
807
808 _GLFW_REQUIRE_INIT();
809
810 if (window->monitor)
811 return;
812
813 _glfw.platform.maximizeWindow(window);
814}
815
816GLFWAPI void glfwShowWindow(GLFWwindow* handle)
817{
818 _GLFWwindow* window = (_GLFWwindow*) handle;
819 assert(window != NULL);
820
821 _GLFW_REQUIRE_INIT();
822
823 if (window->monitor)
824 return;
825
826 _glfw.platform.showWindow(window);
827
828 if (window->focusOnShow)
829 _glfw.platform.focusWindow(window);
830}
831
832GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
833{
834 _GLFWwindow* window = (_GLFWwindow*) handle;
835 assert(window != NULL);
836
837 _GLFW_REQUIRE_INIT();
838
839 _glfw.platform.requestWindowAttention(window);
840}
841
842GLFWAPI void glfwHideWindow(GLFWwindow* handle)
843{
844 _GLFWwindow* window = (_GLFWwindow*) handle;
845 assert(window != NULL);
846
847 _GLFW_REQUIRE_INIT();
848
849 if (window->monitor)
850 return;
851
852 _glfw.platform.hideWindow(window);
853}
854
855GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
856{
857 _GLFWwindow* window = (_GLFWwindow*) handle;
858 assert(window != NULL);
859
860 _GLFW_REQUIRE_INIT();
861
862 _glfw.platform.focusWindow(window);
863}
864
865GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
866{
867 _GLFWwindow* window = (_GLFWwindow*) handle;
868 assert(window != NULL);
869
870 _GLFW_REQUIRE_INIT_OR_RETURN(0);
871
872 switch (attrib)
873 {
874 case GLFW_FOCUSED:
875 return _glfw.platform.windowFocused(window);
876 case GLFW_ICONIFIED:
877 return _glfw.platform.windowIconified(window);
878 case GLFW_VISIBLE:
879 return _glfw.platform.windowVisible(window);
880 case GLFW_MAXIMIZED:
881 return _glfw.platform.windowMaximized(window);
882 case GLFW_HOVERED:
883 return _glfw.platform.windowHovered(window);
884 case GLFW_FOCUS_ON_SHOW:
885 return window->focusOnShow;
886 case GLFW_MOUSE_PASSTHROUGH:
887 return window->mousePassthrough;
888 case GLFW_TRANSPARENT_FRAMEBUFFER:
889 return _glfw.platform.framebufferTransparent(window);
890 case GLFW_RESIZABLE:
891 return window->resizable;
892 case GLFW_DECORATED:
893 return window->decorated;
894 case GLFW_FLOATING:
895 return window->floating;
896 case GLFW_AUTO_ICONIFY:
897 return window->autoIconify;
898 case GLFW_DOUBLEBUFFER:
899 return window->doublebuffer;
900 case GLFW_CLIENT_API:
901 return window->context.client;
902 case GLFW_CONTEXT_CREATION_API:
903 return window->context.source;
904 case GLFW_CONTEXT_VERSION_MAJOR:
905 return window->context.major;
906 case GLFW_CONTEXT_VERSION_MINOR:
907 return window->context.minor;
908 case GLFW_CONTEXT_REVISION:
909 return window->context.revision;
910 case GLFW_CONTEXT_ROBUSTNESS:
911 return window->context.robustness;
912 case GLFW_OPENGL_FORWARD_COMPAT:
913 return window->context.forward;
914 case GLFW_CONTEXT_DEBUG:
915 return window->context.debug;
916 case GLFW_OPENGL_PROFILE:
917 return window->context.profile;
918 case GLFW_CONTEXT_RELEASE_BEHAVIOR:
919 return window->context.release;
920 case GLFW_CONTEXT_NO_ERROR:
921 return window->context.noerror;
922 }
923
924 _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
925 return 0;
926}
927
928GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
929{
930 _GLFWwindow* window = (_GLFWwindow*) handle;
931 assert(window != NULL);
932
933 _GLFW_REQUIRE_INIT();
934
935 value = value ? GLFW_TRUE : GLFW_FALSE;
936
937 switch (attrib)
938 {
939 case GLFW_AUTO_ICONIFY:
940 window->autoIconify = value;
941 return;
942
943 case GLFW_RESIZABLE:
944 window->resizable = value;
945 if (!window->monitor)
946 _glfw.platform.setWindowResizable(window, value);
947 return;
948
949 case GLFW_DECORATED:
950 window->decorated = value;
951 if (!window->monitor)
952 _glfw.platform.setWindowDecorated(window, value);
953 return;
954
955 case GLFW_FLOATING:
956 window->floating = value;
957 if (!window->monitor)
958 _glfw.platform.setWindowFloating(window, value);
959 return;
960
961 case GLFW_FOCUS_ON_SHOW:
962 window->focusOnShow = value;
963 return;
964
965 case GLFW_MOUSE_PASSTHROUGH:
966 window->mousePassthrough = value;
967 _glfw.platform.setWindowMousePassthrough(window, value);
968 return;
969 }
970
971 _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
972}
973
974GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
975{
976 _GLFWwindow* window = (_GLFWwindow*) handle;
977 assert(window != NULL);
978
979 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
980 return (GLFWmonitor*) window->monitor;
981}
982
983GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
984 GLFWmonitor* mh,
985 int xpos, int ypos,
986 int width, int height,
987 int refreshRate)
988{
989 _GLFWwindow* window = (_GLFWwindow*) wh;
990 _GLFWmonitor* monitor = (_GLFWmonitor*) mh;
991 assert(window != NULL);
992 assert(width >= 0);
993 assert(height >= 0);
994
995 _GLFW_REQUIRE_INIT();
996
997 if (width <= 0 || height <= 0)
998 {
999 _glfwInputError(GLFW_INVALID_VALUE,
1000 "Invalid window size %ix%i",
1001 width, height);
1002 return;
1003 }
1004
1005 if (refreshRate < 0 && refreshRate != GLFW_DONT_CARE)
1006 {
1007 _glfwInputError(GLFW_INVALID_VALUE,
1008 "Invalid refresh rate %i",
1009 refreshRate);
1010 return;
1011 }
1012
1013 window->videoMode.width = width;
1014 window->videoMode.height = height;
1015 window->videoMode.refreshRate = refreshRate;
1016
1017 _glfw.platform.setWindowMonitor(window, monitor,
1018 xpos, ypos, width, height,
1019 refreshRate);
1020}
1021
1022GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
1023{
1024 _GLFWwindow* window = (_GLFWwindow*) handle;
1025 assert(window != NULL);
1026
1027 _GLFW_REQUIRE_INIT();
1028 window->userPointer = pointer;
1029}
1030
1031GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
1032{
1033 _GLFWwindow* window = (_GLFWwindow*) handle;
1034 assert(window != NULL);
1035
1036 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1037 return window->userPointer;
1038}
1039
1040GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
1041 GLFWwindowposfun cbfun)
1042{
1043 _GLFWwindow* window = (_GLFWwindow*) handle;
1044 assert(window != NULL);
1045
1046 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1047 _GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun);
1048 return cbfun;
1049}
1050
1051GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
1052 GLFWwindowsizefun cbfun)
1053{
1054 _GLFWwindow* window = (_GLFWwindow*) handle;
1055 assert(window != NULL);
1056
1057 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1058 _GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun);
1059 return cbfun;
1060}
1061
1062GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
1063 GLFWwindowclosefun cbfun)
1064{
1065 _GLFWwindow* window = (_GLFWwindow*) handle;
1066 assert(window != NULL);
1067
1068 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1069 _GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun);
1070 return cbfun;
1071}
1072
1073GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
1074 GLFWwindowrefreshfun cbfun)
1075{
1076 _GLFWwindow* window = (_GLFWwindow*) handle;
1077 assert(window != NULL);
1078
1079 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1080 _GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun);
1081 return cbfun;
1082}
1083
1084GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
1085 GLFWwindowfocusfun cbfun)
1086{
1087 _GLFWwindow* window = (_GLFWwindow*) handle;
1088 assert(window != NULL);
1089
1090 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1091 _GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun);
1092 return cbfun;
1093}
1094
1095GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
1096 GLFWwindowiconifyfun cbfun)
1097{
1098 _GLFWwindow* window = (_GLFWwindow*) handle;
1099 assert(window != NULL);
1100
1101 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1102 _GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun);
1103 return cbfun;
1104}
1105
1106GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
1107 GLFWwindowmaximizefun cbfun)
1108{
1109 _GLFWwindow* window = (_GLFWwindow*) handle;
1110 assert(window != NULL);
1111
1112 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1113 _GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun);
1114 return cbfun;
1115}
1116
1117GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
1118 GLFWframebuffersizefun cbfun)
1119{
1120 _GLFWwindow* window = (_GLFWwindow*) handle;
1121 assert(window != NULL);
1122
1123 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1124 _GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun);
1125 return cbfun;
1126}
1127
1128GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle,
1129 GLFWwindowcontentscalefun cbfun)
1130{
1131 _GLFWwindow* window = (_GLFWwindow*) handle;
1132 assert(window != NULL);
1133
1134 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
1135 _GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun);
1136 return cbfun;
1137}
1138
1139GLFWAPI void glfwPollEvents(void)
1140{
1141 _GLFW_REQUIRE_INIT();
1142 _glfw.platform.pollEvents();
1143}
1144
1145GLFWAPI void glfwWaitEvents(void)
1146{
1147 _GLFW_REQUIRE_INIT();
1148 _glfw.platform.waitEvents();
1149}
1150
1151GLFWAPI void glfwWaitEventsTimeout(double timeout)
1152{
1153 _GLFW_REQUIRE_INIT();
1154 assert(timeout == timeout);
1155 assert(timeout >= 0.0);
1156 assert(timeout <= DBL_MAX);
1157
1158 if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX)
1159 {
1160 _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", timeout);
1161 return;
1162 }
1163
1164 _glfw.platform.waitEventsTimeout(timeout);
1165}
1166
1167GLFWAPI void glfwPostEmptyEvent(void)
1168{
1169 _GLFW_REQUIRE_INIT();
1170 _glfw.platform.postEmptyEvent();
1171}
1172
diff --git a/raylib/src/external/glfw/src/wl_init.c b/raylib/src/external/glfw/src/wl_init.c
new file mode 100644
index 0000000..2428c72
--- /dev/null
+++ b/raylib/src/external/glfw/src/wl_init.c
@@ -0,0 +1,1004 @@
1//========================================================================
2// GLFW 3.4 Wayland (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
5// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_WAYLAND)
31
32#include <errno.h>
33#include <limits.h>
34#include <linux/input.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include <sys/mman.h>
39#include <sys/timerfd.h>
40#include <unistd.h>
41#include <time.h>
42#include <assert.h>
43
44#include "wayland-client-protocol.h"
45#include "xdg-shell-client-protocol.h"
46#include "xdg-decoration-unstable-v1-client-protocol.h"
47#include "viewporter-client-protocol.h"
48#include "relative-pointer-unstable-v1-client-protocol.h"
49#include "pointer-constraints-unstable-v1-client-protocol.h"
50#include "fractional-scale-v1-client-protocol.h"
51#include "xdg-activation-v1-client-protocol.h"
52#include "idle-inhibit-unstable-v1-client-protocol.h"
53
54// NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of
55// wl_interface pointers 'types', making it impossible to combine several unmodified
56// private-code files into a single compilation unit
57// HACK: We override this name with a macro for each file, allowing them to coexist
58
59#define types _glfw_wayland_types
60#include "wayland-client-protocol-code.h"
61#undef types
62
63#define types _glfw_xdg_shell_types
64#include "xdg-shell-client-protocol-code.h"
65#undef types
66
67#define types _glfw_xdg_decoration_types
68#include "xdg-decoration-unstable-v1-client-protocol-code.h"
69#undef types
70
71#define types _glfw_viewporter_types
72#include "viewporter-client-protocol-code.h"
73#undef types
74
75#define types _glfw_relative_pointer_types
76#include "relative-pointer-unstable-v1-client-protocol-code.h"
77#undef types
78
79#define types _glfw_pointer_constraints_types
80#include "pointer-constraints-unstable-v1-client-protocol-code.h"
81#undef types
82
83#define types _glfw_fractional_scale_types
84#include "fractional-scale-v1-client-protocol-code.h"
85#undef types
86
87#define types _glfw_xdg_activation_types
88#include "xdg-activation-v1-client-protocol-code.h"
89#undef types
90
91#define types _glfw_idle_inhibit_types
92#include "idle-inhibit-unstable-v1-client-protocol-code.h"
93#undef types
94
95static void wmBaseHandlePing(void* userData,
96 struct xdg_wm_base* wmBase,
97 uint32_t serial)
98{
99 xdg_wm_base_pong(wmBase, serial);
100}
101
102static const struct xdg_wm_base_listener wmBaseListener =
103{
104 wmBaseHandlePing
105};
106
107static void registryHandleGlobal(void* userData,
108 struct wl_registry* registry,
109 uint32_t name,
110 const char* interface,
111 uint32_t version)
112{
113 if (strcmp(interface, "wl_compositor") == 0)
114 {
115 _glfw.wl.compositor =
116 wl_registry_bind(registry, name, &wl_compositor_interface,
117 _glfw_min(3, version));
118 }
119 else if (strcmp(interface, "wl_subcompositor") == 0)
120 {
121 _glfw.wl.subcompositor =
122 wl_registry_bind(registry, name, &wl_subcompositor_interface, 1);
123 }
124 else if (strcmp(interface, "wl_shm") == 0)
125 {
126 _glfw.wl.shm =
127 wl_registry_bind(registry, name, &wl_shm_interface, 1);
128 }
129 else if (strcmp(interface, "wl_output") == 0)
130 {
131 _glfwAddOutputWayland(name, version);
132 }
133 else if (strcmp(interface, "wl_seat") == 0)
134 {
135 if (!_glfw.wl.seat)
136 {
137 _glfw.wl.seat =
138 wl_registry_bind(registry, name, &wl_seat_interface,
139 _glfw_min(4, version));
140 _glfwAddSeatListenerWayland(_glfw.wl.seat);
141 }
142 }
143 else if (strcmp(interface, "wl_data_device_manager") == 0)
144 {
145 if (!_glfw.wl.dataDeviceManager)
146 {
147 _glfw.wl.dataDeviceManager =
148 wl_registry_bind(registry, name,
149 &wl_data_device_manager_interface, 1);
150 }
151 }
152 else if (strcmp(interface, "xdg_wm_base") == 0)
153 {
154 _glfw.wl.wmBase =
155 wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
156 xdg_wm_base_add_listener(_glfw.wl.wmBase, &wmBaseListener, NULL);
157 }
158 else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0)
159 {
160 _glfw.wl.decorationManager =
161 wl_registry_bind(registry, name,
162 &zxdg_decoration_manager_v1_interface,
163 1);
164 }
165 else if (strcmp(interface, "wp_viewporter") == 0)
166 {
167 _glfw.wl.viewporter =
168 wl_registry_bind(registry, name, &wp_viewporter_interface, 1);
169 }
170 else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0)
171 {
172 _glfw.wl.relativePointerManager =
173 wl_registry_bind(registry, name,
174 &zwp_relative_pointer_manager_v1_interface,
175 1);
176 }
177 else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0)
178 {
179 _glfw.wl.pointerConstraints =
180 wl_registry_bind(registry, name,
181 &zwp_pointer_constraints_v1_interface,
182 1);
183 }
184 else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
185 {
186 _glfw.wl.idleInhibitManager =
187 wl_registry_bind(registry, name,
188 &zwp_idle_inhibit_manager_v1_interface,
189 1);
190 }
191 else if (strcmp(interface, "xdg_activation_v1") == 0)
192 {
193 _glfw.wl.activationManager =
194 wl_registry_bind(registry, name,
195 &xdg_activation_v1_interface,
196 1);
197 }
198 else if (strcmp(interface, "wp_fractional_scale_manager_v1") == 0)
199 {
200 _glfw.wl.fractionalScaleManager =
201 wl_registry_bind(registry, name,
202 &wp_fractional_scale_manager_v1_interface,
203 1);
204 }
205}
206
207static void registryHandleGlobalRemove(void* userData,
208 struct wl_registry* registry,
209 uint32_t name)
210{
211 for (int i = 0; i < _glfw.monitorCount; ++i)
212 {
213 _GLFWmonitor* monitor = _glfw.monitors[i];
214 if (monitor->wl.name == name)
215 {
216 _glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0);
217 return;
218 }
219 }
220}
221
222
223static const struct wl_registry_listener registryListener =
224{
225 registryHandleGlobal,
226 registryHandleGlobalRemove
227};
228
229void libdecorHandleError(struct libdecor* context,
230 enum libdecor_error error,
231 const char* message)
232{
233 _glfwInputError(GLFW_PLATFORM_ERROR,
234 "Wayland: libdecor error %u: %s",
235 error, message);
236}
237
238static const struct libdecor_interface libdecorInterface =
239{
240 libdecorHandleError
241};
242
243static void libdecorReadyCallback(void* userData,
244 struct wl_callback* callback,
245 uint32_t time)
246{
247 _glfw.wl.libdecor.ready = GLFW_TRUE;
248
249 assert(_glfw.wl.libdecor.callback == callback);
250 wl_callback_destroy(_glfw.wl.libdecor.callback);
251 _glfw.wl.libdecor.callback = NULL;
252}
253
254static const struct wl_callback_listener libdecorReadyListener =
255{
256 libdecorReadyCallback
257};
258
259// Create key code translation tables
260//
261static void createKeyTablesWayland(void)
262{
263 memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
264 memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
265
266 _glfw.wl.keycodes[KEY_GRAVE] = GLFW_KEY_GRAVE_ACCENT;
267 _glfw.wl.keycodes[KEY_1] = GLFW_KEY_1;
268 _glfw.wl.keycodes[KEY_2] = GLFW_KEY_2;
269 _glfw.wl.keycodes[KEY_3] = GLFW_KEY_3;
270 _glfw.wl.keycodes[KEY_4] = GLFW_KEY_4;
271 _glfw.wl.keycodes[KEY_5] = GLFW_KEY_5;
272 _glfw.wl.keycodes[KEY_6] = GLFW_KEY_6;
273 _glfw.wl.keycodes[KEY_7] = GLFW_KEY_7;
274 _glfw.wl.keycodes[KEY_8] = GLFW_KEY_8;
275 _glfw.wl.keycodes[KEY_9] = GLFW_KEY_9;
276 _glfw.wl.keycodes[KEY_0] = GLFW_KEY_0;
277 _glfw.wl.keycodes[KEY_SPACE] = GLFW_KEY_SPACE;
278 _glfw.wl.keycodes[KEY_MINUS] = GLFW_KEY_MINUS;
279 _glfw.wl.keycodes[KEY_EQUAL] = GLFW_KEY_EQUAL;
280 _glfw.wl.keycodes[KEY_Q] = GLFW_KEY_Q;
281 _glfw.wl.keycodes[KEY_W] = GLFW_KEY_W;
282 _glfw.wl.keycodes[KEY_E] = GLFW_KEY_E;
283 _glfw.wl.keycodes[KEY_R] = GLFW_KEY_R;
284 _glfw.wl.keycodes[KEY_T] = GLFW_KEY_T;
285 _glfw.wl.keycodes[KEY_Y] = GLFW_KEY_Y;
286 _glfw.wl.keycodes[KEY_U] = GLFW_KEY_U;
287 _glfw.wl.keycodes[KEY_I] = GLFW_KEY_I;
288 _glfw.wl.keycodes[KEY_O] = GLFW_KEY_O;
289 _glfw.wl.keycodes[KEY_P] = GLFW_KEY_P;
290 _glfw.wl.keycodes[KEY_LEFTBRACE] = GLFW_KEY_LEFT_BRACKET;
291 _glfw.wl.keycodes[KEY_RIGHTBRACE] = GLFW_KEY_RIGHT_BRACKET;
292 _glfw.wl.keycodes[KEY_A] = GLFW_KEY_A;
293 _glfw.wl.keycodes[KEY_S] = GLFW_KEY_S;
294 _glfw.wl.keycodes[KEY_D] = GLFW_KEY_D;
295 _glfw.wl.keycodes[KEY_F] = GLFW_KEY_F;
296 _glfw.wl.keycodes[KEY_G] = GLFW_KEY_G;
297 _glfw.wl.keycodes[KEY_H] = GLFW_KEY_H;
298 _glfw.wl.keycodes[KEY_J] = GLFW_KEY_J;
299 _glfw.wl.keycodes[KEY_K] = GLFW_KEY_K;
300 _glfw.wl.keycodes[KEY_L] = GLFW_KEY_L;
301 _glfw.wl.keycodes[KEY_SEMICOLON] = GLFW_KEY_SEMICOLON;
302 _glfw.wl.keycodes[KEY_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
303 _glfw.wl.keycodes[KEY_Z] = GLFW_KEY_Z;
304 _glfw.wl.keycodes[KEY_X] = GLFW_KEY_X;
305 _glfw.wl.keycodes[KEY_C] = GLFW_KEY_C;
306 _glfw.wl.keycodes[KEY_V] = GLFW_KEY_V;
307 _glfw.wl.keycodes[KEY_B] = GLFW_KEY_B;
308 _glfw.wl.keycodes[KEY_N] = GLFW_KEY_N;
309 _glfw.wl.keycodes[KEY_M] = GLFW_KEY_M;
310 _glfw.wl.keycodes[KEY_COMMA] = GLFW_KEY_COMMA;
311 _glfw.wl.keycodes[KEY_DOT] = GLFW_KEY_PERIOD;
312 _glfw.wl.keycodes[KEY_SLASH] = GLFW_KEY_SLASH;
313 _glfw.wl.keycodes[KEY_BACKSLASH] = GLFW_KEY_BACKSLASH;
314 _glfw.wl.keycodes[KEY_ESC] = GLFW_KEY_ESCAPE;
315 _glfw.wl.keycodes[KEY_TAB] = GLFW_KEY_TAB;
316 _glfw.wl.keycodes[KEY_LEFTSHIFT] = GLFW_KEY_LEFT_SHIFT;
317 _glfw.wl.keycodes[KEY_RIGHTSHIFT] = GLFW_KEY_RIGHT_SHIFT;
318 _glfw.wl.keycodes[KEY_LEFTCTRL] = GLFW_KEY_LEFT_CONTROL;
319 _glfw.wl.keycodes[KEY_RIGHTCTRL] = GLFW_KEY_RIGHT_CONTROL;
320 _glfw.wl.keycodes[KEY_LEFTALT] = GLFW_KEY_LEFT_ALT;
321 _glfw.wl.keycodes[KEY_RIGHTALT] = GLFW_KEY_RIGHT_ALT;
322 _glfw.wl.keycodes[KEY_LEFTMETA] = GLFW_KEY_LEFT_SUPER;
323 _glfw.wl.keycodes[KEY_RIGHTMETA] = GLFW_KEY_RIGHT_SUPER;
324 _glfw.wl.keycodes[KEY_COMPOSE] = GLFW_KEY_MENU;
325 _glfw.wl.keycodes[KEY_NUMLOCK] = GLFW_KEY_NUM_LOCK;
326 _glfw.wl.keycodes[KEY_CAPSLOCK] = GLFW_KEY_CAPS_LOCK;
327 _glfw.wl.keycodes[KEY_PRINT] = GLFW_KEY_PRINT_SCREEN;
328 _glfw.wl.keycodes[KEY_SCROLLLOCK] = GLFW_KEY_SCROLL_LOCK;
329 _glfw.wl.keycodes[KEY_PAUSE] = GLFW_KEY_PAUSE;
330 _glfw.wl.keycodes[KEY_DELETE] = GLFW_KEY_DELETE;
331 _glfw.wl.keycodes[KEY_BACKSPACE] = GLFW_KEY_BACKSPACE;
332 _glfw.wl.keycodes[KEY_ENTER] = GLFW_KEY_ENTER;
333 _glfw.wl.keycodes[KEY_HOME] = GLFW_KEY_HOME;
334 _glfw.wl.keycodes[KEY_END] = GLFW_KEY_END;
335 _glfw.wl.keycodes[KEY_PAGEUP] = GLFW_KEY_PAGE_UP;
336 _glfw.wl.keycodes[KEY_PAGEDOWN] = GLFW_KEY_PAGE_DOWN;
337 _glfw.wl.keycodes[KEY_INSERT] = GLFW_KEY_INSERT;
338 _glfw.wl.keycodes[KEY_LEFT] = GLFW_KEY_LEFT;
339 _glfw.wl.keycodes[KEY_RIGHT] = GLFW_KEY_RIGHT;
340 _glfw.wl.keycodes[KEY_DOWN] = GLFW_KEY_DOWN;
341 _glfw.wl.keycodes[KEY_UP] = GLFW_KEY_UP;
342 _glfw.wl.keycodes[KEY_F1] = GLFW_KEY_F1;
343 _glfw.wl.keycodes[KEY_F2] = GLFW_KEY_F2;
344 _glfw.wl.keycodes[KEY_F3] = GLFW_KEY_F3;
345 _glfw.wl.keycodes[KEY_F4] = GLFW_KEY_F4;
346 _glfw.wl.keycodes[KEY_F5] = GLFW_KEY_F5;
347 _glfw.wl.keycodes[KEY_F6] = GLFW_KEY_F6;
348 _glfw.wl.keycodes[KEY_F7] = GLFW_KEY_F7;
349 _glfw.wl.keycodes[KEY_F8] = GLFW_KEY_F8;
350 _glfw.wl.keycodes[KEY_F9] = GLFW_KEY_F9;
351 _glfw.wl.keycodes[KEY_F10] = GLFW_KEY_F10;
352 _glfw.wl.keycodes[KEY_F11] = GLFW_KEY_F11;
353 _glfw.wl.keycodes[KEY_F12] = GLFW_KEY_F12;
354 _glfw.wl.keycodes[KEY_F13] = GLFW_KEY_F13;
355 _glfw.wl.keycodes[KEY_F14] = GLFW_KEY_F14;
356 _glfw.wl.keycodes[KEY_F15] = GLFW_KEY_F15;
357 _glfw.wl.keycodes[KEY_F16] = GLFW_KEY_F16;
358 _glfw.wl.keycodes[KEY_F17] = GLFW_KEY_F17;
359 _glfw.wl.keycodes[KEY_F18] = GLFW_KEY_F18;
360 _glfw.wl.keycodes[KEY_F19] = GLFW_KEY_F19;
361 _glfw.wl.keycodes[KEY_F20] = GLFW_KEY_F20;
362 _glfw.wl.keycodes[KEY_F21] = GLFW_KEY_F21;
363 _glfw.wl.keycodes[KEY_F22] = GLFW_KEY_F22;
364 _glfw.wl.keycodes[KEY_F23] = GLFW_KEY_F23;
365 _glfw.wl.keycodes[KEY_F24] = GLFW_KEY_F24;
366 _glfw.wl.keycodes[KEY_KPSLASH] = GLFW_KEY_KP_DIVIDE;
367 _glfw.wl.keycodes[KEY_KPASTERISK] = GLFW_KEY_KP_MULTIPLY;
368 _glfw.wl.keycodes[KEY_KPMINUS] = GLFW_KEY_KP_SUBTRACT;
369 _glfw.wl.keycodes[KEY_KPPLUS] = GLFW_KEY_KP_ADD;
370 _glfw.wl.keycodes[KEY_KP0] = GLFW_KEY_KP_0;
371 _glfw.wl.keycodes[KEY_KP1] = GLFW_KEY_KP_1;
372 _glfw.wl.keycodes[KEY_KP2] = GLFW_KEY_KP_2;
373 _glfw.wl.keycodes[KEY_KP3] = GLFW_KEY_KP_3;
374 _glfw.wl.keycodes[KEY_KP4] = GLFW_KEY_KP_4;
375 _glfw.wl.keycodes[KEY_KP5] = GLFW_KEY_KP_5;
376 _glfw.wl.keycodes[KEY_KP6] = GLFW_KEY_KP_6;
377 _glfw.wl.keycodes[KEY_KP7] = GLFW_KEY_KP_7;
378 _glfw.wl.keycodes[KEY_KP8] = GLFW_KEY_KP_8;
379 _glfw.wl.keycodes[KEY_KP9] = GLFW_KEY_KP_9;
380 _glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_DECIMAL;
381 _glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL;
382 _glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER;
383 _glfw.wl.keycodes[KEY_102ND] = GLFW_KEY_WORLD_2;
384
385 for (int scancode = 0; scancode < 256; scancode++)
386 {
387 if (_glfw.wl.keycodes[scancode] > 0)
388 _glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
389 }
390}
391
392static GLFWbool loadCursorTheme(void)
393{
394 int cursorSize = 16;
395
396 const char* sizeString = getenv("XCURSOR_SIZE");
397 if (sizeString)
398 {
399 errno = 0;
400 const long cursorSizeLong = strtol(sizeString, NULL, 10);
401 if (errno == 0 && cursorSizeLong > 0 && cursorSizeLong < INT_MAX)
402 cursorSize = (int) cursorSizeLong;
403 }
404
405 const char* themeName = getenv("XCURSOR_THEME");
406
407 _glfw.wl.cursorTheme = wl_cursor_theme_load(themeName, cursorSize, _glfw.wl.shm);
408 if (!_glfw.wl.cursorTheme)
409 {
410 _glfwInputError(GLFW_PLATFORM_ERROR,
411 "Wayland: Failed to load default cursor theme");
412 return GLFW_FALSE;
413 }
414
415 // If this happens to be NULL, we just fallback to the scale=1 version.
416 _glfw.wl.cursorThemeHiDPI =
417 wl_cursor_theme_load(themeName, cursorSize * 2, _glfw.wl.shm);
418
419 _glfw.wl.cursorSurface = wl_compositor_create_surface(_glfw.wl.compositor);
420 _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
421 return GLFW_TRUE;
422}
423
424
425//////////////////////////////////////////////////////////////////////////
426////// GLFW platform API //////
427//////////////////////////////////////////////////////////////////////////
428
429GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
430{
431 const _GLFWplatform wayland =
432 {
433 .platformID = GLFW_PLATFORM_WAYLAND,
434 .init = _glfwInitWayland,
435 .terminate = _glfwTerminateWayland,
436 .getCursorPos = _glfwGetCursorPosWayland,
437 .setCursorPos = _glfwSetCursorPosWayland,
438 .setCursorMode = _glfwSetCursorModeWayland,
439 .setRawMouseMotion = _glfwSetRawMouseMotionWayland,
440 .rawMouseMotionSupported = _glfwRawMouseMotionSupportedWayland,
441 .createCursor = _glfwCreateCursorWayland,
442 .createStandardCursor = _glfwCreateStandardCursorWayland,
443 .destroyCursor = _glfwDestroyCursorWayland,
444 .setCursor = _glfwSetCursorWayland,
445 .getScancodeName = _glfwGetScancodeNameWayland,
446 .getKeyScancode = _glfwGetKeyScancodeWayland,
447 .setClipboardString = _glfwSetClipboardStringWayland,
448 .getClipboardString = _glfwGetClipboardStringWayland,
449#if defined(GLFW_BUILD_LINUX_JOYSTICK)
450 .initJoysticks = _glfwInitJoysticksLinux,
451 .terminateJoysticks = _glfwTerminateJoysticksLinux,
452 .pollJoystick = _glfwPollJoystickLinux,
453 .getMappingName = _glfwGetMappingNameLinux,
454 .updateGamepadGUID = _glfwUpdateGamepadGUIDLinux,
455#else
456 .initJoysticks = _glfwInitJoysticksNull,
457 .terminateJoysticks = _glfwTerminateJoysticksNull,
458 .pollJoystick = _glfwPollJoystickNull,
459 .getMappingName = _glfwGetMappingNameNull,
460 .updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
461#endif
462 .freeMonitor = _glfwFreeMonitorWayland,
463 .getMonitorPos = _glfwGetMonitorPosWayland,
464 .getMonitorContentScale = _glfwGetMonitorContentScaleWayland,
465 .getMonitorWorkarea = _glfwGetMonitorWorkareaWayland,
466 .getVideoModes = _glfwGetVideoModesWayland,
467 .getVideoMode = _glfwGetVideoModeWayland,
468 .getGammaRamp = _glfwGetGammaRampWayland,
469 .setGammaRamp = _glfwSetGammaRampWayland,
470 .createWindow = _glfwCreateWindowWayland,
471 .destroyWindow = _glfwDestroyWindowWayland,
472 .setWindowTitle = _glfwSetWindowTitleWayland,
473 .setWindowIcon = _glfwSetWindowIconWayland,
474 .getWindowPos = _glfwGetWindowPosWayland,
475 .setWindowPos = _glfwSetWindowPosWayland,
476 .getWindowSize = _glfwGetWindowSizeWayland,
477 .setWindowSize = _glfwSetWindowSizeWayland,
478 .setWindowSizeLimits = _glfwSetWindowSizeLimitsWayland,
479 .setWindowAspectRatio = _glfwSetWindowAspectRatioWayland,
480 .getFramebufferSize = _glfwGetFramebufferSizeWayland,
481 .getWindowFrameSize = _glfwGetWindowFrameSizeWayland,
482 .getWindowContentScale = _glfwGetWindowContentScaleWayland,
483 .iconifyWindow = _glfwIconifyWindowWayland,
484 .restoreWindow = _glfwRestoreWindowWayland,
485 .maximizeWindow = _glfwMaximizeWindowWayland,
486 .showWindow = _glfwShowWindowWayland,
487 .hideWindow = _glfwHideWindowWayland,
488 .requestWindowAttention = _glfwRequestWindowAttentionWayland,
489 .focusWindow = _glfwFocusWindowWayland,
490 .setWindowMonitor = _glfwSetWindowMonitorWayland,
491 .windowFocused = _glfwWindowFocusedWayland,
492 .windowIconified = _glfwWindowIconifiedWayland,
493 .windowVisible = _glfwWindowVisibleWayland,
494 .windowMaximized = _glfwWindowMaximizedWayland,
495 .windowHovered = _glfwWindowHoveredWayland,
496 .framebufferTransparent = _glfwFramebufferTransparentWayland,
497 .getWindowOpacity = _glfwGetWindowOpacityWayland,
498 .setWindowResizable = _glfwSetWindowResizableWayland,
499 .setWindowDecorated = _glfwSetWindowDecoratedWayland,
500 .setWindowFloating = _glfwSetWindowFloatingWayland,
501 .setWindowOpacity = _glfwSetWindowOpacityWayland,
502 .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWayland,
503 .pollEvents = _glfwPollEventsWayland,
504 .waitEvents = _glfwWaitEventsWayland,
505 .waitEventsTimeout = _glfwWaitEventsTimeoutWayland,
506 .postEmptyEvent = _glfwPostEmptyEventWayland,
507 .getEGLPlatform = _glfwGetEGLPlatformWayland,
508 .getEGLNativeDisplay = _glfwGetEGLNativeDisplayWayland,
509 .getEGLNativeWindow = _glfwGetEGLNativeWindowWayland,
510 .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWayland,
511 .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWayland,
512 .createWindowSurface = _glfwCreateWindowSurfaceWayland
513 };
514
515 void* module = _glfwPlatformLoadModule("libwayland-client.so.0");
516 if (!module)
517 {
518 if (platformID == GLFW_PLATFORM_WAYLAND)
519 {
520 _glfwInputError(GLFW_PLATFORM_ERROR,
521 "Wayland: Failed to load libwayland-client");
522 }
523
524 return GLFW_FALSE;
525 }
526
527 PFN_wl_display_connect wl_display_connect = (PFN_wl_display_connect)
528 _glfwPlatformGetModuleSymbol(module, "wl_display_connect");
529 if (!wl_display_connect)
530 {
531 if (platformID == GLFW_PLATFORM_WAYLAND)
532 {
533 _glfwInputError(GLFW_PLATFORM_ERROR,
534 "Wayland: Failed to load libwayland-client entry point");
535 }
536
537 _glfwPlatformFreeModule(module);
538 return GLFW_FALSE;
539 }
540
541 struct wl_display* display = wl_display_connect(NULL);
542 if (!display)
543 {
544 if (platformID == GLFW_PLATFORM_WAYLAND)
545 _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to connect to display");
546
547 _glfwPlatformFreeModule(module);
548 return GLFW_FALSE;
549 }
550
551 _glfw.wl.display = display;
552 _glfw.wl.client.handle = module;
553
554 *platform = wayland;
555 return GLFW_TRUE;
556}
557
558int _glfwInitWayland(void)
559{
560 // These must be set before any failure checks
561 _glfw.wl.keyRepeatTimerfd = -1;
562 _glfw.wl.cursorTimerfd = -1;
563
564 _glfw.wl.tag = glfwGetVersionString();
565
566 _glfw.wl.client.display_flush = (PFN_wl_display_flush)
567 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush");
568 _glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read)
569 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_cancel_read");
570 _glfw.wl.client.display_dispatch_pending = (PFN_wl_display_dispatch_pending)
571 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_dispatch_pending");
572 _glfw.wl.client.display_read_events = (PFN_wl_display_read_events)
573 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_read_events");
574 _glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect)
575 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_disconnect");
576 _glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip)
577 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_roundtrip");
578 _glfw.wl.client.display_get_fd = (PFN_wl_display_get_fd)
579 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_get_fd");
580 _glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read)
581 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_prepare_read");
582 _glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal)
583 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal");
584 _glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener)
585 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_add_listener");
586 _glfw.wl.client.proxy_destroy = (PFN_wl_proxy_destroy)
587 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_destroy");
588 _glfw.wl.client.proxy_marshal_constructor = (PFN_wl_proxy_marshal_constructor)
589 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor");
590 _glfw.wl.client.proxy_marshal_constructor_versioned = (PFN_wl_proxy_marshal_constructor_versioned)
591 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned");
592 _glfw.wl.client.proxy_get_user_data = (PFN_wl_proxy_get_user_data)
593 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_user_data");
594 _glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data)
595 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_user_data");
596 _glfw.wl.client.proxy_get_tag = (PFN_wl_proxy_get_tag)
597 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_tag");
598 _glfw.wl.client.proxy_set_tag = (PFN_wl_proxy_set_tag)
599 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_tag");
600 _glfw.wl.client.proxy_get_version = (PFN_wl_proxy_get_version)
601 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_version");
602 _glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags)
603 _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_flags");
604
605 if (!_glfw.wl.client.display_flush ||
606 !_glfw.wl.client.display_cancel_read ||
607 !_glfw.wl.client.display_dispatch_pending ||
608 !_glfw.wl.client.display_read_events ||
609 !_glfw.wl.client.display_disconnect ||
610 !_glfw.wl.client.display_roundtrip ||
611 !_glfw.wl.client.display_get_fd ||
612 !_glfw.wl.client.display_prepare_read ||
613 !_glfw.wl.client.proxy_marshal ||
614 !_glfw.wl.client.proxy_add_listener ||
615 !_glfw.wl.client.proxy_destroy ||
616 !_glfw.wl.client.proxy_marshal_constructor ||
617 !_glfw.wl.client.proxy_marshal_constructor_versioned ||
618 !_glfw.wl.client.proxy_get_user_data ||
619 !_glfw.wl.client.proxy_set_user_data ||
620 !_glfw.wl.client.proxy_get_tag ||
621 !_glfw.wl.client.proxy_set_tag)
622 {
623 _glfwInputError(GLFW_PLATFORM_ERROR,
624 "Wayland: Failed to load libwayland-client entry point");
625 return GLFW_FALSE;
626 }
627
628 _glfw.wl.cursor.handle = _glfwPlatformLoadModule("libwayland-cursor.so.0");
629 if (!_glfw.wl.cursor.handle)
630 {
631 _glfwInputError(GLFW_PLATFORM_ERROR,
632 "Wayland: Failed to load libwayland-cursor");
633 return GLFW_FALSE;
634 }
635
636 _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load)
637 _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
638 _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy)
639 _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
640 _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor)
641 _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
642 _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer)
643 _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
644
645 _glfw.wl.egl.handle = _glfwPlatformLoadModule("libwayland-egl.so.1");
646 if (!_glfw.wl.egl.handle)
647 {
648 _glfwInputError(GLFW_PLATFORM_ERROR,
649 "Wayland: Failed to load libwayland-egl");
650 return GLFW_FALSE;
651 }
652
653 _glfw.wl.egl.window_create = (PFN_wl_egl_window_create)
654 _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_create");
655 _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy)
656 _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_destroy");
657 _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize)
658 _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_resize");
659
660 _glfw.wl.xkb.handle = _glfwPlatformLoadModule("libxkbcommon.so.0");
661 if (!_glfw.wl.xkb.handle)
662 {
663 _glfwInputError(GLFW_PLATFORM_ERROR,
664 "Wayland: Failed to load libxkbcommon");
665 return GLFW_FALSE;
666 }
667
668 _glfw.wl.xkb.context_new = (PFN_xkb_context_new)
669 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_new");
670 _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref)
671 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_unref");
672 _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string)
673 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
674 _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref)
675 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_unref");
676 _glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index)
677 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
678 _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats)
679 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
680 _glfw.wl.xkb.keymap_key_get_syms_by_level = (PFN_xkb_keymap_key_get_syms_by_level)
681 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_get_syms_by_level");
682 _glfw.wl.xkb.state_new = (PFN_xkb_state_new)
683 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_new");
684 _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref)
685 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_unref");
686 _glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms)
687 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
688 _glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
689 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_update_mask");
690 _glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout)
691 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_layout");
692 _glfw.wl.xkb.state_mod_index_is_active = (PFN_xkb_state_mod_index_is_active)
693 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_mod_index_is_active");
694 _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
695 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
696 _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
697 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
698 _glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new)
699 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_new");
700 _glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref)
701 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
702 _glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed)
703 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
704 _glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status)
705 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
706 _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
707 _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
708
709 if (!_glfw.wl.xkb.context_new ||
710 !_glfw.wl.xkb.context_unref ||
711 !_glfw.wl.xkb.keymap_new_from_string ||
712 !_glfw.wl.xkb.keymap_unref ||
713 !_glfw.wl.xkb.keymap_mod_get_index ||
714 !_glfw.wl.xkb.keymap_key_repeats ||
715 !_glfw.wl.xkb.keymap_key_get_syms_by_level ||
716 !_glfw.wl.xkb.state_new ||
717 !_glfw.wl.xkb.state_unref ||
718 !_glfw.wl.xkb.state_key_get_syms ||
719 !_glfw.wl.xkb.state_update_mask ||
720 !_glfw.wl.xkb.state_key_get_layout ||
721 !_glfw.wl.xkb.state_mod_index_is_active ||
722 !_glfw.wl.xkb.compose_table_new_from_locale ||
723 !_glfw.wl.xkb.compose_table_unref ||
724 !_glfw.wl.xkb.compose_state_new ||
725 !_glfw.wl.xkb.compose_state_unref ||
726 !_glfw.wl.xkb.compose_state_feed ||
727 !_glfw.wl.xkb.compose_state_get_status ||
728 !_glfw.wl.xkb.compose_state_get_one_sym)
729 {
730 _glfwInputError(GLFW_PLATFORM_ERROR,
731 "Wayland: Failed to load all entry points from libxkbcommon");
732 return GLFW_FALSE;
733 }
734
735 if (_glfw.hints.init.wl.libdecorMode == GLFW_WAYLAND_PREFER_LIBDECOR)
736 _glfw.wl.libdecor.handle = _glfwPlatformLoadModule("libdecor-0.so.0");
737
738 if (_glfw.wl.libdecor.handle)
739 {
740 _glfw.wl.libdecor.libdecor_new_ = (PFN_libdecor_new)
741 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_new");
742 _glfw.wl.libdecor.libdecor_unref_ = (PFN_libdecor_unref)
743 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_unref");
744 _glfw.wl.libdecor.libdecor_get_fd_ = (PFN_libdecor_get_fd)
745 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_get_fd");
746 _glfw.wl.libdecor.libdecor_dispatch_ = (PFN_libdecor_dispatch)
747 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_dispatch");
748 _glfw.wl.libdecor.libdecor_decorate_ = (PFN_libdecor_decorate)
749 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_decorate");
750 _glfw.wl.libdecor.libdecor_frame_unref_ = (PFN_libdecor_frame_unref)
751 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unref");
752 _glfw.wl.libdecor.libdecor_frame_set_app_id_ = (PFN_libdecor_frame_set_app_id)
753 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_app_id");
754 _glfw.wl.libdecor.libdecor_frame_set_title_ = (PFN_libdecor_frame_set_title)
755 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_title");
756 _glfw.wl.libdecor.libdecor_frame_set_minimized_ = (PFN_libdecor_frame_set_minimized)
757 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_minimized");
758 _glfw.wl.libdecor.libdecor_frame_set_fullscreen_ = (PFN_libdecor_frame_set_fullscreen)
759 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_fullscreen");
760 _glfw.wl.libdecor.libdecor_frame_unset_fullscreen_ = (PFN_libdecor_frame_unset_fullscreen)
761 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unset_fullscreen");
762 _glfw.wl.libdecor.libdecor_frame_map_ = (PFN_libdecor_frame_map)
763 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_map");
764 _glfw.wl.libdecor.libdecor_frame_commit_ = (PFN_libdecor_frame_commit)
765 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_commit");
766 _glfw.wl.libdecor.libdecor_frame_set_min_content_size_ = (PFN_libdecor_frame_set_min_content_size)
767 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_min_content_size");
768 _glfw.wl.libdecor.libdecor_frame_set_max_content_size_ = (PFN_libdecor_frame_set_max_content_size)
769 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_max_content_size");
770 _glfw.wl.libdecor.libdecor_frame_set_maximized_ = (PFN_libdecor_frame_set_maximized)
771 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_maximized");
772 _glfw.wl.libdecor.libdecor_frame_unset_maximized_ = (PFN_libdecor_frame_unset_maximized)
773 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unset_maximized");
774 _glfw.wl.libdecor.libdecor_frame_set_capabilities_ = (PFN_libdecor_frame_set_capabilities)
775 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_capabilities");
776 _glfw.wl.libdecor.libdecor_frame_unset_capabilities_ = (PFN_libdecor_frame_unset_capabilities)
777 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unset_capabilities");
778 _glfw.wl.libdecor.libdecor_frame_set_visibility_ = (PFN_libdecor_frame_set_visibility)
779 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_visibility");
780 _glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ = (PFN_libdecor_frame_get_xdg_toplevel)
781 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_get_xdg_toplevel");
782 _glfw.wl.libdecor.libdecor_configuration_get_content_size_ = (PFN_libdecor_configuration_get_content_size)
783 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_configuration_get_content_size");
784 _glfw.wl.libdecor.libdecor_configuration_get_window_state_ = (PFN_libdecor_configuration_get_window_state)
785 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_configuration_get_window_state");
786 _glfw.wl.libdecor.libdecor_state_new_ = (PFN_libdecor_state_new)
787 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_state_new");
788 _glfw.wl.libdecor.libdecor_state_free_ = (PFN_libdecor_state_free)
789 _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_state_free");
790
791 if (!_glfw.wl.libdecor.libdecor_new_ ||
792 !_glfw.wl.libdecor.libdecor_unref_ ||
793 !_glfw.wl.libdecor.libdecor_get_fd_ ||
794 !_glfw.wl.libdecor.libdecor_dispatch_ ||
795 !_glfw.wl.libdecor.libdecor_decorate_ ||
796 !_glfw.wl.libdecor.libdecor_frame_unref_ ||
797 !_glfw.wl.libdecor.libdecor_frame_set_app_id_ ||
798 !_glfw.wl.libdecor.libdecor_frame_set_title_ ||
799 !_glfw.wl.libdecor.libdecor_frame_set_minimized_ ||
800 !_glfw.wl.libdecor.libdecor_frame_set_fullscreen_ ||
801 !_glfw.wl.libdecor.libdecor_frame_unset_fullscreen_ ||
802 !_glfw.wl.libdecor.libdecor_frame_map_ ||
803 !_glfw.wl.libdecor.libdecor_frame_commit_ ||
804 !_glfw.wl.libdecor.libdecor_frame_set_min_content_size_ ||
805 !_glfw.wl.libdecor.libdecor_frame_set_max_content_size_ ||
806 !_glfw.wl.libdecor.libdecor_frame_set_maximized_ ||
807 !_glfw.wl.libdecor.libdecor_frame_unset_maximized_ ||
808 !_glfw.wl.libdecor.libdecor_frame_set_capabilities_ ||
809 !_glfw.wl.libdecor.libdecor_frame_unset_capabilities_ ||
810 !_glfw.wl.libdecor.libdecor_frame_set_visibility_ ||
811 !_glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ ||
812 !_glfw.wl.libdecor.libdecor_configuration_get_content_size_ ||
813 !_glfw.wl.libdecor.libdecor_configuration_get_window_state_ ||
814 !_glfw.wl.libdecor.libdecor_state_new_ ||
815 !_glfw.wl.libdecor.libdecor_state_free_)
816 {
817 _glfwPlatformFreeModule(_glfw.wl.libdecor.handle);
818 memset(&_glfw.wl.libdecor, 0, sizeof(_glfw.wl.libdecor));
819 }
820 }
821
822 _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
823 wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);
824
825 createKeyTablesWayland();
826
827 _glfw.wl.xkb.context = xkb_context_new(0);
828 if (!_glfw.wl.xkb.context)
829 {
830 _glfwInputError(GLFW_PLATFORM_ERROR,
831 "Wayland: Failed to initialize xkb context");
832 return GLFW_FALSE;
833 }
834
835 // Sync so we got all registry objects
836 wl_display_roundtrip(_glfw.wl.display);
837
838 // Sync so we got all initial output events
839 wl_display_roundtrip(_glfw.wl.display);
840
841 if (_glfw.wl.libdecor.handle)
842 {
843 _glfw.wl.libdecor.context = libdecor_new(_glfw.wl.display, &libdecorInterface);
844 if (_glfw.wl.libdecor.context)
845 {
846 // Perform an initial dispatch and flush to get the init started
847 libdecor_dispatch(_glfw.wl.libdecor.context, 0);
848
849 // Create sync point to "know" when libdecor is ready for use
850 _glfw.wl.libdecor.callback = wl_display_sync(_glfw.wl.display);
851 wl_callback_add_listener(_glfw.wl.libdecor.callback,
852 &libdecorReadyListener,
853 NULL);
854 }
855 }
856
857 if (wl_seat_get_version(_glfw.wl.seat) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
858 {
859 _glfw.wl.keyRepeatTimerfd =
860 timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
861 }
862
863 if (!_glfw.wl.wmBase)
864 {
865 _glfwInputError(GLFW_PLATFORM_ERROR,
866 "Wayland: Failed to find xdg-shell in your compositor");
867 return GLFW_FALSE;
868 }
869
870 if (!_glfw.wl.shm)
871 {
872 _glfwInputError(GLFW_PLATFORM_ERROR,
873 "Wayland: Failed to find wl_shm in your compositor");
874 return GLFW_FALSE;
875 }
876
877 if (!loadCursorTheme())
878 return GLFW_FALSE;
879
880 if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
881 {
882 _glfw.wl.dataDevice =
883 wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
884 _glfw.wl.seat);
885 _glfwAddDataDeviceListenerWayland(_glfw.wl.dataDevice);
886 }
887
888 return GLFW_TRUE;
889}
890
891void _glfwTerminateWayland(void)
892{
893 _glfwTerminateEGL();
894 _glfwTerminateOSMesa();
895
896 if (_glfw.wl.libdecor.context)
897 {
898 // Allow libdecor to finish receiving all its requested globals
899 // and ensure the associated sync callback object is destroyed
900 while (!_glfw.wl.libdecor.ready)
901 _glfwWaitEventsWayland();
902
903 libdecor_unref(_glfw.wl.libdecor.context);
904 }
905
906 if (_glfw.wl.libdecor.handle)
907 {
908 _glfwPlatformFreeModule(_glfw.wl.libdecor.handle);
909 _glfw.wl.libdecor.handle = NULL;
910 }
911
912 if (_glfw.wl.egl.handle)
913 {
914 _glfwPlatformFreeModule(_glfw.wl.egl.handle);
915 _glfw.wl.egl.handle = NULL;
916 }
917
918 if (_glfw.wl.xkb.composeState)
919 xkb_compose_state_unref(_glfw.wl.xkb.composeState);
920 if (_glfw.wl.xkb.keymap)
921 xkb_keymap_unref(_glfw.wl.xkb.keymap);
922 if (_glfw.wl.xkb.state)
923 xkb_state_unref(_glfw.wl.xkb.state);
924 if (_glfw.wl.xkb.context)
925 xkb_context_unref(_glfw.wl.xkb.context);
926 if (_glfw.wl.xkb.handle)
927 {
928 _glfwPlatformFreeModule(_glfw.wl.xkb.handle);
929 _glfw.wl.xkb.handle = NULL;
930 }
931
932 if (_glfw.wl.cursorTheme)
933 wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
934 if (_glfw.wl.cursorThemeHiDPI)
935 wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI);
936 if (_glfw.wl.cursor.handle)
937 {
938 _glfwPlatformFreeModule(_glfw.wl.cursor.handle);
939 _glfw.wl.cursor.handle = NULL;
940 }
941
942 for (unsigned int i = 0; i < _glfw.wl.offerCount; i++)
943 wl_data_offer_destroy(_glfw.wl.offers[i].offer);
944
945 _glfw_free(_glfw.wl.offers);
946
947 if (_glfw.wl.cursorSurface)
948 wl_surface_destroy(_glfw.wl.cursorSurface);
949 if (_glfw.wl.subcompositor)
950 wl_subcompositor_destroy(_glfw.wl.subcompositor);
951 if (_glfw.wl.compositor)
952 wl_compositor_destroy(_glfw.wl.compositor);
953 if (_glfw.wl.shm)
954 wl_shm_destroy(_glfw.wl.shm);
955 if (_glfw.wl.viewporter)
956 wp_viewporter_destroy(_glfw.wl.viewporter);
957 if (_glfw.wl.decorationManager)
958 zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager);
959 if (_glfw.wl.wmBase)
960 xdg_wm_base_destroy(_glfw.wl.wmBase);
961 if (_glfw.wl.selectionOffer)
962 wl_data_offer_destroy(_glfw.wl.selectionOffer);
963 if (_glfw.wl.dragOffer)
964 wl_data_offer_destroy(_glfw.wl.dragOffer);
965 if (_glfw.wl.selectionSource)
966 wl_data_source_destroy(_glfw.wl.selectionSource);
967 if (_glfw.wl.dataDevice)
968 wl_data_device_destroy(_glfw.wl.dataDevice);
969 if (_glfw.wl.dataDeviceManager)
970 wl_data_device_manager_destroy(_glfw.wl.dataDeviceManager);
971 if (_glfw.wl.pointer)
972 wl_pointer_destroy(_glfw.wl.pointer);
973 if (_glfw.wl.keyboard)
974 wl_keyboard_destroy(_glfw.wl.keyboard);
975 if (_glfw.wl.seat)
976 wl_seat_destroy(_glfw.wl.seat);
977 if (_glfw.wl.relativePointerManager)
978 zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager);
979 if (_glfw.wl.pointerConstraints)
980 zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
981 if (_glfw.wl.idleInhibitManager)
982 zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
983 if (_glfw.wl.activationManager)
984 xdg_activation_v1_destroy(_glfw.wl.activationManager);
985 if (_glfw.wl.fractionalScaleManager)
986 wp_fractional_scale_manager_v1_destroy(_glfw.wl.fractionalScaleManager);
987 if (_glfw.wl.registry)
988 wl_registry_destroy(_glfw.wl.registry);
989 if (_glfw.wl.display)
990 {
991 wl_display_flush(_glfw.wl.display);
992 wl_display_disconnect(_glfw.wl.display);
993 }
994
995 if (_glfw.wl.keyRepeatTimerfd >= 0)
996 close(_glfw.wl.keyRepeatTimerfd);
997 if (_glfw.wl.cursorTimerfd >= 0)
998 close(_glfw.wl.cursorTimerfd);
999
1000 _glfw_free(_glfw.wl.clipboardString);
1001}
1002
1003#endif // _GLFW_WAYLAND
1004
diff --git a/raylib/src/external/glfw/src/wl_monitor.c b/raylib/src/external/glfw/src/wl_monitor.c
new file mode 100644
index 0000000..df30313
--- /dev/null
+++ b/raylib/src/external/glfw/src/wl_monitor.c
@@ -0,0 +1,274 @@
1//========================================================================
2// GLFW 3.4 Wayland - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include "internal.h"
28
29#if defined(_GLFW_WAYLAND)
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34#include <errno.h>
35#include <math.h>
36
37#include "wayland-client-protocol.h"
38
39
40static void outputHandleGeometry(void* userData,
41 struct wl_output* output,
42 int32_t x,
43 int32_t y,
44 int32_t physicalWidth,
45 int32_t physicalHeight,
46 int32_t subpixel,
47 const char* make,
48 const char* model,
49 int32_t transform)
50{
51 struct _GLFWmonitor* monitor = userData;
52
53 monitor->wl.x = x;
54 monitor->wl.y = y;
55 monitor->widthMM = physicalWidth;
56 monitor->heightMM = physicalHeight;
57
58 if (strlen(monitor->name) == 0)
59 snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
60}
61
62static void outputHandleMode(void* userData,
63 struct wl_output* output,
64 uint32_t flags,
65 int32_t width,
66 int32_t height,
67 int32_t refresh)
68{
69 struct _GLFWmonitor* monitor = userData;
70 GLFWvidmode mode;
71
72 mode.width = width;
73 mode.height = height;
74 mode.redBits = 8;
75 mode.greenBits = 8;
76 mode.blueBits = 8;
77 mode.refreshRate = (int) round(refresh / 1000.0);
78
79 monitor->modeCount++;
80 monitor->modes =
81 _glfw_realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
82 monitor->modes[monitor->modeCount - 1] = mode;
83
84 if (flags & WL_OUTPUT_MODE_CURRENT)
85 monitor->wl.currentMode = monitor->modeCount - 1;
86}
87
88static void outputHandleDone(void* userData, struct wl_output* output)
89{
90 struct _GLFWmonitor* monitor = userData;
91
92 if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
93 {
94 // If Wayland does not provide a physical size, assume the default 96 DPI
95 const GLFWvidmode* mode = &monitor->modes[monitor->wl.currentMode];
96 monitor->widthMM = (int) (mode->width * 25.4f / 96.f);
97 monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
98 }
99
100 for (int i = 0; i < _glfw.monitorCount; i++)
101 {
102 if (_glfw.monitors[i] == monitor)
103 return;
104 }
105
106 _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
107}
108
109static void outputHandleScale(void* userData,
110 struct wl_output* output,
111 int32_t factor)
112{
113 struct _GLFWmonitor* monitor = userData;
114
115 monitor->wl.scale = factor;
116
117 for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
118 {
119 for (size_t i = 0; i < window->wl.outputScaleCount; i++)
120 {
121 if (window->wl.outputScales[i].output == monitor->wl.output)
122 {
123 window->wl.outputScales[i].factor = monitor->wl.scale;
124 _glfwUpdateBufferScaleFromOutputsWayland(window);
125 break;
126 }
127 }
128 }
129}
130
131void outputHandleName(void* userData, struct wl_output* wl_output, const char* name)
132{
133 struct _GLFWmonitor* monitor = userData;
134
135 strncpy(monitor->name, name, sizeof(monitor->name) - 1);
136}
137
138void outputHandleDescription(void* userData,
139 struct wl_output* wl_output,
140 const char* description)
141{
142}
143
144static const struct wl_output_listener outputListener =
145{
146 outputHandleGeometry,
147 outputHandleMode,
148 outputHandleDone,
149 outputHandleScale,
150 outputHandleName,
151 outputHandleDescription,
152};
153
154
155//////////////////////////////////////////////////////////////////////////
156////// GLFW internal API //////
157//////////////////////////////////////////////////////////////////////////
158
159void _glfwAddOutputWayland(uint32_t name, uint32_t version)
160{
161 if (version < 2)
162 {
163 _glfwInputError(GLFW_PLATFORM_ERROR,
164 "Wayland: Unsupported output interface version");
165 return;
166 }
167
168 version = _glfw_min(version, WL_OUTPUT_NAME_SINCE_VERSION);
169
170 struct wl_output* output = wl_registry_bind(_glfw.wl.registry,
171 name,
172 &wl_output_interface,
173 version);
174 if (!output)
175 return;
176
177 // The actual name of this output will be set in the geometry handler
178 _GLFWmonitor* monitor = _glfwAllocMonitor("", 0, 0);
179 monitor->wl.scale = 1;
180 monitor->wl.output = output;
181 monitor->wl.name = name;
182
183 wl_proxy_set_tag((struct wl_proxy*) output, &_glfw.wl.tag);
184 wl_output_add_listener(output, &outputListener, monitor);
185}
186
187
188//////////////////////////////////////////////////////////////////////////
189////// GLFW platform API //////
190//////////////////////////////////////////////////////////////////////////
191
192void _glfwFreeMonitorWayland(_GLFWmonitor* monitor)
193{
194 if (monitor->wl.output)
195 wl_output_destroy(monitor->wl.output);
196}
197
198void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos)
199{
200 if (xpos)
201 *xpos = monitor->wl.x;
202 if (ypos)
203 *ypos = monitor->wl.y;
204}
205
206void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor,
207 float* xscale, float* yscale)
208{
209 if (xscale)
210 *xscale = (float) monitor->wl.scale;
211 if (yscale)
212 *yscale = (float) monitor->wl.scale;
213}
214
215void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor,
216 int* xpos, int* ypos,
217 int* width, int* height)
218{
219 if (xpos)
220 *xpos = monitor->wl.x;
221 if (ypos)
222 *ypos = monitor->wl.y;
223 if (width)
224 *width = monitor->modes[monitor->wl.currentMode].width;
225 if (height)
226 *height = monitor->modes[monitor->wl.currentMode].height;
227}
228
229GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found)
230{
231 *found = monitor->modeCount;
232 return monitor->modes;
233}
234
235GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode)
236{
237 *mode = monitor->modes[monitor->wl.currentMode];
238 return GLFW_TRUE;
239}
240
241GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
242{
243 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
244 "Wayland: Gamma ramp access is not available");
245 return GLFW_FALSE;
246}
247
248void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
249{
250 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
251 "Wayland: Gamma ramp access is not available");
252}
253
254
255//////////////////////////////////////////////////////////////////////////
256////// GLFW native API //////
257//////////////////////////////////////////////////////////////////////////
258
259GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
260{
261 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
262 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
263
264 if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
265 {
266 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Wayland: Platform not initialized");
267 return NULL;
268 }
269
270 return monitor->wl.output;
271}
272
273#endif // _GLFW_WAYLAND
274
diff --git a/raylib/src/external/glfw/src/wl_platform.h b/raylib/src/external/glfw/src/wl_platform.h
new file mode 100644
index 0000000..149cd24
--- /dev/null
+++ b/raylib/src/external/glfw/src/wl_platform.h
@@ -0,0 +1,691 @@
1//========================================================================
2// GLFW 3.4 Wayland - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include <wayland-client-core.h>
28#include <xkbcommon/xkbcommon.h>
29#include <xkbcommon/xkbcommon-compose.h>
30
31#include <stdbool.h>
32
33typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
34
35typedef struct VkWaylandSurfaceCreateInfoKHR
36{
37 VkStructureType sType;
38 const void* pNext;
39 VkWaylandSurfaceCreateFlagsKHR flags;
40 struct wl_display* display;
41 struct wl_surface* surface;
42} VkWaylandSurfaceCreateInfoKHR;
43
44typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
45typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
46
47#include "xkb_unicode.h"
48#include "posix_poll.h"
49
50typedef int (* PFN_wl_display_flush)(struct wl_display* display);
51typedef void (* PFN_wl_display_cancel_read)(struct wl_display* display);
52typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display* display);
53typedef int (* PFN_wl_display_read_events)(struct wl_display* display);
54typedef struct wl_display* (* PFN_wl_display_connect)(const char*);
55typedef void (* PFN_wl_display_disconnect)(struct wl_display*);
56typedef int (* PFN_wl_display_roundtrip)(struct wl_display*);
57typedef int (* PFN_wl_display_get_fd)(struct wl_display*);
58typedef int (* PFN_wl_display_prepare_read)(struct wl_display*);
59typedef void (* PFN_wl_proxy_marshal)(struct wl_proxy*,uint32_t,...);
60typedef int (* PFN_wl_proxy_add_listener)(struct wl_proxy*,void(**)(void),void*);
61typedef void (* PFN_wl_proxy_destroy)(struct wl_proxy*);
62typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor)(struct wl_proxy*,uint32_t,const struct wl_interface*,...);
63typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor_versioned)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,...);
64typedef void* (* PFN_wl_proxy_get_user_data)(struct wl_proxy*);
65typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*);
66typedef void (* PFN_wl_proxy_set_tag)(struct wl_proxy*,const char*const*);
67typedef const char* const* (* PFN_wl_proxy_get_tag)(struct wl_proxy*);
68typedef uint32_t (* PFN_wl_proxy_get_version)(struct wl_proxy*);
69typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,uint32_t,...);
70#define wl_display_flush _glfw.wl.client.display_flush
71#define wl_display_cancel_read _glfw.wl.client.display_cancel_read
72#define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending
73#define wl_display_read_events _glfw.wl.client.display_read_events
74#define wl_display_disconnect _glfw.wl.client.display_disconnect
75#define wl_display_roundtrip _glfw.wl.client.display_roundtrip
76#define wl_display_get_fd _glfw.wl.client.display_get_fd
77#define wl_display_prepare_read _glfw.wl.client.display_prepare_read
78#define wl_proxy_marshal _glfw.wl.client.proxy_marshal
79#define wl_proxy_add_listener _glfw.wl.client.proxy_add_listener
80#define wl_proxy_destroy _glfw.wl.client.proxy_destroy
81#define wl_proxy_marshal_constructor _glfw.wl.client.proxy_marshal_constructor
82#define wl_proxy_marshal_constructor_versioned _glfw.wl.client.proxy_marshal_constructor_versioned
83#define wl_proxy_get_user_data _glfw.wl.client.proxy_get_user_data
84#define wl_proxy_set_user_data _glfw.wl.client.proxy_set_user_data
85#define wl_proxy_get_tag _glfw.wl.client.proxy_get_tag
86#define wl_proxy_set_tag _glfw.wl.client.proxy_set_tag
87#define wl_proxy_get_version _glfw.wl.client.proxy_get_version
88#define wl_proxy_marshal_flags _glfw.wl.client.proxy_marshal_flags
89
90struct wl_shm;
91struct wl_output;
92
93#define wl_display_interface _glfw_wl_display_interface
94#define wl_subcompositor_interface _glfw_wl_subcompositor_interface
95#define wl_compositor_interface _glfw_wl_compositor_interface
96#define wl_shm_interface _glfw_wl_shm_interface
97#define wl_data_device_manager_interface _glfw_wl_data_device_manager_interface
98#define wl_shell_interface _glfw_wl_shell_interface
99#define wl_buffer_interface _glfw_wl_buffer_interface
100#define wl_callback_interface _glfw_wl_callback_interface
101#define wl_data_device_interface _glfw_wl_data_device_interface
102#define wl_data_offer_interface _glfw_wl_data_offer_interface
103#define wl_data_source_interface _glfw_wl_data_source_interface
104#define wl_keyboard_interface _glfw_wl_keyboard_interface
105#define wl_output_interface _glfw_wl_output_interface
106#define wl_pointer_interface _glfw_wl_pointer_interface
107#define wl_region_interface _glfw_wl_region_interface
108#define wl_registry_interface _glfw_wl_registry_interface
109#define wl_seat_interface _glfw_wl_seat_interface
110#define wl_shell_surface_interface _glfw_wl_shell_surface_interface
111#define wl_shm_pool_interface _glfw_wl_shm_pool_interface
112#define wl_subsurface_interface _glfw_wl_subsurface_interface
113#define wl_surface_interface _glfw_wl_surface_interface
114#define wl_touch_interface _glfw_wl_touch_interface
115#define zwp_idle_inhibitor_v1_interface _glfw_zwp_idle_inhibitor_v1_interface
116#define zwp_idle_inhibit_manager_v1_interface _glfw_zwp_idle_inhibit_manager_v1_interface
117#define zwp_confined_pointer_v1_interface _glfw_zwp_confined_pointer_v1_interface
118#define zwp_locked_pointer_v1_interface _glfw_zwp_locked_pointer_v1_interface
119#define zwp_pointer_constraints_v1_interface _glfw_zwp_pointer_constraints_v1_interface
120#define zwp_relative_pointer_v1_interface _glfw_zwp_relative_pointer_v1_interface
121#define zwp_relative_pointer_manager_v1_interface _glfw_zwp_relative_pointer_manager_v1_interface
122#define wp_viewport_interface _glfw_wp_viewport_interface
123#define wp_viewporter_interface _glfw_wp_viewporter_interface
124#define xdg_toplevel_interface _glfw_xdg_toplevel_interface
125#define zxdg_toplevel_decoration_v1_interface _glfw_zxdg_toplevel_decoration_v1_interface
126#define zxdg_decoration_manager_v1_interface _glfw_zxdg_decoration_manager_v1_interface
127#define xdg_popup_interface _glfw_xdg_popup_interface
128#define xdg_positioner_interface _glfw_xdg_positioner_interface
129#define xdg_surface_interface _glfw_xdg_surface_interface
130#define xdg_toplevel_interface _glfw_xdg_toplevel_interface
131#define xdg_wm_base_interface _glfw_xdg_wm_base_interface
132#define xdg_activation_v1_interface _glfw_xdg_activation_v1_interface
133#define xdg_activation_token_v1_interface _glfw_xdg_activation_token_v1_interface
134#define wl_surface_interface _glfw_wl_surface_interface
135#define wp_fractional_scale_v1_interface _glfw_wp_fractional_scale_v1_interface
136
137#define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl;
138#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl;
139#define GLFW_WAYLAND_MONITOR_STATE _GLFWmonitorWayland wl;
140#define GLFW_WAYLAND_CURSOR_STATE _GLFWcursorWayland wl;
141
142struct wl_cursor_image {
143 uint32_t width;
144 uint32_t height;
145 uint32_t hotspot_x;
146 uint32_t hotspot_y;
147 uint32_t delay;
148};
149struct wl_cursor {
150 unsigned int image_count;
151 struct wl_cursor_image** images;
152 char* name;
153};
154typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*);
155typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*);
156typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*);
157typedef struct wl_buffer* (* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image*);
158#define wl_cursor_theme_load _glfw.wl.cursor.theme_load
159#define wl_cursor_theme_destroy _glfw.wl.cursor.theme_destroy
160#define wl_cursor_theme_get_cursor _glfw.wl.cursor.theme_get_cursor
161#define wl_cursor_image_get_buffer _glfw.wl.cursor.image_get_buffer
162
163typedef struct wl_egl_window* (* PFN_wl_egl_window_create)(struct wl_surface*, int, int);
164typedef void (* PFN_wl_egl_window_destroy)(struct wl_egl_window*);
165typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, int);
166#define wl_egl_window_create _glfw.wl.egl.window_create
167#define wl_egl_window_destroy _glfw.wl.egl.window_destroy
168#define wl_egl_window_resize _glfw.wl.egl.window_resize
169
170typedef struct xkb_context* (* PFN_xkb_context_new)(enum xkb_context_flags);
171typedef void (* PFN_xkb_context_unref)(struct xkb_context*);
172typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
173typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
174typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
175typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
176typedef int (* PFN_xkb_keymap_key_get_syms_by_level)(struct xkb_keymap*,xkb_keycode_t,xkb_layout_index_t,xkb_level_index_t,const xkb_keysym_t**);
177typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
178typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
179typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
180typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
181typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t);
182typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_index_t,enum xkb_state_component);
183#define xkb_context_new _glfw.wl.xkb.context_new
184#define xkb_context_unref _glfw.wl.xkb.context_unref
185#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
186#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
187#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
188#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
189#define xkb_keymap_key_get_syms_by_level _glfw.wl.xkb.keymap_key_get_syms_by_level
190#define xkb_state_new _glfw.wl.xkb.state_new
191#define xkb_state_unref _glfw.wl.xkb.state_unref
192#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
193#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
194#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout
195#define xkb_state_mod_index_is_active _glfw.wl.xkb.state_mod_index_is_active
196
197typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
198typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
199typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
200typedef void (* PFN_xkb_compose_state_unref)(struct xkb_compose_state*);
201typedef enum xkb_compose_feed_result (* PFN_xkb_compose_state_feed)(struct xkb_compose_state*, xkb_keysym_t);
202typedef enum xkb_compose_status (* PFN_xkb_compose_state_get_status)(struct xkb_compose_state*);
203typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_state*);
204#define xkb_compose_table_new_from_locale _glfw.wl.xkb.compose_table_new_from_locale
205#define xkb_compose_table_unref _glfw.wl.xkb.compose_table_unref
206#define xkb_compose_state_new _glfw.wl.xkb.compose_state_new
207#define xkb_compose_state_unref _glfw.wl.xkb.compose_state_unref
208#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
209#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
210#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
211
212struct libdecor;
213struct libdecor_frame;
214struct libdecor_state;
215struct libdecor_configuration;
216
217enum libdecor_error
218{
219 LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
220 LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,
221};
222
223enum libdecor_window_state
224{
225 LIBDECOR_WINDOW_STATE_NONE = 0,
226 LIBDECOR_WINDOW_STATE_ACTIVE = 1,
227 LIBDECOR_WINDOW_STATE_MAXIMIZED = 2,
228 LIBDECOR_WINDOW_STATE_FULLSCREEN = 4,
229 LIBDECOR_WINDOW_STATE_TILED_LEFT = 8,
230 LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16,
231 LIBDECOR_WINDOW_STATE_TILED_TOP = 32,
232 LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64
233};
234
235enum libdecor_capabilities
236{
237 LIBDECOR_ACTION_MOVE = 1,
238 LIBDECOR_ACTION_RESIZE = 2,
239 LIBDECOR_ACTION_MINIMIZE = 4,
240 LIBDECOR_ACTION_FULLSCREEN = 8,
241 LIBDECOR_ACTION_CLOSE = 16
242};
243
244struct libdecor_interface
245{
246 void (* error)(struct libdecor*,enum libdecor_error,const char*);
247 void (* reserved0)(void);
248 void (* reserved1)(void);
249 void (* reserved2)(void);
250 void (* reserved3)(void);
251 void (* reserved4)(void);
252 void (* reserved5)(void);
253 void (* reserved6)(void);
254 void (* reserved7)(void);
255 void (* reserved8)(void);
256 void (* reserved9)(void);
257};
258
259struct libdecor_frame_interface
260{
261 void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*);
262 void (* close)(struct libdecor_frame*,void*);
263 void (* commit)(struct libdecor_frame*,void*);
264 void (* dismiss_popup)(struct libdecor_frame*,const char*,void*);
265 void (* reserved0)(void);
266 void (* reserved1)(void);
267 void (* reserved2)(void);
268 void (* reserved3)(void);
269 void (* reserved4)(void);
270 void (* reserved5)(void);
271 void (* reserved6)(void);
272 void (* reserved7)(void);
273 void (* reserved8)(void);
274 void (* reserved9)(void);
275};
276
277typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*);
278typedef void (* PFN_libdecor_unref)(struct libdecor*);
279typedef int (* PFN_libdecor_get_fd)(struct libdecor*);
280typedef int (* PFN_libdecor_dispatch)(struct libdecor*,int);
281typedef struct libdecor_frame* (* PFN_libdecor_decorate)(struct libdecor*,struct wl_surface*,const struct libdecor_frame_interface*,void*);
282typedef void (* PFN_libdecor_frame_unref)(struct libdecor_frame*);
283typedef void (* PFN_libdecor_frame_set_app_id)(struct libdecor_frame*,const char*);
284typedef void (* PFN_libdecor_frame_set_title)(struct libdecor_frame*,const char*);
285typedef void (* PFN_libdecor_frame_set_minimized)(struct libdecor_frame*);
286typedef void (* PFN_libdecor_frame_set_fullscreen)(struct libdecor_frame*,struct wl_output*);
287typedef void (* PFN_libdecor_frame_unset_fullscreen)(struct libdecor_frame*);
288typedef void (* PFN_libdecor_frame_map)(struct libdecor_frame*);
289typedef void (* PFN_libdecor_frame_commit)(struct libdecor_frame*,struct libdecor_state*,struct libdecor_configuration*);
290typedef void (* PFN_libdecor_frame_set_min_content_size)(struct libdecor_frame*,int,int);
291typedef void (* PFN_libdecor_frame_set_max_content_size)(struct libdecor_frame*,int,int);
292typedef void (* PFN_libdecor_frame_set_maximized)(struct libdecor_frame*);
293typedef void (* PFN_libdecor_frame_unset_maximized)(struct libdecor_frame*);
294typedef void (* PFN_libdecor_frame_set_capabilities)(struct libdecor_frame*,enum libdecor_capabilities);
295typedef void (* PFN_libdecor_frame_unset_capabilities)(struct libdecor_frame*,enum libdecor_capabilities);
296typedef void (* PFN_libdecor_frame_set_visibility)(struct libdecor_frame*,bool visible);
297typedef struct xdg_toplevel* (* PFN_libdecor_frame_get_xdg_toplevel)(struct libdecor_frame*);
298typedef bool (* PFN_libdecor_configuration_get_content_size)(struct libdecor_configuration*,struct libdecor_frame*,int*,int*);
299typedef bool (* PFN_libdecor_configuration_get_window_state)(struct libdecor_configuration*,enum libdecor_window_state*);
300typedef struct libdecor_state* (* PFN_libdecor_state_new)(int,int);
301typedef void (* PFN_libdecor_state_free)(struct libdecor_state*);
302#define libdecor_new _glfw.wl.libdecor.libdecor_new_
303#define libdecor_unref _glfw.wl.libdecor.libdecor_unref_
304#define libdecor_get_fd _glfw.wl.libdecor.libdecor_get_fd_
305#define libdecor_dispatch _glfw.wl.libdecor.libdecor_dispatch_
306#define libdecor_decorate _glfw.wl.libdecor.libdecor_decorate_
307#define libdecor_frame_unref _glfw.wl.libdecor.libdecor_frame_unref_
308#define libdecor_frame_set_app_id _glfw.wl.libdecor.libdecor_frame_set_app_id_
309#define libdecor_frame_set_title _glfw.wl.libdecor.libdecor_frame_set_title_
310#define libdecor_frame_set_minimized _glfw.wl.libdecor.libdecor_frame_set_minimized_
311#define libdecor_frame_set_fullscreen _glfw.wl.libdecor.libdecor_frame_set_fullscreen_
312#define libdecor_frame_unset_fullscreen _glfw.wl.libdecor.libdecor_frame_unset_fullscreen_
313#define libdecor_frame_map _glfw.wl.libdecor.libdecor_frame_map_
314#define libdecor_frame_commit _glfw.wl.libdecor.libdecor_frame_commit_
315#define libdecor_frame_set_min_content_size _glfw.wl.libdecor.libdecor_frame_set_min_content_size_
316#define libdecor_frame_set_max_content_size _glfw.wl.libdecor.libdecor_frame_set_max_content_size_
317#define libdecor_frame_set_maximized _glfw.wl.libdecor.libdecor_frame_set_maximized_
318#define libdecor_frame_unset_maximized _glfw.wl.libdecor.libdecor_frame_unset_maximized_
319#define libdecor_frame_set_capabilities _glfw.wl.libdecor.libdecor_frame_set_capabilities_
320#define libdecor_frame_unset_capabilities _glfw.wl.libdecor.libdecor_frame_unset_capabilities_
321#define libdecor_frame_set_visibility _glfw.wl.libdecor.libdecor_frame_set_visibility_
322#define libdecor_frame_get_xdg_toplevel _glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_
323#define libdecor_configuration_get_content_size _glfw.wl.libdecor.libdecor_configuration_get_content_size_
324#define libdecor_configuration_get_window_state _glfw.wl.libdecor.libdecor_configuration_get_window_state_
325#define libdecor_state_new _glfw.wl.libdecor.libdecor_state_new_
326#define libdecor_state_free _glfw.wl.libdecor.libdecor_state_free_
327
328typedef struct _GLFWfallbackEdgeWayland
329{
330 struct wl_surface* surface;
331 struct wl_subsurface* subsurface;
332 struct wp_viewport* viewport;
333} _GLFWfallbackEdgeWayland;
334
335typedef struct _GLFWofferWayland
336{
337 struct wl_data_offer* offer;
338 GLFWbool text_plain_utf8;
339 GLFWbool text_uri_list;
340} _GLFWofferWayland;
341
342typedef struct _GLFWscaleWayland
343{
344 struct wl_output* output;
345 int32_t factor;
346} _GLFWscaleWayland;
347
348// Wayland-specific per-window data
349//
350typedef struct _GLFWwindowWayland
351{
352 int width, height;
353 int fbWidth, fbHeight;
354 GLFWbool visible;
355 GLFWbool maximized;
356 GLFWbool activated;
357 GLFWbool fullscreen;
358 GLFWbool hovered;
359 GLFWbool transparent;
360 GLFWbool scaleFramebuffer;
361 struct wl_surface* surface;
362 struct wl_callback* callback;
363
364 struct {
365 struct wl_egl_window* window;
366 } egl;
367
368 struct {
369 int width, height;
370 GLFWbool maximized;
371 GLFWbool iconified;
372 GLFWbool activated;
373 GLFWbool fullscreen;
374 } pending;
375
376 struct {
377 struct xdg_surface* surface;
378 struct xdg_toplevel* toplevel;
379 struct zxdg_toplevel_decoration_v1* decoration;
380 uint32_t decorationMode;
381 } xdg;
382
383 struct {
384 struct libdecor_frame* frame;
385 } libdecor;
386
387 _GLFWcursor* currentCursor;
388 double cursorPosX, cursorPosY;
389
390 char* appId;
391
392 // We need to track the monitors the window spans on to calculate the
393 // optimal scaling factor.
394 int32_t bufferScale;
395 _GLFWscaleWayland* outputScales;
396 size_t outputScaleCount;
397 size_t outputScaleSize;
398
399 struct wp_viewport* scalingViewport;
400 uint32_t scalingNumerator;
401 struct wp_fractional_scale_v1* fractionalScale;
402
403 struct zwp_relative_pointer_v1* relativePointer;
404 struct zwp_locked_pointer_v1* lockedPointer;
405 struct zwp_confined_pointer_v1* confinedPointer;
406
407 struct zwp_idle_inhibitor_v1* idleInhibitor;
408 struct xdg_activation_token_v1* activationToken;
409
410 struct {
411 GLFWbool decorations;
412 struct wl_buffer* buffer;
413 _GLFWfallbackEdgeWayland top, left, right, bottom;
414 struct wl_surface* focus;
415 } fallback;
416} _GLFWwindowWayland;
417
418// Wayland-specific global data
419//
420typedef struct _GLFWlibraryWayland
421{
422 struct wl_display* display;
423 struct wl_registry* registry;
424 struct wl_compositor* compositor;
425 struct wl_subcompositor* subcompositor;
426 struct wl_shm* shm;
427 struct wl_seat* seat;
428 struct wl_pointer* pointer;
429 struct wl_keyboard* keyboard;
430 struct wl_data_device_manager* dataDeviceManager;
431 struct wl_data_device* dataDevice;
432 struct xdg_wm_base* wmBase;
433 struct zxdg_decoration_manager_v1* decorationManager;
434 struct wp_viewporter* viewporter;
435 struct zwp_relative_pointer_manager_v1* relativePointerManager;
436 struct zwp_pointer_constraints_v1* pointerConstraints;
437 struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
438 struct xdg_activation_v1* activationManager;
439 struct wp_fractional_scale_manager_v1* fractionalScaleManager;
440
441 _GLFWofferWayland* offers;
442 unsigned int offerCount;
443
444 struct wl_data_offer* selectionOffer;
445 struct wl_data_source* selectionSource;
446
447 struct wl_data_offer* dragOffer;
448 _GLFWwindow* dragFocus;
449 uint32_t dragSerial;
450
451 const char* tag;
452
453 struct wl_cursor_theme* cursorTheme;
454 struct wl_cursor_theme* cursorThemeHiDPI;
455 struct wl_surface* cursorSurface;
456 const char* cursorPreviousName;
457 int cursorTimerfd;
458 uint32_t serial;
459 uint32_t pointerEnterSerial;
460
461 int keyRepeatTimerfd;
462 int32_t keyRepeatRate;
463 int32_t keyRepeatDelay;
464 int keyRepeatScancode;
465
466 char* clipboardString;
467 short int keycodes[256];
468 short int scancodes[GLFW_KEY_LAST + 1];
469 char keynames[GLFW_KEY_LAST + 1][5];
470
471 struct {
472 void* handle;
473 struct xkb_context* context;
474 struct xkb_keymap* keymap;
475 struct xkb_state* state;
476
477 struct xkb_compose_state* composeState;
478
479 xkb_mod_index_t controlIndex;
480 xkb_mod_index_t altIndex;
481 xkb_mod_index_t shiftIndex;
482 xkb_mod_index_t superIndex;
483 xkb_mod_index_t capsLockIndex;
484 xkb_mod_index_t numLockIndex;
485 unsigned int modifiers;
486
487 PFN_xkb_context_new context_new;
488 PFN_xkb_context_unref context_unref;
489 PFN_xkb_keymap_new_from_string keymap_new_from_string;
490 PFN_xkb_keymap_unref keymap_unref;
491 PFN_xkb_keymap_mod_get_index keymap_mod_get_index;
492 PFN_xkb_keymap_key_repeats keymap_key_repeats;
493 PFN_xkb_keymap_key_get_syms_by_level keymap_key_get_syms_by_level;
494 PFN_xkb_state_new state_new;
495 PFN_xkb_state_unref state_unref;
496 PFN_xkb_state_key_get_syms state_key_get_syms;
497 PFN_xkb_state_update_mask state_update_mask;
498 PFN_xkb_state_key_get_layout state_key_get_layout;
499 PFN_xkb_state_mod_index_is_active state_mod_index_is_active;
500
501 PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
502 PFN_xkb_compose_table_unref compose_table_unref;
503 PFN_xkb_compose_state_new compose_state_new;
504 PFN_xkb_compose_state_unref compose_state_unref;
505 PFN_xkb_compose_state_feed compose_state_feed;
506 PFN_xkb_compose_state_get_status compose_state_get_status;
507 PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
508 } xkb;
509
510 _GLFWwindow* pointerFocus;
511 _GLFWwindow* keyboardFocus;
512
513 struct {
514 void* handle;
515 PFN_wl_display_flush display_flush;
516 PFN_wl_display_cancel_read display_cancel_read;
517 PFN_wl_display_dispatch_pending display_dispatch_pending;
518 PFN_wl_display_read_events display_read_events;
519 PFN_wl_display_disconnect display_disconnect;
520 PFN_wl_display_roundtrip display_roundtrip;
521 PFN_wl_display_get_fd display_get_fd;
522 PFN_wl_display_prepare_read display_prepare_read;
523 PFN_wl_proxy_marshal proxy_marshal;
524 PFN_wl_proxy_add_listener proxy_add_listener;
525 PFN_wl_proxy_destroy proxy_destroy;
526 PFN_wl_proxy_marshal_constructor proxy_marshal_constructor;
527 PFN_wl_proxy_marshal_constructor_versioned proxy_marshal_constructor_versioned;
528 PFN_wl_proxy_get_user_data proxy_get_user_data;
529 PFN_wl_proxy_set_user_data proxy_set_user_data;
530 PFN_wl_proxy_get_tag proxy_get_tag;
531 PFN_wl_proxy_set_tag proxy_set_tag;
532 PFN_wl_proxy_get_version proxy_get_version;
533 PFN_wl_proxy_marshal_flags proxy_marshal_flags;
534 } client;
535
536 struct {
537 void* handle;
538
539 PFN_wl_cursor_theme_load theme_load;
540 PFN_wl_cursor_theme_destroy theme_destroy;
541 PFN_wl_cursor_theme_get_cursor theme_get_cursor;
542 PFN_wl_cursor_image_get_buffer image_get_buffer;
543 } cursor;
544
545 struct {
546 void* handle;
547
548 PFN_wl_egl_window_create window_create;
549 PFN_wl_egl_window_destroy window_destroy;
550 PFN_wl_egl_window_resize window_resize;
551 } egl;
552
553 struct {
554 void* handle;
555 struct libdecor* context;
556 struct wl_callback* callback;
557 GLFWbool ready;
558 PFN_libdecor_new libdecor_new_;
559 PFN_libdecor_unref libdecor_unref_;
560 PFN_libdecor_get_fd libdecor_get_fd_;
561 PFN_libdecor_dispatch libdecor_dispatch_;
562 PFN_libdecor_decorate libdecor_decorate_;
563 PFN_libdecor_frame_unref libdecor_frame_unref_;
564 PFN_libdecor_frame_set_app_id libdecor_frame_set_app_id_;
565 PFN_libdecor_frame_set_title libdecor_frame_set_title_;
566 PFN_libdecor_frame_set_minimized libdecor_frame_set_minimized_;
567 PFN_libdecor_frame_set_fullscreen libdecor_frame_set_fullscreen_;
568 PFN_libdecor_frame_unset_fullscreen libdecor_frame_unset_fullscreen_;
569 PFN_libdecor_frame_map libdecor_frame_map_;
570 PFN_libdecor_frame_commit libdecor_frame_commit_;
571 PFN_libdecor_frame_set_min_content_size libdecor_frame_set_min_content_size_;
572 PFN_libdecor_frame_set_max_content_size libdecor_frame_set_max_content_size_;
573 PFN_libdecor_frame_set_maximized libdecor_frame_set_maximized_;
574 PFN_libdecor_frame_unset_maximized libdecor_frame_unset_maximized_;
575 PFN_libdecor_frame_set_capabilities libdecor_frame_set_capabilities_;
576 PFN_libdecor_frame_unset_capabilities libdecor_frame_unset_capabilities_;
577 PFN_libdecor_frame_set_visibility libdecor_frame_set_visibility_;
578 PFN_libdecor_frame_get_xdg_toplevel libdecor_frame_get_xdg_toplevel_;
579 PFN_libdecor_configuration_get_content_size libdecor_configuration_get_content_size_;
580 PFN_libdecor_configuration_get_window_state libdecor_configuration_get_window_state_;
581 PFN_libdecor_state_new libdecor_state_new_;
582 PFN_libdecor_state_free libdecor_state_free_;
583 } libdecor;
584} _GLFWlibraryWayland;
585
586// Wayland-specific per-monitor data
587//
588typedef struct _GLFWmonitorWayland
589{
590 struct wl_output* output;
591 uint32_t name;
592 int currentMode;
593
594 int x;
595 int y;
596 int32_t scale;
597} _GLFWmonitorWayland;
598
599// Wayland-specific per-cursor data
600//
601typedef struct _GLFWcursorWayland
602{
603 struct wl_cursor* cursor;
604 struct wl_cursor* cursorHiDPI;
605 struct wl_buffer* buffer;
606 int width, height;
607 int xhot, yhot;
608 int currentImage;
609} _GLFWcursorWayland;
610
611GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform);
612int _glfwInitWayland(void);
613void _glfwTerminateWayland(void);
614
615GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
616void _glfwDestroyWindowWayland(_GLFWwindow* window);
617void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
618void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
619void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
620void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos);
621void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height);
622void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height);
623void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
624void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom);
625void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height);
626void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
627void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, float* xscale, float* yscale);
628void _glfwIconifyWindowWayland(_GLFWwindow* window);
629void _glfwRestoreWindowWayland(_GLFWwindow* window);
630void _glfwMaximizeWindowWayland(_GLFWwindow* window);
631void _glfwShowWindowWayland(_GLFWwindow* window);
632void _glfwHideWindowWayland(_GLFWwindow* window);
633void _glfwRequestWindowAttentionWayland(_GLFWwindow* window);
634void _glfwFocusWindowWayland(_GLFWwindow* window);
635void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
636GLFWbool _glfwWindowFocusedWayland(_GLFWwindow* window);
637GLFWbool _glfwWindowIconifiedWayland(_GLFWwindow* window);
638GLFWbool _glfwWindowVisibleWayland(_GLFWwindow* window);
639GLFWbool _glfwWindowMaximizedWayland(_GLFWwindow* window);
640GLFWbool _glfwWindowHoveredWayland(_GLFWwindow* window);
641GLFWbool _glfwFramebufferTransparentWayland(_GLFWwindow* window);
642void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled);
643void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled);
644void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled);
645float _glfwGetWindowOpacityWayland(_GLFWwindow* window);
646void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity);
647void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled);
648
649void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled);
650GLFWbool _glfwRawMouseMotionSupportedWayland(void);
651
652void _glfwPollEventsWayland(void);
653void _glfwWaitEventsWayland(void);
654void _glfwWaitEventsTimeoutWayland(double timeout);
655void _glfwPostEmptyEventWayland(void);
656
657void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos);
658void _glfwSetCursorPosWayland(_GLFWwindow* window, double xpos, double ypos);
659void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode);
660const char* _glfwGetScancodeNameWayland(int scancode);
661int _glfwGetKeyScancodeWayland(int key);
662GLFWbool _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
663GLFWbool _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape);
664void _glfwDestroyCursorWayland(_GLFWcursor* cursor);
665void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor);
666void _glfwSetClipboardStringWayland(const char* string);
667const char* _glfwGetClipboardStringWayland(void);
668
669EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs);
670EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void);
671EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window);
672
673void _glfwGetRequiredInstanceExtensionsWayland(char** extensions);
674GLFWbool _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
675VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
676
677void _glfwFreeMonitorWayland(_GLFWmonitor* monitor);
678void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos);
679void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale);
680void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
681GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count);
682GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode);
683GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
684void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
685
686void _glfwAddOutputWayland(uint32_t name, uint32_t version);
687void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window);
688
689void _glfwAddSeatListenerWayland(struct wl_seat* seat);
690void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device);
691
diff --git a/raylib/src/external/glfw/src/wl_window.c b/raylib/src/external/glfw/src/wl_window.c
new file mode 100644
index 0000000..505166e
--- /dev/null
+++ b/raylib/src/external/glfw/src/wl_window.c
@@ -0,0 +1,3309 @@
1//========================================================================
2// GLFW 3.4 Wayland (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
5// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#define _GNU_SOURCE
29
30#include "internal.h"
31
32#if defined(_GLFW_WAYLAND)
33
34#include <stdio.h>
35#include <stdlib.h>
36#include <errno.h>
37#include <assert.h>
38#include <unistd.h>
39#include <string.h>
40#include <fcntl.h>
41#include <sys/mman.h>
42#include <sys/timerfd.h>
43#include <poll.h>
44#include <linux/input-event-codes.h>
45
46#include "wayland-client-protocol.h"
47#include "xdg-shell-client-protocol.h"
48#include "xdg-decoration-unstable-v1-client-protocol.h"
49#include "viewporter-client-protocol.h"
50#include "relative-pointer-unstable-v1-client-protocol.h"
51#include "pointer-constraints-unstable-v1-client-protocol.h"
52#include "xdg-activation-v1-client-protocol.h"
53#include "idle-inhibit-unstable-v1-client-protocol.h"
54#include "fractional-scale-v1-client-protocol.h"
55
56#define GLFW_BORDER_SIZE 4
57#define GLFW_CAPTION_HEIGHT 24
58
59static int createTmpfileCloexec(char* tmpname)
60{
61 int fd;
62
63 fd = mkostemp(tmpname, O_CLOEXEC);
64 if (fd >= 0)
65 unlink(tmpname);
66
67 return fd;
68}
69
70/*
71 * Create a new, unique, anonymous file of the given size, and
72 * return the file descriptor for it. The file descriptor is set
73 * CLOEXEC. The file is immediately suitable for mmap()'ing
74 * the given size at offset zero.
75 *
76 * The file should not have a permanent backing store like a disk,
77 * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
78 *
79 * The file name is deleted from the file system.
80 *
81 * The file is suitable for buffer sharing between processes by
82 * transmitting the file descriptor over Unix sockets using the
83 * SCM_RIGHTS methods.
84 *
85 * posix_fallocate() is used to guarantee that disk space is available
86 * for the file at the given size. If disk space is insufficient, errno
87 * is set to ENOSPC. If posix_fallocate() is not supported, program may
88 * receive SIGBUS on accessing mmap()'ed file contents instead.
89 */
90static int createAnonymousFile(off_t size)
91{
92 static const char template[] = "/glfw-shared-XXXXXX";
93 const char* path;
94 char* name;
95 int fd;
96 int ret;
97
98#ifdef HAVE_MEMFD_CREATE
99 fd = memfd_create("glfw-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING);
100 if (fd >= 0)
101 {
102 // We can add this seal before calling posix_fallocate(), as the file
103 // is currently zero-sized anyway.
104 //
105 // There is also no need to check for the return value, we couldn’t do
106 // anything with it anyway.
107 fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
108 }
109 else
110#elif defined(SHM_ANON)
111 fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600);
112 if (fd < 0)
113#endif
114 {
115 path = getenv("XDG_RUNTIME_DIR");
116 if (!path)
117 {
118 errno = ENOENT;
119 return -1;
120 }
121
122 name = _glfw_calloc(strlen(path) + sizeof(template), 1);
123 strcpy(name, path);
124 strcat(name, template);
125
126 fd = createTmpfileCloexec(name);
127 _glfw_free(name);
128 if (fd < 0)
129 return -1;
130 }
131
132#if defined(SHM_ANON)
133 // posix_fallocate does not work on SHM descriptors
134 ret = ftruncate(fd, size);
135#else
136 ret = posix_fallocate(fd, 0, size);
137#endif
138 if (ret != 0)
139 {
140 close(fd);
141 errno = ret;
142 return -1;
143 }
144 return fd;
145}
146
147static struct wl_buffer* createShmBuffer(const GLFWimage* image)
148{
149 const int stride = image->width * 4;
150 const int length = image->width * image->height * 4;
151
152 const int fd = createAnonymousFile(length);
153 if (fd < 0)
154 {
155 _glfwInputError(GLFW_PLATFORM_ERROR,
156 "Wayland: Failed to create buffer file of size %d: %s",
157 length, strerror(errno));
158 return NULL;
159 }
160
161 void* data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
162 if (data == MAP_FAILED)
163 {
164 _glfwInputError(GLFW_PLATFORM_ERROR,
165 "Wayland: Failed to map file: %s", strerror(errno));
166 close(fd);
167 return NULL;
168 }
169
170 struct wl_shm_pool* pool = wl_shm_create_pool(_glfw.wl.shm, fd, length);
171
172 close(fd);
173
174 unsigned char* source = (unsigned char*) image->pixels;
175 unsigned char* target = data;
176 for (int i = 0; i < image->width * image->height; i++, source += 4)
177 {
178 unsigned int alpha = source[3];
179
180 *target++ = (unsigned char) ((source[2] * alpha) / 255);
181 *target++ = (unsigned char) ((source[1] * alpha) / 255);
182 *target++ = (unsigned char) ((source[0] * alpha) / 255);
183 *target++ = (unsigned char) alpha;
184 }
185
186 struct wl_buffer* buffer =
187 wl_shm_pool_create_buffer(pool, 0,
188 image->width,
189 image->height,
190 stride, WL_SHM_FORMAT_ARGB8888);
191 munmap(data, length);
192 wl_shm_pool_destroy(pool);
193
194 return buffer;
195}
196
197static void createFallbackEdge(_GLFWwindow* window,
198 _GLFWfallbackEdgeWayland* edge,
199 struct wl_surface* parent,
200 struct wl_buffer* buffer,
201 int x, int y,
202 int width, int height)
203{
204 edge->surface = wl_compositor_create_surface(_glfw.wl.compositor);
205 wl_surface_set_user_data(edge->surface, window);
206 wl_proxy_set_tag((struct wl_proxy*) edge->surface, &_glfw.wl.tag);
207 edge->subsurface = wl_subcompositor_get_subsurface(_glfw.wl.subcompositor,
208 edge->surface, parent);
209 wl_subsurface_set_position(edge->subsurface, x, y);
210 edge->viewport = wp_viewporter_get_viewport(_glfw.wl.viewporter,
211 edge->surface);
212 wp_viewport_set_destination(edge->viewport, width, height);
213 wl_surface_attach(edge->surface, buffer, 0, 0);
214
215 struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor);
216 wl_region_add(region, 0, 0, width, height);
217 wl_surface_set_opaque_region(edge->surface, region);
218 wl_surface_commit(edge->surface);
219 wl_region_destroy(region);
220}
221
222static void createFallbackDecorations(_GLFWwindow* window)
223{
224 unsigned char data[] = { 224, 224, 224, 255 };
225 const GLFWimage image = { 1, 1, data };
226
227 if (!_glfw.wl.viewporter)
228 return;
229
230 if (!window->wl.fallback.buffer)
231 window->wl.fallback.buffer = createShmBuffer(&image);
232 if (!window->wl.fallback.buffer)
233 return;
234
235 createFallbackEdge(window, &window->wl.fallback.top, window->wl.surface,
236 window->wl.fallback.buffer,
237 0, -GLFW_CAPTION_HEIGHT,
238 window->wl.width, GLFW_CAPTION_HEIGHT);
239 createFallbackEdge(window, &window->wl.fallback.left, window->wl.surface,
240 window->wl.fallback.buffer,
241 -GLFW_BORDER_SIZE, -GLFW_CAPTION_HEIGHT,
242 GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT);
243 createFallbackEdge(window, &window->wl.fallback.right, window->wl.surface,
244 window->wl.fallback.buffer,
245 window->wl.width, -GLFW_CAPTION_HEIGHT,
246 GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT);
247 createFallbackEdge(window, &window->wl.fallback.bottom, window->wl.surface,
248 window->wl.fallback.buffer,
249 -GLFW_BORDER_SIZE, window->wl.height,
250 window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE);
251
252 window->wl.fallback.decorations = GLFW_TRUE;
253}
254
255static void destroyFallbackEdge(_GLFWfallbackEdgeWayland* edge)
256{
257 if (edge->subsurface)
258 wl_subsurface_destroy(edge->subsurface);
259 if (edge->surface)
260 wl_surface_destroy(edge->surface);
261 if (edge->viewport)
262 wp_viewport_destroy(edge->viewport);
263
264 edge->surface = NULL;
265 edge->subsurface = NULL;
266 edge->viewport = NULL;
267}
268
269static void destroyFallbackDecorations(_GLFWwindow* window)
270{
271 window->wl.fallback.decorations = GLFW_FALSE;
272
273 destroyFallbackEdge(&window->wl.fallback.top);
274 destroyFallbackEdge(&window->wl.fallback.left);
275 destroyFallbackEdge(&window->wl.fallback.right);
276 destroyFallbackEdge(&window->wl.fallback.bottom);
277}
278
279static void xdgDecorationHandleConfigure(void* userData,
280 struct zxdg_toplevel_decoration_v1* decoration,
281 uint32_t mode)
282{
283 _GLFWwindow* window = userData;
284
285 window->wl.xdg.decorationMode = mode;
286
287 if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE)
288 {
289 if (window->decorated && !window->monitor)
290 createFallbackDecorations(window);
291 }
292 else
293 destroyFallbackDecorations(window);
294}
295
296static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener =
297{
298 xdgDecorationHandleConfigure,
299};
300
301// Makes the surface considered as XRGB instead of ARGB.
302static void setContentAreaOpaque(_GLFWwindow* window)
303{
304 struct wl_region* region;
305
306 region = wl_compositor_create_region(_glfw.wl.compositor);
307 if (!region)
308 return;
309
310 wl_region_add(region, 0, 0, window->wl.width, window->wl.height);
311 wl_surface_set_opaque_region(window->wl.surface, region);
312 wl_region_destroy(region);
313}
314
315static void resizeFramebuffer(_GLFWwindow* window)
316{
317 if (window->wl.fractionalScale)
318 {
319 window->wl.fbWidth = (window->wl.width * window->wl.scalingNumerator) / 120;
320 window->wl.fbHeight = (window->wl.height * window->wl.scalingNumerator) / 120;
321 }
322 else
323 {
324 window->wl.fbWidth = window->wl.width * window->wl.bufferScale;
325 window->wl.fbHeight = window->wl.height * window->wl.bufferScale;
326 }
327
328 if (window->wl.egl.window)
329 {
330 wl_egl_window_resize(window->wl.egl.window,
331 window->wl.fbWidth,
332 window->wl.fbHeight,
333 0, 0);
334 }
335
336 if (!window->wl.transparent)
337 setContentAreaOpaque(window);
338
339 _glfwInputFramebufferSize(window, window->wl.fbWidth, window->wl.fbHeight);
340}
341
342static GLFWbool resizeWindow(_GLFWwindow* window, int width, int height)
343{
344 width = _glfw_max(width, 1);
345 height = _glfw_max(height, 1);
346
347 if (width == window->wl.width && height == window->wl.height)
348 return GLFW_FALSE;
349
350 window->wl.width = width;
351 window->wl.height = height;
352
353 resizeFramebuffer(window);
354
355 if (window->wl.scalingViewport)
356 {
357 wp_viewport_set_destination(window->wl.scalingViewport,
358 window->wl.width,
359 window->wl.height);
360 }
361
362 if (window->wl.fallback.decorations)
363 {
364 wp_viewport_set_destination(window->wl.fallback.top.viewport,
365 window->wl.width,
366 GLFW_CAPTION_HEIGHT);
367 wl_surface_commit(window->wl.fallback.top.surface);
368
369 wp_viewport_set_destination(window->wl.fallback.left.viewport,
370 GLFW_BORDER_SIZE,
371 window->wl.height + GLFW_CAPTION_HEIGHT);
372 wl_surface_commit(window->wl.fallback.left.surface);
373
374 wl_subsurface_set_position(window->wl.fallback.right.subsurface,
375 window->wl.width, -GLFW_CAPTION_HEIGHT);
376 wp_viewport_set_destination(window->wl.fallback.right.viewport,
377 GLFW_BORDER_SIZE,
378 window->wl.height + GLFW_CAPTION_HEIGHT);
379 wl_surface_commit(window->wl.fallback.right.surface);
380
381 wl_subsurface_set_position(window->wl.fallback.bottom.subsurface,
382 -GLFW_BORDER_SIZE, window->wl.height);
383 wp_viewport_set_destination(window->wl.fallback.bottom.viewport,
384 window->wl.width + GLFW_BORDER_SIZE * 2,
385 GLFW_BORDER_SIZE);
386 wl_surface_commit(window->wl.fallback.bottom.surface);
387 }
388
389 return GLFW_TRUE;
390}
391
392void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window)
393{
394 if (wl_compositor_get_version(_glfw.wl.compositor) <
395 WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
396 {
397 return;
398 }
399
400 if (!window->wl.scaleFramebuffer)
401 return;
402
403 // When using fractional scaling, the buffer scale should remain at 1
404 if (window->wl.fractionalScale)
405 return;
406
407 // Get the scale factor from the highest scale monitor.
408 int32_t maxScale = 1;
409
410 for (size_t i = 0; i < window->wl.outputScaleCount; i++)
411 maxScale = _glfw_max(window->wl.outputScales[i].factor, maxScale);
412
413 // Only change the framebuffer size if the scale changed.
414 if (window->wl.bufferScale != maxScale)
415 {
416 window->wl.bufferScale = maxScale;
417 wl_surface_set_buffer_scale(window->wl.surface, maxScale);
418 _glfwInputWindowContentScale(window, maxScale, maxScale);
419 resizeFramebuffer(window);
420
421 if (window->wl.visible)
422 _glfwInputWindowDamage(window);
423 }
424}
425
426static void surfaceHandleEnter(void* userData,
427 struct wl_surface* surface,
428 struct wl_output* output)
429{
430 if (wl_proxy_get_tag((struct wl_proxy*) output) != &_glfw.wl.tag)
431 return;
432
433 _GLFWwindow* window = userData;
434 _GLFWmonitor* monitor = wl_output_get_user_data(output);
435 if (!window || !monitor)
436 return;
437
438 if (window->wl.outputScaleCount + 1 > window->wl.outputScaleSize)
439 {
440 window->wl.outputScaleSize++;
441 window->wl.outputScales =
442 _glfw_realloc(window->wl.outputScales,
443 window->wl.outputScaleSize * sizeof(_GLFWscaleWayland));
444 }
445
446 window->wl.outputScaleCount++;
447 window->wl.outputScales[window->wl.outputScaleCount - 1] =
448 (_GLFWscaleWayland) { output, monitor->wl.scale };
449
450 _glfwUpdateBufferScaleFromOutputsWayland(window);
451}
452
453static void surfaceHandleLeave(void* userData,
454 struct wl_surface* surface,
455 struct wl_output* output)
456{
457 if (wl_proxy_get_tag((struct wl_proxy*) output) != &_glfw.wl.tag)
458 return;
459
460 _GLFWwindow* window = userData;
461
462 for (size_t i = 0; i < window->wl.outputScaleCount; i++)
463 {
464 if (window->wl.outputScales[i].output == output)
465 {
466 window->wl.outputScales[i] =
467 window->wl.outputScales[window->wl.outputScaleCount - 1];
468 window->wl.outputScaleCount--;
469 break;
470 }
471 }
472
473 _glfwUpdateBufferScaleFromOutputsWayland(window);
474}
475
476static const struct wl_surface_listener surfaceListener =
477{
478 surfaceHandleEnter,
479 surfaceHandleLeave
480};
481
482static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable)
483{
484 if (enable && !window->wl.idleInhibitor && _glfw.wl.idleInhibitManager)
485 {
486 window->wl.idleInhibitor =
487 zwp_idle_inhibit_manager_v1_create_inhibitor(
488 _glfw.wl.idleInhibitManager, window->wl.surface);
489 if (!window->wl.idleInhibitor)
490 _glfwInputError(GLFW_PLATFORM_ERROR,
491 "Wayland: Failed to create idle inhibitor");
492 }
493 else if (!enable && window->wl.idleInhibitor)
494 {
495 zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
496 window->wl.idleInhibitor = NULL;
497 }
498}
499
500// Make the specified window and its video mode active on its monitor
501//
502static void acquireMonitorWayland(_GLFWwindow* window)
503{
504 if (window->wl.libdecor.frame)
505 {
506 libdecor_frame_set_fullscreen(window->wl.libdecor.frame,
507 window->monitor->wl.output);
508 }
509 else if (window->wl.xdg.toplevel)
510 {
511 xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel,
512 window->monitor->wl.output);
513 }
514
515 setIdleInhibitor(window, GLFW_TRUE);
516
517 if (window->wl.fallback.decorations)
518 destroyFallbackDecorations(window);
519}
520
521// Remove the window and restore the original video mode
522//
523static void releaseMonitorWayland(_GLFWwindow* window)
524{
525 if (window->wl.libdecor.frame)
526 libdecor_frame_unset_fullscreen(window->wl.libdecor.frame);
527 else if (window->wl.xdg.toplevel)
528 xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
529
530 setIdleInhibitor(window, GLFW_FALSE);
531
532 if (!window->wl.libdecor.frame &&
533 window->wl.xdg.decorationMode != ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE)
534 {
535 if (window->decorated)
536 createFallbackDecorations(window);
537 }
538}
539
540void fractionalScaleHandlePreferredScale(void* userData,
541 struct wp_fractional_scale_v1* fractionalScale,
542 uint32_t numerator)
543{
544 _GLFWwindow* window = userData;
545
546 window->wl.scalingNumerator = numerator;
547 _glfwInputWindowContentScale(window, numerator / 120.f, numerator / 120.f);
548 resizeFramebuffer(window);
549
550 if (window->wl.visible)
551 _glfwInputWindowDamage(window);
552}
553
554const struct wp_fractional_scale_v1_listener fractionalScaleListener =
555{
556 fractionalScaleHandlePreferredScale,
557};
558
559static void xdgToplevelHandleConfigure(void* userData,
560 struct xdg_toplevel* toplevel,
561 int32_t width,
562 int32_t height,
563 struct wl_array* states)
564{
565 _GLFWwindow* window = userData;
566 uint32_t* state;
567
568 window->wl.pending.activated = GLFW_FALSE;
569 window->wl.pending.maximized = GLFW_FALSE;
570 window->wl.pending.fullscreen = GLFW_FALSE;
571
572 wl_array_for_each(state, states)
573 {
574 switch (*state)
575 {
576 case XDG_TOPLEVEL_STATE_MAXIMIZED:
577 window->wl.pending.maximized = GLFW_TRUE;
578 break;
579 case XDG_TOPLEVEL_STATE_FULLSCREEN:
580 window->wl.pending.fullscreen = GLFW_TRUE;
581 break;
582 case XDG_TOPLEVEL_STATE_RESIZING:
583 break;
584 case XDG_TOPLEVEL_STATE_ACTIVATED:
585 window->wl.pending.activated = GLFW_TRUE;
586 break;
587 }
588 }
589
590 if (width && height)
591 {
592 if (window->wl.fallback.decorations)
593 {
594 window->wl.pending.width = _glfw_max(0, width - GLFW_BORDER_SIZE * 2);
595 window->wl.pending.height =
596 _glfw_max(0, height - GLFW_BORDER_SIZE - GLFW_CAPTION_HEIGHT);
597 }
598 else
599 {
600 window->wl.pending.width = width;
601 window->wl.pending.height = height;
602 }
603 }
604 else
605 {
606 window->wl.pending.width = window->wl.width;
607 window->wl.pending.height = window->wl.height;
608 }
609}
610
611static void xdgToplevelHandleClose(void* userData,
612 struct xdg_toplevel* toplevel)
613{
614 _GLFWwindow* window = userData;
615 _glfwInputWindowCloseRequest(window);
616}
617
618static const struct xdg_toplevel_listener xdgToplevelListener =
619{
620 xdgToplevelHandleConfigure,
621 xdgToplevelHandleClose
622};
623
624static void xdgSurfaceHandleConfigure(void* userData,
625 struct xdg_surface* surface,
626 uint32_t serial)
627{
628 _GLFWwindow* window = userData;
629
630 xdg_surface_ack_configure(surface, serial);
631
632 if (window->wl.activated != window->wl.pending.activated)
633 {
634 window->wl.activated = window->wl.pending.activated;
635 if (!window->wl.activated)
636 {
637 if (window->monitor && window->autoIconify)
638 xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
639 }
640 }
641
642 if (window->wl.maximized != window->wl.pending.maximized)
643 {
644 window->wl.maximized = window->wl.pending.maximized;
645 _glfwInputWindowMaximize(window, window->wl.maximized);
646 }
647
648 window->wl.fullscreen = window->wl.pending.fullscreen;
649
650 int width = window->wl.pending.width;
651 int height = window->wl.pending.height;
652
653 if (!window->wl.maximized && !window->wl.fullscreen)
654 {
655 if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
656 {
657 const float aspectRatio = (float) width / (float) height;
658 const float targetRatio = (float) window->numer / (float) window->denom;
659 if (aspectRatio < targetRatio)
660 height = width / targetRatio;
661 else if (aspectRatio > targetRatio)
662 width = height * targetRatio;
663 }
664 }
665
666 if (resizeWindow(window, width, height))
667 {
668 _glfwInputWindowSize(window, window->wl.width, window->wl.height);
669
670 if (window->wl.visible)
671 _glfwInputWindowDamage(window);
672 }
673
674 if (!window->wl.visible)
675 {
676 // Allow the window to be mapped only if it either has no XDG
677 // decorations or they have already received a configure event
678 if (!window->wl.xdg.decoration || window->wl.xdg.decorationMode)
679 {
680 window->wl.visible = GLFW_TRUE;
681 _glfwInputWindowDamage(window);
682 }
683 }
684}
685
686static const struct xdg_surface_listener xdgSurfaceListener =
687{
688 xdgSurfaceHandleConfigure
689};
690
691void libdecorFrameHandleConfigure(struct libdecor_frame* frame,
692 struct libdecor_configuration* config,
693 void* userData)
694{
695 _GLFWwindow* window = userData;
696 int width, height;
697
698 enum libdecor_window_state windowState;
699 GLFWbool fullscreen, activated, maximized;
700
701 if (libdecor_configuration_get_window_state(config, &windowState))
702 {
703 fullscreen = (windowState & LIBDECOR_WINDOW_STATE_FULLSCREEN) != 0;
704 activated = (windowState & LIBDECOR_WINDOW_STATE_ACTIVE) != 0;
705 maximized = (windowState & LIBDECOR_WINDOW_STATE_MAXIMIZED) != 0;
706 }
707 else
708 {
709 fullscreen = window->wl.fullscreen;
710 activated = window->wl.activated;
711 maximized = window->wl.maximized;
712 }
713
714 if (!libdecor_configuration_get_content_size(config, frame, &width, &height))
715 {
716 width = window->wl.width;
717 height = window->wl.height;
718 }
719
720 if (!maximized && !fullscreen)
721 {
722 if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
723 {
724 const float aspectRatio = (float) width / (float) height;
725 const float targetRatio = (float) window->numer / (float) window->denom;
726 if (aspectRatio < targetRatio)
727 height = width / targetRatio;
728 else if (aspectRatio > targetRatio)
729 width = height * targetRatio;
730 }
731 }
732
733 struct libdecor_state* frameState = libdecor_state_new(width, height);
734 libdecor_frame_commit(frame, frameState, config);
735 libdecor_state_free(frameState);
736
737 if (window->wl.activated != activated)
738 {
739 window->wl.activated = activated;
740 if (!window->wl.activated)
741 {
742 if (window->monitor && window->autoIconify)
743 libdecor_frame_set_minimized(window->wl.libdecor.frame);
744 }
745 }
746
747 if (window->wl.maximized != maximized)
748 {
749 window->wl.maximized = maximized;
750 _glfwInputWindowMaximize(window, window->wl.maximized);
751 }
752
753 window->wl.fullscreen = fullscreen;
754
755 GLFWbool damaged = GLFW_FALSE;
756
757 if (!window->wl.visible)
758 {
759 window->wl.visible = GLFW_TRUE;
760 damaged = GLFW_TRUE;
761 }
762
763 if (resizeWindow(window, width, height))
764 {
765 _glfwInputWindowSize(window, window->wl.width, window->wl.height);
766 damaged = GLFW_TRUE;
767 }
768
769 if (damaged)
770 _glfwInputWindowDamage(window);
771 else
772 wl_surface_commit(window->wl.surface);
773}
774
775void libdecorFrameHandleClose(struct libdecor_frame* frame, void* userData)
776{
777 _GLFWwindow* window = userData;
778 _glfwInputWindowCloseRequest(window);
779}
780
781void libdecorFrameHandleCommit(struct libdecor_frame* frame, void* userData)
782{
783 _GLFWwindow* window = userData;
784 wl_surface_commit(window->wl.surface);
785}
786
787void libdecorFrameHandleDismissPopup(struct libdecor_frame* frame,
788 const char* seatName,
789 void* userData)
790{
791}
792
793static const struct libdecor_frame_interface libdecorFrameInterface =
794{
795 libdecorFrameHandleConfigure,
796 libdecorFrameHandleClose,
797 libdecorFrameHandleCommit,
798 libdecorFrameHandleDismissPopup
799};
800
801static GLFWbool createLibdecorFrame(_GLFWwindow* window)
802{
803 // Allow libdecor to finish initialization of itself and its plugin
804 while (!_glfw.wl.libdecor.ready)
805 _glfwWaitEventsWayland();
806
807 window->wl.libdecor.frame = libdecor_decorate(_glfw.wl.libdecor.context,
808 window->wl.surface,
809 &libdecorFrameInterface,
810 window);
811 if (!window->wl.libdecor.frame)
812 {
813 _glfwInputError(GLFW_PLATFORM_ERROR,
814 "Wayland: Failed to create libdecor frame");
815 return GLFW_FALSE;
816 }
817
818 struct libdecor_state* frameState =
819 libdecor_state_new(window->wl.width, window->wl.height);
820 libdecor_frame_commit(window->wl.libdecor.frame, frameState, NULL);
821 libdecor_state_free(frameState);
822
823 if (strlen(window->wl.appId))
824 libdecor_frame_set_app_id(window->wl.libdecor.frame, window->wl.appId);
825
826 libdecor_frame_set_title(window->wl.libdecor.frame, window->title);
827
828 if (window->minwidth != GLFW_DONT_CARE &&
829 window->minheight != GLFW_DONT_CARE)
830 {
831 libdecor_frame_set_min_content_size(window->wl.libdecor.frame,
832 window->minwidth,
833 window->minheight);
834 }
835
836 if (window->maxwidth != GLFW_DONT_CARE &&
837 window->maxheight != GLFW_DONT_CARE)
838 {
839 libdecor_frame_set_max_content_size(window->wl.libdecor.frame,
840 window->maxwidth,
841 window->maxheight);
842 }
843
844 if (!window->resizable)
845 {
846 libdecor_frame_unset_capabilities(window->wl.libdecor.frame,
847 LIBDECOR_ACTION_RESIZE);
848 }
849
850 if (window->monitor)
851 {
852 libdecor_frame_set_fullscreen(window->wl.libdecor.frame,
853 window->monitor->wl.output);
854 setIdleInhibitor(window, GLFW_TRUE);
855 }
856 else
857 {
858 if (window->wl.maximized)
859 libdecor_frame_set_maximized(window->wl.libdecor.frame);
860
861 if (!window->decorated)
862 libdecor_frame_set_visibility(window->wl.libdecor.frame, false);
863
864 setIdleInhibitor(window, GLFW_FALSE);
865 }
866
867 libdecor_frame_map(window->wl.libdecor.frame);
868 wl_display_roundtrip(_glfw.wl.display);
869 return GLFW_TRUE;
870}
871
872static void updateXdgSizeLimits(_GLFWwindow* window)
873{
874 int minwidth, minheight, maxwidth, maxheight;
875
876 if (window->resizable)
877 {
878 if (window->minwidth == GLFW_DONT_CARE || window->minheight == GLFW_DONT_CARE)
879 minwidth = minheight = 0;
880 else
881 {
882 minwidth = window->minwidth;
883 minheight = window->minheight;
884
885 if (window->wl.fallback.decorations)
886 {
887 minwidth += GLFW_BORDER_SIZE * 2;
888 minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
889 }
890 }
891
892 if (window->maxwidth == GLFW_DONT_CARE || window->maxheight == GLFW_DONT_CARE)
893 maxwidth = maxheight = 0;
894 else
895 {
896 maxwidth = window->maxwidth;
897 maxheight = window->maxheight;
898
899 if (window->wl.fallback.decorations)
900 {
901 maxwidth += GLFW_BORDER_SIZE * 2;
902 maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
903 }
904 }
905 }
906 else
907 {
908 minwidth = maxwidth = window->wl.width;
909 minheight = maxheight = window->wl.height;
910 }
911
912 xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight);
913 xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight);
914}
915
916static GLFWbool createXdgShellObjects(_GLFWwindow* window)
917{
918 window->wl.xdg.surface = xdg_wm_base_get_xdg_surface(_glfw.wl.wmBase,
919 window->wl.surface);
920 if (!window->wl.xdg.surface)
921 {
922 _glfwInputError(GLFW_PLATFORM_ERROR,
923 "Wayland: Failed to create xdg-surface for window");
924 return GLFW_FALSE;
925 }
926
927 xdg_surface_add_listener(window->wl.xdg.surface, &xdgSurfaceListener, window);
928
929 window->wl.xdg.toplevel = xdg_surface_get_toplevel(window->wl.xdg.surface);
930 if (!window->wl.xdg.toplevel)
931 {
932 _glfwInputError(GLFW_PLATFORM_ERROR,
933 "Wayland: Failed to create xdg-toplevel for window");
934 return GLFW_FALSE;
935 }
936
937 xdg_toplevel_add_listener(window->wl.xdg.toplevel, &xdgToplevelListener, window);
938
939 if (window->wl.appId)
940 xdg_toplevel_set_app_id(window->wl.xdg.toplevel, window->wl.appId);
941
942 xdg_toplevel_set_title(window->wl.xdg.toplevel, window->title);
943
944 if (window->monitor)
945 {
946 xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel, window->monitor->wl.output);
947 setIdleInhibitor(window, GLFW_TRUE);
948 }
949 else
950 {
951 if (window->wl.maximized)
952 xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
953
954 setIdleInhibitor(window, GLFW_FALSE);
955 }
956
957 if (_glfw.wl.decorationManager)
958 {
959 window->wl.xdg.decoration =
960 zxdg_decoration_manager_v1_get_toplevel_decoration(
961 _glfw.wl.decorationManager, window->wl.xdg.toplevel);
962 zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration,
963 &xdgDecorationListener,
964 window);
965
966 uint32_t mode;
967
968 if (window->decorated)
969 mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
970 else
971 mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
972
973 zxdg_toplevel_decoration_v1_set_mode(window->wl.xdg.decoration, mode);
974 }
975 else
976 {
977 if (window->decorated && !window->monitor)
978 createFallbackDecorations(window);
979 }
980
981 updateXdgSizeLimits(window);
982
983 wl_surface_commit(window->wl.surface);
984 wl_display_roundtrip(_glfw.wl.display);
985 return GLFW_TRUE;
986}
987
988static GLFWbool createShellObjects(_GLFWwindow* window)
989{
990 if (_glfw.wl.libdecor.context)
991 {
992 if (createLibdecorFrame(window))
993 return GLFW_TRUE;
994 }
995
996 return createXdgShellObjects(window);
997}
998
999static void destroyShellObjects(_GLFWwindow* window)
1000{
1001 destroyFallbackDecorations(window);
1002
1003 if (window->wl.libdecor.frame)
1004 libdecor_frame_unref(window->wl.libdecor.frame);
1005
1006 if (window->wl.xdg.decoration)
1007 zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration);
1008
1009 if (window->wl.xdg.toplevel)
1010 xdg_toplevel_destroy(window->wl.xdg.toplevel);
1011
1012 if (window->wl.xdg.surface)
1013 xdg_surface_destroy(window->wl.xdg.surface);
1014
1015 window->wl.libdecor.frame = NULL;
1016 window->wl.xdg.decoration = NULL;
1017 window->wl.xdg.decorationMode = 0;
1018 window->wl.xdg.toplevel = NULL;
1019 window->wl.xdg.surface = NULL;
1020}
1021
1022static GLFWbool createNativeSurface(_GLFWwindow* window,
1023 const _GLFWwndconfig* wndconfig,
1024 const _GLFWfbconfig* fbconfig)
1025{
1026 window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
1027 if (!window->wl.surface)
1028 {
1029 _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to create window surface");
1030 return GLFW_FALSE;
1031 }
1032
1033 wl_proxy_set_tag((struct wl_proxy*) window->wl.surface, &_glfw.wl.tag);
1034 wl_surface_add_listener(window->wl.surface,
1035 &surfaceListener,
1036 window);
1037
1038 window->wl.width = wndconfig->width;
1039 window->wl.height = wndconfig->height;
1040 window->wl.fbWidth = wndconfig->width;
1041 window->wl.fbHeight = wndconfig->height;
1042 window->wl.appId = _glfw_strdup(wndconfig->wl.appId);
1043
1044 window->wl.bufferScale = 1;
1045 window->wl.scalingNumerator = 120;
1046 window->wl.scaleFramebuffer = wndconfig->scaleFramebuffer;
1047
1048 window->wl.maximized = wndconfig->maximized;
1049
1050 window->wl.transparent = fbconfig->transparent;
1051 if (!window->wl.transparent)
1052 setContentAreaOpaque(window);
1053
1054 if (_glfw.wl.fractionalScaleManager)
1055 {
1056 if (window->wl.scaleFramebuffer)
1057 {
1058 window->wl.scalingViewport =
1059 wp_viewporter_get_viewport(_glfw.wl.viewporter, window->wl.surface);
1060
1061 wp_viewport_set_destination(window->wl.scalingViewport,
1062 window->wl.width,
1063 window->wl.height);
1064
1065 window->wl.fractionalScale =
1066 wp_fractional_scale_manager_v1_get_fractional_scale(
1067 _glfw.wl.fractionalScaleManager,
1068 window->wl.surface);
1069
1070 wp_fractional_scale_v1_add_listener(window->wl.fractionalScale,
1071 &fractionalScaleListener,
1072 window);
1073 }
1074 }
1075
1076 return GLFW_TRUE;
1077}
1078
1079static void setCursorImage(_GLFWwindow* window,
1080 _GLFWcursorWayland* cursorWayland)
1081{
1082 struct itimerspec timer = {0};
1083 struct wl_cursor* wlCursor = cursorWayland->cursor;
1084 struct wl_cursor_image* image;
1085 struct wl_buffer* buffer;
1086 struct wl_surface* surface = _glfw.wl.cursorSurface;
1087 int scale = 1;
1088
1089 if (!wlCursor)
1090 buffer = cursorWayland->buffer;
1091 else
1092 {
1093 if (window->wl.bufferScale > 1 && cursorWayland->cursorHiDPI)
1094 {
1095 wlCursor = cursorWayland->cursorHiDPI;
1096 scale = 2;
1097 }
1098
1099 image = wlCursor->images[cursorWayland->currentImage];
1100 buffer = wl_cursor_image_get_buffer(image);
1101 if (!buffer)
1102 return;
1103
1104 timer.it_value.tv_sec = image->delay / 1000;
1105 timer.it_value.tv_nsec = (image->delay % 1000) * 1000000;
1106 timerfd_settime(_glfw.wl.cursorTimerfd, 0, &timer, NULL);
1107
1108 cursorWayland->width = image->width;
1109 cursorWayland->height = image->height;
1110 cursorWayland->xhot = image->hotspot_x;
1111 cursorWayland->yhot = image->hotspot_y;
1112 }
1113
1114 wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
1115 surface,
1116 cursorWayland->xhot / scale,
1117 cursorWayland->yhot / scale);
1118 wl_surface_set_buffer_scale(surface, scale);
1119 wl_surface_attach(surface, buffer, 0, 0);
1120 wl_surface_damage(surface, 0, 0,
1121 cursorWayland->width, cursorWayland->height);
1122 wl_surface_commit(surface);
1123}
1124
1125static void incrementCursorImage(_GLFWwindow* window)
1126{
1127 _GLFWcursor* cursor;
1128
1129 if (!window || !window->wl.hovered)
1130 return;
1131
1132 cursor = window->wl.currentCursor;
1133 if (cursor && cursor->wl.cursor)
1134 {
1135 cursor->wl.currentImage += 1;
1136 cursor->wl.currentImage %= cursor->wl.cursor->image_count;
1137 setCursorImage(window, &cursor->wl);
1138 }
1139}
1140
1141static GLFWbool flushDisplay(void)
1142{
1143 while (wl_display_flush(_glfw.wl.display) == -1)
1144 {
1145 if (errno != EAGAIN)
1146 return GLFW_FALSE;
1147
1148 struct pollfd fd = { wl_display_get_fd(_glfw.wl.display), POLLOUT };
1149
1150 while (poll(&fd, 1, -1) == -1)
1151 {
1152 if (errno != EINTR && errno != EAGAIN)
1153 return GLFW_FALSE;
1154 }
1155 }
1156
1157 return GLFW_TRUE;
1158}
1159
1160static int translateKeyWayland(uint32_t scancode)
1161{
1162 if (scancode < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
1163 return _glfw.wl.keycodes[scancode];
1164
1165 return GLFW_KEY_UNKNOWN;
1166}
1167
1168static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
1169{
1170 if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState)
1171 return sym;
1172 if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym)
1173 != XKB_COMPOSE_FEED_ACCEPTED)
1174 return sym;
1175 switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState))
1176 {
1177 case XKB_COMPOSE_COMPOSED:
1178 return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState);
1179 case XKB_COMPOSE_COMPOSING:
1180 case XKB_COMPOSE_CANCELLED:
1181 return XKB_KEY_NoSymbol;
1182 case XKB_COMPOSE_NOTHING:
1183 default:
1184 return sym;
1185 }
1186}
1187
1188static void inputText(_GLFWwindow* window, uint32_t scancode)
1189{
1190 const xkb_keysym_t* keysyms;
1191 const xkb_keycode_t keycode = scancode + 8;
1192
1193 if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1)
1194 {
1195 const xkb_keysym_t keysym = composeSymbol(keysyms[0]);
1196 const uint32_t codepoint = _glfwKeySym2Unicode(keysym);
1197 if (codepoint != GLFW_INVALID_CODEPOINT)
1198 {
1199 const int mods = _glfw.wl.xkb.modifiers;
1200 const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
1201 _glfwInputChar(window, codepoint, mods, plain);
1202 }
1203 }
1204}
1205
1206static void handleEvents(double* timeout)
1207{
1208#if defined(GLFW_BUILD_LINUX_JOYSTICK)
1209 if (_glfw.joysticksInitialized)
1210 _glfwDetectJoystickConnectionLinux();
1211#endif
1212
1213 GLFWbool event = GLFW_FALSE;
1214 enum { DISPLAY_FD, KEYREPEAT_FD, CURSOR_FD, LIBDECOR_FD };
1215 struct pollfd fds[] =
1216 {
1217 [DISPLAY_FD] = { wl_display_get_fd(_glfw.wl.display), POLLIN },
1218 [KEYREPEAT_FD] = { _glfw.wl.keyRepeatTimerfd, POLLIN },
1219 [CURSOR_FD] = { _glfw.wl.cursorTimerfd, POLLIN },
1220 [LIBDECOR_FD] = { -1, POLLIN }
1221 };
1222
1223 if (_glfw.wl.libdecor.context)
1224 fds[LIBDECOR_FD].fd = libdecor_get_fd(_glfw.wl.libdecor.context);
1225
1226 while (!event)
1227 {
1228 while (wl_display_prepare_read(_glfw.wl.display) != 0)
1229 {
1230 if (wl_display_dispatch_pending(_glfw.wl.display) > 0)
1231 return;
1232 }
1233
1234 // If an error other than EAGAIN happens, we have likely been disconnected
1235 // from the Wayland session; try to handle that the best we can.
1236 if (!flushDisplay())
1237 {
1238 wl_display_cancel_read(_glfw.wl.display);
1239
1240 _GLFWwindow* window = _glfw.windowListHead;
1241 while (window)
1242 {
1243 _glfwInputWindowCloseRequest(window);
1244 window = window->next;
1245 }
1246
1247 return;
1248 }
1249
1250 if (!_glfwPollPOSIX(fds, sizeof(fds) / sizeof(fds[0]), timeout))
1251 {
1252 wl_display_cancel_read(_glfw.wl.display);
1253 return;
1254 }
1255
1256 if (fds[DISPLAY_FD].revents & POLLIN)
1257 {
1258 wl_display_read_events(_glfw.wl.display);
1259 if (wl_display_dispatch_pending(_glfw.wl.display) > 0)
1260 event = GLFW_TRUE;
1261 }
1262 else
1263 wl_display_cancel_read(_glfw.wl.display);
1264
1265 if (fds[KEYREPEAT_FD].revents & POLLIN)
1266 {
1267 uint64_t repeats;
1268
1269 if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8)
1270 {
1271 for (uint64_t i = 0; i < repeats; i++)
1272 {
1273 _glfwInputKey(_glfw.wl.keyboardFocus,
1274 translateKeyWayland(_glfw.wl.keyRepeatScancode),
1275 _glfw.wl.keyRepeatScancode,
1276 GLFW_PRESS,
1277 _glfw.wl.xkb.modifiers);
1278 inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode);
1279 }
1280
1281 event = GLFW_TRUE;
1282 }
1283 }
1284
1285 if (fds[CURSOR_FD].revents & POLLIN)
1286 {
1287 uint64_t repeats;
1288
1289 if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8)
1290 incrementCursorImage(_glfw.wl.pointerFocus);
1291 }
1292
1293 if (fds[LIBDECOR_FD].revents & POLLIN)
1294 {
1295 if (libdecor_dispatch(_glfw.wl.libdecor.context, 0) > 0)
1296 event = GLFW_TRUE;
1297 }
1298 }
1299}
1300
1301// Reads the specified data offer as the specified MIME type
1302//
1303static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mimeType)
1304{
1305 int fds[2];
1306
1307 if (pipe2(fds, O_CLOEXEC) == -1)
1308 {
1309 _glfwInputError(GLFW_PLATFORM_ERROR,
1310 "Wayland: Failed to create pipe for data offer: %s",
1311 strerror(errno));
1312 return NULL;
1313 }
1314
1315 wl_data_offer_receive(offer, mimeType, fds[1]);
1316 flushDisplay();
1317 close(fds[1]);
1318
1319 char* string = NULL;
1320 size_t size = 0;
1321 size_t length = 0;
1322
1323 for (;;)
1324 {
1325 const size_t readSize = 4096;
1326 const size_t requiredSize = length + readSize + 1;
1327 if (requiredSize > size)
1328 {
1329 char* longer = _glfw_realloc(string, requiredSize);
1330 if (!longer)
1331 {
1332 _glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
1333 close(fds[0]);
1334 return NULL;
1335 }
1336
1337 string = longer;
1338 size = requiredSize;
1339 }
1340
1341 const ssize_t result = read(fds[0], string + length, readSize);
1342 if (result == 0)
1343 break;
1344 else if (result == -1)
1345 {
1346 if (errno == EINTR)
1347 continue;
1348
1349 _glfwInputError(GLFW_PLATFORM_ERROR,
1350 "Wayland: Failed to read from data offer pipe: %s",
1351 strerror(errno));
1352 close(fds[0]);
1353 return NULL;
1354 }
1355
1356 length += result;
1357 }
1358
1359 close(fds[0]);
1360
1361 string[length] = '\0';
1362 return string;
1363}
1364
1365static void pointerHandleEnter(void* userData,
1366 struct wl_pointer* pointer,
1367 uint32_t serial,
1368 struct wl_surface* surface,
1369 wl_fixed_t sx,
1370 wl_fixed_t sy)
1371{
1372 // Happens in the case we just destroyed the surface.
1373 if (!surface)
1374 return;
1375
1376 if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag)
1377 return;
1378
1379 _GLFWwindow* window = wl_surface_get_user_data(surface);
1380
1381 _glfw.wl.serial = serial;
1382 _glfw.wl.pointerEnterSerial = serial;
1383 _glfw.wl.pointerFocus = window;
1384
1385 if (surface == window->wl.surface)
1386 {
1387 window->wl.hovered = GLFW_TRUE;
1388 _glfwSetCursorWayland(window, window->wl.currentCursor);
1389 _glfwInputCursorEnter(window, GLFW_TRUE);
1390 }
1391 else
1392 {
1393 if (window->wl.fallback.decorations)
1394 window->wl.fallback.focus = surface;
1395 }
1396}
1397
1398static void pointerHandleLeave(void* userData,
1399 struct wl_pointer* pointer,
1400 uint32_t serial,
1401 struct wl_surface* surface)
1402{
1403 if (!surface)
1404 return;
1405
1406 if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag)
1407 return;
1408
1409 _GLFWwindow* window = _glfw.wl.pointerFocus;
1410 if (!window)
1411 return;
1412
1413 _glfw.wl.serial = serial;
1414 _glfw.wl.pointerFocus = NULL;
1415 _glfw.wl.cursorPreviousName = NULL;
1416
1417 if (window->wl.hovered)
1418 {
1419 window->wl.hovered = GLFW_FALSE;
1420 _glfwInputCursorEnter(window, GLFW_FALSE);
1421 }
1422 else
1423 {
1424 if (window->wl.fallback.decorations)
1425 window->wl.fallback.focus = NULL;
1426 }
1427}
1428
1429static void pointerHandleMotion(void* userData,
1430 struct wl_pointer* pointer,
1431 uint32_t time,
1432 wl_fixed_t sx,
1433 wl_fixed_t sy)
1434{
1435 _GLFWwindow* window = _glfw.wl.pointerFocus;
1436 if (!window)
1437 return;
1438
1439 if (window->cursorMode == GLFW_CURSOR_DISABLED)
1440 return;
1441
1442 const double xpos = wl_fixed_to_double(sx);
1443 const double ypos = wl_fixed_to_double(sy);
1444 window->wl.cursorPosX = xpos;
1445 window->wl.cursorPosY = ypos;
1446
1447 if (window->wl.hovered)
1448 {
1449 _glfw.wl.cursorPreviousName = NULL;
1450 _glfwInputCursorPos(window, xpos, ypos);
1451 return;
1452 }
1453
1454 if (window->wl.fallback.decorations)
1455 {
1456 const char* cursorName = "left_ptr";
1457
1458 if (window->resizable)
1459 {
1460 if (window->wl.fallback.focus == window->wl.fallback.top.surface)
1461 {
1462 if (ypos < GLFW_BORDER_SIZE)
1463 cursorName = "n-resize";
1464 }
1465 else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
1466 {
1467 if (ypos < GLFW_BORDER_SIZE)
1468 cursorName = "nw-resize";
1469 else
1470 cursorName = "w-resize";
1471 }
1472 else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
1473 {
1474 if (ypos < GLFW_BORDER_SIZE)
1475 cursorName = "ne-resize";
1476 else
1477 cursorName = "e-resize";
1478 }
1479 else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
1480 {
1481 if (xpos < GLFW_BORDER_SIZE)
1482 cursorName = "sw-resize";
1483 else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
1484 cursorName = "se-resize";
1485 else
1486 cursorName = "s-resize";
1487 }
1488 }
1489
1490 if (_glfw.wl.cursorPreviousName != cursorName)
1491 {
1492 struct wl_surface* surface = _glfw.wl.cursorSurface;
1493 struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
1494 int scale = 1;
1495
1496 if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI)
1497 {
1498 // We only support up to scale=2 for now, since libwayland-cursor
1499 // requires us to load a different theme for each size.
1500 scale = 2;
1501 theme = _glfw.wl.cursorThemeHiDPI;
1502 }
1503
1504 struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName);
1505 if (!cursor)
1506 return;
1507
1508 // TODO: handle animated cursors too.
1509 struct wl_cursor_image* image = cursor->images[0];
1510 if (!image)
1511 return;
1512
1513 struct wl_buffer* buffer = wl_cursor_image_get_buffer(image);
1514 if (!buffer)
1515 return;
1516
1517 wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
1518 surface,
1519 image->hotspot_x / scale,
1520 image->hotspot_y / scale);
1521 wl_surface_set_buffer_scale(surface, scale);
1522 wl_surface_attach(surface, buffer, 0, 0);
1523 wl_surface_damage(surface, 0, 0, image->width, image->height);
1524 wl_surface_commit(surface);
1525
1526 _glfw.wl.cursorPreviousName = cursorName;
1527 }
1528 }
1529}
1530
1531static void pointerHandleButton(void* userData,
1532 struct wl_pointer* pointer,
1533 uint32_t serial,
1534 uint32_t time,
1535 uint32_t button,
1536 uint32_t state)
1537{
1538 _GLFWwindow* window = _glfw.wl.pointerFocus;
1539 if (!window)
1540 return;
1541
1542 if (window->wl.hovered)
1543 {
1544 _glfw.wl.serial = serial;
1545
1546 _glfwInputMouseClick(window,
1547 button - BTN_LEFT,
1548 state == WL_POINTER_BUTTON_STATE_PRESSED,
1549 _glfw.wl.xkb.modifiers);
1550 return;
1551 }
1552
1553 if (window->wl.fallback.decorations)
1554 {
1555 if (button == BTN_LEFT)
1556 {
1557 uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
1558
1559 if (window->wl.fallback.focus == window->wl.fallback.top.surface)
1560 {
1561 if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
1562 edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
1563 else
1564 xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
1565 }
1566 else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
1567 {
1568 if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
1569 edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
1570 else
1571 edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
1572 }
1573 else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
1574 {
1575 if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
1576 edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
1577 else
1578 edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
1579 }
1580 else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
1581 {
1582 if (window->wl.cursorPosX < GLFW_BORDER_SIZE)
1583 edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
1584 else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE)
1585 edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
1586 else
1587 edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
1588 }
1589
1590 if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
1591 {
1592 xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
1593 serial, edges);
1594 }
1595 }
1596 else if (button == BTN_RIGHT)
1597 {
1598 if (window->wl.xdg.toplevel)
1599 {
1600 xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
1601 _glfw.wl.seat, serial,
1602 window->wl.cursorPosX,
1603 window->wl.cursorPosY);
1604 }
1605 }
1606 }
1607}
1608
1609static void pointerHandleAxis(void* userData,
1610 struct wl_pointer* pointer,
1611 uint32_t time,
1612 uint32_t axis,
1613 wl_fixed_t value)
1614{
1615 _GLFWwindow* window = _glfw.wl.pointerFocus;
1616 if (!window)
1617 return;
1618
1619 // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
1620 if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
1621 _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
1622 else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
1623 _glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
1624}
1625
1626static const struct wl_pointer_listener pointerListener =
1627{
1628 pointerHandleEnter,
1629 pointerHandleLeave,
1630 pointerHandleMotion,
1631 pointerHandleButton,
1632 pointerHandleAxis,
1633};
1634
1635static void keyboardHandleKeymap(void* userData,
1636 struct wl_keyboard* keyboard,
1637 uint32_t format,
1638 int fd,
1639 uint32_t size)
1640{
1641 struct xkb_keymap* keymap;
1642 struct xkb_state* state;
1643 struct xkb_compose_table* composeTable;
1644 struct xkb_compose_state* composeState;
1645
1646 char* mapStr;
1647 const char* locale;
1648
1649 if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
1650 {
1651 close(fd);
1652 return;
1653 }
1654
1655 mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
1656 if (mapStr == MAP_FAILED) {
1657 close(fd);
1658 return;
1659 }
1660
1661 keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context,
1662 mapStr,
1663 XKB_KEYMAP_FORMAT_TEXT_V1,
1664 0);
1665 munmap(mapStr, size);
1666 close(fd);
1667
1668 if (!keymap)
1669 {
1670 _glfwInputError(GLFW_PLATFORM_ERROR,
1671 "Wayland: Failed to compile keymap");
1672 return;
1673 }
1674
1675 state = xkb_state_new(keymap);
1676 if (!state)
1677 {
1678 _glfwInputError(GLFW_PLATFORM_ERROR,
1679 "Wayland: Failed to create XKB state");
1680 xkb_keymap_unref(keymap);
1681 return;
1682 }
1683
1684 // Look up the preferred locale, falling back to "C" as default.
1685 locale = getenv("LC_ALL");
1686 if (!locale)
1687 locale = getenv("LC_CTYPE");
1688 if (!locale)
1689 locale = getenv("LANG");
1690 if (!locale)
1691 locale = "C";
1692
1693 composeTable =
1694 xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale,
1695 XKB_COMPOSE_COMPILE_NO_FLAGS);
1696 if (composeTable)
1697 {
1698 composeState =
1699 xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
1700 xkb_compose_table_unref(composeTable);
1701 if (composeState)
1702 _glfw.wl.xkb.composeState = composeState;
1703 else
1704 _glfwInputError(GLFW_PLATFORM_ERROR,
1705 "Wayland: Failed to create XKB compose state");
1706 }
1707 else
1708 {
1709 _glfwInputError(GLFW_PLATFORM_ERROR,
1710 "Wayland: Failed to create XKB compose table");
1711 }
1712
1713 xkb_keymap_unref(_glfw.wl.xkb.keymap);
1714 xkb_state_unref(_glfw.wl.xkb.state);
1715 _glfw.wl.xkb.keymap = keymap;
1716 _glfw.wl.xkb.state = state;
1717
1718 _glfw.wl.xkb.controlIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
1719 _glfw.wl.xkb.altIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
1720 _glfw.wl.xkb.shiftIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
1721 _glfw.wl.xkb.superIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
1722 _glfw.wl.xkb.capsLockIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
1723 _glfw.wl.xkb.numLockIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
1724}
1725
1726static void keyboardHandleEnter(void* userData,
1727 struct wl_keyboard* keyboard,
1728 uint32_t serial,
1729 struct wl_surface* surface,
1730 struct wl_array* keys)
1731{
1732 // Happens in the case we just destroyed the surface.
1733 if (!surface)
1734 return;
1735
1736 if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag)
1737 return;
1738
1739 _GLFWwindow* window = wl_surface_get_user_data(surface);
1740 if (surface != window->wl.surface)
1741 return;
1742
1743 _glfw.wl.serial = serial;
1744 _glfw.wl.keyboardFocus = window;
1745 _glfwInputWindowFocus(window, GLFW_TRUE);
1746}
1747
1748static void keyboardHandleLeave(void* userData,
1749 struct wl_keyboard* keyboard,
1750 uint32_t serial,
1751 struct wl_surface* surface)
1752{
1753 _GLFWwindow* window = _glfw.wl.keyboardFocus;
1754
1755 if (!window)
1756 return;
1757
1758 struct itimerspec timer = {0};
1759 timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
1760
1761 _glfw.wl.serial = serial;
1762 _glfw.wl.keyboardFocus = NULL;
1763 _glfwInputWindowFocus(window, GLFW_FALSE);
1764}
1765
1766static void keyboardHandleKey(void* userData,
1767 struct wl_keyboard* keyboard,
1768 uint32_t serial,
1769 uint32_t time,
1770 uint32_t scancode,
1771 uint32_t state)
1772{
1773 _GLFWwindow* window = _glfw.wl.keyboardFocus;
1774 if (!window)
1775 return;
1776
1777 const int key = translateKeyWayland(scancode);
1778 const int action =
1779 state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE;
1780
1781 _glfw.wl.serial = serial;
1782
1783 struct itimerspec timer = {0};
1784
1785 if (action == GLFW_PRESS)
1786 {
1787 const xkb_keycode_t keycode = scancode + 8;
1788
1789 if (xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, keycode) &&
1790 _glfw.wl.keyRepeatRate > 0)
1791 {
1792 _glfw.wl.keyRepeatScancode = scancode;
1793 if (_glfw.wl.keyRepeatRate > 1)
1794 timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyRepeatRate;
1795 else
1796 timer.it_interval.tv_sec = 1;
1797
1798 timer.it_value.tv_sec = _glfw.wl.keyRepeatDelay / 1000;
1799 timer.it_value.tv_nsec = (_glfw.wl.keyRepeatDelay % 1000) * 1000000;
1800 }
1801 }
1802
1803 timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
1804
1805 _glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers);
1806
1807 if (action == GLFW_PRESS)
1808 inputText(window, scancode);
1809}
1810
1811static void keyboardHandleModifiers(void* userData,
1812 struct wl_keyboard* keyboard,
1813 uint32_t serial,
1814 uint32_t modsDepressed,
1815 uint32_t modsLatched,
1816 uint32_t modsLocked,
1817 uint32_t group)
1818{
1819 _glfw.wl.serial = serial;
1820
1821 if (!_glfw.wl.xkb.keymap)
1822 return;
1823
1824 xkb_state_update_mask(_glfw.wl.xkb.state,
1825 modsDepressed,
1826 modsLatched,
1827 modsLocked,
1828 0,
1829 0,
1830 group);
1831
1832 _glfw.wl.xkb.modifiers = 0;
1833
1834 struct
1835 {
1836 xkb_mod_index_t index;
1837 unsigned int bit;
1838 } modifiers[] =
1839 {
1840 { _glfw.wl.xkb.controlIndex, GLFW_MOD_CONTROL },
1841 { _glfw.wl.xkb.altIndex, GLFW_MOD_ALT },
1842 { _glfw.wl.xkb.shiftIndex, GLFW_MOD_SHIFT },
1843 { _glfw.wl.xkb.superIndex, GLFW_MOD_SUPER },
1844 { _glfw.wl.xkb.capsLockIndex, GLFW_MOD_CAPS_LOCK },
1845 { _glfw.wl.xkb.numLockIndex, GLFW_MOD_NUM_LOCK }
1846 };
1847
1848 for (size_t i = 0; i < sizeof(modifiers) / sizeof(modifiers[0]); i++)
1849 {
1850 if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
1851 modifiers[i].index,
1852 XKB_STATE_MODS_EFFECTIVE) == 1)
1853 {
1854 _glfw.wl.xkb.modifiers |= modifiers[i].bit;
1855 }
1856 }
1857}
1858
1859static void keyboardHandleRepeatInfo(void* userData,
1860 struct wl_keyboard* keyboard,
1861 int32_t rate,
1862 int32_t delay)
1863{
1864 if (keyboard != _glfw.wl.keyboard)
1865 return;
1866
1867 _glfw.wl.keyRepeatRate = rate;
1868 _glfw.wl.keyRepeatDelay = delay;
1869}
1870
1871static const struct wl_keyboard_listener keyboardListener =
1872{
1873 keyboardHandleKeymap,
1874 keyboardHandleEnter,
1875 keyboardHandleLeave,
1876 keyboardHandleKey,
1877 keyboardHandleModifiers,
1878 keyboardHandleRepeatInfo,
1879};
1880
1881static void seatHandleCapabilities(void* userData,
1882 struct wl_seat* seat,
1883 enum wl_seat_capability caps)
1884{
1885 if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer)
1886 {
1887 _glfw.wl.pointer = wl_seat_get_pointer(seat);
1888 wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);
1889 }
1890 else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
1891 {
1892 wl_pointer_destroy(_glfw.wl.pointer);
1893 _glfw.wl.pointer = NULL;
1894 }
1895
1896 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard)
1897 {
1898 _glfw.wl.keyboard = wl_seat_get_keyboard(seat);
1899 wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL);
1900 }
1901 else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)
1902 {
1903 wl_keyboard_destroy(_glfw.wl.keyboard);
1904 _glfw.wl.keyboard = NULL;
1905 }
1906}
1907
1908static void seatHandleName(void* userData,
1909 struct wl_seat* seat,
1910 const char* name)
1911{
1912}
1913
1914static const struct wl_seat_listener seatListener =
1915{
1916 seatHandleCapabilities,
1917 seatHandleName,
1918};
1919
1920static void dataOfferHandleOffer(void* userData,
1921 struct wl_data_offer* offer,
1922 const char* mimeType)
1923{
1924 for (unsigned int i = 0; i < _glfw.wl.offerCount; i++)
1925 {
1926 if (_glfw.wl.offers[i].offer == offer)
1927 {
1928 if (strcmp(mimeType, "text/plain;charset=utf-8") == 0)
1929 _glfw.wl.offers[i].text_plain_utf8 = GLFW_TRUE;
1930 else if (strcmp(mimeType, "text/uri-list") == 0)
1931 _glfw.wl.offers[i].text_uri_list = GLFW_TRUE;
1932
1933 break;
1934 }
1935 }
1936}
1937
1938static const struct wl_data_offer_listener dataOfferListener =
1939{
1940 dataOfferHandleOffer
1941};
1942
1943static void dataDeviceHandleDataOffer(void* userData,
1944 struct wl_data_device* device,
1945 struct wl_data_offer* offer)
1946{
1947 _GLFWofferWayland* offers =
1948 _glfw_realloc(_glfw.wl.offers,
1949 sizeof(_GLFWofferWayland) * (_glfw.wl.offerCount + 1));
1950 if (!offers)
1951 {
1952 _glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
1953 return;
1954 }
1955
1956 _glfw.wl.offers = offers;
1957 _glfw.wl.offerCount++;
1958
1959 _glfw.wl.offers[_glfw.wl.offerCount - 1] = (_GLFWofferWayland) { offer };
1960 wl_data_offer_add_listener(offer, &dataOfferListener, NULL);
1961}
1962
1963static void dataDeviceHandleEnter(void* userData,
1964 struct wl_data_device* device,
1965 uint32_t serial,
1966 struct wl_surface* surface,
1967 wl_fixed_t x,
1968 wl_fixed_t y,
1969 struct wl_data_offer* offer)
1970{
1971 if (_glfw.wl.dragOffer)
1972 {
1973 wl_data_offer_destroy(_glfw.wl.dragOffer);
1974 _glfw.wl.dragOffer = NULL;
1975 _glfw.wl.dragFocus = NULL;
1976 }
1977
1978 for (unsigned int i = 0; i < _glfw.wl.offerCount; i++)
1979 {
1980 if (_glfw.wl.offers[i].offer == offer)
1981 {
1982 _GLFWwindow* window = NULL;
1983
1984 if (surface)
1985 {
1986 if (wl_proxy_get_tag((struct wl_proxy*) surface) == &_glfw.wl.tag)
1987 window = wl_surface_get_user_data(surface);
1988 }
1989
1990 if (surface == window->wl.surface && _glfw.wl.offers[i].text_uri_list)
1991 {
1992 _glfw.wl.dragOffer = offer;
1993 _glfw.wl.dragFocus = window;
1994 _glfw.wl.dragSerial = serial;
1995 }
1996
1997 _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1];
1998 _glfw.wl.offerCount--;
1999 break;
2000 }
2001 }
2002
2003 if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag)
2004 return;
2005
2006 if (_glfw.wl.dragOffer)
2007 wl_data_offer_accept(offer, serial, "text/uri-list");
2008 else
2009 {
2010 wl_data_offer_accept(offer, serial, NULL);
2011 wl_data_offer_destroy(offer);
2012 }
2013}
2014
2015static void dataDeviceHandleLeave(void* userData,
2016 struct wl_data_device* device)
2017{
2018 if (_glfw.wl.dragOffer)
2019 {
2020 wl_data_offer_destroy(_glfw.wl.dragOffer);
2021 _glfw.wl.dragOffer = NULL;
2022 _glfw.wl.dragFocus = NULL;
2023 }
2024}
2025
2026static void dataDeviceHandleMotion(void* userData,
2027 struct wl_data_device* device,
2028 uint32_t time,
2029 wl_fixed_t x,
2030 wl_fixed_t y)
2031{
2032}
2033
2034static void dataDeviceHandleDrop(void* userData,
2035 struct wl_data_device* device)
2036{
2037 if (!_glfw.wl.dragOffer)
2038 return;
2039
2040 char* string = readDataOfferAsString(_glfw.wl.dragOffer, "text/uri-list");
2041 if (string)
2042 {
2043 int count;
2044 char** paths = _glfwParseUriList(string, &count);
2045 if (paths)
2046 _glfwInputDrop(_glfw.wl.dragFocus, count, (const char**) paths);
2047
2048 for (int i = 0; i < count; i++)
2049 _glfw_free(paths[i]);
2050
2051 _glfw_free(paths);
2052 }
2053
2054 _glfw_free(string);
2055}
2056
2057static void dataDeviceHandleSelection(void* userData,
2058 struct wl_data_device* device,
2059 struct wl_data_offer* offer)
2060{
2061 if (_glfw.wl.selectionOffer)
2062 {
2063 wl_data_offer_destroy(_glfw.wl.selectionOffer);
2064 _glfw.wl.selectionOffer = NULL;
2065 }
2066
2067 for (unsigned int i = 0; i < _glfw.wl.offerCount; i++)
2068 {
2069 if (_glfw.wl.offers[i].offer == offer)
2070 {
2071 if (_glfw.wl.offers[i].text_plain_utf8)
2072 _glfw.wl.selectionOffer = offer;
2073 else
2074 wl_data_offer_destroy(offer);
2075
2076 _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1];
2077 _glfw.wl.offerCount--;
2078 break;
2079 }
2080 }
2081}
2082
2083const struct wl_data_device_listener dataDeviceListener =
2084{
2085 dataDeviceHandleDataOffer,
2086 dataDeviceHandleEnter,
2087 dataDeviceHandleLeave,
2088 dataDeviceHandleMotion,
2089 dataDeviceHandleDrop,
2090 dataDeviceHandleSelection,
2091};
2092
2093static void xdgActivationHandleDone(void* userData,
2094 struct xdg_activation_token_v1* activationToken,
2095 const char* token)
2096{
2097 _GLFWwindow* window = userData;
2098
2099 if (activationToken != window->wl.activationToken)
2100 return;
2101
2102 xdg_activation_v1_activate(_glfw.wl.activationManager, token, window->wl.surface);
2103 xdg_activation_token_v1_destroy(window->wl.activationToken);
2104 window->wl.activationToken = NULL;
2105}
2106
2107static const struct xdg_activation_token_v1_listener xdgActivationListener =
2108{
2109 xdgActivationHandleDone
2110};
2111
2112void _glfwAddSeatListenerWayland(struct wl_seat* seat)
2113{
2114 wl_seat_add_listener(seat, &seatListener, NULL);
2115}
2116
2117void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device)
2118{
2119 wl_data_device_add_listener(device, &dataDeviceListener, NULL);
2120}
2121
2122
2123//////////////////////////////////////////////////////////////////////////
2124////// GLFW platform API //////
2125//////////////////////////////////////////////////////////////////////////
2126
2127GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,
2128 const _GLFWwndconfig* wndconfig,
2129 const _GLFWctxconfig* ctxconfig,
2130 const _GLFWfbconfig* fbconfig)
2131{
2132 if (!createNativeSurface(window, wndconfig, fbconfig))
2133 return GLFW_FALSE;
2134
2135 if (ctxconfig->client != GLFW_NO_API)
2136 {
2137 if (ctxconfig->source == GLFW_EGL_CONTEXT_API ||
2138 ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
2139 {
2140 window->wl.egl.window = wl_egl_window_create(window->wl.surface,
2141 window->wl.fbWidth,
2142 window->wl.fbHeight);
2143 if (!window->wl.egl.window)
2144 {
2145 _glfwInputError(GLFW_PLATFORM_ERROR,
2146 "Wayland: Failed to create EGL window");
2147 return GLFW_FALSE;
2148 }
2149
2150 if (!_glfwInitEGL())
2151 return GLFW_FALSE;
2152 if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
2153 return GLFW_FALSE;
2154 }
2155 else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
2156 {
2157 if (!_glfwInitOSMesa())
2158 return GLFW_FALSE;
2159 if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
2160 return GLFW_FALSE;
2161 }
2162
2163 if (!_glfwRefreshContextAttribs(window, ctxconfig))
2164 return GLFW_FALSE;
2165 }
2166
2167 if (wndconfig->mousePassthrough)
2168 _glfwSetWindowMousePassthroughWayland(window, GLFW_TRUE);
2169
2170 if (window->monitor || wndconfig->visible)
2171 {
2172 if (!createShellObjects(window))
2173 return GLFW_FALSE;
2174 }
2175
2176 return GLFW_TRUE;
2177}
2178
2179void _glfwDestroyWindowWayland(_GLFWwindow* window)
2180{
2181 if (window == _glfw.wl.pointerFocus)
2182 _glfw.wl.pointerFocus = NULL;
2183
2184 if (window == _glfw.wl.keyboardFocus)
2185 _glfw.wl.keyboardFocus = NULL;
2186
2187 if (window->wl.activationToken)
2188 xdg_activation_token_v1_destroy(window->wl.activationToken);
2189
2190 if (window->wl.idleInhibitor)
2191 zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
2192
2193 if (window->wl.relativePointer)
2194 zwp_relative_pointer_v1_destroy(window->wl.relativePointer);
2195
2196 if (window->wl.lockedPointer)
2197 zwp_locked_pointer_v1_destroy(window->wl.lockedPointer);
2198
2199 if (window->wl.confinedPointer)
2200 zwp_confined_pointer_v1_destroy(window->wl.confinedPointer);
2201
2202 if (window->context.destroy)
2203 window->context.destroy(window);
2204
2205 destroyShellObjects(window);
2206
2207 if (window->wl.fallback.buffer)
2208 wl_buffer_destroy(window->wl.fallback.buffer);
2209
2210 if (window->wl.egl.window)
2211 wl_egl_window_destroy(window->wl.egl.window);
2212
2213 if (window->wl.surface)
2214 wl_surface_destroy(window->wl.surface);
2215
2216 _glfw_free(window->wl.appId);
2217 _glfw_free(window->wl.outputScales);
2218}
2219
2220void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title)
2221{
2222 if (window->wl.libdecor.frame)
2223 libdecor_frame_set_title(window->wl.libdecor.frame, title);
2224 else if (window->wl.xdg.toplevel)
2225 xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
2226}
2227
2228void _glfwSetWindowIconWayland(_GLFWwindow* window,
2229 int count, const GLFWimage* images)
2230{
2231 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
2232 "Wayland: The platform does not support setting the window icon");
2233}
2234
2235void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos)
2236{
2237 // A Wayland client is not aware of its position, so just warn and leave it
2238 // as (0, 0)
2239
2240 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
2241 "Wayland: The platform does not provide the window position");
2242}
2243
2244void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos)
2245{
2246 // A Wayland client can not set its position, so just warn
2247
2248 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
2249 "Wayland: The platform does not support setting the window position");
2250}
2251
2252void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height)
2253{
2254 if (width)
2255 *width = window->wl.width;
2256 if (height)
2257 *height = window->wl.height;
2258}
2259
2260void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height)
2261{
2262 if (window->monitor)
2263 {
2264 // Video mode setting is not available on Wayland
2265 }
2266 else
2267 {
2268 if (!resizeWindow(window, width, height))
2269 return;
2270
2271 if (window->wl.libdecor.frame)
2272 {
2273 struct libdecor_state* frameState =
2274 libdecor_state_new(window->wl.width, window->wl.height);
2275 libdecor_frame_commit(window->wl.libdecor.frame, frameState, NULL);
2276 libdecor_state_free(frameState);
2277 }
2278
2279 if (window->wl.visible)
2280 _glfwInputWindowDamage(window);
2281 }
2282}
2283
2284void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window,
2285 int minwidth, int minheight,
2286 int maxwidth, int maxheight)
2287{
2288 if (window->wl.libdecor.frame)
2289 {
2290 if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
2291 minwidth = minheight = 0;
2292
2293 if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
2294 maxwidth = maxheight = 0;
2295
2296 libdecor_frame_set_min_content_size(window->wl.libdecor.frame,
2297 minwidth, minheight);
2298 libdecor_frame_set_max_content_size(window->wl.libdecor.frame,
2299 maxwidth, maxheight);
2300 }
2301 else if (window->wl.xdg.toplevel)
2302 updateXdgSizeLimits(window);
2303}
2304
2305void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom)
2306{
2307 if (window->wl.maximized || window->wl.fullscreen)
2308 return;
2309
2310 int width = window->wl.width, height = window->wl.height;
2311
2312 if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
2313 {
2314 const float aspectRatio = (float) width / (float) height;
2315 const float targetRatio = (float) numer / (float) denom;
2316 if (aspectRatio < targetRatio)
2317 height /= targetRatio;
2318 else if (aspectRatio > targetRatio)
2319 width *= targetRatio;
2320 }
2321
2322 if (resizeWindow(window, width, height))
2323 {
2324 if (window->wl.libdecor.frame)
2325 {
2326 struct libdecor_state* frameState =
2327 libdecor_state_new(window->wl.width, window->wl.height);
2328 libdecor_frame_commit(window->wl.libdecor.frame, frameState, NULL);
2329 libdecor_state_free(frameState);
2330 }
2331
2332 _glfwInputWindowSize(window, window->wl.width, window->wl.height);
2333
2334 if (window->wl.visible)
2335 _glfwInputWindowDamage(window);
2336 }
2337}
2338
2339void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height)
2340{
2341 if (width)
2342 *width = window->wl.fbWidth;
2343 if (height)
2344 *height = window->wl.fbHeight;
2345}
2346
2347void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window,
2348 int* left, int* top,
2349 int* right, int* bottom)
2350{
2351 if (window->wl.fallback.decorations)
2352 {
2353 if (top)
2354 *top = GLFW_CAPTION_HEIGHT;
2355 if (left)
2356 *left = GLFW_BORDER_SIZE;
2357 if (right)
2358 *right = GLFW_BORDER_SIZE;
2359 if (bottom)
2360 *bottom = GLFW_BORDER_SIZE;
2361 }
2362}
2363
2364void _glfwGetWindowContentScaleWayland(_GLFWwindow* window,
2365 float* xscale, float* yscale)
2366{
2367 if (window->wl.fractionalScale)
2368 {
2369 if (xscale)
2370 *xscale = (float) window->wl.scalingNumerator / 120.f;
2371 if (yscale)
2372 *yscale = (float) window->wl.scalingNumerator / 120.f;
2373 }
2374 else
2375 {
2376 if (xscale)
2377 *xscale = (float) window->wl.bufferScale;
2378 if (yscale)
2379 *yscale = (float) window->wl.bufferScale;
2380 }
2381}
2382
2383void _glfwIconifyWindowWayland(_GLFWwindow* window)
2384{
2385 if (window->wl.libdecor.frame)
2386 libdecor_frame_set_minimized(window->wl.libdecor.frame);
2387 else if (window->wl.xdg.toplevel)
2388 xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
2389}
2390
2391void _glfwRestoreWindowWayland(_GLFWwindow* window)
2392{
2393 if (window->monitor)
2394 {
2395 // There is no way to unset minimized, or even to know if we are
2396 // minimized, so there is nothing to do in this case.
2397 }
2398 else
2399 {
2400 // We assume we are not minimized and act only on maximization
2401
2402 if (window->wl.maximized)
2403 {
2404 if (window->wl.libdecor.frame)
2405 libdecor_frame_unset_maximized(window->wl.libdecor.frame);
2406 else if (window->wl.xdg.toplevel)
2407 xdg_toplevel_unset_maximized(window->wl.xdg.toplevel);
2408 else
2409 window->wl.maximized = GLFW_FALSE;
2410 }
2411 }
2412}
2413
2414void _glfwMaximizeWindowWayland(_GLFWwindow* window)
2415{
2416 if (window->wl.libdecor.frame)
2417 libdecor_frame_set_maximized(window->wl.libdecor.frame);
2418 else if (window->wl.xdg.toplevel)
2419 xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
2420 else
2421 window->wl.maximized = GLFW_TRUE;
2422}
2423
2424void _glfwShowWindowWayland(_GLFWwindow* window)
2425{
2426 if (!window->wl.libdecor.frame && !window->wl.xdg.toplevel)
2427 {
2428 // NOTE: The XDG surface and role are created here so command-line applications
2429 // with off-screen windows do not appear in for example the Unity dock
2430 createShellObjects(window);
2431 }
2432}
2433
2434void _glfwHideWindowWayland(_GLFWwindow* window)
2435{
2436 if (window->wl.visible)
2437 {
2438 window->wl.visible = GLFW_FALSE;
2439 destroyShellObjects(window);
2440
2441 wl_surface_attach(window->wl.surface, NULL, 0, 0);
2442 wl_surface_commit(window->wl.surface);
2443 }
2444}
2445
2446void _glfwRequestWindowAttentionWayland(_GLFWwindow* window)
2447{
2448 if (!_glfw.wl.activationManager)
2449 return;
2450
2451 // We're about to overwrite this with a new request
2452 if (window->wl.activationToken)
2453 xdg_activation_token_v1_destroy(window->wl.activationToken);
2454
2455 window->wl.activationToken =
2456 xdg_activation_v1_get_activation_token(_glfw.wl.activationManager);
2457 xdg_activation_token_v1_add_listener(window->wl.activationToken,
2458 &xdgActivationListener,
2459 window);
2460
2461 xdg_activation_token_v1_commit(window->wl.activationToken);
2462}
2463
2464void _glfwFocusWindowWayland(_GLFWwindow* window)
2465{
2466 if (!_glfw.wl.activationManager)
2467 return;
2468
2469 if (window->wl.activationToken)
2470 xdg_activation_token_v1_destroy(window->wl.activationToken);
2471
2472 window->wl.activationToken =
2473 xdg_activation_v1_get_activation_token(_glfw.wl.activationManager);
2474 xdg_activation_token_v1_add_listener(window->wl.activationToken,
2475 &xdgActivationListener,
2476 window);
2477
2478 xdg_activation_token_v1_set_serial(window->wl.activationToken,
2479 _glfw.wl.serial,
2480 _glfw.wl.seat);
2481
2482 _GLFWwindow* requester = _glfw.wl.keyboardFocus;
2483 if (requester)
2484 {
2485 xdg_activation_token_v1_set_surface(window->wl.activationToken,
2486 requester->wl.surface);
2487
2488 if (requester->wl.appId)
2489 {
2490 xdg_activation_token_v1_set_app_id(window->wl.activationToken,
2491 requester->wl.appId);
2492 }
2493 }
2494
2495 xdg_activation_token_v1_commit(window->wl.activationToken);
2496}
2497
2498void _glfwSetWindowMonitorWayland(_GLFWwindow* window,
2499 _GLFWmonitor* monitor,
2500 int xpos, int ypos,
2501 int width, int height,
2502 int refreshRate)
2503{
2504 if (window->monitor == monitor)
2505 {
2506 if (!monitor)
2507 _glfwSetWindowSizeWayland(window, width, height);
2508
2509 return;
2510 }
2511
2512 if (window->monitor)
2513 releaseMonitorWayland(window);
2514
2515 _glfwInputWindowMonitor(window, monitor);
2516
2517 if (window->monitor)
2518 acquireMonitorWayland(window);
2519 else
2520 _glfwSetWindowSizeWayland(window, width, height);
2521}
2522
2523GLFWbool _glfwWindowFocusedWayland(_GLFWwindow* window)
2524{
2525 return _glfw.wl.keyboardFocus == window;
2526}
2527
2528GLFWbool _glfwWindowIconifiedWayland(_GLFWwindow* window)
2529{
2530 // xdg-shell doesn’t give any way to request whether a surface is
2531 // iconified.
2532 return GLFW_FALSE;
2533}
2534
2535GLFWbool _glfwWindowVisibleWayland(_GLFWwindow* window)
2536{
2537 return window->wl.visible;
2538}
2539
2540GLFWbool _glfwWindowMaximizedWayland(_GLFWwindow* window)
2541{
2542 return window->wl.maximized;
2543}
2544
2545GLFWbool _glfwWindowHoveredWayland(_GLFWwindow* window)
2546{
2547 return window->wl.hovered;
2548}
2549
2550GLFWbool _glfwFramebufferTransparentWayland(_GLFWwindow* window)
2551{
2552 return window->wl.transparent;
2553}
2554
2555void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled)
2556{
2557 if (window->wl.libdecor.frame)
2558 {
2559 if (enabled)
2560 {
2561 libdecor_frame_set_capabilities(window->wl.libdecor.frame,
2562 LIBDECOR_ACTION_RESIZE);
2563 }
2564 else
2565 {
2566 libdecor_frame_unset_capabilities(window->wl.libdecor.frame,
2567 LIBDECOR_ACTION_RESIZE);
2568 }
2569 }
2570 else if (window->wl.xdg.toplevel)
2571 updateXdgSizeLimits(window);
2572}
2573
2574void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled)
2575{
2576 if (window->wl.libdecor.frame)
2577 {
2578 libdecor_frame_set_visibility(window->wl.libdecor.frame, enabled);
2579 }
2580 else if (window->wl.xdg.decoration)
2581 {
2582 uint32_t mode;
2583
2584 if (enabled)
2585 mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
2586 else
2587 mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
2588
2589 zxdg_toplevel_decoration_v1_set_mode(window->wl.xdg.decoration, mode);
2590 }
2591 else if (window->wl.xdg.toplevel)
2592 {
2593 if (enabled)
2594 createFallbackDecorations(window);
2595 else
2596 destroyFallbackDecorations(window);
2597 }
2598}
2599
2600void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled)
2601{
2602 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
2603 "Wayland: Platform does not support making a window floating");
2604}
2605
2606void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled)
2607{
2608 if (enabled)
2609 {
2610 struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor);
2611 wl_surface_set_input_region(window->wl.surface, region);
2612 wl_region_destroy(region);
2613 }
2614 else
2615 wl_surface_set_input_region(window->wl.surface, NULL);
2616}
2617
2618float _glfwGetWindowOpacityWayland(_GLFWwindow* window)
2619{
2620 return 1.f;
2621}
2622
2623void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity)
2624{
2625 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
2626 "Wayland: The platform does not support setting the window opacity");
2627}
2628
2629void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled)
2630{
2631 // This is handled in relativePointerHandleRelativeMotion
2632}
2633
2634GLFWbool _glfwRawMouseMotionSupportedWayland(void)
2635{
2636 return GLFW_TRUE;
2637}
2638
2639void _glfwPollEventsWayland(void)
2640{
2641 double timeout = 0.0;
2642 handleEvents(&timeout);
2643}
2644
2645void _glfwWaitEventsWayland(void)
2646{
2647 handleEvents(NULL);
2648}
2649
2650void _glfwWaitEventsTimeoutWayland(double timeout)
2651{
2652 handleEvents(&timeout);
2653}
2654
2655void _glfwPostEmptyEventWayland(void)
2656{
2657 wl_display_sync(_glfw.wl.display);
2658 flushDisplay();
2659}
2660
2661void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos)
2662{
2663 if (xpos)
2664 *xpos = window->wl.cursorPosX;
2665 if (ypos)
2666 *ypos = window->wl.cursorPosY;
2667}
2668
2669void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y)
2670{
2671 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
2672 "Wayland: The platform does not support setting the cursor position");
2673}
2674
2675void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode)
2676{
2677 _glfwSetCursorWayland(window, window->wl.currentCursor);
2678}
2679
2680const char* _glfwGetScancodeNameWayland(int scancode)
2681{
2682 if (scancode < 0 || scancode > 255)
2683 {
2684 _glfwInputError(GLFW_INVALID_VALUE,
2685 "Wayland: Invalid scancode %i",
2686 scancode);
2687 return NULL;
2688 }
2689
2690 const int key = _glfw.wl.keycodes[scancode];
2691 if (key == GLFW_KEY_UNKNOWN)
2692 return NULL;
2693
2694 const xkb_keycode_t keycode = scancode + 8;
2695 const xkb_layout_index_t layout =
2696 xkb_state_key_get_layout(_glfw.wl.xkb.state, keycode);
2697 if (layout == XKB_LAYOUT_INVALID)
2698 {
2699 _glfwInputError(GLFW_PLATFORM_ERROR,
2700 "Wayland: Failed to retrieve layout for key name");
2701 return NULL;
2702 }
2703
2704 const xkb_keysym_t* keysyms = NULL;
2705 xkb_keymap_key_get_syms_by_level(_glfw.wl.xkb.keymap,
2706 keycode,
2707 layout,
2708 0,
2709 &keysyms);
2710 if (keysyms == NULL)
2711 {
2712 _glfwInputError(GLFW_PLATFORM_ERROR,
2713 "Wayland: Failed to retrieve keysym for key name");
2714 return NULL;
2715 }
2716
2717 const uint32_t codepoint = _glfwKeySym2Unicode(keysyms[0]);
2718 if (codepoint == GLFW_INVALID_CODEPOINT)
2719 {
2720 _glfwInputError(GLFW_PLATFORM_ERROR,
2721 "Wayland: Failed to retrieve codepoint for key name");
2722 return NULL;
2723 }
2724
2725 const size_t count = _glfwEncodeUTF8(_glfw.wl.keynames[key], codepoint);
2726 if (count == 0)
2727 {
2728 _glfwInputError(GLFW_PLATFORM_ERROR,
2729 "Wayland: Failed to encode codepoint for key name");
2730 return NULL;
2731 }
2732
2733 _glfw.wl.keynames[key][count] = '\0';
2734 return _glfw.wl.keynames[key];
2735}
2736
2737int _glfwGetKeyScancodeWayland(int key)
2738{
2739 return _glfw.wl.scancodes[key];
2740}
2741
2742GLFWbool _glfwCreateCursorWayland(_GLFWcursor* cursor,
2743 const GLFWimage* image,
2744 int xhot, int yhot)
2745{
2746 cursor->wl.buffer = createShmBuffer(image);
2747 if (!cursor->wl.buffer)
2748 return GLFW_FALSE;
2749
2750 cursor->wl.width = image->width;
2751 cursor->wl.height = image->height;
2752 cursor->wl.xhot = xhot;
2753 cursor->wl.yhot = yhot;
2754 return GLFW_TRUE;
2755}
2756
2757GLFWbool _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape)
2758{
2759 const char* name = NULL;
2760
2761 // Try the XDG names first
2762 switch (shape)
2763 {
2764 case GLFW_ARROW_CURSOR:
2765 name = "default";
2766 break;
2767 case GLFW_IBEAM_CURSOR:
2768 name = "text";
2769 break;
2770 case GLFW_CROSSHAIR_CURSOR:
2771 name = "crosshair";
2772 break;
2773 case GLFW_POINTING_HAND_CURSOR:
2774 name = "pointer";
2775 break;
2776 case GLFW_RESIZE_EW_CURSOR:
2777 name = "ew-resize";
2778 break;
2779 case GLFW_RESIZE_NS_CURSOR:
2780 name = "ns-resize";
2781 break;
2782 case GLFW_RESIZE_NWSE_CURSOR:
2783 name = "nwse-resize";
2784 break;
2785 case GLFW_RESIZE_NESW_CURSOR:
2786 name = "nesw-resize";
2787 break;
2788 case GLFW_RESIZE_ALL_CURSOR:
2789 name = "all-scroll";
2790 break;
2791 case GLFW_NOT_ALLOWED_CURSOR:
2792 name = "not-allowed";
2793 break;
2794 }
2795
2796 cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
2797
2798 if (_glfw.wl.cursorThemeHiDPI)
2799 {
2800 cursor->wl.cursorHiDPI =
2801 wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
2802 }
2803
2804 if (!cursor->wl.cursor)
2805 {
2806 // Fall back to the core X11 names
2807 switch (shape)
2808 {
2809 case GLFW_ARROW_CURSOR:
2810 name = "left_ptr";
2811 break;
2812 case GLFW_IBEAM_CURSOR:
2813 name = "xterm";
2814 break;
2815 case GLFW_CROSSHAIR_CURSOR:
2816 name = "crosshair";
2817 break;
2818 case GLFW_POINTING_HAND_CURSOR:
2819 name = "hand2";
2820 break;
2821 case GLFW_RESIZE_EW_CURSOR:
2822 name = "sb_h_double_arrow";
2823 break;
2824 case GLFW_RESIZE_NS_CURSOR:
2825 name = "sb_v_double_arrow";
2826 break;
2827 case GLFW_RESIZE_ALL_CURSOR:
2828 name = "fleur";
2829 break;
2830 default:
2831 _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
2832 "Wayland: Standard cursor shape unavailable");
2833 return GLFW_FALSE;
2834 }
2835
2836 cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
2837 if (!cursor->wl.cursor)
2838 {
2839 _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
2840 "Wayland: Failed to create standard cursor \"%s\"",
2841 name);
2842 return GLFW_FALSE;
2843 }
2844
2845 if (_glfw.wl.cursorThemeHiDPI)
2846 {
2847 if (!cursor->wl.cursorHiDPI)
2848 {
2849 cursor->wl.cursorHiDPI =
2850 wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
2851 }
2852 }
2853 }
2854
2855 return GLFW_TRUE;
2856}
2857
2858void _glfwDestroyCursorWayland(_GLFWcursor* cursor)
2859{
2860 // If it's a standard cursor we don't need to do anything here
2861 if (cursor->wl.cursor)
2862 return;
2863
2864 if (cursor->wl.buffer)
2865 wl_buffer_destroy(cursor->wl.buffer);
2866}
2867
2868static void relativePointerHandleRelativeMotion(void* userData,
2869 struct zwp_relative_pointer_v1* pointer,
2870 uint32_t timeHi,
2871 uint32_t timeLo,
2872 wl_fixed_t dx,
2873 wl_fixed_t dy,
2874 wl_fixed_t dxUnaccel,
2875 wl_fixed_t dyUnaccel)
2876{
2877 _GLFWwindow* window = userData;
2878 double xpos = window->virtualCursorPosX;
2879 double ypos = window->virtualCursorPosY;
2880
2881 if (window->cursorMode != GLFW_CURSOR_DISABLED)
2882 return;
2883
2884 if (window->rawMouseMotion)
2885 {
2886 xpos += wl_fixed_to_double(dxUnaccel);
2887 ypos += wl_fixed_to_double(dyUnaccel);
2888 }
2889 else
2890 {
2891 xpos += wl_fixed_to_double(dx);
2892 ypos += wl_fixed_to_double(dy);
2893 }
2894
2895 _glfwInputCursorPos(window, xpos, ypos);
2896}
2897
2898static const struct zwp_relative_pointer_v1_listener relativePointerListener =
2899{
2900 relativePointerHandleRelativeMotion
2901};
2902
2903static void lockedPointerHandleLocked(void* userData,
2904 struct zwp_locked_pointer_v1* lockedPointer)
2905{
2906}
2907
2908static void lockedPointerHandleUnlocked(void* userData,
2909 struct zwp_locked_pointer_v1* lockedPointer)
2910{
2911}
2912
2913static const struct zwp_locked_pointer_v1_listener lockedPointerListener =
2914{
2915 lockedPointerHandleLocked,
2916 lockedPointerHandleUnlocked
2917};
2918
2919static void lockPointer(_GLFWwindow* window)
2920{
2921 if (!_glfw.wl.relativePointerManager)
2922 {
2923 _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
2924 "Wayland: The compositor does not support pointer locking");
2925 return;
2926 }
2927
2928 window->wl.relativePointer =
2929 zwp_relative_pointer_manager_v1_get_relative_pointer(
2930 _glfw.wl.relativePointerManager,
2931 _glfw.wl.pointer);
2932 zwp_relative_pointer_v1_add_listener(window->wl.relativePointer,
2933 &relativePointerListener,
2934 window);
2935
2936 window->wl.lockedPointer =
2937 zwp_pointer_constraints_v1_lock_pointer(
2938 _glfw.wl.pointerConstraints,
2939 window->wl.surface,
2940 _glfw.wl.pointer,
2941 NULL,
2942 ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
2943 zwp_locked_pointer_v1_add_listener(window->wl.lockedPointer,
2944 &lockedPointerListener,
2945 window);
2946}
2947
2948static void unlockPointer(_GLFWwindow* window)
2949{
2950 zwp_relative_pointer_v1_destroy(window->wl.relativePointer);
2951 window->wl.relativePointer = NULL;
2952
2953 zwp_locked_pointer_v1_destroy(window->wl.lockedPointer);
2954 window->wl.lockedPointer = NULL;
2955}
2956
2957static void confinedPointerHandleConfined(void* userData,
2958 struct zwp_confined_pointer_v1* confinedPointer)
2959{
2960}
2961
2962static void confinedPointerHandleUnconfined(void* userData,
2963 struct zwp_confined_pointer_v1* confinedPointer)
2964{
2965}
2966
2967static const struct zwp_confined_pointer_v1_listener confinedPointerListener =
2968{
2969 confinedPointerHandleConfined,
2970 confinedPointerHandleUnconfined
2971};
2972
2973static void confinePointer(_GLFWwindow* window)
2974{
2975 window->wl.confinedPointer =
2976 zwp_pointer_constraints_v1_confine_pointer(
2977 _glfw.wl.pointerConstraints,
2978 window->wl.surface,
2979 _glfw.wl.pointer,
2980 NULL,
2981 ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
2982
2983 zwp_confined_pointer_v1_add_listener(window->wl.confinedPointer,
2984 &confinedPointerListener,
2985 window);
2986}
2987
2988static void unconfinePointer(_GLFWwindow* window)
2989{
2990 zwp_confined_pointer_v1_destroy(window->wl.confinedPointer);
2991 window->wl.confinedPointer = NULL;
2992}
2993
2994void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
2995{
2996 if (!_glfw.wl.pointer)
2997 return;
2998
2999 window->wl.currentCursor = cursor;
3000
3001 // If we're not in the correct window just save the cursor
3002 // the next time the pointer enters the window the cursor will change
3003 if (!window->wl.hovered)
3004 return;
3005
3006 // Update pointer lock to match cursor mode
3007 if (window->cursorMode == GLFW_CURSOR_DISABLED)
3008 {
3009 if (window->wl.confinedPointer)
3010 unconfinePointer(window);
3011 if (!window->wl.lockedPointer)
3012 lockPointer(window);
3013 }
3014 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
3015 {
3016 if (window->wl.lockedPointer)
3017 unlockPointer(window);
3018 if (!window->wl.confinedPointer)
3019 confinePointer(window);
3020 }
3021 else if (window->cursorMode == GLFW_CURSOR_NORMAL ||
3022 window->cursorMode == GLFW_CURSOR_HIDDEN)
3023 {
3024 if (window->wl.lockedPointer)
3025 unlockPointer(window);
3026 else if (window->wl.confinedPointer)
3027 unconfinePointer(window);
3028 }
3029
3030 if (window->cursorMode == GLFW_CURSOR_NORMAL ||
3031 window->cursorMode == GLFW_CURSOR_CAPTURED)
3032 {
3033 if (cursor)
3034 setCursorImage(window, &cursor->wl);
3035 else
3036 {
3037 struct wl_cursor* defaultCursor =
3038 wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, "left_ptr");
3039 if (!defaultCursor)
3040 {
3041 _glfwInputError(GLFW_PLATFORM_ERROR,
3042 "Wayland: Standard cursor not found");
3043 return;
3044 }
3045
3046 struct wl_cursor* defaultCursorHiDPI = NULL;
3047 if (_glfw.wl.cursorThemeHiDPI)
3048 {
3049 defaultCursorHiDPI =
3050 wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, "left_ptr");
3051 }
3052
3053 _GLFWcursorWayland cursorWayland =
3054 {
3055 defaultCursor,
3056 defaultCursorHiDPI,
3057 NULL,
3058 0, 0,
3059 0, 0,
3060 0
3061 };
3062
3063 setCursorImage(window, &cursorWayland);
3064 }
3065 }
3066 else if (window->cursorMode == GLFW_CURSOR_HIDDEN ||
3067 window->cursorMode == GLFW_CURSOR_DISABLED)
3068 {
3069 wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0);
3070 }
3071}
3072
3073static void dataSourceHandleTarget(void* userData,
3074 struct wl_data_source* source,
3075 const char* mimeType)
3076{
3077 if (_glfw.wl.selectionSource != source)
3078 {
3079 _glfwInputError(GLFW_PLATFORM_ERROR,
3080 "Wayland: Unknown clipboard data source");
3081 return;
3082 }
3083}
3084
3085static void dataSourceHandleSend(void* userData,
3086 struct wl_data_source* source,
3087 const char* mimeType,
3088 int fd)
3089{
3090 // Ignore it if this is an outdated or invalid request
3091 if (_glfw.wl.selectionSource != source ||
3092 strcmp(mimeType, "text/plain;charset=utf-8") != 0)
3093 {
3094 close(fd);
3095 return;
3096 }
3097
3098 char* string = _glfw.wl.clipboardString;
3099 size_t length = strlen(string);
3100
3101 while (length > 0)
3102 {
3103 const ssize_t result = write(fd, string, length);
3104 if (result == -1)
3105 {
3106 if (errno == EINTR)
3107 continue;
3108
3109 _glfwInputError(GLFW_PLATFORM_ERROR,
3110 "Wayland: Error while writing the clipboard: %s",
3111 strerror(errno));
3112 break;
3113 }
3114
3115 length -= result;
3116 string += result;
3117 }
3118
3119 close(fd);
3120}
3121
3122static void dataSourceHandleCancelled(void* userData,
3123 struct wl_data_source* source)
3124{
3125 wl_data_source_destroy(source);
3126
3127 if (_glfw.wl.selectionSource != source)
3128 return;
3129
3130 _glfw.wl.selectionSource = NULL;
3131}
3132
3133static const struct wl_data_source_listener dataSourceListener =
3134{
3135 dataSourceHandleTarget,
3136 dataSourceHandleSend,
3137 dataSourceHandleCancelled,
3138};
3139
3140void _glfwSetClipboardStringWayland(const char* string)
3141{
3142 if (_glfw.wl.selectionSource)
3143 {
3144 wl_data_source_destroy(_glfw.wl.selectionSource);
3145 _glfw.wl.selectionSource = NULL;
3146 }
3147
3148 char* copy = _glfw_strdup(string);
3149 if (!copy)
3150 {
3151 _glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
3152 return;
3153 }
3154
3155 _glfw_free(_glfw.wl.clipboardString);
3156 _glfw.wl.clipboardString = copy;
3157
3158 _glfw.wl.selectionSource =
3159 wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager);
3160 if (!_glfw.wl.selectionSource)
3161 {
3162 _glfwInputError(GLFW_PLATFORM_ERROR,
3163 "Wayland: Failed to create clipboard data source");
3164 return;
3165 }
3166 wl_data_source_add_listener(_glfw.wl.selectionSource,
3167 &dataSourceListener,
3168 NULL);
3169 wl_data_source_offer(_glfw.wl.selectionSource, "text/plain;charset=utf-8");
3170 wl_data_device_set_selection(_glfw.wl.dataDevice,
3171 _glfw.wl.selectionSource,
3172 _glfw.wl.serial);
3173}
3174
3175const char* _glfwGetClipboardStringWayland(void)
3176{
3177 if (!_glfw.wl.selectionOffer)
3178 {
3179 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
3180 "Wayland: No clipboard data available");
3181 return NULL;
3182 }
3183
3184 if (_glfw.wl.selectionSource)
3185 return _glfw.wl.clipboardString;
3186
3187 _glfw_free(_glfw.wl.clipboardString);
3188 _glfw.wl.clipboardString =
3189 readDataOfferAsString(_glfw.wl.selectionOffer, "text/plain;charset=utf-8");
3190 return _glfw.wl.clipboardString;
3191}
3192
3193EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs)
3194{
3195 if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_wayland)
3196 return EGL_PLATFORM_WAYLAND_EXT;
3197 else
3198 return 0;
3199}
3200
3201EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void)
3202{
3203 return _glfw.wl.display;
3204}
3205
3206EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window)
3207{
3208 return window->wl.egl.window;
3209}
3210
3211void _glfwGetRequiredInstanceExtensionsWayland(char** extensions)
3212{
3213 if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
3214 return;
3215
3216 extensions[0] = "VK_KHR_surface";
3217 extensions[1] = "VK_KHR_wayland_surface";
3218}
3219
3220GLFWbool _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance,
3221 VkPhysicalDevice device,
3222 uint32_t queuefamily)
3223{
3224 PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
3225 vkGetPhysicalDeviceWaylandPresentationSupportKHR =
3226 (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)
3227 vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
3228 if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR)
3229 {
3230 _glfwInputError(GLFW_API_UNAVAILABLE,
3231 "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
3232 return VK_NULL_HANDLE;
3233 }
3234
3235 return vkGetPhysicalDeviceWaylandPresentationSupportKHR(device,
3236 queuefamily,
3237 _glfw.wl.display);
3238}
3239
3240VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance,
3241 _GLFWwindow* window,
3242 const VkAllocationCallbacks* allocator,
3243 VkSurfaceKHR* surface)
3244{
3245 VkResult err;
3246 VkWaylandSurfaceCreateInfoKHR sci;
3247 PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
3248
3249 vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)
3250 vkGetInstanceProcAddr(instance, "vkCreateWaylandSurfaceKHR");
3251 if (!vkCreateWaylandSurfaceKHR)
3252 {
3253 _glfwInputError(GLFW_API_UNAVAILABLE,
3254 "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
3255 return VK_ERROR_EXTENSION_NOT_PRESENT;
3256 }
3257
3258 memset(&sci, 0, sizeof(sci));
3259 sci.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
3260 sci.display = _glfw.wl.display;
3261 sci.surface = window->wl.surface;
3262
3263 err = vkCreateWaylandSurfaceKHR(instance, &sci, allocator, surface);
3264 if (err)
3265 {
3266 _glfwInputError(GLFW_PLATFORM_ERROR,
3267 "Wayland: Failed to create Vulkan surface: %s",
3268 _glfwGetVulkanResultString(err));
3269 }
3270
3271 return err;
3272}
3273
3274
3275//////////////////////////////////////////////////////////////////////////
3276////// GLFW native API //////
3277//////////////////////////////////////////////////////////////////////////
3278
3279GLFWAPI struct wl_display* glfwGetWaylandDisplay(void)
3280{
3281 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
3282
3283 if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
3284 {
3285 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
3286 "Wayland: Platform not initialized");
3287 return NULL;
3288 }
3289
3290 return _glfw.wl.display;
3291}
3292
3293GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
3294{
3295 _GLFWwindow* window = (_GLFWwindow*) handle;
3296 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
3297
3298 if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
3299 {
3300 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
3301 "Wayland: Platform not initialized");
3302 return NULL;
3303 }
3304
3305 return window->wl.surface;
3306}
3307
3308#endif // _GLFW_WAYLAND
3309
diff --git a/raylib/src/external/glfw/src/x11_init.c b/raylib/src/external/glfw/src/x11_init.c
new file mode 100644
index 0000000..000bde2
--- /dev/null
+++ b/raylib/src/external/glfw/src/x11_init.c
@@ -0,0 +1,1657 @@
1//========================================================================
2// GLFW 3.4 X11 (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#if defined(_GLFW_X11)
32
33#include <stdlib.h>
34#include <string.h>
35#include <limits.h>
36#include <stdio.h>
37#include <locale.h>
38#include <unistd.h>
39#include <fcntl.h>
40#include <errno.h>
41#include <assert.h>
42
43
44// Translate the X11 KeySyms for a key to a GLFW key code
45// NOTE: This is only used as a fallback, in case the XKB method fails
46// It is layout-dependent and will fail partially on most non-US layouts
47//
48static int translateKeySyms(const KeySym* keysyms, int width)
49{
50 if (width > 1)
51 {
52 switch (keysyms[1])
53 {
54 case XK_KP_0: return GLFW_KEY_KP_0;
55 case XK_KP_1: return GLFW_KEY_KP_1;
56 case XK_KP_2: return GLFW_KEY_KP_2;
57 case XK_KP_3: return GLFW_KEY_KP_3;
58 case XK_KP_4: return GLFW_KEY_KP_4;
59 case XK_KP_5: return GLFW_KEY_KP_5;
60 case XK_KP_6: return GLFW_KEY_KP_6;
61 case XK_KP_7: return GLFW_KEY_KP_7;
62 case XK_KP_8: return GLFW_KEY_KP_8;
63 case XK_KP_9: return GLFW_KEY_KP_9;
64 case XK_KP_Separator:
65 case XK_KP_Decimal: return GLFW_KEY_KP_DECIMAL;
66 case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
67 case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
68 default: break;
69 }
70 }
71
72 switch (keysyms[0])
73 {
74 case XK_Escape: return GLFW_KEY_ESCAPE;
75 case XK_Tab: return GLFW_KEY_TAB;
76 case XK_Shift_L: return GLFW_KEY_LEFT_SHIFT;
77 case XK_Shift_R: return GLFW_KEY_RIGHT_SHIFT;
78 case XK_Control_L: return GLFW_KEY_LEFT_CONTROL;
79 case XK_Control_R: return GLFW_KEY_RIGHT_CONTROL;
80 case XK_Meta_L:
81 case XK_Alt_L: return GLFW_KEY_LEFT_ALT;
82 case XK_Mode_switch: // Mapped to Alt_R on many keyboards
83 case XK_ISO_Level3_Shift: // AltGr on at least some machines
84 case XK_Meta_R:
85 case XK_Alt_R: return GLFW_KEY_RIGHT_ALT;
86 case XK_Super_L: return GLFW_KEY_LEFT_SUPER;
87 case XK_Super_R: return GLFW_KEY_RIGHT_SUPER;
88 case XK_Menu: return GLFW_KEY_MENU;
89 case XK_Num_Lock: return GLFW_KEY_NUM_LOCK;
90 case XK_Caps_Lock: return GLFW_KEY_CAPS_LOCK;
91 case XK_Print: return GLFW_KEY_PRINT_SCREEN;
92 case XK_Scroll_Lock: return GLFW_KEY_SCROLL_LOCK;
93 case XK_Pause: return GLFW_KEY_PAUSE;
94 case XK_Delete: return GLFW_KEY_DELETE;
95 case XK_BackSpace: return GLFW_KEY_BACKSPACE;
96 case XK_Return: return GLFW_KEY_ENTER;
97 case XK_Home: return GLFW_KEY_HOME;
98 case XK_End: return GLFW_KEY_END;
99 case XK_Page_Up: return GLFW_KEY_PAGE_UP;
100 case XK_Page_Down: return GLFW_KEY_PAGE_DOWN;
101 case XK_Insert: return GLFW_KEY_INSERT;
102 case XK_Left: return GLFW_KEY_LEFT;
103 case XK_Right: return GLFW_KEY_RIGHT;
104 case XK_Down: return GLFW_KEY_DOWN;
105 case XK_Up: return GLFW_KEY_UP;
106 case XK_F1: return GLFW_KEY_F1;
107 case XK_F2: return GLFW_KEY_F2;
108 case XK_F3: return GLFW_KEY_F3;
109 case XK_F4: return GLFW_KEY_F4;
110 case XK_F5: return GLFW_KEY_F5;
111 case XK_F6: return GLFW_KEY_F6;
112 case XK_F7: return GLFW_KEY_F7;
113 case XK_F8: return GLFW_KEY_F8;
114 case XK_F9: return GLFW_KEY_F9;
115 case XK_F10: return GLFW_KEY_F10;
116 case XK_F11: return GLFW_KEY_F11;
117 case XK_F12: return GLFW_KEY_F12;
118 case XK_F13: return GLFW_KEY_F13;
119 case XK_F14: return GLFW_KEY_F14;
120 case XK_F15: return GLFW_KEY_F15;
121 case XK_F16: return GLFW_KEY_F16;
122 case XK_F17: return GLFW_KEY_F17;
123 case XK_F18: return GLFW_KEY_F18;
124 case XK_F19: return GLFW_KEY_F19;
125 case XK_F20: return GLFW_KEY_F20;
126 case XK_F21: return GLFW_KEY_F21;
127 case XK_F22: return GLFW_KEY_F22;
128 case XK_F23: return GLFW_KEY_F23;
129 case XK_F24: return GLFW_KEY_F24;
130 case XK_F25: return GLFW_KEY_F25;
131
132 // Numeric keypad
133 case XK_KP_Divide: return GLFW_KEY_KP_DIVIDE;
134 case XK_KP_Multiply: return GLFW_KEY_KP_MULTIPLY;
135 case XK_KP_Subtract: return GLFW_KEY_KP_SUBTRACT;
136 case XK_KP_Add: return GLFW_KEY_KP_ADD;
137
138 // These should have been detected in secondary keysym test above!
139 case XK_KP_Insert: return GLFW_KEY_KP_0;
140 case XK_KP_End: return GLFW_KEY_KP_1;
141 case XK_KP_Down: return GLFW_KEY_KP_2;
142 case XK_KP_Page_Down: return GLFW_KEY_KP_3;
143 case XK_KP_Left: return GLFW_KEY_KP_4;
144 case XK_KP_Right: return GLFW_KEY_KP_6;
145 case XK_KP_Home: return GLFW_KEY_KP_7;
146 case XK_KP_Up: return GLFW_KEY_KP_8;
147 case XK_KP_Page_Up: return GLFW_KEY_KP_9;
148 case XK_KP_Delete: return GLFW_KEY_KP_DECIMAL;
149 case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
150 case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
151
152 // Last resort: Check for printable keys (should not happen if the XKB
153 // extension is available). This will give a layout dependent mapping
154 // (which is wrong, and we may miss some keys, especially on non-US
155 // keyboards), but it's better than nothing...
156 case XK_a: return GLFW_KEY_A;
157 case XK_b: return GLFW_KEY_B;
158 case XK_c: return GLFW_KEY_C;
159 case XK_d: return GLFW_KEY_D;
160 case XK_e: return GLFW_KEY_E;
161 case XK_f: return GLFW_KEY_F;
162 case XK_g: return GLFW_KEY_G;
163 case XK_h: return GLFW_KEY_H;
164 case XK_i: return GLFW_KEY_I;
165 case XK_j: return GLFW_KEY_J;
166 case XK_k: return GLFW_KEY_K;
167 case XK_l: return GLFW_KEY_L;
168 case XK_m: return GLFW_KEY_M;
169 case XK_n: return GLFW_KEY_N;
170 case XK_o: return GLFW_KEY_O;
171 case XK_p: return GLFW_KEY_P;
172 case XK_q: return GLFW_KEY_Q;
173 case XK_r: return GLFW_KEY_R;
174 case XK_s: return GLFW_KEY_S;
175 case XK_t: return GLFW_KEY_T;
176 case XK_u: return GLFW_KEY_U;
177 case XK_v: return GLFW_KEY_V;
178 case XK_w: return GLFW_KEY_W;
179 case XK_x: return GLFW_KEY_X;
180 case XK_y: return GLFW_KEY_Y;
181 case XK_z: return GLFW_KEY_Z;
182 case XK_1: return GLFW_KEY_1;
183 case XK_2: return GLFW_KEY_2;
184 case XK_3: return GLFW_KEY_3;
185 case XK_4: return GLFW_KEY_4;
186 case XK_5: return GLFW_KEY_5;
187 case XK_6: return GLFW_KEY_6;
188 case XK_7: return GLFW_KEY_7;
189 case XK_8: return GLFW_KEY_8;
190 case XK_9: return GLFW_KEY_9;
191 case XK_0: return GLFW_KEY_0;
192 case XK_space: return GLFW_KEY_SPACE;
193 case XK_minus: return GLFW_KEY_MINUS;
194 case XK_equal: return GLFW_KEY_EQUAL;
195 case XK_bracketleft: return GLFW_KEY_LEFT_BRACKET;
196 case XK_bracketright: return GLFW_KEY_RIGHT_BRACKET;
197 case XK_backslash: return GLFW_KEY_BACKSLASH;
198 case XK_semicolon: return GLFW_KEY_SEMICOLON;
199 case XK_apostrophe: return GLFW_KEY_APOSTROPHE;
200 case XK_grave: return GLFW_KEY_GRAVE_ACCENT;
201 case XK_comma: return GLFW_KEY_COMMA;
202 case XK_period: return GLFW_KEY_PERIOD;
203 case XK_slash: return GLFW_KEY_SLASH;
204 case XK_less: return GLFW_KEY_WORLD_1; // At least in some layouts...
205 default: break;
206 }
207
208 // No matching translation was found
209 return GLFW_KEY_UNKNOWN;
210}
211
212// Create key code translation tables
213//
214static void createKeyTablesX11(void)
215{
216 int scancodeMin, scancodeMax;
217
218 memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
219 memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
220
221 if (_glfw.x11.xkb.available)
222 {
223 // Use XKB to determine physical key locations independently of the
224 // current keyboard layout
225
226 XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd);
227 XkbGetNames(_glfw.x11.display, XkbKeyNamesMask | XkbKeyAliasesMask, desc);
228
229 scancodeMin = desc->min_key_code;
230 scancodeMax = desc->max_key_code;
231
232 const struct
233 {
234 int key;
235 char* name;
236 } keymap[] =
237 {
238 { GLFW_KEY_GRAVE_ACCENT, "TLDE" },
239 { GLFW_KEY_1, "AE01" },
240 { GLFW_KEY_2, "AE02" },
241 { GLFW_KEY_3, "AE03" },
242 { GLFW_KEY_4, "AE04" },
243 { GLFW_KEY_5, "AE05" },
244 { GLFW_KEY_6, "AE06" },
245 { GLFW_KEY_7, "AE07" },
246 { GLFW_KEY_8, "AE08" },
247 { GLFW_KEY_9, "AE09" },
248 { GLFW_KEY_0, "AE10" },
249 { GLFW_KEY_MINUS, "AE11" },
250 { GLFW_KEY_EQUAL, "AE12" },
251 { GLFW_KEY_Q, "AD01" },
252 { GLFW_KEY_W, "AD02" },
253 { GLFW_KEY_E, "AD03" },
254 { GLFW_KEY_R, "AD04" },
255 { GLFW_KEY_T, "AD05" },
256 { GLFW_KEY_Y, "AD06" },
257 { GLFW_KEY_U, "AD07" },
258 { GLFW_KEY_I, "AD08" },
259 { GLFW_KEY_O, "AD09" },
260 { GLFW_KEY_P, "AD10" },
261 { GLFW_KEY_LEFT_BRACKET, "AD11" },
262 { GLFW_KEY_RIGHT_BRACKET, "AD12" },
263 { GLFW_KEY_A, "AC01" },
264 { GLFW_KEY_S, "AC02" },
265 { GLFW_KEY_D, "AC03" },
266 { GLFW_KEY_F, "AC04" },
267 { GLFW_KEY_G, "AC05" },
268 { GLFW_KEY_H, "AC06" },
269 { GLFW_KEY_J, "AC07" },
270 { GLFW_KEY_K, "AC08" },
271 { GLFW_KEY_L, "AC09" },
272 { GLFW_KEY_SEMICOLON, "AC10" },
273 { GLFW_KEY_APOSTROPHE, "AC11" },
274 { GLFW_KEY_Z, "AB01" },
275 { GLFW_KEY_X, "AB02" },
276 { GLFW_KEY_C, "AB03" },
277 { GLFW_KEY_V, "AB04" },
278 { GLFW_KEY_B, "AB05" },
279 { GLFW_KEY_N, "AB06" },
280 { GLFW_KEY_M, "AB07" },
281 { GLFW_KEY_COMMA, "AB08" },
282 { GLFW_KEY_PERIOD, "AB09" },
283 { GLFW_KEY_SLASH, "AB10" },
284 { GLFW_KEY_BACKSLASH, "BKSL" },
285 { GLFW_KEY_WORLD_1, "LSGT" },
286 { GLFW_KEY_SPACE, "SPCE" },
287 { GLFW_KEY_ESCAPE, "ESC" },
288 { GLFW_KEY_ENTER, "RTRN" },
289 { GLFW_KEY_TAB, "TAB" },
290 { GLFW_KEY_BACKSPACE, "BKSP" },
291 { GLFW_KEY_INSERT, "INS" },
292 { GLFW_KEY_DELETE, "DELE" },
293 { GLFW_KEY_RIGHT, "RGHT" },
294 { GLFW_KEY_LEFT, "LEFT" },
295 { GLFW_KEY_DOWN, "DOWN" },
296 { GLFW_KEY_UP, "UP" },
297 { GLFW_KEY_PAGE_UP, "PGUP" },
298 { GLFW_KEY_PAGE_DOWN, "PGDN" },
299 { GLFW_KEY_HOME, "HOME" },
300 { GLFW_KEY_END, "END" },
301 { GLFW_KEY_CAPS_LOCK, "CAPS" },
302 { GLFW_KEY_SCROLL_LOCK, "SCLK" },
303 { GLFW_KEY_NUM_LOCK, "NMLK" },
304 { GLFW_KEY_PRINT_SCREEN, "PRSC" },
305 { GLFW_KEY_PAUSE, "PAUS" },
306 { GLFW_KEY_F1, "FK01" },
307 { GLFW_KEY_F2, "FK02" },
308 { GLFW_KEY_F3, "FK03" },
309 { GLFW_KEY_F4, "FK04" },
310 { GLFW_KEY_F5, "FK05" },
311 { GLFW_KEY_F6, "FK06" },
312 { GLFW_KEY_F7, "FK07" },
313 { GLFW_KEY_F8, "FK08" },
314 { GLFW_KEY_F9, "FK09" },
315 { GLFW_KEY_F10, "FK10" },
316 { GLFW_KEY_F11, "FK11" },
317 { GLFW_KEY_F12, "FK12" },
318 { GLFW_KEY_F13, "FK13" },
319 { GLFW_KEY_F14, "FK14" },
320 { GLFW_KEY_F15, "FK15" },
321 { GLFW_KEY_F16, "FK16" },
322 { GLFW_KEY_F17, "FK17" },
323 { GLFW_KEY_F18, "FK18" },
324 { GLFW_KEY_F19, "FK19" },
325 { GLFW_KEY_F20, "FK20" },
326 { GLFW_KEY_F21, "FK21" },
327 { GLFW_KEY_F22, "FK22" },
328 { GLFW_KEY_F23, "FK23" },
329 { GLFW_KEY_F24, "FK24" },
330 { GLFW_KEY_F25, "FK25" },
331 { GLFW_KEY_KP_0, "KP0" },
332 { GLFW_KEY_KP_1, "KP1" },
333 { GLFW_KEY_KP_2, "KP2" },
334 { GLFW_KEY_KP_3, "KP3" },
335 { GLFW_KEY_KP_4, "KP4" },
336 { GLFW_KEY_KP_5, "KP5" },
337 { GLFW_KEY_KP_6, "KP6" },
338 { GLFW_KEY_KP_7, "KP7" },
339 { GLFW_KEY_KP_8, "KP8" },
340 { GLFW_KEY_KP_9, "KP9" },
341 { GLFW_KEY_KP_DECIMAL, "KPDL" },
342 { GLFW_KEY_KP_DIVIDE, "KPDV" },
343 { GLFW_KEY_KP_MULTIPLY, "KPMU" },
344 { GLFW_KEY_KP_SUBTRACT, "KPSU" },
345 { GLFW_KEY_KP_ADD, "KPAD" },
346 { GLFW_KEY_KP_ENTER, "KPEN" },
347 { GLFW_KEY_KP_EQUAL, "KPEQ" },
348 { GLFW_KEY_LEFT_SHIFT, "LFSH" },
349 { GLFW_KEY_LEFT_CONTROL, "LCTL" },
350 { GLFW_KEY_LEFT_ALT, "LALT" },
351 { GLFW_KEY_LEFT_SUPER, "LWIN" },
352 { GLFW_KEY_RIGHT_SHIFT, "RTSH" },
353 { GLFW_KEY_RIGHT_CONTROL, "RCTL" },
354 { GLFW_KEY_RIGHT_ALT, "RALT" },
355 { GLFW_KEY_RIGHT_ALT, "LVL3" },
356 { GLFW_KEY_RIGHT_ALT, "MDSW" },
357 { GLFW_KEY_RIGHT_SUPER, "RWIN" },
358 { GLFW_KEY_MENU, "MENU" }
359 };
360
361 // Find the X11 key code -> GLFW key code mapping
362 for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++)
363 {
364 int key = GLFW_KEY_UNKNOWN;
365
366 // Map the key name to a GLFW key code. Note: We use the US
367 // keyboard layout. Because function keys aren't mapped correctly
368 // when using traditional KeySym translations, they are mapped
369 // here instead.
370 for (int i = 0; i < sizeof(keymap) / sizeof(keymap[0]); i++)
371 {
372 if (strncmp(desc->names->keys[scancode].name,
373 keymap[i].name,
374 XkbKeyNameLength) == 0)
375 {
376 key = keymap[i].key;
377 break;
378 }
379 }
380
381 // Fall back to key aliases in case the key name did not match
382 for (int i = 0; i < desc->names->num_key_aliases; i++)
383 {
384 if (key != GLFW_KEY_UNKNOWN)
385 break;
386
387 if (strncmp(desc->names->key_aliases[i].real,
388 desc->names->keys[scancode].name,
389 XkbKeyNameLength) != 0)
390 {
391 continue;
392 }
393
394 for (int j = 0; j < sizeof(keymap) / sizeof(keymap[0]); j++)
395 {
396 if (strncmp(desc->names->key_aliases[i].alias,
397 keymap[j].name,
398 XkbKeyNameLength) == 0)
399 {
400 key = keymap[j].key;
401 break;
402 }
403 }
404 }
405
406 _glfw.x11.keycodes[scancode] = key;
407 }
408
409 XkbFreeNames(desc, XkbKeyNamesMask, True);
410 XkbFreeKeyboard(desc, 0, True);
411 }
412 else
413 XDisplayKeycodes(_glfw.x11.display, &scancodeMin, &scancodeMax);
414
415 int width;
416 KeySym* keysyms = XGetKeyboardMapping(_glfw.x11.display,
417 scancodeMin,
418 scancodeMax - scancodeMin + 1,
419 &width);
420
421 for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++)
422 {
423 // Translate the un-translated key codes using traditional X11 KeySym
424 // lookups
425 if (_glfw.x11.keycodes[scancode] < 0)
426 {
427 const size_t base = (scancode - scancodeMin) * width;
428 _glfw.x11.keycodes[scancode] = translateKeySyms(&keysyms[base], width);
429 }
430
431 // Store the reverse translation for faster key name lookup
432 if (_glfw.x11.keycodes[scancode] > 0)
433 _glfw.x11.scancodes[_glfw.x11.keycodes[scancode]] = scancode;
434 }
435
436 XFree(keysyms);
437}
438
439// Check whether the IM has a usable style
440//
441static GLFWbool hasUsableInputMethodStyle(void)
442{
443 GLFWbool found = GLFW_FALSE;
444 XIMStyles* styles = NULL;
445
446 if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
447 return GLFW_FALSE;
448
449 for (unsigned int i = 0; i < styles->count_styles; i++)
450 {
451 if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
452 {
453 found = GLFW_TRUE;
454 break;
455 }
456 }
457
458 XFree(styles);
459 return found;
460}
461
462static void inputMethodDestroyCallback(XIM im, XPointer clientData, XPointer callData)
463{
464 _glfw.x11.im = NULL;
465}
466
467static void inputMethodInstantiateCallback(Display* display,
468 XPointer clientData,
469 XPointer callData)
470{
471 if (_glfw.x11.im)
472 return;
473
474 _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
475 if (_glfw.x11.im)
476 {
477 if (!hasUsableInputMethodStyle())
478 {
479 XCloseIM(_glfw.x11.im);
480 _glfw.x11.im = NULL;
481 }
482 }
483
484 if (_glfw.x11.im)
485 {
486 XIMCallback callback;
487 callback.callback = (XIMProc) inputMethodDestroyCallback;
488 callback.client_data = NULL;
489 XSetIMValues(_glfw.x11.im, XNDestroyCallback, &callback, NULL);
490
491 for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
492 _glfwCreateInputContextX11(window);
493 }
494}
495
496// Return the atom ID only if it is listed in the specified array
497//
498static Atom getAtomIfSupported(Atom* supportedAtoms,
499 unsigned long atomCount,
500 const char* atomName)
501{
502 const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
503
504 for (unsigned long i = 0; i < atomCount; i++)
505 {
506 if (supportedAtoms[i] == atom)
507 return atom;
508 }
509
510 return None;
511}
512
513// Check whether the running window manager is EWMH-compliant
514//
515static void detectEWMH(void)
516{
517 // First we read the _NET_SUPPORTING_WM_CHECK property on the root window
518
519 Window* windowFromRoot = NULL;
520 if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
521 _glfw.x11.NET_SUPPORTING_WM_CHECK,
522 XA_WINDOW,
523 (unsigned char**) &windowFromRoot))
524 {
525 return;
526 }
527
528 _glfwGrabErrorHandlerX11();
529
530 // If it exists, it should be the XID of a top-level window
531 // Then we look for the same property on that window
532
533 Window* windowFromChild = NULL;
534 if (!_glfwGetWindowPropertyX11(*windowFromRoot,
535 _glfw.x11.NET_SUPPORTING_WM_CHECK,
536 XA_WINDOW,
537 (unsigned char**) &windowFromChild))
538 {
539 XFree(windowFromRoot);
540 return;
541 }
542
543 _glfwReleaseErrorHandlerX11();
544
545 // If the property exists, it should contain the XID of the window
546
547 if (*windowFromRoot != *windowFromChild)
548 {
549 XFree(windowFromRoot);
550 XFree(windowFromChild);
551 return;
552 }
553
554 XFree(windowFromRoot);
555 XFree(windowFromChild);
556
557 // We are now fairly sure that an EWMH-compliant WM is currently running
558 // We can now start querying the WM about what features it supports by
559 // looking in the _NET_SUPPORTED property on the root window
560 // It should contain a list of supported EWMH protocol and state atoms
561
562 Atom* supportedAtoms = NULL;
563 const unsigned long atomCount =
564 _glfwGetWindowPropertyX11(_glfw.x11.root,
565 _glfw.x11.NET_SUPPORTED,
566 XA_ATOM,
567 (unsigned char**) &supportedAtoms);
568
569 // See which of the atoms we support that are supported by the WM
570
571 _glfw.x11.NET_WM_STATE =
572 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE");
573 _glfw.x11.NET_WM_STATE_ABOVE =
574 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
575 _glfw.x11.NET_WM_STATE_FULLSCREEN =
576 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
577 _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
578 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
579 _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
580 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
581 _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
582 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
583 _glfw.x11.NET_WM_FULLSCREEN_MONITORS =
584 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
585 _glfw.x11.NET_WM_WINDOW_TYPE =
586 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
587 _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
588 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
589 _glfw.x11.NET_WORKAREA =
590 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA");
591 _glfw.x11.NET_CURRENT_DESKTOP =
592 getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP");
593 _glfw.x11.NET_ACTIVE_WINDOW =
594 getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
595 _glfw.x11.NET_FRAME_EXTENTS =
596 getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
597 _glfw.x11.NET_REQUEST_FRAME_EXTENTS =
598 getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
599
600 if (supportedAtoms)
601 XFree(supportedAtoms);
602}
603
604// Look for and initialize supported X11 extensions
605//
606static GLFWbool initExtensions(void)
607{
608#if defined(__OpenBSD__) || defined(__NetBSD__)
609 _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so");
610#else
611 _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1");
612#endif
613 if (_glfw.x11.vidmode.handle)
614 {
615 _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
616 _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
617 _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
618 _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
619 _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp)
620 _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
621 _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize)
622 _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
623
624 _glfw.x11.vidmode.available =
625 XF86VidModeQueryExtension(_glfw.x11.display,
626 &_glfw.x11.vidmode.eventBase,
627 &_glfw.x11.vidmode.errorBase);
628 }
629
630#if defined(__CYGWIN__)
631 _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so");
632#elif defined(__OpenBSD__) || defined(__NetBSD__)
633 _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so");
634#else
635 _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6");
636#endif
637 if (_glfw.x11.xi.handle)
638 {
639 _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion)
640 _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XIQueryVersion");
641 _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents)
642 _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XISelectEvents");
643
644 if (XQueryExtension(_glfw.x11.display,
645 "XInputExtension",
646 &_glfw.x11.xi.majorOpcode,
647 &_glfw.x11.xi.eventBase,
648 &_glfw.x11.xi.errorBase))
649 {
650 _glfw.x11.xi.major = 2;
651 _glfw.x11.xi.minor = 0;
652
653 if (XIQueryVersion(_glfw.x11.display,
654 &_glfw.x11.xi.major,
655 &_glfw.x11.xi.minor) == Success)
656 {
657 _glfw.x11.xi.available = GLFW_TRUE;
658 }
659 }
660 }
661
662#if defined(__CYGWIN__)
663 _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so");
664#elif defined(__OpenBSD__) || defined(__NetBSD__)
665 _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so");
666#else
667 _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2");
668#endif
669 if (_glfw.x11.randr.handle)
670 {
671 _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma)
672 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRAllocGamma");
673 _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
674 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma");
675 _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo)
676 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeCrtcInfo");
677 _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
678 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma");
679 _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo)
680 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeOutputInfo");
681 _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources)
682 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeScreenResources");
683 _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma)
684 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGamma");
685 _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize)
686 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize");
687 _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo)
688 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcInfo");
689 _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo)
690 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputInfo");
691 _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary)
692 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputPrimary");
693 _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent)
694 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent");
695 _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension)
696 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryExtension");
697 _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion)
698 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryVersion");
699 _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput)
700 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSelectInput");
701 _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig)
702 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcConfig");
703 _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma)
704 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcGamma");
705 _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration)
706 _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRUpdateConfiguration");
707
708 if (XRRQueryExtension(_glfw.x11.display,
709 &_glfw.x11.randr.eventBase,
710 &_glfw.x11.randr.errorBase))
711 {
712 if (XRRQueryVersion(_glfw.x11.display,
713 &_glfw.x11.randr.major,
714 &_glfw.x11.randr.minor))
715 {
716 // The GLFW RandR path requires at least version 1.3
717 if (_glfw.x11.randr.major > 1 || _glfw.x11.randr.minor >= 3)
718 _glfw.x11.randr.available = GLFW_TRUE;
719 }
720 else
721 {
722 _glfwInputError(GLFW_PLATFORM_ERROR,
723 "X11: Failed to query RandR version");
724 }
725 }
726 }
727
728 if (_glfw.x11.randr.available)
729 {
730 XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
731 _glfw.x11.root);
732
733 if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
734 {
735 // This is likely an older Nvidia driver with broken gamma support
736 // Flag it as useless and fall back to xf86vm gamma, if available
737 _glfw.x11.randr.gammaBroken = GLFW_TRUE;
738 }
739
740 if (!sr->ncrtc)
741 {
742 // A system without CRTCs is likely a system with broken RandR
743 // Disable the RandR monitor path and fall back to core functions
744 _glfw.x11.randr.monitorBroken = GLFW_TRUE;
745 }
746
747 XRRFreeScreenResources(sr);
748 }
749
750 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
751 {
752 XRRSelectInput(_glfw.x11.display, _glfw.x11.root,
753 RROutputChangeNotifyMask);
754 }
755
756#if defined(__CYGWIN__)
757 _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so");
758#elif defined(__OpenBSD__) || defined(__NetBSD__)
759 _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so");
760#else
761 _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1");
762#endif
763 if (_glfw.x11.xcursor.handle)
764 {
765 _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate)
766 _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageCreate");
767 _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy)
768 _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
769 _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
770 _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
771 _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme)
772 _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetTheme");
773 _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize)
774 _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize");
775 _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage)
776 _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage");
777 }
778
779#if defined(__CYGWIN__)
780 _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so");
781#elif defined(__OpenBSD__) || defined(__NetBSD__)
782 _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so");
783#else
784 _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1");
785#endif
786 if (_glfw.x11.xinerama.handle)
787 {
788 _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive)
789 _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaIsActive");
790 _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension)
791 _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryExtension");
792 _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens)
793 _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryScreens");
794
795 if (XineramaQueryExtension(_glfw.x11.display,
796 &_glfw.x11.xinerama.major,
797 &_glfw.x11.xinerama.minor))
798 {
799 if (XineramaIsActive(_glfw.x11.display))
800 _glfw.x11.xinerama.available = GLFW_TRUE;
801 }
802 }
803
804 _glfw.x11.xkb.major = 1;
805 _glfw.x11.xkb.minor = 0;
806 _glfw.x11.xkb.available =
807 XkbQueryExtension(_glfw.x11.display,
808 &_glfw.x11.xkb.majorOpcode,
809 &_glfw.x11.xkb.eventBase,
810 &_glfw.x11.xkb.errorBase,
811 &_glfw.x11.xkb.major,
812 &_glfw.x11.xkb.minor);
813
814 if (_glfw.x11.xkb.available)
815 {
816 Bool supported;
817
818 if (XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))
819 {
820 if (supported)
821 _glfw.x11.xkb.detectable = GLFW_TRUE;
822 }
823
824 XkbStateRec state;
825 if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
826 _glfw.x11.xkb.group = (unsigned int)state.group;
827
828 XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify,
829 XkbGroupStateMask, XkbGroupStateMask);
830 }
831
832 if (_glfw.hints.init.x11.xcbVulkanSurface)
833 {
834#if defined(__CYGWIN__)
835 _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so");
836#elif defined(__OpenBSD__) || defined(__NetBSD__)
837 _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so");
838#else
839 _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1");
840#endif
841 }
842
843 if (_glfw.x11.x11xcb.handle)
844 {
845 _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
846 _glfwPlatformGetModuleSymbol(_glfw.x11.x11xcb.handle, "XGetXCBConnection");
847 }
848
849#if defined(__CYGWIN__)
850 _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so");
851#elif defined(__OpenBSD__) || defined(__NetBSD__)
852 _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so");
853#else
854 _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1");
855#endif
856 if (_glfw.x11.xrender.handle)
857 {
858 _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension)
859 _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryExtension");
860 _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion)
861 _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryVersion");
862 _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat)
863 _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderFindVisualFormat");
864
865 if (XRenderQueryExtension(_glfw.x11.display,
866 &_glfw.x11.xrender.errorBase,
867 &_glfw.x11.xrender.eventBase))
868 {
869 if (XRenderQueryVersion(_glfw.x11.display,
870 &_glfw.x11.xrender.major,
871 &_glfw.x11.xrender.minor))
872 {
873 _glfw.x11.xrender.available = GLFW_TRUE;
874 }
875 }
876 }
877
878#if defined(__CYGWIN__)
879 _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so");
880#elif defined(__OpenBSD__) || defined(__NetBSD__)
881 _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so");
882#else
883 _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6");
884#endif
885 if (_glfw.x11.xshape.handle)
886 {
887 _glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension)
888 _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryExtension");
889 _glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion)
890 _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineRegion");
891 _glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion)
892 _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryVersion");
893 _glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask)
894 _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineMask");
895
896 if (XShapeQueryExtension(_glfw.x11.display,
897 &_glfw.x11.xshape.errorBase,
898 &_glfw.x11.xshape.eventBase))
899 {
900 if (XShapeQueryVersion(_glfw.x11.display,
901 &_glfw.x11.xshape.major,
902 &_glfw.x11.xshape.minor))
903 {
904 _glfw.x11.xshape.available = GLFW_TRUE;
905 }
906 }
907 }
908
909 // Update the key code LUT
910 // FIXME: We should listen to XkbMapNotify events to track changes to
911 // the keyboard mapping.
912 createKeyTablesX11();
913
914 // String format atoms
915 _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
916 _glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
917 _glfw.x11.ATOM_PAIR = XInternAtom(_glfw.x11.display, "ATOM_PAIR", False);
918
919 // Custom selection property atom
920 _glfw.x11.GLFW_SELECTION =
921 XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
922
923 // ICCCM standard clipboard atoms
924 _glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False);
925 _glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
926 _glfw.x11.PRIMARY = XInternAtom(_glfw.x11.display, "PRIMARY", False);
927 _glfw.x11.INCR = XInternAtom(_glfw.x11.display, "INCR", False);
928 _glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
929
930 // Clipboard manager atoms
931 _glfw.x11.CLIPBOARD_MANAGER =
932 XInternAtom(_glfw.x11.display, "CLIPBOARD_MANAGER", False);
933 _glfw.x11.SAVE_TARGETS =
934 XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False);
935
936 // Xdnd (drag and drop) atoms
937 _glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", False);
938 _glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", False);
939 _glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", False);
940 _glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", False);
941 _glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", False);
942 _glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", False);
943 _glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", False);
944 _glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
945 _glfw.x11.XdndTypeList = XInternAtom(_glfw.x11.display, "XdndTypeList", False);
946 _glfw.x11.text_uri_list = XInternAtom(_glfw.x11.display, "text/uri-list", False);
947
948 // ICCCM, EWMH and Motif window property atoms
949 // These can be set safely even without WM support
950 // The EWMH atoms that require WM support are handled in detectEWMH
951 _glfw.x11.WM_PROTOCOLS =
952 XInternAtom(_glfw.x11.display, "WM_PROTOCOLS", False);
953 _glfw.x11.WM_STATE =
954 XInternAtom(_glfw.x11.display, "WM_STATE", False);
955 _glfw.x11.WM_DELETE_WINDOW =
956 XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
957 _glfw.x11.NET_SUPPORTED =
958 XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
959 _glfw.x11.NET_SUPPORTING_WM_CHECK =
960 XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
961 _glfw.x11.NET_WM_ICON =
962 XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
963 _glfw.x11.NET_WM_PING =
964 XInternAtom(_glfw.x11.display, "_NET_WM_PING", False);
965 _glfw.x11.NET_WM_PID =
966 XInternAtom(_glfw.x11.display, "_NET_WM_PID", False);
967 _glfw.x11.NET_WM_NAME =
968 XInternAtom(_glfw.x11.display, "_NET_WM_NAME", False);
969 _glfw.x11.NET_WM_ICON_NAME =
970 XInternAtom(_glfw.x11.display, "_NET_WM_ICON_NAME", False);
971 _glfw.x11.NET_WM_BYPASS_COMPOSITOR =
972 XInternAtom(_glfw.x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
973 _glfw.x11.NET_WM_WINDOW_OPACITY =
974 XInternAtom(_glfw.x11.display, "_NET_WM_WINDOW_OPACITY", False);
975 _glfw.x11.MOTIF_WM_HINTS =
976 XInternAtom(_glfw.x11.display, "_MOTIF_WM_HINTS", False);
977
978 // The compositing manager selection name contains the screen number
979 {
980 char name[32];
981 snprintf(name, sizeof(name), "_NET_WM_CM_S%u", _glfw.x11.screen);
982 _glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
983 }
984
985 // Detect whether an EWMH-conformant window manager is running
986 detectEWMH();
987
988 return GLFW_TRUE;
989}
990
991// Retrieve system content scale via folklore heuristics
992//
993static void getSystemContentScale(float* xscale, float* yscale)
994{
995 // Start by assuming the default X11 DPI
996 // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
997 // would be set to 96, so assume that is the case if we cannot find it
998 float xdpi = 96.f, ydpi = 96.f;
999
1000 // NOTE: Basing the scale on Xft.dpi where available should provide the most
1001 // consistent user experience (matches Qt, Gtk, etc), although not
1002 // always the most accurate one
1003 char* rms = XResourceManagerString(_glfw.x11.display);
1004 if (rms)
1005 {
1006 XrmDatabase db = XrmGetStringDatabase(rms);
1007 if (db)
1008 {
1009 XrmValue value;
1010 char* type = NULL;
1011
1012 if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
1013 {
1014 if (type && strcmp(type, "String") == 0)
1015 xdpi = ydpi = atof(value.addr);
1016 }
1017
1018 XrmDestroyDatabase(db);
1019 }
1020 }
1021
1022 *xscale = xdpi / 96.f;
1023 *yscale = ydpi / 96.f;
1024}
1025
1026// Create a blank cursor for hidden and disabled cursor modes
1027//
1028static Cursor createHiddenCursor(void)
1029{
1030 unsigned char pixels[16 * 16 * 4] = { 0 };
1031 GLFWimage image = { 16, 16, pixels };
1032 return _glfwCreateNativeCursorX11(&image, 0, 0);
1033}
1034
1035// Create a helper window for IPC
1036//
1037static Window createHelperWindow(void)
1038{
1039 XSetWindowAttributes wa;
1040 wa.event_mask = PropertyChangeMask;
1041
1042 return XCreateWindow(_glfw.x11.display, _glfw.x11.root,
1043 0, 0, 1, 1, 0, 0,
1044 InputOnly,
1045 DefaultVisual(_glfw.x11.display, _glfw.x11.screen),
1046 CWEventMask, &wa);
1047}
1048
1049// Create the pipe for empty events without assumuing the OS has pipe2(2)
1050//
1051static GLFWbool createEmptyEventPipe(void)
1052{
1053 if (pipe(_glfw.x11.emptyEventPipe) != 0)
1054 {
1055 _glfwInputError(GLFW_PLATFORM_ERROR,
1056 "X11: Failed to create empty event pipe: %s",
1057 strerror(errno));
1058 return GLFW_FALSE;
1059 }
1060
1061 for (int i = 0; i < 2; i++)
1062 {
1063 const int sf = fcntl(_glfw.x11.emptyEventPipe[i], F_GETFL, 0);
1064 const int df = fcntl(_glfw.x11.emptyEventPipe[i], F_GETFD, 0);
1065
1066 if (sf == -1 || df == -1 ||
1067 fcntl(_glfw.x11.emptyEventPipe[i], F_SETFL, sf | O_NONBLOCK) == -1 ||
1068 fcntl(_glfw.x11.emptyEventPipe[i], F_SETFD, df | FD_CLOEXEC) == -1)
1069 {
1070 _glfwInputError(GLFW_PLATFORM_ERROR,
1071 "X11: Failed to set flags for empty event pipe: %s",
1072 strerror(errno));
1073 return GLFW_FALSE;
1074 }
1075 }
1076
1077 return GLFW_TRUE;
1078}
1079
1080// X error handler
1081//
1082static int errorHandler(Display *display, XErrorEvent* event)
1083{
1084 if (_glfw.x11.display != display)
1085 return 0;
1086
1087 _glfw.x11.errorCode = event->error_code;
1088 return 0;
1089}
1090
1091
1092//////////////////////////////////////////////////////////////////////////
1093////// GLFW internal API //////
1094//////////////////////////////////////////////////////////////////////////
1095
1096// Sets the X error handler callback
1097//
1098void _glfwGrabErrorHandlerX11(void)
1099{
1100 assert(_glfw.x11.errorHandler == NULL);
1101 _glfw.x11.errorCode = Success;
1102 _glfw.x11.errorHandler = XSetErrorHandler(errorHandler);
1103}
1104
1105// Clears the X error handler callback
1106//
1107void _glfwReleaseErrorHandlerX11(void)
1108{
1109 // Synchronize to make sure all commands are processed
1110 XSync(_glfw.x11.display, False);
1111 XSetErrorHandler(_glfw.x11.errorHandler);
1112 _glfw.x11.errorHandler = NULL;
1113}
1114
1115// Reports the specified error, appending information about the last X error
1116//
1117void _glfwInputErrorX11(int error, const char* message)
1118{
1119 char buffer[_GLFW_MESSAGE_SIZE];
1120 XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
1121 buffer, sizeof(buffer));
1122
1123 _glfwInputError(error, "%s: %s", message, buffer);
1124}
1125
1126// Creates a native cursor object from the specified image and hotspot
1127//
1128Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot)
1129{
1130 Cursor cursor;
1131
1132 if (!_glfw.x11.xcursor.handle)
1133 return None;
1134
1135 XcursorImage* native = XcursorImageCreate(image->width, image->height);
1136 if (native == NULL)
1137 return None;
1138
1139 native->xhot = xhot;
1140 native->yhot = yhot;
1141
1142 unsigned char* source = (unsigned char*) image->pixels;
1143 XcursorPixel* target = native->pixels;
1144
1145 for (int i = 0; i < image->width * image->height; i++, target++, source += 4)
1146 {
1147 unsigned int alpha = source[3];
1148
1149 *target = (alpha << 24) |
1150 ((unsigned char) ((source[0] * alpha) / 255) << 16) |
1151 ((unsigned char) ((source[1] * alpha) / 255) << 8) |
1152 ((unsigned char) ((source[2] * alpha) / 255) << 0);
1153 }
1154
1155 cursor = XcursorImageLoadCursor(_glfw.x11.display, native);
1156 XcursorImageDestroy(native);
1157
1158 return cursor;
1159}
1160
1161
1162//////////////////////////////////////////////////////////////////////////
1163////// GLFW platform API //////
1164//////////////////////////////////////////////////////////////////////////
1165
1166GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
1167{
1168 const _GLFWplatform x11 =
1169 {
1170 .platformID = GLFW_PLATFORM_X11,
1171 .init = _glfwInitX11,
1172 .terminate = _glfwTerminateX11,
1173 .getCursorPos = _glfwGetCursorPosX11,
1174 .setCursorPos = _glfwSetCursorPosX11,
1175 .setCursorMode = _glfwSetCursorModeX11,
1176 .setRawMouseMotion = _glfwSetRawMouseMotionX11,
1177 .rawMouseMotionSupported = _glfwRawMouseMotionSupportedX11,
1178 .createCursor = _glfwCreateCursorX11,
1179 .createStandardCursor = _glfwCreateStandardCursorX11,
1180 .destroyCursor = _glfwDestroyCursorX11,
1181 .setCursor = _glfwSetCursorX11,
1182 .getScancodeName = _glfwGetScancodeNameX11,
1183 .getKeyScancode = _glfwGetKeyScancodeX11,
1184 .setClipboardString = _glfwSetClipboardStringX11,
1185 .getClipboardString = _glfwGetClipboardStringX11,
1186#if defined(GLFW_BUILD_LINUX_JOYSTICK)
1187 .initJoysticks = _glfwInitJoysticksLinux,
1188 .terminateJoysticks = _glfwTerminateJoysticksLinux,
1189 .pollJoystick = _glfwPollJoystickLinux,
1190 .getMappingName = _glfwGetMappingNameLinux,
1191 .updateGamepadGUID = _glfwUpdateGamepadGUIDLinux,
1192#else
1193 .initJoysticks = _glfwInitJoysticksNull,
1194 .terminateJoysticks = _glfwTerminateJoysticksNull,
1195 .pollJoystick = _glfwPollJoystickNull,
1196 .getMappingName = _glfwGetMappingNameNull,
1197 .updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
1198#endif
1199 .freeMonitor = _glfwFreeMonitorX11,
1200 .getMonitorPos = _glfwGetMonitorPosX11,
1201 .getMonitorContentScale = _glfwGetMonitorContentScaleX11,
1202 .getMonitorWorkarea = _glfwGetMonitorWorkareaX11,
1203 .getVideoModes = _glfwGetVideoModesX11,
1204 .getVideoMode = _glfwGetVideoModeX11,
1205 .getGammaRamp = _glfwGetGammaRampX11,
1206 .setGammaRamp = _glfwSetGammaRampX11,
1207 .createWindow = _glfwCreateWindowX11,
1208 .destroyWindow = _glfwDestroyWindowX11,
1209 .setWindowTitle = _glfwSetWindowTitleX11,
1210 .setWindowIcon = _glfwSetWindowIconX11,
1211 .getWindowPos = _glfwGetWindowPosX11,
1212 .setWindowPos = _glfwSetWindowPosX11,
1213 .getWindowSize = _glfwGetWindowSizeX11,
1214 .setWindowSize = _glfwSetWindowSizeX11,
1215 .setWindowSizeLimits = _glfwSetWindowSizeLimitsX11,
1216 .setWindowAspectRatio = _glfwSetWindowAspectRatioX11,
1217 .getFramebufferSize = _glfwGetFramebufferSizeX11,
1218 .getWindowFrameSize = _glfwGetWindowFrameSizeX11,
1219 .getWindowContentScale = _glfwGetWindowContentScaleX11,
1220 .iconifyWindow = _glfwIconifyWindowX11,
1221 .restoreWindow = _glfwRestoreWindowX11,
1222 .maximizeWindow = _glfwMaximizeWindowX11,
1223 .showWindow = _glfwShowWindowX11,
1224 .hideWindow = _glfwHideWindowX11,
1225 .requestWindowAttention = _glfwRequestWindowAttentionX11,
1226 .focusWindow = _glfwFocusWindowX11,
1227 .setWindowMonitor = _glfwSetWindowMonitorX11,
1228 .windowFocused = _glfwWindowFocusedX11,
1229 .windowIconified = _glfwWindowIconifiedX11,
1230 .windowVisible = _glfwWindowVisibleX11,
1231 .windowMaximized = _glfwWindowMaximizedX11,
1232 .windowHovered = _glfwWindowHoveredX11,
1233 .framebufferTransparent = _glfwFramebufferTransparentX11,
1234 .getWindowOpacity = _glfwGetWindowOpacityX11,
1235 .setWindowResizable = _glfwSetWindowResizableX11,
1236 .setWindowDecorated = _glfwSetWindowDecoratedX11,
1237 .setWindowFloating = _glfwSetWindowFloatingX11,
1238 .setWindowOpacity = _glfwSetWindowOpacityX11,
1239 .setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11,
1240 .pollEvents = _glfwPollEventsX11,
1241 .waitEvents = _glfwWaitEventsX11,
1242 .waitEventsTimeout = _glfwWaitEventsTimeoutX11,
1243 .postEmptyEvent = _glfwPostEmptyEventX11,
1244 .getEGLPlatform = _glfwGetEGLPlatformX11,
1245 .getEGLNativeDisplay = _glfwGetEGLNativeDisplayX11,
1246 .getEGLNativeWindow = _glfwGetEGLNativeWindowX11,
1247 .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsX11,
1248 .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportX11,
1249 .createWindowSurface = _glfwCreateWindowSurfaceX11
1250 };
1251
1252 // HACK: If the application has left the locale as "C" then both wide
1253 // character text input and explicit UTF-8 input via XIM will break
1254 // This sets the CTYPE part of the current locale from the environment
1255 // in the hope that it is set to something more sane than "C"
1256 if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
1257 setlocale(LC_CTYPE, "");
1258
1259#if defined(__CYGWIN__)
1260 void* module = _glfwPlatformLoadModule("libX11-6.so");
1261#elif defined(__OpenBSD__) || defined(__NetBSD__)
1262 void* module = _glfwPlatformLoadModule("libX11.so");
1263#else
1264 void* module = _glfwPlatformLoadModule("libX11.so.6");
1265#endif
1266 if (!module)
1267 {
1268 if (platformID == GLFW_PLATFORM_X11)
1269 _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib");
1270
1271 return GLFW_FALSE;
1272 }
1273
1274 PFN_XInitThreads XInitThreads = (PFN_XInitThreads)
1275 _glfwPlatformGetModuleSymbol(module, "XInitThreads");
1276 PFN_XrmInitialize XrmInitialize = (PFN_XrmInitialize)
1277 _glfwPlatformGetModuleSymbol(module, "XrmInitialize");
1278 PFN_XOpenDisplay XOpenDisplay = (PFN_XOpenDisplay)
1279 _glfwPlatformGetModuleSymbol(module, "XOpenDisplay");
1280 if (!XInitThreads || !XrmInitialize || !XOpenDisplay)
1281 {
1282 if (platformID == GLFW_PLATFORM_X11)
1283 _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib entry point");
1284
1285 _glfwPlatformFreeModule(module);
1286 return GLFW_FALSE;
1287 }
1288
1289 XInitThreads();
1290 XrmInitialize();
1291
1292 Display* display = XOpenDisplay(NULL);
1293 if (!display)
1294 {
1295 if (platformID == GLFW_PLATFORM_X11)
1296 {
1297 const char* name = getenv("DISPLAY");
1298 if (name)
1299 {
1300 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
1301 "X11: Failed to open display %s", name);
1302 }
1303 else
1304 {
1305 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
1306 "X11: The DISPLAY environment variable is missing");
1307 }
1308 }
1309
1310 _glfwPlatformFreeModule(module);
1311 return GLFW_FALSE;
1312 }
1313
1314 _glfw.x11.display = display;
1315 _glfw.x11.xlib.handle = module;
1316
1317 *platform = x11;
1318 return GLFW_TRUE;
1319}
1320
1321int _glfwInitX11(void)
1322{
1323 _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint)
1324 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocClassHint");
1325 _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints)
1326 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocSizeHints");
1327 _glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints)
1328 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocWMHints");
1329 _glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty)
1330 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeProperty");
1331 _glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes)
1332 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeWindowAttributes");
1333 _glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent)
1334 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckIfEvent");
1335 _glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent)
1336 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent");
1337 _glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay)
1338 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseDisplay");
1339 _glfw.x11.xlib.CloseIM = (PFN_XCloseIM)
1340 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseIM");
1341 _glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection)
1342 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XConvertSelection");
1343 _glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap)
1344 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateColormap");
1345 _glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor)
1346 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateFontCursor");
1347 _glfw.x11.xlib.CreateIC = (PFN_XCreateIC)
1348 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateIC");
1349 _glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion)
1350 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateRegion");
1351 _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow)
1352 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateWindow");
1353 _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor)
1354 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDefineCursor");
1355 _glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext)
1356 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteContext");
1357 _glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty)
1358 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteProperty");
1359 _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC)
1360 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyIC");
1361 _glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion)
1362 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyRegion");
1363 _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow)
1364 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyWindow");
1365 _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes)
1366 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDisplayKeycodes");
1367 _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued)
1368 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XEventsQueued");
1369 _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent)
1370 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFilterEvent");
1371 _glfw.x11.xlib.FindContext = (PFN_XFindContext)
1372 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFindContext");
1373 _glfw.x11.xlib.Flush = (PFN_XFlush)
1374 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFlush");
1375 _glfw.x11.xlib.Free = (PFN_XFree)
1376 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFree");
1377 _glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap)
1378 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeColormap");
1379 _glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor)
1380 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeCursor");
1381 _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData)
1382 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeEventData");
1383 _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText)
1384 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetErrorText");
1385 _glfw.x11.xlib.GetEventData = (PFN_XGetEventData)
1386 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetEventData");
1387 _glfw.x11.xlib.GetICValues = (PFN_XGetICValues)
1388 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetICValues");
1389 _glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues)
1390 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetIMValues");
1391 _glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus)
1392 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetInputFocus");
1393 _glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping)
1394 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetKeyboardMapping");
1395 _glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver)
1396 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetScreenSaver");
1397 _glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner)
1398 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetSelectionOwner");
1399 _glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo)
1400 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetVisualInfo");
1401 _glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints)
1402 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWMNormalHints");
1403 _glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes)
1404 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowAttributes");
1405 _glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty)
1406 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowProperty");
1407 _glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer)
1408 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGrabPointer");
1409 _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow)
1410 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XIconifyWindow");
1411 _glfw.x11.xlib.InternAtom = (PFN_XInternAtom)
1412 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInternAtom");
1413 _glfw.x11.xlib.LookupString = (PFN_XLookupString)
1414 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XLookupString");
1415 _glfw.x11.xlib.MapRaised = (PFN_XMapRaised)
1416 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapRaised");
1417 _glfw.x11.xlib.MapWindow = (PFN_XMapWindow)
1418 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapWindow");
1419 _glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow)
1420 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveResizeWindow");
1421 _glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow)
1422 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveWindow");
1423 _glfw.x11.xlib.NextEvent = (PFN_XNextEvent)
1424 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XNextEvent");
1425 _glfw.x11.xlib.OpenIM = (PFN_XOpenIM)
1426 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenIM");
1427 _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent)
1428 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPeekEvent");
1429 _glfw.x11.xlib.Pending = (PFN_XPending)
1430 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPending");
1431 _glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension)
1432 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryExtension");
1433 _glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer)
1434 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryPointer");
1435 _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow)
1436 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRaiseWindow");
1437 _glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback)
1438 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback");
1439 _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow)
1440 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResizeWindow");
1441 _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString)
1442 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResourceManagerString");
1443 _glfw.x11.xlib.SaveContext = (PFN_XSaveContext)
1444 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSaveContext");
1445 _glfw.x11.xlib.SelectInput = (PFN_XSelectInput)
1446 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSelectInput");
1447 _glfw.x11.xlib.SendEvent = (PFN_XSendEvent)
1448 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSendEvent");
1449 _glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint)
1450 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetClassHint");
1451 _glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler)
1452 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetErrorHandler");
1453 _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus)
1454 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetICFocus");
1455 _glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues)
1456 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetIMValues");
1457 _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus)
1458 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetInputFocus");
1459 _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers)
1460 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetLocaleModifiers");
1461 _glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver)
1462 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetScreenSaver");
1463 _glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner)
1464 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetSelectionOwner");
1465 _glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints)
1466 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMHints");
1467 _glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints)
1468 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMNormalHints");
1469 _glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols)
1470 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMProtocols");
1471 _glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale)
1472 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSupportsLocale");
1473 _glfw.x11.xlib.Sync = (PFN_XSync)
1474 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSync");
1475 _glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates)
1476 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XTranslateCoordinates");
1477 _glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor)
1478 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUndefineCursor");
1479 _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer)
1480 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUngrabPointer");
1481 _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow)
1482 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnmapWindow");
1483 _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus)
1484 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnsetICFocus");
1485 _glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual)
1486 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XVisualIDFromVisual");
1487 _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer)
1488 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XWarpPointer");
1489 _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard)
1490 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeKeyboard");
1491 _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames)
1492 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeNames");
1493 _glfw.x11.xkb.GetMap = (PFN_XkbGetMap)
1494 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetMap");
1495 _glfw.x11.xkb.GetNames = (PFN_XkbGetNames)
1496 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetNames");
1497 _glfw.x11.xkb.GetState = (PFN_XkbGetState)
1498 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetState");
1499 _glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym)
1500 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym");
1501 _glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension)
1502 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbQueryExtension");
1503 _glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails)
1504 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSelectEventDetails");
1505 _glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat)
1506 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat");
1507 _glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase)
1508 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmDestroyDatabase");
1509 _glfw.x11.xrm.GetResource = (PFN_XrmGetResource)
1510 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetResource");
1511 _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase)
1512 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetStringDatabase");
1513 _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark)
1514 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmUniqueQuark");
1515 _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback)
1516 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback");
1517 _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString)
1518 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8LookupString");
1519 _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties)
1520 _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8SetWMProperties");
1521
1522 if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties)
1523 _glfw.x11.xlib.utf8 = GLFW_TRUE;
1524
1525 _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
1526 _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
1527 _glfw.x11.context = XUniqueContext();
1528
1529 getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY);
1530
1531 if (!createEmptyEventPipe())
1532 return GLFW_FALSE;
1533
1534 if (!initExtensions())
1535 return GLFW_FALSE;
1536
1537 _glfw.x11.helperWindowHandle = createHelperWindow();
1538 _glfw.x11.hiddenCursorHandle = createHiddenCursor();
1539
1540 if (XSupportsLocale() && _glfw.x11.xlib.utf8)
1541 {
1542 XSetLocaleModifiers("");
1543
1544 // If an IM is already present our callback will be called right away
1545 XRegisterIMInstantiateCallback(_glfw.x11.display,
1546 NULL, NULL, NULL,
1547 inputMethodInstantiateCallback,
1548 NULL);
1549 }
1550
1551 _glfwPollMonitorsX11();
1552 return GLFW_TRUE;
1553}
1554
1555void _glfwTerminateX11(void)
1556{
1557 if (_glfw.x11.helperWindowHandle)
1558 {
1559 if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
1560 _glfw.x11.helperWindowHandle)
1561 {
1562 _glfwPushSelectionToManagerX11();
1563 }
1564
1565 XDestroyWindow(_glfw.x11.display, _glfw.x11.helperWindowHandle);
1566 _glfw.x11.helperWindowHandle = None;
1567 }
1568
1569 if (_glfw.x11.hiddenCursorHandle)
1570 {
1571 XFreeCursor(_glfw.x11.display, _glfw.x11.hiddenCursorHandle);
1572 _glfw.x11.hiddenCursorHandle = (Cursor) 0;
1573 }
1574
1575 _glfw_free(_glfw.x11.primarySelectionString);
1576 _glfw_free(_glfw.x11.clipboardString);
1577
1578 XUnregisterIMInstantiateCallback(_glfw.x11.display,
1579 NULL, NULL, NULL,
1580 inputMethodInstantiateCallback,
1581 NULL);
1582
1583 if (_glfw.x11.im)
1584 {
1585 XCloseIM(_glfw.x11.im);
1586 _glfw.x11.im = NULL;
1587 }
1588
1589 if (_glfw.x11.display)
1590 {
1591 XCloseDisplay(_glfw.x11.display);
1592 _glfw.x11.display = NULL;
1593 }
1594
1595 if (_glfw.x11.x11xcb.handle)
1596 {
1597 _glfwPlatformFreeModule(_glfw.x11.x11xcb.handle);
1598 _glfw.x11.x11xcb.handle = NULL;
1599 }
1600
1601 if (_glfw.x11.xcursor.handle)
1602 {
1603 _glfwPlatformFreeModule(_glfw.x11.xcursor.handle);
1604 _glfw.x11.xcursor.handle = NULL;
1605 }
1606
1607 if (_glfw.x11.randr.handle)
1608 {
1609 _glfwPlatformFreeModule(_glfw.x11.randr.handle);
1610 _glfw.x11.randr.handle = NULL;
1611 }
1612
1613 if (_glfw.x11.xinerama.handle)
1614 {
1615 _glfwPlatformFreeModule(_glfw.x11.xinerama.handle);
1616 _glfw.x11.xinerama.handle = NULL;
1617 }
1618
1619 if (_glfw.x11.xrender.handle)
1620 {
1621 _glfwPlatformFreeModule(_glfw.x11.xrender.handle);
1622 _glfw.x11.xrender.handle = NULL;
1623 }
1624
1625 if (_glfw.x11.vidmode.handle)
1626 {
1627 _glfwPlatformFreeModule(_glfw.x11.vidmode.handle);
1628 _glfw.x11.vidmode.handle = NULL;
1629 }
1630
1631 if (_glfw.x11.xi.handle)
1632 {
1633 _glfwPlatformFreeModule(_glfw.x11.xi.handle);
1634 _glfw.x11.xi.handle = NULL;
1635 }
1636
1637 _glfwTerminateOSMesa();
1638 // NOTE: These need to be unloaded after XCloseDisplay, as they register
1639 // cleanup callbacks that get called by that function
1640 _glfwTerminateEGL();
1641 _glfwTerminateGLX();
1642
1643 if (_glfw.x11.xlib.handle)
1644 {
1645 _glfwPlatformFreeModule(_glfw.x11.xlib.handle);
1646 _glfw.x11.xlib.handle = NULL;
1647 }
1648
1649 if (_glfw.x11.emptyEventPipe[0] || _glfw.x11.emptyEventPipe[1])
1650 {
1651 close(_glfw.x11.emptyEventPipe[0]);
1652 close(_glfw.x11.emptyEventPipe[1]);
1653 }
1654}
1655
1656#endif // _GLFW_X11
1657
diff --git a/raylib/src/external/glfw/src/x11_monitor.c b/raylib/src/external/glfw/src/x11_monitor.c
new file mode 100644
index 0000000..38af7e0
--- /dev/null
+++ b/raylib/src/external/glfw/src/x11_monitor.c
@@ -0,0 +1,641 @@
1//========================================================================
2// GLFW 3.4 X11 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_X11)
31
32#include <limits.h>
33#include <stdlib.h>
34#include <string.h>
35#include <math.h>
36
37
38// Check whether the display mode should be included in enumeration
39//
40static GLFWbool modeIsGood(const XRRModeInfo* mi)
41{
42 return (mi->modeFlags & RR_Interlace) == 0;
43}
44
45// Calculates the refresh rate, in Hz, from the specified RandR mode info
46//
47static int calculateRefreshRate(const XRRModeInfo* mi)
48{
49 if (mi->hTotal && mi->vTotal)
50 return (int) round((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));
51 else
52 return 0;
53}
54
55// Returns the mode info for a RandR mode XID
56//
57static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
58{
59 for (int i = 0; i < sr->nmode; i++)
60 {
61 if (sr->modes[i].id == id)
62 return sr->modes + i;
63 }
64
65 return NULL;
66}
67
68// Convert RandR mode info to GLFW video mode
69//
70static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,
71 const XRRCrtcInfo* ci)
72{
73 GLFWvidmode mode;
74
75 if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
76 {
77 mode.width = mi->height;
78 mode.height = mi->width;
79 }
80 else
81 {
82 mode.width = mi->width;
83 mode.height = mi->height;
84 }
85
86 mode.refreshRate = calculateRefreshRate(mi);
87
88 _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
89 &mode.redBits, &mode.greenBits, &mode.blueBits);
90
91 return mode;
92}
93
94
95//////////////////////////////////////////////////////////////////////////
96////// GLFW internal API //////
97//////////////////////////////////////////////////////////////////////////
98
99// Poll for changes in the set of connected monitors
100//
101void _glfwPollMonitorsX11(void)
102{
103 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
104 {
105 int disconnectedCount, screenCount = 0;
106 _GLFWmonitor** disconnected = NULL;
107 XineramaScreenInfo* screens = NULL;
108 XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
109 _glfw.x11.root);
110 RROutput primary = XRRGetOutputPrimary(_glfw.x11.display,
111 _glfw.x11.root);
112
113 if (_glfw.x11.xinerama.available)
114 screens = XineramaQueryScreens(_glfw.x11.display, &screenCount);
115
116 disconnectedCount = _glfw.monitorCount;
117 if (disconnectedCount)
118 {
119 disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
120 memcpy(disconnected,
121 _glfw.monitors,
122 _glfw.monitorCount * sizeof(_GLFWmonitor*));
123 }
124
125 for (int i = 0; i < sr->noutput; i++)
126 {
127 int j, type, widthMM, heightMM;
128
129 XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
130 if (oi->connection != RR_Connected || oi->crtc == None)
131 {
132 XRRFreeOutputInfo(oi);
133 continue;
134 }
135
136 for (j = 0; j < disconnectedCount; j++)
137 {
138 if (disconnected[j] &&
139 disconnected[j]->x11.output == sr->outputs[i])
140 {
141 disconnected[j] = NULL;
142 break;
143 }
144 }
145
146 if (j < disconnectedCount)
147 {
148 XRRFreeOutputInfo(oi);
149 continue;
150 }
151
152 XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
153 if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
154 {
155 widthMM = oi->mm_height;
156 heightMM = oi->mm_width;
157 }
158 else
159 {
160 widthMM = oi->mm_width;
161 heightMM = oi->mm_height;
162 }
163
164 if (widthMM <= 0 || heightMM <= 0)
165 {
166 // HACK: If RandR does not provide a physical size, assume the
167 // X11 default 96 DPI and calculate from the CRTC viewport
168 // NOTE: These members are affected by rotation, unlike the mode
169 // info and output info members
170 widthMM = (int) (ci->width * 25.4f / 96.f);
171 heightMM = (int) (ci->height * 25.4f / 96.f);
172 }
173
174 _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
175 monitor->x11.output = sr->outputs[i];
176 monitor->x11.crtc = oi->crtc;
177
178 for (j = 0; j < screenCount; j++)
179 {
180 if (screens[j].x_org == ci->x &&
181 screens[j].y_org == ci->y &&
182 screens[j].width == ci->width &&
183 screens[j].height == ci->height)
184 {
185 monitor->x11.index = j;
186 break;
187 }
188 }
189
190 if (monitor->x11.output == primary)
191 type = _GLFW_INSERT_FIRST;
192 else
193 type = _GLFW_INSERT_LAST;
194
195 _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
196
197 XRRFreeOutputInfo(oi);
198 XRRFreeCrtcInfo(ci);
199 }
200
201 XRRFreeScreenResources(sr);
202
203 if (screens)
204 XFree(screens);
205
206 for (int i = 0; i < disconnectedCount; i++)
207 {
208 if (disconnected[i])
209 _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
210 }
211
212 _glfw_free(disconnected);
213 }
214 else
215 {
216 const int widthMM = DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
217 const int heightMM = DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
218
219 _glfwInputMonitor(_glfwAllocMonitor("Display", widthMM, heightMM),
220 GLFW_CONNECTED,
221 _GLFW_INSERT_FIRST);
222 }
223}
224
225// Set the current video mode for the specified monitor
226//
227void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
228{
229 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
230 {
231 GLFWvidmode current;
232 RRMode native = None;
233
234 const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
235 _glfwGetVideoModeX11(monitor, &current);
236 if (_glfwCompareVideoModes(&current, best) == 0)
237 return;
238
239 XRRScreenResources* sr =
240 XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
241 XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
242 XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
243
244 for (int i = 0; i < oi->nmode; i++)
245 {
246 const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
247 if (!modeIsGood(mi))
248 continue;
249
250 const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
251 if (_glfwCompareVideoModes(best, &mode) == 0)
252 {
253 native = mi->id;
254 break;
255 }
256 }
257
258 if (native)
259 {
260 if (monitor->x11.oldMode == None)
261 monitor->x11.oldMode = ci->mode;
262
263 XRRSetCrtcConfig(_glfw.x11.display,
264 sr, monitor->x11.crtc,
265 CurrentTime,
266 ci->x, ci->y,
267 native,
268 ci->rotation,
269 ci->outputs,
270 ci->noutput);
271 }
272
273 XRRFreeOutputInfo(oi);
274 XRRFreeCrtcInfo(ci);
275 XRRFreeScreenResources(sr);
276 }
277}
278
279// Restore the saved (original) video mode for the specified monitor
280//
281void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
282{
283 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
284 {
285 if (monitor->x11.oldMode == None)
286 return;
287
288 XRRScreenResources* sr =
289 XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
290 XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
291
292 XRRSetCrtcConfig(_glfw.x11.display,
293 sr, monitor->x11.crtc,
294 CurrentTime,
295 ci->x, ci->y,
296 monitor->x11.oldMode,
297 ci->rotation,
298 ci->outputs,
299 ci->noutput);
300
301 XRRFreeCrtcInfo(ci);
302 XRRFreeScreenResources(sr);
303
304 monitor->x11.oldMode = None;
305 }
306}
307
308
309//////////////////////////////////////////////////////////////////////////
310////// GLFW platform API //////
311//////////////////////////////////////////////////////////////////////////
312
313void _glfwFreeMonitorX11(_GLFWmonitor* monitor)
314{
315}
316
317void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos)
318{
319 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
320 {
321 XRRScreenResources* sr =
322 XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
323 XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
324
325 if (ci)
326 {
327 if (xpos)
328 *xpos = ci->x;
329 if (ypos)
330 *ypos = ci->y;
331
332 XRRFreeCrtcInfo(ci);
333 }
334
335 XRRFreeScreenResources(sr);
336 }
337}
338
339void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor,
340 float* xscale, float* yscale)
341{
342 if (xscale)
343 *xscale = _glfw.x11.contentScaleX;
344 if (yscale)
345 *yscale = _glfw.x11.contentScaleY;
346}
347
348void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor,
349 int* xpos, int* ypos,
350 int* width, int* height)
351{
352 int areaX = 0, areaY = 0, areaWidth = 0, areaHeight = 0;
353
354 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
355 {
356 XRRScreenResources* sr =
357 XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
358 XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
359
360 areaX = ci->x;
361 areaY = ci->y;
362
363 const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
364
365 if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
366 {
367 areaWidth = mi->height;
368 areaHeight = mi->width;
369 }
370 else
371 {
372 areaWidth = mi->width;
373 areaHeight = mi->height;
374 }
375
376 XRRFreeCrtcInfo(ci);
377 XRRFreeScreenResources(sr);
378 }
379 else
380 {
381 areaWidth = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
382 areaHeight = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
383 }
384
385 if (_glfw.x11.NET_WORKAREA && _glfw.x11.NET_CURRENT_DESKTOP)
386 {
387 Atom* extents = NULL;
388 Atom* desktop = NULL;
389 const unsigned long extentCount =
390 _glfwGetWindowPropertyX11(_glfw.x11.root,
391 _glfw.x11.NET_WORKAREA,
392 XA_CARDINAL,
393 (unsigned char**) &extents);
394
395 if (_glfwGetWindowPropertyX11(_glfw.x11.root,
396 _glfw.x11.NET_CURRENT_DESKTOP,
397 XA_CARDINAL,
398 (unsigned char**) &desktop) > 0)
399 {
400 if (extentCount >= 4 && *desktop < extentCount / 4)
401 {
402 const int globalX = extents[*desktop * 4 + 0];
403 const int globalY = extents[*desktop * 4 + 1];
404 const int globalWidth = extents[*desktop * 4 + 2];
405 const int globalHeight = extents[*desktop * 4 + 3];
406
407 if (areaX < globalX)
408 {
409 areaWidth -= globalX - areaX;
410 areaX = globalX;
411 }
412
413 if (areaY < globalY)
414 {
415 areaHeight -= globalY - areaY;
416 areaY = globalY;
417 }
418
419 if (areaX + areaWidth > globalX + globalWidth)
420 areaWidth = globalX - areaX + globalWidth;
421 if (areaY + areaHeight > globalY + globalHeight)
422 areaHeight = globalY - areaY + globalHeight;
423 }
424 }
425
426 if (extents)
427 XFree(extents);
428 if (desktop)
429 XFree(desktop);
430 }
431
432 if (xpos)
433 *xpos = areaX;
434 if (ypos)
435 *ypos = areaY;
436 if (width)
437 *width = areaWidth;
438 if (height)
439 *height = areaHeight;
440}
441
442GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
443{
444 GLFWvidmode* result;
445
446 *count = 0;
447
448 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
449 {
450 XRRScreenResources* sr =
451 XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
452 XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
453 XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
454
455 result = _glfw_calloc(oi->nmode, sizeof(GLFWvidmode));
456
457 for (int i = 0; i < oi->nmode; i++)
458 {
459 const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
460 if (!modeIsGood(mi))
461 continue;
462
463 const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
464 int j;
465
466 for (j = 0; j < *count; j++)
467 {
468 if (_glfwCompareVideoModes(result + j, &mode) == 0)
469 break;
470 }
471
472 // Skip duplicate modes
473 if (j < *count)
474 continue;
475
476 (*count)++;
477 result[*count - 1] = mode;
478 }
479
480 XRRFreeOutputInfo(oi);
481 XRRFreeCrtcInfo(ci);
482 XRRFreeScreenResources(sr);
483 }
484 else
485 {
486 *count = 1;
487 result = _glfw_calloc(1, sizeof(GLFWvidmode));
488 _glfwGetVideoModeX11(monitor, result);
489 }
490
491 return result;
492}
493
494GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
495{
496 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
497 {
498 XRRScreenResources* sr =
499 XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
500 const XRRModeInfo* mi = NULL;
501
502 XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
503 if (ci)
504 {
505 mi = getModeInfo(sr, ci->mode);
506 if (mi)
507 *mode = vidmodeFromModeInfo(mi, ci);
508
509 XRRFreeCrtcInfo(ci);
510 }
511
512 XRRFreeScreenResources(sr);
513
514 if (!mi)
515 {
516 _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to query video mode");
517 return GLFW_FALSE;
518 }
519 }
520 else
521 {
522 mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
523 mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
524 mode->refreshRate = 0;
525
526 _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
527 &mode->redBits, &mode->greenBits, &mode->blueBits);
528 }
529
530 return GLFW_TRUE;
531}
532
533GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
534{
535 if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
536 {
537 const size_t size = XRRGetCrtcGammaSize(_glfw.x11.display,
538 monitor->x11.crtc);
539 XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,
540 monitor->x11.crtc);
541
542 _glfwAllocGammaArrays(ramp, size);
543
544 memcpy(ramp->red, gamma->red, size * sizeof(unsigned short));
545 memcpy(ramp->green, gamma->green, size * sizeof(unsigned short));
546 memcpy(ramp->blue, gamma->blue, size * sizeof(unsigned short));
547
548 XRRFreeGamma(gamma);
549 return GLFW_TRUE;
550 }
551 else if (_glfw.x11.vidmode.available)
552 {
553 int size;
554 XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size);
555
556 _glfwAllocGammaArrays(ramp, size);
557
558 XF86VidModeGetGammaRamp(_glfw.x11.display,
559 _glfw.x11.screen,
560 ramp->size, ramp->red, ramp->green, ramp->blue);
561 return GLFW_TRUE;
562 }
563 else
564 {
565 _glfwInputError(GLFW_PLATFORM_ERROR,
566 "X11: Gamma ramp access not supported by server");
567 return GLFW_FALSE;
568 }
569}
570
571void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
572{
573 if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
574 {
575 if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size)
576 {
577 _glfwInputError(GLFW_PLATFORM_ERROR,
578 "X11: Gamma ramp size must match current ramp size");
579 return;
580 }
581
582 XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size);
583
584 memcpy(gamma->red, ramp->red, ramp->size * sizeof(unsigned short));
585 memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short));
586 memcpy(gamma->blue, ramp->blue, ramp->size * sizeof(unsigned short));
587
588 XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma);
589 XRRFreeGamma(gamma);
590 }
591 else if (_glfw.x11.vidmode.available)
592 {
593 XF86VidModeSetGammaRamp(_glfw.x11.display,
594 _glfw.x11.screen,
595 ramp->size,
596 (unsigned short*) ramp->red,
597 (unsigned short*) ramp->green,
598 (unsigned short*) ramp->blue);
599 }
600 else
601 {
602 _glfwInputError(GLFW_PLATFORM_ERROR,
603 "X11: Gamma ramp access not supported by server");
604 }
605}
606
607
608//////////////////////////////////////////////////////////////////////////
609////// GLFW native API //////
610//////////////////////////////////////////////////////////////////////////
611
612GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
613{
614 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
615 _GLFW_REQUIRE_INIT_OR_RETURN(None);
616
617 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
618 {
619 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
620 return None;
621 }
622
623 return monitor->x11.crtc;
624}
625
626GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
627{
628 _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
629 _GLFW_REQUIRE_INIT_OR_RETURN(None);
630
631 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
632 {
633 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
634 return None;
635 }
636
637 return monitor->x11.output;
638}
639
640#endif // _GLFW_X11
641
diff --git a/raylib/src/external/glfw/src/x11_platform.h b/raylib/src/external/glfw/src/x11_platform.h
new file mode 100644
index 0000000..14e363d
--- /dev/null
+++ b/raylib/src/external/glfw/src/x11_platform.h
@@ -0,0 +1,1004 @@
1//========================================================================
2// GLFW 3.4 X11 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include <unistd.h>
29#include <signal.h>
30#include <stdint.h>
31
32#include <X11/Xlib.h>
33#include <X11/keysym.h>
34#include <X11/Xatom.h>
35#include <X11/Xresource.h>
36#include <X11/Xcursor/Xcursor.h>
37
38// The XRandR extension provides mode setting and gamma control
39#include <X11/extensions/Xrandr.h>
40
41// The Xkb extension provides improved keyboard support
42#include <X11/XKBlib.h>
43
44// The Xinerama extension provides legacy monitor indices
45#include <X11/extensions/Xinerama.h>
46
47// The XInput extension provides raw mouse motion input
48#include <X11/extensions/XInput2.h>
49
50// The Shape extension provides custom window shapes
51#include <X11/extensions/shape.h>
52
53#define GLX_VENDOR 1
54#define GLX_RGBA_BIT 0x00000001
55#define GLX_WINDOW_BIT 0x00000001
56#define GLX_DRAWABLE_TYPE 0x8010
57#define GLX_RENDER_TYPE 0x8011
58#define GLX_RGBA_TYPE 0x8014
59#define GLX_DOUBLEBUFFER 5
60#define GLX_STEREO 6
61#define GLX_AUX_BUFFERS 7
62#define GLX_RED_SIZE 8
63#define GLX_GREEN_SIZE 9
64#define GLX_BLUE_SIZE 10
65#define GLX_ALPHA_SIZE 11
66#define GLX_DEPTH_SIZE 12
67#define GLX_STENCIL_SIZE 13
68#define GLX_ACCUM_RED_SIZE 14
69#define GLX_ACCUM_GREEN_SIZE 15
70#define GLX_ACCUM_BLUE_SIZE 16
71#define GLX_ACCUM_ALPHA_SIZE 17
72#define GLX_SAMPLES 0x186a1
73#define GLX_VISUAL_ID 0x800b
74
75#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
76#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
77#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
78#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
79#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
80#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
81#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
82#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
83#define GLX_CONTEXT_FLAGS_ARB 0x2094
84#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
85#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
86#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
87#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
88#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
89#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
90#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
91#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
92#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
93
94typedef XID GLXWindow;
95typedef XID GLXDrawable;
96typedef struct __GLXFBConfig* GLXFBConfig;
97typedef struct __GLXcontext* GLXContext;
98typedef void (*__GLXextproc)(void);
99
100typedef XClassHint* (* PFN_XAllocClassHint)(void);
101typedef XSizeHints* (* PFN_XAllocSizeHints)(void);
102typedef XWMHints* (* PFN_XAllocWMHints)(void);
103typedef int (* PFN_XChangeProperty)(Display*,Window,Atom,Atom,int,int,const unsigned char*,int);
104typedef int (* PFN_XChangeWindowAttributes)(Display*,Window,unsigned long,XSetWindowAttributes*);
105typedef Bool (* PFN_XCheckIfEvent)(Display*,XEvent*,Bool(*)(Display*,XEvent*,XPointer),XPointer);
106typedef Bool (* PFN_XCheckTypedWindowEvent)(Display*,Window,int,XEvent*);
107typedef int (* PFN_XCloseDisplay)(Display*);
108typedef Status (* PFN_XCloseIM)(XIM);
109typedef int (* PFN_XConvertSelection)(Display*,Atom,Atom,Atom,Window,Time);
110typedef Colormap (* PFN_XCreateColormap)(Display*,Window,Visual*,int);
111typedef Cursor (* PFN_XCreateFontCursor)(Display*,unsigned int);
112typedef XIC (* PFN_XCreateIC)(XIM,...);
113typedef Region (* PFN_XCreateRegion)(void);
114typedef Window (* PFN_XCreateWindow)(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*);
115typedef int (* PFN_XDefineCursor)(Display*,Window,Cursor);
116typedef int (* PFN_XDeleteContext)(Display*,XID,XContext);
117typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom);
118typedef void (* PFN_XDestroyIC)(XIC);
119typedef int (* PFN_XDestroyRegion)(Region);
120typedef int (* PFN_XDestroyWindow)(Display*,Window);
121typedef int (* PFN_XDisplayKeycodes)(Display*,int*,int*);
122typedef int (* PFN_XEventsQueued)(Display*,int);
123typedef Bool (* PFN_XFilterEvent)(XEvent*,Window);
124typedef int (* PFN_XFindContext)(Display*,XID,XContext,XPointer*);
125typedef int (* PFN_XFlush)(Display*);
126typedef int (* PFN_XFree)(void*);
127typedef int (* PFN_XFreeColormap)(Display*,Colormap);
128typedef int (* PFN_XFreeCursor)(Display*,Cursor);
129typedef void (* PFN_XFreeEventData)(Display*,XGenericEventCookie*);
130typedef int (* PFN_XGetErrorText)(Display*,int,char*,int);
131typedef Bool (* PFN_XGetEventData)(Display*,XGenericEventCookie*);
132typedef char* (* PFN_XGetICValues)(XIC,...);
133typedef char* (* PFN_XGetIMValues)(XIM,...);
134typedef int (* PFN_XGetInputFocus)(Display*,Window*,int*);
135typedef KeySym* (* PFN_XGetKeyboardMapping)(Display*,KeyCode,int,int*);
136typedef int (* PFN_XGetScreenSaver)(Display*,int*,int*,int*,int*);
137typedef Window (* PFN_XGetSelectionOwner)(Display*,Atom);
138typedef XVisualInfo* (* PFN_XGetVisualInfo)(Display*,long,XVisualInfo*,int*);
139typedef Status (* PFN_XGetWMNormalHints)(Display*,Window,XSizeHints*,long*);
140typedef Status (* PFN_XGetWindowAttributes)(Display*,Window,XWindowAttributes*);
141typedef int (* PFN_XGetWindowProperty)(Display*,Window,Atom,long,long,Bool,Atom,Atom*,int*,unsigned long*,unsigned long*,unsigned char**);
142typedef int (* PFN_XGrabPointer)(Display*,Window,Bool,unsigned int,int,int,Window,Cursor,Time);
143typedef Status (* PFN_XIconifyWindow)(Display*,Window,int);
144typedef Status (* PFN_XInitThreads)(void);
145typedef Atom (* PFN_XInternAtom)(Display*,const char*,Bool);
146typedef int (* PFN_XLookupString)(XKeyEvent*,char*,int,KeySym*,XComposeStatus*);
147typedef int (* PFN_XMapRaised)(Display*,Window);
148typedef int (* PFN_XMapWindow)(Display*,Window);
149typedef int (* PFN_XMoveResizeWindow)(Display*,Window,int,int,unsigned int,unsigned int);
150typedef int (* PFN_XMoveWindow)(Display*,Window,int,int);
151typedef int (* PFN_XNextEvent)(Display*,XEvent*);
152typedef Display* (* PFN_XOpenDisplay)(const char*);
153typedef XIM (* PFN_XOpenIM)(Display*,XrmDatabase*,char*,char*);
154typedef int (* PFN_XPeekEvent)(Display*,XEvent*);
155typedef int (* PFN_XPending)(Display*);
156typedef Bool (* PFN_XQueryExtension)(Display*,const char*,int*,int*,int*);
157typedef Bool (* PFN_XQueryPointer)(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*);
158typedef int (* PFN_XRaiseWindow)(Display*,Window);
159typedef Bool (* PFN_XRegisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
160typedef int (* PFN_XResizeWindow)(Display*,Window,unsigned int,unsigned int);
161typedef char* (* PFN_XResourceManagerString)(Display*);
162typedef int (* PFN_XSaveContext)(Display*,XID,XContext,const char*);
163typedef int (* PFN_XSelectInput)(Display*,Window,long);
164typedef Status (* PFN_XSendEvent)(Display*,Window,Bool,long,XEvent*);
165typedef int (* PFN_XSetClassHint)(Display*,Window,XClassHint*);
166typedef XErrorHandler (* PFN_XSetErrorHandler)(XErrorHandler);
167typedef void (* PFN_XSetICFocus)(XIC);
168typedef char* (* PFN_XSetIMValues)(XIM,...);
169typedef int (* PFN_XSetInputFocus)(Display*,Window,int,Time);
170typedef char* (* PFN_XSetLocaleModifiers)(const char*);
171typedef int (* PFN_XSetScreenSaver)(Display*,int,int,int,int);
172typedef int (* PFN_XSetSelectionOwner)(Display*,Atom,Window,Time);
173typedef int (* PFN_XSetWMHints)(Display*,Window,XWMHints*);
174typedef void (* PFN_XSetWMNormalHints)(Display*,Window,XSizeHints*);
175typedef Status (* PFN_XSetWMProtocols)(Display*,Window,Atom*,int);
176typedef Bool (* PFN_XSupportsLocale)(void);
177typedef int (* PFN_XSync)(Display*,Bool);
178typedef Bool (* PFN_XTranslateCoordinates)(Display*,Window,Window,int,int,int*,int*,Window*);
179typedef int (* PFN_XUndefineCursor)(Display*,Window);
180typedef int (* PFN_XUngrabPointer)(Display*,Time);
181typedef int (* PFN_XUnmapWindow)(Display*,Window);
182typedef void (* PFN_XUnsetICFocus)(XIC);
183typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*);
184typedef int (* PFN_XWarpPointer)(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int);
185typedef void (* PFN_XkbFreeKeyboard)(XkbDescPtr,unsigned int,Bool);
186typedef void (* PFN_XkbFreeNames)(XkbDescPtr,unsigned int,Bool);
187typedef XkbDescPtr (* PFN_XkbGetMap)(Display*,unsigned int,unsigned int);
188typedef Status (* PFN_XkbGetNames)(Display*,unsigned int,XkbDescPtr);
189typedef Status (* PFN_XkbGetState)(Display*,unsigned int,XkbStatePtr);
190typedef KeySym (* PFN_XkbKeycodeToKeysym)(Display*,KeyCode,int,int);
191typedef Bool (* PFN_XkbQueryExtension)(Display*,int*,int*,int*,int*,int*);
192typedef Bool (* PFN_XkbSelectEventDetails)(Display*,unsigned int,unsigned int,unsigned long,unsigned long);
193typedef Bool (* PFN_XkbSetDetectableAutoRepeat)(Display*,Bool,Bool*);
194typedef void (* PFN_XrmDestroyDatabase)(XrmDatabase);
195typedef Bool (* PFN_XrmGetResource)(XrmDatabase,const char*,const char*,char**,XrmValue*);
196typedef XrmDatabase (* PFN_XrmGetStringDatabase)(const char*);
197typedef void (* PFN_XrmInitialize)(void);
198typedef XrmQuark (* PFN_XrmUniqueQuark)(void);
199typedef Bool (* PFN_XUnregisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
200typedef int (* PFN_Xutf8LookupString)(XIC,XKeyPressedEvent*,char*,int,KeySym*,Status*);
201typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char*,char**,int,XSizeHints*,XWMHints*,XClassHint*);
202#define XAllocClassHint _glfw.x11.xlib.AllocClassHint
203#define XAllocSizeHints _glfw.x11.xlib.AllocSizeHints
204#define XAllocWMHints _glfw.x11.xlib.AllocWMHints
205#define XChangeProperty _glfw.x11.xlib.ChangeProperty
206#define XChangeWindowAttributes _glfw.x11.xlib.ChangeWindowAttributes
207#define XCheckIfEvent _glfw.x11.xlib.CheckIfEvent
208#define XCheckTypedWindowEvent _glfw.x11.xlib.CheckTypedWindowEvent
209#define XCloseDisplay _glfw.x11.xlib.CloseDisplay
210#define XCloseIM _glfw.x11.xlib.CloseIM
211#define XConvertSelection _glfw.x11.xlib.ConvertSelection
212#define XCreateColormap _glfw.x11.xlib.CreateColormap
213#define XCreateFontCursor _glfw.x11.xlib.CreateFontCursor
214#define XCreateIC _glfw.x11.xlib.CreateIC
215#define XCreateRegion _glfw.x11.xlib.CreateRegion
216#define XCreateWindow _glfw.x11.xlib.CreateWindow
217#define XDefineCursor _glfw.x11.xlib.DefineCursor
218#define XDeleteContext _glfw.x11.xlib.DeleteContext
219#define XDeleteProperty _glfw.x11.xlib.DeleteProperty
220#define XDestroyIC _glfw.x11.xlib.DestroyIC
221#define XDestroyRegion _glfw.x11.xlib.DestroyRegion
222#define XDestroyWindow _glfw.x11.xlib.DestroyWindow
223#define XDisplayKeycodes _glfw.x11.xlib.DisplayKeycodes
224#define XEventsQueued _glfw.x11.xlib.EventsQueued
225#define XFilterEvent _glfw.x11.xlib.FilterEvent
226#define XFindContext _glfw.x11.xlib.FindContext
227#define XFlush _glfw.x11.xlib.Flush
228#define XFree _glfw.x11.xlib.Free
229#define XFreeColormap _glfw.x11.xlib.FreeColormap
230#define XFreeCursor _glfw.x11.xlib.FreeCursor
231#define XFreeEventData _glfw.x11.xlib.FreeEventData
232#define XGetErrorText _glfw.x11.xlib.GetErrorText
233#define XGetEventData _glfw.x11.xlib.GetEventData
234#define XGetICValues _glfw.x11.xlib.GetICValues
235#define XGetIMValues _glfw.x11.xlib.GetIMValues
236#define XGetInputFocus _glfw.x11.xlib.GetInputFocus
237#define XGetKeyboardMapping _glfw.x11.xlib.GetKeyboardMapping
238#define XGetScreenSaver _glfw.x11.xlib.GetScreenSaver
239#define XGetSelectionOwner _glfw.x11.xlib.GetSelectionOwner
240#define XGetVisualInfo _glfw.x11.xlib.GetVisualInfo
241#define XGetWMNormalHints _glfw.x11.xlib.GetWMNormalHints
242#define XGetWindowAttributes _glfw.x11.xlib.GetWindowAttributes
243#define XGetWindowProperty _glfw.x11.xlib.GetWindowProperty
244#define XGrabPointer _glfw.x11.xlib.GrabPointer
245#define XIconifyWindow _glfw.x11.xlib.IconifyWindow
246#define XInternAtom _glfw.x11.xlib.InternAtom
247#define XLookupString _glfw.x11.xlib.LookupString
248#define XMapRaised _glfw.x11.xlib.MapRaised
249#define XMapWindow _glfw.x11.xlib.MapWindow
250#define XMoveResizeWindow _glfw.x11.xlib.MoveResizeWindow
251#define XMoveWindow _glfw.x11.xlib.MoveWindow
252#define XNextEvent _glfw.x11.xlib.NextEvent
253#define XOpenIM _glfw.x11.xlib.OpenIM
254#define XPeekEvent _glfw.x11.xlib.PeekEvent
255#define XPending _glfw.x11.xlib.Pending
256#define XQueryExtension _glfw.x11.xlib.QueryExtension
257#define XQueryPointer _glfw.x11.xlib.QueryPointer
258#define XRaiseWindow _glfw.x11.xlib.RaiseWindow
259#define XRegisterIMInstantiateCallback _glfw.x11.xlib.RegisterIMInstantiateCallback
260#define XResizeWindow _glfw.x11.xlib.ResizeWindow
261#define XResourceManagerString _glfw.x11.xlib.ResourceManagerString
262#define XSaveContext _glfw.x11.xlib.SaveContext
263#define XSelectInput _glfw.x11.xlib.SelectInput
264#define XSendEvent _glfw.x11.xlib.SendEvent
265#define XSetClassHint _glfw.x11.xlib.SetClassHint
266#define XSetErrorHandler _glfw.x11.xlib.SetErrorHandler
267#define XSetICFocus _glfw.x11.xlib.SetICFocus
268#define XSetIMValues _glfw.x11.xlib.SetIMValues
269#define XSetInputFocus _glfw.x11.xlib.SetInputFocus
270#define XSetLocaleModifiers _glfw.x11.xlib.SetLocaleModifiers
271#define XSetScreenSaver _glfw.x11.xlib.SetScreenSaver
272#define XSetSelectionOwner _glfw.x11.xlib.SetSelectionOwner
273#define XSetWMHints _glfw.x11.xlib.SetWMHints
274#define XSetWMNormalHints _glfw.x11.xlib.SetWMNormalHints
275#define XSetWMProtocols _glfw.x11.xlib.SetWMProtocols
276#define XSupportsLocale _glfw.x11.xlib.SupportsLocale
277#define XSync _glfw.x11.xlib.Sync
278#define XTranslateCoordinates _glfw.x11.xlib.TranslateCoordinates
279#define XUndefineCursor _glfw.x11.xlib.UndefineCursor
280#define XUngrabPointer _glfw.x11.xlib.UngrabPointer
281#define XUnmapWindow _glfw.x11.xlib.UnmapWindow
282#define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus
283#define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual
284#define XWarpPointer _glfw.x11.xlib.WarpPointer
285#define XkbFreeKeyboard _glfw.x11.xkb.FreeKeyboard
286#define XkbFreeNames _glfw.x11.xkb.FreeNames
287#define XkbGetMap _glfw.x11.xkb.GetMap
288#define XkbGetNames _glfw.x11.xkb.GetNames
289#define XkbGetState _glfw.x11.xkb.GetState
290#define XkbKeycodeToKeysym _glfw.x11.xkb.KeycodeToKeysym
291#define XkbQueryExtension _glfw.x11.xkb.QueryExtension
292#define XkbSelectEventDetails _glfw.x11.xkb.SelectEventDetails
293#define XkbSetDetectableAutoRepeat _glfw.x11.xkb.SetDetectableAutoRepeat
294#define XrmDestroyDatabase _glfw.x11.xrm.DestroyDatabase
295#define XrmGetResource _glfw.x11.xrm.GetResource
296#define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase
297#define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark
298#define XUnregisterIMInstantiateCallback _glfw.x11.xlib.UnregisterIMInstantiateCallback
299#define Xutf8LookupString _glfw.x11.xlib.utf8LookupString
300#define Xutf8SetWMProperties _glfw.x11.xlib.utf8SetWMProperties
301
302typedef XRRCrtcGamma* (* PFN_XRRAllocGamma)(int);
303typedef void (* PFN_XRRFreeCrtcInfo)(XRRCrtcInfo*);
304typedef void (* PFN_XRRFreeGamma)(XRRCrtcGamma*);
305typedef void (* PFN_XRRFreeOutputInfo)(XRROutputInfo*);
306typedef void (* PFN_XRRFreeScreenResources)(XRRScreenResources*);
307typedef XRRCrtcGamma* (* PFN_XRRGetCrtcGamma)(Display*,RRCrtc);
308typedef int (* PFN_XRRGetCrtcGammaSize)(Display*,RRCrtc);
309typedef XRRCrtcInfo* (* PFN_XRRGetCrtcInfo) (Display*,XRRScreenResources*,RRCrtc);
310typedef XRROutputInfo* (* PFN_XRRGetOutputInfo)(Display*,XRRScreenResources*,RROutput);
311typedef RROutput (* PFN_XRRGetOutputPrimary)(Display*,Window);
312typedef XRRScreenResources* (* PFN_XRRGetScreenResourcesCurrent)(Display*,Window);
313typedef Bool (* PFN_XRRQueryExtension)(Display*,int*,int*);
314typedef Status (* PFN_XRRQueryVersion)(Display*,int*,int*);
315typedef void (* PFN_XRRSelectInput)(Display*,Window,int);
316typedef Status (* PFN_XRRSetCrtcConfig)(Display*,XRRScreenResources*,RRCrtc,Time,int,int,RRMode,Rotation,RROutput*,int);
317typedef void (* PFN_XRRSetCrtcGamma)(Display*,RRCrtc,XRRCrtcGamma*);
318typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
319#define XRRAllocGamma _glfw.x11.randr.AllocGamma
320#define XRRFreeCrtcInfo _glfw.x11.randr.FreeCrtcInfo
321#define XRRFreeGamma _glfw.x11.randr.FreeGamma
322#define XRRFreeOutputInfo _glfw.x11.randr.FreeOutputInfo
323#define XRRFreeScreenResources _glfw.x11.randr.FreeScreenResources
324#define XRRGetCrtcGamma _glfw.x11.randr.GetCrtcGamma
325#define XRRGetCrtcGammaSize _glfw.x11.randr.GetCrtcGammaSize
326#define XRRGetCrtcInfo _glfw.x11.randr.GetCrtcInfo
327#define XRRGetOutputInfo _glfw.x11.randr.GetOutputInfo
328#define XRRGetOutputPrimary _glfw.x11.randr.GetOutputPrimary
329#define XRRGetScreenResourcesCurrent _glfw.x11.randr.GetScreenResourcesCurrent
330#define XRRQueryExtension _glfw.x11.randr.QueryExtension
331#define XRRQueryVersion _glfw.x11.randr.QueryVersion
332#define XRRSelectInput _glfw.x11.randr.SelectInput
333#define XRRSetCrtcConfig _glfw.x11.randr.SetCrtcConfig
334#define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma
335#define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration
336
337typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int);
338typedef void (* PFN_XcursorImageDestroy)(XcursorImage*);
339typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*);
340typedef char* (* PFN_XcursorGetTheme)(Display*);
341typedef int (* PFN_XcursorGetDefaultSize)(Display*);
342typedef XcursorImage* (* PFN_XcursorLibraryLoadImage)(const char*,const char*,int);
343#define XcursorImageCreate _glfw.x11.xcursor.ImageCreate
344#define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy
345#define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor
346#define XcursorGetTheme _glfw.x11.xcursor.GetTheme
347#define XcursorGetDefaultSize _glfw.x11.xcursor.GetDefaultSize
348#define XcursorLibraryLoadImage _glfw.x11.xcursor.LibraryLoadImage
349
350typedef Bool (* PFN_XineramaIsActive)(Display*);
351typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*);
352typedef XineramaScreenInfo* (* PFN_XineramaQueryScreens)(Display*,int*);
353#define XineramaIsActive _glfw.x11.xinerama.IsActive
354#define XineramaQueryExtension _glfw.x11.xinerama.QueryExtension
355#define XineramaQueryScreens _glfw.x11.xinerama.QueryScreens
356
357typedef XID xcb_window_t;
358typedef XID xcb_visualid_t;
359typedef struct xcb_connection_t xcb_connection_t;
360typedef xcb_connection_t* (* PFN_XGetXCBConnection)(Display*);
361#define XGetXCBConnection _glfw.x11.x11xcb.GetXCBConnection
362
363typedef Bool (* PFN_XF86VidModeQueryExtension)(Display*,int*,int*);
364typedef Bool (* PFN_XF86VidModeGetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
365typedef Bool (* PFN_XF86VidModeSetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
366typedef Bool (* PFN_XF86VidModeGetGammaRampSize)(Display*,int,int*);
367#define XF86VidModeQueryExtension _glfw.x11.vidmode.QueryExtension
368#define XF86VidModeGetGammaRamp _glfw.x11.vidmode.GetGammaRamp
369#define XF86VidModeSetGammaRamp _glfw.x11.vidmode.SetGammaRamp
370#define XF86VidModeGetGammaRampSize _glfw.x11.vidmode.GetGammaRampSize
371
372typedef Status (* PFN_XIQueryVersion)(Display*,int*,int*);
373typedef int (* PFN_XISelectEvents)(Display*,Window,XIEventMask*,int);
374#define XIQueryVersion _glfw.x11.xi.QueryVersion
375#define XISelectEvents _glfw.x11.xi.SelectEvents
376
377typedef Bool (* PFN_XRenderQueryExtension)(Display*,int*,int*);
378typedef Status (* PFN_XRenderQueryVersion)(Display*dpy,int*,int*);
379typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const*);
380#define XRenderQueryExtension _glfw.x11.xrender.QueryExtension
381#define XRenderQueryVersion _glfw.x11.xrender.QueryVersion
382#define XRenderFindVisualFormat _glfw.x11.xrender.FindVisualFormat
383
384typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*);
385typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*);
386typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,int);
387typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
388
389#define XShapeQueryExtension _glfw.x11.xshape.QueryExtension
390#define XShapeQueryVersion _glfw.x11.xshape.QueryVersion
391#define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
392#define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
393
394typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
395typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
396typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
397typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
398typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
399typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
400typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
401typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
402typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
403typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
404typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
405typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
406typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
407typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
408typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
409
410typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
411typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
412typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
413
414// libGL.so function pointer typedefs
415#define glXGetFBConfigs _glfw.glx.GetFBConfigs
416#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
417#define glXGetClientString _glfw.glx.GetClientString
418#define glXQueryExtension _glfw.glx.QueryExtension
419#define glXQueryVersion _glfw.glx.QueryVersion
420#define glXDestroyContext _glfw.glx.DestroyContext
421#define glXMakeCurrent _glfw.glx.MakeCurrent
422#define glXSwapBuffers _glfw.glx.SwapBuffers
423#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
424#define glXCreateNewContext _glfw.glx.CreateNewContext
425#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
426#define glXCreateWindow _glfw.glx.CreateWindow
427#define glXDestroyWindow _glfw.glx.DestroyWindow
428
429typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
430typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
431
432typedef struct VkXlibSurfaceCreateInfoKHR
433{
434 VkStructureType sType;
435 const void* pNext;
436 VkXlibSurfaceCreateFlagsKHR flags;
437 Display* dpy;
438 Window window;
439} VkXlibSurfaceCreateInfoKHR;
440
441typedef struct VkXcbSurfaceCreateInfoKHR
442{
443 VkStructureType sType;
444 const void* pNext;
445 VkXcbSurfaceCreateFlagsKHR flags;
446 xcb_connection_t* connection;
447 xcb_window_t window;
448} VkXcbSurfaceCreateInfoKHR;
449
450typedef VkResult (APIENTRY *PFN_vkCreateXlibSurfaceKHR)(VkInstance,const VkXlibSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
451typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice,uint32_t,Display*,VisualID);
452typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
453typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t);
454
455#include "xkb_unicode.h"
456#include "posix_poll.h"
457
458#define GLFW_X11_WINDOW_STATE _GLFWwindowX11 x11;
459#define GLFW_X11_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11;
460#define GLFW_X11_MONITOR_STATE _GLFWmonitorX11 x11;
461#define GLFW_X11_CURSOR_STATE _GLFWcursorX11 x11;
462
463#define GLFW_GLX_CONTEXT_STATE _GLFWcontextGLX glx;
464#define GLFW_GLX_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx;
465
466
467// GLX-specific per-context data
468//
469typedef struct _GLFWcontextGLX
470{
471 GLXContext handle;
472 GLXWindow window;
473} _GLFWcontextGLX;
474
475// GLX-specific global data
476//
477typedef struct _GLFWlibraryGLX
478{
479 int major, minor;
480 int eventBase;
481 int errorBase;
482
483 void* handle;
484
485 // GLX 1.3 functions
486 PFNGLXGETFBCONFIGSPROC GetFBConfigs;
487 PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
488 PFNGLXGETCLIENTSTRINGPROC GetClientString;
489 PFNGLXQUERYEXTENSIONPROC QueryExtension;
490 PFNGLXQUERYVERSIONPROC QueryVersion;
491 PFNGLXDESTROYCONTEXTPROC DestroyContext;
492 PFNGLXMAKECURRENTPROC MakeCurrent;
493 PFNGLXSWAPBUFFERSPROC SwapBuffers;
494 PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
495 PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
496 PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
497 PFNGLXCREATEWINDOWPROC CreateWindow;
498 PFNGLXDESTROYWINDOWPROC DestroyWindow;
499
500 // GLX 1.4 and extension functions
501 PFNGLXGETPROCADDRESSPROC GetProcAddress;
502 PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
503 PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
504 PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
505 PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
506 PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
507 GLFWbool SGI_swap_control;
508 GLFWbool EXT_swap_control;
509 GLFWbool MESA_swap_control;
510 GLFWbool ARB_multisample;
511 GLFWbool ARB_framebuffer_sRGB;
512 GLFWbool EXT_framebuffer_sRGB;
513 GLFWbool ARB_create_context;
514 GLFWbool ARB_create_context_profile;
515 GLFWbool ARB_create_context_robustness;
516 GLFWbool EXT_create_context_es2_profile;
517 GLFWbool ARB_create_context_no_error;
518 GLFWbool ARB_context_flush_control;
519} _GLFWlibraryGLX;
520
521// X11-specific per-window data
522//
523typedef struct _GLFWwindowX11
524{
525 Colormap colormap;
526 Window handle;
527 Window parent;
528 XIC ic;
529
530 GLFWbool overrideRedirect;
531 GLFWbool iconified;
532 GLFWbool maximized;
533
534 // Whether the visual supports framebuffer transparency
535 GLFWbool transparent;
536
537 // Cached position and size used to filter out duplicate events
538 int width, height;
539 int xpos, ypos;
540
541 // The last received cursor position, regardless of source
542 int lastCursorPosX, lastCursorPosY;
543 // The last position the cursor was warped to by GLFW
544 int warpCursorPosX, warpCursorPosY;
545
546 // The time of the last KeyPress event per keycode, for discarding
547 // duplicate key events generated for some keys by ibus
548 Time keyPressTimes[256];
549} _GLFWwindowX11;
550
551// X11-specific global data
552//
553typedef struct _GLFWlibraryX11
554{
555 Display* display;
556 int screen;
557 Window root;
558
559 // System content scale
560 float contentScaleX, contentScaleY;
561 // Helper window for IPC
562 Window helperWindowHandle;
563 // Invisible cursor for hidden cursor mode
564 Cursor hiddenCursorHandle;
565 // Context for mapping window XIDs to _GLFWwindow pointers
566 XContext context;
567 // XIM input method
568 XIM im;
569 // The previous X error handler, to be restored later
570 XErrorHandler errorHandler;
571 // Most recent error code received by X error handler
572 int errorCode;
573 // Primary selection string (while the primary selection is owned)
574 char* primarySelectionString;
575 // Clipboard string (while the selection is owned)
576 char* clipboardString;
577 // Key name string
578 char keynames[GLFW_KEY_LAST + 1][5];
579 // X11 keycode to GLFW key LUT
580 short int keycodes[256];
581 // GLFW key to X11 keycode LUT
582 short int scancodes[GLFW_KEY_LAST + 1];
583 // Where to place the cursor when re-enabled
584 double restoreCursorPosX, restoreCursorPosY;
585 // The window whose disabled cursor mode is active
586 _GLFWwindow* disabledCursorWindow;
587 int emptyEventPipe[2];
588
589 // Window manager atoms
590 Atom NET_SUPPORTED;
591 Atom NET_SUPPORTING_WM_CHECK;
592 Atom WM_PROTOCOLS;
593 Atom WM_STATE;
594 Atom WM_DELETE_WINDOW;
595 Atom NET_WM_NAME;
596 Atom NET_WM_ICON_NAME;
597 Atom NET_WM_ICON;
598 Atom NET_WM_PID;
599 Atom NET_WM_PING;
600 Atom NET_WM_WINDOW_TYPE;
601 Atom NET_WM_WINDOW_TYPE_NORMAL;
602 Atom NET_WM_STATE;
603 Atom NET_WM_STATE_ABOVE;
604 Atom NET_WM_STATE_FULLSCREEN;
605 Atom NET_WM_STATE_MAXIMIZED_VERT;
606 Atom NET_WM_STATE_MAXIMIZED_HORZ;
607 Atom NET_WM_STATE_DEMANDS_ATTENTION;
608 Atom NET_WM_BYPASS_COMPOSITOR;
609 Atom NET_WM_FULLSCREEN_MONITORS;
610 Atom NET_WM_WINDOW_OPACITY;
611 Atom NET_WM_CM_Sx;
612 Atom NET_WORKAREA;
613 Atom NET_CURRENT_DESKTOP;
614 Atom NET_ACTIVE_WINDOW;
615 Atom NET_FRAME_EXTENTS;
616 Atom NET_REQUEST_FRAME_EXTENTS;
617 Atom MOTIF_WM_HINTS;
618
619 // Xdnd (drag and drop) atoms
620 Atom XdndAware;
621 Atom XdndEnter;
622 Atom XdndPosition;
623 Atom XdndStatus;
624 Atom XdndActionCopy;
625 Atom XdndDrop;
626 Atom XdndFinished;
627 Atom XdndSelection;
628 Atom XdndTypeList;
629 Atom text_uri_list;
630
631 // Selection (clipboard) atoms
632 Atom TARGETS;
633 Atom MULTIPLE;
634 Atom INCR;
635 Atom CLIPBOARD;
636 Atom PRIMARY;
637 Atom CLIPBOARD_MANAGER;
638 Atom SAVE_TARGETS;
639 Atom NULL_;
640 Atom UTF8_STRING;
641 Atom COMPOUND_STRING;
642 Atom ATOM_PAIR;
643 Atom GLFW_SELECTION;
644
645 struct {
646 void* handle;
647 GLFWbool utf8;
648 PFN_XAllocClassHint AllocClassHint;
649 PFN_XAllocSizeHints AllocSizeHints;
650 PFN_XAllocWMHints AllocWMHints;
651 PFN_XChangeProperty ChangeProperty;
652 PFN_XChangeWindowAttributes ChangeWindowAttributes;
653 PFN_XCheckIfEvent CheckIfEvent;
654 PFN_XCheckTypedWindowEvent CheckTypedWindowEvent;
655 PFN_XCloseDisplay CloseDisplay;
656 PFN_XCloseIM CloseIM;
657 PFN_XConvertSelection ConvertSelection;
658 PFN_XCreateColormap CreateColormap;
659 PFN_XCreateFontCursor CreateFontCursor;
660 PFN_XCreateIC CreateIC;
661 PFN_XCreateRegion CreateRegion;
662 PFN_XCreateWindow CreateWindow;
663 PFN_XDefineCursor DefineCursor;
664 PFN_XDeleteContext DeleteContext;
665 PFN_XDeleteProperty DeleteProperty;
666 PFN_XDestroyIC DestroyIC;
667 PFN_XDestroyRegion DestroyRegion;
668 PFN_XDestroyWindow DestroyWindow;
669 PFN_XDisplayKeycodes DisplayKeycodes;
670 PFN_XEventsQueued EventsQueued;
671 PFN_XFilterEvent FilterEvent;
672 PFN_XFindContext FindContext;
673 PFN_XFlush Flush;
674 PFN_XFree Free;
675 PFN_XFreeColormap FreeColormap;
676 PFN_XFreeCursor FreeCursor;
677 PFN_XFreeEventData FreeEventData;
678 PFN_XGetErrorText GetErrorText;
679 PFN_XGetEventData GetEventData;
680 PFN_XGetICValues GetICValues;
681 PFN_XGetIMValues GetIMValues;
682 PFN_XGetInputFocus GetInputFocus;
683 PFN_XGetKeyboardMapping GetKeyboardMapping;
684 PFN_XGetScreenSaver GetScreenSaver;
685 PFN_XGetSelectionOwner GetSelectionOwner;
686 PFN_XGetVisualInfo GetVisualInfo;
687 PFN_XGetWMNormalHints GetWMNormalHints;
688 PFN_XGetWindowAttributes GetWindowAttributes;
689 PFN_XGetWindowProperty GetWindowProperty;
690 PFN_XGrabPointer GrabPointer;
691 PFN_XIconifyWindow IconifyWindow;
692 PFN_XInternAtom InternAtom;
693 PFN_XLookupString LookupString;
694 PFN_XMapRaised MapRaised;
695 PFN_XMapWindow MapWindow;
696 PFN_XMoveResizeWindow MoveResizeWindow;
697 PFN_XMoveWindow MoveWindow;
698 PFN_XNextEvent NextEvent;
699 PFN_XOpenIM OpenIM;
700 PFN_XPeekEvent PeekEvent;
701 PFN_XPending Pending;
702 PFN_XQueryExtension QueryExtension;
703 PFN_XQueryPointer QueryPointer;
704 PFN_XRaiseWindow RaiseWindow;
705 PFN_XRegisterIMInstantiateCallback RegisterIMInstantiateCallback;
706 PFN_XResizeWindow ResizeWindow;
707 PFN_XResourceManagerString ResourceManagerString;
708 PFN_XSaveContext SaveContext;
709 PFN_XSelectInput SelectInput;
710 PFN_XSendEvent SendEvent;
711 PFN_XSetClassHint SetClassHint;
712 PFN_XSetErrorHandler SetErrorHandler;
713 PFN_XSetICFocus SetICFocus;
714 PFN_XSetIMValues SetIMValues;
715 PFN_XSetInputFocus SetInputFocus;
716 PFN_XSetLocaleModifiers SetLocaleModifiers;
717 PFN_XSetScreenSaver SetScreenSaver;
718 PFN_XSetSelectionOwner SetSelectionOwner;
719 PFN_XSetWMHints SetWMHints;
720 PFN_XSetWMNormalHints SetWMNormalHints;
721 PFN_XSetWMProtocols SetWMProtocols;
722 PFN_XSupportsLocale SupportsLocale;
723 PFN_XSync Sync;
724 PFN_XTranslateCoordinates TranslateCoordinates;
725 PFN_XUndefineCursor UndefineCursor;
726 PFN_XUngrabPointer UngrabPointer;
727 PFN_XUnmapWindow UnmapWindow;
728 PFN_XUnsetICFocus UnsetICFocus;
729 PFN_XVisualIDFromVisual VisualIDFromVisual;
730 PFN_XWarpPointer WarpPointer;
731 PFN_XUnregisterIMInstantiateCallback UnregisterIMInstantiateCallback;
732 PFN_Xutf8LookupString utf8LookupString;
733 PFN_Xutf8SetWMProperties utf8SetWMProperties;
734 } xlib;
735
736 struct {
737 PFN_XrmDestroyDatabase DestroyDatabase;
738 PFN_XrmGetResource GetResource;
739 PFN_XrmGetStringDatabase GetStringDatabase;
740 PFN_XrmUniqueQuark UniqueQuark;
741 } xrm;
742
743 struct {
744 GLFWbool available;
745 void* handle;
746 int eventBase;
747 int errorBase;
748 int major;
749 int minor;
750 GLFWbool gammaBroken;
751 GLFWbool monitorBroken;
752 PFN_XRRAllocGamma AllocGamma;
753 PFN_XRRFreeCrtcInfo FreeCrtcInfo;
754 PFN_XRRFreeGamma FreeGamma;
755 PFN_XRRFreeOutputInfo FreeOutputInfo;
756 PFN_XRRFreeScreenResources FreeScreenResources;
757 PFN_XRRGetCrtcGamma GetCrtcGamma;
758 PFN_XRRGetCrtcGammaSize GetCrtcGammaSize;
759 PFN_XRRGetCrtcInfo GetCrtcInfo;
760 PFN_XRRGetOutputInfo GetOutputInfo;
761 PFN_XRRGetOutputPrimary GetOutputPrimary;
762 PFN_XRRGetScreenResourcesCurrent GetScreenResourcesCurrent;
763 PFN_XRRQueryExtension QueryExtension;
764 PFN_XRRQueryVersion QueryVersion;
765 PFN_XRRSelectInput SelectInput;
766 PFN_XRRSetCrtcConfig SetCrtcConfig;
767 PFN_XRRSetCrtcGamma SetCrtcGamma;
768 PFN_XRRUpdateConfiguration UpdateConfiguration;
769 } randr;
770
771 struct {
772 GLFWbool available;
773 GLFWbool detectable;
774 int majorOpcode;
775 int eventBase;
776 int errorBase;
777 int major;
778 int minor;
779 unsigned int group;
780 PFN_XkbFreeKeyboard FreeKeyboard;
781 PFN_XkbFreeNames FreeNames;
782 PFN_XkbGetMap GetMap;
783 PFN_XkbGetNames GetNames;
784 PFN_XkbGetState GetState;
785 PFN_XkbKeycodeToKeysym KeycodeToKeysym;
786 PFN_XkbQueryExtension QueryExtension;
787 PFN_XkbSelectEventDetails SelectEventDetails;
788 PFN_XkbSetDetectableAutoRepeat SetDetectableAutoRepeat;
789 } xkb;
790
791 struct {
792 int count;
793 int timeout;
794 int interval;
795 int blanking;
796 int exposure;
797 } saver;
798
799 struct {
800 int version;
801 Window source;
802 Atom format;
803 } xdnd;
804
805 struct {
806 void* handle;
807 PFN_XcursorImageCreate ImageCreate;
808 PFN_XcursorImageDestroy ImageDestroy;
809 PFN_XcursorImageLoadCursor ImageLoadCursor;
810 PFN_XcursorGetTheme GetTheme;
811 PFN_XcursorGetDefaultSize GetDefaultSize;
812 PFN_XcursorLibraryLoadImage LibraryLoadImage;
813 } xcursor;
814
815 struct {
816 GLFWbool available;
817 void* handle;
818 int major;
819 int minor;
820 PFN_XineramaIsActive IsActive;
821 PFN_XineramaQueryExtension QueryExtension;
822 PFN_XineramaQueryScreens QueryScreens;
823 } xinerama;
824
825 struct {
826 void* handle;
827 PFN_XGetXCBConnection GetXCBConnection;
828 } x11xcb;
829
830 struct {
831 GLFWbool available;
832 void* handle;
833 int eventBase;
834 int errorBase;
835 PFN_XF86VidModeQueryExtension QueryExtension;
836 PFN_XF86VidModeGetGammaRamp GetGammaRamp;
837 PFN_XF86VidModeSetGammaRamp SetGammaRamp;
838 PFN_XF86VidModeGetGammaRampSize GetGammaRampSize;
839 } vidmode;
840
841 struct {
842 GLFWbool available;
843 void* handle;
844 int majorOpcode;
845 int eventBase;
846 int errorBase;
847 int major;
848 int minor;
849 PFN_XIQueryVersion QueryVersion;
850 PFN_XISelectEvents SelectEvents;
851 } xi;
852
853 struct {
854 GLFWbool available;
855 void* handle;
856 int major;
857 int minor;
858 int eventBase;
859 int errorBase;
860 PFN_XRenderQueryExtension QueryExtension;
861 PFN_XRenderQueryVersion QueryVersion;
862 PFN_XRenderFindVisualFormat FindVisualFormat;
863 } xrender;
864
865 struct {
866 GLFWbool available;
867 void* handle;
868 int major;
869 int minor;
870 int eventBase;
871 int errorBase;
872 PFN_XShapeQueryExtension QueryExtension;
873 PFN_XShapeCombineRegion ShapeCombineRegion;
874 PFN_XShapeQueryVersion QueryVersion;
875 PFN_XShapeCombineMask ShapeCombineMask;
876 } xshape;
877} _GLFWlibraryX11;
878
879// X11-specific per-monitor data
880//
881typedef struct _GLFWmonitorX11
882{
883 RROutput output;
884 RRCrtc crtc;
885 RRMode oldMode;
886
887 // Index of corresponding Xinerama screen,
888 // for EWMH full screen window placement
889 int index;
890} _GLFWmonitorX11;
891
892// X11-specific per-cursor data
893//
894typedef struct _GLFWcursorX11
895{
896 Cursor handle;
897} _GLFWcursorX11;
898
899
900GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform);
901int _glfwInitX11(void);
902void _glfwTerminateX11(void);
903
904GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
905void _glfwDestroyWindowX11(_GLFWwindow* window);
906void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
907void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
908void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);
909void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos);
910void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height);
911void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height);
912void _glfwSetWindowSizeLimitsX11(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
913void _glfwSetWindowAspectRatioX11(_GLFWwindow* window, int numer, int denom);
914void _glfwGetFramebufferSizeX11(_GLFWwindow* window, int* width, int* height);
915void _glfwGetWindowFrameSizeX11(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
916void _glfwGetWindowContentScaleX11(_GLFWwindow* window, float* xscale, float* yscale);
917void _glfwIconifyWindowX11(_GLFWwindow* window);
918void _glfwRestoreWindowX11(_GLFWwindow* window);
919void _glfwMaximizeWindowX11(_GLFWwindow* window);
920void _glfwShowWindowX11(_GLFWwindow* window);
921void _glfwHideWindowX11(_GLFWwindow* window);
922void _glfwRequestWindowAttentionX11(_GLFWwindow* window);
923void _glfwFocusWindowX11(_GLFWwindow* window);
924void _glfwSetWindowMonitorX11(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
925GLFWbool _glfwWindowFocusedX11(_GLFWwindow* window);
926GLFWbool _glfwWindowIconifiedX11(_GLFWwindow* window);
927GLFWbool _glfwWindowVisibleX11(_GLFWwindow* window);
928GLFWbool _glfwWindowMaximizedX11(_GLFWwindow* window);
929GLFWbool _glfwWindowHoveredX11(_GLFWwindow* window);
930GLFWbool _glfwFramebufferTransparentX11(_GLFWwindow* window);
931void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled);
932void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled);
933void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled);
934float _glfwGetWindowOpacityX11(_GLFWwindow* window);
935void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity);
936void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled);
937
938void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled);
939GLFWbool _glfwRawMouseMotionSupportedX11(void);
940
941void _glfwPollEventsX11(void);
942void _glfwWaitEventsX11(void);
943void _glfwWaitEventsTimeoutX11(double timeout);
944void _glfwPostEmptyEventX11(void);
945
946void _glfwGetCursorPosX11(_GLFWwindow* window, double* xpos, double* ypos);
947void _glfwSetCursorPosX11(_GLFWwindow* window, double xpos, double ypos);
948void _glfwSetCursorModeX11(_GLFWwindow* window, int mode);
949const char* _glfwGetScancodeNameX11(int scancode);
950int _glfwGetKeyScancodeX11(int key);
951GLFWbool _glfwCreateCursorX11(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
952GLFWbool _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape);
953void _glfwDestroyCursorX11(_GLFWcursor* cursor);
954void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor);
955void _glfwSetClipboardStringX11(const char* string);
956const char* _glfwGetClipboardStringX11(void);
957
958EGLenum _glfwGetEGLPlatformX11(EGLint** attribs);
959EGLNativeDisplayType _glfwGetEGLNativeDisplayX11(void);
960EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window);
961
962void _glfwGetRequiredInstanceExtensionsX11(char** extensions);
963GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
964VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
965
966void _glfwFreeMonitorX11(_GLFWmonitor* monitor);
967void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
968void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
969void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
970GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count);
971GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode);
972GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
973void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
974
975void _glfwPollMonitorsX11(void);
976void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
977void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
978
979Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot);
980
981unsigned long _glfwGetWindowPropertyX11(Window window,
982 Atom property,
983 Atom type,
984 unsigned char** value);
985GLFWbool _glfwIsVisualTransparentX11(Visual* visual);
986
987void _glfwGrabErrorHandlerX11(void);
988void _glfwReleaseErrorHandlerX11(void);
989void _glfwInputErrorX11(int error, const char* message);
990
991void _glfwPushSelectionToManagerX11(void);
992void _glfwCreateInputContextX11(_GLFWwindow* window);
993
994GLFWbool _glfwInitGLX(void);
995void _glfwTerminateGLX(void);
996GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
997 const _GLFWctxconfig* ctxconfig,
998 const _GLFWfbconfig* fbconfig);
999void _glfwDestroyContextGLX(_GLFWwindow* window);
1000GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
1001 const _GLFWctxconfig* ctxconfig,
1002 const _GLFWfbconfig* fbconfig,
1003 Visual** visual, int* depth);
1004
diff --git a/raylib/src/external/glfw/src/x11_window.c b/raylib/src/external/glfw/src/x11_window.c
new file mode 100644
index 0000000..49e60a5
--- /dev/null
+++ b/raylib/src/external/glfw/src/x11_window.c
@@ -0,0 +1,3358 @@
1//========================================================================
2// GLFW 3.4 X11 (modified for raylib) - www.glfw.org; www.raylib.com
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
7//
8// This software is provided 'as-is', without any express or implied
9// warranty. In no event will the authors be held liable for any damages
10// arising from the use of this software.
11//
12// Permission is granted to anyone to use this software for any purpose,
13// including commercial applications, and to alter it and redistribute it
14// freely, subject to the following restrictions:
15//
16// 1. The origin of this software must not be misrepresented; you must not
17// claim that you wrote the original software. If you use this software
18// in a product, an acknowledgment in the product documentation would
19// be appreciated but is not required.
20//
21// 2. Altered source versions must be plainly marked as such, and must not
22// be misrepresented as being the original software.
23//
24// 3. This notice may not be removed or altered from any source
25// distribution.
26//
27//========================================================================
28
29#include "internal.h"
30
31#if defined(_GLFW_X11)
32
33#include <X11/cursorfont.h>
34#include <X11/Xmd.h>
35
36#include <poll.h>
37
38#include <string.h>
39#include <stdio.h>
40#include <stdlib.h>
41#include <limits.h>
42#include <errno.h>
43#include <assert.h>
44
45// Action for EWMH client messages
46#define _NET_WM_STATE_REMOVE 0
47#define _NET_WM_STATE_ADD 1
48#define _NET_WM_STATE_TOGGLE 2
49
50// Additional mouse button names for XButtonEvent
51#define Button6 6
52#define Button7 7
53
54// Motif WM hints flags
55#define MWM_HINTS_DECORATIONS 2
56#define MWM_DECOR_ALL 1
57
58#define _GLFW_XDND_VERSION 5
59
60// Wait for event data to arrive on the X11 display socket
61// This avoids blocking other threads via the per-display Xlib lock that also
62// covers GLX functions
63//
64static GLFWbool waitForX11Event(double* timeout)
65{
66 struct pollfd fd = { ConnectionNumber(_glfw.x11.display), POLLIN };
67
68 while (!XPending(_glfw.x11.display))
69 {
70 if (!_glfwPollPOSIX(&fd, 1, timeout))
71 return GLFW_FALSE;
72 }
73
74 return GLFW_TRUE;
75}
76
77// Wait for event data to arrive on any event file descriptor
78// This avoids blocking other threads via the per-display Xlib lock that also
79// covers GLX functions
80//
81static GLFWbool waitForAnyEvent(double* timeout)
82{
83 enum { XLIB_FD, PIPE_FD, INOTIFY_FD };
84 struct pollfd fds[] =
85 {
86 [XLIB_FD] = { ConnectionNumber(_glfw.x11.display), POLLIN },
87 [PIPE_FD] = { _glfw.x11.emptyEventPipe[0], POLLIN },
88 [INOTIFY_FD] = { -1, POLLIN }
89 };
90
91#if defined(GLFW_BUILD_LINUX_JOYSTICK)
92 if (_glfw.joysticksInitialized)
93 fds[INOTIFY_FD].fd = _glfw.linjs.inotify;
94#endif
95
96 while (!XPending(_glfw.x11.display))
97 {
98 if (!_glfwPollPOSIX(fds, sizeof(fds) / sizeof(fds[0]), timeout))
99 return GLFW_FALSE;
100
101 for (int i = 1; i < sizeof(fds) / sizeof(fds[0]); i++)
102 {
103 if (fds[i].revents & POLLIN)
104 return GLFW_TRUE;
105 }
106 }
107
108 return GLFW_TRUE;
109}
110
111// Writes a byte to the empty event pipe
112//
113static void writeEmptyEvent(void)
114{
115 for (;;)
116 {
117 const char byte = 0;
118 const ssize_t result = write(_glfw.x11.emptyEventPipe[1], &byte, 1);
119 if (result == 1 || (result == -1 && errno != EINTR))
120 break;
121 }
122}
123
124// Drains available data from the empty event pipe
125//
126static void drainEmptyEvents(void)
127{
128 for (;;)
129 {
130 char dummy[64];
131 const ssize_t result = read(_glfw.x11.emptyEventPipe[0], dummy, sizeof(dummy));
132 if (result == -1 && errno != EINTR)
133 break;
134 }
135}
136
137// Waits until a VisibilityNotify event arrives for the specified window or the
138// timeout period elapses (ICCCM section 4.2.2)
139//
140static GLFWbool waitForVisibilityNotify(_GLFWwindow* window)
141{
142 XEvent dummy;
143 double timeout = 0.1;
144
145 while (!XCheckTypedWindowEvent(_glfw.x11.display,
146 window->x11.handle,
147 VisibilityNotify,
148 &dummy))
149 {
150 if (!waitForX11Event(&timeout))
151 return GLFW_FALSE;
152 }
153
154 return GLFW_TRUE;
155}
156
157// Returns whether the window is iconified
158//
159static int getWindowState(_GLFWwindow* window)
160{
161 int result = WithdrawnState;
162 struct {
163 CARD32 state;
164 Window icon;
165 } *state = NULL;
166
167 if (_glfwGetWindowPropertyX11(window->x11.handle,
168 _glfw.x11.WM_STATE,
169 _glfw.x11.WM_STATE,
170 (unsigned char**) &state) >= 2)
171 {
172 result = state->state;
173 }
174
175 if (state)
176 XFree(state);
177
178 return result;
179}
180
181// Returns whether the event is a selection event
182//
183static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)
184{
185 if (event->xany.window != _glfw.x11.helperWindowHandle)
186 return False;
187
188 return event->type == SelectionRequest ||
189 event->type == SelectionNotify ||
190 event->type == SelectionClear;
191}
192
193// Returns whether it is a _NET_FRAME_EXTENTS event for the specified window
194//
195static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer)
196{
197 _GLFWwindow* window = (_GLFWwindow*) pointer;
198 return event->type == PropertyNotify &&
199 event->xproperty.state == PropertyNewValue &&
200 event->xproperty.window == window->x11.handle &&
201 event->xproperty.atom == _glfw.x11.NET_FRAME_EXTENTS;
202}
203
204// Returns whether it is a property event for the specified selection transfer
205//
206static Bool isSelPropNewValueNotify(Display* display, XEvent* event, XPointer pointer)
207{
208 XEvent* notification = (XEvent*) pointer;
209 return event->type == PropertyNotify &&
210 event->xproperty.state == PropertyNewValue &&
211 event->xproperty.window == notification->xselection.requestor &&
212 event->xproperty.atom == notification->xselection.property;
213}
214
215// Translates an X event modifier state mask
216//
217static int translateState(int state)
218{
219 int mods = 0;
220
221 if (state & ShiftMask)
222 mods |= GLFW_MOD_SHIFT;
223 if (state & ControlMask)
224 mods |= GLFW_MOD_CONTROL;
225 if (state & Mod1Mask)
226 mods |= GLFW_MOD_ALT;
227 if (state & Mod4Mask)
228 mods |= GLFW_MOD_SUPER;
229 if (state & LockMask)
230 mods |= GLFW_MOD_CAPS_LOCK;
231 if (state & Mod2Mask)
232 mods |= GLFW_MOD_NUM_LOCK;
233
234 return mods;
235}
236
237// Translates an X11 key code to a GLFW key token
238//
239static int translateKeyX11(int scancode)
240{
241 // Use the pre-filled LUT (see createKeyTablesX11() in x11_init.c)
242 if (scancode < 0 || scancode > 255)
243 return GLFW_KEY_UNKNOWN;
244
245 return _glfw.x11.keycodes[scancode];
246}
247
248// Sends an EWMH or ICCCM event to the window manager
249//
250static void sendEventToWM(_GLFWwindow* window, Atom type,
251 long a, long b, long c, long d, long e)
252{
253 XEvent event = { ClientMessage };
254 event.xclient.window = window->x11.handle;
255 event.xclient.format = 32; // Data is 32-bit longs
256 event.xclient.message_type = type;
257 event.xclient.data.l[0] = a;
258 event.xclient.data.l[1] = b;
259 event.xclient.data.l[2] = c;
260 event.xclient.data.l[3] = d;
261 event.xclient.data.l[4] = e;
262
263 XSendEvent(_glfw.x11.display, _glfw.x11.root,
264 False,
265 SubstructureNotifyMask | SubstructureRedirectMask,
266 &event);
267}
268
269// Updates the normal hints according to the window settings
270//
271static void updateNormalHints(_GLFWwindow* window, int width, int height)
272{
273 XSizeHints* hints = XAllocSizeHints();
274
275 long supplied;
276 XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &supplied);
277
278 hints->flags &= ~(PMinSize | PMaxSize | PAspect);
279
280 if (!window->monitor)
281 {
282 if (window->resizable)
283 {
284 if (window->minwidth != GLFW_DONT_CARE &&
285 window->minheight != GLFW_DONT_CARE)
286 {
287 hints->flags |= PMinSize;
288 hints->min_width = window->minwidth;
289 hints->min_height = window->minheight;
290 }
291
292 if (window->maxwidth != GLFW_DONT_CARE &&
293 window->maxheight != GLFW_DONT_CARE)
294 {
295 hints->flags |= PMaxSize;
296 hints->max_width = window->maxwidth;
297 hints->max_height = window->maxheight;
298 }
299
300 if (window->numer != GLFW_DONT_CARE &&
301 window->denom != GLFW_DONT_CARE)
302 {
303 hints->flags |= PAspect;
304 hints->min_aspect.x = hints->max_aspect.x = window->numer;
305 hints->min_aspect.y = hints->max_aspect.y = window->denom;
306 }
307 }
308 else
309 {
310 hints->flags |= (PMinSize | PMaxSize);
311 hints->min_width = hints->max_width = width;
312 hints->min_height = hints->max_height = height;
313 }
314 }
315
316 XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
317 XFree(hints);
318}
319
320// Updates the full screen status of the window
321//
322static void updateWindowMode(_GLFWwindow* window)
323{
324 if (window->monitor)
325 {
326 if (_glfw.x11.xinerama.available &&
327 _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
328 {
329 sendEventToWM(window,
330 _glfw.x11.NET_WM_FULLSCREEN_MONITORS,
331 window->monitor->x11.index,
332 window->monitor->x11.index,
333 window->monitor->x11.index,
334 window->monitor->x11.index,
335 0);
336 }
337
338 if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
339 {
340 sendEventToWM(window,
341 _glfw.x11.NET_WM_STATE,
342 _NET_WM_STATE_ADD,
343 _glfw.x11.NET_WM_STATE_FULLSCREEN,
344 0, 1, 0);
345 }
346 else
347 {
348 // This is the butcher's way of removing window decorations
349 // Setting the override-redirect attribute on a window makes the
350 // window manager ignore the window completely (ICCCM, section 4)
351 // The good thing is that this makes undecorated full screen windows
352 // easy to do; the bad thing is that we have to do everything
353 // manually and some things (like iconify/restore) won't work at
354 // all, as those are tasks usually performed by the window manager
355
356 XSetWindowAttributes attributes;
357 attributes.override_redirect = True;
358 XChangeWindowAttributes(_glfw.x11.display,
359 window->x11.handle,
360 CWOverrideRedirect,
361 &attributes);
362
363 window->x11.overrideRedirect = GLFW_TRUE;
364 }
365
366 // Enable compositor bypass
367 if (!window->x11.transparent)
368 {
369 const unsigned long value = 1;
370
371 XChangeProperty(_glfw.x11.display, window->x11.handle,
372 _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
373 PropModeReplace, (unsigned char*) &value, 1);
374 }
375 }
376 else
377 {
378 if (_glfw.x11.xinerama.available &&
379 _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
380 {
381 XDeleteProperty(_glfw.x11.display, window->x11.handle,
382 _glfw.x11.NET_WM_FULLSCREEN_MONITORS);
383 }
384
385 if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
386 {
387 sendEventToWM(window,
388 _glfw.x11.NET_WM_STATE,
389 _NET_WM_STATE_REMOVE,
390 _glfw.x11.NET_WM_STATE_FULLSCREEN,
391 0, 1, 0);
392 }
393 else
394 {
395 XSetWindowAttributes attributes;
396 attributes.override_redirect = False;
397 XChangeWindowAttributes(_glfw.x11.display,
398 window->x11.handle,
399 CWOverrideRedirect,
400 &attributes);
401
402 window->x11.overrideRedirect = GLFW_FALSE;
403 }
404
405 // Disable compositor bypass
406 if (!window->x11.transparent)
407 {
408 XDeleteProperty(_glfw.x11.display, window->x11.handle,
409 _glfw.x11.NET_WM_BYPASS_COMPOSITOR);
410 }
411 }
412}
413
414// Decode a Unicode code point from a UTF-8 stream
415// Based on cutef8 by Jeff Bezanson (Public Domain)
416//
417static uint32_t decodeUTF8(const char** s)
418{
419 uint32_t codepoint = 0, count = 0;
420 static const uint32_t offsets[] =
421 {
422 0x00000000u, 0x00003080u, 0x000e2080u,
423 0x03c82080u, 0xfa082080u, 0x82082080u
424 };
425
426 do
427 {
428 codepoint = (codepoint << 6) + (unsigned char) **s;
429 (*s)++;
430 count++;
431 } while ((**s & 0xc0) == 0x80);
432
433 assert(count <= 6);
434 return codepoint - offsets[count - 1];
435}
436
437// Convert the specified Latin-1 string to UTF-8
438//
439static char* convertLatin1toUTF8(const char* source)
440{
441 size_t size = 1;
442 const char* sp;
443
444 for (sp = source; *sp; sp++)
445 size += (*sp & 0x80) ? 2 : 1;
446
447 char* target = _glfw_calloc(size, 1);
448 char* tp = target;
449
450 for (sp = source; *sp; sp++)
451 tp += _glfwEncodeUTF8(tp, *sp);
452
453 return target;
454}
455
456// Updates the cursor image according to its cursor mode
457//
458static void updateCursorImage(_GLFWwindow* window)
459{
460 if (window->cursorMode == GLFW_CURSOR_NORMAL ||
461 window->cursorMode == GLFW_CURSOR_CAPTURED)
462 {
463 if (window->cursor)
464 {
465 XDefineCursor(_glfw.x11.display, window->x11.handle,
466 window->cursor->x11.handle);
467 }
468 else
469 XUndefineCursor(_glfw.x11.display, window->x11.handle);
470 }
471 else
472 {
473 XDefineCursor(_glfw.x11.display, window->x11.handle,
474 _glfw.x11.hiddenCursorHandle);
475 }
476}
477
478// Grabs the cursor and confines it to the window
479//
480static void captureCursor(_GLFWwindow* window)
481{
482 XGrabPointer(_glfw.x11.display, window->x11.handle, True,
483 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
484 GrabModeAsync, GrabModeAsync,
485 window->x11.handle,
486 None,
487 CurrentTime);
488}
489
490// Ungrabs the cursor
491//
492static void releaseCursor(void)
493{
494 XUngrabPointer(_glfw.x11.display, CurrentTime);
495}
496
497// Enable XI2 raw mouse motion events
498//
499static void enableRawMouseMotion(_GLFWwindow* window)
500{
501 XIEventMask em;
502 unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 };
503
504 em.deviceid = XIAllMasterDevices;
505 em.mask_len = sizeof(mask);
506 em.mask = mask;
507 XISetMask(mask, XI_RawMotion);
508
509 XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
510}
511
512// Disable XI2 raw mouse motion events
513//
514static void disableRawMouseMotion(_GLFWwindow* window)
515{
516 XIEventMask em;
517 unsigned char mask[] = { 0 };
518
519 em.deviceid = XIAllMasterDevices;
520 em.mask_len = sizeof(mask);
521 em.mask = mask;
522
523 XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
524}
525
526// Apply disabled cursor mode to a focused window
527//
528static void disableCursor(_GLFWwindow* window)
529{
530 if (window->rawMouseMotion)
531 enableRawMouseMotion(window);
532
533 _glfw.x11.disabledCursorWindow = window;
534 _glfwGetCursorPosX11(window,
535 &_glfw.x11.restoreCursorPosX,
536 &_glfw.x11.restoreCursorPosY);
537 updateCursorImage(window);
538 _glfwCenterCursorInContentArea(window);
539 captureCursor(window);
540}
541
542// Exit disabled cursor mode for the specified window
543//
544static void enableCursor(_GLFWwindow* window)
545{
546 if (window->rawMouseMotion)
547 disableRawMouseMotion(window);
548
549 _glfw.x11.disabledCursorWindow = NULL;
550 releaseCursor();
551 _glfwSetCursorPosX11(window,
552 _glfw.x11.restoreCursorPosX,
553 _glfw.x11.restoreCursorPosY);
554 updateCursorImage(window);
555}
556
557// Clear its handle when the input context has been destroyed
558//
559static void inputContextDestroyCallback(XIC ic, XPointer clientData, XPointer callData)
560{
561 _GLFWwindow* window = (_GLFWwindow*) clientData;
562 window->x11.ic = NULL;
563}
564
565// Create the X11 window (and its colormap)
566//
567static GLFWbool createNativeWindow(_GLFWwindow* window,
568 const _GLFWwndconfig* wndconfig,
569 Visual* visual, int depth)
570{
571 int width = wndconfig->width;
572 int height = wndconfig->height;
573
574 if (wndconfig->scaleToMonitor)
575 {
576 width *= _glfw.x11.contentScaleX;
577 height *= _glfw.x11.contentScaleY;
578 }
579
580 int xpos = 0, ypos = 0;
581
582 if (wndconfig->xpos != GLFW_ANY_POSITION && wndconfig->ypos != GLFW_ANY_POSITION)
583 {
584 xpos = wndconfig->xpos;
585 ypos = wndconfig->ypos;
586 }
587
588 // Create a colormap based on the visual used by the current context
589 window->x11.colormap = XCreateColormap(_glfw.x11.display,
590 _glfw.x11.root,
591 visual,
592 AllocNone);
593
594 window->x11.transparent = _glfwIsVisualTransparentX11(visual);
595
596 XSetWindowAttributes wa = { 0 };
597 wa.colormap = window->x11.colormap;
598 wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
599 PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
600 ExposureMask | FocusChangeMask | VisibilityChangeMask |
601 EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
602
603 _glfwGrabErrorHandlerX11();
604
605 window->x11.parent = _glfw.x11.root;
606 window->x11.handle = XCreateWindow(_glfw.x11.display,
607 _glfw.x11.root,
608 xpos, ypos,
609 width, height,
610 0, // Border width
611 depth, // Color depth
612 InputOutput,
613 visual,
614 CWBorderPixel | CWColormap | CWEventMask,
615 &wa);
616
617 _glfwReleaseErrorHandlerX11();
618
619 if (!window->x11.handle)
620 {
621 _glfwInputErrorX11(GLFW_PLATFORM_ERROR,
622 "X11: Failed to create window");
623 return GLFW_FALSE;
624 }
625
626 XSaveContext(_glfw.x11.display,
627 window->x11.handle,
628 _glfw.x11.context,
629 (XPointer) window);
630
631 if (!wndconfig->decorated)
632 _glfwSetWindowDecoratedX11(window, GLFW_FALSE);
633
634 if (_glfw.x11.NET_WM_STATE && !window->monitor)
635 {
636 Atom states[3];
637 int count = 0;
638
639 if (wndconfig->floating)
640 {
641 if (_glfw.x11.NET_WM_STATE_ABOVE)
642 states[count++] = _glfw.x11.NET_WM_STATE_ABOVE;
643 }
644
645 if (wndconfig->maximized)
646 {
647 if (_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
648 _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
649 {
650 states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT;
651 states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ;
652 window->x11.maximized = GLFW_TRUE;
653 }
654 }
655
656 if (count)
657 {
658 XChangeProperty(_glfw.x11.display, window->x11.handle,
659 _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
660 PropModeReplace, (unsigned char*) states, count);
661 }
662 }
663
664 // Declare the WM protocols supported by GLFW
665 {
666 Atom protocols[] =
667 {
668 _glfw.x11.WM_DELETE_WINDOW,
669 _glfw.x11.NET_WM_PING
670 };
671
672 XSetWMProtocols(_glfw.x11.display, window->x11.handle,
673 protocols, sizeof(protocols) / sizeof(Atom));
674 }
675
676 // Declare our PID
677 {
678 const long pid = getpid();
679
680 XChangeProperty(_glfw.x11.display, window->x11.handle,
681 _glfw.x11.NET_WM_PID, XA_CARDINAL, 32,
682 PropModeReplace,
683 (unsigned char*) &pid, 1);
684 }
685
686 if (_glfw.x11.NET_WM_WINDOW_TYPE && _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL)
687 {
688 Atom type = _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL;
689 XChangeProperty(_glfw.x11.display, window->x11.handle,
690 _glfw.x11.NET_WM_WINDOW_TYPE, XA_ATOM, 32,
691 PropModeReplace, (unsigned char*) &type, 1);
692 }
693
694 // Set ICCCM WM_HINTS property
695 {
696 XWMHints* hints = XAllocWMHints();
697 if (!hints)
698 {
699 _glfwInputError(GLFW_OUT_OF_MEMORY,
700 "X11: Failed to allocate WM hints");
701 return GLFW_FALSE;
702 }
703
704 hints->flags = StateHint;
705 hints->initial_state = NormalState;
706
707 XSetWMHints(_glfw.x11.display, window->x11.handle, hints);
708 XFree(hints);
709 }
710
711 // Set ICCCM WM_NORMAL_HINTS property
712 {
713 XSizeHints* hints = XAllocSizeHints();
714 if (!hints)
715 {
716 _glfwInputError(GLFW_OUT_OF_MEMORY, "X11: Failed to allocate size hints");
717 return GLFW_FALSE;
718 }
719
720 if (!wndconfig->resizable)
721 {
722 hints->flags |= (PMinSize | PMaxSize);
723 hints->min_width = hints->max_width = width;
724 hints->min_height = hints->max_height = height;
725 }
726
727 // HACK: Explicitly setting PPosition to any value causes some WMs, notably
728 // Compiz and Metacity, to honor the position of unmapped windows
729 if (wndconfig->xpos != GLFW_ANY_POSITION && wndconfig->ypos != GLFW_ANY_POSITION)
730 {
731 hints->flags |= PPosition;
732 hints->x = 0;
733 hints->y = 0;
734 }
735
736 hints->flags |= PWinGravity;
737 hints->win_gravity = StaticGravity;
738
739 XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
740 XFree(hints);
741 }
742
743 // Set ICCCM WM_CLASS property
744 {
745 XClassHint* hint = XAllocClassHint();
746
747 if (strlen(wndconfig->x11.instanceName) &&
748 strlen(wndconfig->x11.className))
749 {
750 hint->res_name = (char*) wndconfig->x11.instanceName;
751 hint->res_class = (char*) wndconfig->x11.className;
752 }
753 else
754 {
755 const char* resourceName = getenv("RESOURCE_NAME");
756 if (resourceName && strlen(resourceName))
757 hint->res_name = (char*) resourceName;
758 else if (strlen(wndconfig->title))
759 hint->res_name = (char*) wndconfig->title;
760 else
761 hint->res_name = (char*) "glfw-application";
762
763 if (strlen(wndconfig->title))
764 hint->res_class = (char*) wndconfig->title;
765 else
766 hint->res_class = (char*) "GLFW-Application";
767 }
768
769 XSetClassHint(_glfw.x11.display, window->x11.handle, hint);
770 XFree(hint);
771 }
772
773 // Announce support for Xdnd (drag and drop)
774 {
775 const Atom version = _GLFW_XDND_VERSION;
776 XChangeProperty(_glfw.x11.display, window->x11.handle,
777 _glfw.x11.XdndAware, XA_ATOM, 32,
778 PropModeReplace, (unsigned char*) &version, 1);
779 }
780
781 if (_glfw.x11.im)
782 _glfwCreateInputContextX11(window);
783
784 _glfwSetWindowTitleX11(window, wndconfig->title);
785 _glfwGetWindowPosX11(window, &window->x11.xpos, &window->x11.ypos);
786 _glfwGetWindowSizeX11(window, &window->x11.width, &window->x11.height);
787
788 return GLFW_TRUE;
789}
790
791// Set the specified property to the selection converted to the requested target
792//
793static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
794{
795 char* selectionString = NULL;
796 const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING };
797 const int formatCount = sizeof(formats) / sizeof(formats[0]);
798
799 if (request->selection == _glfw.x11.PRIMARY)
800 selectionString = _glfw.x11.primarySelectionString;
801 else
802 selectionString = _glfw.x11.clipboardString;
803
804 if (request->property == None)
805 {
806 // The requester is a legacy client (ICCCM section 2.2)
807 // We don't support legacy clients, so fail here
808 return None;
809 }
810
811 if (request->target == _glfw.x11.TARGETS)
812 {
813 // The list of supported targets was requested
814
815 const Atom targets[] = { _glfw.x11.TARGETS,
816 _glfw.x11.MULTIPLE,
817 _glfw.x11.UTF8_STRING,
818 XA_STRING };
819
820 XChangeProperty(_glfw.x11.display,
821 request->requestor,
822 request->property,
823 XA_ATOM,
824 32,
825 PropModeReplace,
826 (unsigned char*) targets,
827 sizeof(targets) / sizeof(targets[0]));
828
829 return request->property;
830 }
831
832 if (request->target == _glfw.x11.MULTIPLE)
833 {
834 // Multiple conversions were requested
835
836 Atom* targets;
837 const unsigned long count =
838 _glfwGetWindowPropertyX11(request->requestor,
839 request->property,
840 _glfw.x11.ATOM_PAIR,
841 (unsigned char**) &targets);
842
843 for (unsigned long i = 0; i < count; i += 2)
844 {
845 int j;
846
847 for (j = 0; j < formatCount; j++)
848 {
849 if (targets[i] == formats[j])
850 break;
851 }
852
853 if (j < formatCount)
854 {
855 XChangeProperty(_glfw.x11.display,
856 request->requestor,
857 targets[i + 1],
858 targets[i],
859 8,
860 PropModeReplace,
861 (unsigned char *) selectionString,
862 strlen(selectionString));
863 }
864 else
865 targets[i + 1] = None;
866 }
867
868 XChangeProperty(_glfw.x11.display,
869 request->requestor,
870 request->property,
871 _glfw.x11.ATOM_PAIR,
872 32,
873 PropModeReplace,
874 (unsigned char*) targets,
875 count);
876
877 XFree(targets);
878
879 return request->property;
880 }
881
882 if (request->target == _glfw.x11.SAVE_TARGETS)
883 {
884 // The request is a check whether we support SAVE_TARGETS
885 // It should be handled as a no-op side effect target
886
887 XChangeProperty(_glfw.x11.display,
888 request->requestor,
889 request->property,
890 _glfw.x11.NULL_,
891 32,
892 PropModeReplace,
893 NULL,
894 0);
895
896 return request->property;
897 }
898
899 // Conversion to a data target was requested
900
901 for (int i = 0; i < formatCount; i++)
902 {
903 if (request->target == formats[i])
904 {
905 // The requested target is one we support
906
907 XChangeProperty(_glfw.x11.display,
908 request->requestor,
909 request->property,
910 request->target,
911 8,
912 PropModeReplace,
913 (unsigned char *) selectionString,
914 strlen(selectionString));
915
916 return request->property;
917 }
918 }
919
920 // The requested target is not supported
921
922 return None;
923}
924
925static void handleSelectionRequest(XEvent* event)
926{
927 const XSelectionRequestEvent* request = &event->xselectionrequest;
928
929 XEvent reply = { SelectionNotify };
930 reply.xselection.property = writeTargetToProperty(request);
931 reply.xselection.display = request->display;
932 reply.xselection.requestor = request->requestor;
933 reply.xselection.selection = request->selection;
934 reply.xselection.target = request->target;
935 reply.xselection.time = request->time;
936
937 XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);
938}
939
940static const char* getSelectionString(Atom selection)
941{
942 char** selectionString = NULL;
943 const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
944 const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
945
946 if (selection == _glfw.x11.PRIMARY)
947 selectionString = &_glfw.x11.primarySelectionString;
948 else
949 selectionString = &_glfw.x11.clipboardString;
950
951 if (XGetSelectionOwner(_glfw.x11.display, selection) ==
952 _glfw.x11.helperWindowHandle)
953 {
954 // Instead of doing a large number of X round-trips just to put this
955 // string into a window property and then read it back, just return it
956 return *selectionString;
957 }
958
959 _glfw_free(*selectionString);
960 *selectionString = NULL;
961
962 for (size_t i = 0; i < targetCount; i++)
963 {
964 char* data;
965 Atom actualType;
966 int actualFormat;
967 unsigned long itemCount, bytesAfter;
968 XEvent notification, dummy;
969
970 XConvertSelection(_glfw.x11.display,
971 selection,
972 targets[i],
973 _glfw.x11.GLFW_SELECTION,
974 _glfw.x11.helperWindowHandle,
975 CurrentTime);
976
977 while (!XCheckTypedWindowEvent(_glfw.x11.display,
978 _glfw.x11.helperWindowHandle,
979 SelectionNotify,
980 &notification))
981 {
982 waitForX11Event(NULL);
983 }
984
985 if (notification.xselection.property == None)
986 continue;
987
988 XCheckIfEvent(_glfw.x11.display,
989 &dummy,
990 isSelPropNewValueNotify,
991 (XPointer) &notification);
992
993 XGetWindowProperty(_glfw.x11.display,
994 notification.xselection.requestor,
995 notification.xselection.property,
996 0,
997 LONG_MAX,
998 True,
999 AnyPropertyType,
1000 &actualType,
1001 &actualFormat,
1002 &itemCount,
1003 &bytesAfter,
1004 (unsigned char**) &data);
1005
1006 if (actualType == _glfw.x11.INCR)
1007 {
1008 size_t size = 1;
1009 char* string = NULL;
1010
1011 for (;;)
1012 {
1013 while (!XCheckIfEvent(_glfw.x11.display,
1014 &dummy,
1015 isSelPropNewValueNotify,
1016 (XPointer) &notification))
1017 {
1018 waitForX11Event(NULL);
1019 }
1020
1021 XFree(data);
1022 XGetWindowProperty(_glfw.x11.display,
1023 notification.xselection.requestor,
1024 notification.xselection.property,
1025 0,
1026 LONG_MAX,
1027 True,
1028 AnyPropertyType,
1029 &actualType,
1030 &actualFormat,
1031 &itemCount,
1032 &bytesAfter,
1033 (unsigned char**) &data);
1034
1035 if (itemCount)
1036 {
1037 size += itemCount;
1038 string = _glfw_realloc(string, size);
1039 string[size - itemCount - 1] = '\0';
1040 strcat(string, data);
1041 }
1042
1043 if (!itemCount)
1044 {
1045 if (string)
1046 {
1047 if (targets[i] == XA_STRING)
1048 {
1049 *selectionString = convertLatin1toUTF8(string);
1050 _glfw_free(string);
1051 }
1052 else
1053 *selectionString = string;
1054 }
1055
1056 break;
1057 }
1058 }
1059 }
1060 else if (actualType == targets[i])
1061 {
1062 if (targets[i] == XA_STRING)
1063 *selectionString = convertLatin1toUTF8(data);
1064 else
1065 *selectionString = _glfw_strdup(data);
1066 }
1067
1068 XFree(data);
1069
1070 if (*selectionString)
1071 break;
1072 }
1073
1074 if (!*selectionString)
1075 {
1076 _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
1077 "X11: Failed to convert selection to string");
1078 }
1079
1080 return *selectionString;
1081}
1082
1083// Make the specified window and its video mode active on its monitor
1084//
1085static void acquireMonitorX11(_GLFWwindow* window)
1086{
1087 if (_glfw.x11.saver.count == 0)
1088 {
1089 // Remember old screen saver settings
1090 XGetScreenSaver(_glfw.x11.display,
1091 &_glfw.x11.saver.timeout,
1092 &_glfw.x11.saver.interval,
1093 &_glfw.x11.saver.blanking,
1094 &_glfw.x11.saver.exposure);
1095
1096 // Disable screen saver
1097 XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,
1098 DefaultExposures);
1099 }
1100
1101 if (!window->monitor->window)
1102 _glfw.x11.saver.count++;
1103
1104 _glfwSetVideoModeX11(window->monitor, &window->videoMode);
1105
1106 if (window->x11.overrideRedirect)
1107 {
1108 int xpos, ypos;
1109 GLFWvidmode mode;
1110
1111 // Manually position the window over its monitor
1112 _glfwGetMonitorPosX11(window->monitor, &xpos, &ypos);
1113 _glfwGetVideoModeX11(window->monitor, &mode);
1114
1115 XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
1116 xpos, ypos, mode.width, mode.height);
1117 }
1118
1119 _glfwInputMonitorWindow(window->monitor, window);
1120}
1121
1122// Remove the window and restore the original video mode
1123//
1124static void releaseMonitorX11(_GLFWwindow* window)
1125{
1126 if (window->monitor->window != window)
1127 return;
1128
1129 _glfwInputMonitorWindow(window->monitor, NULL);
1130 _glfwRestoreVideoModeX11(window->monitor);
1131
1132 _glfw.x11.saver.count--;
1133
1134 if (_glfw.x11.saver.count == 0)
1135 {
1136 // Restore old screen saver settings
1137 XSetScreenSaver(_glfw.x11.display,
1138 _glfw.x11.saver.timeout,
1139 _glfw.x11.saver.interval,
1140 _glfw.x11.saver.blanking,
1141 _glfw.x11.saver.exposure);
1142 }
1143}
1144
1145// Process the specified X event
1146//
1147static void processEvent(XEvent *event)
1148{
1149 int keycode = 0;
1150 Bool filtered = False;
1151
1152 // HACK: Save scancode as some IMs clear the field in XFilterEvent
1153 if (event->type == KeyPress || event->type == KeyRelease)
1154 keycode = event->xkey.keycode;
1155
1156 filtered = XFilterEvent(event, None);
1157
1158 if (_glfw.x11.randr.available)
1159 {
1160 if (event->type == _glfw.x11.randr.eventBase + RRNotify)
1161 {
1162 XRRUpdateConfiguration(event);
1163 _glfwPollMonitorsX11();
1164 return;
1165 }
1166 }
1167
1168 if (_glfw.x11.xkb.available)
1169 {
1170 if (event->type == _glfw.x11.xkb.eventBase + XkbEventCode)
1171 {
1172 if (((XkbEvent*) event)->any.xkb_type == XkbStateNotify &&
1173 (((XkbEvent*) event)->state.changed & XkbGroupStateMask))
1174 {
1175 _glfw.x11.xkb.group = ((XkbEvent*) event)->state.group;
1176 }
1177
1178 return;
1179 }
1180 }
1181
1182 if (event->type == GenericEvent)
1183 {
1184 if (_glfw.x11.xi.available)
1185 {
1186 _GLFWwindow* window = _glfw.x11.disabledCursorWindow;
1187
1188 if (window &&
1189 window->rawMouseMotion &&
1190 event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
1191 XGetEventData(_glfw.x11.display, &event->xcookie) &&
1192 event->xcookie.evtype == XI_RawMotion)
1193 {
1194 XIRawEvent* re = event->xcookie.data;
1195 if (re->valuators.mask_len)
1196 {
1197 const double* values = re->raw_values;
1198 double xpos = window->virtualCursorPosX;
1199 double ypos = window->virtualCursorPosY;
1200
1201 if (XIMaskIsSet(re->valuators.mask, 0))
1202 {
1203 xpos += *values;
1204 values++;
1205 }
1206
1207 if (XIMaskIsSet(re->valuators.mask, 1))
1208 ypos += *values;
1209
1210 _glfwInputCursorPos(window, xpos, ypos);
1211 }
1212 }
1213
1214 XFreeEventData(_glfw.x11.display, &event->xcookie);
1215 }
1216
1217 return;
1218 }
1219
1220 if (event->type == SelectionRequest)
1221 {
1222 handleSelectionRequest(event);
1223 return;
1224 }
1225
1226 _GLFWwindow* window = NULL;
1227 if (XFindContext(_glfw.x11.display,
1228 event->xany.window,
1229 _glfw.x11.context,
1230 (XPointer*) &window) != 0)
1231 {
1232 // This is an event for a window that has already been destroyed
1233 return;
1234 }
1235
1236 switch (event->type)
1237 {
1238 case ReparentNotify:
1239 {
1240 window->x11.parent = event->xreparent.parent;
1241 return;
1242 }
1243
1244 case KeyPress:
1245 {
1246 const int key = translateKeyX11(keycode);
1247 const int mods = translateState(event->xkey.state);
1248 const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
1249
1250 if (window->x11.ic)
1251 {
1252 // HACK: Do not report the key press events duplicated by XIM
1253 // Duplicate key releases are filtered out implicitly by
1254 // the GLFW key repeat logic in _glfwInputKey
1255 // A timestamp per key is used to handle simultaneous keys
1256 // NOTE: Always allow the first event for each key through
1257 // (the server never sends a timestamp of zero)
1258 // NOTE: Timestamp difference is compared to handle wrap-around
1259 Time diff = event->xkey.time - window->x11.keyPressTimes[keycode];
1260 if (diff == event->xkey.time || (diff > 0 && diff < ((Time)1 << 31)))
1261 {
1262 if (keycode)
1263 _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
1264
1265 window->x11.keyPressTimes[keycode] = event->xkey.time;
1266 }
1267
1268 if (!filtered)
1269 {
1270 int count;
1271 Status status;
1272 char buffer[100];
1273 char* chars = buffer;
1274
1275 count = Xutf8LookupString(window->x11.ic,
1276 &event->xkey,
1277 buffer, sizeof(buffer) - 1,
1278 NULL, &status);
1279
1280 if (status == XBufferOverflow)
1281 {
1282 chars = _glfw_calloc(count + 1, 1);
1283 count = Xutf8LookupString(window->x11.ic,
1284 &event->xkey,
1285 chars, count,
1286 NULL, &status);
1287 }
1288
1289 if (status == XLookupChars || status == XLookupBoth)
1290 {
1291 const char* c = chars;
1292 chars[count] = '\0';
1293 while (c - chars < count)
1294 _glfwInputChar(window, decodeUTF8(&c), mods, plain);
1295 }
1296
1297 if (chars != buffer)
1298 _glfw_free(chars);
1299 }
1300 }
1301 else
1302 {
1303 KeySym keysym;
1304 XLookupString(&event->xkey, NULL, 0, &keysym, NULL);
1305
1306 _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
1307
1308 const uint32_t codepoint = _glfwKeySym2Unicode(keysym);
1309 if (codepoint != GLFW_INVALID_CODEPOINT)
1310 _glfwInputChar(window, codepoint, mods, plain);
1311 }
1312
1313 return;
1314 }
1315
1316 case KeyRelease:
1317 {
1318 const int key = translateKeyX11(keycode);
1319 const int mods = translateState(event->xkey.state);
1320
1321 if (!_glfw.x11.xkb.detectable)
1322 {
1323 // HACK: Key repeat events will arrive as KeyRelease/KeyPress
1324 // pairs with similar or identical time stamps
1325 // The key repeat logic in _glfwInputKey expects only key
1326 // presses to repeat, so detect and discard release events
1327 if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))
1328 {
1329 XEvent next;
1330 XPeekEvent(_glfw.x11.display, &next);
1331
1332 if (next.type == KeyPress &&
1333 next.xkey.window == event->xkey.window &&
1334 next.xkey.keycode == keycode)
1335 {
1336 // HACK: The time of repeat events sometimes doesn't
1337 // match that of the press event, so add an
1338 // epsilon
1339 // Toshiyuki Takahashi can press a button
1340 // 16 times per second so it's fairly safe to
1341 // assume that no human is pressing the key 50
1342 // times per second (value is ms)
1343 if ((next.xkey.time - event->xkey.time) < 20)
1344 {
1345 // This is very likely a server-generated key repeat
1346 // event, so ignore it
1347 return;
1348 }
1349 }
1350 }
1351 }
1352
1353 _glfwInputKey(window, key, keycode, GLFW_RELEASE, mods);
1354 return;
1355 }
1356
1357 case ButtonPress:
1358 {
1359 const int mods = translateState(event->xbutton.state);
1360
1361 if (event->xbutton.button == Button1)
1362 _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
1363 else if (event->xbutton.button == Button2)
1364 _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
1365 else if (event->xbutton.button == Button3)
1366 _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
1367
1368 // Modern X provides scroll events as mouse button presses
1369 else if (event->xbutton.button == Button4)
1370 _glfwInputScroll(window, 0.0, 1.0);
1371 else if (event->xbutton.button == Button5)
1372 _glfwInputScroll(window, 0.0, -1.0);
1373 else if (event->xbutton.button == Button6)
1374 _glfwInputScroll(window, 1.0, 0.0);
1375 else if (event->xbutton.button == Button7)
1376 _glfwInputScroll(window, -1.0, 0.0);
1377
1378 else
1379 {
1380 // Additional buttons after 7 are treated as regular buttons
1381 // We subtract 4 to fill the gap left by scroll input above
1382 _glfwInputMouseClick(window,
1383 event->xbutton.button - Button1 - 4,
1384 GLFW_PRESS,
1385 mods);
1386 }
1387
1388 return;
1389 }
1390
1391 case ButtonRelease:
1392 {
1393 const int mods = translateState(event->xbutton.state);
1394
1395 if (event->xbutton.button == Button1)
1396 {
1397 _glfwInputMouseClick(window,
1398 GLFW_MOUSE_BUTTON_LEFT,
1399 GLFW_RELEASE,
1400 mods);
1401 }
1402 else if (event->xbutton.button == Button2)
1403 {
1404 _glfwInputMouseClick(window,
1405 GLFW_MOUSE_BUTTON_MIDDLE,
1406 GLFW_RELEASE,
1407 mods);
1408 }
1409 else if (event->xbutton.button == Button3)
1410 {
1411 _glfwInputMouseClick(window,
1412 GLFW_MOUSE_BUTTON_RIGHT,
1413 GLFW_RELEASE,
1414 mods);
1415 }
1416 else if (event->xbutton.button > Button7)
1417 {
1418 // Additional buttons after 7 are treated as regular buttons
1419 // We subtract 4 to fill the gap left by scroll input above
1420 _glfwInputMouseClick(window,
1421 event->xbutton.button - Button1 - 4,
1422 GLFW_RELEASE,
1423 mods);
1424 }
1425
1426 return;
1427 }
1428
1429 case EnterNotify:
1430 {
1431 // XEnterWindowEvent is XCrossingEvent
1432 const int x = event->xcrossing.x;
1433 const int y = event->xcrossing.y;
1434
1435 // HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
1436 // ignore the defined cursor for hidden cursor mode
1437 if (window->cursorMode == GLFW_CURSOR_HIDDEN)
1438 updateCursorImage(window);
1439
1440 _glfwInputCursorEnter(window, GLFW_TRUE);
1441 _glfwInputCursorPos(window, x, y);
1442
1443 window->x11.lastCursorPosX = x;
1444 window->x11.lastCursorPosY = y;
1445 return;
1446 }
1447
1448 case LeaveNotify:
1449 {
1450 _glfwInputCursorEnter(window, GLFW_FALSE);
1451 return;
1452 }
1453
1454 case MotionNotify:
1455 {
1456 const int x = event->xmotion.x;
1457 const int y = event->xmotion.y;
1458
1459 if (x != window->x11.warpCursorPosX ||
1460 y != window->x11.warpCursorPosY)
1461 {
1462 // The cursor was moved by something other than GLFW
1463
1464 if (window->cursorMode == GLFW_CURSOR_DISABLED)
1465 {
1466 if (_glfw.x11.disabledCursorWindow != window)
1467 return;
1468 if (window->rawMouseMotion)
1469 return;
1470
1471 const int dx = x - window->x11.lastCursorPosX;
1472 const int dy = y - window->x11.lastCursorPosY;
1473
1474 _glfwInputCursorPos(window,
1475 window->virtualCursorPosX + dx,
1476 window->virtualCursorPosY + dy);
1477 }
1478 else
1479 _glfwInputCursorPos(window, x, y);
1480 }
1481
1482 window->x11.lastCursorPosX = x;
1483 window->x11.lastCursorPosY = y;
1484 return;
1485 }
1486
1487 case ConfigureNotify:
1488 {
1489 if (event->xconfigure.width != window->x11.width ||
1490 event->xconfigure.height != window->x11.height)
1491 {
1492 window->x11.width = event->xconfigure.width;
1493 window->x11.height = event->xconfigure.height;
1494
1495 _glfwInputFramebufferSize(window,
1496 event->xconfigure.width,
1497 event->xconfigure.height);
1498
1499 _glfwInputWindowSize(window,
1500 event->xconfigure.width,
1501 event->xconfigure.height);
1502 }
1503
1504 int xpos = event->xconfigure.x;
1505 int ypos = event->xconfigure.y;
1506
1507 // NOTE: ConfigureNotify events from the server are in local
1508 // coordinates, so if we are reparented we need to translate
1509 // the position into root (screen) coordinates
1510 if (!event->xany.send_event && window->x11.parent != _glfw.x11.root)
1511 {
1512 _glfwGrabErrorHandlerX11();
1513
1514 Window dummy;
1515 XTranslateCoordinates(_glfw.x11.display,
1516 window->x11.parent,
1517 _glfw.x11.root,
1518 xpos, ypos,
1519 &xpos, &ypos,
1520 &dummy);
1521
1522 _glfwReleaseErrorHandlerX11();
1523 if (_glfw.x11.errorCode == BadWindow)
1524 return;
1525 }
1526
1527 if (xpos != window->x11.xpos || ypos != window->x11.ypos)
1528 {
1529 window->x11.xpos = xpos;
1530 window->x11.ypos = ypos;
1531
1532 _glfwInputWindowPos(window, xpos, ypos);
1533 }
1534
1535 return;
1536 }
1537
1538 case ClientMessage:
1539 {
1540 // Custom client message, probably from the window manager
1541
1542 if (filtered)
1543 return;
1544
1545 if (event->xclient.message_type == None)
1546 return;
1547
1548 if (event->xclient.message_type == _glfw.x11.WM_PROTOCOLS)
1549 {
1550 const Atom protocol = event->xclient.data.l[0];
1551 if (protocol == None)
1552 return;
1553
1554 if (protocol == _glfw.x11.WM_DELETE_WINDOW)
1555 {
1556 // The window manager was asked to close the window, for
1557 // example by the user pressing a 'close' window decoration
1558 // button
1559 _glfwInputWindowCloseRequest(window);
1560 }
1561 else if (protocol == _glfw.x11.NET_WM_PING)
1562 {
1563 // The window manager is pinging the application to ensure
1564 // it's still responding to events
1565
1566 XEvent reply = *event;
1567 reply.xclient.window = _glfw.x11.root;
1568
1569 XSendEvent(_glfw.x11.display, _glfw.x11.root,
1570 False,
1571 SubstructureNotifyMask | SubstructureRedirectMask,
1572 &reply);
1573 }
1574 }
1575 else if (event->xclient.message_type == _glfw.x11.XdndEnter)
1576 {
1577 // A drag operation has entered the window
1578 unsigned long count;
1579 Atom* formats = NULL;
1580 const GLFWbool list = event->xclient.data.l[1] & 1;
1581
1582 _glfw.x11.xdnd.source = event->xclient.data.l[0];
1583 _glfw.x11.xdnd.version = event->xclient.data.l[1] >> 24;
1584 _glfw.x11.xdnd.format = None;
1585
1586 if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
1587 return;
1588
1589 if (list)
1590 {
1591 count = _glfwGetWindowPropertyX11(_glfw.x11.xdnd.source,
1592 _glfw.x11.XdndTypeList,
1593 XA_ATOM,
1594 (unsigned char**) &formats);
1595 }
1596 else
1597 {
1598 count = 3;
1599 formats = (Atom*) event->xclient.data.l + 2;
1600 }
1601
1602 for (unsigned int i = 0; i < count; i++)
1603 {
1604 if (formats[i] == _glfw.x11.text_uri_list)
1605 {
1606 _glfw.x11.xdnd.format = _glfw.x11.text_uri_list;
1607 break;
1608 }
1609 }
1610
1611 if (list && formats)
1612 XFree(formats);
1613 }
1614 else if (event->xclient.message_type == _glfw.x11.XdndDrop)
1615 {
1616 // The drag operation has finished by dropping on the window
1617 Time time = CurrentTime;
1618
1619 if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
1620 return;
1621
1622 if (_glfw.x11.xdnd.format)
1623 {
1624 if (_glfw.x11.xdnd.version >= 1)
1625 time = event->xclient.data.l[2];
1626
1627 // Request the chosen format from the source window
1628 XConvertSelection(_glfw.x11.display,
1629 _glfw.x11.XdndSelection,
1630 _glfw.x11.xdnd.format,
1631 _glfw.x11.XdndSelection,
1632 window->x11.handle,
1633 time);
1634 }
1635 else if (_glfw.x11.xdnd.version >= 2)
1636 {
1637 XEvent reply = { ClientMessage };
1638 reply.xclient.window = _glfw.x11.xdnd.source;
1639 reply.xclient.message_type = _glfw.x11.XdndFinished;
1640 reply.xclient.format = 32;
1641 reply.xclient.data.l[0] = window->x11.handle;
1642 reply.xclient.data.l[1] = 0; // The drag was rejected
1643 reply.xclient.data.l[2] = None;
1644
1645 XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
1646 False, NoEventMask, &reply);
1647 XFlush(_glfw.x11.display);
1648 }
1649 }
1650 else if (event->xclient.message_type == _glfw.x11.XdndPosition)
1651 {
1652 // The drag operation has moved over the window
1653 const int xabs = (event->xclient.data.l[2] >> 16) & 0xffff;
1654 const int yabs = (event->xclient.data.l[2]) & 0xffff;
1655 Window dummy;
1656 int xpos, ypos;
1657
1658 if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
1659 return;
1660
1661 XTranslateCoordinates(_glfw.x11.display,
1662 _glfw.x11.root,
1663 window->x11.handle,
1664 xabs, yabs,
1665 &xpos, &ypos,
1666 &dummy);
1667
1668 _glfwInputCursorPos(window, xpos, ypos);
1669
1670 XEvent reply = { ClientMessage };
1671 reply.xclient.window = _glfw.x11.xdnd.source;
1672 reply.xclient.message_type = _glfw.x11.XdndStatus;
1673 reply.xclient.format = 32;
1674 reply.xclient.data.l[0] = window->x11.handle;
1675 reply.xclient.data.l[2] = 0; // Specify an empty rectangle
1676 reply.xclient.data.l[3] = 0;
1677
1678 if (_glfw.x11.xdnd.format)
1679 {
1680 // Reply that we are ready to copy the dragged data
1681 reply.xclient.data.l[1] = 1; // Accept with no rectangle
1682 if (_glfw.x11.xdnd.version >= 2)
1683 reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy;
1684 }
1685
1686 XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
1687 False, NoEventMask, &reply);
1688 XFlush(_glfw.x11.display);
1689 }
1690
1691 return;
1692 }
1693
1694 case SelectionNotify:
1695 {
1696 if (event->xselection.property == _glfw.x11.XdndSelection)
1697 {
1698 // The converted data from the drag operation has arrived
1699 char* data;
1700 const unsigned long result =
1701 _glfwGetWindowPropertyX11(event->xselection.requestor,
1702 event->xselection.property,
1703 event->xselection.target,
1704 (unsigned char**) &data);
1705
1706 if (result)
1707 {
1708 int count;
1709 char** paths = _glfwParseUriList(data, &count);
1710
1711 _glfwInputDrop(window, count, (const char**) paths);
1712
1713 for (int i = 0; i < count; i++)
1714 _glfw_free(paths[i]);
1715 _glfw_free(paths);
1716 }
1717
1718 if (data)
1719 XFree(data);
1720
1721 if (_glfw.x11.xdnd.version >= 2)
1722 {
1723 XEvent reply = { ClientMessage };
1724 reply.xclient.window = _glfw.x11.xdnd.source;
1725 reply.xclient.message_type = _glfw.x11.XdndFinished;
1726 reply.xclient.format = 32;
1727 reply.xclient.data.l[0] = window->x11.handle;
1728 reply.xclient.data.l[1] = result;
1729 reply.xclient.data.l[2] = _glfw.x11.XdndActionCopy;
1730
1731 XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
1732 False, NoEventMask, &reply);
1733 XFlush(_glfw.x11.display);
1734 }
1735 }
1736
1737 return;
1738 }
1739
1740 case FocusIn:
1741 {
1742 if (event->xfocus.mode == NotifyGrab ||
1743 event->xfocus.mode == NotifyUngrab)
1744 {
1745 // Ignore focus events from popup indicator windows, window menu
1746 // key chords and window dragging
1747 return;
1748 }
1749
1750 if (window->cursorMode == GLFW_CURSOR_DISABLED)
1751 disableCursor(window);
1752 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
1753 captureCursor(window);
1754
1755 if (window->x11.ic)
1756 XSetICFocus(window->x11.ic);
1757
1758 _glfwInputWindowFocus(window, GLFW_TRUE);
1759 return;
1760 }
1761
1762 case FocusOut:
1763 {
1764 if (event->xfocus.mode == NotifyGrab ||
1765 event->xfocus.mode == NotifyUngrab)
1766 {
1767 // Ignore focus events from popup indicator windows, window menu
1768 // key chords and window dragging
1769 return;
1770 }
1771
1772 if (window->cursorMode == GLFW_CURSOR_DISABLED)
1773 enableCursor(window);
1774 else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
1775 releaseCursor();
1776
1777 if (window->x11.ic)
1778 XUnsetICFocus(window->x11.ic);
1779
1780 if (window->monitor && window->autoIconify)
1781 _glfwIconifyWindowX11(window);
1782
1783 _glfwInputWindowFocus(window, GLFW_FALSE);
1784 return;
1785 }
1786
1787 case Expose:
1788 {
1789 _glfwInputWindowDamage(window);
1790 return;
1791 }
1792
1793 case PropertyNotify:
1794 {
1795 if (event->xproperty.state != PropertyNewValue)
1796 return;
1797
1798 if (event->xproperty.atom == _glfw.x11.WM_STATE)
1799 {
1800 const int state = getWindowState(window);
1801 if (state != IconicState && state != NormalState)
1802 return;
1803
1804 const GLFWbool iconified = (state == IconicState);
1805 if (window->x11.iconified != iconified)
1806 {
1807 if (window->monitor)
1808 {
1809 if (iconified)
1810 releaseMonitorX11(window);
1811 else
1812 acquireMonitorX11(window);
1813 }
1814
1815 window->x11.iconified = iconified;
1816 _glfwInputWindowIconify(window, iconified);
1817 }
1818 }
1819 else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE)
1820 {
1821 const GLFWbool maximized = _glfwWindowMaximizedX11(window);
1822 if (window->x11.maximized != maximized)
1823 {
1824 window->x11.maximized = maximized;
1825 _glfwInputWindowMaximize(window, maximized);
1826 }
1827 }
1828
1829 return;
1830 }
1831
1832 case DestroyNotify:
1833 return;
1834 }
1835}
1836
1837
1838//////////////////////////////////////////////////////////////////////////
1839////// GLFW internal API //////
1840//////////////////////////////////////////////////////////////////////////
1841
1842// Retrieve a single window property of the specified type
1843// Inspired by fghGetWindowProperty from freeglut
1844//
1845unsigned long _glfwGetWindowPropertyX11(Window window,
1846 Atom property,
1847 Atom type,
1848 unsigned char** value)
1849{
1850 Atom actualType;
1851 int actualFormat;
1852 unsigned long itemCount, bytesAfter;
1853
1854 XGetWindowProperty(_glfw.x11.display,
1855 window,
1856 property,
1857 0,
1858 LONG_MAX,
1859 False,
1860 type,
1861 &actualType,
1862 &actualFormat,
1863 &itemCount,
1864 &bytesAfter,
1865 value);
1866
1867 return itemCount;
1868}
1869
1870GLFWbool _glfwIsVisualTransparentX11(Visual* visual)
1871{
1872 if (!_glfw.x11.xrender.available)
1873 return GLFW_FALSE;
1874
1875 XRenderPictFormat* pf = XRenderFindVisualFormat(_glfw.x11.display, visual);
1876 return pf && pf->direct.alphaMask;
1877}
1878
1879// Push contents of our selection to clipboard manager
1880//
1881void _glfwPushSelectionToManagerX11(void)
1882{
1883 XConvertSelection(_glfw.x11.display,
1884 _glfw.x11.CLIPBOARD_MANAGER,
1885 _glfw.x11.SAVE_TARGETS,
1886 None,
1887 _glfw.x11.helperWindowHandle,
1888 CurrentTime);
1889
1890 for (;;)
1891 {
1892 XEvent event;
1893
1894 while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
1895 {
1896 switch (event.type)
1897 {
1898 case SelectionRequest:
1899 handleSelectionRequest(&event);
1900 break;
1901
1902 case SelectionNotify:
1903 {
1904 if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
1905 {
1906 // This means one of two things; either the selection
1907 // was not owned, which means there is no clipboard
1908 // manager, or the transfer to the clipboard manager has
1909 // completed
1910 // In either case, it means we are done here
1911 return;
1912 }
1913
1914 break;
1915 }
1916 }
1917 }
1918
1919 waitForX11Event(NULL);
1920 }
1921}
1922
1923void _glfwCreateInputContextX11(_GLFWwindow* window)
1924{
1925 XIMCallback callback;
1926 callback.callback = (XIMProc) inputContextDestroyCallback;
1927 callback.client_data = (XPointer) window;
1928
1929 window->x11.ic = XCreateIC(_glfw.x11.im,
1930 XNInputStyle,
1931 XIMPreeditNothing | XIMStatusNothing,
1932 XNClientWindow,
1933 window->x11.handle,
1934 XNFocusWindow,
1935 window->x11.handle,
1936 XNDestroyCallback,
1937 &callback,
1938 NULL);
1939
1940 if (window->x11.ic)
1941 {
1942 XWindowAttributes attribs;
1943 XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
1944
1945 unsigned long filter = 0;
1946 if (XGetICValues(window->x11.ic, XNFilterEvents, &filter, NULL) == NULL)
1947 {
1948 XSelectInput(_glfw.x11.display,
1949 window->x11.handle,
1950 attribs.your_event_mask | filter);
1951 }
1952 }
1953}
1954
1955
1956//////////////////////////////////////////////////////////////////////////
1957////// GLFW platform API //////
1958//////////////////////////////////////////////////////////////////////////
1959
1960GLFWbool _glfwCreateWindowX11(_GLFWwindow* window,
1961 const _GLFWwndconfig* wndconfig,
1962 const _GLFWctxconfig* ctxconfig,
1963 const _GLFWfbconfig* fbconfig)
1964{
1965 Visual* visual = NULL;
1966 int depth;
1967
1968 if (ctxconfig->client != GLFW_NO_API)
1969 {
1970 if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
1971 {
1972 if (!_glfwInitGLX())
1973 return GLFW_FALSE;
1974 if (!_glfwChooseVisualGLX(wndconfig, ctxconfig, fbconfig, &visual, &depth))
1975 return GLFW_FALSE;
1976 }
1977 else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
1978 {
1979 if (!_glfwInitEGL())
1980 return GLFW_FALSE;
1981 if (!_glfwChooseVisualEGL(wndconfig, ctxconfig, fbconfig, &visual, &depth))
1982 return GLFW_FALSE;
1983 }
1984 else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
1985 {
1986 if (!_glfwInitOSMesa())
1987 return GLFW_FALSE;
1988 }
1989 }
1990
1991 if (!visual)
1992 {
1993 visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen);
1994 depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen);
1995 }
1996
1997 if (!createNativeWindow(window, wndconfig, visual, depth))
1998 return GLFW_FALSE;
1999
2000 if (ctxconfig->client != GLFW_NO_API)
2001 {
2002 if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
2003 {
2004 if (!_glfwCreateContextGLX(window, ctxconfig, fbconfig))
2005 return GLFW_FALSE;
2006 }
2007 else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
2008 {
2009 if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
2010 return GLFW_FALSE;
2011 }
2012 else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
2013 {
2014 if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
2015 return GLFW_FALSE;
2016 }
2017
2018 if (!_glfwRefreshContextAttribs(window, ctxconfig))
2019 return GLFW_FALSE;
2020 }
2021
2022 if (wndconfig->mousePassthrough)
2023 _glfwSetWindowMousePassthroughX11(window, GLFW_TRUE);
2024
2025 if (window->monitor)
2026 {
2027 _glfwShowWindowX11(window);
2028 updateWindowMode(window);
2029 acquireMonitorX11(window);
2030
2031 if (wndconfig->centerCursor)
2032 _glfwCenterCursorInContentArea(window);
2033 }
2034 else
2035 {
2036 if (wndconfig->visible)
2037 {
2038 _glfwShowWindowX11(window);
2039 if (wndconfig->focused)
2040 _glfwFocusWindowX11(window);
2041 }
2042 }
2043
2044 XFlush(_glfw.x11.display);
2045 return GLFW_TRUE;
2046}
2047
2048void _glfwDestroyWindowX11(_GLFWwindow* window)
2049{
2050 if (_glfw.x11.disabledCursorWindow == window)
2051 enableCursor(window);
2052
2053 if (window->monitor)
2054 releaseMonitorX11(window);
2055
2056 if (window->x11.ic)
2057 {
2058 XDestroyIC(window->x11.ic);
2059 window->x11.ic = NULL;
2060 }
2061
2062 if (window->context.destroy)
2063 window->context.destroy(window);
2064
2065 if (window->x11.handle)
2066 {
2067 XDeleteContext(_glfw.x11.display, window->x11.handle, _glfw.x11.context);
2068 XUnmapWindow(_glfw.x11.display, window->x11.handle);
2069 XDestroyWindow(_glfw.x11.display, window->x11.handle);
2070 window->x11.handle = (Window) 0;
2071 }
2072
2073 if (window->x11.colormap)
2074 {
2075 XFreeColormap(_glfw.x11.display, window->x11.colormap);
2076 window->x11.colormap = (Colormap) 0;
2077 }
2078
2079 XFlush(_glfw.x11.display);
2080}
2081
2082void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title)
2083{
2084 if (_glfw.x11.xlib.utf8)
2085 {
2086 Xutf8SetWMProperties(_glfw.x11.display,
2087 window->x11.handle,
2088 title, title,
2089 NULL, 0,
2090 NULL, NULL, NULL);
2091 }
2092
2093 XChangeProperty(_glfw.x11.display, window->x11.handle,
2094 _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
2095 PropModeReplace,
2096 (unsigned char*) title, strlen(title));
2097
2098 XChangeProperty(_glfw.x11.display, window->x11.handle,
2099 _glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
2100 PropModeReplace,
2101 (unsigned char*) title, strlen(title));
2102
2103 XFlush(_glfw.x11.display);
2104}
2105
2106void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images)
2107{
2108 if (count)
2109 {
2110 int longCount = 0;
2111
2112 for (int i = 0; i < count; i++)
2113 longCount += 2 + images[i].width * images[i].height;
2114
2115 unsigned long* icon = _glfw_calloc(longCount, sizeof(unsigned long));
2116 unsigned long* target = icon;
2117
2118 for (int i = 0; i < count; i++)
2119 {
2120 *target++ = images[i].width;
2121 *target++ = images[i].height;
2122
2123 for (int j = 0; j < images[i].width * images[i].height; j++)
2124 {
2125 *target++ = (((unsigned long) images[i].pixels[j * 4 + 0]) << 16) |
2126 (((unsigned long) images[i].pixels[j * 4 + 1]) << 8) |
2127 (((unsigned long) images[i].pixels[j * 4 + 2]) << 0) |
2128 (((unsigned long) images[i].pixels[j * 4 + 3]) << 24);
2129 }
2130 }
2131
2132 // NOTE: XChangeProperty expects 32-bit values like the image data above to be
2133 // placed in the 32 least significant bits of individual longs. This is
2134 // true even if long is 64-bit and a WM protocol calls for "packed" data.
2135 // This is because of a historical mistake that then became part of the Xlib
2136 // ABI. Xlib will pack these values into a regular array of 32-bit values
2137 // before sending it over the wire.
2138 XChangeProperty(_glfw.x11.display, window->x11.handle,
2139 _glfw.x11.NET_WM_ICON,
2140 XA_CARDINAL, 32,
2141 PropModeReplace,
2142 (unsigned char*) icon,
2143 longCount);
2144
2145 _glfw_free(icon);
2146 }
2147 else
2148 {
2149 XDeleteProperty(_glfw.x11.display, window->x11.handle,
2150 _glfw.x11.NET_WM_ICON);
2151 }
2152
2153 XFlush(_glfw.x11.display);
2154}
2155
2156void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos)
2157{
2158 Window dummy;
2159 int x, y;
2160
2161 XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
2162 0, 0, &x, &y, &dummy);
2163
2164 if (xpos)
2165 *xpos = x;
2166 if (ypos)
2167 *ypos = y;
2168}
2169
2170void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos)
2171{
2172 // HACK: Explicitly setting PPosition to any value causes some WMs, notably
2173 // Compiz and Metacity, to honor the position of unmapped windows
2174 if (!_glfwWindowVisibleX11(window))
2175 {
2176 long supplied;
2177 XSizeHints* hints = XAllocSizeHints();
2178
2179 if (XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &supplied))
2180 {
2181 hints->flags |= PPosition;
2182 hints->x = hints->y = 0;
2183
2184 XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
2185 }
2186
2187 XFree(hints);
2188 }
2189
2190 XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
2191 XFlush(_glfw.x11.display);
2192}
2193
2194void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height)
2195{
2196 XWindowAttributes attribs;
2197 XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
2198
2199 if (width)
2200 *width = attribs.width;
2201 if (height)
2202 *height = attribs.height;
2203}
2204
2205void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height)
2206{
2207 if (window->monitor)
2208 {
2209 if (window->monitor->window == window)
2210 acquireMonitorX11(window);
2211 }
2212 else
2213 {
2214 if (!window->resizable)
2215 updateNormalHints(window, width, height);
2216
2217 XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
2218 }
2219
2220 XFlush(_glfw.x11.display);
2221}
2222
2223void _glfwSetWindowSizeLimitsX11(_GLFWwindow* window,
2224 int minwidth, int minheight,
2225 int maxwidth, int maxheight)
2226{
2227 int width, height;
2228 _glfwGetWindowSizeX11(window, &width, &height);
2229 updateNormalHints(window, width, height);
2230 XFlush(_glfw.x11.display);
2231}
2232
2233void _glfwSetWindowAspectRatioX11(_GLFWwindow* window, int numer, int denom)
2234{
2235 int width, height;
2236 _glfwGetWindowSizeX11(window, &width, &height);
2237 updateNormalHints(window, width, height);
2238 XFlush(_glfw.x11.display);
2239}
2240
2241void _glfwGetFramebufferSizeX11(_GLFWwindow* window, int* width, int* height)
2242{
2243 _glfwGetWindowSizeX11(window, width, height);
2244}
2245
2246void _glfwGetWindowFrameSizeX11(_GLFWwindow* window,
2247 int* left, int* top,
2248 int* right, int* bottom)
2249{
2250 long* extents = NULL;
2251
2252 if (window->monitor || !window->decorated)
2253 return;
2254
2255 if (_glfw.x11.NET_FRAME_EXTENTS == None)
2256 return;
2257
2258 if (!_glfwWindowVisibleX11(window) &&
2259 _glfw.x11.NET_REQUEST_FRAME_EXTENTS)
2260 {
2261 XEvent event;
2262 double timeout = 0.5;
2263
2264 // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
2265 // function before the window is mapped
2266 sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS,
2267 0, 0, 0, 0, 0);
2268
2269 // HACK: Use a timeout because earlier versions of some window managers
2270 // (at least Unity, Fluxbox and Xfwm) failed to send the reply
2271 // They have been fixed but broken versions are still in the wild
2272 // If you are affected by this and your window manager is NOT
2273 // listed above, PLEASE report it to their and our issue trackers
2274 while (!XCheckIfEvent(_glfw.x11.display,
2275 &event,
2276 isFrameExtentsEvent,
2277 (XPointer) window))
2278 {
2279 if (!waitForX11Event(&timeout))
2280 {
2281 _glfwInputError(GLFW_PLATFORM_ERROR,
2282 "X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue");
2283 return;
2284 }
2285 }
2286 }
2287
2288 if (_glfwGetWindowPropertyX11(window->x11.handle,
2289 _glfw.x11.NET_FRAME_EXTENTS,
2290 XA_CARDINAL,
2291 (unsigned char**) &extents) == 4)
2292 {
2293 if (left)
2294 *left = extents[0];
2295 if (top)
2296 *top = extents[2];
2297 if (right)
2298 *right = extents[1];
2299 if (bottom)
2300 *bottom = extents[3];
2301 }
2302
2303 if (extents)
2304 XFree(extents);
2305}
2306
2307void _glfwGetWindowContentScaleX11(_GLFWwindow* window, float* xscale, float* yscale)
2308{
2309 if (xscale)
2310 *xscale = _glfw.x11.contentScaleX;
2311 if (yscale)
2312 *yscale = _glfw.x11.contentScaleY;
2313}
2314
2315void _glfwIconifyWindowX11(_GLFWwindow* window)
2316{
2317 if (window->x11.overrideRedirect)
2318 {
2319 // Override-redirect windows cannot be iconified or restored, as those
2320 // tasks are performed by the window manager
2321 _glfwInputError(GLFW_PLATFORM_ERROR,
2322 "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
2323 return;
2324 }
2325
2326 XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);
2327 XFlush(_glfw.x11.display);
2328}
2329
2330void _glfwRestoreWindowX11(_GLFWwindow* window)
2331{
2332 if (window->x11.overrideRedirect)
2333 {
2334 // Override-redirect windows cannot be iconified or restored, as those
2335 // tasks are performed by the window manager
2336 _glfwInputError(GLFW_PLATFORM_ERROR,
2337 "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
2338 return;
2339 }
2340
2341 if (_glfwWindowIconifiedX11(window))
2342 {
2343 XMapWindow(_glfw.x11.display, window->x11.handle);
2344 waitForVisibilityNotify(window);
2345 }
2346 else if (_glfwWindowVisibleX11(window))
2347 {
2348 if (_glfw.x11.NET_WM_STATE &&
2349 _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
2350 _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2351 {
2352 sendEventToWM(window,
2353 _glfw.x11.NET_WM_STATE,
2354 _NET_WM_STATE_REMOVE,
2355 _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
2356 _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
2357 1, 0);
2358 }
2359 }
2360
2361 XFlush(_glfw.x11.display);
2362}
2363
2364void _glfwMaximizeWindowX11(_GLFWwindow* window)
2365{
2366 if (!_glfw.x11.NET_WM_STATE ||
2367 !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
2368 !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2369 {
2370 return;
2371 }
2372
2373 if (_glfwWindowVisibleX11(window))
2374 {
2375 sendEventToWM(window,
2376 _glfw.x11.NET_WM_STATE,
2377 _NET_WM_STATE_ADD,
2378 _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
2379 _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
2380 1, 0);
2381 }
2382 else
2383 {
2384 Atom* states = NULL;
2385 unsigned long count =
2386 _glfwGetWindowPropertyX11(window->x11.handle,
2387 _glfw.x11.NET_WM_STATE,
2388 XA_ATOM,
2389 (unsigned char**) &states);
2390
2391 // NOTE: We don't check for failure as this property may not exist yet
2392 // and that's fine (and we'll create it implicitly with append)
2393
2394 Atom missing[2] =
2395 {
2396 _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
2397 _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ
2398 };
2399 unsigned long missingCount = 2;
2400
2401 for (unsigned long i = 0; i < count; i++)
2402 {
2403 for (unsigned long j = 0; j < missingCount; j++)
2404 {
2405 if (states[i] == missing[j])
2406 {
2407 missing[j] = missing[missingCount - 1];
2408 missingCount--;
2409 }
2410 }
2411 }
2412
2413 if (states)
2414 XFree(states);
2415
2416 if (!missingCount)
2417 return;
2418
2419 XChangeProperty(_glfw.x11.display, window->x11.handle,
2420 _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
2421 PropModeAppend,
2422 (unsigned char*) missing,
2423 missingCount);
2424 }
2425
2426 XFlush(_glfw.x11.display);
2427}
2428
2429void _glfwShowWindowX11(_GLFWwindow* window)
2430{
2431 if (_glfwWindowVisibleX11(window))
2432 return;
2433
2434 XMapWindow(_glfw.x11.display, window->x11.handle);
2435 waitForVisibilityNotify(window);
2436}
2437
2438void _glfwHideWindowX11(_GLFWwindow* window)
2439{
2440 XUnmapWindow(_glfw.x11.display, window->x11.handle);
2441 XFlush(_glfw.x11.display);
2442}
2443
2444void _glfwRequestWindowAttentionX11(_GLFWwindow* window)
2445{
2446 if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION)
2447 return;
2448
2449 sendEventToWM(window,
2450 _glfw.x11.NET_WM_STATE,
2451 _NET_WM_STATE_ADD,
2452 _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION,
2453 0, 1, 0);
2454}
2455
2456void _glfwFocusWindowX11(_GLFWwindow* window)
2457{
2458 if (_glfw.x11.NET_ACTIVE_WINDOW)
2459 sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0);
2460 else if (_glfwWindowVisibleX11(window))
2461 {
2462 XRaiseWindow(_glfw.x11.display, window->x11.handle);
2463 XSetInputFocus(_glfw.x11.display, window->x11.handle,
2464 RevertToParent, CurrentTime);
2465 }
2466
2467 XFlush(_glfw.x11.display);
2468}
2469
2470void _glfwSetWindowMonitorX11(_GLFWwindow* window,
2471 _GLFWmonitor* monitor,
2472 int xpos, int ypos,
2473 int width, int height,
2474 int refreshRate)
2475{
2476 if (window->monitor == monitor)
2477 {
2478 if (monitor)
2479 {
2480 if (monitor->window == window)
2481 acquireMonitorX11(window);
2482 }
2483 else
2484 {
2485 if (!window->resizable)
2486 updateNormalHints(window, width, height);
2487
2488 XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
2489 xpos, ypos, width, height);
2490 }
2491
2492 XFlush(_glfw.x11.display);
2493 return;
2494 }
2495
2496 if (window->monitor)
2497 {
2498 _glfwSetWindowDecoratedX11(window, window->decorated);
2499 _glfwSetWindowFloatingX11(window, window->floating);
2500 releaseMonitorX11(window);
2501 }
2502
2503 _glfwInputWindowMonitor(window, monitor);
2504 updateNormalHints(window, width, height);
2505
2506 if (window->monitor)
2507 {
2508 if (!_glfwWindowVisibleX11(window))
2509 {
2510 XMapRaised(_glfw.x11.display, window->x11.handle);
2511 waitForVisibilityNotify(window);
2512 }
2513
2514 updateWindowMode(window);
2515 acquireMonitorX11(window);
2516 }
2517 else
2518 {
2519 updateWindowMode(window);
2520 XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
2521 xpos, ypos, width, height);
2522 }
2523
2524 XFlush(_glfw.x11.display);
2525}
2526
2527GLFWbool _glfwWindowFocusedX11(_GLFWwindow* window)
2528{
2529 Window focused;
2530 int state;
2531
2532 XGetInputFocus(_glfw.x11.display, &focused, &state);
2533 return window->x11.handle == focused;
2534}
2535
2536GLFWbool _glfwWindowIconifiedX11(_GLFWwindow* window)
2537{
2538 return getWindowState(window) == IconicState;
2539}
2540
2541GLFWbool _glfwWindowVisibleX11(_GLFWwindow* window)
2542{
2543 XWindowAttributes wa;
2544 XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);
2545 return wa.map_state == IsViewable;
2546}
2547
2548GLFWbool _glfwWindowMaximizedX11(_GLFWwindow* window)
2549{
2550 Atom* states;
2551 GLFWbool maximized = GLFW_FALSE;
2552
2553 if (!_glfw.x11.NET_WM_STATE ||
2554 !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
2555 !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2556 {
2557 return maximized;
2558 }
2559
2560 const unsigned long count =
2561 _glfwGetWindowPropertyX11(window->x11.handle,
2562 _glfw.x11.NET_WM_STATE,
2563 XA_ATOM,
2564 (unsigned char**) &states);
2565
2566 for (unsigned long i = 0; i < count; i++)
2567 {
2568 if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
2569 states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
2570 {
2571 maximized = GLFW_TRUE;
2572 break;
2573 }
2574 }
2575
2576 if (states)
2577 XFree(states);
2578
2579 return maximized;
2580}
2581
2582GLFWbool _glfwWindowHoveredX11(_GLFWwindow* window)
2583{
2584 Window w = _glfw.x11.root;
2585 while (w)
2586 {
2587 Window root;
2588 int rootX, rootY, childX, childY;
2589 unsigned int mask;
2590
2591 _glfwGrabErrorHandlerX11();
2592
2593 const Bool result = XQueryPointer(_glfw.x11.display, w,
2594 &root, &w, &rootX, &rootY,
2595 &childX, &childY, &mask);
2596
2597 _glfwReleaseErrorHandlerX11();
2598
2599 if (_glfw.x11.errorCode == BadWindow)
2600 w = _glfw.x11.root;
2601 else if (!result)
2602 return GLFW_FALSE;
2603 else if (w == window->x11.handle)
2604 return GLFW_TRUE;
2605 }
2606
2607 return GLFW_FALSE;
2608}
2609
2610GLFWbool _glfwFramebufferTransparentX11(_GLFWwindow* window)
2611{
2612 if (!window->x11.transparent)
2613 return GLFW_FALSE;
2614
2615 return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None;
2616}
2617
2618void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled)
2619{
2620 int width, height;
2621 _glfwGetWindowSizeX11(window, &width, &height);
2622 updateNormalHints(window, width, height);
2623}
2624
2625void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled)
2626{
2627 struct
2628 {
2629 unsigned long flags;
2630 unsigned long functions;
2631 unsigned long decorations;
2632 long input_mode;
2633 unsigned long status;
2634 } hints = {0};
2635
2636 hints.flags = MWM_HINTS_DECORATIONS;
2637 hints.decorations = enabled ? MWM_DECOR_ALL : 0;
2638
2639 XChangeProperty(_glfw.x11.display, window->x11.handle,
2640 _glfw.x11.MOTIF_WM_HINTS,
2641 _glfw.x11.MOTIF_WM_HINTS, 32,
2642 PropModeReplace,
2643 (unsigned char*) &hints,
2644 sizeof(hints) / sizeof(long));
2645}
2646
2647void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled)
2648{
2649 if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_ABOVE)
2650 return;
2651
2652 if (_glfwWindowVisibleX11(window))
2653 {
2654 const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
2655 sendEventToWM(window,
2656 _glfw.x11.NET_WM_STATE,
2657 action,
2658 _glfw.x11.NET_WM_STATE_ABOVE,
2659 0, 1, 0);
2660 }
2661 else
2662 {
2663 Atom* states = NULL;
2664 const unsigned long count =
2665 _glfwGetWindowPropertyX11(window->x11.handle,
2666 _glfw.x11.NET_WM_STATE,
2667 XA_ATOM,
2668 (unsigned char**) &states);
2669
2670 // NOTE: We don't check for failure as this property may not exist yet
2671 // and that's fine (and we'll create it implicitly with append)
2672
2673 if (enabled)
2674 {
2675 unsigned long i;
2676
2677 for (i = 0; i < count; i++)
2678 {
2679 if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
2680 break;
2681 }
2682
2683 if (i == count)
2684 {
2685 XChangeProperty(_glfw.x11.display, window->x11.handle,
2686 _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
2687 PropModeAppend,
2688 (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
2689 1);
2690 }
2691 }
2692 else if (states)
2693 {
2694 for (unsigned long i = 0; i < count; i++)
2695 {
2696 if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
2697 {
2698 states[i] = states[count - 1];
2699 XChangeProperty(_glfw.x11.display, window->x11.handle,
2700 _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
2701 PropModeReplace, (unsigned char*) states, count - 1);
2702 break;
2703 }
2704 }
2705 }
2706
2707 if (states)
2708 XFree(states);
2709 }
2710
2711 XFlush(_glfw.x11.display);
2712}
2713
2714void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled)
2715{
2716 if (!_glfw.x11.xshape.available)
2717 return;
2718
2719 if (enabled)
2720 {
2721 Region region = XCreateRegion();
2722 XShapeCombineRegion(_glfw.x11.display, window->x11.handle,
2723 ShapeInput, 0, 0, region, ShapeSet);
2724 XDestroyRegion(region);
2725 }
2726 else
2727 {
2728 XShapeCombineMask(_glfw.x11.display, window->x11.handle,
2729 ShapeInput, 0, 0, None, ShapeSet);
2730 }
2731}
2732
2733float _glfwGetWindowOpacityX11(_GLFWwindow* window)
2734{
2735 float opacity = 1.f;
2736
2737 if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx))
2738 {
2739 CARD32* value = NULL;
2740
2741 if (_glfwGetWindowPropertyX11(window->x11.handle,
2742 _glfw.x11.NET_WM_WINDOW_OPACITY,
2743 XA_CARDINAL,
2744 (unsigned char**) &value))
2745 {
2746 opacity = (float) (*value / (double) 0xffffffffu);
2747 }
2748
2749 if (value)
2750 XFree(value);
2751 }
2752
2753 return opacity;
2754}
2755
2756void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity)
2757{
2758 const CARD32 value = (CARD32) (0xffffffffu * (double) opacity);
2759 XChangeProperty(_glfw.x11.display, window->x11.handle,
2760 _glfw.x11.NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
2761 PropModeReplace, (unsigned char*) &value, 1);
2762}
2763
2764void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled)
2765{
2766 if (!_glfw.x11.xi.available)
2767 return;
2768
2769 if (_glfw.x11.disabledCursorWindow != window)
2770 return;
2771
2772 if (enabled)
2773 enableRawMouseMotion(window);
2774 else
2775 disableRawMouseMotion(window);
2776}
2777
2778GLFWbool _glfwRawMouseMotionSupportedX11(void)
2779{
2780 return _glfw.x11.xi.available;
2781}
2782
2783void _glfwPollEventsX11(void)
2784{
2785 drainEmptyEvents();
2786
2787#if defined(GLFW_BUILD_LINUX_JOYSTICK)
2788 if (_glfw.joysticksInitialized)
2789 _glfwDetectJoystickConnectionLinux();
2790#endif
2791 XPending(_glfw.x11.display);
2792
2793 while (QLength(_glfw.x11.display))
2794 {
2795 XEvent event;
2796 XNextEvent(_glfw.x11.display, &event);
2797 processEvent(&event);
2798 }
2799
2800 _GLFWwindow* window = _glfw.x11.disabledCursorWindow;
2801 if (window)
2802 {
2803 int width, height;
2804 _glfwGetWindowSizeX11(window, &width, &height);
2805
2806 // NOTE: Re-center the cursor only if it has moved since the last call,
2807 // to avoid breaking glfwWaitEvents with MotionNotify
2808 if (window->x11.lastCursorPosX != width / 2 ||
2809 window->x11.lastCursorPosY != height / 2)
2810 {
2811 _glfwSetCursorPosX11(window, width / 2, height / 2);
2812 }
2813 }
2814
2815 XFlush(_glfw.x11.display);
2816}
2817
2818void _glfwWaitEventsX11(void)
2819{
2820 waitForAnyEvent(NULL);
2821 _glfwPollEventsX11();
2822}
2823
2824void _glfwWaitEventsTimeoutX11(double timeout)
2825{
2826 waitForAnyEvent(&timeout);
2827 _glfwPollEventsX11();
2828}
2829
2830void _glfwPostEmptyEventX11(void)
2831{
2832 writeEmptyEvent();
2833}
2834
2835void _glfwGetCursorPosX11(_GLFWwindow* window, double* xpos, double* ypos)
2836{
2837 Window root, child;
2838 int rootX, rootY, childX, childY;
2839 unsigned int mask;
2840
2841 XQueryPointer(_glfw.x11.display, window->x11.handle,
2842 &root, &child,
2843 &rootX, &rootY, &childX, &childY,
2844 &mask);
2845
2846 if (xpos)
2847 *xpos = childX;
2848 if (ypos)
2849 *ypos = childY;
2850}
2851
2852void _glfwSetCursorPosX11(_GLFWwindow* window, double x, double y)
2853{
2854 // Store the new position so it can be recognized later
2855 window->x11.warpCursorPosX = (int) x;
2856 window->x11.warpCursorPosY = (int) y;
2857
2858 XWarpPointer(_glfw.x11.display, None, window->x11.handle,
2859 0,0,0,0, (int) x, (int) y);
2860 XFlush(_glfw.x11.display);
2861}
2862
2863void _glfwSetCursorModeX11(_GLFWwindow* window, int mode)
2864{
2865 if (_glfwWindowFocusedX11(window))
2866 {
2867 if (mode == GLFW_CURSOR_DISABLED)
2868 {
2869 _glfwGetCursorPosX11(window,
2870 &_glfw.x11.restoreCursorPosX,
2871 &_glfw.x11.restoreCursorPosY);
2872 _glfwCenterCursorInContentArea(window);
2873 if (window->rawMouseMotion)
2874 enableRawMouseMotion(window);
2875 }
2876 else if (_glfw.x11.disabledCursorWindow == window)
2877 {
2878 if (window->rawMouseMotion)
2879 disableRawMouseMotion(window);
2880 }
2881
2882 if (mode == GLFW_CURSOR_DISABLED || mode == GLFW_CURSOR_CAPTURED)
2883 captureCursor(window);
2884 else
2885 releaseCursor();
2886
2887 if (mode == GLFW_CURSOR_DISABLED)
2888 _glfw.x11.disabledCursorWindow = window;
2889 else if (_glfw.x11.disabledCursorWindow == window)
2890 {
2891 _glfw.x11.disabledCursorWindow = NULL;
2892 _glfwSetCursorPosX11(window,
2893 _glfw.x11.restoreCursorPosX,
2894 _glfw.x11.restoreCursorPosY);
2895 }
2896 }
2897
2898 updateCursorImage(window);
2899 XFlush(_glfw.x11.display);
2900}
2901
2902const char* _glfwGetScancodeNameX11(int scancode)
2903{
2904 if (!_glfw.x11.xkb.available)
2905 return NULL;
2906
2907 if (scancode < 0 || scancode > 0xff)
2908 {
2909 _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
2910 return NULL;
2911 }
2912
2913 const int key = _glfw.x11.keycodes[scancode];
2914 if (key == GLFW_KEY_UNKNOWN)
2915 return NULL;
2916
2917 const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
2918 scancode, _glfw.x11.xkb.group, 0);
2919 if (keysym == NoSymbol)
2920 return NULL;
2921
2922 const uint32_t codepoint = _glfwKeySym2Unicode(keysym);
2923 if (codepoint == GLFW_INVALID_CODEPOINT)
2924 return NULL;
2925
2926 const size_t count = _glfwEncodeUTF8(_glfw.x11.keynames[key], codepoint);
2927 if (count == 0)
2928 return NULL;
2929
2930 _glfw.x11.keynames[key][count] = '\0';
2931 return _glfw.x11.keynames[key];
2932}
2933
2934int _glfwGetKeyScancodeX11(int key)
2935{
2936 return _glfw.x11.scancodes[key];
2937}
2938
2939GLFWbool _glfwCreateCursorX11(_GLFWcursor* cursor,
2940 const GLFWimage* image,
2941 int xhot, int yhot)
2942{
2943 cursor->x11.handle = _glfwCreateNativeCursorX11(image, xhot, yhot);
2944 if (!cursor->x11.handle)
2945 return GLFW_FALSE;
2946
2947 return GLFW_TRUE;
2948}
2949
2950GLFWbool _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape)
2951{
2952 if (_glfw.x11.xcursor.handle)
2953 {
2954 char* theme = XcursorGetTheme(_glfw.x11.display);
2955 if (theme)
2956 {
2957 const int size = XcursorGetDefaultSize(_glfw.x11.display);
2958 const char* name = NULL;
2959
2960 switch (shape)
2961 {
2962 case GLFW_ARROW_CURSOR:
2963 name = "default";
2964 break;
2965 case GLFW_IBEAM_CURSOR:
2966 name = "text";
2967 break;
2968 case GLFW_CROSSHAIR_CURSOR:
2969 name = "crosshair";
2970 break;
2971 case GLFW_POINTING_HAND_CURSOR:
2972 name = "pointer";
2973 break;
2974 case GLFW_RESIZE_EW_CURSOR:
2975 name = "ew-resize";
2976 break;
2977 case GLFW_RESIZE_NS_CURSOR:
2978 name = "ns-resize";
2979 break;
2980 case GLFW_RESIZE_NWSE_CURSOR:
2981 name = "nwse-resize";
2982 break;
2983 case GLFW_RESIZE_NESW_CURSOR:
2984 name = "nesw-resize";
2985 break;
2986 case GLFW_RESIZE_ALL_CURSOR:
2987 name = "all-scroll";
2988 break;
2989 case GLFW_NOT_ALLOWED_CURSOR:
2990 name = "not-allowed";
2991 break;
2992 }
2993
2994 XcursorImage* image = XcursorLibraryLoadImage(name, theme, size);
2995 if (image)
2996 {
2997 cursor->x11.handle = XcursorImageLoadCursor(_glfw.x11.display, image);
2998 XcursorImageDestroy(image);
2999 }
3000 }
3001 }
3002
3003 if (!cursor->x11.handle)
3004 {
3005 unsigned int native = 0;
3006
3007 switch (shape)
3008 {
3009 case GLFW_ARROW_CURSOR:
3010 native = XC_left_ptr;
3011 break;
3012 case GLFW_IBEAM_CURSOR:
3013 native = XC_xterm;
3014 break;
3015 case GLFW_CROSSHAIR_CURSOR:
3016 native = XC_crosshair;
3017 break;
3018 case GLFW_POINTING_HAND_CURSOR:
3019 native = XC_hand2;
3020 break;
3021 case GLFW_RESIZE_EW_CURSOR:
3022 native = XC_sb_h_double_arrow;
3023 break;
3024 case GLFW_RESIZE_NS_CURSOR:
3025 native = XC_sb_v_double_arrow;
3026 break;
3027 case GLFW_RESIZE_ALL_CURSOR:
3028 native = XC_fleur;
3029 break;
3030 default:
3031 _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
3032 "X11: Standard cursor shape unavailable");
3033 return GLFW_FALSE;
3034 }
3035
3036 cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
3037 if (!cursor->x11.handle)
3038 {
3039 _glfwInputError(GLFW_PLATFORM_ERROR,
3040 "X11: Failed to create standard cursor");
3041 return GLFW_FALSE;
3042 }
3043 }
3044
3045 return GLFW_TRUE;
3046}
3047
3048void _glfwDestroyCursorX11(_GLFWcursor* cursor)
3049{
3050 if (cursor->x11.handle)
3051 XFreeCursor(_glfw.x11.display, cursor->x11.handle);
3052}
3053
3054void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor)
3055{
3056 if (window->cursorMode == GLFW_CURSOR_NORMAL ||
3057 window->cursorMode == GLFW_CURSOR_CAPTURED)
3058 {
3059 updateCursorImage(window);
3060 XFlush(_glfw.x11.display);
3061 }
3062}
3063
3064void _glfwSetClipboardStringX11(const char* string)
3065{
3066 char* copy = _glfw_strdup(string);
3067 _glfw_free(_glfw.x11.clipboardString);
3068 _glfw.x11.clipboardString = copy;
3069
3070 XSetSelectionOwner(_glfw.x11.display,
3071 _glfw.x11.CLIPBOARD,
3072 _glfw.x11.helperWindowHandle,
3073 CurrentTime);
3074
3075 if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) !=
3076 _glfw.x11.helperWindowHandle)
3077 {
3078 _glfwInputError(GLFW_PLATFORM_ERROR,
3079 "X11: Failed to become owner of clipboard selection");
3080 }
3081}
3082
3083const char* _glfwGetClipboardStringX11(void)
3084{
3085 return getSelectionString(_glfw.x11.CLIPBOARD);
3086}
3087
3088EGLenum _glfwGetEGLPlatformX11(EGLint** attribs)
3089{
3090 if (_glfw.egl.ANGLE_platform_angle)
3091 {
3092 int type = 0;
3093
3094 if (_glfw.egl.ANGLE_platform_angle_opengl)
3095 {
3096 if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
3097 type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
3098 }
3099
3100 if (_glfw.egl.ANGLE_platform_angle_vulkan)
3101 {
3102 if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
3103 type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
3104 }
3105
3106 if (type)
3107 {
3108 *attribs = _glfw_calloc(5, sizeof(EGLint));
3109 (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
3110 (*attribs)[1] = type;
3111 (*attribs)[2] = EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE;
3112 (*attribs)[3] = EGL_PLATFORM_X11_EXT;
3113 (*attribs)[4] = EGL_NONE;
3114 return EGL_PLATFORM_ANGLE_ANGLE;
3115 }
3116 }
3117
3118 if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_x11)
3119 return EGL_PLATFORM_X11_EXT;
3120
3121 return 0;
3122}
3123
3124EGLNativeDisplayType _glfwGetEGLNativeDisplayX11(void)
3125{
3126 return _glfw.x11.display;
3127}
3128
3129EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window)
3130{
3131 if (_glfw.egl.platform)
3132 return &window->x11.handle;
3133 else
3134 return (EGLNativeWindowType) window->x11.handle;
3135}
3136
3137void _glfwGetRequiredInstanceExtensionsX11(char** extensions)
3138{
3139 if (!_glfw.vk.KHR_surface)
3140 return;
3141
3142 if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
3143 {
3144 if (!_glfw.vk.KHR_xlib_surface)
3145 return;
3146 }
3147
3148 extensions[0] = "VK_KHR_surface";
3149
3150 // NOTE: VK_KHR_xcb_surface is preferred due to some early ICDs exposing but
3151 // not correctly implementing VK_KHR_xlib_surface
3152 if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
3153 extensions[1] = "VK_KHR_xcb_surface";
3154 else
3155 extensions[1] = "VK_KHR_xlib_surface";
3156}
3157
3158GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance,
3159 VkPhysicalDevice device,
3160 uint32_t queuefamily)
3161{
3162 VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
3163 _glfw.x11.screen));
3164
3165 if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
3166 {
3167 PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
3168 vkGetPhysicalDeviceXcbPresentationSupportKHR =
3169 (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)
3170 vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
3171 if (!vkGetPhysicalDeviceXcbPresentationSupportKHR)
3172 {
3173 _glfwInputError(GLFW_API_UNAVAILABLE,
3174 "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
3175 return GLFW_FALSE;
3176 }
3177
3178 xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
3179 if (!connection)
3180 {
3181 _glfwInputError(GLFW_PLATFORM_ERROR,
3182 "X11: Failed to retrieve XCB connection");
3183 return GLFW_FALSE;
3184 }
3185
3186 return vkGetPhysicalDeviceXcbPresentationSupportKHR(device,
3187 queuefamily,
3188 connection,
3189 visualID);
3190 }
3191 else
3192 {
3193 PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
3194 vkGetPhysicalDeviceXlibPresentationSupportKHR =
3195 (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)
3196 vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
3197 if (!vkGetPhysicalDeviceXlibPresentationSupportKHR)
3198 {
3199 _glfwInputError(GLFW_API_UNAVAILABLE,
3200 "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
3201 return GLFW_FALSE;
3202 }
3203
3204 return vkGetPhysicalDeviceXlibPresentationSupportKHR(device,
3205 queuefamily,
3206 _glfw.x11.display,
3207 visualID);
3208 }
3209}
3210
3211VkResult _glfwCreateWindowSurfaceX11(VkInstance instance,
3212 _GLFWwindow* window,
3213 const VkAllocationCallbacks* allocator,
3214 VkSurfaceKHR* surface)
3215{
3216 if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
3217 {
3218 VkResult err;
3219 VkXcbSurfaceCreateInfoKHR sci;
3220 PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
3221
3222 xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
3223 if (!connection)
3224 {
3225 _glfwInputError(GLFW_PLATFORM_ERROR,
3226 "X11: Failed to retrieve XCB connection");
3227 return VK_ERROR_EXTENSION_NOT_PRESENT;
3228 }
3229
3230 vkCreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)
3231 vkGetInstanceProcAddr(instance, "vkCreateXcbSurfaceKHR");
3232 if (!vkCreateXcbSurfaceKHR)
3233 {
3234 _glfwInputError(GLFW_API_UNAVAILABLE,
3235 "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
3236 return VK_ERROR_EXTENSION_NOT_PRESENT;
3237 }
3238
3239 memset(&sci, 0, sizeof(sci));
3240 sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
3241 sci.connection = connection;
3242 sci.window = window->x11.handle;
3243
3244 err = vkCreateXcbSurfaceKHR(instance, &sci, allocator, surface);
3245 if (err)
3246 {
3247 _glfwInputError(GLFW_PLATFORM_ERROR,
3248 "X11: Failed to create Vulkan XCB surface: %s",
3249 _glfwGetVulkanResultString(err));
3250 }
3251
3252 return err;
3253 }
3254 else
3255 {
3256 VkResult err;
3257 VkXlibSurfaceCreateInfoKHR sci;
3258 PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
3259
3260 vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)
3261 vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR");
3262 if (!vkCreateXlibSurfaceKHR)
3263 {
3264 _glfwInputError(GLFW_API_UNAVAILABLE,
3265 "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
3266 return VK_ERROR_EXTENSION_NOT_PRESENT;
3267 }
3268
3269 memset(&sci, 0, sizeof(sci));
3270 sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
3271 sci.dpy = _glfw.x11.display;
3272 sci.window = window->x11.handle;
3273
3274 err = vkCreateXlibSurfaceKHR(instance, &sci, allocator, surface);
3275 if (err)
3276 {
3277 _glfwInputError(GLFW_PLATFORM_ERROR,
3278 "X11: Failed to create Vulkan X11 surface: %s",
3279 _glfwGetVulkanResultString(err));
3280 }
3281
3282 return err;
3283 }
3284}
3285
3286
3287//////////////////////////////////////////////////////////////////////////
3288////// GLFW native API //////
3289//////////////////////////////////////////////////////////////////////////
3290
3291GLFWAPI Display* glfwGetX11Display(void)
3292{
3293 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
3294
3295 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
3296 {
3297 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
3298 return NULL;
3299 }
3300
3301 return _glfw.x11.display;
3302}
3303
3304GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
3305{
3306 _GLFWwindow* window = (_GLFWwindow*) handle;
3307 _GLFW_REQUIRE_INIT_OR_RETURN(None);
3308
3309 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
3310 {
3311 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
3312 return None;
3313 }
3314
3315 return window->x11.handle;
3316}
3317
3318GLFWAPI void glfwSetX11SelectionString(const char* string)
3319{
3320 _GLFW_REQUIRE_INIT();
3321
3322 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
3323 {
3324 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
3325 return;
3326 }
3327
3328 _glfw_free(_glfw.x11.primarySelectionString);
3329 _glfw.x11.primarySelectionString = _glfw_strdup(string);
3330
3331 XSetSelectionOwner(_glfw.x11.display,
3332 _glfw.x11.PRIMARY,
3333 _glfw.x11.helperWindowHandle,
3334 CurrentTime);
3335
3336 if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.PRIMARY) !=
3337 _glfw.x11.helperWindowHandle)
3338 {
3339 _glfwInputError(GLFW_PLATFORM_ERROR,
3340 "X11: Failed to become owner of primary selection");
3341 }
3342}
3343
3344GLFWAPI const char* glfwGetX11SelectionString(void)
3345{
3346 _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
3347
3348 if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
3349 {
3350 _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
3351 return NULL;
3352 }
3353
3354 return getSelectionString(_glfw.x11.PRIMARY);
3355}
3356
3357#endif // _GLFW_X11
3358
diff --git a/raylib/src/external/glfw/src/xkb_unicode.c b/raylib/src/external/glfw/src/xkb_unicode.c
new file mode 100644
index 0000000..6b8dfca
--- /dev/null
+++ b/raylib/src/external/glfw/src/xkb_unicode.c
@@ -0,0 +1,943 @@
1//========================================================================
2// GLFW 3.4 X11 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#include "internal.h"
29
30#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND)
31
32/*
33 * Marcus: This code was originally written by Markus G. Kuhn.
34 * I have made some slight changes (trimmed it down a bit from >60 KB to
35 * 20 KB), but the functionality is the same.
36 */
37
38/*
39 * This module converts keysym values into the corresponding ISO 10646
40 * (UCS, Unicode) values.
41 *
42 * The array keysymtab[] contains pairs of X11 keysym values for graphical
43 * characters and the corresponding Unicode value. The function
44 * _glfwKeySym2Unicode() maps a keysym onto a Unicode value using a binary
45 * search, therefore keysymtab[] must remain SORTED by keysym value.
46 *
47 * We allow to represent any UCS character in the range U-00000000 to
48 * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
49 * This admittedly does not cover the entire 31-bit space of UCS, but
50 * it does cover all of the characters up to U-10FFFF, which can be
51 * represented by UTF-16, and more, and it is very unlikely that higher
52 * UCS codes will ever be assigned by ISO. So to get Unicode character
53 * U+ABCD you can directly use keysym 0x0100abcd.
54 *
55 * Original author: Markus G. Kuhn <mkuhn@acm.org>, University of
56 * Cambridge, April 2001
57 *
58 * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
59 * an initial draft of the mapping table.
60 *
61 */
62
63
64//************************************************************************
65//**** KeySym to Unicode mapping table ****
66//************************************************************************
67
68static const struct codepair {
69 unsigned short keysym;
70 unsigned short ucs;
71} keysymtab[] = {
72 { 0x01a1, 0x0104 },
73 { 0x01a2, 0x02d8 },
74 { 0x01a3, 0x0141 },
75 { 0x01a5, 0x013d },
76 { 0x01a6, 0x015a },
77 { 0x01a9, 0x0160 },
78 { 0x01aa, 0x015e },
79 { 0x01ab, 0x0164 },
80 { 0x01ac, 0x0179 },
81 { 0x01ae, 0x017d },
82 { 0x01af, 0x017b },
83 { 0x01b1, 0x0105 },
84 { 0x01b2, 0x02db },
85 { 0x01b3, 0x0142 },
86 { 0x01b5, 0x013e },
87 { 0x01b6, 0x015b },
88 { 0x01b7, 0x02c7 },
89 { 0x01b9, 0x0161 },
90 { 0x01ba, 0x015f },
91 { 0x01bb, 0x0165 },
92 { 0x01bc, 0x017a },
93 { 0x01bd, 0x02dd },
94 { 0x01be, 0x017e },
95 { 0x01bf, 0x017c },
96 { 0x01c0, 0x0154 },
97 { 0x01c3, 0x0102 },
98 { 0x01c5, 0x0139 },
99 { 0x01c6, 0x0106 },
100 { 0x01c8, 0x010c },
101 { 0x01ca, 0x0118 },
102 { 0x01cc, 0x011a },
103 { 0x01cf, 0x010e },
104 { 0x01d0, 0x0110 },
105 { 0x01d1, 0x0143 },
106 { 0x01d2, 0x0147 },
107 { 0x01d5, 0x0150 },
108 { 0x01d8, 0x0158 },
109 { 0x01d9, 0x016e },
110 { 0x01db, 0x0170 },
111 { 0x01de, 0x0162 },
112 { 0x01e0, 0x0155 },
113 { 0x01e3, 0x0103 },
114 { 0x01e5, 0x013a },
115 { 0x01e6, 0x0107 },
116 { 0x01e8, 0x010d },
117 { 0x01ea, 0x0119 },
118 { 0x01ec, 0x011b },
119 { 0x01ef, 0x010f },
120 { 0x01f0, 0x0111 },
121 { 0x01f1, 0x0144 },
122 { 0x01f2, 0x0148 },
123 { 0x01f5, 0x0151 },
124 { 0x01f8, 0x0159 },
125 { 0x01f9, 0x016f },
126 { 0x01fb, 0x0171 },
127 { 0x01fe, 0x0163 },
128 { 0x01ff, 0x02d9 },
129 { 0x02a1, 0x0126 },
130 { 0x02a6, 0x0124 },
131 { 0x02a9, 0x0130 },
132 { 0x02ab, 0x011e },
133 { 0x02ac, 0x0134 },
134 { 0x02b1, 0x0127 },
135 { 0x02b6, 0x0125 },
136 { 0x02b9, 0x0131 },
137 { 0x02bb, 0x011f },
138 { 0x02bc, 0x0135 },
139 { 0x02c5, 0x010a },
140 { 0x02c6, 0x0108 },
141 { 0x02d5, 0x0120 },
142 { 0x02d8, 0x011c },
143 { 0x02dd, 0x016c },
144 { 0x02de, 0x015c },
145 { 0x02e5, 0x010b },
146 { 0x02e6, 0x0109 },
147 { 0x02f5, 0x0121 },
148 { 0x02f8, 0x011d },
149 { 0x02fd, 0x016d },
150 { 0x02fe, 0x015d },
151 { 0x03a2, 0x0138 },
152 { 0x03a3, 0x0156 },
153 { 0x03a5, 0x0128 },
154 { 0x03a6, 0x013b },
155 { 0x03aa, 0x0112 },
156 { 0x03ab, 0x0122 },
157 { 0x03ac, 0x0166 },
158 { 0x03b3, 0x0157 },
159 { 0x03b5, 0x0129 },
160 { 0x03b6, 0x013c },
161 { 0x03ba, 0x0113 },
162 { 0x03bb, 0x0123 },
163 { 0x03bc, 0x0167 },
164 { 0x03bd, 0x014a },
165 { 0x03bf, 0x014b },
166 { 0x03c0, 0x0100 },
167 { 0x03c7, 0x012e },
168 { 0x03cc, 0x0116 },
169 { 0x03cf, 0x012a },
170 { 0x03d1, 0x0145 },
171 { 0x03d2, 0x014c },
172 { 0x03d3, 0x0136 },
173 { 0x03d9, 0x0172 },
174 { 0x03dd, 0x0168 },
175 { 0x03de, 0x016a },
176 { 0x03e0, 0x0101 },
177 { 0x03e7, 0x012f },
178 { 0x03ec, 0x0117 },
179 { 0x03ef, 0x012b },
180 { 0x03f1, 0x0146 },
181 { 0x03f2, 0x014d },
182 { 0x03f3, 0x0137 },
183 { 0x03f9, 0x0173 },
184 { 0x03fd, 0x0169 },
185 { 0x03fe, 0x016b },
186 { 0x047e, 0x203e },
187 { 0x04a1, 0x3002 },
188 { 0x04a2, 0x300c },
189 { 0x04a3, 0x300d },
190 { 0x04a4, 0x3001 },
191 { 0x04a5, 0x30fb },
192 { 0x04a6, 0x30f2 },
193 { 0x04a7, 0x30a1 },
194 { 0x04a8, 0x30a3 },
195 { 0x04a9, 0x30a5 },
196 { 0x04aa, 0x30a7 },
197 { 0x04ab, 0x30a9 },
198 { 0x04ac, 0x30e3 },
199 { 0x04ad, 0x30e5 },
200 { 0x04ae, 0x30e7 },
201 { 0x04af, 0x30c3 },
202 { 0x04b0, 0x30fc },
203 { 0x04b1, 0x30a2 },
204 { 0x04b2, 0x30a4 },
205 { 0x04b3, 0x30a6 },
206 { 0x04b4, 0x30a8 },
207 { 0x04b5, 0x30aa },
208 { 0x04b6, 0x30ab },
209 { 0x04b7, 0x30ad },
210 { 0x04b8, 0x30af },
211 { 0x04b9, 0x30b1 },
212 { 0x04ba, 0x30b3 },
213 { 0x04bb, 0x30b5 },
214 { 0x04bc, 0x30b7 },
215 { 0x04bd, 0x30b9 },
216 { 0x04be, 0x30bb },
217 { 0x04bf, 0x30bd },
218 { 0x04c0, 0x30bf },
219 { 0x04c1, 0x30c1 },
220 { 0x04c2, 0x30c4 },
221 { 0x04c3, 0x30c6 },
222 { 0x04c4, 0x30c8 },
223 { 0x04c5, 0x30ca },
224 { 0x04c6, 0x30cb },
225 { 0x04c7, 0x30cc },
226 { 0x04c8, 0x30cd },
227 { 0x04c9, 0x30ce },
228 { 0x04ca, 0x30cf },
229 { 0x04cb, 0x30d2 },
230 { 0x04cc, 0x30d5 },
231 { 0x04cd, 0x30d8 },
232 { 0x04ce, 0x30db },
233 { 0x04cf, 0x30de },
234 { 0x04d0, 0x30df },
235 { 0x04d1, 0x30e0 },
236 { 0x04d2, 0x30e1 },
237 { 0x04d3, 0x30e2 },
238 { 0x04d4, 0x30e4 },
239 { 0x04d5, 0x30e6 },
240 { 0x04d6, 0x30e8 },
241 { 0x04d7, 0x30e9 },
242 { 0x04d8, 0x30ea },
243 { 0x04d9, 0x30eb },
244 { 0x04da, 0x30ec },
245 { 0x04db, 0x30ed },
246 { 0x04dc, 0x30ef },
247 { 0x04dd, 0x30f3 },
248 { 0x04de, 0x309b },
249 { 0x04df, 0x309c },
250 { 0x05ac, 0x060c },
251 { 0x05bb, 0x061b },
252 { 0x05bf, 0x061f },
253 { 0x05c1, 0x0621 },
254 { 0x05c2, 0x0622 },
255 { 0x05c3, 0x0623 },
256 { 0x05c4, 0x0624 },
257 { 0x05c5, 0x0625 },
258 { 0x05c6, 0x0626 },
259 { 0x05c7, 0x0627 },
260 { 0x05c8, 0x0628 },
261 { 0x05c9, 0x0629 },
262 { 0x05ca, 0x062a },
263 { 0x05cb, 0x062b },
264 { 0x05cc, 0x062c },
265 { 0x05cd, 0x062d },
266 { 0x05ce, 0x062e },
267 { 0x05cf, 0x062f },
268 { 0x05d0, 0x0630 },
269 { 0x05d1, 0x0631 },
270 { 0x05d2, 0x0632 },
271 { 0x05d3, 0x0633 },
272 { 0x05d4, 0x0634 },
273 { 0x05d5, 0x0635 },
274 { 0x05d6, 0x0636 },
275 { 0x05d7, 0x0637 },
276 { 0x05d8, 0x0638 },
277 { 0x05d9, 0x0639 },
278 { 0x05da, 0x063a },
279 { 0x05e0, 0x0640 },
280 { 0x05e1, 0x0641 },
281 { 0x05e2, 0x0642 },
282 { 0x05e3, 0x0643 },
283 { 0x05e4, 0x0644 },
284 { 0x05e5, 0x0645 },
285 { 0x05e6, 0x0646 },
286 { 0x05e7, 0x0647 },
287 { 0x05e8, 0x0648 },
288 { 0x05e9, 0x0649 },
289 { 0x05ea, 0x064a },
290 { 0x05eb, 0x064b },
291 { 0x05ec, 0x064c },
292 { 0x05ed, 0x064d },
293 { 0x05ee, 0x064e },
294 { 0x05ef, 0x064f },
295 { 0x05f0, 0x0650 },
296 { 0x05f1, 0x0651 },
297 { 0x05f2, 0x0652 },
298 { 0x06a1, 0x0452 },
299 { 0x06a2, 0x0453 },
300 { 0x06a3, 0x0451 },
301 { 0x06a4, 0x0454 },
302 { 0x06a5, 0x0455 },
303 { 0x06a6, 0x0456 },
304 { 0x06a7, 0x0457 },
305 { 0x06a8, 0x0458 },
306 { 0x06a9, 0x0459 },
307 { 0x06aa, 0x045a },
308 { 0x06ab, 0x045b },
309 { 0x06ac, 0x045c },
310 { 0x06ae, 0x045e },
311 { 0x06af, 0x045f },
312 { 0x06b0, 0x2116 },
313 { 0x06b1, 0x0402 },
314 { 0x06b2, 0x0403 },
315 { 0x06b3, 0x0401 },
316 { 0x06b4, 0x0404 },
317 { 0x06b5, 0x0405 },
318 { 0x06b6, 0x0406 },
319 { 0x06b7, 0x0407 },
320 { 0x06b8, 0x0408 },
321 { 0x06b9, 0x0409 },
322 { 0x06ba, 0x040a },
323 { 0x06bb, 0x040b },
324 { 0x06bc, 0x040c },
325 { 0x06be, 0x040e },
326 { 0x06bf, 0x040f },
327 { 0x06c0, 0x044e },
328 { 0x06c1, 0x0430 },
329 { 0x06c2, 0x0431 },
330 { 0x06c3, 0x0446 },
331 { 0x06c4, 0x0434 },
332 { 0x06c5, 0x0435 },
333 { 0x06c6, 0x0444 },
334 { 0x06c7, 0x0433 },
335 { 0x06c8, 0x0445 },
336 { 0x06c9, 0x0438 },
337 { 0x06ca, 0x0439 },
338 { 0x06cb, 0x043a },
339 { 0x06cc, 0x043b },
340 { 0x06cd, 0x043c },
341 { 0x06ce, 0x043d },
342 { 0x06cf, 0x043e },
343 { 0x06d0, 0x043f },
344 { 0x06d1, 0x044f },
345 { 0x06d2, 0x0440 },
346 { 0x06d3, 0x0441 },
347 { 0x06d4, 0x0442 },
348 { 0x06d5, 0x0443 },
349 { 0x06d6, 0x0436 },
350 { 0x06d7, 0x0432 },
351 { 0x06d8, 0x044c },
352 { 0x06d9, 0x044b },
353 { 0x06da, 0x0437 },
354 { 0x06db, 0x0448 },
355 { 0x06dc, 0x044d },
356 { 0x06dd, 0x0449 },
357 { 0x06de, 0x0447 },
358 { 0x06df, 0x044a },
359 { 0x06e0, 0x042e },
360 { 0x06e1, 0x0410 },
361 { 0x06e2, 0x0411 },
362 { 0x06e3, 0x0426 },
363 { 0x06e4, 0x0414 },
364 { 0x06e5, 0x0415 },
365 { 0x06e6, 0x0424 },
366 { 0x06e7, 0x0413 },
367 { 0x06e8, 0x0425 },
368 { 0x06e9, 0x0418 },
369 { 0x06ea, 0x0419 },
370 { 0x06eb, 0x041a },
371 { 0x06ec, 0x041b },
372 { 0x06ed, 0x041c },
373 { 0x06ee, 0x041d },
374 { 0x06ef, 0x041e },
375 { 0x06f0, 0x041f },
376 { 0x06f1, 0x042f },
377 { 0x06f2, 0x0420 },
378 { 0x06f3, 0x0421 },
379 { 0x06f4, 0x0422 },
380 { 0x06f5, 0x0423 },
381 { 0x06f6, 0x0416 },
382 { 0x06f7, 0x0412 },
383 { 0x06f8, 0x042c },
384 { 0x06f9, 0x042b },
385 { 0x06fa, 0x0417 },
386 { 0x06fb, 0x0428 },
387 { 0x06fc, 0x042d },
388 { 0x06fd, 0x0429 },
389 { 0x06fe, 0x0427 },
390 { 0x06ff, 0x042a },
391 { 0x07a1, 0x0386 },
392 { 0x07a2, 0x0388 },
393 { 0x07a3, 0x0389 },
394 { 0x07a4, 0x038a },
395 { 0x07a5, 0x03aa },
396 { 0x07a7, 0x038c },
397 { 0x07a8, 0x038e },
398 { 0x07a9, 0x03ab },
399 { 0x07ab, 0x038f },
400 { 0x07ae, 0x0385 },
401 { 0x07af, 0x2015 },
402 { 0x07b1, 0x03ac },
403 { 0x07b2, 0x03ad },
404 { 0x07b3, 0x03ae },
405 { 0x07b4, 0x03af },
406 { 0x07b5, 0x03ca },
407 { 0x07b6, 0x0390 },
408 { 0x07b7, 0x03cc },
409 { 0x07b8, 0x03cd },
410 { 0x07b9, 0x03cb },
411 { 0x07ba, 0x03b0 },
412 { 0x07bb, 0x03ce },
413 { 0x07c1, 0x0391 },
414 { 0x07c2, 0x0392 },
415 { 0x07c3, 0x0393 },
416 { 0x07c4, 0x0394 },
417 { 0x07c5, 0x0395 },
418 { 0x07c6, 0x0396 },
419 { 0x07c7, 0x0397 },
420 { 0x07c8, 0x0398 },
421 { 0x07c9, 0x0399 },
422 { 0x07ca, 0x039a },
423 { 0x07cb, 0x039b },
424 { 0x07cc, 0x039c },
425 { 0x07cd, 0x039d },
426 { 0x07ce, 0x039e },
427 { 0x07cf, 0x039f },
428 { 0x07d0, 0x03a0 },
429 { 0x07d1, 0x03a1 },
430 { 0x07d2, 0x03a3 },
431 { 0x07d4, 0x03a4 },
432 { 0x07d5, 0x03a5 },
433 { 0x07d6, 0x03a6 },
434 { 0x07d7, 0x03a7 },
435 { 0x07d8, 0x03a8 },
436 { 0x07d9, 0x03a9 },
437 { 0x07e1, 0x03b1 },
438 { 0x07e2, 0x03b2 },
439 { 0x07e3, 0x03b3 },
440 { 0x07e4, 0x03b4 },
441 { 0x07e5, 0x03b5 },
442 { 0x07e6, 0x03b6 },
443 { 0x07e7, 0x03b7 },
444 { 0x07e8, 0x03b8 },
445 { 0x07e9, 0x03b9 },
446 { 0x07ea, 0x03ba },
447 { 0x07eb, 0x03bb },
448 { 0x07ec, 0x03bc },
449 { 0x07ed, 0x03bd },
450 { 0x07ee, 0x03be },
451 { 0x07ef, 0x03bf },
452 { 0x07f0, 0x03c0 },
453 { 0x07f1, 0x03c1 },
454 { 0x07f2, 0x03c3 },
455 { 0x07f3, 0x03c2 },
456 { 0x07f4, 0x03c4 },
457 { 0x07f5, 0x03c5 },
458 { 0x07f6, 0x03c6 },
459 { 0x07f7, 0x03c7 },
460 { 0x07f8, 0x03c8 },
461 { 0x07f9, 0x03c9 },
462 { 0x08a1, 0x23b7 },
463 { 0x08a2, 0x250c },
464 { 0x08a3, 0x2500 },
465 { 0x08a4, 0x2320 },
466 { 0x08a5, 0x2321 },
467 { 0x08a6, 0x2502 },
468 { 0x08a7, 0x23a1 },
469 { 0x08a8, 0x23a3 },
470 { 0x08a9, 0x23a4 },
471 { 0x08aa, 0x23a6 },
472 { 0x08ab, 0x239b },
473 { 0x08ac, 0x239d },
474 { 0x08ad, 0x239e },
475 { 0x08ae, 0x23a0 },
476 { 0x08af, 0x23a8 },
477 { 0x08b0, 0x23ac },
478 { 0x08bc, 0x2264 },
479 { 0x08bd, 0x2260 },
480 { 0x08be, 0x2265 },
481 { 0x08bf, 0x222b },
482 { 0x08c0, 0x2234 },
483 { 0x08c1, 0x221d },
484 { 0x08c2, 0x221e },
485 { 0x08c5, 0x2207 },
486 { 0x08c8, 0x223c },
487 { 0x08c9, 0x2243 },
488 { 0x08cd, 0x21d4 },
489 { 0x08ce, 0x21d2 },
490 { 0x08cf, 0x2261 },
491 { 0x08d6, 0x221a },
492 { 0x08da, 0x2282 },
493 { 0x08db, 0x2283 },
494 { 0x08dc, 0x2229 },
495 { 0x08dd, 0x222a },
496 { 0x08de, 0x2227 },
497 { 0x08df, 0x2228 },
498 { 0x08ef, 0x2202 },
499 { 0x08f6, 0x0192 },
500 { 0x08fb, 0x2190 },
501 { 0x08fc, 0x2191 },
502 { 0x08fd, 0x2192 },
503 { 0x08fe, 0x2193 },
504 { 0x09e0, 0x25c6 },
505 { 0x09e1, 0x2592 },
506 { 0x09e2, 0x2409 },
507 { 0x09e3, 0x240c },
508 { 0x09e4, 0x240d },
509 { 0x09e5, 0x240a },
510 { 0x09e8, 0x2424 },
511 { 0x09e9, 0x240b },
512 { 0x09ea, 0x2518 },
513 { 0x09eb, 0x2510 },
514 { 0x09ec, 0x250c },
515 { 0x09ed, 0x2514 },
516 { 0x09ee, 0x253c },
517 { 0x09ef, 0x23ba },
518 { 0x09f0, 0x23bb },
519 { 0x09f1, 0x2500 },
520 { 0x09f2, 0x23bc },
521 { 0x09f3, 0x23bd },
522 { 0x09f4, 0x251c },
523 { 0x09f5, 0x2524 },
524 { 0x09f6, 0x2534 },
525 { 0x09f7, 0x252c },
526 { 0x09f8, 0x2502 },
527 { 0x0aa1, 0x2003 },
528 { 0x0aa2, 0x2002 },
529 { 0x0aa3, 0x2004 },
530 { 0x0aa4, 0x2005 },
531 { 0x0aa5, 0x2007 },
532 { 0x0aa6, 0x2008 },
533 { 0x0aa7, 0x2009 },
534 { 0x0aa8, 0x200a },
535 { 0x0aa9, 0x2014 },
536 { 0x0aaa, 0x2013 },
537 { 0x0aae, 0x2026 },
538 { 0x0aaf, 0x2025 },
539 { 0x0ab0, 0x2153 },
540 { 0x0ab1, 0x2154 },
541 { 0x0ab2, 0x2155 },
542 { 0x0ab3, 0x2156 },
543 { 0x0ab4, 0x2157 },
544 { 0x0ab5, 0x2158 },
545 { 0x0ab6, 0x2159 },
546 { 0x0ab7, 0x215a },
547 { 0x0ab8, 0x2105 },
548 { 0x0abb, 0x2012 },
549 { 0x0abc, 0x2329 },
550 { 0x0abe, 0x232a },
551 { 0x0ac3, 0x215b },
552 { 0x0ac4, 0x215c },
553 { 0x0ac5, 0x215d },
554 { 0x0ac6, 0x215e },
555 { 0x0ac9, 0x2122 },
556 { 0x0aca, 0x2613 },
557 { 0x0acc, 0x25c1 },
558 { 0x0acd, 0x25b7 },
559 { 0x0ace, 0x25cb },
560 { 0x0acf, 0x25af },
561 { 0x0ad0, 0x2018 },
562 { 0x0ad1, 0x2019 },
563 { 0x0ad2, 0x201c },
564 { 0x0ad3, 0x201d },
565 { 0x0ad4, 0x211e },
566 { 0x0ad6, 0x2032 },
567 { 0x0ad7, 0x2033 },
568 { 0x0ad9, 0x271d },
569 { 0x0adb, 0x25ac },
570 { 0x0adc, 0x25c0 },
571 { 0x0add, 0x25b6 },
572 { 0x0ade, 0x25cf },
573 { 0x0adf, 0x25ae },
574 { 0x0ae0, 0x25e6 },
575 { 0x0ae1, 0x25ab },
576 { 0x0ae2, 0x25ad },
577 { 0x0ae3, 0x25b3 },
578 { 0x0ae4, 0x25bd },
579 { 0x0ae5, 0x2606 },
580 { 0x0ae6, 0x2022 },
581 { 0x0ae7, 0x25aa },
582 { 0x0ae8, 0x25b2 },
583 { 0x0ae9, 0x25bc },
584 { 0x0aea, 0x261c },
585 { 0x0aeb, 0x261e },
586 { 0x0aec, 0x2663 },
587 { 0x0aed, 0x2666 },
588 { 0x0aee, 0x2665 },
589 { 0x0af0, 0x2720 },
590 { 0x0af1, 0x2020 },
591 { 0x0af2, 0x2021 },
592 { 0x0af3, 0x2713 },
593 { 0x0af4, 0x2717 },
594 { 0x0af5, 0x266f },
595 { 0x0af6, 0x266d },
596 { 0x0af7, 0x2642 },
597 { 0x0af8, 0x2640 },
598 { 0x0af9, 0x260e },
599 { 0x0afa, 0x2315 },
600 { 0x0afb, 0x2117 },
601 { 0x0afc, 0x2038 },
602 { 0x0afd, 0x201a },
603 { 0x0afe, 0x201e },
604 { 0x0ba3, 0x003c },
605 { 0x0ba6, 0x003e },
606 { 0x0ba8, 0x2228 },
607 { 0x0ba9, 0x2227 },
608 { 0x0bc0, 0x00af },
609 { 0x0bc2, 0x22a5 },
610 { 0x0bc3, 0x2229 },
611 { 0x0bc4, 0x230a },
612 { 0x0bc6, 0x005f },
613 { 0x0bca, 0x2218 },
614 { 0x0bcc, 0x2395 },
615 { 0x0bce, 0x22a4 },
616 { 0x0bcf, 0x25cb },
617 { 0x0bd3, 0x2308 },
618 { 0x0bd6, 0x222a },
619 { 0x0bd8, 0x2283 },
620 { 0x0bda, 0x2282 },
621 { 0x0bdc, 0x22a2 },
622 { 0x0bfc, 0x22a3 },
623 { 0x0cdf, 0x2017 },
624 { 0x0ce0, 0x05d0 },
625 { 0x0ce1, 0x05d1 },
626 { 0x0ce2, 0x05d2 },
627 { 0x0ce3, 0x05d3 },
628 { 0x0ce4, 0x05d4 },
629 { 0x0ce5, 0x05d5 },
630 { 0x0ce6, 0x05d6 },
631 { 0x0ce7, 0x05d7 },
632 { 0x0ce8, 0x05d8 },
633 { 0x0ce9, 0x05d9 },
634 { 0x0cea, 0x05da },
635 { 0x0ceb, 0x05db },
636 { 0x0cec, 0x05dc },
637 { 0x0ced, 0x05dd },
638 { 0x0cee, 0x05de },
639 { 0x0cef, 0x05df },
640 { 0x0cf0, 0x05e0 },
641 { 0x0cf1, 0x05e1 },
642 { 0x0cf2, 0x05e2 },
643 { 0x0cf3, 0x05e3 },
644 { 0x0cf4, 0x05e4 },
645 { 0x0cf5, 0x05e5 },
646 { 0x0cf6, 0x05e6 },
647 { 0x0cf7, 0x05e7 },
648 { 0x0cf8, 0x05e8 },
649 { 0x0cf9, 0x05e9 },
650 { 0x0cfa, 0x05ea },
651 { 0x0da1, 0x0e01 },
652 { 0x0da2, 0x0e02 },
653 { 0x0da3, 0x0e03 },
654 { 0x0da4, 0x0e04 },
655 { 0x0da5, 0x0e05 },
656 { 0x0da6, 0x0e06 },
657 { 0x0da7, 0x0e07 },
658 { 0x0da8, 0x0e08 },
659 { 0x0da9, 0x0e09 },
660 { 0x0daa, 0x0e0a },
661 { 0x0dab, 0x0e0b },
662 { 0x0dac, 0x0e0c },
663 { 0x0dad, 0x0e0d },
664 { 0x0dae, 0x0e0e },
665 { 0x0daf, 0x0e0f },
666 { 0x0db0, 0x0e10 },
667 { 0x0db1, 0x0e11 },
668 { 0x0db2, 0x0e12 },
669 { 0x0db3, 0x0e13 },
670 { 0x0db4, 0x0e14 },
671 { 0x0db5, 0x0e15 },
672 { 0x0db6, 0x0e16 },
673 { 0x0db7, 0x0e17 },
674 { 0x0db8, 0x0e18 },
675 { 0x0db9, 0x0e19 },
676 { 0x0dba, 0x0e1a },
677 { 0x0dbb, 0x0e1b },
678 { 0x0dbc, 0x0e1c },
679 { 0x0dbd, 0x0e1d },
680 { 0x0dbe, 0x0e1e },
681 { 0x0dbf, 0x0e1f },
682 { 0x0dc0, 0x0e20 },
683 { 0x0dc1, 0x0e21 },
684 { 0x0dc2, 0x0e22 },
685 { 0x0dc3, 0x0e23 },
686 { 0x0dc4, 0x0e24 },
687 { 0x0dc5, 0x0e25 },
688 { 0x0dc6, 0x0e26 },
689 { 0x0dc7, 0x0e27 },
690 { 0x0dc8, 0x0e28 },
691 { 0x0dc9, 0x0e29 },
692 { 0x0dca, 0x0e2a },
693 { 0x0dcb, 0x0e2b },
694 { 0x0dcc, 0x0e2c },
695 { 0x0dcd, 0x0e2d },
696 { 0x0dce, 0x0e2e },
697 { 0x0dcf, 0x0e2f },
698 { 0x0dd0, 0x0e30 },
699 { 0x0dd1, 0x0e31 },
700 { 0x0dd2, 0x0e32 },
701 { 0x0dd3, 0x0e33 },
702 { 0x0dd4, 0x0e34 },
703 { 0x0dd5, 0x0e35 },
704 { 0x0dd6, 0x0e36 },
705 { 0x0dd7, 0x0e37 },
706 { 0x0dd8, 0x0e38 },
707 { 0x0dd9, 0x0e39 },
708 { 0x0dda, 0x0e3a },
709 { 0x0ddf, 0x0e3f },
710 { 0x0de0, 0x0e40 },
711 { 0x0de1, 0x0e41 },
712 { 0x0de2, 0x0e42 },
713 { 0x0de3, 0x0e43 },
714 { 0x0de4, 0x0e44 },
715 { 0x0de5, 0x0e45 },
716 { 0x0de6, 0x0e46 },
717 { 0x0de7, 0x0e47 },
718 { 0x0de8, 0x0e48 },
719 { 0x0de9, 0x0e49 },
720 { 0x0dea, 0x0e4a },
721 { 0x0deb, 0x0e4b },
722 { 0x0dec, 0x0e4c },
723 { 0x0ded, 0x0e4d },
724 { 0x0df0, 0x0e50 },
725 { 0x0df1, 0x0e51 },
726 { 0x0df2, 0x0e52 },
727 { 0x0df3, 0x0e53 },
728 { 0x0df4, 0x0e54 },
729 { 0x0df5, 0x0e55 },
730 { 0x0df6, 0x0e56 },
731 { 0x0df7, 0x0e57 },
732 { 0x0df8, 0x0e58 },
733 { 0x0df9, 0x0e59 },
734 { 0x0ea1, 0x3131 },
735 { 0x0ea2, 0x3132 },
736 { 0x0ea3, 0x3133 },
737 { 0x0ea4, 0x3134 },
738 { 0x0ea5, 0x3135 },
739 { 0x0ea6, 0x3136 },
740 { 0x0ea7, 0x3137 },
741 { 0x0ea8, 0x3138 },
742 { 0x0ea9, 0x3139 },
743 { 0x0eaa, 0x313a },
744 { 0x0eab, 0x313b },
745 { 0x0eac, 0x313c },
746 { 0x0ead, 0x313d },
747 { 0x0eae, 0x313e },
748 { 0x0eaf, 0x313f },
749 { 0x0eb0, 0x3140 },
750 { 0x0eb1, 0x3141 },
751 { 0x0eb2, 0x3142 },
752 { 0x0eb3, 0x3143 },
753 { 0x0eb4, 0x3144 },
754 { 0x0eb5, 0x3145 },
755 { 0x0eb6, 0x3146 },
756 { 0x0eb7, 0x3147 },
757 { 0x0eb8, 0x3148 },
758 { 0x0eb9, 0x3149 },
759 { 0x0eba, 0x314a },
760 { 0x0ebb, 0x314b },
761 { 0x0ebc, 0x314c },
762 { 0x0ebd, 0x314d },
763 { 0x0ebe, 0x314e },
764 { 0x0ebf, 0x314f },
765 { 0x0ec0, 0x3150 },
766 { 0x0ec1, 0x3151 },
767 { 0x0ec2, 0x3152 },
768 { 0x0ec3, 0x3153 },
769 { 0x0ec4, 0x3154 },
770 { 0x0ec5, 0x3155 },
771 { 0x0ec6, 0x3156 },
772 { 0x0ec7, 0x3157 },
773 { 0x0ec8, 0x3158 },
774 { 0x0ec9, 0x3159 },
775 { 0x0eca, 0x315a },
776 { 0x0ecb, 0x315b },
777 { 0x0ecc, 0x315c },
778 { 0x0ecd, 0x315d },
779 { 0x0ece, 0x315e },
780 { 0x0ecf, 0x315f },
781 { 0x0ed0, 0x3160 },
782 { 0x0ed1, 0x3161 },
783 { 0x0ed2, 0x3162 },
784 { 0x0ed3, 0x3163 },
785 { 0x0ed4, 0x11a8 },
786 { 0x0ed5, 0x11a9 },
787 { 0x0ed6, 0x11aa },
788 { 0x0ed7, 0x11ab },
789 { 0x0ed8, 0x11ac },
790 { 0x0ed9, 0x11ad },
791 { 0x0eda, 0x11ae },
792 { 0x0edb, 0x11af },
793 { 0x0edc, 0x11b0 },
794 { 0x0edd, 0x11b1 },
795 { 0x0ede, 0x11b2 },
796 { 0x0edf, 0x11b3 },
797 { 0x0ee0, 0x11b4 },
798 { 0x0ee1, 0x11b5 },
799 { 0x0ee2, 0x11b6 },
800 { 0x0ee3, 0x11b7 },
801 { 0x0ee4, 0x11b8 },
802 { 0x0ee5, 0x11b9 },
803 { 0x0ee6, 0x11ba },
804 { 0x0ee7, 0x11bb },
805 { 0x0ee8, 0x11bc },
806 { 0x0ee9, 0x11bd },
807 { 0x0eea, 0x11be },
808 { 0x0eeb, 0x11bf },
809 { 0x0eec, 0x11c0 },
810 { 0x0eed, 0x11c1 },
811 { 0x0eee, 0x11c2 },
812 { 0x0eef, 0x316d },
813 { 0x0ef0, 0x3171 },
814 { 0x0ef1, 0x3178 },
815 { 0x0ef2, 0x317f },
816 { 0x0ef3, 0x3181 },
817 { 0x0ef4, 0x3184 },
818 { 0x0ef5, 0x3186 },
819 { 0x0ef6, 0x318d },
820 { 0x0ef7, 0x318e },
821 { 0x0ef8, 0x11eb },
822 { 0x0ef9, 0x11f0 },
823 { 0x0efa, 0x11f9 },
824 { 0x0eff, 0x20a9 },
825 { 0x13a4, 0x20ac },
826 { 0x13bc, 0x0152 },
827 { 0x13bd, 0x0153 },
828 { 0x13be, 0x0178 },
829 { 0x20ac, 0x20ac },
830 { 0xfe50, '`' },
831 { 0xfe51, 0x00b4 },
832 { 0xfe52, '^' },
833 { 0xfe53, '~' },
834 { 0xfe54, 0x00af },
835 { 0xfe55, 0x02d8 },
836 { 0xfe56, 0x02d9 },
837 { 0xfe57, 0x00a8 },
838 { 0xfe58, 0x02da },
839 { 0xfe59, 0x02dd },
840 { 0xfe5a, 0x02c7 },
841 { 0xfe5b, 0x00b8 },
842 { 0xfe5c, 0x02db },
843 { 0xfe5d, 0x037a },
844 { 0xfe5e, 0x309b },
845 { 0xfe5f, 0x309c },
846 { 0xfe63, '/' },
847 { 0xfe64, 0x02bc },
848 { 0xfe65, 0x02bd },
849 { 0xfe66, 0x02f5 },
850 { 0xfe67, 0x02f3 },
851 { 0xfe68, 0x02cd },
852 { 0xfe69, 0xa788 },
853 { 0xfe6a, 0x02f7 },
854 { 0xfe6e, ',' },
855 { 0xfe6f, 0x00a4 },
856 { 0xfe80, 'a' }, // XK_dead_a
857 { 0xfe81, 'A' }, // XK_dead_A
858 { 0xfe82, 'e' }, // XK_dead_e
859 { 0xfe83, 'E' }, // XK_dead_E
860 { 0xfe84, 'i' }, // XK_dead_i
861 { 0xfe85, 'I' }, // XK_dead_I
862 { 0xfe86, 'o' }, // XK_dead_o
863 { 0xfe87, 'O' }, // XK_dead_O
864 { 0xfe88, 'u' }, // XK_dead_u
865 { 0xfe89, 'U' }, // XK_dead_U
866 { 0xfe8a, 0x0259 },
867 { 0xfe8b, 0x018f },
868 { 0xfe8c, 0x00b5 },
869 { 0xfe90, '_' },
870 { 0xfe91, 0x02c8 },
871 { 0xfe92, 0x02cc },
872 { 0xff80 /*XKB_KEY_KP_Space*/, ' ' },
873 { 0xff95 /*XKB_KEY_KP_7*/, 0x0037 },
874 { 0xff96 /*XKB_KEY_KP_4*/, 0x0034 },
875 { 0xff97 /*XKB_KEY_KP_8*/, 0x0038 },
876 { 0xff98 /*XKB_KEY_KP_6*/, 0x0036 },
877 { 0xff99 /*XKB_KEY_KP_2*/, 0x0032 },
878 { 0xff9a /*XKB_KEY_KP_9*/, 0x0039 },
879 { 0xff9b /*XKB_KEY_KP_3*/, 0x0033 },
880 { 0xff9c /*XKB_KEY_KP_1*/, 0x0031 },
881 { 0xff9d /*XKB_KEY_KP_5*/, 0x0035 },
882 { 0xff9e /*XKB_KEY_KP_0*/, 0x0030 },
883 { 0xffaa /*XKB_KEY_KP_Multiply*/, '*' },
884 { 0xffab /*XKB_KEY_KP_Add*/, '+' },
885 { 0xffac /*XKB_KEY_KP_Separator*/, ',' },
886 { 0xffad /*XKB_KEY_KP_Subtract*/, '-' },
887 { 0xffae /*XKB_KEY_KP_Decimal*/, '.' },
888 { 0xffaf /*XKB_KEY_KP_Divide*/, '/' },
889 { 0xffb0 /*XKB_KEY_KP_0*/, 0x0030 },
890 { 0xffb1 /*XKB_KEY_KP_1*/, 0x0031 },
891 { 0xffb2 /*XKB_KEY_KP_2*/, 0x0032 },
892 { 0xffb3 /*XKB_KEY_KP_3*/, 0x0033 },
893 { 0xffb4 /*XKB_KEY_KP_4*/, 0x0034 },
894 { 0xffb5 /*XKB_KEY_KP_5*/, 0x0035 },
895 { 0xffb6 /*XKB_KEY_KP_6*/, 0x0036 },
896 { 0xffb7 /*XKB_KEY_KP_7*/, 0x0037 },
897 { 0xffb8 /*XKB_KEY_KP_8*/, 0x0038 },
898 { 0xffb9 /*XKB_KEY_KP_9*/, 0x0039 },
899 { 0xffbd /*XKB_KEY_KP_Equal*/, '=' }
900};
901
902
903//////////////////////////////////////////////////////////////////////////
904////// GLFW internal API //////
905//////////////////////////////////////////////////////////////////////////
906
907// Convert XKB KeySym to Unicode
908//
909uint32_t _glfwKeySym2Unicode(unsigned int keysym)
910{
911 int min = 0;
912 int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
913 int mid;
914
915 // First check for Latin-1 characters (1:1 mapping)
916 if ((keysym >= 0x0020 && keysym <= 0x007e) ||
917 (keysym >= 0x00a0 && keysym <= 0x00ff))
918 {
919 return keysym;
920 }
921
922 // Also check for directly encoded 24-bit UCS characters
923 if ((keysym & 0xff000000) == 0x01000000)
924 return keysym & 0x00ffffff;
925
926 // Binary search in table
927 while (max >= min)
928 {
929 mid = (min + max) / 2;
930 if (keysymtab[mid].keysym < keysym)
931 min = mid + 1;
932 else if (keysymtab[mid].keysym > keysym)
933 max = mid - 1;
934 else
935 return keysymtab[mid].ucs;
936 }
937
938 // No matching Unicode value found
939 return GLFW_INVALID_CODEPOINT;
940}
941
942#endif // _GLFW_WAYLAND or _GLFW_X11
943
diff --git a/raylib/src/external/glfw/src/xkb_unicode.h b/raylib/src/external/glfw/src/xkb_unicode.h
new file mode 100644
index 0000000..b07408f
--- /dev/null
+++ b/raylib/src/external/glfw/src/xkb_unicode.h
@@ -0,0 +1,30 @@
1//========================================================================
2// GLFW 3.4 Linux - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#define GLFW_INVALID_CODEPOINT 0xffffffffu
28
29uint32_t _glfwKeySym2Unicode(unsigned int keysym);
30
diff --git a/raylib/src/external/jar_mod.h b/raylib/src/external/jar_mod.h
new file mode 100644
index 0000000..eacd3b7
--- /dev/null
+++ b/raylib/src/external/jar_mod.h
@@ -0,0 +1,1596 @@
1// jar_mod.h - v0.01 - public domain C0 - Joshua Reisenauer
2//
3// HISTORY:
4//
5// v0.01 2016-03-12 Setup
6//
7//
8// USAGE:
9//
10// In ONE source file, put:
11//
12// #define JAR_MOD_IMPLEMENTATION
13// #include "jar_mod.h"
14//
15// Other source files should just include jar_mod.h
16//
17// SAMPLE CODE:
18// jar_mod_context_t modctx;
19// short samplebuff[4096];
20// bool bufferFull = false;
21// int intro_load(void)
22// {
23// jar_mod_init(&modctx);
24// jar_mod_load_file(&modctx, "file.mod");
25// return 1;
26// }
27// int intro_unload(void)
28// {
29// jar_mod_unload(&modctx);
30// return 1;
31// }
32// int intro_tick(long counter)
33// {
34// if(!bufferFull)
35// {
36// jar_mod_fillbuffer(&modctx, samplebuff, 4096, 0);
37// bufferFull=true;
38// }
39// if(IsKeyDown(KEY_ENTER))
40// return 1;
41// return 0;
42// }
43//
44//
45// LISCENSE:
46//
47// Written by: Jean-François DEL NERO (http://hxc2001.com/) <Email : jeanfrancoisdelnero <> free.fr>
48// Adapted to jar_mod by: Joshua Adam Reisenauer <kd7tck@gmail.com>
49// This program is free software. It comes without any warranty, to the
50// extent permitted by applicable law. You can redistribute it and/or
51// modify it under the terms of the Do What The Fuck You Want To Public
52// License, Version 2, as published by Sam Hocevar. See
53// http://sam.zoy.org/wtfpl/COPYING for more details.
54///////////////////////////////////////////////////////////////////////////////////
55// HxCMOD Core API:
56// -------------------------------------------
57// int jar_mod_init(jar_mod_context_t * modctx)
58//
59// - Initialize the jar_mod_context_t buffer. Must be called before doing anything else.
60// Return 1 if success. 0 in case of error.
61// -------------------------------------------
62// mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename)
63//
64// - "Load" a MOD from file, context must already be initialized.
65// Return size of file in bytes.
66// -------------------------------------------
67// void jar_mod_fillbuffer( jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf )
68//
69// - Generate and return the next samples chunk to outbuffer.
70// nbsample specify the number of stereo 16bits samples you want.
71// The output format is by default signed 48000Hz 16-bit Stereo PCM samples, otherwise it is changed with jar_mod_setcfg().
72// The output buffer size in bytes must be equal to ( nbsample * 2 * channels ).
73// The optional trkbuf parameter can be used to get detailed status of the player. Put NULL/0 is unused.
74// -------------------------------------------
75// void jar_mod_unload( jar_mod_context_t * modctx )
76// - "Unload" / clear the player status.
77// -------------------------------------------
78///////////////////////////////////////////////////////////////////////////////////
79
80
81#ifndef INCLUDE_JAR_MOD_H
82#define INCLUDE_JAR_MOD_H
83
84// Allow custom memory allocators
85#ifndef JARMOD_MALLOC
86 #define JARMOD_MALLOC(sz) malloc(sz)
87#endif
88#ifndef JARMOD_FREE
89 #define JARMOD_FREE(p) free(p)
90#endif
91
92
93// Basic type
94typedef unsigned char muchar;
95typedef unsigned short muint;
96typedef short mint;
97typedef unsigned long mulong;
98
99#define NUMMAXCHANNELS 32
100#define MAXNOTES 12*12
101#define DEFAULT_SAMPLE_RATE 48000
102//
103// MOD file structures
104//
105
106#pragma pack(1)
107
108typedef struct {
109 muchar name[22];
110 muint length;
111 muchar finetune;
112 muchar volume;
113 muint reppnt;
114 muint replen;
115} sample;
116
117typedef struct {
118 muchar sampperiod;
119 muchar period;
120 muchar sampeffect;
121 muchar effect;
122} note;
123
124typedef struct {
125 muchar title[20];
126 sample samples[31];
127 muchar length; // length of tablepos
128 muchar protracker;
129 muchar patterntable[128];
130 muchar signature[4];
131 muchar speed;
132} module;
133
134#pragma pack()
135
136//
137// HxCMod Internal structures
138//
139typedef struct {
140 char* sampdata;
141 muint sampnum;
142 muint length;
143 muint reppnt;
144 muint replen;
145 mulong samppos;
146 muint period;
147 muchar volume;
148 mulong ticks;
149 muchar effect;
150 muchar parameffect;
151 muint effect_code;
152 mint decalperiod;
153 mint portaspeed;
154 mint portaperiod;
155 mint vibraperiod;
156 mint Arpperiods[3];
157 muchar ArpIndex;
158 mint oldk;
159 muchar volumeslide;
160 muchar vibraparam;
161 muchar vibrapointeur;
162 muchar finetune;
163 muchar cut_param;
164 muint patternloopcnt;
165 muint patternloopstartpoint;
166} channel;
167
168typedef struct {
169 module song;
170 char* sampledata[31];
171 note* patterndata[128];
172
173 mulong playrate;
174 muint tablepos;
175 muint patternpos;
176 muint patterndelay;
177 muint jump_loop_effect;
178 muchar bpm;
179 mulong patternticks;
180 mulong patterntickse;
181 mulong patternticksaim;
182 mulong sampleticksconst;
183 mulong samplenb;
184 channel channels[NUMMAXCHANNELS];
185 muint number_of_channels;
186 muint fullperiod[MAXNOTES * 8];
187 muint mod_loaded;
188 mint last_r_sample;
189 mint last_l_sample;
190 mint stereo;
191 mint stereo_separation;
192 mint bits;
193 mint filter;
194
195 muchar *modfile; // the raw mod file
196 mulong modfilesize;
197 muint loopcount;
198} jar_mod_context_t;
199
200//
201// Player states structures
202//
203typedef struct track_state_
204{
205 unsigned char instrument_number;
206 unsigned short cur_period;
207 unsigned char cur_volume;
208 unsigned short cur_effect;
209 unsigned short cur_parameffect;
210}track_state;
211
212typedef struct tracker_state_
213{
214 int number_of_tracks;
215 int bpm;
216 int speed;
217 int cur_pattern;
218 int cur_pattern_pos;
219 int cur_pattern_table_pos;
220 unsigned int buf_index;
221 track_state tracks[32];
222}tracker_state;
223
224typedef struct tracker_state_instrument_
225{
226 char name[22];
227 int active;
228}tracker_state_instrument;
229
230typedef struct jar_mod_tracker_buffer_state_
231{
232 int nb_max_of_state;
233 int nb_of_state;
234 int cur_rd_index;
235 int sample_step;
236 char name[64];
237 tracker_state_instrument instruments[31];
238 tracker_state * track_state_buf;
239}jar_mod_tracker_buffer_state;
240
241#ifdef __cplusplus
242extern "C" {
243#endif
244
245bool jar_mod_init(jar_mod_context_t * modctx);
246bool jar_mod_setcfg(jar_mod_context_t * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter);
247void jar_mod_fillbuffer(jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf);
248void jar_mod_unload(jar_mod_context_t * modctx);
249mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename);
250mulong jar_mod_current_samples(jar_mod_context_t * modctx);
251mulong jar_mod_max_samples(jar_mod_context_t * modctx);
252void jar_mod_seek_start(jar_mod_context_t * ctx);
253
254#ifdef __cplusplus
255}
256#endif
257//--------------------------------------------------------------------
258
259
260
261//-------------------------------------------------------------------------------
262#ifdef JAR_MOD_IMPLEMENTATION
263
264#include <stdio.h>
265#include <stdlib.h>
266//#include <stdbool.h>
267
268// Effects list
269#define EFFECT_ARPEGGIO 0x0 // Supported
270#define EFFECT_PORTAMENTO_UP 0x1 // Supported
271#define EFFECT_PORTAMENTO_DOWN 0x2 // Supported
272#define EFFECT_TONE_PORTAMENTO 0x3 // Supported
273#define EFFECT_VIBRATO 0x4 // Supported
274#define EFFECT_VOLSLIDE_TONEPORTA 0x5 // Supported
275#define EFFECT_VOLSLIDE_VIBRATO 0x6 // Supported
276#define EFFECT_VOLSLIDE_TREMOLO 0x7 // - TO BE DONE -
277#define EFFECT_SET_PANNING 0x8 // - TO BE DONE -
278#define EFFECT_SET_OFFSET 0x9 // Supported
279#define EFFECT_VOLUME_SLIDE 0xA // Supported
280#define EFFECT_JUMP_POSITION 0xB // Supported
281#define EFFECT_SET_VOLUME 0xC // Supported
282#define EFFECT_PATTERN_BREAK 0xD // Supported
283
284#define EFFECT_EXTENDED 0xE
285#define EFFECT_E_FINE_PORTA_UP 0x1 // Supported
286#define EFFECT_E_FINE_PORTA_DOWN 0x2 // Supported
287#define EFFECT_E_GLISSANDO_CTRL 0x3 // - TO BE DONE -
288#define EFFECT_E_VIBRATO_WAVEFORM 0x4 // - TO BE DONE -
289#define EFFECT_E_SET_FINETUNE 0x5 // - TO BE DONE -
290#define EFFECT_E_PATTERN_LOOP 0x6 // Supported
291#define EFFECT_E_TREMOLO_WAVEFORM 0x7 // - TO BE DONE -
292#define EFFECT_E_SET_PANNING_2 0x8 // - TO BE DONE -
293#define EFFECT_E_RETRIGGER_NOTE 0x9 // - TO BE DONE -
294#define EFFECT_E_FINE_VOLSLIDE_UP 0xA // Supported
295#define EFFECT_E_FINE_VOLSLIDE_DOWN 0xB // Supported
296#define EFFECT_E_NOTE_CUT 0xC // Supported
297#define EFFECT_E_NOTE_DELAY 0xD // - TO BE DONE -
298#define EFFECT_E_PATTERN_DELAY 0xE // Supported
299#define EFFECT_E_INVERT_LOOP 0xF // - TO BE DONE -
300#define EFFECT_SET_SPEED 0xF0 // Supported
301#define EFFECT_SET_TEMPO 0xF2 // Supported
302
303#define PERIOD_TABLE_LENGTH MAXNOTES
304#define FULL_PERIOD_TABLE_LENGTH ( PERIOD_TABLE_LENGTH * 8 )
305
306static const short periodtable[]=
307{
308 27392, 25856, 24384, 23040, 21696, 20480, 19328, 18240, 17216, 16256, 15360, 14496,
309 13696, 12928, 12192, 11520, 10848, 10240, 9664, 9120, 8606, 8128, 7680, 7248,
310 6848, 6464, 6096, 5760, 5424, 5120, 4832, 4560, 4304, 4064, 3840, 3624,
311 3424, 3232, 3048, 2880, 2712, 2560, 2416, 2280, 2152, 2032, 1920, 1812,
312 1712, 1616, 1524, 1440, 1356, 1280, 1208, 1140, 1076, 1016, 960, 906,
313 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453,
314 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226,
315 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113,
316 107, 101, 95, 90, 85, 80, 75, 71, 67, 63, 60, 56,
317 53, 50, 47, 45, 42, 40, 37, 35, 33, 31, 30, 28,
318 27, 25, 24, 22, 21, 20, 19, 18, 17, 16, 15, 14,
319 13, 13, 12, 11, 11, 10, 9, 9, 8, 8, 7, 7
320};
321
322static const short sintable[]={
323 0, 24, 49, 74, 97, 120, 141,161,
324 180, 197, 212, 224, 235, 244, 250,253,
325 255, 253, 250, 244, 235, 224, 212,197,
326 180, 161, 141, 120, 97, 74, 49, 24
327};
328
329typedef struct modtype_
330{
331 unsigned char signature[5];
332 int numberofchannels;
333}modtype;
334
335modtype modlist[]=
336{
337 { "M!K!",4},
338 { "M.K.",4},
339 { "FLT4",4},
340 { "FLT8",8},
341 { "4CHN",4},
342 { "6CHN",6},
343 { "8CHN",8},
344 { "10CH",10},
345 { "12CH",12},
346 { "14CH",14},
347 { "16CH",16},
348 { "18CH",18},
349 { "20CH",20},
350 { "22CH",22},
351 { "24CH",24},
352 { "26CH",26},
353 { "28CH",28},
354 { "30CH",30},
355 { "32CH",32},
356 { "",0}
357};
358
359