From 9ea2e69579f50f397ee47f9131dca47d616f044c Mon Sep 17 00:00:00 2001 From: Ben Doherty Date: Tue, 10 Mar 2020 17:57:59 -0700 Subject: [PATCH] Fix gltf_viewer (#2233) --- samples/gltf_viewer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/samples/gltf_viewer.cpp b/samples/gltf_viewer.cpp index 168aee7880..0b3a317d36 100644 --- a/samples/gltf_viewer.cpp +++ b/samples/gltf_viewer.cpp @@ -295,7 +295,7 @@ int main(int argc, char** argv) { } // Consume the glTF file. - std::ifstream in(filename.c_str(), std::ifstream::in); + std::ifstream in(filename.c_str(), std::ifstream::binary | std::ifstream::in); std::vector buffer(static_cast(contentSize)); if (!in.read((char*) buffer.data(), contentSize)) { std::cerr << "Unable to read " << filename << std::endl; @@ -439,8 +439,10 @@ int main(int argc, char** argv) { app.scene.groundMaterial->setDefaultParameter( "strength", app.viewOptions.groundShadowStrength); - FilamentApp::get().getIBL()->getSkybox()->setLayerMask( - 0xff, app.viewOptions.skyboxEnabled ? 0xff : 0x00); + auto ibl = FilamentApp::get().getIBL(); + if (ibl) { + ibl->getSkybox()->setLayerMask(0xff, app.viewOptions.skyboxEnabled ? 0xff : 0x00); + } view->setClearColor( LinearColorA{ inverseTonemapSRGB(app.viewOptions.backgroundColor), 1.0f }); };