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

Author Topic: sf::image constructor that allows to initialize an imagefile  (Read 2680 times)

0 Members and 1 Guest are viewing this topic.

kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
sf::image constructor that allows to initialize an imagefile
« on: December 27, 2013, 01:56:42 pm »
hi,

just stumbled upon this, is there a reason there is no

sf::image(std::string filename)
{
loadImage(filename);
}

constructor in the sf::image class? Would be nice to have in my opinion.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::image constructor that allows to initialize an imagefile
« Reply #1 on: December 27, 2013, 02:36:20 pm »
Yes, such a constructor has two disadvantages:
  • It is less expressive and possibly ambiguous (consider sf::Shader which can be loaded from a file or from a string), thus one should consider the named constructor idiom.
  • SFML 2 doesn't use exceptions, so there is no way to report errors.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: