1
\$\begingroup\$

I have been searching for this everywhere and never found the answer.

I am developing a feature to allow the user to select which monitor to run the game.

I have two monitors, primary and secondary. I tried to use "GraphicsAdapter.Adapters" but it always retrieves only 1 monitor (the one I am running the Visual Studio which is the default one).

Is this a bug? How can I retrieve all the monitors available?

Thanks

MONOGAME 3.6 OPENGL (cross platform) Visual Studio 2015 Windows 10 Pro 64bits

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

If we look at the code for the 3.6 release:

There are three files containing GraphicsAdapter source code. It looks like GraphicsAdapter.Legacy.cs is used if you are using the Windows/OpenGL build of MonoGame.

In this version of the code, the Adapters property performs lazy-initialization of the underlying _adapters array. It has preprocessor blocks to build the array differently based on which platform is being built for. Since you're using Windows, that translates to a call to this line:

_adapters = new ReadOnlyCollection<GraphicsAdapter>(new[] { new GraphicsAdapter() });

The property then simply returns _adapters.

So yes, for OpenGL builds on Windows, GraphicsAdapter.Adapters will only ever return a single item. MonoGame does not appear to implement the functionality necessary to expose multiple-monitor support for OpenGL on Windows, at least not in the fashion you're looking for.

\$\endgroup\$
1
  • \$\begingroup\$ thank you for this useful information, Josh. Now I know where to head to. I dont have enough reputation to vote up yet but the vote was recorded! You will get it as soon as my rep increases it \$\endgroup\$ May 4, 2017 at 20:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .