diff --git a/src/flamegpu/visualiser/Visualiser.cpp b/src/flamegpu/visualiser/Visualiser.cpp index fd096cd..f3c8897 100644 --- a/src/flamegpu/visualiser/Visualiser.cpp +++ b/src/flamegpu/visualiser/Visualiser.cpp @@ -21,6 +21,7 @@ #include "flamegpu/visualiser/ui/SplashScreen.h" #include "flamegpu/visualiser/multipass/FrameBuffer.h" #include "flamegpu/visualiser/multipass/FrameBufferAttachment.h" +#include "util/Resources.h" namespace flamegpu { namespace visualiser { @@ -1230,7 +1231,13 @@ void Visualiser::screenshot(const bool verbose) { void Visualiser::setWindowIcon() { if (!window) return; - auto surface = Texture::loadImage(modelConfig.isPython ? "resources/pyflamegpu_icon.png" : "resources/flamegpu_icon.png"); + std::shared_ptr surface; + try { + surface = Texture::loadImage(modelConfig.isPython ? "resources/pyflamegpu_icon.png" : "resources/flamegpu_icon.png"); + } catch(...) { + // Fail silently, branding is not required + fprintf(stderr, "Failed to load window icon: %s\n", Resources::locateFile(modelConfig.isPython ? "resources/pyflamegpu_icon.png" : "resources/flamegpu_icon.png").c_str()); + } if (surface) SDL_SetWindowIcon(window, surface.get()); } diff --git a/src/flamegpu/visualiser/ui/SplashScreen.cpp b/src/flamegpu/visualiser/ui/SplashScreen.cpp index 0431a2f..f99a3ed 100644 --- a/src/flamegpu/visualiser/ui/SplashScreen.cpp +++ b/src/flamegpu/visualiser/ui/SplashScreen.cpp @@ -5,6 +5,7 @@ #include "flamegpu/visualiser/ui/Sprite2D.h" #include "flamegpu/visualiser/ui/Text.h" #include "flamegpu/visualiser/util/fonts.h" +#include "flamegpu/visualiser/util/Resources.h" namespace flamegpu { namespace visualiser { @@ -12,17 +13,28 @@ namespace visualiser { SplashScreen::SplashScreen(const glm::vec3& textColor, const std::string& message, bool isPython) : logo_offset(0) , text_offset(0) { - logo = std::make_shared(Texture2D::load(isPython ? "resources/pyflamegpu.png" : "resources/flamegpu.png")); + int logo_height = 0; + try { + logo = std::make_shared(Texture2D::load(isPython ? "resources/pyflamegpu.png" : "resources/flamegpu.png")); + logo_height = logo->getHeight(); + } catch(...) { + // Fail silently, branding is not required + fprintf(stderr, "Failed to load splash screen logo: %s\n", Resources::locateFile(isPython ? "resources/pyflamegpu.png" : "resources/flamegpu.png").c_str()); + } text = std::make_shared("Loading...", 45, textColor, fonts::findFont({ "Arial" }, fonts::GenericFontFamily::SANS).c_str()); // Calculate offsets for vertical stacking const int PADDING = 10; - const int FULL_HEIGHT = logo->getHeight() + PADDING + text->getHeight(); + const int FULL_HEIGHT = logo_height + PADDING + text->getHeight(); const int MID_HEIGHT = FULL_HEIGHT / 2; - logo_offset.y = MID_HEIGHT - (logo->getHeight() / 2); - text_offset.y = MID_HEIGHT - (logo->getHeight() + PADDING + (text->getHeight() / 2)); + logo_offset.y = MID_HEIGHT - (logo_height / 2); + text_offset.y = MID_HEIGHT - (logo_height + PADDING + (text->getHeight() / 2)); } std::vector SplashScreen::getOverlays() const { - return std::vector{OverlayItem{ logo, logo_offset, 0 }, OverlayItem{ text, text_offset, 0 }}; + if (logo) { + return std::vector{OverlayItem{ logo, logo_offset, 0 }, OverlayItem{ text, text_offset, 0 }}; + } else { + return std::vector{OverlayItem{ text, text_offset, 0 }}; + } } } // namespace visualiser