mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-06-20 21:57:52 +00:00
* Tests/GameWindowStates.cs: Add bidirectional mode changes.
This commit is contained in:
parent
a5455cc4e7
commit
cecc9c4867
|
@ -8,10 +8,12 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using System.Drawing;
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace Examples.Tests
|
namespace Examples.Tests
|
||||||
{
|
{
|
||||||
|
@ -19,7 +21,50 @@ namespace Examples.Tests
|
||||||
public class GameWindowStates : GameWindow
|
public class GameWindowStates : GameWindow
|
||||||
{
|
{
|
||||||
TextureFont font = new TextureFont(new Font(FontFamily.GenericSansSerif, 16.0f));
|
TextureFont font = new TextureFont(new Font(FontFamily.GenericSansSerif, 16.0f));
|
||||||
TextPrinter printer = new TextPrinter();
|
TextPrinter printer = new TextPrinter();
|
||||||
|
|
||||||
|
WindowState[] window_state_sequence = new WindowState[]
|
||||||
|
{
|
||||||
|
WindowState.Normal,
|
||||||
|
WindowState.Maximized,
|
||||||
|
WindowState.Fullscreen,
|
||||||
|
WindowState.Minimized
|
||||||
|
};
|
||||||
|
|
||||||
|
WindowBorder[] window_border_sequence = new WindowBorder[]
|
||||||
|
{
|
||||||
|
WindowBorder.Resizable,
|
||||||
|
WindowBorder.Fixed,
|
||||||
|
WindowBorder.Hidden,
|
||||||
|
};
|
||||||
|
|
||||||
|
int window_state_counter = 0;
|
||||||
|
int WindowStateCounter
|
||||||
|
{
|
||||||
|
get { return window_state_counter; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 0)
|
||||||
|
window_state_counter = window_state_sequence.Length - 1;
|
||||||
|
else
|
||||||
|
window_state_counter = ++window_state_counter % window_state_sequence.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int window_border_counter = 0;
|
||||||
|
int WindowBorderCounter
|
||||||
|
{
|
||||||
|
get { return window_border_counter; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 0)
|
||||||
|
window_border_counter = window_border_sequence.Length - 1;
|
||||||
|
else
|
||||||
|
window_border_counter = ++window_border_counter % window_border_sequence.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GameWindowStates()
|
public GameWindowStates()
|
||||||
: base(800, 600)
|
: base(800, 600)
|
||||||
|
@ -31,7 +76,7 @@ namespace Examples.Tests
|
||||||
GL.ClearColor(System.Drawing.Color.SteelBlue);
|
GL.ClearColor(System.Drawing.Color.SteelBlue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard_KeyUp(OpenTK.Input.KeyboardDevice sender, OpenTK.Input.Key key)
|
void Keyboard_KeyUp(KeyboardDevice sender, Key key)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
@ -39,29 +84,40 @@ namespace Examples.Tests
|
||||||
this.Exit();
|
this.Exit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpenTK.Input.Key.Number1:
|
case OpenTK.Input.Key.Number1:
|
||||||
switch (this.WindowState)
|
if (sender[Key.ShiftLeft] || sender[Key.ShiftRight])
|
||||||
{
|
WindowStateCounter--;
|
||||||
case WindowState.Normal: this.WindowState = WindowState.Maximized; break;
|
else
|
||||||
case WindowState.Maximized: this.WindowState = WindowState.Fullscreen; break;
|
WindowStateCounter++;
|
||||||
case WindowState.Fullscreen:
|
WindowState = window_state_sequence[WindowStateCounter];
|
||||||
this.WindowState = WindowState.Normal;
|
|
||||||
this.WindowState = WindowState.Minimized;
|
// switch (this.WindowState)
|
||||||
break;
|
// {
|
||||||
case WindowState.Minimized: this.WindowState = WindowState.Normal;
|
// case WindowState.Normal: this.WindowState = WindowState.Maximized; break;1
|
||||||
break;
|
// case WindowState.Maximized: this.WindowState = WindowState.Fullscreen; break;
|
||||||
|
// case WindowState.Fullscreen:
|
||||||
}
|
// this.WindowState = WindowState.Normal;
|
||||||
|
// this.WindowState = WindowState.Minimized;
|
||||||
|
// break;
|
||||||
|
// case WindowState.Minimized: this.WindowState = WindowState.Normal;
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpenTK.Input.Key.Number2:
|
case OpenTK.Input.Key.Number2:
|
||||||
this.WindowState = WindowState.Normal;
|
if (sender[Key.ShiftLeft] || sender[Key.ShiftRight])
|
||||||
switch (this.WindowBorder)
|
WindowBorderCounter--;
|
||||||
{
|
else
|
||||||
case WindowBorder.Fixed: this.WindowBorder = WindowBorder.Hidden; break;
|
WindowBorderCounter++;
|
||||||
case WindowBorder.Hidden: this.WindowBorder = WindowBorder.Resizable; break;
|
WindowBorder = window_border_sequence[WindowBorderCounter];
|
||||||
case WindowBorder.Resizable: this.WindowBorder = WindowBorder.Fixed; break;
|
// this.WindowState = WindowState.Normal;
|
||||||
}
|
// switch (this.WindowBorder)
|
||||||
|
// {
|
||||||
|
// case WindowBorder.Fixed: this.WindowBorder = WindowBorder.Hidden; break;
|
||||||
|
// case WindowBorder.Hidden: this.WindowBorder = WindowBorder.Resizable; break;
|
||||||
|
// case WindowBorder.Resizable: this.WindowBorder = WindowBorder.Fixed; break;
|
||||||
|
// }
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -97,14 +153,15 @@ namespace Examples.Tests
|
||||||
|
|
||||||
printer.End();
|
printer.End();
|
||||||
|
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
|
Thread.Sleep(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
using (GameWindowStates ex = new GameWindowStates())
|
using (GameWindowStates ex = new GameWindowStates())
|
||||||
{
|
{
|
||||||
Utilities.SetWindowTitle(ex);
|
Utilities.SetWindowTitle(ex);
|
||||||
ex.Run(20.0);
|
ex.Run(20.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue