|
@@ -23,7 +23,7 @@ unsigned char * stbi_load(char const *, int *, int *, int *, int);
|
|
|
void stbi_image_free(void *);
|
|
void stbi_image_free(void *);
|
|
|
|
|
|
|
|
namespace {
|
|
namespace {
|
|
|
- std::unordered_map<std::string, ::graphics::texture> g_textures;
|
|
|
|
|
|
|
+ std::unordered_map<std::string, flyweight<graphics::texture>> g_textures;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
namespace graphics {
|
|
namespace graphics {
|
|
@@ -38,7 +38,7 @@ namespace graphics {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- texture texture::create(std::string const & imagefile) {
|
|
|
|
|
|
|
+ flyweight<texture> texture::create(std::string const & imagefile) {
|
|
|
auto found = g_textures.find(imagefile);
|
|
auto found = g_textures.find(imagefile);
|
|
|
if (found != g_textures.end()) { return found->second; }
|
|
if (found != g_textures.end()) { return found->second; }
|
|
|
|
|
|
|
@@ -56,7 +56,7 @@ namespace graphics {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
texture::texture(unsigned int id, math::vec2i sz)
|
|
texture::texture(unsigned int id, math::vec2i sz)
|
|
|
- : identity<graphics::texture>(id), size(sz) {}
|
|
|
|
|
|
|
+ : identity<texture>(id), size(sz) {}
|
|
|
|
|
|
|
|
texture const texture::WHITE = texture::create("\xFF\xFF\xFF\xFF", {{1, 1}});
|
|
texture const texture::WHITE = texture::create("\xFF\xFF\xFF\xFF", {{1, 1}});
|
|
|
texture const texture::DARK_YELLOW =
|
|
texture const texture::DARK_YELLOW =
|