Skip to content

Commit 0e760e6

Browse files
committed
Start on a more clean sheet and conservative implementation
1 parent 2295ce6 commit 0e760e6

25 files changed

+1366
-619
lines changed

Silk.NET.sln

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SilkTouch", "SilkTouch", "{
9090
EndProject
9191
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Windowing", "Windowing", "{AE84F4C8-6102-4A72-86EF-0C9345AA27A9}"
9292
EndProject
93-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Windowing.Common", "sources\Windowing\Common\Silk.NET.Windowing.Common.csproj", "{D1542DA9-7C7D-417C-8B63-791570D4C4A0}"
94-
EndProject
9593
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Windowing", "sources\Windowing\Windowing\Silk.NET.Windowing.csproj", "{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}"
9694
EndProject
9795
Global
@@ -144,10 +142,6 @@ Global
144142
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Debug|Any CPU.Build.0 = Debug|Any CPU
145143
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Release|Any CPU.ActiveCfg = Release|Any CPU
146144
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Release|Any CPU.Build.0 = Release|Any CPU
147-
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
148-
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
149-
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
150-
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Release|Any CPU.Build.0 = Release|Any CPU
151145
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
152146
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}.Debug|Any CPU.Build.0 = Debug|Any CPU
153147
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -179,7 +173,6 @@ Global
179173
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807} = {49D426BF-A009-43D5-A9E2-EFAAAA7196FC}
180174
{600D712C-4ABF-44C4-96C3-B1DEE1F38298} = {AB25C482-DA9D-4335-8E26-2F29C3700152}
181175
{AE84F4C8-6102-4A72-86EF-0C9345AA27A9} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
182-
{D1542DA9-7C7D-417C-8B63-791570D4C4A0} = {AE84F4C8-6102-4A72-86EF-0C9345AA27A9}
183176
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52} = {AE84F4C8-6102-4A72-86EF-0C9345AA27A9}
184177
EndGlobalSection
185178
GlobalSection(ExtensibilityGlobals) = postSolution

sources/Core/Core/Abstractions/IGLContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ public interface IGLContext : INativeContext
1717
/// </summary>
1818
int SwapInterval { get; set; }
1919

20+
/// <summary>
21+
/// Gets or sets a value indicating whether <see cref="SwapInterval" /> is non-zero.
22+
/// </summary>
23+
bool VSync
24+
{
25+
get => SwapInterval > 0;
26+
set => SwapInterval = value ? 1 : 0;
27+
}
28+
2029
/// <summary>
2130
/// Swaps the backbuffer to present the contents to the window.
2231
/// </summary>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
4+
namespace Silk.NET.Core;
5+
6+
/// <summary>
7+
/// Represents a source of a <see cref="IGLContext" />
8+
/// </summary>
9+
// Same as in 1.X/2.X, just a different namespace.
10+
public interface IGLContextSource
11+
{
12+
/// <summary>
13+
/// The OpenGL context.
14+
/// </summary>
15+
IGLContext? GLContext { get; }
16+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
4+
using System.Diagnostics.CodeAnalysis;
5+
6+
namespace Silk.NET.Core;
7+
8+
/// <summary>
9+
/// Represents a window that possesses native handles or other platform-specific information.
10+
/// </summary>
11+
public interface INativeWindow
12+
{
13+
/// <summary>
14+
/// Attempts to obtain native platform information with type <typeparamref name="TPlatformInfo" />.
15+
/// </summary>
16+
/// <param name="info">
17+
/// The platform-specific information, or <c>default</c> if the platform-specific information is not available for
18+
/// this platform.
19+
/// </param>
20+
/// <returns>True if <paramref name="info" /> contains the platform-specific information, false otherwise.</returns>
21+
bool TryGetPlatformInfo<TPlatformInfo>([NotNullWhen(true)] out TPlatformInfo? info);
22+
}

sources/Core/Core/Abstractions/ITypeChain.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

sources/Core/Core/Abstractions/TypeChain`2.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

sources/Playground/Program.cs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// See https://aka.ms/new-console-template for more information
22

33
using System.Runtime.InteropServices;
4+
using Silk.NET.Core;
45
using Silk.NET.OpenGL;
56
using Silk.NET.SDL;
67

@@ -12,12 +13,31 @@
1213
);
1314
}
1415

15-
var window = Sdl.CreateWindow("Hello Window!", 1000, 800, Sdl.WindowOpengl);
16+
var window = Sdl.CreateWindow(
17+
"Hello Window!",
18+
1000,
19+
800,
20+
Sdl.WindowOpengl | Sdl.WindowHighPixelDensity
21+
);
1622
if (window == nullptr)
1723
{
1824
throw new Exception($"failed to create window: {(string)Sdl.GetError()}");
1925
}
2026

27+
Console.WriteLine(
28+
$"SDL_GetDisplayContentScale {Sdl.GetDisplayContentScale(Sdl.GetDisplayForWindow(window))}"
29+
);
30+
Console.WriteLine($"SDL_GetWindowDisplayScale {Sdl.GetWindowDisplayScale(window)}");
31+
Console.WriteLine($"SDL_GetWindowPixelDensity {Sdl.GetWindowPixelDensity(window)}");
32+
int sx = 0,
33+
sy = 0,
34+
px = 0,
35+
py = 0;
36+
Sdl.GetWindowSize(window, sx.AsRef(), sy.AsRef());
37+
Sdl.GetWindowSizeInPixels(window, px.AsRef(), py.AsRef());
38+
Console.WriteLine($"SDL_GetWindowSize {sx} {sy}");
39+
Console.WriteLine($"SDL_GetWindowSizeInPixels {px} {py}");
40+
2141
var context = new SdlContext(
2242
window,
2343
new KeyValuePair<GLattr, int>(GLattr.ContextMajorVersion, 3),
@@ -86,6 +106,23 @@ void main()
86106
break;
87107
}
88108

109+
if (@event.Window.Type == EventType.WindowDisplayScaleChanged)
110+
{
111+
Console.WriteLine(
112+
$"SDL_GetDisplayContentScale {Sdl.GetDisplayContentScale(Sdl.GetDisplayForWindow(window))}"
113+
);
114+
Console.WriteLine($"SDL_GetWindowDisplayScale {Sdl.GetWindowDisplayScale(window)}");
115+
Console.WriteLine($"SDL_GetWindowPixelDensity {Sdl.GetWindowPixelDensity(window)}");
116+
}
117+
118+
if (@event.Window.Type == EventType.WindowResized)
119+
{
120+
Sdl.GetWindowSize(window, sx.AsRef(), sy.AsRef());
121+
Sdl.GetWindowSizeInPixels(window, px.AsRef(), py.AsRef());
122+
Console.WriteLine($"SDL_GetWindowSize {sx} {sy}");
123+
Console.WriteLine($"SDL_GetWindowSizeInPixels {px} {py}");
124+
}
125+
89126
GL.Clear(ClearBufferMask.ColorBufferBit);
90127
GL.DrawArrays(PrimitiveType.Triangles, 0, 3);
91128
context.SwapBuffers();

sources/Windowing/Common/Components/IGLComponent.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

sources/Windowing/Common/Components/ISurface.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

sources/Windowing/Common/Configuration/IGLConfiguration.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)