From bbdf218a9c90f6167e0ff23dc66456f4f07b0e0d Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sun, 3 Mar 2024 16:58:59 -0600 Subject: [PATCH] use stb submodule --- .gitmodules | 3 +++ Makefile | 7 ++++--- source/engine/texture.c | 6 +++--- source/engine/thirdparty/stb | 1 + source/engine/window.c | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) create mode 160000 source/engine/thirdparty/stb diff --git a/.gitmodules b/.gitmodules index 8a16bdf..d868043 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "source/engine/thirdparty/sokol"] path = source/engine/thirdparty/sokol url = https://github.com/floooh/sokol.git +[submodule "source/engine/thirdparty/stb"] + path = source/engine/thirdparty/stb + url = https://github.com/nothings/stb.git diff --git a/Makefile b/Makefile index 3eee09e..5310a58 100755 --- a/Makefile +++ b/Makefile @@ -155,8 +155,9 @@ endif OBJDIR = $(BIN)/obj # All other sources -OBJS != find source/engine -type f -name '*.c' | grep -v 'tests' -OBJS += $(shell find source/engine -type f -name '*.cpp') +OBJS != find source/engine -type f -name '*.c' | grep -vE 'test|tool' +CPPOBJS != find source/engine -type f -name '*.cpp' | grep -vE 'test|tool' +OBJS += $(CPPOBJS) OBJS += $(shell find source/engine -type f -name '*.m') OBJS := $(patsubst %.cpp, %.o, $(OBJS)) OBJS := $(patsubst %.c, %.o,$(OBJS)) @@ -165,7 +166,7 @@ OBJS := $(addprefix $(BIN)/obj/, $(OBJS)) engineincs != find source/engine -maxdepth 1 -type d includeflag != find source -type d -name include -includeflag += $(engineincs) source/engine/thirdparty/tinycdb source/shaders source/engine/thirdparty/sokol +includeflag += $(engineincs) source/engine/thirdparty/tinycdb source/shaders source/engine/thirdparty/sokol source/engine/thirdparty/stb includeflag := $(addprefix -I, $(includeflag)) # Adding different SDKs diff --git a/source/engine/texture.c b/source/engine/texture.c index 2c7169c..55da3c9 100644 --- a/source/engine/texture.c +++ b/source/engine/texture.c @@ -10,7 +10,7 @@ #include "resources.h" #define STB_IMAGE_RESIZE_IMPLEMENTATION -#include "stb_image_resize.h" +#include "stb_image_resize2.h" #include @@ -179,7 +179,7 @@ struct Texture *texture_pullfromfile(const char *path) { mip_wh(tex->width, tex->height, &mipw, &miph, i-1); /* mipw miph are previous iteration */ mip_wh(tex->width, tex->height, &w, &h, i); mipdata[i] = malloc(w * h * 4); - stbir_resize_uint8(mipdata[i-1], mipw, miph, 0, mipdata[i], w, h, 0, 4); + stbir_resize_uint8_linear(mipdata[i-1], mipw, miph, 0, mipdata[i], w, h, 0, 4); sg_img_data.subimage[0][i] = (sg_range){ .ptr = mipdata[i], .size = w*h*4 }; mipw = w; @@ -261,7 +261,7 @@ struct Texture *texture_fromdata(void *raw, long size) mip_wh(tex->width, tex->height, &mipw, &miph, i-1); /* mipw miph are previous iteration */ mip_wh(tex->width, tex->height, &w, &h, i); mipdata[i] = malloc(w * h * 4); - stbir_resize_uint8(mipdata[i-1], mipw, miph, 0, mipdata[i], w, h, 0, 4); + stbir_resize_uint8_linear(mipdata[i-1], mipw, miph, 0, mipdata[i], w, h, 0, 4); sg_img_data.subimage[0][i] = (sg_range){ .ptr = mipdata[i], .size = w*h*4 }; mipw = w; diff --git a/source/engine/thirdparty/stb b/source/engine/thirdparty/stb new file mode 160000 index 0000000..ae721c5 --- /dev/null +++ b/source/engine/thirdparty/stb @@ -0,0 +1 @@ +Subproject commit ae721c50eaf761660b4f90cc590453cdb0c2acd0 diff --git a/source/engine/window.c b/source/engine/window.c index d351d25..d7caf24 100644 --- a/source/engine/window.c +++ b/source/engine/window.c @@ -13,7 +13,7 @@ #include "stb_ds.h" #include "sokol/sokol_app.h" -#include "stb_image_resize.h" +#include "stb_image_resize2.h" struct window mainwin; @@ -90,7 +90,7 @@ void window_seticon(struct window *w, struct Texture *tex) for (int i = 0; i < 4; i++) { sizes[i].data = malloc(4*sizes[i].size*sizes[i].size); - stbir_resize_uint8(tex->data, tex->width, tex->height, 0, sizes[i].data, sizes[i].size, sizes[i].size, 0, 4); + stbir_resize_uint8_linear(tex->data, tex->width, tex->height, 0, sizes[i].data, sizes[i].size, sizes[i].size, 0, 4); } sapp_icon_desc idsc = {