当前位置: 首页>>代码示例>>C#>>正文


C# RasterizerState.Dispose方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.RasterizerState.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# RasterizerState.Dispose方法的具体用法?C# RasterizerState.Dispose怎么用?C# RasterizerState.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.RasterizerState的用法示例。


在下文中一共展示了RasterizerState.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            _spriteBatch.GraphicsDevice.ScissorRectangle = _displayRect;
            RasterizerState rstate = new RasterizerState();
            rstate.ScissorTestEnable = true;

            _spriteBatch.Begin(SpriteSortMode.Immediate,
                        BlendState.AlphaBlend,
                        null,
                        null,
                        rstate,
                        null);
            if (_hasBorder || _focus)
            {
                _spriteBatch.Draw(_background, _displayRect, new Rectangle(39, 6, 1, 1), _focus ? Color.Blue : Color.White);
                _spriteBatch.Draw(_background, new Rectangle(_displayRect.X + 2, _displayRect.Y + 1, _displayRect.Width - 3, _displayRect.Height - 2), new Rectangle(39, 6, 1, 1), Color.Black);
            }
            //_startPos = 2;
            for (int count = _startPos; count < Math.Min(_numLines + _startPos, _text.Count); ++count)
            {
                int centerX = _displayRect.Left + 5;
                if (_center)
                {
                    centerX = 5 + _displayRect.X + ((int)(_displayRect.Width - 55 - _font.MeasureString(_text[count]).X) / 2);
                }

                _spriteBatch.DrawString(_font, _text[count], new Vector2(centerX, _displayRect.Top + 5 +
                    (count - _startPos) * _lineHeight), _color[count]);

            }
            if (_numLines < _text.Count)
            {
                _spriteBatch.Draw(_arrows, new Rectangle(_displayRect.Right - 22, _displayRect.Top + 2, 20, 20), new Rectangle(32, 0, 28, 28), Color.White);
                _spriteBatch.Draw(_arrows, new Rectangle(_displayRect.Right - 22, _displayRect.Bottom - 22, 20, 20), new Rectangle(0, 0, 28, 28), Color.White);
            }
            _spriteBatch.End();
            _spriteBatch.GraphicsDevice.RasterizerState.ScissorTestEnable = false;

            rstate.Dispose();
        }
开发者ID:propra13-orga,项目名称:gruppe22,代码行数:44,代码来源:Statusbox.cs

示例2: Draw

        protected void Draw(Scene drawnScene, RenderTarget2D renderTarget)
        {
            Device.SetRenderTarget(renderTarget);
            try
            {
                Device.Viewport = drawnScene.Viewport;
            }
            catch (ArgumentException)
            {
                UpdateSceneViewport(drawnScene);
                Device.Viewport = drawnScene.Viewport;

            }

            annotationOverlayEffect.RenderTargetSize = drawnScene.Viewport;

            #if DEBUG
            if (renderTarget != null)
            {
                Debug.Assert(renderTarget.Bounds.Width >= drawnScene.Viewport.Width &&
                             renderTarget.Bounds.Height >= drawnScene.Viewport.Height);

            }
            #endif

            if (DefaultDepthState == null || DefaultDepthState.IsDisposed)
            {
                DefaultDepthState = new DepthStencilState();

                DefaultDepthState.DepthBufferEnable = true;
                DefaultDepthState.DepthBufferFunction = CompareFunction.LessEqual;
                DefaultDepthState.StencilEnable = false;
                DefaultDepthState.DepthBufferWriteEnable = true;
            }

            Device.DepthStencilState = DefaultDepthState;

            if (DefaultBlendState == null || DefaultBlendState.IsDisposed)
            {
                DefaultBlendState = new BlendState();
                DefaultBlendState.AlphaSourceBlend = Blend.SourceAlpha;
                DefaultBlendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
                DefaultBlendState.ColorSourceBlend = Blend.SourceAlpha;
                DefaultBlendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
            }

            Device.BlendState = DefaultBlendState;

            SamplerState sampleState = Device.SamplerStates[0];

            if (sampleState == null || sampleState.IsDisposed ||
                (sampleState.AddressU != TextureAddressMode.Clamp || sampleState.AddressV != TextureAddressMode.Clamp))
            {
                try
                {
                    sampleState = new SamplerState();
                    sampleState.AddressU = TextureAddressMode.Clamp;    //Compatability with Reach
                    sampleState.AddressV = TextureAddressMode.Clamp;
                    Device.SamplerStates[0] = sampleState;
                }
                catch (Exception)
                {
                    if (sampleState != null)
                    {
                        sampleState.Dispose();
                        sampleState = null;
                    }
                }
            }

            Device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, float.MaxValue, 0);

            if (Device.RasterizerState == null ||
                Device.RasterizerState.IsDisposed ||
                Device.RasterizerState.CullMode != CullMode.None)
            {
                RasterizerState rState = null;
                try
                {
                    rState = new RasterizerState();
                    rState.CullMode = CullMode.None;
                    Device.RasterizerState = rState;
                }
                catch (Exception)
                {
                    if (rState != null)
                    {
                        rState.Dispose();
                        rState = null;
                    }
                }
            }

            Matrix worldViewProj = drawnScene.WorldViewProj;

            //Enables some basic effect characteristics, such as vertex coloring and default lighting.
            basicEffect.Projection = drawnScene.Projection;
            basicEffect.View = drawnScene.Camera.View;
            basicEffect.World = drawnScene.World;

//.........这里部分代码省略.........
开发者ID:abordt,项目名称:Viking,代码行数:101,代码来源:ViewerControl.cs

示例3: Draw

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            _spriteBatch.GraphicsDevice.ScissorRectangle = _displayRect;
            RasterizerState rstate = new RasterizerState();
            rstate.ScissorTestEnable = true;

            _spriteBatch.Begin(SpriteSortMode.Immediate,
                        BlendState.AlphaBlend,
                        null,
                        null,
                        rstate,
                        null);
            _spriteBatch.Draw(_background, _displayRect, new Rectangle(39, 6, 1, 1), Color.White);
            _spriteBatch.Draw(_background, new Rectangle(_displayRect.X + 2, _displayRect.Y + 2, _displayRect.Width - 4, _displayRect.Height - 4), new Rectangle(39, 6, 1, 1), Color.Black);
            //_startPos = 2;
            for (int count = _startPos; count < Math.Min(_numLines + _startPos, _text.Count); ++count)
            {
                _spriteBatch.DrawString(_font, _text[count], new Vector2(_displayRect.Left + 20, _displayRect.Top +
                    (count - _startPos) * _lineHeight), Color.White);
            }
            _spriteBatch.Draw(_arrows, new Rectangle(_displayRect.Right - 35, _displayRect.Top + 5, 28, 28), new Rectangle(32, 0, 28, 28), Color.White);
            _spriteBatch.Draw(_arrows, new Rectangle(_displayRect.Right - 35, _displayRect.Bottom - 35, 28, 28), new Rectangle(0, 0, 28, 28), Color.White);

            _spriteBatch.End();
            _spriteBatch.GraphicsDevice.RasterizerState.ScissorTestEnable = false;

            rstate.Dispose();
        }
开发者ID:propra13-orga,项目名称:gruppe22,代码行数:32,代码来源:Menu.cs

示例4: Draw

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin();
            _spriteBatch.Draw(_mapIcon, _displayRect, new Rectangle(39, 6, 1, 1), Color.White);
            _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.X + 1, _displayRect.Y + 1, _displayRect.Width - 2, _displayRect.Height - 2), new Rectangle(39, 6, 1, 1), Color.Black);
            _spriteBatch.End();
            _spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(_displayRect.Left + 3, _displayRect.Top + 3, _displayRect.Width - 6, _displayRect.Height - 6);
            RasterizerState rstate = new RasterizerState();
            rstate.ScissorTestEnable = true;

            _spriteBatch.Begin(SpriteSortMode.BackToFront,
                  BlendState.AlphaBlend,
                  null,
                  null,
                  rstate,
                  null,
                  _camera.matrix);
            if (_map != null)
            {
                for (int y = 0; y < _map.height; ++y)
                {
                    for (int x = 0; x < _map.width; ++x)
                    {
                        if (_map[x, y].visible)
                        {
                            if (!_map[x, y].canEnter)
                            {
                                _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + 2 + x * 16, _displayRect.Top + 2 + y * 16, 15, 15), new Rectangle(32, 0, 16, 16), Color.White);
                            }
                            else
                            {
                                if (_map[x, y].hasPlayer)
                                {
                                    _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + 2 + x * 16, _displayRect.Top + 2 + y * 16, 16, 16), new Rectangle(48, 16, 16, 16), Color.White);

                                }
                                else
                                {
                                    if ((_map[x, y].hasEnemy) && (_map.actors[_playerID].tile.coords.DistanceFrom(x, y) < Math.Max(_map.actors[_playerID].viewRange, _map.light)))
                                    {
                                        _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + x * 16, _displayRect.Top + y * 16, 16, 16), new Rectangle(64, 16, 16, 16), Color.White);
                                    }
                                    else
                                    {
                                        if (_map[x, y].hasTreasure)
                                        {
                                            _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + x * 16, _displayRect.Top + y * 16, 16, 16), new Rectangle(64, 0, 16, 16), Color.White);
                                        }
                                        else
                                        {
                                            if (_map[x, y].hasTeleport)
                                            {
                                                if (x == 0)
                                                {
                                                    _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + x * 16, _displayRect.Top + y * 16, 16, 16), new Rectangle(0, 0, 16, 16), Color.White);
                                                }
                                                if (y == 0)
                                                {
                                                    _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + x * 16, _displayRect.Top + y * 16, 16, 16), new Rectangle(16, 0, 16, 16), Color.White);
                                                }
                                                if (x == _map.width - 1)
                                                {
                                                    _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + x * 16, _displayRect.Top + y * 16, 16, 16), new Rectangle(16, 16, 16, 16), Color.White);
                                                }
                                                if (y == _map.height - 1)
                                                {
                                                    _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + x * 16, _displayRect.Top + y * 16, 16, 16), new Rectangle(0, 16, 16, 16), Color.White);
                                                }
                                            }
                                            else
                                            {
                                                if (_map[x, y].hasTarget)
                                                {
                                                    _spriteBatch.Draw(_mapIcon, new Rectangle(_displayRect.Left + x * 16, _displayRect.Top + y * 16, 16, 16), new Rectangle(48, 0, 16, 16), Color.White);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            _spriteBatch.End();
            _spriteBatch.GraphicsDevice.RasterizerState.ScissorTestEnable = false;
            rstate.Dispose();
        }
开发者ID:propra13-orga,项目名称:gruppe22,代码行数:93,代码来源:Minimap.cs

示例5: Draw

        /// <summary>
        /// Draw the Map
        /// </summary>
        public override void Draw(GameTime gametime)
        {
            if (_enabled)
            {

                // Rasterizer: Enable cropping at borders (otherwise map would be overlapping everything else)
                RasterizerState rstate = new RasterizerState();
                rstate.ScissorTestEnable = true;

                // Blendstate used for light circle / fog of war
                BlendState blendState = new BlendState();
                blendState.AlphaDestinationBlend = Blend.SourceColor;
                blendState.ColorDestinationBlend = Blend.SourceColor;
                blendState.AlphaSourceBlend = Blend.Zero;
                blendState.ColorSourceBlend = Blend.Zero;

                // Draw border of window (black square in white square)
                _spriteBatch.Begin();
                _spriteBatch.Draw(_background, _displayRect, new Rectangle(39, 6, 1, 1), Color.White);
                _spriteBatch.Draw(_background, new Rectangle(_displayRect.X + 1, _displayRect.Y + 1, _displayRect.Width - 2, _displayRect.Height - 2), new Rectangle(39, 6, 1, 1), Color.Black);
                _spriteBatch.End();

                _spriteBatch.Begin(SpriteSortMode.Deferred,
                            BlendState.AlphaBlend,
                            null,
                            null,
                            rstate,
                            null,
                            _camera.matrix);

                _spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(_displayRect.Left + 5, _displayRect.Top + 5, _displayRect.Width - 10, _displayRect.Height - 10);

                _drawFloor(); // Draw the floow

                for (int i = 0; i < _projectiles.Count; ++i)
                {
                    _projectiles[i].Draw(_spriteBatch, _environment[1][(int)Math.Log((double)_projectiles[i].direction, 2)]);
                }

                for (int i = 0; i < _effects.Count; ++i)
                {
                    _effects[i].Draw(_spriteBatch, gametime);
                }

                _drawWalls(gametime); // Draw walls, other objects, player and enemies

                _spriteBatch.End();

                // Draw circle of light / fog of war
                _spriteBatch.Begin(SpriteSortMode.Texture, blendState, null,
                            null,
                            rstate,
                            null,
                            _camera.matrix);
                _spriteBatch.Draw(_circle, new Rectangle(
                    (int)(_actors[_playerID].position.x + 1) - 250 * Math.Max(_map.actors[_playerID].viewRange, _map.light),
                    (int)(_actors[_playerID].position.y + 1) - 250 * Math.Max(_map.actors[_playerID].viewRange, _map.light), 520 * Math.Max(_map.actors[_playerID].viewRange, _map.light), 520 * Math.Max(_map.actors[_playerID].viewRange, _map.light)), Color.White);
                _spriteBatch.End();

                _spriteBatch.GraphicsDevice.RasterizerState.ScissorTestEnable = false;

                rstate.Dispose();
                blendState.Dispose();

                if ((_highlightedTile.x > -1)
                    && (_highlightedTile.x >= _map.actors[_playerID].tile.coords.x - Math.Max(_map.actors[_playerID].viewRange, _map.light))
                    && (_highlightedTile.x <= _map.actors[_playerID].tile.coords.x + Math.Max(_map.actors[_playerID].viewRange, _map.light))
                    && (_highlightedTile.y >= _map.actors[_playerID].tile.coords.y - Math.Max(_map.actors[_playerID].viewRange, _map.light))
                    && (_highlightedTile.y <= _map.actors[_playerID].tile.coords.y + Math.Max(_map.actors[_playerID].viewRange, _map.light)))
                    _tooltip.DisplayToolTip(_map[_highlightedTile.x, _highlightedTile.y]);
                for (int i = 0; i < _floatnumbers.Count; ++i)
                {
                    _floatnumbers[i].Draw();
                }

                if (_bigText != "")
                {
                    _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
                    float opacity = ((float)((_visibility <= 0) ? (100 + _visibility) : (_visibility))) / 100f;
                    _spriteBatch.DrawString(_font, _bigText, new Vector2(_displayRect.Left + 10, _displayRect.Bottom - _font.MeasureString(_bigText).Y - _font.MeasureString(_smallText).Y), new Color(opacity, 0, 0), 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
                    _spriteBatch.DrawString(_font, _smallText, new Vector2(_displayRect.Left + 10, _displayRect.Bottom - _font.MeasureString(_smallText).Y), new Color(opacity, opacity, opacity), 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 1f);

                    _spriteBatch.End();
                }
            }
        }
开发者ID:propra13-orga,项目名称:gruppe22,代码行数:89,代码来源:Mainmap.cs


注:本文中的Microsoft.Xna.Framework.Graphics.RasterizerState.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。