mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 06:05:29 +00:00
Fullscreen mode changes now work!
This commit is contained in:
parent
54224ed65c
commit
3a026d5d5e
|
@ -14,6 +14,7 @@ using OpenTK;
|
||||||
using OpenTK.OpenGL;
|
using OpenTK.OpenGL;
|
||||||
using OpenTK.Fonts;
|
using OpenTK.Fonts;
|
||||||
using OpenTK.OpenGL.Enums;
|
using OpenTK.OpenGL.Enums;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace Examples.Tutorial
|
namespace Examples.Tutorial
|
||||||
{
|
{
|
||||||
|
@ -23,8 +24,28 @@ namespace Examples.Tutorial
|
||||||
[Example("Simple Window", ExampleCategory.Tutorial, 1)]
|
[Example("Simple Window", ExampleCategory.Tutorial, 1)]
|
||||||
public class T01_Simple_Window : GameWindow
|
public class T01_Simple_Window : GameWindow
|
||||||
{
|
{
|
||||||
public T01_Simple_Window() : base(new DisplayMode(800, 600))
|
public T01_Simple_Window() : base()
|
||||||
{ }
|
{
|
||||||
|
Keyboard.KeyDown += new OpenTK.Input.KeyDownEvent(Keyboard_KeyDown);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Keyboard_KeyDown
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when a key is pressed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The KeyboardDevice which generated this event.</param>
|
||||||
|
/// <param name="key">The key that was pressed.</param>
|
||||||
|
void Keyboard_KeyDown(KeyboardDevice sender, Key key)
|
||||||
|
{
|
||||||
|
if ((sender[Key.AltLeft] || sender[Key.AltRight]) && sender[Key.Enter])
|
||||||
|
this.Fullscreen = !this.Fullscreen;
|
||||||
|
|
||||||
|
if (sender[Key.Escape])
|
||||||
|
this.Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region OnLoad
|
#region OnLoad
|
||||||
|
|
||||||
|
@ -68,10 +89,7 @@ namespace Examples.Tutorial
|
||||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnUpdateFrame(e);
|
// Nothing to do!
|
||||||
|
|
||||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
|
||||||
this.Exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -114,8 +132,7 @@ namespace Examples.Tutorial
|
||||||
using (T01_Simple_Window example = new T01_Simple_Window())
|
using (T01_Simple_Window example = new T01_Simple_Window())
|
||||||
{
|
{
|
||||||
// Get the title and category of this example using reflection.
|
// Get the title and category of this example using reflection.
|
||||||
ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
|
Utilities.SetWindowTitle(example);
|
||||||
example.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
|
|
||||||
example.Run(30.0, 0.0);
|
example.Run(30.0, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace Examples
|
namespace Examples
|
||||||
{
|
{
|
||||||
|
|
|
@ -201,8 +201,8 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Fullscreen
|
public bool Fullscreen
|
||||||
{
|
{
|
||||||
get { return false;/* return glWindow.Fullscreen; */ }
|
get { return glWindow.Fullscreen; }
|
||||||
set { /* glWindow.Fullscreen = value; */}
|
set { glWindow.Fullscreen = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace OpenTK.Platform
|
||||||
bool IsIdle { get; }
|
bool IsIdle { get; }
|
||||||
//IGLContext Context { get; }
|
//IGLContext Context { get; }
|
||||||
IInputDriver InputDriver { get; }
|
IInputDriver InputDriver { get; }
|
||||||
|
bool Fullscreen { get; set; }
|
||||||
|
|
||||||
event CreateEvent Create;
|
event CreateEvent Create;
|
||||||
event DestroyEvent Destroy;
|
event DestroyEvent Destroy;
|
||||||
|
|
|
@ -2299,6 +2299,13 @@ namespace OpenTK.Platform.Windows
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
internal struct Rectangle
|
internal struct Rectangle
|
||||||
{
|
{
|
||||||
|
internal Rectangle(int width, int height)
|
||||||
|
{
|
||||||
|
left = top = 0;
|
||||||
|
right = width;
|
||||||
|
bottom = height;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the x-coordinate of the upper-left corner of the rectangle.
|
/// Specifies the x-coordinate of the upper-left corner of the rectangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2316,6 +2323,9 @@ namespace OpenTK.Platform.Windows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal LONG bottom;
|
internal LONG bottom;
|
||||||
|
|
||||||
|
internal int Width { get { return right - left; } }
|
||||||
|
internal int Height { get { return bottom - top; } }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format("({0},{1})-({2},{3})", left, top, right, bottom);
|
return String.Format("({0},{1})-({2},{3})", left, top, right, bottom);
|
||||||
|
|
|
@ -30,13 +30,14 @@ namespace OpenTK.Platform.Windows
|
||||||
private DisplayMode mode = new DisplayMode();
|
private DisplayMode mode = new DisplayMode();
|
||||||
private IInputDriver driver;
|
private IInputDriver driver;
|
||||||
|
|
||||||
//private bool fullscreen;
|
private bool fullscreen, visible = true;
|
||||||
private bool disposed;
|
private bool disposed;
|
||||||
private bool isExiting;
|
private bool isExiting;
|
||||||
private bool exists;
|
private bool exists;
|
||||||
private WindowInfo window = new WindowInfo();
|
private WindowInfo window = new WindowInfo();
|
||||||
private int top, bottom, left, right;
|
private int top, bottom, left, right;
|
||||||
private int width = 0, height = 0;
|
private int width = 0, height = 0;
|
||||||
|
private Rectangle pre_maximized;
|
||||||
|
|
||||||
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
||||||
|
|
||||||
|
@ -192,13 +193,32 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return false;
|
return fullscreen;
|
||||||
//throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
IntPtr style = IntPtr.Zero;
|
||||||
//fullscreen = false;
|
ShowWindowCommand command = (ShowWindowCommand)0;
|
||||||
|
if (value && !Fullscreen)
|
||||||
|
{
|
||||||
|
style = (IntPtr)(int)(WindowStyle.Popup | WindowStyle.ClipChildren | WindowStyle.ClipSiblings);
|
||||||
|
command = ShowWindowCommand.SHOWMAXIMIZED;
|
||||||
|
pre_maximized = new Rectangle(width, height);
|
||||||
|
Functions.AdjustWindowRect(ref pre_maximized, WindowStyle.OverlappedWindow, false);
|
||||||
|
}
|
||||||
|
else if (!value && Fullscreen)
|
||||||
|
{
|
||||||
|
style = (IntPtr)(int)(WindowStyle.OverlappedWindow | WindowStyle.ClipChildren | WindowStyle.ClipSiblings);
|
||||||
|
command = ShowWindowCommand.SHOWNORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Functions.SetWindowLongPtr(Handle, GetWindowLongOffsets.STYLE, style);
|
||||||
|
Functions.ShowWindow(Handle, command);
|
||||||
|
if (!value && Fullscreen)
|
||||||
|
Functions.SetWindowPos(Handle, WindowPlacementOptions.TOP, 0, 0, pre_maximized.Width, pre_maximized.Height,
|
||||||
|
SetWindowPosFlags.SHOWWINDOW);
|
||||||
|
|
||||||
|
fullscreen = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,11 +273,20 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//Functions.GetW
|
return visible;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value && !Visible)
|
||||||
|
{
|
||||||
|
Functions.ShowWindow(Handle, ShowWindowCommand.SHOWNORMAL);
|
||||||
|
visible = true;
|
||||||
|
}
|
||||||
|
else if (!value && Visible)
|
||||||
|
{
|
||||||
|
Functions.ShowWindow(Handle, ShowWindowCommand.HIDE);
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue