Пример #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();
            }
        }
Пример #2
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

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

                _lightEffect?.Dispose();
                _renderer?.Dispose();
                _finalTexture?.Dispose();
                _finalTarget?.Dispose();
                _backgroundLogoTexture?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Пример #3
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(Initialize(), Idle);

                if (_mp3Player != null)
                {
                    _mp3Player.Stop();
                }
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _mp3Player.Dispose();
                _renderer?.Dispose();
                _trooper?.Dispose();
                _metal?.Dispose();
                _targetView?.Dispose();
                _target?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Пример #4
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

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

                foreach (GorgonTexture2D texture in _textures)
                {
                    texture?.Dispose();
                }

                _renderer?.Dispose();
                _depthBuffer?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
                _assemblyCache?.Dispose();
            }
        }
Пример #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

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

                _helpFont?.Dispose();
                _shadowTexture?.Dispose();
                _gaussBlur?.Dispose();
                _spriteTexture?.Dispose();
                _backgroundTexture?.Dispose();
                _renderer?.Dispose();
                _blurTexture?.Dispose();
                _blurTarget?.Dispose();
                _layer1Texture?.Dispose();
                _layer1Target?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Пример #6
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

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

                _gaussBlur?.Dispose();
                _oldFilm?.Dispose();
                _displacement?.Dispose();
                _finalView?.Dispose();
                _finalTarget?.Dispose();
                _postView2?.Dispose();
                _postTarget2?.Dispose();
                _postView1?.Dispose();
                _postTarget1?.Dispose();
                _background?.Dispose();
                _renderer?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Пример #7
0
 /// <summary>
 /// Function to perform clean up operations.
 /// </summary>
 private static void CleanUp()
 {
     GorgonExample.UnloadResources();
     _window?.Dispose();
     _fontFactory?.Dispose();
     _graphics?.Dispose();
 }
Пример #8
0
        /// <summary>Raises the <see cref="E:System.Windows.Forms.Form.FormClosing" /> event.</summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.FormClosingEventArgs" /> that contains the event data. </param>
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            GorgonExample.UnloadResources();

            _renderer?.Dispose();
            _leftPanel?.Dispose();
            _rightPanel?.Dispose();
            _graphics?.Dispose();
        }
Пример #9
0
        public static async Task Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.DoEvents();

                // This is necessary to get winforms to play nice with our background thread prior to running the application.
                WindowsFormsSynchronizationContext.AutoInstall = false;
                SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());

                FormMain window = GorgonExample.Initialize(new DX.Size2(Settings.Default.Resolution.Width, Settings.Default.Resolution.Height), "Space Scene",
                                                           async(sender, _) => await InitializeAsync(sender as FormMain));

                GorgonApplication.Run(window);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                // Always perform your clean up.
                if (_keyboard != null)
                {
                    _keyboard.KeyUp -= Keyboard_KeyUp;
                }

                _helpFont?.Dispose();
                _fontFactory?.Dispose();

                GorgonExample.UnloadResources();

                if (_keyboard != null)
                {
                    _input?.UnregisterDevice(_keyboard);
                }
                _input?.Dispose();
                _sceneRenderer?.Dispose();
                _resources?.Dispose();
                _renderer?.Dispose();
                _mainRtv?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
                _assemblyCache?.Dispose();
            }
        }
Пример #10
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.FormClosing"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.FormClosingEventArgs"></see> that contains the event data.</param>
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            GorgonExample.UnloadResources();

            // Perform clean up.
            Gorgon2D        renderer = Interlocked.Exchange(ref _renderer, null);
            GorgonSwapChain screen   = Interlocked.Exchange(ref _screen, null);
            GorgonGraphics  graphics = Interlocked.Exchange(ref _graphics, null);

            renderer?.Dispose();
            screen?.Dispose();
            graphics?.Dispose();
        }
Пример #11
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                Initialize();

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

                _2DRenderer.Dispose();
                _fontFactory.Dispose();

                _input?.Dispose();

                if (_renderer != null)
                {
                    foreach (Mesh mesh in _renderer.Meshes)
                    {
                        mesh.Dispose();
                    }

                    _renderer.Dispose();
                }

                _icoSphere?.Dispose();
                _clouds?.Dispose();
                _sphere?.Dispose();
                _cube?.Dispose();
                _plane?.Dispose();
                _triangle?.Dispose();

                _swapChain?.Dispose();
                _graphics?.Dispose();
            }
        }
Пример #12
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(new Form());
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();
            }
        }
Пример #13
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

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

                if (_images != null)
                {
                    for (int i = 0; i < _images.Length; ++i)
                    {
                        _images[i]?.Dispose();
                    }
                }

                if (_compositor != null)
                {
                    foreach (Gorgon2DCompositionPass pass in _compositor.Passes)
                    {
                        pass.Effect?.Dispose();
                    }
                    _compositor.Dispose();
                }

                _renderer?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }