-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGLFW.java
1381 lines (1171 loc) · 55.2 KB
/
GLFW.java
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 LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl.glfw;
import android.util.*;
import java.lang.annotation.Native;
import java.lang.reflect.*;
import java.nio.*;
import javax.annotation.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
import java.util.*;
import sun.misc.Unsafe;
public class GLFW
{
static FloatBuffer joystickData = (FloatBuffer)FloatBuffer.allocate(8).flip();
static ByteBuffer buttonData = (ByteBuffer)ByteBuffer.allocate(8).flip();
/** The major version number of the GLFW library. This is incremented when the API is changed in non-compatible ways. */
public static final int GLFW_VERSION_MAJOR = 3;
/** The minor version number of the GLFW library. This is incremented when features are added to the API but it remains backward-compatible. */
public static final int GLFW_VERSION_MINOR = 4;
/** The revision number of the GLFW library. This is incremented when a bug fix release is made that does not contain any API changes. */
public static final int GLFW_VERSION_REVISION = 0;
/** Boolean values. */
public static final int
GLFW_TRUE = 1,
GLFW_FALSE = 0;
/** The key or button was released. */
public static final int GLFW_RELEASE = 0;
/** The key or button was pressed. */
public static final int GLFW_PRESS = 1;
/** The key was held down until it repeated. */
public static final int GLFW_REPEAT = 2;
/** Joystick hat states. */
public static final int
GLFW_HAT_CENTERED = 0,
GLFW_HAT_UP = 1,
GLFW_HAT_RIGHT = 2,
GLFW_HAT_DOWN = 4,
GLFW_HAT_LEFT = 8,
GLFW_HAT_RIGHT_UP = (GLFW_HAT_RIGHT | GLFW_HAT_UP),
GLFW_HAT_RIGHT_DOWN = (GLFW_HAT_RIGHT | GLFW_HAT_DOWN),
GLFW_HAT_LEFT_UP = (GLFW_HAT_LEFT | GLFW_HAT_UP),
GLFW_HAT_LEFT_DOWN = (GLFW_HAT_LEFT | GLFW_HAT_DOWN);
/** The unknown key. */
public static final int GLFW_KEY_UNKNOWN = -1;
/** Printable keys. */
public static final int
GLFW_KEY_SPACE = 32,
GLFW_KEY_APOSTROPHE = 39,
GLFW_KEY_COMMA = 44,
GLFW_KEY_MINUS = 45,
GLFW_KEY_PERIOD = 46,
GLFW_KEY_SLASH = 47,
GLFW_KEY_0 = 48,
GLFW_KEY_1 = 49,
GLFW_KEY_2 = 50,
GLFW_KEY_3 = 51,
GLFW_KEY_4 = 52,
GLFW_KEY_5 = 53,
GLFW_KEY_6 = 54,
GLFW_KEY_7 = 55,
GLFW_KEY_8 = 56,
GLFW_KEY_9 = 57,
GLFW_KEY_SEMICOLON = 59,
GLFW_KEY_EQUAL = 61,
GLFW_KEY_A = 65,
GLFW_KEY_B = 66,
GLFW_KEY_C = 67,
GLFW_KEY_D = 68,
GLFW_KEY_E = 69,
GLFW_KEY_F = 70,
GLFW_KEY_G = 71,
GLFW_KEY_H = 72,
GLFW_KEY_I = 73,
GLFW_KEY_J = 74,
GLFW_KEY_K = 75,
GLFW_KEY_L = 76,
GLFW_KEY_M = 77,
GLFW_KEY_N = 78,
GLFW_KEY_O = 79,
GLFW_KEY_P = 80,
GLFW_KEY_Q = 81,
GLFW_KEY_R = 82,
GLFW_KEY_S = 83,
GLFW_KEY_T = 84,
GLFW_KEY_U = 85,
GLFW_KEY_V = 86,
GLFW_KEY_W = 87,
GLFW_KEY_X = 88,
GLFW_KEY_Y = 89,
GLFW_KEY_Z = 90,
GLFW_KEY_LEFT_BRACKET = 91,
GLFW_KEY_BACKSLASH = 92,
GLFW_KEY_RIGHT_BRACKET = 93,
GLFW_KEY_GRAVE_ACCENT = 96,
GLFW_KEY_WORLD_1 = 161,
GLFW_KEY_WORLD_2 = 162;
/** Function keys. */
public static final int
GLFW_KEY_ESCAPE = 256,
GLFW_KEY_ENTER = 257,
GLFW_KEY_TAB = 258,
GLFW_KEY_BACKSPACE = 259,
GLFW_KEY_INSERT = 260,
GLFW_KEY_DELETE = 261,
GLFW_KEY_RIGHT = 262,
GLFW_KEY_LEFT = 263,
GLFW_KEY_DOWN = 264,
GLFW_KEY_UP = 265,
GLFW_KEY_PAGE_UP = 266,
GLFW_KEY_PAGE_DOWN = 267,
GLFW_KEY_HOME = 268,
GLFW_KEY_END = 269,
GLFW_KEY_CAPS_LOCK = 280,
GLFW_KEY_SCROLL_LOCK = 281,
GLFW_KEY_NUM_LOCK = 282,
GLFW_KEY_PRINT_SCREEN = 283,
GLFW_KEY_PAUSE = 284,
GLFW_KEY_F1 = 290,
GLFW_KEY_F2 = 291,
GLFW_KEY_F3 = 292,
GLFW_KEY_F4 = 293,
GLFW_KEY_F5 = 294,
GLFW_KEY_F6 = 295,
GLFW_KEY_F7 = 296,
GLFW_KEY_F8 = 297,
GLFW_KEY_F9 = 298,
GLFW_KEY_F10 = 299,
GLFW_KEY_F11 = 300,
GLFW_KEY_F12 = 301,
GLFW_KEY_F13 = 302,
GLFW_KEY_F14 = 303,
GLFW_KEY_F15 = 304,
GLFW_KEY_F16 = 305,
GLFW_KEY_F17 = 306,
GLFW_KEY_F18 = 307,
GLFW_KEY_F19 = 308,
GLFW_KEY_F20 = 309,
GLFW_KEY_F21 = 310,
GLFW_KEY_F22 = 311,
GLFW_KEY_F23 = 312,
GLFW_KEY_F24 = 313,
GLFW_KEY_F25 = 314,
GLFW_KEY_KP_0 = 320,
GLFW_KEY_KP_1 = 321,
GLFW_KEY_KP_2 = 322,
GLFW_KEY_KP_3 = 323,
GLFW_KEY_KP_4 = 324,
GLFW_KEY_KP_5 = 325,
GLFW_KEY_KP_6 = 326,
GLFW_KEY_KP_7 = 327,
GLFW_KEY_KP_8 = 328,
GLFW_KEY_KP_9 = 329,
GLFW_KEY_KP_DECIMAL = 330,
GLFW_KEY_KP_DIVIDE = 331,
GLFW_KEY_KP_MULTIPLY = 332,
GLFW_KEY_KP_SUBTRACT = 333,
GLFW_KEY_KP_ADD = 334,
GLFW_KEY_KP_ENTER = 335,
GLFW_KEY_KP_EQUAL = 336,
GLFW_KEY_LEFT_SHIFT = 340,
GLFW_KEY_LEFT_CONTROL = 341,
GLFW_KEY_LEFT_ALT = 342,
GLFW_KEY_LEFT_SUPER = 343,
GLFW_KEY_RIGHT_SHIFT = 344,
GLFW_KEY_RIGHT_CONTROL = 345,
GLFW_KEY_RIGHT_ALT = 346,
GLFW_KEY_RIGHT_SUPER = 347,
GLFW_KEY_MENU = 348,
GLFW_KEY_LAST = GLFW_KEY_MENU;
/** If this bit is set one or more Shift keys were held down. */
public static final int GLFW_MOD_SHIFT = 0x1;
/** If this bit is set one or more Control keys were held down. */
public static final int GLFW_MOD_CONTROL = 0x2;
/** If this bit is set one or more Alt keys were held down. */
public static final int GLFW_MOD_ALT = 0x4;
/** If this bit is set one or more Super keys were held down. */
public static final int GLFW_MOD_SUPER = 0x8;
/** If this bit is set the Caps Lock key is enabled and the {@link #GLFW_LOCK_KEY_MODS LOCK_KEY_MODS} input mode is set. */
public static final int GLFW_MOD_CAPS_LOCK = 0x10;
/** If this bit is set the Num Lock key is enabled and the {@link #GLFW_LOCK_KEY_MODS LOCK_KEY_MODS} input mode is set. */
public static final int GLFW_MOD_NUM_LOCK = 0x20;
/** Mouse buttons. See <a target="_blank" href="http://www.glfw.org/docs/latest/input.html#input_mouse_button">mouse button input</a> for how these are used. */
public static final int
GLFW_MOUSE_BUTTON_1 = 0,
GLFW_MOUSE_BUTTON_2 = 1,
GLFW_MOUSE_BUTTON_3 = 2,
GLFW_MOUSE_BUTTON_4 = 3,
GLFW_MOUSE_BUTTON_5 = 4,
GLFW_MOUSE_BUTTON_6 = 5,
GLFW_MOUSE_BUTTON_7 = 6,
GLFW_MOUSE_BUTTON_8 = 7,
GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8,
GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1,
GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2,
GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3;
/** Joysticks. See <a target="_blank" href="http://www.glfw.org/docs/latest/input.html#joystick">joystick input</a> for how these are used. */
public static final int
GLFW_JOYSTICK_1 = 0,
GLFW_JOYSTICK_2 = 1,
GLFW_JOYSTICK_3 = 2,
GLFW_JOYSTICK_4 = 3,
GLFW_JOYSTICK_5 = 4,
GLFW_JOYSTICK_6 = 5,
GLFW_JOYSTICK_7 = 6,
GLFW_JOYSTICK_8 = 7,
GLFW_JOYSTICK_9 = 8,
GLFW_JOYSTICK_10 = 9,
GLFW_JOYSTICK_11 = 10,
GLFW_JOYSTICK_12 = 11,
GLFW_JOYSTICK_13 = 12,
GLFW_JOYSTICK_14 = 13,
GLFW_JOYSTICK_15 = 14,
GLFW_JOYSTICK_16 = 15,
GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16;
/** Gamepad buttons. See <a target="_blank" href="http://www.glfw.org/docs/latest/input.html#gamepad">gamepad</a> for how these are used. */
public static final int
GLFW_GAMEPAD_BUTTON_A = 0,
GLFW_GAMEPAD_BUTTON_B = 1,
GLFW_GAMEPAD_BUTTON_X = 2,
GLFW_GAMEPAD_BUTTON_Y = 3,
GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4,
GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5,
GLFW_GAMEPAD_BUTTON_BACK = 6,
GLFW_GAMEPAD_BUTTON_START = 7,
GLFW_GAMEPAD_BUTTON_GUIDE = 8,
GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9,
GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10,
GLFW_GAMEPAD_BUTTON_DPAD_UP = 11,
GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12,
GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13,
GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14,
GLFW_GAMEPAD_BUTTON_LAST = GLFW_GAMEPAD_BUTTON_DPAD_LEFT,
GLFW_GAMEPAD_BUTTON_CROSS = GLFW_GAMEPAD_BUTTON_A,
GLFW_GAMEPAD_BUTTON_CIRCLE = GLFW_GAMEPAD_BUTTON_B,
GLFW_GAMEPAD_BUTTON_SQUARE = GLFW_GAMEPAD_BUTTON_X,
GLFW_GAMEPAD_BUTTON_TRIANGLE = GLFW_GAMEPAD_BUTTON_Y;
/** Gamepad axes. See <a target="_blank" href="http://www.glfw.org/docs/latest/input.html#gamepad">gamepad</a> for how these are used. */
public static final int
GLFW_GAMEPAD_AXIS_LEFT_X = 0,
GLFW_GAMEPAD_AXIS_LEFT_Y = 1,
GLFW_GAMEPAD_AXIS_RIGHT_X = 2,
GLFW_GAMEPAD_AXIS_RIGHT_Y = 3,
GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4,
GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5,
GLFW_GAMEPAD_AXIS_LAST = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER;
public static final int
GLFW_NO_ERROR = 0,
GLFW_NOT_INITIALIZED = 0x10001,
GLFW_NO_CURRENT_CONTEXT = 0x10002,
GLFW_INVALID_ENUM = 0x10003,
GLFW_INVALID_VALUE = 0x10004,
GLFW_OUT_OF_MEMORY = 0x10005,
GLFW_API_UNAVAILABLE = 0x10006,
GLFW_VERSION_UNAVAILABLE = 0x10007,
GLFW_PLATFORM_ERROR = 0x10008,
GLFW_FORMAT_UNAVAILABLE = 0x10009,
GLFW_NO_WINDOW_CONTEXT = 0x1000A,
GLFW_CURSOR_UNAVAILABLE = 0x1000B,
GLFW_FEATURE_UNAVAILABLE = 0x1000C,
GLFW_FEATURE_UNIMPLEMENTED = 0x1000D;
public static final int
GLFW_FOCUSED = 0x20001,
GLFW_ICONIFIED = 0x20002,
GLFW_RESIZABLE = 0x20003,
GLFW_VISIBLE = 0x20004,
GLFW_DECORATED = 0x20005,
GLFW_AUTO_ICONIFY = 0x20006,
GLFW_FLOATING = 0x20007,
GLFW_MAXIMIZED = 0x20008,
GLFW_CENTER_CURSOR = 0x20009,
GLFW_TRANSPARENT_FRAMEBUFFER = 0x2000A,
GLFW_HOVERED = 0x2000B,
GLFW_FOCUS_ON_SHOW = 0x2000C;
/** Input options. */
public static final int
GLFW_CURSOR = 0x33001,
GLFW_STICKY_KEYS = 0x33002,
GLFW_STICKY_MOUSE_BUTTONS = 0x33003,
GLFW_LOCK_KEY_MODS = 0x33004,
GLFW_RAW_MOUSE_MOTION = 0x33005;
/** Cursor state. */
public static final int
GLFW_CURSOR_NORMAL = 0x34001,
GLFW_CURSOR_HIDDEN = 0x34002,
GLFW_CURSOR_DISABLED = 0x34003;
/** The regular arrow cursor shape. */
public static final int GLFW_ARROW_CURSOR = 0x36001;
/** The text input I-beam cursor shape. */
public static final int GLFW_IBEAM_CURSOR = 0x36002;
/** The crosshair cursor shape. */
public static final int GLFW_CROSSHAIR_CURSOR = 0x36003;
/** The pointing hand cursor shape. */
public static final int GLFW_POINTING_HAND_CURSOR = 0x36004;
public static final int GLFW_RESIZE_EW_CURSOR = 0x36005;
public static final int GLFW_RESIZE_NS_CURSOR = 0x36006;
public static final int GLFW_RESIZE_NWSE_CURSOR = 0x36007;
public static final int GLFW_RESIZE_NESW_CURSOR = 0x36008;
/**
* The omni-directional resize cursor/move shape.
*
* <p>This is usually either a combined horizontal and vertical double-headed arrow or a grabbing hand.</p>
*/
public static final int GLFW_RESIZE_ALL_CURSOR = 0x36009;
public static final int GLFW_NOT_ALLOWED_CURSOR = 0x3600A;
/** Legacy name for compatibility. */
public static final int GLFW_HRESIZE_CURSOR = GLFW_RESIZE_EW_CURSOR;
/** Legacy name for compatibility. */
public static final int GLFW_VRESIZE_CURSOR = GLFW_RESIZE_NS_CURSOR;
/** Legacy name for compatibility. */
public static final int GLFW_HAND_CURSOR = GLFW_POINTING_HAND_CURSOR;
/** Monitor events. */
public static final int
GLFW_CONNECTED = 0x40001,
GLFW_DISCONNECTED = 0x40002;
/** Init hints. */
public static final int
GLFW_JOYSTICK_HAT_BUTTONS = 0x50001,
GLFW_COCOA_CHDIR_RESOURCES = 0x51001,
GLFW_COCOA_MENUBAR = 0x51002;
/** Hint value for {@link #GLFW_PLATFORM PLATFORM} that enables automatic platform selection. */
public static final int
GLFW_ANY_PLATFORM = 0x60000,
GLFW_PLATFORM_WIN32 = 0x60001,
GLFW_PLATFORM_COCOA = 0x60002,
GLFW_PLATFORM_WAYLAND = 0x60003,
GLFW_PLATFORM_X11 = 0x60004,
GLFW_PLATFORM_NULL = 0x60005;
/** Don't care value. */
public static final int GLFW_DONT_CARE = -1;
/** PixelFormat hints. */
public static final int
GLFW_RED_BITS = 0x21001,
GLFW_GREEN_BITS = 0x21002,
GLFW_BLUE_BITS = 0x21003,
GLFW_ALPHA_BITS = 0x21004,
GLFW_DEPTH_BITS = 0x21005,
GLFW_STENCIL_BITS = 0x21006,
GLFW_ACCUM_RED_BITS = 0x21007,
GLFW_ACCUM_GREEN_BITS = 0x21008,
GLFW_ACCUM_BLUE_BITS = 0x21009,
GLFW_ACCUM_ALPHA_BITS = 0x2100A,
GLFW_AUX_BUFFERS = 0x2100B,
GLFW_STEREO = 0x2100C,
GLFW_SAMPLES = 0x2100D,
GLFW_SRGB_CAPABLE = 0x2100E,
GLFW_REFRESH_RATE = 0x2100F,
GLFW_DOUBLEBUFFER = 0x21010;
public static final int
GLFW_CLIENT_API = 0x22001,
GLFW_CONTEXT_VERSION_MAJOR = 0x22002,
GLFW_CONTEXT_VERSION_MINOR = 0x22003,
GLFW_CONTEXT_REVISION = 0x22004,
GLFW_CONTEXT_ROBUSTNESS = 0x22005,
GLFW_OPENGL_FORWARD_COMPAT = 0x22006,
GLFW_OPENGL_DEBUG_CONTEXT = 0x22007,
GLFW_OPENGL_PROFILE = 0x22008,
GLFW_CONTEXT_RELEASE_BEHAVIOR = 0x22009,
GLFW_CONTEXT_NO_ERROR = 0x2200A,
GLFW_CONTEXT_CREATION_API = 0x2200B,
GLFW_SCALE_TO_MONITOR = 0x2200C;
/** Specifies whether to use full resolution framebuffers on Retina displays. This is ignored on other platforms. */
public static final int GLFW_COCOA_RETINA_FRAMEBUFFER = 0x23001;
/**
* Specifies the UTF-8 encoded name to use for autosaving the window frame, or if empty disables frame autosaving for the window. This is ignored on other
* platforms. This is set with {@link #glfwWindowHintString WindowHintString}.
*/
public static final int GLFW_COCOA_FRAME_NAME = 0x23002;
/**
* Specifies whether to enable Automatic Graphics Switching, i.e. to allow the system to choose the integrated GPU for the OpenGL context and move it
* between GPUs if necessary or whether to force it to always run on the discrete GPU. This only affects systems with both integrated and discrete GPUs.
* This is ignored on other platforms.
*/
public static final int GLFW_COCOA_GRAPHICS_SWITCHING = 0x23003;
/** The desired ASCII encoded class and instance parts of the ICCCM {@code WM_CLASS} window property. These are set with {@link #glfwWindowHintString WindowHintString}. */
public static final int
GLFW_X11_CLASS_NAME = 0x24001,
GLFW_X11_INSTANCE_NAME = 0x24002;
/**
* Specifies whether to allow access to the window menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts.
*
* <p>This is ignored on other platforms.</p>
*/
public static final int GLFW_WIN32_KEYBOARD_MENU = 0x25001;
/** Values for the {@link #GLFW_CLIENT_API CLIENT_API} hint. */
public static final int
GLFW_NO_API = 0,
GLFW_OPENGL_API = 0x30001,
GLFW_OPENGL_ES_API = 0x30002;
/** Values for the {@link #GLFW_CONTEXT_ROBUSTNESS CONTEXT_ROBUSTNESS} hint. */
public static final int
GLFW_NO_ROBUSTNESS = 0,
GLFW_NO_RESET_NOTIFICATION = 0x31001,
GLFW_LOSE_CONTEXT_ON_RESET = 0x31002;
/** Values for the {@link #GLFW_OPENGL_PROFILE OPENGL_PROFILE} hint. */
public static final int
GLFW_OPENGL_ANY_PROFILE = 0,
GLFW_OPENGL_CORE_PROFILE = 0x32001,
GLFW_OPENGL_COMPAT_PROFILE = 0x32002;
/** Values for the {@link #GLFW_CONTEXT_RELEASE_BEHAVIOR CONTEXT_RELEASE_BEHAVIOR} hint. */
public static final int
GLFW_ANY_RELEASE_BEHAVIOR = 0,
GLFW_RELEASE_BEHAVIOR_FLUSH = 0x35001,
GLFW_RELEASE_BEHAVIOR_NONE = 0x35002;
/** Values for the {@link #GLFW_CONTEXT_CREATION_API CONTEXT_CREATION_API} hint. */
public static final int
GLFW_NATIVE_CONTEXT_API = 0x36001,
GLFW_EGL_CONTEXT_API = 0x36002,
GLFW_OSMESA_CONTEXT_API = 0x36003;
// GLFW Callbacks
/* volatile */ public static GLFWCharCallback mGLFWCharCallback;
/* volatile */ public static GLFWCharModsCallback mGLFWCharModsCallback;
/* volatile */ public static GLFWCursorEnterCallback mGLFWCursorEnterCallback;
/* volatile */ public static GLFWCursorPosCallback mGLFWCursorPosCallback;
/* volatile */ public static GLFWDropCallback mGLFWDropCallback;
/* volatile */ public static GLFWErrorCallback mGLFWErrorCallback;
/* volatile */ public static GLFWFramebufferSizeCallback mGLFWFramebufferSizeCallback;
/* volatile */ public static GLFWJoystickCallback mGLFWJoystickCallback;
/* volatile */ public static GLFWKeyCallback mGLFWKeyCallback;
/* volatile */ public static GLFWMonitorCallback mGLFWMonitorCallback;
/* volatile */ public static GLFWMouseButtonCallback mGLFWMouseButtonCallback;
/* volatile */ public static GLFWScrollCallback mGLFWScrollCallback;
/* volatile */ public static GLFWWindowCloseCallback mGLFWWindowCloseCallback;
/* volatile */ public static GLFWWindowContentScaleCallback mGLFWWindowContentScaleCallback;
/* volatile */ public static GLFWWindowFocusCallback mGLFWWindowFocusCallback;
/* volatile */ public static GLFWWindowIconifyCallback mGLFWWindowIconifyCallback;
/* volatile */ public static GLFWWindowMaximizeCallback mGLFWWindowMaximizeCallback;
/* volatile */ public static GLFWWindowPosCallback mGLFWWindowPosCallback;
/* volatile */ public static GLFWWindowRefreshCallback mGLFWWindowRefreshCallback;
/* volatile */ public static GLFWWindowSizeCallback mGLFWWindowSizeCallback;
volatile public static int mGLFWWindowWidth, mGLFWWindowHeight;
private static GLFWGammaRamp mGLFWGammaRamp;
private static Map<Integer, String> mGLFWKeyCodes;
private static GLFWVidMode mGLFWVideoMode;
private static long mGLFWWindowMonitor;
private static double mGLFWInitialTime;
private static ArrayMap<Long, GLFWWindowProperties> mGLFWWindowMap;
public static boolean mGLFWIsInputReady;
public static final ByteBuffer keyDownBuffer = ByteBuffer.allocateDirect(317);
public static final ByteBuffer mouseDownBuffer = ByteBuffer.allocateDirect(8);
private static final String PROP_WINDOW_WIDTH = "glfwstub.windowWidth";
private static final String PROP_WINDOW_HEIGHT= "glfwstub.windowHeight";
public static long mainContext = 0;
static {
String windowWidth = System.getProperty(PROP_WINDOW_WIDTH);
String windowHeight = System.getProperty(PROP_WINDOW_HEIGHT);
if (windowWidth == null || windowHeight == null) {
System.err.println("Warning: Property " + PROP_WINDOW_WIDTH + " or " + PROP_WINDOW_HEIGHT + " not set, defaulting to 1280 and 720");
mGLFWWindowWidth = 1280;
mGLFWWindowHeight = 720;
} else {
mGLFWWindowWidth = Integer.parseInt(windowWidth);
mGLFWWindowHeight = Integer.parseInt(windowHeight);
}
// Minecraft triggers a glfwPollEvents() on splash screen, so update window size there.
// CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE, mGLFWWindowWidth, mGLFWWindowHeight, 0, 0);
// CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_WINDOW_SIZE, mGLFWWindowWidth, mGLFWWindowHeight, 0, 0);
try {
System.loadLibrary("pojavexec");
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
}
mGLFWErrorCallback = GLFWErrorCallback.createPrint();
mGLFWKeyCodes = new ArrayMap<>();
mGLFWWindowMap = new ArrayMap<>();
mGLFWVideoMode = new GLFWVidMode(ByteBuffer.allocateDirect(GLFWVidMode.SIZEOF));
memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.WIDTH, mGLFWWindowWidth);
memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.HEIGHT, mGLFWWindowHeight);
memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REDBITS, 8);
memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.GREENBITS, 8);
memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.BLUEBITS, 8);
memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REFRESHRATE, 60);
// A way to generate key code names
Field[] thisFieldArr = GLFW.class.getFields();
try {
for (Field thisField : thisFieldArr) {
if (thisField.getName().startsWith("GLFW_KEY_")) {
mGLFWKeyCodes.put(
(int) thisField.get(null),
thisField.getName().substring(9, 10).toUpperCase() +
thisField.getName().substring(10).replace("_", " ").toLowerCase()
);
}
}
} catch (IllegalAccessException e) {
// This will never happen since this is accessing itself
}
/*
mGLFWMonitorCallback = new GLFWMonitorCallback(){
// Fake one!!!
@Override
public void free() {}
@Override
public void callback(long args) {
// TODO: Implement this method
}
};
*/
}
private static native long nglfwSetCharCallback(long window, long ptr);
private static native long nglfwSetCharModsCallback(long window, long ptr);
private static native long nglfwSetCursorEnterCallback(long window, long ptr);
private static native long nglfwSetCursorPosCallback(long window, long ptr);
private static native long nglfwSetFramebufferSizeCallback(long window, long ptr);
private static native long nglfwSetKeyCallback(long window, long ptr);
private static native long nglfwSetMouseButtonCallback(long window, long ptr);
private static native long nglfwSetScrollCallback(long window, long ptr);
private static native long nglfwSetWindowSizeCallback(long window, long ptr);
// private static native void nglfwSetInputReady();
private static native void nglfwSetShowingWindow(long window);
/*
private static void priGlfwSetError(int error) {
mGLFW_currentError = error;
if (error != GLFW_NO_ERROR && mGLFWErrorCallback != null) {
mGLFWErrorCallback.invoke(error, 0);
}
}
private static void priGlfwNoError() {
priGlfwSetError(GLFW_NO_ERROR);
}
*/
protected GLFW() {
throw new UnsupportedOperationException();
}
private static final SharedLibrary GLFW = Library.loadNative(GLFW.class, "org.lwjgl.glfw", "libpojavexec.so", true);
/** Contains the function pointers loaded from the glfw {@link SharedLibrary}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
Init = apiGetFunctionAddress(GLFW, "pojavInit"),
CreateContext = apiGetFunctionAddress(GLFW, "pojavCreateContext"),
GetCurrentContext = apiGetFunctionAddress(GLFW, "pojavGetCurrentContext"),
//DetachOnCurrentThread = apiGetFunctionAddress(GLFW, "pojavDetachOnCurrentThread"),
MakeContextCurrent = apiGetFunctionAddress(GLFW, "pojavMakeCurrent"),
Terminate = apiGetFunctionAddress(GLFW, "pojavTerminate"),
SetWindowHint = apiGetFunctionAddress(GLFW, "pojavSetWindowHint"),
SwapBuffers = apiGetFunctionAddress(GLFW, "pojavSwapBuffers"),
SwapInterval = apiGetFunctionAddress(GLFW, "pojavSwapInterval"),
PumpEvents = apiGetFunctionAddress(GLFW, "pojavPumpEvents"),
RewindEvents = apiGetFunctionAddress(GLFW, "pojavRewindEvents"),
SetupEvents = apiGetFunctionAddress(GLFW, "pojavComputeEventTarget");
}
public static SharedLibrary getLibrary() {
return GLFW;
}
public static void internalChangeMonitorSize(int width, int height) {
mGLFWWindowWidth = width;
mGLFWWindowHeight = height;
if (mGLFWVideoMode == null) return;
memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.WIDTH, mGLFWWindowWidth);
memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.HEIGHT, mGLFWWindowHeight);
}
public static GLFWWindowProperties internalGetWindow(long window) {
GLFWWindowProperties win = mGLFWWindowMap.get(window);
if (win == null) {
throw new IllegalArgumentException("No window pointer found: " + window);
}
return win;
}
// Generated stub callback methods
public static GLFWCharCallback glfwSetCharCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcharfun") GLFWCharCallbackI cbfun) {
GLFWCharCallback lastCallback = mGLFWCharCallback;
if (cbfun == null) mGLFWCharCallback = null;
else mGLFWCharCallback = GLFWCharCallback.createSafe(nglfwSetCharCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWCharModsCallback glfwSetCharModsCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcharmodsfun") GLFWCharModsCallbackI cbfun) {
GLFWCharModsCallback lastCallback = mGLFWCharModsCallback;
if (cbfun == null) mGLFWCharModsCallback = null;
else mGLFWCharModsCallback = GLFWCharModsCallback.createSafe(nglfwSetCharModsCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWCursorEnterCallback glfwSetCursorEnterCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcursorenterfun") GLFWCursorEnterCallbackI cbfun) {
GLFWCursorEnterCallback lastCallback = mGLFWCursorEnterCallback;
if (cbfun == null) mGLFWCursorEnterCallback = null;
else mGLFWCursorEnterCallback = GLFWCursorEnterCallback.createSafe(nglfwSetCursorEnterCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWCursorPosCallback glfwSetCursorPosCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcursorposfun") GLFWCursorPosCallbackI cbfun) {
GLFWCursorPosCallback lastCallback = mGLFWCursorPosCallback;
if (cbfun == null) mGLFWCursorPosCallback = null;
else mGLFWCursorPosCallback = GLFWCursorPosCallback.createSafe(nglfwSetCursorPosCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWDropCallback glfwSetDropCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWdropfun") GLFWDropCallbackI cbfun) {
GLFWDropCallback lastCallback = mGLFWDropCallback;
if (cbfun == null) mGLFWDropCallback = null;
else mGLFWDropCallback = GLFWDropCallback.create(cbfun);
return lastCallback;
}
public static GLFWErrorCallback glfwSetErrorCallback(@Nullable @NativeType("GLFWerrorfun") GLFWErrorCallbackI cbfun) {
GLFWErrorCallback lastCallback = mGLFWErrorCallback;
if (cbfun == null) mGLFWErrorCallback = null;
else mGLFWErrorCallback = GLFWErrorCallback.create(cbfun);
return lastCallback;
}
public static GLFWFramebufferSizeCallback glfwSetFramebufferSizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWframebuffersizefun") GLFWFramebufferSizeCallbackI cbfun) {
GLFWFramebufferSizeCallback lastCallback = mGLFWFramebufferSizeCallback;
if (cbfun == null) mGLFWFramebufferSizeCallback = null;
else mGLFWFramebufferSizeCallback = GLFWFramebufferSizeCallback.createSafe(nglfwSetFramebufferSizeCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWJoystickCallback glfwSetJoystickCallback(/* @NativeType("GLFWwindow *") long window, */ @Nullable @NativeType("GLFWjoystickfun") GLFWJoystickCallbackI cbfun) {
GLFWJoystickCallback lastCallback = mGLFWJoystickCallback;
if (cbfun == null) mGLFWJoystickCallback = null;
else mGLFWJoystickCallback = GLFWJoystickCallback.create(cbfun);
return lastCallback;
}
public static GLFWKeyCallback glfwSetKeyCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWkeyfun") GLFWKeyCallbackI cbfun) {
GLFWKeyCallback lastCallback = mGLFWKeyCallback;
if (cbfun == null) mGLFWKeyCallback = null;
else mGLFWKeyCallback = GLFWKeyCallback.createSafe(nglfwSetKeyCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWMonitorCallback glfwSetMonitorCallback(@Nullable @NativeType("GLFWmonitorfun") GLFWMonitorCallbackI cbfun) {
GLFWMonitorCallback lastCallback = mGLFWMonitorCallback;
if (cbfun == null) mGLFWMonitorCallback = null;
else mGLFWMonitorCallback = GLFWMonitorCallback.create(cbfun);
return lastCallback;
}
public static GLFWMouseButtonCallback glfwSetMouseButtonCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWmousebuttonfun") GLFWMouseButtonCallbackI cbfun) {
GLFWMouseButtonCallback lastCallback = mGLFWMouseButtonCallback;
if (cbfun == null) mGLFWMouseButtonCallback = null;
else mGLFWMouseButtonCallback = GLFWMouseButtonCallback.createSafe(nglfwSetMouseButtonCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWScrollCallback glfwSetScrollCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWscrollfun") GLFWScrollCallbackI cbfun) {
GLFWScrollCallback lastCallback = mGLFWScrollCallback;
if (cbfun == null) mGLFWScrollCallback = null;
else mGLFWScrollCallback = GLFWScrollCallback.createSafe(nglfwSetScrollCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWWindowCloseCallback glfwSetWindowCloseCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowclosefun") GLFWWindowCloseCallbackI cbfun) {
GLFWWindowCloseCallback lastCallback = mGLFWWindowCloseCallback;
if (cbfun == null) mGLFWWindowCloseCallback = null;
else mGLFWWindowCloseCallback = GLFWWindowCloseCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowContentScaleCallback glfwSetWindowContentScaleCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowcontentscalefun") GLFWWindowContentScaleCallbackI cbfun) {
GLFWWindowContentScaleCallback lastCallback = mGLFWWindowContentScaleCallback;
if (cbfun == null) mGLFWWindowContentScaleCallback = null;
else mGLFWWindowContentScaleCallback = GLFWWindowContentScaleCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowFocusCallback glfwSetWindowFocusCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowfocusfun") GLFWWindowFocusCallbackI cbfun) {
GLFWWindowFocusCallback lastCallback = mGLFWWindowFocusCallback;
if (cbfun == null) mGLFWWindowFocusCallback = null;
else mGLFWWindowFocusCallback = GLFWWindowFocusCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowIconifyCallback glfwSetWindowIconifyCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowiconifyfun") GLFWWindowIconifyCallbackI cbfun) {
GLFWWindowIconifyCallback lastCallback = mGLFWWindowIconifyCallback;
if (cbfun == null) mGLFWWindowIconifyCallback = null;
else mGLFWWindowIconifyCallback = GLFWWindowIconifyCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowMaximizeCallback glfwSetWindowMaximizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowmaximizefun") GLFWWindowMaximizeCallbackI cbfun) {
GLFWWindowMaximizeCallback lastCallback = mGLFWWindowMaximizeCallback;
if (cbfun == null) mGLFWWindowMaximizeCallback = null;
else mGLFWWindowMaximizeCallback = GLFWWindowMaximizeCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowPosCallback glfwSetWindowPosCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowposfun") GLFWWindowPosCallbackI cbfun) {
GLFWWindowPosCallback lastCallback = mGLFWWindowPosCallback;
if (cbfun == null) mGLFWWindowPosCallback = null;
else mGLFWWindowPosCallback = GLFWWindowPosCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowRefreshCallback glfwSetWindowRefreshCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowrefreshfun") GLFWWindowRefreshCallbackI cbfun) {
GLFWWindowRefreshCallback lastCallback = mGLFWWindowRefreshCallback;
if (cbfun == null) mGLFWWindowRefreshCallback = null;
else mGLFWWindowRefreshCallback = GLFWWindowRefreshCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowSizeCallback glfwSetWindowSizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowsizefun") GLFWWindowSizeCallbackI cbfun) {
GLFWWindowSizeCallback lastCallback = mGLFWWindowSizeCallback;
if (cbfun == null) mGLFWWindowSizeCallback = null;
else mGLFWWindowSizeCallback = GLFWWindowSizeCallback.createSafe(nglfwSetWindowSizeCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
static boolean isGLFWReady;
public static boolean glfwInit() {
if (!isGLFWReady) {
//CallbackBridge.nativeAttachThreadToOther(false, false);
mGLFWInitialTime = (double) System.nanoTime();
long __functionAddress = Functions.Init;
isGLFWReady = invokeI(__functionAddress) != 0;
}
return isGLFWReady;
}
public static void glfwTerminate() {
mGLFWIsInputReady = false;
CallbackBridge.nativeSetInputReady(false);
long __functionAddress = Functions.Terminate;
invokeV(__functionAddress);
}
public static void glfwInitHint(int hint, int value) { }
public static int glfwGetPlatform() {
return GLFW_PLATFORM_X11;
}
@NativeType("GLFWwindow *")
public static long glfwGetCurrentContext() {
long __functionAddress = Functions.GetCurrentContext;
return invokeP(__functionAddress);
}
public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height) {
if (CHECKS) {
checkSafe(width, 1);
checkSafe(height, 1);
}
width.put(internalGetWindow(window).width);
height.put(internalGetWindow(window).height);
}
@Nullable
@NativeType("GLFWmonitor **")
public static PointerBuffer glfwGetMonitors() {
PointerBuffer pBuffer = PointerBuffer.allocateDirect(1);
pBuffer.put(glfwGetPrimaryMonitor());
return pBuffer;
}
public static long glfwGetPrimaryMonitor() {
// Prevent NULL check
return 1L;
}
public static void glfwGetMonitorPos(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") IntBuffer xpos, @Nullable @NativeType("int *") IntBuffer ypos) {
if (CHECKS) {
checkSafe(xpos, 1);
checkSafe(ypos, 1);
}
xpos.put(0);
ypos.put(0);
}
public static void glfwGetMonitorWorkarea(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") IntBuffer xpos, @Nullable @NativeType("int *") IntBuffer ypos, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height) {
if (CHECKS) {
checkSafe(xpos, 1);
checkSafe(ypos, 1);
checkSafe(width, 1);
checkSafe(height, 1);
}
xpos.put(0);
ypos.put(0);
width.put(mGLFWWindowWidth);
height.put(mGLFWWindowHeight);
}
@NativeType("GLFWmonitor *")
public static long glfwGetWindowMonitor(@NativeType("GLFWwindow *") long window) {
return mGLFWWindowMonitor;
}
public static void glfwSetWindowMonitor(@NativeType("GLFWwindow *") long window, @NativeType("GLFWmonitor *") long monitor, int xpos, int ypos, int width, int height, int refreshRate) {
// weird calculation to fake pointer
mGLFWWindowMonitor = window * monitor;
}
public static int glfwGetWindowAttrib(@NativeType("GLFWwindow *") long window, int attrib) {
return internalGetWindow(window).windowAttribs.getOrDefault(attrib, 0);
}
public static void glfwSetWindowAttrib(@NativeType("GLFWwindow *") long window, int attrib, int value) {
internalGetWindow(window).windowAttribs.put(attrib, value);
}
public static void glfwGetVersion(IntBuffer major, IntBuffer minor, IntBuffer rev) {
if (CHECKS) {
checkSafe(major, 1);
checkSafe(minor, 1);
checkSafe(rev, 1);
}
major.put(GLFW_VERSION_MAJOR);
minor.put(GLFW_VERSION_MINOR);
rev.put(GLFW_VERSION_REVISION);
}
public static String glfwGetVersionString() {
return GLFW_VERSION_MAJOR + "." + GLFW_VERSION_MINOR + "." + GLFW_VERSION_REVISION;
}
public static int glfwGetError(@Nullable PointerBuffer description) {
return GLFW_NO_ERROR;
}
@Nullable
@NativeType("GLFWvidmode const *")
public static GLFWVidMode.Buffer glfwGetVideoModes(@NativeType("GLFWmonitor *") long monitor) {
MemoryStack stack = stackGet(); int stackPointer = stack.getPointer();
try {
// long __result = nglfwGetVideoModes(monitor, memAddress(count));
long __result = glfwGetVideoMode(monitor).address();
return GLFWVidMode.createSafe(__result, 1);
} finally {
stack.setPointer(stackPointer);
}
}
@Nullable
public static GLFWVidMode glfwGetVideoMode(long monitor) {
return mGLFWVideoMode;
}
public static GLFWGammaRamp glfwGetGammaRamp(@NativeType("GLFWmonitor *") long monitor) {
return mGLFWGammaRamp;
}
public static void glfwSetGammaRamp(@NativeType("GLFWmonitor *") long monitor, @NativeType("const GLFWgammaramp *") GLFWGammaRamp ramp) {
mGLFWGammaRamp = ramp;
}
public static void glfwMakeContextCurrent(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.MakeContextCurrent;
invokePV(window, __functionAddress);
}
public static void glfwSwapBuffers(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.SwapBuffers;
invokePV(window, __functionAddress);
}
public static void glfwSwapInterval(int interval) {
long __functionAddress = Functions.SwapInterval;
invokeV(interval, __functionAddress);
}
// private static double mTime = 0d;
public static double glfwGetTime() {
// Boardwalk: just use system timer
// System.out.println("glfwGetTime");
return (System.nanoTime() - mGLFWInitialTime) / 1.e9;
}
public static void glfwSetTime(double time) {
mGLFWInitialTime = System.nanoTime() - (long) time;
}
public static long glfwGetTimerValue() {
return System.currentTimeMillis();
}
public static long glfwGetTimerFrequency() {
// FIXME set correct value!!
return 60;
}
// GLFW Window functions
public static long nglfwCreateContext(long share) {
return invokePP(share, Functions.CreateContext);
}
public static long glfwCreateWindow(int width, int height, CharSequence title, long monitor, long share) {
// Create an ACTUAL EGL context
long ptr = nglfwCreateContext(share);
//nativeEglMakeCurrent(ptr);
GLFWWindowProperties win = new GLFWWindowProperties();
// win.width = width;
// win.height = height;