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

Author Topic: sf::View isn't updated  (Read 3010 times)

0 Members and 1 Guest are viewing this topic.

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
sf::View isn't updated
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::View isn't updated
« Reply #1 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.
Laurent Gomila - SFML developer

RedIrony

  • Newbie
  • *
  • Posts: 23
    • View Profile
sf::View isn't updated
« Reply #2 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?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
sf::View isn't updated
« Reply #3 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
sf::View isn't updated
« Reply #4 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.

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
sf::View isn't updated
« Reply #5 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::View isn't updated
« Reply #6 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 ;)
Laurent Gomila - SFML developer