简体   繁体   中英

Im getting an error when using the openTk GameWindow extention

I started c# a few days ago and tried to use the openTk libary.

I installed it via commandline (using vsCode: dotnet add package OpenTK --version 4.2.0) and it seemed like it worked. But in the internet, when searching for examples, they always use the 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. 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.

The Opentk.net shows only the docs for v3, these are samples of v4: https://github.com/opentk/LearnOpenTK

Sample code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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