diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 5173de3d..8fce64c4 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -86,9 +86,15 @@ void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const cha if (icon) { GLFWimage image; - image.pixels = stbi_load(icon, &image.width, &image.height, NULL, 3); + size_t size; + lovrAssert(lovrFilesystemIsFile(icon), "Could not read icon from %s", icon); + void* data = lovrFilesystemRead(icon, &size); + lovrAssert(data, "Could not read icon from %s", icon); + image.pixels = stbi_load_from_memory(data, size, &image.width, &image.height, NULL, 4); + lovrAssert(image.pixels, "Could not read icon from %s", icon); glfwSetWindowIcon(state.window, 1, &image); free(image.pixels); + free(data); } glfwMakeContextCurrent(state.window); diff --git a/src/lib/stb/stb_image.c b/src/lib/stb/stb_image.c index 8ddfd1f5..afb8f103 100644 --- a/src/lib/stb/stb_image.c +++ b/src/lib/stb/stb_image.c @@ -1,2 +1,6 @@ #define STB_IMAGE_IMPLEMENTATION +#define STBI_NO_STDIO +#define STBI_ONLY_JPEG +#define STBI_ONLY_PNG +#define STBI_ONLY_HDR #include "stb_image.h"