mirror of https://github.com/ppy/SDL3-CS.git
79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
using SDL;
|
|
using static SDL.SDL3;
|
|
|
|
namespace SDL3.Tests
|
|
{
|
|
public static class Program
|
|
{
|
|
public static void Main()
|
|
{
|
|
Console.OutputEncoding = Encoding.UTF8;
|
|
|
|
unsafe
|
|
{
|
|
// Encoding.UTF8.GetBytes can churn out null pointers and doesn't guarantee null termination
|
|
fixed (byte* badPointer = Encoding.UTF8.GetBytes(""))
|
|
Debug.Assert(badPointer == null);
|
|
|
|
fixed (byte* pointer = UTF8GetBytes(""))
|
|
{
|
|
Debug.Assert(pointer != null);
|
|
Debug.Assert(pointer[0] == '\0');
|
|
}
|
|
}
|
|
|
|
SDL_SetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, "null byte \0 in string"u8);
|
|
Debug.Assert(SDL_GetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4) == "null byte ");
|
|
|
|
SDL_SetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, "1"u8);
|
|
SDL_SetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, "1");
|
|
|
|
using (var window = new MyWindow())
|
|
{
|
|
Console.WriteLine($"SDL revision: {SDL_GetRevision()}");
|
|
|
|
printDisplays();
|
|
|
|
window.Setup();
|
|
window.Create();
|
|
|
|
const SDL_Keymod state = SDL_Keymod.SDL_KMOD_CAPS | SDL_Keymod.SDL_KMOD_ALT;
|
|
SDL_SetModState(state);
|
|
Debug.Assert(SDL_GetModState() == state);
|
|
|
|
window.Run();
|
|
}
|
|
|
|
SDL_Quit();
|
|
}
|
|
|
|
private static void printDisplays()
|
|
{
|
|
using var displays = SDL_GetDisplays();
|
|
if (displays == null)
|
|
return;
|
|
|
|
for (int i = 0; i < displays.Count; i++)
|
|
{
|
|
SDL_DisplayID id = displays[i];
|
|
Console.WriteLine(id);
|
|
|
|
using var modes = SDL_GetFullscreenDisplayModes(id);
|
|
if (modes == null)
|
|
continue;
|
|
|
|
for (int j = 0; j < modes.Count; j++)
|
|
{
|
|
SDL_DisplayMode mode = modes[j];
|
|
Console.WriteLine($"{mode.w}x{mode.h}@{mode.refresh_rate}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|