Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-platform OpenGL rendering in Xamarin

We're developing very similar applications for Windows and Android using Xamarin platform and C#. Both will incorporate some on-screen and off-screen 3D rendering, such as 3D mesh visualization.

We'd like to implement this as cross-platform as possible. How is this usually done in Xamarin? Is it better to do rendering in C++ code, or is there a C# wrapper with abstractions over platform-specific context creation etc.?

like image 513
Aleksei Petrenko Avatar asked Oct 19 '22 15:10

Aleksei Petrenko


1 Answers

After some time I can answer my own question.

At least in my case it turned out to be more convenient to use OpenGL from C++. We just built a shared library from C++ code and link it to .NET dll's using DllImport.

Our tool for building C++ libraries is CMake, however you can use other build systems, such as new features of VS2015.

One particular benefit of this solution is that you can reuse this code anywhere else: in iOS application, desktop application for Windows, Mac, Linux, etc.

like image 155
Aleksei Petrenko Avatar answered Oct 22 '22 09:10

Aleksei Petrenko