diff options
author | mattkae <mattkae@protonmail.com> | 2022-05-07 12:17:36 -0400 |
---|---|---|
committer | mattkae <mattkae@protonmail.com> | 2022-05-07 12:17:36 -0400 |
commit | 0b8596a5ebec39f797fe8a14eed1bda3c2e3a93d (patch) | |
tree | ea248ce7d55046d578f5ad371f4083405a4f7892 /themes/main.cpp | |
parent | 1c051dffdb27ff6ebaa96802b021e99e49afb861 (diff) |
Working bunny render
Diffstat (limited to 'themes/main.cpp')
-rw-r--r-- | themes/main.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/themes/main.cpp b/themes/main.cpp index d3966af..ef7d18b 100644 --- a/themes/main.cpp +++ b/themes/main.cpp @@ -37,6 +37,9 @@ struct WinterTheme { }; struct SpringTheme { + bool canRenderBunny = false; + Mesh3d bunnyMesh; + void load(Renderer3D* renderer); void update(f32 dtSeconds); void render(Renderer3D* renderer); @@ -227,17 +230,21 @@ void WinterTheme::unload() { // -- Spring theme void onBunnySuccess(emscripten_fetch_t *fetch) { - printf("Finished downloading %llu bytes from URL %s.\n", fetch->numBytes, fetch->url); - // The data is now available at fetch->data[0] through fetch->data[fetch->numBytes-1]; - emscripten_fetch_close(fetch); // Free data associated with the fetch. + springTheme.canRenderBunny = true; + printf("Finished downloading %llu bytes from URL %s.\n", fetch->numBytes, fetch->url); + const i32 len = fetch->numBytes; + springTheme.bunnyMesh = Mesh3d_fromObj(&renderer3d, fetch->data, len); + // The data is now available at fetch->data[0] through fetch->data[fetch->numBytes-1]; + emscripten_fetch_close(fetch); // Free data associated with the fetch. } void onBunnyFail(emscripten_fetch_t *fetch) { - printf("Downloading %s failed, HTTP failure status code: %d.\n", fetch->url, fetch->status); - emscripten_fetch_close(fetch); // Also free data on failure. + printf("Downloading %s failed, HTTP failure status code: %d.\n", fetch->url, fetch->status); + emscripten_fetch_close(fetch); // Also free data on failure. } void SpringTheme::load(Renderer3D* renderer) { + canRenderBunny = false; renderer->clearColor = Vector4(160, 231, 160, 255.f).toNormalizedColor(); emscripten_fetch_attr_t attr; @@ -253,7 +260,12 @@ void SpringTheme::update(f32 dtSeconds) { } void SpringTheme::render(Renderer3D* renderer) { + renderer->render(); + if (canRenderBunny) { + bunnyMesh.render(renderer); + } } void SpringTheme::unload() { -}
\ No newline at end of file + bunnyMesh.unload(); +} |