From 7cd81b31eb303bb91583d503f948f9be39bc69a1 Mon Sep 17 00:00:00 2001 From: Shylie Date: Wed, 29 May 2024 08:00:30 -0400 Subject: [PATCH] print stbi failure reason --- source/glerminal.cpp | 10 +++++----- tests/basic.cpp | 9 --------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/source/glerminal.cpp b/source/glerminal.cpp index 1ed442d..5ad4892 100644 --- a/source/glerminal.cpp +++ b/source/glerminal.cpp @@ -825,16 +825,16 @@ int glerminal_load_sprites_file(const char* filename) stbi_uc* const buffer = stbi_load(filename, &w, &h, nullptr, 4); // verify atlas size is a multiple of CELL_SIZE in each dimension - if (buffer && w % glerminal::CELL_SIZE == 0 && h % glerminal::CELL_SIZE == 0) + if (!buffer) + { + std::cout << stbi_failure_reason() << std::endl; + } + else if (w % glerminal::CELL_SIZE == 0 && h % glerminal::CELL_SIZE == 0) { GLERMINAL_G->load_atlas(w / glerminal::CELL_SIZE, h / glerminal::CELL_SIZE, reinterpret_cast(buffer)); success = true; } - else if (buffer) - { - std::cout << "Invalid image width/height" << std::endl; - } stbi_image_free(buffer); diff --git a/tests/basic.cpp b/tests/basic.cpp index 7d1ae93..9322eee 100644 --- a/tests/basic.cpp +++ b/tests/basic.cpp @@ -4,21 +4,12 @@ #include -#ifndef _WIN32 -#include -#endif - namespace { void init() { if (!glerminal_load_sprites_file("resources/image.png")) { -#ifndef _WIN32 - char buffer[257] = {}; - getcwd(buffer, 256); - std::cout << buffer << std::endl; -#endif std::cout << "Failed to load texture" << std::endl; }