-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfunc.h
More file actions
3209 lines (2937 loc) · 90.5 KB
/
func.h
File metadata and controls
3209 lines (2937 loc) · 90.5 KB
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
//
// Change working directory, return true on success
//
static int cmd_changedirectory(int argc, slib_par_t *params, var_t *retval) {
auto dir = get_param_str(argc, params, 0, 0);
auto fnResult = ChangeDirectory(dir);
v_setint(retval, fnResult);
return 1;
}
//
// Check collision between two bounding boxes
//
static int cmd_checkcollisionboxes(int argc, slib_par_t *params, var_t *retval) {
auto box1 = get_param_bounding_box(argc, params, 0);
auto box2 = get_param_bounding_box(argc, params, 1);
auto fnResult = CheckCollisionBoxes(box1, box2);
v_setint(retval, fnResult);
return 1;
}
//
// Check collision between box and sphere
//
static int cmd_checkcollisionboxsphere(int argc, slib_par_t *params, var_t *retval) {
auto box = get_param_bounding_box(argc, params, 0);
auto center = get_param_vec3(argc, params, 1);
auto radius = get_param_num(argc, params, 2, 0);
auto fnResult = CheckCollisionBoxSphere(box, center, radius);
v_setint(retval, fnResult);
return 1;
}
//
// Check if circle collides with a line created betweeen two points [p1] and [p2]
//
static int cmd_checkcollisioncircleline(int argc, slib_par_t *params, var_t *retval) {
auto center = get_param_vec2(argc, params, 0);
auto radius = get_param_num(argc, params, 1, 0);
auto p1 = get_param_vec2(argc, params, 2);
auto p2 = get_param_vec2(argc, params, 3);
auto fnResult = CheckCollisionCircleLine(center, radius, p1, p2);
v_setint(retval, fnResult);
return 1;
}
//
// Check collision between circle and rectangle
//
static int cmd_checkcollisioncirclerec(int argc, slib_par_t *params, var_t *retval) {
auto center = get_param_vec2(argc, params, 0);
auto radius = get_param_num(argc, params, 1, 0);
auto rec = get_param_rect(argc, params, 2);
auto fnResult = CheckCollisionCircleRec(center, radius, rec);
v_setint(retval, fnResult);
return 1;
}
//
// Check collision between two circles
//
static int cmd_checkcollisioncircles(int argc, slib_par_t *params, var_t *retval) {
auto center1 = get_param_vec2(argc, params, 0);
auto radius1 = get_param_num(argc, params, 1, 0);
auto center2 = get_param_vec2(argc, params, 2);
auto radius2 = get_param_num(argc, params, 3, 0);
auto fnResult = CheckCollisionCircles(center1, radius1, center2, radius2);
v_setint(retval, fnResult);
return 1;
}
//
// Check the collision between two lines defined by two points each, returns collision point by reference
//
static int cmd_checkcollisionlines(int argc, slib_par_t *params, var_t *retval) {
auto startPos1 = get_param_vec2(argc, params, 0);
auto endPos1 = get_param_vec2(argc, params, 1);
auto startPos2 = get_param_vec2(argc, params, 2);
auto endPos2 = get_param_vec2(argc, params, 3);
auto collisionPoint = (Vector2 *)get_param_vec2_array(argc, params, 4);
auto fnResult = CheckCollisionLines(startPos1, endPos1, startPos2, endPos2, collisionPoint);
v_setint(retval, fnResult);
return 1;
}
//
// Check if point is inside circle
//
static int cmd_checkcollisionpointcircle(int argc, slib_par_t *params, var_t *retval) {
auto point = get_param_vec2(argc, params, 0);
auto center = get_param_vec2(argc, params, 1);
auto radius = get_param_num(argc, params, 2, 0);
auto fnResult = CheckCollisionPointCircle(point, center, radius);
v_setint(retval, fnResult);
return 1;
}
//
// Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
//
static int cmd_checkcollisionpointline(int argc, slib_par_t *params, var_t *retval) {
auto point = get_param_vec2(argc, params, 0);
auto p1 = get_param_vec2(argc, params, 1);
auto p2 = get_param_vec2(argc, params, 2);
auto threshold = get_param_int(argc, params, 3, 0);
auto fnResult = CheckCollisionPointLine(point, p1, p2, threshold);
v_setint(retval, fnResult);
return 1;
}
//
// Check if point is within a polygon described by array of vertices
//
static int cmd_checkcollisionpointpoly(int argc, slib_par_t *params, var_t *retval) {
auto point = get_param_vec2(argc, params, 0);
auto points = (Vector2 *)get_param_vec2_array(argc, params, 1);
auto pointCount = get_param_int(argc, params, 2, 0);
auto fnResult = CheckCollisionPointPoly(point, points, pointCount);
v_setint(retval, fnResult);
return 1;
}
//
// Check if point is inside rectangle
//
static int cmd_checkcollisionpointrec(int argc, slib_par_t *params, var_t *retval) {
auto point = get_param_vec2(argc, params, 0);
auto rec = get_param_rect(argc, params, 1);
auto fnResult = CheckCollisionPointRec(point, rec);
v_setint(retval, fnResult);
return 1;
}
//
// Check if point is inside a triangle
//
static int cmd_checkcollisionpointtriangle(int argc, slib_par_t *params, var_t *retval) {
auto point = get_param_vec2(argc, params, 0);
auto p1 = get_param_vec2(argc, params, 1);
auto p2 = get_param_vec2(argc, params, 2);
auto p3 = get_param_vec2(argc, params, 3);
auto fnResult = CheckCollisionPointTriangle(point, p1, p2, p3);
v_setint(retval, fnResult);
return 1;
}
//
// Check collision between two rectangles
//
static int cmd_checkcollisionrecs(int argc, slib_par_t *params, var_t *retval) {
auto rec1 = get_param_rect(argc, params, 0);
auto rec2 = get_param_rect(argc, params, 1);
auto fnResult = CheckCollisionRecs(rec1, rec2);
v_setint(retval, fnResult);
return 1;
}
//
// Check collision between two spheres
//
static int cmd_checkcollisionspheres(int argc, slib_par_t *params, var_t *retval) {
auto center1 = get_param_vec3(argc, params, 0);
auto radius1 = get_param_num(argc, params, 1, 0);
auto center2 = get_param_vec3(argc, params, 2);
auto radius2 = get_param_num(argc, params, 3, 0);
auto fnResult = CheckCollisionSpheres(center1, radius1, center2, radius2);
v_setint(retval, fnResult);
return 1;
}
//
// Encode one codepoint into UTF-8 byte array (array length returned as parameter)
//
static int cmd_codepointtoutf8(int argc, slib_par_t *params, var_t *retval) {
auto codepoint = get_param_int(argc, params, 0, 0);
auto utf8Size = 0;
auto fnResult = (const char *)CodepointToUTF8(codepoint, &utf8Size);
v_setstrn(retval, fnResult, utf8Size);
MemFree((void *)fnResult);
return 1;
}
//
// Get color with alpha applied, alpha goes from 0.0f to 1.0f
//
static int cmd_coloralpha(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto alpha = get_param_num(argc, params, 1, 0);
auto fnResult = ColorAlpha(color, alpha);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get src alpha-blended into dst color with tint
//
static int cmd_coloralphablend(int argc, slib_par_t *params, var_t *retval) {
auto dst = get_param_color(argc, params, 0);
auto src = get_param_color(argc, params, 1);
auto tint = get_param_color(argc, params, 2);
auto fnResult = ColorAlphaBlend(dst, src, tint);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
//
static int cmd_colorbrightness(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto factor = get_param_num(argc, params, 1, 0);
auto fnResult = ColorBrightness(color, factor);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get color with contrast correction, contrast values between -1.0f and 1.0f
//
static int cmd_colorcontrast(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto contrast = get_param_num(argc, params, 1, 0);
auto fnResult = ColorContrast(color, contrast);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get a Color from HSV values, hue [0..360], saturation/value [0..1]
//
static int cmd_colorfromhsv(int argc, slib_par_t *params, var_t *retval) {
auto hue = get_param_num(argc, params, 0, 0);
auto saturation = get_param_num(argc, params, 1, 0);
auto value = get_param_num(argc, params, 2, 0);
auto fnResult = ColorFromHSV(hue, saturation, value);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get Color from normalized values [0..1]
//
static int cmd_colorfromnormalized(int argc, slib_par_t *params, var_t *retval) {
auto normalized = get_param_vec4(argc, params, 0);
auto fnResult = ColorFromNormalized(normalized);
v_setcolor(retval, fnResult);
return 1;
}
//
// Check if two colors are equal
//
static int cmd_colorisequal(int argc, slib_par_t *params, var_t *retval) {
auto col1 = get_param_color(argc, params, 0);
auto col2 = get_param_color(argc, params, 1);
auto fnResult = ColorIsEqual(col1, col2);
v_setint(retval, fnResult);
return 1;
}
//
// Get color lerp interpolation between two colors, factor [0.0f..1.0f]
//
static int cmd_colorlerp(int argc, slib_par_t *params, var_t *retval) {
auto color1 = get_param_color(argc, params, 0);
auto color2 = get_param_color(argc, params, 1);
auto factor = get_param_num(argc, params, 2, 0);
auto fnResult = ColorLerp(color1, color2, factor);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get Color normalized as float [0..1]
//
static int cmd_colornormalize(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto fnResult = ColorNormalize(color);
v_setvec4(retval, fnResult);
return 1;
}
//
// Get color multiplied with another color
//
static int cmd_colortint(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto tint = get_param_color(argc, params, 1);
auto fnResult = ColorTint(color, tint);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get HSV values for a Color, hue [0..360], saturation/value [0..1]
//
static int cmd_colortohsv(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto fnResult = ColorToHSV(color);
v_setvec3(retval, fnResult);
return 1;
}
//
// Get hexadecimal value for a Color (0xRRGGBBAA)
//
static int cmd_colortoint(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto fnResult = ColorToInt(color);
v_setint(retval, fnResult);
return 1;
}
//
// Compress data (DEFLATE algorithm), memory must be MemFree()
//
static int cmd_compressdata(int argc, slib_par_t *params, var_t *retval) {
auto data = (const unsigned char *)get_param_str(argc, params, 0, 0);
auto dataSize = get_param_int(argc, params, 1, 0);
auto compDataSize = 0;
auto fnResult = (const char *)CompressData(data, dataSize, &compDataSize);
v_setstrn(retval, fnResult, compDataSize);
MemFree((void *)fnResult);
return 1;
}
//
// Compute CRC32 hash code
//
static int cmd_computecrc32(int argc, slib_par_t *params, var_t *retval) {
auto data = (unsigned char *)get_param_str(argc, params, 0, 0);
auto dataSize = get_param_int(argc, params, 1, 0);
auto fnResult = ComputeCRC32(data, dataSize);
v_setint(retval, fnResult);
return 1;
}
//
// Compute MD5 hash code, returns static int[4] (16 bytes)
//
static int cmd_computemd5(int argc, slib_par_t *params, var_t *retval) {
auto data = (unsigned char *)get_param_str(argc, params, 0, 0);
auto dataSize = get_param_int(argc, params, 1, 0);
auto fnResult = (var_int_t)ComputeMD5(data, dataSize);
v_setint(retval, fnResult);
return 1;
}
//
// Compute SHA1 hash code, returns static int[5] (20 bytes)
//
static int cmd_computesha1(int argc, slib_par_t *params, var_t *retval) {
auto data = (unsigned char *)get_param_str(argc, params, 0, 0);
auto dataSize = get_param_int(argc, params, 1, 0);
auto fnResult = (var_int_t)ComputeSHA1(data, dataSize);
v_setint(retval, fnResult);
return 1;
}
//
// Decode Base64 string data, memory must be MemFree()
//
static int cmd_decodedatabase64(int argc, slib_par_t *params, var_t *retval) {
auto data = (const unsigned char *)get_param_str(argc, params, 0, 0);
auto outputSize = 0;
auto fnResult = (const char *)DecodeDataBase64(data, &outputSize);
v_setstrn(retval, fnResult, outputSize);
MemFree((void *)fnResult);
return 1;
}
//
// Decompress data (DEFLATE algorithm), memory must be MemFree()
//
static int cmd_decompressdata(int argc, slib_par_t *params, var_t *retval) {
auto compData = (const unsigned char *)get_param_str(argc, params, 0, 0);
auto compDataSize = get_param_int(argc, params, 1, 0);
auto dataSize = 0;
auto fnResult = (const char *)DecompressData(compData, compDataSize, &dataSize);
v_setstrn(retval, fnResult, dataSize);
MemFree((void *)fnResult);
return 1;
}
//
// Check if a directory path exists
//
static int cmd_directoryexists(int argc, slib_par_t *params, var_t *retval) {
auto dirPath = get_param_str(argc, params, 0, 0);
auto fnResult = DirectoryExists(dirPath);
v_setint(retval, fnResult);
return 1;
}
//
// Encode data to Base64 string, memory must be MemFree()
//
static int cmd_encodedatabase64(int argc, slib_par_t *params, var_t *retval) {
auto data = (const unsigned char *)get_param_str(argc, params, 0, 0);
auto dataSize = get_param_int(argc, params, 1, 0);
auto outputSize = 0;
auto fnResult = (const char *)EncodeDataBase64(data, dataSize, &outputSize);
v_setstrn(retval, fnResult, outputSize);
MemFree((void *)fnResult);
return 1;
}
//
// Export automation events list as text file
//
static int cmd_exportautomationeventlist(int argc, slib_par_t *params, var_t *retval) {
int result;
int list_id = get_automationeventlist_id(argc, params, 0, retval);
if (list_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportAutomationEventList(_automationEventListMap.at(list_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export data to code (.h), returns true on success
//
static int cmd_exportdataascode(int argc, slib_par_t *params, var_t *retval) {
auto data = (const unsigned char *)get_param_str(argc, params, 0, 0);
auto dataSize = get_param_int(argc, params, 1, 0);
auto fileName = get_param_str(argc, params, 2, 0);
auto fnResult = ExportDataAsCode(data, dataSize, fileName);
v_setint(retval, fnResult);
return 1;
}
//
// Export font as code file, returns true on success
//
static int cmd_exportfontascode(int argc, slib_par_t *params, var_t *retval) {
int result;
int font_id = get_font_id(argc, params, 0, retval);
if (font_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportFontAsCode(_fontMap.at(font_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export image data to file, returns true on success
//
static int cmd_exportimage(int argc, slib_par_t *params, var_t *retval) {
int result;
int image_id = get_image_id(argc, params, 0, retval);
if (image_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportImage(_imageMap.at(image_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export image as code file defining an array of bytes, returns true on success
//
static int cmd_exportimageascode(int argc, slib_par_t *params, var_t *retval) {
int result;
int image_id = get_image_id(argc, params, 0, retval);
if (image_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportImageAsCode(_imageMap.at(image_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export image to memory buffer
//
static int cmd_exportimagetomemory(int argc, slib_par_t *params, var_t *retval) {
int result;
int image_id = get_image_id(argc, params, 0, retval);
if (image_id != -1) {
auto fileType = get_param_str(argc, params, 1, 0);
auto fileSize = 0;
auto fnResult = (const char *)ExportImageToMemory(_imageMap.at(image_id), fileType, &fileSize);
v_setstrn(retval, fnResult, fileSize);
MemFree((void *)fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export mesh data to file, returns true on success
//
static int cmd_exportmesh(int argc, slib_par_t *params, var_t *retval) {
int result;
int mesh_id = get_mesh_id(argc, params, 0, retval);
if (mesh_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportMesh(_meshMap.at(mesh_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export mesh as code file (.h) defining multiple arrays of vertex attributes
//
static int cmd_exportmeshascode(int argc, slib_par_t *params, var_t *retval) {
int result;
int mesh_id = get_mesh_id(argc, params, 0, retval);
if (mesh_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportMeshAsCode(_meshMap.at(mesh_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export wave data to file, returns true on success
//
static int cmd_exportwave(int argc, slib_par_t *params, var_t *retval) {
int result;
int wave_id = get_wave_id(argc, params, 0, retval);
if (wave_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportWave(_waveMap.at(wave_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Export wave sample data to code (.h), returns true on success
//
static int cmd_exportwaveascode(int argc, slib_par_t *params, var_t *retval) {
int result;
int wave_id = get_wave_id(argc, params, 0, retval);
if (wave_id != -1) {
auto fileName = get_param_str(argc, params, 1, 0);
auto fnResult = ExportWaveAsCode(_waveMap.at(wave_id), fileName);
v_setint(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Get color with alpha applied, alpha goes from 0.0f to 1.0f
//
static int cmd_fade(int argc, slib_par_t *params, var_t *retval) {
auto color = get_param_color(argc, params, 0);
auto alpha = get_param_num(argc, params, 1, 0);
auto fnResult = Fade(color, alpha);
v_setcolor(retval, fnResult);
return 1;
}
//
// Check if file exists
//
static int cmd_fileexists(int argc, slib_par_t *params, var_t *retval) {
auto fileName = get_param_str(argc, params, 0, 0);
auto fnResult = FileExists(fileName);
v_setint(retval, fnResult);
return 1;
}
//
// Generate image: cellular algorithm, bigger tileSize means bigger cells
//
static int cmd_genimagecellular(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto tileSize = get_param_int(argc, params, 2, 0);
auto fnResult = GenImageCellular(width, height, tileSize);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: checked
//
static int cmd_genimagechecked(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto checksX = get_param_int(argc, params, 2, 0);
auto checksY = get_param_int(argc, params, 3, 0);
auto col1 = get_param_color(argc, params, 4);
auto col2 = get_param_color(argc, params, 5);
auto fnResult = GenImageChecked(width, height, checksX, checksY, col1, col2);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: plain color
//
static int cmd_genimagecolor(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto color = get_param_color(argc, params, 2);
auto fnResult = GenImageColor(width, height, color);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient
//
static int cmd_genimagegradientlinear(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto direction = get_param_int(argc, params, 2, 0);
auto start = get_param_color(argc, params, 3);
auto end = get_param_color(argc, params, 4);
auto fnResult = GenImageGradientLinear(width, height, direction, start, end);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: radial gradient
//
static int cmd_genimagegradientradial(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto density = get_param_num(argc, params, 2, 0);
auto inner = get_param_color(argc, params, 3);
auto outer = get_param_color(argc, params, 4);
auto fnResult = GenImageGradientRadial(width, height, density, inner, outer);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: square gradient
//
static int cmd_genimagegradientsquare(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto density = get_param_num(argc, params, 2, 0);
auto inner = get_param_color(argc, params, 3);
auto outer = get_param_color(argc, params, 4);
auto fnResult = GenImageGradientSquare(width, height, density, inner, outer);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: perlin noise
//
static int cmd_genimageperlinnoise(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto offsetX = get_param_int(argc, params, 2, 0);
auto offsetY = get_param_int(argc, params, 3, 0);
auto scale = get_param_num(argc, params, 4, 0);
auto fnResult = GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: grayscale image from text data
//
static int cmd_genimagetext(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto text = get_param_str(argc, params, 2, 0);
auto fnResult = GenImageText(width, height, text);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate image: white noise
//
static int cmd_genimagewhitenoise(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_int(argc, params, 0, 0);
auto height = get_param_int(argc, params, 1, 0);
auto factor = get_param_num(argc, params, 2, 0);
auto fnResult = GenImageWhiteNoise(width, height, factor);
v_setimage(retval, fnResult);
return 1;
}
//
// Generate cone/pyramid mesh
//
static int cmd_genmeshcone(int argc, slib_par_t *params, var_t *retval) {
auto radius = get_param_num(argc, params, 0, 0);
auto height = get_param_num(argc, params, 1, 0);
auto slices = get_param_int(argc, params, 2, 0);
auto fnResult = GenMeshCone(radius, height, slices);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate cuboid mesh
//
static int cmd_genmeshcube(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_num(argc, params, 0, 0);
auto height = get_param_num(argc, params, 1, 0);
auto length = get_param_num(argc, params, 2, 0);
auto fnResult = GenMeshCube(width, height, length);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate cubes-based map mesh from image data
//
static int cmd_genmeshcubicmap(int argc, slib_par_t *params, var_t *retval) {
int result;
int cubicmap_id = get_image_id(argc, params, 0, retval);
if (cubicmap_id != -1) {
auto cubeSize = get_param_vec3(argc, params, 1);
auto fnResult = GenMeshCubicmap(_imageMap.at(cubicmap_id), cubeSize);
v_setmesh(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Generate cylinder mesh
//
static int cmd_genmeshcylinder(int argc, slib_par_t *params, var_t *retval) {
auto radius = get_param_num(argc, params, 0, 0);
auto height = get_param_num(argc, params, 1, 0);
auto slices = get_param_int(argc, params, 2, 0);
auto fnResult = GenMeshCylinder(radius, height, slices);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate heightmap mesh from image data
//
static int cmd_genmeshheightmap(int argc, slib_par_t *params, var_t *retval) {
int result;
int heightmap_id = get_image_id(argc, params, 0, retval);
if (heightmap_id != -1) {
auto size = get_param_vec3(argc, params, 1);
auto fnResult = GenMeshHeightmap(_imageMap.at(heightmap_id), size);
v_setmesh(retval, fnResult);
result = 1;
} else {
result = 0;
}
return result;
}
//
// Generate half-sphere mesh (no bottom cap)
//
static int cmd_genmeshhemisphere(int argc, slib_par_t *params, var_t *retval) {
auto radius = get_param_num(argc, params, 0, 0);
auto rings = get_param_int(argc, params, 1, 0);
auto slices = get_param_int(argc, params, 2, 0);
auto fnResult = GenMeshHemiSphere(radius, rings, slices);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate trefoil knot mesh
//
static int cmd_genmeshknot(int argc, slib_par_t *params, var_t *retval) {
auto radius = get_param_num(argc, params, 0, 0);
auto size = get_param_num(argc, params, 1, 0);
auto radSeg = get_param_int(argc, params, 2, 0);
auto sides = get_param_int(argc, params, 3, 0);
auto fnResult = GenMeshKnot(radius, size, radSeg, sides);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate plane mesh (with subdivisions)
//
static int cmd_genmeshplane(int argc, slib_par_t *params, var_t *retval) {
auto width = get_param_num(argc, params, 0, 0);
auto length = get_param_num(argc, params, 1, 0);
auto resX = get_param_int(argc, params, 2, 0);
auto resZ = get_param_int(argc, params, 3, 0);
auto fnResult = GenMeshPlane(width, length, resX, resZ);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate polygonal mesh
//
static int cmd_genmeshpoly(int argc, slib_par_t *params, var_t *retval) {
auto sides = get_param_int(argc, params, 0, 0);
auto radius = get_param_num(argc, params, 1, 0);
auto fnResult = GenMeshPoly(sides, radius);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate sphere mesh (standard sphere)
//
static int cmd_genmeshsphere(int argc, slib_par_t *params, var_t *retval) {
auto radius = get_param_num(argc, params, 0, 0);
auto rings = get_param_int(argc, params, 1, 0);
auto slices = get_param_int(argc, params, 2, 0);
auto fnResult = GenMeshSphere(radius, rings, slices);
v_setmesh(retval, fnResult);
return 1;
}
//
// Generate torus mesh
//
static int cmd_genmeshtorus(int argc, slib_par_t *params, var_t *retval) {
auto radius = get_param_num(argc, params, 0, 0);
auto size = get_param_num(argc, params, 1, 0);
auto radSeg = get_param_int(argc, params, 2, 0);
auto sides = get_param_int(argc, params, 3, 0);
auto fnResult = GenMeshTorus(radius, size, radSeg, sides);
v_setmesh(retval, fnResult);
return 1;
}
//
// Get the directory of the running application (uses static string)
//
static int cmd_getapplicationdirectory(int argc, slib_par_t *params, var_t *retval) {
auto fnResult = (const char *)GetApplicationDirectory();
v_setstr(retval, fnResult);
return 1;
}
//
// Get camera transform matrix (view matrix)
//
static int cmd_getcameramatrix(int argc, slib_par_t *params, var_t *retval) {
auto camera = get_camera_3d(argc, params, 0);
auto fnResult = GetCameraMatrix(camera);
v_setmatrix(retval, fnResult);
return 1;
}
//
// Get camera 2d transform matrix
//
static int cmd_getcameramatrix2d(int argc, slib_par_t *params, var_t *retval) {
auto camera = get_camera_2d(argc, params, 0);
auto fnResult = GetCameraMatrix2D(camera);
v_setmatrix(retval, fnResult);
return 1;
}
//
// Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
//
static int cmd_getcharpressed(int argc, slib_par_t *params, var_t *retval) {
auto fnResult = GetCharPressed();
v_setint(retval, fnResult);
return 1;
}
//
// Get clipboard image content
//
static int cmd_getclipboardimage(int argc, slib_par_t *params, var_t *retval) {
auto fnResult = GetClipboardImage();
v_setimage(retval, fnResult);
return 1;
}
//
// Get clipboard text content
//
static int cmd_getclipboardtext(int argc, slib_par_t *params, var_t *retval) {
auto fnResult = (const char *)GetClipboardText();
v_setstr(retval, fnResult);
return 1;
}
//
// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
//
static int cmd_getcodepoint(int argc, slib_par_t *params, var_t *retval) {
auto text = get_param_str(argc, params, 0, 0);
auto codepointSize = (int *)0;
auto fnResult = GetCodepoint(text, codepointSize);
v_setint(retval, fnResult);
return 1;
}
//
// Get total number of codepoints in a UTF-8 encoded string
//
static int cmd_getcodepointcount(int argc, slib_par_t *params, var_t *retval) {
auto text = get_param_str(argc, params, 0, 0);
auto fnResult = GetCodepointCount(text);
v_setint(retval, fnResult);
return 1;
}
//
// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
//
static int cmd_getcodepointnext(int argc, slib_par_t *params, var_t *retval) {
auto text = get_param_str(argc, params, 0, 0);
auto codepointSize = (int *)0;
auto fnResult = GetCodepointNext(text, codepointSize);
v_setint(retval, fnResult);
return 1;
}
//
// Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
//
static int cmd_getcodepointprevious(int argc, slib_par_t *params, var_t *retval) {
auto text = get_param_str(argc, params, 0, 0);
auto codepointSize = (int *)0;
auto fnResult = GetCodepointPrevious(text, codepointSize);
v_setint(retval, fnResult);
return 1;
}
//
// Get collision rectangle for two rectangles collision
//
static int cmd_getcollisionrec(int argc, slib_par_t *params, var_t *retval) {
auto rec1 = get_param_rect(argc, params, 0);
auto rec2 = get_param_rect(argc, params, 1);
auto fnResult = GetCollisionRec(rec1, rec2);
v_setrect(retval, fnResult);
return 1;
}
//
// Get Color structure from hexadecimal value
//
static int cmd_getcolor(int argc, slib_par_t *params, var_t *retval) {
auto hexValue = get_param_int(argc, params, 0, 0);
auto fnResult = GetColor(hexValue);
v_setcolor(retval, fnResult);
return 1;
}
//
// Get current monitor where window is placed
//
static int cmd_getcurrentmonitor(int argc, slib_par_t *params, var_t *retval) {
auto fnResult = GetCurrentMonitor();
v_setint(retval, fnResult);
return 1;
}
//
// Get full path for a given fileName with path (uses static string)
//
static int cmd_getdirectorypath(int argc, slib_par_t *params, var_t *retval) {
auto filePath = get_param_str(argc, params, 0, 0);
auto fnResult = (const char *)GetDirectoryPath(filePath);
v_setstr(retval, fnResult);
return 1;
}
//
// Get pointer to extension for a filename string (includes dot: '.png')
//