-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglfw.go
4266 lines (3894 loc) · 151 KB
/
glfw.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2018 Beta Kuang
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
// Package glfw is a hand-crafted Go binding for GLFW, an open-source and
// multi-platform library for OpenGL.
package glfw
/*
// Windows build tags.
#cgo windows CFLAGS: -D_GLFW_WIN32 -Iglfw/deps/mingw
#cgo windows LDFLAGS: -lopengl32 -lgdi32
// Darwin build tags.
#cgo darwin CFLAGS: -D_GLFW_COCOA -D_GLFW_USE_CHDIR -D_GLFW_USE_MENUBAR -D_GLFW_USE_RETINA -Wno-deprecated-declarations
#cgo darwin LDFLAGS: -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
// Linux build tags.
#cgo linux,!wayland CFLAGS: -D_GLFW_X11
#cgo linux,wayland CFLAGS: -D_GLFW_WAYLAND -D_GNU_SOURCE
#cgo linux,!wayland LDFLAGS: -lGL -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -lm -lXinerama -ldl -lrt
#cgo linux,wayland LDFLAGS: -lGL -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon -lm -ldl -lrt
#include <stdlib.h>
#include <string.h>
#include "glfw/include/GLFW/glfw3.h"
// Error callback.
void _errorCallback(int, char*);
// Workaround due to that Go does not support const function params.
static void _errorCallbackConst(int err, const char* desc) {
char* desc_ = strdup(desc);
_errorCallback(err, desc_);
free(desc_);
}
static void goSetErrorCallback() {
glfwSetErrorCallback(_errorCallbackConst);
}
static void goRemoveErrorCallback() {
glfwSetErrorCallback(NULL);
}
// Monitor callback.
void _monitorCallback(GLFWmonitor*, int);
static void goSetMonitorCallback() {
glfwSetMonitorCallback(_monitorCallback);
}
static void goRemoveMonitorCallback() {
glfwSetMonitorCallback(NULL);
}
// Window position callback.
void _windowPosCallback(GLFWwindow*, int, int);
static void goSetWindowPosCallback(GLFWwindow* window) {
glfwSetWindowPosCallback(window, _windowPosCallback);
}
static void goRemoveWindowPosCallback(GLFWwindow* window) {
glfwSetWindowPosCallback(window, NULL);
}
// Window size callback.
void _windowSizeCallback(GLFWwindow*, int, int);
static void goSetWindowSizeCallback(GLFWwindow* window) {
glfwSetWindowSizeCallback(window, _windowSizeCallback);
}
static void goRemoveWindowSizeCallback(GLFWwindow* window) {
glfwSetWindowSizeCallback(window, NULL);
}
// Window close callback.
void _windowCloseCallback(GLFWwindow*);
static void goSetWindowCloseCallback(GLFWwindow* window) {
glfwSetWindowCloseCallback(window, _windowCloseCallback);
}
static void goRemoveWindowCloseCallback(GLFWwindow* window) {
glfwSetWindowCloseCallback(window, NULL);
}
// Window refresh callback.
void _windowRefreshCallback(GLFWwindow*);
static void goSetWindowRefreshCallback(GLFWwindow* window) {
glfwSetWindowRefreshCallback(window, _windowRefreshCallback);
}
static void goRemoveWindowRefreshCallback(GLFWwindow* window) {
glfwSetWindowRefreshCallback(window, NULL);
}
// Window focus callback.
void _windowFocusCallback(GLFWwindow*, int);
static void goSetWindowFocusCallback(GLFWwindow* window) {
glfwSetWindowFocusCallback(window, _windowFocusCallback);
}
static void goRemoveWindowFocusCallback(GLFWwindow* window) {
glfwSetWindowFocusCallback(window, NULL);
}
// Window iconify callback.
void _windowIconifyCallback(GLFWwindow*, int);
static void goSetWindowIconifyCallback(GLFWwindow* window) {
glfwSetWindowIconifyCallback(window, _windowIconifyCallback);
}
static void goRemoveWindowIconifyCallback(GLFWwindow* window) {
glfwSetWindowIconifyCallback(window, NULL);
}
// Window maximize callback.
void _windowMaximizeCallback(GLFWwindow*, int);
static void goSetWindowMaximizeCallback(GLFWwindow* window) {
glfwSetWindowMaximizeCallback(window, _windowMaximizeCallback);
}
static void goRemoveWindowMaximizeCallback(GLFWwindow* window) {
glfwSetWindowMaximizeCallback(window, NULL);
}
// Framebuffer size callback.
void _framebufferSizeCallback(GLFWwindow*, int, int);
static void goSetFramebufferSizeCallback(GLFWwindow* window) {
glfwSetFramebufferSizeCallback(window, _framebufferSizeCallback);
}
static void goRemoveFramebufferSizeCallback(GLFWwindow* window) {
glfwSetFramebufferSizeCallback(window, NULL);
}
// Window content scale callback.
void _windowContentScaleCallback(GLFWwindow*, float, float);
static void goSetWindowContentScaleCallback(GLFWwindow* window) {
glfwSetWindowContentScaleCallback(window, _windowContentScaleCallback);
}
static void goRemoveWindowContentScaleCallback(GLFWwindow* window) {
glfwSetWindowContentScaleCallback(window, NULL);
}
// Key callback.
void _keyCallback(GLFWwindow*, int, int, int, int);
static void goSetKeyCallback(GLFWwindow* window) {
glfwSetKeyCallback(window, _keyCallback);
}
static void goRemoveKeyCallback(GLFWwindow* window) {
glfwSetKeyCallback(window, NULL);
}
// Char callback.
void _charCallback(GLFWwindow*, unsigned int);
static void goSetCharCallback(GLFWwindow* window) {
glfwSetCharCallback(window, _charCallback);
}
static void goRemoveCharCallback(GLFWwindow* window) {
glfwSetCharCallback(window, NULL);
}
// Char mods callback.
void _charModsCallback(GLFWwindow*, unsigned int, int);
static void goSetCharModsCallback(GLFWwindow* window) {
glfwSetCharModsCallback(window, _charModsCallback);
}
static void goRemoveCharModsCallback(GLFWwindow* window) {
glfwSetCharModsCallback(window, NULL);
}
// Mouse button callback.
void _mouseButtonCallback(GLFWwindow*, int, int, int);
static void goSetMouseButtonCallback(GLFWwindow* window) {
glfwSetMouseButtonCallback(window, _mouseButtonCallback);
}
static void goRemoveMouseButtonCallback(GLFWwindow* window) {
glfwSetMouseButtonCallback(window, NULL);
}
// Cursor position callback.
void _cursorPosCallback(GLFWwindow*, double, double);
static void goSetCursorPosCallback(GLFWwindow* window) {
glfwSetCursorPosCallback(window, _cursorPosCallback);
}
static void goRemoveCursorPosCallback(GLFWwindow* window) {
glfwSetCursorPosCallback(window, NULL);
}
// Cursor enter callback.
void _cursorEnterCallback(GLFWwindow*, int);
static void goSetCursorEnterCallback(GLFWwindow* window) {
glfwSetCursorEnterCallback(window, _cursorEnterCallback);
}
static void goRemoveCursorEnterCallback(GLFWwindow* window) {
glfwSetCursorEnterCallback(window, NULL);
}
// Scroll callback.
void _scrollCallback(GLFWwindow*, double, double);
static void goSetScrollCallback(GLFWwindow* window) {
glfwSetScrollCallback(window, _scrollCallback);
}
static void goRemoveScrollCallback(GLFWwindow* window) {
glfwSetScrollCallback(window, NULL);
}
// Drop callback.
void _dropCallback(GLFWwindow*, int, char**);
// Workaround due to that Go does not support const function params.
static void _dropCallbackConst(GLFWwindow* window, int count, const char** paths) {
char** paths_ = malloc(count * sizeof(char*));
for (int i = 0; i < count; i++) {
paths_[i] = strdup(paths[i]);
}
_dropCallback(window, count, paths_);
free(paths_);
}
static void goSetDropCallback(GLFWwindow* window) {
glfwSetDropCallback(window, _dropCallbackConst);
}
static void goRemoveDropCallback(GLFWwindow* window) {
glfwSetDropCallback(window, NULL);
}
// Joystick callback.
void _joystickCallback(int, int);
static void goSetJoystickCallback() {
glfwSetJoystickCallback(_joystickCallback);
}
static void goRemoveJoystickCallback() {
glfwSetJoystickCallback(NULL);
}
*/
import "C"
import "unsafe"
// GLFW version constants.
const (
// VersionMajor : The major version number of the GLFW library.
//
// This is incremented when the API is changed in non-compatible ways.
VersionMajor uint = 3
// VersionMinor : The minor version number of the GLFW library.
//
// This is incremented when features are added to the API but it remains
// backward-compatible.
VersionMinor uint = 3
// VersionRevision : The revision number of the GLFW library.
//
// This is incremented when a bug fix release is made that does not contain
// any API changes.
VersionRevision uint = 0
)
// Action is a key and button action.
type Action int
const (
// Release : The key or mouse button was released.
Release Action = 0
// Press : The key or mouse button was pressed.
Press Action = 1
// Repeat : The key was held down until it repeated.
Repeat Action = 2
)
// HatState is a joystick hat state.
type HatState int
// Joystick hat states.
const (
HatCentered HatState = 0
HatUp HatState = 1
HatRight HatState = 2
HatDown HatState = 4
HatLeft HatState = 8
HatRightUp HatState = HatRight | HatUp
HatRightDown HatState = HatRight | HatDown
HatLeftUp HatState = HatLeft | HatUp
HatLeftDown HatState = HatLeft | HatDown
)
// Key is a keyboard key.
//
// These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
// but re-arranged to map to 7-bit ASCII for printable keys (function keys are
// put in the 256+ range).
//
// The naming of the key codes follow these rules:
//
// - The US keyboard layout is used
//
// - Names of printable alpha-numeric characters are used (e.g. "A", "R", "3",
// etc.)
//
// - For non-alphanumeric characters, Unicode:ish names are used (e.g. "Comma",
// "LeftSquareBracket", etc.). Note that some names do not correspond to the
// Unicode standard (usually for brevity)
//
// - Keys that lack a clear US mapping are named "Worldx"
//
// - For non-printable keys, custom names are used (e.g. "F4", "Backspace",
// etc.)
type Key int
// Keyboard keys.
const (
// KeyUnknown : The unknown key.
KeyUnknown Key = -1
// Printable keys.
KeySpace Key = 32
// KeyApostrophe : "'".
KeyApostrophe Key = 39
// KeyComma : ",".
KeyComma Key = 44
// KeyMinus : "-".
KeyMinus Key = 45
// KeyPeriod : ".".
KeyPeriod Key = 46
// KeySlash : "/".
KeySlash Key = 47
Key0 Key = 48
Key1 Key = 49
Key2 Key = 50
Key3 Key = 51
Key4 Key = 52
Key5 Key = 53
Key6 Key = 54
Key7 Key = 55
Key8 Key = 56
Key9 Key = 57
// KeySemicolon : ";".
KeySemicolon Key = 59
// KeyEqual : "=".
KeyEqual Key = 61
KeyA Key = 65
KeyB Key = 66
KeyC Key = 67
KeyD Key = 68
KeyE Key = 69
KeyF Key = 70
KeyG Key = 71
KeyH Key = 72
KeyI Key = 73
KeyJ Key = 74
KeyK Key = 75
KeyL Key = 76
KeyM Key = 77
KeyN Key = 78
KeyO Key = 79
KeyP Key = 80
KeyQ Key = 81
KeyR Key = 82
KeyS Key = 83
KeyT Key = 84
KeyU Key = 85
KeyV Key = 86
KeyW Key = 87
KeyX Key = 88
KeyY Key = 89
KeyZ Key = 90
// KeyLeftBracket : "[".
KeyLeftBracket Key = 91
// KeyBackslash : "\".
KeyBackslash Key = 92
// KeyRightBracket : "]".
KeyRightBracket Key = 93
// KeyGraveAccent : "`".
KeyGraveAccent Key = 96
// KeyWorld1 : non-US #1.
KeyWorld1 Key = 161
// KeyWorld2 : non-US #2.
KeyWorld2 Key = 162
// Function keys.
KeyEscape Key = 256
KeyEnter Key = 257
KeyTab Key = 258
KeyBackspace Key = 259
KeyInsert Key = 260
KeyDelete Key = 261
KeyRight Key = 262
KeyLeft Key = 263
KeyDown Key = 264
KeyUp Key = 265
KeyPageUp Key = 266
KeyPageDown Key = 267
KeyHome Key = 268
KeyEnd Key = 269
KeyCapsLock Key = 280
KeyScrollLock Key = 281
KeyNumLock Key = 282
KeyPrintScreen Key = 283
KeyPause Key = 284
KeyF1 Key = 290
KeyF2 Key = 291
KeyF3 Key = 292
KeyF4 Key = 293
KeyF5 Key = 294
KeyF6 Key = 295
KeyF7 Key = 296
KeyF8 Key = 297
KeyF9 Key = 298
KeyF10 Key = 299
KeyF11 Key = 300
KeyF12 Key = 301
KeyF13 Key = 302
KeyF14 Key = 303
KeyF15 Key = 304
KeyF16 Key = 305
KeyF17 Key = 306
KeyF18 Key = 307
KeyF19 Key = 308
KeyF20 Key = 309
KeyF21 Key = 310
KeyF22 Key = 311
KeyF23 Key = 312
KeyF24 Key = 313
KeyF25 Key = 314
KeyKp0 Key = 320
KeyKp1 Key = 321
KeyKp2 Key = 322
KeyKp3 Key = 323
KeyKp4 Key = 324
KeyKp5 Key = 325
KeyKp6 Key = 326
KeyKp7 Key = 327
KeyKp8 Key = 328
KeyKp9 Key = 329
KeyKpDecimal Key = 330
KeyKpDivide Key = 331
KeyKpMultiply Key = 332
KeyKpSubtract Key = 333
KeyKpAdd Key = 334
KeyKpEnter Key = 335
KeyKpEqual Key = 336
KeyLeftShift Key = 340
KeyLeftControl Key = 341
KeyLeftAlt Key = 342
KeyLeftSuper Key = 343
KeyRightShift Key = 344
KeyRightControl Key = 345
KeyRightAlt Key = 346
KeyRightSuper Key = 347
KeyMenu Key = 348
KeyLast Key = KeyMenu
)
// ModifierFlag is a modifier key flag.
type ModifierFlag int
const (
// ModShift : If this bit is set one or more Shift keys were held down.
ModShift ModifierFlag = 0x0001
// ModControl : If this bit is set one or more Control keys were held down.
ModControl ModifierFlag = 0x0002
// ModAlt : If this bit is set one or more Alt keys were held down.
ModAlt ModifierFlag = 0x0004
// ModSuper : If this bit is set one or more Super keys were held down.
ModSuper ModifierFlag = 0x0008
// ModCapsLock : If this bit is set the Caps Lock key is enabled and the
// LockKeyModsMode input mode is set.
ModCapsLock ModifierFlag = 0x0010
// ModNumLock : If this bit is set the Num Lock key is enabled and the
// LockKeyModsMode input mode is set.
ModNumLock ModifierFlag = 0x0020
)
// Button is a mouse button.
type Button int
// Mouse buttons.
const (
MouseButton1 Button = 0
MouseButton2 Button = 1
MouseButton3 Button = 2
MouseButton4 Button = 3
MouseButton5 Button = 4
MouseButton6 Button = 5
MouseButton7 Button = 6
MouseButton8 Button = 7
MouseButtonLast Button = MouseButton8
MouseButtonLeft Button = MouseButton1
MouseButtonRight Button = MouseButton2
MouseButtonMiddle Button = MouseButton3
)
// Joystick is a joystick.
type Joystick int
// Joysticks.
const (
Joystick1 Joystick = 0
Joystick2 Joystick = 1
Joystick3 Joystick = 2
Joystick4 Joystick = 3
Joystick5 Joystick = 4
Joystick6 Joystick = 5
Joystick7 Joystick = 6
Joystick8 Joystick = 7
Joystick9 Joystick = 8
Joystick10 Joystick = 9
Joystick11 Joystick = 10
Joystick12 Joystick = 11
Joystick13 Joystick = 12
Joystick14 Joystick = 13
Joystick15 Joystick = 14
Joystick16 Joystick = 15
JoystickLast Joystick = Joystick16
)
// GamepadButton is a gamepad button.
type GamepadButton int
// Gamepad buttons.
const (
GamepadButtonA GamepadButton = 0
GamepadButtonB GamepadButton = 1
GamepadButtonX GamepadButton = 2
GamepadButtonY GamepadButton = 3
GamepadButtonLeftBumper GamepadButton = 4
GamepadButtonRightBumper GamepadButton = 5
GamepadButtonBack GamepadButton = 6
GamepadButtonStart GamepadButton = 7
GamepadButtonGuide GamepadButton = 8
GamepadButtonLeftThumb GamepadButton = 9
GamepadButtonRightThumb GamepadButton = 10
GamepadButtonDPadUp GamepadButton = 11
GamepadButtonDPadRight GamepadButton = 12
GamepadButtonDPadDown GamepadButton = 13
GamepadButtonDPadLeft GamepadButton = 14
GamepadButtonLast GamepadButton = GamepadButtonDPadLeft
GamepadButtonCross GamepadButton = GamepadButtonA
GamepadButtonCircle GamepadButton = GamepadButtonB
GamepadButtonSquare GamepadButton = GamepadButtonX
GamepadButtonTriangle GamepadButton = GamepadButtonY
)
// GamepadAxis is a gamepad axis.
type GamepadAxis int
// Gamepad axes.
const (
GamepadAxisLeftX GamepadAxis = 0
GamepadAxisLeftY GamepadAxis = 1
GamepadAxisRightX GamepadAxis = 2
GamepadAxisRightY GamepadAxis = 3
GamepadAxisLeftTrigger GamepadAxis = 4
GamepadAxisRightTrigger GamepadAxis = 5
GamepadAxisLast GamepadAxis = GamepadAxisRightTrigger
)
// Error represents an error code.
type Error int
const (
// NoError : No error has occurred.
NoError Error = 0
// NotInitialized : GLFW has not been initialized.
//
// This occurs if a GLFW function was called that must not be called unless
// the library is initialized.
//
// Analysis
//
// This is an application programmer error. Initialize GLFW before calling
// any function that requires initialization.
NotInitialized Error = 0x00010001
// NoCurrentContext : No context is current for this thread.
//
// This occurs if a GLFW function was called that needs and operates on the
// current OpenGL or OpenGL ES contest but no context is current on the
// calling thread. One such function is SwapInterval().
//
// Analysis
//
// This is an application programmer error. Ensure a context is current
// before calling functions that require a current context.
NoCurrentContext Error = 0x00010002
// InvalidEnum : One or the arguments to the function was an invalid enum
// value, for example requesting RedBits with GetWindowAttrib.
//
// Analysis
//
// This is an application programmer error. Fix the offending call.
InvalidEnum Error = 0x00010003
// InvalidValue : One of the arguments to the function was an invalid value,
// for example requesting a non-existent OpenGL or OpenGL ES version like
// 2.7.
//
// Requesting a valid but unavailable OpenGL or OpenGL ES version will
// instead result in a VersionUnavailable error.
//
// Analysis
//
// This is an application programmer error. Fix the offending call.
InvalidValue Error = 0x00010004
// OutOfMemory : A memory allocation failed.
//
// Analysis
//
// This is a bug in GLFW, the GLFW library or the underlying operating
// system. Report the bug to our issue tracker
// (https://github.com/beta/glfw/issues) or the GLFW library's
// (https://github.com/glfw/glfw/issues).
OutOfMemory Error = 0x00010005
// APIUnavailable : GLFW could not find support for the requested API on the
// system.
//
// Analysis
//
// Thhe installed graphics driver does not support the requested API, or
// does not support it via the chosen context creation backend. Below are a
// few examples.
//
// Some pre-installed Windows graphics drivers do not support OpenGL. AMD
// only supports OpenGL ES via EGL, while Nvidia and Intel only support it
// via a WGL or GLX extension. macOS does not provide OpenGL ES at all.
// The Mesa EGL, OpenGL and OpenGL ES libraries do not interface with the
// Nvidia binary driver. Older graphics drivers do not support Vulkan.
APIUnavailable Error = 0x00010006
// VersionUnavailable : The requested OpenGL or OpenGL ES version (including
// any requested context or framebuffer hints) is not available on this
// machine.
//
// Analysis
//
// The machine does not support your requirements. If your application is
// sufficiently flexible, downgrade your requirements and try again.
// Otherwise, inform the user that their machine does not match your
// requirements.
//
// Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if
// 5.0 comes out before the 4.x series gets that far, also fail with this
// error and not InvalidValue, because GLFW cannot know what future versions
// will exist.
VersionUnavailable Error = 0x00010007
// PlatformError : A platform-specific error occurred that does not match
// any of the more specific categories.
//
// Analysis
//
// This is a bug or configuration error in GLFW, the GLFW library, the
// underlying operating system or its drivers, or a lack of required
// resources. Report the issue to our issue tracker
// (https://github.com/beta/glfw/issues) or the GLFW library's
// (https://github.com/glfw/glfw/issues).
PlatformError Error = 0x00010008
// FormatUnavailable : The requested format is not supported or available.
//
// If emitted during window creation, the requested pixel format is not
// supported.
//
// If emitted when querying the clipboard, the contents of the clipboard
// could not be converted to the requested format.
//
// Analysis
//
// If emmited during window creation, one or more hard constraints
// (http://www.glfw.org/docs/latest/window_guide.html#window_hints_hard) did
// not match any of the available pixel formats. If your application is
// sufficiently flexible, downgrade your requirements and try again.
// Otherwise, inform the user that their machine does not match your
// requirements.
//
// If emitted when querying the clipboard, ignore the error or report it to
// the user, as appropriate.
FormatUnavailable Error = 0x00010009
// NoWindowContext : A window that does not have an OpenGL or OpenGL ES was
// passed to a function that requires it to have one.
//
// Analysis
//
// This is an application programmer error. Fix the offending call.
NoWindowContext Error = 0x0001000A
)
// Hint is a bit field for creating windows and context.
type Hint int
const (
// Focused : Input focus window hint and attribute.
Focused Hint = 0x00020001
// Iconified : Window iconification window attribute.
Iconified Hint = 0x00020002
// Resizable : Window resize-ability window hint and attribute.
Resizable Hint = 0x00020003
// Visible : Window visibility window hint and attribute.
Visible Hint = 0x00020004
// Decorated : Window decoration window hint and attribute.
Decorated Hint = 0x00020005
// AutoIconify : Window auto-iconification window hint and attribute.
AutoIconify Hint = 0x00020006
// Floating : Window floating window hint and attribute.
Floating Hint = 0x00020007
// Maximized : Window maximization window hint and attribute.
Maximized Hint = 0x00020008
// CenterCursor : Cursor centering window hint.
CenterCursor Hint = 0x00020009
// TransparentFramebuffer : Window framebuffer transparency hint and
// attribute.
TransparentFramebuffer Hint = 0x0002000A
// Hovered : Mouse cursor hover window attribute.
Hovered Hint = 0x0002000B
// FocusOnShow : Input focus on calling show window hint and attribute.
FocusOnShow Hint = 0x0002000C
// RedBits : Framebuffer bit depth hint.
RedBits Hint = 0x00021001
// GreenBits : Framebuffer bit depth hint.
GreenBits Hint = 0x00021002
// BlueBits : Framebuffer bit depth hint.
BlueBits Hint = 0x00021003
// AlphaBits : Framebuffer bit depth hint.
AlphaBits Hint = 0x00021004
// DepthBits : Framebuffer bit depth hint.
DepthBits Hint = 0x00021005
// StencilBits : Framebuffer bit depth hint.
StencilBits Hint = 0x00021006
// AccumRedBits : Framebuffer bit depth hint.
AccumRedBits Hint = 0x00021007
// AccumGreenBits : Framebuffer bit depth hint.
AccumGreenBits Hint = 0x00021008
// AccumBlueBits : Framebuffer bit depth hint.
AccumBlueBits Hint = 0x00021009
// AccumAlphaBits : Framebuffer bit depth hint.
AccumAlphaBits Hint = 0x0002100A
// AuxBuffers : Framebuffer auxiliary buffer hint.
AuxBuffers Hint = 0x0002100B
// Stereo : OpenGL stereoscopic rendering hint.
Stereo Hint = 0x0002100C
// Samples : Framebuffer MSAA samples hint.
Samples Hint = 0x0002100D
// SRGBCapable : Framebuffer sRGB hint.
SRGBCapable Hint = 0x0002100E
// RefreshRate : Monitor refresh rate hint.
RefreshRate Hint = 0x0002100F
// Doublebuffer : Framebuffer double buffering hint.
Doublebuffer Hint = 0x00021010
// ClientAPI : Context client API hint and attribute.
ClientAPI Hint = 0x00022001
// ContextVersionMajor : Context client API major version hint and
// attribute.
ContextVersionMajor Hint = 0x00022002
// ContextVersionMinor : Context client API minor version hint and
// attribute.
ContextVersionMinor Hint = 0x00022003
// ContextRevision : Context client API revision number hint and attribute.
ContextRevision Hint = 0x00022004
// ContextRobustness : Context robustness hint and attribute.
ContextRobustness Hint = 0x00022005
// OpenGLForwardCompat : OpenGL forward-compatibility hint and attribute.
OpenGLForwardCompat Hint = 0x00022006
// OpenGLDebugContext : OpenGL debug context hint and attribute.
OpenGLDebugContext Hint = 0x00022007
// OpenGLProfile : OpenGL profile hint and attribute.
OpenGLProfile Hint = 0x00022008
// ContextReleaseBehavior : Context flush-on-release hint and attribute.
ContextReleaseBehavior Hint = 0x00022009
// ContextNoError : Context error suppression hint and attribute.
ContextNoError Hint = 0x0002200A
// ContextCreationAPI : Context creation API hint and attribute.
ContextCreationAPI Hint = 0x0002200B
// ScaleToMonitor : Window content area scaling window hint.
ScaleToMonitor Hint = 0x0002200C
// CocoaRetinaFramebuffer : macOS specific window hint.
CocoaRetinaFramebuffer Hint = 0x00023001
// CocoaFrameName : macOS specific window hint.
CocoaFrameName Hint = 0x00023002
// CocoaGraphicsSwitching : macOS specific window hint.
CocoaGraphicsSwitching Hint = 0x00023003
// X11ClassName : X11 specific window hint.
X11ClassName Hint = 0x00024001
// X11InstanceName : X11 specific window hint.
X11InstanceName Hint = 0x00024002
// JoystickHatButtons : Joystick hat buttons init hint.
JoystickHatButtons Hint = 0x00050001
// CocoaChdirResources : macOS specific init hint.
CocoaChdirResources Hint = 0x00051001
// CocoaMenubar : macOS specific init hint.
CocoaMenubar Hint = 0x00051002
)
// HintValue is the value for a hint.
type HintValue int
// Hint values.
const (
// Common values.
DontCare HintValue = -1
// Values for ClientAPI.
NoAPI HintValue = 0
OpenGLAPI HintValue = 0x00030001
OpenGLESAPI HintValue = 0x00030002
// Values for ContextRobustness.
NoRobustness HintValue = 0
NoResetNotification HintValue = 0x00031001
LoseContextOnReset HintValue = 0x00031002
// Values for OpenGLProfile.
OpenGLAnyProfile HintValue = 0
OpenGLCoreProfile HintValue = 0x00032001
OpenGLCompatProfile HintValue = 0x00032002
// Values for ContextReleaseBehavior.
AnyReleaseBehavior HintValue = 0
ReleaseBehaviorFlush HintValue = 0x00035001
ReleaseBehaviorNone HintValue = 0x00035002
// Values for ContextCreationAPI.
NativeContextAPI HintValue = 0x00036001
EGLContextAPI HintValue = 0x00036002
OSMesaContextAPI HintValue = 0x00036003
)
// InputMode specifies the input mode.
type InputMode int
// Input modes.
const (
CursorMode InputMode = 0x00033001
StickyKeysMode InputMode = 0x00033002
StickyMouseButtonsMode InputMode = 0x00033003
LockKeyModsMode InputMode = 0x00033004
RawMouseMotionMode InputMode = 0x00033005
)
// CursorModeValue specifies mode of the cursor when the input mode is
// CursorMode.
type CursorModeValue int
// Cursor mode values.
const (
CursorNormal CursorModeValue = 0x00034001
CursorHidden CursorModeValue = 0x00034002
CursorDisabled CursorModeValue = 0x00034003
)
// ConnectionEvent represents whether a device is connected or disconnected
// from the system.
type ConnectionEvent int
// Connection events.
const (
Connected ConnectionEvent = 0x00040001
Disconnected ConnectionEvent = 0x00040002
)
// CursorShape represent a standard cursor shape.
type CursorShape int
const (
// ArrowCursor : The regular arrow cursor shape.
ArrowCursor CursorShape = 0x00036001
// IBeamCursor : The text input I-beam cursor shape.
IBeamCursor CursorShape = 0x00036002
// CrosshairCursor : The crosshair shape.
CrosshairCursor CursorShape = 0x00036003
// HandCursor : The hand shape.
HandCursor CursorShape = 0x00036004
// HResizeCursor : The horizontal resize arrow shape.
HResizeCursor CursorShape = 0x00036005
// VResizeCursor : The vertical resize arrow shape.
VResizeCursor CursorShape = 0x00036006
)
// Constants.
const (
True = 1
False = 0
)
// Monitor is an opaque monitor object.
type Monitor C.GLFWmonitor
func (monitor *Monitor) c() *C.GLFWmonitor {
return (*C.GLFWmonitor)(monitor)
}
// Window is an opaque window object.
type Window C.GLFWwindow
func (win *Window) c() *C.GLFWwindow {
return (*C.GLFWwindow)(win)
}
// Cursor is an opaque cursor object.
type Cursor C.GLFWcursor
func (cursor *Cursor) c() *C.GLFWcursor {
return (*C.GLFWcursor)(cursor)
}
// ErrorCallback is a function type for error callbacks.
//
// err is an Error, and desc is a string describing the error.
type ErrorCallback func(err Error, desc string)
// WindowPosCallback is the function type for window position callbacks.
//
// win is the window that was moved. x and y are the new x- and y-coordinate,
// in screen coordinates, of the upper-left corner of the content area of the
// window.
type WindowPosCallback func(win *Window, x, y int)
// WindowSizeCallback is the function type for window resize callbacks.
//
// win is the window that was resized. width and height are the new width and
// height, in screen coordinates, of the window.
type WindowSizeCallback func(win *Window, width, height int)
// WindowCloseCallback is the function type for window close callbacks.
//
// win is the window that user attempted to close.
type WindowCloseCallback func(win *Window)
// WindowRefreshCallback is the function type for window content refresh
// callbacks.
//
// win is the window whose content needs to be refreshed.
type WindowRefreshCallback func(win *Window)
// WindowFocusCallback is the function type for window focus/defocus callbacks.
//
// win is the window that gained or lost input focus. focused is true if the
// window was given input focus, or false if it lost it.
type WindowFocusCallback func(win *Window, focused bool)
// WindowIconifyCallback is the function type for window iconify/restore
// callbacks.
//
// win is the window that was iconified or restored. iconified is true if the
// window was iconified, or false if it was restored.
type WindowIconifyCallback func(win *Window, iconified bool)
// WindowMaximizeCallback is the function type for window maximize/restore