将EventHandler <eventargs>转换为EventHandler <keyboardeventargs>

时间:2018-03-16 16:29:40

标签: c# opengl 3d opentk

以下代码由于行window.KeyPress += keypress;而无法编译,错误表示无法将EventHandler<EventArgs>隐式转换为EventHandler<KeyboardEventArgs>。我想围绕OpenTK输入处理构建一个包装器,以便以后能够实现其他框架。有关如何分配通用事件处理程序以便调用类不知道OpenTK的任何建议?提前谢谢。

public override void CreateWindow(int width, int height, bool fullscreen, string title, EventHandler<EventArgs> keypress)
{
    window = new NativeWindow(width, height, title, fullscreen ? GameWindowFlags.Fullscreen : GameWindowFlags.FixedWindow, GraphicsMode.Default, DisplayDevice.Default);
    context = new GraphicsContext(GraphicsMode.Default, window.WindowInfo, 4, 4, GraphicsContextFlags.Default);
    context.MakeCurrent(window.WindowInfo);
    (context as IGraphicsContextInternal).LoadAll();
    window.Visible = true;
    window.Resize += OnResize;
    window.KeyPress += keypress;

    GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL.Enable(EnableCap.CullFace);
}

0 个答案:

没有答案