Draw() public méthode

Draw the sprite to a render target
public Draw ( RenderTarget target, RenderStates states ) : void
target RenderTarget Render target to draw to
states RenderStates Current render states
Résultat void
Exemple #1
0
        /// <summary>
        /// Creates a Sprite from RenderImage Texture and draws it to the screen
        /// </summary>
        /// <param name="Position"> Position of Texture </param>
        /// <param name="Size"> Size of the Texture </param>
        /// <param name="color"> Global color of object </param>
        public void Blit(SFML.System.Vector2f position, SFML.System.Vector2f Size, SFML.Graphics.Color color)
        {
            isStillDrawing();
            blitsprite          = new SFML.Graphics.Sprite(Texture);
            blitsprite.Position = position;
            blitsprite.Color    = color;
            var bounds = blitsprite.GetLocalBounds();

            if (Mode == BlitterSizeMode.Scale)
            {
                SFML.System.Vector2f scale = new SFML.System.Vector2f((Size.X / bounds.Width), (Size.Y / bounds.Height));
                blitsprite.Scale = scale;
            }
            else if (Mode == BlitterSizeMode.Crop)
            {
                IntRect crop = new IntRect((int)position.X, (int)position.Y, (int)Size.X, (int)Size.Y);
                blitsprite.TextureRect = crop;
            }


            if (CluwneLib.CurrentRenderTarget == this)
            {
                return;
            }

            blitsprite.Draw();
        }
 public void Draw(Color4 Color)
 {
     _currentSprite.Scale = new SFML.System.Vector2f(HorizontalFlip ? -1 : 1, 1);
     _currentSprite.Color = Color.Convert();
     _currentSprite.Draw();
     _currentSprite.Color = Color4.White.Convert();
 }
        public void GaussianBlurRadius11_ShouldBlur()
        {
            preblur = new RenderImage("testGaussianBlur", 1280, 768);
            _gaussianBlur = new GaussianBlur(_resourceManager);

            _gaussianBlur.SetRadius(11);
            _gaussianBlur.SetAmount(2);
            _gaussianBlur.SetSize(new Vector2f(preblur.Width, preblur.Height));

            while (CluwneLib.IsRunning)
            {
                var lastFrameTime = clock.ElapsedTime.AsSeconds();
                clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();

                preblur.BeginDrawing(); // set temp as CRT (Current Render Target)
                //preblur.Clear();       //Clear
                sprite = _resourceManager.GetSprite("flashlight_mask");
                sprite.Position = new Vector2f();
                sprite.Draw();
                preblur.EndDrawing();  // set previous rendertarget as CRT (screen in this case)

                //_gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget

                preblur.Blit(0,0, preblur.Width, preblur.Height,Color.White, BlitterSizeMode.Crop ); // draw blurred nosprite logo

                CluwneLib.Screen.Display();

            }
        }
Exemple #4
0
        public void LoadTestShader_ShouldDrawAllRed()
        {
            testRenderImage.BeginDrawing();


            GLSLShader currshader = resources.GetShader("RedShader");

            currshader.SetParameter("TextureUnit0", testsprite.Texture);
            currshader.setAsCurrentShader();
            testsprite.Draw();
            testRenderImage.EndDrawing();
            currshader.ResetCurrentShader();
            testRenderImage.Blit(0, 0, 1280, 720, Color.White, BlitterSizeMode.Crop);

            resources.GetSprite("flashlight_mask").Draw();
        }
Exemple #5
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            if (counterVertical < SpriteCountVertical)
            {
                if (counterHorizontal < SpriteCountHorizontal)
                {
                    explosionSprite.TextureRect = new IntRect(spriteSize * counterHorizontal, spriteSize * counterVertical, spriteSize, spriteSize);
                    explosionSprite.Draw(target, states);
                    counterHorizontal++;
                }
                counterVertical++;
            }

            else
            {
                SelfDestruct(this);
            }
        }
Exemple #6
0
        /// <summary>
        /// Draws a rectangle with an image.
        /// If the image doesn't match the size of the rectangle, the image is repeated.
        /// </summary>
        /// <param name="img">Image to use.</param>
        /// <param name="imgSrcRect">Source region of the image to use.</param>
        /// <param name="rect">Rectangle to draw.</param>
        /// <param name="color">Tint to give to the image.</param>
        public void DrawImage(Texture img, FloatRect rect, IntRect imgSrcRect, Color color)
        {
            img.Repeated = true;
            Sprite srect = new Sprite(img, imgSrcRect);
            srect.Position = new Vector2f(rect.Left + Translation.X, rect.Top + Translation.Y);
            srect.Scale = new Vector2f(rect.Width / (float)imgSrcRect.Width, rect.Height / (float)imgSrcRect.Height);
            srect.Color = ActualColor(color);

            srect.Draw(myTarget, RenderStates.Default);
        }
Exemple #7
0
 public void Draw()
 {
     _currentSprite.Scale = new SFML.System.Vector2f(HorizontalFlip ? -1 : 1, 1);
     _currentSprite.Draw();
 }
        /// <summary>
        /// Creates a Sprite from RenderImage Texture and draws it to the screen
        /// </summary>
        /// <param name="Position"> Position of Texture </param>
        /// <param name="Size"> Size of the Texture </param>
        /// <param name="color"> Global color of object </param>
        public void Blit(SFML.System.Vector2f position, SFML.System.Vector2f Size, SFML.Graphics.Color color)
        {
            isStillDrawing();
            blitsprite = new SFML.Graphics.Sprite(Texture);
            blitsprite.Position = position;
            blitsprite.Color = color;
            var bounds = blitsprite.GetLocalBounds();

            if (Mode == BlitterSizeMode.Scale)
            {
                SFML.System.Vector2f scale = new SFML.System.Vector2f(( Size.X / bounds.Width ),( Size.Y / bounds.Height ));
                blitsprite.Scale = scale;

            }
            else if (Mode == BlitterSizeMode.Crop)
            {
                IntRect crop = new IntRect((int)position.X, (int)position.Y, (int)Size.X, (int)Size.Y);
                blitsprite.TextureRect = crop;

            }

            if (CluwneLib.CurrentRenderTarget == this)
                return;

            blitsprite.Draw();
        }
        private void RenderWorking()
        {
            window.Clear(Color.Black);

            textureOne.Clear(Color.White);
            textureOne.Display();

            var renderSprite = new Sprite(textureOne.Texture);

            // Note #2
            // renderSprite.Position = new Vector2f(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y);

            renderSprite.Draw(window, RenderStates.Default);

            // Note #1
            // window.Display();
        }
Exemple #10
0
 public static void Draw(this SFML.Graphics.Sprite sprite)
 {
     sprite.Draw(CluwneLib.CurrentRenderTarget, new RenderStates(CluwneLib.CurrentShader));
 }
Exemple #11
0
 /// <summary>
 /// There is a bug with some AMD drivers that will cause the state to get corrupt after drawing an OpenGL shape. When drawing a shape, the next
 /// object rendered will have the transparency f****d up. Then it is all good. So what we do here is whenever we draw a shape, we call this afterwards
 /// to draw a 1x1 transparent sprite off-screen. This sprite will get messed up, but its off-screen, so we don't care.
 ///
 /// Details: http://en.sfml-dev.org/forums/index.php?topic=9561
 /// </summary>
 public static void AMDShapeRenderFix(RenderTarget target)
 {
     _amdShapeRenderFixSprite.Draw(target, RenderStates.Default);
 }
Exemple #12
-1
        /// <summary>
        /// Draws a rectangle with an image.
        /// If the image doesn't match the size of the rectangle, the image is repeated.
        /// </summary>
        /// <param name="img">Image to use.</param>
        /// <param name="rect">Rectangle to draw.</param>
        public void DrawImage(Texture img, FloatRect rect)
        {
            img.Repeated = true;
            Sprite srect = new Sprite(img);
            srect.Position = new Vector2f(rect.Left + Translation.X, rect.Top + Translation.Y);
            srect.Scale = new Vector2f(rect.Width / img.Size.X, rect.Height / img.Size.Y);
            srect.Color = Tint;

            srect.Draw(myTarget, RenderStates.Default);
        }