Skip to content

Commit

Permalink
correctted loadFromMemory
Browse files Browse the repository at this point in the history
  • Loading branch information
jporsay committed Mar 21, 2013
1 parent 493c2fa commit 76053d1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/cricketsfml/include/cricketsfml/graphics/Sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ friend class window::SFMLWindow;
FloatPoint getScale() const;

inline static Sprite* loadFromMemory(const char* data, uint64_t size) {
sf::Texture t;
if (data == 0) {
std::cout << "failed to load sprite from memory: empty data" << std::endl;
return 0;
}
if (!t.loadFromMemory(data, size)) {
sf::Texture* t = new sf::Texture();
if (!t->loadFromMemory(data, size)) {
std::cout << "failed to load sprite from memory: t.loadFromMemory failed" << std::endl;
return 0;
}
Sprite* s = new Sprite();
s->setSprite(new sf::Sprite(t));
sf::Sprite* sf = new sf::Sprite();
sf->setTexture(*t);
s->setSprite(sf);
return s;
}
};
Expand Down

0 comments on commit 76053d1

Please sign in to comment.