add sprite object and parse image

refs #15
This commit is contained in:
Konstantin Käfer
2014-02-03 17:38:40 +01:00
parent f1d5f75c4f
commit a6e464b9a7
5 changed files with 231 additions and 60 deletions

View File

@@ -20,7 +20,9 @@ Map::Map(Settings& settings)
painter(transform, settings, style),
min_zoom(0),
max_zoom(14) {
loadSprite("http://localhost:3333/gl/debug/img/sprite.json");
sprite = std::make_shared<Sprite>();
sprite->load("http://localhost:3333/gl/debug/img/sprite");
}
Map::~Map() {
@@ -34,13 +36,7 @@ void Map::setup() {
}
void Map::loadSprite(const std::string& url) {
platform::request_http(url, [](const platform::Response& res) {
if (res.code == 200) {
createTexture(res.body);
} else {
fprintf(stderr, "failed to load sprite\n");
}
});
}
void Map::loadStyle(const uint8_t *const data, uint32_t bytes) {