سؤال

Is it safe to use OpenTK functions from within a MonoGame project? Do I lose any portability?

هل كانت مفيدة؟

المحلول

The short answer is no and yes respectively. You shouldn't make a habit of using OpenTK functions from within a MonoGame project because you could lose portability.

MonoGame uses OpenTK under the hood to provide support for some (probably most) of it's platforms. However, there's no good reason to believe that all future platforms will support OpenTK or that MonoGame will always use it.

I can see 10 supported platforms based on the solution files on github and at least one of them uses Windows DirectX instead of OpenGL. Although, there is an OpenGL version as well.

That said, if you really need to use OpenTK in your project directly, you could do it the same way MonoGame implements multi-platform support. If you poke around the code for a bit you'll notice various defines for platform specific code like so:

#if ANDROID
  // your code here
#endif

#if DIRECTX
 // your code here
#endif

#if WINDOWS_PHONE
 // your code here
#endif

At the end of the day, you just need to weigh up the risks depending on what platforms you would like to support and the effort you're willing to go to do so. Good luck! :)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top