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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - dm

Pages: [1]
1
Graphics / sf::Transformable::getTransform() broken?
« on: November 06, 2014, 12:56:46 pm »
Consider this:
int main(int, char const**)
{
    sf::RenderWindow window(sf::VideoMode(480, 320), "SFML window");
   
    sf::RectangleShape parent;
    parent.setSize({50, 50});
    parent.setFillColor(sf::Color::Green);
    parent.setOrigin({-50, -50});
   
    sf::RectangleShape child;
    child.setSize({50, 50});
    child.setFillColor(sf::Color::Red);
   
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }

        window.clear();
        window.draw(parent);
        // child should be drawn at origin, but instead it drawn over parent.
        window.draw(child, parent.getTransform());
        window.display();
    }
    return EXIT_SUCCESS;
}
 

I think, child should be drawn at parent origin but instead it drawn over parent. It is a bug in getTransform() or I misunderstood something?

Pages: [1]