I just started to learn OpenTK and stumbled upon a problem when going through this tutorial.
This is what I tried:
using System;
using OpenTK;
using OpenTK
The tutorial is based on OpenTK 3.x, which was written for .NET framwork. OpenTK 4.x is written for .NET core. In 3.x the GameWindow was part of the OpenTK.Graphics namespace. Now the class is contained in OpenTK.Windowing.Desktop and behaves different. The constructor has 2 arguments, GameWindowSettings and NativeWindowSettings.
namespace Testing
{
public class GraphicsWindow : GameWindow
{
public GraphicsWindow(int width, int height, string title)
: base(
new GameWindowSettings(),
new NativeWindowSettings()
{
Size = new OpenTK.Mathematics.Vector2i(width, height),
Title = title
})
{ }
}
}
Alternatively create a static factory method:
namespace Testing
{
public class GraphicsWindow : GameWindow
{
public static GraphicsWindow New(int width, int height, string title)
{
GameWindowSettings setting = new GameWindowSettings();
NativeWindowSettings nativeSettings = new NativeWindowSettings();
nativeSettings.Size = new OpenTK.Mathematics.Vector2i(width, height);
nativeSettings.Title = title;
return new GraphicsWindow(setting, nativeSettings);
}
public GraphicsWindow(GameWindowSettings setting, NativeWindowSettings nativeSettings)
: base(setting, nativeSettings)
{}
}
}
var myGraphicsWindow = GraphicsWindow.New(800, 600);