summaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2022-12-23 12:47:10 -0500
committermattkae <mattkae@protonmail.com>2022-12-23 12:47:10 -0500
commit7228b2e1a2d0a8399facce3493d71a3569d250d5 (patch)
tree8eb5e4b686bf68fa12fcbb270ef88dd29aa1d704 /themes
parentf63d0af456f76d713e56ca17be114fba0af22f6c (diff)
Improved the makefile considerably
Diffstat (limited to 'themes')
-rw-r--r--themes/Makefile49
-rwxr-xr-xthemes/dist/output.wasmbin135615 -> 135480 bytes
-rw-r--r--themes/src/LeafParticleRender.cpp (renamed from themes/LeafParticleRender.cpp)0
-rw-r--r--themes/src/LeafParticleRender.h (renamed from themes/LeafParticleRender.h)0
-rw-r--r--themes/src/Logger.cpp (renamed from themes/Logger.cpp)0
-rw-r--r--themes/src/Logger.h (renamed from themes/Logger.h)0
-rw-r--r--themes/src/MainLoop.cpp (renamed from themes/MainLoop.cpp)0
-rw-r--r--themes/src/MainLoop.h (renamed from themes/MainLoop.h)0
-rw-r--r--themes/src/Renderer2d.cpp (renamed from themes/Renderer2d.cpp)0
-rw-r--r--themes/src/Renderer2d.h (renamed from themes/Renderer2d.h)0
-rw-r--r--themes/src/Renderer3d.cpp (renamed from themes/Renderer3d.cpp)0
-rw-r--r--themes/src/Renderer3d.h (renamed from themes/Renderer3d.h)0
-rw-r--r--themes/src/Shader.cpp (renamed from themes/Shader.cpp)0
-rw-r--r--themes/src/Shader.h (renamed from themes/Shader.h)0
-rw-r--r--themes/src/Snowflake.cpp (renamed from themes/Snowflake.cpp)12
-rw-r--r--themes/src/Snowflake.h (renamed from themes/Snowflake.h)5
-rw-r--r--themes/src/SummerTheme.cpp (renamed from themes/SummerTheme.cpp)0
-rw-r--r--themes/src/SummerTheme.h (renamed from themes/SummerTheme.h)0
-rw-r--r--themes/src/TreeShape.cpp (renamed from themes/TreeShape.cpp)0
-rw-r--r--themes/src/TreeShape.h (renamed from themes/TreeShape.h)0
-rw-r--r--themes/src/WebglContext.cpp (renamed from themes/WebglContext.cpp)0
-rw-r--r--themes/src/WebglContext.h (renamed from themes/WebglContext.h)0
-rw-r--r--themes/src/list.h (renamed from themes/list.h)0
-rw-r--r--themes/src/main.cpp (renamed from themes/main.cpp)1
-rw-r--r--themes/src/mathlib.cpp (renamed from themes/mathlib.cpp)0
-rw-r--r--themes/src/mathlib.h (renamed from themes/mathlib.h)0
-rw-r--r--themes/src/types.h (renamed from themes/types.h)0
27 files changed, 42 insertions, 25 deletions
diff --git a/themes/Makefile b/themes/Makefile
index 8bdc04e..bfe42a3 100644
--- a/themes/Makefile
+++ b/themes/Makefile
@@ -1,17 +1,44 @@
-CXX = emcc
-EXE = dist/output.js
-SRCS = $(wildcard *.cpp)
-OBJS = $(patsubst %.cpp,%.o,$(SRCS))
+TARGET_EXEC ?= output.js
+
+BUILD_DIR ?= ./dist
+SRC_DIRS ?= ./src
+
+CC := emcc
+CXX := emcc
+SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
+OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
+DEPS := $(OBJS:.o=.d)
+
+INC_DIRS := $(shell find $(SRC_DIRS) -type d)
+INC_FLAGS := $(addprefix -I,$(INC_DIRS))
LDFLAGS = -s ALLOW_MEMORY_GROWTH=1 -s USE_WEBGL2=1 -s FULL_ES3=1 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s FETCH
-all: build $(EXE)
+CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
+
+$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
+ $(CC) $(OBJS) -o $@ $(LDFLAGS)
+
+# assembly
+$(BUILD_DIR)/%.s.o: %.s
+ $(MKDIR_P) $(dir $@)
+ $(AS) $(ASFLAGS) -c $< -o $@
-$(EXE): $(OBJS)
- echo $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(LDFLAGS)
+# c source
+$(BUILD_DIR)/%.c.o: %.c
+ $(MKDIR_P) $(dir $@)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
-build:
- @mkdir -p dist
+# c++ source
+$(BUILD_DIR)/%.cpp.o: %.cpp
+ $(MKDIR_P) $(dir $@)
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+
+
+.PHONY: clean
clean:
- rm -rf dist && rm *.o \ No newline at end of file
+ $(RM) -r $(BUILD_DIR)
+
+-include $(DEPS)
+
+MKDIR_P ?= mkdir -p
diff --git a/themes/dist/output.wasm b/themes/dist/output.wasm
index 33cd231..02f03e6 100755
--- a/themes/dist/output.wasm
+++ b/themes/dist/output.wasm
Binary files differ
diff --git a/themes/LeafParticleRender.cpp b/themes/src/LeafParticleRender.cpp
index 0c6fbca..0c6fbca 100644
--- a/themes/LeafParticleRender.cpp
+++ b/themes/src/LeafParticleRender.cpp
diff --git a/themes/LeafParticleRender.h b/themes/src/LeafParticleRender.h
index 713d9f6..713d9f6 100644
--- a/themes/LeafParticleRender.h
+++ b/themes/src/LeafParticleRender.h
diff --git a/themes/Logger.cpp b/themes/src/Logger.cpp
index 1068d88..1068d88 100644
--- a/themes/Logger.cpp
+++ b/themes/src/Logger.cpp
diff --git a/themes/Logger.h b/themes/src/Logger.h
index 7596b6f..7596b6f 100644
--- a/themes/Logger.h
+++ b/themes/src/Logger.h
diff --git a/themes/MainLoop.cpp b/themes/src/MainLoop.cpp
index 09aa643..09aa643 100644
--- a/themes/MainLoop.cpp
+++ b/themes/src/MainLoop.cpp
diff --git a/themes/MainLoop.h b/themes/src/MainLoop.h
index 2573bb8..2573bb8 100644
--- a/themes/MainLoop.h
+++ b/themes/src/MainLoop.h
diff --git a/themes/Renderer2d.cpp b/themes/src/Renderer2d.cpp
index c303e83..c303e83 100644
--- a/themes/Renderer2d.cpp
+++ b/themes/src/Renderer2d.cpp
diff --git a/themes/Renderer2d.h b/themes/src/Renderer2d.h
index 909f088..909f088 100644
--- a/themes/Renderer2d.h
+++ b/themes/src/Renderer2d.h
diff --git a/themes/Renderer3d.cpp b/themes/src/Renderer3d.cpp
index 5f9ce88..5f9ce88 100644
--- a/themes/Renderer3d.cpp
+++ b/themes/src/Renderer3d.cpp
diff --git a/themes/Renderer3d.h b/themes/src/Renderer3d.h
index 7e89c93..7e89c93 100644
--- a/themes/Renderer3d.h
+++ b/themes/src/Renderer3d.h
diff --git a/themes/Shader.cpp b/themes/src/Shader.cpp
index 5f2b00e..5f2b00e 100644
--- a/themes/Shader.cpp
+++ b/themes/src/Shader.cpp
diff --git a/themes/Shader.h b/themes/src/Shader.h
index bc81764..bc81764 100644
--- a/themes/Shader.h
+++ b/themes/src/Shader.h
diff --git a/themes/Snowflake.cpp b/themes/src/Snowflake.cpp
index 1cb056a..7cab8b3 100644
--- a/themes/Snowflake.cpp
+++ b/themes/src/Snowflake.cpp
@@ -38,14 +38,13 @@ inline void initFlake(SnowflakeParticleRenderer* renderer, SnowflakeUpdateData*
generateSnowflakeShape(&renderer->vertices, randomIntBetween(4, 16), randomFloatBetween(8.f, 16.f), randomFloatBetween(2.f, 6.f));
ud->numVertices = renderer->vertices.numElements - ud->vtxIdx;
ud->velocity = Vector2(randomFloatBetween(-10, 10), randomFloatBetween(-100, -85));
- ud->position = Vector2(randomFloatBetween(0, renderer->xMax), randomFloatBetween(renderer->yMax, renderer->yMax + 256));
+ ud->position = Vector2(randomFloatBetween(0, renderer->xMax), randomFloatBetween(renderer->yMax, -renderer->yMax));
}
void SnowflakeParticleRenderer::load(SnowflakeLoadParameters params, Renderer2d* renderer) {
- spawnIntervalSeconds = params.spawnIntervalSeconds;
- numSnowflakes = params.maxSnowflakes;
+ numSnowflakes = params.numSnowflakes;
- updateData = new SnowflakeUpdateData[params.maxSnowflakes];
+ updateData = new SnowflakeUpdateData[params.numSnowflakes];
xMax = static_cast<f32>(renderer->context->width);
yMax = static_cast<f32>(renderer->context->height);
@@ -101,11 +100,6 @@ inline void updateFlake(SnowflakeParticleRenderer* renderer, SnowflakeUpdateData
}
void SnowflakeParticleRenderer::update(f32 dtSeconds) {
- timeUntilNextSpawnSeconds -= dtSeconds;
- if (timeUntilNextSpawnSeconds < 0) {
- timeUntilNextSpawnSeconds = spawnIntervalSeconds;
- }
-
bool addWind = false;
timeUntilNextWindSeconds -= dtSeconds;
if (timeUntilNextWindSeconds < 0) {
diff --git a/themes/Snowflake.h b/themes/src/Snowflake.h
index 5ad2670..c6323d6 100644
--- a/themes/Snowflake.h
+++ b/themes/src/Snowflake.h
@@ -6,13 +6,12 @@ struct Renderer2d;
struct Vertex2D;
struct SnowflakeLoadParameters {
- i32 maxSnowflakes = 1000;
+ i32 numSnowflakes = 1000;
f32 rateOfSnowfall = 0.1f;
Vector2 flakeV0 = { 0, 1 };
f32 flakeSize = 5.f;
f32 flakeSizeDeviation = 1.f;
Vector4 snowColor = { 0.8, 0.8, 0.8, 1.0 };
- f32 spawnIntervalSeconds = 0.3;
f32 windIntervalSeconds = 1.5;
};
@@ -30,12 +29,10 @@ struct SnowflakeUpdateData {
struct SnowflakeParticleRenderer {
f32 xMax = 0;
f32 yMax = 0;
- f32 spawnIntervalSeconds = 0.3;
f32 windIntervalSeconds = 1.5;
i32 numSnowflakes = 0;
Vector2 windSpeed;
SnowflakeUpdateData* updateData;
- f32 timeUntilNextSpawnSeconds = 0;
f32 timeUntilNextWindSeconds = 0;
u32 vao;
diff --git a/themes/SummerTheme.cpp b/themes/src/SummerTheme.cpp
index 20bb310..20bb310 100644
--- a/themes/SummerTheme.cpp
+++ b/themes/src/SummerTheme.cpp
diff --git a/themes/SummerTheme.h b/themes/src/SummerTheme.h
index 1d9093a..1d9093a 100644
--- a/themes/SummerTheme.h
+++ b/themes/src/SummerTheme.h
diff --git a/themes/TreeShape.cpp b/themes/src/TreeShape.cpp
index a3ae8f7..a3ae8f7 100644
--- a/themes/TreeShape.cpp
+++ b/themes/src/TreeShape.cpp
diff --git a/themes/TreeShape.h b/themes/src/TreeShape.h
index 32b00d3..32b00d3 100644
--- a/themes/TreeShape.h
+++ b/themes/src/TreeShape.h
diff --git a/themes/WebglContext.cpp b/themes/src/WebglContext.cpp
index df49c2d..df49c2d 100644
--- a/themes/WebglContext.cpp
+++ b/themes/src/WebglContext.cpp
diff --git a/themes/WebglContext.h b/themes/src/WebglContext.h
index 1956092..1956092 100644
--- a/themes/WebglContext.h
+++ b/themes/src/WebglContext.h
diff --git a/themes/list.h b/themes/src/list.h
index 25b236a..25b236a 100644
--- a/themes/list.h
+++ b/themes/src/list.h
diff --git a/themes/main.cpp b/themes/src/main.cpp
index 4e82ca0..f8771d4 100644
--- a/themes/main.cpp
+++ b/themes/src/main.cpp
@@ -258,7 +258,6 @@ void AutumnTheme::unload() {
void WinterTheme::load(Renderer2d* renderer) {
renderer->clearColor = Vector4(200, 229, 239, 255).toNormalizedColor();
SnowflakeLoadParameters lp;
- lp.spawnIntervalSeconds = 0.05;
spr.load(lp, renderer);
}
diff --git a/themes/mathlib.cpp b/themes/src/mathlib.cpp
index 9e86833..9e86833 100644
--- a/themes/mathlib.cpp
+++ b/themes/src/mathlib.cpp
diff --git a/themes/mathlib.h b/themes/src/mathlib.h
index bb62f39..bb62f39 100644
--- a/themes/mathlib.h
+++ b/themes/src/mathlib.h
diff --git a/themes/types.h b/themes/src/types.h
index ae8aa4e..ae8aa4e 100644
--- a/themes/types.h
+++ b/themes/src/types.h