diff --git a/examples/Examples.sln b/examples/Examples.sln
index a114aeac..82164da3 100644
--- a/examples/Examples.sln
+++ b/examples/Examples.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.9.34902.65
+# Visual Studio Version 18
+VisualStudioVersion = 18.2.11408.102
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SFML", "SFML", "{620580C3-9270-42C9-A2BF-4DA85B522831}"
EndProject
@@ -27,7 +27,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SFML.System", "..\src\SFML.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SFML.Window", "..\src\SFML.Window\SFML.Window.csproj", "{698CC2F9-93C8-4119-997B-B622193FA827}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "netcore", "netcore\netcore.csproj", "{93B8425A-AC40-4486-96AF-20027B738C09}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "netfx", "netfx\netfx.csproj", "{93B8425A-AC40-4486-96AF-20027B738C09}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A64BFAB3-DD36-4ABE-AABB-8A594327CCDD}"
ProjectSection(SolutionItems) = preProject
@@ -45,61 +45,73 @@ Global
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2FC1071D-4470-4704-B28E-29FF4DD432A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Debug|x64.ActiveCfg = Debug|x64
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Debug|x64.Build.0 = Debug|x64
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Debug|x86.ActiveCfg = Debug|x86
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Debug|x86.Build.0 = Debug|x86
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2FC1071D-4470-4704-B28E-29FF4DD432A0}.Release|Any CPU.Build.0 = Release|Any CPU
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Release|x64.ActiveCfg = Release|x64
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Release|x64.Build.0 = Release|x64
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Release|x86.ActiveCfg = Release|x86
{2FC1071D-4470-4704-B28E-29FF4DD432A0}.Release|x86.Build.0 = Release|x86
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EBF44846-C2C9-4595-881F-FD3489C0828F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Debug|x64.ActiveCfg = Debug|x64
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Debug|x64.Build.0 = Debug|x64
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Debug|x86.ActiveCfg = Debug|x86
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Debug|x86.Build.0 = Debug|x86
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EBF44846-C2C9-4595-881F-FD3489C0828F}.Release|Any CPU.Build.0 = Release|Any CPU
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Release|x64.ActiveCfg = Release|x64
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Release|x64.Build.0 = Release|x64
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Release|x86.ActiveCfg = Release|x86
{EBF44846-C2C9-4595-881F-FD3489C0828F}.Release|x86.Build.0 = Release|x86
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {16B5B101-D5CC-449D-B6C5-E93048B01108}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Debug|x64.ActiveCfg = Debug|x64
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Debug|x64.Build.0 = Debug|x64
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Debug|x86.ActiveCfg = Debug|x86
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Debug|x86.Build.0 = Debug|x86
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {16B5B101-D5CC-449D-B6C5-E93048B01108}.Release|Any CPU.Build.0 = Release|Any CPU
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Release|x64.ActiveCfg = Release|x64
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Release|x64.Build.0 = Release|x64
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Release|x86.ActiveCfg = Release|x86
{16B5B101-D5CC-449D-B6C5-E93048B01108}.Release|x86.Build.0 = Release|x86
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Debug|x64.ActiveCfg = Debug|x64
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Debug|x64.Build.0 = Debug|x64
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Debug|x86.ActiveCfg = Debug|x86
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Debug|x86.Build.0 = Debug|x86
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Release|Any CPU.Build.0 = Release|Any CPU
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Release|x64.ActiveCfg = Release|x64
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Release|x64.Build.0 = Release|x64
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Release|x86.ActiveCfg = Release|x86
{FBA62527-7197-4EEE-B96A-7E3FEC313BCE}.Release|x86.Build.0 = Release|x86
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Debug|x64.ActiveCfg = Debug|x64
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Debug|x64.Build.0 = Debug|x64
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Debug|x86.ActiveCfg = Debug|x86
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Debug|x86.Build.0 = Debug|x86
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Release|Any CPU.Build.0 = Release|Any CPU
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Release|x64.ActiveCfg = Release|x64
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Release|x64.Build.0 = Release|x64
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Release|x86.ActiveCfg = Release|x86
{98552080-F688-46B4-A2FF-1AC7C50ECBE8}.Release|x86.Build.0 = Release|x86
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Debug|x64.ActiveCfg = Debug|x64
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Debug|x64.Build.0 = Debug|x64
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Debug|x86.ActiveCfg = Debug|x86
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Debug|x86.Build.0 = Debug|x86
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Release|Any CPU.Build.0 = Release|Any CPU
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Release|x64.ActiveCfg = Release|x64
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Release|x64.Build.0 = Release|x64
{7696A8C5-CB82-4B53-8E55-BF4C7B20E8E2}.Release|x86.ActiveCfg = Release|x86
@@ -164,14 +176,14 @@ Global
{698CC2F9-93C8-4119-997B-B622193FA827}.Release|x64.Build.0 = Release|x64
{698CC2F9-93C8-4119-997B-B622193FA827}.Release|x86.ActiveCfg = Release|x86
{698CC2F9-93C8-4119-997B-B622193FA827}.Release|x86.Build.0 = Release|x86
- {93B8425A-AC40-4486-96AF-20027B738C09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {93B8425A-AC40-4486-96AF-20027B738C09}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {93B8425A-AC40-4486-96AF-20027B738C09}.Debug|Any CPU.ActiveCfg = Debug|x64
+ {93B8425A-AC40-4486-96AF-20027B738C09}.Debug|Any CPU.Build.0 = Debug|x64
{93B8425A-AC40-4486-96AF-20027B738C09}.Debug|x64.ActiveCfg = Debug|x64
{93B8425A-AC40-4486-96AF-20027B738C09}.Debug|x64.Build.0 = Debug|x64
{93B8425A-AC40-4486-96AF-20027B738C09}.Debug|x86.ActiveCfg = Debug|x86
{93B8425A-AC40-4486-96AF-20027B738C09}.Debug|x86.Build.0 = Debug|x86
- {93B8425A-AC40-4486-96AF-20027B738C09}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {93B8425A-AC40-4486-96AF-20027B738C09}.Release|Any CPU.Build.0 = Release|Any CPU
+ {93B8425A-AC40-4486-96AF-20027B738C09}.Release|Any CPU.ActiveCfg = Release|x64
+ {93B8425A-AC40-4486-96AF-20027B738C09}.Release|Any CPU.Build.0 = Release|x64
{93B8425A-AC40-4486-96AF-20027B738C09}.Release|x64.ActiveCfg = Release|x64
{93B8425A-AC40-4486-96AF-20027B738C09}.Release|x64.Build.0 = Release|x64
{93B8425A-AC40-4486-96AF-20027B738C09}.Release|x86.ActiveCfg = Release|x86
diff --git a/examples/netcore/Properties/launchSettings.json b/examples/netcore/Properties/launchSettings.json
deleted file mode 100644
index fa088e9b..00000000
--- a/examples/netcore/Properties/launchSettings.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "profiles": {
- "netcore": {
- "commandName": "Project",
- "nativeDebugging": true
- }
- }
-}
\ No newline at end of file
diff --git a/examples/netcore/readme.md b/examples/netcore/readme.md
deleted file mode 100644
index bb3ae0f8..00000000
--- a/examples/netcore/readme.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# SFML.Net running on .NET Core
-
-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).
diff --git a/examples/netcore/Program.cs b/examples/netfx/Program.cs
similarity index 71%
rename from examples/netcore/Program.cs
rename to examples/netfx/Program.cs
index e52f5c3b..75b3aa71 100644
--- a/examples/netcore/Program.cs
+++ b/examples/netfx/Program.cs
@@ -4,28 +4,30 @@
using SFML.System;
using SFML.Window;
-namespace netcore;
+namespace netfx;
-internal class Program
+public static class Program
{
private static void Main()
{
- var shape = new RectangleShape(new Vector2f(100, 100))
+ var window = new RenderWindow(new VideoMode((800, 600)), "SFML running with .NET Framework");
+ window.Closed += (_, _) => window.Close();
+
+ var shape = new CircleShape(100f, 50)
{
- FillColor = Color.Black
+ FillColor = Color.Green,
+ Origin = new Vector2f(100f, 100f),
+ Position = new Vector2f(400f, 300f)
};
var sound = new Sound(GenerateSineWave(frequency: 440.0, volume: .25, seconds: 1));
- var window = new RenderWindow(new VideoMode((800, 600)), "SFML running in .NET Core");
- window.Closed += (_, _) => window.Close();
-
sound.Play();
while (window.IsOpen)
{
window.DispatchEvents();
- window.Clear(Color.White);
+ window.Clear();
window.Draw(shape);
window.Display();
}
@@ -41,6 +43,6 @@ private static SoundBuffer GenerateSineWave(double frequency, double volume, int
samples[i] = (short)(Math.Sin(frequency * (2 * Math.PI) * i / sampleRate) * volume * short.MaxValue);
}
- return new SoundBuffer(samples, 1, sampleRate, new SoundChannel[] { SoundChannel.Mono });
+ return new SoundBuffer(samples, 1, sampleRate, [SoundChannel.Mono]);
}
}
diff --git a/examples/netcore/netcore.csproj b/examples/netfx/netfx.csproj
similarity index 72%
rename from examples/netcore/netcore.csproj
rename to examples/netfx/netfx.csproj
index fe60441a..34f92a95 100644
--- a/examples/netcore/netcore.csproj
+++ b/examples/netfx/netfx.csproj
@@ -4,9 +4,10 @@
Exe
- net6.0
+ net48
+ 12
+ x86;x64
3.0.0
- AnyCPU;x64;x86
diff --git a/examples/netfx/readme.md b/examples/netfx/readme.md
new file mode 100644
index 00000000..ade70141
--- /dev/null
+++ b/examples/netfx/readme.md
@@ -0,0 +1,7 @@
+# SFML.Net running on .NET Framework
+
+This project showcases how SFML.Net can be run on .NET Framwork 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).
diff --git a/examples/opengl/OpenGL.cs b/examples/opengl/OpenGL.cs
index 6de548cd..5dbe314f 100644
--- a/examples/opengl/OpenGL.cs
+++ b/examples/opengl/OpenGL.cs
@@ -1,217 +1,218 @@
using System;
using System.Runtime.InteropServices;
+using OpenTK;
using OpenTK.Graphics.OpenGL;
using SFML.Graphics;
using SFML.System;
using SFML.Window;
-namespace opengl
+namespace opengl;
+
+internal static class Program
{
- internal static class Program
+ private sealed class SfmlBindingsContext : IBindingsContext
{
- ///
- /// The main entry point for the application.
- ///
- private static void Main()
+ public IntPtr GetProcAddress(string procName) => Context.GetFunction(procName);
+ }
+
+ ///
+ /// The main entry point for the application.
+ ///
+ private static void Main()
+ {
+ // Request a 24-bits depth buffer when creating the window
+ var contextSettings = new ContextSettings
{
- // NOTE : This is workaround to create a functioning opengl context for OpenTK (for current OpenTK version)
- var gameWindow = new OpenTK.GameWindow();
-
- // Request a 24-bits depth buffer when creating the window
- var contextSettings = new ContextSettings
- {
- DepthBits = 24
- };
-
- // Create the main window
- var window = new RenderWindow(new VideoMode((800, 600)), "SFML graphics with OpenGL", Styles.Default, State.Windowed, contextSettings);
- window.SetVerticalSyncEnabled(true);
-
- // Initialize OpenTK
- // NOTE : next 2 lines are kept from old examples until we resolve proper OpenTK versioning
- //Toolkit.Init();
- //GraphicsContext context = new GraphicsContext(new ContextHandle(IntPtr.Zero), null);
-
- // Setup event handlers
- window.Closed += new EventHandler(OnClosed);
- window.KeyPressed += new EventHandler(OnKeyPressed);
- window.Resized += new EventHandler(OnResized);
-
- // Create a sprite for the background
- var background = new Sprite(new Texture("resources/background.jpg"));
-
- // Create a text to display on top of the OpenGL object
- var text = new Text(new Font("resources/sansation.ttf"), "SFML / OpenGL demo")
- {
- Position = new Vector2f(250, 450),
- FillColor = new SFML.Graphics.Color(255, 255, 255, 170)
- };
-
- // Make the window the active target for OpenGL calls
- _ = window.SetActive();
-
- // Load an OpenGL texture.
- // We could directly use a SFML.Graphics.Texture as an OpenGL texture (with its Bind() member function),
- // but here we want more control on it (generate mipmaps, ...) so we create a new one
- var texture = 0;
- using (var image = new SFML.Graphics.Image("resources/texture.jpg"))
- {
- GL.GenTextures(1, out texture);
- GL.BindTexture(TextureTarget.Texture2D, texture);
- GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)image.Size.X, (int)image.Size.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Pixels);
- GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
- GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
- }
-
- // Enable Z-buffer read and write
- GL.Enable(EnableCap.DepthTest);
- GL.DepthMask(true);
- GL.ClearDepth(1);
-
- // Disable lighting
- GL.Disable(EnableCap.Lighting);
-
- // Configure the viewport (the same size as the window)
- GL.Viewport(0, 0, (int)window.Size.X, (int)window.Size.Y);
-
- // Setup a perspective projection
- GL.MatrixMode(MatrixMode.Projection);
- GL.LoadIdentity();
- var ratio = (float)window.Size.X / window.Size.Y;
- GL.Frustum(-ratio, ratio, -1, 1, 1, 500);
+ DepthBits = 24
+ };
- // Bind the texture
- GL.Enable(EnableCap.Texture2D);
- GL.BindTexture(TextureTarget.Texture2D, texture);
- // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
- var cube = new float[]
- {
- // positions // texture coordinates
- -20, -20, -20, 0, 0,
- -20, 20, -20, 1, 0,
- -20, -20, 20, 0, 1,
- -20, -20, 20, 0, 1,
- -20, 20, -20, 1, 0,
- -20, 20, 20, 1, 1,
-
- 20, -20, -20, 0, 0,
- 20, 20, -20, 1, 0,
- 20, -20, 20, 0, 1,
- 20, -20, 20, 0, 1,
- 20, 20, -20, 1, 0,
- 20, 20, 20, 1, 1,
-
- -20, -20, -20, 0, 0,
- 20, -20, -20, 1, 0,
- -20, -20, 20, 0, 1,
- -20, -20, 20, 0, 1,
- 20, -20, -20, 1, 0,
- 20, -20, 20, 1, 1,
-
- -20, 20, -20, 0, 0,
- 20, 20, -20, 1, 0,
- -20, 20, 20, 0, 1,
- -20, 20, 20, 0, 1,
- 20, 20, -20, 1, 0,
- 20, 20, 20, 1, 1,
-
- -20, -20, -20, 0, 0,
- 20, -20, -20, 1, 0,
- -20, 20, -20, 0, 1,
- -20, 20, -20, 0, 1,
- 20, -20, -20, 1, 0,
- 20, 20, -20, 1, 1,
-
- -20, -20, 20, 0, 0,
- 20, -20, 20, 1, 0,
- -20, 20, 20, 0, 1,
- -20, 20, 20, 0, 1,
- 20, -20, 20, 1, 0,
- 20, 20, 20, 1, 1
- };
-
- // Enable position and texture coordinates vertex components
- GL.EnableClientState(ArrayCap.VertexArray);
- GL.EnableClientState(ArrayCap.TextureCoordArray);
- GL.VertexPointer(3, VertexPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 0));
- GL.TexCoordPointer(2, TexCoordPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 3));
-
- // Disable normal and color vertex components
- GL.DisableClientState(ArrayCap.NormalArray);
- GL.DisableClientState(ArrayCap.ColorArray);
-
- var clock = new Clock();
-
- // Start game loop
- while (window.IsOpen)
- {
- // Process events
- window.DispatchEvents();
-
- // Clear the window
- GL.Clear(ClearBufferMask.DepthBufferBit);
-
- // Draw background
- window.PushGLStates();
- window.Draw(background);
- window.PopGLStates();
-
- // Clear the depth buffer
- GL.Clear(ClearBufferMask.DepthBufferBit);
-
- // We get the position of the mouse cursor, so that we can move the box accordingly
- var x = (Mouse.GetPosition(window).X * 200.0F / window.Size.X) - 100.0F;
- var y = (-Mouse.GetPosition(window).Y * 200.0F / window.Size.Y) + 100.0F;
-
- // Apply some transformations
- GL.MatrixMode(MatrixMode.Modelview);
- GL.LoadIdentity();
- GL.Translate(x, y, -100.0F);
- GL.Rotate(clock.ElapsedTime.AsSeconds() * 50, 1.0F, 0.0F, 0.0F);
- GL.Rotate(clock.ElapsedTime.AsSeconds() * 30, 0.0F, 1.0F, 0.0F);
- GL.Rotate(clock.ElapsedTime.AsSeconds() * 90, 0.0F, 0.0F, 1.0F);
-
- // Draw the cube
- GL.DrawArrays(OpenTK.Graphics.OpenGL.PrimitiveType.Triangles, 0, 36);
-
- // Draw some text on top of our OpenGL object
- window.PushGLStates();
- window.Draw(text);
- window.PopGLStates();
-
- // Finally, display the rendered frame on screen
- window.Display();
- }
-
- // Don't forget to destroy our texture
- GL.DeleteTextures(1, ref texture);
- }
+ // Create the main window
+ var window = new RenderWindow(new VideoMode((800, 600)), "SFML graphics with OpenGL", Styles.Default, State.Windowed, contextSettings);
+ window.SetVerticalSyncEnabled(true);
+
+ // Init OpenTK
+ GL.LoadBindings(new SfmlBindingsContext());
+
+ // Setup event handlers
+ window.Closed += new EventHandler(OnClosed);
+ window.KeyPressed += new EventHandler(OnKeyPressed);
+ window.Resized += new EventHandler(OnResized);
+
+ // Create a sprite for the background
+ var background = new Sprite(new Texture("resources/background.jpg"));
- ///
- /// Function called when the window is closed
- ///
- private static void OnClosed(object sender, EventArgs e)
+ // Create a text to display on top of the OpenGL object
+ var text = new Text(new Font("resources/sansation.ttf"), "SFML / OpenGL demo")
{
- var window = (RenderWindow)sender;
- window.Close();
+ Position = new Vector2f(250, 450),
+ FillColor = new SFML.Graphics.Color(255, 255, 255, 170)
+ };
+
+ // Make the window the active target for OpenGL calls
+ _ = window.SetActive();
+
+ // Load an OpenGL texture.
+ // We could directly use a SFML.Graphics.Texture as an OpenGL texture (with its Bind() member function),
+ // but here we want more control on it (generate mipmaps, ...) so we create a new one
+ var texture = 0;
+ using (var image = new SFML.Graphics.Image("resources/texture.jpg"))
+ {
+ GL.GenTextures(1, out texture);
+ GL.BindTexture(TextureTarget.Texture2D, texture);
+ GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)image.Size.X, (int)image.Size.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Pixels);
+ GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
+ GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
}
- ///
- /// Function called when a key is pressed
- ///
- private static void OnKeyPressed(object sender, KeyEventArgs e)
+ // Enable Z-buffer read and write
+ GL.Enable(EnableCap.DepthTest);
+ GL.DepthMask(true);
+ GL.ClearDepth(1);
+
+ // Disable lighting
+ GL.Disable(EnableCap.Lighting);
+
+ // Configure the viewport (the same size as the window)
+ GL.Viewport(0, 0, (int)window.Size.X, (int)window.Size.Y);
+
+ // Setup a perspective projection
+ GL.MatrixMode(MatrixMode.Projection);
+ GL.LoadIdentity();
+ var ratio = (float)window.Size.X / window.Size.Y;
+ GL.Frustum(-ratio, ratio, -1, 1, 1, 500);
+
+ // Bind the texture
+ GL.Enable(EnableCap.Texture2D);
+ GL.BindTexture(TextureTarget.Texture2D, texture);
+
+ // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
+ var cube = new float[]
+ {
+ // positions // texture coordinates
+ -20, -20, -20, 0, 0,
+ -20, 20, -20, 1, 0,
+ -20, -20, 20, 0, 1,
+ -20, -20, 20, 0, 1,
+ -20, 20, -20, 1, 0,
+ -20, 20, 20, 1, 1,
+
+ 20, -20, -20, 0, 0,
+ 20, 20, -20, 1, 0,
+ 20, -20, 20, 0, 1,
+ 20, -20, 20, 0, 1,
+ 20, 20, -20, 1, 0,
+ 20, 20, 20, 1, 1,
+
+ -20, -20, -20, 0, 0,
+ 20, -20, -20, 1, 0,
+ -20, -20, 20, 0, 1,
+ -20, -20, 20, 0, 1,
+ 20, -20, -20, 1, 0,
+ 20, -20, 20, 1, 1,
+
+ -20, 20, -20, 0, 0,
+ 20, 20, -20, 1, 0,
+ -20, 20, 20, 0, 1,
+ -20, 20, 20, 0, 1,
+ 20, 20, -20, 1, 0,
+ 20, 20, 20, 1, 1,
+
+ -20, -20, -20, 0, 0,
+ 20, -20, -20, 1, 0,
+ -20, 20, -20, 0, 1,
+ -20, 20, -20, 0, 1,
+ 20, -20, -20, 1, 0,
+ 20, 20, -20, 1, 1,
+
+ -20, -20, 20, 0, 0,
+ 20, -20, 20, 1, 0,
+ -20, 20, 20, 0, 1,
+ -20, 20, 20, 0, 1,
+ 20, -20, 20, 1, 0,
+ 20, 20, 20, 1, 1
+ };
+
+ // Enable position and texture coordinates vertex components
+ GL.EnableClientState(ArrayCap.VertexArray);
+ GL.EnableClientState(ArrayCap.TextureCoordArray);
+ GL.VertexPointer(3, VertexPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 0));
+ GL.TexCoordPointer(2, TexCoordPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 3));
+
+ // Disable normal and color vertex components
+ GL.DisableClientState(ArrayCap.NormalArray);
+ GL.DisableClientState(ArrayCap.ColorArray);
+
+ var clock = new Clock();
+
+ // Start game loop
+ while (window.IsOpen)
{
- var window = (RenderWindow)sender;
- if (e.Code == Keyboard.Key.Escape)
- {
- window.Close();
- }
+ // Process events
+ window.DispatchEvents();
+
+ // Clear the window
+ GL.Clear(ClearBufferMask.DepthBufferBit);
+
+ // Draw background
+ window.PushGLStates();
+ window.Draw(background);
+ window.PopGLStates();
+
+ // Clear the depth buffer
+ GL.Clear(ClearBufferMask.DepthBufferBit);
+
+ // We get the position of the mouse cursor, so that we can move the box accordingly
+ var x = (Mouse.GetPosition(window).X * 200.0F / window.Size.X) - 100.0F;
+ var y = (-Mouse.GetPosition(window).Y * 200.0F / window.Size.Y) + 100.0F;
+
+ // Apply some transformations
+ GL.MatrixMode(MatrixMode.Modelview);
+ GL.LoadIdentity();
+ GL.Translate(x, y, -100.0F);
+ GL.Rotate(clock.ElapsedTime.AsSeconds() * 50, 1.0F, 0.0F, 0.0F);
+ GL.Rotate(clock.ElapsedTime.AsSeconds() * 30, 0.0F, 1.0F, 0.0F);
+ GL.Rotate(clock.ElapsedTime.AsSeconds() * 90, 0.0F, 0.0F, 1.0F);
+
+ // Draw the cube
+ GL.DrawArrays(OpenTK.Graphics.OpenGL.PrimitiveType.Triangles, 0, 36);
+
+ // Draw some text on top of our OpenGL object
+ window.PushGLStates();
+ window.Draw(text);
+ window.PopGLStates();
+
+ // Finally, display the rendered frame on screen
+ window.Display();
}
- ///
- /// Function called when the window is resized
- ///
- private static void OnResized(object sender, SizeEventArgs e) => GL.Viewport(0, 0, (int)e.Size.X, (int)e.Size.Y);
+ // Don't forget to destroy our texture
+ GL.DeleteTextures(1, ref texture);
}
-}
+
+ ///
+ /// Function called when the window is closed
+ ///
+ private static void OnClosed(object sender, EventArgs e)
+ {
+ var window = (RenderWindow)sender;
+ window.Close();
+ }
+
+ ///
+ /// Function called when a key is pressed
+ ///
+ private static void OnKeyPressed(object sender, KeyEventArgs e)
+ {
+ var window = (RenderWindow)sender;
+ if (e.Code == Keyboard.Key.Escape)
+ {
+ window.Close();
+ }
+ }
+
+ ///
+ /// Function called when the window is resized
+ ///
+ private static void OnResized(object sender, SizeEventArgs e) => GL.Viewport(0, 0, (int)e.Size.X, (int)e.Size.Y);
+}
\ No newline at end of file
diff --git a/examples/opengl/OpenTK.dll.config b/examples/opengl/OpenTK.dll.config
deleted file mode 100644
index 7098d39e..00000000
--- a/examples/opengl/OpenTK.dll.config
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/opengl/Properties/launchSettings.json b/examples/opengl/Properties/launchSettings.json
deleted file mode 100644
index b87f96f5..00000000
--- a/examples/opengl/Properties/launchSettings.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "profiles": {
- "opengl": {
- "commandName": "Project",
- "nativeDebugging": true
- }
- }
-}
\ No newline at end of file
diff --git a/examples/opengl/opengl.csproj b/examples/opengl/opengl.csproj
index b69babb7..e7926663 100644
--- a/examples/opengl/opengl.csproj
+++ b/examples/opengl/opengl.csproj
@@ -4,16 +4,14 @@
Exe
- net48
- opengl
- opengl
- Debug;Release
+ net8.0
+ 12
+ AnyCPU;x86;x64
3.0.0
- AnyCPU;x64;x86
-
+
diff --git a/examples/opengl/packages.config b/examples/opengl/packages.config
deleted file mode 100644
index 27f307ea..00000000
--- a/examples/opengl/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/examples/shader/Shader.cs b/examples/shader/Shader.cs
index b27fd509..94d852d1 100644
--- a/examples/shader/Shader.cs
+++ b/examples/shader/Shader.cs
@@ -3,388 +3,387 @@
using SFML.System;
using SFML.Window;
-namespace shader
+namespace shader;
+
+/// Base class for effects
+internal abstract class Effect : IDrawable
{
- /// Base class for effects
- internal abstract class Effect : IDrawable
- {
- protected Effect(string name) => Name = name;
+ protected Effect(string name) => Name = name;
- public string Name { get; }
- public void Update(float time, float x, float y)
+ public string Name { get; }
+ public void Update(float time, float x, float y)
+ {
+ if (Shader.IsAvailable)
{
- if (Shader.IsAvailable)
- {
- OnUpdate(time, x, y);
- }
+ OnUpdate(time, x, y);
}
-
- public void Draw(IRenderTarget target, RenderStates states)
- {
- if (Shader.IsAvailable)
- {
- OnDraw(target, states);
- }
- else
- {
- var error = new Text(Font, "Shader not\nsupported")
- {
- Position = new Vector2f(320, 200),
- CharacterSize = 36
- };
- target.Draw(error, states);
- }
- }
-
- protected abstract void OnUpdate(float time, float x, float y);
- protected abstract void OnDraw(IRenderTarget target, RenderStates states);
-
- public static Font Font { get; set; }
}
- /// "Pixelate" fragment shader
- internal class Pixelate : Effect
+ public void Draw(IRenderTarget target, RenderStates states)
{
- public Pixelate() : base("pixelate")
+ if (Shader.IsAvailable)
{
- // Load the texture and initialize the sprite
- _texture = new Texture("resources/background.jpg");
- _sprite = new Sprite(_texture);
-
- // Load the shader
- _shader = new Shader(null, null, "resources/pixelate.frag");
- _shader.SetUniform("texture", Shader.CurrentTexture);
+ OnDraw(target, states);
}
-
- protected override void OnUpdate(float time, float x, float y) => _shader.SetUniform("pixel_threshold", (x + y) / 30);
-
- protected override void OnDraw(IRenderTarget target, RenderStates states)
+ else
{
- states = new RenderStates(states)
+ var error = new Text(Font, "Shader not\nsupported")
{
- Shader = _shader
+ Position = new Vector2f(320, 200),
+ CharacterSize = 36
};
- target.Draw(_sprite, states);
+ target.Draw(error, states);
}
-
- private readonly Texture _texture;
- private readonly Sprite _sprite;
- private readonly Shader _shader;
}
- /// "Wave" vertex shader + "blur" fragment shader
- internal class WaveBlur : Effect
+ protected abstract void OnUpdate(float time, float x, float y);
+ protected abstract void OnDraw(IRenderTarget target, RenderStates states);
+
+ public static Font Font { get; set; }
+}
+
+/// "Pixelate" fragment shader
+internal class Pixelate : Effect
+{
+ public Pixelate() : base("pixelate")
{
- public WaveBlur() : base("wave + blur")
- {
- // Create the text
- _text = new Text(Font)
- {
- DisplayedString = "Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n" +
- "Mauris mi odio, bibendum quis fringilla a, laoreet vel orci. Proin vitae vulputate tortor.\n" +
- "Praesent cursus ultrices justo, ut feugiat ante vehicula quis.\n" +
- "Donec fringilla scelerisque mauris et viverra.\n" +
- "Maecenas adipiscing ornare scelerisque. Nullam at libero elit.\n" +
- "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n" +
- "Nullam leo urna, tincidunt id semper eget, ultricies sed mi.\n" +
- "Morbi mauris massa, commodo id dignissim vel, lobortis et elit.\n" +
- "Fusce vel libero sed neque scelerisque venenatis.\n" +
- "Integer mattis tincidunt quam vitae iaculis.\n" +
- "Vivamus fringilla sem non velit venenatis fermentum.\n" +
- "Vivamus varius tincidunt nisi id vehicula.\n" +
- "Integer ullamcorper, enim vitae euismod rutrum, massa nisl semper ipsum,\n" +
- "vestibulum sodales sem ante in massa.\n" +
- "Vestibulum in augue non felis convallis viverra.\n" +
- "Mauris ultricies dolor sed massa convallis sed aliquet augue fringilla.\n" +
- "Duis erat eros, porta in accumsan in, blandit quis sem.\n" +
- "In hac habitasse platea dictumst. Etiam fringilla est id odio dapibus sit amet semper dui laoreet.\n",
- CharacterSize = 22,
- Position = new Vector2f(30, 20)
- };
+ // Load the texture and initialize the sprite
+ _texture = new Texture("resources/background.jpg");
+ _sprite = new Sprite(_texture);
- // Load the shader
- _shader = new Shader("resources/wave.vert", null, "resources/blur.frag");
- }
+ // Load the shader
+ _shader = new Shader(null, null, "resources/pixelate.frag");
+ _shader.SetUniform("texture", Shader.CurrentTexture);
+ }
+
+ protected override void OnUpdate(float time, float x, float y) => _shader.SetUniform("pixel_threshold", (x + y) / 30);
- protected override void OnUpdate(float time, float x, float y)
+ protected override void OnDraw(IRenderTarget target, RenderStates states)
+ {
+ states = new RenderStates(states)
{
- _shader.SetUniform("wave_phase", time);
- _shader.SetUniform("wave_amplitude", new Vector2f(x * 40, y * 40));
- _shader.SetUniform("blur_radius", (x + y) * 0.008F);
- }
+ Shader = _shader
+ };
+ target.Draw(_sprite, states);
+ }
+
+ private readonly Texture _texture;
+ private readonly Sprite _sprite;
+ private readonly Shader _shader;
+}
- protected override void OnDraw(IRenderTarget target, RenderStates states)
+/// "Wave" vertex shader + "blur" fragment shader
+internal class WaveBlur : Effect
+{
+ public WaveBlur() : base("wave + blur")
+ {
+ // Create the text
+ _text = new Text(Font)
{
- states = new RenderStates(states)
- {
- Shader = _shader
- };
- target.Draw(_text, states);
- }
+ DisplayedString = "Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n" +
+ "Mauris mi odio, bibendum quis fringilla a, laoreet vel orci. Proin vitae vulputate tortor.\n" +
+ "Praesent cursus ultrices justo, ut feugiat ante vehicula quis.\n" +
+ "Donec fringilla scelerisque mauris et viverra.\n" +
+ "Maecenas adipiscing ornare scelerisque. Nullam at libero elit.\n" +
+ "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n" +
+ "Nullam leo urna, tincidunt id semper eget, ultricies sed mi.\n" +
+ "Morbi mauris massa, commodo id dignissim vel, lobortis et elit.\n" +
+ "Fusce vel libero sed neque scelerisque venenatis.\n" +
+ "Integer mattis tincidunt quam vitae iaculis.\n" +
+ "Vivamus fringilla sem non velit venenatis fermentum.\n" +
+ "Vivamus varius tincidunt nisi id vehicula.\n" +
+ "Integer ullamcorper, enim vitae euismod rutrum, massa nisl semper ipsum,\n" +
+ "vestibulum sodales sem ante in massa.\n" +
+ "Vestibulum in augue non felis convallis viverra.\n" +
+ "Mauris ultricies dolor sed massa convallis sed aliquet augue fringilla.\n" +
+ "Duis erat eros, porta in accumsan in, blandit quis sem.\n" +
+ "In hac habitasse platea dictumst. Etiam fringilla est id odio dapibus sit amet semper dui laoreet.\n",
+ CharacterSize = 22,
+ Position = new Vector2f(30, 20)
+ };
+
+ // Load the shader
+ _shader = new Shader("resources/wave.vert", null, "resources/blur.frag");
+ }
- private readonly Text _text;
- private readonly Shader _shader;
+ protected override void OnUpdate(float time, float x, float y)
+ {
+ _shader.SetUniform("wave_phase", time);
+ _shader.SetUniform("wave_amplitude", new Vector2f(x * 40, y * 40));
+ _shader.SetUniform("blur_radius", (x + y) * 0.008F);
}
- /// "Storm" vertex shader + "blink" fragment shader
- internal class StormBlink : Effect
+ protected override void OnDraw(IRenderTarget target, RenderStates states)
{
- public StormBlink() : base("storm + blink")
+ states = new RenderStates(states)
{
- var random = new Random();
+ Shader = _shader
+ };
+ target.Draw(_text, states);
+ }
- // Create the points
- _points = new VertexArray(PrimitiveType.Points);
- for (var i = 0; i < 40000; ++i)
- {
- float x = random.Next(0, 800);
- float y = random.Next(0, 600);
- var r = (byte)random.Next(0, 255);
- var g = (byte)random.Next(0, 255);
- var b = (byte)random.Next(0, 255);
- _points.Append(new Vertex(new Vector2f(x, y), new Color(r, g, b)));
- }
+ private readonly Text _text;
+ private readonly Shader _shader;
+}
- // Load the shader
- _shader = new Shader("resources/storm.vert", null, "resources/blink.frag");
- }
+/// "Storm" vertex shader + "blink" fragment shader
+internal class StormBlink : Effect
+{
+ public StormBlink() : base("storm + blink")
+ {
+ var random = new Random();
- protected override void OnUpdate(float time, float x, float y)
+ // Create the points
+ _points = new VertexArray(PrimitiveType.Points);
+ for (var i = 0; i < 40000; ++i)
{
- var radius = 200 + ((float)Math.Cos(time) * 150);
- _shader.SetUniform("storm_position", new Vector2f(x * 800, y * 600));
- _shader.SetUniform("storm_inner_radius", radius / 3);
- _shader.SetUniform("storm_total_radius", radius);
- _shader.SetUniform("blink_alpha", 0.5F + ((float)Math.Cos(time * 3) * 0.25F));
+ float x = random.Next(0, 800);
+ float y = random.Next(0, 600);
+ var r = (byte)random.Next(0, 255);
+ var g = (byte)random.Next(0, 255);
+ var b = (byte)random.Next(0, 255);
+ _points.Append(new Vertex(new Vector2f(x, y), new Color(r, g, b)));
}
- protected override void OnDraw(IRenderTarget target, RenderStates states)
- {
- states = new RenderStates(states)
- {
- Shader = _shader
- };
- target.Draw(_points, states);
- }
+ // Load the shader
+ _shader = new Shader("resources/storm.vert", null, "resources/blink.frag");
+ }
- private readonly VertexArray _points;
- private readonly Shader _shader;
+ protected override void OnUpdate(float time, float x, float y)
+ {
+ var radius = 200 + ((float)Math.Cos(time) * 150);
+ _shader.SetUniform("storm_position", new Vector2f(x * 800, y * 600));
+ _shader.SetUniform("storm_inner_radius", radius / 3);
+ _shader.SetUniform("storm_total_radius", radius);
+ _shader.SetUniform("blink_alpha", 0.5F + ((float)Math.Cos(time * 3) * 0.25F));
}
- /// "Edge" post-effect fragment shader
- internal class Edge : Effect
+ protected override void OnDraw(IRenderTarget target, RenderStates states)
{
- public Edge() : base("edge post-effect")
+ states = new RenderStates(states)
{
- // Create the off-screen surface
- _surface = new RenderTexture((800, 600))
- {
- Smooth = true
- };
+ Shader = _shader
+ };
+ target.Draw(_points, states);
+ }
- // Load the textures
- _backgroundTexture = new Texture("resources/sfml.png")
- {
- Smooth = true
- };
- _entityTexture = new Texture("resources/devices.png")
- {
- Smooth = true
- };
+ private readonly VertexArray _points;
+ private readonly Shader _shader;
+}
- // Initialize the background sprite
- _backgroundSprite = new Sprite(_backgroundTexture)
- {
- Position = new Vector2f(135, 100)
- };
+/// "Edge" post-effect fragment shader
+internal class Edge : Effect
+{
+ public Edge() : base("edge post-effect")
+ {
+ // Create the off-screen surface
+ _surface = new RenderTexture((800, 600))
+ {
+ Smooth = true
+ };
- // Load the moving entities
- _entities = new Sprite[6];
- for (var i = 0; i < _entities.Length; ++i)
- {
- _entities[i] = new Sprite(_entityTexture, new IntRect((96 * i, 0), (96, 96)));
- }
+ // Load the textures
+ _backgroundTexture = new Texture("resources/sfml.png")
+ {
+ Smooth = true
+ };
+ _entityTexture = new Texture("resources/devices.png")
+ {
+ Smooth = true
+ };
- // Load the shader
- _shader = new Shader(null, null, "resources/edge.frag");
- _shader.SetUniform("texture", Shader.CurrentTexture);
- }
+ // Initialize the background sprite
+ _backgroundSprite = new Sprite(_backgroundTexture)
+ {
+ Position = new Vector2f(135, 100)
+ };
- protected override void OnUpdate(float time, float x, float y)
+ // Load the moving entities
+ _entities = new Sprite[6];
+ for (var i = 0; i < _entities.Length; ++i)
{
- _shader.SetUniform("edge_threshold", 1 - ((x + y) / 2));
+ _entities[i] = new Sprite(_entityTexture, new IntRect((96 * i, 0), (96, 96)));
+ }
- // Update the position of the moving entities
- for (var i = 0; i < _entities.Length; ++i)
- {
- var posX = ((float)Math.Cos(0.25F * ((time * i) + (_entities.Length - i))) * 300) + 350;
- var posY = ((float)Math.Sin(0.25F * ((time * (_entities.Length - i)) + i)) * 200) + 250;
- _entities[i].Position = new Vector2f(posX, posY);
- }
+ // Load the shader
+ _shader = new Shader(null, null, "resources/edge.frag");
+ _shader.SetUniform("texture", Shader.CurrentTexture);
+ }
- // Render the updated scene to the off-screen surface
- _surface.Clear(Color.White);
- _surface.Draw(_backgroundSprite);
- foreach (var entity in _entities)
- {
- _surface.Draw(entity);
- }
+ protected override void OnUpdate(float time, float x, float y)
+ {
+ _shader.SetUniform("edge_threshold", 1 - ((x + y) / 2));
- _surface.Display();
+ // Update the position of the moving entities
+ for (var i = 0; i < _entities.Length; ++i)
+ {
+ var posX = ((float)Math.Cos(0.25F * ((time * i) + (_entities.Length - i))) * 300) + 350;
+ var posY = ((float)Math.Sin(0.25F * ((time * (_entities.Length - i)) + i)) * 200) + 250;
+ _entities[i].Position = new Vector2f(posX, posY);
}
- protected override void OnDraw(IRenderTarget target, RenderStates states)
+ // Render the updated scene to the off-screen surface
+ _surface.Clear(Color.White);
+ _surface.Draw(_backgroundSprite);
+ foreach (var entity in _entities)
{
- states = new RenderStates(states)
- {
- Shader = _shader
- };
- target.Draw(new Sprite(_surface.Texture), states);
+ _surface.Draw(entity);
}
- private readonly RenderTexture _surface;
- private readonly Texture _backgroundTexture;
- private readonly Texture _entityTexture;
- private readonly Sprite _backgroundSprite;
- private readonly Sprite[] _entities;
- private readonly Shader _shader;
+ _surface.Display();
}
- internal static class Program
+ protected override void OnDraw(IRenderTarget target, RenderStates states)
{
- private static Effect[] _effects;
- private static int _current;
- private static Text _description;
-
- ///
- /// The main entry point for the application.
- ///
- private static void Main()
+ states = new RenderStates(states)
{
- // Create the main window
- var window = new RenderWindow(new VideoMode((800, 600)), "SFML.Net Shader");
- window.SetVerticalSyncEnabled(true);
+ Shader = _shader
+ };
+ target.Draw(new Sprite(_surface.Texture), states);
+ }
- // Setup event handlers
- window.Closed += OnClosed;
- window.KeyPressed += OnKeyPressed;
+ private readonly RenderTexture _surface;
+ private readonly Texture _backgroundTexture;
+ private readonly Texture _entityTexture;
+ private readonly Sprite _backgroundSprite;
+ private readonly Sprite[] _entities;
+ private readonly Shader _shader;
+}
- // Load the application font and pass it to the Effect class
- var font = new Font("resources/sansation.ttf");
- Effect.Font = font;
+internal static class Program
+{
+ private static Effect[] _effects;
+ private static int _current;
+ private static Text _description;
+
+ ///
+ /// The main entry point for the application.
+ ///
+ private static void Main()
+ {
+ // Create the main window
+ var window = new RenderWindow(new VideoMode((800, 600)), "SFML.Net Shader");
+ window.SetVerticalSyncEnabled(true);
+
+ // Setup event handlers
+ window.Closed += OnClosed;
+ window.KeyPressed += OnKeyPressed;
+
+ // Load the application font and pass it to the Effect class
+ var font = new Font("resources/sansation.ttf");
+ Effect.Font = font;
+
+ // Create the effects
+ _effects =
+ [
+ new Pixelate(),
+ new WaveBlur(),
+ new StormBlink(),
+ new Edge()
+ ];
+ _current = 0;
+
+ // Create the messages background
+ var textBackgroundTexture = new Texture("resources/text-background.png");
+ var textBackground = new Sprite(textBackgroundTexture)
+ {
+ Position = new Vector2f(0, 520),
+ Color = new Color(255, 255, 255, 200)
+ };
- // Create the effects
- _effects = new Effect[]
- {
- new Pixelate(),
- new WaveBlur(),
- new StormBlink(),
- new Edge()
- };
- _current = 0;
+ // Create the description text
+ _description = new Text(font, "Current effect: " + _effects[_current].Name, 20)
+ {
+ Position = new Vector2f(10, 530),
+ FillColor = new Color(80, 80, 80)
+ };
- // Create the messages background
- var textBackgroundTexture = new Texture("resources/text-background.png");
- var textBackground = new Sprite(textBackgroundTexture)
- {
- Position = new Vector2f(0, 520),
- Color = new Color(255, 255, 255, 200)
- };
+ // Create the instructions text
+ var instructions = new Text(font, "Press left and right arrows to change the current shader", 20)
+ {
+ Position = new Vector2f(280, 555),
+ FillColor = new Color(80, 80, 80)
+ };
- // Create the description text
- _description = new Text(font, "Current effect: " + _effects[_current].Name, 20)
- {
- Position = new Vector2f(10, 530),
- FillColor = new Color(80, 80, 80)
- };
+ // Start the game loop
+ var clock = new Clock();
+ while (window.IsOpen)
+ {
+ // Process events
+ window.DispatchEvents();
- // Create the instructions text
- var instructions = new Text(font, "Press left and right arrows to change the current shader", 20)
- {
- Position = new Vector2f(280, 555),
- FillColor = new Color(80, 80, 80)
- };
+ // Update the current example
+ var x = (float)Mouse.GetPosition(window).X / window.Size.X;
+ var y = (float)Mouse.GetPosition(window).Y / window.Size.Y;
+ _effects[_current].Update(clock.ElapsedTime.AsSeconds(), x, y);
- // Start the game loop
- var clock = new Clock();
- while (window.IsOpen)
- {
- // Process events
- window.DispatchEvents();
+ // Clear the window
+ window.Clear(new Color(255, 128, 0));
- // Update the current example
- var x = (float)Mouse.GetPosition(window).X / window.Size.X;
- var y = (float)Mouse.GetPosition(window).Y / window.Size.Y;
- _effects[_current].Update(clock.ElapsedTime.AsSeconds(), x, y);
+ // Draw the current example
+ window.Draw(_effects[_current]);
- // Clear the window
- window.Clear(new Color(255, 128, 0));
+ // Draw the text
+ window.Draw(textBackground);
+ window.Draw(instructions);
+ window.Draw(_description);
- // Draw the current example
- window.Draw(_effects[_current]);
+ // Finally, display the rendered frame on screen
+ window.Display();
+ }
+ }
- // Draw the text
- window.Draw(textBackground);
- window.Draw(instructions);
- window.Draw(_description);
+ ///
+ /// Function called when the window is closed
+ ///
+ private static void OnClosed(object sender, EventArgs e)
+ {
+ var window = (RenderWindow)sender;
+ window.Close();
+ }
- // Finally, display the rendered frame on screen
- window.Display();
- }
- }
+ ///
+ /// Function called when a key is pressed
+ ///
+ private static void OnKeyPressed(object sender, KeyEventArgs e)
+ {
+ var window = (RenderWindow)sender;
- ///
- /// Function called when the window is closed
- ///
- private static void OnClosed(object sender, EventArgs e)
+ // Escape key : exit
+ if (e.Code == Keyboard.Key.Escape)
{
- var window = (RenderWindow)sender;
window.Close();
}
- ///
- /// Function called when a key is pressed
- ///
- private static void OnKeyPressed(object sender, KeyEventArgs e)
- {
- var window = (RenderWindow)sender;
- // Escape key : exit
- if (e.Code == Keyboard.Key.Escape)
+ // Left arrow key: previous shader
+ if (e.Code == Keyboard.Key.Left)
+ {
+ if (_current == 0)
+ {
+ _current = _effects.Length - 1;
+ }
+ else
{
- window.Close();
+ _current--;
}
+ _description.DisplayedString = $"Current effect: {_effects[_current].Name}";
+ }
- // Left arrow key: previous shader
- if (e.Code == Keyboard.Key.Left)
+ // Right arrow key: next shader
+ if (e.Code == Keyboard.Key.Right)
+ {
+ if (_current == _effects.Length - 1)
{
- if (_current == 0)
- {
- _current = _effects.Length - 1;
- }
- else
- {
- _current--;
- }
-
- _description.DisplayedString = $"Current effect: {_effects[_current].Name}";
+ _current = 0;
}
-
- // Right arrow key: next shader
- if (e.Code == Keyboard.Key.Right)
+ else
{
- if (_current == _effects.Length - 1)
- {
- _current = 0;
- }
- else
- {
- _current++;
- }
-
- _description.DisplayedString = $"Current effect: {_effects[_current].Name}";
+ _current++;
}
+
+ _description.DisplayedString = $"Current effect: {_effects[_current].Name}";
}
}
-}
+}
\ No newline at end of file
diff --git a/examples/shader/shader.csproj b/examples/shader/shader.csproj
index 5aa31985..d5d3523d 100644
--- a/examples/shader/shader.csproj
+++ b/examples/shader/shader.csproj
@@ -4,12 +4,10 @@
Exe
- net48
- shader
- shader
- Debug;Release
+ net8.0
+ 12
+ AnyCPU;x86;x64
3.0.0
- AnyCPU;x64;x86
diff --git a/examples/sound/Sound.cs b/examples/sound/Sound.cs
index 7ea43582..613fe6e5 100644
--- a/examples/sound/Sound.cs
+++ b/examples/sound/Sound.cs
@@ -2,80 +2,79 @@
using System.Threading;
using SFML.Audio;
-namespace sound
+namespace sound;
+
+internal static class Program
{
- internal static class Program
+ ///
+ /// The main entry point for the application.
+ ///
+ private static void Main()
{
- ///
- /// The main entry point for the application.
- ///
- private static void Main()
- {
- // Play a sound
- PlaySound();
- Console.Clear();
+ // Play a sound
+ PlaySound();
+ Console.Clear();
- // Play a music
- PlayMusic();
- }
+ // Play a music
+ PlayMusic();
+ }
- ///
- /// Play a sound
- ///
- private static void PlaySound()
- {
- // Load a sound buffer from a wav file
- var buffer = new SoundBuffer("resources/canary.wav");
+ ///
+ /// Play a sound
+ ///
+ private static void PlaySound()
+ {
+ // Load a sound buffer from a wav file
+ var buffer = new SoundBuffer("resources/canary.wav");
- // Display sound information
- Console.WriteLine("canary.wav :");
- Console.WriteLine(" " + buffer.Duration.AsSeconds() + " sec");
- Console.WriteLine(" " + buffer.SampleRate + " samples / sec");
- Console.WriteLine(" " + buffer.ChannelCount + " channels");
+ // Display sound information
+ Console.WriteLine("canary.wav :");
+ Console.WriteLine(" " + buffer.Duration.AsSeconds() + " sec");
+ Console.WriteLine(" " + buffer.SampleRate + " samples / sec");
+ Console.WriteLine(" " + buffer.ChannelCount + " channels");
- // Create a sound instance and play it
- var sound = new Sound(buffer);
- sound.Play();
+ // Create a sound instance and play it
+ var sound = new Sound(buffer);
+ sound.Play();
- // Loop while the sound is playing
- while (sound.Status == SoundStatus.Playing)
- {
- // Display the playing position
- Console.CursorLeft = 0;
- Console.Write("Playing... " + sound.PlayingOffset.AsSeconds() + " sec ");
+ // Loop while the sound is playing
+ while (sound.Status == SoundStatus.Playing)
+ {
+ // Display the playing position
+ Console.CursorLeft = 0;
+ Console.Write("Playing... " + sound.PlayingOffset.AsSeconds() + " sec ");
- // Leave some CPU time for other processes
- Thread.Sleep(100);
- }
+ // Leave some CPU time for other processes
+ Thread.Sleep(100);
}
+ }
- ///
- /// Play a music
- ///
- private static void PlayMusic()
- {
- // Load an ogg music file
- var music = new Music("resources/orchestral.ogg");
+ ///
+ /// Play a music
+ ///
+ private static void PlayMusic()
+ {
+ // Load an ogg music file
+ var music = new Music("resources/orchestral.ogg");
- // Display music information
- Console.WriteLine("orchestral.ogg :");
- Console.WriteLine(" " + music.Duration.AsSeconds() + " sec");
- Console.WriteLine(" " + music.SampleRate + " samples / sec");
- Console.WriteLine(" " + music.ChannelCount + " channels");
+ // Display music information
+ Console.WriteLine("orchestral.ogg :");
+ Console.WriteLine(" " + music.Duration.AsSeconds() + " sec");
+ Console.WriteLine(" " + music.SampleRate + " samples / sec");
+ Console.WriteLine(" " + music.ChannelCount + " channels");
- // Play it
- music.Play();
+ // Play it
+ music.Play();
- // Loop while the music is playing
- while (music.Status == SoundStatus.Playing)
- {
- // Display the playing position
- Console.CursorLeft = 0;
- Console.Write("Playing... " + music.PlayingOffset.AsSeconds() + " sec ");
+ // Loop while the music is playing
+ while (music.Status == SoundStatus.Playing)
+ {
+ // Display the playing position
+ Console.CursorLeft = 0;
+ Console.Write("Playing... " + music.PlayingOffset.AsSeconds() + " sec ");
- // Leave some CPU time for other processes
- Thread.Sleep(100);
- }
+ // Leave some CPU time for other processes
+ Thread.Sleep(100);
}
}
-}
+}
\ No newline at end of file
diff --git a/examples/sound/sound.csproj b/examples/sound/sound.csproj
index 9d3c6fb8..be0d01fe 100644
--- a/examples/sound/sound.csproj
+++ b/examples/sound/sound.csproj
@@ -4,12 +4,10 @@
Exe
- net48
- sound
- sound
- Debug;Release
+ net8.0
+ 12
+ AnyCPU;x86;x64
3.0.0
- AnyCPU;x64;x86
diff --git a/examples/sound_capture/SoundCapture.cs b/examples/sound_capture/SoundCapture.cs
index 961ab67b..1326a91c 100644
--- a/examples/sound_capture/SoundCapture.cs
+++ b/examples/sound_capture/SoundCapture.cs
@@ -2,81 +2,86 @@
using System.Threading;
using SFML.Audio;
-namespace sound_capture
+namespace sound_capture;
+
+internal static class Program
{
- internal static class Program
+ ///
+ /// The main entry point for the application.
+ ///
+ private static void Main()
{
- ///
- /// The main entry point for the application.
- ///
- private static void Main()
+ // Check that the device can capture audio
+ if (!SoundRecorder.IsAvailable)
{
- // Check that the device can capture audio
- if (!SoundRecorder.IsAvailable)
- {
- Console.WriteLine("Sorry, audio capture is not supported by your system");
- return;
- }
+ Console.WriteLine("Sorry, audio capture is not supported by your system");
+ return;
+ }
- // Choose the sample rate
+ // Choose the sample rate
+ uint sampleRate;
+ do
+ {
Console.WriteLine("Please choose the sample rate for sound capture (44100 is CD quality) : ");
- var sampleRate = uint.Parse(Console.ReadLine());
+ } while (!uint.TryParse(Console.ReadLine(), out sampleRate));
- // Wait for user input...
- Console.WriteLine("Press enter to start recording audio");
- _ = Console.ReadLine();
+ // Wait for user input...
+ Console.WriteLine("Press enter to start recording audio");
+ _ = Console.ReadLine();
- // Here we'll use an integrated custom recorder, which saves the captured data into a SoundBuffer
- var recorder = new SoundBufferRecorder();
+ // Here we'll use an integrated custom recorder, which saves the captured data into a SoundBuffer
+ var recorder = new SoundBufferRecorder();
- // Audio capture is done in a separate thread, so we can block the main thread while it is capturing
- _ = recorder.Start(sampleRate);
- Console.WriteLine("Recording... press enter to stop");
- _ = Console.ReadLine();
- recorder.Stop();
+ // Audio capture is done in a separate thread, so we can block the main thread while it is capturing
+ _ = recorder.Start(sampleRate);
+ Console.WriteLine("Recording... press enter to stop");
+ _ = Console.ReadLine();
+ recorder.Stop();
- // Get the buffer containing the captured data
- var buffer = recorder.SoundBuffer;
+ // Get the buffer containing the captured data
+ var buffer = recorder.SoundBuffer;
- // Display captured sound information
- Console.WriteLine("Sound information :");
- Console.WriteLine(" " + buffer.Duration + " seconds");
- Console.WriteLine(" " + buffer.SampleRate + " samples / seconds");
- Console.WriteLine(" " + buffer.ChannelCount + " channels");
+ // Display captured sound information
+ Console.WriteLine("Sound information :");
+ Console.WriteLine(" " + buffer.Duration + " seconds");
+ Console.WriteLine(" " + buffer.SampleRate + " samples / seconds");
+ Console.WriteLine(" " + buffer.ChannelCount + " channels");
- // Choose what to do with the recorded sound data
+ // Choose what to do with the recorded sound data
+ char choice;
+ do
+ {
Console.WriteLine("What do you want to do with captured sound (p = play, s = save) ? ");
- var choice = char.Parse(Console.ReadLine());
+ } while (!char.TryParse(Console.ReadLine(), out choice));
- if (choice == 's')
- {
- // Choose the filename
- Console.WriteLine("Choose the file to create : ");
- var filename = Console.ReadLine();
+ if (choice == 's')
+ {
+ // Choose the filename
+ Console.WriteLine("Choose the file to create : ");
+ var filename = Console.ReadLine();
- // Save the buffer
- _ = buffer.SaveToFile(filename);
- }
- else
- {
- // Create a sound instance and play it
- var sound = new Sound(buffer);
- sound.Play();
+ // Save the buffer
+ _ = buffer.SaveToFile(filename);
+ }
+ else
+ {
+ // Create a sound instance and play it
+ var sound = new Sound(buffer);
+ sound.Play();
- // Wait until finished
- while (sound.Status == SoundStatus.Playing)
- {
- // Display the playing position
- Console.CursorLeft = 0;
- Console.Write("Playing... " + sound.PlayingOffset + " sec ");
+ // Wait until finished
+ while (sound.Status == SoundStatus.Playing)
+ {
+ // Display the playing position
+ Console.CursorLeft = 0;
+ Console.Write("Playing... " + sound.PlayingOffset.AsSeconds() + " sec ");
- // Leave some CPU time for other threads
- Thread.Sleep(100);
- }
+ // Leave some CPU time for other threads
+ Thread.Sleep(100);
}
-
- // Finished !
- Console.WriteLine("\nDone !");
}
+
+ // Finished !
+ Console.WriteLine("\nDone !");
}
-}
+}
\ No newline at end of file
diff --git a/examples/sound_capture/sound_capture.csproj b/examples/sound_capture/sound_capture.csproj
index c5a900e4..307c65f4 100644
--- a/examples/sound_capture/sound_capture.csproj
+++ b/examples/sound_capture/sound_capture.csproj
@@ -4,12 +4,10 @@
Exe
- net48
- sound_capture
- sound_capture
- Debug;Release
+ net8.0
+ 12
+ AnyCPU;x86;x64
3.0.0
- AnyCPU;x64;x86
diff --git a/examples/visualbasic/My Project/Application.Designer.vb b/examples/visualbasic/My Project/Application.Designer.vb
deleted file mode 100644
index 88dd01c7..00000000
--- a/examples/visualbasic/My Project/Application.Designer.vb
+++ /dev/null
@@ -1,13 +0,0 @@
-'------------------------------------------------------------------------------
-'
-' This code was generated by a tool.
-' Runtime Version:4.0.30319.42000
-'
-' Changes to this file may cause incorrect behavior and will be lost if
-' the code is regenerated.
-'
-'------------------------------------------------------------------------------
-
-Option Strict On
-Option Explicit On
-
diff --git a/examples/visualbasic/My Project/Application.myapp b/examples/visualbasic/My Project/Application.myapp
deleted file mode 100644
index e62f1a53..00000000
--- a/examples/visualbasic/My Project/Application.myapp
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- false
- false
- 0
- true
- 0
- 2
- true
-
diff --git a/examples/visualbasic/My Project/AssemblyInfo.vb b/examples/visualbasic/My Project/AssemblyInfo.vb
deleted file mode 100644
index f831d3ff..00000000
--- a/examples/visualbasic/My Project/AssemblyInfo.vb
+++ /dev/null
@@ -1,34 +0,0 @@
-Imports System.Reflection
-Imports System.Runtime.InteropServices
-
-' General Information about an assembly is controlled through the following
-' set of attributes. Change these attribute values to modify the information
-' associated with an assembly.
-
-' Review the values of the assembly attributes
-
-
-
-
-
-
-
-
-
-
-'The following GUID is for the ID of the typelib if this project is exposed to COM
-
-
-' Version information for an assembly consists of the following four values:
-'
-' Major Version
-' Minor Version
-' Build Number
-' Revision
-'
-' You can specify all the values or you can default the Build and Revision Numbers
-' by using the '*' as shown below:
-'
-
-
-
diff --git a/examples/visualbasic/My Project/Resources.Designer.vb b/examples/visualbasic/My Project/Resources.Designer.vb
deleted file mode 100644
index e738ea55..00000000
--- a/examples/visualbasic/My Project/Resources.Designer.vb
+++ /dev/null
@@ -1,63 +0,0 @@
-'------------------------------------------------------------------------------
-'
-' This code was generated by a tool.
-' Runtime Version:4.0.30319.42000
-'
-' Changes to this file may cause incorrect behavior and will be lost if
-' the code is regenerated.
-'
-'------------------------------------------------------------------------------
-
-Option Strict On
-Option Explicit On
-
-Imports System
-
-Namespace My.Resources
-
- 'This class was auto-generated by the StronglyTypedResourceBuilder
- 'class via a tool like ResGen or Visual Studio.
- 'To add or remove a member, edit your .ResX file then rerun ResGen
- 'with the /str option, or rebuild your VS project.
- '''
- ''' A strongly-typed resource class, for looking up localized strings, etc.
- '''
- _
- Friend Module Resources
-
- Private resourceMan As Global.System.Resources.ResourceManager
-
- Private resourceCulture As Global.System.Globalization.CultureInfo
-
- '''
- ''' Returns the cached ResourceManager instance used by this class.
- '''
- _
- Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
- Get
- If Object.ReferenceEquals(resourceMan, Nothing) Then
- Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("visualbasic.Resources", GetType(Resources).Assembly)
- resourceMan = temp
- End If
- Return resourceMan
- End Get
- End Property
-
- '''
- ''' Overrides the current thread's CurrentUICulture property for all
- ''' resource lookups using this strongly typed resource class.
- '''
- _
- Friend Property Culture() As Global.System.Globalization.CultureInfo
- Get
- Return resourceCulture
- End Get
- Set
- resourceCulture = value
- End Set
- End Property
- End Module
-End Namespace
diff --git a/examples/visualbasic/My Project/Resources.resx b/examples/visualbasic/My Project/Resources.resx
deleted file mode 100644
index af7dbebb..00000000
--- a/examples/visualbasic/My Project/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/examples/visualbasic/My Project/Settings.Designer.vb b/examples/visualbasic/My Project/Settings.Designer.vb
deleted file mode 100644
index 7696185c..00000000
--- a/examples/visualbasic/My Project/Settings.Designer.vb
+++ /dev/null
@@ -1,73 +0,0 @@
-'------------------------------------------------------------------------------
-'
-' This code was generated by a tool.
-' Runtime Version:4.0.30319.42000
-'
-' Changes to this file may cause incorrect behavior and will be lost if
-' the code is regenerated.
-'
-'------------------------------------------------------------------------------
-
-Option Strict On
-Option Explicit On
-
-
-Namespace My
-
- _
- Partial Friend NotInheritable Class MySettings
- Inherits Global.System.Configuration.ApplicationSettingsBase
-
- Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
-
-#Region "My.Settings Auto-Save Functionality"
-#If _MyType = "WindowsForms" Then
- Private Shared addedHandler As Boolean
-
- Private Shared addedHandlerLockObject As New Object
-
- _
- Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
- If My.Application.SaveMySettingsOnExit Then
- My.Settings.Save()
- End If
- End Sub
-#End If
-#End Region
-
- Public Shared ReadOnly Property [Default]() As MySettings
- Get
-
-#If _MyType = "WindowsForms" Then
- If Not addedHandler Then
- SyncLock addedHandlerLockObject
- If Not addedHandler Then
- AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
- addedHandler = True
- End If
- End SyncLock
- End If
-#End If
- Return defaultInstance
- End Get
- End Property
- End Class
-End Namespace
-
-Namespace My
-
- _
- Friend Module MySettingsProperty
-
- _
- Friend ReadOnly Property Settings() As Global.visualbasic.My.MySettings
- Get
- Return Global.visualbasic.My.MySettings.Default
- End Get
- End Property
- End Module
-End Namespace
diff --git a/examples/visualbasic/My Project/Settings.settings b/examples/visualbasic/My Project/Settings.settings
deleted file mode 100644
index 85b890b3..00000000
--- a/examples/visualbasic/My Project/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/examples/visualbasic/OpenGL.vb b/examples/visualbasic/OpenGL.vb
index 58c81539..cde3cb84 100644
--- a/examples/visualbasic/OpenGL.vb
+++ b/examples/visualbasic/OpenGL.vb
@@ -1,12 +1,22 @@
Imports System.Runtime.InteropServices
+Imports OpenTK
Imports SFML.System
Imports SFML.Window
Imports SFML.Graphics
-Imports OpenTK
-Imports OpenTK.Graphics
Imports OpenTk.Graphics.OpenGL
Friend Module OpenGL
+ Private Class SfmlBindingsContext
+ Implements IBindingsContext
+
+ Public Function GetProcAddress(procName As String) As IntPtr _
+ Implements IBindingsContext.GetProcAddress
+
+ Return Context.GetFunction(procName)
+ End Function
+
+ End Class
+
Private WithEvents window As RenderWindow
'''
@@ -24,8 +34,7 @@ Friend Module OpenGL
window.SetVerticalSyncEnabled(True)
' Initialize OpenTK
- Dim unused1 = Toolkit.Init()
- Dim context As New GraphicsContext(New ContextHandle(IntPtr.Zero), Nothing)
+ GL.LoadBindings(New SfmlBindingsContext())
' Create a sprite for the background
Dim background = New Sprite(New Texture("resources/background.jpg"))
diff --git a/examples/visualbasic/visualbasic.vbproj b/examples/visualbasic/visualbasic.vbproj
index 17e73b70..4f743041 100644
--- a/examples/visualbasic/visualbasic.vbproj
+++ b/examples/visualbasic/visualbasic.vbproj
@@ -1,15 +1,11 @@
-
+
- net48
- WinExe
+ net8.0
+ Exe
visualbasic.OpenGL
- WindowsFormsWithCustomSubMain
- false
- true
- true
+ AnyCPU;x86;x64
3.0.0
- AnyCPU;x64;x86
visualbasic.xml
@@ -43,27 +39,6 @@
-
- True
- Application.myapp
- True
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
-
-
- MyApplicationCodeGenerator
- Application.Designer.vb
-
PreserveNewest
@@ -75,7 +50,7 @@
-
+
diff --git a/examples/window/Program.cs b/examples/window/Program.cs
index 55585075..09490a86 100644
--- a/examples/window/Program.cs
+++ b/examples/window/Program.cs
@@ -1,54 +1,54 @@
using System;
-namespace window_core
+namespace window;
+
+internal static class Program
{
- internal static class Program
+ private static void Main()
{
- private static void Main()
- {
- Console.WriteLine("Press ESC key to close window");
- var window = new SimpleWindow();
- window.Run();
+ Console.WriteLine("Press ESC key to close window");
+ var window = new SimpleWindow();
+ window.Run();
- Console.WriteLine("All done");
- }
+ Console.WriteLine("All done");
}
+}
- internal class SimpleWindow
+internal class SimpleWindow
+{
+ public void Run()
{
- public void Run()
+ var mode = new SFML.Window.VideoMode((800, 600));
+ var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");
+ window.KeyPressed += Window_KeyPressed;
+ window.Closed += (_, _) => window.Close();
+
+ var circle = new SFML.Graphics.CircleShape(100f)
{
- var mode = new SFML.Window.VideoMode((800, 600));
- var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");
- window.KeyPressed += Window_KeyPressed;
-
- var circle = new SFML.Graphics.CircleShape(100f)
- {
- FillColor = SFML.Graphics.Color.Blue
- };
-
- // Start the game loop
- while (window.IsOpen)
- {
- // Process events
- window.DispatchEvents();
- window.Draw(circle);
-
- // Finally, display the rendered frame on screen
- window.Display();
- }
+ FillColor = SFML.Graphics.Color.Blue
+ };
+
+ // Start the game loop
+ while (window.IsOpen)
+ {
+ // Process events
+ window.DispatchEvents();
+ window.Draw(circle);
+
+ // Finally, display the rendered frame on screen
+ window.Display();
}
+ }
- ///
- /// Function called when a key is pressed
- ///
- private void Window_KeyPressed(object sender, SFML.Window.KeyEventArgs e)
+ ///
+ /// Function called when a key is pressed
+ ///
+ private void Window_KeyPressed(object sender, SFML.Window.KeyEventArgs e)
+ {
+ var window = (SFML.Window.Window)sender;
+ if (e.Code == SFML.Window.Keyboard.Key.Escape)
{
- var window = (SFML.Window.Window)sender;
- if (e.Code == SFML.Window.Keyboard.Key.Escape)
- {
- window.Close();
- }
+ window.Close();
}
}
-}
+}
\ No newline at end of file
diff --git a/examples/window/window.csproj b/examples/window/window.csproj
index 4d01af7c..2307de8c 100644
--- a/examples/window/window.csproj
+++ b/examples/window/window.csproj
@@ -4,12 +4,10 @@
Exe
- net48
- window
- window
- Debug;Release
+ net8.0
+ 12
+ AnyCPU;x86;x64
3.0.0
- AnyCPU;x64;x86