diff --git a/Source/Examples/Tutorial/T01_Simple_Window.cs b/Source/Examples/Tutorial/T01_Simple_Window.cs
index a7faaa8b..3bcad12e 100644
--- a/Source/Examples/Tutorial/T01_Simple_Window.cs
+++ b/Source/Examples/Tutorial/T01_Simple_Window.cs
@@ -14,6 +14,7 @@ using OpenTK;
using OpenTK.OpenGL;
using OpenTK.Fonts;
using OpenTK.OpenGL.Enums;
+using OpenTK.Input;
namespace Examples.Tutorial
{
@@ -23,8 +24,28 @@ namespace Examples.Tutorial
[Example("Simple Window", ExampleCategory.Tutorial, 1)]
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
+
+ ///
+ /// Occurs when a key is pressed.
+ ///
+ /// The KeyboardDevice which generated this event.
+ /// The key that was pressed.
+ 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
@@ -68,10 +89,7 @@ namespace Examples.Tutorial
/// There is no need to call the base implementation.
public override void OnUpdateFrame(UpdateFrameEventArgs e)
{
- base.OnUpdateFrame(e);
-
- if (Keyboard[OpenTK.Input.Key.Escape])
- this.Exit();
+ // Nothing to do!
}
#endregion
@@ -114,8 +132,7 @@ namespace Examples.Tutorial
using (T01_Simple_Window example = new T01_Simple_Window())
{
// Get the title and category of this example using reflection.
- ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
- example.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
+ Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
}
diff --git a/Source/Examples/Utilities.cs b/Source/Examples/Utilities.cs
index 5f3981a6..3624dbe0 100644
--- a/Source/Examples/Utilities.cs
+++ b/Source/Examples/Utilities.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Drawing;
using OpenTK;
+using OpenTK.Input;
namespace Examples
{
diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs
index 11336f2f..384c1e8f 100644
--- a/Source/OpenTK/GameWindow.cs
+++ b/Source/OpenTK/GameWindow.cs
@@ -201,8 +201,8 @@ namespace OpenTK
///
public bool Fullscreen
{
- get { return false;/* return glWindow.Fullscreen; */ }
- set { /* glWindow.Fullscreen = value; */}
+ get { return glWindow.Fullscreen; }
+ set { glWindow.Fullscreen = value; }
}
#endregion
diff --git a/Source/OpenTK/Platform/INativeGLWindow.cs b/Source/OpenTK/Platform/INativeGLWindow.cs
index 398d6279..29a96b35 100644
--- a/Source/OpenTK/Platform/INativeGLWindow.cs
+++ b/Source/OpenTK/Platform/INativeGLWindow.cs
@@ -31,6 +31,7 @@ namespace OpenTK.Platform
bool IsIdle { get; }
//IGLContext Context { get; }
IInputDriver InputDriver { get; }
+ bool Fullscreen { get; set; }
event CreateEvent Create;
event DestroyEvent Destroy;
diff --git a/Source/OpenTK/Platform/Windows/API.cs b/Source/OpenTK/Platform/Windows/API.cs
index 50906d25..daad6250 100644
--- a/Source/OpenTK/Platform/Windows/API.cs
+++ b/Source/OpenTK/Platform/Windows/API.cs
@@ -2299,6 +2299,13 @@ namespace OpenTK.Platform.Windows
[StructLayout(LayoutKind.Sequential)]
internal struct Rectangle
{
+ internal Rectangle(int width, int height)
+ {
+ left = top = 0;
+ right = width;
+ bottom = height;
+ }
+
///
/// Specifies the x-coordinate of the upper-left corner of the rectangle.
///
@@ -2316,6 +2323,9 @@ namespace OpenTK.Platform.Windows
///
internal LONG bottom;
+ internal int Width { get { return right - left; } }
+ internal int Height { get { return bottom - top; } }
+
public override string ToString()
{
return String.Format("({0},{1})-({2},{3})", left, top, right, bottom);
diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs
index e6e170a2..cbc4ec32 100644
--- a/Source/OpenTK/Platform/Windows/WinGLNative.cs
+++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs
@@ -30,13 +30,14 @@ namespace OpenTK.Platform.Windows
private DisplayMode mode = new DisplayMode();
private IInputDriver driver;
- //private bool fullscreen;
+ private bool fullscreen, visible = true;
private bool disposed;
private bool isExiting;
private bool exists;
private WindowInfo window = new WindowInfo();
private int top, bottom, left, right;
private int width = 0, height = 0;
+ private Rectangle pre_maximized;
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
@@ -192,13 +193,32 @@ namespace OpenTK.Platform.Windows
{
get
{
- return false;
- //throw new NotImplementedException();
+ return fullscreen;
}
set
{
- throw new NotImplementedException();
- //fullscreen = false;
+ IntPtr style = IntPtr.Zero;
+ 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
{
- //Functions.GetW
- return true;
+ return visible;
}
set
{
+ if (value && !Visible)
+ {
+ Functions.ShowWindow(Handle, ShowWindowCommand.SHOWNORMAL);
+ visible = true;
+ }
+ else if (!value && Visible)
+ {
+ Functions.ShowWindow(Handle, ShowWindowCommand.HIDE);
+ visible = false;
+ }
}
}
@@ -313,7 +342,7 @@ namespace OpenTK.Platform.Windows
cp.Width = rect.right - rect.left;
cp.Height = rect.bottom - rect.top;
cp.Caption = "OpenTK Game Window";
-
+
// Keep in mind that some construction code runs in WM_CREATE,
// which is raised CreateHandle()
CreateHandle(cp);