Can I remove the Xamarin version of OpenTK and use another?

余生颓废 提交于 2020-01-05 04:11:25

问题


I've down loaded visual studio for mac and have created a cross platform solution. I want to use OpenTK v2 (not the one supplied with xamarin).

The problem is that there appears to be an OpenTK namespace that is used run the Xamarin.Mac even when it isn't referenced. The types (Vector4 etc) and the Math Helper class show up in my solution even if the reference isn't showing in the references section.

When I add the OpenTK v2 .dll to the packages (from nuget) I get errors saying 'The imported type 'Opentk.Vector3' (or whatever the type) is defined multiple times. Once in OpenTk and the other in Xamarin.mac (v0).

I've deleted the reference to Xamarin.Mac and the error goes away, but then of course I get errors saying I can't use CoreGraphics etc.

Is there some way of specifying which type you mean? Or removing the references to OpenTK that shouldn't really be there?

Ive tried OpenTK.Matrix4 mat = new OpenTK.Matrix4() but it still doesn't like it.


回答1:


1) Set an Alias for the referenced assembly (reference properties):

2) Add an extern alias to the top of your source file(s):

extern alias OpenTK2;

3) You can then use a using alias or the fully qualified name:

using AlphaFunction = OpenTK2::OpenTK.Graphics.OpenGL.AlphaFunction;
~~~

var alpha = AlphaFunction.Always;
alpha = OpenTK2::OpenTK.Graphics.OpenGL.AlphaFunction.Equal


来源:https://stackoverflow.com/questions/40702057/can-i-remove-the-xamarin-version-of-opentk-and-use-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!