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

Author Topic: const View & RenderWindow::GetView() const  (Read 1677 times)

0 Members and 1 Guest are viewing this topic.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
const View & RenderWindow::GetView() const
« on: September 09, 2010, 01:50:53 am »
Why returning a const reference? I think it could be useful to return just a reference, so you can store it somewhere and modify it.

In the tutorials you assume you have a View & RenderWindow::GetView() function.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
const View & RenderWindow::GetView() const
« Reply #1 on: September 09, 2010, 08:09:33 am »
It would be too much responsibility. The window uses the view, it never modifies it. Therefore, it manipulates a read-only reference to the view.

The view is supposed to be managed completely externally to the window. If you want it to be available somewhere in your code where the original instance is not known, it's your problem, SFML is not supposed to help you ;)

But don't worry, things have changed in SFML 2, and this is not an "issue" anymore. Views are manipulated by copy so basically you don't need to store the view outside the window anymore.
Laurent Gomila - SFML developer