C# OpenTK游戏窗口未实现异常
在1.1版(稳定版)中,我得到了一个C# OpenTK游戏窗口未实现异常,c#,opentk,C#,Opentk,在1.1版(稳定版)中,我得到了一个NotImplementedException,源代码已经包含在程序中,没有资源也没有编译到OpenTK.dll(单文件应用程序) 我以前做过,但在1.1版中没有: public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int ma
NotImplementedException
,源代码已经包含在程序中,没有资源也没有编译到OpenTK.dll(单文件应用程序)
我以前做过,但在1.1版中没有:
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device,
int major, int minor, GraphicsContextFlags flags, IGraphicsContext sharedContext)
: base(width, height, title, options,
mode == null ? GraphicsMode.Default : mode,
device == null ? DisplayDevice.Default : device)
{
try
{
glContext = new GraphicsContext(mode == null ? GraphicsMode.Default : mode, WindowInfo, major, minor, flags);
glContext.MakeCurrent(WindowInfo);
(glContext as IGraphicsContextInternal).LoadAll();
VSync = VSyncMode.On;
//glWindow.WindowInfoChanged += delegate(object sender, EventArgs e) { OnWindowInfoChangedInternal(e); };
}
catch (Exception e)
{
Debug.Print(e.ToString());
base.Dispose();
throw;
}
}
有办法解决这个问题吗?一些来源指出这是链接器的问题,工具包库在构建之后正在被修改。简而言之,它是可以修复的,还是应该恢复到旧版本(看起来不太吸引人)?事实上,OpenTK 1.1包含了一个基于“calli”指令的新绑定机制,这在常规C#中是不可用的。其优点是,与使用代理或DllImports相比,它们允许我们提高性能并降低内存消耗。(OpenTK 1.1在5K对象中消耗500KB内存,而在OpenTK 1.0中30K对象中消耗1500KB内存。) 当然,缺点是我们需要将OpenTK.dll作为构建后事件进行后期处理。如果使用预编译的二进制文件或从源代码处编译OpenTK.dll,则这不是问题,但如果将.cs文件直接包含到项目中,则会使问题变得更加复杂 三种解决方案,按优先顺序排列:
- 升级新的OpenGL API变得轻而易举(使用nuget或手动复制新的dll)
- 根据我使用的功能,monolinker将OpenTK.dll减少到190-550KB。相比之下,OpenTK1.0是2900KB,OpenTK1.1是3800KB