【问题标题】:How do I create openGL context for opentk in dotnetcore c#如何在 dotnetcore c# 中为 opentk 创建 openGL 上下文
【发布时间】:2020-10-06 08:03:47
【问题描述】:

我正在使用 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 类采用 SharedContext 类型的 IGLFWGraphics 上下文。这就是我卡住的地方。我在 c++ 上使用了 glfw 和 opengl 4.6,窗口创建处理上下文创建。所以我不知道如何创建上下文。有人可以帮忙吗?

【问题讨论】:

    标签: c# .net-core glfw opentk opengl-4


    【解决方案1】:

    我在这里犯了一个错误。我忘了包括两个功能。一个是swapbuffer()。和 另一个是makecurrent()。包括这个之后,所有的opengl函数都可以正常工作。 这意味着 GameWindow 类自己创建了一个 opengl 上下文。我仍然不清楚 nativewindowsettings 类 object.sharedcontext 的用途。

    【讨论】:

      猜你喜欢
      • 2020-08-29
      • 1970-01-01
      • 1970-01-01
      • 2015-07-12
      • 2016-10-03
      • 2013-03-30
      • 1970-01-01
      • 2014-06-02
      • 1970-01-01
      相关资源
      最近更新 更多