From ea93e9dcec0e9831e9ac1fa29e3300c8690a436c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sun, 31 Aug 2025 13:30:58 +0200 Subject: [PATCH 1/6] Align license and readme file with SFML's structure --- SFML.NuGet.props | 4 ++-- examples/netcore/{README.md => readme.md} | 2 +- license.txt => license.md | 12 +----------- README.md => readme.md | 4 ++++ 4 files changed, 8 insertions(+), 14 deletions(-) rename examples/netcore/{README.md => readme.md} (81%) rename license.txt => license.md (80%) rename README.md => readme.md (96%) diff --git a/SFML.NuGet.props b/SFML.NuGet.props index 5df98f69..e7364163 100644 --- a/SFML.NuGet.props +++ b/SFML.NuGet.props @@ -14,7 +14,7 @@ https://www.sfml-dev.org/ https://github.com/SFML/SFML.Net sfml-icon.png - README.md + readme.md true @@ -23,7 +23,7 @@ - + diff --git a/examples/netcore/README.md b/examples/netcore/readme.md similarity index 81% rename from examples/netcore/README.md rename to examples/netcore/readme.md index cb4b9138..bb3ae0f8 100644 --- a/examples/netcore/README.md +++ b/examples/netcore/readme.md @@ -4,4 +4,4 @@ This project showcases how SFML.Net can be run on .NET core with NuGet packages. To execute this example, just run `dotnet run` inside of this directory. Please note that platform availability is still limited by native CSFML libraries. -For more information on that, check [the main README](/README.md). +For more information on that, check [the main readme](/readme.md). diff --git a/license.txt b/license.md similarity index 80% rename from license.txt rename to license.md index 51db7395..20c347b5 100644 --- a/license.txt +++ b/license.md @@ -1,7 +1,4 @@ -SFML.Net --------- - -SFML.Net - Copyright (C) 2007-2023 Laurent Gomila - laurent@sfml-dev.org +SFML.Net - Copyright (C) 2007-2025 Laurent Gomila - laurent@sfml-dev.org This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held @@ -22,10 +19,3 @@ it freely, subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. - - - -External libraries used by SFML.Net ------------------------------------ - -* CSFML is under the zlib/png license diff --git a/README.md b/readme.md similarity index 96% rename from README.md rename to readme.md index 89c2b948..d20c27e2 100644 --- a/README.md +++ b/readme.md @@ -54,3 +54,7 @@ SFML and SFML.Net are open-source projects, and they need your help to go on gro Don't hesitate to post suggestions or bug reports on [the forum](https://en.sfml-dev.org/forums/) or post new bugs/features requests on the [issue tracker](https://github.com/SFML/SFML.Net/issues/). You can even fork the project on GitHub, maintain your own version and send us pull requests periodically to merge your work. + +## External libraries used by SFML.Net + +* [CSFML](https://github.com/SFML/CSFML/) is under the zlib/png license From 87a126af28410d543397058278dc2fd85e11bf5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sun, 31 Aug 2025 14:16:55 +0200 Subject: [PATCH 2/6] Update Systemtest dependencies --- .github/workflows/ci.yml | 6 ++---- SFML.sln | 1 + test/SFML.System.Test/SFML.System.Test.csproj | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24e9b447..b6d9cbf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,6 @@ jobs: - { name: macOS x64, os: macos-13 } - { name: macOS ARM64, os: macos-14 } dotnet: - - { name: .NET 6, version: "6.0.x" } - - { name: .NET 7, version: "7.0.x" } - { name: .NET 8, version: "8.0.x" } - { name: .NET 9, version: "9.0.x" } @@ -48,7 +46,7 @@ jobs: - name: Build SFML.Net run: dotnet build --configuration Release --no-restore - name: Test SFML.Net - if: matrix.dotnet.name == '.NET 6' + if: matrix.dotnet.name == '.NET 8' run: dotnet test --configuration Release --no-restore - name: Pack SFML.Net run: dotnet pack --configuration Release -o Publish @@ -56,7 +54,7 @@ jobs: - name: Install SFML.Net Examples Dependencies run: dotnet restore examples/Examples.sln - name: Build SFML.Net Examples - run: dotnet build --configuration Release --no-restore examples/Examples.sln + run: dotnet build --configuration Release --no-restore examples/Examples.sln - name: Upload Artifact uses: actions/upload-artifact@v4 diff --git a/SFML.sln b/SFML.sln index 7d235c6f..eed4fbcc 100644 --- a/SFML.sln +++ b/SFML.sln @@ -19,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution SFML.Module.props = SFML.Module.props SFML.NuGet.props = SFML.NuGet.props SFML.CodeStyle.props = SFML.CodeStyle.props + .github\workflows\ci.yml = .github\workflows\ci.yml EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SFML.System.Test", "test\SFML.System.Test\SFML.System.Test.csproj", "{958AC8B0-2D99-4C65-97C1-2979A090C82D}" diff --git a/test/SFML.System.Test/SFML.System.Test.csproj b/test/SFML.System.Test/SFML.System.Test.csproj index 18c28950..4eb7ad1b 100644 --- a/test/SFML.System.Test/SFML.System.Test.csproj +++ b/test/SFML.System.Test/SFML.System.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -11,13 +11,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive From c0d6d3256b75751782ea3608c46079cdd29d70f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sun, 31 Aug 2025 13:19:52 +0200 Subject: [PATCH 3/6] Update CSFML to the latest Release Candidate --- .github/workflows/ci.yml | 1 + SFML.Module.props | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6d9cbf2..b14845d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: dotnet: - { name: .NET 8, version: "8.0.x" } - { name: .NET 9, version: "9.0.x" } + - { name: .NET 10, version: "10.0.x" } steps: - name: Check out SFML.Net diff --git a/SFML.Module.props b/SFML.Module.props index e904eeaa..18f8f655 100644 --- a/SFML.Module.props +++ b/SFML.Module.props @@ -18,7 +18,7 @@ - + From cfa9409aa9cfcc5f4fe2bf4c38a5f2c058922030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sun, 31 Aug 2025 13:58:29 +0200 Subject: [PATCH 4/6] Add missing Resize method to the texture --- src/SFML.Graphics/Texture.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/SFML.Graphics/Texture.cs b/src/SFML.Graphics/Texture.cs index 76991460..4bff8222 100644 --- a/src/SFML.Graphics/Texture.cs +++ b/src/SFML.Graphics/Texture.cs @@ -255,6 +255,15 @@ public Texture(Texture copy) : //////////////////////////////////////////////////////////// public Image CopyToImage() => new Image(sfTexture_copyToImage(CPointer)); + //////////////////////////////////////////////////////////// + /// + /// Resize the texture. + /// + /// Width and height of the texture + /// True to enable sRGB conversion, false to disable it + //////////////////////////////////////////////////////////// + public bool Resize(Vector2u size, bool srgb = false) => srgb ? sfTexture_resizeSrgb(CPointer, size) : sfTexture_resize(CPointer, size); + //////////////////////////////////////////////////////////// /// /// Update a texture from an array of pixels @@ -346,7 +355,7 @@ public void Update(byte[] pixels, Vector2u size, Vector2u dest) /// /// Generate a mipmap using the current texture data /// - /// + /// /// /// Mipmaps are pre-computed chains of optimized textures. Each /// level of texture in a mipmap is generated by halving each of @@ -365,7 +374,7 @@ public void Update(byte[] pixels, Vector2u size, Vector2u dest) /// modified, at which point this function will have to be called again to /// regenerate it. /// - /// + /// /// True if mipmap generation was successful, false if unsuccessful //////////////////////////////////////////////////////////// public bool GenerateMipmap() => sfTexture_generateMipmap(CPointer); @@ -393,7 +402,7 @@ public bool Smooth /// /// Enable or disable conversion from sRGB /// - /// + /// /// /// When providing texture data from an image file or memory, it can /// either be stored in a linear color space or an sRGB color space. @@ -538,6 +547,12 @@ protected override void Destroy(bool disposing) [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern void sfTexture_destroy(IntPtr texture); + [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool sfTexture_resize(IntPtr texture, Vector2u size); + + [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool sfTexture_resizeSrgb(IntPtr texture, Vector2u size); + [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern Vector2u sfTexture_getSize(IntPtr texture); From 5ba03289d82e62799aa6edd94116c976600774f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Wed, 3 Sep 2025 23:26:52 +0200 Subject: [PATCH 5/6] Update example version to 3.0.0 --- examples/netcore/netcore.csproj | 2 +- examples/opengl/opengl.csproj | 2 +- examples/shader/shader.csproj | 2 +- examples/sound/sound.csproj | 2 +- examples/sound_capture/sound_capture.csproj | 2 +- examples/visualbasic/visualbasic.vbproj | 2 +- examples/window/window.csproj | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/netcore/netcore.csproj b/examples/netcore/netcore.csproj index 004005c2..fe60441a 100644 --- a/examples/netcore/netcore.csproj +++ b/examples/netcore/netcore.csproj @@ -5,7 +5,7 @@ Exe net6.0 - 2.6.0 + 3.0.0 AnyCPU;x64;x86 diff --git a/examples/opengl/opengl.csproj b/examples/opengl/opengl.csproj index fb1aa4d6..b69babb7 100644 --- a/examples/opengl/opengl.csproj +++ b/examples/opengl/opengl.csproj @@ -8,7 +8,7 @@ opengl opengl Debug;Release - 2.6.0 + 3.0.0 AnyCPU;x64;x86 diff --git a/examples/shader/shader.csproj b/examples/shader/shader.csproj index fee32556..5aa31985 100644 --- a/examples/shader/shader.csproj +++ b/examples/shader/shader.csproj @@ -8,7 +8,7 @@ shader shader Debug;Release - 2.6.0 + 3.0.0 AnyCPU;x64;x86 diff --git a/examples/sound/sound.csproj b/examples/sound/sound.csproj index 99a3afe2..9d3c6fb8 100644 --- a/examples/sound/sound.csproj +++ b/examples/sound/sound.csproj @@ -8,7 +8,7 @@ sound sound Debug;Release - 2.6.0 + 3.0.0 AnyCPU;x64;x86 diff --git a/examples/sound_capture/sound_capture.csproj b/examples/sound_capture/sound_capture.csproj index 7c75da44..c5a900e4 100644 --- a/examples/sound_capture/sound_capture.csproj +++ b/examples/sound_capture/sound_capture.csproj @@ -8,7 +8,7 @@ sound_capture sound_capture Debug;Release - 2.6.0 + 3.0.0 AnyCPU;x64;x86 diff --git a/examples/visualbasic/visualbasic.vbproj b/examples/visualbasic/visualbasic.vbproj index e5bcc7a3..17e73b70 100644 --- a/examples/visualbasic/visualbasic.vbproj +++ b/examples/visualbasic/visualbasic.vbproj @@ -8,7 +8,7 @@ false true true - 2.6.0 + 3.0.0 AnyCPU;x64;x86 diff --git a/examples/window/window.csproj b/examples/window/window.csproj index 72dce20d..4d01af7c 100644 --- a/examples/window/window.csproj +++ b/examples/window/window.csproj @@ -8,7 +8,7 @@ window window Debug;Release - 2.6.0 + 3.0.0 AnyCPU;x64;x86 From 1ba01a5f2848e75fe91e8888f24bf6bce469dae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Thu, 4 Sep 2025 00:02:44 +0200 Subject: [PATCH 6/6] Add missing SetMinimum/MaximumSize to the window classes --- src/SFML.Graphics/RenderWindow.cs | 58 ++++++++++++++++++++++++++++--- src/SFML.Window/Window.cs | 52 ++++++++++++++++++++++++++- src/SFML.Window/WindowBase.cs | 50 ++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 5 deletions(-) diff --git a/src/SFML.Graphics/RenderWindow.cs b/src/SFML.Graphics/RenderWindow.cs index 1f56bd51..4f784f0d 100644 --- a/src/SFML.Graphics/RenderWindow.cs +++ b/src/SFML.Graphics/RenderWindow.cs @@ -143,6 +143,50 @@ public override Vector2u Size //////////////////////////////////////////////////////////// public bool IsSrgb => sfRenderWindow_isSrgb(CPointer); + //////////////////////////////////////////////////////////// + /// + /// Set the minimum window rendering region size + /// + /// New minimum size, in pixels, null to reset the minimum size + //////////////////////////////////////////////////////////// + public override void SetMinimumSize(Vector2u? minimumSize) + { + unsafe + { + if (minimumSize.HasValue) + { + var minimumSizeRef = minimumSize.Value; + sfRenderWindow_setMinimumSize(CPointer, &minimumSizeRef); + } + else + { + sfRenderWindow_setMinimumSize(CPointer, null); + } + } + } + + //////////////////////////////////////////////////////////// + /// + /// Set the maximum window rendering region size + /// + /// New maximum size, in pixels, null to reset the maximum size + //////////////////////////////////////////////////////////// + public override void SetMaximumSize(Vector2u? maximumSize) + { + unsafe + { + if (maximumSize.HasValue) + { + var maximumSizeRef = maximumSize.Value; + sfRenderWindow_setMaximumSize(CPointer, &maximumSizeRef); + } + else + { + sfRenderWindow_setMaximumSize(CPointer, null); + } + } + } + //////////////////////////////////////////////////////////// /// /// Change the title of the window @@ -210,7 +254,7 @@ public override void SetIcon(Vector2u size, byte[] pixels) /// Grab or release the mouse cursor /// /// True to grab, false to release - /// + /// /// /// If set, grabs the mouse cursor inside this window's client /// area so it may no longer be moved outside its bounds. @@ -329,7 +373,7 @@ public override void SetIcon(Vector2u size, byte[] pixels) /// The specified stencil value is truncated to the bit /// width of the current stencil buffer. /// - /// Fill color to use to clear the render target + /// Fill color to use to clear the render target /// Stencil value to clear to //////////////////////////////////////////////////////////// public void Clear(Color color, StencilValue stencilValue) => sfRenderWindow_clearColorAndStencil(CPointer, color, stencilValue); @@ -548,7 +592,7 @@ public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type, /// /// Save the current OpenGL render states and matrices. /// - /// + /// /// /// // OpenGL code here... /// window.PushGLStates(); @@ -602,7 +646,7 @@ public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type, /// states needed by SFML are set, so that subsequent Draw() /// calls will work as expected. /// - /// + /// /// /// // OpenGL code here... /// glPushAttrib(...); @@ -761,6 +805,12 @@ private void Initialize() [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern void sfRenderWindow_setSize(IntPtr cPointer, Vector2u size); + [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern unsafe void sfRenderWindow_setMinimumSize(IntPtr cPointer, Vector2u* minimumSize); + + [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern unsafe void sfRenderWindow_setMaximumSize(IntPtr cPointer, Vector2u* maximumSize); + [DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern void sfRenderWindow_setUnicodeTitle(IntPtr cPointer, IntPtr title); diff --git a/src/SFML.Window/Window.cs b/src/SFML.Window/Window.cs index 264c52d5..a1d966f8 100644 --- a/src/SFML.Window/Window.cs +++ b/src/SFML.Window/Window.cs @@ -162,6 +162,50 @@ public override void SetTitle(string title) } } + //////////////////////////////////////////////////////////// + /// + /// Set the minimum window rendering region size + /// + /// New minimum size, in pixels, null to reset the minimum size + //////////////////////////////////////////////////////////// + public override void SetMinimumSize(Vector2u? minimumSize) + { + unsafe + { + if (minimumSize.HasValue) + { + var minimumSizeRef = minimumSize.Value; + sfWindow_setMinimumSize(CPointer, &minimumSizeRef); + } + else + { + sfWindow_setMinimumSize(CPointer, null); + } + } + } + + //////////////////////////////////////////////////////////// + /// + /// Set the maximum window rendering region size + /// + /// New maximum size, in pixels, null to reset the maximum size + //////////////////////////////////////////////////////////// + public override void SetMaximumSize(Vector2u? maximumSize) + { + unsafe + { + if (maximumSize.HasValue) + { + var maximumSizeRef = maximumSize.Value; + sfWindow_setMaximumSize(CPointer, &maximumSizeRef); + } + else + { + sfWindow_setMaximumSize(CPointer, null); + } + } + } + //////////////////////////////////////////////////////////// /// /// Change the window's icon @@ -201,7 +245,7 @@ public override void SetIcon(Vector2u size, byte[] pixels) /// Grab or release the mouse cursor /// /// True to grab, false to release - /// + /// /// /// If set, grabs the mouse cursor inside this window's client /// area so it may no longer be moved outside its bounds. @@ -441,6 +485,12 @@ protected Window(IntPtr cPointer, int dummy) : [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern void sfWindow_setSize(IntPtr cPointer, Vector2u size); + [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern unsafe void sfWindow_setMinimumSize(IntPtr cPointer, Vector2u* minimumSize); + + [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern unsafe void sfWindow_setMaximumSize(IntPtr cPointer, Vector2u* maximumSize); + [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern void sfWindow_setUnicodeTitle(IntPtr cPointer, IntPtr title); diff --git a/src/SFML.Window/WindowBase.cs b/src/SFML.Window/WindowBase.cs index 2e3bca1e..c7a6c87d 100644 --- a/src/SFML.Window/WindowBase.cs +++ b/src/SFML.Window/WindowBase.cs @@ -139,6 +139,50 @@ public virtual Vector2u Size set => sfWindowBase_setSize(CPointer, value); } + //////////////////////////////////////////////////////////// + /// + /// Set the minimum window rendering region size + /// + /// New minimum size, in pixels, null to reset the minimum size + //////////////////////////////////////////////////////////// + public virtual void SetMinimumSize(Vector2u? minimumSize) + { + unsafe + { + if (minimumSize.HasValue) + { + var minimumSizeRef = minimumSize.Value; + sfWindowBase_setMinimumSize(CPointer, &minimumSizeRef); + } + else + { + sfWindowBase_setMinimumSize(CPointer, null); + } + } + } + + //////////////////////////////////////////////////////////// + /// + /// Set the maximum window rendering region size + /// + /// New maximum size, in pixels, null to reset the maximum size + //////////////////////////////////////////////////////////// + public virtual void SetMaximumSize(Vector2u? maximumSize) + { + unsafe + { + if (maximumSize.HasValue) + { + var maximumSizeRef = maximumSize.Value; + sfWindowBase_setMaximumSize(CPointer, &maximumSizeRef); + } + else + { + sfWindowBase_setMaximumSize(CPointer, null); + } + } + } + //////////////////////////////////////////////////////////// /// /// Change the title of the window @@ -615,6 +659,12 @@ private void CallEventHandler(Event e) [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern void sfWindowBase_setSize(IntPtr cPointer, Vector2u size); + [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern unsafe void sfWindowBase_setMinimumSize(IntPtr cPointer, Vector2u* minimumSize); + + [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern unsafe void sfWindowBase_setMaximumSize(IntPtr cPointer, Vector2u* maximumSize); + [DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern void sfWindowBase_setUnicodeTitle(IntPtr cPointer, IntPtr title);