Exemple #1
0
        protected override void OnClosed(EventArgs e)
        {
            // dispose all the DirectX bits

            deviceContext.ClearState();
            deviceContext.Flush();


            if (vertexBuffer != null)
            {
                vertexBuffer.Dispose();
            }

            if (vertexShader != null)
            {
                vertexShader.Dispose();
            }

            if (pixelShader != null)
            {
                pixelShader.Dispose();
            }

            if (renderTargetView != null)
            {
                renderTargetView.Dispose();
            }

            if (device != null)
            {
                device.Dispose();
            }

            base.OnClosed(e);
        }
Exemple #2
0
 protected virtual void DisposeDirectXResources()
 {
     DwFactory?.Dispose();
     RenderTarget?.Dispose();
     D2DFactory?.Dispose();
     D3DDevice?.Dispose();
 }
 public override void Dispose()
 {
     D3DDevice.Dispose();
     DxgiDevice.Dispose();
     D2DDevice.Dispose();
     base.Dispose();
 }
Exemple #4
0
 protected virtual void DisposeDirectXResources()
 {
     DwFactory.Dispose();
     RenderTarget.Dispose();
     RenderTargetView.Dispose();
     D2DFactory.Dispose();
     SwapChain.Dispose();
     D3DDeviceContext.Dispose();
     D3DDevice.Dispose();
 }
Exemple #5
0
        public void Dispose()
        {
            renderTargetView.Dispose();

            ImmediateContext.ClearState();
            ImmediateContext.Flush();
            ImmediateContext.Dispose();

            D3DDevice.Dispose();
            swapChain.Dispose();
        }
Exemple #6
0
        public void Destroy()
        {
            Application.Idle -= OnTick;

            Screen.OnDisposeBuffers();

            Screen.OnDispose();

            BackbufferRTV.Dispose();

            D3DDevice.Dispose();
            DXGISwapChain.Dispose();
        }
Exemple #7
0
        /// <summary>
        ///		終了する。
        /// </summary>
        public virtual void Dispose()
        {
            if (!D3DDeviceContext.IsDisposed && D3DDeviceContext.Rasterizer.State != null && !D3DDeviceContext.Rasterizer.State.IsDisposed)
            {
                D3DDeviceContext.Rasterizer.State.Dispose();
            }

            if (D3DDevice != null && !D3DDevice.IsDisposed)
            {
                D3DDevice.Dispose();
            }

            if (Adapter != null && !Adapter.IsDisposed)
            {
                Adapter.Dispose();
            }

            if (DXGIFactory != null && !DXGIFactory.IsDisposed)
            {
                DXGIFactory.Dispose();
            }
        }
Exemple #8
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                Gorgon.Log.Print("Gorgon Graphics Context shutting down...", LoggingLevel.Simple);

                if (!IsDeferred)
                {
                    _trackedObjects.ReleaseAll();
                }
                else
                {
                    Context.ClearState();
                }

                DestroyInterfaces();

                // Only clean up the context if the context is deferred.
                if (IsDeferred)
                {
                    if (_commands != null)
                    {
                        // Release any outstanding command lists.
                        while (_commands.Count > 0)
                        {
                            ReleaseCommands(_commands[_commands.Count - 1]);
                        }
                    }

                    if (Context != null)
                    {
                        Context.Flush();
                        Context.Dispose();
                    }

                    Context = null;

                    // Remove us from object tracking.
                    ImmediateContext.RemoveTrackedObject(this);
                }
                else
                {
                    Gorgon.Log.Print("Removing D3D11 Device object...", LoggingLevel.Verbose);

                    // Destroy the video device interface.
                    if (D3DDevice != null)
                    {
                        D3DDevice.Dispose();
                        D3DDevice = null;
                    }

                    if (Adapter != null)
                    {
                        Adapter.Dispose();
                        Adapter = null;
                    }

                    if (GIFactory != null)
                    {
                        GIFactory.Dispose();
                        GIFactory = null;
                    }

                    if (VideoDevice != null)
                    {
                        VideoDevice.Graphics = null;
                    }

                    Gorgon.Log.Print("Removing DXGI factory interface...", LoggingLevel.Verbose);
                    if (GIFactory != null)
                    {
                        GIFactory.Dispose();
                        GIFactory = null;
                    }

                    // Remove us from the object tracker.
                    Gorgon.RemoveTrackedObject(this);
                }

                Gorgon.Log.Print("Gorgon Graphics Context shut down successfully", LoggingLevel.Simple);
            }

            _disposed = true;
        }
Exemple #9
0
        // Disposer
        public void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Let the plugins know
                General.Plugins.OnMapCloseBegin();

                // Stop processing
                General.MainWindow.StopProcessing();

                // Change to no mode
                General.Editing.ChangeMode((EditMode)null);

                // Unbind any methods
                General.Actions.UnbindMethods(this);

                // Dispose
                if (grid != null)
                {
                    grid.Dispose();
                }
                if (launcher != null)
                {
                    launcher.Dispose();
                }
                if (copypaste != null)
                {
                    copypaste.Dispose();
                }
                if (undoredo != null)
                {
                    undoredo.Dispose();
                }
                General.WriteLogLine("Unloading data resources...");
                if (data != null)
                {
                    data.Dispose();
                }
                General.WriteLogLine("Unloading map data...");
                if (map != null)
                {
                    map.Dispose();
                }
                General.WriteLogLine("Stopping graphics device...");
                if (renderer2d != null)
                {
                    renderer2d.Dispose();
                }
                if (renderer3d != null)
                {
                    renderer3d.Dispose();
                }
                if (graphics != null)
                {
                    graphics.Dispose();
                }
                visualcamera = null;
                grid         = null;
                launcher     = null;
                copypaste    = null;
                undoredo     = null;
                data         = null;
                //tempwad = null;
                map        = null;
                renderer2d = null;
                renderer3d = null;
                graphics   = null;

                // We may spend some time to clean things up here
                GC.Collect();

                // Let the plugins know
                General.Plugins.OnMapCloseEnd();

                // Done
                isdisposed = true;
            }
        }