
Is it possible to import or reference a small subset of OpenTK.Compatibility.dll?
Posted Tuesday, 17 May, 2011 - 01:07 by jfinken inMy sincere apologies if this is more of a general .NET question and/or too off-topic.
My app references OpenTK.dll and OpenTK.GLControl.dll. I'd like to investigate the use of the tesselator functionality found in OpenTK.Compatibility.dll, Glu.Tess*, etc. However including the Compat dll in my project wreaks havoc with my existing code due to GL calls not being fully-qualified. I get several hundred errors like:
'GL' is an ambiguous reference between 'OpenTK.Graphics.GL' and 'OpenTK.Graphics.OpenGL.GL'
because of things like:
GL.GenBuffers(1, out vbo.VertexBufferId);
instead of, say:
OpenTK.Graphics.OpenGL.GL.GL.GenBuffers(1, out vbo.VertexBufferId);
Is there a way to somehow include the Compatibility DLL but tell Visual Studio not use it to resolve identifiers? (Thus allowing me to cherry pick just the tesselator functionality via the 'using' directive). Or something similar? Yes, I could resolve the ambiguities but I thought I'd ask before the significant code change.
Many thanks in advance!


Comments
Re: Is it possible to import or reference a small subset of ...
The source code is available, so I'd suggest to simply take the Glu source files and add them to your project. Problem solved!
Re: Is it possible to import or reference a small subset of ...
I think (although I haven't tested it) that if you change the alias under which the compatibility library is imported it will only resolve when you refer to that alias. To do this expand the references section of the Solution Explorer and in the properties page change the Aliases property from global to something else. I think you'll have to do the same with the using directive as well. Have a look here for more details http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx
Re: Is it possible to import or reference a small subset of ...
I was hoping to somewhat avoid that option, but in the interest of trying the tessellator, I gave it a go. One problem is that GluHelper.cs calls
GL.GetExtensionDelegatethereby causing the same overall problem. So I copied the following methods and classes from OpenTK.Compatibility.Graphics.GL.GLHelper.cs to the GLHelper.cs now in my project:It compiles and when trying to run the tessellate code from my copied Glu.cs, I get the following exception during Glu::LoadAll():
EntryPointNotFoundException: Unable to find an entry point named 'wglGetProcAddress' in DLL 'glu32.dll'.
Is wglGetProcAddress only an entry point in opengl32.dll? Copying the above methods and classes not a good idea?
EDIT:
I can simply change the Library string from "glu32.dll" to "opengl32.dll" in my copied GluHelper.cs and ultimately the tessellate code gets invoked.
However I should have tried elaverick's suggestion first. Many thanks for the tip to investigate Aliases. I changed the Alias property of OpenTK.Compatibility to 'open_tk_glu', for example. Then referenced the aliased assembly like:
I now get a AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at the call to open_tk_glu::OpenTK.Graphics.Glu.DeleteTess(tess);
Re: Is it possible to import or reference a small subset of ...
Here's my entire Tessellate class in case anyone has any ideas. Should look familiar! Thanks in advance.