* OpenTK/Test/Multithreading.cs: Replaced anonymous delegate by a private function for easier debugging.

Switch to/from fullscreen when Key.Space is pressed.
This commit is contained in:
the_fiddler 2009-11-09 19:14:14 +00:00
parent 089b72c9c8
commit 20216d0d2b

View file

@ -37,20 +37,13 @@ namespace Examples.Tests
{ {
public static void Main() public static void Main()
{ {
const int ThreadCount = 4; const int ThreadCount = 2;
List<Thread> threads = new List<Thread>(); List<Thread> threads = new List<Thread>();
// launch threads // launch threads
for (int i = 0; i < ThreadCount; i++) for (int i = 0; i < ThreadCount; i++)
{ {
Thread t = new Thread(delegate() Thread t = new Thread(RunGame);
{
using (Tutorial.T03_Immediate_Mode_Cube game = new Examples.Tutorial.T03_Immediate_Mode_Cube())
{
Utilities.SetWindowTitle(game);
game.Run(30.0);
}
});
t.IsBackground = true; t.IsBackground = true;
t.Priority = ThreadPriority.BelowNormal; t.Priority = ThreadPriority.BelowNormal;
t.Start(); t.Start();
@ -63,5 +56,24 @@ namespace Examples.Tests
t.Join(); t.Join();
} }
} }
static void RunGame()
{
using (Tutorial.T03_Immediate_Mode_Cube game = new Examples.Tutorial.T03_Immediate_Mode_Cube())
{
Utilities.SetWindowTitle(game);
game.Keyboard.KeyUp += delegate(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
if (e.Key == OpenTK.Input.Key.Space)
{
if (game.WindowState == OpenTK.WindowState.Fullscreen)
game.WindowState = OpenTK.WindowState.Normal;
else
game.WindowState = OpenTK.WindowState.Fullscreen;
}
};
game.Run(30.0);
}
}
} }
} }