volviewer

Volumetric Data Toy Viewer
git clone anongit@rnpnr.xyz:volviewer.git
Log | Files | Refs | Feed | LICENSE

Commit: 64a87ca0208c054cda530c8fb020531c92fd4388
Parent: 36e3c15caefece796d2370e8b97260f1fdb05669
Author: Randy Palamar
Date:   Wed, 28 May 2025 21:57:25 -0600

drop multi file volume stitching

just concatenate the files dummy

Diffstat:
Mcommon.c | 37++++---------------------------------
Moptions.h | 7+++----
2 files changed, 7 insertions(+), 37 deletions(-)

diff --git a/common.c b/common.c @@ -3,7 +3,6 @@ #include "GLFW/glfw3.h" #include <stdio.h> -#include <stdarg.h> #include "options.h" @@ -59,21 +58,6 @@ gl_debug_logger(u32 src, u32 type, u32 id, u32 lvl, s32 len, const char *msg, co stream_reset(e, 0); } -function void -stream_printf(Stream *s, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - s32 length = vsnprintf(0, 0, format, ap); - s->errors |= (s->cap - s->widx) < (length + 1); - if (!s->errors) { - vsnprintf((char *)(s->data + s->widx), s->cap - s->widx, format, ap); - s->widx += length; - } - va_end(ap); -} - function u32 compile_shader(OS *os, Arena a, u32 type, str8 shader, str8 name) { @@ -167,7 +151,7 @@ function FILE_WATCH_CALLBACK_FN(reload_shader) } function u32 -load_complex_texture(Arena arena, c8 *file_path, b32 multi_file, u32 width, u32 height, u32 depth) +load_complex_texture(Arena arena, c8 *file_path, u32 width, u32 height, u32 depth) { u32 result = 0; glCreateTextures(GL_TEXTURE_3D, 1, &result); @@ -178,21 +162,8 @@ load_complex_texture(Arena arena, c8 *file_path, b32 multi_file, u32 width, u32 glTextureParameteri(result, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTextureParameteri(result, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - if (multi_file) { - /* NOTE(rnp): assumes single plane */ - Arena start = arena; - for (u32 i = 0; i < depth; i++) { - arena = start; - Stream spath = arena_stream(arena); - stream_printf(&spath, file_path, i); - str8 path = arena_stream_commit_zero(&arena, &spath); - str8 raw = os_read_whole_file(&arena, (char *)path.data); - if (raw.len) glTextureSubImage3D(result, 0, 0, 0, i, width, height, 1, GL_RG, GL_FLOAT, raw.data); - } - } else { - str8 raw = os_read_whole_file(&arena, file_path); - if (raw.len) glTextureSubImage3D(result, 0, 0, 0, 0, width, height, depth, GL_RG, GL_FLOAT, raw.data); - } + str8 raw = os_read_whole_file(&arena, file_path); + if (raw.len) glTextureSubImage3D(result, 0, 0, 0, 0, width, height, depth, GL_RG, GL_FLOAT, raw.data); return result; } @@ -572,7 +543,7 @@ function void draw_volume_item(ViewerContext *ctx, VolumeDisplayItem *v, f32 rotation, f32 translate_x) { if (!v->texture) { - v->texture = load_complex_texture(ctx->arena, v->file_path, v->multi_file, + v->texture = load_complex_texture(ctx->arena, v->file_path, v->width, v->height, v->depth); } diff --git a/options.h b/options.h @@ -29,7 +29,6 @@ typedef struct { f32 threshold; f32 translate_x; /* mm to translate by when multi display is active */ b32 swizzle; /* 1 -> swap y-z coordinates when sampling texture */ - b32 multi_file; /* 1 -> depth == N-frames, file_path == fmt string */ f32 gain; /* uniform image gain */ u32 texture; } VolumeDisplayItem; @@ -38,8 +37,8 @@ typedef struct { global u32 single_volume_index = 0; global VolumeDisplayItem volumes[] = { /* WALKING FORCES */ - {"./data/test/frame_%02u.bin", 512, 1024, 64, {{-20.5, -9.6, 5}}, {{20.5, 9.6, 50}}, 0.62, 72, 0, 0, 1, 3.7}, + {"./data/walking.bin", 512, 1024, 64, {{-20.5, -9.6, 5}}, {{20.5, 9.6, 50}}, 0.62, 72, 0, 0, 3.7}, /* RCA */ - {"./data/tpw.bin", 512, 64, 1024, {{-9.6, -9.6, 5}}, {{9.6, 9.6, 50}}, 0, 92, -5 * 18.5, 1, 0, 5}, - {"./data/vls.bin", 512, 64, 1024, {{-9.6, -9.6, 5}}, {{9.6, 9.6, 50}}, 0, 89, 5 * 18.5, 1, 0, 5}, + {"./data/tpw.bin", 512, 64, 1024, {{-9.6, -9.6, 5}}, {{9.6, 9.6, 50}}, 0, 92, -5 * 18.5, 1, 5}, + {"./data/vls.bin", 512, 64, 1024, {{-9.6, -9.6, 5}}, {{9.6, 9.6, 50}}, 0, 89, 5 * 18.5, 1, 5}, };