-
Notifications
You must be signed in to change notification settings - Fork 9
/
raylib.c
12167 lines (9979 loc) · 416 KB
/
raylib.c
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
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Joseph Montanez |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/* If defined, the following flags inhibit definition of the indicated items.*/
#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_
#define NOVIRTUALKEYCODES // VK_*
#define NOWINMESSAGES // WM_*, EM_*, LB_*, CB_*
#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
#define NOSYSMETRICS // SM_*
#define NOMENUS // MF_*
#define NOICONS // IDI_*
#define NOKEYSTATES // MK_*
#define NOSYSCOMMANDS // SC_*
#define NORASTEROPS // Binary and Tertiary raster ops
#define NOSHOWWINDOW // SW_*
#define OEMRESOURCE // OEM Resource values
#define NOATOM // Atom Manager routines
#define NOCLIPBOARD // Clipboard routines
#define NOCOLOR // Screen colors
#define NOCTLMGR // Control and Dialog routines
#define NODRAWTEXT // DrawText() and DT_*
#define NOGDI // All GDI defines and routines
#define NOKERNEL // All KERNEL defines and routines
#define NOUSER // All USER defines and routines
/*#define NONLS // All NLS defines and routines*/
#define NOMB // MB_* and MessageBox()
#define NOMEMMGR // GMEM_*, LMEM_*, GHND, LHND, associated routines
#define NOMETAFILE // typedef METAFILEPICT
#define NOMINMAX // Macros min(a,b) and max(a,b)
#define NOMSG // typedef MSG and associated routines
#define NOOPENFILE // OpenFile(), OemToAnsi, AnsiToOem, and OF_*
#define NOSCROLL // SB_* and scrolling routines
#define NOSERVICE // All Service Controller routines, SERVICE_ equates, etc.
#define NOSOUND // Sound driver routines
#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines
#define NOWH // SetWindowsHook and WH_*
#define NOWINOFFSETS // GWL_*, GCL_*, associated routines
#define NOCOMM // COMM driver routines
#define NOKANJI // Kanji support stuff.
#define NOHELP // Help engine interface.
#define NOPROFILER // Profiler interface.
#define NODEFERWINDOWPOS // DeferWindowPos routines
#define NOMCX // Modem Configuration Extensions
#define VC_EXTRALEAN // Maybe fix?
#define WIN32_LEAN_AND_MEAN // Maybe fix?
/* Type required before windows.h inclusion */
typedef struct tagMSG* LPMSG;
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php_raylib.h"
#include "vector2.h"
#include "vector3.h"
#include "vector4.h"
#include "matrix.h"
#include "color.h"
#include "rectangle.h"
#include "image.h"
#include "texture.h"
#include "rendertexture.h"
#include "npatchinfo.h"
#include "glyphinfo.h"
#include "font.h"
#include "camera3d.h"
#include "camera2d.h"
#include "mesh.h"
#include "shader.h"
#include "materialmap.h"
#include "material.h"
#include "transform.h"
#include "boneinfo.h"
#include "model.h"
#include "modelanimation.h"
#include "ray.h"
#include "raycollision.h"
#include "boundingbox.h"
#include "wave.h"
#include "audiostream.h"
#include "sound.h"
#include "music.h"
#include "vrdeviceinfo.h"
#include "vrstereoconfig.h"
#include "filepathlist.h"
#include "texture.h"
#include "texture.h"
#include "rendertexture.h"
#include "camera3d.h"
#include "vector4.h"
ZEND_BEGIN_ARG_INFO_EX(arginfo_confirm_raylib_compiled, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(confirm_raylib_compiled)
{
char *arg = NULL;
size_t arg_len;
// size_t arg_len, len;
zend_string *strg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &arg, &arg_len) == FAILURE) {
return;
}
strg = strpprintf(0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "raylib", arg);
RETURN_STR(strg);
}
// Initialize window and OpenGL context
// RLAPI void InitWindow(int width, int height, const char * title);
ZEND_BEGIN_ARG_INFO_EX(arginfo_InitWindow, 0, 0, 3)
ZEND_ARG_INFO(0, width)
ZEND_ARG_INFO(0, height)
ZEND_ARG_INFO(0, title)
ZEND_END_ARG_INFO()
PHP_FUNCTION(InitWindow)
{
zend_long width;
zend_long height;
zend_string *title;
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_LONG(width)
Z_PARAM_LONG(height)
Z_PARAM_STR(title)
ZEND_PARSE_PARAMETERS_END();
InitWindow((width <= INT_MAX) ? (int) ((zend_long) width) : -1, (height <= INT_MAX) ? (int) ((zend_long) height) : -1, title->val);
}
// Check if KEY_ESCAPE pressed or Close icon pressed
// RLAPI bool WindowShouldClose();
ZEND_BEGIN_ARG_INFO_EX(arginfo_WindowShouldClose, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(WindowShouldClose)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(WindowShouldClose());
}
// Close window and unload OpenGL context
// RLAPI void CloseWindow();
ZEND_BEGIN_ARG_INFO_EX(arginfo_CloseWindow, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(CloseWindow)
{
ZEND_PARSE_PARAMETERS_NONE();
CloseWindow();
}
// Check if window has been initialized successfully
// RLAPI bool IsWindowReady();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowReady, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowReady)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsWindowReady());
}
// Check if window is currently fullscreen
// RLAPI bool IsWindowFullscreen();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowFullscreen, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowFullscreen)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsWindowFullscreen());
}
// Check if window is currently hidden (only PLATFORM_DESKTOP)
// RLAPI bool IsWindowHidden();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowHidden, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowHidden)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsWindowHidden());
}
// Check if window is currently minimized (only PLATFORM_DESKTOP)
// RLAPI bool IsWindowMinimized();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowMinimized, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowMinimized)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsWindowMinimized());
}
// Check if window is currently maximized (only PLATFORM_DESKTOP)
// RLAPI bool IsWindowMaximized();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowMaximized, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowMaximized)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsWindowMaximized());
}
// Check if window is currently focused (only PLATFORM_DESKTOP)
// RLAPI bool IsWindowFocused();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowFocused, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowFocused)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsWindowFocused());
}
// Check if window has been resized last frame
// RLAPI bool IsWindowResized();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowResized, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowResized)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsWindowResized());
}
// Check if one specific window flag is enabled
// RLAPI bool IsWindowState(unsigned int flag);
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsWindowState, 0, 0, 1)
ZEND_ARG_INFO(0, flag)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsWindowState)
{
zend_long flag;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(flag)
ZEND_PARSE_PARAMETERS_END();
RETURN_BOOL(IsWindowState((flag <= INT_MAX) ? (int) ((zend_long) flag) : -1));
}
// Set window configuration state using flags (only PLATFORM_DESKTOP)
// RLAPI void SetWindowState(unsigned int flags);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowState, 0, 0, 1)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowState)
{
zend_long flags;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(flags)
ZEND_PARSE_PARAMETERS_END();
SetWindowState((flags <= INT_MAX) ? (int) ((zend_long) flags) : -1);
}
// Clear window configuration state flags
// RLAPI void ClearWindowState(unsigned int flags);
ZEND_BEGIN_ARG_INFO_EX(arginfo_ClearWindowState, 0, 0, 1)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
PHP_FUNCTION(ClearWindowState)
{
zend_long flags;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(flags)
ZEND_PARSE_PARAMETERS_END();
ClearWindowState((flags <= INT_MAX) ? (int) ((zend_long) flags) : -1);
}
// Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
// RLAPI void ToggleFullscreen();
ZEND_BEGIN_ARG_INFO_EX(arginfo_ToggleFullscreen, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(ToggleFullscreen)
{
ZEND_PARSE_PARAMETERS_NONE();
ToggleFullscreen();
}
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
// RLAPI void MaximizeWindow();
ZEND_BEGIN_ARG_INFO_EX(arginfo_MaximizeWindow, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(MaximizeWindow)
{
ZEND_PARSE_PARAMETERS_NONE();
MaximizeWindow();
}
// Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
// RLAPI void MinimizeWindow();
ZEND_BEGIN_ARG_INFO_EX(arginfo_MinimizeWindow, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(MinimizeWindow)
{
ZEND_PARSE_PARAMETERS_NONE();
MinimizeWindow();
}
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
// RLAPI void RestoreWindow();
ZEND_BEGIN_ARG_INFO_EX(arginfo_RestoreWindow, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(RestoreWindow)
{
ZEND_PARSE_PARAMETERS_NONE();
RestoreWindow();
}
// Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
// RLAPI void SetWindowIcon(Image image);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowIcon, 0, 0, 1)
ZEND_ARG_INFO(0, image)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowIcon)
{
zval *image;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(image)
ZEND_PARSE_PARAMETERS_END();
php_raylib_image_object *phpImage = Z_IMAGE_OBJ_P(image);
SetWindowIcon(*php_raylib_image_fetch_data(phpImage));
}
// Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
// RLAPI void SetWindowIcons(Image* images, int count);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowIcons, 0, 0, 2)
ZEND_ARG_INFO(0, images)
ZEND_ARG_INFO(0, count)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowIcons)
{
zval *images;
zend_long count;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ARRAY(images)
Z_PARAM_LONG(count)
ZEND_PARSE_PARAMETERS_END();
zval *images_element;
int images_index;
HashTable *images_hash = Z_ARRVAL_P(images);
SEPARATE_ARRAY(images);
int images_count = zend_hash_num_elements(images_hash);
Image* images_array = safe_emalloc(sizeof(Image*), images_count, 0);
ZEND_HASH_FOREACH_VAL(images_hash, images_element) {
ZVAL_DEREF(images_element);
if ((Z_TYPE_P(images_element) == IS_OBJECT && instanceof_function(Z_OBJCE_P(images_element), php_raylib_image_ce))) {
php_raylib_image_object *image_obj = Z_IMAGE_OBJ_P(images_element);
images_array[images_index] = *php_raylib_image_fetch_data(image_obj);
}
images_index++;
} ZEND_HASH_FOREACH_END();
SetWindowIcons(images_array, (count <= INT_MAX) ? (int) ((zend_long) count) : -1);
}
// Set title for window (only PLATFORM_DESKTOP)
// RLAPI void SetWindowTitle(const char * title);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowTitle, 0, 0, 1)
ZEND_ARG_INFO(0, title)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowTitle)
{
zend_string *title;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STR(title)
ZEND_PARSE_PARAMETERS_END();
SetWindowTitle(title->val);
}
// Set window position on screen (only PLATFORM_DESKTOP)
// RLAPI void SetWindowPosition(int x, int y);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowPosition, 0, 0, 2)
ZEND_ARG_INFO(0, x)
ZEND_ARG_INFO(0, y)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowPosition)
{
zend_long x;
zend_long y;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG(x)
Z_PARAM_LONG(y)
ZEND_PARSE_PARAMETERS_END();
SetWindowPosition((x <= INT_MAX) ? (int) ((zend_long) x) : -1, (y <= INT_MAX) ? (int) ((zend_long) y) : -1);
}
// Set monitor for the current window (fullscreen mode)
// RLAPI void SetWindowMonitor(int monitor);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowMonitor, 0, 0, 1)
ZEND_ARG_INFO(0, monitor)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowMonitor)
{
zend_long monitor;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(monitor)
ZEND_PARSE_PARAMETERS_END();
SetWindowMonitor((monitor <= INT_MAX) ? (int) ((zend_long) monitor) : -1);
}
// Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
// RLAPI void SetWindowMinSize(int width, int height);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowMinSize, 0, 0, 2)
ZEND_ARG_INFO(0, width)
ZEND_ARG_INFO(0, height)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowMinSize)
{
zend_long width;
zend_long height;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG(width)
Z_PARAM_LONG(height)
ZEND_PARSE_PARAMETERS_END();
SetWindowMinSize((width <= INT_MAX) ? (int) ((zend_long) width) : -1, (height <= INT_MAX) ? (int) ((zend_long) height) : -1);
}
// Set window dimensions
// RLAPI void SetWindowSize(int width, int height);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetWindowSize, 0, 0, 2)
ZEND_ARG_INFO(0, width)
ZEND_ARG_INFO(0, height)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetWindowSize)
{
zend_long width;
zend_long height;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG(width)
Z_PARAM_LONG(height)
ZEND_PARSE_PARAMETERS_END();
SetWindowSize((width <= INT_MAX) ? (int) ((zend_long) width) : -1, (height <= INT_MAX) ? (int) ((zend_long) height) : -1);
}
// Get current screen width
// RLAPI int GetScreenWidth();
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetScreenWidth, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetScreenWidth)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_LONG(GetScreenWidth());
}
// Get current screen height
// RLAPI int GetScreenHeight();
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetScreenHeight, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetScreenHeight)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_LONG(GetScreenHeight());
}
// Get number of connected monitors
// RLAPI int GetMonitorCount();
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetMonitorCount, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetMonitorCount)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_LONG(GetMonitorCount());
}
// Get current connected monitor
// RLAPI int GetCurrentMonitor();
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetCurrentMonitor, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetCurrentMonitor)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_LONG(GetCurrentMonitor());
}
// Get specified monitor position
// RLAPI Vector2 GetMonitorPosition(int monitor);
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetMonitorPosition, 0, 0, 1)
ZEND_ARG_INFO(0, monitor)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetMonitorPosition)
{
zend_long monitor;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(monitor)
ZEND_PARSE_PARAMETERS_END();
Vector2 originalResult = GetMonitorPosition((monitor <= INT_MAX) ? (int) ((zend_long) monitor) : -1);
zend_object *result = php_raylib_vector2_new_ex(php_raylib_vector2_ce, NULL);
php_raylib_vector2_object *phpResult = php_raylib_vector2_fetch_object(result);
Vector2 *vector2Data = php_raylib_vector2_fetch_data(phpResult);
// Dereference vector2Data for assignment back to object
*vector2Data = originalResult;
RETURN_OBJ(&phpResult->std);
}
// Get specified monitor width (current video mode used by monitor)
// RLAPI int GetMonitorWidth(int monitor);
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetMonitorWidth, 0, 0, 1)
ZEND_ARG_INFO(0, monitor)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetMonitorWidth)
{
zend_long monitor;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(monitor)
ZEND_PARSE_PARAMETERS_END();
RETURN_LONG(GetMonitorWidth((monitor <= INT_MAX) ? (int) ((zend_long) monitor) : -1));
}
// Get specified monitor height (current video mode used by monitor)
// RLAPI int GetMonitorHeight(int monitor);
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetMonitorHeight, 0, 0, 1)
ZEND_ARG_INFO(0, monitor)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetMonitorHeight)
{
zend_long monitor;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(monitor)
ZEND_PARSE_PARAMETERS_END();
RETURN_LONG(GetMonitorHeight((monitor <= INT_MAX) ? (int) ((zend_long) monitor) : -1));
}
// Get specified monitor physical width in millimetres
// RLAPI int GetMonitorPhysicalWidth(int monitor);
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetMonitorPhysicalWidth, 0, 0, 1)
ZEND_ARG_INFO(0, monitor)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetMonitorPhysicalWidth)
{
zend_long monitor;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(monitor)
ZEND_PARSE_PARAMETERS_END();
RETURN_LONG(GetMonitorPhysicalWidth((monitor <= INT_MAX) ? (int) ((zend_long) monitor) : -1));
}
// Get specified monitor physical height in millimetres
// RLAPI int GetMonitorPhysicalHeight(int monitor);
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetMonitorPhysicalHeight, 0, 0, 1)
ZEND_ARG_INFO(0, monitor)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetMonitorPhysicalHeight)
{
zend_long monitor;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(monitor)
ZEND_PARSE_PARAMETERS_END();
RETURN_LONG(GetMonitorPhysicalHeight((monitor <= INT_MAX) ? (int) ((zend_long) monitor) : -1));
}
// Get specified monitor refresh rate
// RLAPI int GetMonitorRefreshRate(int monitor);
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetMonitorRefreshRate, 0, 0, 1)
ZEND_ARG_INFO(0, monitor)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetMonitorRefreshRate)
{
zend_long monitor;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(monitor)
ZEND_PARSE_PARAMETERS_END();
RETURN_LONG(GetMonitorRefreshRate((monitor <= INT_MAX) ? (int) ((zend_long) monitor) : -1));
}
// Get window position XY on monitor
// RLAPI Vector2 GetWindowPosition();
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetWindowPosition, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetWindowPosition)
{
ZEND_PARSE_PARAMETERS_NONE();
Vector2 originalResult = GetWindowPosition();
zend_object *result = php_raylib_vector2_new_ex(php_raylib_vector2_ce, NULL);
php_raylib_vector2_object *phpResult = php_raylib_vector2_fetch_object(result);
Vector2 *vector2Data = php_raylib_vector2_fetch_data(phpResult);
// Dereference vector2Data for assignment back to object
*vector2Data = originalResult;
RETURN_OBJ(&phpResult->std);
}
// Get window scale DPI factor
// RLAPI Vector2 GetWindowScaleDPI();
ZEND_BEGIN_ARG_INFO_EX(arginfo_GetWindowScaleDPI, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(GetWindowScaleDPI)
{
ZEND_PARSE_PARAMETERS_NONE();
Vector2 originalResult = GetWindowScaleDPI();
zend_object *result = php_raylib_vector2_new_ex(php_raylib_vector2_ce, NULL);
php_raylib_vector2_object *phpResult = php_raylib_vector2_fetch_object(result);
Vector2 *vector2Data = php_raylib_vector2_fetch_data(phpResult);
// Dereference vector2Data for assignment back to object
*vector2Data = originalResult;
RETURN_OBJ(&phpResult->std);
}
// Set clipboard text content
// RLAPI void SetClipboardText(const char * text);
ZEND_BEGIN_ARG_INFO_EX(arginfo_SetClipboardText, 0, 0, 1)
ZEND_ARG_INFO(0, text)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SetClipboardText)
{
zend_string *text;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STR(text)
ZEND_PARSE_PARAMETERS_END();
SetClipboardText(text->val);
}
// Enable waiting for events on EndDrawing(), no automatic event polling
// RLAPI void EnableEventWaiting();
ZEND_BEGIN_ARG_INFO_EX(arginfo_EnableEventWaiting, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(EnableEventWaiting)
{
ZEND_PARSE_PARAMETERS_NONE();
EnableEventWaiting();
}
// Disable waiting for events on EndDrawing(), automatic events polling
// RLAPI void DisableEventWaiting();
ZEND_BEGIN_ARG_INFO_EX(arginfo_DisableEventWaiting, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(DisableEventWaiting)
{
ZEND_PARSE_PARAMETERS_NONE();
DisableEventWaiting();
}
// Swap back buffer with front buffer (screen drawing)
// RLAPI void SwapScreenBuffer();
ZEND_BEGIN_ARG_INFO_EX(arginfo_SwapScreenBuffer, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SwapScreenBuffer)
{
ZEND_PARSE_PARAMETERS_NONE();
SwapScreenBuffer();
}
// Register all input events
// RLAPI void PollInputEvents();
ZEND_BEGIN_ARG_INFO_EX(arginfo_PollInputEvents, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(PollInputEvents)
{
ZEND_PARSE_PARAMETERS_NONE();
PollInputEvents();
}
// Wait for some time (halt program execution)
// RLAPI void WaitTime(double seconds);
ZEND_BEGIN_ARG_INFO_EX(arginfo_WaitTime, 0, 0, 1)
ZEND_ARG_INFO(0, seconds)
ZEND_END_ARG_INFO()
PHP_FUNCTION(WaitTime)
{
double seconds;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_DOUBLE(seconds)
ZEND_PARSE_PARAMETERS_END();
WaitTime((double) seconds);
}
// Shows cursor
// RLAPI void ShowCursor();
ZEND_BEGIN_ARG_INFO_EX(arginfo_ShowCursor, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(ShowCursor)
{
ZEND_PARSE_PARAMETERS_NONE();
ShowCursor();
}
// Hides cursor
// RLAPI void HideCursor();
ZEND_BEGIN_ARG_INFO_EX(arginfo_HideCursor, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(HideCursor)
{
ZEND_PARSE_PARAMETERS_NONE();
HideCursor();
}
// Check if cursor is not visible
// RLAPI bool IsCursorHidden();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsCursorHidden, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsCursorHidden)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsCursorHidden());
}
// Enables cursor (unlock cursor)
// RLAPI void EnableCursor();
ZEND_BEGIN_ARG_INFO_EX(arginfo_EnableCursor, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(EnableCursor)
{
ZEND_PARSE_PARAMETERS_NONE();
EnableCursor();
}
// Disables cursor (lock cursor)
// RLAPI void DisableCursor();
ZEND_BEGIN_ARG_INFO_EX(arginfo_DisableCursor, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(DisableCursor)
{
ZEND_PARSE_PARAMETERS_NONE();
DisableCursor();
}
// Check if cursor is on the screen
// RLAPI bool IsCursorOnScreen();
ZEND_BEGIN_ARG_INFO_EX(arginfo_IsCursorOnScreen, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(IsCursorOnScreen)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(IsCursorOnScreen());
}
// Set background color (framebuffer clear color)
// RLAPI void ClearBackground(Color color);
ZEND_BEGIN_ARG_INFO_EX(arginfo_ClearBackground, 0, 0, 1)
ZEND_ARG_INFO(0, color)
ZEND_END_ARG_INFO()
PHP_FUNCTION(ClearBackground)
{
zval *color;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(color)
ZEND_PARSE_PARAMETERS_END();
php_raylib_color_object *phpColor = Z_COLOR_OBJ_P(color);
ClearBackground(*php_raylib_color_fetch_data(phpColor));
}
// Setup canvas (framebuffer) to start drawing
// RLAPI void BeginDrawing();
ZEND_BEGIN_ARG_INFO_EX(arginfo_BeginDrawing, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(BeginDrawing)
{
ZEND_PARSE_PARAMETERS_NONE();
BeginDrawing();
}
// End canvas drawing and swap buffers (double buffering)
// RLAPI void EndDrawing();
ZEND_BEGIN_ARG_INFO_EX(arginfo_EndDrawing, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(EndDrawing)
{
ZEND_PARSE_PARAMETERS_NONE();
EndDrawing();
}
// Begin 2D mode with custom camera (2D)
// RLAPI void BeginMode2D(Camera2D camera);
ZEND_BEGIN_ARG_INFO_EX(arginfo_BeginMode2D, 0, 0, 1)
ZEND_ARG_INFO(0, camera)
ZEND_END_ARG_INFO()
PHP_FUNCTION(BeginMode2D)
{
zval *camera;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(camera)
ZEND_PARSE_PARAMETERS_END();
php_raylib_camera2d_object *phpCamera = Z_CAMERA2D_OBJ_P(camera);
BeginMode2D(*php_raylib_camera2d_fetch_data(phpCamera));
}
// Ends 2D mode with custom camera
// RLAPI void EndMode2D();
ZEND_BEGIN_ARG_INFO_EX(arginfo_EndMode2D, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(EndMode2D)
{
ZEND_PARSE_PARAMETERS_NONE();
EndMode2D();
}
// Begin 3D mode with custom camera (3D)
// RLAPI void BeginMode3D(Camera3D camera);
ZEND_BEGIN_ARG_INFO_EX(arginfo_BeginMode3D, 0, 0, 1)
ZEND_ARG_INFO(0, camera)
ZEND_END_ARG_INFO()
PHP_FUNCTION(BeginMode3D)
{
zval *camera;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(camera)
ZEND_PARSE_PARAMETERS_END();
php_raylib_camera3d_object *phpCamera = Z_CAMERA3D_OBJ_P(camera);
BeginMode3D(*php_raylib_camera3d_fetch_data(phpCamera));
}
// Ends 3D mode and returns to default 2D orthographic mode
// RLAPI void EndMode3D();
ZEND_BEGIN_ARG_INFO_EX(arginfo_EndMode3D, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(EndMode3D)
{
ZEND_PARSE_PARAMETERS_NONE();
EndMode3D();
}
// Begin drawing to render texture
// RLAPI void BeginTextureMode(RenderTexture target);
ZEND_BEGIN_ARG_INFO_EX(arginfo_BeginTextureMode, 0, 0, 1)
ZEND_ARG_INFO(0, target)
ZEND_END_ARG_INFO()
PHP_FUNCTION(BeginTextureMode)
{
zval *target;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(target)
ZEND_PARSE_PARAMETERS_END();