MonoGame inside your web browser

More than recompile. Get the source, add bridge.net to it, and fix all discrepancies. Bit of a pain and I think when I did it I probably broke pieces of it, but luckily never used those pieces.

Hey yall! I donā€™t know if anyone is still working on MonoGame.bridge, I was poking around with it and ran into a bug that has me stumpedā€¦ When I add the Bridge.Newtonsoft.Json package to a monogame.bridge project, when I try to load it in the browser it throws an error in the LoadContent method:

Uncaught TypeError: Microsoft.Xna.Framework.Graphics.EffectResource.dict.set is not a function

Is this still work in progress? Please donā€™t tell me this feature was cancelled :sob:

1 Like

Monogame is amazing, and if it runs on wasm, I would no longer need to use game engines like godot or unity

In my case I canā€™t run Bridge.net because my engine has a lot of dependencies on newtownsoft.json :frowning:

1 Like

Man bridge.net does not look good in terms of how they present themselves :frowning: entering bridge.net leads to this empty github org:

Which doesnā€™t even look related? And the tool itself which I assume this one:

https://marketplace.visualstudio.com/items?itemName=BridgeNET.BridgeNET

Have this broken repo URL as its project home link:

https://github.com/bridgedotnet/Bridge

Am I looking at the right place or maybe I missed something? O.o

Not sure if this is the correct one, but take a look at this:

Thanks for the link. Its the same person from bridge.net and in the readme he mentions the VS extension so thatā€™s probably legit too.

Many of the links there are broken too, looks like he tried to reorganize his stuff and just dropped it in the middle so now its all messy :man_shrugging:

Looks like a really cool project, running C# + MG from web can really help distributing small projects and showcase stuff. Also libgdx already got web so its time for MG to have it too :smiley:

2 Likes

I gave up, bridge.net is beyond dead. If you run into problems, there is no one to help, and most of the support material has been removed from their webpage :frowning:

God Damn. What a shame.

1 Like

Iā€™ve setup a demo project on github as a testbed for porting monogame to Blazor/Wasm. That project will eventually become the visual studio template for blazor project. Currently it can draw some primitive types.

7 Likes

I downloaded and got this to work in VS 2022.

FYI @nkast - had to add the 2 shapes to Components and also draw them before I saw anything other than the @ icon in the browser window.

In Game1.cs constructor and Draw() method.

you didnt had to do that. draw is called on components by the framework.

Ah - ok - I took another look.

Building and executing the code as downloaded only shows a revolving ā€œ@ iconā€ image.

This is becase line 19 of Game1.cs is commented out.

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";

        _tri = new TriangleComponent(this);
        _triTx = new QuadTxComponent(this);
        //Components.Add(_tri);                   <---- commented out
        Components.Add(_triTx);

        //tests
        var wnd = this.Window;
        var wndbounds = wnd.ClientBounds;

        return;
    }

This is my first post on mono games. I use to program XNA though Silverlight ā€¦ I gave up on it when MS killed IE and Silverlight. and have been waiting for HTML to mature to allow XNA since at the time this was the theory that HTML would be able to do everything that silverlight did. I started looking at things about 4 months ago and saw that one MS was updating its operating system and a new VS would be coming out shortly there after. one the new features was of the VS was going to be some sort of merger of monogame and something else and that a lot of the old silverlight function/programing language would be coming back as being available for web. I sure i have save those post somewhere in my bookmarks but I bookmark a lot of stuff. Anyway I have now come here to get an update on this merger as I would think mono would know whats going on. this seem like the post that had the most to do with online gaming so I was expecting the update info to be at the end of this post. this says bridge is shutting down which would make sense if a new update was about to take over. so I thought I would say something since ppl seem to be giving up on bridge. Maybe someone with more info could comment on whats up coming. I am just a passive programer at this time but would take more interest if XNA can be brought back to the web in a stable way that would last more than one or two years.

2 Likes

Thatā€™s super cool! Iā€™ve been poking at doing some web3 games, and getting MonoGame stood up in the browser is the last big piece. Thanks again!

@nkast I played around with the Test project in the last few days again, and took a look at the github repository.

I was interested in seeing if I could draw and move a 2D image on the screen.
I altered the quad class supplied in the example to draw in 3D with a flat Z plane and that worked fine.

I then tried to use SpriteBatch.Draw but it looks like that is not implemented (Google Chrome stacktrace showed that it threw a notImplemented Exception).

I then updated the nugets to the latest version in the hope that itā€™s been implemented since, but that broke everything and now it doesnā€™t work at all.

So basically what I was wondering is - is tainicom.xna.Framework.Blazor the official monogame WebGL version that we have all been waiting for? i.e. this:

Apologies if this is an obvious question but I couldnā€™t find any indication in github or nuget.

Iā€™ve added a SpriteBatch test case a couple of weeks ago.
It support the most basic Draw operations. Can you first try if that works for you?

Make sure you sync the latest code from github and do a cache clean up on the browser to ensure you get the latest js changes.
If the SpriteComponent works , then in your case maybe you are using a sample state or some other feature thatā€™s not implemented yet. Try to identify whatā€™s different in your code from the sample SpriteComponent and also look on the full stacktrace to see exactly which execution path throws the notImplemented.

The library is an independent effort to bring the framework on the web, thereā€™s no connection to the official MonoGame repository and releases.

5 Likes

I replaced the sprite with 10 of my own and set them in motion - very nice - thank you!!

4 Likes

I am actually using the Bridge.Net version in a commercial project for a web casino and it works, but has its issues.

How will the speed of something like this compare? Much faster?

@nkast Thank you!!!

Iā€™ve problems with Texture2D.FromStream(), when I try to load a image I get ā€œThis image format is not supportedā€
I submitted the detailed issue: https://github.com/nkast/WebGLxnaProj/issues/1