Exemplo n.º 1
0
        internal void drawTexture(MonoGameTexture texture, float x, float y, int srcX, int srcY, int srcWidth,
                                  int srcHeight, float scaleX, float scaleY, float originX, float originY, float rotation, bool flipX,
                                  bool flipY, MonoGameColor tint)
        {
            beginRendering();
            if (texture.getUAddressMode() != _currentUMode || texture.getVAddressMode() != _currentVMode)
            {
                _currentUMode = texture.getUAddressMode();
                _currentVMode = texture.getVAddressMode();
                updateAddressMode();
            }


            _sharedPositionVector.X       = x - originX;
            _sharedPositionVector.Y       = y - originY;
            _sharedSourceRectangle.X      = srcX;
            _sharedSourceRectangle.Y      = srcY;
            _sharedSourceRectangle.Width  = srcWidth;
            _sharedSourceRectangle.Height = srcHeight;
            _sharedOriginVector.X         = originX;
            _sharedOriginVector.Y         = originY;
            _sharedScaleVector.X          = scaleX;
            _sharedScaleVector.Y          = scaleY;

            _spriteBatch.Draw(texture.texture2D, _sharedPositionVector, _sharedSourceRectangle, tint._color,
                              MonoGameMathsUtil.degreeToRadian(rotation), _sharedOriginVector, _sharedScaleVector,
                              (flipX ? SpriteEffects.FlipHorizontally : SpriteEffects.None) |
                              (flipY ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f);
        }
Exemplo n.º 2
0
 internal MonoGameGameFontCache(GameFont font)
 {
     _gameFont       = (MonoGameGameFont)font;
     _graphicsDevice = ((MonoGameGraphics)Mdx.graphicsContext)._graphicsDevice;
     _spriteBatch    = new SpriteBatch(_graphicsDevice);
     _gameFontCache  = new MonoGameTexture(new RenderTarget2D(_graphicsDevice, Mdx.graphicsContext.getWindowWidth(), Mdx.graphicsContext.getWindowHeight(), false, SurfaceFormat.Color, _graphicsDevice.PresentationParameters.DepthStencilFormat, 0, RenderTargetUsage.PreserveContents));
     beginSpriteBatch();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the texture.
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="mipmap">if set to <c>true</c> [mipmap].</param>
        /// <param name="dynamic">if set to <c>true</c> [dynamic].</param>
        /// <returns></returns>
        public override TextureBase CreateTexture(int width, int height, bool mipmap, bool dynamic)
        {
            if (width == 0 || height == 0)
            {
                return(null);
            }

            Texture2D       native  = new Texture2D(GraphicsDevice, width, height, false, SurfaceFormat.Color);
            MonoGameTexture texture = new MonoGameTexture(native);

            return(texture);
        }
Exemplo n.º 4
0
        public MonoGameFontCacheTexture()
        {
            _graphicsDevice = ((MonoGameGraphics)Mdx.graphicsContext_)._graphicsDevice;
            _spriteBatch    = new SpriteBatch(_graphicsDevice);
            _texture        = new MonoGameTexture(new RenderTarget2D(_graphicsDevice, TEXTURE_WIDTH, TEXTURE_HEIGHT, false, SurfaceFormat.Color, _graphicsDevice.PresentationParameters.DepthStencilFormat, 0, RenderTargetUsage.PreserveContents));

            for (int x = 0; x < REGION_ARRAY_WIDTH; x++)
            {
                for (int y = 0; y < REGION_ARRAY_HEIGHT; y++)
                {
                    _regions[x, y] = -1;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the texture.
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="mipmap">if set to <c>true</c> [mipmap].</param>
        /// <param name="dynamic">if set to <c>true</c> [dynamic].</param>
        /// <returns></returns>
        public override TextureBase CreateTexture(int width, int height, bool mipmap, bool dynamic)
        {
            if (width == 0 || height == 0)
            {
                return null;
            }

            Texture2D native = new Texture2D(GraphicsDevice, width, height, false, SurfaceFormat.Color);
            MonoGameTexture texture = new MonoGameTexture(native);
            return texture;
        }