dotnet / dotnet/Silk.NET

Unable to switch from fullscreen to normal mode in SDL

Open
#2,532 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
5.2k
Forks
477
Avg merge
3d 16h
Merged PRs (30d)
2

Description

# Summary
When trying to set `window.WindowState = WindowState.Normal` in fullscreen mode nothing happens with SDL as backend for windowing.

# Steps to reproduce
- Platform: Desktop
- Framework Version: .NET Core 10.0
- Silk.NET Version: 2.23.0
- API: OpenGL
- API Version: Any GL version

1. Use this minimal reproducible example:
```
using System;
using System.Drawing;
using Silk.NET.Input;
using Silk.NET.OpenGL;
using Silk.NET.Windowing;

// ReSharper disable AccessToDisposedClosure

namespace SlikTest;

internal static class Program
{
private static void Main(string[] args)
{
using var window = Window.Create(WindowOptions.Default);

IInputContext input;
GL gl = null!;

window.Load += () =>
{
gl = window.CreateOpenGL();
input = window.CreateInput();
input.Keyboards[0].KeyDown += (keyboard, _, _) =>
{
if (keyboard.IsKeyPressed(Key.Enter))
{
switch (window.WindowState)
{
case WindowState.Normal:
window.WindowState = WindowState.Fullscreen;
break;
case WindowState.Fullscreen:
window.WindowState = WindowState.Normal;
break;
default:
throw new ArgumentOutOfRangeException();
}
}

if (keyboard.IsKeyPressed(Key.Escape))
window.Close();
};
};

window.Render += _ =>
{
var color = window.WindowState switch
{
WindowState.Normal => Color.Red,
WindowState.Fullscreen => Color.Green,
_ => Color.White,
};
gl.ClearColor(color);
gl.Clear(ClearBufferMask.ColorBufferBit);
};

window.Run();
}
}
```
2. Press Enter to switch to full screen mode
3. Press Enter and the window will not return to normal
4. See bug

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.