Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Image distortion  (Read 1727 times)

0 Members and 1 Guest are viewing this topic.

TodesBrot

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Image distortion
« on: November 15, 2013, 09:59:39 pm »
I found a bug when displaying a sprite. It looks like this:



And it should look like this:



It happens when the Position.X/Y value is near .50050
I could recreate it with this little program, you can use any path that leads to an image instead of "image.png". The RenderTexture is just for scaling. It also works without the RenderTexture, but then the bug doesn't happen when it's scaled.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Graphics;
using SFML.Window;

namespace distortionrecreationtest
{
    static class Program
    {
        static RenderWindow Window = new RenderWindow(new VideoMode(300, 200), "");

        static void Main(string[] args)
        {
            Window.Clear(Color.White);

            RenderTexture r = new RenderTexture(300, 200);

            Sprite s = new Sprite(new Texture("image.png"));
            s.Position = new Vector2f(0.50050f, 0.50050f);
            r.Draw(s);

            r.Display();

            s = new Sprite(r.Texture);
            s.Scale = new Vector2f(5, 5);
            Window.Draw(s);

            Window.Display();

            Window.Closed += Closed;

            while (Window.IsOpen())
            {
                Window.DispatchEvents();
            }
        }

        static void Closed(object sender, EventArgs e)
        {
            Window.Close();
        }
    }
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Image distortion
« Reply #1 on: November 15, 2013, 10:21:43 pm »
It's not a bug, decimal coordinates can cause such artifacts because of OpenGL rasterization rules. If you want to ensure 1:1 drawing, avoid them.
Laurent Gomila - SFML developer

 

anything