0

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

Magnus
  • 1
  • 1
  • Does this answer your question? [OpenTK: Why is GraphicsMode not available?](https://stackoverflow.com/questions/64534969/opentk-why-is-graphicsmode-not-available) – Rabbid76 Nov 20 '20 at 16:56
  • Read the error, it's telling you that you need to implement a constructor to call `GameWindow`'s constructor, since it doesn't have a default one. – Blindy Nov 20 '20 at 18:08

1 Answers1

0

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

1

vimuth
  • 5,064
  • 33
  • 79
  • 116