2007-08-10 09:27:13 +00:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
|
|
|
* See license.txt for license info
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
using System;
|
2007-08-03 00:14:31 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
2007-09-26 11:47:30 +00:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.OpenGL;
|
|
|
|
|
|
2007-08-03 00:14:31 +00:00
|
|
|
|
namespace Examples.Tests
|
|
|
|
|
{
|
2007-09-09 11:53:25 +00:00
|
|
|
|
public class S02_RawInput_Logger : GameWindow//, IExample
|
2007-08-03 00:14:31 +00:00
|
|
|
|
{
|
|
|
|
|
#region IExample Members
|
|
|
|
|
|
|
|
|
|
public void Launch()
|
|
|
|
|
{
|
2007-08-20 10:46:37 +00:00
|
|
|
|
try
|
2007-08-03 00:14:31 +00:00
|
|
|
|
{
|
2007-08-20 10:46:37 +00:00
|
|
|
|
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,
|
2007-08-04 12:09:58 +00:00
|
|
|
|
expt.Message
|
2007-08-20 10:46:37 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
/*MessageBox.Show(
|
|
|
|
|
String.Format(
|
|
|
|
|
"Stacktrace:{0}{1}{0}{0}{2}",
|
|
|
|
|
System.Environment.NewLine,
|
|
|
|
|
expt.TargetSite,
|
|
|
|
|
expt.StackTrace
|
|
|
|
|
),
|
|
|
|
|
expt.Message
|
|
|
|
|
);*/
|
|
|
|
|
throw;
|
2007-08-03 00:14:31 +00:00
|
|
|
|
}
|
2007-08-04 12:09:58 +00:00
|
|
|
|
Debug.Flush();
|
|
|
|
|
Debug.Close();
|
|
|
|
|
|
2007-08-03 00:14:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public S02_RawInput_Logger()
|
|
|
|
|
{
|
2007-09-02 00:07:40 +00:00
|
|
|
|
this.CreateWindow(new DisplayMode(100, 100));
|
2007-08-20 13:45:04 +00:00
|
|
|
|
|
2007-09-26 11:47:30 +00:00
|
|
|
|
Keyboard.KeyDown += new OpenTK.Input.KeyDownEvent(LogKeyDown);
|
|
|
|
|
Keyboard.KeyUp += new OpenTK.Input.KeyUpEvent(LogKeyUp);
|
2007-08-20 13:45:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LogKeyDown(object sender, OpenTK.Input.Key key)
|
|
|
|
|
{
|
|
|
|
|
Trace.WriteLine(String.Format("OpenTK key {0} pressed on Keyboard: ({1}).",
|
2007-09-26 11:47:30 +00:00
|
|
|
|
key, sender as OpenTK.Input.KeyboardDevice));
|
2007-08-20 13:45:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LogKeyUp(object sender, OpenTK.Input.Key key)
|
|
|
|
|
{
|
|
|
|
|
Trace.WriteLine(String.Format("OpenTK key {0} released on Keyboard: ({1}).",
|
2007-09-26 11:47:30 +00:00
|
|
|
|
key, sender as OpenTK.Input.KeyboardDevice));
|
2007-08-06 11:26:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
|
2007-08-03 00:14:31 +00:00
|
|
|
|
GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-23 12:09:42 +00:00
|
|
|
|
public override void OnRenderFrame(RenderFrameEventArgs e)
|
2007-08-03 00:14:31 +00:00
|
|
|
|
{
|
2007-08-06 11:22:18 +00:00
|
|
|
|
base.OnRenderFrame(e);
|
2007-08-03 00:14:31 +00:00
|
|
|
|
|
|
|
|
|
GL.Clear(GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
|
|
|
|
|
Context.SwapBuffers();
|
2007-08-20 13:45:04 +00:00
|
|
|
|
Thread.Sleep(1);
|
2007-08-03 00:14:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|