Klasa Image z biblioteki sfml nie ma konstruktora wczytującego od razu obraz z pliku, tak jak to jest w przypadku np. klasy Texture.
Czy istnieje jakiś sposób żeby wczytać do obiektu static const sf::Image obraz z pliku?
Oto fragment klasy:
template <unsigned int width_p, unsigned int height_p>
class Chunk
{
private:
static const DataManager <std::string, Tile> tile_list;
static const DataManager <sf::Color, std::string> tile_colors;
static const sf::Texture tile_textures;
static const sf::Image game_map;
static const sf::Vector2u game_map_size;
sf::Vector2u position;
Tile** tiles;
public:
int width();
int height();
int size();
Tile* at(int pos);
Tile* at(int x, int y);
Tile* begin();
const Tile* begin() const;
Tile* end();
const Tile* end() const;
Chunk(sf::Vector2u position_p);
Chunk();
~Chunk();
};
template <unsigned int width_p, unsigned int height_p>
const DataManager <std::string, Tile> Chunk<width_p, height_p>::tile_list("resources/tile_list.txt", true);
template <unsigned int width_p, unsigned int height_p>
const DataManager <sf::Color, std::string> Chunk<width_p, height_p>::tile_colors("resources/tile_colors.txt", true);
template <unsigned int width_p, unsigned int height_p>
const sf::Image Chunk<width_p, height_p>::game_map;
// nie ma konstruktora wczytującego obrazek z pliku
template <unsigned int width_p, unsigned int height_p>
sf::Image Chunk<width_p, height_p>::game_map.loadFromFile("resources/map.png");
template <unsigned int width_p, unsigned int height_p>
const sf::Texture Chunk<width_p, height_p>::tile_textures("resources/tile_textures.png");