I pulled together all of the bits on this topic I could find and wrote up a tutorial on how to get MonoGame running on a website with @harry-cpp’s fantastic WebGL package.
Is it possible to split the .js file into individual files, one per class or namespace
and then use ES6 modules to load them on demand?
e.g. “import {Vector2, Vector3} from ‘/modules/xna.monogame.Framework-module.js’;”
e.g. “import {Viewport} from ‘/modules/xna.monogame.Framework.graphics-module.js’;”
With this you will improve loading times, (assuming the monogame.js is found in the browser cache),
webapps can use the latest version,
and collect statistics about usage.
Hey, this is awesome and managed to display a few things on my web browser. But as I wanted to port a small game I made, I ran into a Specified method is not supported error. My game is quite simple and I think I won’t have any problem finding a workaround for this method… if only I knew which one !
Is it possible to know where my problem is? Thanks.
Here’s the full stacktrace :
System.Exception: Uncaught System.NotSupportedException: Specified method is not supported.
Error: Specified method is not supported.
at ctor (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/bridge.min.js:7:91540)
at ctor.$ctor1 (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/bridge.min.js:7:92638)
at new ctor (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/bridge.min.js:7:672784)
at Function.GetGLFormat (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/MonoGame.Framework.min.js:1:797900)
at $ctor1.PlatformConstruct (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/MonoGame.Framework.min.js:1:1465479)
at $ctor1.$ctor3 (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/MonoGame.Framework.min.js:1:1459903)
at new $ctor1 (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/MonoGame.Framework.min.js:1:1458253)
at ctor.Read$1 (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/MonoGame.Framework.min.js:1:1504857)
at ctor.Read (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/MonoGame.Framework.min.js:1:987998)
at ctor.InnerReadObject (https://v6p9d9t4.ssl.hwcdn.net/html/1591541/net472/MonoGame.Framework.min.js:1:178591)
I’ve been meaning to check this out for a while and finally got around to it. Alpha or not. This rocks!! Good job @harry-cpp . I just ported one of our monogame based games. I expected a lot of issues during the port, but I was surprised by how much was already working.
Take a look at https://www.bingonomics.com. choose play as a guest and take a look at the “High Noon Saloon” game. Speed was not much of an issue since the game is designed to run on low cost android tablets.
There are a few issues I have found with sound effects especially when exiting and restarting the game. And it needs the ability to resize on the fly.
I am pretty familiar with the monogame source code since I use a customized version to integrate into our platforms. I think I will grab the source see if I can figure out what is going on.
Also thanks to @craftworkgames on the excellent info for getting things setup.
Heads up on this. You’ll be tempted to pull in the latest Bridge.NET Nuget, but the current one has an incompatibility. It’ll work until you try to load textures. Use Bridge.NET 17.2 or earlier.
There used to be a starter project out there but I can’t find it now.
General things for me.
start a project and add the bridge.net NuGet package as well as the MonoGame for bridge package.
The bridge.net package you use must be only up to 17.2ish unless you want to manually “fix” Monogame for the latest bridge version by downloading the source.
Look at his sample code for some good async loading examples.
I was unable to really load graphics up and display them until I created an iis local web server. Always got a script error trying to run them by pulling up index.html in a browser.
Make sure to add MIME type .xnb for your web server.
@T_F_G Saw your post a bit late, spritebatch will more than likely get you better performance than DrawUserIndexedPrimitives with Bridge.NET (some marshaling issue), but a proper wasm version isn’t too far off now and it should be available in a couple of months.