-
Notifications
You must be signed in to change notification settings - Fork 1
/
vitasdk_raylib_4.2.0.patch
1257 lines (1219 loc) · 47.8 KB
/
vitasdk_raylib_4.2.0.patch
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
diff --git a/src/Makefile b/src/Makefile
index c03278fb..e7d2ed8a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -11,6 +11,7 @@
# PLATFORM_RPI: Raspberry Pi (deprecated - RPI OS Buster only)
# PLATFORM_DRM: Linux native mode, including Raspberry Pi (RPI OS Bullseye)
# PLATFORM_WEB: HTML5 (Chrome, Firefox)
+# PLATFORM_VITA: PlayStation Vita
#
# Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
# Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
@@ -42,8 +43,7 @@
# Define required environment variables
#------------------------------------------------------------------------------------------------
# Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
-PLATFORM ?= PLATFORM_DESKTOP
-
+PLATFORM ?= PLATFORM_VITA
# Define required raylib variables
RAYLIB_VERSION = 4.2.0
RAYLIB_API_VERSION = 420
@@ -76,10 +76,11 @@ RAYLIB_CONFIG_FLAGS ?= NONE
# Include raylib modules on compilation
# NOTE: Some programs like tools could not require those modules
-RAYLIB_MODULE_AUDIO ?= TRUE
+RAYLIB_MODULE_AUDIO ?= FALSE
RAYLIB_MODULE_MODELS ?= TRUE
RAYLIB_MODULE_RAYGUI ?= FALSE
RAYLIB_MODULE_PHYSAC ?= FALSE
+RAYLIB_MODULE_SPINE ?= FALSE
# NOTE: Additional libraries have been moved to their own repos:
# raygui: https://github.com/raysan5/raygui
@@ -88,7 +89,7 @@ RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src
RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/../../physac/src
# Use external GLFW library instead of rglfw module
-USE_EXTERNAL_GLFW ?= FALSE
+USE_EXTERNAL_GLFW ?= TRUE
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
# NOTE: This variable is only used for PLATFORM_OS: LINUX
@@ -103,9 +104,10 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
endif
+
# Determine if the file has root access (only required to install raylib)
# "whoami" prints the name of the user that calls him (so, if it is the root user, "whoami" prints "root")
-ROOT = $(shell whoami)
+ROOT = $(whoami)
# By default we suppose we are working on Windows
HOST_PLATFORM_OS ?= WINDOWS
@@ -179,7 +181,10 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
endif
endif
endif
-
+ifeq ($(PLATFORM),PLATFORM_VITA)
+ PLATFORM_OS = VITA
+ PLATFORM_SHELL = sh
+endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH ?= C:/emsdk
@@ -248,7 +253,9 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
# By default use OpenGL ES 2.0 on Android
GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif
-
+ifeq ($(PLATFORM),PLATFORM_VITA)
+ GRAPHICS = GRAPHICS_API_OPENGL_ES2
+endif
# Define default C compiler and archiver to pack library: CC, AR
#------------------------------------------------------------------------------------------------
CC = gcc
@@ -295,7 +302,10 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
# It seems from Android NDK r22 onwards we need to use llvm-ar
AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar
endif
-
+ifeq ($(PLATFORM),PLATFORM_VITA)
+ CC = arm-vita-eabi-gcc
+ AR = arm-vita-eabi-ar
+endif
# Define compiler flags: CFLAGS
#------------------------------------------------------------------------------------------------
# -O1 defines optimization level
@@ -414,7 +424,10 @@ endif
# NOTE: Several external required libraries (stb and others)
#------------------------------------------------------------------------------------------------
INCLUDE_PATHS = -I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw
-
+ifeq ($(PLATFORM),PLATFORM_VITA)
+ CFLAGS = -Wl,-q -Wall -Wno-incompatible-pointer-types -Wno-pointer-sign -O3 -nostartfiles -DVITA -D$(PLATFORM) -D$(GRAPHICS)
+ INCLUDE_PATHS = -I.
+endif
# Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),BSD)
@@ -563,6 +576,10 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
OBJS += android_native_app_glue.o
endif
+ifeq ($(RAYLIB_MODULE_SPINE),TRUE)
+ OBJS += rspine.o
+endif
+
# Define processes to execute
#------------------------------------------------------------------------------------------------
# Default target entry
@@ -635,7 +652,7 @@ else
else
# Compile raylib static library version $(RAYLIB_VERSION)
# WARNING: You should type "make clean" before doing this target.
- $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
+ $(AR) rc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
@echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!"
endif
endif
@@ -703,6 +720,10 @@ endif
android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
+# Compile spine module
+rspine.o : rspine.c raylib.h rlgl.h raymath.h utils.h
+ $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
+
# Install generated and needed files to desired directories.
# On GNU/Linux and BSDs, there are some standard directories that contain extra
@@ -716,69 +737,32 @@ android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
# See below and ../examples/Makefile for more information.
# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
-DESTDIR ?= /usr/local
+DESTDIR ?= $(VITASDK)/arm-vita-eabi
RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
install :
-ifeq ($(ROOT),root)
- ifeq ($(PLATFORM_OS),LINUX)
- # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH)
- # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information.
- # Prepare the environment as needed.
- mkdir --parents --verbose $(RAYLIB_INSTALL_PATH)
- mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH)
- ifeq ($(RAYLIB_LIBTYPE),SHARED)
- # Installing raylib to $(RAYLIB_INSTALL_PATH).
- cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)
- cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
- cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
- # Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH.
- # Not necessary if later embedding RPATH in your executable. See examples/Makefile.
- ldconfig $(RAYLIB_INSTALL_PATH)
- else
- # Installing raylib to $(RAYLIB_INSTALL_PATH).
- cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a
- endif
- # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH).
- cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
- cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
- cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
- @echo "raylib development files installed/updated!"
- else
- @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
- endif
-else
- @echo "Error: Root permissions needed for installation. Try sudo make install"
-endif
+ mkdir -p $(RAYLIB_INSTALL_PATH)
+ mkdir -p $(RAYLIB_H_INSTALL_PATH)
+ cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a
+ cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
+ cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
+ cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
+ cp --update rayspine.h $(RAYLIB_H_INSTALL_PATH)/rayspine.h
+# cp --update $(RAYLIB_MODULE_PHYSAC_PATH)/physac.h $(RAYLIB_H_INSTALL_PATH)/physac.h
+ @echo "raylib development files installed/updated!"
+
# Remove raylib dev files installed on the system
# NOTE: see 'install' target.
uninstall :
-ifeq ($(ROOT),root)
- # WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH).
- # and $(RAYLIB_H_INSTALL_PATH). Please confirm each item.
- ifeq ($(PLATFORM_OS),LINUX)
- ifeq ($(RAYLIB_LIBTYPE),SHARED)
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
- # Uncomment to clean up the runtime linker cache. See install target.
- ldconfig
- else
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
- endif
- rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
- rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
- rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
- @echo "raylib development files removed!"
- else
- @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
- endif
-else
- @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall"
-endif
+ rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
+ rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
+ rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
+ rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/physac.h
+ rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rayspine.h
+ @echo "raylib development files removed!"
.PHONY: clean_shell_cmd clean_shell_sh
diff --git a/src/config.h b/src/config.h
index ce7d9b04..979d4211 100644
--- a/src/config.h
+++ b/src/config.h
@@ -41,26 +41,26 @@
// Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
#define SUPPORT_CAMERA_SYSTEM 1
// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
-#define SUPPORT_GESTURES_SYSTEM 1
+#define SUPPORT_GESTURES_SYSTEM 0
// Mouse gestures are directly mapped like touches and processed by gestures system
-#define SUPPORT_MOUSE_GESTURES 1
+#define SUPPORT_MOUSE_GESTURES 0
// Reconfigure standard input to receive key inputs, works with SSH connection.
-#define SUPPORT_SSH_KEYBOARD_RPI 1
+#define SUPPORT_SSH_KEYBOARD_RPI 0
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
-#define SUPPORT_WINMM_HIGHRES_TIMER 1
+#define SUPPORT_WINMM_HIGHRES_TIMER 0
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
-//#define SUPPORT_BUSY_WAIT_LOOP 1
+#define SUPPORT_BUSY_WAIT_LOOP 1
// Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy
#define SUPPORT_PARTIALBUSY_WAIT_LOOP
// Wait for events passively (sleeping while no events) instead of polling them actively every frame
//#define SUPPORT_EVENTS_WAITING 1
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
-#define SUPPORT_SCREEN_CAPTURE 1
+#define SUPPORT_SCREEN_CAPTURE 0
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
-#define SUPPORT_GIF_RECORDING 1
+#define SUPPORT_GIF_RECORDING 0
// Support CompressData() and DecompressData() functions
-#define SUPPORT_COMPRESSION_API 1
+#define SUPPORT_COMPRESSION_API 0
// Support automatic generated events, loading and recording of those events when required
//#define SUPPORT_EVENTS_AUTOMATION 1
// Support custom frame control, only for advance users
@@ -93,7 +93,7 @@
//#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 1
// Show OpenGL extensions and capabilities detailed logs on init
-//#define RLGL_SHOW_GL_DETAILS_INFO 1
+#define RLGL_SHOW_GL_DETAILS_INFO 1
//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
@@ -126,7 +126,6 @@
#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
-
//------------------------------------------------------------------------------------
// Module: rshapes - Configuration Flags
//------------------------------------------------------------------------------------
@@ -167,6 +166,7 @@
//------------------------------------------------------------------------------------
// Default font is loaded on window initialization to be available for the user to render simple text
// NOTE: If enabled, uses external module functions to load default raylib font
+#define SUPPORT_FONT_TEXTURE 1
#define SUPPORT_DEFAULT_FONT 1
// Selected desired font fileformats to be supported for loading
#define SUPPORT_FILEFORMAT_FNT 1
diff --git a/src/rayspine.h b/src/rayspine.h
new file mode 100644
index 00000000..c0709efe
--- /dev/null
+++ b/src/rayspine.h
@@ -0,0 +1,30 @@
+#include <spine/spine.h>
+#include <spine/extension.h>
+#ifndef SP_LAYER_SPACING
+#define SP_LAYER_SPACING 0
+#endif
+
+#ifndef SP_LAYER_SPACING_BASE
+#define SP_LAYER_SPACING_BASE 0
+#endif
+typedef struct Vertex
+{
+ // Position in x/y plane
+ float x, y;
+
+ // UV coordinates
+ float u, v;
+
+ // Color, each channel in the range from 0-1
+ // (Should really be a 32-bit RGBA packed color)
+ float r, g, b, a;
+} Vertex;
+#define MAX_TEXTURES 10
+#define MAX_VERTICES_PER_ATTACHMENT 2048
+
+
+void SpineDrawRegion(Vertex* vertices, Texture* texture, Vector3 position, int* vertex_order);
+void SpineDrawMesh(Vertex *vertices, int start, int count, Texture *texture, Vector3 position, int *vertex_order);
+void SpineDrawSkeleton(spSkeleton *skeleton, Vector3 position);
+Texture2D *SpineCreateTexture2d(char *path);
+void SpineTextureDestroy();
diff --git a/src/rcore.c b/src/rcore.c
index d90acf6c..16e0fdad 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -11,6 +11,7 @@
* - PLATFORM_RPI: Raspberry Pi 0,1,2,3 (Raspbian, native mode)
* - PLATFORM_DRM: Linux native mode, including Raspberry Pi 4 with V3D fkms driver
* - PLATFORM_WEB: HTML5 with WebAssembly
+* - PLATFORM_VITA: PlayStation Vita
*
* CONFIGURATION:
*
@@ -290,6 +291,15 @@
#include <emscripten/html5.h> // Emscripten HTML5 library
#endif
+#if defined(PLATFORM_VITA)
+ #include <pib.h>
+ #include <psp2/gxm.h>
+ #include <psp2/display.h>
+ #include <psp2/kernel/processmgr.h>
+ #include "EGL/egl.h"
+ #include "EGL/eglext.h"
+ #include "GLES2/gl2.h"
+#endif
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
@@ -372,7 +382,7 @@ typedef struct CoreData {
#if defined(PLATFORM_RPI)
EGL_DISPMANX_WINDOW_T handle; // Native window handle (graphic device)
#endif
-#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
+#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_VITA)
#if defined(PLATFORM_DRM)
int fd; // File descriptor for /dev/dri/...
drmModeConnector *connector; // Direct Rendering Manager (DRM) mode connector
@@ -491,7 +501,7 @@ typedef struct CoreData {
double draw; // Time measure for frame draw
double frame; // Time measure for one frame
double target; // Desired time for one frame, if 0 not applied
-#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
+#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_VITA)
unsigned long long base; // Base time measure for hi-res timer
#endif
unsigned int frameCounter; // Frame counter
@@ -721,6 +731,68 @@ struct android_app *GetAndroidApp(void)
// Initialize window and OpenGL context
// NOTE: data parameter could be used to pass any kind of required data to the initialization
+#if defined(PLATFORM_VITA)
+void InitWindow(int width, int height, const char *title)
+{
+ TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
+ TRACELOG(LOG_INFO, "Supported raylib modules:");
+ TRACELOG(LOG_INFO, " > rcore:..... loaded (mandatory)");
+ TRACELOG(LOG_INFO, " > rlgl:...... loaded (mandatory)");
+#if defined(SUPPORT_MODULE_RSHAPES)
+ TRACELOG(LOG_INFO, " > rshapes:... loaded (optional)");
+#else
+ TRACELOG(LOG_INFO, " > rshapes:... not loaded (optional)");
+#endif
+#if defined(SUPPORT_MODULE_RTEXTURES)
+ TRACELOG(LOG_INFO, " > rtextures:. loaded (optional)");
+#else
+ TRACELOG(LOG_INFO, " > rtextures:. not loaded (optional)");
+#endif
+#if defined(SUPPORT_MODULE_RTEXT)
+ TRACELOG(LOG_INFO, " > rtext:..... loaded (optional)");
+#else
+ TRACELOG(LOG_INFO, " > rtext:..... not loaded (optional)");
+#endif
+#if defined(SUPPORT_MODULE_RMODELS)
+ TRACELOG(LOG_INFO, " > rmodels:... loaded (optional)");
+#else
+ TRACELOG(LOG_INFO, " > rmodels:... not loaded (optional)");
+#endif
+#if defined(SUPPORT_MODULE_RAUDIO)
+ TRACELOG(LOG_INFO, " > raudio:.... loaded (optional)");
+#else
+ TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)");
+#endif
+ if ((title != NULL) && (title[0] != 0)) CORE.Window.title = title;
+ // Init hi-res timer
+
+ InitTimer();
+ //TRACELOG(LOG_INFO, "after timer ");
+
+ // Init graphics device (display device and OpenGL context)
+ // NOTE: returns true if window and graphic device has been initialized successfully
+ CORE.Window.ready = InitGraphicsDevice(width, height);
+ CORE.Window.screen.width = width;
+ CORE.Window.screen.height = height;
+ CORE.Window.currentFbo.width = width;
+ CORE.Window.currentFbo.height = height;
+ CORE.Input.Mouse.currentPosition.x = (float)CORE.Window.screen.width/2.0f;
+ CORE.Input.Mouse.currentPosition.y = (float)CORE.Window.screen.height/2.0f;
+ CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
+
+
+ if (!CORE.Window.ready) return;
+
+#if defined(SUPPORT_DEFAULT_FONT)
+ // Load default font
+ // NOTE: External functions (defined in module: text)
+ LoadFontDefault();
+ Rectangle rec = GetFontDefault().recs[95];
+ // NOTE: We setup a 1px padding on char rectangle to avoid pixel bleeding on MSAA filtering
+ SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 });
+#endif
+}
+#else
void InitWindow(int width, int height, const char *title)
{
TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
@@ -925,6 +997,7 @@ void InitWindow(int width, int height, const char *title)
#endif // PLATFORM_DESKTOP || PLATFORM_WEB || PLATFORM_RPI || PLATFORM_DRM
}
+#endif
// Close window and unload OpenGL context
void CloseWindow(void)
@@ -953,7 +1026,7 @@ void CloseWindow(void)
timeEndPeriod(1); // Restore time period
#endif
-#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
+#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_VITA)
// Close surface, context and display
if (CORE.Window.device != EGL_NO_DISPLAY)
{
@@ -1103,7 +1176,7 @@ bool WindowShouldClose(void)
else return true;
#endif
-#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
+#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_VITA)
if (CORE.Window.ready) return CORE.Window.shouldClose;
else return true;
#endif
@@ -2754,6 +2827,9 @@ double GetTime(void)
return (double)(time - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
#endif
+#if defined(PLATFORM_VITA)
+ return (double)(sceKernelGetProcessTimeWide() - CORE.Time.base)*1e-6;
+#endif
}
// Setup window configuration flags (view FLAGS)
@@ -3029,9 +3105,11 @@ const char *GetWorkingDirectory(void)
{
static char currentDir[MAX_FILEPATH_LENGTH] = { 0 };
memset(currentDir, 0, MAX_FILEPATH_LENGTH);
-
+#if !defined(PLATFORM_VITA)
char *path = GETCWD(currentDir, MAX_FILEPATH_LENGTH - 1);
-
+#else
+ char *path = ".";
+#endif
return path;
}
@@ -3182,8 +3260,11 @@ void UnloadDirectoryFiles(FilePathList files)
// Change working directory, returns true on success
bool ChangeDirectory(const char *dir)
{
+#if !defined(PLATFORM_VITA)
bool result = CHDIR(dir);
-
+#else
+ bool result = 0;
+#endif
if (result != 0) TRACELOG(LOG_WARNING, "SYSTEM: Failed to change to directory: %s", dir);
return (result == 0);
@@ -3878,6 +3959,171 @@ int GetTouchPointCount(void)
// NOTE: width and height represent the screen (framebuffer) desired size, not actual display size
// If width or height are 0, default display size will be used for framebuffer size
// NOTE: returns false in case graphic device could not be created
+#if defined(PLATFORM_VITA)
+static bool InitGraphicsDevice(int width, int height)
+{
+ CORE.Window.screen.width = width; // User desired width
+ CORE.Window.screen.height = height; // User desired height
+ CORE.Window.display.width = width; // User desired width
+ CORE.Window.display.height = height; // User desired height
+ CORE.Window.currentFbo.width = width;
+ CORE.Window.currentFbo.height = height;
+ CORE.Window.render.width = width;
+ CORE.Window.render.height = height;
+
+ CORE.Window.position.x = CORE.Window.display.width/2 - CORE.Window.screen.width/2;
+ CORE.Window.position.y = CORE.Window.display.height/2 - CORE.Window.screen.height/2;
+
+ CORE.Window.screenScale = MatrixIdentity(); // No draw scaling required by default
+
+ SetupFramebuffer(CORE.Window.display.width,CORE.Window.display.height);
+
+ CORE.Window.fullscreen = true;
+
+ EGLint samples = 0;
+ EGLint sampleBuffer = 0;
+ //TRACELOG(LOG_INFO, "after setugframebuffer");
+
+ if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
+ {
+ samples = 4;
+ sampleBuffer = 1;
+ TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
+ }
+
+ const EGLint framebufferAttribs[] = {
+ //EGL_CONFIG_ID, 2, // You can always provide a configuration id. The one displayed here is Configuration 2
+ EGL_RED_SIZE, 8, // These four are always 8
+ EGL_GREEN_SIZE, 8, //
+ EGL_BLUE_SIZE, 8, //
+ EGL_ALPHA_SIZE, 8, //
+ EGL_DEPTH_SIZE, 32, // Depth is either 32 or 0
+ EGL_STENCIL_SIZE, 8, // Stencil Size is either 8 or 0
+ EGL_SURFACE_TYPE, 5, // This is ALWAYS 5
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Always EGL_OPENGL_ES2_BIT or 0x4
+ EGL_NONE};
+
+ const EGLint contextAttribs[] =
+ {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+
+ /* const EGLint surfaceAttributes[] =
+ {
+ EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
+ EGL_NONE,
+ };*/
+ EGLint numConfigs = 0;
+ CORE.Window.device = eglGetDisplay(0);
+ //TRACELOG(LOG_INFO, "after eglgetdisplay ");
+
+ if (CORE.Window.device == EGL_NO_DISPLAY)
+ {
+ TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device");
+ return false;
+ }
+ EGLint majorVersion;
+ EGLint minorVersion;
+ //TRACELOG(LOG_INFO, "before eglInitialize ");
+
+ // Initialize the EGL device connection
+ if (eglInitialize(CORE.Window.device, &majorVersion, &minorVersion) == EGL_FALSE)
+ {
+ // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred.
+ TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device");
+ return false;
+ }
+ TRACELOG(LOG_INFO,"DISPLAY: EGL version major:%d, minor:%d",majorVersion,minorVersion);
+ int ret=eglBindAPI(EGL_OPENGL_ES_API);
+ if(!ret)
+ {
+ ret=eglGetError();
+ TRACELOG(LOG_ERROR,"DISPLAY: eglBindAPI failed: 0x%08X",ret);
+ return false;
+ }
+ TRACELOG(LOG_INFO,"DISPLAY: eglBindAPI success.");
+
+ /*ret=eglSwapInterval(CORE.Window.device,0);
+ if(!ret)
+ {
+ ret=eglGetError();
+ TRACELOG(LOG_ERROR,"DISPLAY: eglSwapInterval failed: 0x%08X",ret);
+ //return false;
+ }
+ //TRACELOG(LOG_INFO,"DISPLAY: eglSwapInterval success.");*/
+ ret=eglChooseConfig(CORE.Window.device, framebufferAttribs, &CORE.Window.config, 1, &numConfigs);
+ if(!ret)
+ {
+ ret=eglGetError();
+ TRACELOG(LOG_ERROR,"DISPLAY: eglChooseConfig failed: 0x%08X",ret);
+ return false;
+ }
+ if (numConfigs!=1)
+ {
+ TRACELOG(LOG_ERROR,"DISPLAY: No available configuration found.");
+ return false;
+ }
+ TRACELOG(LOG_INFO,"DISPLAY: eglChooseConfig success.");
+
+
+ CORE.Window.surface=eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, VITA_WINDOW_960X544, NULL);
+ if(CORE.Window.surface==EGL_NO_SURFACE)
+ {
+ ret=eglGetError();
+ TRACELOG(LOG_ERROR,"DISPLAY: eglCreateWindowSurface failed: 0x%08X",ret);
+ return false;
+ }
+ TRACELOG(LOG_INFO,"DISPLAY: eglCreateWindowSurface success.");
+// Create an EGL rendering context
+ CORE.Window.context = eglCreateContext(CORE.Window.device, CORE.Window.config, EGL_NO_CONTEXT, contextAttribs);
+ if (CORE.Window.context == EGL_NO_CONTEXT)
+ {
+ ret=eglGetError();
+ TRACELOG(LOG_ERROR,"DISPLAY: Failed to create EGL context 0x%08X",ret);
+ return false;
+ }
+ TRACELOG(LOG_INFO,"DISPLAY: context create EGL window surface");
+ EGLint surface_width, surface_height;
+ if (eglMakeCurrent(CORE.Window.device, CORE.Window.surface, CORE.Window.surface, CORE.Window.context) == EGL_FALSE)
+ {
+ ret=eglGetError();
+ TRACELOG(LOG_ERROR,"DISPLAY: Failed to attach EGL rendering context to EGL surface 0x%08X");
+ return false;
+ }
+ TRACELOG(LOG_INFO,"DISPLAY: eglMakeCurrent success.\n");
+
+ eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_WIDTH, &surface_width);
+ eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_HEIGHT, &surface_height);
+ printf("Surface Width: %d, Surface Height: %d\n", surface_width, surface_height);
+
+
+ //const char *gl_exts = (char *) glGetString(GL_EXTENSIONS);
+ //TRACELOG(LOG_INFO,"DISPLAY: GL_VENDOR: \"%s\"\n", glGetString(GL_VENDOR));
+ //TRACELOG(LOG_INFO,"DISPLAY: GL_VERSION: \"%s\"\n", glGetString(GL_VERSION));
+ //TRACELOG(LOG_INFO,"DISPLAY: GL_RENDERER: \"%s\"\n", glGetString(GL_RENDERER));
+ //TRACELOG(LOG_INFO,"DISPLAY: SL_VERSION: \"%s\"\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
+ //TRACELOG(LOG_INFO,"DISPLAY: GL_EXTs: \"%s\"\n",glGetString(GL_SHADING_LANGUAGE_VERSION));
+
+ rlglInit(CORE.Window.screen.width, CORE.Window.screen.height);
+
+ int fbWidth = CORE.Window.render.width;
+ int fbHeight = CORE.Window.render.height;
+
+
+
+ // Setup default viewport
+ SetupViewport(fbWidth, fbHeight);
+
+ CORE.Window.currentFbo.width = CORE.Window.screen.width;
+ CORE.Window.currentFbo.height = CORE.Window.screen.height;
+
+ ClearBackground(RAYWHITE); // Default background color for raylib games :P
+
+ //CORE.Window.ready=true;
+ return true;
+}
+#else
static bool InitGraphicsDevice(int width, int height)
{
CORE.Window.screen.width = width; // User desired width
@@ -4633,7 +4879,7 @@ static bool InitGraphicsDevice(int width, int height)
return true;
}
-
+#endif
// Set viewport for a provided width and height
static void SetupViewport(int width, int height)
{
@@ -4760,7 +5006,9 @@ static void InitTimer(void)
}
else TRACELOG(LOG_WARNING, "TIMER: Hi-resolution timer not available");
#endif
-
+#if defined(PLATFORM_VITA)
+ CORE.Time.base=sceKernelGetProcessTimeWide();
+#endif
CORE.Time.previous = GetTime(); // Get time as double
}
@@ -4815,7 +5063,7 @@ void SwapScreenBuffer(void)
glfwSwapBuffers(CORE.Window.handle);
#endif
-#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
+#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_VITA)
eglSwapBuffers(CORE.Window.device, CORE.Window.surface);
#if defined(PLATFORM_DRM)
diff --git a/src/rlgl.h b/src/rlgl.h
index 123791a0..17221984 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -4309,6 +4309,33 @@ static void rlLoadShaderDefault(void)
for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) RLGL.State.defaultShaderLocs[i] = -1;
// Vertex shader directly defined, no external file required
+#if defined (PLATFORM_VITA)
+const char *defaultVShaderCode =
+ "void main( \n"
+ "float3 vertexPosition, \n"
+ "float2 vertexTexCoord, \n"
+ "float4 vertexColor, \n"
+ "float2 out fragTexCoord : TEXCOORD0,\n"
+ "float4 out fragColor : COLOR0, \n"
+ "float4 out gl_Position : POSITION, \n"
+ "uniform float4x4 mvp) \n"
+ "{ \n"
+ " fragTexCoord = vertexTexCoord; \n"
+ " fragColor = vertexColor; \n"
+ " gl_Position = mul(float4(vertexPosition,1.f),mvp); \n"
+ "} \n";
+ const char *defaultFShaderCode =
+ "void main( \n"
+ "float2 fragTexCoord : TEXCOORD0, \n"
+ "float4 fragColor : COLOR0, \n"
+ "uniform sampler2D texture0, \n"
+ "uniform float4 colDiffuse, \n"
+ "float4 out finalColor) \n"
+ "{ \n"
+ " float4 texelColor = tex2D(texture0, fragTexCoord); \n"
+ " finalColor=texelColor*colDiffuse*fragColor; \n"
+ "} \n";
+#else
const char *defaultVShaderCode =
#if defined(GRAPHICS_API_OPENGL_21)
"#version 120 \n"
@@ -4379,6 +4406,7 @@ static void rlLoadShaderDefault(void)
" vec4 texelColor = texture2D(texture0, fragTexCoord); \n"
" gl_FragColor = texelColor*colDiffuse*fragColor; \n"
"} \n";
+#endif
#endif
// NOTE: Compiled vertex/fragment shaders are not deleted,
diff --git a/src/rmodels.c b/src/rmodels.c
index ee8b2117..d91eae36 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -1102,7 +1102,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
// WARNING: When setting default vertex attribute values, the values for each generic vertex attribute
// is part of current state and it is maintained even if a different program object is used
-
+#if !defined(PLATFORM_VITA)
if (mesh->normals != NULL)
{
// Enable vertex attributes: normals (shader-location = 2)
@@ -1119,7 +1119,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
rlSetVertexAttributeDefault(2, value, SHADER_ATTRIB_VEC3, 3);
rlDisableVertexAttribute(2);
}
-
+#endif
if (mesh->colors != NULL)
{
// Enable vertex attribute: color (shader-location = 3)
@@ -3747,11 +3747,12 @@ static Model LoadOBJ(const char *fileName)
char currentDir[1024] = { 0 };
strcpy(currentDir, GetWorkingDirectory());
const char *workingDir = GetDirectoryPath(fileName);
+#if !defined(PLATFORM_VITA)
if (CHDIR(workingDir) != 0)
{
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to change working directory", workingDir);
}
-
+#endif
unsigned int flags = TINYOBJ_FLAG_TRIANGULATE;
int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, fileText, dataSize, flags);
@@ -3894,13 +3895,13 @@ static Model LoadOBJ(const char *fileName)
RL_FREE(vtCount);
RL_FREE(vnCount);
RL_FREE(faceCount);
-
+#if !defined(PLATFORM_VITA)
if (CHDIR(currentDir) != 0)
{
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to change working directory", currentDir);
}
+#endif
}
-
return model;
}
#endif
diff --git a/src/rspine.c b/src/rspine.c
new file mode 100644
index 00000000..97f78020
--- /dev/null
+++ b/src/rspine.c
@@ -0,0 +1,255 @@
+#include "raylib.h" // Declares module functions
+
+// Check if config flags have been externally provided on compilation line
+#if !defined(EXTERNAL_CONFIG_FLAGS)
+ #include "config.h" // Defines module configuration flags
+#endif
+
+#include "utils.h" // Required for: TRACELOG(), LoadFileData(), LoadFileText(), SaveFileText()
+#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2
+#include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality
+
+#include <stdio.h> // Required for: sprintf()
+#include <stdlib.h> // Required for: malloc(), free()
+#include <string.h> // Required for: memcmp(), strlen()
+#include <math.h> // Required for: sinf(), cosf(), sqrtf(), fabsf()
+
+#include "rayspine.h"
+
+Texture2D gtexture;
+Texture2D tm_textures[MAX_TEXTURES] = {0};
+int texture_index = 0;
+float anti_z_fighting_index = SP_LAYER_SPACING_BASE;
+float worldVerticesPositions[MAX_VERTICES_PER_ATTACHMENT];
+Vertex vertices[MAX_VERTICES_PER_ATTACHMENT];
+int VERTEX_ORDER_NORMAL[] = {0, 1, 2, 4};
+int VERTEX_ORDER_INVERSE[] = {4, 2, 1, 0};
+
+
+void SpineAddVertex(float x, float y, float u, float v, float r, float g, float b, float a, int* index)
+{
+ Vertex* vertex = &vertices[*index];
+ vertex->x = x;
+ vertex->y = y;
+ vertex->u = u;
+ vertex->v = v;
+ vertex->r = r;
+ vertex->g = g;
+ vertex->b = b;
+ vertex->a = a;
+ // TraceLog(LOG_INFO,"%s val=%d x=%f y=%f u=%f v=%f r=%f g=%f b=%f a=%f index=%d",__FUNCTION__,val,x,y,u,v,r,g,b,a,*index);
+
+ *index += 1;
+}
+Texture2D *SpineCreateTexture2d(char *path)
+{
+ tm_textures[texture_index] = LoadTexture(path);
+ gtexture=tm_textures[texture_index];
+ Texture2D *t = &tm_textures[texture_index];
+ SetTextureFilter(*t,TEXTURE_FILTER_BILINEAR);
+ texture_index++;
+ return t;
+}
+
+void SpineTextureDestroy()
+{
+ while(texture_index--) UnloadTexture(tm_textures[texture_index]);
+}
+
+void SpineDrawRegion(Vertex* vertices, Texture* texture, Vector3 position, int* vertex_order)
+{
+ Vertex vertex;
+// TRACELOG(LOG_INFO, "%s %d",__FUNCTION__,texture->id);
+
+ rlSetTexture(texture->id);
+ rlPushMatrix();
+ {
+ rlBegin(RL_QUADS);
+ {
+ rlColor4f(1.0, 1.0, 1.0, 1.0);
+ rlNormal3f(0.0f, 0.0f, 1.0f);
+ for (int i = 0; i < 4; i++)
+ {
+ vertex = vertices[vertex_order[i]];
+ rlTexCoord2f(vertex.u, vertex.v);
+ rlVertex3f( position.x + vertex.x, position.y + vertex.y, position.z + anti_z_fighting_index);
+ }
+ }
+ rlEnd();
+
+#ifdef SP_DRAW_DOUBLE_FACED
+ rlBegin(RL_QUADS);
+ {
+ rlNormal3f(0.0f, 0.0f, 1.0f);
+ for (int i = 3; i >= 0; i--)
+ {
+ vertex = vertices[vertex_order[i]];
+ rlTexCoord2f(vertex.u, vertex.v);
+ rlColor4f(vertex.r, vertex.g, vertex.b, vertex.a);
+ rlVertex3f( position.x + vertex.x, position.y + vertex.y, position.z - anti_z_fighting_index);
+ }
+ }
+ rlEnd();
+#endif
+
+ }
+ rlPopMatrix();
+ rlSetTexture(0);
+}
+void SpineDrawMesh(Vertex *vertices, int start, int count, Texture *texture, Vector3 position, int *vertex_order)
+{
+ Vertex vertex;
+ //TRACELOG(LOG_INFO, "%s %d",__FUNCTION__,texture->id);
+
+ rlPushMatrix();
+ {
+ for(int vertexIndex = start; vertexIndex < count; vertexIndex += 3)
+ {
+ rlEnableTexture(texture->id);
+ rlBegin(RL_QUADS);
+ {
+ int i;
+ for (i = 2; i > -1; i--)
+ {
+ vertex = vertices[vertexIndex + i];
+ rlTexCoord2f(vertex.u, vertex.v);
+ rlColor4f(vertex.r, vertex.g, vertex.b, vertex.a);
+ rlVertex3f(position.x + vertex.x, position.y + vertex.y, position.z + anti_z_fighting_index);
+ }
+ rlVertex3f(position.x + vertex.x, position.y + vertex.y, position.z + anti_z_fighting_index);
+ }
+ rlEnd();
+#ifdef SP_DRAW_DOUBLE_FACED
+ TraceLog(LOG_INFO,"double sided not supported for mesh based spine files\n");
+ return;
+#endif
+
+#ifdef SP_RENDER_WIREFRAME
+ DrawTriangleLines((Vector2) {vertices[vertexIndex].x + position.x, vertices[vertexIndex].y + position.y},
+ (Vector2) {vertices[vertexIndex + 1].x + position.x, vertices[vertexIndex + 1].y + position.y},
+ (Vector2) {vertices[vertexIndex + 2].x + position.x, vertices[vertexIndex + 2].y + position.y}, vertexIndex == 0 ? RED : GREEN);
+#endif
+ }
+ }
+ rlPopMatrix();
+ rlDisableTexture();
+}
+void SpineDrawSkeleton(spSkeleton *skeleton, Vector3 position)
+{
+
+ int *vertex_order = (skeleton->scaleX * skeleton->scaleY < 0) ? VERTEX_ORDER_NORMAL : VERTEX_ORDER_INVERSE;
+ anti_z_fighting_index = SP_LAYER_SPACING_BASE;
+
+ // For each slot in the draw order array of the skeleton
+ for (int i = 0; i <skeleton->slotsCount; ++i)
+ {
+ //TraceLog(LOG_INFO,"%s %d",__FUNCTION__,i);
+ anti_z_fighting_index -= SP_LAYER_SPACING;
+ spSlot *slot = skeleton->drawOrder[i];
+
+ // Fetch the currently active attachment, continue
+ // with the next slot in the draw order if no
+ // attachment is active on the slot
+ spAttachment *attachment = slot->attachment;
+ if(!attachment) continue;
+
+ // Calculate the tinting color based on the skeleton's color
+ // and the slot's color. Each color channel is given in the
+ // range [0-1], you may have to multiply by 255 and cast to
+ // and int if your engine uses integer ranges for color channels.
+ float tintR = skeleton->color.r * slot->color.r;
+ float tintG = skeleton->color.g * slot->color.g;
+ float tintB = skeleton->color.b * slot->color.b;
+ float tintA = skeleton->color.a * slot->color.a;
+
+ // Fill the vertices array depending on the type of attachment
+ Texture *texture = 0;
+ int vertexIndex = 0;
+ if (attachment->type == SP_ATTACHMENT_REGION)
+ {
+ //TraceLog(LOG_INFO,"%s %d",__FUNCTION__,i);
+
+ // Cast to an spRegionAttachment so we can get the rendererObject
+ // and compute the world vertices
+ spRegionAttachment *regionAttachment = (spRegionAttachment *) attachment;
+
+ // Our engine specific Texture is stored in the spAtlasRegion which was
+ // assigned to the attachment on load. It represents the texture atlas
+ // page that contains the image the region attachment is mapped to
+ texture = (Texture *) ((spAtlasRegion *) regionAttachment->rendererObject)->page->rendererObject;
+ //TraceLog(LOG_INFO,"%s texture id=%d",__FUNCTION__,texture->id);
+
+ // Computed the world vertices positions for the 4 vertices that make up
+ // the rectangular region attachment. This assumes the world transform of the
+ // bone to which the slot (and hence attachment) is attached has been calculated
+ // before rendering via spSkeleton_updateWorldTransform
+ spRegionAttachment_computeWorldVertices(regionAttachment, slot->bone, worldVerticesPositions, 0, 2);
+
+ // Create 2 triangles, with 3 vertices each from the region's
+ // world vertex positions and its UV coordinates (in the range [0-1]).
+ SpineAddVertex(worldVerticesPositions[0], worldVerticesPositions[1],
+ regionAttachment->uvs[0], regionAttachment->uvs[1],
+ tintR, tintG, tintB, tintA, &vertexIndex);
+
+ SpineAddVertex(worldVerticesPositions[2], worldVerticesPositions[3],
+ regionAttachment->uvs[2], regionAttachment->uvs[3],
+ tintR, tintG, tintB, tintA, &vertexIndex);