Skip to content

Commit

Permalink
Start on a more clean sheet and conservative implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Perksey committed Nov 13, 2024
1 parent 2295ce6 commit 0e760e6
Show file tree
Hide file tree
Showing 25 changed files with 1,366 additions and 619 deletions.
7 changes: 0 additions & 7 deletions Silk.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SilkTouch", "SilkTouch", "{
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Windowing", "Windowing", "{AE84F4C8-6102-4A72-86EF-0C9345AA27A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Windowing.Common", "sources\Windowing\Common\Silk.NET.Windowing.Common.csproj", "{D1542DA9-7C7D-417C-8B63-791570D4C4A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Windowing", "sources\Windowing\Windowing\Silk.NET.Windowing.csproj", "{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}"
EndProject
Global
Expand Down Expand Up @@ -144,10 +142,6 @@ Global
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Release|Any CPU.Build.0 = Release|Any CPU
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1542DA9-7C7D-417C-8B63-791570D4C4A0}.Release|Any CPU.Build.0 = Release|Any CPU
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -179,7 +173,6 @@ Global
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807} = {49D426BF-A009-43D5-A9E2-EFAAAA7196FC}
{600D712C-4ABF-44C4-96C3-B1DEE1F38298} = {AB25C482-DA9D-4335-8E26-2F29C3700152}
{AE84F4C8-6102-4A72-86EF-0C9345AA27A9} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
{D1542DA9-7C7D-417C-8B63-791570D4C4A0} = {AE84F4C8-6102-4A72-86EF-0C9345AA27A9}
{6B3A9BCC-8EBF-4132-B306-8E275D05CB52} = {AE84F4C8-6102-4A72-86EF-0C9345AA27A9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
9 changes: 9 additions & 0 deletions sources/Core/Core/Abstractions/IGLContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ public interface IGLContext : INativeContext
/// </summary>
int SwapInterval { get; set; }

/// <summary>
/// Gets or sets a value indicating whether <see cref="SwapInterval" /> is non-zero.
/// </summary>
bool VSync
{
get => SwapInterval > 0;
set => SwapInterval = value ? 1 : 0;
}

/// <summary>
/// Swaps the backbuffer to present the contents to the window.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions sources/Core/Core/Abstractions/IGLContextSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +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.Core;

/// <summary>
/// Represents a source of a <see cref="IGLContext" />
/// </summary>
// Same as in 1.X/2.X, just a different namespace.
public interface IGLContextSource
{
/// <summary>
/// The OpenGL context.
/// </summary>
IGLContext? GLContext { get; }
}
22 changes: 22 additions & 0 deletions sources/Core/Core/Abstractions/INativeWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace Silk.NET.Core;

/// <summary>
/// Represents a window that possesses native handles or other platform-specific information.
/// </summary>
public interface INativeWindow
{
/// <summary>
/// Attempts to obtain native platform information with type <typeparamref name="TPlatformInfo" />.
/// </summary>
/// <param name="info">
/// The platform-specific information, or <c>default</c> if the platform-specific information is not available for
/// this platform.
/// </param>
/// <returns>True if <paramref name="info" /> contains the platform-specific information, false otherwise.</returns>
bool TryGetPlatformInfo<TPlatformInfo>([NotNullWhen(true)] out TPlatformInfo? info);
}
35 changes: 0 additions & 35 deletions sources/Core/Core/Abstractions/ITypeChain.cs

This file was deleted.

19 changes: 0 additions & 19 deletions sources/Core/Core/Abstractions/TypeChain`2.cs

This file was deleted.

39 changes: 38 additions & 1 deletion sources/Playground/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// See https://aka.ms/new-console-template for more information

using System.Runtime.InteropServices;
using Silk.NET.Core;
using Silk.NET.OpenGL;
using Silk.NET.SDL;

Expand All @@ -12,12 +13,31 @@
);
}

var window = Sdl.CreateWindow("Hello Window!", 1000, 800, Sdl.WindowOpengl);
var window = Sdl.CreateWindow(
"Hello Window!",
1000,
800,
Sdl.WindowOpengl | Sdl.WindowHighPixelDensity
);
if (window == nullptr)
{
throw new Exception($"failed to create window: {(string)Sdl.GetError()}");
}

Console.WriteLine(
$"SDL_GetDisplayContentScale {Sdl.GetDisplayContentScale(Sdl.GetDisplayForWindow(window))}"
);
Console.WriteLine($"SDL_GetWindowDisplayScale {Sdl.GetWindowDisplayScale(window)}");
Console.WriteLine($"SDL_GetWindowPixelDensity {Sdl.GetWindowPixelDensity(window)}");
int sx = 0,
sy = 0,
px = 0,
py = 0;
Sdl.GetWindowSize(window, sx.AsRef(), sy.AsRef());
Sdl.GetWindowSizeInPixels(window, px.AsRef(), py.AsRef());
Console.WriteLine($"SDL_GetWindowSize {sx} {sy}");
Console.WriteLine($"SDL_GetWindowSizeInPixels {px} {py}");

var context = new SdlContext(
window,
new KeyValuePair<GLattr, int>(GLattr.ContextMajorVersion, 3),
Expand Down Expand Up @@ -86,6 +106,23 @@ void main()
break;
}

if (@event.Window.Type == EventType.WindowDisplayScaleChanged)
{
Console.WriteLine(
$"SDL_GetDisplayContentScale {Sdl.GetDisplayContentScale(Sdl.GetDisplayForWindow(window))}"
);
Console.WriteLine($"SDL_GetWindowDisplayScale {Sdl.GetWindowDisplayScale(window)}");
Console.WriteLine($"SDL_GetWindowPixelDensity {Sdl.GetWindowPixelDensity(window)}");
}

if (@event.Window.Type == EventType.WindowResized)
{
Sdl.GetWindowSize(window, sx.AsRef(), sy.AsRef());
Sdl.GetWindowSizeInPixels(window, px.AsRef(), py.AsRef());
Console.WriteLine($"SDL_GetWindowSize {sx} {sy}");
Console.WriteLine($"SDL_GetWindowSizeInPixels {px} {py}");
}

GL.Clear(ClearBufferMask.ColorBufferBit);
GL.DrawArrays(PrimitiveType.Triangles, 0, 3);
context.SwapBuffers();
Expand Down
11 changes: 0 additions & 11 deletions sources/Windowing/Common/Components/IGLComponent.cs

This file was deleted.

47 changes: 0 additions & 47 deletions sources/Windowing/Common/Components/ISurface.cs

This file was deleted.

52 changes: 0 additions & 52 deletions sources/Windowing/Common/Configuration/IGLConfiguration.cs

This file was deleted.

25 changes: 0 additions & 25 deletions sources/Windowing/Common/Configuration/OpenGLContextFlags.cs

This file was deleted.

23 changes: 0 additions & 23 deletions sources/Windowing/Common/Configuration/OpenGLContextProfile.cs

This file was deleted.

Loading

0 comments on commit 0e760e6

Please sign in to comment.