diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 002f55d..797afd3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,8 @@ -name: Build +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + on: push: branches: ["main"] @@ -7,186 +11,46 @@ on: paths-ignore: - "README.md" - ".github/ISSUE_TEMPLATE/**" + workflow_dispatch: + jobs: build: - runs-on: ubuntu-22.04 - outputs: - version: ${{ steps.version.outputs.version }} - pkgversion: ${{ steps.version.outputs.pkgversion }} + runs-on: ubuntu-latest + steps: - - name: checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - - name: check raylib version - id: version - shell: bash - run: | - echo "version=$(sed -n 's/.*\(.*\)<\/TargetRaylibTag>.*/\1/p' Raylib-cs/Build.props)">> ${GITHUB_OUTPUT} - echo "pkgversion=$(sed -n 's/.*\(.*\)<\/PackageVersion>.*/\1/p' Raylib-cs/Build.props)">> ${GITHUB_OUTPUT} - - build-linux: - runs-on: ubuntu-22.04 - needs: build - steps: - - name: checkout repository - uses: actions/checkout@v4 - - - name: setup dotnet - uses: actions/setup-dotnet@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v5 with: dotnet-version: | - 6.0.x 8.0.x + 9.0.x + 10.0.x - - name: setup dependencies - run: | - sudo apt-get update - sudo apt-get install \ - libasound2-dev \ - libx11-dev \ - libxrandr-dev \ - libxi-dev \ - libgl1-mesa-dev \ - libglu1-mesa-dev \ - libxcursor-dev \ - libxinerama-dev + - name: Prepare local NuGet source + run: mkdir -p nuget - - name: build projects - run: dotnet build -c Release - - - name: run tests - run: dotnet test Raylib-cs.Tests -c Release - - - name: upload build - uses: actions/upload-artifact@v4 - with: - name: linux-x64 - path: Raylib-cs.Native/bin/Release/native/raylib/libraylib.so - if-no-files-found: error - - build-osx: - runs-on: macos-latest - needs: build - strategy: - matrix: - name: [arm64, x64] - include: - - name: arm64 - arch: arm64 - - name: x64 - arch: x86_64 - steps: - - name: checkout repository - uses: actions/checkout@v4 - - - name: setup dotnet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - - name: build projects - run: dotnet build -c Release /p:BuildArch=${{ matrix.arch }} - - - name: run tests - run: dotnet test Raylib-cs.Tests -c Release - - - name: upload build - uses: actions/upload-artifact@v4 - with: - name: osx-${{ matrix.name }} - path: Raylib-cs.Native/bin/Release/native/raylib/libraylib.dylib - if-no-files-found: error - - build-windows: - runs-on: windows-latest - needs: build - strategy: - matrix: - name: [x86, x64] - include: - - name: x86 - arch: win32 - - name: x64 - arch: x64 - steps: - - name: checkout repository - uses: actions/checkout@v4 - - - name: setup dotnet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - - name: build projects - run: dotnet build -c Release /p:BuildArch=${{ matrix.arch }} - - - name: run tests - run: dotnet test Raylib-cs.Tests -c Release - - - name: upload build - uses: actions/upload-artifact@v4 - with: - name: win-${{ matrix.name }} - path: Raylib-cs.Native/bin/Release/native/raylib/Release/raylib.dll - if-no-files-found: error - - build-publish: - runs-on: ubuntu-22.04 - needs: - - build-linux - - build-osx - - build-windows - steps: - - name: checkout repository - uses: actions/checkout@v4 - - - uses: actions/download-artifact@v4.1.7 - with: - name: linux-x64 - path: Raylib-cs/runtimes/linux-x64/native - - - uses: actions/download-artifact@v4.1.7 - with: - name: osx-arm64 - path: Raylib-cs/runtimes/osx-arm64/native - - - uses: actions/download-artifact@v4.1.7 - with: - name: osx-x64 - path: Raylib-cs/runtimes/osx-x64/native - - - uses: actions/download-artifact@v4.1.7 - with: - name: win-x86 - path: Raylib-cs/runtimes/win-x86/native - - - uses: actions/download-artifact@v4.1.7 - with: - name: win-x64 - path: Raylib-cs/runtimes/win-x64/native - - - name: setup dotnet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - - name: create NuGet Package + - name: Create NuGet Package run: dotnet pack Raylib-cs -c Release --output nuget + + + - name: Restore + Install Built Package + run: | + dotnet restore + + - name: Run Tests + run: | + dotnet test --verbosity normal - name: upload NuGet Package As Artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: path: nuget/* - name: upload NuGet Package As Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v3 if: startsWith(github.ref, 'refs/tags/') with: files: nuget/* diff --git a/.gitignore b/.gitignore index f3e5588..0203353 100644 --- a/.gitignore +++ b/.gitignore @@ -177,6 +177,7 @@ PublishScripts/ # NuGet Packages *.nupkg +nuget # The packages folder can be ignored because of Package Restore **/packages/* # except build/, which is used as an MSBuild target. diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..92fc659 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,14 @@ + + + + 8.1.0 + + + + + true + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..bc743c2 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,10 @@ + + + + Library + + diff --git a/Examples/Core/InputGamepad.cs b/Examples/Core/InputGamepad.cs index 7d0104a..efd2ffb 100644 --- a/Examples/Core/InputGamepad.cs +++ b/Examples/Core/InputGamepad.cs @@ -21,7 +21,6 @@ using System.Numerics; -using Raylib_cs; using static Raylib_cs.Raylib; namespace Examples.Core; diff --git a/Examples/Examples.csproj b/Examples/Examples.csproj index cacf967..c03c904 100644 --- a/Examples/Examples.csproj +++ b/Examples/Examples.csproj @@ -1,25 +1,34 @@ - - Exe - net8.0;net10.0 - true - Examples.Program - $(MSBuildThisFileDirectory) - default - enable - + + Exe + net8.0;net10.0 + true + Examples.Program + $(MSBuildThisFileDirectory) + 12 + enable + false + - - - - + + + + - - - + + + + + + + + + + + + + + - - - - diff --git a/Examples/Shapes/FollowingEyes.cs b/Examples/Shapes/FollowingEyes.cs index 80ea28b..679ac3e 100644 --- a/Examples/Shapes/FollowingEyes.cs +++ b/Examples/Shapes/FollowingEyes.cs @@ -11,6 +11,7 @@ using System; using System.Numerics; +using Raylib_cs; using static Raylib_cs.Raylib; namespace Examples.Shapes; diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000..df24209 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 0dd37c2..406665f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Raylib-cs -C# bindings for raylib, a simple and easy-to-use library to learn videogames programming (www.raylib.com) +C# bindings for raylib, a simple and easy-to-use library to learn video games programming (www.raylib.com) [![GitHub contributors](https://img.shields.io/github/contributors/raylib-cs/raylib-cs)](https://github.com/raylib-cs/raylib-cs/graphs/contributors) [![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE) @@ -13,17 +13,30 @@ C# bindings for raylib, a simple and easy-to-use library to learn videogames pro Raylib-cs targets net8.0, net10.0 and uses the [official 6.0 release](https://github.com/raysan5/raylib/releases/tag/6.0) to build the native libraries. +### Version 8.1.0 of Raylib-cs supports the following runtimes: +- **browser-wasm** *(raylib-6.0_webassembly)* 🆕 +- **linux-x64** *(raylib-6.0_linux_amd64)* +- **osx-arm64** *(raylib-6.0_macos)* +- **osx-x64** *(raylib-6.0_macos)* +- **win-x64** *(raylib-6.0_win64_msvc16)* +- **win-x86** *(raylib-6.0_win32_msvc16)* + +The following frameworks are deprecated (fall back to Version 7.x if required): +- net6.0 (end of life) + + ## Status Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be -accepted if they don't have a large maintainence burden. +accepted if they don't have a large maintenance burden. ## Installation - NuGet -This is the prefered method to get started. +This is the preferred method to get started. -1) Pick a folder in which you would like to start a raylib project. For example "MyRaylibCSProj". -2) Then from a terminal whilst in the directory you just created run the following commands. (Please keep in mind .NET should already be installed on your system). +1) Pick a folder in which you would like to start a raylib project. For example, "MyRaylibCSProj." +2) Then from a terminal (for example, a VSCode terminal), whilst in the directory you just created + run the following commands. (Please keep in mind .NET should already be installed on your system) ``` dotnet new console @@ -34,9 +47,11 @@ dotnet add package Raylib-cs [![NuGet](https://img.shields.io/nuget/dt/raylib-cs)](https://www.nuget.org/packages/Raylib-cs/) -If you need to edit Raylib-cs source then you will need to add the bindings as a project (see below). +If you need to edit the Raylib-cs source, then you will need to add the bindings as a project (see below). -Remember if you are trying to run the above commands in the terminal that you need to be *inside the intended project directory* (not just inside the solution directory) otherwise the command won't work. +If you are new to using NuGet (or you've forgotten) and are trying to run the above command in the command prompt, +remember that you need to be *inside the intended project directory* (not just inside the solution directory); +otherwise the command won't work. ## Installation - Manual @@ -46,9 +61,28 @@ Remember if you are trying to run the above commands in the terminal that you ne 3. Download/build the native libraries for the platforms you want using the [official 6.0 release](https://github.com/raysan5/raylib/releases/tag/6.0). **NOTE: the MSVC version is required for Windows platforms** -4. Add the native libraries to your project so they are in the same directory as the executable/can be found in the [search path](https://www.mono-project.com/docs/advanced/pinvoke/). +4. Set up the native libraries, so they are in the same directory as the executable/can be found in the [search path](https://www.mono-project.com/docs/advanced/pinvoke/). -6. Start coding! +5. Start coding! + +## Building from source + +The `Examples` and `Raylib-cs.Tests` projects consume the binding as a NuGet package, and the in-repo +version may not be published on nuget.org yet. Pack it once into the local feed before the first build: + +``` +dotnet pack Raylib-cs -c Release -o nuget +dotnet build +``` + +`NuGet.config` points restore at the local `./nuget` feed, so both projects pick up the freshly packed +package. If you skip the pack step on a fresh clone, restore fails with NU1301 (the `./nuget` source +doesn't exist) or NU1102 (Raylib-cs not found) — running the pack command fixes both. + +When iterating on the binding itself, note that NuGet caches the extracted package by version and +ignores repacks of the same version. After repacking, delete the old package from `./nuget` and clear +the cached copy (`dotnet nuget locals global-packages --clear`, or delete +`~/.nuget/packages/raylib-cs/`) before restoring again. ## Hello, World! diff --git a/Raylib-cs.Native/Native.cs b/Raylib-cs.Native/Native.cs deleted file mode 100644 index 7efa532..0000000 --- a/Raylib-cs.Native/Native.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Raylib_cs.Native; - -internal class Native -{ -} diff --git a/Raylib-cs.Native/Raylib-cs.Native.csproj b/Raylib-cs.Native/Raylib-cs.Native.csproj deleted file mode 100644 index 92415c8..0000000 --- a/Raylib-cs.Native/Raylib-cs.Native.csproj +++ /dev/null @@ -1,71 +0,0 @@ - - - net8.0 - false - none - false - False - - - - - - so - lib - x64 - - - - dylib - lib - x86_x64 - $(BuildArch) - - - - dll - $(Configuration)/ - x64 - $(BuildArch) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Raylib-cs.Tests/Raylib-cs.Tests.csproj b/Raylib-cs.Tests/Raylib-cs.Tests.csproj index eb14162..fb066da 100644 --- a/Raylib-cs.Tests/Raylib-cs.Tests.csproj +++ b/Raylib-cs.Tests/Raylib-cs.Tests.csproj @@ -1,18 +1,21 @@ - - net10.0 - true - 12 - + + net8.0;net10.0 + true + 12 + - - - - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - - + + + diff --git a/Raylib-cs.Tests/RaylibTests.cs b/Raylib-cs.Tests/RaylibTests.cs index eefdbc0..745371f 100644 --- a/Raylib-cs.Tests/RaylibTests.cs +++ b/Raylib-cs.Tests/RaylibTests.cs @@ -15,7 +15,7 @@ public static class BlittableHelper public class RaylibTests { - private unsafe void CheckType() where T : unmanaged + private static void CheckType() where T : unmanaged { Assert.True(BlittableHelper.IsBlittable()); } diff --git a/Raylib-cs.sln b/Raylib-cs.sln index 851d40f..015e8d1 100644 --- a/Raylib-cs.sln +++ b/Raylib-cs.sln @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-cs.Tests", "Raylib-c EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{1E2A5986-3F11-457F-AF97-D0C08D0060BA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-cs.Native", "Raylib-cs.Native\Raylib-cs.Native.csproj", "{B89AA313-3675-42A3-80BC-6156913E3A27}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,9 +30,5 @@ Global {1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Release|Any CPU.ActiveCfg = Release|Any CPU {1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Release|Any CPU.Build.0 = Release|Any CPU - {B89AA313-3675-42A3-80BC-6156913E3A27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B89AA313-3675-42A3-80BC-6156913E3A27}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B89AA313-3675-42A3-80BC-6156913E3A27}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B89AA313-3675-42A3-80BC-6156913E3A27}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Raylib-cs.sln.DotSettings b/Raylib-cs.sln.DotSettings new file mode 100644 index 0000000..bc4499d --- /dev/null +++ b/Raylib-cs.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/Raylib-cs/Build.props b/Raylib-cs/Build.props index 1603a20..3a91b49 100644 --- a/Raylib-cs/Build.props +++ b/Raylib-cs/Build.props @@ -1,7 +1,7 @@ 6.0 - 8.0.0 - 8.0.0 + $(RaylibCsVersion) + $(RaylibCsVersion) diff --git a/Raylib-cs/Raylib-cs.csproj b/Raylib-cs/Raylib-cs.csproj index c7f551a..d9964e4 100644 --- a/Raylib-cs/Raylib-cs.csproj +++ b/Raylib-cs/Raylib-cs.csproj @@ -1,54 +1,165 @@  - - net8.0;net10.0 - false - Raylib-cs - Raylib_cs - true - false - $(NoWarn);1591 - 12 - + + net8.0;net10.0 + Raylib-cs + Raylib_cs + true + 12 + - - Raylib-cs - C# bindings for raylib - A simple and easy-to-use library to learn videogames programming - https://github.com/raylib-cs/raylib-cs/ - raylib-cs - Zlib - README.md - raylib-cs_64x64.png - raylib csharp gamedev - https://www.raylib.com/ - true - true - snupkg - git - true - + + $(NoWarn);1591 + - - - - + + Raylib-cs + C# bindings for raylib + https://github.com/raylib-cs/raylib-cs/ + raylib-cs + Zlib + README.md + raylib-cs_64x64.png + raylib csharp gamedev - - - + true + snupkg + true + - + + + + + + - - - runtimes/ - true - PreserveNewest - - + + + - - - - - - + + + + 6.0 + + + + $(BaseIntermediateOutputPath)natives/ + + + + + + + + + + + + + + + + @(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Pkg)') + @(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Ext)') + @(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Lib)') + + + + + + + + + + + + <_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')" + Condition="'%(RaylibRid.PackAs)' == ''"> + runtimes/%(RaylibRid.Identity)/native/ + None + + <_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')" + Condition="'%(RaylibRid.PackAs)' != ''"> + runtimes/%(RaylibRid.Identity)/native/%(RaylibRid.PackAs) + None + + + + + + + + + + + + <_RaylibNativesDir>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/$(NativesRoot)')) + + + <_NativeCandidate Include="$(_RaylibNativesDir)$(RuntimeIdentifier)/**/$(LibPattern)"/> + <_RaylibNativeLibraryItem Include="@(_NativeCandidate)"/> + + + + + + + <_WasmNativeSrc>$(NativesRoot)browser-wasm/$(RaylibPackageName)/lib/libraylib.web.a + <_WasmNativeDst>$(MSBuildThisFileDirectory)obj/browser-wasm/raylib.a + + + + + + + + + + + + + <_WorkDir>$(NativesRoot)$(RuntimeIdentifier)/ + <_ArchiveFile>$(_WorkDir)$(RaylibPackageName)$(ArchiveExt) + + <_ExtractMarker>$(_WorkDir)$(RaylibPackageName).extracted + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Raylib-cs/Raylib-cs.targets b/Raylib-cs/Raylib-cs.targets new file mode 100644 index 0000000..290cbc8 --- /dev/null +++ b/Raylib-cs/Raylib-cs.targets @@ -0,0 +1,54 @@ + + + + 6.0 + + + + $(EmccFlags) -sUSE_GLFW=3 + + + + + + + + + + + + + + + + + + + + <_RaylibNativeRid Condition="'$(_RaylibNativeRid)' == ''">$(RuntimeIdentifier) + <_RaylibNativeRid Condition="'$(_RaylibNativeRid)' == ''">$(NETCoreSdkPortableRuntimeIdentifier) + <_RaylibNativeOutputDir>$(OutputPath)runtimes\$(_RaylibNativeRid)\native\ + + + + + + + + + + diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index 4e5e186..c7ca8f9 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -26,7 +26,14 @@ public static unsafe partial class Raylib static Raylib() { - NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport); + // On WebAssembly (browser) the native library is statically linked into the main + // module, and P/Invokes are resolved by the runtime's built-in static-linking table. + // A custom resolver would override that and fail (there is no library to load), so we + // only install it on platforms where raylib is a separate dynamic library. + if (!OperatingSystem.IsBrowser()) + { + NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport); + } } public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) diff --git a/Raylib-cs/interop/Rlgl.cs b/Raylib-cs/interop/Rlgl.cs index 2938ca5..c65440d 100644 --- a/Raylib-cs/interop/Rlgl.cs +++ b/Raylib-cs/interop/Rlgl.cs @@ -298,19 +298,6 @@ public static unsafe partial class Rlgl [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableVertexAttribute(uint index); - /// Enable attribute state pointer
- /// NOTE: Only available for GRAPHICS_API_OPENGL_11
- [LibraryImport(NativeLibName, EntryPoint = "rlEnableStatePointer")] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void EnableStatePointer(int vertexAttribType, void* buffer); - - /// Disable attribute state pointer
- /// NOTE: Only available for GRAPHICS_API_OPENGL_11
- [LibraryImport(NativeLibName, EntryPoint = "rlDisableStatePointer")] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void DisableStatePointer(int vertexAttribType); - - // Textures state /// Select and active a texture slot @@ -757,7 +744,7 @@ public static unsafe partial class Rlgl /// Load depth texture/renderbuffer (to be attached to fbo) [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureDepth")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial uint LoadTextureDepth(int width, int height, CBool useRenderBuffer); + public static partial uint LoadTextureDepth(int width, int height, int useRenderBuffer); /// Load texture cubemap data [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap")] @@ -826,8 +813,8 @@ public static unsafe partial class Rlgl public static partial void FramebufferAttach( uint fboId, uint texId, - FramebufferAttachType attachType, - FramebufferAttachTextureType texType, + int attachType, + int texType, int mipLevel ); diff --git a/Raylib-cs/runtimes/linux-x64/native/.keep b/Raylib-cs/runtimes/linux-x64/native/.keep deleted file mode 100644 index 8d1c8b6..0000000 --- a/Raylib-cs/runtimes/linux-x64/native/.keep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Raylib-cs/runtimes/osx-arm64/native/.keep b/Raylib-cs/runtimes/osx-arm64/native/.keep deleted file mode 100644 index 8b13789..0000000 --- a/Raylib-cs/runtimes/osx-arm64/native/.keep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Raylib-cs/runtimes/osx-x64/native/.keep b/Raylib-cs/runtimes/osx-x64/native/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/Raylib-cs/runtimes/win-x64/native/.keep b/Raylib-cs/runtimes/win-x64/native/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/Raylib-cs/runtimes/win-x86/native/.keep b/Raylib-cs/runtimes/win-x86/native/.keep deleted file mode 100644 index 8d1c8b6..0000000 --- a/Raylib-cs/runtimes/win-x86/native/.keep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Raylib-cs/types/Raylib.Utils.cs b/Raylib-cs/types/Raylib.Utils.cs index 8f92726..3e10ae6 100644 --- a/Raylib-cs/types/Raylib.Utils.cs +++ b/Raylib-cs/types/Raylib.Utils.cs @@ -186,6 +186,14 @@ public static unsafe partial class Raylib /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) public static void TraceLog(TraceLogLevel logLevel, string text) { + // raylib's TraceLog is variadic (const char *text, ...). WebAssembly cannot invoke + // variadic C functions from managed code (traps with "function signature mismatch"). + if (OperatingSystem.IsBrowser()) + { + Console.WriteLine(text); + return; + } + using Utf8Buffer str1 = text.ToUtf8Buffer(); TraceLog(logLevel, str1.AsPointer()); } diff --git a/Raylib-cs/types/Rlgl.Utils.cs b/Raylib-cs/types/Rlgl.Utils.cs index 3f50d50..5f258e0 100644 --- a/Raylib-cs/types/Rlgl.Utils.cs +++ b/Raylib-cs/types/Rlgl.Utils.cs @@ -4,6 +4,19 @@ namespace Raylib_cs; public static unsafe partial class Rlgl { + /// Load depth texture/renderbuffer (to be attached to fbo) + public static uint LoadTextureDepth(int width, int height, bool useRenderBuffer) => + LoadTextureDepth(width, height, useRenderBuffer ? 1 : 0); + + /// Attach texture/renderbuffer to a framebuffer + public static void FramebufferAttach( + uint fboId, + uint texId, + FramebufferAttachType attachType, + FramebufferAttachTextureType texType, + int mipLevel + ) => FramebufferAttach(fboId, texId, (int)attachType, (int)texType, mipLevel); + /// Set shader value matrices public static void SetUniformMatrices(int locIndex, Matrix4x4[] mat) {