SFML.Net
SFML.Net copied to clipboard
SFML.Net 3
This is nowhere near ready (CSFML v3 isn't even out), but I'm making this PR to track progress and to have higher visibility on the code changes.
The changes involved are as follows:
- remove obsolete code
- change methods that used multiple parameters for vector components (i.e.
int x, int y, int z) to use vectors instead - change P/Invokes to match the new (or expected) signatures on the CSFML side
- rename some members to match the C++ side (for example,
SystemHandle->NativeHandle) - implement miniaudio changes for the Audio module
- extract
Countstyle enum values into a readonly field - implement
Angleand the new methods onVector2andVector3, useAngleinstead of degrees expessed as floats - implement
GetGeometricCentermethods on shapes - implement stencil and scissor features for Graphics module
- implement new methods for starting / stopping
Clock - added raw mouse event for Window
- added timeout parameter to
WaitEventstyle calls - create basic unit tests (currently only
Angleis tested)
The current PR seems to run with local CSFML 3.0 binaries (i.e. all example programs seem to run without any immediate issues), so I think it's now possible for people to test it out if they want to (although I'd expect it to crash in a lot of other places).
Since CSFML and SFML.Net 3.0 nuget packages are not available yet, here's instructions on how to build local CSFML and SFML.Net nuget packages for Windows / Visual Studio 2022:
Before all:
- run
dotnet nuget locals all --clearto clear previous cached packages if needed (i.e. if you update the package code but use the same version)
For CSFML 3.0:
- Clone CSFML master branch (or
https://github.com/Marioalexsan/CSFML/tree/render-statesif the latest CSFML PR is not merged yet) - Open a Powershell terminal in
tools/nugetand run./build.win.ps1 - in
tools/nuget, rundotnet pack -c Release - in Visual Studio 2022, in
Tools -> NuGet Package Manager -> Package Sources, add a path toCSFML/tools/nuget/CSFML/bin/Release
For SFML.Net 3.0:
- run
dotnet build -c Debug - in Visual Studio 2022, in
Tools -> NuGet Package Manager -> Package Sources, add the following paths:SFML.Net\src\SFML.Net\bin\DebugSFML.Net\src\SFML.Graphics\bin\DebugSFML.Net\src\SFML.Audio\bin\DebugSFML.Net\src\SFML.Window\bin\DebugSFML.Net\src\SFML.System\bin\Debug
- create a new project, and add the following to your
.csproj:
<ItemGroup>
<PackageReference Include="SFML.Net" Version="3.0.0-alpha1" />
</ItemGroup>
I've tested this flow with a new console project that uses one of the examples as source code, but let me know if it breaks in some other cases.
I've taken the liberty to update your branch by splitting the one commit into two, extracting the test stuff into a dedicated commit.
Also you can't really (in an easy way) multi-target tests while mixing it in the same solution. So I just limited it to .NET 6