Reputation: 756
I'm getting a NotImplementedException
in version 1.1 (stable release), the source has been included in the program, and not compiled to OpenTK.dll (single file app) without resources.
I have done this before but not with version 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;
}
}
Is there a way around this? Some sources indicate that it's a linker issue, that the toolkit library is being modified after the build. In short, can it be fixed, or should I revert to an older version (which seems unattractive)?
Upvotes: 0
Views: 518
Reputation: 2794
Indeed, OpenTK 1.1 includes a new binding mechanism based on 'calli' instructions, which are not available in regular C#. The advantage is that they allow us to improve performance and lower memory consumption compared to using delegates or DllImports. (OpenTK 1.1 is consuming 500KB of memory in 5K objets, compared to 1500KB in 30K objects in OpenTK 1.0.)
The downside, of course, is that we need to post-process OpenTK.dll as a post-build event. This is not an issue if you are using a precompiled binary or compiling OpenTK.dll from source, but it makes it more complicated if you include the .cs files directly into your project.
Three solutions, in order of preference:
Depending on why you are embedding the .cs files in your project, some approaches might make more sense than others. I personally follow approach #1, as it is by far the simplest and most versatile option:
A copy of monolinker is included in the OpenTK downloads if you need it.
Upvotes: 1