Beispiel #1
0
        public static void execute() // executes the pipeline
        {
            if (win == null) return;

            Graphics.frame_index++;

            render_target = win;

            win.Clear(familiarize_color(back_color));

            Statistics.sprites_drawn = 0;
            Statistics.sprites_discarded = 0;

            Pipeline.execute();

            win.Display();

            if (screenshot_signal)
            {
                bool found = false; int ctr = 0; string path = "";
                while (!found)
                {
                    path = XF.Application.root_path +  "screenshot" + ctr + ".png";
                    found = !System.IO.File.Exists(path);
                    ctr++;
                }

                SFML.Graphics.Image screenshot = new SFML.Graphics.Image(screen_w, screen_h);
                screenshot.CopyScreen(win) ;
                screenshot.SaveToFile(path);

                screenshot_signal = false;
            }

        } 
Beispiel #2
0
        /// <summary>
        ///  <para>Loads Image from given Zip-File and Entry.</para>
        /// </summary>
        private Image LoadImageFrom(ZipFile zipFile, ZipEntry imageEntry)
        {
            string ResourceName = Path.GetFileNameWithoutExtension(imageEntry.Name).ToLowerInvariant();

            if (TextureCache.Textures.Contains(ResourceName))
            {
                return(null); // ImageCache.Images[ResourceName];
            }
            var byteBuffer = new byte[zipBufferSize];

            try
            {
                Stream zipStream = zipFile.GetInputStream(imageEntry);
                var    memStream = new MemoryStream();

                StreamUtils.Copy(zipStream, memStream, byteBuffer);
                memStream.Position = 0;

                Image loadedImg = new Image(memStream);
                TextureCache.Add(ResourceName, loadedImg);

                memStream.Close();
                zipStream.Close();
                memStream.Dispose();
                zipStream.Dispose();
                return(loadedImg);
            }
            catch (Exception I)
            {
                System.Console.WriteLine("Failed to load " + imageEntry.Name + ": " + I.ToString());
            }

            return(null);
        }
Beispiel #3
0
        protected static bool IsAssetValid(Image asset)
        {
            if (asset == null || asset.IsDisposed)
                return false;

            return true;
        }
Beispiel #4
0
 public static Sprite LoadSprite(string fileName, Vector2f scale)
 {
     Image image = new Image(fileName);
     Texture texture = new Texture(image);
     Sprite sprite = new Sprite(texture) { Scale = scale };
     return sprite;
 }
Beispiel #5
0
        private void SetNextBlock()
        {
            Color col = BlockInformation.BlockColors.Where(c => c.Key == m_Arena.CurrentPiece).FirstOrDefault().Value;

            int[,] currentBlock = BlockInformation.BlockArrays.Where(a => a.Key == m_Arena.CurrentPiece).FirstOrDefault().Value;
            if (currentBlock != null && col != null)
            {
                SFML.Graphics.Image img = new SFML.Graphics.Image(100, 100, Color.White);
                for (int y = 0; y < currentBlock.GetLength(0); y++)
                {
                    for (int x = 0; x < currentBlock.GetLength(1); x++)
                    {
                        if (currentBlock[y, x] <= 0)
                        {
                            continue;
                        }
                        uint posY = (img.Size.Y / 2) - ((uint)y / 2);
                        uint posX = (img.Size.X / 2) + ((uint)x / 2);

                        for (uint i = 0; i < BlockInformation.Size.Y; i++)
                        {
                            for (uint j = 0; j < BlockInformation.Size.X; j++)
                            {
                                img.SetPixel(posX + j, posY + i, col);
                            }
                        }
                    }
                }

                imageNextBlock.SetImage(img);
            }
        }
Beispiel #6
0
    /// <summary>
    /// Processes a black and white image to determine which areas on a map can or can't be clicked
    /// </summary>
    /// <param name="path">Path to click map file</param>
    /// <param name="pathGrid">Grid object to set</param>
    /// <returns></returns>
    public static void LoadAndProcessClickMap(string path, PathNode[,] pathNodes, Grid pathGrid, int tileSize)
    {
        var map      = new SFML.Graphics.Image(path);
        var clickMap = new bool[map.Size.X, map.Size.Y];

        float totalPixelsInTile = tileSize * tileSize;
        int   totalTrue         = 0;
        int   xMax = 0;
        int   yMax = 0;

        for (int x = 0; x < pathNodes.GetLength(0); x++)
        {
            for (int y = 0; y < pathNodes.GetLength(1); y++)
            {
                totalTrue = 0;
                xMax      = tileSize * x + tileSize;

                for (int xMap = tileSize * x; xMap < xMax; xMap++)
                {
                    yMax = tileSize * y + tileSize;
                    for (int yMap = tileSize * y; yMap < yMax; yMap++)
                    {
                        if (xMap < map.Size.X && yMap < map.Size.Y && map.GetPixel((uint)xMap, (uint)yMap).B > 40)
                        {
                            totalTrue++;
                        }
                    }
                }
                pathGrid.SetTile(x, y, pathNodes[x, y].Enabled = (totalTrue / totalPixelsInTile) >= .5f);
            }
        }
    }
Beispiel #7
0
        // [omeg] added, pixelData are in RGBA format
        public override void LoadTextureRaw(Texture texture, byte[] pixelData)
        {
            if (null == texture)
            {
                return;
            }

            Debug.Print("LoadTextureRaw: {0}", texture.RendererData);

            if (texture.RendererData != null)
            {
                FreeTexture(texture);
            }

            SFMLTexture sfTexture;

            try
            {
                var img = new Image((uint)texture.Width, (uint)texture.Height, pixelData); // SFML Image
                sfTexture        = new SFMLTexture(img);
                sfTexture.Smooth = true;
                img.Dispose();
            }
            catch (LoadingFailedException)
            {
                Debug.Print("LoadTextureRaw: failed");
                texture.Failed = true;
                return;
            }

            texture.RendererData = sfTexture;
            texture.Failed       = false;
        }
Beispiel #8
0
        public void resetPPU()
        {
            frame             = new SFML.Graphics.Image(256, 240);
            emptyFrame        = new SFML.Graphics.Image(1, 1);
            fullWindow        = new SFML.Graphics.Image(512, 512);
            screenUpdateWatch = new Stopwatch();

            ppuRam = new byte[0x4000];
            oamRam = new byte[0x100];

            scrollWrittenOnce      = false;
            ppuAddressWrittenOnce  = false;
            oamAddressWrittenOnce  = false;
            ppuWriteAddress        = 0;
            tempPPUWriteAddress    = 0;
            oamWriteAddress        = 0;
            tempOAMWriteAddress    = 0;
            pendingNMI             = false;
            spriteZeroHit          = false;
            spriteOverflow         = false;
            isNametableMirrored    = false;
            isHorizNametableMirror = false;
            isVertNametableMirror  = false;

            scrollX    = 0;
            scrollY    = 0;
            ly         = 0;
            ppuState   = 0;
            frameCount = 0;
        }
Beispiel #9
0
 private void importerUneSéquenceToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openTexture.ShowDialog() == DialogResult.OK)
     {
         var name = Path.GetFileNameWithoutExtension(openTexture.FileName);
         while (char.IsDigit(name[name.Length - 1]))
         {
             name = name.Substring(0, name.Length - 1);
         }
         var list = openTexture.FileNames.ToList();
         list.Sort();
         var      imgs = list.ConvertAll((s) => new SFML.Graphics.Image(s));
         Vector2u size = imgs[0].Size;
         if (!imgs.All((img) => img.Size == size))
         {
             MessageBox.Show(this, "Les images ne font pas toutes la même taille.", "Erreur lors de la compilation d'images", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         Vector2i matrixSize = default;
         {
             var root = Math.Sqrt(imgs.Count);
             matrixSize.X = (int)Math.Ceiling(root);
             if (root - Math.Truncate(root) < .5)
             {
                 matrixSize.Y = (int)Math.Floor(root);
             }
             else
             {
                 matrixSize.Y = (int)Math.Ceiling(root);
             }
         }
         var      globalImg = new SFML.Graphics.Image((uint)(size.X * matrixSize.X), (uint)(size.Y * matrixSize.Y), SFML.Graphics.Color.Transparent);
         Vector2i offset    = default;
         foreach (var img in imgs)
         {
             for (uint x = 0; x < size.X; x++)
             {
                 for (uint y = 0; y < size.Y; y++)
                 {
                     globalImg.SetPixel(x + (uint)offset.X, y + (uint)offset.Y, img.GetPixel(x, y));
                 }
             }
             offset.X += (int)size.X;
             if (offset.X >= globalImg.Size.X)
             {
                 offset.X  = 0;
                 offset.Y += (int)size.Y;
             }
         }
         var res = new Resource();
         res.Name   = name;
         res.Smooth = true;
         res.ChangeBaseImage(globalImg);
         res.ChangeFrames((Vector2i)globalImg.Size, new Vector2i());
         Program.DynamicObject.AddResource(res);
         UpdateInterface();
     }
 }
Beispiel #10
0
 public static Sprite LoadSprite(string fileName, Vector2f scale, bool flipH, bool flipV)
 {
     Image image = new Image(fileName);
     if (flipH) image.FlipHorizontally();
     else if (flipV) image.FlipVertically();
     Texture texture = new Texture(image);
     Sprite sprite = new Sprite(texture) { Scale = scale };
     return sprite;
 }
Beispiel #11
0
        public PixelCollider(Texture texture, params int[] tags)
        {
            this.texture = texture.SFMLTexture;
            collideImage = this.texture.CopyToImage();

            Width = this.texture.Size.X;
            Height = this.texture.Size.Y;

            AddTag(tags);
        }
Beispiel #12
0
        /// <summary>
        /// Creates a pixel collider.
        /// </summary>
        /// <param name="source">The source image to create the collider from.</param>
        /// <param name="tags">The tags to register the collider with.</param>
        public PixelCollider(string source, params int[] tags)
        {
            texture = Textures.Load(source);
            collideImage = texture.CopyToImage();

            Width = texture.Size.X;
            Height = texture.Size.Y;

            AddTag(tags);
        }
Beispiel #13
0
        public PixelCollider(Texture texture, params int[] tags)
        {
            this.texture = texture.SFMLTexture;
            collideImage = this.texture.CopyToImage();

            Width  = this.texture.Size.X;
            Height = this.texture.Size.Y;

            AddTag(tags);
        }
Beispiel #14
0
        /// <summary>
        /// Creates a pixel collider.
        /// </summary>
        /// <param name="source">The source image to create the collider from.</param>
        /// <param name="tags">The tags to register the collider with.</param>
        public PixelCollider(string source, params int[] tags)
        {
            texture      = Textures.Load(source);
            collideImage = texture.CopyToImage();

            Width  = texture.Size.X;
            Height = texture.Size.Y;

            AddTag(tags);
        }
Beispiel #15
0
        /// <summary>
        /// Set the icon of the current window.
        /// </summary>
        /// <param name="width">The width of the icon.</param>
        /// <param name="height">The height of the icon.</param>
        /// <param name="source">The source path to the icon image.</param>
        public void SetIcon(string source)
        {
            SFML.Graphics.Image img;

            img = new SFML.Graphics.Image(source);

            iconWidth  = img.Size.X;
            iconHeight = img.Size.Y;
            iconPath   = source;
            iconImage  = img;
            Window?.SetIcon(iconWidth, iconHeight, iconImage.Pixels);
        }
Beispiel #16
0
        public static byte[] ToBytes(Texture image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            SFML.Graphics.Image im = image.CopyToImage();
            byte[] pixels          = im.Pixels;
            im.Dispose();

            return(pixels);
        }
Beispiel #17
0
    /// <summary>
    /// Processes a greyscale image to determe a scaling factor for each location on the map
    /// </summary>
    /// <param name="path">Indigo path to content</param>
    /// <param name="minScaleValue">Scaling value that represents black in the image</param>
    /// <param name="maxScaleVale">Scaling value that represents white in the image</param>
    /// <returns></returns>
    public static float[,] LoadAndProcessPerspectiveMap(string path, float minScaleValue, float maxScaleVale)
    {
        var   map            = new SFML.Graphics.Image(path);
        var   perspectiveMap = new float[map.Size.X, map.Size.Y];
        float maxValue       = maxScaleVale - minScaleValue;

        for (uint i = 0; i < map.Size.X; i++)
        {
            for (uint j = 0; j < map.Size.Y; j++)
            {
                perspectiveMap[i, j] = (map.GetPixel(i, j).B / 255f) * maxValue + minScaleValue;
            }
        }
        return(perspectiveMap);
    }
Beispiel #18
0
        private void btnSplit_Click(object sender, EventArgs e)
        {
            if (Resource != null)
            {
                btnSplit.Visible = false;

                if (!Directory.Exists(txtOutputPath.Text))
                {
                    Directory.CreateDirectory(txtOutputPath.Text);
                }

                var srcExt = txtFile.Text.Substring(
                    txtFile.Text.LastIndexOf(".") + 1);
                var srcName = txtFile.Text.Substring(
                    txtFile.Text.LastIndexOf(Path.DirectorySeparatorChar) + 1).Replace("." + srcExt, string.Empty);

                var cols   = ((int)numericX.Value >= 1) ? (int)numericX.Value : 1;
                var rows   = ((int)numericY.Value >= 1) ? (int)numericY.Value : 1;
                var width  = (int)Resource.Image.Size.X / cols;
                var height = (int)Resource.Image.Size.Y / rows;

                for (int r = 0; r < rows; r++)
                {
                    for (int c = 0; c < cols; c++)
                    {
                        var destName = txtOutputFormat.Text.Replace(
                            "%f", srcName).Replace(
                            "%ext", srcExt).Replace(
                            "%r", r.ToString()).Replace(
                            "%c", c.ToString()).Replace(
                            "%t", ((r * cols) + c).ToString());

                        Image image = new Image((uint)width, (uint)height);
                        image.Copy(Resource.Image, 0, 0, new IntRect(c * width, r * height, width, height));

                        image.SaveToFile(txtOutputPath.Text + destName);
                        image?.Dispose();
                        image = null;

                        Application.DoEvents();
                    }
                }

                btnSplit.Visible = true;
            }

            txtFile.Focus();
        }
Beispiel #19
0
        public static SFML.Graphics.Image ToSFMLImage(System.Drawing.Bitmap bmp)
        {
            SFML.Graphics.Color[,] sfmlcolorarray = new SFML.Graphics.Color[bmp.Height, bmp.Width];
            SFML.Graphics.Image newimage = null;
            for (int x = 0; x < bmp.Width; x++)
            {
                for (int y = 0; y < bmp.Height; y++)
                {
                    System.Drawing.Color csharpcolor = bmp.GetPixel(x, y);
                    sfmlcolorarray[y, x] = new SFML.Graphics.Color(csharpcolor.R, csharpcolor.G, csharpcolor.B, csharpcolor.A);
                }
            }
            newimage = new SFML.Graphics.Image(sfmlcolorarray);

            return(newimage);
        }
Beispiel #20
0
        public static SFML.Graphics.Image BitmapToImage(Bitmap bitmap)
        {
            SFML.Graphics.Image image = new SFML.Graphics.Image((uint)bitmap.Width, (uint)bitmap.Height);

            for (int x = 0; x < bitmap.Width; x++)
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    System.Drawing.Color systemColor = bitmap.GetPixel(x, y);
                    SFML.Graphics.Color  sfmlColor   = new SFML.Graphics.Color(systemColor.R, systemColor.G, systemColor.B);
                    image.SetPixel((uint)x, (uint)y, sfmlColor);
                }
            }

            return(image);
        }
Beispiel #21
0
        public Sprite Paint(byte[,,] data)
        {
            Image image = new Image((uint)data.GetLength(0), (uint)data.GetLength(1));

            sizeVector = image.Size;
            for (uint i = 0; i < data.GetLength(0); i++)
            {
                for (uint j = 0; j < data.GetLength(1); j++)
                {
                    Color color = new Color(data[i, j, 0], data[i, j, 1], data[i, j, 2]);
                    image.SetPixel(i, j, color);
                }
            }
            Texture texture = new Texture(image);

            return(new Sprite(texture));
        }
Beispiel #22
0
        public GraphicsDisplay(uint width, uint height)
        {
            Width = width;
            Height = height;

            _data = new Image(width, height, Color.Black);
            _dataTexture = new Texture(_data);
            _palette = new Image("Data/palette.png");
            _paletteTexture = new Texture(_palette);

            _display = new Sprite(_dataTexture);

            _renderer = new Shader("Data/display.vert", "Data/display.frag");
            _renderer.SetParameter("data", _dataTexture);
            _renderer.SetParameter("dataSize", width, height);
            _renderer.SetParameter("palette", _paletteTexture);
        }
        /// <summary>
        ///  <para>Loads the embedded base files.</para>
        /// </summary>
        public void LoadBaseResources()
        {
            Assembly _assembly = Assembly.GetExecutingAssembly(); ;
            Stream _stream;

            _stream = _assembly.GetManifestResourceStream("SS14.Client.Services._EmbeddedBaseResources.bluehigh.ttf");
            if (_stream != null)
                _fonts.Add("base_font", new Font( _stream));
            _stream = null;

            _stream = _assembly.GetManifestResourceStream("SS14.Client.Services._EmbeddedBaseResources.noSprite.png");
            if (_stream != null)
            {
                Image nospriteimage = new Image( _stream);
                _images.Add("nosprite", nospriteimage);
                _sprites.Add("nosprite", new CluwneSprite("nosprite", nospriteimage));  
            }
            _stream = null;
        }
Beispiel #24
0
        /// <summary>
        ///  <para>Loads the embedded base files.</para>
        /// </summary>
        public void LoadBaseResources()
        {
            Assembly _assembly = Assembly.GetExecutingAssembly();;
            Stream   _stream;

            _stream = _assembly.GetManifestResourceStream("SS14.Client.Services._EmbeddedBaseResources.bluehigh.ttf");
            if (_stream != null)
            {
                _fonts.Add("base_font", new Font(_stream));
            }
            _stream = null;

            _stream = _assembly.GetManifestResourceStream("SS14.Client.Services._EmbeddedBaseResources.noSprite.png");
            if (_stream != null)
            {
                Image nospriteimage = new Image(_stream);
                _images.Add("nosprite", nospriteimage);
                _sprites.Add("nosprite", new CluwneSprite("nosprite", nospriteimage));
            }
            _stream = null;
        }
        public Bitmap GetEditorImage(TileObject instance)
        {
            Icon editorIcon = instance.EditorIcon;

            if (editorIcon == null)
            {
                return(null);
            }

            Texture texture = GetTexture(editorIcon.GetResourceId(0));

            if (texture == null)
            {
                return(null);
            }
            Image image = texture.CopyToImage();

            byte[] pixels = image.Pixels;

            int width  = (int)image.Size.X;
            int height = (int)image.Size.Y;

            Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            var        boundsRect = new Rectangle(0, 0, width, height);
            BitmapData bmpData    = bmp.LockBits(boundsRect,
                                                 ImageLockMode.WriteOnly,
                                                 bmp.PixelFormat);

            IntPtr ptr = bmpData.Scan0;

            int bytes     = bmpData.Stride * bmp.Height;
            var rgbValues = new byte[bytes];

            Array.Copy(pixels, 0, rgbValues, 0, pixels.Length);

            Marshal.Copy(rgbValues, 0, ptr, bytes);
            bmp.UnlockBits(bmpData);
            return(bmp);
        }
Beispiel #26
0
        public static Bitmap BitmapFromTexture(Texture tex)
        {
            if (tex == null)
            {
                throw new ArgumentNullException("tex");
            }

            SFML.Graphics.Image im = tex.CopyToImage();
            Bitmap bitmap          = new Bitmap((int)im.Size.X, (int)im.Size.Y);

            for (uint x = 0; x < im.Size.X; x++)
            {
                for (uint y = 0; y < im.Size.Y; y++)
                {
                    SFML.Graphics.Color c = im.GetPixel(x, y);
                    bitmap.SetPixel((int)x, (int)y, System.Drawing.Color.FromArgb(c.A, c.R, c.G, c.B));
                }
            }

            im.Dispose();
            return(bitmap);
        }
        private bool IsUnderCursor(TileObject to, Vector2f cursorProjection)
        {
            if (!_layersVisibility[(int)to.Layer])
            {
                return(false);
            }
            if (to.Icon == null)
            {
                return(false);
            }
            for (int i = 0; i < to.Icon.SpritesCount; i++)
            {
                Texture texture = GetTexture(to.Icon.GetResourceId(i));
                if (texture == null)
                {
                    return(false);
                }
                Image    image      = texture.CopyToImage();
                Vector2f sfmlCursor = cursorProjection;
                Vector2f sfmlObject = WorldToSfml(to.Position, to.Offset);
                float    imageX     = sfmlCursor.X - sfmlObject.X;
                float    imageY     = sfmlCursor.Y - sfmlObject.Y;
                if (imageX < 0 || imageY < 0 || imageX >= PixelsPerUnit || imageY >= PixelsPerUnit)
                {
                    continue;
                }

                uint imageXInt = (uint)Math.Round(imageX);
                uint imageYInt = (uint)Math.Round(imageY);

                if (image.GetPixel(imageXInt, imageYInt).A > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #28
0
 /// <summary>
 /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles,
 /// color tint, rotation, origin, effects, and sort depth.
 /// </summary>
 /// <param name="texture">The sprite texture.</param>
 /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param>
 /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with
 /// no tinting.</param>
 /// <param name="shader">The shader to use on the text being drawn.</param>
 public virtual void Draw(Image texture, Vector2 position, Color color, Shader shader = null)
 {
     Draw(texture, position, null, color, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, shader);
 }
Beispiel #29
0
        internal Layer(World world, System.Xml.XmlElement la, int tilewidth, int tileheight, SFML.Graphics.Image image)
        {
            Name            = la.GetAttributeString("name");
            width           = la.GetAttributeInt("width");
            height          = la.GetAttributeInt("height");
            this.tilewidth  = tilewidth;
            this.tileheight = tileheight;

            tiles = new int[width * height];

            var data  = la.FirstElement("data");
            int index = 0;

            foreach (var tile in data.ElementsNamed("tile"))
            {
                var gid = tile.GetAttributeInt("gid");
                tiles[index] = gid;
                ++index;
            }

            foreach (var o in ObjectDatas)
            {
                if (o.gid != 0)
                {
                    var sp = Tiles.CreateSprite(image, o.gid, tilewidth, tileheight);
                    sp.Position = o.pos;
                    sprites.Add(sp);
                }
            }
        }
Beispiel #30
0
        /// <summary>
        /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles,
        /// color tint, rotation, origin, effects, and sort depth.
        /// </summary>
        /// <param name="texture">The sprite texture.</param>
        /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param>
        /// <param name="sourceRectangle">A rectangle specifying, in texels, which section of the rectangle to draw.
        /// Use null to draw the entire texture.</param>
        /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with
        /// no tinting.</param>
        /// <param name="rotation">The angle, in radians, to rotate the sprite around the origin.</param>
        /// <param name="origin">The origin of the sprite. Specify (0,0) for the upper-left corner.</param>
        /// <param name="scale">Vector containing separate scalar multiples for the x- and y-axes of the sprite.</param>
        /// <param name="effects">Rotations to apply prior to rendering.</param>
        /// <param name="shader">The shader to use on the text being drawn.</param>
        public virtual void Draw(Image texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation,
                                 Vector2 origin, Vector2 scale, SpriteEffects effects = SpriteEffects.None, Shader shader = null)
        {
            if (!IsAssetValid(texture))
                return;

            _sprite.Image = texture;
            _sprite.Position = position;
            _sprite.SubRect = sourceRectangle.HasValue
                                  ? (IntRect)sourceRectangle
                                  : new IntRect(0, 0, (int)_sprite.Image.Width, (int)_sprite.Image.Height);
            _sprite.Color = color;
            _sprite.Rotation = MathHelper.ToDegrees(rotation);
            _sprite.Origin = origin;
            _sprite.FlipX((effects & SpriteEffects.FlipHorizontally) != 0);
            _sprite.FlipY((effects & SpriteEffects.FlipVertically) != 0);
            _sprite.Scale = scale;

            _rt.Draw(_sprite, shader);
        }
Beispiel #31
0
 /// <summary>
 /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles,
 /// color tint, rotation, origin, effects, and sort depth.
 /// </summary>
 /// <param name="texture">The sprite texture.</param>
 /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param>
 /// <param name="sourceRectangle">A rectangle specifying, in texels, which section of the rectangle to draw.
 /// Use null to draw the entire texture.</param>
 /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with
 /// no tinting.</param>
 /// <param name="rotation">The angle, in radians, to rotate the sprite around the origin.</param>
 /// <param name="origin">The origin of the sprite. Specify (0,0) for the upper-left corner.</param>
 /// <param name="scale">Uniform multiple by which to scale the sprite width and height.</param>
 /// <param name="effects">Rotations to apply prior to rendering.</param>
 /// <param name="shader">The shader to use on the text being drawn.</param>
 public virtual void Draw(Image texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation,
                          Vector2 origin, float scale, SpriteEffects effects = SpriteEffects.None, Shader shader = null)
 {
     Draw(texture, position, sourceRectangle, color, rotation, origin, new Vector2(scale), effects, shader);
 }
Beispiel #32
0
        /// <summary>
        ///  <para>Loads all Resources from given Zip into the respective Resource Lists and Caches</para>
        /// </summary>
        public void LoadResourceZip(string path = null, string pw = null)
        {
            string zipPath  = path ?? _configurationManager.GetResourcePath();
            string password = pw ?? _configurationManager.GetResourcePassword();


            if (!File.Exists(zipPath))
            {
                throw new FileNotFoundException("Specified Zip does not exist: " + zipPath);
            }

            FileStream zipFileStream = File.OpenRead(zipPath);
            var        zipFile       = new ZipFile(zipFileStream);

            if (!string.IsNullOrWhiteSpace(password))
            {
                zipFile.Password = password;
            }

            var directories = from ZipEntry a in zipFile
                              where a.IsDirectory
                              orderby a.Name.ToLowerInvariant() == "textures" descending
                              select a;

            Dictionary <string, List <ZipEntry> > sorted = new Dictionary <string, List <ZipEntry> >();

            foreach (ZipEntry dir in directories)
            {
                if (sorted.ContainsKey(dir.Name.ToLowerInvariant()))
                {
                    continue;                                                  //Duplicate folder? shouldnt happen.
                }
                List <ZipEntry> folderContents = (from ZipEntry entry in zipFile
                                                  where entry.Name.ToLowerInvariant().Contains(dir.Name.ToLowerInvariant())
                                                  where entry.IsFile
                                                  select entry).ToList();

                sorted.Add(dir.Name.ToLowerInvariant(), folderContents);
            }

            sorted = sorted.OrderByDescending(x => x.Key == "textures/").ToDictionary(x => x.Key, x => x.Value); //Textures first.

            foreach (KeyValuePair <string, List <ZipEntry> > current in sorted)
            {
                switch (current.Key)
                {
                case ("textures/"):
                    foreach (ZipEntry texture in current.Value)
                    {
                        if (supportedImageExtensions.Contains(Path.GetExtension(texture.Name).ToLowerInvariant()))
                        {
                            Image loadedImg = LoadImageFrom(zipFile, texture);
                            if (loadedImg == null)
                            {
                                continue;
                            }
                            else
                            {
                                _images.Add(texture.Name, loadedImg);
                            }
                        }
                    }
                    break;

                case ("tai/"):    // Tai?
                    foreach (ZipEntry tai in current.Value)
                    {
                        if (Path.GetExtension(tai.Name).ToLowerInvariant() == ".tai")
                        {
                            IEnumerable <CluwneSprite> loadedSprites = LoadSpritesFrom(zipFile, tai);
                            foreach (CluwneSprite currentSprite in loadedSprites.Where(currentSprite => !_sprites.ContainsKey(currentSprite.Name)))
                            {
                                _sprites.Add(currentSprite.Name, currentSprite);
                            }
                        }
                    }
                    break;

                case ("fonts/"):
                    foreach (ZipEntry font in current.Value)
                    {
                        if (Path.GetExtension(font.Name).ToLowerInvariant() == ".ttf")
                        {
                            Font loadedFont = LoadFontFrom(zipFile, font);
                            if (loadedFont == null)
                            {
                                continue;
                            }
                            string ResourceName = Path.GetFileNameWithoutExtension(font.Name).ToLowerInvariant();
                            _fonts.Add(ResourceName, loadedFont);
                        }
                    }
                    break;

                case ("particlesystems/"):
                    foreach (ZipEntry particles in current.Value)
                    {
                        if (Path.GetExtension(particles.Name).ToLowerInvariant() == ".xml")
                        {
                            ParticleSettings particleSettings = LoadParticlesFrom(zipFile, particles);
                            if (particleSettings == null)
                            {
                                continue;
                            }
                            else
                            {
                                _particles.Add(Path.GetFileNameWithoutExtension(particles.Name), particleSettings);
                            }
                        }
                    }
                    break;

                case ("shaders/"):
                    foreach (ZipEntry shader in current.Value)
                    {
                        //FIXME Throws Exception
                        //if (Path.GetExtension(shader.Name).ToLowerInvariant() == ".fx")
                        //{
                        //    FXShader loadedShader = LoadShaderFrom(zipFile, shader);
                        //    if (loadedShader == null) continue;
                        //    else _shaders.Add(shader.Name, loadedShader);
                        //}
                    }
                    break;

                case ("animations/"):
                    foreach (ZipEntry animation in current.Value)
                    {
                        if (Path.GetExtension(animation.Name).ToLowerInvariant() == ".xml")
                        {
                            AnimationCollection animationCollection = LoadAnimationCollectionFrom(zipFile, animation);
                            if (animationCollection == null)
                            {
                                continue;
                            }
                            else
                            {
                                _animationCollections.Add(animationCollection.Name, animationCollection);
                            }
                        }
                    }
                    break;
                }
            }

            sorted = null;

            zipFile.Close();
            zipFileStream.Close();
            zipFileStream.Dispose();

            GC.Collect();
        }
Beispiel #33
0
 /// <summary>
 /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles,
 /// color tint, rotation, origin, effects, and sort depth.
 /// </summary>
 /// <param name="texture">The sprite texture.</param>
 /// <param name="destinationRectangle">A rectangle specifying, in screen coordinates, where the sprite will be drawn.
 /// If this rectangle is not the same size as sourceRectangle, the sprite is scaled to fit.</param>
 /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with
 /// no tinting.</param>
 /// <param name="shader">The shader to use on the text being drawn.</param>
 public virtual void Draw(Image texture, Rectangle destinationRectangle, Color color, Shader shader = null)
 {
     Draw(texture, destinationRectangle, null, color, 0f, Vector2.Zero, SpriteEffects.None, shader);
 }
Beispiel #34
0
 public void generate(string unique_identifier, uint w, uint h, uint color)
 {
     image = new SFML.Graphics.Image(w, h, familiarize_color(color));
     size_full.set(w, h);
     set_sprite_grid(1, 1);
     identifier = unique_identifier;
 }
Beispiel #35
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // NOTE : This is workaround to create a functioning opengl context for OpenTK (for current OpenTK version)
            var gameWindow = new OpenTK.GameWindow();

            // Request a 24-bits depth buffer when creating the window
            var contextSettings = new ContextSettings();

            contextSettings.DepthBits = 24;

            // Create the main window
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML graphics with OpenGL", Styles.Default, contextSettings);

            window.SetVerticalSyncEnabled(true);

            // Initialize OpenTK
            // NOTE : next 2 lines are kept from old examples until we resolve proper OpenTK versioning
            //Toolkit.Init();
            //GraphicsContext context = new GraphicsContext(new ContextHandle(IntPtr.Zero), null);

            // Setup event handlers
            window.Closed     += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler <KeyEventArgs>(OnKeyPressed);
            window.Resized    += new EventHandler <SizeEventArgs>(OnResized);

            // Create a sprite for the background
            var background = new Sprite(new Texture("resources/background.jpg"));

            // Create a text to display on top of the OpenGL object
            var text = new Text("SFML / OpenGL demo", new Font("resources/sansation.ttf"));

            text.Position  = new Vector2f(250, 450);
            text.FillColor = new SFML.Graphics.Color(255, 255, 255, 170);

            // Make the window the active target for OpenGL calls
            window.SetActive();

            // Load an OpenGL texture.
            // We could directly use a SFML.Graphics.Texture as an OpenGL texture (with its Bind() member function),
            // but here we want more control on it (generate mipmaps, ...) so we create a new one
            int texture = 0;

            using (var image = new SFML.Graphics.Image("resources/texture.jpg"))
            {
                GL.GenTextures(1, out texture);
                GL.BindTexture(TextureTarget.Texture2D, texture);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)image.Size.X, (int)image.Size.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Pixels);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            }

            // Enable Z-buffer read and write
            GL.Enable(EnableCap.DepthTest);
            GL.DepthMask(true);
            GL.ClearDepth(1);

            // Disable lighting
            GL.Disable(EnableCap.Lighting);

            // Configure the viewport (the same size as the window)
            GL.Viewport(0, 0, (int)window.Size.X, (int)window.Size.Y);

            // Setup a perspective projection
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            float ratio = (float)(window.Size.X) / window.Size.Y;

            GL.Frustum(-ratio, ratio, -1, 1, 1, 500);

            // Bind the texture
            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, texture);

            // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
            float[] cube = new float[]
            {
                // positions    // texture coordinates
                -20, -20, -20, 0, 0,
                -20, 20, -20, 1, 0,
                -20, -20, 20, 0, 1,
                -20, -20, 20, 0, 1,
                -20, 20, -20, 1, 0,
                -20, 20, 20, 1, 1,

                20, -20, -20, 0, 0,
                20, 20, -20, 1, 0,
                20, -20, 20, 0, 1,
                20, -20, 20, 0, 1,
                20, 20, -20, 1, 0,
                20, 20, 20, 1, 1,

                -20, -20, -20, 0, 0,
                20, -20, -20, 1, 0,
                -20, -20, 20, 0, 1,
                -20, -20, 20, 0, 1,
                20, -20, -20, 1, 0,
                20, -20, 20, 1, 1,

                -20, 20, -20, 0, 0,
                20, 20, -20, 1, 0,
                -20, 20, 20, 0, 1,
                -20, 20, 20, 0, 1,
                20, 20, -20, 1, 0,
                20, 20, 20, 1, 1,

                -20, -20, -20, 0, 0,
                20, -20, -20, 1, 0,
                -20, 20, -20, 0, 1,
                -20, 20, -20, 0, 1,
                20, -20, -20, 1, 0,
                20, 20, -20, 1, 1,

                -20, -20, 20, 0, 0,
                20, -20, 20, 1, 0,
                -20, 20, 20, 0, 1,
                -20, 20, 20, 0, 1,
                20, -20, 20, 1, 0,
                20, 20, 20, 1, 1
            };

            // Enable position and texture coordinates vertex components
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.VertexPointer(3, VertexPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 0));
            GL.TexCoordPointer(2, TexCoordPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 3));

            // Disable normal and color vertex components
            GL.DisableClientState(ArrayCap.NormalArray);
            GL.DisableClientState(ArrayCap.ColorArray);

            var clock = new Clock();

            // Start game loop
            while (window.IsOpen)
            {
                // Process events
                window.DispatchEvents();

                // Clear the window
                GL.Clear(ClearBufferMask.DepthBufferBit);

                // Draw background
                window.PushGLStates();
                window.Draw(background);
                window.PopGLStates();

                // Clear the depth buffer
                GL.Clear(ClearBufferMask.DepthBufferBit);

                // We get the position of the mouse cursor, so that we can move the box accordingly
                float x = Mouse.GetPosition(window).X * 200.0F / window.Size.X - 100.0F;
                float y = -Mouse.GetPosition(window).Y * 200.0F / window.Size.Y + 100.0F;

                // Apply some transformations
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();
                GL.Translate(x, y, -100.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 50, 1.0F, 0.0F, 0.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 30, 0.0F, 1.0F, 0.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 90, 0.0F, 0.0F, 1.0F);

                // Draw the cube
                GL.DrawArrays(OpenTK.Graphics.OpenGL.PrimitiveType.Triangles, 0, 36);

                // Draw some text on top of our OpenGL object
                window.PushGLStates();
                window.Draw(text);
                window.PopGLStates();

                // Finally, display the rendered frame on screen
                window.Display();
            }

            // Don't forget to destroy our texture
            GL.DeleteTextures(1, ref texture);
        }
Beispiel #36
0
 /// <summary>
 /// This method is called on the client side, called when the client just connect
 /// or make sure that it got everything drawn correctly
 /// </summary>
 /// <param name="p">an array of byte representing the image, its size is width * height * 4</param>
 public void DrawReceivedWhiteboard(int curMap, byte[] p)
 {
     if (curMap < 0)
         return;
     if (p == null)
         return;
     changeMap(curMap);
     startBoard = new SFML.Graphics.Image(MapSprite.Texture.Size.X, MapSprite.Texture.Size.Y, p);
     boardImage.Update(startBoard);
     ToDraw = new Sprite(boardImage);
     forDraw.Draw(ToDraw);
 }
Beispiel #37
0
            internal void reload()
            {
                loading_in_progress = true;
                var path = _filepath;

                if (path == "")
                    throw new Exception("Trying to reload a texture that hasn't been properly loaded, derp");

                //Debug.Log("Loading texture from file... " + path);

                string ext = path.Substring(path.LastIndexOf('.') + 1);
                string def_file = path;
                def_file = def_file.Remove(def_file.LastIndexOf('.'));
                def_file += ".def";

                string alpha_file = path;
                alpha_file = alpha_file.Remove(alpha_file.LastIndexOf('.'));
                alpha_file += "_alpha." + ext;

                bool has_alpha_tex = System.IO.File.Exists(alpha_file);

                if (!_loaded)
                if (System.IO.File.Exists(def_file))
                {
                    parse_graphics_def_file(this, def_file);
                }

                if (this.image != null) this.image.Bind();
                //this.render_image = null;
                this.image = new Image(path);
                size_full.set(image.Width, image.Height);
                set_sprite_grid(sequence.x, sequence.y);
                image.Smooth = manipulate_smooth;
                _loaded = true;
                loading_in_progress = false;
            }
 /// <summary>
 /// Creates a new CluwneSprite With a key and a Image
 /// </summary>
 /// <param name="key"> Key </param>
 /// <param name="image"> Image </param>
 public CluwneSprite(string key, Image image)
 {
     this._key   = key;
     this._image = image;
 }
Beispiel #39
0
 /// <summary>
 /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles,
 /// color tint, rotation, origin, effects, and sort depth.
 /// </summary>
 /// <param name="texture">The sprite texture.</param>
 /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param>
 /// <param name="sourceRectangle">A rectangle specifying, in texels, which section of the rectangle to draw.
 /// Use null to draw the entire texture.</param>
 /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with
 /// no tinting.</param>
 /// <param name="rotation">The angle, in radians, to rotate the sprite around the origin.</param>
 /// <param name="origin">The origin of the sprite. Specify (0,0) for the upper-left corner.</param>
 /// <param name="scale">Vector containing separate scalar multiples for the x- and y-axes of the sprite.</param>
 /// <param name="effects">Rotations to apply prior to rendering.</param>
 /// <param name="shader">The shader to use on the text being drawn.</param>
 public override void Draw(Image texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation,
                           Vector2 origin, Vector2 scale, SpriteEffects effects = SpriteEffects.None, Shader shader = null)
 {
     base.Draw(texture, position.Round(), sourceRectangle, color, rotation, origin, scale, effects, shader);
 }
Beispiel #40
0
        // [omeg] added, pixelData are in RGBA format
        public override void LoadTextureRaw(Texture texture, byte[] pixelData)
        {
            if (null == texture) return;

            Debug.Print("LoadTextureRaw: {0}", texture.RendererData);

            if (texture.RendererData != null) 
                FreeTexture(texture);

            SFMLTexture sfTexture;

            try
            {
                var img = new Image((uint)texture.Width, (uint)texture.Height, pixelData); // SFML Image
                sfTexture = new SFMLTexture(img);
                sfTexture.Smooth = true;
                img.Dispose();
            }
            catch (LoadingFailedException)
            {
                Debug.Print("LoadTextureRaw: failed");
                texture.Failed = true;
                return;
            }

            texture.RendererData = sfTexture;
            texture.Failed = false;
        }
        /// <summary>
        ///  <para>Loads Image from given Zip-File and Entry.</para>
        /// </summary>
        private Image LoadImageFrom(ZipFile zipFile, ZipEntry imageEntry)
        {
            string ResourceName = Path.GetFileNameWithoutExtension(imageEntry.Name).ToLowerInvariant();

            if (TextureCache.Textures.Contains(ResourceName))
                return null; // ImageCache.Images[ResourceName];

            var byteBuffer = new byte[zipBufferSize];

            try
            {
                Stream zipStream = zipFile.GetInputStream(imageEntry);
                var memStream = new MemoryStream();

                StreamUtils.Copy(zipStream, memStream, byteBuffer);
                memStream.Position = 0;

                Image loadedImg = new Image(memStream);
                TextureCache.Add(ResourceName, loadedImg);

                memStream.Close();
                zipStream.Close();
                memStream.Dispose();
                zipStream.Dispose();
                return loadedImg;

            }
            catch(Exception I)
            {
                System.Console.WriteLine("Failed to load " + imageEntry.Name + ": " + I.ToString());
            }

            return null;
          
        }
 /// <summary>
 /// Creates a new CluwneSprite With a key and a Image
 /// </summary>
 /// <param name="key"> Key </param>
 /// <param name="image"> Image </param>
 public CluwneSprite(string key, Image image)
 {       
     this._key = key;
     this._image = image;
 }
Beispiel #43
0
 /// <summary>
 /// This method will change the map being drawn to the map index that was given
 /// </summary>
 /// <param name="id">an integer that represent the map index inside the data
 /// content pipeline for maps</param>
 public void changeMap(int id)
 {
     // Reset map
     MapSprite = new Sprite(MainViewer.Instance.Data.MapsList[id].TextureImage);
     forDraw = new RenderTexture(MapSprite.Texture.Size.X, MapSprite.Texture.Size.Y);
     startBoard = new SFML.Graphics.Image(MapSprite.Texture.Size.X, MapSprite.Texture.Size.Y);
     loadedMap = true;
     boardImage.Update(startBoard);
     if (ViewPort != null && DrawWindow != null)
     {
         Zoom(100);
         MainViewer.Instance.UpdateDrawTurretList(id);
     }
     else
     {
         MainViewer.Instance.CurrentMap = id;
     }
 }
Beispiel #44
0
        public static Texture GeneratePlanetTexture(Vector2u texSize)
        {
            var imgSize = texSize;
            perlin = new Perlin(random.Next(2, 3), 0.2, NoiseQuality.Best, 4, 0.7, random.Next(0, 1024));
            ridgedMulti = new RidgedMulti(random.NextDouble() * 2, 0.3, 2, NoiseQuality.Best, random.Next(0, 1024));
            voronoi = new Voronoi(0.1, random.NextDouble() * 2, true, random.Next(0, 1024));
            selectModule = new Select(1.0, 1.0, 0.0);
            selectModule.SetSourceModule(0, perlin);
            selectModule.SetSourceModule(1, ridgedMulti);
            selectModule.SetSourceModule(2, voronoi);

            heightMapBuilder = new PlanarNoiseMapBuilder(imgSize.X, imgSize.Y, 0, selectModule, 1, 5, 1, 5, true);
            heightMap = heightMapBuilder.Build();

            var texColors = new GradientColour();
            texColors.AddGradientPoint(-1, GenerateProceduralColor());
            texColors.AddGradientPoint(-0.2 + random.NextDouble() * 0.4, GenerateProceduralColor());
            texColors.AddGradientPoint(1, GenerateProceduralColor());
            var renderer = new ImageBuilder(heightMap, texColors);
            var renderedImg = renderer.Render();
            var img = new Bitmap(renderedImg);
            var sfmlImg = new SFML.Graphics.Image(imgSize.X, imgSize.Y);

            for (uint x = 0; x < imgSize.X; x++)
            {
                for (uint y = 0; y < imgSize.Y; y++)
                {
                    var col = img.GetPixel((int)x, (int)y);
                    sfmlImg.SetPixel(x, y, new Color(col.R, col.G, col.B, col.A));
                }
            }

            var returnTex = new Texture(sfmlImg);
            return returnTex;
        }
Beispiel #45
0
        public SmiteMap()
        {
            InitializeComponent();

            // By default no offset (draw at 0, 0)
            OffsetX = 0;
            OffsetY = 0;

            // initialize empty int for temporary god location:
            tempGodX = 0;
            tempGodY = 0;

            // Set the default zoom
            zoom = 1;

            //Defining the default shape for both images and drawing stuffs
            startBoard = new SFML.Graphics.Image(963, 891);
            forDraw = new RenderTexture(963, 891);

            // Defining drawing vertexes for lines
            vertexesToDraw = new Vector2f[6];

            // Define the whiteboard data for transmiting between client and server
            WhiteBoardPixel = new List<byte>();
            WhiteBoardX = new List<int>();
            WhiteBoardY = new List<int>();

            // Create a texture from the image
            boardImage = new Texture(startBoard);

            // No map loaded by default
            loadedMap = false;

            // Default selected Team is team1
            selectedTeam1 = true;

            // Initialize god team draw order
            renderOrder = new List<KeyValuePair<int, int>>();
        }
Beispiel #46
0
 /// <summary>
 /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles,
 /// color tint, rotation, origin, effects, and sort depth.
 /// </summary>
 /// <param name="texture">The sprite texture.</param>
 /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param>
 /// <param name="sourceRectangle">A rectangle specifying, in texels, which section of the rectangle to draw.
 /// Use null to draw the entire texture.</param>
 /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with
 /// no tinting.</param>
 /// <param name="shader">The shader to use on the text being drawn.</param>
 public override void Draw(Image texture, Vector2 position, Rectangle? sourceRectangle, Color color, Shader shader = null)
 {
     base.Draw(texture, position.Round(), sourceRectangle, color, shader);
 }