以下代码由于行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);
}