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

Author Topic: sf::Texture::Texture(std::string file)  (Read 10079 times)

0 Members and 2 Guests are viewing this topic.

kim366

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: sf::Texture::Texture(std::string file)
« Reply #15 on: December 28, 2014, 09:43:49 am »
Okay, I did not think about that. But just be able to print an image in 1 or 2 liness would be nice (and without using too many variables).

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: sf::Texture::Texture(std::string file)
« Reply #16 on: December 28, 2014, 10:53:44 am »
Variables wont cost $. They make you think of a good name, helping you a few months later understanding your code.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: sf::Texture::Texture(std::string file)
« Reply #17 on: December 28, 2014, 05:13:32 pm »
It's already possible to do it in "two lines" without violating any taboos:

int main() {
    sf::Texture texture("thingy.png"); // line 1
    sf::RenderWindow window(...);
    while(window.isOpen()) {
        window.clear();
        window.draw(sf::Sprite(texture)); // line 2
        window.dispay();
    }
}
 

Is this not simple enough?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: sf::Texture::Texture(std::string file)
« Reply #18 on: December 28, 2014, 06:17:51 pm »
I don't see the point of line 2 being that compact. It's **really** rare to draw a sprite without custom position.
SFML / OS X developer