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

Author Topic: RenderTarget::SetView()  (Read 2270 times)

0 Members and 1 Guest are viewing this topic.

Pseudonym

  • Newbie
  • *
  • Posts: 1
    • View Profile
RenderTarget::SetView()
« on: October 17, 2010, 10:15:35 pm »
Hi!

I find it confusing that RenderTarget::SetView(const View& view);
stores a pointer to view, instead of copying it.
Thus I have to keep the View object around to keep the pointer valid:

Code: [Select]

void canvas::resize(int width, int height) {
static sf::View view;
sf::FloatRect canvasRect(0, 0, width, height);
view.SetFromRect(canvasRect);
SetView(view);
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
RenderTarget::SetView()
« Reply #1 on: October 17, 2010, 10:53:44 pm »
It's already changed in SFML 2.

This is more convenient to use, but I don't find it less confusing. It's common that a class uses an instance of another class managed externally, without taking ownership of it or duplicating it. Look at sf::Sprite and sf::Image for example.
Laurent Gomila - SFML developer

 

anything