C# Mono, MonoDroid and Windows

March 30th, 2011

Woot! had a sale on Viewsonic gTablets last week and I couldn’t resist.  The gTablet is built with the NVIDIA Tegra 2 and has a dual core A9 processor.  Battery life is “ok”, I see about 4 hours with Wi-Fi enabled.

My previous tablet (a wow! pad) was unable to connect to my development system via USB.  This coupled with a Google Wi-Fi ADB bug prevented me from debugging MonoDroid using the Visual Studio debugger.  DDMS worked, but wasn’t nearly as nice to use.

Anyway, I moved forward on a proof of concept to see just how much code I could share between Windows, Linux and Android.

My testing was done using Visual Studio 2010, .NET 4, Mono 2.1 on Suse, and MonoDroid (9779).

I was extremely pleased on the code sharing between Windows and Linux.  I managed to share 99.9% of my UI (Windows Forms), Network (SOAP calls), and Rendering (using OpenTK).  The only issue I ran into was the Microsoft generated web service wrapper, which would not run under Mono unless I set the Nullable = false.

I had high hopes for the MonoDroid version, but these died fast. 

The Android Activity is different enough to require custom code.  This wasn’t too bad, I kind of expected that.

The SOAP code worked, which was nice.

The rendering code is where I got a dose of reality.  I expected OpenTK to provide the same interface for OpenGL ES as it provided for the standard OpenGL (in hindsight, I should have known better).  Well, that isn’t the case.

For example; if I want to render a yellow triangle using OpenTK under Windows or Linux, I would do this:

GL.Color3(Color.Yellow);
GL.Begin(BeginMode.Triangles);
    GL.Vertex2(0.0, 0.0);
    GL.Vertex2(1.0, 0.0);
    GL.Vertex2(0.5, 1.0);
GL.End();            

 

Using OpenGL ES, you would do something like this:

float[] vertices = {
    0.0f, 0.0f,
    1.0f, 0.0f,
    0.5f, 1.0f };
 
GL.Color4(255, 255, 0, 255);
GL.VertexPointer(2, All.Float, 0, square_vertices);
GL.EnableClientState(All.VertexArray);                        
GL.DrawArrays(All.Triangles, 0, 4);

 

So, the rendering code would need to be specialized for the ES API.  This is a bit of a bummer.

I checked back into the Qt Lighthouse (Android) project it has progressed a bit.  For example Qt Creator is up and running, and there is a system wide shared Qt .so installer.  But, it still seems a bit young for commercial development right now.

My current mindset is that MonoDroid will help get a Desktop App over to Android, but will require a great deal of custom code (which means more testing).

Entry Filed under: Uncategorized

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

March 2011
M T W T F S S
« Jan   May »
 123456
78910111213
14151617181920
21222324252627
28293031  

Most Recent Posts