Not sure if this is a bug, or I'm doing something wrong here, but I'm stumped at the moment...
I've been working on some shape helpers and whenever I ask for globalbounds on a triangle with a 45 degree rotation, I get a larger bounding rect then I should be getting. It works fine for any 90 degree increment, but nothing in between (45 degrees is just an example).
Here is my main function, so you can reproduce the behavior.
What am I doing wrong here, or am I not understanding the getGlobalBounds() function?
thanks,
int main()
{
sf::ConvexShape myTri(3);
myTri.setPoint(0,sf::Vector2f(0,100));
myTri.setPoint(1,sf::Vector2f(100,0));
myTri.setPoint(2,sf::Vector2f(200,100));
myTri.setFillColor(sf::Color::Black);
myTri.setOrigin(100,50);
myTri.rotate(45);
sf::FloatRect bounds = myTri.getGlobalBounds();
sf::RectangleShape myRect( sf::Vector2f(bounds.width, bounds.height) );
myTri.move(bounds.width/2,bounds.height/2);
sf::RenderWindow window(sf::VideoMode(1024, 768), "SFML window");
// Limit the framerate to 60 frames per second (this step is optional)
window.setFramerateLimit(60);
// The main loop - ends as soon as the window is closed
while (window.isOpen())
{
// Event processing
sf::Event event;
while (window.pollEvent(event))
{
// Request for closing the window
if (event.type == sf::Event::Closed)
window.close();
}
// Clear the whole window before rendering a new frame
window.clear(sf::Color(0,0,255));
// Draw some graphical entities
window.draw(myRect);
window.draw(myTri);
// End the current frame and display its contents on screen
window.display();
}
return 0;
}