SFML community forums
Help => Window => Topic started 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.
-
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.
-
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?
-
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.
-
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.
-
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?
-
It's big but not expensive (there's no dynamic allocation). It's very unlikely to slow down your app, don't worry ;)