aboutsummaryrefslogtreecommitdiff
path: root/sources/TZR_DirectResourceLoad.c
diff options
context:
space:
mode:
Diffstat (limited to 'sources/TZR_DirectResourceLoad.c')
-rw-r--r--sources/TZR_DirectResourceLoad.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sources/TZR_DirectResourceLoad.c b/sources/TZR_DirectResourceLoad.c
index 7b53a5e..16f0f64 100644
--- a/sources/TZR_DirectResourceLoad.c
+++ b/sources/TZR_DirectResourceLoad.c
@@ -4,6 +4,7 @@
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_rwops.h>
+#include <errno.h>
#include <string.h>
#ifdef TZR_STB_IMAGE
@@ -19,12 +20,12 @@ stbi_load_surface(void *src, int size)
const int pitch = (width * 4 + 3) & ~3;
if (data == NULL) {
- fprintf(stderr, "stbi: %s\n", stbi_failure_reason());
+ TZR_Log("stbi: %s", stbi_failure_reason());
return NULL;
}
if (chans != 4) {
- fprintf(stderr, "TZR only supports RGBA images\n");
+ TZR_Log("TZR only supports RGBA images");
free(data);
return NULL;
}
@@ -61,7 +62,7 @@ TZR_DirectResourceLoad(TZR_Resource *res, const void *data, int size)
res->raw.size = size;
res->raw.data = malloc(size);
if (res->raw.data == NULL) {
- perror("TZR_DirectResourceLoad");
+ TZR_Log("%s", strerror(errno));
return -1;
}
memcpy(res->raw.data, data, size);
@@ -97,17 +98,17 @@ TZR_DirectResourceLoad(TZR_Resource *res, const void *data, int size)
} break;
case TZR_RES_SOUND: {
if (!___tzr_config.mixer) {
- SDL_Log("audio mixer disabled, skip loading");
+ TZR_Log("audio mixer disabled, skip loading");
return -1;
}
#ifdef TZR_SOLOUD
Wav *wav = Wav_create();
if (wav == NULL) {
- SDL_Log("Wav_create failed");
+ TZR_Log("Wav_create failed");
return -1;
}
if (Wav_loadMemEx(wav, data, size, true, false)) {
- SDL_Log("Wav_loadMem failed");
+ TZR_Log("Wav_loadMem failed");
Wav_destroy(wav);
return -1;
}
@@ -124,7 +125,7 @@ TZR_DirectResourceLoad(TZR_Resource *res, const void *data, int size)
#endif
} break;
default:
- fprintf(stderr, "invalid type\n");
+ TZR_Log("invalid type");
return -1;
}
return 0;