0

The preview release of Visual studio for Mac uses OpenTK 0,0,0,0 from Package Xamarin.Mac.framework

This is missing numerous calls I need,

  • GL.BindVertexArray
  • GL.DeleteVertexArray
  • GL.GenVertexArrays

Is there some way to P/Invoke these and how should you do it? Or, where is there any good information on how to do it?

Can I remove the .dll from the /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/OpenTK.dll directory and replace it with one elsewhere that has these calls? (I can't use OpenTKv2 open source as Xamarin has Vector2 types, and others stored in another namespace that clash)

andrew
  • 27
  • 6

2 Answers2

1

Can I remove the .dll from the /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/OpenTK.dll directory and replace it with one elsewhere that has these calls? (I can't use OpenTKv2 open source as Xamarin has Vector2 types, and others stored in another namespace that clash)

No, not safely. Replacing random assemblies from inside Xamarin.Mac will not lead to happy results.

Is there some way to P/Invoke these and how should you do it? Or, where is there any good information on how to do it?

Yes, for C functions, like this the standard DllImport should work fine. You can find some examples here.

Chris Hamons
  • 1,510
  • 11
  • 22
  • Please also consider filing bugs bugzilla.xamarin.com/index.cgi for missing bindings so they get fixed. – Chris Hamons Dec 12 '16 at 22:05
  • Awesome - Ill take a look later tonight. I've filed he bugs through the 'report a problem' before asking this. Does that get to bugzilla? – andrew Dec 12 '16 at 22:54
  • Chris - the link you provided seems to point to the latest open source version of xamarin.mac - am I right? I am guessing this isn't used in the preview version of Mac Visual Studio as it **does** seem to have the methods mentioned. [link](https://developer.xamarin.com/guides/cross-platform/visual-studio-mac/) says it uses mono 4.6 where the latest is mono 4.8 - I guess this is the issue. – andrew Dec 13 '16 at 07:30
0

So after Chris's answer I created a class below

public static class PInvoke
{ 
public const string file = "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL";
#if __MAC__

[DllImport(file, EntryPoint = "glBindVertexArray", ExactSpelling = true)]
    internal extern static void BindVertexArray(UInt32 array);
#endif
}

Then from the another class used

PInvoke.glBindVertexArray((uint) _vertexBuffer._VAO_ID);

and it just works instead of

GL.BindVeryexArray((uint) _vertexBuffer._VAO_ID)
andrew
  • 27
  • 6