Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using OpenTK;
- using OpenTK.Graphics.OpenGL;
- using OpenTK.Input;
- namespace Examples.Tutorial
- {
- public class Runner {
- private class SimpleWindow : GameWindow
- {
- public SimpleWindow() : base(800, 600)
- {
- KeyUp += Key_Up;
- }
- void Key_Up(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
- {
- if (e.Key == Key.A)
- {
- CursorGrabbed = true;
- }
- else if (e.Key == Key.S)
- {
- CursorGrabbed = false;
- }
- else if (e.Key == Key.Q)
- {
- CursorVisible = true;
- }
- else if (e.Key == Key.W)
- {
- CursorVisible = false;
- }
- }
- protected override void OnLoad(EventArgs e)
- {
- GL.ClearColor(Color.MidnightBlue);
- }
- protected override void OnResize(EventArgs e)
- {
- GL.Viewport(0, 0, Width, Height);
- GL.MatrixMode(MatrixMode.Projection);
- GL.LoadIdentity();
- GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
- }
- }
- public static void Main()
- {
- ToolkitOptions opt = new ToolkitOptions();
- opt.Backend = PlatformBackend.PreferNative;
- Toolkit.Init(opt);
- SimpleWindow example = new SimpleWindow();
- example.Run(30.0, 0.0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement