none
Problem with openTK library, window not closing RRS feed

  • Question

  • Hi, 

    I have just started learning how to use openTK library. I was performing the first tutorial on openTK's web.

    This program consist on create a window, and allow the user to press Escape key to close it. I have followed all of the instructions and the program is not working, the window opens but it doesn't close on pressing Escape key.

    I attach the code here:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace CreatingWindow
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (Game game = new Game(800, 600, "LearnOpenTK"))
                {
                    game.Run(60.0);
                  
                }
                
                
            }
    
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using OpenTK;
    using OpenTK.Graphics;
    using OpenTK.Input;
    
    namespace CreatingWindow
    {
        public class Game : GameWindow
        {
    
    
            public Game(int width, int height, string title) : base(width, height, GraphicsMode.Default, title)
            {
    
    
                
            }
    
            protected override void OnUpdateFrame(FrameEventArgs e)
            {
                KeyboardState input = Keyboard.GetState();
    
                if (input.IsKeyDown(Key.Escape))
                {
                    Exit();
                }
    
                base.OnUpdateFrame(e);
            }
        }
    }
    • Moved by CoolDadTx Thursday, October 31, 2019 1:42 PM Third party product
    Thursday, October 31, 2019 8:37 AM

All replies

  • We only provide support for C#-specific questions here. Please post questions related to third party products in their support forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, October 31, 2019 1:42 PM