Do the Android and iOS versions of OpenTK have the same API?

你说的曾经没有我的故事 提交于 2019-12-13 06:19:26

问题


I'm trying to get into mobile game development with Xamarin; I am using OpenTK for rendering.
My plan is the following:
1. Make a shared library that is actually the game (and has all openTK code).
2. Make a a runnable project for iOS and Android that handles platform specific stuff (e.g. popping up alerts) and uses my shared library.

Is this possible with openTK? Does it have exactly the same API on iOS and on Android, just the linked library is different? If yes, how to avoid code duplication?


回答1:


Your approach sounds very reasonable and will work with a little bit of effort.

The reason is that Xamarin.Android and Xamarin.iOS were forked from an alpha version of the library and have evolved slightly different APIs. Much of the OpenGL ES binding is identical, but some functions have annoying (and unnecessary) differences that you will need to #ifdef in your shared library.

The good news is that the Xamarin fork of OpenTK has now been open-sourced, so we are actively working towards a solution. I already have a private build of library that exposes an identical OpenGL ES API between Android and desktop platforms[1] and I'm working on fixing the differences between the iOS and Android versions.

You can follow the development of OpenTK in the official github repository.

[1] You can execute OpenGL ES code on the desktop using ANGLE or the ARB_ES2_compatibility and ARB_ES3_compatibility extensions. This makes OpenGL ES the first graphics API to work across all major platforms (Windows, Linux, Mac, Android, iOS - and hopefully WinPhone in the future.)



来源:https://stackoverflow.com/questions/21976102/do-the-android-and-ios-versions-of-opentk-have-the-same-api

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