SFML community forums

Help => Window => Topic started by: BlueMagic on January 21, 2012, 04:21:02 am

Title: sf::View isn't updated
Post by: BlueMagic on January 21, 2012, 04:21:02 am
I have a piece of code where I change the Window's View to a new one. According to the documentation, sfml copies the view and it's not necessary to keep the sf::View object alive. That's ok, but how can I update the view later on? If I wanted to scroll it, for example, I should create a new view, move it, and then pass it on to the window?
If I try to get the view via Window::GetCurrentView() I can't update it because it's const.

Using SFML 2.
Title: sf::View isn't updated
Post by: Laurent on January 21, 2012, 09:27:49 am
Views are now handled by copy, so there's no point trying to directly modify what GetCurrentView() returns. Copy it in a new sf::View variable, modify it, and pass it back to SetView.
Title: sf::View isn't updated
Post by: RedIrony on January 21, 2012, 10:15:22 am
Out of curiosity, why did you guys make that change? Doesn't it mean that the window reallocates the view every time you modify the camera?
Title: sf::View isn't updated
Post by: Nexus on January 21, 2012, 10:36:18 am
Using copies leads to less surprises when one passes temporary objects or ones that go out of scope. The user doesn't have to store the view on its own.

The assignment of a sf::View instance is not expensive at all, there is no dynamic allocation necessary.
Title: sf::View isn't updated
Post by: BlueMagic on January 22, 2012, 02:45:49 am
I ran a sizeof(sf::View) and it's about 148. I definitely haven't got a lot of experience in this, but isn't that kind of a big size to be copying 60 times per second? Mind you, I didn't do many practical tests.
Title: sf::View isn't updated
Post by: BlueMagic on January 23, 2012, 05:23:31 pm
Quote from: "BlueMagic"
I ran a sizeof(sf::View) and it's about 148. I definitely haven't got a lot of experience in this, but isn't that kind of a big size to be copying 60 times per second? Mind you, I didn't do many practical tests.


Anyone?
Title: sf::View isn't updated
Post by: Laurent on January 23, 2012, 09:57:22 pm
It's big but not expensive (there's no dynamic allocation). It's very unlikely to slow down your app, don't worry ;)