Good evening
In the following code, I create a red image and fill a rectangular part of it with blue color. Then, I create a sprite that takes the whole blue area as sub-rect. Therefore, if I draw the sprite, it should be entirely blue. However, this is not the case. I see a small red border on the left side of the sprite. When I set the X coordinate's decimal part to another value like .49 or .51, everything looks good. I thought the sub-rectangle would be independent of the sprite's position on the screen, how can this happen?
I use Windows 7 64Bit and the Git revision from 2011-04-18, the code has been compiled with Visual Studio 2010.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Title");
window.SetFramerateLimit(30);
unsigned int x = 301;
unsigned int y = 303;
unsigned int s = 40;
sf::Image red, blue;
red.Create(400, 400, sf::Color::Red);
blue.Create(s, s, sf::Color::Blue);
red.Copy(blue, x, y);
sf::Sprite sprite(red);
sprite.SetSubRect(sf::IntRect(x, y, s, s));
sprite.Move(56.5f, 103.f);
for (;;)
{
sf::Event event;
while (window.PollEvent(event))
{
if (event.Type == sf::Event::Closed || event.Type == sf::Event::KeyPressed)
return 0;
}
window.Clear();
window.Draw(sprite);
window.Display();
}
}