From 13d959cb4d32622b75433edb145522f7c3d8768a Mon Sep 17 00:00:00 2001
From: Redhacker1 <66490743+Redhacker1@users.noreply.github.com>
Date: Fri, 5 Aug 2022 14:54:02 -0500
Subject: [PATCH 1/6] Start of windowing implementation
Implements "Stub" windowing API, the framework is there, but the meat and potatoes are not currently implemented
---
Silk.NET.sln | 3 +
.../Abstract/ContextFlags.cs | 26 +++
.../Abstract/ContextProfile.cs | 19 ++
.../Silk.Net.Windowing/Abstract/Delegates.cs | 8 +
.../Abstract/IDesktopSurface.cs | 150 ++++++++++++++++
.../Abstract/IGLDesktopSurface.cs | 5 +
.../Silk.Net.Windowing/Abstract/IGLSurface.cs | 17 ++
.../IGLTransparentFramebufferSurface.cs | 8 +
.../Abstract/IGlesDesktopSurface.cs | 7 +
.../Abstract/IGlesSurface.cs | 11 ++
.../Abstract/INativeGLSurface.cs | 56 ++++++
.../Silk.Net.Windowing/Abstract/IScreen.cs | 44 +++++
.../Silk.Net.Windowing/Abstract/ISurface.cs | 162 ++++++++++++++++++
.../Abstract/IVkDesktopSurface.cs | 30 ++++
.../Silk.Net.Windowing/Abstract/IVkSurface.cs | 6 +
.../Abstract/IWindowHandlesSource.cs | 7 +
.../Silk.Net.Windowing/Abstract/RawImage.cs | 83 +++++++++
.../Silk.Net.Windowing/Abstract/Surface.cs | 20 +++
.../Abstract/SurfaceExtensions.cs | 59 +++++++
.../Silk.Net.Windowing/Abstract/Version32.cs | 70 ++++++++
.../Silk.Net.Windowing/Abstract/VideoMode.cs | 32 ++++
.../Abstract/WindowBorder.cs | 23 +++
.../Abstract/WindowHandles.cs | 11 ++
.../Abstract/WindowState.cs | 28 +++
.../Implementations/GLFW/GLFWSurface.cs | 88 ++++++++++
.../Silk.Net.Windowing.csproj | 13 ++
26 files changed, 986 insertions(+)
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
create mode 100644 src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
diff --git a/Silk.NET.sln b/Silk.NET.sln
index 85eb610c5c..f97abc2d9b 100644
--- a/Silk.NET.sln
+++ b/Silk.NET.sln
@@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libraries", "libraries", "{
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Maths", "src\libraries\Silk.NET.Maths\Silk.NET.Maths.csproj", "{7A2A3176-DBA1-4026-AF65-8E36B4F09B01}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Windowing", "src\libraries\Silk.NET.Windowing\Silk.NET.Windowing.csproj", "{7A2A3176-DBA1-4026-AF65-8E36B4F09B02}"
+EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{FD15E196-1C63-47D6-8AD5-64F015120B4B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "infrastructure", "infrastructure", "{F07CABFC-DC6A-4B5B-BC56-B10EEC2C0BFA}"
@@ -361,6 +363,7 @@ Global
{5329AC43-7177-4953-AFAB-A9FA7B9A4C7C} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
{66FE736C-C407-44C3-A94E-4345E22AA95E} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
{381D1039-3259-488F-BB25-D90EE63A3E82} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
+ {7A2A3176-DBA1-4026-AF65-8E36B4F09B02} = {C9718C94-2F21-4E8D-B55D-8F0B1A131346}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
new file mode 100644
index 0000000000..03b0ba1da6
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
@@ -0,0 +1,26 @@
+namespace Silk.NET.Windowing
+{
+ ///
+ /// Represents flags related to the OpenGL context.
+ ///
+ [Flags]
+ public enum ContextFlags
+ {
+ ///
+ /// No flags enabled.
+ ///
+ Default = 0,
+
+ ///
+ /// Enables debug context; debug contexts provide more debugging info, but can run slower.
+ ///
+ Debug = 1,
+
+ ///
+ /// Enables forward compatability; this context won't support anything marked as deprecated in the current
+ /// version.
+ ///
+ /// On OpenGL contexts older than 3.0, this flag does nothing.
+ ForwardCompatible = 2
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
new file mode 100644
index 0000000000..4aee8c408d
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
@@ -0,0 +1,19 @@
+namespace Silk.NET.Windowing
+{
+ ///
+ /// Represents the context profile OpenGL should use.
+ ///
+ public enum ContextProfile
+ {
+ ///
+ /// Uses a core OpenGL context, which removes some deprecated functionality.
+ ///
+ Core = 0,
+
+ ///
+ /// Uses a compatability OpenGL context, allowing for some deprecated functionality. This should only ever be
+ /// used for maintaining legacy code; no newly-written software should use this.
+ ///
+ Compatability
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
new file mode 100644
index 0000000000..75d40e9876
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
@@ -0,0 +1,8 @@
+using Silk.NET.Maths;
+using Silk.NET.Windowing;
+
+public delegate void Vector2DAction(Vector2D newValue);
+public delegate void DeltaAction(double deltaTime);
+public delegate void WindowStateAction(WindowState newState);
+public delegate void FilePathsAction(string[] filePaths);
+public delegate void ToggleAction(bool newValue);
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
new file mode 100644
index 0000000000..9f2fc1c094
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
@@ -0,0 +1,150 @@
+using Silk.NET.Core;
+using Silk.NET.Maths;
+
+namespace Silk.NET.Windowing
+{
+ ///
+ /// A surface which wraps a Desktop Window.
+ ///
+ public interface IDesktopSurface : ISurface
+ {
+ ///
+ /// Whether or not the window is visible.
+ ///
+ bool IsVisible { get; set; }
+
+ ///
+ /// The position of the window. If set to -1, use the backend default.
+ ///
+ Vector2D Position { get; set; }
+
+ ///
+ /// The size of the window in pixels.
+ ///
+ new Vector2D Size { get; set; }
+
+ ///
+ /// The window title.
+ ///
+ string Title { get; set; }
+
+ ///
+ /// The window state.
+ ///
+ WindowState WindowState { get; set; }
+
+ ///
+ /// The window border.
+ ///
+ WindowBorder WindowBorder { get; set; }
+
+ ///
+ /// The video mode.
+ ///
+ VideoMode VideoMode { get; set; }
+
+ ///
+ /// Gets the screen on which this window is active.
+ ///
+ IScreen? CurrentScreen { get; set; }
+
+ ///
+ /// Gets the available screens for this surface.
+ ///
+ IEnumerable? AvailableScreens { get; }
+
+ ///
+ /// Gets or sets whether the window waits for an event to be posted before existing .
+ ///
+ bool IsEventDriven { get; set; }
+
+ ///
+ /// Gets or sets whether the window has been requested to close.
+ ///
+ bool IsCloseRequested { get; set; }
+
+ ///
+ /// Gets whether the window is focused or not.
+ ///
+ bool IsFocused { get; }
+
+ ///
+ /// Gets the distances in screen coordinates from the edges of the content area to the corresponding edges of
+ /// the full window.
+ ///
+ ///
+ /// Because these are distances and not coordinates, they are always zero or positive.
+ ///
+ ///
+ Rectangle BorderSize { get; }
+
+ ///
+ /// Raised when the window has been requested to close.
+ ///
+ event Action CloseRequested;
+
+ ///
+ /// Raised when the window is moved.
+ ///
+ event Vector2DAction? Move;
+
+ ///
+ /// Raised when the window state is changed.
+ ///
+ event WindowStateAction? StateChanged;
+
+ ///
+ /// Raised when the user drops files onto the window.
+ ///
+ event FilePathsAction? FileDrop;
+
+ ///
+ /// Raised when the window focus changes.
+ ///
+ event ToggleAction? FocusChanged;
+
+ ///
+ /// Sets the window icons.
+ ///
+ /// Either a collection of window icons, or null to set to the default icon.
+ void SetWindowIcon(ReadOnlySpan icons)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// When using = true, wakes the main thread from
+ /// its blocking wait on incoming events. Can be called from any thread.
+ ///
+ void ContinueEvents()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Converts this point to client coordinates.
+ ///
+ /// The point to transform.
+ /// The transformed point.
+ /// Expects screen coordinates as input.
+ Vector2D PointToClient(Vector2D point)
+ {
+ return new Vector2D(point.X - Position.X, point.Y - Position.Y);
+ }
+
+ ///
+ /// Converts this point to screen coordinates.
+ ///
+ /// The point to transform.
+ /// The transformed point.
+ /// Expects client coordinates as input.
+ Vector2D PointToScreen(Vector2D point)
+ {
+ return new Vector2D(point.X + Position.X, point.Y + Position.Y);
+ }
+ public Vector2D PointToFramebuffer(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
new file mode 100644
index 0000000000..4ca2956fb2
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
@@ -0,0 +1,5 @@
+
+namespace Silk.NET.Windowing
+{
+ public interface IGLDesktopSurface : IDesktopSurface, IGLSurface { }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
new file mode 100644
index 0000000000..bfae8bd52c
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
@@ -0,0 +1,17 @@
+namespace Silk.NET.Windowing
+{
+ public interface IGLSurface : INativeGLSurface
+ {
+ ContextFlags ContextFlags { get; set; }
+ ContextProfile ContextProfile { get; set; }
+ IGLSurface? SharedContext { get; set; }
+
+ ///
+ /// Enables OpenGL support for this surface. This will create a surface upon initialization.
+ ///
+ bool TryEnableOpenGL()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
new file mode 100644
index 0000000000..0dfeeff8b0
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
@@ -0,0 +1,8 @@
+
+namespace Silk.NET.Windowing
+{
+ public interface IGLTransparentFramebuffer : INativeGLSurface
+ {
+ bool TransparentFramebuffer { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
new file mode 100644
index 0000000000..58ff9afece
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
@@ -0,0 +1,7 @@
+namespace Silk.NET.Windowing
+{
+ public interface IGlesDesktopSurface : IDesktopSurface, IGlesSurface
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
new file mode 100644
index 0000000000..22ab3f2966
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
@@ -0,0 +1,11 @@
+namespace Silk.NET.Windowing
+{
+ public interface IGlesSurface : INativeGLSurface
+ {
+ IGlesSurface? SharedContext { get; set; }
+ ///
+ /// Enables OpenGLES support for this surface. This will create a surface upon initialization.
+ ///
+ bool TryEnableOpenGLES();
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
new file mode 100644
index 0000000000..9208ecc56d
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
@@ -0,0 +1,56 @@
+using Silk.NET.Core;
+using Silk.NET.Maths;
+
+namespace Silk.NET.Windowing
+{
+ public interface INativeGLSurface : ISurface
+ {
+ nint Handle { get; }
+ bool IsContextCurrent { get; set; }
+ bool ShouldSwapAutomatically { get; set; }
+
+ ///
+ /// Sets the number of vertical blanks to wait between calling and presenting the image,
+ /// a.k.a vertical synchronization (V-Sync). Set to 1 to enable V-Sync.
+ ///
+ ///
+ /// Due to platform restrictions, this value can only be set and not retrieved.
+ ///
+ int SwapInterval { set; }
+
+ ///
+ /// Preferred depth buffer bits of the window's framebuffer.
+ ///
+ ///
+ /// Pass null or -1 to use the system default.
+ ///
+ int? PreferredDepthBufferBits { get; set; }
+
+ ///
+ /// Preferred stencil buffer bits of the window's framebuffer.
+ ///
+ ///
+ /// Pass null or -1 to use the system default.
+ ///
+ int? PreferredStencilBufferBits { get; set; }
+
+ ///
+ /// Preferred red, green, blue, and alpha bits of the window's framebuffer.
+ ///
+ ///
+ /// Pass null or -1 for any of the channels to use the system default.
+ ///
+ Vector4D? PreferredBitDepth { get; set; }
+
+ ///
+ /// The API version to use.
+ ///
+ Version32? ApiVersion { get; set; }
+
+ nint? GetProcAddress(string proc);
+ void SwapBuffers()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
new file mode 100644
index 0000000000..8f512cf73b
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
@@ -0,0 +1,44 @@
+using Silk.NET.Maths;
+
+namespace Silk.NET.Windowing
+{
+ ///
+ /// An interface representing a screen.
+ ///
+ public interface IScreen
+ {
+ ///
+ /// The name of this screen.
+ ///
+ string Name { get; }
+
+ ///
+ /// The index of this screen.
+ ///
+ int Index { get; }
+
+ ///
+ /// The workarea of this screen.
+ ///
+ Rectangle WorkArea { get; }
+
+ ///
+ /// The current video mode of this monitor.
+ ///
+ VideoMode VideoMode { get; }
+
+ ///
+ /// This screen's gamma correction.
+ ///
+ float Gamma { get; set; }
+
+ ///
+ /// Get all video modes that this screen supports.
+ ///
+ /// An array of all video modes.
+ IEnumerable GetAllVideoModes()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
new file mode 100644
index 0000000000..16844b2599
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
@@ -0,0 +1,162 @@
+using Silk.NET.Core;
+using Silk.NET.Maths;
+
+namespace Silk.NET.Windowing
+{
+ public interface ISurface : IWindowHandlesSource, IDisposable
+ {
+ ///
+ /// Determines whether the surface is being destroyed by the platform.
+ ///
+ bool IsTerminating { get; }
+
+ ///
+ /// Determines whether the surface is being paused by the platform.
+ ///
+ bool IsPausing { get; }
+
+ ///
+ /// Elapsed time in seconds since the Run method last started.
+ ///
+ double Time { get; }
+
+ ///
+ /// The size of the surface's inner framebuffer. May differ from the surface size.
+ ///
+ // NB: This is not OpenGL specific and is valid in any case where there's a high DPI monitor.
+ Vector2D FramebufferSize { get; }
+
+ ///
+ /// The size of the surface.
+ ///
+ Vector2D Size { get; }
+
+ ///
+ /// The number of rendering operations to run every second.
+ ///
+ double FramesPerSecond { get; set; }
+
+ ///
+ /// The number of update operations to run every second.
+ ///
+ double UpdatesPerSecond { get; set; }
+
+ ///
+ /// Raised when the surface is resized.
+ ///
+ event Vector2DAction? Resize;
+
+ ///
+ /// Raised when the surface's framebuffer is resized.
+ ///
+ event Vector2DAction? FramebufferResize;
+
+ ///
+ /// Raised when the surface is being terminated.
+ ///
+ event Action? Terminating;
+
+ ///
+ /// Raised when the surface is running low on memory.
+ ///
+ event Action? LowMemory;
+
+ ///
+ /// Raised when the surface is about to pause. This is a good indicator that the Run method is about to exit, though this may not necessarily be the case, but the surface isn't terminating yet.
+ ///
+ event Action? Pausing;
+
+ ///
+ /// Raised when the surface is about to resume. This is a good indicator to expect the entry point to be called again, though this may not necessarily be the case.
+ ///
+ event Action? Resuming;
+
+ ///
+ /// Raised when the surface is initialized for the first time.
+ ///
+ event Action? Created;
+
+ ///
+ /// Raised just before the Update event is raised.
+ ///
+ event Action? PreUpdate;
+
+ ///
+ /// Raised when an update should be run.
+ ///
+ event DeltaAction? Update;
+
+ ///
+ /// Raised when a frame should be rendered.
+ ///
+ event DeltaAction? Render;
+
+ ///
+ /// Creates the surface on the underlying platform.
+ ///
+ void Initialize()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Calls the Render event.
+ ///
+ void DoRender()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Calls the Update event.
+ ///
+ void DoUpdate()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Polls the underlying platform for events.
+ ///
+ void DoEvents()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Unloads the surface on the underlying platform.
+ ///
+ void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Terminates this surface.
+ ///
+ void Terminate()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Converts this point to framebuffer coordinates.
+ ///
+ /// The point to transform.
+ /// The transformed point.
+ /// Expects client coordinates as input.
+ Vector2D PointToFramebuffer(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Initiates a render loop in which the given callback is called as fast as the underlying platform can manage.
+ ///
+ /// The callback to run each frame.
+ void Run(Action onFrame)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
new file mode 100644
index 0000000000..348380ea34
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
@@ -0,0 +1,30 @@
+
+namespace Silk.NET.Windowing
+{
+ public interface IVkSurface : ISurface
+ {
+ /// Enables Vulkan support for this surface.
+ bool TryEnableVulkan();
+
+ ///
+ /// Create a Vulkan surface.
+ ///
+ /// The Vulkan instance to create a surface for.
+ /// A custom Vulkan allocator. Can be omitted by passing null.
+ /// A handle to the Vulkan surface created
+ unsafe ulong Create(nint instance, void* allocator)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Get the extensions required for Vulkan to work on this platform.
+ ///
+ /// The number of extensions in the returned array
+ /// An array of strings, containing names for all required extensions
+ unsafe byte** GetRequiredExtensions(out uint count)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
new file mode 100644
index 0000000000..43f71131d6
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
@@ -0,0 +1,6 @@
+using Silk.NET.Core.Contexts;
+
+namespace Silk.NET.Windowing
+{
+ public interface IVkDesktopSurface : IDesktopSurface, IVkSurface { }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
new file mode 100644
index 0000000000..49fa6b37f9
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
@@ -0,0 +1,7 @@
+namespace Silk.NET.Core
+{
+ public interface IWindowHandlesSource
+ {
+ WindowHandles Native { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
new file mode 100644
index 0000000000..039b5eddff
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
@@ -0,0 +1,83 @@
+
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Core
+{
+ ///
+ /// Represents loaded, uncompressed, processed image data.
+ ///
+ public readonly struct RawImage : IEquatable
+ {
+ ///
+ /// Creates a given pixel data and pixel dimensions.
+ ///
+ /// The width of the image.
+ /// The height of the image.
+ /// The image daqta.
+ public RawImage(int width, int height, Memory rgbaPixels)
+ {
+ Pixels = rgbaPixels;
+ Width = width;
+ Height = height;
+ }
+
+ ///
+ /// The width of the image in pixels
+ ///
+ public int Width { get; }
+ ///
+ /// The height of the image in pixels.
+ ///
+ public int Height { get; }
+
+ ///
+ /// The image data.
+ ///
+ public Memory Pixels { get; }
+
+ ///
+ /// Checks whether the two given s are equal.
+ ///
+ /// The first raw image.
+ /// The second raw image to compare the first against.
+ /// True if they are equal, false otherwise.
+ ///
+ /// This does not check whether the byte arrays are equal, only whether their references are the same.
+ ///
+ public static bool operator ==(RawImage left, RawImage right) => left.Equals(right);
+
+ ///
+ /// Checks whether the two given s are not equal.
+ ///
+ /// The first raw image.
+ /// The second raw image to compare the first against.
+ /// True if they are not equal, false otherwise.
+ ///
+ /// This does not check whether the byte arrays are equal, only whether their references are the same.
+ ///
+ public static bool operator !=(RawImage left, RawImage right) => !(left == right);
+
+ ///
+ /// Checks whether the given is equal to this one.
+ ///
+ /// The raw image to compare this raw image against.
+ /// True if they are equal, false otherwise.
+ ///
+ /// This does not check whether the byte arrays have equal, only whether their references are the same.
+ ///
+ public bool Equals(RawImage other)
+ {
+ // Apparently it is not needed to compare height? IDK, kai said not to.
+ return Width == other.Width && Equals(Pixels, other.Pixels);
+ }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ return obj is RawImage other && Equals(other);
+ }
+
+ ///
+ public override int GetHashCode() => HashCode.Combine(Width, Height, Pixels);
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
new file mode 100644
index 0000000000..f9fa119e79
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
@@ -0,0 +1,20 @@
+namespace Silk.NET.Windowing
+{
+ public static class Surface
+ {
+ public static bool IsPlatformSupported { get => throw new NotImplementedException(); }
+
+ public static ISurface GetOrCreate()
+ {
+ throw new NotImplementedException();
+ }
+ public static ISurface CreateNew()
+ {
+ throw new NotImplementedException();
+ }
+ public static void ClearCurrentContexts()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
new file mode 100644
index 0000000000..1fe824cf2e
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
@@ -0,0 +1,59 @@
+using Silk.NET.Core;
+using Silk.NET.Maths;
+
+namespace Silk.NET.Windowing
+{
+ ///
+ /// Extensions for ISurface
+ ///
+ public static class SurfaceExtensions
+ {
+ ///
+ /// Start the default event loop on this surface.
+ ///
+ /// The surface to begin the loop on.
+ public static void Run(this ISurface surface)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Gets the full size of the given window including its borders.
+ ///
+ /// The window to get size information from.
+ /// The full size of the window (including both content area and borders)
+ public static Vector2D GetFullSize(this IDesktopSurface window)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Centers this window to the given monitor or, if null, the current monitor the window's on.
+ ///
+ /// The window to center.
+ /// The specific screen to center the window to, if any.
+ public static void Center(this IDesktopSurface window, IScreen? screen = null)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Sets the window icon to default on the given window.
+ ///
+ /// The window.
+ public static void SetDefaultIcon(this IDesktopSurface window)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Sets a single window icon on the given window.
+ ///
+ /// The window.
+ /// The icon to set.
+ public static void SetWindowIcon(this IDesktopSurface window, ref RawImage icon)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs b/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
new file mode 100644
index 0000000000..5e76997f9b
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
@@ -0,0 +1,70 @@
+
+using System;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Core
+{
+ ///
+ /// A 32-bit version structure.
+ ///
+ public readonly struct Version32
+ {
+ ///
+ /// The underlying Vulkan-compatible 32-bit version integer.
+ ///
+ public uint Value { get; }
+ ///
+ /// Creates a Vulkan version structure from the given major, minor, and patch values.
+ ///
+ /// The major value.
+ /// The minor value.
+ /// The patch value.
+ public Version32(uint major, uint minor, uint patch) => Value = major << 22 | minor << 12 | patch;
+ ///
+ /// Creates a Vulkan version structure from the given Vulkan-compatible value.
+ ///
+ /// The value.
+ private Version32(uint value) => Value = value;
+ ///
+ /// Gets the major component of this version structure.
+ ///
+ public uint Major => Value >> 22;
+ ///
+ /// Gets the minor component of this version structure.
+ ///
+ public uint Minor => (Value >> 12) & 0x3ff;
+ ///
+ /// Gets the patch component of this version structure.
+ ///
+ public uint Patch => Value & 0xfff;
+ ///
+ /// Creates a 32-bit version structure from the given 32-bit unsigned integer.
+ ///
+ /// The uint value.
+ /// The 32-bit version structure.
+ public static explicit operator Version32(uint val) => new Version32(val);
+
+ ///
+ /// Creates a 32-bit version structure from the given managed version class.
+ ///
+ /// The version instance.
+ /// The 32-bit version structure.
+ public static implicit operator Version32
+ (Version version) => new Version32((uint) version.Major, (uint) version.Minor, (uint) version.Build);
+
+ ///
+ /// Gets the 32-bit unsigned integer representation for this 32-bit version structure.
+ ///
+ /// The 32-bit version structure.
+ /// The 32-bit unsigned integer.
+ public static implicit operator uint(Version32 version) => version.Value;
+
+ ///
+ /// Converts this 32-bit version structure to a managed version class.
+ ///
+ /// The 32-bit version structure.
+ /// The managed representation.
+ public static implicit operator Version
+ (Version32 version) => new Version((int) version.Major, (int) version.Minor, (int) version.Patch);
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
new file mode 100644
index 0000000000..c4e97ab052
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
@@ -0,0 +1,32 @@
+using Silk.NET.Maths;
+
+namespace Silk.NET.Windowing
+{
+ public readonly struct VideoMode
+ {
+ public VideoMode(Vector2D? resolution = null, int? refreshRate = null)
+ {
+ throw new NotImplementedException();
+ }
+
+ public VideoMode(int? refreshRate)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Resolution of the full screen window.
+ ///
+ public Vector2D? Resolution { get; init; }
+
+ ///
+ /// Refresh rate of the full screen window in Hz.
+ ///
+ public int? RefreshRate { get; init; }
+
+ ///
+ /// The default video mode. This uses the window size for resolution and doesn't care about other values.
+ ///
+ public static VideoMode Default { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
new file mode 100644
index 0000000000..204237168c
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
@@ -0,0 +1,23 @@
+namespace Silk.NET.Windowing
+{
+ ///
+ /// Represents the window border.
+ ///
+ public enum WindowBorder
+ {
+ ///
+ /// The window can be resized by clicking and dragging its border.
+ ///
+ Resizable = 0,
+
+ ///
+ /// The window border is visible, but cannot be resized. All window-resizings must happen solely in the code.
+ ///
+ Fixed,
+
+ ///
+ /// The window border is hidden.
+ ///
+ Hidden
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
new file mode 100644
index 0000000000..1135289ef4
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
@@ -0,0 +1,11 @@
+using System.Runtime.InteropServices;
+
+namespace Silk.NET.Core
+{
+ [StructLayout(LayoutKind.Auto)]
+ public struct WindowHandles
+ {
+ public bool IsSupported { get; }
+ // ...
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
new file mode 100644
index 0000000000..71737bff2c
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
@@ -0,0 +1,28 @@
+namespace Silk.NET.Windowing
+{
+ ///
+ /// Represents the current state of the window.
+ ///
+ public enum WindowState
+ {
+ ///
+ /// The window is in its regular configuration.
+ ///
+ Normal = 0,
+
+ ///
+ /// The window has been minimized to the task bar.
+ ///
+ Minimized,
+
+ ///
+ /// The window has been maximized, covering the entire desktop, but not the taskbar.
+ ///
+ Maximized,
+
+ ///
+ /// The window has been fullscreened, covering the entire surface of the monitor.
+ ///
+ Fullscreen
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
new file mode 100644
index 0000000000..d4131474c0
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
@@ -0,0 +1,88 @@
+using Silk.NET.Core;
+using Silk.NET.Maths;
+
+namespace Silk.NET.Windowing.Implementations.GLFW;
+
+public class GLFWSurface : IGLTransparentFramebuffer, IGlesDesktopSurface, IVkDesktopSurface, IGLDesktopSurface
+{
+ IGlesSurface? _sharedContext;
+ IGLSurface? _sharedContext1;
+ public WindowHandles Native { get; }
+ public void Dispose()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsTerminating { get; }
+ public bool IsPausing { get; }
+ public double Time { get; }
+ public Vector2D FramebufferSize { get; }
+ public bool IsVisible { get; set; }
+ public Vector2D Position { get; set; }
+ public Vector2D Size { get; set; }
+ public string Title { get; set; }
+ public WindowState WindowState { get; set; }
+ public WindowBorder WindowBorder { get; set; }
+ public VideoMode VideoMode { get; set; }
+ public IScreen? CurrentScreen { get; set; }
+ public IEnumerable? AvailableScreens { get; }
+ public bool IsEventDriven { get; set; }
+ public bool IsCloseRequested { get; set; }
+ public bool IsFocused { get; }
+ public Rectangle BorderSize { get; }
+ public event Action? CloseRequested;
+ public event Vector2DAction? Move;
+ public event WindowStateAction? StateChanged;
+ public event FilePathsAction? FileDrop;
+ public event ToggleAction? FocusChanged;
+ public double FramesPerSecond { get; set; }
+ public double UpdatesPerSecond { get; set; }
+ public event Vector2DAction? Resize;
+ public event Vector2DAction? FramebufferResize;
+ public event Action? Terminating;
+ public event Action? LowMemory;
+ public event Action? Pausing;
+ public event Action? Resuming;
+ public event Action? Created;
+ public event Action? PreUpdate;
+ public event DeltaAction? Update;
+ public event DeltaAction? Render;
+ public nint Handle { get; }
+ public bool IsContextCurrent { get; set; }
+ public bool ShouldSwapAutomatically { get; set; }
+ public int SwapInterval { get; set; }
+ public int? PreferredDepthBufferBits { get; set; }
+ public int? PreferredStencilBufferBits { get; set; }
+ public Vector4D? PreferredBitDepth { get; set; }
+ public Version32? ApiVersion { get; set; }
+ public nint? GetProcAddress(string proc)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool TransparentFramebuffer { get; set; }
+ public ContextFlags ContextFlags { get; set; }
+ public ContextProfile ContextProfile { get; set; }
+
+ IGLSurface? IGLSurface.SharedContext
+ {
+ get => _sharedContext1;
+ set => _sharedContext1 = value;
+ }
+
+ IGlesSurface? IGlesSurface.SharedContext
+ {
+ get => _sharedContext;
+ set => _sharedContext = value;
+ }
+
+ public bool TryEnableOpenGLES()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool TryEnableVulkan()
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
new file mode 100644
index 0000000000..818681a097
--- /dev/null
+++ b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
@@ -0,0 +1,13 @@
+
+
+
+ $(SilkTargetFramework)
+ enable
+ true
+ true
+ true
+ 9.0
+
+ true
+
+
From 118fc0c058d910f810486837237f47791aaea814 Mon Sep 17 00:00:00 2001
From: Redhacker1 <66490743+Redhacker1@users.noreply.github.com>
Date: Sun, 7 Aug 2022 10:28:07 -0500
Subject: [PATCH 2/6] Made to mostly compile, added docs (Getting MSB4057 RN)
---
.../Abstract => Silk.NET.Core}/Version32.cs | 44 +-
.../Abstract/ContextFlags.cs | 8 +-
.../Abstract/ContextProfile.cs | 6 +-
.../Silk.Net.Windowing/Abstract/Delegates.cs | 23 +-
.../Abstract/IDesktopSurface.cs | 38 +-
.../Abstract/IGLDesktopSurface.cs | 8 +-
.../Silk.Net.Windowing/Abstract/IGLSurface.cs | 25 +-
.../IGLTransparentFramebufferSurface.cs | 12 +-
.../Abstract/IGlesDesktopSurface.cs | 9 +-
.../Abstract/IGlesSurface.cs | 14 +-
.../Abstract/INativeGLSurface.cs | 20 +-
.../Silk.Net.Windowing/Abstract/IScreen.cs | 14 +-
.../Silk.Net.Windowing/Abstract/ISurface.cs | 50 +-
.../Abstract/IVkDesktopSurface.cs | 18 +-
.../Silk.Net.Windowing/Abstract/IVkSurface.cs | 9 +-
.../Abstract/IWindowHandlesSource.cs | 12 +-
.../Silk.Net.Windowing/Abstract/RawImage.cs | 13 +-
.../Silk.Net.Windowing/Abstract/Surface.cs | 28 +-
.../Abstract/SurfaceExtensions.cs | 11 +-
.../Silk.Net.Windowing/Abstract/VideoMode.cs | 19 +-
.../Abstract/WindowBorder.cs | 6 +-
.../Abstract/WindowHandles.cs | 10 +-
.../Abstract/WindowState.cs | 6 +-
.../Implementations/GLFW/GLFWSurface.cs | 501 +++++++++++++++---
.../Silk.Net.Windowing.csproj | 6 +
25 files changed, 695 insertions(+), 215 deletions(-)
rename src/libraries/{Silk.Net.Windowing/Abstract => Silk.NET.Core}/Version32.cs (59%)
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs b/src/libraries/Silk.NET.Core/Version32.cs
similarity index 59%
rename from src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
rename to src/libraries/Silk.NET.Core/Version32.cs
index 5e76997f9b..511759222e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
+++ b/src/libraries/Silk.NET.Core/Version32.cs
@@ -1,7 +1,6 @@
-
-using System;
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System;
namespace Silk.NET.Core
{
///
@@ -13,18 +12,45 @@ public readonly struct Version32
/// The underlying Vulkan-compatible 32-bit version integer.
///
public uint Value { get; }
+
///
/// Creates a Vulkan version structure from the given major, minor, and patch values.
///
- /// The major value.
- /// The minor value.
- /// The patch value.
- public Version32(uint major, uint minor, uint patch) => Value = major << 22 | minor << 12 | patch;
+ /// The major value. It is a 3-bit integer
+ /// The major value. It is a 7-bit integer
+ /// The minor value. It is a 10-bit integer
+ /// The patch value. It is a 12-bit integer
+ /// major, minor, or patch were out of the range of valid values
+ public Version32(uint variant, uint major, uint minor, uint patch)
+ {
+ /*The variant is a 3-bit integer packed into bits 31-29. -Donovan/Redhacker1, Why is this not used?
+
+ The major version is a 7-bit integer packed into bits 28-22. 2^7 = 128
+
+ The minor version number is a 10-bit integer packed into bits 21-12. 2^10 = 1024
+
+ The patch version number is a 12-bit integer packed into bits 11-0. 2^12 = 4096
+ */
+ // Sanity check to ensure that the values are correct
+ if ( (variant & uint.MaxValue - 7) != 0 || (major & uint.MaxValue - 127) != 0 || (minor & uint.MaxValue - 1023) != 0 || (patch & uint.MaxValue - 4095) != 0)
+ {
+ throw new ArgumentOutOfRangeException("variant, major, minor and/or patch were out of range, ");
+ }
+
+
+ Value = (variant & 7) << 29 | (major & 127) << 22 | (minor & 1023) << 12 | (patch & 4095);
+ }
+
///
/// Creates a Vulkan version structure from the given Vulkan-compatible value.
///
/// The value.
private Version32(uint value) => Value = value;
+
+ ///
+ /// Gets the variant component of this version structure.
+ ///
+ public uint Variant => Value >> 29;
///
/// Gets the major component of this version structure.
///
@@ -50,7 +76,7 @@ public readonly struct Version32
/// The version instance.
/// The 32-bit version structure.
public static implicit operator Version32
- (Version version) => new Version32((uint) version.Major, (uint) version.Minor, (uint) version.Build);
+ (Version version) => new Version32(0, (uint) version.Major, (uint) version.Minor, (uint) version.Build);
///
/// Gets the 32-bit unsigned integer representation for this 32-bit version structure.
@@ -67,4 +93,4 @@ public static implicit operator Version32
public static implicit operator Version
(Version32 version) => new Version((int) version.Major, (int) version.Minor, (int) version.Patch);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
index 03b0ba1da6..8440f28660 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
@@ -1,4 +1,8 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+
+namespace Silk.NET.Windowing
{
///
/// Represents flags related to the OpenGL context.
@@ -23,4 +27,4 @@ public enum ContextFlags
/// On OpenGL contexts older than 3.0, this flag does nothing.
ForwardCompatible = 2
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
index 4aee8c408d..843792235e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
@@ -1,4 +1,6 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
///
/// Represents the context profile OpenGL should use.
@@ -16,4 +18,4 @@ public enum ContextProfile
///
Compatability
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
index 75d40e9876..967ccdaac2 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
@@ -1,8 +1,27 @@
-using Silk.NET.Maths;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using Silk.NET.Maths;
using Silk.NET.Windowing;
+//TODO: Copy proposal explanation as to why we are doing this, also other than Vector2DAction these names are HIGHLY specialized for no apparently good reason, I am not a fan.
+///
+/// An action that takes a
+///
public delegate void Vector2DAction(Vector2D newValue);
+
+///
+/// An action that takes a double as a parameter
+///
public delegate void DeltaAction(double deltaTime);
+///
+/// An action that takes a
+///
public delegate void WindowStateAction(WindowState newState);
+///
+/// An action that takes a list of strings as a parameter, intended for file path callbacks
+///
public delegate void FilePathsAction(string[] filePaths);
-public delegate void ToggleAction(bool newValue);
\ No newline at end of file
+///
+/// An action that takes a bool as a parameter, intended for a callback when things are toggled.
+///
+public delegate void ToggleAction(bool newValue);
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
index 9f2fc1c094..50daddd1f6 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
@@ -1,4 +1,8 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using System.Collections.Generic;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
@@ -54,7 +58,7 @@ public interface IDesktopSurface : ISurface
IEnumerable? AvailableScreens { get; }
///
- /// Gets or sets whether the window waits for an event to be posted before existing .
+ /// Gets or sets whether the window waits for an event to be posted before existing .
///
bool IsEventDriven { get; set; }
@@ -75,7 +79,7 @@ public interface IDesktopSurface : ISurface
///
/// Because these are distances and not coordinates, they are always zero or positive.
///
- ///
+ ///
Rectangle BorderSize { get; }
///
@@ -107,19 +111,13 @@ public interface IDesktopSurface : ISurface
/// Sets the window icons.
///
/// Either a collection of window icons, or null to set to the default icon.
- void SetWindowIcon(ReadOnlySpan icons)
- {
- throw new NotImplementedException();
- }
+ void SetWindowIcon(ReadOnlySpan icons);
///
- /// When using = true, wakes the main thread from
+ /// When using = true, wakes the main thread from
/// its blocking wait on incoming events. Can be called from any thread.
///
- void ContinueEvents()
- {
- throw new NotImplementedException();
- }
+ void ContinueEvents();
///
/// Converts this point to client coordinates.
@@ -127,10 +125,7 @@ void ContinueEvents()
/// The point to transform.
/// The transformed point.
/// Expects screen coordinates as input.
- Vector2D PointToClient(Vector2D point)
- {
- return new Vector2D(point.X - Position.X, point.Y - Position.Y);
- }
+ Vector2D PointToClient(Vector2D point);
///
/// Converts this point to screen coordinates.
@@ -138,13 +133,6 @@ Vector2D PointToClient(Vector2D point)
/// The point to transform.
/// The transformed point.
/// Expects client coordinates as input.
- Vector2D PointToScreen(Vector2D point)
- {
- return new Vector2D(point.X + Position.X, point.Y + Position.Y);
- }
- public Vector2D PointToFramebuffer(Vector2D point)
- {
- throw new NotImplementedException();
- }
+ Vector2D PointToScreen(Vector2D point);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
index 4ca2956fb2..f024ed15a9 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
@@ -1,5 +1,9 @@
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// An interface that defines a desktop surface with the ability to create a desktop GL Context
+ ///
public interface IGLDesktopSurface : IDesktopSurface, IGLSurface { }
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
index bfae8bd52c..07e9d75b1a 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
@@ -1,17 +1,28 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
+ ///
+ /// A surface that can have a desktop GL context.
+ ///
public interface IGLSurface : INativeGLSurface
{
+ ///
+ /// The flags the context was created with
+ ///
ContextFlags ContextFlags { get; set; }
+ ///
+ /// The profile of the specified context.
+ ///
ContextProfile ContextProfile { get; set; }
- IGLSurface? SharedContext { get; set; }
+ ///
+ /// The surface representing the context to use.
+ ///
+ IGLSurface? SharedContext { get; set; } // Redhacker1/Donovan: DAFUQ? What exactly is supposed to be going on here
///
/// Enables OpenGL support for this surface. This will create a surface upon initialization.
///
- bool TryEnableOpenGL()
- {
- throw new NotImplementedException();
- }
+ bool TryEnableOpenGL();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
index 0dfeeff8b0..90157a7d37 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
@@ -1,8 +1,16 @@
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a GL Surface with a transparent Framebuffer
+ ///
+ // Is GLFW making this an optional feature worth adding this? -Donovan/Redhacker1
public interface IGLTransparentFramebuffer : INativeGLSurface
{
+ ///
+ /// Whether the buffer can be actually transparent
+ ///
bool TransparentFramebuffer { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
index 58ff9afece..76253f9e0f 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
@@ -1,7 +1,12 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
+ ///
+ /// A Desktop Surface with the ability to create a GLES surface
+ ///
public interface IGlesDesktopSurface : IDesktopSurface, IGlesSurface
{
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
index 22ab3f2966..73dcaa930e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
@@ -1,11 +1,19 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
+ ///
+ /// Defines a surface that can have a GLES context attatched
+ ///
public interface IGlesSurface : INativeGLSurface
{
- IGlesSurface? SharedContext { get; set; }
+ ///
+ /// The surface representing the context to use.
+ ///
+ IGlesSurface? SharedContext { get; set; } // Donovan/Redhacker1: How on earth is this supposed to work?
///
/// Enables OpenGLES support for this surface. This will create a surface upon initialization.
///
bool TryEnableOpenGLES();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
index 9208ecc56d..056545ab77 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
@@ -1,12 +1,23 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
public interface INativeGLSurface : ISurface
{
+ ///
+ /// the GL Handle
+ ///
nint Handle { get; }
+ ///
+ /// Whether this is the currently running context on this thread
+ ///
bool IsContextCurrent { get; set; }
+ ///
+ /// Should the buffers swap immediately upon completion?
+ ///
bool ShouldSwapAutomatically { get; set; }
///
@@ -48,9 +59,6 @@ public interface INativeGLSurface : ISurface
Version32? ApiVersion { get; set; }
nint? GetProcAddress(string proc);
- void SwapBuffers()
- {
- throw new NotImplementedException();
- }
+ void SwapBuffers();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
index 8f512cf73b..c81da687df 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
@@ -1,9 +1,12 @@
-using Silk.NET.Maths;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System.Collections.Generic;
+using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
///
- /// An interface representing a screen.
+ /// An interface representing a screen
///
public interface IScreen
{
@@ -36,9 +39,6 @@ public interface IScreen
/// Get all video modes that this screen supports.
///
/// An array of all video modes.
- IEnumerable GetAllVideoModes()
- {
- throw new NotImplementedException();
- }
+ IEnumerable GetAllVideoModes();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
index 16844b2599..cf35541fef 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
@@ -1,8 +1,14 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a surface with a framebuffer on which to draw on.
+ ///
public interface ISurface : IWindowHandlesSource, IDisposable
{
///
@@ -94,50 +100,32 @@ public interface ISurface : IWindowHandlesSource, IDisposable
///
/// Creates the surface on the underlying platform.
///
- void Initialize()
- {
- throw new NotImplementedException();
- }
+ void Initialize();
///
/// Calls the Render event.
///
- void DoRender()
- {
- throw new NotImplementedException();
- }
+ void DoRender();
///
/// Calls the Update event.
///
- void DoUpdate()
- {
- throw new NotImplementedException();
- }
+ void DoUpdate();
///
/// Polls the underlying platform for events.
///
- void DoEvents()
- {
- throw new NotImplementedException();
- }
+ void DoEvents();
///
/// Unloads the surface on the underlying platform.
///
- void Reset()
- {
- throw new NotImplementedException();
- }
+ void Reset();
///
/// Terminates this surface.
///
- void Terminate()
- {
- throw new NotImplementedException();
- }
+ void Terminate();
///
/// Converts this point to framebuffer coordinates.
@@ -145,18 +133,12 @@ void Terminate()
/// The point to transform.
/// The transformed point.
/// Expects client coordinates as input.
- Vector2D PointToFramebuffer(Vector2D point)
- {
- throw new NotImplementedException();
- }
+ Vector2D PointToFramebuffer(Vector2D point);
///
/// Initiates a render loop in which the given callback is called as fast as the underlying platform can manage.
///
/// The callback to run each frame.
- void Run(Action onFrame)
- {
- throw new NotImplementedException();
- }
+ void Run(Action onFrame);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
index 348380ea34..1aeb549a91 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
@@ -1,6 +1,10 @@
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a surface with Vulkan support
+ ///
public interface IVkSurface : ISurface
{
/// Enables Vulkan support for this surface.
@@ -12,19 +16,13 @@ public interface IVkSurface : ISurface
/// The Vulkan instance to create a surface for.
/// A custom Vulkan allocator. Can be omitted by passing null.
/// A handle to the Vulkan surface created
- unsafe ulong Create(nint instance, void* allocator)
- {
- throw new NotImplementedException();
- }
+ unsafe ulong Create(nint instance, void* allocator);
///
/// Get the extensions required for Vulkan to work on this platform.
///
/// The number of extensions in the returned array
/// An array of strings, containing names for all required extensions
- unsafe byte** GetRequiredExtensions(out uint count)
- {
- throw new NotImplementedException();
- }
+ unsafe byte** GetRequiredExtensions(out uint count);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
index 43f71131d6..be3056d659 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
@@ -1,6 +1,9 @@
-using Silk.NET.Core.Contexts;
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a desktop surface with Vulkan support
+ ///
public interface IVkDesktopSurface : IDesktopSurface, IVkSurface { }
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
index 49fa6b37f9..3dab0d04e8 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
@@ -1,7 +1,15 @@
-namespace Silk.NET.Core
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Core
{
+ ///
+ /// Represents something that has access to a window handle
+ ///
public interface IWindowHandlesSource
{
+ ///
+ /// The native handles this window could possibly have, the .Net foundation reserves the right to append to this list as they see fit
+ ///
WindowHandles Native { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
index 039b5eddff..9ae1a5b028 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
@@ -1,6 +1,7 @@
-
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+
namespace Silk.NET.Core
{
///
@@ -14,7 +15,7 @@ namespace Silk.NET.Core
/// The width of the image.
/// The height of the image.
/// The image daqta.
- public RawImage(int width, int height, Memory rgbaPixels)
+ public RawImage(int width, int height, ReadOnlyMemory rgbaPixels)
{
Pixels = rgbaPixels;
Width = width;
@@ -33,7 +34,7 @@ public RawImage(int width, int height, Memory rgbaPixels)
///
/// The image data.
///
- public Memory Pixels { get; }
+ public ReadOnlyMemory Pixels { get; }
///
/// Checks whether the two given s are equal.
@@ -72,7 +73,7 @@ public bool Equals(RawImage other)
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return obj is RawImage other && Equals(other);
}
@@ -80,4 +81,4 @@ public override bool Equals(object obj)
///
public override int GetHashCode() => HashCode.Combine(Width, Height, Pixels);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
index f9fa119e79..1a9b7deb4e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
@@ -1,20 +1,44 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+namespace Silk.NET.Windowing
{
+ ///
+ /// A factory that creates and/or gets surfaces.
+ ///
public static class Surface
{
+ ///
+ /// Whether the platform is supported by any backend of of Silk.Net.Windowing.
+ ///
+ ///
public static bool IsPlatformSupported { get => throw new NotImplementedException(); }
+ ///
+ /// Gets a surface if a surface already exist, if it does then return said surface.
+ ///
+ /// an object.
+ // Does this return null on IsPlatformSupported is false? Does it throw? Should it return a bool indicating whether it returned an existing surface or created a new one?
public static ISurface GetOrCreate()
{
throw new NotImplementedException();
}
+ ///
+ /// Creates an regardless as to whether one already exists
+ ///
+ /// an object.
+ // Does this return null on IsPlatformSupported is false? Does it throw? Should it return a bool indicating whether it returned an existing surface or created a new one?
public static ISurface CreateNew()
{
throw new NotImplementedException();
}
+
+ ///
+ /// Clears the contexts of ALL objects.
+ ///
public static void ClearCurrentContexts()
{
throw new NotImplementedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
index 1fe824cf2e..56a1dc6887 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
@@ -1,4 +1,7 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
@@ -11,7 +14,7 @@ public static class SurfaceExtensions
///
/// Start the default event loop on this surface.
///
- /// The surface to begin the loop on.
+ /// The surface to begin the loop on.
public static void Run(this ISurface surface)
{
throw new NotImplementedException();
@@ -51,9 +54,9 @@ public static void SetDefaultIcon(this IDesktopSurface window)
///
/// The window.
/// The icon to set.
- public static void SetWindowIcon(this IDesktopSurface window, ref RawImage icon)
+ public static void SetWindowIcon(this IDesktopSurface window, RawImage icon)
{
throw new NotImplementedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
index c4e97ab052..7a3a18d24b 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
@@ -1,14 +1,29 @@
-using Silk.NET.Maths;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a screens supported refresh rate and resolution
+ ///
public readonly struct VideoMode
{
+ ///
+ /// Creates a with a resolution and refreshRate parameter.
+ ///
+ /// The dimensions of the VideoMode in question
+ /// How many times per second the screen refreshes
public VideoMode(Vector2D? resolution = null, int? refreshRate = null)
{
throw new NotImplementedException();
}
+ ///
+ /// Creates a with a refreshRate parameter.
+ ///
+ /// How many times per second the screen refreshes
public VideoMode(int? refreshRate)
{
throw new NotImplementedException();
@@ -29,4 +44,4 @@ public VideoMode(int? refreshRate)
///
public static VideoMode Default { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
index 204237168c..d29db0e943 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
@@ -1,4 +1,6 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
///
/// Represents the window border.
@@ -20,4 +22,4 @@ public enum WindowBorder
///
Hidden
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
index 1135289ef4..63d5c1839d 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
@@ -1,11 +1,17 @@
-using System.Runtime.InteropServices;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System.Runtime.InteropServices;
namespace Silk.NET.Core
{
+ ///
+ /// A struct of potential WindowHandles, represented by nullables
+ ///
[StructLayout(LayoutKind.Auto)]
public struct WindowHandles
{
+ /// Probably redundant? Not sure
public bool IsSupported { get; }
// ...
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
index 71737bff2c..44894c1819 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
@@ -1,4 +1,6 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
///
/// Represents the current state of the window.
@@ -25,4 +27,4 @@ public enum WindowState
///
Fullscreen
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
index d4131474c0..cc8c0d875c 100644
--- a/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
@@ -1,88 +1,435 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using System.Collections.Generic;
+using Silk.NET.Core;
using Silk.NET.Maths;
-namespace Silk.NET.Windowing.Implementations.GLFW;
-
-public class GLFWSurface : IGLTransparentFramebuffer, IGlesDesktopSurface, IVkDesktopSurface, IGLDesktopSurface
+namespace Silk.NET.Windowing.Implementations.GLFW
{
- IGlesSurface? _sharedContext;
- IGLSurface? _sharedContext1;
- public WindowHandles Native { get; }
- public void Dispose()
+ ///
+ /// A Desktop surface backed by GLFW
+ ///
+ public class GLFWSurface : IGLTransparentFramebuffer, IGlesDesktopSurface, IVkDesktopSurface, IGLDesktopSurface
{
- throw new NotImplementedException();
- }
+ private IGlesSurface? _sharedContext;
+ private IGLSurface? _sharedContext1;
- public bool IsTerminating { get; }
- public bool IsPausing { get; }
- public double Time { get; }
- public Vector2D FramebufferSize { get; }
- public bool IsVisible { get; set; }
- public Vector2D Position { get; set; }
- public Vector2D Size { get; set; }
- public string Title { get; set; }
- public WindowState WindowState { get; set; }
- public WindowBorder WindowBorder { get; set; }
- public VideoMode VideoMode { get; set; }
- public IScreen? CurrentScreen { get; set; }
- public IEnumerable? AvailableScreens { get; }
- public bool IsEventDriven { get; set; }
- public bool IsCloseRequested { get; set; }
- public bool IsFocused { get; }
- public Rectangle BorderSize { get; }
- public event Action? CloseRequested;
- public event Vector2DAction? Move;
- public event WindowStateAction? StateChanged;
- public event FilePathsAction? FileDrop;
- public event ToggleAction? FocusChanged;
- public double FramesPerSecond { get; set; }
- public double UpdatesPerSecond { get; set; }
- public event Vector2DAction? Resize;
- public event Vector2DAction? FramebufferResize;
- public event Action? Terminating;
- public event Action? LowMemory;
- public event Action? Pausing;
- public event Action? Resuming;
- public event Action? Created;
- public event Action? PreUpdate;
- public event DeltaAction? Update;
- public event DeltaAction? Render;
- public nint Handle { get; }
- public bool IsContextCurrent { get; set; }
- public bool ShouldSwapAutomatically { get; set; }
- public int SwapInterval { get; set; }
- public int? PreferredDepthBufferBits { get; set; }
- public int? PreferredStencilBufferBits { get; set; }
- public Vector4D? PreferredBitDepth { get; set; }
- public Version32? ApiVersion { get; set; }
- public nint? GetProcAddress(string proc)
- {
- throw new NotImplementedException();
- }
+
+ ///
+ ///
+ ///
+ public WindowHandles Native { get; }
+
+ ///
+ ///
+ ///
+ public void Dispose()
+ {
+ throw new NotImplementedException();
+ }
- public bool TransparentFramebuffer { get; set; }
- public ContextFlags ContextFlags { get; set; }
- public ContextProfile ContextProfile { get; set; }
+ ///
+ ///
+ ///
+ public bool IsTerminating { get; }
+
+ ///
+ ///
+ ///
+ public bool IsPausing { get; }
- IGLSurface? IGLSurface.SharedContext
- {
- get => _sharedContext1;
- set => _sharedContext1 = value;
- }
+ ///
+ ///
+ ///
+ public double Time { get; }
+
+ ///
+ ///
+ ///
+ public Vector2D FramebufferSize { get; }
+
+ ///
+ ///
+ ///
+ public bool IsVisible { get; set; }
+
+ ///
+ ///
+ ///
+ public Vector2D Position { get; set; }
+
+ ///
+ ///
+ ///
+ public Vector2D Size { get; set; }
+
+ ///
+ ///
+ ///
+ public string Title { get; set; } = null!;
- IGlesSurface? IGlesSurface.SharedContext
- {
- get => _sharedContext;
- set => _sharedContext = value;
- }
+ ///
+ ///
+ ///
+ public WindowState WindowState { get; set; }
+
+ ///
+ ///
+ ///
+ public WindowBorder WindowBorder { get; set; }
+
+ ///
+ ///
+ ///
+ public VideoMode VideoMode { get; set; }
+
+ ///
+ ///
+ ///
+ public IScreen? CurrentScreen { get; set; }
+
+ ///
+ ///
+ ///
+ public IEnumerable? AvailableScreens { get; }
+
+ ///
+ ///
+ ///
+ public bool IsEventDriven { get; set; }
+
+ ///
+ ///
+ ///
+ public bool IsCloseRequested { get; set; }
+
+ ///
+ ///
+ ///
+ public bool IsFocused { get; }
+
+ ///
+ ///
+ ///
+ public Rectangle BorderSize { get; }
+
+ ///
+ ///
+ ///
+ public event Action? CloseRequested;
+
+ ///
+ ///
+ ///
+ public event Vector2DAction? Move;
+
+ ///
+ ///
+ ///
+ public event WindowStateAction? StateChanged;
+
+ ///
+ ///
+ ///
+ public event FilePathsAction? FileDrop;
+
+ ///
+ ///
+ ///
+ public event ToggleAction? FocusChanged;
+
+ ///
+ ///
+ ///
+ public void SetWindowIcon(ReadOnlySpan icons)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void ContinueEvents()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public Vector2D PointToClient(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public Vector2D PointToScreen(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
- public bool TryEnableOpenGLES()
- {
- throw new NotImplementedException();
- }
+
+ ///
+ ///
+ ///
+ public double FramesPerSecond { get; set; }
+
+ ///
+ ///
+ ///
+ public double UpdatesPerSecond { get; set; }
+
+ ///
+ ///
+ ///
+ public event Vector2DAction? Resize;
+
+ ///
+ ///
+ ///
+ public event Vector2DAction? FramebufferResize;
+
+ ///
+ ///
+ ///
+ public event Action? Terminating;
+
+ ///
+ ///
+ ///
+ public event Action? LowMemory;
+
+ ///
+ ///
+ ///
+ public event Action? Pausing;
+
+ ///
+ ///
+ ///
+ public event Action? Resuming;
+
+ ///
+ ///
+ ///
+ public event Action? Created;
+
+ ///
+ ///
+ ///
+ public event Action? PreUpdate;
+
+ ///
+ ///
+ ///
+ public event DeltaAction? Update;
+
+ ///
+ ///
+ ///
+ public event DeltaAction? Render;
+
+ ///
+ ///
+ ///
+ public void Initialize()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void DoRender()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void DoUpdate()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void DoEvents()
+ {
+ throw new NotImplementedException();
+ }
- public bool TryEnableVulkan()
- {
- throw new NotImplementedException();
+ ///
+ ///
+ ///
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void Terminate()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public Vector2D PointToFramebuffer(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void Run(Action onFrame)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public nint Handle { get; }
+
+ ///
+ ///
+ ///
+ public bool IsContextCurrent { get; set; }
+
+ ///
+ ///
+ ///
+ public bool ShouldSwapAutomatically { get; set; }
+
+ ///
+ ///
+ ///
+ public int SwapInterval { get; set; }
+
+ ///
+ ///
+ ///
+ public int? PreferredDepthBufferBits { get; set; }
+
+ ///
+ ///
+ ///
+ public int? PreferredStencilBufferBits { get; set; }
+
+ ///
+ ///
+ ///
+ public Vector4D? PreferredBitDepth { get; set; }
+
+ ///
+ ///
+ ///
+ public Version32? ApiVersion { get; set; }
+
+ ///
+ ///
+ ///
+ public nint? GetProcAddress(string proc)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void SwapBuffers()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public bool TransparentFramebuffer { get; set; }
+
+
+ ///
+ ///
+ ///
+ public ContextFlags ContextFlags { get; set; }
+
+
+ ///
+ ///
+ ///
+ public ContextProfile ContextProfile { get; set; }
+
+ ///
+ ///
+ ///
+ IGLSurface? IGLSurface.SharedContext
+ {
+ get => _sharedContext1;
+ set => _sharedContext1 = value;
+ }
+
+ ///
+ ///
+ ///
+ public bool TryEnableOpenGL()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ IGlesSurface? IGlesSurface.SharedContext
+ {
+ get => _sharedContext;
+ set => _sharedContext = value;
+ }
+
+
+ ///
+ ///
+ ///
+ public bool TryEnableOpenGLES()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ public bool TryEnableVulkan()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ public unsafe ulong Create(nint instance, void* allocator)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ public unsafe byte** GetRequiredExtensions(out uint count)
+ {
+ throw new NotImplementedException();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
index 818681a097..54b3e83c5c 100644
--- a/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
+++ b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
@@ -2,6 +2,7 @@
$(SilkTargetFramework)
+
enable
true
true
@@ -10,4 +11,9 @@
true
+
+
+
+
+
From d10fe337a348c653354b08e5ff0de9eef5c99ff5 Mon Sep 17 00:00:00 2001
From: Redhacker1 <66490743+Redhacker1@users.noreply.github.com>
Date: Sun, 7 Aug 2022 10:32:54 -0500
Subject: [PATCH 3/6] Revert "Made to mostly compile, added docs (Getting
MSB4057 RN)"
This reverts commit 118fc0c058d910f810486837237f47791aaea814.
---
.../Abstract/ContextFlags.cs | 8 +-
.../Abstract/ContextProfile.cs | 6 +-
.../Silk.Net.Windowing/Abstract/Delegates.cs | 23 +-
.../Abstract/IDesktopSurface.cs | 38 +-
.../Abstract/IGLDesktopSurface.cs | 8 +-
.../Silk.Net.Windowing/Abstract/IGLSurface.cs | 25 +-
.../IGLTransparentFramebufferSurface.cs | 12 +-
.../Abstract/IGlesDesktopSurface.cs | 9 +-
.../Abstract/IGlesSurface.cs | 14 +-
.../Abstract/INativeGLSurface.cs | 20 +-
.../Silk.Net.Windowing/Abstract/IScreen.cs | 14 +-
.../Silk.Net.Windowing/Abstract/ISurface.cs | 50 +-
.../Abstract/IVkDesktopSurface.cs | 18 +-
.../Silk.Net.Windowing/Abstract/IVkSurface.cs | 9 +-
.../Abstract/IWindowHandlesSource.cs | 12 +-
.../Silk.Net.Windowing/Abstract/RawImage.cs | 13 +-
.../Silk.Net.Windowing/Abstract/Surface.cs | 28 +-
.../Abstract/SurfaceExtensions.cs | 11 +-
.../Abstract}/Version32.cs | 44 +-
.../Silk.Net.Windowing/Abstract/VideoMode.cs | 19 +-
.../Abstract/WindowBorder.cs | 6 +-
.../Abstract/WindowHandles.cs | 10 +-
.../Abstract/WindowState.cs | 6 +-
.../Implementations/GLFW/GLFWSurface.cs | 501 +++---------------
.../Silk.Net.Windowing.csproj | 6 -
25 files changed, 215 insertions(+), 695 deletions(-)
rename src/libraries/{Silk.NET.Core => Silk.Net.Windowing/Abstract}/Version32.cs (59%)
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
index 8440f28660..03b0ba1da6 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
@@ -1,8 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
///
/// Represents flags related to the OpenGL context.
@@ -27,4 +23,4 @@ public enum ContextFlags
/// On OpenGL contexts older than 3.0, this flag does nothing.
ForwardCompatible = 2
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
index 843792235e..4aee8c408d 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
@@ -1,6 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
///
/// Represents the context profile OpenGL should use.
@@ -18,4 +16,4 @@ public enum ContextProfile
///
Compatability
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
index 967ccdaac2..75d40e9876 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
@@ -1,27 +1,8 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using Silk.NET.Maths;
+using Silk.NET.Maths;
using Silk.NET.Windowing;
-//TODO: Copy proposal explanation as to why we are doing this, also other than Vector2DAction these names are HIGHLY specialized for no apparently good reason, I am not a fan.
-///
-/// An action that takes a
-///
public delegate void Vector2DAction(Vector2D newValue);
-
-///
-/// An action that takes a double as a parameter
-///
public delegate void DeltaAction(double deltaTime);
-///
-/// An action that takes a
-///
public delegate void WindowStateAction(WindowState newState);
-///
-/// An action that takes a list of strings as a parameter, intended for file path callbacks
-///
public delegate void FilePathsAction(string[] filePaths);
-///
-/// An action that takes a bool as a parameter, intended for a callback when things are toggled.
-///
-public delegate void ToggleAction(bool newValue);
+public delegate void ToggleAction(bool newValue);
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
index 50daddd1f6..9f2fc1c094 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
@@ -1,8 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using System.Collections.Generic;
-using Silk.NET.Core;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
@@ -58,7 +54,7 @@ public interface IDesktopSurface : ISurface
IEnumerable? AvailableScreens { get; }
///
- /// Gets or sets whether the window waits for an event to be posted before existing .
+ /// Gets or sets whether the window waits for an event to be posted before existing .
///
bool IsEventDriven { get; set; }
@@ -79,7 +75,7 @@ public interface IDesktopSurface : ISurface
///
/// Because these are distances and not coordinates, they are always zero or positive.
///
- ///
+ ///
Rectangle BorderSize { get; }
///
@@ -111,13 +107,19 @@ public interface IDesktopSurface : ISurface
/// Sets the window icons.
///
/// Either a collection of window icons, or null to set to the default icon.
- void SetWindowIcon(ReadOnlySpan icons);
+ void SetWindowIcon(ReadOnlySpan icons)
+ {
+ throw new NotImplementedException();
+ }
///
- /// When using = true, wakes the main thread from
+ /// When using = true, wakes the main thread from
/// its blocking wait on incoming events. Can be called from any thread.
///
- void ContinueEvents();
+ void ContinueEvents()
+ {
+ throw new NotImplementedException();
+ }
///
/// Converts this point to client coordinates.
@@ -125,7 +127,10 @@ public interface IDesktopSurface : ISurface
/// The point to transform.
/// The transformed point.
/// Expects screen coordinates as input.
- Vector2D PointToClient(Vector2D point);
+ Vector2D PointToClient(Vector2D point)
+ {
+ return new Vector2D(point.X - Position.X, point.Y - Position.Y);
+ }
///
/// Converts this point to screen coordinates.
@@ -133,6 +138,13 @@ public interface IDesktopSurface : ISurface
/// The point to transform.
/// The transformed point.
/// Expects client coordinates as input.
- Vector2D PointToScreen(Vector2D point);
+ Vector2D PointToScreen(Vector2D point)
+ {
+ return new Vector2D(point.X + Position.X, point.Y + Position.Y);
+ }
+ public Vector2D PointToFramebuffer(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
index f024ed15a9..4ca2956fb2 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
@@ -1,9 +1,5 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
+
namespace Silk.NET.Windowing
{
- ///
- /// An interface that defines a desktop surface with the ability to create a desktop GL Context
- ///
public interface IGLDesktopSurface : IDesktopSurface, IGLSurface { }
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
index 07e9d75b1a..bfae8bd52c 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
@@ -1,28 +1,17 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
- ///
- /// A surface that can have a desktop GL context.
- ///
public interface IGLSurface : INativeGLSurface
{
- ///
- /// The flags the context was created with
- ///
ContextFlags ContextFlags { get; set; }
- ///
- /// The profile of the specified context.
- ///
ContextProfile ContextProfile { get; set; }
- ///
- /// The surface representing the context to use.
- ///
- IGLSurface? SharedContext { get; set; } // Redhacker1/Donovan: DAFUQ? What exactly is supposed to be going on here
+ IGLSurface? SharedContext { get; set; }
///
/// Enables OpenGL support for this surface. This will create a surface upon initialization.
///
- bool TryEnableOpenGL();
+ bool TryEnableOpenGL()
+ {
+ throw new NotImplementedException();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
index 90157a7d37..0dfeeff8b0 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
@@ -1,16 +1,8 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
+
namespace Silk.NET.Windowing
{
- ///
- /// Represents a GL Surface with a transparent Framebuffer
- ///
- // Is GLFW making this an optional feature worth adding this? -Donovan/Redhacker1
public interface IGLTransparentFramebuffer : INativeGLSurface
{
- ///
- /// Whether the buffer can be actually transparent
- ///
bool TransparentFramebuffer { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
index 76253f9e0f..58ff9afece 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
@@ -1,12 +1,7 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
- ///
- /// A Desktop Surface with the ability to create a GLES surface
- ///
public interface IGlesDesktopSurface : IDesktopSurface, IGlesSurface
{
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
index 73dcaa930e..22ab3f2966 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
@@ -1,19 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
- ///
- /// Defines a surface that can have a GLES context attatched
- ///
public interface IGlesSurface : INativeGLSurface
{
- ///
- /// The surface representing the context to use.
- ///
- IGlesSurface? SharedContext { get; set; } // Donovan/Redhacker1: How on earth is this supposed to work?
+ IGlesSurface? SharedContext { get; set; }
///
/// Enables OpenGLES support for this surface. This will create a surface upon initialization.
///
bool TryEnableOpenGLES();
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
index 056545ab77..9208ecc56d 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
@@ -1,23 +1,12 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using Silk.NET.Core;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
public interface INativeGLSurface : ISurface
{
- ///
- /// the GL Handle
- ///
nint Handle { get; }
- ///
- /// Whether this is the currently running context on this thread
- ///
bool IsContextCurrent { get; set; }
- ///
- /// Should the buffers swap immediately upon completion?
- ///
bool ShouldSwapAutomatically { get; set; }
///
@@ -59,6 +48,9 @@ public interface INativeGLSurface : ISurface
Version32? ApiVersion { get; set; }
nint? GetProcAddress(string proc);
- void SwapBuffers();
+ void SwapBuffers()
+ {
+ throw new NotImplementedException();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
index c81da687df..8f512cf73b 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
@@ -1,12 +1,9 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System.Collections.Generic;
-using Silk.NET.Maths;
+using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
///
- /// An interface representing a screen
+ /// An interface representing a screen.
///
public interface IScreen
{
@@ -39,6 +36,9 @@ public interface IScreen
/// Get all video modes that this screen supports.
///
/// An array of all video modes.
- IEnumerable GetAllVideoModes();
+ IEnumerable GetAllVideoModes()
+ {
+ throw new NotImplementedException();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
index cf35541fef..16844b2599 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
@@ -1,14 +1,8 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using Silk.NET.Core;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
- ///
- /// Represents a surface with a framebuffer on which to draw on.
- ///
public interface ISurface : IWindowHandlesSource, IDisposable
{
///
@@ -100,32 +94,50 @@ public interface ISurface : IWindowHandlesSource, IDisposable
///
/// Creates the surface on the underlying platform.
///
- void Initialize();
+ void Initialize()
+ {
+ throw new NotImplementedException();
+ }
///
/// Calls the Render event.
///
- void DoRender();
+ void DoRender()
+ {
+ throw new NotImplementedException();
+ }
///
/// Calls the Update event.
///
- void DoUpdate();
+ void DoUpdate()
+ {
+ throw new NotImplementedException();
+ }
///
/// Polls the underlying platform for events.
///
- void DoEvents();
+ void DoEvents()
+ {
+ throw new NotImplementedException();
+ }
///
/// Unloads the surface on the underlying platform.
///
- void Reset();
+ void Reset()
+ {
+ throw new NotImplementedException();
+ }
///
/// Terminates this surface.
///
- void Terminate();
+ void Terminate()
+ {
+ throw new NotImplementedException();
+ }
///
/// Converts this point to framebuffer coordinates.
@@ -133,12 +145,18 @@ public interface ISurface : IWindowHandlesSource, IDisposable
/// The point to transform.
/// The transformed point.
/// Expects client coordinates as input.
- Vector2D PointToFramebuffer(Vector2D point);
+ Vector2D PointToFramebuffer(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
///
/// Initiates a render loop in which the given callback is called as fast as the underlying platform can manage.
///
/// The callback to run each frame.
- void Run(Action onFrame);
+ void Run(Action onFrame)
+ {
+ throw new NotImplementedException();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
index 1aeb549a91..348380ea34 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
@@ -1,10 +1,6 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
+
namespace Silk.NET.Windowing
{
- ///
- /// Represents a surface with Vulkan support
- ///
public interface IVkSurface : ISurface
{
/// Enables Vulkan support for this surface.
@@ -16,13 +12,19 @@ public interface IVkSurface : ISurface
/// The Vulkan instance to create a surface for.
/// A custom Vulkan allocator. Can be omitted by passing null.
/// A handle to the Vulkan surface created
- unsafe ulong Create(nint instance, void* allocator);
+ unsafe ulong Create(nint instance, void* allocator)
+ {
+ throw new NotImplementedException();
+ }
///
/// Get the extensions required for Vulkan to work on this platform.
///
/// The number of extensions in the returned array
/// An array of strings, containing names for all required extensions
- unsafe byte** GetRequiredExtensions(out uint count);
+ unsafe byte** GetRequiredExtensions(out uint count)
+ {
+ throw new NotImplementedException();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
index be3056d659..43f71131d6 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
@@ -1,9 +1,6 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
+using Silk.NET.Core.Contexts;
+
namespace Silk.NET.Windowing
{
- ///
- /// Represents a desktop surface with Vulkan support
- ///
public interface IVkDesktopSurface : IDesktopSurface, IVkSurface { }
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
index 3dab0d04e8..49fa6b37f9 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
@@ -1,15 +1,7 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-namespace Silk.NET.Core
+namespace Silk.NET.Core
{
- ///
- /// Represents something that has access to a window handle
- ///
public interface IWindowHandlesSource
{
- ///
- /// The native handles this window could possibly have, the .Net foundation reserves the right to append to this list as they see fit
- ///
WindowHandles Native { get; }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
index 9ae1a5b028..039b5eddff 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
@@ -1,7 +1,6 @@
-// Licensed to the .NET Foundation under one or more agreements.
+
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-
namespace Silk.NET.Core
{
///
@@ -15,7 +14,7 @@ namespace Silk.NET.Core
/// The width of the image.
/// The height of the image.
/// The image daqta.
- public RawImage(int width, int height, ReadOnlyMemory rgbaPixels)
+ public RawImage(int width, int height, Memory rgbaPixels)
{
Pixels = rgbaPixels;
Width = width;
@@ -34,7 +33,7 @@ public RawImage(int width, int height, ReadOnlyMemory rgbaPixels)
///
/// The image data.
///
- public ReadOnlyMemory Pixels { get; }
+ public Memory Pixels { get; }
///
/// Checks whether the two given s are equal.
@@ -73,7 +72,7 @@ public bool Equals(RawImage other)
}
///
- public override bool Equals(object? obj)
+ public override bool Equals(object obj)
{
return obj is RawImage other && Equals(other);
}
@@ -81,4 +80,4 @@ public override bool Equals(object? obj)
///
public override int GetHashCode() => HashCode.Combine(Width, Height, Pixels);
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
index 1a9b7deb4e..f9fa119e79 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
@@ -1,44 +1,20 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
- ///
- /// A factory that creates and/or gets surfaces.
- ///
public static class Surface
{
- ///
- /// Whether the platform is supported by any backend of of Silk.Net.Windowing.
- ///
- ///
public static bool IsPlatformSupported { get => throw new NotImplementedException(); }
- ///
- /// Gets a surface if a surface already exist, if it does then return said surface.
- ///
- /// an object.
- // Does this return null on IsPlatformSupported is false? Does it throw? Should it return a bool indicating whether it returned an existing surface or created a new one?
public static ISurface GetOrCreate()
{
throw new NotImplementedException();
}
- ///
- /// Creates an regardless as to whether one already exists
- ///
- /// an object.
- // Does this return null on IsPlatformSupported is false? Does it throw? Should it return a bool indicating whether it returned an existing surface or created a new one?
public static ISurface CreateNew()
{
throw new NotImplementedException();
}
-
- ///
- /// Clears the contexts of ALL objects.
- ///
public static void ClearCurrentContexts()
{
throw new NotImplementedException();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
index 56a1dc6887..1fe824cf2e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
@@ -1,7 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using Silk.NET.Core;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
@@ -14,7 +11,7 @@ public static class SurfaceExtensions
///
/// Start the default event loop on this surface.
///
- /// The surface to begin the loop on.
+ /// The surface to begin the loop on.
public static void Run(this ISurface surface)
{
throw new NotImplementedException();
@@ -54,9 +51,9 @@ public static void SetDefaultIcon(this IDesktopSurface window)
///
/// The window.
/// The icon to set.
- public static void SetWindowIcon(this IDesktopSurface window, RawImage icon)
+ public static void SetWindowIcon(this IDesktopSurface window, ref RawImage icon)
{
throw new NotImplementedException();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.NET.Core/Version32.cs b/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
similarity index 59%
rename from src/libraries/Silk.NET.Core/Version32.cs
rename to src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
index 511759222e..5e76997f9b 100644
--- a/src/libraries/Silk.NET.Core/Version32.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
@@ -1,6 +1,7 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
+
using System;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Core
{
///
@@ -12,45 +13,18 @@ public readonly struct Version32
/// The underlying Vulkan-compatible 32-bit version integer.
///
public uint Value { get; }
-
///
/// Creates a Vulkan version structure from the given major, minor, and patch values.
///
- /// The major value. It is a 3-bit integer
- /// The major value. It is a 7-bit integer
- /// The minor value. It is a 10-bit integer
- /// The patch value. It is a 12-bit integer
- /// major, minor, or patch were out of the range of valid values
- public Version32(uint variant, uint major, uint minor, uint patch)
- {
- /*The variant is a 3-bit integer packed into bits 31-29. -Donovan/Redhacker1, Why is this not used?
-
- The major version is a 7-bit integer packed into bits 28-22. 2^7 = 128
-
- The minor version number is a 10-bit integer packed into bits 21-12. 2^10 = 1024
-
- The patch version number is a 12-bit integer packed into bits 11-0. 2^12 = 4096
- */
- // Sanity check to ensure that the values are correct
- if ( (variant & uint.MaxValue - 7) != 0 || (major & uint.MaxValue - 127) != 0 || (minor & uint.MaxValue - 1023) != 0 || (patch & uint.MaxValue - 4095) != 0)
- {
- throw new ArgumentOutOfRangeException("variant, major, minor and/or patch were out of range, ");
- }
-
-
- Value = (variant & 7) << 29 | (major & 127) << 22 | (minor & 1023) << 12 | (patch & 4095);
- }
-
+ /// The major value.
+ /// The minor value.
+ /// The patch value.
+ public Version32(uint major, uint minor, uint patch) => Value = major << 22 | minor << 12 | patch;
///
/// Creates a Vulkan version structure from the given Vulkan-compatible value.
///
/// The value.
private Version32(uint value) => Value = value;
-
- ///
- /// Gets the variant component of this version structure.
- ///
- public uint Variant => Value >> 29;
///
/// Gets the major component of this version structure.
///
@@ -76,7 +50,7 @@ public Version32(uint variant, uint major, uint minor, uint patch)
/// The version instance.
/// The 32-bit version structure.
public static implicit operator Version32
- (Version version) => new Version32(0, (uint) version.Major, (uint) version.Minor, (uint) version.Build);
+ (Version version) => new Version32((uint) version.Major, (uint) version.Minor, (uint) version.Build);
///
/// Gets the 32-bit unsigned integer representation for this 32-bit version structure.
@@ -93,4 +67,4 @@ public static implicit operator Version32
public static implicit operator Version
(Version32 version) => new Version((int) version.Major, (int) version.Minor, (int) version.Patch);
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
index 7a3a18d24b..c4e97ab052 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
@@ -1,29 +1,14 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using Silk.NET.Maths;
+using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
- ///
- /// Represents a screens supported refresh rate and resolution
- ///
public readonly struct VideoMode
{
- ///
- /// Creates a with a resolution and refreshRate parameter.
- ///
- /// The dimensions of the VideoMode in question
- /// How many times per second the screen refreshes
public VideoMode(Vector2D? resolution = null, int? refreshRate = null)
{
throw new NotImplementedException();
}
- ///
- /// Creates a with a refreshRate parameter.
- ///
- /// How many times per second the screen refreshes
public VideoMode(int? refreshRate)
{
throw new NotImplementedException();
@@ -44,4 +29,4 @@ public VideoMode(int? refreshRate)
///
public static VideoMode Default { get; }
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
index d29db0e943..204237168c 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
@@ -1,6 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
///
/// Represents the window border.
@@ -22,4 +20,4 @@ public enum WindowBorder
///
Hidden
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
index 63d5c1839d..1135289ef4 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
@@ -1,17 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
namespace Silk.NET.Core
{
- ///
- /// A struct of potential WindowHandles, represented by nullables
- ///
[StructLayout(LayoutKind.Auto)]
public struct WindowHandles
{
- /// Probably redundant? Not sure
public bool IsSupported { get; }
// ...
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
index 44894c1819..71737bff2c 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
@@ -1,6 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-namespace Silk.NET.Windowing
+namespace Silk.NET.Windowing
{
///
/// Represents the current state of the window.
@@ -27,4 +25,4 @@ public enum WindowState
///
Fullscreen
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
index cc8c0d875c..d4131474c0 100644
--- a/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
@@ -1,435 +1,88 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using System.Collections.Generic;
-using Silk.NET.Core;
+using Silk.NET.Core;
using Silk.NET.Maths;
-namespace Silk.NET.Windowing.Implementations.GLFW
+namespace Silk.NET.Windowing.Implementations.GLFW;
+
+public class GLFWSurface : IGLTransparentFramebuffer, IGlesDesktopSurface, IVkDesktopSurface, IGLDesktopSurface
{
- ///
- /// A Desktop surface backed by GLFW
- ///
- public class GLFWSurface : IGLTransparentFramebuffer, IGlesDesktopSurface, IVkDesktopSurface, IGLDesktopSurface
+ IGlesSurface? _sharedContext;
+ IGLSurface? _sharedContext1;
+ public WindowHandles Native { get; }
+ public void Dispose()
{
- private IGlesSurface? _sharedContext;
- private IGLSurface? _sharedContext1;
-
-
- ///
- ///
- ///
- public WindowHandles Native { get; }
-
- ///
- ///
- ///
- public void Dispose()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public bool IsTerminating { get; }
-
- ///
- ///
- ///
- public bool IsPausing { get; }
-
- ///
- ///
- ///
- public double Time { get; }
-
- ///
- ///
- ///
- public Vector2D FramebufferSize { get; }
-
- ///
- ///
- ///
- public bool IsVisible { get; set; }
-
- ///
- ///
- ///
- public Vector2D Position { get; set; }
-
- ///
- ///
- ///
- public Vector2D Size { get; set; }
-
- ///
- ///
- ///
- public string Title { get; set; } = null!;
-
- ///
- ///
- ///
- public WindowState WindowState { get; set; }
-
- ///
- ///
- ///
- public WindowBorder WindowBorder { get; set; }
-
- ///
- ///
- ///
- public VideoMode VideoMode { get; set; }
-
- ///
- ///
- ///
- public IScreen? CurrentScreen { get; set; }
-
- ///
- ///
- ///
- public IEnumerable? AvailableScreens { get; }
-
- ///
- ///
- ///
- public bool IsEventDriven { get; set; }
-
- ///
- ///
- ///
- public bool IsCloseRequested { get; set; }
-
- ///
- ///
- ///
- public bool IsFocused { get; }
-
- ///
- ///
- ///
- public Rectangle BorderSize { get; }
-
- ///
- ///
- ///
- public event Action? CloseRequested;
-
- ///
- ///
- ///
- public event Vector2DAction? Move;
-
- ///
- ///
- ///
- public event WindowStateAction? StateChanged;
-
- ///
- ///
- ///
- public event FilePathsAction? FileDrop;
-
- ///
- ///
- ///
- public event ToggleAction? FocusChanged;
-
- ///
- ///
- ///
- public void SetWindowIcon(ReadOnlySpan icons)
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public void ContinueEvents()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public Vector2D PointToClient(Vector2D point)
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public Vector2D PointToScreen(Vector2D point)
- {
- throw new NotImplementedException();
- }
-
-
- ///
- ///
- ///
- public double FramesPerSecond { get; set; }
-
- ///
- ///
- ///
- public double UpdatesPerSecond { get; set; }
-
- ///
- ///
- ///
- public event Vector2DAction? Resize;
-
- ///
- ///
- ///
- public event Vector2DAction? FramebufferResize;
-
- ///
- ///
- ///
- public event Action? Terminating;
-
- ///
- ///
- ///
- public event Action? LowMemory;
-
- ///
- ///
- ///
- public event Action? Pausing;
-
- ///
- ///
- ///
- public event Action? Resuming;
-
- ///
- ///
- ///
- public event Action? Created;
-
- ///
- ///
- ///
- public event Action? PreUpdate;
-
- ///
- ///
- ///
- public event DeltaAction? Update;
-
- ///
- ///
- ///
- public event DeltaAction? Render;
-
- ///
- ///
- ///
- public void Initialize()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public void DoRender()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public void DoUpdate()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public void DoEvents()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public void Reset()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public void Terminate()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public Vector2D PointToFramebuffer(Vector2D point)
- {
- throw new NotImplementedException();
- }
+ throw new NotImplementedException();
+ }
- ///
- ///
- ///
- public void Run(Action onFrame)
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public nint Handle { get; }
-
- ///
- ///
- ///
- public bool IsContextCurrent { get; set; }
-
- ///
- ///
- ///
- public bool ShouldSwapAutomatically { get; set; }
-
- ///
- ///
- ///
- public int SwapInterval { get; set; }
-
- ///
- ///
- ///
- public int? PreferredDepthBufferBits { get; set; }
-
- ///
- ///
- ///
- public int? PreferredStencilBufferBits { get; set; }
-
- ///
- ///
- ///
- public Vector4D? PreferredBitDepth { get; set; }
-
- ///
- ///
- ///
- public Version32? ApiVersion { get; set; }
-
- ///
- ///
- ///
- public nint? GetProcAddress(string proc)
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public void SwapBuffers()
- {
- throw new NotImplementedException();
- }
-
- ///
- ///
- ///
- public bool TransparentFramebuffer { get; set; }
-
-
- ///
- ///
- ///
- public ContextFlags ContextFlags { get; set; }
-
-
- ///
- ///
- ///
- public ContextProfile ContextProfile { get; set; }
-
- ///
- ///
- ///
- IGLSurface? IGLSurface.SharedContext
- {
- get => _sharedContext1;
- set => _sharedContext1 = value;
- }
-
- ///
- ///
- ///
- public bool TryEnableOpenGL()
- {
- throw new NotImplementedException();
- }
+ public bool IsTerminating { get; }
+ public bool IsPausing { get; }
+ public double Time { get; }
+ public Vector2D FramebufferSize { get; }
+ public bool IsVisible { get; set; }
+ public Vector2D Position { get; set; }
+ public Vector2D Size { get; set; }
+ public string Title { get; set; }
+ public WindowState WindowState { get; set; }
+ public WindowBorder WindowBorder { get; set; }
+ public VideoMode VideoMode { get; set; }
+ public IScreen? CurrentScreen { get; set; }
+ public IEnumerable? AvailableScreens { get; }
+ public bool IsEventDriven { get; set; }
+ public bool IsCloseRequested { get; set; }
+ public bool IsFocused { get; }
+ public Rectangle BorderSize { get; }
+ public event Action? CloseRequested;
+ public event Vector2DAction? Move;
+ public event WindowStateAction? StateChanged;
+ public event FilePathsAction? FileDrop;
+ public event ToggleAction? FocusChanged;
+ public double FramesPerSecond { get; set; }
+ public double UpdatesPerSecond { get; set; }
+ public event Vector2DAction? Resize;
+ public event Vector2DAction? FramebufferResize;
+ public event Action? Terminating;
+ public event Action? LowMemory;
+ public event Action? Pausing;
+ public event Action? Resuming;
+ public event Action? Created;
+ public event Action? PreUpdate;
+ public event DeltaAction? Update;
+ public event DeltaAction? Render;
+ public nint Handle { get; }
+ public bool IsContextCurrent { get; set; }
+ public bool ShouldSwapAutomatically { get; set; }
+ public int SwapInterval { get; set; }
+ public int? PreferredDepthBufferBits { get; set; }
+ public int? PreferredStencilBufferBits { get; set; }
+ public Vector4D? PreferredBitDepth { get; set; }
+ public Version32? ApiVersion { get; set; }
+ public nint? GetProcAddress(string proc)
+ {
+ throw new NotImplementedException();
+ }
-
- ///
- ///
- ///
- IGlesSurface? IGlesSurface.SharedContext
- {
- get => _sharedContext;
- set => _sharedContext = value;
- }
+ public bool TransparentFramebuffer { get; set; }
+ public ContextFlags ContextFlags { get; set; }
+ public ContextProfile ContextProfile { get; set; }
-
- ///
- ///
- ///
- public bool TryEnableOpenGLES()
- {
- throw new NotImplementedException();
- }
+ IGLSurface? IGLSurface.SharedContext
+ {
+ get => _sharedContext1;
+ set => _sharedContext1 = value;
+ }
-
- ///
- ///
- ///
- public bool TryEnableVulkan()
- {
- throw new NotImplementedException();
- }
+ IGlesSurface? IGlesSurface.SharedContext
+ {
+ get => _sharedContext;
+ set => _sharedContext = value;
+ }
-
- ///
- ///
- ///
- public unsafe ulong Create(nint instance, void* allocator)
- {
- throw new NotImplementedException();
- }
+ public bool TryEnableOpenGLES()
+ {
+ throw new NotImplementedException();
+ }
-
- ///
- ///
- ///
- public unsafe byte** GetRequiredExtensions(out uint count)
- {
- throw new NotImplementedException();
- }
+ public bool TryEnableVulkan()
+ {
+ throw new NotImplementedException();
}
-}
+}
\ No newline at end of file
diff --git a/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
index 54b3e83c5c..818681a097 100644
--- a/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
+++ b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
@@ -2,7 +2,6 @@
$(SilkTargetFramework)
-
enable
true
true
@@ -11,9 +10,4 @@
true
-
-
-
-
-
From 0e95025288760d49d3b23584d1acde7c035bdc4c Mon Sep 17 00:00:00 2001
From: Redhacker1 <66490743+Redhacker1@users.noreply.github.com>
Date: Sat, 13 Aug 2022 11:44:10 -0500
Subject: [PATCH 4/6] Resolving issues seen by Kai
Implementing test for Version32, moving Version32 to Core, removing implementations from Interfaces among other stuff I probably forgot.
---
Silk.NET.sln | 15 +
.../Abstract => Silk.NET.Core}/Version32.cs | 44 +-
.../Abstract/ContextFlags.cs | 8 +-
.../Abstract/ContextProfile.cs | 6 +-
.../Silk.Net.Windowing/Abstract/Delegates.cs | 23 +-
.../Abstract/IDesktopSurface.cs | 38 +-
.../Abstract/IGLDesktopSurface.cs | 8 +-
.../Silk.Net.Windowing/Abstract/IGLSurface.cs | 25 +-
.../IGLTransparentFramebufferSurface.cs | 12 +-
.../Abstract/IGlesDesktopSurface.cs | 9 +-
.../Abstract/IGlesSurface.cs | 14 +-
.../Abstract/INativeGLSurface.cs | 20 +-
.../Silk.Net.Windowing/Abstract/IScreen.cs | 14 +-
.../Silk.Net.Windowing/Abstract/ISurface.cs | 50 +-
.../Abstract/IVkDesktopSurface.cs | 18 +-
.../Silk.Net.Windowing/Abstract/IVkSurface.cs | 9 +-
.../Abstract/IWindowHandlesSource.cs | 12 +-
.../Silk.Net.Windowing/Abstract/RawImage.cs | 13 +-
.../Silk.Net.Windowing/Abstract/Surface.cs | 28 +-
.../Abstract/SurfaceExtensions.cs | 11 +-
.../Silk.Net.Windowing/Abstract/VideoMode.cs | 19 +-
.../Abstract/WindowBorder.cs | 6 +-
.../Abstract/WindowHandles.cs | 10 +-
.../Abstract/WindowState.cs | 6 +-
.../Implementations/GLFW/GLFWSurface.cs | 501 +++++++++++++++---
.../Silk.Net.Windowing.csproj | 6 +
tests/Silk.NET.Core.Tests/Program.cs | 66 +++
.../Silk.NET.Core.Tests.csproj | 23 +
28 files changed, 799 insertions(+), 215 deletions(-)
rename src/libraries/{Silk.Net.Windowing/Abstract => Silk.NET.Core}/Version32.cs (59%)
create mode 100644 tests/Silk.NET.Core.Tests/Program.cs
create mode 100644 tests/Silk.NET.Core.Tests/Silk.NET.Core.Tests.csproj
diff --git a/Silk.NET.sln b/Silk.NET.sln
index f97abc2d9b..7996100e78 100644
--- a/Silk.NET.sln
+++ b/Silk.NET.sln
@@ -82,6 +82,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.SilkTouch.Integrat
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.SilkTouch.TestFramework", "tests\Silk.NET.SilkTouch.TestFramework\Silk.NET.SilkTouch.TestFramework.csproj", "{381D1039-3259-488F-BB25-D90EE63A3E82}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Core.Tests", "tests\Silk.NET.Core.Tests\Silk.NET.Core.Tests.csproj", "{6076C9E6-D094-49C5-B526-0AF355D11AC7}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -332,6 +334,18 @@ Global
{381D1039-3259-488F-BB25-D90EE63A3E82}.Release|x64.Build.0 = Release|Any CPU
{381D1039-3259-488F-BB25-D90EE63A3E82}.Release|x86.ActiveCfg = Release|Any CPU
{381D1039-3259-488F-BB25-D90EE63A3E82}.Release|x86.Build.0 = Release|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x64.Build.0 = Debug|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x86.Build.0 = Debug|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x64.ActiveCfg = Release|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x64.Build.0 = Release|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x86.ActiveCfg = Release|Any CPU
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -364,6 +378,7 @@ Global
{66FE736C-C407-44C3-A94E-4345E22AA95E} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
{381D1039-3259-488F-BB25-D90EE63A3E82} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
{7A2A3176-DBA1-4026-AF65-8E36B4F09B02} = {C9718C94-2F21-4E8D-B55D-8F0B1A131346}
+ {6076C9E6-D094-49C5-B526-0AF355D11AC7} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs b/src/libraries/Silk.NET.Core/Version32.cs
similarity index 59%
rename from src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
rename to src/libraries/Silk.NET.Core/Version32.cs
index 5e76997f9b..511759222e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Version32.cs
+++ b/src/libraries/Silk.NET.Core/Version32.cs
@@ -1,7 +1,6 @@
-
-using System;
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System;
namespace Silk.NET.Core
{
///
@@ -13,18 +12,45 @@ public readonly struct Version32
/// The underlying Vulkan-compatible 32-bit version integer.
///
public uint Value { get; }
+
///
/// Creates a Vulkan version structure from the given major, minor, and patch values.
///
- /// The major value.
- /// The minor value.
- /// The patch value.
- public Version32(uint major, uint minor, uint patch) => Value = major << 22 | minor << 12 | patch;
+ /// The major value. It is a 3-bit integer
+ /// The major value. It is a 7-bit integer
+ /// The minor value. It is a 10-bit integer
+ /// The patch value. It is a 12-bit integer
+ /// major, minor, or patch were out of the range of valid values
+ public Version32(uint variant, uint major, uint minor, uint patch)
+ {
+ /*The variant is a 3-bit integer packed into bits 31-29. -Donovan/Redhacker1, Why is this not used?
+
+ The major version is a 7-bit integer packed into bits 28-22. 2^7 = 128
+
+ The minor version number is a 10-bit integer packed into bits 21-12. 2^10 = 1024
+
+ The patch version number is a 12-bit integer packed into bits 11-0. 2^12 = 4096
+ */
+ // Sanity check to ensure that the values are correct
+ if ( (variant & uint.MaxValue - 7) != 0 || (major & uint.MaxValue - 127) != 0 || (minor & uint.MaxValue - 1023) != 0 || (patch & uint.MaxValue - 4095) != 0)
+ {
+ throw new ArgumentOutOfRangeException("variant, major, minor and/or patch were out of range, ");
+ }
+
+
+ Value = (variant & 7) << 29 | (major & 127) << 22 | (minor & 1023) << 12 | (patch & 4095);
+ }
+
///
/// Creates a Vulkan version structure from the given Vulkan-compatible value.
///
/// The value.
private Version32(uint value) => Value = value;
+
+ ///
+ /// Gets the variant component of this version structure.
+ ///
+ public uint Variant => Value >> 29;
///
/// Gets the major component of this version structure.
///
@@ -50,7 +76,7 @@ public readonly struct Version32
/// The version instance.
/// The 32-bit version structure.
public static implicit operator Version32
- (Version version) => new Version32((uint) version.Major, (uint) version.Minor, (uint) version.Build);
+ (Version version) => new Version32(0, (uint) version.Major, (uint) version.Minor, (uint) version.Build);
///
/// Gets the 32-bit unsigned integer representation for this 32-bit version structure.
@@ -67,4 +93,4 @@ public static implicit operator Version32
public static implicit operator Version
(Version32 version) => new Version((int) version.Major, (int) version.Minor, (int) version.Patch);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
index 03b0ba1da6..8440f28660 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs
@@ -1,4 +1,8 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+
+namespace Silk.NET.Windowing
{
///
/// Represents flags related to the OpenGL context.
@@ -23,4 +27,4 @@ public enum ContextFlags
/// On OpenGL contexts older than 3.0, this flag does nothing.
ForwardCompatible = 2
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
index 4aee8c408d..843792235e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs
@@ -1,4 +1,6 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
///
/// Represents the context profile OpenGL should use.
@@ -16,4 +18,4 @@ public enum ContextProfile
///
Compatability
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
index 75d40e9876..967ccdaac2 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Delegates.cs
@@ -1,8 +1,27 @@
-using Silk.NET.Maths;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using Silk.NET.Maths;
using Silk.NET.Windowing;
+//TODO: Copy proposal explanation as to why we are doing this, also other than Vector2DAction these names are HIGHLY specialized for no apparently good reason, I am not a fan.
+///
+/// An action that takes a
+///
public delegate void Vector2DAction(Vector2D newValue);
+
+///
+/// An action that takes a double as a parameter
+///
public delegate void DeltaAction(double deltaTime);
+///
+/// An action that takes a
+///
public delegate void WindowStateAction(WindowState newState);
+///
+/// An action that takes a list of strings as a parameter, intended for file path callbacks
+///
public delegate void FilePathsAction(string[] filePaths);
-public delegate void ToggleAction(bool newValue);
\ No newline at end of file
+///
+/// An action that takes a bool as a parameter, intended for a callback when things are toggled.
+///
+public delegate void ToggleAction(bool newValue);
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
index 9f2fc1c094..50daddd1f6 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs
@@ -1,4 +1,8 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using System.Collections.Generic;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
@@ -54,7 +58,7 @@ public interface IDesktopSurface : ISurface
IEnumerable? AvailableScreens { get; }
///
- /// Gets or sets whether the window waits for an event to be posted before existing .
+ /// Gets or sets whether the window waits for an event to be posted before existing .
///
bool IsEventDriven { get; set; }
@@ -75,7 +79,7 @@ public interface IDesktopSurface : ISurface
///
/// Because these are distances and not coordinates, they are always zero or positive.
///
- ///
+ ///
Rectangle BorderSize { get; }
///
@@ -107,19 +111,13 @@ public interface IDesktopSurface : ISurface
/// Sets the window icons.
///
/// Either a collection of window icons, or null to set to the default icon.
- void SetWindowIcon(ReadOnlySpan icons)
- {
- throw new NotImplementedException();
- }
+ void SetWindowIcon(ReadOnlySpan icons);
///
- /// When using = true, wakes the main thread from
+ /// When using = true, wakes the main thread from
/// its blocking wait on incoming events. Can be called from any thread.
///
- void ContinueEvents()
- {
- throw new NotImplementedException();
- }
+ void ContinueEvents();
///
/// Converts this point to client coordinates.
@@ -127,10 +125,7 @@ void ContinueEvents()
/// The point to transform.
/// The transformed point.
/// Expects screen coordinates as input.
- Vector2D PointToClient(Vector2D point)
- {
- return new Vector2D(point.X - Position.X, point.Y - Position.Y);
- }
+ Vector2D PointToClient(Vector2D point);
///
/// Converts this point to screen coordinates.
@@ -138,13 +133,6 @@ Vector2D PointToClient(Vector2D point)
/// The point to transform.
/// The transformed point.
/// Expects client coordinates as input.
- Vector2D PointToScreen(Vector2D point)
- {
- return new Vector2D(point.X + Position.X, point.Y + Position.Y);
- }
- public Vector2D PointToFramebuffer(Vector2D point)
- {
- throw new NotImplementedException();
- }
+ Vector2D PointToScreen(Vector2D point);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
index 4ca2956fb2..f024ed15a9 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLDesktopSurface.cs
@@ -1,5 +1,9 @@
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// An interface that defines a desktop surface with the ability to create a desktop GL Context
+ ///
public interface IGLDesktopSurface : IDesktopSurface, IGLSurface { }
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
index bfae8bd52c..07e9d75b1a 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLSurface.cs
@@ -1,17 +1,28 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
+ ///
+ /// A surface that can have a desktop GL context.
+ ///
public interface IGLSurface : INativeGLSurface
{
+ ///
+ /// The flags the context was created with
+ ///
ContextFlags ContextFlags { get; set; }
+ ///
+ /// The profile of the specified context.
+ ///
ContextProfile ContextProfile { get; set; }
- IGLSurface? SharedContext { get; set; }
+ ///
+ /// The surface representing the context to use.
+ ///
+ IGLSurface? SharedContext { get; set; } // Redhacker1/Donovan: DAFUQ? What exactly is supposed to be going on here
///
/// Enables OpenGL support for this surface. This will create a surface upon initialization.
///
- bool TryEnableOpenGL()
- {
- throw new NotImplementedException();
- }
+ bool TryEnableOpenGL();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
index 0dfeeff8b0..90157a7d37 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGLTransparentFramebufferSurface.cs
@@ -1,8 +1,16 @@
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a GL Surface with a transparent Framebuffer
+ ///
+ // Is GLFW making this an optional feature worth adding this? -Donovan/Redhacker1
public interface IGLTransparentFramebuffer : INativeGLSurface
{
+ ///
+ /// Whether the buffer can be actually transparent
+ ///
bool TransparentFramebuffer { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
index 58ff9afece..76253f9e0f 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesDesktopSurface.cs
@@ -1,7 +1,12 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
+ ///
+ /// A Desktop Surface with the ability to create a GLES surface
+ ///
public interface IGlesDesktopSurface : IDesktopSurface, IGlesSurface
{
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
index 22ab3f2966..73dcaa930e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IGlesSurface.cs
@@ -1,11 +1,19 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
+ ///
+ /// Defines a surface that can have a GLES context attatched
+ ///
public interface IGlesSurface : INativeGLSurface
{
- IGlesSurface? SharedContext { get; set; }
+ ///
+ /// The surface representing the context to use.
+ ///
+ IGlesSurface? SharedContext { get; set; } // Donovan/Redhacker1: How on earth is this supposed to work?
///
/// Enables OpenGLES support for this surface. This will create a surface upon initialization.
///
bool TryEnableOpenGLES();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
index 9208ecc56d..056545ab77 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/INativeGLSurface.cs
@@ -1,12 +1,23 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
public interface INativeGLSurface : ISurface
{
+ ///
+ /// the GL Handle
+ ///
nint Handle { get; }
+ ///
+ /// Whether this is the currently running context on this thread
+ ///
bool IsContextCurrent { get; set; }
+ ///
+ /// Should the buffers swap immediately upon completion?
+ ///
bool ShouldSwapAutomatically { get; set; }
///
@@ -48,9 +59,6 @@ public interface INativeGLSurface : ISurface
Version32? ApiVersion { get; set; }
nint? GetProcAddress(string proc);
- void SwapBuffers()
- {
- throw new NotImplementedException();
- }
+ void SwapBuffers();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
index 8f512cf73b..c81da687df 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IScreen.cs
@@ -1,9 +1,12 @@
-using Silk.NET.Maths;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System.Collections.Generic;
+using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
///
- /// An interface representing a screen.
+ /// An interface representing a screen
///
public interface IScreen
{
@@ -36,9 +39,6 @@ public interface IScreen
/// Get all video modes that this screen supports.
///
/// An array of all video modes.
- IEnumerable GetAllVideoModes()
- {
- throw new NotImplementedException();
- }
+ IEnumerable GetAllVideoModes();
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
index 16844b2599..cf35541fef 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/ISurface.cs
@@ -1,8 +1,14 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a surface with a framebuffer on which to draw on.
+ ///
public interface ISurface : IWindowHandlesSource, IDisposable
{
///
@@ -94,50 +100,32 @@ public interface ISurface : IWindowHandlesSource, IDisposable
///
/// Creates the surface on the underlying platform.
///
- void Initialize()
- {
- throw new NotImplementedException();
- }
+ void Initialize();
///
/// Calls the Render event.
///
- void DoRender()
- {
- throw new NotImplementedException();
- }
+ void DoRender();
///
/// Calls the Update event.
///
- void DoUpdate()
- {
- throw new NotImplementedException();
- }
+ void DoUpdate();
///
/// Polls the underlying platform for events.
///
- void DoEvents()
- {
- throw new NotImplementedException();
- }
+ void DoEvents();
///
/// Unloads the surface on the underlying platform.
///
- void Reset()
- {
- throw new NotImplementedException();
- }
+ void Reset();
///
/// Terminates this surface.
///
- void Terminate()
- {
- throw new NotImplementedException();
- }
+ void Terminate();
///
/// Converts this point to framebuffer coordinates.
@@ -145,18 +133,12 @@ void Terminate()
/// The point to transform.
/// The transformed point.
/// Expects client coordinates as input.
- Vector2D PointToFramebuffer(Vector2D point)
- {
- throw new NotImplementedException();
- }
+ Vector2D PointToFramebuffer(Vector2D point);
///
/// Initiates a render loop in which the given callback is called as fast as the underlying platform can manage.
///
/// The callback to run each frame.
- void Run(Action onFrame)
- {
- throw new NotImplementedException();
- }
+ void Run(Action onFrame);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
index 348380ea34..1aeb549a91 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkDesktopSurface.cs
@@ -1,6 +1,10 @@
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a surface with Vulkan support
+ ///
public interface IVkSurface : ISurface
{
/// Enables Vulkan support for this surface.
@@ -12,19 +16,13 @@ public interface IVkSurface : ISurface
/// The Vulkan instance to create a surface for.
/// A custom Vulkan allocator. Can be omitted by passing null.
/// A handle to the Vulkan surface created
- unsafe ulong Create(nint instance, void* allocator)
- {
- throw new NotImplementedException();
- }
+ unsafe ulong Create(nint instance, void* allocator);
///
/// Get the extensions required for Vulkan to work on this platform.
///
/// The number of extensions in the returned array
/// An array of strings, containing names for all required extensions
- unsafe byte** GetRequiredExtensions(out uint count)
- {
- throw new NotImplementedException();
- }
+ unsafe byte** GetRequiredExtensions(out uint count);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
index 43f71131d6..be3056d659 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IVkSurface.cs
@@ -1,6 +1,9 @@
-using Silk.NET.Core.Contexts;
-
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a desktop surface with Vulkan support
+ ///
public interface IVkDesktopSurface : IDesktopSurface, IVkSurface { }
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
index 49fa6b37f9..3dab0d04e8 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/IWindowHandlesSource.cs
@@ -1,7 +1,15 @@
-namespace Silk.NET.Core
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Core
{
+ ///
+ /// Represents something that has access to a window handle
+ ///
public interface IWindowHandlesSource
{
+ ///
+ /// The native handles this window could possibly have, the .Net foundation reserves the right to append to this list as they see fit
+ ///
WindowHandles Native { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
index 039b5eddff..9ae1a5b028 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/RawImage.cs
@@ -1,6 +1,7 @@
-
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+
namespace Silk.NET.Core
{
///
@@ -14,7 +15,7 @@ namespace Silk.NET.Core
/// The width of the image.
/// The height of the image.
/// The image daqta.
- public RawImage(int width, int height, Memory rgbaPixels)
+ public RawImage(int width, int height, ReadOnlyMemory rgbaPixels)
{
Pixels = rgbaPixels;
Width = width;
@@ -33,7 +34,7 @@ public RawImage(int width, int height, Memory rgbaPixels)
///
/// The image data.
///
- public Memory Pixels { get; }
+ public ReadOnlyMemory Pixels { get; }
///
/// Checks whether the two given s are equal.
@@ -72,7 +73,7 @@ public bool Equals(RawImage other)
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
return obj is RawImage other && Equals(other);
}
@@ -80,4 +81,4 @@ public override bool Equals(object obj)
///
public override int GetHashCode() => HashCode.Combine(Width, Height, Pixels);
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
index f9fa119e79..1a9b7deb4e 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/Surface.cs
@@ -1,20 +1,44 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+namespace Silk.NET.Windowing
{
+ ///
+ /// A factory that creates and/or gets surfaces.
+ ///
public static class Surface
{
+ ///
+ /// Whether the platform is supported by any backend of of Silk.Net.Windowing.
+ ///
+ ///
public static bool IsPlatformSupported { get => throw new NotImplementedException(); }
+ ///
+ /// Gets a surface if a surface already exist, if it does then return said surface.
+ ///
+ /// an object.
+ // Does this return null on IsPlatformSupported is false? Does it throw? Should it return a bool indicating whether it returned an existing surface or created a new one?
public static ISurface GetOrCreate()
{
throw new NotImplementedException();
}
+ ///
+ /// Creates an regardless as to whether one already exists
+ ///
+ /// an object.
+ // Does this return null on IsPlatformSupported is false? Does it throw? Should it return a bool indicating whether it returned an existing surface or created a new one?
public static ISurface CreateNew()
{
throw new NotImplementedException();
}
+
+ ///
+ /// Clears the contexts of ALL objects.
+ ///
public static void ClearCurrentContexts()
{
throw new NotImplementedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
index 1fe824cf2e..56a1dc6887 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/SurfaceExtensions.cs
@@ -1,4 +1,7 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using Silk.NET.Core;
using Silk.NET.Maths;
namespace Silk.NET.Windowing
@@ -11,7 +14,7 @@ public static class SurfaceExtensions
///
/// Start the default event loop on this surface.
///
- /// The surface to begin the loop on.
+ /// The surface to begin the loop on.
public static void Run(this ISurface surface)
{
throw new NotImplementedException();
@@ -51,9 +54,9 @@ public static void SetDefaultIcon(this IDesktopSurface window)
///
/// The window.
/// The icon to set.
- public static void SetWindowIcon(this IDesktopSurface window, ref RawImage icon)
+ public static void SetWindowIcon(this IDesktopSurface window, RawImage icon)
{
throw new NotImplementedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
index c4e97ab052..7a3a18d24b 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/VideoMode.cs
@@ -1,14 +1,29 @@
-using Silk.NET.Maths;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using Silk.NET.Maths;
namespace Silk.NET.Windowing
{
+ ///
+ /// Represents a screens supported refresh rate and resolution
+ ///
public readonly struct VideoMode
{
+ ///
+ /// Creates a with a resolution and refreshRate parameter.
+ ///
+ /// The dimensions of the VideoMode in question
+ /// How many times per second the screen refreshes
public VideoMode(Vector2D? resolution = null, int? refreshRate = null)
{
throw new NotImplementedException();
}
+ ///
+ /// Creates a with a refreshRate parameter.
+ ///
+ /// How many times per second the screen refreshes
public VideoMode(int? refreshRate)
{
throw new NotImplementedException();
@@ -29,4 +44,4 @@ public VideoMode(int? refreshRate)
///
public static VideoMode Default { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
index 204237168c..d29db0e943 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowBorder.cs
@@ -1,4 +1,6 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
///
/// Represents the window border.
@@ -20,4 +22,4 @@ public enum WindowBorder
///
Hidden
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
index 1135289ef4..63d5c1839d 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowHandles.cs
@@ -1,11 +1,17 @@
-using System.Runtime.InteropServices;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System.Runtime.InteropServices;
namespace Silk.NET.Core
{
+ ///
+ /// A struct of potential WindowHandles, represented by nullables
+ ///
[StructLayout(LayoutKind.Auto)]
public struct WindowHandles
{
+ /// Probably redundant? Not sure
public bool IsSupported { get; }
// ...
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
index 71737bff2c..44894c1819 100644
--- a/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
+++ b/src/libraries/Silk.Net.Windowing/Abstract/WindowState.cs
@@ -1,4 +1,6 @@
-namespace Silk.NET.Windowing
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+namespace Silk.NET.Windowing
{
///
/// Represents the current state of the window.
@@ -25,4 +27,4 @@ public enum WindowState
///
Fullscreen
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
index d4131474c0..cc8c0d875c 100644
--- a/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
+++ b/src/libraries/Silk.Net.Windowing/Implementations/GLFW/GLFWSurface.cs
@@ -1,88 +1,435 @@
-using Silk.NET.Core;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using System.Collections.Generic;
+using Silk.NET.Core;
using Silk.NET.Maths;
-namespace Silk.NET.Windowing.Implementations.GLFW;
-
-public class GLFWSurface : IGLTransparentFramebuffer, IGlesDesktopSurface, IVkDesktopSurface, IGLDesktopSurface
+namespace Silk.NET.Windowing.Implementations.GLFW
{
- IGlesSurface? _sharedContext;
- IGLSurface? _sharedContext1;
- public WindowHandles Native { get; }
- public void Dispose()
+ ///
+ /// A Desktop surface backed by GLFW
+ ///
+ public class GLFWSurface : IGLTransparentFramebuffer, IGlesDesktopSurface, IVkDesktopSurface, IGLDesktopSurface
{
- throw new NotImplementedException();
- }
+ private IGlesSurface? _sharedContext;
+ private IGLSurface? _sharedContext1;
- public bool IsTerminating { get; }
- public bool IsPausing { get; }
- public double Time { get; }
- public Vector2D FramebufferSize { get; }
- public bool IsVisible { get; set; }
- public Vector2D Position { get; set; }
- public Vector2D Size { get; set; }
- public string Title { get; set; }
- public WindowState WindowState { get; set; }
- public WindowBorder WindowBorder { get; set; }
- public VideoMode VideoMode { get; set; }
- public IScreen? CurrentScreen { get; set; }
- public IEnumerable? AvailableScreens { get; }
- public bool IsEventDriven { get; set; }
- public bool IsCloseRequested { get; set; }
- public bool IsFocused { get; }
- public Rectangle BorderSize { get; }
- public event Action? CloseRequested;
- public event Vector2DAction? Move;
- public event WindowStateAction? StateChanged;
- public event FilePathsAction? FileDrop;
- public event ToggleAction? FocusChanged;
- public double FramesPerSecond { get; set; }
- public double UpdatesPerSecond { get; set; }
- public event Vector2DAction? Resize;
- public event Vector2DAction? FramebufferResize;
- public event Action? Terminating;
- public event Action? LowMemory;
- public event Action? Pausing;
- public event Action? Resuming;
- public event Action? Created;
- public event Action? PreUpdate;
- public event DeltaAction? Update;
- public event DeltaAction? Render;
- public nint Handle { get; }
- public bool IsContextCurrent { get; set; }
- public bool ShouldSwapAutomatically { get; set; }
- public int SwapInterval { get; set; }
- public int? PreferredDepthBufferBits { get; set; }
- public int? PreferredStencilBufferBits { get; set; }
- public Vector4D? PreferredBitDepth { get; set; }
- public Version32? ApiVersion { get; set; }
- public nint? GetProcAddress(string proc)
- {
- throw new NotImplementedException();
- }
+
+ ///
+ ///
+ ///
+ public WindowHandles Native { get; }
+
+ ///
+ ///
+ ///
+ public void Dispose()
+ {
+ throw new NotImplementedException();
+ }
- public bool TransparentFramebuffer { get; set; }
- public ContextFlags ContextFlags { get; set; }
- public ContextProfile ContextProfile { get; set; }
+ ///
+ ///
+ ///
+ public bool IsTerminating { get; }
+
+ ///
+ ///
+ ///
+ public bool IsPausing { get; }
- IGLSurface? IGLSurface.SharedContext
- {
- get => _sharedContext1;
- set => _sharedContext1 = value;
- }
+ ///
+ ///
+ ///
+ public double Time { get; }
+
+ ///
+ ///
+ ///
+ public Vector2D FramebufferSize { get; }
+
+ ///
+ ///
+ ///
+ public bool IsVisible { get; set; }
+
+ ///
+ ///
+ ///
+ public Vector2D Position { get; set; }
+
+ ///
+ ///
+ ///
+ public Vector2D Size { get; set; }
+
+ ///
+ ///
+ ///
+ public string Title { get; set; } = null!;
- IGlesSurface? IGlesSurface.SharedContext
- {
- get => _sharedContext;
- set => _sharedContext = value;
- }
+ ///
+ ///
+ ///
+ public WindowState WindowState { get; set; }
+
+ ///
+ ///
+ ///
+ public WindowBorder WindowBorder { get; set; }
+
+ ///
+ ///
+ ///
+ public VideoMode VideoMode { get; set; }
+
+ ///
+ ///
+ ///
+ public IScreen? CurrentScreen { get; set; }
+
+ ///
+ ///
+ ///
+ public IEnumerable? AvailableScreens { get; }
+
+ ///
+ ///
+ ///
+ public bool IsEventDriven { get; set; }
+
+ ///
+ ///
+ ///
+ public bool IsCloseRequested { get; set; }
+
+ ///
+ ///
+ ///
+ public bool IsFocused { get; }
+
+ ///
+ ///
+ ///
+ public Rectangle BorderSize { get; }
+
+ ///
+ ///
+ ///
+ public event Action? CloseRequested;
+
+ ///
+ ///
+ ///
+ public event Vector2DAction? Move;
+
+ ///
+ ///
+ ///
+ public event WindowStateAction? StateChanged;
+
+ ///
+ ///
+ ///
+ public event FilePathsAction? FileDrop;
+
+ ///
+ ///
+ ///
+ public event ToggleAction? FocusChanged;
+
+ ///
+ ///
+ ///
+ public void SetWindowIcon(ReadOnlySpan icons)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void ContinueEvents()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public Vector2D PointToClient(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public Vector2D PointToScreen(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
- public bool TryEnableOpenGLES()
- {
- throw new NotImplementedException();
- }
+
+ ///
+ ///
+ ///
+ public double FramesPerSecond { get; set; }
+
+ ///
+ ///
+ ///
+ public double UpdatesPerSecond { get; set; }
+
+ ///
+ ///
+ ///
+ public event Vector2DAction? Resize;
+
+ ///
+ ///
+ ///
+ public event Vector2DAction? FramebufferResize;
+
+ ///
+ ///
+ ///
+ public event Action? Terminating;
+
+ ///
+ ///
+ ///
+ public event Action? LowMemory;
+
+ ///
+ ///
+ ///
+ public event Action? Pausing;
+
+ ///
+ ///
+ ///
+ public event Action? Resuming;
+
+ ///
+ ///
+ ///
+ public event Action? Created;
+
+ ///
+ ///
+ ///
+ public event Action? PreUpdate;
+
+ ///
+ ///
+ ///
+ public event DeltaAction? Update;
+
+ ///
+ ///
+ ///
+ public event DeltaAction? Render;
+
+ ///
+ ///
+ ///
+ public void Initialize()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void DoRender()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void DoUpdate()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void DoEvents()
+ {
+ throw new NotImplementedException();
+ }
- public bool TryEnableVulkan()
- {
- throw new NotImplementedException();
+ ///
+ ///
+ ///
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void Terminate()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public Vector2D PointToFramebuffer(Vector2D point)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void Run(Action onFrame)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public nint Handle { get; }
+
+ ///
+ ///
+ ///
+ public bool IsContextCurrent { get; set; }
+
+ ///
+ ///
+ ///
+ public bool ShouldSwapAutomatically { get; set; }
+
+ ///
+ ///
+ ///
+ public int SwapInterval { get; set; }
+
+ ///
+ ///
+ ///
+ public int? PreferredDepthBufferBits { get; set; }
+
+ ///
+ ///
+ ///
+ public int? PreferredStencilBufferBits { get; set; }
+
+ ///
+ ///
+ ///
+ public Vector4D? PreferredBitDepth { get; set; }
+
+ ///
+ ///
+ ///
+ public Version32? ApiVersion { get; set; }
+
+ ///
+ ///
+ ///
+ public nint? GetProcAddress(string proc)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public void SwapBuffers()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ ///
+ ///
+ public bool TransparentFramebuffer { get; set; }
+
+
+ ///
+ ///
+ ///
+ public ContextFlags ContextFlags { get; set; }
+
+
+ ///
+ ///
+ ///
+ public ContextProfile ContextProfile { get; set; }
+
+ ///
+ ///
+ ///
+ IGLSurface? IGLSurface.SharedContext
+ {
+ get => _sharedContext1;
+ set => _sharedContext1 = value;
+ }
+
+ ///
+ ///
+ ///
+ public bool TryEnableOpenGL()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ IGlesSurface? IGlesSurface.SharedContext
+ {
+ get => _sharedContext;
+ set => _sharedContext = value;
+ }
+
+
+ ///
+ ///
+ ///
+ public bool TryEnableOpenGLES()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ public bool TryEnableVulkan()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ public unsafe ulong Create(nint instance, void* allocator)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ ///
+ ///
+ ///
+ public unsafe byte** GetRequiredExtensions(out uint count)
+ {
+ throw new NotImplementedException();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
index 818681a097..54b3e83c5c 100644
--- a/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
+++ b/src/libraries/Silk.Net.Windowing/Silk.Net.Windowing.csproj
@@ -2,6 +2,7 @@
$(SilkTargetFramework)
+
enable
true
true
@@ -10,4 +11,9 @@
true
+
+
+
+
+
diff --git a/tests/Silk.NET.Core.Tests/Program.cs b/tests/Silk.NET.Core.Tests/Program.cs
new file mode 100644
index 0000000000..ace37b0bff
--- /dev/null
+++ b/tests/Silk.NET.Core.Tests/Program.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using Xunit;
+using Silk.NET.Core;
+
+namespace Silk.NET.Core.Tests
+{
+ public class Tests
+ {
+ //Gets an IEnumerable with Offsets of 0
+ private IEnumerable<(uint, uint, uint, uint)> Range => Sample();
+ ///
+ /// Tests within the range of valid for > if any of them throw, fail the test
+ ///
+ [Theory, MemberData(nameof(Range))]
+ public void InRangeTest(uint variant, uint major, uint minor, uint patch)
+ {
+ try
+ {
+ new Version32(variant, major, minor, patch);
+ }
+ catch (ArgumentOutOfRangeException)
+ {
+ Assert.True(false, $"In range test failed with values: Variant: {variant} Major: {major}, Minor: {minor}, Patch: {patch}");
+ }
+ }
+
+ ///
+ /// An integer with numberOfBits turned on starting at the low-order bit. Ex: CalcNumBits(4) == 15 (2^4)-1
+ ///
+ /// The number of bits to "light up" or turn on.
+ /// An integer with numberOfBits turned on
+ public static int CalcNumBits(int numberOfBits)
+ {
+ return ~(~0 << numberOfBits);
+ }
+
+
+ public static IEnumerable<(uint, uint, uint, uint)> Sample()
+ {
+ for (uint variant = 0; variant == CalcNumBits(3); variant++)
+ for(uint major = 0; major == CalcNumBits(7); major++)
+ for(uint minor = 0; minor == CalcNumBits(10); minor++)
+ for (uint patch = 0; patch == CalcNumBits(12); patch++)
+ yield return (variant,major,minor,patch);
+ }
+
+
+ ///
+ /// Tests outside the range of valid for . If any of them throw, fail the test
+ ///
+ [Theory, MemberData(nameof(Range))]
+ public void OutsideRangeTest(uint variant, uint major, uint minor, uint patch)
+ {
+ try
+ {
+ new Version32(variant + (uint)CalcNumBits(3) + 1u, major + (uint)CalcNumBits(7) + 1u, minor+ (uint)CalcNumBits(10) + 1u, patch + (uint)CalcNumBits(12) + 1u);
+ }
+ catch (ArgumentOutOfRangeException)
+ {
+ return;
+ }
+ Assert.True(false , $"Out of range test failed with values: {major}, {minor}, {patch}");
+ }
+ }
+}
diff --git a/tests/Silk.NET.Core.Tests/Silk.NET.Core.Tests.csproj b/tests/Silk.NET.Core.Tests/Silk.NET.Core.Tests.csproj
new file mode 100644
index 0000000000..61811682bc
--- /dev/null
+++ b/tests/Silk.NET.Core.Tests/Silk.NET.Core.Tests.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net6.0
+ false
+
+ true
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
From abc46d312bcb7889b8a8f4c73ca0788a4b2daf77 Mon Sep 17 00:00:00 2001
From: Redhacker1 <66490743+Redhacker1@users.noreply.github.com>
Date: Sat, 13 Aug 2022 12:24:53 -0500
Subject: [PATCH 5/6] readd nuget config
For some reason my branch is not picking it up
---
nuget.config | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 nuget.config
diff --git a/nuget.config b/nuget.config
new file mode 100644
index 0000000000..b2f8b565e8
--- /dev/null
+++ b/nuget.config
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 369a0188ccc9ba67ec52f3b11b46ad94a3b5cd52 Mon Sep 17 00:00:00 2001
From: Redhacker1 <66490743+Redhacker1@users.noreply.github.com>
Date: Sun, 28 Aug 2022 11:27:36 -0500
Subject: [PATCH 6/6] attempt to improve test method
---
Silk.NET.sln | 4 ++++
.../Silk.NET.Maths/Silk.NET.Maths.csproj | 6 ------
tests/Silk.NET.Core.Tests/Program.cs | 15 +++++++++------
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/Silk.NET.sln b/Silk.NET.sln
index 7996100e78..058a1297c2 100644
--- a/Silk.NET.sln
+++ b/Silk.NET.sln
@@ -346,6 +346,10 @@ Global
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x64.Build.0 = Release|Any CPU
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x86.ActiveCfg = Release|Any CPU
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x86.Build.0 = Release|Any CPU
+ {7A2A3176-DBA1-4026-AF65-8E36B4F09B02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7A2A3176-DBA1-4026-AF65-8E36B4F09B02}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7A2A3176-DBA1-4026-AF65-8E36B4F09B02}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7A2A3176-DBA1-4026-AF65-8E36B4F09B02}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/libraries/Silk.NET.Maths/Silk.NET.Maths.csproj b/src/libraries/Silk.NET.Maths/Silk.NET.Maths.csproj
index d121e59ce5..c6ee69d908 100644
--- a/src/libraries/Silk.NET.Maths/Silk.NET.Maths.csproj
+++ b/src/libraries/Silk.NET.Maths/Silk.NET.Maths.csproj
@@ -7,12 +7,6 @@
true
true
9.0
-
-
- $(DefineConstants);SSE
- $(DefineConstants);BTEC_INTRINSICS;MATHF
- $(DefineConstants);POH;AdvSIMD
- true
true
diff --git a/tests/Silk.NET.Core.Tests/Program.cs b/tests/Silk.NET.Core.Tests/Program.cs
index ace37b0bff..3f8d6e11d4 100644
--- a/tests/Silk.NET.Core.Tests/Program.cs
+++ b/tests/Silk.NET.Core.Tests/Program.cs
@@ -8,7 +8,7 @@ namespace Silk.NET.Core.Tests
public class Tests
{
//Gets an IEnumerable with Offsets of 0
- private IEnumerable<(uint, uint, uint, uint)> Range => Sample();
+ private static IEnumerable<(uint, uint, uint, uint)> Range => Sample();
///
/// Tests within the range of valid for > if any of them throw, fail the test
///
@@ -38,11 +38,14 @@ public static int CalcNumBits(int numberOfBits)
public static IEnumerable<(uint, uint, uint, uint)> Sample()
{
- for (uint variant = 0; variant == CalcNumBits(3); variant++)
- for(uint major = 0; major == CalcNumBits(7); major++)
- for(uint minor = 0; minor == CalcNumBits(10); minor++)
- for (uint patch = 0; patch == CalcNumBits(12); patch++)
- yield return (variant,major,minor,patch);
+ for (uint variant = 0; variant <= CalcNumBits(3); variant++)
+ for(uint major = 0; major <= CalcNumBits(7); major++)
+ for(uint minor = 0; minor <= CalcNumBits(10); minor++)
+ for (uint patch = 0; patch <= CalcNumBits(12); patch++)
+ {
+ yield return (variant,major,minor,patch);
+ }
+
}