This project is read-only.

Porting experiment

Dec 10, 2013 at 9:57 AM
Hi there!

I was thinking about doing some experiments in porting Neoforce to SharpDX. Maybe it would be easier than finding a new GUI and porting the entire GUI code.

The first thing I tried is maintaining XNA but getting rid of the content manager because it is not available under DirectX.

So I made the Skin code load a raw XML and load all textures from raw DDS files. This work but alpha blending is messed up:

Changing the blend state to NonPremultiplied improves the looks, but the colors are distorted:

This is probably because I generally have problems with my Alpha vs. NonPremultiplied and I'm probably not that familiar with the was XNA converts its images to XNB.

Otherwise, it seems to work and behave well. I'll investigate some premultiplied alpha articles and try to fix the alpha values.
Dec 10, 2013 at 10:41 AM

Hi blo,

Thats fantastic progress!

Have you looked at Monogame at all?

Its a open source implementation of xna and they have a sharpdx version as well.

I have been wanting to move Neoforce to monogame for a while. Currently Monogame does not have a working content pipeline and following the implementation of that porting should be much easier.

Only issue I can see is the lack of a cross platform hardware cursor.

Dec 10, 2013 at 11:03 AM
Hi grimston,

I'm not interested in MonoGame or the SharpDX Toolkit. I have been bitten in the ass by such toolkits before and I don't want to risk again having them be abandoned by their creators.

But I am interested in Neoforce and would like to see it go beyond XNA. XNA is fine right now, but in a couple of years and maybe a few more minor versions of DirectX it will become less and less attractive because of its attachment to an abandoned platform.

I could provide you with a content manager-less version of the code base if you are interested. The only problem is the fonts, which currently I can only load after being processed by the the content manager. But the rest, the XML and images and cursors should work just fine without the content manager with a common code base under XNA, MonoGame, SharpDX and possibly anything else. For XNA a function is needed that I have access to that creates a texture out of a DDS file and under SharpDX the default texture loader should work. For MonoGame I can't tell you anything, but the XNA one should work.

The only problem is that my version won't support archives.

I have figured out the alpha-blending issue to. I just need a tool to batch convert the textures to pre-multiplied DDS.
Dec 10, 2013 at 11:56 AM
blo wrote:
The only problem is that my version won't support archives.

I have figured out the alpha-blending issue to. I just need a tool to batch convert the textures to pre-multiplied DDS.
I take that back. I managed to get archives to work. I defined a new compilation flag. If the flag is set, Neoforce will skip the content manager and use a derived class from ArchiveManager to load raw XML and DDS files from the archive.

A single archive can now support both: XNB files or real extension original files. Or once could use two separate skin files, one for XNA and one general.

If this works out, my plan is to keep XNA and the content manager around, but start using the new FLAG and isolate Neoforce form the content manager. If the flag is not defined, Neoforce behaves just as before. So you could swap out support by changing the DLL.

I'll keep you updated.
Dec 10, 2013 at 12:54 PM

Here is a screenshot with proper alpha blending:

I used this .skin file to get this result:

It has both content manager and raw content, but only for XML and control textures. Fonts and cursors are not yet implemented, so they still use the standard XNA content manager.
Mar 4, 2014 at 1:16 PM
Hi there!

I've been very busy the past few months and did not have time to further investigate this.

But before I got so busy, I did manage to get some results.

First, I managed to produce a version of the skin importer with ZIP support and that was completely isolated from the content manager. Both can exist in parallel.

Then I tried to advance the port and fork NeoForce to not use XNA. I got some very modest results, mainly I couldn't get controls to render the correct state and skin stretching was not supported.

Then I became busy.

But yesterday I had some time and decided to give it a go. To simplify things, I wrote a mini NeoForce from scratch, with the only dependency being SharpDX, supporting only Manager, Control, Button, Label, CheckBox and a new Control, DevicePanel. DevicePanel is a new control I added that allows plug&play device controls to be added to any SharpDX app. Here is a screenshot of it in action:

Now, writing a fresh GUI was exponentially easier than porting the existing code. I made sure that superficial API compatibility is maintained, because I have tons of existing XNA GUI written in NeoForce. The API compatibility was done from memory, not by going over the NeoForce classes. After I have reimplemented all the controls I need I want to be able to copy and paste the entire code base without modification and it must work, behave identically and look pretty much pixel perfect (except for the fonts).

Since this is a fresh implementation, I can "improve" some aspects. IMHO NeoForce is a bit over-engineered and it does do some funky stuff with render target allocation. Also focus events are backwards. An the "initialize" paradigm is not optimally used IMO under this scenario.

I'll add Window and all the controls needed tot create a very good DevicePanel class, but after I'm not sure what to do.

There are several options. I could make sure that most of the interface is identical, but that would mean a lot of copy and pasting. A lot of controls could be 100% identical, especially simple controls like Label and Button.

I don't have time to do a proper port because NeoForce is pretty big. I don't want to copy & paste because that is almost plagiarism.
Mar 21, 2014 at 1:14 PM
I only have time to add or port features when I actually need them, but in the meantime I added a more robust skinning system, client margins, label borders and the Window class and a new VertCombo control that is probably similar to a spinner:

I need to add Anchors support, make the Windows movable and resizable and ListBox and I can start my full on porting of my GUI code from XNA. And fix a few linear filtering bugs.
Jun 19, 2014 at 3:33 PM
how is going the port of neoforce to monogame
Jul 3, 2014 at 6:46 PM
Basic port is available here now:
Jul 3, 2014 at 9:20 PM
I was looking for a sharpdx port this morning and came across this post. I have just ported it to SharpDX too.
Jul 15, 2014 at 9:54 AM
Hmm, we are starting to get some serious progress in regards of porting.

Here is a screenshot of my pseudo-port:

I improved a list box a little to support multiple columns and custom rendering of elements.
Jul 15, 2014 at 10:25 AM
Hey Blo, have you shared your port anywhere? I would like to take a look :-)
Jul 15, 2014 at 10:54 AM
No, I only shared a few of KiB of prototype stuff.

The real version I'm using right now is not shared. I wanted to share it and contacted grimston using Codeplex, but I did not get an answer so I do not know if I am allowed to share.
Jul 15, 2014 at 12:45 PM
I thought I did respond before…

If I didn't, the answer to share is go for it. 😊

Jul 16, 2014 at 1:06 PM
With a basic port to Mono and to SharpDX, my version is less useful.

Still, my version may have some merit since it will never be over 100-120 KiB (currently 72, but it is missing some controls like toolbar and menu) of code and runs on DirectX 9. Once I stop using DirectX 9 I'll port it to 10/11. I isolated it perfectly form my engine and now it only depends on the SharpDX package. I'll clean up the code a bit and post up the code.

For now I have named it Neoforce.Mini. Are you okay with this?
Aug 14, 2014 at 2:25 PM
blo is possibel share the code of VertCombo control
Sep 9, 2014 at 1:20 PM
Lancha wrote:
blo is possibel share the code of VertCombo control
Yes, a slightly outdated unofficial version can be found here:

You need Tut13+.