Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Input/Silk.NET.Input/Silk.NET.Input.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOsPlatform('Linux'))">$(TargetFrameworks);net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<SilkMetapackage>true</SilkMetapackage>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,19 @@ public void Update(float deltaSeconds)
private void SetPerFrameImGuiData(float deltaSeconds)
{
var io = ImGuiNET.ImGui.GetIO();
var size = _view.Size;
var framebufferSize = _view.FramebufferSize;

// Update here since Resize isn't raised on all platforms
_windowWidth = size.X;
_windowHeight = size.Y;
Comment on lines +242 to +244

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When going fullscreen Resize is fired and the updated window size is correctly reflected, but when returning to windowed mode on Wayland, GLFX does not end up invoking the resize callback so we never end up receiving the updated window dimensions.


io.DisplaySize = new Vector2(_windowWidth, _windowHeight);

if (_windowWidth > 0 && _windowHeight > 0)
{
io.DisplayFramebufferScale = new Vector2(_view.FramebufferSize.X / _windowWidth,
_view.FramebufferSize.Y / _windowHeight);
io.DisplayFramebufferScale = new Vector2((float) framebufferSize.X / _windowWidth,
(float) framebufferSize.Y / _windowHeight);
}

io.DeltaTime = deltaSeconds; // DeltaTime is in seconds.
Expand Down Expand Up @@ -427,6 +434,9 @@ private unsafe void SetupRenderState(ImDrawDataPtr drawDataPtr, int framebufferW
_gl.PolygonMode(GLEnum.FrontAndBack, GLEnum.Fill);
#endif

// Setup viewport, orthographic projection matrix
_gl.Viewport(0, 0, (uint) framebufferWidth, (uint) framebufferHeight);

float L = drawDataPtr.DisplayPos.X;
float R = drawDataPtr.DisplayPos.X + drawDataPtr.DisplaySize.X;
float T = drawDataPtr.DisplayPos.Y;
Expand Down Expand Up @@ -488,6 +498,8 @@ private unsafe void RenderImDrawData(ImDrawDataPtr drawDataPtr)
_gl.GetInteger(GLEnum.PolygonMode, lastPolygonMode);
#endif

Span<int> lastViewport = stackalloc int[4];
_gl.GetInteger(GLEnum.Viewport, lastViewport);
Span<int> lastScissorBox = stackalloc int[4];
_gl.GetInteger(GLEnum.ScissorBox, lastScissorBox);

Expand Down Expand Up @@ -637,6 +649,7 @@ private unsafe void RenderImDrawData(ImDrawDataPtr drawDataPtr)
_gl.PolygonMode(GLEnum.FrontAndBack, (GLEnum) lastPolygonMode[0]);
#endif

_gl.Viewport(lastViewport[0], lastViewport[1], (uint) lastViewport[2], (uint) lastViewport[3]);
_gl.Scissor(lastScissorBox[0], lastScissorBox[1], (uint) lastScissorBox[2], (uint) lastScissorBox[3]);
}

Expand Down
32 changes: 32 additions & 0 deletions src/Windowing/Silk.NET.GLFW/Glfw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,38 @@ public unsafe partial WindowHandle* CreateWindow
/// </remarks>
public unsafe partial void GetFramebufferSize(WindowHandle* window, out int width, out int height);

/// <summary>
/// <para>
/// This function retrieves the content scale for the specified window.
/// </para>
/// <para>
/// The content scale is the ratio between the current DPI and the platform's default DPI.
/// </para>
/// <para>
/// If you scale all pixel dimensions by this scale then your content should appear at an appropriate size.
/// This is especially important for text and any UI elements.
/// </para>
/// <para>
/// On platforms where each monitor can have its own content scale, the window content scale
/// depends on which monitor the system considers the window to be on.
/// </para>
/// </summary>
/// <param name="window">The window to query.</param>
/// <param name="xscale">Where to store the x-axis content scale, or <c>out _</c>.</param>
/// <param name="yscale">Where to store the y-axis content scale, or <c>out _</c>.</param>
/// <remarks>
/// <para>
/// This function must only be called from the main thread.
/// </para>
/// <para>
/// Possible errors include <see cref="ErrorCode.NotInitialized" /> and <see cref="ErrorCode.PlatformError" />.
/// </para>
/// </remarks>
/// <seealso cref="GetMonitorContentScale" />
// ReSharper disable IdentifierTypo
public unsafe partial void GetWindowContentScale(WindowHandle* window, out float xscale, out float yscale);
// ReSharper enable IdentifierTypo

/// <summary>
/// <para>
/// This function returns the value of an input option for the specified window.
Expand Down