2021-01-19 19:24:23 +00:00
|
|
|
using System;
|
|
|
|
using SDL2;
|
|
|
|
|
2021-01-25 21:02:35 +00:00
|
|
|
namespace MoonWorks.Window
|
2021-01-19 19:24:23 +00:00
|
|
|
{
|
2021-01-25 21:02:35 +00:00
|
|
|
public class OSWindow
|
2021-01-19 19:24:23 +00:00
|
|
|
{
|
2021-01-20 02:06:10 +00:00
|
|
|
internal IntPtr Handle { get; }
|
2021-01-19 19:24:23 +00:00
|
|
|
public ScreenMode ScreenMode { get; }
|
|
|
|
|
2021-01-25 21:02:35 +00:00
|
|
|
public OSWindow(WindowCreateInfo windowCreateInfo)
|
2021-01-19 19:24:23 +00:00
|
|
|
{
|
|
|
|
var windowFlags = SDL.SDL_WindowFlags.SDL_WINDOW_VULKAN;
|
|
|
|
|
|
|
|
if (windowCreateInfo.ScreenMode == ScreenMode.Fullscreen)
|
|
|
|
{
|
|
|
|
windowFlags |= SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN;
|
|
|
|
}
|
|
|
|
else if (windowCreateInfo.ScreenMode == ScreenMode.BorderlessWindow)
|
|
|
|
{
|
|
|
|
windowFlags |= SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScreenMode = windowCreateInfo.ScreenMode;
|
|
|
|
|
|
|
|
Handle = SDL.SDL_CreateWindow(
|
2021-01-20 05:33:25 +00:00
|
|
|
windowCreateInfo.WindowTitle,
|
2021-01-19 19:24:23 +00:00
|
|
|
SDL.SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
SDL.SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
(int)windowCreateInfo.WindowWidth,
|
|
|
|
(int)windowCreateInfo.WindowHeight,
|
|
|
|
windowFlags
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ChangeScreenMode(ScreenMode screenMode)
|
|
|
|
{
|
|
|
|
SDL.SDL_WindowFlags windowFlag = 0;
|
|
|
|
|
|
|
|
if (screenMode == ScreenMode.Fullscreen)
|
|
|
|
{
|
|
|
|
windowFlag = SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN;
|
|
|
|
}
|
|
|
|
else if (screenMode == ScreenMode.BorderlessWindow)
|
|
|
|
{
|
|
|
|
windowFlag = SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL.SDL_SetWindowFullscreen(Handle, (uint) windowFlag);
|
|
|
|
}
|
2021-02-24 21:03:39 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Resizes the window.
|
|
|
|
/// Note that you are responsible for recreating any graphics resources that need to change as a result of the size change.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="width"></param>
|
|
|
|
/// <param name="height"></param>
|
|
|
|
public void SetWindowSize(uint width, uint height)
|
|
|
|
{
|
|
|
|
SDL.SDL_SetWindowSize(Handle, (int)width, (int)height);
|
|
|
|
}
|
2021-01-19 19:24:23 +00:00
|
|
|
}
|
|
|
|
}
|