Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using OpenTK;
  4. using OpenTK.Graphics.OpenGL;
  5. using OpenTK.Input;
  6.  
  7. namespace Examples.Tutorial
  8. {
  9. public class Runner {
  10. private class SimpleWindow : GameWindow
  11. {
  12. public SimpleWindow() : base(800, 600)
  13. {
  14. KeyUp += Key_Up;
  15. }
  16.  
  17. void Key_Up(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
  18. {
  19. if (e.Key == Key.A)
  20. {
  21. CursorGrabbed = true;
  22. }
  23. else if (e.Key == Key.S)
  24. {
  25. CursorGrabbed = false;
  26. }
  27. else if (e.Key == Key.Q)
  28. {
  29. CursorVisible = true;
  30. }
  31. else if (e.Key == Key.W)
  32. {
  33. CursorVisible = false;
  34. }
  35. }
  36.  
  37. protected override void OnLoad(EventArgs e)
  38. {
  39. GL.ClearColor(Color.MidnightBlue);
  40. }
  41.  
  42. protected override void OnResize(EventArgs e)
  43. {
  44. GL.Viewport(0, 0, Width, Height);
  45.  
  46. GL.MatrixMode(MatrixMode.Projection);
  47. GL.LoadIdentity();
  48. GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
  49. }
  50.  
  51. }
  52.  
  53. public static void Main()
  54. {
  55. ToolkitOptions opt = new ToolkitOptions();
  56. opt.Backend = PlatformBackend.PreferNative;
  57.  
  58. Toolkit.Init(opt);
  59.  
  60. SimpleWindow example = new SimpleWindow();
  61.  
  62. example.Run(30.0, 0.0);
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement