OpenTK的试用笔记

安装:

Install-Package OpenTK

https://opentk.net/learn/chapter1/1-creating-a-window.html?tabs=baseclass-opentk4%2Cgamewindow-ctor-opentk4%2Cgamewindow-run-opentk4%2Ckeypress-opentk4

using OpenTK.Graphics.OpenGL4;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;

using (Game game = new Game(800, 600, "LearnOpenTK"))
{
    game.Run();
}

public class Game : GameWindow
{
    public Game(int width, int height, string title) : base(GameWindowSettings.Default, new NativeWindowSettings() { Size = (width, height), Title = title })
    {
    }

    protected override void OnUpdateFrame(FrameEventArgs e)
    {
        base.OnUpdateFrame(e);

        if (KeyboardState.IsKeyDown(Keys.Escape))
        {
            Close();
        }
    }
}
posted @ 2024-10-24 11:19  wzwyc  阅读(10)  评论(0编辑  收藏  举报