From c54d9cd552316d51be08911ca252bbc8bcd57bf7 Mon Sep 17 00:00:00 2001 From: megagrump <31128870+megagrump@users.noreply.github.com> Date: Mon, 31 Jan 2022 09:39:21 +0100 Subject: [PATCH 001/237] simplify QuaternionInvert (#2324) --- src/raymath.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 8a54bbccc..51dc2abc1 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -282,7 +282,7 @@ RMAPI float Vector2Distance(Vector2 v1, Vector2 v2) RMAPI float Vector2Angle(Vector2 v1, Vector2 v2) { float result = atan2f(v2.y, v2.x) - atan2f(v1.y, v1.x); - + return result; } @@ -549,12 +549,12 @@ RMAPI float Vector3Distance(Vector3 v1, Vector3 v2) RMAPI float Vector3Angle(Vector3 v1, Vector3 v2) { float result = 0.0f; - + Vector3 cross = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x }; float len = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z); float dot = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); result = atan2f(len, dot); - + return result; } @@ -1490,8 +1490,7 @@ RMAPI Quaternion QuaternionInvert(Quaternion q) { Quaternion result = q; - float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); - float lengthSq = length*length; + float lengthSq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w; if (lengthSq != 0.0) { From a0895f1a3c5178049c0d538fc7bd1818e5721c32 Mon Sep 17 00:00:00 2001 From: Audi Nugraha Date: Thu, 3 Feb 2022 18:00:33 +0700 Subject: [PATCH 002/237] Fix Undefined Symbol `_ftelli64` (#2319) --- src/external/cgltf.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/external/cgltf.h b/src/external/cgltf.h index 565003801..796eb86c1 100644 --- a/src/external/cgltf.h +++ b/src/external/cgltf.h @@ -948,7 +948,11 @@ static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* m fseek(file, 0, SEEK_END); #ifdef _WIN32 - __int64 length = _ftelli64(file); + #ifdef __TINYC__ + __int64 length = ftell(file); + #else + __int64 length = _ftelli64(file); + #endif #else long length = ftell(file); #endif From c895bed5e6506180d2325efaad601901b94912e0 Mon Sep 17 00:00:00 2001 From: iskolbin Date: Thu, 3 Feb 2022 16:56:00 +0300 Subject: [PATCH 003/237] Added defines to parser (#2269) * added defines to parser * added value and description for defines in parser * parser: fixed lua defines output, fixed makefile for raygui, added LONG type for defines * parser defines: remove postfix for LONG/FLOAT, support for hexadecimal consts, convert hex ints to decimal for JSON output * removed defines from raylib_apis --- parser/Makefile | 3 +- parser/raylib_parser.c | 210 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 208 insertions(+), 5 deletions(-) diff --git a/parser/Makefile b/parser/Makefile index b9197e206..9446e2826 100644 --- a/parser/Makefile +++ b/parser/Makefile @@ -20,8 +20,9 @@ parse: ./raylib_parser -i ../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI ./raylib_parser -i ../src/extras/easings.h -o easings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF ./raylib_parser -i ../src/extras/physac.h -o physac_api.$(EXTENSION) -f $(FORMAT) -d PHYSACDEF - ./raylib_parser -i ../src/extras/raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIDEF + ./raylib_parser -i ../src/extras/raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI ./raylib_parser -i ../src/extras/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI + ./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI clean: rm -f raylib_parser *.json *.txt *.xml *.lua diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c index ed534299c..68c893f4e 100644 --- a/parser/raylib_parser.c +++ b/parser/raylib_parser.c @@ -2,12 +2,13 @@ raylib API parser - This parser scans raylib.h to get API information about structs, enums and functions. + This parser scans raylib.h to get API information about structs, enums, functions and defines. All data is divided into pieces, usually as strings. The following types are used for data: - struct FunctionInfo - struct StructInfo - struct EnumInfo + - struct DefInfo CONSTRAINTS: @@ -62,10 +63,12 @@ #include // Required for: malloc(), calloc(), realloc(), free(), atoi(), strtol() #include // Required for: printf(), fopen(), fseek(), ftell(), fread(), fclose() #include // Required for: bool +#include // Required for: isdigit() #define MAX_FUNCS_TO_PARSE 512 // Maximum number of functions to parse #define MAX_STRUCTS_TO_PARSE 64 // Maximum number of structures to parse #define MAX_ENUMS_TO_PARSE 64 // Maximum number of enums to parse +#define MAX_DEFINES_TO_PARSE 2048 // Maximum number of defines to parse #define MAX_LINE_LENGTH 512 // Maximum length of one line (including comments) #define MAX_STRUCT_LINE_LENGTH 2048 // Maximum length of one struct (multiple lines) @@ -108,6 +111,18 @@ typedef struct EnumInfo { char valueDesc[MAX_ENUM_VALUES][128]; // Value description } EnumInfo; +// Type of parsed define +typedef enum { UNKNOWN = 0, MACRO, GUARD, INT, LONG, FLOAT, DOUBLE, CHAR, STRING, COLOR } DefineType; + +// Define info data +typedef struct DefineInfo { + char name[64]; // Define name + DefineType type; // Define type + char value[256]; // Define value + char desc[128]; // Define description + bool isHex; // Define is hex number (for types INT, LONG) +} DefineInfo; + // Output format for parsed data typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat; @@ -117,9 +132,11 @@ typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat; static int funcCount = 0; static int structCount = 0; static int enumCount = 0; +static int defineCount = 0; static FunctionInfo *funcs = NULL; static StructInfo *structs = NULL; static EnumInfo *enums = NULL; +static DefineInfo *defines = NULL; static char apiDefine[32] = "RLAPI\0"; // Command line variables @@ -143,6 +160,8 @@ static char *EscapeBackslashes(char *text); // Replace '\' by "\ static void ExportParsedData(const char *fileName, int format); // Export parsed data in desired format +static const char *StrDefineType(DefineType type); // Get string of define type + //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -169,6 +188,9 @@ int main(int argc, char* argv[]) // Enums lines pointers, selected from buffer "lines" int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int)); + // Defines lines pointers, selected from buffer "lines" + int *defineLines = (int *)malloc(MAX_DEFINES_TO_PARSE*sizeof(int)); + // Prepare required lines for parsing //-------------------------------------------------------------------------------------------------- @@ -228,7 +250,22 @@ int main(int argc, char* argv[]) } } - // At this point we have all raylib structs, enums, functions lines data to start parsing + // Read const lines + for (int i = 0; i < linesCount; i++) + { + int j = 0; + while (lines[i][j] == ' ' || lines[i][j] == '\t') j++; // skip spaces and tabs in the begining + // Read define line + if (IsTextEqual(lines[i]+j, "#define ", 8)) + { + // Keep the line position in the array of lines, + // so, we can scan that position and following lines + defineLines[defineCount] = i; + defineCount++; + } + } + + // At this point we have all raylib structs, enums, functions, defines lines data to start parsing free(buffer); // Unload text buffer @@ -402,9 +439,94 @@ int main(int argc, char* argv[]) } } } - free(enumLines); + // Define info data + defines = (DefineInfo *)calloc(MAX_DEFINES_TO_PARSE, sizeof(DefineInfo)); + int defineIndex = 0; + + for (int i = 0; i < defineCount; i++) + { + char *linePtr = lines[defineLines[i]]; + int j = 0; + + while (linePtr[j] == ' ' || linePtr[j] == '\t') j++; // Skip spaces and tabs in the begining + j += 8; // Skip "#define " + while (linePtr[j] == ' ' || linePtr[j] == '\t') j++; // Skip spaces and tabs after "#define " + + // Extract name + int defineNameStart = j; + while (linePtr[j] != ' ' && linePtr[j] != '\t' && linePtr[j] != '\0') j++; + int defineNameEnd = j-1; + + // Skip duplicates + int nameLen = defineNameEnd - defineNameStart + 1; + bool isDuplicate = false; + for (int k = 0; k < defineIndex; k++) { + if (nameLen == TextLength(defines[k].name) && IsTextEqual(defines[k].name, linePtr + defineNameStart, nameLen)) { + isDuplicate = true; + break; + } + } + if (isDuplicate) continue; + + MemoryCopy(defines[defineIndex].name, linePtr + defineNameStart, nameLen); + + // Determine type + if (linePtr[defineNameEnd] == ')') defines[defineIndex].type = MACRO; + + while (linePtr[j] == ' ' || linePtr[j] == '\t') j++; // Skip spaces and tabs after name + + int defineValueStart = j; + if (linePtr[j] == '\0' || linePtr == "/") defines[defineIndex].type = GUARD; + if (linePtr[j] == '"') defines[defineIndex].type = STRING; + else if (linePtr[j] == '\'') defines[defineIndex].type = CHAR; + else if (IsTextEqual(linePtr+j, "CLITERAL(Color)", 15)) defines[defineIndex].type = COLOR; + else if (isdigit(linePtr[j])) { // Parsing numbers + bool isFloat = false, isNumber = true, isHex = false; + while (linePtr[j] != ' ' && linePtr[j] != '\t' && linePtr[j] != '\0') { + char ch = linePtr[j]; + if (ch == '.') isFloat = true; + if (ch == 'x') isHex = true; + if (!(isdigit(ch)||(ch >= 'a' && ch <= 'f')||(ch >= 'A' && ch <= 'F')||ch=='x'||ch=='L'||ch=='.'||ch=='+'||ch=='-')) isNumber = false; + j++; + } + if (isNumber) { + if (isFloat) { + defines[defineIndex].type = linePtr[j-1] == 'f' ? FLOAT : DOUBLE; + } else { + defines[defineIndex].type = linePtr[j-1] == 'L' ? LONG : INT; + defines[defineIndex].isHex = isHex; + } + } + } + + // Extracting value + while (linePtr[j] != '\\' && linePtr[j] != '\0' && !(linePtr[j] == '/' && linePtr[j+1] == '/')) j++; + int defineValueEnd = j-1; + while (linePtr[defineValueEnd] == ' ' || linePtr[defineValueEnd] == '\t') defineValueEnd--; // Remove trailing spaces and tabs + if (defines[defineIndex].type == LONG || defines[defineIndex].type == FLOAT) defineValueEnd--; // Remove number postfix + int valueLen = defineValueEnd - defineValueStart + 1; + if (valueLen > 255) valueLen = 255; + + if (valueLen > 0) MemoryCopy(defines[defineIndex].value, linePtr + defineValueStart, valueLen); + + // Extracting description + if (linePtr[j] == '/') { + int commentStart = j; + while (linePtr[j] != '\\' && linePtr[j] != '\0') j++; + int commentEnd = j-1; + int commentLen = commentEnd - commentStart + 1; + if (commentLen > 127) commentLen = 127; + + MemoryCopy(defines[defineIndex].desc, linePtr + commentStart, commentLen); + } + + defineIndex++; + } + defineCount = defineIndex; + free(defineLines); + // Functions info data funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo)); @@ -486,6 +608,7 @@ int main(int argc, char* argv[]) // structs[] -> We have all the structs decomposed into pieces for further analysis // enums[] -> We have all the enums decomposed into pieces for further analysis // funcs[] -> We have all the functions decomposed into pieces for further analysis + // defines[] -> We have all the defines decomposed into pieces for further analysis // Process input file to output if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15); @@ -759,6 +882,25 @@ static char *EscapeBackslashes(char *text) return buffer; } +// Get string of define type +static const char *StrDefineType(DefineType type) +{ + switch (type) + { + case UNKNOWN: return "UNKNOWN"; + case GUARD: return "GUARD"; + case MACRO: return "MACRO"; + case INT: return "INT"; + case LONG: return "LONG"; + case FLOAT: return "FLOAT"; + case DOUBLE: return "DOUBLE"; + case CHAR: return "CHAR"; + case STRING: return "STRING"; + case COLOR: return "COLOR"; + } + return ""; +} + /* // Replace text string // REQUIRES: strlen(), strstr(), strncpy(), strcpy() -> TODO: Replace by custom implementations! @@ -836,7 +978,7 @@ static void ExportParsedData(const char *fileName, int format) { fprintf(outFile, "Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount); fprintf(outFile, " Name: %s\n", enums[i].name); - fprintf(outFile, " Description: %s\n", enums[i].desc + 3); + fprintf(outFile, " Description: %s\n", enums[i].desc + 3); for (int e = 0; e < enums[i].valueCount; e++) fprintf(outFile, " Value[%s]: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]); } @@ -851,6 +993,16 @@ static void ExportParsedData(const char *fileName, int format) for (int p = 0; p < funcs[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]); if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n"); } + + fprintf(outFile, "\nDefines found: %i\n\n", defineCount); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, "Define %03i: %s\n", i + 1, defines[i].name); + fprintf(outFile, " Name: %s\n", defines[i].name); + fprintf(outFile, " Type: %s\n", StrDefineType(defines[i].type)); + fprintf(outFile, " Value: %s\n", defines[i].value); + fprintf(outFile, " Description: %s\n", defines[i].desc + 3); + } } break; case LUA: { @@ -906,6 +1058,26 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " },\n"); + // Print defines info + fprintf(outFile, " defines = {\n"); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", defines[i].name); + fprintf(outFile, " type = \"%s\",\n", StrDefineType(defines[i].type)); + if (defines[i].type == INT || defines[i].type == LONG || defines[i].type == FLOAT || defines[i].type == DOUBLE || defines[i].type == STRING) { + fprintf(outFile, " value = %s,\n", defines[i].value); + } else { + fprintf(outFile, " value = \"%s\",\n", defines[i].value); + } + fprintf(outFile, " description = \"%s\"\n", defines[i].desc + 3); + fprintf(outFile, " }"); + + if (i < defineCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + // Print functions info fprintf(outFile, " functions = {\n"); for (int i = 0; i < funcCount; i++) @@ -989,6 +1161,28 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " ],\n"); + // Print defines info + fprintf(outFile, " \"defines\": [\n"); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " \"name\": \"%s\",\n", defines[i].name); + fprintf(outFile, " \"type\": \"%s\",\n", StrDefineType(defines[i].type)); + if (defines[i].isHex) { // INT or LONG + fprintf(outFile, " \"value\": %ld,\n", strtol(defines[i].value, NULL, 16)); + } else if (defines[i].type == INT || defines[i].type == LONG || defines[i].type == FLOAT || defines[i].type == DOUBLE || defines[i].type == STRING) { + fprintf(outFile, " \"value\": %s,\n", defines[i].value); + } else { + fprintf(outFile, " \"value\": \"%s\",\n", defines[i].value); + } + fprintf(outFile, " \"description\": \"%s\"\n", defines[i].desc + 3); + fprintf(outFile, " }"); + + if (i < defineCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " ],\n"); + // Print functions info fprintf(outFile, " \"functions\": [\n"); for (int i = 0; i < funcCount; i++) @@ -1077,6 +1271,14 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " \n"); + // Print defines info + fprintf(outFile, " \n", defineCount); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, " \n", defines[i].name, StrDefineType(defines[i].type), defines[i].value, defines[i].desc); + } + fprintf(outFile, " \n"); + // Print functions info fprintf(outFile, " \n", funcCount); for (int i = 0; i < funcCount; i++) From 1e436be51d4f8853c3494a0753eabe7628ac6d90 Mon Sep 17 00:00:00 2001 From: locriacyber <74560659+locriacyber@users.noreply.github.com> Date: Sat, 5 Feb 2022 13:33:05 +0100 Subject: [PATCH 004/237] Make audio examples compile with external glfw on Linux (#2329) --- cmake/LibraryConfigurations.cmake | 4 ++++ src/CMakeLists.txt | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake index b7874888f..9227aef0d 100644 --- a/cmake/LibraryConfigurations.cmake +++ b/cmake/LibraryConfigurations.cmake @@ -28,6 +28,10 @@ if (${PLATFORM} MATCHES "Desktop") endif () set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY}) + + if (USE_AUDIO) + set(LIBS_PRIVATE ${LIBS_PRIVATE} dl) + endif () endif () elseif (${PLATFORM} MATCHES "Web") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2877c9ac8..c96f4f560 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,6 +41,10 @@ set(raylib_sources # /cmake/GlfwImport.cmake handles the details around the inclusion of glfw include(GlfwImport) +# Sets additional platform options and link libraries for each platform +# also selects the proper graphics API and version for that platform +# Produces a variable LIBS_PRIVATE that will be used later +include(LibraryConfigurations) if (USE_AUDIO) MESSAGE(STATUS "Audio Backend: miniaudio") @@ -49,10 +53,6 @@ else () MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)") endif () -# Sets additional platform options and link libraries for each platform -# also selects the proper graphics API and version for that platform -# Produces a variable LIBS_PRIVATE that will be used later -include(LibraryConfigurations) add_library(raylib ${raylib_sources} ${raylib_public_headers}) From 96452637d979da3a37d0af79df32a83a935d6f85 Mon Sep 17 00:00:00 2001 From: Scribe of the Ziggurat <72305366+zigster64@users.noreply.github.com> Date: Wed, 9 Feb 2022 17:23:14 +1000 Subject: [PATCH 005/237] Add BSD support for zig builds (#2332) - Adds a new OS clause to build.zig for the BSDs - Tested on my FreeBSD box using https://github.com/Not-Nik/raylib-zig - All demos build and render just fine. Nice ! --- src/build.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/build.zig b/src/build.zig index 915d33a83..61c0e6626 100644 --- a/src/build.zig +++ b/src/build.zig @@ -47,6 +47,19 @@ pub fn Pkg(srcdir: []const u8) type { raylib.linkSystemLibrary("m"); raylib.linkSystemLibrary("X11"); }, + .freebsd, .openbsd, .netbsd, .dragonfly => { + raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags); + raylib.linkSystemLibrary("GL"); + raylib.linkSystemLibrary("rt"); + raylib.linkSystemLibrary("dl"); + raylib.linkSystemLibrary("m"); + raylib.linkSystemLibrary("X11"); + raylib.linkSystemLibrary("Xrandr"); + raylib.linkSystemLibrary("Xinerama"); + raylib.linkSystemLibrary("Xi"); + raylib.linkSystemLibrary("Xxf86vm"); + raylib.linkSystemLibrary("Xcursor"); + }, .macos => { // On macos rglfw.c include Objective-C files. const raylib_flags_extra_macos = &[_][]const u8{ 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 006/237] 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 007/237] 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 008/237] 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 009/237] 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 010/237] 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 011/237] 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 012/237] 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 013/237] 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 014/237] 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 015/237] 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 016/237] 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 017/237] 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 018/237] 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 019/237] 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 020/237] 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 021/237] 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 022/237] 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 @@ - + - +