static Sdl2KeyMap map = new Sdl2KeyMap();
- public Sdl2NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device)
+ public Sdl2NativeWindow(int x, int y, int width, int height,
+ string title, GameWindowFlags options, DisplayDevice device)
{
var bounds = device.Bounds;
var flags = TranslateFlags(options);
- IntPtr handle = SDL.SDL_CreateWindow(title, bounds.Left + x, bounds.Right + y, width, height, flags);
+ flags |= SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL;
+ flags |= SDL.SDL_WindowFlags.SDL_WINDOW_RESIZABLE;
+ IntPtr handle = SDL.SDL_CreateWindow(title, bounds.Left + x, bounds.Top + y, width, height, flags);
window = new Sdl2WindowInfo(handle, null);
keyboard.Description = "Standard Windows keyboard";
switch (flags)
{
case GameWindowFlags.Fullscreen:
- return SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN;
+ return SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP;
default:
return (SDL.SDL_WindowFlags)0;
}
}
+ void DestroyWindow()
+ {
+ exists = false;
+ SDL.SDL_DestroyWindow(window.Handle);
+ window.Handle = IntPtr.Zero;
+ }
+
#endregion
#region INativeWindow Members
Closing(this, close_args);
if (!close_args.Cancel)
{
- exists = false;
- SDL.SDL_DestroyWindow(window.Handle);
- window.Handle = IntPtr.Zero;
+ DestroyWindow();
}
break;
switch (value)
{
case WindowState.Fullscreen:
- if (SDL.SDL_SetWindowFullscreen(window.Handle, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN) < 0)
+ if (SDL.SDL_SetWindowFullscreen(window.Handle, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP) < 0)
{
- SDL.SDL_SetWindowFullscreen(window.Handle, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP);
+ if (SDL.SDL_SetWindowFullscreen(window.Handle, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN) < 0)
+ {
+ Debug.Print("SDL2 failed to enter fullscreen mode: {0}", SDL.SDL_GetError());
+ }
}
break;
{
if (!disposed)
{
- Close();
+ if (Exists)
+ {
+ DestroyWindow();
+ }
}
else
{