示例#1
0
        internal GameWindow(GameOptions options)
        {
            GLFWNative.WindowHint(GLFWNative.VISIBLE, 0);
            GLFWNative.WindowHint(GLFWNative.RESIZABLE, options.WindowResizable ? 1 : 0);

            IntPtr monitor = IntPtr.Zero;

            if (options.WindowIsFullscreen)
            {
                monitor = GLFWNative.GetPrimaryMonitor();
                this.IsFullscreen = true;
            }

            this.window = GLFWNative.CreateWindow(options.WindowWidth, options.WindowHeight, string.Empty, monitor, IntPtr.Zero);

            this.title = string.Empty;
            this.size = new Size(options.WindowWidth, options.WindowHeight);
            this.position = new Point(0, 0);

            // It is important to hold references to the callbacks so that the GC does not garbage collect the delegates.

            this.windowPosCallback = this.OnWindowMove;
            GLFWNative.SetWindowPosCallback(this.window, this.windowPosCallback);

            this.windowSizeCallback = this.OnWindowResize;
            GLFWNative.SetWindowSizeCallback(this.window, this.windowSizeCallback);

            this.charCallback = this.OnChar;
            GLFWNative.SetCharCallback(this.window, this.charCallback);

            this.keyCallback = this.OnKey;
            GLFWNative.SetKeyCallback(this.window, this.keyCallback);

            this.cursorPosCallback = this.OnCursorPos;
            GLFWNative.SetCursorPosCallback(this.window, this.cursorPosCallback);

            this.mouseButtonCallback = this.OnMouseButton;
            GLFWNative.SetMouseButtonCallback(this.window, this.mouseButtonCallback);

            this.scrollCallback = this.OnScroll;
            GLFWNative.SetScrollCallback(this.window, this.scrollCallback);

            GLFWNative.MakeContextCurrent(this.window);

            this.keyEventArgs = new KeyEventArgs();
            this.keyPressEventArgs = new KeyPressEventArgs();
            this.mouseEventArgs = new MouseEventArgs();
            this.mouseButtonEventArgs = new MouseButtonEventArgs();
            this.mouseWheelEventArgs = new MouseWheelEventArgs();
        }
示例#2
0
 private void Window_KeyUp(object sender, KeyEventArgs e)
 {
     this.keys[(int)e.Key] = false;
 }
示例#3
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     this.keys[(int)e.Key] = true;
 }