void DoCleanup()
        {
            if (_context != null)
            {
                using (_context.MakeCurrent())
                {
                    var gl = _context.GlInterface;
                    gl.BindTexture(GL_TEXTURE_2D, 0);
                    gl.BindFramebuffer(GL_FRAMEBUFFER, 0);
                    gl.DeleteFramebuffers(1, new[] { _fb });
                    _fb = 0;
                    gl.DeleteRenderbuffers(1, new[] { _depthBuffer });
                    _depthBuffer = 0;
                    _attachment?.Dispose();
                    _attachment = null;
                    _bitmap?.Dispose();
                    _bitmap = null;

                    try
                    {
                        if (_initialized)
                        {
                            _initialized = false;
                            OnOpenGlDeinit(_context.GlInterface, _fb);
                        }
                    }
                    finally
                    {
                        _context.Dispose();
                        _context = null;
                    }
                }
            }
        }
 void EnsureTextureAttachment()
 {
     _context.GlInterface.BindFramebuffer(GL_FRAMEBUFFER, _fb);
     if (_bitmap == null || _attachment == null || _bitmap.PixelSize != GetPixelSize())
     {
         _attachment?.Dispose();
         _attachment = null;
         _bitmap?.Dispose();
         _bitmap     = null;
         _bitmap     = new OpenGlBitmap(GetPixelSize(), new Vector(96, 96));
         _attachment = _bitmap.CreateFramebufferAttachment(_context);
     }
 }