use stb submodule

This commit is contained in:
John Alanbrook 2024-03-03 16:58:59 -06:00
parent 1a3b322df4
commit bbdf218a9c
5 changed files with 13 additions and 8 deletions

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "source/engine/thirdparty/sokol"] [submodule "source/engine/thirdparty/sokol"]
path = source/engine/thirdparty/sokol path = source/engine/thirdparty/sokol
url = https://github.com/floooh/sokol.git url = https://github.com/floooh/sokol.git
[submodule "source/engine/thirdparty/stb"]
path = source/engine/thirdparty/stb
url = https://github.com/nothings/stb.git

View file

@ -155,8 +155,9 @@ endif
OBJDIR = $(BIN)/obj OBJDIR = $(BIN)/obj
# All other sources # All other sources
OBJS != find source/engine -type f -name '*.c' | grep -v 'tests' OBJS != find source/engine -type f -name '*.c' | grep -vE 'test|tool'
OBJS += $(shell find source/engine -type f -name '*.cpp') CPPOBJS != find source/engine -type f -name '*.cpp' | grep -vE 'test|tool'
OBJS += $(CPPOBJS)
OBJS += $(shell find source/engine -type f -name '*.m') OBJS += $(shell find source/engine -type f -name '*.m')
OBJS := $(patsubst %.cpp, %.o, $(OBJS)) OBJS := $(patsubst %.cpp, %.o, $(OBJS))
OBJS := $(patsubst %.c, %.o,$(OBJS)) OBJS := $(patsubst %.c, %.o,$(OBJS))
@ -165,7 +166,7 @@ OBJS := $(addprefix $(BIN)/obj/, $(OBJS))
engineincs != find source/engine -maxdepth 1 -type d engineincs != find source/engine -maxdepth 1 -type d
includeflag != find source -type d -name include 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)) includeflag := $(addprefix -I, $(includeflag))
# Adding different SDKs # Adding different SDKs

View file

@ -10,7 +10,7 @@
#include "resources.h" #include "resources.h"
#define STB_IMAGE_RESIZE_IMPLEMENTATION #define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize.h" #include "stb_image_resize2.h"
#include <stdio.h> #include <stdio.h>
@ -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, &mipw, &miph, i-1); /* mipw miph are previous iteration */
mip_wh(tex->width, tex->height, &w, &h, i); mip_wh(tex->width, tex->height, &w, &h, i);
mipdata[i] = malloc(w * h * 4); 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 }; sg_img_data.subimage[0][i] = (sg_range){ .ptr = mipdata[i], .size = w*h*4 };
mipw = w; 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, &mipw, &miph, i-1); /* mipw miph are previous iteration */
mip_wh(tex->width, tex->height, &w, &h, i); mip_wh(tex->width, tex->height, &w, &h, i);
mipdata[i] = malloc(w * h * 4); 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 }; sg_img_data.subimage[0][i] = (sg_range){ .ptr = mipdata[i], .size = w*h*4 };
mipw = w; mipw = w;

1
source/engine/thirdparty/stb vendored Submodule

@ -0,0 +1 @@
Subproject commit ae721c50eaf761660b4f90cc590453cdb0c2acd0

View file

@ -13,7 +13,7 @@
#include "stb_ds.h" #include "stb_ds.h"
#include "sokol/sokol_app.h" #include "sokol/sokol_app.h"
#include "stb_image_resize.h" #include "stb_image_resize2.h"
struct window mainwin; struct window mainwin;
@ -90,7 +90,7 @@ void window_seticon(struct window *w, struct Texture *tex)
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
sizes[i].data = malloc(4*sizes[i].size*sizes[i].size); 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 = { sapp_icon_desc idsc = {