Game Engine Development with MonoGame

I’ve been looking for a solid framework to build a cross-platform game engine / editor!

I was going to go completely from scratch using libraries like (OpenGL, OpenAL, FreeType, Etc.) but I have realised how much of a monumental task this is becoming over months of planning. I’ve known about MonoGame for a very long time although I have only just started learning basic things and searching the source code to get an understanding how some things work.

The problem I’m facing is that MonoGame seems to rely on the external MonoGame Content Pipeline tool with is a GUI program for processing content for us in MonoGame.

However, I have noticed you can avoid using this tool with calls such as Texture2D.FromFile which loads a .png file into my application without the Content Pipleline tool.

How limited is this? Does it work on ALL platforms? What happens when it comes to Fonts? (spritefonts) What about shaders? (Effects) How can I compile fonts into spritefont files and use them? How can I compile shaders into fx files and use them?

These are the sort of problems I’m faced with before making my decision to take the project on, if these can be solved this looks very very promising for my application.

Thank you!

Hi @LloydJHowarth, Welcome to the Community!

This thread may shed some light on the question somewhat…

I did find some other relevant threads but I think this one would answer a lot of questions you may have…

Happy Coding!

1 Like

I guess for discussion, why would you be concerned with using the MGCB Editor to process content. Is there a reason you can’t or won’t use it?

Truth be told, there is a divide in comminity discussion, some either hate the MGCB Editor content proessing and others use it with no issue. Im in the latter.

If theres no legitiamte reason to avoid using it other than some people dont like it, id say try using it and see how it works for you and your use case.

1 Like

@Aristurtle The reason I do not wish to use it is because I will be making a game engine / editor (like Unity) and using third party tools with the engine just isn’t ideal. The work flow would become more hassle using other programs with the core engine. Imagine if Unity required you to use a content management tool that isn’t built into the engine. The ‘content’ in Unity is compiled as soon as its found in the “Assets” directory.

In order to make a similar system for my own engine I would need to know if I can compile spritefonts from font files and compile effects from text files.

Is there a way to use the Content Pipeline tool but through commands instead of using the actual GUI application?

@MrValentine This project does look interesting. I will take a look and see if they use a custom content management system.

EDIT:
So there is a custom content management system that doesn’t involve the GUI tool. Which is awesome, however there is no download. I have found another community post though where the developer of MonoGame.Forms has roughly explained how you could go about doing what he did.

Link: Building and loading content at runtime?

Thanks a lot for the information!

1 Like

Yea all of the content building can be done via the dotnet-mgcb tool via command line without the editor.

You should also take a look at flatredball and maybe speak with vchelaru the MG discord about how they do it

https://flatredball.com/

3 Likes

Thanks a lot I will take a look :slight_smile:

Actually, the MGCB GUI is just a front end text editor for the Content.mgcb file.
It has a couple of nice features, like present options and allowing builds/cleanup/rebuilds and displaying error messages and build time, but it is not required.

The game build process includes the building of out of date or non-existing content from the text of the Content.mgcb file and the source files.

I believe it does work on all platforms, I cannot speak for the consoles. Certain platforms may have storage permission and placement requirements.

Using .png files is only efficient for storage. Once loaded, the file is decompressed and converted(per pixel) to bitmap array, and as such has much higher memory requirements and video card bus bandwidth requirements than the optimized compressed version for the target platform (DXT1/5,ETC1/2, PVRTC, ATSC…)

Manual building of a spritefont is not a trivial task. It involves creating a packed texture, a dictionary of source rectangles and spacing data for each glyph and font spacing data.

Unlike textures, there is currently no common shader format (Vulcan aims to do this but implementation is spotty and very driver dependent as of this writing; Like all new technologies, the situation will improve with time.)

Manually:
You can write and compile your own shaders for each platform and create an C# class with register allocation mappings and hooks. I cringe at the fragility of this suggestion.

Bottom Line:

Use the Content system, you will save yourself from a lot of headaches later on. It is a mature cross platform solution that works. It is not perfect by any means, but it has a dedicated community following willing to help.

If you find the existing system inadequate, you can always modify it to suit your needs.

For example, I implemented a runtime text renderer in Android for complete color emoji support. It is not as efficient as the built in SpriteFont class, but it worked for my purposes.

The takeaway is that you should stand upon the the shoulders of those who came before you.

1 Like

This code snippet might be useful for you if you want to build some assets via code

1 Like

Also take a look at GitHub - rds1983/XNAssets: Alternative to MonoGame Content Pipeline that loads raw assets. It seems to be possible to completley skip MGCB (and its dependencies) and loading most common assets rawly. I need to test this myself. It looks interesting.

1 Like