コード例 #1
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        private void SetGraphicsMode(AtlasGraphicsMode mode)
        {
            if (_currentMode == mode)
            {
                return;
            }

            switch (_currentMode)
            {
            case AtlasGraphicsMode.Sprite:
                _spriteBatch.End();
                break;

            case AtlasGraphicsMode.Vector:
                DrawVectorBatch();
                break;
            }

            _currentMode = AtlasGraphicsMode.None;

            switch (mode)
            {
            case AtlasGraphicsMode.Sprite:
                BeginSprite();
                break;

            case AtlasGraphicsMode.Vector:
                BeginVector();
                break;
            }

            _currentMode = mode;
        }
コード例 #2
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        public AtlasGraphics(AtlasGlobal atlas, GraphicsDeviceManager _graphicsDeviceManager)
            : base(atlas)
        {
            _currentMode = AtlasGraphicsMode.None;

            _graphicsDevice = atlas.Game.GraphicsDevice;
            this._graphicsDeviceManager = _graphicsDeviceManager;

            _graphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color;

            #if XNA
            _graphicsDeviceManager.PreferredBackBufferHeight = 768;
            _graphicsDeviceManager.PreferredBackBufferWidth = 1024;
            #endif
            ////_graphicsDeviceManager.IsFullScreen = true;
            _graphicsDeviceManager.ApplyChanges();

            _spriteBatch = new SpriteBatch(_graphicsDevice);

            _basicEffect = new BasicEffect(_graphicsDeviceManager.GraphicsDevice);

            batch = new VertexPositionColorTexture[32][];
            batchPrimitiveCount = new int[batch.Length];

            _viewPort = new Viewport(0, 0,
                _graphicsDeviceManager.PreferredBackBufferWidth,
                _graphicsDeviceManager.PreferredBackBufferHeight);
        }
コード例 #3
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        public AtlasGraphics(AtlasGlobal atlas, GraphicsDeviceManager _graphicsDeviceManager)
            : base(atlas)
        {
            _currentMode = AtlasGraphicsMode.None;

            _graphicsDevice             = atlas.Game.GraphicsDevice;
            this._graphicsDeviceManager = _graphicsDeviceManager;

            _graphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color;

#if XNA
            _graphicsDeviceManager.PreferredBackBufferHeight = 768;
            _graphicsDeviceManager.PreferredBackBufferWidth  = 1024;
#endif
            ////_graphicsDeviceManager.IsFullScreen = true;
            _graphicsDeviceManager.ApplyChanges();

            _spriteBatch = new SpriteBatch(_graphicsDevice);

            _basicEffect = new BasicEffect(_graphicsDeviceManager.GraphicsDevice);

            batch = new VertexPositionColorTexture[32][];
            batchPrimitiveCount = new int[batch.Length];

            _viewPort = new Viewport(0, 0,
                                     _graphicsDeviceManager.PreferredBackBufferWidth,
                                     _graphicsDeviceManager.PreferredBackBufferHeight);
        }
コード例 #4
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        public void BeginSprite(BlendState blendState, SamplerState samplerState)
        {
            if (_currentMode == AtlasGraphicsMode.Sprite &&
                _lastBlendState == blendState &&
                _lastSamplerState == samplerState)
            {
                return;
            }
            Flush();
            _lastBlendState   = blendState;
            _lastSamplerState = samplerState;

            drawCalls = 0;

            if (_matrixHandler == null)
            {
                _spriteBatch.Begin(SpriteSortMode.Deferred,
                                   blendState,
                                   samplerState,
                                   DepthStencilState.None,
                                   RasterizerState.CullCounterClockwise,
                                   null);
            }
            else
            {
                _spriteBatch.Begin(SpriteSortMode.Deferred,
                                   blendState,
                                   samplerState,
                                   DepthStencilState.None,
                                   _matrixHandler.RasterState,
                                   null, _matrixHandler.GetSpriteBatchMatrix());
            }
            _currentMode = AtlasGraphicsMode.Sprite;
#if DEBUG
            d_spritebatch_begins++;
#endif
        }
コード例 #5
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        //Vector

        public void BeginVector()
        {
            if (_currentMode == AtlasGraphicsMode.Vector &&
                _lastBlendState == blendState &&
                _lastSamplerState == samplerState)
            {
                return;
            }

            _lastBlendState   = blendState;
            _lastSamplerState = samplerState;

            Flush();

            if (_matrixHandler != null)
            {
                _basicEffect.Projection = _matrixHandler.GetEffectMatrix();
            }
            else
            {
                _basicEffect.Projection =
                    Matrix.CreateOrthographicOffCenter(0, ResolutionWidth, ResolutionHeight, 0, -100, 100);
            }

            _currentMode = AtlasGraphicsMode.Vector;
            //_basicEffect.World = Matrix.CreateTranslation(10, 10, 0);

            _basicEffect.TextureEnabled       = true;
            _basicEffect.VertexColorEnabled   = true;
            _graphicsDevice.BlendState        = blendState;
            _graphicsDevice.DepthStencilState = DepthStencilState.None;
            _graphicsDevice.RasterizerState   = RasterizerState.CullClockwise;
            _graphicsDevice.SamplerStates[0]  = samplerState;

            indexCounter = 0;
        }
コード例 #6
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        private void SetGraphicsMode(AtlasGraphicsMode mode)
        {
            if (_currentMode == mode)
                return;

            switch (_currentMode)
            {
                case AtlasGraphicsMode.Sprite:
                    _spriteBatch.End();
                    break;
                case AtlasGraphicsMode.Vector:
                    DrawVectorBatch();
                    break;
            }

            _currentMode = AtlasGraphicsMode.None;

            switch (mode)
            {
                case AtlasGraphicsMode.Sprite:
                    BeginSprite();
                    break;
                case AtlasGraphicsMode.Vector:
                    BeginVector();
                    break;
            }

            _currentMode = mode;
        }
コード例 #7
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        //Vector
        public void BeginVector()
        {
            if (_currentMode == AtlasGraphicsMode.Vector &&
                _lastBlendState == blendState &&
                _lastSamplerState == samplerState)
                return;

            _lastBlendState = blendState;
            _lastSamplerState = samplerState;

            Flush();

            if (_matrixHandler != null)
                _basicEffect.Projection = _matrixHandler.GetEffectMatrix();
            else
                _basicEffect.Projection =
                    Matrix.CreateOrthographicOffCenter(0, ResolutionWidth, ResolutionHeight, 0, -100, 100);

            _currentMode = AtlasGraphicsMode.Vector;
            //_basicEffect.World = Matrix.CreateTranslation(10, 10, 0);

            _basicEffect.TextureEnabled = true;
            _basicEffect.VertexColorEnabled = true;
            _graphicsDevice.BlendState = blendState;
            _graphicsDevice.DepthStencilState = DepthStencilState.None;
            _graphicsDevice.RasterizerState = RasterizerState.CullClockwise;
            _graphicsDevice.SamplerStates[0] = samplerState;

            indexCounter = 0;
        }
コード例 #8
0
ファイル: AtlasGraphics.cs プロジェクト: Racura/AtlasEngine
        public void BeginSprite(BlendState blendState, SamplerState samplerState)
        {
            if (_currentMode == AtlasGraphicsMode.Sprite &&
                _lastBlendState == blendState &&
                _lastSamplerState == samplerState)
            {
                return;
            }
            Flush();
            _lastBlendState = blendState;
            _lastSamplerState = samplerState;

            drawCalls = 0;

            if (_matrixHandler == null)
            {
                _spriteBatch.Begin(SpriteSortMode.Deferred,
                                blendState,
                                samplerState,
                                DepthStencilState.None,
                                RasterizerState.CullCounterClockwise,
                                null);
            }
            else
            {
                _spriteBatch.Begin(SpriteSortMode.Deferred,
                                blendState,
                                samplerState,
                                DepthStencilState.None,
                                _matrixHandler.RasterState,
                                null, _matrixHandler.GetSpriteBatchMatrix());
            }
            _currentMode = AtlasGraphicsMode.Sprite;
            #if DEBUG
            d_spritebatch_begins++;
            #endif
        }