Gpu cleanup

This commit is contained in:
luboslenco
2025-06-19 19:55:16 +02:00
parent be6eaf1327
commit a7df5974ae
116 changed files with 2034 additions and 2211 deletions
+9 -9
View File
@@ -18,7 +18,7 @@ typedef struct image {
int width;
int height;
bool is_hdr;
} iron_gpu_texture_t;
} gpu_texture_t;
static bool ends_with(const char *s, const char *end) {
size_t len_s = strlen(s);
@@ -26,21 +26,21 @@ static bool ends_with(const char *s, const char *end) {
return strncmp(s + len_s - len_end, end, len_end) == 0;
}
static iron_gpu_texture_t read_png_jpg(const char *filename) {
static gpu_texture_t read_png_jpg(const char *filename) {
int width, height, n;
char *data = stbi_load(filename, &width, &height, &n, 4);
iron_gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false };
gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false };
return img;
}
static iron_gpu_texture_t read_hdr(const char *filename) {
static gpu_texture_t read_hdr(const char *filename) {
int width, height, n;
float *data = stbi_loadf(filename, &width, &height, &n, 4);
iron_gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true };
gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true };
return img;
}
static void *scale_image(iron_gpu_texture_t img, int width, int height) {
static void *scale_image(gpu_texture_t img, int width, int height) {
unsigned char *scaled = malloc(width * height * 4);
stbir_resize_uint8_generic(img.data, img.width, img.height, img.width * 4, scaled, width, height, width * 4, 4, 3, 0,
STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_COLORSPACE_SRGB, 0);
@@ -72,7 +72,7 @@ static void write_ico_entry(FILE *file, int width, int height, int size, int off
}
void export_ico(const char *from, const char *to) {
iron_gpu_texture_t img = read_png_jpg(from);
gpu_texture_t img = read_png_jpg(from);
FILE *file = fopen(to, "wb");
unsigned char *data256 = scale_image(img, 256, 256);
@@ -126,7 +126,7 @@ void export_ico(const char *from, const char *to) {
}
void export_png(const char *from, const char *to, int width, int height) {
iron_gpu_texture_t img = read_png_jpg(from);
gpu_texture_t img = read_png_jpg(from);
if (width > 0 && height > 0) {
unsigned char *scaled = scale_image(img, width, height);
@@ -162,7 +162,7 @@ static void write_k(int width, int height, const char *format, char *data, int s
}
void export_k(const char *from, const char *to) {
iron_gpu_texture_t img;
gpu_texture_t img;
if (ends_with(from, ".hdr")) {
img = read_hdr(from);
}
+1 -1
View File
@@ -23,7 +23,7 @@ let minimap_w: i32 = 150;
let minimap_h: i32 = 0;
let minimap_box_h: i32 = 0;
let minimap_scrolling: bool = false;
let minimap: iron_gpu_texture_t = null;
let minimap: gpu_texture_t = null;
let window_header_h: i32 = 0;
function drop_files(path: string) {