Opentk/Source/Examples/Tests/S02_RawInput_Logger.cs

97 lines
2.6 KiB
C#

#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.Serialization;
using System.IO;
using System.Diagnostics;
using OpenTK;
using OpenTK.OpenGL;
namespace Examples.Tests
{
public class S02_RawInput_Logger : GameWindow//, IExample
{
#region IExample Members
public void Launch()
{
try
{
Run();
}
catch (Exception expt)
{
System.Diagnostics.Debug.WriteLine(
String.Format(
"Exception: {3}{0}Stacktrace:{0}{1}{0}{0}{2}",
System.Environment.NewLine,
expt.TargetSite,
expt.StackTrace,
expt.Message
)
);
/*MessageBox.Show(
String.Format(
"Stacktrace:{0}{1}{0}{0}{2}",
System.Environment.NewLine,
expt.TargetSite,
expt.StackTrace
),
expt.Message
);*/
throw;
}
Debug.Flush();
Debug.Close();
}
#endregion
public S02_RawInput_Logger()
{
this.CreateWindow(new DisplayMode(100, 100));
Keyboard.KeyDown += new OpenTK.Input.KeyDownEvent(LogKeyDown);
Keyboard.KeyUp += new OpenTK.Input.KeyUpEvent(LogKeyUp);
}
void LogKeyDown(object sender, OpenTK.Input.Key key)
{
Trace.WriteLine(String.Format("OpenTK key {0} pressed on Keyboard: ({1}).",
key, sender as OpenTK.Input.KeyboardDevice));
}
void LogKeyUp(object sender, OpenTK.Input.Key key)
{
Trace.WriteLine(String.Format("OpenTK key {0} released on Keyboard: ({1}).",
key, sender as OpenTK.Input.KeyboardDevice));
}
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
public override void OnRenderFrame(RenderFrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Clear(GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
Context.SwapBuffers();
Thread.Sleep(1);
}
}
}