You've already forked flecs_tests
Remove all file-scope mutable state so the codebase compiles cleanly as a single translation unit. State moved into structs owned by userdata_t: - group_index_ctx_t replaces g_group_by_id/g_group_by_id_cap - shape_pool_ctx_t replaces g_shape_pool_dirty/g_shape_data_dirty and g_shape_groups/g_shape_groups_count - panel_log_ctx_t wired through all subsystems explicitly - pipeline_ctx_t owns render pipeline handles - overlay_upload_state_t (per-buffer flags) replaces single bool New features piggybacking on the refactor: - Pen tool: click-to-place anchors, Catmull-Rom preview, finalize into Bezier shapes with control points - Edit mode: anchor/handle hit testing, dragging, pre-drag undo snapshots, dedicated GPU buffers for edit overlays - Frustum culling: spatial-grid-based viewport cull in draw_shapes with linear-scan fallback for oversized viewports - Log dedup: FNV-1a 64-bit hash to skip duplicate messages - Buffer shrink: halve draw buffers after 60 frames of low usage - Shape geometry hashing for instanced-draw vertex-buffer grouping - Group member_indices arrays with O(n) rebuild - Log ring expanded 64→256 entries, added log_filter Debug build: added --profiling-funcs and -sASSERTIONS flags.
94 lines
2.3 KiB
Makefile
94 lines
2.3 KiB
Makefile
# Compiler and tools
|
|
CC = emcc
|
|
XXD = xxd
|
|
FETCH = ./fetch_libs.sh
|
|
|
|
# Directories
|
|
SRC_DIR = src
|
|
LIB_DIR = lib
|
|
SHADER_DIR = $(SRC_DIR)/shaders
|
|
GENERATED_DIR = $(SRC_DIR)/generated
|
|
|
|
# Output
|
|
TARGET = app.html
|
|
|
|
# Source files
|
|
C_SOURCES = $(SRC_DIR)/main.c
|
|
IMGUI_SOURCES = $(LIB_DIR)/imgui/imgui/imgui.cpp \
|
|
$(LIB_DIR)/imgui/imgui/imgui_draw.cpp \
|
|
$(LIB_DIR)/imgui/imgui/imgui_tables.cpp \
|
|
$(LIB_DIR)/imgui/imgui/imgui_widgets.cpp \
|
|
$(LIB_DIR)/imgui/cimgui.cpp
|
|
CGLM_SOURCES = $(wildcard $(LIB_DIR)/cglm/src/*.c)
|
|
|
|
# Dynamic shader processing
|
|
SHADER_FILES = $(wildcard $(SHADER_DIR)/*.wgsl)
|
|
SHADER_HEADERS = $(patsubst $(SHADER_DIR)/%.wgsl,$(GENERATED_DIR)/%.h,$(SHADER_FILES))
|
|
|
|
# Compiler flags
|
|
EMCC_FLAGS = --use-port=emdawnwebgpu \
|
|
-sWASM_BIGINT \
|
|
-sALLOW_MEMORY_GROWTH \
|
|
-msimd128 \
|
|
-sFILESYSTEM=0 \
|
|
-flto
|
|
|
|
# Shell template
|
|
SHELL_FILE = shell.html
|
|
|
|
# Default target
|
|
all: $(FETCH) $(TARGET)
|
|
|
|
# Main build target
|
|
$(TARGET): $(SHADER_HEADERS) $(C_SOURCES) $(IMGUI_SOURCES) $(CGLM_SOURCES) $(SHELL_FILE)
|
|
$(CC) $(C_SOURCES) $(IMGUI_SOURCES) $(CGLM_SOURCES) \
|
|
-o $(TARGET) \
|
|
$(EMCC_FLAGS) \
|
|
-O3 \
|
|
-I$(LIB_DIR)/sokol \
|
|
-I$(LIB_DIR)/imgui \
|
|
-I$(LIB_DIR)/imgui/imgui \
|
|
-I$(LIB_DIR)/util \
|
|
-I$(LIB_DIR)/cglm/include \
|
|
--shell-file=$(SHELL_FILE)
|
|
|
|
# Shader header generation
|
|
$(GENERATED_DIR)/%.h: $(SHADER_DIR)/%.wgsl | $(GENERATED_DIR)
|
|
@echo "Generating header for $<"
|
|
$(XXD) -i $< $@
|
|
|
|
# Create generated directory if it doesn't exist
|
|
$(GENERATED_DIR):
|
|
mkdir -p $(GENERATED_DIR)
|
|
|
|
debug: $(FETCH) $(SHADER_HEADERS) $(C_SOURCES) $(IMGUI_SOURCES) $(CGLM_SOURCES) $(SHELL_FILE)
|
|
$(CC) $(C_SOURCES) $(IMGUI_SOURCES) $(CGLM_SOURCES) \
|
|
-o $(TARGET) \
|
|
$(EMCC_FLAGS) \
|
|
-g --profiling-funcs -gsource-map=inline \
|
|
-sASSERTIONS \
|
|
-I$(LIB_DIR)/sokol \
|
|
-I$(LIB_DIR)/imgui \
|
|
-I$(LIB_DIR)/imgui/imgui \
|
|
-I$(LIB_DIR)/util \
|
|
-I$(LIB_DIR)/cglm/include \
|
|
--shell-file=$(SHELL_FILE)
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
rm -f $(TARGET) app.js app.wasm
|
|
rm -rf $(GENERATED_DIR)
|
|
|
|
# Rebuild everything
|
|
rebuild: clean all
|
|
|
|
# List all shader files (for debugging)
|
|
list-shaders:
|
|
@echo "Shader files found:"
|
|
@echo "$(SHADER_FILES)"
|
|
@echo ""
|
|
@echo "Generated headers:"
|
|
@echo "$(SHADER_HEADERS)"
|
|
|
|
# Phony targets
|
|
.PHONY: all clean rebuild list-shaders $(FETCH) |