-
Notifications
You must be signed in to change notification settings - Fork 0
/
orbis_raylib_4.0.patch
1224 lines (1177 loc) · 46.6 KB
/
orbis_raylib_4.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 6fbb8a3f..8cd8c3c1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -11,6 +11,8 @@
# PLATFORM_RPI: Raspberry Pi (Raspbian)
# PLATFORM_DRM: Linux native mode, including Raspberry Pi 4 with V3D fkms driver
# PLATFORM_WEB: HTML5 (Chrome, Firefox)
+# PLATFORM_VITA: PlayStation Vita
+# PLATFORM_ORBIS: PlayStation 4/PlayStation 5 ORBIS/PROSPERO
#
# Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
# Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
@@ -67,20 +69,21 @@ RAYLIB_RES_FILE ?= ./raylib.dll.rc.data
# Define raylib platform
# Options: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
-PLATFORM ?= PLATFORM_DESKTOP
+PLATFORM ?= PLATFORM_ORBIS
# 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
RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/extras
RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/extras
# 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
@@ -143,7 +146,12 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
PLATFORM_OS = LINUX
endif
endif
-
+ifeq ($(PLATFORM),PLATFORM_VITA)
+ PLATFORM_OS = VITA
+endif
+ifeq ($(PLATFORM),PLATFORM_ORBIS)
+ PLATFORM_OS = ORBIS
+endif
# RAYLIB_SRC_PATH adjustment for different platforms.
# If using GNU make, we can get the full path to the top of the tree. Windows? BSD?
# Required for ldconfig or other tools that do not perform path expansion.
@@ -222,7 +230,12 @@ 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
+ifeq ($(PLATFORM),PLATFORM_ORBIS)
+ GRAPHICS = GRAPHICS_API_OPENGL_ES2
+endif
# Define default C compiler and archiver to pack library
CC = gcc
AR = ar
@@ -262,7 +275,14 @@ 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
+ifeq ($(PLATFORM),PLATFORM_ORBIS)
+ CC = clang
+ AR = orbis-ar
+endif
# Define compiler flags:
# -O1 defines optimization level
# -g include debug information on compilation
@@ -376,7 +396,15 @@ endif
# Define include paths for required headers
# 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
+ INCLUDE_PATHS = -I.
+endif
+ifeq ($(PLATFORM),PLATFORM_ORBIS)
+ CFLAGS = -std=c11 -O3 -Wall --target=x86_64-scei-ps4 -D__PS4__ -D__ORBIS__
+ INCLUDE_PATHS = -isysroot $(ORBISDEV) -I. -Iinclude -I$(ORBISDEV)/usr/include/orbis
+ LDFLAGS = -L$(ORBISDEV)/usr/lib -L. -Llib
+endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),BSD)
INCLUDE_PATHS += -I/usr/local/include
@@ -465,7 +493,9 @@ endif
ifeq ($(RAYLIB_MODULE_PHYSAC),TRUE)
OBJS += physac.o
endif
-
+ifeq ($(RAYLIB_MODULE_SPINE),TRUE)
+ OBJS += rspine.o
+endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
OBJS += android_native_app_glue.o
endif
@@ -540,8 +570,8 @@ 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)
- @echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!"
+ $(AR) rcs $(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
@@ -595,6 +625,10 @@ physac.c:
@echo #define PHYSAC_IMPLEMENTATION > physac.c
@echo #include "$(RAYLIB_MODULE_PHYSAC_PATH)/physac.h" >> physac.c
+# Compile models module
+rspine.o : rspine.c raylib.h rlgl.h raymath.h utils.h
+ $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
+
# Compile android_native_app_glue module
android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
@@ -613,71 +647,35 @@ android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
# TODO: Add other platforms. Remove sudo requirement, i.e. add USER mode.
# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
-DESTDIR ?= /usr/local
+ifeq ($(PLATFORM),PLATFORM_VITA)
+DESTDIR ?= $(VITASDK)/arm-vita-eabi
+endif
+ifeq ($(PLATFORM),PLATFORM_ORBIS)
+DESTDIR ?= $(ORBISDEV)/usr
+endif
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
- cp --update extras/physac.h $(RAYLIB_H_INSTALL_PATH)/physac.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 $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a
+ cp raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
+ cp raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
+ cp rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
+ cp extras/physac.h $(RAYLIB_H_INSTALL_PATH)/physac.h
+ cp rayspine.h $(RAYLIB_H_INSTALL_PATH)/rayspine.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
- rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/physac.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 $(RAYLIB_H_INSTALL_PATH)/raylib.h
+ rm $(RAYLIB_H_INSTALL_PATH)/raymath.h
+ rm $(RAYLIB_H_INSTALL_PATH)/rlgl.h
+ rm $(RAYLIB_H_INSTALL_PATH)/physac.h
+ rm $(RAYLIB_H_INSTALL_PATH)/rayspine.h
# Clean everything
clean:
diff --git a/src/config.h b/src/config.h
index aea7df78..f99a8a4c 100644
--- a/src/config.h
+++ b/src/config.h
@@ -31,30 +31,30 @@
// 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
// Draw a mouse pointer on screen
-//#define SUPPORT_MOUSE_CURSOR_POINT 1
+//#define SUPPORT_MOUSE_CURSOR_POINT 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
+//#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 saving binary data automatically to a generated storage.data file. This file is managed internally.
-#define SUPPORT_DATA_STORAGE 1
+#define SUPPORT_DATA_STORAGE 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
@@ -89,7 +89,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,6 +126,7 @@
//------------------------------------------------------------------------------------
// Module: shapes - Configuration Flags
//------------------------------------------------------------------------------------
+#define SUPPORT_FONT_TEXTURE 1
// Use QUADS instead of TRIANGLES for drawing when possible
// Some lines-based shapes could still use lines
#define SUPPORT_QUADS_DRAW_MODE 1
@@ -223,7 +224,7 @@
// Show TRACELOG() output messages
// NOTE: By default LOG_DEBUG traces not shown
#define SUPPORT_TRACELOG 1
-//#define SUPPORT_TRACELOG_DEBUG 1
+#define SUPPORT_TRACELOG_DEBUG 1
// utils: Configuration values
//------------------------------------------------------------------------------------
diff --git a/src/external/stb_truetype.h b/src/external/stb_truetype.h
index bbf2284b..edd94515 100644
--- a/src/external/stb_truetype.h
+++ b/src/external/stb_truetype.h
@@ -3042,15 +3042,25 @@ static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edg
}
if (x0 == x)
+ {
STBTT_assert(x1 <= x+1);
+ }
else if (x0 == x+1)
+ {
STBTT_assert(x1 >= x);
+ }
else if (x0 <= x)
+ {
STBTT_assert(x1 <= x);
+ }
else if (x0 >= x+1)
+ {
STBTT_assert(x1 >= x+1);
+ }
else
+ {
STBTT_assert(x1 >= x && x1 <= x+1);
+ }
if (x0 <= x && x1 <= x)
scanline[x] += e->direction * (y1-y0);
diff --git a/src/rayspine.h b/src/rayspine.h
new file mode 100644
index 00000000..3d6fe867
--- /dev/null
+++ b/src/rayspine.h
@@ -0,0 +1,29 @@
+#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);
diff --git a/src/rcore.c b/src/rcore.c
index 3b451552..8b4c7c5d 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -11,6 +11,8 @@
* - 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
+* - PLATFORM_ORBIS: PlayStation 4/PlayStation 5 ORBIS/PROSPERO
*
* CONFIGURATION:
*
@@ -159,7 +161,9 @@
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
#endif
-
+#if defined(PLATFORM_ORBIS)
+#include <user_mem.h>
+#endif
#include <stdlib.h> // Required for: srand(), rand(), atexit()
#include <stdio.h> // Required for: sprintf() [Used in OpenURL()]
#include <string.h> // Required for: strrchr(), strcmp(), strlen()
@@ -256,6 +260,22 @@
//#include "GLES2/gl2.h" // OpenGL ES 2.0 library (not required in this module, only in rlgl)
#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
+#if defined(PLATFORM_ORBIS)
+ #include "EGL/egl.h"
+ #include "EGL/eglext.h"
+ #include "GLES2/gl2.h"
+ #include <piglet.h>
+#endif
+
#if defined(PLATFORM_WEB)
#define GLFW_INCLUDE_ES2 // GLFW3: Enable OpenGL ES 2.0 (translated to WebGL)
#include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management
@@ -354,7 +374,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) || defined(PLATFORM_ORBIS)
#if defined(PLATFORM_DRM)
int fd; // File descriptor for /dev/dri/...
drmModeConnector *connector; // Direct Rendering Manager (DRM) mode connector
@@ -472,7 +492,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) || defined(PLATFORM_ORBIS)
unsigned long long base; // Base time measure for hi-res timer
#endif
unsigned int frameCounter; // Frame counter
@@ -694,6 +714,45 @@ 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)|| defined(PLATFORM_ORBIS)
+void InitWindow(int width, int height, const char *title)
+{
+ TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
+ 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 });
+#else
+ // Set default texture and rectangle to be used for shapes drawing
+ // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
+ Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
+ SetShapesTexture(texture, (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f });
+#endif
+}
+#else
void InitWindow(int width, int height, const char *title)
{
TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
@@ -854,7 +913,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)
{
@@ -882,7 +941,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) || defined(PLATFORM_ORBIS)
// Close surface, context and display
if (CORE.Window.device != EGL_NO_DISPLAY)
{
@@ -1032,7 +1091,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) || defined(PLATFORM_ORBIS)
if (CORE.Window.ready) return CORE.Window.shouldClose;
else return true;
#endif
@@ -2636,13 +2695,16 @@ double GetTime(void)
return glfwGetTime(); // Elapsed time since glfwInit()
#endif
-#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
+#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_ORBIS)
struct timespec ts = { 0 };
clock_gettime(CLOCK_MONOTONIC, &ts);
unsigned long long int time = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
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)
@@ -2888,9 +2950,11 @@ const char *GetWorkingDirectory(void)
{
static char currentDir[MAX_FILEPATH_LENGTH] = { 0 };
memset(currentDir, 0, MAX_FILEPATH_LENGTH);
-
+#if !defined(PLATFORM_VITA) || !defined(PLATFORM_ORBIS)
char *path = GETCWD(currentDir, MAX_FILEPATH_LENGTH - 1);
-
+#else
+ char *path = ".";
+#endif
return path;
}
@@ -2948,8 +3012,11 @@ void ClearDirectoryFiles(void)
// Change working directory, returns true on success
bool ChangeDirectory(const char *dir)
{
+#if !defined(PLATFORM_VITA) || !defined(PLATFORM_ORBIS)
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);
@@ -3698,6 +3765,205 @@ 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) || defined(PLATFORM_ORBIS)
+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_ES3_BIT, // Always EGL_OPENGL_ES2_BIT or 0x4
+ EGL_NONE};
+
+ const EGLint contextAttribs[] =
+ {
+ EGL_CONTEXT_CLIENT_VERSION, 3,
+ EGL_NONE
+ };
+
+ const EGLint surfaceAttributes[] =
+ {
+ EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
+ EGL_NONE,
+ };
+ int ret;
+ #if defined(PLATFORM_ORBIS)
+ SceWindow render_window={0,width,height};
+ ScePglConfig pgl_config;
+ memset(&pgl_config, 0, sizeof(pgl_config));
+ {
+ pgl_config.size = sizeof(pgl_config);
+ pgl_config.flags = SCE_PGL_FLAGS_USE_COMPOSITE_EXT | SCE_PGL_FLAGS_USE_FLEXIBLE_MEMORY | 0x60;
+ pgl_config.processOrder = 1;
+ pgl_config.systemSharedMemorySize = 0x1000000;
+ pgl_config.videoSharedMemorySize = 0x3000000;
+ pgl_config.maxMappedFlexibleMemory = 0xFFFFFFFF;
+ pgl_config.drawCommandBufferSize = 0x100000;
+ pgl_config.lcueResourceBufferSize = 0x1000000;
+ pgl_config.dbgPosCmd_0x40 = 1920;
+ pgl_config.dbgPosCmd_0x44 = 1080;
+ pgl_config.dbgPosCmd_0x48 = 0;
+ pgl_config.dbgPosCmd_0x4C = 0;
+ pgl_config.unk_0x5C = 2;
+ }
+ ret=scePigletSetConfigurationVSH(&pgl_config);
+ if (!ret)
+ {
+ TRACELOG(LOG_WARNING, "DISPLAY: Failed on scePigletSetConfigurationVSH: 0x%08x", ret);
+ return false;
+ }
+ #endif
+ EGLint numConfigs = 0;
+ CORE.Window.device = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ //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);
+ 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\n",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.");
+ TRACELOG(LOG_TRACE, "DISPLAY: EGL matching configs available: %d", numConfigs);
+
+
+#if defined(PLATFORM_VITA)
+ CORE.Window.surface=eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, VITA_WINDOW_960X544, NULL);
+#else
+ CORE.Window.surface=eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, &render_window, surfaceAttributes);
+#endif
+ 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);
+
+ rlLoadExtensions(eglGetProcAddress);
+
+
+ //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
@@ -4450,7 +4716,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)
{
@@ -4568,7 +4834,7 @@ static void InitTimer(void)
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
#endif
-#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
+#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_ORBIS)
struct timespec now = { 0 };
if (clock_gettime(CLOCK_MONOTONIC, &now) == 0) // Success
@@ -4577,7 +4843,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
}
@@ -4635,7 +4903,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) || defined(PLATFORM_ORBIS)
eglSwapBuffers(CORE.Window.device, CORE.Window.surface);
#if defined(PLATFORM_DRM)
diff --git a/src/rlgl.h b/src/rlgl.h
index 4f9d8fa0..58c30f2d 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -129,7 +129,14 @@
#define TRACELOG(level, ...) (void)0
#define TRACELOGD(...) (void)0
#endif
-
+#if defined(PLATFORM_ORBIS)
+#include <stdio.h>
+#include <user_mem.h>
+extern char* default_vertex_shader;
+extern int default_vertex_shader_length;
+extern char* default_fragment_shader;
+extern int default_fragment_shader_length;
+#endif
// Allow custom memory allocators
#ifndef RL_MALLOC
#define RL_MALLOC(sz) malloc(sz)
@@ -963,11 +970,12 @@ static rlglData RLGL = { 0 };
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
#if defined(GRAPHICS_API_OPENGL_ES2)
+#if !defined(PLATFORM_ORBIS)
// NOTE: VAO functionality is exposed through extensions (OES)
static PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays = NULL;
static PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray = NULL;
static PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays = NULL;
-
+#endif
// NOTE: Instancing functionality could also be available through extension
static PFNGLDRAWARRAYSINSTANCEDEXTPROC glDrawArraysInstanced = NULL;
static PFNGLDRAWELEMENTSINSTANCEDEXTPROC glDrawElementsInstanced = NULL;
@@ -2040,6 +2048,7 @@ void rlLoadExtensions(void *loader)
{
// Check VAO support
// NOTE: Only check on OpenGL ES, OpenGL 3.3 has VAO support as core feature
+ #if !defined(PLATFORM_ORBIS)
if (strcmp(extList[i], (const char *)"GL_OES_vertex_array_object") == 0)
{
// The extension is supported by our hardware and driver, try to get related functions pointers
@@ -2051,6 +2060,9 @@ void rlLoadExtensions(void *loader)
if ((glGenVertexArrays != NULL) && (glBindVertexArray != NULL) && (glDeleteVertexArrays != NULL)) RLGL.ExtSupported.vao = true;
}
+ #else
+ RLGL.ExtSupported.vao = true;
+ #endif
// Check instanced rendering support
if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0) // Web ANGLE
@@ -2134,7 +2146,7 @@ void rlLoadExtensions(void *loader)
#endif
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &RLGL.ExtSupported.maxAnisotropyLevel);
-#if defined(RLGL_SHOW_GL_DETAILS_INFO)
+//#if defined(RLGL_SHOW_GL_DETAILS_INFO)
// Show some OpenGL GPU capabilities
TRACELOG(RL_LOG_INFO, "GL: OpenGL capabilities:");
GLint capability = 0;
@@ -2167,7 +2179,7 @@ void rlLoadExtensions(void *loader)
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability);
TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_LOCATIONS: %i", capability);
*/
-#else // RLGL_SHOW_GL_DETAILS_INFO
+//#else // RLGL_SHOW_GL_DETAILS_INFO
// Show some basic info about GL supported features
#if defined(GRAPHICS_API_OPENGL_ES2)
@@ -2183,7 +2195,7 @@ void rlLoadExtensions(void *loader)
if (RLGL.ExtSupported.texCompASTC) TRACELOG(RL_LOG_INFO, "GL: ASTC compressed textures supported");
if (RLGL.ExtSupported.computeShader) TRACELOG(RL_LOG_INFO, "GL: Compute shaders supported");
if (RLGL.ExtSupported.ssbo) TRACELOG(RL_LOG_INFO, "GL: Shader storage buffer objects supported");
-#endif // RLGL_SHOW_GL_DETAILS_INFO
+//#endif // RLGL_SHOW_GL_DETAILS_INFO
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
}
@@ -4265,6 +4277,37 @@ 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
+#if defined (PLATFORM_ORBIS)
+
+
+#else
const char *defaultVShaderCode =
#if defined(GRAPHICS_API_OPENGL_21)
"#version 120 \n"
@@ -4336,11 +4379,19 @@ static void rlLoadShaderDefault(void)
" gl_FragColor = texelColor*colDiffuse*fragColor; \n"
"} \n";
#endif
+#endif
+#endif
+#if defined(PLATFORM_ORBIS)
+ RLGL.State.defaultVShaderId=glCreateShader(GL_VERTEX_SHADER);
+ RLGL.State.defaultFShaderId=glCreateShader(GL_FRAGMENT_SHADER);
+ glShaderBinary(1, &RLGL.State.defaultVShaderId, 0, default_vertex_shader, default_vertex_shader_length);
+ glShaderBinary(1, &RLGL.State.defaultFShaderId, 0, default_fragment_shader, default_fragment_shader_length);
+#else
// NOTE: Compiled vertex/fragment shaders are kept for re-use
RLGL.State.defaultVShaderId = rlCompileShader(defaultVShaderCode, GL_VERTEX_SHADER); // Compile default vertex shader
RLGL.State.defaultFShaderId = rlCompileShader(defaultFShaderCode, GL_FRAGMENT_SHADER); // Compile default fragment shader
-
+#endif
RLGL.State.defaultShaderId = rlLoadShaderProgram(RLGL.State.defaultVShaderId, RLGL.State.defaultFShaderId);
if (RLGL.State.defaultShaderId > 0)
diff --git a/src/rmodels.c b/src/rmodels.c
index 8218a818..a5985f69 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -50,6 +50,9 @@
#include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality
#include <stdio.h> // Required for: sprintf()
+#if defined(PLATFORM_ORBIS)
+#include <user_mem.h>
+#endif
#include <stdlib.h> // Required for: malloc(), free()
#include <string.h> // Required for: memcmp(), strlen()
#include <math.h> // Required for: sinf(), cosf(), sqrtf(), fabsf()
@@ -1095,7 +1098,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
mesh->vboId[1] = rlLoadVertexBuffer(mesh->texcoords, mesh->vertexCount*2*sizeof(float), dynamic);
rlSetVertexAttribute(1, 2, RL_FLOAT, 0, 0, 0);
rlEnableVertexAttribute(1);
-
+#if !defined(PLATFORM_VITA) || !defined(PLATFORM_ORBIS)
if (mesh->normals != NULL)
{
// Enable vertex attributes: normals (shader-location = 2)
@@ -1111,7 +1114,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)
@@ -3741,11 +3744,12 @@ static Model LoadOBJ(const char *fileName)
char currentDir[1024] = { 0 };
strcpy(currentDir, GetWorkingDirectory());
const char *workingDir = GetDirectoryPath(fileName);
+#if !defined(PLATFORM_VITA) || !defined(PLATFORM_ORBIS)
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);
@@ -3888,12 +3892,13 @@ static Model LoadOBJ(const char *fileName)
RL_FREE(vtCount);
RL_FREE(vnCount);
RL_FREE(faceCount);
-
+#if !defined(PLATFORM_VITA) || !defined(PLATFORM_ORBIS)
if (CHDIR(currentDir) != 0)
{
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to change working directory", currentDir);
}
}
+#endif
return model;
}
diff --git a/src/utils.c b/src/utils.c
index 215454cc..748b5035 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -44,7 +44,10 @@
#include <android/log.h> // Required for: Android log system: __android_log_vprint()
#include <android/asset_manager.h> // Required for: Android assets manager: AAsset, AAssetManager_open(), ...
#endif
-
+#if defined(PLATFORM_ORBIS)
+#include <stdio.h>
+#include <user_mem.h>
+#endif
#include <stdlib.h> // Required for: exit()