New test for Basic Mouse Input. Does not work on Mac.

This commit is contained in:
Andy Korth 2012-12-21 15:22:37 -06:00
parent 02ce1430ab
commit 3c609872fe
2 changed files with 78 additions and 0 deletions

View file

@ -49,6 +49,8 @@ namespace Examples
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
// Examples.Tests.BasicMouseInput.Main ();
using (Form browser = new ExampleBrowser()) using (Form browser = new ExampleBrowser())
{ {
try try

View file

@ -0,0 +1,76 @@
// This code was written for the OpenTK library and has been released
// to the Public Domain by Andy Korth
// It is provided "as is" without express or implied warranty of any kind.
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
#endregion --- Using Directives ---
namespace Examples.Tests
{
/// <summary>
/// Demonstrates basic recommended mouse input, and to see if it actually works
/// </summary>
[Example("Basic Mouse Input", ExampleCategory.OpenTK,"Basic Mouse Input")]
public class BasicMouseInput : GameWindow
{
public BasicMouseInput()
: base(800, 600, GraphicsMode.Default)
{ }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
// Here's the big test!
if(OpenTK.Input.Mouse.GetState()[MouseButton.Left]){
Console.WriteLine("You clicked the left mouse button!");
}
if (Keyboard[OpenTK.Input.Key.Escape])
this.Exit();
if (Keyboard[OpenTK.Input.Key.F11])
if (WindowState != WindowState.Fullscreen)
WindowState = WindowState.Fullscreen;
else
WindowState = WindowState.Normal;
}
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
SwapBuffers();
}
[STAThread]
public static void Main()
{
using (BasicMouseInput example = new BasicMouseInput())
{
// Get the title and category of this example using reflection.
ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]);
example.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title);
example.Run(30.0, 0.0);
}
}
}
}