Headless Monogame

In looking over the requirements for a personal project, I find myself in need of a headless Monogame instance. No graphics, no drawing, but using the same MonoGame classes so I only need to create a single copy of any of my nongraphical behaviors.

Looking through the github source, I think this would be doable by creating a new GraphicsDeviceManager, possibly with the aid of a HeadlessGamePlatform class.

Before I get actually making a fork and pull request for this, is there any interest in seeing this? Is there already an accepted way to make a headless Monogame that I’m simply missing?

So you still want it to be able to create graphics resources like textures or shaders, but don’t don’t want a window or anything to be rendered?

This is just a assumption but he might just want to use monogame since it pulls resources from the GPU not the CPU?

More concerned with being able to run simulation code without needing to reimplement timing or Game Component classes. Technically unnecessary, but could help clean up my own code

Maybe this is what you need?

I’ve seen that, and while this idea would solve a similar problem, the answer for unit tests seems to be in the direction of making a window and just hiding it. What I’m looking at is preventing the need for that much, since I plan to make it deployable into a non graphical environment, such as a VM

I might understand now what you are after. Decouple your game logic from monogame’s game class and introduce a layer of abstraction for all classes that do require a GraphicsDevice instance.

Hi,

I know it’s 10 years later but I’ve searched for the same thing now and found nothing.
To take care of my needs in this Headless context I’ve created this subversion patch http://pastebin.com/Hi4tf3px

It works for me and what I need, but I may have broken stuff for other who apply this patch.

Get the source code and apply it, then call game.SetHeadless(true); on your game instance before game.Run.
Maybe somebody will find it useful.

Hi, I know it’s four years later but I found a solution that works on Desktop that doesn’t require patching MonoGame.

2 Likes

Still interested enough that I’ll check it out, thanks!