Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET/Mono HW Accelerated Graphics with Software Fallback

Background

As far as I know, WPF does hardware-accelerated drawing if possible, with a fallback to software rendering if the user does not have DirectX 9+. That is a very interesting idea, and I even like the idea of XAML.

The reason I don't like it, and why I didn't even bother learning it, is that while Windows Forms is a Microsoft technology, and inferior to WPF, it is cross-platform through Mono, something that's not true for WPF, and probably will never be.
There's debate around whether a .NET WinForms wrapper for Linux/OS X will hit a patent brick wall in the future, but that's outside of the scope of this question.

Question

Is there any library for .NET and Mono that will let me use basic hardware acceleration (think alpha compositing, fast pixel manipulation, etc) with a software fallback for systems without the required GPUs/drivers?

In short: fast graphics on non-ancient desktops and modern laptops, but usable graphics on low-end netbooks and similar devices. This is not for game development.

Further Notes

There are several tricks to make GDI+ faster. Set/GetPixel are much improved by raw pointer access.
The pixel format used can improve rendering greatly, 32bppPArgb (32-bit with 8-bit Alpha and RGB values Pre-multiplied by the alpha).
There are other tricks that can get faster speeds, but managed GDI+ is still slow for some purposes.

Frameworks I'm Aware Of

  • Unity3D - AFAIK does not support Mono. Does. Shareware with free version.
  • TAO Framework - Looks a bit complicated, and does not seem to support sofware rendering.
  • OpenTK - Active, well-developed, and better than TAO, but no software fallback either.
  • SDL.NET - Same problem as above.
  • MonoXNA - Same as above.
  • Irrlicht - "It is completely cross-platform, using D3D, OpenGL and its own software renderer".
  • Silverlight/Moonlight - Suggested by dthorpe. Alpha quality, no support whatsoever.
  • Mono.Cairo - Suggested by Mark H.
  • AGG - High quality, very efficient software rendering, implemented in C++ with an unofficial C# port.
  • Axiom3D - Ogre port. Supports Mono, open-source and seems alive. Promising.

My current choice is to try Irrlicht, but only because I see no alternative. Is there?
Besides, even though it seems to support software rendering, I don't know how's the state of it in it's .NET/Mono wrapper, and the support link of it is a forum post.

none at the moment.

Besides there is a further problem: I have no idea how to "abstract" around a graphics library. If further on I realize I've made the wrong choice, I won't know what to do.

Please excuse the length of this question.


Edit: Since this question had two really constructive answers, I'll wait some days and tick the most upvoted one as the accepted answer.

In another news, it seems OpenGL is implemented in software, both by OS vendors as by third parties, and these implementations will be used by OpenGL frameworks in the lack of third party drivers.

like image 650
Camilo Martin Avatar asked Dec 14 '11 23:12

Camilo Martin


3 Answers

How about cairo? It has multiple back-ends, including OpenGL, GDI, X, and Quartz, and should work on nearly any device. Mono.Cairo implements a .NET wrapper for it, but I'm unsure whether this allows switching back-end through code, or whether it requires rebuilding for each system.

Cairo is used as the back-end for Moonlight, Gtk+, and Mono's System.Drawing implementation.

like image 105
Mark H Avatar answered Sep 30 '22 06:09

Mark H


One framework set not mentioned in your lineup is Silverlight. It's hardware accelerated on Windows, and Moonlight is now hardware accelerated on Linux. Not sure about software fallback, but I imagine they have to have fallback since they were both designed for very broad consumer use.

like image 43
dthorpe Avatar answered Sep 30 '22 05:09

dthorpe


How about OpenTK but then using http://www.mesa3d.org/? It's been a long time since I looked at mesa3d but it provides a software-rendering capability to OpenGL.

like image 25
JimFing Avatar answered Sep 30 '22 04:09

JimFing