public void Dispose()
 {
     _spriteBatch.Dispose();
       _meshRenderer.Dispose();
       _billboardRenderer.Dispose();
       DebugRenderer2D.Dispose();
       DebugRenderer.Dispose();
       Scene.Dispose(false);
 }
        protected override void OnRender(RenderContext context)
        {
            var graphicsDevice = GraphicsService.GraphicsDevice;

              if (ClearBackground)
            graphicsDevice.Clear(BackgroundColor);

              if (CameraNode != null)
              {
            // ----- Render Scene.
            // Set the current camera and current scene in the render context. This
            // information is very important; it is used by the scene node renderers.
            context.CameraNode = CameraNode;
            context.Scene = Scene;

            // Frustum Culling: Get all the scene nodes that intersect the camera frustum.
            var query = Scene.Query<CameraFrustumQuery>(context.CameraNode, context);

            // Set the render states for opaque objects.
            graphicsDevice.DepthStencilState = DepthStencilState.Default;
            graphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
            graphicsDevice.BlendState = BlendState.Opaque;
            graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

            // Render the meshes that are visible from the camera.
            // We must set a render pass. This is a string which tells the MeshRenderer
            // which effects it has to use to render the objects. The default render
            // pass is always called "Default".
            context.RenderPass = "******";
            _meshRenderer.Render(query.SceneNodes, context);
            context.RenderPass = null;

            // ----- For SkinnedEffectSample:
            // Render meshes with "Sky" material pass. The SkinnedEffectSample uses a
            // ProceduralSkyDome as the background. The material has a special "Sky"
            // pass. Depth writes need to be disabled.
            graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
            context.RenderPass = "******";
            _meshRenderer.Render(query.SceneNodes, context);
            context.RenderPass = null;
            // -----

            // Set the render states for alpha blended objects.
            graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
            graphicsDevice.RasterizerState = RasterizerState.CullNone;
            graphicsDevice.BlendState = BlendState.NonPremultiplied;
            graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

            // The BillboardRenderer renders BillboardNodes and ParticleSystemNodes.
            _billboardRenderer.Render(query.SceneNodes, context);

            // Clean up.
            context.CameraNode = null;
            context.Scene = null;
              }

              var font = UseFixedWidthFont ? _fixedWidthFont : _defaultFont;
              DebugRenderer2D.SpriteFont = font;
              DebugRenderer.SpriteFont = font;

              // Render 3D graphics.
              if (CameraNode != null)
              {
            context.CameraNode = CameraNode;
            DebugRenderer.Render(context);
              }

              // Render 2D graphics.
              context.CameraNode = _cameraNode2D;
              DebugRenderer2D.Render(context);

              // Draw reticle.
              if (DrawReticle && _sampleFramework.IsGuiVisible)
              {
            var viewport = context.Viewport;
            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            _spriteBatch.Draw(
              _reticle,
              new Vector2(viewport.Width / 2 - _reticle.Width / 2, viewport.Height / 2 - _reticle.Height / 2),
              Color.Black);
            _spriteBatch.End();
              }

              context.CameraNode = null;
        }