From c1ab645ca298a2801097931d1079b10ff7eb9df8 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 18 Nov 2024 13:21:10 +0100 Subject: [PATCH 01/35] Update HISTORY.md --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index af158bada..3cecb2a67 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -487,7 +487,7 @@ Some numbers for this release: Highlights for `raylib 5.5`: - - **`NEW` raylib pre-configured Windows package**: The new raylib **postable and self-contained Windows package** for `raylib 5.5`, intended for nobel devs that start in programming world, comes with one big addition: support for **C code building for Web platform with one-single-mouse-click!** For the last 10 years, the pre-configured raylib Windows package allowed to edit simple C projects on Notepad++ and easely compile Windows executables with an automatic script; this new release adds the possibility to compile the same C projects for Web platform with a simple mouse click. This new addition **greatly simplifies C to WebAssembly project building for new users**. The `raylib Windows Installer` package can be downloaded for free from [raylib on itch.io](https://raysan5.itch.io/raylib). + - **`NEW` raylib pre-configured Windows package**: The new raylib **portable and self-contained Windows package** for `raylib 5.5`, intended for nobel devs that start in programming world, comes with one big addition: support for **C code building for Web platform with one-single-mouse-click!** For the last 10 years, the pre-configured raylib Windows package allowed to edit simple C projects on Notepad++ and easely compile Windows executables with an automatic script; this new release adds the possibility to compile the same C projects for Web platform with a simple mouse click. This new addition **greatly simplifies C to WebAssembly project building for new users**. The `raylib Windows Installer` package can be downloaded for free from [raylib on itch.io](https://raysan5.itch.io/raylib). - **`NEW` raylib project creator tool**: A brand new tool developed to help raylib users to **setup new projects in a professional way**. `raylib project creator` generates a complete project structure with **multiple build systems ready-to-use** and **GitHub CI/CD actions pre-configured**. It only requires providing some C files and basic project parameters! The tools is [free and open-source](https://raysan5.itch.io/raylib-project-creator), and [it can be used online](https://raysan5.itch.io/raylib-project-creator)!. From 71e0b8b5813fb1d2916c81c8e6db42d12d9274ab Mon Sep 17 00:00:00 2001 From: Gunko Vadim Date: Mon, 18 Nov 2024 18:38:28 +0500 Subject: [PATCH 02/35] Update BINDINGS.md (#4504) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index fd9bddcb6..8f68c66d3 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -51,7 +51,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [raylib_odin_bindings](https://github.com/Deathbat2190/raylib_odin_bindings) | 4.0-dev | [Odin](https://odin-lang.org) | MIT | | [raylib-ocaml](https://github.com/tjammer/raylib-ocaml) | **5.0** | [OCaml](https://ocaml.org) | MIT | | [TurboRaylib](https://github.com/turborium/TurboRaylib) | 4.5 | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | MIT | -| [Ray4Laz](https://github.com/GuvaCode/Ray4Laz) | **5.0** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib | +| [Ray4Laz](https://github.com/GuvaCode/Ray4Laz) | **5.5** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib | | [Raylib.4.0.Pascal](https://github.com/sysrpl/Raylib.4.0.Pascal) | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib | | [pyraylib](https://github.com/Ho011/pyraylib) | 3.7 | [Python](https://www.python.org) | Zlib | | [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | 4.2 | [Python](https://www.python.org) | EPL-2.0 | From 8375581f870ec1c4bcf17fdf842c608463a46b68 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 19 Nov 2024 00:19:39 +0100 Subject: [PATCH 03/35] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29173d665..29f0f61ff 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html) [![GitHub Releases Downloads](https://img.shields.io/github/downloads/raysan5/raylib/total)](https://github.com/raysan5/raylib/releases) [![GitHub Stars](https://img.shields.io/github/stars/raysan5/raylib?style=flat&label=stars)](https://github.com/raysan5/raylib/stargazers) -[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/raysan5/raylib/5.0)](https://github.com/raysan5/raylib/commits/master) +[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/raysan5/raylib/5.5)](https://github.com/raysan5/raylib/commits/master) [![GitHub Sponsors](https://img.shields.io/github/sponsors/raysan5?label=sponsors)](https://github.com/sponsors/raysan5) [![Packaging Status](https://repology.org/badge/tiny-repos/raylib.svg)](https://repology.org/project/raylib/versions) [![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE) From fde3779ebd58e69f84b61cb4c3f941235e418881 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 18 Nov 2024 18:37:33 -0500 Subject: [PATCH 04/35] BINDINGS: raylib-cpp supports raylib 5.5 (#4511) [raylib-cpp](https://github.com/RobLoach/raylib-cpp) has been updated to use the new raylib 5.5 functions. This is a great release! Thanks so much. --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 8f68c66d3..7f79cb8d5 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -90,7 +90,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's paradigm. | Name | raylib Version | Language | License | | ---------------------------------------------------- | :------------: | :------------------------------------------: | :-----: | -| [raylib-cpp](https://github.com/robloach/raylib-cpp) | **5.0** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib | +| [raylib-cpp](https://github.com/robloach/raylib-cpp) | **5.5** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib | | [claylib](https://github.com/defun-games/claylib) | 4.5 | [Common Lisp](https://common-lisp.net) | Zlib | | [rayed-bqn](https://github.com/Brian-ED/rayed-bqn) | **5.0** | [BQN](https://mlochbaum.github.io/BQN) | MIT | From 05b2603c456eab3d12f37de0d4271bed869dc717 Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Tue, 19 Nov 2024 03:03:39 -0500 Subject: [PATCH 05/35] Update raylib-d binding to 5.5 (#4506) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 7f79cb8d5..e5aa66815 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -23,7 +23,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [dart-raylib](https://gitlab.com/wolfenrain/dart-raylib) | 4.0 | [Dart](https://dart.dev) | MIT | | [bindbc-raylib3](https://github.com/o3o/bindbc-raylib3) | **5.0** | [D](https://dlang.org) | BSL-1.0 | | [dray](https://github.com/redthing1/dray) | **5.0** | [D](https://dlang.org) | Apache-2.0 | -| [raylib-d](https://github.com/schveiguy/raylib-d) | **5.0** | [D](https://dlang.org) | Zlib | +| [raylib-d](https://github.com/schveiguy/raylib-d) | **5.5** | [D](https://dlang.org) | Zlib | | [rayex](https://github.com/shiryel/rayex) | 3.7 | [elixir](https://elixir-lang.org) | Apache-2.0 | | [raylib-factor](https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor) | 4.5 | [Factor](https://factorcode.org) | BSD | | [raylib-freebasic](https://github.com/WIITD/raylib-freebasic) | **5.0** | [FreeBASIC](https://www.freebasic.net) | MIT | From f979cc62eeff9bd510eadb99d4937ac6da353f0f Mon Sep 17 00:00:00 2001 From: Mute Date: Tue, 19 Nov 2024 08:04:14 +0000 Subject: [PATCH 06/35] Fixed grammar mistakes in core_3d_camera_first_person.c (#4508) Changed line 118 from, "// For advance camera controls, it's reecommended to compute camera movement manually", to, "// For advanced camera controls, it's recommended to compute camera movement manually". --- examples/core/core_3d_camera_first_person.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c index 35b18ace4..2b36c598b 100644 --- a/examples/core/core_3d_camera_first_person.c +++ b/examples/core/core_3d_camera_first_person.c @@ -115,7 +115,7 @@ int main(void) // Update camera computes movement internally depending on the camera mode // Some default standard keyboard/mouse inputs are hardcoded to simplify use - // For advance camera controls, it's reecommended to compute camera movement manually + // For advanced camera controls, it's recommended to compute camera movement manually UpdateCamera(&camera, cameraMode); // Update camera /* @@ -203,4 +203,4 @@ int main(void) //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} From 65f955a4dc967c1a9c0c0935724cc5117f5c3d9e Mon Sep 17 00:00:00 2001 From: kovidomi Date: Tue, 19 Nov 2024 09:05:09 +0100 Subject: [PATCH 07/35] Add missing VS2022 example projects for models_bone_socket and shaders_vertex_displacement (#4510) --- .../examples/models_bone_socket.vcxproj | 387 ++++++++++++++++++ .../shaders_vertex_displacement.vcxproj | 387 ++++++++++++++++++ projects/VS2022/raylib.sln | 38 ++ 3 files changed, 812 insertions(+) create mode 100644 projects/VS2022/examples/models_bone_socket.vcxproj create mode 100644 projects/VS2022/examples/shaders_vertex_displacement.vcxproj diff --git a/projects/VS2022/examples/models_bone_socket.vcxproj b/projects/VS2022/examples/models_bone_socket.vcxproj new file mode 100644 index 000000000..9d89856b0 --- /dev/null +++ b/projects/VS2022/examples/models_bone_socket.vcxproj @@ -0,0 +1,387 @@ + + + + + Debug.DLL + Win32 + + + Debug.DLL + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release.DLL + Win32 + + + Release.DLL + x64 + + + Release + Win32 + + + Release + x64 + + + + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F} + Win32Proj + models_bone_socket + 10.0 + models_bone_socket + + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\models + WindowsLocalDebugger + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + /FS %(AdditionalOptions) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + + + + {e89d61ac-55de-4482-afd4-df7242ebc859} + + + + + + \ No newline at end of file diff --git a/projects/VS2022/examples/shaders_vertex_displacement.vcxproj b/projects/VS2022/examples/shaders_vertex_displacement.vcxproj new file mode 100644 index 000000000..294d5f76d --- /dev/null +++ b/projects/VS2022/examples/shaders_vertex_displacement.vcxproj @@ -0,0 +1,387 @@ + + + + + Debug.DLL + Win32 + + + Debug.DLL + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release.DLL + Win32 + + + Release.DLL + x64 + + + Release + Win32 + + + Release + x64 + + + + {CCA63A76-D9FC-4130-9F67-4D97F9770D53} + Win32Proj + shaders_vertex_displacement + 10.0 + shaders_vertex_displacement + + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + /FS %(AdditionalOptions) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + + + + {e89d61ac-55de-4482-afd4-df7242ebc859} + + + + + + \ No newline at end of file diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index 4d03db808..5142c14a1 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -305,6 +305,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_shadowmap", "exampl EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_input_virtual_controls", "examples\core_input_virtual_controls.vcxproj", "{0981CA28-E4A5-4DF1-987F-A41D09131EFC}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_bone_socket", "examples\models_bone_socket.vcxproj", "{3A7FE53D-35F7-49DC-9C9A-A5204A53523F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_vertex_displacement", "examples\shaders_vertex_displacement.vcxproj", "{CCA63A76-D9FC-4130-9F67-4D97F9770D53}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug.DLL|x64 = Debug.DLL|x64 @@ -2585,6 +2589,38 @@ Global {0981CA28-E4A5-4DF1-987F-A41D09131EFC}.Release|x64.Build.0 = Release|x64 {0981CA28-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.ActiveCfg = Release|Win32 {0981CA28-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.Build.0 = Release|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug|x64.ActiveCfg = Debug|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug|x64.Build.0 = Debug|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug|x86.ActiveCfg = Debug|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Debug|x86.Build.0 = Debug|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release.DLL|x64.Build.0 = Release.DLL|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release.DLL|x86.Build.0 = Release.DLL|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release|x64.ActiveCfg = Release|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release|x64.Build.0 = Release|x64 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release|x86.ActiveCfg = Release|Win32 + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F}.Release|x86.Build.0 = Release|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug|x64.ActiveCfg = Debug|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug|x64.Build.0 = Debug|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug|x86.ActiveCfg = Debug|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Debug|x86.Build.0 = Debug|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release.DLL|x64.Build.0 = Release.DLL|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release.DLL|x86.Build.0 = Release.DLL|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release|x64.ActiveCfg = Release|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release|x64.Build.0 = Release|x64 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release|x86.ActiveCfg = Release|Win32 + {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2739,6 +2775,8 @@ Global {8245DAD9-D402-4D5C-8F45-32229CD3B263} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C} {41BBCC10-6FDE-48A1-B2E0-A0EC6A668629} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9} {0981CA28-E4A5-4DF1-987F-A41D09131EFC} = {6C82BAAE-BDDF-457D-8FA8-7E2490B07035} + {3A7FE53D-35F7-49DC-9C9A-A5204A53523F} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C} + {CCA63A76-D9FC-4130-9F67-4D97F9770D53} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29} From 21575856f4fb35e9138cc4947e23caa6bd55a1ba Mon Sep 17 00:00:00 2001 From: Alexandre B A Villares <3694604+villares@users.noreply.github.com> Date: Tue, 19 Nov 2024 05:05:39 -0300 Subject: [PATCH 08/35] Update BINDINGS.md: raylib-python-cffi is on v5.0 (#4512) According to https://github.com/electronstudio/raylib-python-cffi --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index e5aa66815..62c01d86c 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -54,7 +54,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [Ray4Laz](https://github.com/GuvaCode/Ray4Laz) | **5.5** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib | | [Raylib.4.0.Pascal](https://github.com/sysrpl/Raylib.4.0.Pascal) | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib | | [pyraylib](https://github.com/Ho011/pyraylib) | 3.7 | [Python](https://www.python.org) | Zlib | -| [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | 4.2 | [Python](https://www.python.org) | EPL-2.0 | +| [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | 5.0 | [Python](https://www.python.org) | EPL-2.0 | | [raylibpyctbg](https://github.com/overdev/raylibpyctbg) | 4.5 | [Python](https://www.python.org) | MIT | | [raylib-py](https://github.com/overdev/raylib-py) | **5.0b1** | [Python](https://www.python.org) | MIT | | [raylib-python-ctypes](https://github.com/sDos280/raylib-python-ctypes) | 4.6-dev | [Python](https://www.python.org) | MIT | From 7127cba5cc7c217a747096b500bfae795aa5e6c0 Mon Sep 17 00:00:00 2001 From: Andrew Dunbar Date: Tue, 19 Nov 2024 16:33:36 +0700 Subject: [PATCH 09/35] typo/spello: arribes->arrives (#4515) --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 3cecb2a67..02e226437 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -475,7 +475,7 @@ Undoubtedly, this is the **biggest raylib update in 10 years**. Many new feature notes on raylib 5.5 ------------------- -One year after raylib 5.0 release, arribes `raylib 5.5`, the next big revision of the library. It's been **11 years** since raylib 1.0 release and in all this time it has never stopped growing and improving. With an outstanding number of new contributors and improvements, it's, again, the biggest raylib release to date. +One year after raylib 5.0 release, arrives `raylib 5.5`, the next big revision of the library. It's been **11 years** since raylib 1.0 release and in all this time it has never stopped growing and improving. With an outstanding number of new contributors and improvements, it's, again, the biggest raylib release to date. Some numbers for this release: From bd706dfcf240355cb4e0fd8b84b554f601016d2d Mon Sep 17 00:00:00 2001 From: Jannis Date: Tue, 19 Nov 2024 09:35:10 +0000 Subject: [PATCH 10/35] Update BINDINGS.md for raylib-beef (#4514) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 62c01d86c..b3aef1293 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -7,7 +7,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | Name | raylib Version | Language | License | | :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: | | [raylib](https://github.com/raysan5/raylib) | **5.0** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | -| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.0** | [Beef](https://www.beeflang.org) | MIT | +| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT | | [raylib-boo](https://github.com/Rabios/raylib-boo) | 3.7 | [Boo](http://boo-language.github.io) | MIT | | [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT | | [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | From 95e766472f0b71c66b97e2fb7d612b335194da17 Mon Sep 17 00:00:00 2001 From: mikeemm <42421968+mikeemm@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:35:47 +0100 Subject: [PATCH 11/35] [rmodels] Improve OBJ vertex data precision and lower memory usage by ExportMesh() (#4496) * increased vertex data precision to match blender exports * modified memory allocation to better fit higher precision data * now accounting for newline characters during allocation * now accounting for potentially higher vertex counts * removed unnecessary final newline --- src/rmodels.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/rmodels.c b/src/rmodels.c index b5830b2c0..05ad8083c 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -1943,13 +1943,14 @@ bool ExportMesh(Mesh mesh, const char *fileName) if (IsFileExtension(fileName, ".obj")) { // Estimated data size, it should be enough... - int dataSize = mesh.vertexCount*(int)strlen("v 0000.00f 0000.00f 0000.00f") + - mesh.vertexCount*(int)strlen("vt 0.000f 0.00f") + - mesh.vertexCount*(int)strlen("vn 0.000f 0.00f 0.00f") + - mesh.triangleCount*(int)strlen("f 00000/00000/00000 00000/00000/00000 00000/00000/00000"); + int vc = mesh.vertexCount; + int dataSize = vc*(int)strlen("v -0000.000000f -0000.000000f -0000.000000f\n") + + vc*(int)strlen("vt -0.000000f -0.000000f\n") + + vc*(int)strlen("vn -0.0000f -0.0000f -0.0000f\n") + + mesh.triangleCount*snprintf(NULL, 0, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", vc, vc, vc, vc, vc, vc, vc, vc, vc); // NOTE: Text data buffer size is estimated considering mesh data size - char *txtData = (char *)RL_CALLOC(dataSize*2 + 2000, sizeof(char)); + char *txtData = (char *)RL_CALLOC(dataSize + 1000, sizeof(char)); int byteCount = 0; byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n"); @@ -1969,17 +1970,17 @@ bool ExportMesh(Mesh mesh, const char *fileName) for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3) { - byteCount += sprintf(txtData + byteCount, "v %.2f %.2f %.2f\n", mesh.vertices[v], mesh.vertices[v + 1], mesh.vertices[v + 2]); + byteCount += sprintf(txtData + byteCount, "v %.6f %.6f %.6f\n", mesh.vertices[v], mesh.vertices[v + 1], mesh.vertices[v + 2]); } for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 2) { - byteCount += sprintf(txtData + byteCount, "vt %.3f %.3f\n", mesh.texcoords[v], mesh.texcoords[v + 1]); + byteCount += sprintf(txtData + byteCount, "vt %.6f %.6f\n", mesh.texcoords[v], mesh.texcoords[v + 1]); } for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3) { - byteCount += sprintf(txtData + byteCount, "vn %.3f %.3f %.3f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]); + byteCount += sprintf(txtData + byteCount, "vn %.4f %.4f %.4f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]); } if (mesh.indices != NULL) @@ -2000,8 +2001,6 @@ bool ExportMesh(Mesh mesh, const char *fileName) } } - byteCount += sprintf(txtData + byteCount, "\n"); - // NOTE: Text data length exported is determined by '\0' (NULL) character success = SaveFileText(fileName, txtData); From 10789a4d496128492d190877f2506b6fa728325d Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 19 Nov 2024 12:31:14 +0100 Subject: [PATCH 12/35] Update rlgl.h --- src/rlgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rlgl.h b/src/rlgl.h index 756656e58..3bb996add 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -3,7 +3,7 @@ * rlgl v5.0 - A multi-OpenGL abstraction layer with an immediate-mode style API * * DESCRIPTION: -* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0) +* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0, ES 3.0) * that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...) * * ADDITIONAL NOTES: From c78757a95957adb3c3b3437d99e31273c1e361ea Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 19 Nov 2024 12:31:49 +0100 Subject: [PATCH 13/35] REVIEWED: `GetClipboardImage()`, make symbol available on all platforms --- src/config.h | 51 ++++++++++++++---------------- src/platforms/rcore_android.c | 10 ++++++ src/platforms/rcore_desktop_glfw.c | 29 ++++++++--------- src/platforms/rcore_desktop_rgfw.c | 43 ++++++++++++------------- src/platforms/rcore_drm.c | 10 ++++++ src/platforms/rcore_template.c | 10 ++++++ src/platforms/rcore_web.c | 10 ++++++ 7 files changed, 97 insertions(+), 66 deletions(-) diff --git a/src/config.h b/src/config.h index e3749c560..d8f7112eb 100644 --- a/src/config.h +++ b/src/config.h @@ -71,6 +71,30 @@ // Enabling this flag allows manual control of the frame processes, use at your own risk //#define SUPPORT_CUSTOM_FRAME_CONTROL 1 +// Support for clipboard image loading +// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows) +#define SUPPORT_CLIPBOARD_IMAGE 1 + +// NOTE: Clipboard image loading requires support for some image file formats +// TODO: Those defines should probably be removed from here, I prefer to let the user manage them +#if defined(SUPPORT_CLIPBOARD_IMAGE) + #ifndef SUPPORT_MODULE_RTEXTURES + #define SUPPORT_MODULE_RTEXTURES 1 + #endif + #ifndef STBI_REQUIRED + #define STBI_REQUIRED + #endif + #ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows + #define SUPPORT_FILEFORMAT_BMP 1 + #endif + #ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu + #define SUPPORT_FILEFORMAT_PNG 1 + #endif + #ifndef SUPPORT_FILEFORMAT_JPG + #define SUPPORT_FILEFORMAT_JPG 1 + #endif +#endif + // rcore: Configuration values //------------------------------------------------------------------------------------ @@ -273,31 +297,4 @@ //------------------------------------------------------------------------------------ #define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message - -// Enable partial support for clipboard image, only working on SDL3 or -// being on both Windows OS + GLFW or Windows OS + RGFW -#define SUPPORT_CLIPBOARD_IMAGE 1 - -#if defined(SUPPORT_CLIPBOARD_IMAGE) - #ifndef STBI_REQUIRED - #define STBI_REQUIRED - #endif - - #ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows - #define SUPPORT_FILEFORMAT_BMP 1 - #endif - - #ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu - #define SUPPORT_FILEFORMAT_PNG 1 - #endif - - #ifndef SUPPORT_FILEFORMAT_JPG - #define SUPPORT_FILEFORMAT_JPG 1 - #endif - - #ifndef SUPPORT_MODULE_RTEXTURES - #define SUPPORT_MODULE_RTEXTURES 1 - #endif -#endif - #endif // CONFIG_H diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 85ce82a3a..401e2a067 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -515,6 +515,16 @@ const char *GetClipboardText(void) return NULL; } +// Get clipboard image +Image GetClipboardImage(void) +{ + Image image = { 0 }; + + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); + + return image; +} + // Show mouse cursor void ShowCursor(void) { diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index baf2967fe..839852d9f 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -967,32 +967,29 @@ const char *GetClipboardText(void) return glfwGetClipboardString(platform.handle); } -#if defined(SUPPORT_CLIPBOARD_IMAGE) // Get clipboard image Image GetClipboardImage(void) { - Image image = {0}; + Image image = { 0 }; + +#if defined(SUPPORT_CLIPBOARD_IMAGE) +#if defined(_WIN32) unsigned long long int dataSize = 0; - void* fileData = NULL; - -#ifdef _WIN32 - int width, height; + void *fileData = NULL; + int width = 0; + int height = 0; + fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); + + if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); + else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); #else - TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_GLFW doesn't implement `GetClipboardImage` for this OS"); + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); #endif +#endif // SUPPORT_CLIPBOARD_IMAGE - if (fileData == NULL) - { - TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); - } - else - { - image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); - } return image; } -#endif // SUPPORT_CLIPBOARD_IMAGE // Show mouse cursor void ShowCursor(void) diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index f3f26e3e8..7a2ea9c0d 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -664,42 +664,39 @@ const char *GetClipboardText(void) return RGFW_readClipboard(NULL); } - #if defined(SUPPORT_CLIPBOARD_IMAGE) - -#ifdef _WIN32 -# define WIN32_CLIPBOARD_IMPLEMENTATION -# define WINUSER_ALREADY_INCLUDED -# define WINBASE_ALREADY_INCLUDED -# define WINGDI_ALREADY_INCLUDED -# include "../external/win32_clipboard.h" +#if defined(_WIN32) + #define WIN32_CLIPBOARD_IMPLEMENTATION + #define WINUSER_ALREADY_INCLUDED + #define WINBASE_ALREADY_INCLUDED + #define WINGDI_ALREADY_INCLUDED + #include "../external/win32_clipboard.h" #endif +#endif // SUPPORT_CLIPBOARD_IMAGE // Get clipboard image Image GetClipboardImage(void) { - Image image = {0}; + Image image = { 0 }; + +#if defined(SUPPORT_CLIPBOARD_IMAGE) +#if defined(_WIN32) unsigned long long int dataSize = 0; - void* fileData = NULL; - -#ifdef _WIN32 - int width, height; + void *fileData = NULL; + int width = 0; + int height = 0; + fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); + + if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); + else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); #else - TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement `GetClipboardImage` for this OS"); + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); #endif +#endif // SUPPORT_CLIPBOARD_IMAGE - if (fileData == NULL) - { - TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); - } - else - { - image = LoadImageFromMemory(".bmp", fileData, dataSize); - } return image; } -#endif // SUPPORT_CLIPBOARD_IMAGE // Show mouse cursor void ShowCursor(void) diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index eb8ef0103..e53f6e86d 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -509,6 +509,16 @@ const char *GetClipboardText(void) return NULL; } +// Get clipboard image +Image GetClipboardImage(void) +{ + Image image = { 0 }; + + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); + + return image; +} + // Show mouse cursor void ShowCursor(void) { diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 6bc3432eb..83994e30f 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -292,6 +292,16 @@ const char *GetClipboardText(void) return NULL; } +// Get clipboard image +Image GetClipboardImage(void) +{ + Image image = { 0 }; + + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); + + return image; +} + // Show mouse cursor void ShowCursor(void) { diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index f9d93e5a3..aea9fef83 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -805,6 +805,16 @@ const char *GetClipboardText(void) return NULL; } +// Get clipboard image +Image GetClipboardImage(void) +{ + Image image = { 0 }; + + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); + + return image; +} + // Show mouse cursor void ShowCursor(void) { From 9e4f513a43a953b17203cab2c1257573850ab918 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 19 Nov 2024 12:31:57 +0100 Subject: [PATCH 14/35] Reviewed formating --- src/platforms/rcore_desktop_sdl.c | 147 +++++++++++++++--------------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index a201f2cde..0b8406c7d 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -74,7 +74,6 @@ #endif #endif - //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- @@ -240,7 +239,7 @@ static const int CursorsLUT[] = { // SDL3 Migration Layer made to avoid `ifdefs` inside functions when we can. -#ifdef PLATFORM_DESKTOP_SDL3 +#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: // SDL_WINDOW_FULLSCREEN_DESKTOP has been removed, @@ -249,7 +248,6 @@ static const int CursorsLUT[] = { // or the borderless fullscreen desktop mode will be used #define SDL_WINDOW_FULLSCREEN_DESKTOP SDL_WINDOW_FULLSCREEN - #define SDL_IGNORE false #define SDL_DISABLE false #define SDL_ENABLE true @@ -260,27 +258,29 @@ static const int CursorsLUT[] = { // SDL3 Migration: The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag. #define SDL_WINDOW_SHOWN 0x0 // It's a flag, so no problem in setting it to zero if we use in a bitor (|) -// // SDL3 Migration: Renamed -// IMPORTANT: -// Might need to call SDL_CleanupEvent somewhere see :https://github.com/libsdl-org/SDL/issues/3540#issuecomment-1793449852 -// +// IMPORTANT: Might need to call SDL_CleanupEvent somewhere see :https://github.com/libsdl-org/SDL/issues/3540#issuecomment-1793449852 #define SDL_DROPFILE SDL_EVENT_DROP_FILE - -const char* SDL_GameControllerNameForIndex(int joystickIndex) +// SDL2 implementation for SDL3 function +const char *SDL_GameControllerNameForIndex(int joystickIndex) { // NOTE: SDL3 uses the IDs itself (SDL_JoystickID) instead of SDL2 joystick_index - const char* name = NULL; + const char *name = NULL; int numJoysticks = 0; SDL_JoystickID *joysticks = SDL_GetJoysticks(&numJoysticks); - if (joysticks) { - if (joystickIndex < numJoysticks) { + + if (joysticks) + { + if (joystickIndex < numJoysticks) + { SDL_JoystickID instance_id = joysticks[joystickIndex]; name = SDL_GetGamepadNameForID(instance_id); } + SDL_free(joysticks); } + return name; } @@ -288,45 +288,40 @@ int SDL_GetNumVideoDisplays(void) { int monitorCount = 0; SDL_DisplayID *displays = SDL_GetDisplays(&monitorCount); - // Safe because If `mem` is NULL, SDL_free does nothing. + + // Safe because If `mem` is NULL, SDL_free does nothing SDL_free(displays); return monitorCount; } - -// SLD3 Migration: -// To emulate SDL2 this function should return `SDL_DISABLE` or `SDL_ENABLE` -// representing the *processing state* of the event before this function makes any changes to it. -Uint8 SDL_EventState(Uint32 type, int state) { - +// SLD3 Migration: To emulate SDL2 this function should return `SDL_DISABLE` or `SDL_ENABLE` +// representing the *processing state* of the event before this function makes any changes to it +Uint8 SDL_EventState(Uint32 type, int state) +{ Uint8 stateBefore = SDL_EventEnabled(type); + switch (state) { case SDL_DISABLE: SDL_SetEventEnabled(type, false); break; case SDL_ENABLE: SDL_SetEventEnabled(type, true); break; default: TRACELOG(LOG_WARNING, "Event sate: unknow type"); } + return stateBefore; } void SDL_GetCurrentDisplayMode_Adapter(SDL_DisplayID displayID, SDL_DisplayMode* mode) { const SDL_DisplayMode* currMode = SDL_GetCurrentDisplayMode(displayID); - if (currMode == NULL) - { - TRACELOG(LOG_WARNING, "No current display mode"); - } - else - { - *mode = *currMode; - } + + if (currMode == NULL) TRACELOG(LOG_WARNING, "No current display mode"); + else *mode = *currMode; } // SDL3 Migration: Renamed #define SDL_GetCurrentDisplayMode SDL_GetCurrentDisplayMode_Adapter - SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { return SDL_CreateSurface(width, height, SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask)); @@ -337,11 +332,14 @@ SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth // not reliable across platforms, approximately replaced by multiplying // SDL_GetWindowDisplayScale() times 160 on iPhone and Android, and 96 on other platforms. // returns 0 on success or a negative error code on failure -int SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi) { - float dpi = SDL_GetWindowDisplayScale(platform.window) * 96.0; +int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi) +{ + float dpi = SDL_GetWindowDisplayScale(platform.window)*96.0; + if (ddpi != NULL) *ddpi = dpi; if (hdpi != NULL) *hdpi = dpi; if (vdpi != NULL) *vdpi = dpi; + return 0; } @@ -368,17 +366,13 @@ int SDL_NumJoysticks(void) return numJoysticks; } - // SDL_SetRelativeMouseMode // returns 0 on success or a negative error code on failure // If relative mode is not supported, this returns -1. int SDL_SetRelativeMouseMode_Adapter(SDL_bool enabled) { - - // // SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled) // \returns true on success or false on failure; call SDL_GetError() for more - // if (SDL_SetWindowRelativeMouseMode(platform.window, enabled)) { return 0; // success @@ -398,7 +392,6 @@ bool SDL_GetRelativeMouseMode_Adapter(void) #define SDL_GetRelativeMouseMode SDL_GetRelativeMouseMode_Adapter - int SDL_GetNumTouchFingers(SDL_TouchID touchID) { // SDL_Finger **SDL_GetTouchFingers(SDL_TouchID touchID, int *count) @@ -412,16 +405,16 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID) // Since SDL2 doesn't have this function we leave a stub // SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3) -void* SDL_GetClipboardData(const char *mime_type, size_t *size) { +void* SDL_GetClipboardData(const char *mime_type, size_t *size) +{ TRACELOG(LOG_WARNING, "Getting clipboard data that is not text is only available in SDL3"); + // We could possibly implement it ourselves in this case for some easier platforms return NULL; } #endif // PLATFORM_DESKTOP_SDL3 - - //---------------------------------------------------------------------------------- // Module Internal Functions Declaration //---------------------------------------------------------------------------------- @@ -452,7 +445,7 @@ void ToggleFullscreen(void) const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); -#ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure +#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -479,7 +472,8 @@ void ToggleBorderlessWindowed(void) { const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); -#ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure + +#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -532,7 +526,8 @@ void SetWindowState(unsigned int flags) { const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); - #ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure + + #if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -595,7 +590,8 @@ void SetWindowState(unsigned int flags) { const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); - #ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure + + #if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -818,7 +814,8 @@ void SetWindowMonitor(int monitor) const int screenWidth = CORE.Window.screen.width; const int screenHeight = CORE.Window.screen.height; SDL_Rect usableBounds; - #ifdef PLATFORM_DESKTOP_SDL3 // Different style for success checking + + #if defined(PLATFORM_DESKTOP_SDL3) // Different style for success checking if (SDL_GetDisplayUsableBounds(monitor, &usableBounds)) #else if (SDL_GetDisplayUsableBounds(monitor, &usableBounds) == 0) @@ -933,7 +930,8 @@ Vector2 GetMonitorPosition(int monitor) if ((monitor >= 0) && (monitor < monitorCount)) { SDL_Rect displayBounds; - #ifdef PLATFORM_DESKTOP_SDL3 + + #if defined(PLATFORM_DESKTOP_SDL3) if (SDL_GetDisplayUsableBounds(monitor, &displayBounds)) #else if (SDL_GetDisplayUsableBounds(monitor, &displayBounds) == 0) @@ -1104,53 +1102,55 @@ const char *GetClipboardText(void) return buffer; } - -#if defined(SUPPORT_CLIPBOARD_IMAGE) // Get clipboard image Image GetClipboardImage(void) { + Image image = { 0 }; + +#if defined(SUPPORT_CLIPBOARD_IMAGE) // Let's hope compiler put these arrays in static memory - const char *image_formats[] = { + const char *imageFormats[] = { "image/bmp", "image/png", "image/jpg", "image/tiff", }; - const char *image_extensions[] = { + const char *imageExtensions[] = { ".bmp", ".png", ".jpg", ".tiff", }; - - Image image = {0}; size_t dataSize = 0; void *fileData = NULL; - for (int i = 0; i < SDL_arraysize(image_formats); ++i) + + for (int i = 0; i < SDL_arraysize(imageFormats); ++i) { - // NOTE: This pointer should be free with SDL_free() at some point. - fileData = SDL_GetClipboardData(image_formats[i], &dataSize); - if (fileData) { - image = LoadImageFromMemory(image_extensions[i], fileData, dataSize); + // NOTE: This pointer should be free with SDL_free() at some point + fileData = SDL_GetClipboardData(imageFormats[i], &dataSize); + + if (fileData) + { + image = LoadImageFromMemory(imageExtensions[i], fileData, dataSize); if (IsImageValid(image)) { - TRACELOG(LOG_INFO, "Clipboard image: Got image from clipboard as a `%s` successfully", image_extensions[i]); + TRACELOG(LOG_INFO, "Clipboard image: Got image from clipboard as a `%s` successfully", imageExtensions[i]); return image; } } } - TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data. %s", SDL_GetError()); - return image; -} + if (!IsImageValid(image)) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data. Error: %s", SDL_GetError()); #endif + return image; +} // Show mouse cursor void ShowCursor(void) { -#ifdef PLATFORM_DESKTOP_SDL3 +#if defined(PLATFORM_DESKTOP_SDL3) SDL_ShowCursor(); #else SDL_ShowCursor(SDL_ENABLE); @@ -1161,7 +1161,7 @@ void ShowCursor(void) // Hides mouse cursor void HideCursor(void) { -#ifdef PLATFORM_DESKTOP_SDL3 +#if defined(PLATFORM_DESKTOP_SDL3) SDL_HideCursor(); #else SDL_ShowCursor(SDL_DISABLE); @@ -1174,7 +1174,7 @@ void EnableCursor(void) { SDL_SetRelativeMouseMode(SDL_FALSE); -#ifdef PLATFORM_DESKTOP_SDL3 +#if defined(PLATFORM_DESKTOP_SDL3) // SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible() SDL_ShowCursor(); #else @@ -1275,7 +1275,7 @@ const char *GetKeyName(int key) static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event) { -#ifdef PLATFORM_DESKTOP_SDL3 // SDL3 +#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 int count = 0; SDL_Finger **fingers = SDL_GetTouchFingers(event.touchID, &count); CORE.Input.Touch.pointCount = count; @@ -1288,7 +1288,9 @@ static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event) CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height; CORE.Input.Touch.currentTouchState[i] = 1; } + SDL_free(fingers); + #else // SDL2 CORE.Input.Touch.pointCount = SDL_GetNumTouchFingers(event.touchId); @@ -1393,7 +1395,8 @@ void PollInputEvents(void) CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *)); CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); - #ifdef PLATFORM_DESKTOP_SDL3 + + #if defined(PLATFORM_DESKTOP_SDL3) // const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */ // Event memory is now managed by SDL, so you should not free the data in SDL_EVENT_DROP_FILE, and if you want to hold onto the text in SDL_EVENT_TEXT_EDITING and SDL_EVENT_TEXT_INPUT events, you should make a copy of it. SDL_TEXTINPUTEVENT_TEXT_SIZE is no longer necessary and has been removed. strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data); @@ -1407,7 +1410,8 @@ void PollInputEvents(void) else if (CORE.Window.dropFileCount < 1024) { CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); - #ifdef PLATFORM_DESKTOP_SDL3 + + #if defined(PLATFORM_DESKTOP_SDL3) strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data); #else strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.file); @@ -1460,7 +1464,7 @@ void PollInputEvents(void) case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_RESTORED: - #ifdef PLATFORM_DESKTOP_SDL3 + #if defined(PLATFORM_DESKTOP_SDL3) break; #else default: break; @@ -1471,7 +1475,7 @@ void PollInputEvents(void) // Keyboard events case SDL_KEYDOWN: { - #ifdef PLATFORM_DESKTOP_SDL3 + #if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: The following structures have been removed: * SDL_Keysym KeyboardKey key = ConvertScancodeToKey(event.key.scancode); #else @@ -1502,7 +1506,7 @@ void PollInputEvents(void) case SDL_KEYUP: { - #ifdef PLATFORM_DESKTOP_SDL3 + #if defined(PLATFORM_DESKTOP_SDL3) KeyboardKey key = ConvertScancodeToKey(event.key.scancode); #else KeyboardKey key = ConvertScancodeToKey(event.key.keysym.scancode); @@ -1858,7 +1862,7 @@ int InitPlatform(void) } // Init window -#ifdef PLATFORM_DESKTOP_SDL3 +#if defined(PLATFORM_DESKTOP_SDL3) platform.window = SDL_CreateWindow(CORE.Window.title, CORE.Window.screen.width, CORE.Window.screen.height, flags); #else platform.window = SDL_CreateWindow(CORE.Window.title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, CORE.Window.screen.width, CORE.Window.screen.height, flags); @@ -1946,11 +1950,10 @@ int InitPlatform(void) CORE.Storage.basePath = SDL_GetBasePath(); // Alternative: GetWorkingDirectory(); //---------------------------------------------------------------------------- - -#ifdef PLATFORM_DESKTOP_SDL3 +#if defined(PLATFORM_DESKTOP_SDL3) TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL3): Initialized successfully"); #else - TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL): Initialized successfully"); + TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL2): Initialized successfully"); #endif return 0; From 26548c10620c4ae6937cf8b506c777a006b33c16 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 19 Nov 2024 12:33:13 +0100 Subject: [PATCH 15/35] Remove trail-spaces --- src/platforms/rcore_android.c | 2 +- src/platforms/rcore_desktop_glfw.c | 8 +++---- src/platforms/rcore_desktop_rgfw.c | 14 ++++++------ src/platforms/rcore_desktop_sdl.c | 36 +++++++++++++++--------------- src/platforms/rcore_drm.c | 2 +- src/platforms/rcore_template.c | 2 +- src/platforms/rcore_web.c | 2 +- src/rlgl.h | 4 ++-- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 401e2a067..47dc5cabc 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -519,7 +519,7 @@ const char *GetClipboardText(void) Image GetClipboardImage(void) { Image image = { 0 }; - + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); return image; diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 839852d9f..5caf17ead 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -68,7 +68,7 @@ // NOTE: Those functions require linking with winmm library //#pragma warning(disable: 4273) __declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod); - //#pragma warning(default: 4273) + //#pragma warning(default: 4273) #endif #endif #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) @@ -971,16 +971,16 @@ const char *GetClipboardText(void) Image GetClipboardImage(void) { Image image = { 0 }; - + #if defined(SUPPORT_CLIPBOARD_IMAGE) #if defined(_WIN32) unsigned long long int dataSize = 0; void *fileData = NULL; int width = 0; int height = 0; - + fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); - + if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); #else diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 7a2ea9c0d..1d3ddf60f 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -246,7 +246,7 @@ bool WindowShouldClose(void) // Toggle fullscreen mode void ToggleFullscreen(void) -{ +{ RGFW_window_maximize(platform.window); ToggleBorderlessWindowed(); } @@ -678,16 +678,16 @@ const char *GetClipboardText(void) Image GetClipboardImage(void) { Image image = { 0 }; - + #if defined(SUPPORT_CLIPBOARD_IMAGE) #if defined(_WIN32) unsigned long long int dataSize = 0; void *fileData = NULL; int width = 0; int height = 0; - + fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); - + if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); #else @@ -1194,7 +1194,7 @@ void PollInputEvents(void) int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2; int pressed = (value > 0.1f); CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed; - + if (pressed) CORE.Input.Gamepad.lastButtonPressed = button; else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; } @@ -1286,8 +1286,8 @@ int InitPlatform(void) RGFW_area screenSize = RGFW_getScreenSize(); CORE.Window.display.width = screenSize.w; CORE.Window.display.height = screenSize.h; - /* - I think this is needed by Raylib now ? + /* + I think this is needed by Raylib now ? If so, rcore_destkop_sdl should be updated too */ SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 0b8406c7d..99de9af22 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -244,7 +244,7 @@ static const int CursorsLUT[] = { // SDL3 Migration: // SDL_WINDOW_FULLSCREEN_DESKTOP has been removed, // and you can call SDL_GetWindowFullscreenMode() -// to see whether an exclusive fullscreen mode will be used +// to see whether an exclusive fullscreen mode will be used // or the borderless fullscreen desktop mode will be used #define SDL_WINDOW_FULLSCREEN_DESKTOP SDL_WINDOW_FULLSCREEN @@ -269,7 +269,7 @@ const char *SDL_GameControllerNameForIndex(int joystickIndex) const char *name = NULL; int numJoysticks = 0; SDL_JoystickID *joysticks = SDL_GetJoysticks(&numJoysticks); - + if (joysticks) { if (joystickIndex < numJoysticks) @@ -277,10 +277,10 @@ const char *SDL_GameControllerNameForIndex(int joystickIndex) SDL_JoystickID instance_id = joysticks[joystickIndex]; name = SDL_GetGamepadNameForID(instance_id); } - + SDL_free(joysticks); } - + return name; } @@ -288,7 +288,7 @@ int SDL_GetNumVideoDisplays(void) { int monitorCount = 0; SDL_DisplayID *displays = SDL_GetDisplays(&monitorCount); - + // Safe because If `mem` is NULL, SDL_free does nothing SDL_free(displays); @@ -300,21 +300,21 @@ int SDL_GetNumVideoDisplays(void) Uint8 SDL_EventState(Uint32 type, int state) { Uint8 stateBefore = SDL_EventEnabled(type); - + switch (state) { case SDL_DISABLE: SDL_SetEventEnabled(type, false); break; case SDL_ENABLE: SDL_SetEventEnabled(type, true); break; default: TRACELOG(LOG_WARNING, "Event sate: unknow type"); } - + return stateBefore; } void SDL_GetCurrentDisplayMode_Adapter(SDL_DisplayID displayID, SDL_DisplayMode* mode) { const SDL_DisplayMode* currMode = SDL_GetCurrentDisplayMode(displayID); - + if (currMode == NULL) TRACELOG(LOG_WARNING, "No current display mode"); else *mode = *currMode; } @@ -335,11 +335,11 @@ SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi) { float dpi = SDL_GetWindowDisplayScale(platform.window)*96.0; - + if (ddpi != NULL) *ddpi = dpi; if (hdpi != NULL) *hdpi = dpi; if (vdpi != NULL) *vdpi = dpi; - + return 0; } @@ -408,7 +408,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID) void* SDL_GetClipboardData(const char *mime_type, size_t *size) { TRACELOG(LOG_WARNING, "Getting clipboard data that is not text is only available in SDL3"); - + // We could possibly implement it ourselves in this case for some easier platforms return NULL; } @@ -930,7 +930,7 @@ Vector2 GetMonitorPosition(int monitor) if ((monitor >= 0) && (monitor < monitorCount)) { SDL_Rect displayBounds; - + #if defined(PLATFORM_DESKTOP_SDL3) if (SDL_GetDisplayUsableBounds(monitor, &displayBounds)) #else @@ -1124,12 +1124,12 @@ Image GetClipboardImage(void) size_t dataSize = 0; void *fileData = NULL; - + for (int i = 0; i < SDL_arraysize(imageFormats); ++i) { // NOTE: This pointer should be free with SDL_free() at some point fileData = SDL_GetClipboardData(imageFormats[i], &dataSize); - + if (fileData) { image = LoadImageFromMemory(imageExtensions[i], fileData, dataSize); @@ -1288,9 +1288,9 @@ static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event) CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height; CORE.Input.Touch.currentTouchState[i] = 1; } - + SDL_free(fingers); - + #else // SDL2 CORE.Input.Touch.pointCount = SDL_GetNumTouchFingers(event.touchId); @@ -1395,7 +1395,7 @@ void PollInputEvents(void) CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *)); CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); - + #if defined(PLATFORM_DESKTOP_SDL3) // const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */ // Event memory is now managed by SDL, so you should not free the data in SDL_EVENT_DROP_FILE, and if you want to hold onto the text in SDL_EVENT_TEXT_EDITING and SDL_EVENT_TEXT_INPUT events, you should make a copy of it. SDL_TEXTINPUTEVENT_TEXT_SIZE is no longer necessary and has been removed. @@ -1410,7 +1410,7 @@ void PollInputEvents(void) else if (CORE.Window.dropFileCount < 1024) { CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); - + #if defined(PLATFORM_DESKTOP_SDL3) strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data); #else diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index e53f6e86d..e9a236868 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -513,7 +513,7 @@ const char *GetClipboardText(void) Image GetClipboardImage(void) { Image image = { 0 }; - + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); return image; diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 83994e30f..891c4ab34 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -296,7 +296,7 @@ const char *GetClipboardText(void) Image GetClipboardImage(void) { Image image = { 0 }; - + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); return image; diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index aea9fef83..859b2c1f3 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -809,7 +809,7 @@ const char *GetClipboardText(void) Image GetClipboardImage(void) { Image image = { 0 }; - + TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); return image; diff --git a/src/rlgl.h b/src/rlgl.h index 3bb996add..92971df62 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -3417,9 +3417,9 @@ unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mi { if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) { - if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) || + if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) || (format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) || - (format == RL_PIXELFORMAT_UNCOMPRESSED_R16) || + (format == RL_PIXELFORMAT_UNCOMPRESSED_R16) || (format == RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)) TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported"); else glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, glFormat, glType, NULL); } From 481095226daedfc2a2254372cdb5f5ff225915d7 Mon Sep 17 00:00:00 2001 From: Alexandre B A Villares <3694604+villares@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:41:14 -0300 Subject: [PATCH 16/35] Update BINDINGS.md: github.com/electronstudio/raylib-python-cffi now 5.5 (#4517) --- BINDINGS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BINDINGS.md b/BINDINGS.md index b3aef1293..f82a66be7 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -54,9 +54,9 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [Ray4Laz](https://github.com/GuvaCode/Ray4Laz) | **5.5** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib | | [Raylib.4.0.Pascal](https://github.com/sysrpl/Raylib.4.0.Pascal) | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib | | [pyraylib](https://github.com/Ho011/pyraylib) | 3.7 | [Python](https://www.python.org) | Zlib | -| [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | 5.0 | [Python](https://www.python.org) | EPL-2.0 | +| [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | **5.5** | [Python](https://www.python.org) | EPL-2.0 | | [raylibpyctbg](https://github.com/overdev/raylibpyctbg) | 4.5 | [Python](https://www.python.org) | MIT | -| [raylib-py](https://github.com/overdev/raylib-py) | **5.0b1** | [Python](https://www.python.org) | MIT | +| [raylib-py](https://github.com/overdev/raylib-py) | 5.0b1 | [Python](https://www.python.org) | MIT | | [raylib-python-ctypes](https://github.com/sDos280/raylib-python-ctypes) | 4.6-dev | [Python](https://www.python.org) | MIT | | [raylib-pkpy-bindings](https://github.com/blueloveTH/pkpy-bindings) | 4.6-dev | [pocketpy](https://pocketpy.dev) | MIT | | [raylib-php](https://github.com/joseph-montanez/raylib-php) | 4.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | From a145779e215772cbcbb7d68e74fdf927264facc1 Mon Sep 17 00:00:00 2001 From: Philipp Date: Tue, 19 Nov 2024 21:42:34 +0000 Subject: [PATCH 17/35] Update BINDINGS.md: fortran-raylib is on v5.5 (#4518) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index f82a66be7..5c2170373 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -27,7 +27,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [rayex](https://github.com/shiryel/rayex) | 3.7 | [elixir](https://elixir-lang.org) | Apache-2.0 | | [raylib-factor](https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor) | 4.5 | [Factor](https://factorcode.org) | BSD | | [raylib-freebasic](https://github.com/WIITD/raylib-freebasic) | **5.0** | [FreeBASIC](https://www.freebasic.net) | MIT | -| [fortran-raylib](https://github.com/interkosmos/fortran-raylib) | 4.5 | [Fortran](https://fortran-lang.org) | ISC | +| [fortran-raylib](https://github.com/interkosmos/fortran-raylib) | **5.5** | [Fortran](https://fortran-lang.org) | ISC | | [raylib-go](https://github.com/gen2brain/raylib-go) | **5.0** | [Go](https://golang.org) | Zlib | | [raylib-guile](https://github.com/petelliott/raylib-guile) | **auto** | [Guile](https://www.gnu.org/software/guile) | Zlib | | [gforth-raylib](https://github.com/ArnautDaniel/gforth-raylib) | 3.5 | [Gforth](https://gforth.org) | **???** | From 57edbc3bab77e89b88e157f6f31ee29d9f62a040 Mon Sep 17 00:00:00 2001 From: "Jorge A. Gomes" Date: Wed, 20 Nov 2024 07:24:47 -0300 Subject: [PATCH 18/35] Update BINDINGS.md for raylib-py 5.5 (#4519) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 5c2170373..919bc51ca 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -56,7 +56,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [pyraylib](https://github.com/Ho011/pyraylib) | 3.7 | [Python](https://www.python.org) | Zlib | | [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | **5.5** | [Python](https://www.python.org) | EPL-2.0 | | [raylibpyctbg](https://github.com/overdev/raylibpyctbg) | 4.5 | [Python](https://www.python.org) | MIT | -| [raylib-py](https://github.com/overdev/raylib-py) | 5.0b1 | [Python](https://www.python.org) | MIT | +| [raylib-py](https://github.com/overdev/raylib-py) | 5.5 | [Python](https://www.python.org) | MIT | | [raylib-python-ctypes](https://github.com/sDos280/raylib-python-ctypes) | 4.6-dev | [Python](https://www.python.org) | MIT | | [raylib-pkpy-bindings](https://github.com/blueloveTH/pkpy-bindings) | 4.6-dev | [pocketpy](https://pocketpy.dev) | MIT | | [raylib-php](https://github.com/joseph-montanez/raylib-php) | 4.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | From 6af664c04ee4d75cff31c563967d75f0295a7325 Mon Sep 17 00:00:00 2001 From: devdad Date: Wed, 20 Nov 2024 11:25:31 +0100 Subject: [PATCH 19/35] Update shaders_basic_pbr example to work on web (#4516) * basic pbr example pbr implementation includes rpbr.h and few shader files header only file, which self contain everything needed for pbr rendering. Few textures and one model of the car which is under free licence which is included inside basic_pbr.c example file currently supported shader versions are 120 and 330 , version 100 has small issue which I have to resolve * Unloading PBRMAterial I forgot unloading PBRMaterial * fix small issue with texOffset assigment. value was Vector4 at first but I found out it would be unclear for and users, so I change to have two Vector2 instead, but forgot to assign offset . * Changed size of textures and file name changed Changed size of textures from 2048x2048 to 1024x1024 and file name changed to shaders_basic_pbr.c , Added the function PBRModel PBRModelLoadFromMesh(Mesh mesh); but GenMeshPlane(2, 2.0, 3, 3) culdn't be used because it crash once GenMeshTangents() is used with that plane mesh * Update to 5.5 version of eexample and fix to work in web set GLSL_VERSION 100 set precision highp float; removed in keyword fix for loop has to use only constant * Update shader_basic_pbr example to work on web changed to GLSL_VERSION 100 update glsl100 shader set float precision to highp removed keyword in change for loop tu use constant value gives an error * Update shader_basic_pbr example to work on web changed to GLSL_VERSION 100 update glsl100 shader set float precision to highp removed keyword in change for loop tu use constant value gives an error * removed rpbr.h removed rpbr.h --- .../shaders/resources/shaders/glsl100/pbr.fs | 16 ++++++++-------- examples/shaders/shaders_basic_pbr.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/shaders/resources/shaders/glsl100/pbr.fs b/examples/shaders/resources/shaders/glsl100/pbr.fs index 1ada83317..27d496968 100644 --- a/examples/shaders/resources/shaders/glsl100/pbr.fs +++ b/examples/shaders/resources/shaders/glsl100/pbr.fs @@ -1,6 +1,6 @@ #version 100 -precision mediump float; +precision highp float; #define MAX_LIGHTS 4 #define LIGHT_DIRECTIONAL 0 @@ -17,12 +17,12 @@ struct Light { }; // Input vertex attributes (from vertex shader) -varying in vec3 fragPosition; -varying in vec2 fragTexCoord; -varying in vec4 fragColor; -varying in vec3 fragNormal; -varying in vec4 shadowPos; -varying in mat3 TBN; +varying vec3 fragPosition; +varying vec2 fragTexCoord; +varying vec4 fragColor; +varying vec3 fragNormal; +varying vec4 shadowPos; +varying mat3 TBN; // Input uniform values @@ -113,7 +113,7 @@ vec3 pbr(){ vec3 baseRefl = mix(vec3(0.04),albedo.rgb,metallic); vec3 Lo = vec3(0.0); // acumulate lighting lum - for(int i=0;i // Required for: NULL From 532167d28baade92a50c1020c127f2d060cd392f Mon Sep 17 00:00:00 2001 From: kimierik <105240664+kimierik@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:26:29 +0200 Subject: [PATCH 20/35] build.zig: fix raygui inclusion in windows crosscompilation (#4489) --- build.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.zig b/build.zig index 5c2ac77cd..4cc412bc5 100644 --- a/build.zig +++ b/build.zig @@ -302,12 +302,14 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. } pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *std.Build.Dependency) void { + const raylib_dep = b.dependencyFromBuildZig(@This(), .{}); var gen_step = b.addWriteFiles(); raylib.step.dependOn(&gen_step.step); const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n"); raylib.addCSourceFile(.{ .file = raygui_c_path }); raylib.addIncludePath(raygui_dep.path("src")); + raylib.addIncludePath(raylib_dep.path("src")); raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h"); } From 415a98965a9d8ca1538e890367f27ec08c95f05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gael=20P=C3=A9rez?= Date: Wed, 20 Nov 2024 04:27:14 -0600 Subject: [PATCH 21/35] update raymath.h: add Vector2CrossProduct function (#4520) --- src/raymath.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/raymath.h b/src/raymath.h index e522113b1..06865e199 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -304,6 +304,14 @@ RMAPI float Vector2DotProduct(Vector2 v1, Vector2 v2) return result; } +// Calculate two vectors cross product +RMAPI float Vector2CrossProduct(Vector2 v1, Vector2 v2) +{ + float result = (v1.x*v2.y - v1.y*v2.x); + + return result; +} + // Calculate distance between two vectors RMAPI float Vector2Distance(Vector2 v1, Vector2 v2) { From 11429b48eb244c8e153838cf7d876d75da992815 Mon Sep 17 00:00:00 2001 From: veins1 <19636663+veins1@users.noreply.github.com> Date: Thu, 21 Nov 2024 01:28:46 +0500 Subject: [PATCH 22/35] Fix for #4521 (#4523) --- src/raudio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/raudio.c b/src/raudio.c index 15859a661..33c0c4e04 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1855,6 +1855,8 @@ void SeekMusicStream(Music music, float position) ma_mutex_lock(&AUDIO.System.lock); music.stream.buffer->framesProcessed = positionInFrames; + music.stream.buffer->isSubBufferProcessed[0] = true; + music.stream.buffer->isSubBufferProcessed[1] = true; ma_mutex_unlock(&AUDIO.System.lock); } From 0d39e7137b28980f05843bd505ef3e74d8772d03 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 21 Nov 2024 12:38:29 +0100 Subject: [PATCH 23/35] Fix #4527 --- .../shaders/glsl330/hybrid_raster.fs | 12 +++++++-- .../resources/shaders/glsl330/sobel.fs | 26 +++++++++---------- .../resources/shaders/glsl330/swirl.fs | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs b/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs index 85ef492c0..26c7e8f26 100644 --- a/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs +++ b/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs @@ -1,14 +1,22 @@ -#version 330 +#version 330 +// Input vertex attributes (from vertex shader) in vec2 fragTexCoord; in vec4 fragColor; +// Input uniform values uniform sampler2D texture0; uniform vec4 colDiffuse; +// Output fragment color +//out vec4 finalColor; + +// NOTE: Add here your custom variables + void main() { - vec4 texelColor = texture2D(texture0, fragTexCoord); + vec4 texelColor = texture(texture0, fragTexCoord); + gl_FragColor = texelColor*colDiffuse*fragColor; gl_FragDepth = gl_FragCoord.z; } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/sobel.fs b/examples/shaders/resources/shaders/glsl330/sobel.fs index f76e9cab9..80883710d 100644 --- a/examples/shaders/resources/shaders/glsl330/sobel.fs +++ b/examples/shaders/resources/shaders/glsl330/sobel.fs @@ -20,22 +20,22 @@ void main() float y = 1.0/resolution.y; vec4 horizEdge = vec4(0.0); - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; + horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; + horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; vec4 vertEdge = vec4(0.0); - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + vertEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + vertEdge -= texture(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; + vertEdge -= texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + vertEdge += texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + vertEdge += texture(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; + vertEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); - finalColor = vec4(edge, texture2D(texture0, fragTexCoord).a); + finalColor = vec4(edge, texture(texture0, fragTexCoord).a); } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/swirl.fs b/examples/shaders/resources/shaders/glsl330/swirl.fs index bb0732c55..6a71e3696 100644 --- a/examples/shaders/resources/shaders/glsl330/swirl.fs +++ b/examples/shaders/resources/shaders/glsl330/swirl.fs @@ -41,7 +41,7 @@ void main() } tc += center; - vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;; + vec4 color = texture(texture0, tc/texSize)*colDiffuse*fragColor;; finalColor = vec4(color.rgb, 1.0);; } \ No newline at end of file From a53a8958f293c0cc5760021cce616574408aee50 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Fri, 22 Nov 2024 06:52:55 -0300 Subject: [PATCH 24/35] Add implementation to GetWindowScaleDPI() for PLATFORM_WEB (#4526) --- src/platforms/rcore_web.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 859b2c1f3..d0be02514 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -771,8 +771,11 @@ Vector2 GetWindowPosition(void) // Get window scale DPI factor for current monitor Vector2 GetWindowScaleDPI(void) { - TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform"); - return (Vector2){ 1.0f, 1.0f }; + // NOTE: Returned scale is relative to the current monitor where the browser window is located + Vector2 scale = { 1.0f, 1.0f }; + scale.x = (float)EM_ASM_DOUBLE( { return window.devicePixelRatio; } ); + scale.y = scale.x; + return scale; } // Set clipboard text content From 50a2afff9ebf4f76c61fcf84c046586c9e9b6355 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 22 Nov 2024 11:01:10 +0100 Subject: [PATCH 25/35] Update raylib version to 5.6-dev to avoid confusions with release --- src/raylib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index a26b8ce6b..e548f6def 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raylib v5.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) +* raylib v5.6-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) * * FEATURES: * - NO external dependencies, all required libraries included with raylib @@ -88,9 +88,9 @@ #include // Required for: va_list - Only used by TraceLogCallback #define RAYLIB_VERSION_MAJOR 5 -#define RAYLIB_VERSION_MINOR 5 +#define RAYLIB_VERSION_MINOR 6 #define RAYLIB_VERSION_PATCH 0 -#define RAYLIB_VERSION "5.5" +#define RAYLIB_VERSION "5.6-dev" // Function specifiers in case library is build/used as a shared library // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll From 65e0d2cfda9a53a00b8b9e9350544867896817d1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 22 Nov 2024 10:01:29 +0000 Subject: [PATCH 26/35] Update raylib_api.* by CI --- parser/output/raylib_api.json | 4 ++-- parser/output/raylib_api.lua | 4 ++-- parser/output/raylib_api.txt | 4 ++-- parser/output/raylib_api.xml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index 0921ed40e..8561bc343 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -15,7 +15,7 @@ { "name": "RAYLIB_VERSION_MINOR", "type": "INT", - "value": 5, + "value": 6, "description": "" }, { @@ -27,7 +27,7 @@ { "name": "RAYLIB_VERSION", "type": "STRING", - "value": "5.5", + "value": "5.6-dev", "description": "" }, { diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index a8e242ac7..9ff6c1a9c 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -15,7 +15,7 @@ return { { name = "RAYLIB_VERSION_MINOR", type = "INT", - value = 5, + value = 6, description = "" }, { @@ -27,7 +27,7 @@ return { { name = "RAYLIB_VERSION", type = "STRING", - value = "5.5", + value = "5.6-dev", description = "" }, { diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index a9cfa005c..e7d04cb46 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -14,7 +14,7 @@ Define 002: RAYLIB_VERSION_MAJOR Define 003: RAYLIB_VERSION_MINOR Name: RAYLIB_VERSION_MINOR Type: INT - Value: 5 + Value: 6 Description: Define 004: RAYLIB_VERSION_PATCH Name: RAYLIB_VERSION_PATCH @@ -24,7 +24,7 @@ Define 004: RAYLIB_VERSION_PATCH Define 005: RAYLIB_VERSION Name: RAYLIB_VERSION Type: STRING - Value: "5.5" + Value: "5.6-dev" Description: Define 006: __declspec(x) Name: __declspec(x) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index dcc079f10..6a5cecf5e 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -3,9 +3,9 @@ - + - + From da6fa1d756b4fac76881250089dc48f6e9d2ac1c Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 22 Nov 2024 11:06:34 +0100 Subject: [PATCH 27/35] Fix #4529 --- src/rtext.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rtext.c b/src/rtext.c index 81bfe1a8a..999557d38 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1339,6 +1339,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing int GetGlyphIndex(Font font, int codepoint) { int index = 0; + if (!IsFontValid(font)) return index; #define SUPPORT_UNORDERED_CHARSET #if defined(SUPPORT_UNORDERED_CHARSET) From a9aa6b498834925509ed9176d71ad9e96033cc4d Mon Sep 17 00:00:00 2001 From: HaxSam Date: Sun, 24 Nov 2024 16:22:51 +0100 Subject: [PATCH 28/35] [build.zig] improve build system for zig (#4531) Is now possible to switch platform Is now possible to diable raudio, rmodels, and so on Made getOptions public so it can be used for zig wrappers --- build.zig | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/build.zig b/build.zig index 4cc412bc5..866e70034 100644 --- a/build.zig +++ b/build.zig @@ -12,8 +12,6 @@ comptime { } fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void { - raylib.defineCMacro("PLATFORM_DESKTOP", null); - switch (platform) { .glfw => raylib.defineCMacro("PLATFORM_DESKTOP_GLFW", null), .rgfw => raylib.defineCMacro("PLATFORM_DESKTOP_RGFW", null), @@ -58,6 +56,7 @@ const config_h_flags = outer: { var lines = std.mem.tokenizeScalar(u8, config_h, '\n'); while (lines.next()) |line| { if (!std.mem.containsAtLeast(u8, line, 1, "SUPPORT")) continue; + if (std.mem.containsAtLeast(u8, line, 1, "MODULE")) continue; if (std.mem.startsWith(u8, line, "//")) continue; if (std.mem.startsWith(u8, line, "#if")) continue; @@ -94,10 +93,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. }); } + // Sets a flag indiciating the use of a custom `config.h` + try raylib_flags_arr.append("-DEXTERNAL_CONFIG_FLAGS"); if (options.config.len > 0) { - // Sets a flag indiciating the use of a custom `config.h` - try raylib_flags_arr.append("-DEXTERNAL_CONFIG_FLAGS"); - // Splits a space-separated list of config flags into multiple flags // // Note: This means certain flags like `-x c++` won't be processed properly. @@ -126,6 +124,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. // Otherwise, append default value from config.h to compile flags try raylib_flags_arr.append(flag); } + } else { + // Set default config if no custome config got set + try raylib_flags_arr.appendSlice(&config_h_flags); } const raylib = if (options.shared) @@ -150,26 +151,32 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. var c_source_files = try std.ArrayList([]const u8).initCapacity(b.allocator, 2); c_source_files.appendSliceAssumeCapacity(&.{ "src/rcore.c", "src/utils.c" }); - if (options.raudio) { - try c_source_files.append("src/raudio.c"); - } - if (options.rmodels) { - try c_source_files.append("src/rmodels.c"); - } if (options.rshapes) { try c_source_files.append("src/rshapes.c"); + try raylib_flags_arr.append("-DSUPPORT_MODULE_RSHAPES"); + } + if (options.rtextures) { + try c_source_files.append("src/rtextures.c"); + try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXTURES"); } if (options.rtext) { try c_source_files.append("src/rtext.c"); + try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXT"); } - if (options.rtextures) { - try c_source_files.append("src/rtextures.c"); + if (options.rmodels) { + try c_source_files.append("src/rmodels.c"); + try raylib_flags_arr.append("-DSUPPORT_MODULE_RMODELS"); + } + if (options.raudio) { + try c_source_files.append("src/raudio.c"); + try raylib_flags_arr.append("-DSUPPORT_MODULE_RAUDIO"); } if (options.opengl_version != .auto) { raylib.defineCMacro(options.opengl_version.toCMacroStr(), null); } + raylib.addIncludePath(b.path("src/platforms")); switch (target.result.os.tag) { .windows => { try c_source_files.append("src/rglfw.c"); @@ -329,7 +336,7 @@ pub const Options = struct { const defaults = Options{}; - fn getOptions(b: *std.Build) Options { + pub fn getOptions(b: *std.Build) Options { return .{ .platform = b.option(PlatformBackend, "platform", "Choose the platform backedn for desktop target") orelse defaults.platform, .raudio = b.option(bool, "raudio", "Compile with audio support") orelse defaults.raudio, From e494c545b879fa80f55aae13772316fd5c25daac Mon Sep 17 00:00:00 2001 From: listeria <56203103+ListeriaM@users.noreply.github.com> Date: Sun, 24 Nov 2024 12:24:34 -0300 Subject: [PATCH 29/35] raymath: fix C++ operator overloads (#4535) Co-authored-by: Listeria monocytogenes --- src/raymath.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 06865e199..5b5e4c74f 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -2656,7 +2656,7 @@ inline Vector2 operator * (const Vector2& lhs, const Matrix& rhs) return Vector2Transform(lhs, rhs); } -inline const Vector2& operator -= (Vector2& lhs, const Matrix& rhs) +inline const Vector2& operator *= (Vector2& lhs, const Matrix& rhs) { lhs = Vector2Transform(lhs, rhs); return lhs; @@ -2669,7 +2669,7 @@ inline Vector2 operator / (const Vector2& lhs, const float& rhs) inline const Vector2& operator /= (Vector2& lhs, const float& rhs) { - lhs = Vector2Scale(lhs, rhs); + lhs = Vector2Scale(lhs, 1.0f / rhs); return lhs; } @@ -2750,7 +2750,7 @@ inline Vector3 operator * (const Vector3& lhs, const Matrix& rhs) return Vector3Transform(lhs, rhs); } -inline const Vector3& operator -= (Vector3& lhs, const Matrix& rhs) +inline const Vector3& operator *= (Vector3& lhs, const Matrix& rhs) { lhs = Vector3Transform(lhs, rhs); return lhs; @@ -2763,7 +2763,7 @@ inline Vector3 operator / (const Vector3& lhs, const float& rhs) inline const Vector3& operator /= (Vector3& lhs, const float& rhs) { - lhs = Vector3Scale(lhs, rhs); + lhs = Vector3Scale(lhs, 1.0f / rhs); return lhs; } @@ -2847,7 +2847,7 @@ inline Vector4 operator / (const Vector4& lhs, const float& rhs) inline const Vector4& operator /= (Vector4& lhs, const float& rhs) { - lhs = Vector4Scale(lhs, rhs); + lhs = Vector4Scale(lhs, 1.0f / rhs); return lhs; } From 6141489b003be8136d0900479b44fb0732998ff8 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Sun, 24 Nov 2024 07:25:36 -0800 Subject: [PATCH 30/35] Fixes casting warnings with RGFW platform. (#4534) --- src/platforms/rcore_desktop_rgfw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 1d3ddf60f..913223511 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -587,7 +587,7 @@ Vector2 GetMonitorPosition(int monitor) { RGFW_monitor *mons = RGFW_getMonitors(); - return (Vector2){mons[monitor].rect.x, mons[monitor].rect.y}; + return (Vector2){(float)mons[monitor].rect.x, (float)mons[monitor].rect.y}; } // Get selected monitor width (currently used by monitor) @@ -611,7 +611,7 @@ int GetMonitorPhysicalWidth(int monitor) { RGFW_monitor* mons = RGFW_getMonitors(); - return mons[monitor].physW; + return (int)mons[monitor].physW; } // Get selected monitor physical height in millimetres @@ -619,7 +619,7 @@ int GetMonitorPhysicalHeight(int monitor) { RGFW_monitor *mons = RGFW_getMonitors(); - return mons[monitor].physH; + return (int)mons[monitor].physH; } // Get selected monitor refresh rate @@ -640,7 +640,7 @@ const char *GetMonitorName(int monitor) // Get window position XY on monitor Vector2 GetWindowPosition(void) { - return (Vector2){ platform.window->r.x, platform.window->r.y }; + return (Vector2){ (float)platform.window->r.x, (float)platform.window->r.y }; } // Get window scale DPI factor for current monitor @@ -654,7 +654,7 @@ Vector2 GetWindowScaleDPI(void) // Set clipboard text content void SetClipboardText(const char *text) { - RGFW_writeClipboard(text, strlen(text)); + RGFW_writeClipboard(text, (u32)strlen(text)); } // Get clipboard text content @@ -947,7 +947,7 @@ void PollInputEvents(void) case RGFW_quit: CORE.Window.shouldClose = true; break; case RGFW_dnd: // Dropped file { - for (int i = 0; i < event->droppedFilesCount; i++) + for (u32 i = 0; i < event->droppedFilesCount; i++) { if (CORE.Window.dropFileCount == 0) { @@ -1031,7 +1031,7 @@ void PollInputEvents(void) { if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) { - CORE.Input.Mouse.currentWheelMove.y = event->scroll; + CORE.Input.Mouse.currentWheelMove.y = (float)event->scroll; break; } @@ -1050,7 +1050,7 @@ void PollInputEvents(void) if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) { - CORE.Input.Mouse.currentWheelMove.y = event->scroll; + CORE.Input.Mouse.currentWheelMove.y = (float)event->scroll; break; } From e6d7d0cf239679ad7050e374477923268f59839f Mon Sep 17 00:00:00 2001 From: ColleagueRiley Date: Sun, 24 Nov 2024 13:14:56 -0500 Subject: [PATCH 31/35] update raylib (merge) --- Makefile | 8 ++++ src/external/RGFW.h | 11 ++++-- src/platforms/rcore_desktop_rgfw.c | 59 ++++++++++++++++-------------- 3 files changed, 46 insertions(+), 32 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..ba7767f3f --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +EXAMPLE = core/core_input_gamepad +PLATFORM = PLATOFRM_WEB_RGFW OS=linux + + +all: + rm -f examples/$(EXAMPLE).exe examples/$(EXAMPLE).html examples/$(EXAMPLE).wasm examples/$(EXAMPLE).js src/rcore.o + cd src && make PLATFORM=$(PLATFORM) + cd examples && make $(EXAMPLE) PLATFORM=$(PLATFORM) diff --git a/src/external/RGFW.h b/src/external/RGFW.h index 3f3136c62..d013dc8d0 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -5209,11 +5209,15 @@ static HMODULE wglinstance = NULL; if (RGFW_XInput_dll) { XInputGetStateSRC = (PFN_XInputGetState)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetState"); - - if (XInputGetStateSRC == NULL) - printf("Failed to load XInputGetState"); + XInputGetKeystrokeSRC = (PFN_XInputGetKeystroke)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetKeystroke"); } } + + if (XInputGetStateSRC == NULL) + printf("RGFW ERR: Failed to load XInputGetState\n"); + if (XInputGetKeystrokeSRC == NULL) + printf("RGFW ERR: Failed to load XInputGetKeystroke\n"); + } #endif @@ -5656,7 +5660,6 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) { RGFW_UNUSED(win) - size_t i; for (i = 0; i < 4; i++) { XINPUT_KEYSTROKE keystroke; diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 0c6823fb3..fc83ca2e2 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -253,7 +253,7 @@ bool WindowShouldClose(void) // Toggle fullscreen mode void ToggleFullscreen(void) -{ +{ RGFW_window_maximize(platform.window); ToggleBorderlessWindowed(); } @@ -594,7 +594,7 @@ Vector2 GetMonitorPosition(int monitor) { RGFW_monitor *mons = RGFW_getMonitors(); - return (Vector2){(float)mons[monitor].rect.x, (float)mons[monitor].rect.y}; + return (Vector2){mons[monitor].rect.x, mons[monitor].rect.y}; } // Get selected monitor width (currently used by monitor) @@ -618,7 +618,7 @@ int GetMonitorPhysicalWidth(int monitor) { RGFW_monitor* mons = RGFW_getMonitors(); - return (int)mons[monitor].physW; + return mons[monitor].physW; } // Get selected monitor physical height in millimetres @@ -626,7 +626,7 @@ int GetMonitorPhysicalHeight(int monitor) { RGFW_monitor *mons = RGFW_getMonitors(); - return (int)mons[monitor].physH; + return mons[monitor].physH; } // Get selected monitor refresh rate @@ -647,7 +647,7 @@ const char *GetMonitorName(int monitor) // Get window position XY on monitor Vector2 GetWindowPosition(void) { - return (Vector2){ (float)platform.window->r.x, (float)platform.window->r.y }; + return (Vector2){ platform.window->r.x, platform.window->r.y }; } // Get window scale DPI factor for current monitor @@ -661,7 +661,7 @@ Vector2 GetWindowScaleDPI(void) // Set clipboard text content void SetClipboardText(const char *text) { - RGFW_writeClipboard(text, (u32)strlen(text)); + RGFW_writeClipboard(text, strlen(text)); } // Get clipboard text content @@ -671,39 +671,42 @@ const char *GetClipboardText(void) return RGFW_readClipboard(NULL); } + #if defined(SUPPORT_CLIPBOARD_IMAGE) -#if defined(_WIN32) - #define WIN32_CLIPBOARD_IMPLEMENTATION - #define WINUSER_ALREADY_INCLUDED - #define WINBASE_ALREADY_INCLUDED - #define WINGDI_ALREADY_INCLUDED - #include "../external/win32_clipboard.h" + +#ifdef _WIN32 +# define WIN32_CLIPBOARD_IMPLEMENTATION +# define WINUSER_ALREADY_INCLUDED +# define WINBASE_ALREADY_INCLUDED +# define WINGDI_ALREADY_INCLUDED +# include "../external/win32_clipboard.h" #endif -#endif // SUPPORT_CLIPBOARD_IMAGE // Get clipboard image Image GetClipboardImage(void) { - Image image = { 0 }; - -#if defined(SUPPORT_CLIPBOARD_IMAGE) -#if defined(_WIN32) + Image image = {0}; unsigned long long int dataSize = 0; - void *fileData = NULL; - int width = 0; - int height = 0; + void* fileData = NULL; +#ifdef _WIN32 + int width, height; fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); - - if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); - else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); #else - TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); + TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement `GetClipboardImage` for this OS"); #endif -#endif // SUPPORT_CLIPBOARD_IMAGE + if (fileData == NULL) + { + TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); + } + else + { + image = LoadImageFromMemory(".bmp", fileData, dataSize); + } return image; } +#endif // SUPPORT_CLIPBOARD_IMAGE // Show mouse cursor void ShowCursor(void) @@ -976,7 +979,7 @@ void PollInputEvents(void) case RGFW_quit: CORE.Window.shouldClose = true; break; case RGFW_dnd: // Dropped file { - for (u32 i = 0; i < event->droppedFilesCount; i++) + for (int i = 0; i < event->droppedFilesCount; i++) { if (CORE.Window.dropFileCount == 0) { @@ -1060,7 +1063,7 @@ void PollInputEvents(void) if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) { - CORE.Input.Mouse.currentWheelMove.y = (float)event->scroll; + CORE.Input.Mouse.currentWheelMove.y = event->scroll; break; } @@ -1078,7 +1081,7 @@ void PollInputEvents(void) { if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) { - CORE.Input.Mouse.currentWheelMove.y = (float)event->scroll; + CORE.Input.Mouse.currentWheelMove.y = event->scroll; break; } From 2a9d25b0678fa833d4596e9b11c64cc5d18512fb Mon Sep 17 00:00:00 2001 From: ColleagueRiley Date: Sun, 24 Nov 2024 17:17:24 -0500 Subject: [PATCH 32/35] fix xinput stuff --- Makefile | 2 +- src/external/RGFW.h | 40 +++++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index ba7767f3f..8ef697943 100644 --- a/Makefile +++ b/Makefile @@ -4,5 +4,5 @@ PLATFORM = PLATOFRM_WEB_RGFW OS=linux all: rm -f examples/$(EXAMPLE).exe examples/$(EXAMPLE).html examples/$(EXAMPLE).wasm examples/$(EXAMPLE).js src/rcore.o - cd src && make PLATFORM=$(PLATFORM) + cd src && make PLATFORM=$(PLATFORM) cd examples && make $(EXAMPLE) PLATFORM=$(PLATFORM) diff --git a/src/external/RGFW.h b/src/external/RGFW.h index d013dc8d0..d089e109c 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -5198,19 +5198,22 @@ static HMODULE wglinstance = NULL; u32 i; static const char* names[] = { "xinput1_4.dll", - "xinput1_3.dll", "xinput9_1_0.dll", "xinput1_2.dll", "xinput1_1.dll" }; - for (i = 0; i < sizeof(names) / sizeof(const char*); i++) { + for (i = 0; i < sizeof(names) / sizeof(const char*) && (XInputGetStateSRC == NULL || XInputGetStateSRC != NULL); i++) { RGFW_XInput_dll = LoadLibraryA(names[i]); - if (RGFW_XInput_dll) { + if (RGFW_XInput_dll == NULL) + continue; + + if (XInputGetStateSRC == NULL) XInputGetStateSRC = (PFN_XInputGetState)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetState"); + + if (XInputGetKeystrokeSRC == NULL) XInputGetKeystrokeSRC = (PFN_XInputGetKeystroke)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetKeystroke"); - } } if (XInputGetStateSRC == NULL) @@ -5655,7 +5658,9 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ RGFW_JS_LEFT, /* dpad left */ RGFW_JS_RIGHT, /* dpad right */ RGFW_JS_START, /* start button */ - RGFW_JS_SELECT/* select button */ + RGFW_JS_SELECT,/* select button */ + RGFW_JS_L3, + RGFW_JS_R3, }; static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) { @@ -5672,10 +5677,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if ((keystroke.Flags & XINPUT_KEYSTROKE_REPEAT) == 0 && result != ERROR_EMPTY) { if (result != ERROR_SUCCESS) return 0; - - if (keystroke.VirtualKey > VK_PAD_BACK) + + if (keystroke.VirtualKey > VK_PAD_RTHUMB_PRESS) continue; - + // RGFW_jsButtonPressed + 1 = RGFW_jsButtonReleased e->type = RGFW_jsButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); e->button = RGFW_xinput2RGFW[keystroke.VirtualKey - 0x5800]; @@ -5689,6 +5694,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ XInputGetState((DWORD) i, &state) == ERROR_DEVICE_NOT_CONNECTED ) return 0; + #define INPUT_DEADZONE ( 0.24f * (float)(0x7FFF) ) // Default to 24% of the +/- 32767 range. This is a reasonable default value but can be altered if needed. if ((state.Gamepad.sThumbLX < INPUT_DEADZONE && @@ -5710,22 +5716,26 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ } e->axisesCount = 2; - RGFW_point axis1 = RGFW_POINT(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY); - RGFW_point axis2 = RGFW_POINT(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY); + RGFW_point axis1 = RGFW_POINT(((float)state.Gamepad.sThumbLX / 32768.0f) * 100, ((float)state.Gamepad.sThumbLY / -32768.0f) * 100); + RGFW_point axis2 = RGFW_POINT(((float)state.Gamepad.sThumbRX / 32768.0f) * 100, ((float)state.Gamepad.sThumbRY / -32768.0f) * 100); - if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y || axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) { - win->event.whichAxis = (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y) ? 0 : 1; + if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y){ + win->event.whichAxis = 0; e->type = RGFW_jsAxisMove; e->axis[0] = axis1; - e->axis[1] = axis2; return 1; } - e->axis[0] = axis1; - e->axis[1] = axis2; + if (axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) { + win->event.whichAxis = 1; + e->type = RGFW_jsAxisMove; + e->axis[1] = axis2; + + return 1; + } } return 0; From 6bbed2993b53e27f0e01e0255efb5ac1f68e63cd Mon Sep 17 00:00:00 2001 From: ColleagueRiley Date: Tue, 26 Nov 2024 10:08:41 -0500 Subject: [PATCH 33/35] delete makefile added by mistake --- Makefile | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index 8ef697943..000000000 --- a/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -EXAMPLE = core/core_input_gamepad -PLATFORM = PLATOFRM_WEB_RGFW OS=linux - - -all: - rm -f examples/$(EXAMPLE).exe examples/$(EXAMPLE).html examples/$(EXAMPLE).wasm examples/$(EXAMPLE).js src/rcore.o - cd src && make PLATFORM=$(PLATFORM) - cd examples && make $(EXAMPLE) PLATFORM=$(PLATFORM) From 3729901903c37611685a61c1684c638f7e09b637 Mon Sep 17 00:00:00 2001 From: ColleagueRiley Date: Tue, 26 Nov 2024 21:12:59 -0500 Subject: [PATCH 34/35] update RGFW --- src/external/RGFW.h | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/external/RGFW.h b/src/external/RGFW.h index d089e109c..0436c8024 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -88,6 +88,7 @@ Joshua Rowe (omnisci3nce) - bug fix, review (macOS) @lesleyrs -> bug fix, review (OpenGL) Nick Porcino (meshula) - testing, organization, review (MacOS, examples) + @DarekParodia -> code review (X11) (C++) */ #if _MSC_VER @@ -634,6 +635,8 @@ RGFWDEF void RGFW_setClassName(char* name); /*! this has to be set before createWindow is called, else the fulscreen size is used */ RGFWDEF void RGFW_setBufferSize(RGFW_area size); /*!< the buffer cannot be resized (by RGFW) */ +/* NOTE: (windows)If the executable has an icon resource named RGFW_ICON, it will be set as the initial icon for the window.*/ + RGFWDEF RGFW_window* RGFW_createWindow( const char* name, /* name of the window */ RGFW_rect rect, /* rect of window */ @@ -2805,7 +2808,7 @@ Start of Linux / Unix defines u32 i; win->event.type = 0; - + XEvent reply = { ClientMessage }; switch (E.type) { case KeyPress: @@ -2944,7 +2947,6 @@ Start of Linux / Unix defines if ((win->_winArgs & RGFW_ALLOW_DND) == 0) break; - XEvent reply = { ClientMessage }; reply.xclient.window = xdnd.source; reply.xclient.format = 32; reply.xclient.data.l[0] = (long) win->src.window; @@ -5295,7 +5297,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (RGFW_Shcore_dll == NULL) { RGFW_Shcore_dll = LoadLibraryA("shcore.dll"); GetDpiForMonitorSRC = (PFN_GetDpiForMonitor)(void*)GetProcAddress(RGFW_Shcore_dll, "GetDpiForMonitor"); - #if defined(_WIN64) || (_WIN32_WINNT >= 0x0600) + #if (_WIN32_WINNT >= 0x0600) SetProcessDPIAware(); #endif } @@ -5340,6 +5342,11 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ Class.hCursor = LoadCursor(NULL, IDC_ARROW); Class.lpfnWndProc = WndProc; + Class.hIcon = LoadImageA(GetModuleHandleW(NULL), "RGFW_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + if (Class.hIcon == NULL) { + Class.hIcon = LoadImageA(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + } + RegisterClassA(&Class); DWORD window_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN; @@ -5352,7 +5359,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (!(args & RGFW_NO_RESIZE)) window_style |= WS_SIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME; } else - window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX; + window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX; + HWND dummyWin = CreateWindowA(Class.lpszClassName, name, window_style, win->r.x, win->r.y, win->r.w, win->r.h, 0, 0, inh, 0); @@ -8356,17 +8364,28 @@ EM_BOOL Emscripten_on_fullscreenchange(int eventType, const EmscriptenFullscreen RGFW_root->r = RGFW_RECT(0, 0, e->screenWidth, e->screenHeight); + EM_ASM("Module.canvas.focus();"); + if (fullscreen == RGFW_FALSE) { RGFW_root->r = RGFW_RECT(0, 0, ogRect.w, ogRect.h); + // emscripten_request_fullscreen("#canvas", 0); + } else { + #if __EMSCRIPTEN_major__ >= 1 && __EMSCRIPTEN_minor__ >= 29 && __EMSCRIPTEN_tiny__ >= 0 + EmscriptenFullscreenStrategy FSStrat = {0}; + FSStrat.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;//EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT;// : EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; + FSStrat.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF; + FSStrat.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; + emscripten_request_fullscreen_strategy("#canvas", 1, &FSStrat); + #else + emscripten_request_fullscreen("#canvas", 1); + #endif + } emscripten_set_canvas_element_size("#canvas", RGFW_root->r.w, RGFW_root->r.h); - #ifdef LEGACY_GL_EMULATION - EM_ASM("Module.canvas.focus()"); - #endif - RGFW_windowResizeCallback(RGFW_root, RGFW_root->r); + return EM_TRUE; } From 0e2c2197412f000c0e8d9aa652a94b723c427654 Mon Sep 17 00:00:00 2001 From: ColleagueRiley Date: Wed, 27 Nov 2024 17:48:11 -0500 Subject: [PATCH 35/35] update RGFW (rename joystick to gamepad to avoid misunderstandings --- src/external/RGFW.h | 270 ++++++++++++++--------------- src/platforms/rcore_desktop_rgfw.c | 76 ++++---- 2 files changed, 173 insertions(+), 173 deletions(-) diff --git a/src/external/RGFW.h b/src/external/RGFW.h index 0436c8024..f8af494ef 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -345,12 +345,12 @@ typedef RGFW_ENUM(u8, RGFW_event_types) { RGFW_Event.button holds which mouse button was pressed */ - RGFW_jsButtonPressed, /*!< a joystick button was pressed */ - RGFW_jsButtonReleased, /*!< a joystick button was released */ - RGFW_jsAxisMove, /*!< an axis of a joystick was moved*/ - /*! joystick event note - RGFW_Event.joystick holds which joystick was altered, if any - RGFW_Event.button holds which joystick button was pressed + RGFW_gpButtonPressed, /*!< a gamepad button was pressed */ + RGFW_gpButtonReleased, /*!< a gamepad button was released */ + RGFW_gpAxisMove, /*!< an axis of a gamepad was moved*/ + /*! gamepad event note + RGFW_Event.gamepad holds which gamepad was altered, if any + RGFW_Event.button holds which gamepad button was pressed RGFW_Event.axis holds the data of all the axis RGFW_Event.axisCount says how many axis there are @@ -399,26 +399,26 @@ typedef RGFW_ENUM(u8, RGFW_event_types) { #define RGFW_CAPSLOCK (1L << 1) #define RGFW_NUMLOCK (1L << 2) -/*! joystick button codes (based on xbox/playstation), you may need to change these values per controller */ -#ifndef RGFW_joystick_codes - typedef RGFW_ENUM(u8, RGFW_joystick_codes) { - RGFW_JS_A = 0, /*!< or PS X button */ - RGFW_JS_B = 1, /*!< or PS circle button */ - RGFW_JS_Y = 2, /*!< or PS triangle button */ - RGFW_JS_X = 3, /*!< or PS square button */ - RGFW_JS_START = 9, /*!< start button */ - RGFW_JS_SELECT = 8, /*!< select button */ - RGFW_JS_HOME = 10, /*!< home button */ - RGFW_JS_UP = 13, /*!< dpad up */ - RGFW_JS_DOWN = 14, /*!< dpad down*/ - RGFW_JS_LEFT = 15, /*!< dpad left */ - RGFW_JS_RIGHT = 16, /*!< dpad right */ - RGFW_JS_L1 = 4, /*!< left bump */ - RGFW_JS_L2 = 5, /*!< left trigger*/ - RGFW_JS_R1 = 6, /*!< right bumper */ - RGFW_JS_R2 = 7, /*!< right trigger */ - RGFW_JS_L3 = 11, /* left thumb stick */ - RGFW_JS_R3 = 12 /*!< right thumb stick */ +/*! gamepad button codes (based on xbox/playstation), you may need to change these values per controller */ +#ifndef RGFW_gamepad_codes + typedef RGFW_ENUM(u8, RGFW_gamepad_codes) { + RGFW_GP_A = 0, /*!< or PS X button */ + RGFW_GP_B = 1, /*!< or PS circle button */ + RGFW_GP_Y = 2, /*!< or PS triangle button */ + RGFW_GP_X = 3, /*!< or PS square button */ + RGFW_GP_START = 9, /*!< start button */ + RGFW_GP_SELECT = 8, /*!< select button */ + RGFW_GP_HOME = 10, /*!< home button */ + RGFW_GP_UP = 13, /*!< dpad up */ + RGFW_GP_DOWN = 14, /*!< dpad down*/ + RGFW_GP_LEFT = 15, /*!< dpad left */ + RGFW_GP_RIGHT = 16, /*!< dpad right */ + RGFW_GP_L1 = 4, /*!< left bump */ + RGFW_GP_L2 = 5, /*!< left trigger*/ + RGFW_GP_R1 = 6, /*!< right bumper */ + RGFW_GP_R2 = 7, /*!< right trigger */ + RGFW_GP_L3 = 11, /* left thumb stick */ + RGFW_GP_R3 = 12 /*!< right thumb stick */ }; #endif @@ -490,10 +490,10 @@ typedef struct RGFW_Event { u8 lockState; - u8 button; /* !< which mouse (or joystick) button was pressed */ + u8 button; /* !< which mouse (or gamepad) button was pressed */ double scroll; /*!< the raw mouse scroll value */ - u16 joystick; /*! which joystick this event applies to (if applicable to any) */ + u16 gamepad; /*! which gamepad this event applies to (if applicable to any) */ u8 axisesCount; /*!< number of axises */ u8 whichAxis; /* which axis was effected */ @@ -876,10 +876,10 @@ typedef void (* RGFW_windowrefreshfunc)(RGFW_window* win); typedef void (* RGFW_keyfunc)(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed); /*! RGFW_mouseButtonPressed / RGFW_mouseButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ typedef void (* RGFW_mousebuttonfunc)(RGFW_window* win, u8 button, double scroll, b8 pressed); -/*! RGFW_jsButtonPressed / RGFW_jsButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ -typedef void (* RGFW_jsButtonfunc)(RGFW_window* win, u16 joystick, u8 button, b8 pressed); -/*! RGFW_jsAxisMove, the window that got the event, the joystick in question, the axis values and the amount of axises */ -typedef void (* RGFW_jsAxisfunc)(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount); +/*!gp /gp, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ +typedef void (* RGFW_gpButtonfunc)(RGFW_window* win, u16 gamepad, u8 button, b8 pressed); +/*! RGFW_gpAxisMove, the window that got the event, the gamepad in question, the axis values and the amount of axises */ +typedef void (* RGFW_gpAxisfunc)(RGFW_window* win, u16 gamepad, RGFW_point axis[2], u8 axisesCount); /*! RGFW_dnd, the window that had the drop, the drop data and the amount files dropped returns previous callback function (if it was set) */ @@ -911,9 +911,9 @@ RGFWDEF RGFW_keyfunc RGFW_setKeyCallback(RGFW_keyfunc func); /*! set callback for a mouse button (press / release ) event returns previous callback function (if it was set) */ RGFWDEF RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func); /*! set callback for a controller button (press / release ) event returns previous callback function (if it was set) */ -RGFWDEF RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func); -/*! set callback for a joystick axis mov event returns previous callback function (if it was set) */ -RGFWDEF RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func); +RGFWDEF RGFW_gpButtonfunc RGFW_setgpButtonCallback(RGFW_gpButtonfunc func); +/*! set callback for a gamepad axis mov event returns previous callback function (if it was set) */ +RGFWDEF RGFW_gpAxisfunc RGFW_setgpAxisCallback(RGFW_gpAxisfunc func); /** @} */ @@ -944,15 +944,15 @@ RGFWDEF RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func); /** @} */ -/** * @defgroup joystick +/** * @defgroup gamepad * @{ */ -/*! joystick count starts at 0*/ -/*!< register joystick to window based on a number (the number is based on when it was connected eg. /dev/js0)*/ -RGFWDEF u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber); -RGFWDEF u16 RGFW_registerJoystickF(RGFW_window* win, char* file); +/*! gamepad count starts at 0*/ +/*!< register gamepad to window based on a number (the number is based on when it was connected eg. /dev/js0)*/ +RGFWDEF u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber); +RGFWDEF u16 RGFW_registerGamepadF(RGFW_window* win, char* file); -RGFWDEF u32 RGFW_isPressedJS(RGFW_window* win, u16 controller, u8 button); +RGFWDEF u32 RGFW_isPressedGP(RGFW_window* win, u16 controller, u8 button); /** @} */ @@ -1449,11 +1449,11 @@ char RGFW_keyCodeToCharAuto(u32 keycode, u8 lockState) { return RGFW_keyCodeToCh this is the end of keycode data */ -/* joystick data */ -u8 RGFW_jsPressed[4][16]; /*!< if a key is currently pressed or not (per joystick) */ +/* gamepad data */ +u8 RGFW_gpPressed[4][16]; /*!< if a key is currently pressed or not (per gamepad) */ -i32 RGFW_joysticks[4]; /*!< limit of 4 joysticks at a time */ -u16 RGFW_joystickCount; /*!< the actual amount of joysticks */ +i32 RGFW_gamepads[4]; /*!< limit of 4 gamepads at a time */ +u16 RGFW_gamepadCount; /*!< the actual amount of gamepads */ /* event callback defines start here @@ -1475,8 +1475,8 @@ void RGFW_dndInitfuncEMPTY(RGFW_window* win, RGFW_point point) {RGFW_UNUSED(win) void RGFW_windowrefreshfuncEMPTY(RGFW_window* win) {RGFW_UNUSED(win); } void RGFW_keyfuncEMPTY(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(keycode); RGFW_UNUSED(keyName); RGFW_UNUSED(lockState); RGFW_UNUSED(pressed);} void RGFW_mousebuttonfuncEMPTY(RGFW_window* win, u8 button, double scroll, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(button); RGFW_UNUSED(scroll); RGFW_UNUSED(pressed);} -void RGFW_jsButtonfuncEMPTY(RGFW_window* win, u16 joystick, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(button); RGFW_UNUSED(pressed); } -void RGFW_jsAxisfuncEMPTY(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); } +void RGFW_gpButtonfuncEMPTY(RGFW_window* win, u16 gamepad, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(button); RGFW_UNUSED(pressed); } +void RGFW_gpAxisfuncEMPTY(RGFW_window* win, u16 gamepad, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); } #ifdef RGFW_ALLOC_DROPFILES void RGFW_dndfuncEMPTY(RGFW_window* win, char** droppedFiles, u32 droppedFilesCount) {RGFW_UNUSED(win); RGFW_UNUSED(droppedFiles); RGFW_UNUSED(droppedFilesCount);} @@ -1495,8 +1495,8 @@ RGFW_dndfunc RGFW_dndCallback = RGFW_dndfuncEMPTY; RGFW_dndInitfunc RGFW_dndInitCallback = RGFW_dndInitfuncEMPTY; RGFW_keyfunc RGFW_keyCallback = RGFW_keyfuncEMPTY; RGFW_mousebuttonfunc RGFW_mouseButtonCallback = RGFW_mousebuttonfuncEMPTY; -RGFW_jsButtonfunc RGFW_jsButtonCallback = RGFW_jsButtonfuncEMPTY; -RGFW_jsAxisfunc RGFW_jsAxisCallback = RGFW_jsAxisfuncEMPTY; +RGFW_gpButtonfunc RGFW_gpButtonCallback = RGFW_gpButtonfuncEMPTY; +RGFW_gpAxisfunc RGFW_gpAxisCallback = RGFW_gpAxisfuncEMPTY; void RGFW_window_checkEvents(RGFW_window* win, i32 waitMS) { RGFW_window_eventWait(win, waitMS); @@ -1567,14 +1567,14 @@ RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func) { RGFW_mouseButtonCallback = func; return prev; } -RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func) { - RGFW_jsButtonfunc prev = (RGFW_jsButtonCallback == RGFW_jsButtonfuncEMPTY) ? NULL : RGFW_jsButtonCallback; - RGFW_jsButtonCallback = func; +RGFW_gpButtonfunc RGFW_setgpButtonCallback(RGFW_gpButtonfunc func) { + RGFW_gpButtonfunc prev = (RGFW_gpButtonCallback == RGFW_gpButtonfuncEMPTY) ? NULL : RGFW_gpButtonCallback; + RGFW_gpButtonCallback = func; return prev; } -RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func) { - RGFW_jsAxisfunc prev = (RGFW_jsAxisCallback == RGFW_jsAxisfuncEMPTY) ? NULL : RGFW_jsAxisCallback; - RGFW_jsAxisCallback = func; +RGFW_gpAxisfunc RGFW_setgpAxisCallback(RGFW_gpAxisfunc func) { + RGFW_gpAxisfunc prev = (RGFW_gpAxisCallback == RGFW_gpAxisfuncEMPTY) ? NULL : RGFW_gpAxisCallback; + RGFW_gpAxisCallback = func; return prev; } /* @@ -1636,7 +1636,7 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) { win->r = rect; win->event.inFocus = 1; win->event.droppedFilesCount = 0; - RGFW_joystickCount = 0; + RGFW_gamepadCount = 0; win->_winArgs = 0; win->event.lockState = 0; @@ -1815,9 +1815,9 @@ u32 RGFW_window_checkFPS(RGFW_window* win, u32 fpsCap) { return output_fps; } -u32 RGFW_isPressedJS(RGFW_window* win, u16 c, u8 button) { +u32 RGFW_isPressedGP(RGFW_window* win, u16 c, u8 button) { RGFW_UNUSED(win); - return RGFW_jsPressed[c][button]; + return RGFW_gpPressed[c][button]; } #if defined(RGFW_X11) || defined(RGFW_WINDOWS) @@ -2275,33 +2275,33 @@ This is where OS specific stuff starts #include #include - RGFW_Event* RGFW_linux_updateJoystick(RGFW_window* win) { + RGFW_Event* RGFW_linux_updateGamepad(RGFW_window* win) { u8 i; - for (i = 0; i < RGFW_joystickCount; i++) { + for (i = 0; i < RGFW_gamepadCount; i++) { struct js_event e; - if (RGFW_joysticks[i] == 0) + if (RGFW_gamepads[i] == 0) continue; - i32 flags = fcntl(RGFW_joysticks[i], F_GETFL, 0); - fcntl(RGFW_joysticks[i], F_SETFL, flags | O_NONBLOCK); + i32 flags = fcntl(RGFW_gamepads[i], F_GETFL, 0); + fcntl(RGFW_gamepads[i], F_SETFL, flags | O_NONBLOCK); ssize_t bytes; - while ((bytes = read(RGFW_joysticks[i], &e, sizeof(e))) > 0) { + while ((bytes = read(RGFW_gamepads[i], &e, sizeof(e))) > 0) { switch (e.type) { case JS_EVENT_BUTTON: - win->event.type = e.value ? RGFW_jsButtonPressed : RGFW_jsButtonReleased; + win->event.type = e.value ? RGFW_gpButtonPressed : RGFW_gpButtonReleased; win->event.button = e.number; - RGFW_jsPressed[i][e.number + 1] = e.value; - RGFW_jsButtonCallback(win, i, e.number, e.value); + RGFW_gpPressed[i][e.number + 1] = e.value; + RGFW_gpButtonCallback(win, i, e.number, e.value); return &win->event; case JS_EVENT_AXIS: { size_t axis = e.number / 2; if (axis == 2) axis = 1; - ioctl(RGFW_joysticks[i], JSIOCGAXES, &win->event.axisesCount); + ioctl(RGFW_gamepads[i], JSIOCGAXES, &win->event.axisesCount); win->event.axisesCount = 2; if (axis < 3) { @@ -2312,10 +2312,10 @@ This is where OS specific stuff starts } } - win->event.type = RGFW_jsAxisMove; - win->event.joystick = i; + win->event.type = RGFW_gpAxisMove; + win->event.gamepad = i; win->event.whichAxis = axis; - RGFW_jsAxisCallback(win, i, win->event.axis, win->event.axisesCount); + RGFW_gpAxisCallback(win, i, win->event.axis, win->event.axisesCount); return &win->event; } default: break; @@ -2788,7 +2788,7 @@ Start of Linux / Unix defines win->event.type = 0; #ifdef __linux__ - RGFW_Event* event = RGFW_linux_updateJoystick(win); + RGFW_Event* event = RGFW_linux_updateGamepad(win); if (event != NULL) return event; #endif @@ -3965,8 +3965,8 @@ Start of Linux / Unix defines } u8 i; - for (i = 0; i < RGFW_joystickCount; i++) - close(RGFW_joysticks[i]); + for (i = 0; i < RGFW_gamepadCount; i++) + close(RGFW_gamepads[i]); } /* set cleared display / window to NULL for error checking */ @@ -3989,43 +3989,43 @@ Start of Linux / Unix defines #include #include #include - u16 RGFW_registerJoystickF(RGFW_window* win, char* file) { + u16 RGFW_registerGamepadF(RGFW_window* win, char* file) { assert(win != NULL); #ifdef __linux__ i32 js = open(file, O_RDONLY); - if (js && RGFW_joystickCount < 4) { - RGFW_joystickCount++; + if (js && RGFW_gamepadCount < 4) { + RGFW_gamepadCount++; - RGFW_joysticks[RGFW_joystickCount - 1] = open(file, O_RDONLY); + RGFW_gamepads[RGFW_gamepadCount - 1] = open(file, O_RDONLY); u8 i; for (i = 0; i < 16; i++) - RGFW_jsPressed[RGFW_joystickCount - 1][i] = 0; + RGFW_gpPressed[RGFW_gamepadCount - 1][i] = 0; } else { #ifdef RGFW_PRINT_ERRORS RGFW_error = 1; - fprintf(stderr, "Error RGFW_registerJoystickF : Cannot open file %s\n", file); + fprintf(stderr, "Error RGFW_registerGamepadF : Cannot open file %s\n", file); #endif } - return RGFW_joystickCount - 1; + return RGFW_gamepadCount - 1; #endif } - u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) { + u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) { assert(win != NULL); #ifdef __linux__ char file[15]; - sprintf(file, "/dev/input/js%i", jsNumber); + sprintf(file, "/dev/input/js%i", gpNumber); - return RGFW_registerJoystickF(win, file); + return RGFW_registerGamepadF(win, file); #endif } @@ -4061,7 +4061,7 @@ Start of Linux / Unix defines { ConnectionNumber(win->src.display), POLLIN, 0 }, #endif { RGFW_eventWait_forceStop[0], POLLIN, 0 }, - #ifdef __linux__ /* blank space for 4 joystick files*/ + #ifdef __linux__ /* blank space for 4 gamepad files*/ { -1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0} #endif }; @@ -4069,11 +4069,11 @@ Start of Linux / Unix defines u8 index = 2; #if defined(__linux__) - for (i = 0; i < RGFW_joystickCount; i++) { - if (RGFW_joysticks[i] == 0) + for (i = 0; i < RGFW_gamepadCount; i++) { + if (RGFW_gamepads[i] == 0) continue; - fds[index].fd = RGFW_joysticks[i]; + fds[index].fd = RGFW_gamepads[i]; index++; } #endif @@ -4759,7 +4759,7 @@ static const struct wl_callback_listener wl_surface_frame_listener = { } #ifdef __linux__ - RGFW_Event* event = RGFW_linux_updateJoystick(win); + RGFW_Event* event = RGFW_linux_updateGamepad(win); if (event != NULL) return event; #endif @@ -5085,7 +5085,7 @@ static const struct wl_callback_listener wl_surface_frame_listener = { #define wglGetSwapIntervalEXT wglGetSwapIntervalEXTSrc - void* RGFWjoystickApi = NULL; + void* RGFWgamepadApi = NULL; /* these two wgl functions need to be preloaded */ typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hdc, HGLRC hglrc, const int *attribList); @@ -5652,23 +5652,23 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ u8 RGFW_xinput2RGFW[] = { - RGFW_JS_A, /* or PS X button */ - RGFW_JS_B, /* or PS circle button */ - RGFW_JS_X, /* or PS square button */ - RGFW_JS_Y, /* or PS triangle button */ - RGFW_JS_R1, /* right bumper */ - RGFW_JS_L1, /* left bump */ - RGFW_JS_L2, /* left trigger*/ - RGFW_JS_R2, /* right trigger */ + RGFW_GP_A, /* or PS X button */ + RGFW_GP_B, /* or PS circle button */ + RGFW_GP_X, /* or PS square button */ + RGFW_GP_Y, /* or PS triangle button */ + RGFW_GP_R1, /* right bumper */ + RGFW_GP_L1, /* left bump */ + RGFW_GP_L2, /* left trigger*/ + RGFW_GP_R2, /* right trigger */ 0, 0, 0, 0, 0, 0, 0, 0, - RGFW_JS_UP, /* dpad up */ - RGFW_JS_DOWN, /* dpad down*/ - RGFW_JS_LEFT, /* dpad left */ - RGFW_JS_RIGHT, /* dpad right */ - RGFW_JS_START, /* start button */ - RGFW_JS_SELECT,/* select button */ - RGFW_JS_L3, - RGFW_JS_R3, + RGFW_GP_UP, /* dpad up */ + RGFW_GP_DOWN, /* dpad down*/ + RGFW_GP_LEFT, /* dpad left */ + RGFW_GP_RIGHT, /* dpad right */ + RGFW_GP_START, /* start button */ + RGFW_GP_SELECT,/* select button */ + RGFW_GP_L3, + RGFW_GP_R3, }; static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) { @@ -5689,10 +5689,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (keystroke.VirtualKey > VK_PAD_RTHUMB_PRESS) continue; - // RGFW_jsButtonPressed + 1 = RGFW_jsButtonReleased - e->type = RGFW_jsButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); + //gp + 1 = RGFW_gpButtonReleased + e->type = RGFW_gpButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); e->button = RGFW_xinput2RGFW[keystroke.VirtualKey - 0x5800]; - RGFW_jsPressed[i][e->button] = !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); + RGFW_gpPressed[i][e->button] = !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); return 1; } @@ -5730,7 +5730,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y){ win->event.whichAxis = 0; - e->type = RGFW_jsAxisMove; + e->type = RGFW_gpAxisMove; e->axis[0] = axis1; @@ -5739,7 +5739,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) { win->event.whichAxis = 1; - e->type = RGFW_jsAxisMove; + e->type = RGFW_gpAxisMove; e->axis[1] = axis2; return 1; @@ -6538,19 +6538,19 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ CloseClipboard(); } - u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) { + u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) { assert(win != NULL); - RGFW_UNUSED(jsNumber) + RGFW_UNUSED(gpNumber) - return RGFW_registerJoystickF(win, (char*) ""); + return RGFW_registerGamepadF(win, (char*) ""); } - u16 RGFW_registerJoystickF(RGFW_window* win, char* file) { + u16 RGFW_registerGamepadF(RGFW_window* win, char* file) { assert(win != NULL); RGFW_UNUSED(file) - return RGFW_joystickCount - 1; + return RGFW_gamepadCount - 1; } void RGFW_window_moveMouse(RGFW_window* win, RGFW_point p) { @@ -8148,20 +8148,20 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ NSPasteBoard_setString(NSPasteboard_generalPasteboard(), text, NSPasteboardTypeString); } - u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) { - RGFW_UNUSED(jsNumber); + u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) { + RGFW_UNUSED(gpNumber); assert(win != NULL); - return RGFW_registerJoystickF(win, (char*) ""); + return RGFW_registerGamepadF(win, (char*) ""); } - u16 RGFW_registerJoystickF(RGFW_window* win, char* file) { + u16 RGFW_registerGamepadF(RGFW_window* win, char* file) { RGFW_UNUSED(file); assert(win != NULL); - return RGFW_joystickCount - 1; + return RGFW_gamepadCount - 1; } #ifdef RGFW_OPENGL @@ -8541,7 +8541,7 @@ EM_BOOL Emscripten_on_gamepad(int eventType, const EmscriptenGamepadEvent *gamep if (gamepadEvent->index >= 4) return 0; - RGFW_joysticks[gamepadEvent->index] = gamepadEvent->connected; + RGFW_gamepads[gamepadEvent->index] = gamepadEvent->connected; return 1; // The event was consumed by the callback handler } @@ -8761,7 +8761,7 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { emscripten_sample_gamepad_data(); /* check gamepads */ for (int i = 0; (i < emscripten_get_num_gamepads()) && (i < 4); i++) { - if (RGFW_joysticks[i] == 0) + if (RGFW_gamepads[i] == 0) continue; EmscriptenGamepadEvent gamepadState; @@ -8771,11 +8771,11 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { // Register buttons data for every connected gamepad for (int j = 0; (j < gamepadState.numButtons) && (j < 16); j++) { u32 map[] = { - RGFW_JS_A, RGFW_JS_B, RGFW_JS_X, RGFW_JS_Y, - RGFW_JS_L1, RGFW_JS_R1, RGFW_JS_L2, RGFW_JS_R2, - RGFW_JS_SELECT, RGFW_JS_START, - RGFW_JS_L3, RGFW_JS_R3, - RGFW_JS_UP, RGFW_JS_DOWN, RGFW_JS_LEFT, RGFW_JS_RIGHT + RGFW_GP_A, RGFW_GP_B, RGFW_GP_X, RGFW_GP_Y, + RGFW_GP_L1, RGFW_GP_R1, RGFW_GP_L2, RGFW_GP_R2, + RGFW_GP_SELECT, RGFW_GP_START, + RGFW_GP_L3, RGFW_GP_R3, + RGFW_GP_UP, RGFW_GP_DOWN, RGFW_GP_LEFT, RGFW_GP_RIGHT }; @@ -8783,15 +8783,15 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { if (button == 404) continue; - if (RGFW_jsPressed[i][button] != gamepadState.digitalButton[j]) { + if (RGFW_gpPressed[i][button] != gamepadState.digitalButton[j]) { if (gamepadState.digitalButton[j]) - win->event.type = RGFW_jsButtonPressed; + win->event.type = RGFW_gpButtonPressed; else - win->event.type = RGFW_jsButtonReleased; + win->event.type = RGFW_gpButtonReleased; - win->event.joystick = i; + win->event.gamepad = i; win->event.button = map[j]; - RGFW_jsPressed[i][button] = gamepadState.digitalButton[j]; + RGFW_gpPressed[i][button] = gamepadState.digitalButton[j]; return &win->event; } } @@ -8803,8 +8803,8 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { ) { win->event.axis[j / 2].x = (i8)(gamepadState.axis[j] * 100.0f); win->event.axis[j / 2].y = (i8)(gamepadState.axis[j + 1] * 100.0f); - win->event.type = RGFW_jsAxisMove; - win->event.joystick = i; + win->event.type = RGFW_gpAxisMove; + win->event.gamepad = i; win->event.whichAxis = j / 2; return &win->event; } diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index fc83ca2e2..5573807cd 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -865,24 +865,24 @@ char RSGL_keystrToChar(const char *str) return '\0'; } -int RGFW_jsConvTable[18] = { - [RGFW_JS_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP, - [RGFW_JS_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, - [RGFW_JS_A] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN, - [RGFW_JS_X] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT, - [RGFW_JS_L1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1, - [RGFW_JS_R1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1, - [RGFW_JS_L2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2, - [RGFW_JS_R2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2, - [RGFW_JS_SELECT] = GAMEPAD_BUTTON_MIDDLE_LEFT, - [RGFW_JS_HOME] = GAMEPAD_BUTTON_MIDDLE, - [RGFW_JS_START] = GAMEPAD_BUTTON_MIDDLE_RIGHT, - [RGFW_JS_UP] = GAMEPAD_BUTTON_LEFT_FACE_UP, - [RGFW_JS_RIGHT] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT, - [RGFW_JS_DOWN] = GAMEPAD_BUTTON_LEFT_FACE_DOWN, - [RGFW_JS_LEFT] = GAMEPAD_BUTTON_LEFT_FACE_LEFT, - [RGFW_JS_L3] = GAMEPAD_BUTTON_LEFT_THUMB, - [RGFW_JS_R3] = GAMEPAD_BUTTON_RIGHT_THUMB, +int RGFW_gpConvTable[18] = { + [RGFW_GP_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP, + [RGFW_GP_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, + [RGFW_GP_A] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN, + [RGFW_GP_X] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT, + [RGFW_GP_L1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1, + [RGFW_GP_R1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1, + [RGFW_GP_L2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2, + [RGFW_GP_R2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2, + [RGFW_GP_SELECT] = GAMEPAD_BUTTON_MIDDLE_LEFT, + [RGFW_GP_HOME] = GAMEPAD_BUTTON_MIDDLE, + [RGFW_GP_START] = GAMEPAD_BUTTON_MIDDLE_RIGHT, + [RGFW_GP_UP] = GAMEPAD_BUTTON_LEFT_FACE_UP, + [RGFW_GP_RIGHT] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT, + [RGFW_GP_DOWN] = GAMEPAD_BUTTON_LEFT_FACE_DOWN, + [RGFW_GP_LEFT] = GAMEPAD_BUTTON_LEFT_FACE_LEFT, + [RGFW_GP_L3] = GAMEPAD_BUTTON_LEFT_THUMB, + [RGFW_GP_R3] = GAMEPAD_BUTTON_RIGHT_THUMB, }; @@ -959,15 +959,15 @@ void PollInputEvents(void) while (RGFW_window_checkEvent(platform.window)) { - if ((platform.window->event.type >= RGFW_jsButtonPressed) && (platform.window->event.type <= RGFW_jsAxisMove)) + if ((platform.window->event.type >= RGFW_gpButtonPressed) && (platform.window->event.type <= RGFW_gpAxisMove)) { - if (!CORE.Input.Gamepad.ready[platform.window->event.joystick]) + if (!CORE.Input.Gamepad.ready[platform.window->event.gamepad]) { - CORE.Input.Gamepad.ready[platform.window->event.joystick] = true; - CORE.Input.Gamepad.axisCount[platform.window->event.joystick] = platform.window->event.axisesCount; - CORE.Input.Gamepad.name[platform.window->event.joystick][0] = '\0'; - CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; - CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; + CORE.Input.Gamepad.ready[platform.window->event.gamepad] = true; + CORE.Input.Gamepad.axisCount[platform.window->event.gamepad] = platform.window->event.axisesCount; + CORE.Input.Gamepad.name[platform.window->event.gamepad][0] = '\0'; + CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; + CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; } } @@ -1112,24 +1112,24 @@ void PollInputEvents(void) CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; touchAction = 2; } break; - case RGFW_jsButtonPressed: + case RGFW_gpButtonPressed: { - int button = RGFW_jsConvTable[event->button]; + int button = RGFW_gpConvTable[event->button]; if (button >= 0) { - CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 1; + CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 1; CORE.Input.Gamepad.lastButtonPressed = button; } } break; - case RGFW_jsButtonReleased: + case RGFW_gpButtonReleased: { - int button = RGFW_jsConvTable[event->button]; + int button = RGFW_gpConvTable[event->button]; - CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 0; + CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 0; if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; } break; - case RGFW_jsAxisMove: + case RGFW_gpAxisMove: { int axis = -1; @@ -1137,19 +1137,19 @@ void PollInputEvents(void) switch(event->whichAxis) { case 0: { - CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f; - CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f; + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f; + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f; } break; case 1: { - CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f; - CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f; + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f; + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f; } break; case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER; case 3: { if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER; int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2; int pressed = (value > 0.1f); - CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed; + CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = pressed; if (pressed) CORE.Input.Gamepad.lastButtonPressed = button; else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; @@ -1316,7 +1316,7 @@ int InitPlatform(void) #ifdef RGFW_X11 for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++) { - RGFW_registerJoystick(platform.window, i); + RGFW_registergamepad(platform.window, i); } #endif