Refactor filaweb::Asset.

This commit is contained in:
Philip Rideout
2018-09-21 11:54:03 -07:00
parent 63f2fe4ebc
commit 665ff2cd8f
4 changed files with 43 additions and 56 deletions
+6 -6
View File
@@ -59,11 +59,11 @@ static SuzanneApp app;
static Texture* setTextureParameter(Engine& engine, filaweb::Asset& asset, string name, bool linear,
TextureSampler const &sampler) {
const auto& info = asset.ktx->getInfo();
const auto& info = asset.texture->getInfo();
const auto destructor = [](void* buffer, size_t size, void* user) {
auto asset = (filaweb::Asset*) user;
asset->ktx.reset();
asset->texture.reset();
};
Texture::Format format;
@@ -76,7 +76,7 @@ static Texture* setTextureParameter(Engine& engine, filaweb::Asset& asset, strin
uint8_t* data;
uint32_t nbytes;
asset.ktx->getBlob({}, &data, &nbytes);
asset.texture->getBlob({}, &data, &nbytes);
Texture::PixelBufferDescriptor pb(data, nbytes, format, Texture::Type::UBYTE, destructor,
&asset);
@@ -119,11 +119,11 @@ void setup(Engine* engine, View* view, Scene* scene) {
static auto ao = filaweb::getTexture("ao");
// Create mesh.
printf("%s: %d bytes\n", "mesh", mesh.nbytes);
const uint8_t* mdata = mesh.data.get();
printf("%s: %d bytes\n", "mesh", mesh.rawSize);
const uint8_t* mdata = mesh.rawData.get();
const auto destructor = [](void* buffer, size_t size, void* user) {
auto asset = (filaweb::Asset*) user;
asset->data.reset();
asset->rawData.reset();
};
app.filamesh = decodeMesh(*engine, mdata, 0, app.mi, destructor, &mesh);
scene->addEntity(app.filamesh->renderable);