diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 002f55d..ca787a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,184 +1,45 @@ -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"] + branches: ["master"] pull_request: branches: ["*"] 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@v4 - - 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 + - name: Setup .NET uses: actions/setup-dotnet@v4 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: 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 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..54386fe 100644 --- a/Examples/Examples.csproj +++ b/Examples/Examples.csproj @@ -1,25 +1,25 @@ - - 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..642a38a 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.0.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,9 @@ 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! ## 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..31bc88b 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/Raylib-cs.csproj b/Raylib-cs/Raylib-cs.csproj index c7f551a..5907915 100644 --- a/Raylib-cs/Raylib-cs.csproj +++ b/Raylib-cs/Raylib-cs.csproj @@ -1,54 +1,193 @@  - - net8.0;net10.0 - false - Raylib-cs - Raylib_cs - true - false - $(NoWarn);1591 - 12 - + + net8.0;net10.0 + Raylib-cs + Raylib_cs + true + 12 + win-x64;win-x86;linux-x64;osx-x64;osx-arm64;browser-wasm + - - 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 + 8.0.0 + 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/ + + + + + + raylib-$(TargetRaylibTag)_win64_msvc16 + .zip + raylib.dll + + + + + raylib-$(TargetRaylibTag)_win32_msvc16 + .zip + raylib.dll + + + + + raylib-$(TargetRaylibTag)_linux_amd64 + .tar.gz + libraylib.so* + + + + + raylib-$(TargetRaylibTag)_macos + .tar.gz + libraylib.dylib + + + + + raylib-$(TargetRaylibTag)_macos + .tar.gz + libraylib.dylib + + + + + raylib-$(TargetRaylibTag)_webassembly + .zip + libraylib.web.a + + + + + + + + + + <_TargetRids Include="$(PackageRids)"/> + + + + + + + <_PackageFiles Include="$(NativesRoot)win-x64/raylib-$(TargetRaylibTag)_win64_msvc16/lib/raylib.dll"> + runtimes/win-x64/native/ + None + + + <_PackageFiles Include="$(NativesRoot)win-x86/raylib-$(TargetRaylibTag)_win32_msvc16/lib/raylib.dll"> + runtimes/win-x86/native/ + None + + + <_PackageFiles Include="$(NativesRoot)linux-x64/raylib-$(TargetRaylibTag)_linux_amd64/lib/libraylib.so"> + runtimes/linux-x64/native/ + None + + + <_PackageFiles Include="$(NativesRoot)osx-x64/raylib-$(TargetRaylibTag)_macos/lib/libraylib.dylib"> + runtimes/osx-x64/native/ + None + + + <_PackageFiles Include="$(NativesRoot)osx-arm64/raylib-$(TargetRaylibTag)_macos/lib/libraylib.dylib"> + runtimes/osx-arm64/native/ + None + + + <_PackageFiles Include="$(NativesRoot)browser-wasm/raylib-$(TargetRaylibTag)_webassembly/lib/libraylib.web.a"> + runtimes/browser-wasm/native/raylib.a + None + + + + + + + + + + + + + <_NativeToCopy Include="$(NativesRoot)$(RuntimeIdentifier)/**/$(LibPattern)"/> + + + + + + + + + + + <_WorkDir>$(NativesRoot)$(RuntimeIdentifier)/ + <_ArchiveFile>$(_WorkDir)$(RaylibPackageName)$(ArchiveExt) + <_ExtractMarker>$(_WorkDir).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..7cde8d4 --- /dev/null +++ b/Raylib-cs/Raylib-cs.targets @@ -0,0 +1,10 @@ + + + + + + + + $(EmccFlags) -sUSE_GLFW=3 + + diff --git a/Raylib-cs/interop/Rlgl.cs b/Raylib-cs/interop/Rlgl.cs index 2938ca5..677be6e 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 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 @@ -