Opentk/Source/Examples/Tests/S02_RawInput_Logger.cs
the_fiddler defa7aa9c5 Updated examples to reflect namespace change of DisplayMode and ColorMode.
Renamed T03_RotatingCube.cs to T03_Immediate_Mode_Cube.cs.
Renamed T07_DisplayLists_Cube.cs to T07_Display_Lists_Flower.cs.
Renamed Cube.cs to W02_Immediate_Mode_Cube.cs
Updated colors in T10_GLSL_Cube and T03_Immediate_Mode_Cube
Add S03_Stack_Imbalance.cs test.
Add T01_Simple_Window.cs and T02_Resizable_Window.cs tutorials.
2007-09-02 00:07:40 +00:00

100 lines
2.7 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 OpenTK;
using OpenTK.OpenGL;
using System.Threading;
using System.Runtime.Serialization;
using System.IO;
using System.Diagnostics;
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));
foreach (OpenTK.Input.Keyboard k in this.Keyboard)
{
k.KeyDown += new OpenTK.Input.KeyDownEvent(LogKeyDown);
k.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.Keyboard));
}
void LogKeyUp(object sender, OpenTK.Input.Key key)
{
Trace.WriteLine(String.Format("OpenTK key {0} released on Keyboard: ({1}).",
key, sender as OpenTK.Input.Keyboard));
}
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
public override void OnRenderFrame(EventArgs e)
{
base.OnRenderFrame(e);
GL.Clear(GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
Context.SwapBuffers();
Thread.Sleep(1);
}
}
}