Skip to content

Commit 0e95025

Browse files
committed
Resolving issues seen by Kai
Implementing test for Version32, moving Version32 to Core, removing implementations from Interfaces among other stuff I probably forgot.
1 parent d10fe33 commit 0e95025

28 files changed

+799
-215
lines changed

Silk.NET.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.SilkTouch.Integrat
8282
EndProject
8383
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}"
8484
EndProject
85+
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}"
86+
EndProject
8587
Global
8688
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8789
Debug|Any CPU = Debug|Any CPU
@@ -332,6 +334,18 @@ Global
332334
{381D1039-3259-488F-BB25-D90EE63A3E82}.Release|x64.Build.0 = Release|Any CPU
333335
{381D1039-3259-488F-BB25-D90EE63A3E82}.Release|x86.ActiveCfg = Release|Any CPU
334336
{381D1039-3259-488F-BB25-D90EE63A3E82}.Release|x86.Build.0 = Release|Any CPU
337+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
338+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
339+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x64.ActiveCfg = Debug|Any CPU
340+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x64.Build.0 = Debug|Any CPU
341+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x86.ActiveCfg = Debug|Any CPU
342+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Debug|x86.Build.0 = Debug|Any CPU
343+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
344+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|Any CPU.Build.0 = Release|Any CPU
345+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x64.ActiveCfg = Release|Any CPU
346+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x64.Build.0 = Release|Any CPU
347+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x86.ActiveCfg = Release|Any CPU
348+
{6076C9E6-D094-49C5-B526-0AF355D11AC7}.Release|x86.Build.0 = Release|Any CPU
335349
EndGlobalSection
336350
GlobalSection(SolutionProperties) = preSolution
337351
HideSolutionNode = FALSE
@@ -364,6 +378,7 @@ Global
364378
{66FE736C-C407-44C3-A94E-4345E22AA95E} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
365379
{381D1039-3259-488F-BB25-D90EE63A3E82} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
366380
{7A2A3176-DBA1-4026-AF65-8E36B4F09B02} = {C9718C94-2F21-4E8D-B55D-8F0B1A131346}
381+
{6076C9E6-D094-49C5-B526-0AF355D11AC7} = {94D5D1E1-B998-4CB1-9D04-DA138A2B0F3C}
367382
EndGlobalSection
368383
GlobalSection(ExtensibilityGlobals) = postSolution
369384
SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D}

src/libraries/Silk.Net.Windowing/Abstract/Version32.cs renamed to src/libraries/Silk.NET.Core/Version32.cs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-

2-
using System;
3-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
42
// The .NET Foundation licenses this file to you under the MIT license.
3+
using System;
54
namespace Silk.NET.Core
65
{
76
/// <summary>
@@ -13,18 +12,45 @@ public readonly struct Version32
1312
/// The underlying Vulkan-compatible 32-bit version integer.
1413
/// </summary>
1514
public uint Value { get; }
15+
1616
/// <summary>
1717
/// Creates a Vulkan version structure from the given major, minor, and patch values.
1818
/// </summary>
19-
/// <param name="major">The major value.</param>
20-
/// <param name="minor">The minor value.</param>
21-
/// <param name="patch">The patch value.</param>
22-
public Version32(uint major, uint minor, uint patch) => Value = major << 22 | minor << 12 | patch;
19+
/// <param name="variant">The major value. It is a 3-bit integer</param>
20+
/// <param name="major">The major value. It is a 7-bit integer</param>
21+
/// <param name="minor">The minor value. It is a 10-bit integer</param>
22+
/// <param name="patch">The patch value. It is a 12-bit integer</param>
23+
/// <exception cref="ArgumentOutOfRangeException">major, minor, or patch were out of the range of valid values</exception>
24+
public Version32(uint variant, uint major, uint minor, uint patch)
25+
{
26+
/*The variant is a 3-bit integer packed into bits 31-29. -Donovan/Redhacker1, Why is this not used?
27+
28+
The major version is a 7-bit integer packed into bits 28-22. 2^7 = 128
29+
30+
The minor version number is a 10-bit integer packed into bits 21-12. 2^10 = 1024
31+
32+
The patch version number is a 12-bit integer packed into bits 11-0. 2^12 = 4096
33+
*/
34+
// Sanity check to ensure that the values are correct
35+
if ( (variant & uint.MaxValue - 7) != 0 || (major & uint.MaxValue - 127) != 0 || (minor & uint.MaxValue - 1023) != 0 || (patch & uint.MaxValue - 4095) != 0)
36+
{
37+
throw new ArgumentOutOfRangeException("variant, major, minor and/or patch were out of range, ");
38+
}
39+
40+
41+
Value = (variant & 7) << 29 | (major & 127) << 22 | (minor & 1023) << 12 | (patch & 4095);
42+
}
43+
2344
/// <summary>
2445
/// Creates a Vulkan version structure from the given Vulkan-compatible value.
2546
/// </summary>
2647
/// <param name="value">The value.</param>
2748
private Version32(uint value) => Value = value;
49+
50+
/// <summary>
51+
/// Gets the variant component of this version structure.
52+
/// </summary>
53+
public uint Variant => Value >> 29;
2854
/// <summary>
2955
/// Gets the major component of this version structure.
3056
/// </summary>
@@ -50,7 +76,7 @@ public readonly struct Version32
5076
/// <param name="version">The version instance.</param>
5177
/// <returns>The 32-bit version structure.</returns>
5278
public static implicit operator Version32
53-
(Version version) => new Version32((uint) version.Major, (uint) version.Minor, (uint) version.Build);
79+
(Version version) => new Version32(0, (uint) version.Major, (uint) version.Minor, (uint) version.Build);
5480

5581
/// <summary>
5682
/// Gets the 32-bit unsigned integer representation for this 32-bit version structure.
@@ -67,4 +93,4 @@ public static implicit operator Version32
6793
public static implicit operator Version
6894
(Version32 version) => new Version((int) version.Major, (int) version.Minor, (int) version.Patch);
6995
}
70-
}
96+
}

src/libraries/Silk.Net.Windowing/Abstract/ContextFlags.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
namespace Silk.NET.Windowing
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
using System;
4+
5+
namespace Silk.NET.Windowing
26
{
37
/// <summary>
48
/// Represents flags related to the OpenGL context.
@@ -23,4 +27,4 @@ public enum ContextFlags
2327
/// <remarks>On OpenGL contexts older than 3.0, this flag does nothing.</remarks>
2428
ForwardCompatible = 2
2529
}
26-
}
30+
}

src/libraries/Silk.Net.Windowing/Abstract/ContextProfile.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Silk.NET.Windowing
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
namespace Silk.NET.Windowing
24
{
35
/// <summary>
46
/// Represents the context profile OpenGL should use.
@@ -16,4 +18,4 @@ public enum ContextProfile
1618
/// </summary>
1719
Compatability
1820
}
19-
}
21+
}
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
using Silk.NET.Maths;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
using Silk.NET.Maths;
24
using Silk.NET.Windowing;
35

6+
//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.
7+
/// <summary>
8+
/// An action that takes a <see cref="Vector2D{T}"/>
9+
/// </summary>
410
public delegate void Vector2DAction(Vector2D<int> newValue);
11+
12+
/// <summary>
13+
/// An action that takes a double as a parameter
14+
/// </summary>
515
public delegate void DeltaAction(double deltaTime);
16+
/// <summary>
17+
/// An action that takes a <see cref="WindowState"/>
18+
/// </summary>
619
public delegate void WindowStateAction(WindowState newState);
20+
/// <summary>
21+
/// An action that takes a list of strings as a parameter, intended for file path callbacks
22+
/// </summary>
723
public delegate void FilePathsAction(string[] filePaths);
8-
public delegate void ToggleAction(bool newValue);
24+
/// <summary>
25+
/// An action that takes a bool as a parameter, intended for a callback when things are toggled.
26+
/// </summary>
27+
public delegate void ToggleAction(bool newValue);

src/libraries/Silk.Net.Windowing/Abstract/IDesktopSurface.cs

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using Silk.NET.Core;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
using System;
4+
using System.Collections.Generic;
5+
using Silk.NET.Core;
26
using Silk.NET.Maths;
37

48
namespace Silk.NET.Windowing
@@ -54,7 +58,7 @@ public interface IDesktopSurface : ISurface
5458
IEnumerable<IScreen>? AvailableScreens { get; }
5559

5660
/// <summary>
57-
/// Gets or sets whether the window waits for an event to be posted before existing <see cref="DoEvents" />.
61+
/// Gets or sets whether the window waits for an event to be posted before existing <see cref="IDesktopSurface.DoEvents" />.
5862
/// </summary>
5963
bool IsEventDriven { get; set; }
6064

@@ -75,7 +79,7 @@ public interface IDesktopSurface : ISurface
7579
/// <remarks>
7680
/// Because these are distances and not coordinates, they are always zero or positive.
7781
/// </remarks>
78-
/// <seealso cref="WindowExtensions.GetFullSize"/>
82+
/// <seealso cref="IDesktopSurface.Size"/>
7983
Rectangle<int> BorderSize { get; }
8084

8185
/// <summary>
@@ -107,44 +111,28 @@ public interface IDesktopSurface : ISurface
107111
/// Sets the window icons.
108112
/// </summary>
109113
/// <param name="icons">Either a collection of window icons, or null to set to the default icon.</param>
110-
void SetWindowIcon(ReadOnlySpan<RawImage> icons)
111-
{
112-
throw new NotImplementedException();
113-
}
114+
void SetWindowIcon(ReadOnlySpan<RawImage> icons);
114115

115116
/// <summary>
116-
/// When using <see cref="WindowOptions.IsEventDriven"/> = true, wakes the main thread from
117+
/// When using <see cref="IDesktopSurface.IsEventDriven"/> = true, wakes the main thread from
117118
/// its blocking wait on incoming events. Can be called from any thread.
118119
/// </summary>
119-
void ContinueEvents()
120-
{
121-
throw new NotImplementedException();
122-
}
120+
void ContinueEvents();
123121

124122
/// <summary>
125123
/// Converts this point to client coordinates.
126124
/// </summary>
127125
/// <param name="point">The point to transform.</param>
128126
/// <returns>The transformed point.</returns>
129127
/// <remarks>Expects screen coordinates as input.</remarks>
130-
Vector2D<int> PointToClient(Vector2D<int> point)
131-
{
132-
return new Vector2D<int>(point.X - Position.X, point.Y - Position.Y);
133-
}
128+
Vector2D<int> PointToClient(Vector2D<int> point);
134129

135130
/// <summary>
136131
/// Converts this point to screen coordinates.
137132
/// </summary>
138133
/// <param name="point">The point to transform.</param>
139134
/// <returns>The transformed point.</returns>
140135
/// <remarks>Expects client coordinates as input.</remarks>
141-
Vector2D<int> PointToScreen(Vector2D<int> point)
142-
{
143-
return new Vector2D<int>(point.X + Position.X, point.Y + Position.Y);
144-
}
145-
public Vector2D<int> PointToFramebuffer(Vector2D<int> point)
146-
{
147-
throw new NotImplementedException();
148-
}
136+
Vector2D<int> PointToScreen(Vector2D<int> point);
149137
}
150-
}
138+
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-

1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23
namespace Silk.NET.Windowing
34
{
5+
/// <summary>
6+
/// An interface that defines a desktop surface with the ability to create a desktop GL Context
7+
/// </summary>
48
public interface IGLDesktopSurface : IDesktopSurface, IGLSurface { }
5-
}
9+
}
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
namespace Silk.NET.Windowing
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
namespace Silk.NET.Windowing
24
{
5+
/// <summary>
6+
/// A surface that can have a desktop GL context.
7+
/// </summary>
38
public interface IGLSurface : INativeGLSurface
49
{
10+
/// <summary>
11+
/// The flags the context was created with
12+
/// </summary>
513
ContextFlags ContextFlags { get; set; }
14+
/// <summary>
15+
/// The profile of the specified context.
16+
/// </summary>
617
ContextProfile ContextProfile { get; set; }
7-
IGLSurface? SharedContext { get; set; }
18+
/// <summary>
19+
/// The surface representing the context to use.
20+
/// </summary>
21+
IGLSurface? SharedContext { get; set; } // Redhacker1/Donovan: DAFUQ? What exactly is supposed to be going on here
822

923
/// <summary>
1024
/// Enables OpenGL support for this surface. This will create a surface upon initialization.
1125
/// </summary>
12-
bool TryEnableOpenGL()
13-
{
14-
throw new NotImplementedException();
15-
}
26+
bool TryEnableOpenGL();
1627
}
17-
}
28+
}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-

1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23
namespace Silk.NET.Windowing
34
{
5+
/// <summary>
6+
/// Represents a GL Surface with a transparent Framebuffer
7+
/// </summary>
8+
// Is GLFW making this an optional feature worth adding this? -Donovan/Redhacker1
49
public interface IGLTransparentFramebuffer : INativeGLSurface
510
{
11+
/// <summary>
12+
/// Whether the buffer can be actually transparent
13+
/// </summary>
614
bool TransparentFramebuffer { get; set; }
715
}
8-
}
16+
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
namespace Silk.NET.Windowing
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
namespace Silk.NET.Windowing
24
{
5+
/// <summary>
6+
/// A Desktop Surface with the ability to create a GLES surface
7+
/// </summary>
38
public interface IGlesDesktopSurface : IDesktopSurface, IGlesSurface
49
{
510

611
}
7-
}
12+
}

0 commit comments

Comments
 (0)