[英]How do I create openGL context for opentk in dotnetcore c#
我正在使用 opentk 在 C# .Net Core 中编写我的图形控制台应用程序。 我继承了GameWindow
类,如下所示:
class OpenGLWindow:GameWindow
{
public OpenGLWindow(GameWindowSettings gws, NativeWindowSettings nws):base(gws, nws)
{
}
//other overloaded methods here
}
我在 main 方法中创建了窗口,如下所示:
Console.WriteLine("Hello World!");
NativeWindowSettings settings = NativeWindowSettings.Default;
settings.Title = "Befiker";
settings.APIVersion = new Version(4, 6);
GameWindowSettings gws = new GameWindowSettings();
gws.RenderFrequency = 60.0;
using(var win = new OpenGLWindow(gws, settings))
{
win.Run();
}
Console.ReadKey();
窗口已创建,但我注意到它没有清除缓冲区位。 我确定这是因为我还没有创建 opengl 上下文。 NativeWindowSettings
类采用 IGLFWGraphics 上下文类型的SharedContext
。 这就是我被困的地方。 我在 c++ 上使用了 glfw 和 opengl 4.6,并且窗口创建处理上下文创建。 所以我不知道如何创建上下文。 有人可以帮忙吗?
我在这里犯了一个错误。 我忘了包括两个功能。 一种是swapbuffer()。 另一个是makecurrent()。 包含此内容后,所有 opengl 功能都可以正常工作。 这意味着 GameWindow 类自己创建了一个 opengl 上下文。 我仍然不清楚 nativewindowsettings 类 object.sharedcontext 的用途。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.