How to create a second Window in monogame DesktopGL

Hi I’m new in monogame and in my game I find that I need another game window.
In Windows DX it works well.
but after I change the target to DesktopGL, my code went wrong.
In the code:

            Thread thread = new Thread(new ThreadStart(() => {
                var v = new ControlWindow(); 
                v.Run();
            }));

An exception occured. It shows:
Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException:“Failed to create graphics device!”
I just wonder how to properly create another game window in DesktopGL. Any tips can you share?

Could the problem be that you are starting your 2nd game window in a separate thread?

It actually works,but if I don’t starting it in another thread, I will be unable to control the first one. So I wonder is there any way that I can make both of them able to be controlled?

OpenGL doesn’t like getting called from multiple threads, and other parts in MG might also cause problems, because they are not thread safe.
I guess you need to find a way to keep both windows alive from one thread. Could tasks maybe be used for that? (System.Threading.Tasks.Task)
And then I’m still not sure if you’re running into more problems later, because MG might not be built for that use case.

1 Like