Example #1
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();
            }
        }
Example #2
0
        private static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Initialize();

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

                // Always clean up when you're done.
                // Since Gorgon uses Direct 3D 11.4, 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.
                _depthStencil?.Dispose();
                _texture?.Dispose();
                _geometryShader?.Dispose();
                _pixelShader?.Dispose();
                _vertexShader?.Dispose();
                _bufferless?.Dispose();
                _swap?.Dispose();
                _graphics?.Dispose();
            }
        }
Example #3
0
        /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
        public void Dispose()
        {
            for (int i = 0; i < _volumeRtSections.Length; ++i)
            {
                _volumeSections[i]?.Dispose();
                _volumeRtSections[i]?.Dispose();
            }
            _textureView = null;

            _cube?.Dispose();
            _volumeScaleFactor?.Dispose();
            _volumeRayParams?.Dispose();
            _cubeTransform?.Dispose();
            _cubePosShader?.Dispose();
            _cubeDirShader?.Dispose();
            _cubeVs?.Dispose();
            _inputLayout?.Dispose();

            _cubeTransform     = null;
            _inputLayout       = null;
            _cube              = null;
            _volumeScaleFactor = null;
            _volumeRayParams   = null;
            _cubePosShader     = null;
            _cubeDirShader     = null;
            _cubeVs            = null;
        }
Example #4
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();
        }
Example #5
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();
 }
Example #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();
            }
        }