简体   繁体   English

使用 openTk GameWindow 扩展时出现错误

[英]Im getting an error when using the openTk GameWindow extention

I started c# a few days ago and tried to use the openTk libary.几天前我开始使用 c# 并尝试使用 openTk 库。

I installed it via commandline (using vsCode: dotnet add package OpenTK --version 4.2.0) and it seemed like it worked.我通过命令行安装了它(使用vsCode:dotnet add package OpenTK --version 4.2.0),它似乎有效。 But in the internet, when searching for examples, they always use the Game:: GameWindow class.但是在互联网上,在搜索示例时,他们总是使用 Game::GameWindow class。 When I type that, im getting an error.当我键入时,我得到一个错误。 Can you help me?你能帮助我吗? Heres my code:这是我的代码:

using System;
using OpenTK;
using OpenTK.Graphics.OpenGL4;

namespace tk_test1
{
    public class Game : GameWindow
    {

    }
}

Error picture错误图片

That's because you're probably using OpenTK v4, So please check your version.那是因为您可能使用的是 OpenTK v4,所以请检查您的版本。 In that case, your 'using' must looks like this:在这种情况下,您的“使用”必须如下所示:

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

Then, your GameWindow extends must works.然后,您的 GameWindow 扩展必须有效。

The Opentk.net shows only the docs for v3, these are samples of v4: https://github.com/opentk/LearnOpenTK Opentk.net 仅显示 v3 的文档,这些是 v4 的示例: https://github.com/opentk/LearnOpenTK

Sample code示例代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM