Use defines to shrink stb_image footprint;

This commit is contained in:
bjorn 2018-08-16 13:01:50 -07:00
parent 7f158a3473
commit 3d691ed087
2 changed files with 11 additions and 1 deletions

View File

@ -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);

View File

@ -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"