Ejemplo n.º 1
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>
        protected override void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            GorgonVertexShader       vertexShader   = Interlocked.Exchange(ref _vertexDeferShader, null);
            GorgonPixelShader        deferredShader = Interlocked.Exchange(ref _pixelDeferShader, null);
            GorgonPixelShader        lightShader    = Interlocked.Exchange(ref _pixelLitShader, null);
            GorgonConstantBufferView lightData      = Interlocked.Exchange(ref _lightData, null);
            GorgonConstantBufferView globalData     = Interlocked.Exchange(ref _globalData, null);

            GorgonRenderTargetView[] targets     = Interlocked.Exchange(ref _gbufferTargets, null);
            GorgonTexture2DView      textureView = Interlocked.Exchange(ref _gbufferTexture, null);

            textureView?.Dispose();

            for (int i = 0; i < targets.Length; ++i)
            {
                targets[i]?.Dispose();
            }

            globalData?.Dispose();
            lightData?.Dispose();
            lightShader?.Dispose();
            deferredShader?.Dispose();
            vertexShader?.Dispose();
        }
Ejemplo n.º 2
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                // Now begin running the application idle loop.
                GorgonApplication.Run(Initialize(), Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                // Always clean up when you're done.
                // Since Gorgon uses Direct 3D 11.x, which allocate objects that use native memory and COM objects, we must be careful to dispose of any objects that implement
                // IDisposable. Failure to do so can lead to warnings from the Direct 3D runtime when running in DEBUG mode.
                GorgonExample.UnloadResources();

                _constantBuffer?.Dispose();
                _vertexBuffer.VertexBuffer?.Dispose();
                _inputLayout?.Dispose();
                _vertexShader?.Dispose();
                _pixelShader?.Dispose();
                _swap?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 3
0
 /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
 public void Dispose()
 {
     _materialBuffer?.Dispose();
     _viewProjectionBuffer?.Dispose();
     _worldBuffer?.Dispose();
     _cameraBuffer?.Dispose();
     _lightBuffer?.Dispose();
     _vertexLayout?.Dispose();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     _defaultTexture?.Texture?.Dispose();
     _wvpBuffer?.Dispose();
     _vertexBufferBindings?[0].VertexBuffer?.Dispose();
     _inputLayout?.Dispose();
     _vertexShader?.Dispose();
     _pixelShader?.Dispose();
 }
        /// <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>
        protected override void Dispose(bool disposing)
        {
            GorgonTexture1DView      texture = Interlocked.Exchange(ref _defaultLut, null);
            GorgonPixelShader        shader1 = Interlocked.Exchange(ref _chromeAbShader, null);
            GorgonPixelShader        shader2 = Interlocked.Exchange(ref _simpleChromeAbShader, null);
            GorgonConstantBufferView cbv     = Interlocked.Exchange(ref _settings, null);

            shader1?.Dispose();
            shader2?.Dispose();
            texture?.Dispose();
            cbv?.Dispose();
        }
Ejemplo n.º 6
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                Initialize();
                GorgonApplication.Run(_mainForm, Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _2D.Dispose();

                // Always call dispose so we can free the native memory allocated for the backing graphics API.
                _sphere?.Dispose();

                if (_planes != null)
                {
                    foreach (Plane plane in _planes)
                    {
                        plane?.Dispose();
                    }
                }

                _texture?.Dispose();
                _wvpBuffer?.Dispose();
                _materialBuffer?.Dispose();
                _vertexShader?.Dispose();
                _pixelShader?.Dispose();
                _inputLayout?.Dispose();
                _swap?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            GorgonConstantBufferView buffer = Interlocked.Exchange(ref _cameraBuffer, null);

            buffer?.Dispose();
        }