From 30797d32010247257c38f7849ae8fd67193580cf Mon Sep 17 00:00:00 2001 From: gtrxAC <59177874+gtrxAC@users.noreply.github.com> Date: Thu, 10 Feb 2022 21:51:46 +0200 Subject: [PATCH 001/520] Update file names in build scripts (#2339) * JSON parser: Use array for function params (#2255) * Parser: follow C convention of type before name * Update file names in build scripts --- projects/scripts/build-linux.sh | 10 +++++----- projects/scripts/build-osx.sh | 10 +++++----- projects/scripts/build-rpi.sh | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) mode change 100644 => 100755 projects/scripts/build-linux.sh mode change 100644 => 100755 projects/scripts/build-osx.sh diff --git a/projects/scripts/build-linux.sh b/projects/scripts/build-linux.sh old mode 100644 new mode 100755 index 4f3871d03..ccae8d7ff --- a/projects/scripts/build-linux.sh +++ b/projects/scripts/build-linux.sh @@ -24,7 +24,7 @@ set -e while getopts ":hdusrcq" opt; do case $opt in h) - echo "Usage: ./linux-build.sh [-hdusrcqq]" + echo "Usage: ./build-linux.sh [-hdusrcqq]" echo " -h Show this information" echo " -d Faster builds that have debug symbols, and enable warnings" echo " -u Run upx* on the executable after compilation (before -r)" @@ -39,10 +39,10 @@ while getopts ":hdusrcq" opt; do echo " requires that you have upx installed and on your path, of course." echo "" echo "Examples:" - echo " Build a release build: ./linux-build.sh" - echo " Build a release build, full recompile: ./linux-build.sh -c" - echo " Build a debug build and run: ./linux-build.sh -d -r" - echo " Build in debug, run, don't print at all: ./linux-build.sh -drqq" + echo " Build a release build: ./build-linux.sh" + echo " Build a release build, full recompile: ./build-linux.sh -c" + echo " Build a debug build and run: ./build-linux.sh -d -r" + echo " Build in debug, run, don't print at all: ./build-linux.sh -drqq" exit 0 ;; d) diff --git a/projects/scripts/build-osx.sh b/projects/scripts/build-osx.sh old mode 100644 new mode 100755 index e7bf5cf92..e2ab834b1 --- a/projects/scripts/build-osx.sh +++ b/projects/scripts/build-osx.sh @@ -24,7 +24,7 @@ set -e while getopts ":hdusrcq" opt; do case $opt in h) - echo "Usage: ./osx-build.sh [-hdusrcqq]" + echo "Usage: ./build-osx.sh [-hdusrcqq]" echo " -h Show this information" echo " -d Faster builds that have debug symbols, and enable warnings" echo " -u Run upx* on the executable after compilation (before -r)" @@ -39,10 +39,10 @@ while getopts ":hdusrcq" opt; do echo " requires that you have upx installed and on your path, of course." echo "" echo "Examples:" - echo " Build a release build: ./osx-build.sh" - echo " Build a release build, full recompile: ./osx-build.sh -c" - echo " Build a debug build and run: ./osx-build.sh -d -r" - echo " Build in debug, run, don't print at all: ./osx-build.sh -drqq" + echo " Build a release build: ./build-osx.sh" + echo " Build a release build, full recompile: ./build-osx.sh -c" + echo " Build a debug build and run: ./build-osx.sh -d -r" + echo " Build in debug, run, don't print at all: ./build-osx.sh -drqq" exit 0 ;; d) diff --git a/projects/scripts/build-rpi.sh b/projects/scripts/build-rpi.sh index 7b4237f2f..646cf90c9 100755 --- a/projects/scripts/build-rpi.sh +++ b/projects/scripts/build-rpi.sh @@ -24,7 +24,7 @@ set -e while getopts ":hdusrcq" opt; do case $opt in h) - echo "Usage: ./linux-build.sh [-hdusrcqq]" + echo "Usage: ./build-rpi.sh [-hdusrcqq]" echo " -h Show this information" echo " -d Faster builds that have debug symbols, and enable warnings" echo " -u Run upx* on the executable after compilation (before -r)" @@ -39,10 +39,10 @@ while getopts ":hdusrcq" opt; do echo " requires that you have upx installed and on your path, of course." echo "" echo "Examples:" - echo " Build a release build: ./linux-build.sh" - echo " Build a release build, full recompile: ./linux-build.sh -c" - echo " Build a debug build and run: ./linux-build.sh -d -r" - echo " Build in debug, run, don't print at all: ./linux-build.sh -drqq" + echo " Build a release build: ./build-rpi.sh" + echo " Build a release build, full recompile: ./build-rpi.sh -c" + echo " Build a debug build and run: ./build-rpi.sh -d -r" + echo " Build in debug, run, don't print at all: ./build-rpi.sh -drqq" exit 0 ;; d) From 81cced4d83a388c387695a8a5477ff35e613e527 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Thu, 10 Feb 2022 19:52:34 +0000 Subject: [PATCH 002/520] Fix make clean target failing when shell is not cmd (#2338) GNU make on Windows first tries to find sh.exe on the path, and will execute build rules using it if it is present. The make clean target uses the builtin cmd.exe command del, which won't work under sh.exe The reason this is not done for the entire Makefile is because it would break cross-compilation of raylib. --- src/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Makefile b/src/Makefile index ddac896cb..3048f98a4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -731,6 +731,12 @@ endif # Clean everything clean: ifeq ($(PLATFORM_OS),WINDOWS) + # Make always tries to run build rules under sh.exe by default + # So if sh.exe is present in the PATH on windows, the del commands will fail + # see README.W32 of GNU Make for more details + # It is not specified earlier in the Makefile, because then cross-compilation + # will also fail. + SHELL = cmd del *.o /s cd $(RAYLIB_RELEASE_PATH) del lib$(RAYLIB_LIB_NAME).a /s From ab47c6401e3a7da22a2e9e1f4a2a63144d51e13a Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 12 Feb 2022 17:37:12 +0100 Subject: [PATCH 003/520] Reviewed Makefile clean target to use CMD shell on Windows Tested on the following environments: - w64devkit.exe - Windows 10 cmd - Notepad++ NppExec console --- src/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3048f98a4..c63326e10 100644 --- a/src/Makefile +++ b/src/Makefile @@ -36,7 +36,6 @@ # NOTE: Highly recommended to read the raylib Wiki to know how to compile raylib for different platforms # https://github.com/raysan5/raylib/wiki - .PHONY: all clean install uninstall # Define required environment variables @@ -106,6 +105,7 @@ ROOT = $(shell whoami) # By default we suppose we are working on Windows HOST_PLATFORM_OS ?= WINDOWS +PLATFORM_OS ?= WINDOWS # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -148,6 +148,12 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif endif +ifeq ($(PLATFORM_OS),WINDOWS) + # Make uses by default Sh shell, if a different shell is required, it must be specified + # On Windows we set CMD as default shell to allow calling del command on clean target + SHELL := cmd +endif + ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH ?= C:/emsdk @@ -731,12 +737,6 @@ endif # Clean everything clean: ifeq ($(PLATFORM_OS),WINDOWS) - # Make always tries to run build rules under sh.exe by default - # So if sh.exe is present in the PATH on windows, the del commands will fail - # see README.W32 of GNU Make for more details - # It is not specified earlier in the Makefile, because then cross-compilation - # will also fail. - SHELL = cmd del *.o /s cd $(RAYLIB_RELEASE_PATH) del lib$(RAYLIB_LIB_NAME).a /s From ddba8478c53f32e00b89432b960d2c69392e4360 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 12 Feb 2022 17:58:38 +0100 Subject: [PATCH 004/520] Revert "Reviewed Makefile clean target to use CMD shell on Windows" This reverts commit ab47c6401e3a7da22a2e9e1f4a2a63144d51e13a. --- src/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index c63326e10..3048f98a4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -36,6 +36,7 @@ # NOTE: Highly recommended to read the raylib Wiki to know how to compile raylib for different platforms # https://github.com/raysan5/raylib/wiki + .PHONY: all clean install uninstall # Define required environment variables @@ -105,7 +106,6 @@ ROOT = $(shell whoami) # By default we suppose we are working on Windows HOST_PLATFORM_OS ?= WINDOWS -PLATFORM_OS ?= WINDOWS # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -148,12 +148,6 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif endif -ifeq ($(PLATFORM_OS),WINDOWS) - # Make uses by default Sh shell, if a different shell is required, it must be specified - # On Windows we set CMD as default shell to allow calling del command on clean target - SHELL := cmd -endif - ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH ?= C:/emsdk @@ -737,6 +731,12 @@ endif # Clean everything clean: ifeq ($(PLATFORM_OS),WINDOWS) + # Make always tries to run build rules under sh.exe by default + # So if sh.exe is present in the PATH on windows, the del commands will fail + # see README.W32 of GNU Make for more details + # It is not specified earlier in the Makefile, because then cross-compilation + # will also fail. + SHELL = cmd del *.o /s cd $(RAYLIB_RELEASE_PATH) del lib$(RAYLIB_LIB_NAME).a /s From dd15531e25b73f1b3d37196effd5ac7685d8026e Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Sat, 12 Feb 2022 16:59:48 +0000 Subject: [PATCH 005/520] Properly fix make clean under windows (#2341) * Properly fix make clean under sh.exe * Ensure make clean works properly under Windows if RAYLIB_RELEASE_PATH is modified --- src/Makefile | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3048f98a4..f543b0b51 100644 --- a/src/Makefile +++ b/src/Makefile @@ -728,24 +728,24 @@ else @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall" endif +.PHONY: clean_LINUX clean_WINDOWS clean_ANDROID clean_BSD clean_OSX + # Clean everything -clean: -ifeq ($(PLATFORM_OS),WINDOWS) - # Make always tries to run build rules under sh.exe by default - # So if sh.exe is present in the PATH on windows, the del commands will fail - # see README.W32 of GNU Make for more details - # It is not specified earlier in the Makefile, because then cross-compilation - # will also fail. - SHELL = cmd - del *.o /s - cd $(RAYLIB_RELEASE_PATH) - del lib$(RAYLIB_LIB_NAME).a /s - del lib$(RAYLIB_LIB_NAME)dll.a /s - del $(RAYLIB_LIB_NAME).dll /s -else - rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* -endif -ifeq ($(PLATFORM),PLATFORM_ANDROID) - rm -rf $(ANDROID_TOOLCHAIN) $(NATIVE_APP_GLUE)/android_native_app_glue.o -endif +clean: clean_$(PLATFORM_OS) @echo "removed all generated files!" + +clean_LINUX clean_BSD clean_OSX: + rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* + +clean_ANDROID: + rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* + rm -rf $(ANDROID_TOOLCHAIN) $(NATIVE_APP_GLUE)/android_native_app_glue.o + +clean_WINDOWS: SHELL := cmd.exe + +clean_WINDOWS: + del *.o /s + cd $(RAYLIB_RELEASE_PATH) & \ + del lib$(RAYLIB_LIB_NAME).a /s & \ + del lib$(RAYLIB_LIB_NAME)dll.a /s & \ + del $(RAYLIB_LIB_NAME).dll /s From d0008ae8cda8e0a7dda68b18c9e4be12fff00ae6 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 12 Feb 2022 18:06:21 +0100 Subject: [PATCH 006/520] REVIEWED: Issue when compiling for PLATFORM_WEB --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index f543b0b51..c29701a36 100644 --- a/src/Makefile +++ b/src/Makefile @@ -106,6 +106,7 @@ ROOT = $(shell whoami) # By default we suppose we are working on Windows HOST_PLATFORM_OS ?= WINDOWS +PLATFORM_OS ?= WINDOWS # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -741,8 +742,8 @@ clean_ANDROID: rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* rm -rf $(ANDROID_TOOLCHAIN) $(NATIVE_APP_GLUE)/android_native_app_glue.o +# Set specific target variable clean_WINDOWS: SHELL := cmd.exe - clean_WINDOWS: del *.o /s cd $(RAYLIB_RELEASE_PATH) & \ From 6ef6dbff2d86d8fbf11a138cafd17d13e791604e Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 12 Feb 2022 19:08:31 +0100 Subject: [PATCH 007/520] REVIEWED: PLATFORM_OS for PLATFORM_WEB --- src/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Makefile b/src/Makefile index c29701a36..cb9bb88c6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -148,6 +148,16 @@ ifeq ($(PLATFORM),PLATFORM_DRM) PLATFORM_OS = LINUX endif endif +ifeq ($(PLATFORM),PLATFORM_WEB) + ifeq ($(OS),Windows_NT) + PLATFORM_OS = WINDOWS + else + UNAMEOS = $(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS = LINUX + endif + endif +endif ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables From 2f3fc41c33d4d380cdfd251a7e9987758202c5ae Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 12 Feb 2022 19:31:27 +0100 Subject: [PATCH 008/520] Allow setting a custom PLATFORM_SHELL --- src/Makefile | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Makefile b/src/Makefile index cb9bb88c6..279f39cd9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -114,6 +114,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) PLATFORM_OS = WINDOWS + ifndef PLATFORM_SHELL + PLATFORM_SHELL = cmd + endif else UNAMEOS = $(shell uname) ifeq ($(UNAMEOS),Linux) @@ -134,6 +137,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(UNAMEOS),Darwin) PLATFORM_OS = OSX endif + ifndef PLATFORM_SHELL + PLATFORM_SHELL = cmd + endif endif endif ifeq ($(PLATFORM),PLATFORM_RPI) @@ -141,21 +147,33 @@ ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(UNAMEOS),Linux) PLATFORM_OS = LINUX endif + ifndef PLATFORM_SHELL + PLATFORM_SHELL = cmd + endif endif ifeq ($(PLATFORM),PLATFORM_DRM) UNAMEOS = $(shell uname) ifeq ($(UNAMEOS),Linux) PLATFORM_OS = LINUX endif + ifndef PLATFORM_SHELL + PLATFORM_SHELL = cmd + endif endif ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(OS),Windows_NT) PLATFORM_OS = WINDOWS + ifndef PLATFORM_SHELL + PLATFORM_SHELL = cmd + endif else UNAMEOS = $(shell uname) ifeq ($(UNAMEOS),Linux) PLATFORM_OS = LINUX endif + ifndef PLATFORM_SHELL + PLATFORM_SHELL = sh + endif endif endif @@ -739,22 +757,21 @@ else @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall" endif -.PHONY: clean_LINUX clean_WINDOWS clean_ANDROID clean_BSD clean_OSX +.PHONY: clean_shell_cmd clean_shell_sh # Clean everything -clean: clean_$(PLATFORM_OS) +clean: clean_shell_$(PLATFORM_SHELL) @echo "removed all generated files!" -clean_LINUX clean_BSD clean_OSX: - rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* - -clean_ANDROID: +clean_shell_sh: rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* +ifeq ($(PLATFORM),PLATFORM_ANDROID) rm -rf $(ANDROID_TOOLCHAIN) $(NATIVE_APP_GLUE)/android_native_app_glue.o +endif # Set specific target variable -clean_WINDOWS: SHELL := cmd.exe -clean_WINDOWS: +clean_shell_cmd: SHELL=cmd +clean_shell_cmd: del *.o /s cd $(RAYLIB_RELEASE_PATH) & \ del lib$(RAYLIB_LIB_NAME).a /s & \ From 8c9a0221a4cbb60d14c62b21666547a01c253865 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 12 Feb 2022 19:38:14 +0100 Subject: [PATCH 009/520] Update Makefile --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 279f39cd9..20809be19 100644 --- a/src/Makefile +++ b/src/Makefile @@ -766,7 +766,7 @@ clean: clean_shell_$(PLATFORM_SHELL) clean_shell_sh: rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* ifeq ($(PLATFORM),PLATFORM_ANDROID) - rm -rf $(ANDROID_TOOLCHAIN) $(NATIVE_APP_GLUE)/android_native_app_glue.o + rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o endif # Set specific target variable From 9cf170e6e91670eade739c1cffefe8e1ea24980b Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 13 Feb 2022 10:47:09 +0100 Subject: [PATCH 010/520] Reviewed makefile to use right shell on right platform --- src/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Makefile b/src/Makefile index 20809be19..87d76a650 100644 --- a/src/Makefile +++ b/src/Makefile @@ -42,7 +42,7 @@ # Define required environment variables #------------------------------------------------------------------------------------------------ # Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP +PLATFORM ?= PLATFORM_DESKTOP # Define required raylib variables RAYLIB_VERSION = 4.0.0 @@ -138,7 +138,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) PLATFORM_OS = OSX endif ifndef PLATFORM_SHELL - PLATFORM_SHELL = cmd + PLATFORM_SHELL = sh endif endif endif @@ -148,7 +148,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI) PLATFORM_OS = LINUX endif ifndef PLATFORM_SHELL - PLATFORM_SHELL = cmd + PLATFORM_SHELL = sh endif endif ifeq ($(PLATFORM),PLATFORM_DRM) @@ -157,7 +157,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM) PLATFORM_OS = LINUX endif ifndef PLATFORM_SHELL - PLATFORM_SHELL = cmd + PLATFORM_SHELL = sh endif endif ifeq ($(PLATFORM),PLATFORM_WEB) @@ -297,7 +297,7 @@ endif #------------------------------------------------------------------------------------------------ # -O1 defines optimization level # -g include debug information on compilation -# -s strip unnecessary data from build +# -s strip unnecessary data from build --> linker # -Wall turns on most, but not all, compiler warnings # -std=c99 defines C language mode (standard C from 1999 revision) # -std=gnu99 defines C language mode (GNU C from 1999 revision) @@ -331,7 +331,7 @@ ifeq ($(RAYLIB_BUILD_MODE),RELEASE) CFLAGS += -Os endif ifeq ($(PLATFORM),PLATFORM_DESKTOP) - CFLAGS += -s -O1 + CFLAGS += -O1 endif ifeq ($(PLATFORM),PLATFORM_ANDROID) CFLAGS += -O2 From 4bc6e0d7de105820e2dbddb6e134539aa781ca86 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 13 Feb 2022 10:47:19 +0100 Subject: [PATCH 011/520] Update rtext.c --- src/rtext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtext.c b/src/rtext.c index f07b8804a..a62f0d834 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -960,7 +960,7 @@ bool ExportFontAsCode(Font font, const char *fileName) byteCount += sprintf(txtData + byteCount, " font.glyphs = fontGlyphs_%s;\n\n", fileNamePascal); #endif byteCount += sprintf(txtData + byteCount, " return font;\n"); - byteCount += sprintf(txtData + byteCount, "}\n\0"); + byteCount += sprintf(txtData + byteCount, "}\n"); UnloadImage(image); From f40eed5adf6a707250ac6c7783fe5eb097d29297 Mon Sep 17 00:00:00 2001 From: megagrump <31128870+megagrump@users.noreply.github.com> Date: Sun, 13 Feb 2022 18:42:24 +0100 Subject: [PATCH 012/520] add premultiplied alpha blend mode (#2342) --- src/raylib.h | 1 + src/rlgl.h | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 70384e281..315658917 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -839,6 +839,7 @@ typedef enum { BLEND_MULTIPLIED, // Blend textures multiplying colors BLEND_ADD_COLORS, // Blend textures adding colors (alternative) BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) + BLEND_ALPHA_PREMUL, // Blend premultiplied textures considering alpha BLEND_CUSTOM // Blend textures using custom src/dst factors (use rlSetBlendMode()) } BlendMode; diff --git a/src/rlgl.h b/src/rlgl.h index fa096ca6b..f3977e670 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -433,6 +433,7 @@ typedef enum { RL_BLEND_MULTIPLIED, // Blend textures multiplying colors RL_BLEND_ADD_COLORS, // Blend textures adding colors (alternative) RL_BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) + RL_BLEND_ALPHA_PREMUL, // Blend premultiplied textures considering alpha RL_BLEND_CUSTOM // Blend textures using custom src/dst factors (use rlSetBlendFactors()) } rlBlendMode; @@ -1778,10 +1779,11 @@ void rlSetBlendMode(int mode) case RL_BLEND_MULTIPLIED: glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; case RL_BLEND_ADD_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_ADD); break; case RL_BLEND_SUBTRACT_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_SUBTRACT); break; - case RL_BLEND_CUSTOM: + case RL_BLEND_ALPHA_PREMUL: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; + case RL_BLEND_CUSTOM: { // NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors() - glBlendFunc(RLGL.State.glBlendSrcFactor, RLGL.State.glBlendDstFactor); glBlendEquation(RLGL.State.glBlendEquation); + glBlendFunc(RLGL.State.glBlendSrcFactor, RLGL.State.glBlendDstFactor); glBlendEquation(RLGL.State.glBlendEquation); } break; default: break; } @@ -3911,7 +3913,7 @@ void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned unsigned int rlLoadShaderBuffer(unsigned long long size, const void *data, int usageHint) { unsigned int ssbo = 0; - + #if defined(GRAPHICS_API_OPENGL_43) glGenBuffers(1, &ssbo); glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo); @@ -3944,7 +3946,7 @@ void rlUpdateShaderBufferElements(unsigned int id, const void *data, unsigned lo unsigned long long rlGetShaderBufferSize(unsigned int id) { long long size = 0; - + #if defined(GRAPHICS_API_OPENGL_43) glBindBuffer(GL_SHADER_STORAGE_BUFFER, id); glGetInteger64v(GL_SHADER_STORAGE_BUFFER_SIZE, &size); From b54e9db7647ae6e5ed86a8a5d92dbd63157c89ac Mon Sep 17 00:00:00 2001 From: Jaedeok Kim Date: Mon, 14 Feb 2022 02:43:17 +0900 Subject: [PATCH 013/520] Optimize `Vector2Rotate()` function (#2340) --- src/raymath.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 51dc2abc1..00c134d89 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -189,7 +189,7 @@ RMAPI float Normalize(float value, float start, float end) // Remap input value within input range to output range RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd) { - float result =(value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart; + float result = (value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart; return result; } @@ -378,8 +378,11 @@ RMAPI Vector2 Vector2Rotate(Vector2 v, float angle) { Vector2 result = { 0 }; - result.x = v.x*cosf(angle) - v.y*sinf(angle); - result.y = v.x*sinf(angle) + v.y*cosf(angle); + float cosres = cosf(angle); + float sinres = sinf(angle); + + result.x = v.x*cosres - v.y*sinres; + result.y = v.x*sinres + v.y*cosres; return result; } From 4815065c47da8e4cbab2600a247f34ed32d538f1 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 15 Feb 2022 18:35:17 +0000 Subject: [PATCH 014/520] Update Raylib-cs bindings version (#2343) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index ac79a1fa9..4c72acbe6 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -7,7 +7,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to | name | raylib version | language | license | repo | |:------------------:|:---------------:|:---------:|:----------:|-----------------------------------------------------------| | raylib | **4.0** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib | -| Raylib-cs | 3.7 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs | +| Raylib-cs | **4.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs | | Raylib-CsLo | **4.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo | | raylib-boo | 3.7 | [Boo](http://boo-language.github.io/)| MIT | https://github.com/Rabios/raylib-boo | | bindbc-raylib3 | **4.0** | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 | From 4f2bfc54760cbcbf142417b0bb24ddebf9ee4221 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 15 Feb 2022 19:38:28 +0100 Subject: [PATCH 015/520] Reviewed bug on `FindNearestConnectorMode()` --- src/rcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rcore.c b/src/rcore.c index f0652d3bb..44d65c7b7 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -6580,7 +6580,7 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt TRACELOG(LOG_TRACE, "DISPLAY: DRM mode: %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh, (mode->flags & DRM_MODE_FLAG_INTERLACE) ? "interlaced" : "progressive"); - if ((mode->hdisplay < width) || (mode->vdisplay < height) | (mode->vrefresh < fps)) + if ((mode->hdisplay < width) || (mode->vdisplay < height) || (mode->vrefresh < fps)) { TRACELOG(LOG_TRACE, "DISPLAY: DRM mode is too small"); continue; From 963de06d08f28784e03b6cfa994d545f9e0ef8b5 Mon Sep 17 00:00:00 2001 From: Antonis Geralis <43617260+planetis-m@users.noreply.github.com> Date: Thu, 17 Feb 2022 01:54:21 +0200 Subject: [PATCH 016/520] follow style guide (#2346) * follow style guide * Update rmodels.c --- src/raylib.h | 2 +- src/rmodels.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 315658917..9f4e7caab 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1456,7 +1456,7 @@ RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount); // Load model animations from file RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data -RLAPI void UnloadModelAnimations(ModelAnimation* animations, unsigned int count); // Unload animation array data +RLAPI void UnloadModelAnimations(ModelAnimation *animations, unsigned int count); // Unload animation array data RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match // Collision detection functions diff --git a/src/rmodels.c b/src/rmodels.c index 601ce234d..c15c4c07b 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -1930,7 +1930,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) } // Unload animation array data -void UnloadModelAnimations(ModelAnimation* animations, unsigned int count) +void UnloadModelAnimations(ModelAnimation *animations, unsigned int count) { for (unsigned int i = 0; i < count; i++) UnloadModelAnimation(animations[i]); RL_FREE(animations); @@ -4301,7 +4301,7 @@ static Model LoadIQM(const char *fileName) } // Load IQM animation data -static ModelAnimation* LoadModelAnimationsIQM(const char *fileName, unsigned int *animCount) +static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int *animCount) { #define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number #define IQM_VERSION 2 // only IQM version 2 supported From d4382f4a52e7631bf02ff8073ed24b282596ce0a Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 18 Feb 2022 20:30:46 +0100 Subject: [PATCH 017/520] Removed trailing spaces --- src/raudio.c | 4 +- src/rcore.c | 36 ++++++++-------- src/rmodels.c | 20 ++++----- src/rshapes.c | 20 ++++----- src/rtext.c | 6 +-- src/rtextures.c | 14 +++--- src/shell.html | 112 ++++++++++++++++++++++++------------------------ 7 files changed, 106 insertions(+), 106 deletions(-) diff --git a/src/raudio.c b/src/raudio.c index 5abb1d05c..2d41b2385 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -664,7 +664,7 @@ void SetAudioBufferPitch(AudioBuffer *buffer, float pitch) // Set pan for an audio buffer void SetAudioBufferPan(AudioBuffer *buffer, float pan) { - if (pan < 0.0f) pan = 0.0f; + if (pan < 0.0f) pan = 0.0f; else if (pan > 1.0f) pan = 1.0f; if (buffer != NULL) buffer->pan = pan; @@ -998,7 +998,7 @@ bool ExportWaveAsCode(Wave wave, const char *fileName) success = SaveFileText(fileName, txtData); RL_FREE(txtData); - + if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Wave as code exported successfully", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export wave as code", fileName); diff --git a/src/rcore.c b/src/rcore.c index 44d65c7b7..2b0164ee2 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -722,7 +722,7 @@ struct android_app *GetAndroidApp(void) 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)"); @@ -731,12 +731,12 @@ void InitWindow(int width, int height, const char *title) #else TRACELOG(LOG_INFO, " > rshapes:... not loaded (optional)"); #endif -#if defined(SUPPORT_MODULE_RTEXTURES) +#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) +#endif +#if defined(SUPPORT_MODULE_RTEXT) TRACELOG(LOG_INFO, " > rtext:..... loaded (optional)"); #else TRACELOG(LOG_INFO, " > rtext:..... not loaded (optional)"); @@ -746,7 +746,7 @@ void InitWindow(int width, int height, const char *title) #else TRACELOG(LOG_INFO, " > rmodels:... not loaded (optional)"); #endif -#if defined(SUPPORT_MODULE_RAUDIO) +#if defined(SUPPORT_MODULE_RAUDIO) TRACELOG(LOG_INFO, " > raudio:.... loaded (optional)"); #else TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)"); @@ -890,7 +890,7 @@ void InitWindow(int width, int height, const char *title) //emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback); // Trigger this once to get initial window sizing //EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL); - + // Support keyboard events -> Not used, GLFW.JS takes care of that //emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback); //emscripten_set_keydown_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback); @@ -1276,7 +1276,7 @@ void ToggleFullscreen(void) int width, height; emscripten_get_canvas_element_size("#canvas", &width, &height); TRACELOG(LOG_WARNING, "Emscripten: Exit fullscreen: Canvas size: %i x %i", width, height); - + CORE.Window.fullscreen = false; // Toggle fullscreen flag CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE; } @@ -2750,7 +2750,7 @@ void TakeScreenshot(const char *fileName) char path[2048] = { 0 }; strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName)); - + ExportImage(image, path); // WARNING: Module required: rtextures RL_FREE(imgData); @@ -2798,7 +2798,7 @@ bool FileExists(const char *fileName) // NOTE: Alternatively, stat() can be used instead of access() //#include - //struct stat statbuf; + //struct stat statbuf; //if (stat(filename, &statbuf) == 0) result = true; return result; @@ -2856,9 +2856,9 @@ bool DirectoryExists(const char *dirPath) int GetFileLength(const char *fileName) { int size = 0; - + FILE *file = fopen(fileName, "rb"); - + if (file != NULL) { fseek(file, 0L, SEEK_END); @@ -3093,7 +3093,7 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount) if (dir != NULL) // It's a directory { // Count files - while ((entity = readdir(dir)) != NULL) counter++; + while ((entity = readdir(dir)) != NULL) counter++; dirFileCount = counter; *fileCount = dirFileCount; @@ -3101,7 +3101,7 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount) // Memory allocation for dirFileCount dirFilesPath = (char **)RL_MALLOC(dirFileCount*sizeof(char *)); for (int i = 0; i < dirFileCount; i++) dirFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char)); - + // Reset our position in the directory to the beginning rewinddir(dir); @@ -4162,7 +4162,7 @@ static bool InitGraphicsDevice(int width, int height) glfwSwapInterval(1); TRACELOG(LOG_INFO, "DISPLAY: Trying to enable VSYNC"); } - + int fbWidth = CORE.Window.screen.width; int fbHeight = CORE.Window.screen.height; @@ -4187,7 +4187,7 @@ static bool InitGraphicsDevice(int width, int height) CORE.Window.render.height = fbHeight; CORE.Window.currentFbo.width = fbWidth; CORE.Window.currentFbo.height = fbHeight; - + TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); @@ -4601,7 +4601,7 @@ static bool InitGraphicsDevice(int width, int height) CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.currentFbo.width = CORE.Window.render.width; CORE.Window.currentFbo.height = CORE.Window.render.height; - + TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); @@ -4940,7 +4940,7 @@ void PollInputEvents(void) // Register previous touch states for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; - + // Reset touch positions // TODO: It resets on PLATFORM_WEB the mouse position and not filled again until a move-event, // so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed! @@ -5224,7 +5224,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key; CORE.Input.Keyboard.keyPressedQueueCount++; } - + // Check the exit key to set close window if ((key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(CORE.Window.handle, GLFW_TRUE); diff --git a/src/rmodels.c b/src/rmodels.c index c15c4c07b..223414cde 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -1692,7 +1692,7 @@ bool ExportMesh(Mesh mesh, const char *fileName) { for (int i = 0, v = 0; i < mesh.triangleCount; i++, v += 3) { - byteCount += sprintf(txtData + byteCount, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", + byteCount += sprintf(txtData + byteCount, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", mesh.indices[v] + 1, mesh.indices[v] + 1, mesh.indices[v] + 1, mesh.indices[v + 1] + 1, mesh.indices[v + 1] + 1, mesh.indices[v + 1] + 1, mesh.indices[v + 2] + 1, mesh.indices[v + 2] + 1, mesh.indices[v + 2] + 1); @@ -4543,7 +4543,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat cgltf_options options = { 0 }; cgltf_result result = cgltf_load_buffer_base64(&options, outSize, cgltfImage->uri + i + 1, &data); - + if (result == cgltf_result_success) { image = LoadImageFromMemory(".png", (unsigned char *)data, outSize); @@ -4571,12 +4571,12 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat // Check mime_type for image: (cgltfImage->mime_type == "image/png") // NOTE: Detected that some models define mime_type as "image\\/png" - if ((strcmp(cgltfImage->mime_type, "image\\/png") == 0) || + if ((strcmp(cgltfImage->mime_type, "image\\/png") == 0) || (strcmp(cgltfImage->mime_type, "image/png") == 0)) image = LoadImageFromMemory(".png", data, (int)cgltfImage->buffer_view->size); else if ((strcmp(cgltfImage->mime_type, "image\\/jpeg") == 0) || (strcmp(cgltfImage->mime_type, "image/jpeg") == 0)) image = LoadImageFromMemory(".jpg", data, (int)cgltfImage->buffer_view->size); else TRACELOG(LOG_WARNING, "MODEL: glTF image data MIME type not recognized", TextFormat("%s/%s", texPath, cgltfImage->uri)); - + RL_FREE(data); } @@ -4637,7 +4637,7 @@ static Model LoadGLTF(const char *fileName) cgltf_options options = { 0 }; cgltf_data *data = NULL; cgltf_result result = cgltf_parse(&options, fileData, dataSize, &data); - + if (result == cgltf_result_success) { if (data->file_type == cgltf_file_type_glb) TRACELOG(LOG_INFO, "MODEL: [%s] Model basic data (glb) loaded successfully", fileName); @@ -4665,7 +4665,7 @@ static Model LoadGLTF(const char *fileName) for (int i = 0; i < model.meshCount; i++) model.meshes[i].vboId = (unsigned int*)RL_CALLOC(MAX_MESH_VERTEX_BUFFERS, sizeof(unsigned int)); // NOTE: We keep an extra slot for default material, in case some mesh requires it - model.materialCount = (int)data->materials_count + 1; + model.materialCount = (int)data->materials_count + 1; model.materials = RL_CALLOC(model.materialCount, sizeof(Material)); model.materials[0] = LoadMaterialDefault(); // Load default material (index: 0) @@ -4708,8 +4708,8 @@ static Model LoadGLTF(const char *fileName) model.materials[j].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTextureFromImage(imMetallicRoughness); UnloadImage(imMetallicRoughness); } - - // Load metallic/roughness material properties + + // Load metallic/roughness material properties float roughness = data->materials[i].pbr_metallic_roughness.roughness_factor; model.materials[j].maps[MATERIAL_MAP_ROUGHNESS].value = roughness; @@ -4757,7 +4757,7 @@ static Model LoadGLTF(const char *fileName) } } - // Other possible materials not supported by raylib pipeline: + // Other possible materials not supported by raylib pipeline: // has_clearcoat, has_transmission, has_volume, has_ior, has specular, has_sheen } @@ -4787,7 +4787,7 @@ static Model LoadGLTF(const char *fileName) if ((attribute->component_type == cgltf_component_type_r_32f) && (attribute->type == cgltf_type_vec3)) { - // Init raylib mesh vertices to copy glTF attribute data + // Init raylib mesh vertices to copy glTF attribute data model.meshes[meshIndex].vertexCount = (int)attribute->count; model.meshes[meshIndex].vertices = RL_MALLOC(attribute->count*3*sizeof(float)); diff --git a/src/rshapes.c b/src/rshapes.c index d93b4db6f..79631d622 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -6,12 +6,12 @@ * Shapes can be draw using 3 types of primitives: LINES, TRIANGLES and QUADS. * Some functions implement two drawing options: TRIANGLES and QUADS, by default TRIANGLES * are used but QUADS implementation can be selected with SUPPORT_QUADS_DRAW_MODE define -* -* Some functions define texture coordinates (rlTexCoord2f()) for the shapes and use a +* +* Some functions define texture coordinates (rlTexCoord2f()) for the shapes and use a * user-provided texture with SetShapesTexture(), the pourpouse of this implementation * is allowing to reduce draw calls when combined with a texture-atlas. * -* By default, raylib sets the default texture and rectangle at InitWindow()[rcore] to one +* By default, raylib sets the default texture and rectangle at InitWindow()[rcore] to one * white character of default font [rtext], this way, raylib text and shapes can be draw with * a single draw call and it also allows users to configure it the same way with their own fonts. * @@ -723,7 +723,7 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color rlCheckRenderBatchLimit(4); rlSetTexture(texShapes.id); - + rlBegin(RL_QUADS); rlNormal3f(0.0f, 0.0f, 1.0f); @@ -742,13 +742,13 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color rlVertex2f(topRight.x, topRight.y); rlEnd(); - + rlSetTexture(0); #else rlCheckRenderBatchLimit(6); rlBegin(RL_TRIANGLES); - + rlColor4ub(color.r, color.g, color.b, color.a); rlVertex2f(topLeft.x, topLeft.y); @@ -1609,7 +1609,7 @@ bool CheckCollisionPointRec(Vector2 point, Rectangle rec) bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius) { bool collision = false; - + collision = CheckCollisionCircles(point, 0, center, radius); return collision; @@ -1681,7 +1681,7 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec) (dy - rec.height/2.0f)*(dy - rec.height/2.0f); collision = (cornerDistanceSq <= (radius*radius)); - + return collision; } @@ -1695,10 +1695,10 @@ bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, if (fabsf(div) >= FLT_EPSILON) { collision = true; - + float xi = ((startPos2.x - endPos2.x)*(startPos1.x*endPos1.y - startPos1.y*endPos1.x) - (startPos1.x - endPos1.x)*(startPos2.x*endPos2.y - startPos2.y*endPos2.x))/div; float yi = ((startPos2.y - endPos2.y)*(startPos1.x*endPos1.y - startPos1.y*endPos1.x) - (startPos1.y - endPos1.y)*(startPos2.x*endPos2.y - startPos2.y*endPos2.x))/div; - + if (((fabsf(startPos1.x - endPos1.x) > FLT_EPSILON) && (xi < fminf(startPos1.x, endPos1.x) || (xi > fmaxf(startPos1.x, endPos1.x)))) || ((fabsf(startPos2.x - endPos2.x) > FLT_EPSILON) && (xi < fminf(startPos2.x, endPos2.x) || (xi > fmaxf(startPos2.x, endPos2.x)))) || ((fabsf(startPos1.y - endPos1.y) > FLT_EPSILON) && (yi < fminf(startPos1.y, endPos1.y) || (yi > fmaxf(startPos1.y, endPos1.y)))) || diff --git a/src/rtext.c b/src/rtext.c index a62f0d834..0a8af79e1 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -825,7 +825,7 @@ void UnloadFont(Font font) bool ExportFontAsCode(Font font, const char *fileName) { bool success = false; - + #ifndef TEXT_BYTES_PER_LINE #define TEXT_BYTES_PER_LINE 20 #endif @@ -865,7 +865,7 @@ bool ExportFontAsCode(Font font, const char *fileName) Image image = LoadImageFromTexture(font.texture); if (image.format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) TRACELOG(LOG_WARNING, "Font export as code: Font image format is not GRAY+ALPHA!"); int imageDataSize = GetPixelDataSize(image.width, image.height, image.format); - + // Image data is usually GRAYSCALE + ALPHA and can be reduced to GRAYSCALE //ImageFormat(&image, PIXELFORMAT_UNCOMPRESSED_GRAYSCALE); @@ -874,7 +874,7 @@ bool ExportFontAsCode(Font font, const char *fileName) // WARNING: Data is compressed using raylib CompressData() DEFLATE, // it requires to be decompressed with raylib DecompressData(), that requires // compiling raylib with SUPPORT_COMPRESSION_API config flag enabled - + // Compress font image data int compDataSize = 0; unsigned char *compData = CompressData(image.data, imageDataSize, &compDataSize); diff --git a/src/rtextures.c b/src/rtextures.c index 12732274f..c4cf1903e 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -133,7 +133,7 @@ #if defined(SUPPORT_FILEFORMAT_QOI) #define QOI_MALLOC RL_MALLOC #define QOI_FREE RL_FREE - + #define QOI_IMPLEMENTATION #include "external/qoi.h" #endif @@ -375,7 +375,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i } #endif #if defined(SUPPORT_FILEFORMAT_QOI) - else if (strcmp(fileType, ".qoi") == 0) + else if (strcmp(fileType, ".qoi") == 0) { qoi_desc desc = { 0 }; image.data = qoi_decode(fileData, dataSize, &desc, 4); @@ -500,7 +500,7 @@ bool ExportImage(Image image, const char *fileName) else if (IsFileExtension(fileName, ".tga")) success = stbi_write_tga(fileName, image.width, image.height, channels, imgData); #endif #if defined(SUPPORT_FILEFORMAT_JPG) - else if (IsFileExtension(fileName, ".jpg") || + else if (IsFileExtension(fileName, ".jpg") || IsFileExtension(fileName, ".jpeg")) success = stbi_write_jpg(fileName, image.width, image.height, channels, imgData, 90); // JPG quality: between 1 and 100 #endif #if defined(SUPPORT_FILEFORMAT_QOI) @@ -510,11 +510,11 @@ bool ExportImage(Image image, const char *fileName) if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) channels = 3; else if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) channels = 4; else TRACELOG(LOG_WARNING, "IMAGE: Image pixel format must be R8G8B8 or R8G8B8A8"); - + if ((channels == 3) || (channels == 4)) { qoi_desc desc = { 0 }; - desc.width = image.width; + desc.width = image.width; desc.height = image.height; desc.channels = channels; desc.colorspace = QOI_SRGB; @@ -2771,7 +2771,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color // [x] Consider fast path: same src/dst format with no alpha -> direct line copy // [-] GetPixelColor(): Get Vector4 instead of Color, easier for ColorAlphaBlend() // [ ] Support f32bit channels drawing - + // TODO: Support PIXELFORMAT_UNCOMPRESSED_R32, PIXELFORMAT_UNCOMPRESSED_R32G32B32, PIXELFORMAT_UNCOMPRESSED_R32G32B32A32 Color colSrc, colDst, blend; @@ -2954,7 +2954,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layout) ImageFormat(&faces, image.format); // NOTE: Image formating does not work with compressed textures - + for (int i = 0; i < 6; i++) ImageDraw(&faces, image, faceRecs[i], (Rectangle){ 0, (float)size*i, (float)size, (float)size }, WHITE); } diff --git a/src/shell.html b/src/shell.html index 333f6528f..3ab8c3a30 100644 --- a/src/shell.html +++ b/src/shell.html @@ -3,14 +3,14 @@ - + raylib web game - + - + @@ -26,30 +26,30 @@ - + - +