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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
/// <summary> /// Function to return a leased out swap chain. /// </summary> /// <param name="swapChain">The swap chain to return.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="swapChain"/> parameter is <b>null</b>.</exception> public void ReturnSwapPresenter(ref GorgonSwapChain swapChain) { if (swapChain == null) { throw new ArgumentNullException(nameof(swapChain)); } // This swap chain does not exist. if (swapChain.Window.IsDisposed) { return; } // This swap chain is not cached here, so do nothing. if (!_swapChainLeases.TryGetValue(swapChain.Window.Name, out WeakReference <GorgonSwapChain> cachedSwap)) { return; } if (!cachedSwap.TryGetTarget(out swapChain)) { return; } _swapChainLeases.Remove(swapChain.Window.Name); swapChain.Dispose(); }
/// <summary> /// Function to clean up the renderer objects. /// </summary> private void CleanUpRenderer() { if (_renderer == null) { return; } if (_lastState != null) { _renderer.End2D(_lastState); _lastState = null; } if (_texture != null) { _texture.Dispose(); _texture = null; } if (_defaultTexture != null) { _defaultTexture.Dispose(); _defaultTexture = null; } if (_swapChain != null) { _swapChain.Dispose(); _swapChain = null; } _clipper = null; _graphics = null; }
/// <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(); }
/// <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(); _pluginCache?.Dispose(); _texture?.Dispose(); _swap?.Dispose(); _graphics?.Dispose(); _image?.Dispose(); }
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(); } }
/// <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(); }
/// <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); _blurredImage[1]?.Dispose(); _blurredTarget[1]?.Dispose(); _blurredImage[0]?.Dispose(); _blurredTarget[0]?.Dispose(); _blurEffect?.Dispose(); _helpFont?.Dispose(); _textFont?.Dispose(); _renderer?.Dispose(); _screen?.Dispose(); _graphics?.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) { if (!_disposed) { if (disposing) { // Save our settings. GorgonFontEditorPlugIn.Settings.Save(); if (_badGlyphTexture != null) { _badGlyphTexture.Dispose(); } // Remove any externally linked dependencies. EditorFile = null; if (Font != null) { Font.Dispose(); } if (Renderer != null) { Renderer.Dispose(); } if (_textDisplay != null) { _textDisplay.Dispose(); } if (_swap != null) { _swap.Dispose(); } } _swap = null; Renderer = null; Font = null; _panel = null; _textDisplay = null; _disposed = true; } base.Dispose(disposing); }
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(); } }
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(); } }
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(); } }
public void CleanUp() { if (_renderer != null) { _renderer.Dispose(); _renderer = null; } if (_screen != null) { _screen.Dispose(); _screen = null; } if (_graphics != null) { _graphics.Dispose(); _graphics = null; } if (_form != null) { _form.Dispose(); _form = null; } }
protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); if (_font != null) { _font.Dispose(); } if (_2d != null) { _2d.Dispose(); } if (_swap != null) { _swap.Dispose(); } if (_graphics != null) { _graphics.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) { if (!_disposed) { if (disposing) { GorgonSpriteEditorPlugIn.Settings.Save(); // Clear any external dependencies. EditorFile = null; if (BackgroundTexture != null) { BackgroundTexture.Dispose(); } if (_swap != null) { _swap.Dispose(); } if (Renderer != null) { Renderer.Dispose(); } } } _disposed = true; Texture = null; BackgroundTexture = null; Renderer = null; _swap = null; base.Dispose(disposing); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() => _swapChain?.Dispose();
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Initialize(); Gorgon.Run(_form, Idle); } catch (Exception ex) { GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex)); } finally { if (_materialBuffer != null) { _materialBuffer.Dispose(); } if (_normalEarfMap != null) { _normalEarfMap.Dispose(); } if (_normalMap != null) { _normalMap.Dispose(); } if (_specEarfMap != null) { _specEarfMap.Dispose(); } if (_specMap != null) { _specMap.Dispose(); } if (_cloudMap != null) { _cloudMap.Dispose(); } if (_clouds != null) { _clouds.Dispose(); } if (_sphere != null) { _sphere.Dispose(); } if (_light != null) { _light.Dispose(); } if (_cube != null) { _cube.Dispose(); } if (_plane != null) { _plane.Dispose(); } if (_triangle != null) { _triangle.Dispose(); } if (_wvp != null) { _wvp.Dispose(); } if (_renderer2D != null) { _renderer2D.Dispose(); } if (_swapChain != null) { _swapChain.Dispose(); } if (_graphics != null) { _graphics.Dispose(); } } }