MG 3.3 Win Forms


My Editor which was using MG and Win Forms isn’t working anymore, I think it has something to do with the GraphicsDevice changes.

I tried this code sample.

In the line where the GraphicsDevice should be created i get an Object null reference error, but none of the GraphicsDevice parametes are null.

protected void CreateDevice (IntPtr windowHandle, int width, int height)
    GraphicsAdapter adapter = GraphicsAdapter.DefaultAdapter;
    GraphicsProfile profile = GraphicsProfile.Reach;
    PresentationParameters pp = new PresentationParameters() {
        DeviceWindowHandle = windowHandle,
        BackBufferWidth = Math.Max(width, 1),
        BackBufferHeight = Math.Max(height, 1),
    _device = new GraphicsDevice(adapter, profile, pp);
    if (DeviceCreated != null)
        DeviceCreated(this, EventArgs.Empty);

It sounds like you’re not using the Game class and running everything within the game loop. The MG 3.2 changes seem to make the GraphicsDevice creation dependent on the Game class. Logically, it shouldn’t be, but I guess since most people use MG for making games, developers didn’t notice/care. Hopefully it will change in the future.

See this post: “It turns out that since version 3.2 create GraphicsDevice outside Game class is impossible frowning”