Пример #1
0
        public static void RenderScreen(FBO fbo)
        {
            // Create the screen if it's not exist
            if (screenVAO == 0)
            {
                float[] indArray = new float[] {
                    -1.0f, 1.0f, 0.0f, 1.0f,
                    1.0f, 1.0f, 1.0f, 1.0f,
                    1.0f, -1.0f, 1.0f, 0.0f,

                    1.0f, -1.0f, 1.0f, 0.0f,
                    -1.0f, -1.0f, 0.0f, 0.0f,
                    -1.0f, 1.0f, 0.0f, 1.0f
                };

                screenVAO = GL.GenVertexArray();
                screenVBO = GL.GenBuffer();

                GL.BindVertexArray(screenVAO);
                GL.BindBuffer(BufferTarget.ArrayBuffer, screenVBO);
                GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * indArray.Length, indArray, BufferUsageHint.StaticDraw);
                GL.EnableVertexAttribArray(GL.VERTEX_POSITION_LOCATION);
                GL.VertexAttribPointer(GL.VERTEX_POSITION_LOCATION, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 0);
                GL.EnableVertexAttribArray(GL.VERTEX_TEXTURE_COORD_LOCATION);
                GL.VertexAttribPointer(GL.VERTEX_TEXTURE_COORD_LOCATION, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 2 * sizeof(float));

                screenShaderProgram = new RenderTextureShaderProgram()
                {
                    PostEffectMode = PostEffectMode.None,
                    Width          = fbo.Size.Width,
                    Height         = fbo.Size.Height
                };
            }

            // Bind the shader
            screenShaderProgram.Bind();

            // Bind the vertex array
            GL.BindVertexArray(screenVAO);

            // Depth test settings
            BackupState(RendererBackupMode.DepthTest);
            BackupState(RendererBackupMode.FaceCulling);
            DepthTest(false);
            FaceCulling(false);

            // Bind the texture
            GL.ActiveTexture(GL.COLOR_TEXTURE_UNIT_INDEX);
            GL.BindTexture(TextureTarget.Texture2D, fbo.GetTextureID(FramebufferAttachment.ColorAttachment0));

            // Draw the screen
            GL.DrawArrays(BeginMode.Triangles, 0, 6);

            // Make sure this VAO don't change from the outside
            GL.BindVertexArray(0);

            // Restore states
            RestoreState(RendererBackupMode.DepthTest);
            RestoreState(RendererBackupMode.FaceCulling);
        }
Пример #2
0
 public void ClearAllColourBuffers(Vector4 colour)
 {
     foreach (var slot in TextureSlots.Where(s => s.Enabled).Select(s => s.Slot))
     {
         FBO.ClearColourBuffer(slot, colour);
     }
 }
Пример #3
0
 protected override void OnRendering(IHostScreen screen, ref FBO currentFbo)
 {
     currentFbo = _gBuffer.FBO;
     FBO.Bind(currentFbo, FBO.Target.FrameBuffer);
     ElffyGL.Clear(ClearMask.ColorBufferBit | ClearMask.DepthBufferBit);
     _gBuffer.ClearColorBuffers();
 }
Пример #4
0
        public RenderTexture(int width, int height, Filter filterMode = Filter.Linear, Wrapping wrapMode = Wrapping.Repeat, string path = "") : base(path, false)
        {
            fbo = new FBO();
            fbo.Bind();

            Handle = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, Handle);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, width, height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);

            depthStencil = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, depthStencil);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Depth24Stencil8, width, height, 0, PixelFormat.DepthStencil, PixelType.UnsignedInt248, IntPtr.Zero);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);

            var metaData = LoadMetaData();

            SetFilter(metaData.Count >= 1 ? (Filter)Convert.ToInt32(metaData[0].value) : filterMode, false);
            SetWrapping(metaData.Count >= 2 ? (Wrapping)Convert.ToInt32(metaData[1].value) : wrapMode);

            fbo.AttachTexture(Handle);
            fbo.AttachDepthStencilTexture(depthStencil);

            if (GL.Ext.CheckFramebufferStatus(FramebufferTarget.Framebuffer) != FramebufferErrorCode.FramebufferComplete)
            {
                Logging.LogWarning(this, "Framebuffer is not complete!");
            }
            fbo.Unbind();
        }
Пример #5
0
            static (IHostScreen Screen, FBO Fbo, TextureObject DepthTex, Vector2i Size) Create(int width, int height)
            {
                var screen = Engine.GetValidCurrentContext();
                var size   = new Vector2i(width, height);
                var depth  = TextureObject.Empty;
                var fbo    = FBO.Empty;

                try {
                    depth = TextureObject.Create();
                    TextureObject.Bind2D(depth);
                    TextureObject.DepthImage2DUninitialized(size);
                    TextureObject.Parameter2DMinFilter(TextureShrinkMode.NearestNeighbor, TextureMipmapMode.None);
                    TextureObject.Parameter2DMagFilter(TextureExpansionMode.NearestNeighbor);
                    TextureObject.Parameter2DWrapS(TextureWrapMode.ClampToBorder);
                    TextureObject.Parameter2DWrapT(TextureWrapMode.ClampToBorder);
                    fbo = FBO.Create();
                    FBO.Bind(fbo, FBO.Target.FrameBuffer);
                    FBO.SetTexture2DBuffer(depth, FBO.Attachment.DepthAttachment);
                    GL.DrawBuffer(DrawBufferMode.None);
                    GL.ReadBuffer(ReadBufferMode.None);
                    FBO.ThrowIfInvalidStatus();
                    FBO.Unbind(FBO.Target.FrameBuffer);
                    return(Screen : screen, Fbo : fbo, DepthTex : depth, Size : size);
                }
                catch {
                    TextureObject.Delete(ref depth);
                    FBO.Delete(ref fbo);
                    throw;
                }
            }
Пример #6
0
 public void newSize()
 {
     if (_SnapBuffer != null)
     {
         _SnapBuffer.Dispose();
     }
     _SnapBuffer = null;
 }
Пример #7
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     if (FBO.ShowDialog() == DialogResult.OK)
     {
         Settings.Default.SavePath = FBO.SelectedPath;
         Directory_Read(FBO.SelectedPath);
     }
 }
Пример #8
0
        private protected sealed override void RenderOverride(IHostScreen screen, ref FBO currentFbo)
        {
            var timingPoints = TimingPoints;

            timingPoints.BeforeRendering.DoQueuedEvents();
            if (IsVisible)
            {
                RenderPostProcess(screen, ref currentFbo);
            }
            timingPoints.AfterRendering.DoQueuedEvents();
        }
Пример #9
0
 public Rasterizer(int resolutionX, int resolutionY, DrawHandler drawHandler)
 {
     if (ReferenceEquals(null, drawHandler))
     {
         throw new ArgumentException("Draw handler must not equal null!");
     }
     this.drawHandler  = drawHandler;
     copyToFrameBuffer = new TextureToFrameBuffer();
     texRenderSurface  = Texture.Create(resolutionX, resolutionY);
     texRenderSurface.FilterNearest();
     renderToTexture = new FBO(texRenderSurface);
 }
Пример #10
0
 public void BindForWriting()
 {
     SaveViewport();
     FBO.Bind(FramebufferTarget.DrawFramebuffer);
     GL.Viewport(0, 0, Width, Height);
     SetDrawBuffers();
     if (WantDepth)
     {
         GL.Enable(EnableCap.DepthTest);
         GL.DepthMask(true);
     }
 }
Пример #11
0
 public Image(int width, int height, bool hasDepthBuffer = false, byte components = 4, bool floatingPoint = false) : this(hasDepthBuffer)
 {
     var tex = TextureLoader.Create(width, height, components, floatingPoint);
     if (hasDepthBuffer)
     {
         fbo = new FBOwithDepth(tex);
     }
     else
     {
         fbo = new FBO(tex);
     }
 }
Пример #12
0
 public void Resize(int width, int height)
 {
     _width                       = width;
     _height                      = height;
     _aspect                      = (float)width / height;
     _renderToTexture[0]          = new FBO(Texture2dGL.Create(width, height));
     _renderToTexture[1]          = new FBO(Texture2dGL.Create(width, height));
     _renderToTexture[2]          = new FBO(Texture2dGL.Create(width, height));
     _renderToTexture[3]          = new FBO(Texture2dGL.Create(width / 2, height / 2));
     _renderToTexture[4]          = new FBO(Texture2dGL.Create(width, height));
     _renderToTextureWithDepth[0] = new FBOwithDepth(Texture2dGL.Create(width, height));
     _renderToTextureWithDepth[1] = new FBOwithDepth(Texture2dGL.Create(width / 2, height / 2, 1, true));
 }
Пример #13
0
        private void GlSetup()
        {
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.DepthClamp);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Blend);
            GL.CullFace(CullFaceMode.Back);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.ActiveTexture(TextureUnit.Texture0);

            _frameBuffer = new FBO(Width, Height, false, 4);
        }
Пример #14
0
        public Rasterizer(IContentLoader contentLoader, int resolutionX, int resolutionY, Action drawHandler)
        {
            if (drawHandler is null)
            {
                throw new ArgumentException("Draw handler must not equal null!");
            }

            this.drawHandler  = drawHandler;
            copyToFrameBuffer = new PostProcessing(contentLoader.LoadPixelShader("copy.frag"));
            var texRenderSurface = Texture2dGL.Create(resolutionX, resolutionY);

            texRenderSurface.Filter = TextureFilterMode.Nearest;
            fbo = new FBO(texRenderSurface);
        }
Пример #15
0
        /// <summary>
        /// Bind GBuffer for writing to the supplied textures
        /// </summary>
        /// <param name="outputTextures"></param>
        public void BindForWritingTo(params TextureSlot[] outputTextures)
        {
            // shouldn't call this if we've got any texture slots defined.
            SaveViewport();
            FBO.Bind(FramebufferTarget.DrawFramebuffer);
            GL.Viewport(0, 0, Width, Height);

            for (int i = 0; i < outputTextures.Length; i++)
            {
                outputTextures[i].AttachToFramebuffer(FBO.Target);
            }

            GL.DrawBuffers(outputTextures.Length, outputTextures.Select(t => t.DrawBufferSlot).ToArray());
        }
Пример #16
0
        public PlayerTrail()
        {
            var window = Framework.Game.Instance.Window;

            fbo = new FBO(Texture2dGL.Create(window.Width, window.Height));
            fbo.Texture.WrapFunction = TextureWrapFunction.MirroredRepeat;
            try {
                shader = ShaderLoader.FromStrings(
                    DefaultShader.VertexShaderScreenQuad,
                    DefaultShader.FragmentShaderCopy);
            } catch (ShaderException e) {
                Console.WriteLine(e.ShaderLog);
            }
        }
Пример #17
0
        public void UnbindFromWriting()
        {
            FBO.Unbind(FramebufferTarget.DrawFramebuffer);
            RestoreViewport();

            // generate any requested mipmaps
            foreach (var ts in TextureSlots.Where(s => s.Enabled && s.TextureParam.MipMaps))
            {
                GL.Enable(EnableCap.Texture2D);
                ts.Texture.Bind();
                ts.Texture.ApplyParameters();
                GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
            }
        }
Пример #18
0
        private void GlSetup()
        {
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.DepthClamp);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Blend);
            GL.CullFace(CullFaceMode.Back);

            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL.Enable(EnableCap.Multisample);
            GL.ActiveTexture(TextureUnit.Texture0);

            _frameBuffer = new FBO(Width, Height, true);
        }
Пример #19
0
        protected override void OnRendered(IHostScreen screen, ref FBO currentFbo)
        {
            var targetFbo = FBO.Empty;

            var gBuffer    = _gBuffer;
            var screenSize = screen.FrameBufferSize;
            var gBufSize   = gBuffer.Size;

            Debug.Assert(_postProcess is not null);
            Debug.Assert(_ppProgram is not null);
            FBO.Bind(targetFbo, FBO.Target.FrameBuffer);
            if (IsVisible)
            {
                _ppProgram.Render(screenSize, (Vector2)screenSize / (Vector2)gBufSize);
            }
            currentFbo = targetFbo;
        }
Пример #20
0
 public void UpdateSurfaceSize(int width, int height)
 {
     if (0 == width || 0 == height)
     {
         return;
     }
     if (width != activeFBO.Texture.Width || height != activeFBO.Texture.Height)
     {
         var isActive = activeFBO == fboA;
         fboA.Texture.Dispose();
         fboB.Texture.Dispose();
         fboA.Dispose();
         fboB.Dispose();
         fboA      = new FBO(CreateTexture(width, height));
         fboB      = new FBO(CreateTexture(width, height));
         activeFBO = isActive ? fboA : fboB;
     }
 }
Пример #21
0
        public PostProcesser(OpenGL gl, int width, int height)
        {
            _gl  = gl;
            _fbo = new FBO(gl, width, height);

            _flatProgram = new FlatShader(gl);

            _flat       = new VAO(gl);
            _flatBuffer = new VBO(gl);

            using (new Bind(_flat))
                using (new Bind(_flatBuffer))
                {
                    var flatData = new float[] { -1, -1, 1, -1, -1, 1, 1, 1, };
                    _flatBuffer.Update(flatData, flatData.Length * sizeof(float));
                    gl.EnableVertexAttribArray(0);
                    gl.VertexAttribPointer(0, 2, OpenGL.GL_FLOAT, false, 0, new IntPtr(0));
                    gl.BindVertexArray(0);
                }
        }
Пример #22
0
 public PostProcessingVisual(int width, int height, IContentLoader contentLoader)
 {
     renderToTexture = new FBO(Texture2dGL.Create(width, height));
     renderToTexture.Texture.WrapFunction = TextureWrapFunction.MirroredRepeat;
     try
     {
         shaderProgram = contentLoader.LoadPixelShader("Grayscale");
         shaderProgram = contentLoader.LoadPixelShader("Sepia");
         shaderProgram = contentLoader.LoadPixelShader("Vignetting");
         shaderProgram = contentLoader.LoadPixelShader("ChromaticAberration");
         shaderProgram = contentLoader.LoadPixelShader("convolution");
         shaderProgram = contentLoader.LoadPixelShader("EdgeDetect");
         shaderProgram = contentLoader.LoadPixelShader("Ripple");
         shaderProgram = contentLoader.LoadPixelShader("Swirl");
     }
     catch (ShaderException e)
     {
         Console.WriteLine(e.Message);
         Console.ReadLine();
     }
 }
Пример #23
0
        public void Load()
        {
            LogTrace($"Creating G-Buffer of size {Width}x{Height}");
            FBO.Load();

            FBO.Bind();
            UnloadAndDestroyAllTextures();
            InitAllTextures();

            if (WantDepth)
            {
                InitAndAttachDepthTexture();
            }

            SetDrawBuffers();

            var status = FBO.GetStatus();

            LogTrace($"FBO state is {FBO.Status}");

            FBO.Unbind();
        }
Пример #24
0
 protected abstract void RenderPostProcess(IHostScreen screen, ref FBO currentFbo);
Пример #25
0
 public PostProcessing(int width, int height)
 {
     renderToTexture = new FBO(Texture.Create(width, height));
     SetShader(TextureToFrameBuffer.FragmentShaderCopy);
 }
Пример #26
0
 public RenderSurfacePingPong()
 {
     fboA      = new FBO(CreateTexture(1, 1));
     fboB      = new FBO(CreateTexture(1, 1));
     activeFBO = fboA;
 }
Пример #27
0
 protected override void OnRendered(IHostScreen screen, ref FBO currentFbo)
 {
     // nop
 }
Пример #28
0
 protected override void OnRendering(IHostScreen screen, ref FBO currentFbo)
 {
     FBO.Bind(FBO.Empty, FBO.Target.FrameBuffer);
     currentFbo = FBO.Empty;
 }
Пример #29
0
 protected sealed override void OnRendered(IHostScreen screen, ref FBO currentFbo)
 {
     Debug.Fail("This method should not be called.");
     throw new NotSupportedException("This method should not be called.");
 }
Пример #30
0
        /// <summary>Load resources here.</summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            //Base
            base.OnLoad(e);

            if (Utilities.EngineSettings == null) Utilities.EngineSettings = new Settings();

            //Print useful information about the card
            Console.WriteLine("==================================");
            Console.WriteLine("Vendor: {0}", GL.GetString(StringName.Vendor));
            Console.WriteLine("Renderer: {0}", GL.GetString(StringName.Renderer));
            Console.WriteLine("GLSL Version: {0}", GL.GetString(StringName.ShadingLanguageVersion));
            string versionOpenGL = GL.GetString(StringName.Version);
            GLVersion.Major = (int)Char.GetNumericValue(versionOpenGL[0]);
            GLVersion.Minor = (int)Char.GetNumericValue(versionOpenGL[2]);
            Console.WriteLine("OpenGL version: {0}", versionOpenGL);

            if (GLVersion.Major < 3 || (GLVersion.Major == 3 && GLVersion.Minor < 2))
            {
                Utilities.Print("You graphics card is on an older version of OpenGL ({0}). This application uses OpenGL 3.2. Good luck!", Utilities.PrintCode.WARNING, GLVersion.SimpleString() );
            }
            Console.WriteLine("==================================");

            Utilities.Init(this);
            Audio.Init();

            GL.ClearColor(0, 0, 0, 0.0f);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.AlphaFunc(AlphaFunction.Greater, 0.1f);

            //Textures
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.DepthClamp);

            //Initialize our shadow FBO
            shadowFBO = new FBO(Utilities.EngineSettings.ShadowMapSize, Utilities.EngineSettings.ShadowMapSize);
            //Change some specific texture parameters
            GL.BindTexture(TextureTarget.Texture2D, shadowFBO._RT);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareMode, (int)TextureCompareMode.CompareRefToTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareFunc, (int)All.Lequal);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            //Bind some textures to our default framebuffer
            //Utilities.ScreenDepthTex = FBO.BindTextureToFBO(0, this.WindowContext.Width, this.WindowContext.Height, PixelInternalFormat.DepthComponent, PixelFormat.DepthComponent, FramebufferAttachment.DepthAttachment);
            //Utilities.ScreenTex = FBO.BindTextureToFBO(0, this.WindowContext.Width, this.WindowContext.Height, PixelInternalFormat.Rgba, PixelFormat.Rgba, FramebufferAttachment.ColorAttachment1);

            //Initalize lighting
            LightingTechnique.Init();

            //Initialize our shadows
            ShadowTechnique.Init();
            ShadowTechnique.Enabled = Utilities.EngineSettings.EnableShadows;

            //Initialize skybox
            SkyboxTechnique.Init();

            //Initalize our gui system
            GUI.GUIManager.Init();

            //Create some debug stuff
            Graphics.Init();

            //Let's have some built in debug out stuff
            GUI.GUIManager.PostDrawHUD += new GUI.GUIManager.OnDrawHUD(GUIManager_PostDrawHUD);
        }
Пример #31
0
        public void RenderFrame()
        {
            // ------------------------------------------------------------
            // Out of frame loop
            Debug.Assert(_currentTiming == CurrentFrameTiming.OutOfFrameLoop);
            var isCloseRequested = _isCloseRequested;
            var layers           = Layers;

            var frameTimingPoints = TimingPoints;

            Mouse.InitFrame();
            Keyboard.InitFrame();

            // ------------------------------------------------------------
            // First Frame initializing
            if (_state == RenderingAreaLifeState.Activating)
            {
                _currentTiming = CurrentFrameTiming.FirstFrameInitializing;
                try {
                    Initialized?.Invoke(OwnerScreen);
                }
                catch {
                    if (EngineSetting.UserCodeExceptionCatchMode == UserCodeExceptionCatchMode.Throw)
                    {
                        throw;
                    }
                    // Don't throw. (Ignore exceptions in user code)
                }
                finally {
                    _state = RenderingAreaLifeState.Alive;
                }
            }

            // ------------------------------------------------------------
            // Frame initializing
            _currentTiming = CurrentFrameTiming.FrameInitializing;
            if (isCloseRequested && _state == RenderingAreaLifeState.Alive)
            {
                _state = RenderingAreaLifeState.Terminating;
                _runningTokenSource.Cancel();
                layers.TerminateAllLayers(this,
                                          onDead: static self =>
                {
                    self._state = RenderingAreaLifeState.Dead;
                });
            }
            layers.ApplyAdd();
            frameTimingPoints.FrameInitializing.DoQueuedEvents();

            // ------------------------------------------------------------
            // Early update
            _currentTiming = CurrentFrameTiming.EarlyUpdate;
            frameTimingPoints.EarlyUpdate.DoQueuedEvents();
            layers.EarlyUpdate();

            // ------------------------------------------------------------
            // Update
            _currentTiming = CurrentFrameTiming.Update;
            frameTimingPoints.Update.DoQueuedEvents();
            layers.Update();

            // ------------------------------------------------------------
            // Late update
            _currentTiming = CurrentFrameTiming.LateUpdate;
            frameTimingPoints.LateUpdate.DoQueuedEvents();
            layers.LateUpdate();

            // ------------------------------------------------------------
            // Before rendering
            _currentTiming = CurrentFrameTiming.BeforeRendering;
            FBO.Bind(FBO.Empty, FBO.Target.FrameBuffer);
            ElffyGL.Clear(ClearMask.ColorBufferBit | ClearMask.DepthBufferBit);
            frameTimingPoints.BeforeRendering.DoQueuedEvents();

            // ------------------------------------------------------------
            // Rendering
            _currentTiming = CurrentFrameTiming.Rendering;
            layers.Render();

            // ------------------------------------------------------------
            // After rendering
            _currentTiming = CurrentFrameTiming.AfterRendering;
            frameTimingPoints.AfterRendering.DoQueuedEvents();

            // ------------------------------------------------------------
            // Frame finalizing
            _currentTiming = CurrentFrameTiming.FrameFinalizing;
            layers.ApplyRemove();

            // ------------------------------------------------------------
            // End of frame (only internal accessible)
            _currentTiming = CurrentFrameTiming.Internal_EndOfFrame;
            frameTimingPoints.InternalEndOfFrame.DoQueuedEvents();

            // ------------------------------------------------------------
            // Out of frame loop
            _currentTiming = CurrentFrameTiming.OutOfFrameLoop;
            ContextAssociatedMemorySafety.CollectIfExist(OwnerScreen);

            if (_state == RenderingAreaLifeState.Dead)
            {
                Dispose();
            }
        }