/// <summary> /// gets called, after the handle has been destroyed /// </summary> /// <param name="e"></param> protected override void OnHandleDestroyed(EventArgs e) { base.OnHandleDestroyed(e); if (m_context != null) { m_context.Dispose(); m_context = null; } m_window_info = null; }
/// <summary>Raises the HandleCreated event.</summary> /// <param name="e">Not used.</param> protected override void OnHandleCreated(EventArgs e) { if (UseOpenGL) { if (context != null) { context.Dispose(); } if (implementation != null) { implementation.WindowInfo.Dispose(); } if (design_mode) { implementation = new DummyGLControl(); } else { implementation = new GLControlFactory().CreateGLControl(format, this); } context = implementation.CreateContext(major, minor, flags); MakeCurrent(); if (!design_mode) { ((IGraphicsContextInternal)Context).LoadAll(); } // Deferred setting of vsync mode. See VSync property for more information. if (initial_vsync_value.HasValue) { Context.VSync = initial_vsync_value.Value; initial_vsync_value = null; } } base.OnHandleCreated(e); if (UseOpenGL) { if (resize_event_suppressed) { OnResize(EventArgs.Empty); resize_event_suppressed = false; } } }
public override void Dispose() { _sceneDataConstantBuffers.Dispose(); _cubeInstanceBuffers.Dispose(); _renderTarget.Dispose(); _gfx.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 virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // Free other state (managed objects). } // Free your own state (unmanaged objects). if (_context != null) { _context.Dispose(); _context = null; } if (_wi != null) { _wi.Dispose(); _wi = null; } _disposed = true; } }
private void Dispose(bool manual) { if (!IsDisposed) { lock (SyncRoot) { RemoveContext(this); } // Note: we cannot dispose the implementation // from a different thread. See wglDeleteContext. // This is also known to crash GLX implementations. if (manual) { Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString()); if (implementation != null) { implementation.Dispose(); } } else { Debug.WriteLine("GraphicsContext leaked, did you forget to call Dispose()?"); } IsDisposed = true; } }
public void Dispose() { _vertexBufferManager.Dispose(); _renderTarget.Dispose(); _graphics.Dispose(); _app.Dispose(); }
public bool Parse() { Exception e = null; Thread thrd = new Thread(new ThreadStart(delegate { try{ CreateContext(); CreateProgram(); if (Compile()) { Attach(); if (Link()) { LoadAttributes(); LoadUniforms(); } } }catch (Exception ex) { e = ex; } })); thrd.Start(); thrd.Join(); window.Dispose(); context.Dispose(); if (e != null) { throw e; } return(true); }
// -------------------------------------------------------------------- public void Dispose() { mWindowsInfo.Dispose(); mGraphicsContext.Dispose(); mWindowsInfo = null; mGraphicsContext = null; }
/// <summary>Raises the HandleCreated event.</summary> /// <param name="e">Not used.</param> protected override void OnHandleCreated(EventArgs e) { if (_dummyContext != null) { _dummyContext.Dispose(); } if (implementation != null) { implementation.WindowInfo.Dispose(); } if (Configuration.RunningOnWindows) { implementation = new WinGLControl(_graphics.Mode, this); } //else if (Configuration.RunningOnMacOS) return new CarbonGLControl(mode, control); //else if (Configuration.RunningOnX11) return new X11GLControl(mode, control); else { throw new PlatformNotSupportedException(); } _dummyContext = implementation.CreateContext(1, 1, GraphicsContextFlags.Default); MakeCurrent(); if (!design_mode) { ((IGraphicsContextInternal)Context).LoadAll(); } // Deferred setting of vsync mode. See VSync property for more information. if (initial_vsync_value.HasValue) { _graphics.GraphicsContext.SwapInterval = initial_vsync_value.Value ? 1 : 0; initial_vsync_value = null; } base.OnHandleCreated(e); if (resize_event_suppressed) { OnResize(EventArgs.Empty); resize_event_suppressed = false; } }
public void Dispose() { _constantBufferManager.Dispose(); _meshBufferManager.Dispose(); _renderTarget.Dispose(); _graphics.Dispose(); _app.Dispose(); }
private void ReleaseOpenGLResources() { _renderer?.DeleteBuffers(); if (!_settings.IsUsingExternalContext) { _context?.Dispose(); _context = null; } }
private void DestroyContext() { AssertNotDisposed(); AssertValidContext(); __renderbuffergraphicsContext.Dispose(); __renderbuffergraphicsContext = null; _glapi = null; }
public void Dispose() { Release(); _context?.Dispose(); if (BoundContexts.Contains(this)) { BoundContexts.Remove(this); } }
/// <summary>Raises the HandleCreated event.</summary> /// <param name="e">Not used.</param> protected override void OnHandleCreated(EventArgs e) { if (context != null) { context.Dispose(); } if (windowInfo != null) { windowInfo.Dispose(); } this.windowInfo = Utilities.CreateWindowsWindowInfo(this.Handle); this.context = new GraphicsContext(this.graphicsMode, this.windowInfo, major, minor, flags); MakeCurrent(); ((IGraphicsContextInternal)Context).LoadAll(); if (!this.IsInitialized) { this.IsInitialized = true; this.Initialized(this, EventArgs.Empty); } // Deferred setting of vsync mode. See VSync property for more information. if (initialVsyncValue.HasValue) { Context.SwapInterval = initialVsyncValue.Value ? 1 : 0; initialVsyncValue = null; } base.OnHandleCreated(e); if (resizeEventSuppressed) { OnResize(EventArgs.Empty); resizeEventSuppressed = false; } }
public void Dispose() { //Release(); if (_context != null) { _context.Dispose(); } if (CurrentContexts.Contains(this)) { CurrentContexts.Remove(this); } }
public void Dispose() { Release(); if (_context != null) { _context.Dispose(); } if (BoundContexts.Contains(this)) { BoundContexts.Remove(this); } }
/// <summary> /// Raises the HandleCreated event. /// </summary> /// <param name="e">Not used.</param> protected override void OnHandleCreated(EventArgs e) { if (!(_implementation is DummyGLControl)) { // No need to recreate our DummyGLControl _context?.Dispose(); _implementation?.WindowInfo.Dispose(); if (_designMode) { _implementation = new DummyGLControl(); _context = _implementation.CreateContext(_major, _minor, _flags); HasValidContext = false; } else { try { _implementation = new GLControlFactory().CreateGLControl(_format, this); _context = _implementation.CreateContext(_major, _minor, _flags); HasValidContext = true; } catch (GraphicsModeException) { _implementation = new DummyGLControl(); _context = _implementation.CreateContext(_major, _minor, _flags); HasValidContext = false; } } MakeCurrent(); if (HasValidContext) { ((IGraphicsContextInternal)_context).LoadAll(); } // Deferred setting of vsync mode. See VSync property for more information. if (_initialVsyncValue.HasValue) { _context.SwapInterval = _initialVsyncValue.Value ? 1 : 0; _initialVsyncValue = null; } } base.OnHandleCreated(e); if (_resizeEventSuppressed) { OnResize(EventArgs.Empty); _resizeEventSuppressed = false; } }
public virtual void Dispose(bool disposing) { if (disposing) { graphicsContext.MakeCurrent(windowInfo); OnShuttingDown(); if (GraphicsContext.ShareContexts && (Interlocked.Decrement(ref graphicsContextCount) == 0)) { OnGraphicsContextShuttingDown(); sharedContextInitialized = false; } graphicsContext.Dispose(); } }
protected override void Dispose(bool disposing) { if (disposing) { _GraphicsContext.MakeCurrent(_WindowInfo); OnShuttingDown(); if (GraphicsContext.ShareContexts && (Interlocked.Decrement(ref _GraphicsContextCount) == 0)) { OnGraphicsContextShuttingDown(); _SharedContextInitialized = false; } _GraphicsContext.Dispose(); } }
/// <summary> Disposes of the GameWindow, releasing all resources consumed by it. </summary> public override void Dispose() { try { Dispose(true); } finally { try { if (glContext != null) { glContext.Dispose(); glContext = null; } } finally { base.Dispose(); } } GC.SuppressFinalize(this); }
/// <summary>Raises the HandleCreated event.</summary> /// <param name="e">Not used.</param> protected override void OnHandleCreated(EventArgs e) { context?.Dispose(); implementation?.WindowInfo?.Dispose(); // Test the current flags flags = GetUsableContextFlags(flags); if ((flags & GraphicsContextFlags.AngleD3D9) > 0) { if (ConfigManager.sFullscreen) { ForcedWindowed = false; flags |= GraphicsContextFlags.AngleFullscreen; } else { ForcedWindowed = true; } } implementation = design_mode ? new DummyGLControl() : new GLControlFactory().CreateGLControl(format, this, flags); context = implementation.CreateContext(major, minor, flags); MakeCurrent(); if (!design_mode) { ((IGraphicsContextInternal)context).LoadAll(); } // Deferred setting of vsync mode. See VSync property for more information. if (initial_vsync_value.HasValue) { Context.SwapInterval = initial_vsync_value.Value ? 1 : 0; initial_vsync_value = null; } base.OnHandleCreated(e); if (resize_event_suppressed) { OnResize(EventArgs.Empty); resize_event_suppressed = false; } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_config != null) { Toml.WriteFile(_config, "config.toml", _tomlSettings); _config = null; } _waveIn?.StopRecording(); _waveIn?.Dispose(); _waveIn = null; _speechRecognizer?.Dispose(); _speechRecognizer = null; _skFont?.Dispose(); _skFont = null; _skStrokePaint?.Dispose(); _skStrokePaint = null; _skFillPaint?.Dispose(); _skFillPaint = null; _skScreenSurface?.Dispose(); _skScreenSurface = null; _skScreenRenderTarget?.Dispose(); _skScreenRenderTarget = null; _skContext?.Dispose(); _skContext = null; _skInterface?.Dispose(); _skInterface = null; _tkContext?.Dispose(); _tkContext = null; _tkWindow?.Dispose(); _tkWindow = null; } }
public void Dispose() { if (disposed) { return; } disposed = true; context?.Dispose(); if (Window != IntPtr.Zero) { SDL.SDL_DestroyWindow(Window); } SDL.SDL_Quit(); }
/// <summary>Raises the HandleDestroyed event.</summary> /// <param name="e">Not used.</param> protected override void OnHandleDestroyed(EventArgs e) { // Ensure that context is still alive when passing to events // => This allows to perform cleanup operations in OnHandleDestroyed handlers base.OnHandleDestroyed(e); if (context != null) { context.Dispose(); context = null; } if (implementation != null) { implementation.WindowInfo.Dispose(); implementation = null; } }
void Dispose(bool disposing) { if (!IsDisposed) { // Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString()); lock (SyncRoot) { available_contexts.Remove((this as IGraphicsContextInternal).Context); } if (!IsExternal) { if (implementation != null) { implementation.Dispose(); } } IsDisposed = true; } }
/// <summary>Raises the HandleDestroyed event.</summary> /// <param name="e">Not used.</param> protected override void OnHandleDestroyed(EventArgs e) { // Ensure that context is still alive when passing to events // => This allows to perform cleanup operations in OnHandleDestroyed handlers base.OnHandleDestroyed(e); if (_implementation is DummyGLControl) { // No need to destroy our DummyGLControl return; } if (_context != null) { _context.Dispose(); _context = null; } if (_implementation != null) { _implementation.WindowInfo.Dispose(); _implementation = null; } }
public override void Dispose() { base.Dispose(); glContext.Dispose(); }
protected override void DoDispose() => context.Dispose();
public static void Remove(IGraphicsContext context) { if (context != null) Contexts.Remove(context); context.Dispose(); }
internal void Dispose() { if (m_window == null) { return; } try { if (!m_context.IsDisposed && !m_context.IsCurrent && !m_window.Exists) { return; } m_context.MakeCurrent(m_window.WindowInfo); ErrorCode err = GL.GetError(); if (err != ErrorCode.NoError) { MyLog.WARNING.WriteLine(Owner.Name + ": OpenGL error detected when disposing stuff, code: " + err); } // delete textures if (m_textureHandles != null) { foreach (int handle in m_textureHandles.Values) { int h = handle; GL.DeleteTextures(1, ref h); } m_textureHandles.Clear(); } if (m_renderTextureHandle != 0) { GL.DeleteTextures(1, ref m_renderTextureHandle); m_renderTextureHandle = 0; } if (m_scoreTextHandle != 0) { GL.DeleteTextures(1, ref m_scoreTextHandle); m_scoreTextHandle = 0; } // delete FBO if (m_fboHandle != 0) { GL.DeleteFramebuffers(1, ref m_fboHandle); m_fboHandle = 0; } // delete PBO if (m_sharedBufferHandle != 0) { GL.DeleteBuffers(1, ref m_sharedBufferHandle); m_sharedBufferHandle = 0; } // delete CUDA <-> GL interop if (m_renderResource != null) { m_renderResource.Dispose(); m_renderResource = null; } if (m_context != null) { m_context.Dispose(); m_context = null; } if (m_window != null) { m_window.Dispose(); m_window = null; } } catch (AccessViolationException e) { MyLog.WARNING.WriteLine(Owner.Name + ": Failed when disposing OpenGL stuff. Cautious progress advised. Error: " + e.Message); } catch (Exception e) { MyLog.WARNING.WriteLine(Owner.Name + ": Failed when disposing OpenGL. Error: " + e.Message); } }
public void Cleanup() { _rtt.Dispose(); _context.Dispose(); _window.Dispose(); }