add rapidjson for parsing sprite json files

This commit is contained in:
Konstantin Käfer
2014-02-03 11:36:34 +01:00
parent c7b012ba42
commit 202e0270f7
22 changed files with 2868 additions and 17 deletions

View File

@@ -3,6 +3,7 @@
//#include <llmr/util/vec2.hpp>
#include <llmr/style/resources.hpp>
#include <llmr/style/sprite.hpp>
#include <iostream>
#include <thread>
@@ -19,6 +20,7 @@ Map::Map(Settings& settings)
painter(transform, settings, style),
min_zoom(0),
max_zoom(14) {
loadSprite("http://localhost:3333/gl/debug/img/sprite.json");
}
Map::~Map() {
@@ -28,6 +30,17 @@ void Map::setup() {
painter.setup();
style.load(resources::style, resources::style_size);
// style.loadJSON((const char *)resources::style, resources::style_size);
}
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) {

View File

@@ -74,9 +74,9 @@ void Tile::request() {
// Note: Somehow this feels slower than the change to request_http()
std::shared_ptr<Tile> tile = shared_from_this();
platform::request_http(url, [=](const platform::Response& res) {
platform::request_http(url, [=](platform::Response& res) {
if (res.code == 200) {
tile->data.assign(res.body, res.body + res.length);
tile->data.swap(res.body);
platform::async([tile]() {
tile->parse();