Skip to content

RenderTarget2D.Dispose behavior not the same #575

Description

@7aGiven
    class MyGame : Game
    {
        [STAThread]
        static void Main(string[] args)
        {
            using (MyGame g = new MyGame())
            {
                g.Run();
            }
        }

        private readonly GraphicsDeviceManager gdm;
        MyGame()
        {
            gdm = new GraphicsDeviceManager(this);
            Window.AllowUserResizing = true;
        }

        bool flag = true;
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            if (flag)
            {
                flag = false;
                GraphicsDevice gd = GraphicsDevice;
                RenderTarget2D renderTarget = new RenderTarget2D(gd, 10, 10);
                gd.SetRenderTarget(renderTarget);
                renderTarget.Dispose();
                gd.SetRenderTarget(null);
            }
        }
    }

When use XNA, it no error.
When use FNA, it throw error System.InvalidOperationException: Disposing target that is still bound.

How to the same behavior to them?

Note: if remove gd.SetRenderTarget(null);, XNA will throw error.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions