summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--themes/compile_commands.json128
-rwxr-xr-xthemes/compile_commands.sh2
-rwxr-xr-xthemes/dist/output.wasmbin149889 -> 153554 bytes
-rw-r--r--themes/src/autumn/AutumnTheme.cpp41
-rw-r--r--themes/src/autumn/AutumnTheme.hpp4
-rw-r--r--themes/src/autumn/TreeShape.cpp2
-rw-r--r--themes/src/shapes_2d.cpp49
-rw-r--r--themes/src/shapes_2d.h19
8 files changed, 236 insertions, 9 deletions
diff --git a/themes/compile_commands.json b/themes/compile_commands.json
index fe51488..1c3aee5 100644
--- a/themes/compile_commands.json
+++ b/themes/compile_commands.json
@@ -1 +1,127 @@
-[]
+[
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/MainLoop.cpp -o dist/./src/MainLoop.cpp.o",
+ "file": "dist/./src/MainLoop.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/spring/SpringTheme.cpp -o dist/./src/spring/SpringTheme.cpp.o",
+ "file": "dist/./src/spring/SpringTheme.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/spring/GrassRenderer.cpp -o dist/./src/spring/GrassRenderer.cpp.o",
+ "file": "dist/./src/spring/GrassRenderer.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/mathlib.cpp -o dist/./src/mathlib.cpp.o",
+ "file": "dist/./src/mathlib.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shaders/renderer3d_frag.cpp -o dist/./src/shaders/renderer3d_frag.cpp.o",
+ "file": "dist/./src/shaders/renderer3d_frag.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shaders/sun_frag.cpp -o dist/./src/shaders/sun_frag.cpp.o",
+ "file": "dist/./src/shaders/sun_frag.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shaders/renderer3d_vert.cpp -o dist/./src/shaders/renderer3d_vert.cpp.o",
+ "file": "dist/./src/shaders/renderer3d_vert.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shaders/renderer2d_frag.cpp -o dist/./src/shaders/renderer2d_frag.cpp.o",
+ "file": "dist/./src/shaders/renderer2d_frag.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shaders/sun_vert.cpp -o dist/./src/shaders/sun_vert.cpp.o",
+ "file": "dist/./src/shaders/sun_vert.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shaders/renderer2d_vert.cpp -o dist/./src/shaders/renderer2d_vert.cpp.o",
+ "file": "dist/./src/shaders/renderer2d_vert.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shader_fetcher.cpp -o dist/./src/shader_fetcher.cpp.o",
+ "file": "dist/./src/shader_fetcher.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/Logger.cpp -o dist/./src/Logger.cpp.o",
+ "file": "dist/./src/Logger.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/Renderer3d.cpp -o dist/./src/Renderer3d.cpp.o",
+ "file": "dist/./src/Renderer3d.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/Shader.cpp -o dist/./src/Shader.cpp.o",
+ "file": "dist/./src/Shader.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/summer/SummerTheme.cpp -o dist/./src/summer/SummerTheme.cpp.o",
+ "file": "dist/./src/summer/SummerTheme.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/winter/Windfield.cpp -o dist/./src/winter/Windfield.cpp.o",
+ "file": "dist/./src/winter/Windfield.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/winter/WinterTheme.cpp -o dist/./src/winter/WinterTheme.cpp.o",
+ "file": "dist/./src/winter/WinterTheme.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/winter/Snowflake.cpp -o dist/./src/winter/Snowflake.cpp.o",
+ "file": "dist/./src/winter/Snowflake.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/autumn/AutumnTheme.cpp -o dist/./src/autumn/AutumnTheme.cpp.o",
+ "file": "dist/./src/autumn/AutumnTheme.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/autumn/TreeShape.cpp -o dist/./src/autumn/TreeShape.cpp.o",
+ "file": "dist/./src/autumn/TreeShape.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/autumn/LeafParticleRender.cpp -o dist/./src/autumn/LeafParticleRender.cpp.o",
+ "file": "dist/./src/autumn/LeafParticleRender.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/shapes_2d.cpp -o dist/./src/shapes_2d.cpp.o",
+ "file": "dist/./src/shapes_2d.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/Renderer2d.cpp -o dist/./src/Renderer2d.cpp.o",
+ "file": "dist/./src/Renderer2d.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/main.cpp -o dist/./src/main.cpp.o",
+ "file": "dist/./src/main.cpp.o"
+ },
+ {
+ "directory": ".",
+ "command": "emcc -I./src -I./src/spring -I./src/shaders -I./src/tools -I./src/summer -I./src/winter -I./src/autumn -I./src/_shaders -MMD -MP -c src/WebglContext.cpp -o dist/./src/WebglContext.cpp.o",
+ "file": "dist/./src/WebglContext.cpp.o"
+ }
+]
diff --git a/themes/compile_commands.sh b/themes/compile_commands.sh
index 2cb3fed..06ebba0 100755
--- a/themes/compile_commands.sh
+++ b/themes/compile_commands.sh
@@ -1,5 +1,5 @@
make --always-make --dry-run \
- | grep -wE 'gcc|g\+\+|c\+\+' \
+ | grep -wE 'emcc|gcc|g\+\+|c\+\+' \
| grep -w '\-c' \
| jq -nR '[inputs|{directory:".", command:., file: match(" [^ ]+$").string[1:]}]' \
> compile_commands.json
diff --git a/themes/dist/output.wasm b/themes/dist/output.wasm
index 24cbd12..26dfb36 100755
--- a/themes/dist/output.wasm
+++ b/themes/dist/output.wasm
Binary files differ
diff --git a/themes/src/autumn/AutumnTheme.cpp b/themes/src/autumn/AutumnTheme.cpp
index 754a841..affcc00 100644
--- a/themes/src/autumn/AutumnTheme.cpp
+++ b/themes/src/autumn/AutumnTheme.cpp
@@ -3,16 +3,41 @@
#include "../shapes_2d.h"
#include <memory>
+namespace
+{
+ const int NUM_HILLS = 3;
+}
+
void AutumnTheme::load(Renderer2d* renderer) {
renderer->clearColor = Vector4(252, 210, 153, 255).toNormalizedColor();
auto lr = tree.load(renderer);
leafParticles.load(renderer, &lr);
- background = new RectangularGradient(*renderer,
- Vector4{135, 206, 235, 255}.toNormalizedColor(),
- Vector4(252, 210, 153, 255).toNormalizedColor(),
- renderer->get_width(),
- renderer->get_height(),
- {0, 0});
+ background = new RectangularGradient(
+ *renderer,
+ Vector4{135, 206, 235, 255}.toNormalizedColor(),
+ Vector4(252, 210, 153, 255).toNormalizedColor(),
+ renderer->get_width(),
+ renderer->get_height(),
+ {0, 0});
+
+
+ background_hill = new Circleish(
+ *renderer,
+ 1000,
+ Vector4(137, 129, 33, 255).toNormalizedColor(),
+ 100,
+ 0,
+ 50);
+ background_hill->mesh.model = background_hill->mesh.model.translateByVec2({1200, -700});
+
+ tree_hill = new Circleish(
+ *renderer,
+ 500,
+ Vector4{ 76, 75, 22, 255 }.toNormalizedColor(),
+ 100,
+ 0,
+ 50);
+ tree_hill->mesh.model = tree_hill->mesh.model.translateByVec2(Vector2(300, -290));
}
void AutumnTheme::update(f32 dtSeconds) {
@@ -22,7 +47,9 @@ void AutumnTheme::update(f32 dtSeconds) {
void AutumnTheme::render(Renderer2d* renderer) {
background->render();
+ background_hill->render();
tree.render(renderer);
+ tree_hill->render();
leafParticles.render(renderer);
}
@@ -30,4 +57,6 @@ void AutumnTheme::unload() {
tree.unload();
leafParticles.unload();
delete background;
+ delete background_hill;
+ delete tree_hill;
}
diff --git a/themes/src/autumn/AutumnTheme.hpp b/themes/src/autumn/AutumnTheme.hpp
index 7c1f4f2..2d9958c 100644
--- a/themes/src/autumn/AutumnTheme.hpp
+++ b/themes/src/autumn/AutumnTheme.hpp
@@ -5,14 +5,18 @@
#include "LeafParticleRender.h"
#include "../types.h"
#include <memory>
+#include <vector>
struct Renderer2d;
class RectangularGradient;
+class Circleish;
struct AutumnTheme {
TreeShape tree;
LeafParticleRender leafParticles;
RectangularGradient* background;
+ Circleish* tree_hill;
+ Circleish* background_hill;
void load(Renderer2d* renderer);
void update(f32 dtSeconds);
diff --git a/themes/src/autumn/TreeShape.cpp b/themes/src/autumn/TreeShape.cpp
index 9738fd5..7c80929 100644
--- a/themes/src/autumn/TreeShape.cpp
+++ b/themes/src/autumn/TreeShape.cpp
@@ -42,7 +42,7 @@ TreeShapeLoadResult TreeShape::load(Renderer2d* renderer) {
lr.updateData = updateData;
lr.numBranches = numBranches;
i32 branchIndex = 0;
- createBranch(&ld, generationData, numBranches, &branchIndex, 0, ld.trunkWidth, ld.trunkHeight, Vector2 { 300.f, 50.f }, 0, NULL, vertices, &lr);
+ createBranch(&ld, generationData, numBranches, &branchIndex, 0, ld.trunkWidth, ld.trunkHeight, Vector2 { 300.f, 200.f }, 0, NULL, vertices, &lr);
useShader(renderer->shader);
diff --git a/themes/src/shapes_2d.cpp b/themes/src/shapes_2d.cpp
index a85e0da..d5a29ed 100644
--- a/themes/src/shapes_2d.cpp
+++ b/themes/src/shapes_2d.cpp
@@ -1,6 +1,7 @@
#include "shapes_2d.h"
#include "Renderer2d.h"
#include "mathlib.h"
+#include "list.h"
RectangularGradient::RectangularGradient(Renderer2d& renderer,
Vector4 top,
@@ -37,3 +38,51 @@ void RectangularGradient::render()
{
mesh.render(&renderer);
}
+
+
+Circleish::Circleish(
+ Renderer2d& renderer,
+ f32 radius,
+ Vector4 color,
+ i32 segments,
+ i32 segment_start,
+ i32 segment_end)
+ : renderer{renderer}
+{
+ matte::List<Vertex2D> vertices;
+ matte::List<u32> indices;
+ vertices.add({ Vector2(0, 0), color, Mat4x4() });
+
+ if (segment_end == 0)
+ segment_end = segments;
+
+ f32 radiansPerSector = (2.f * PI) / segments;
+ for (i32 i = segment_start; i <= segment_end; i++) {
+ f32 radians = radiansPerSector * i;
+ f32 cosAngle = cosf(radians);
+ f32 sinAngle = sinf(radians);
+ Vector2 vertex = Vector2(radius * cosAngle, radius * sinAngle);
+ vertices.add({ vertex, color, Mat4x4() });
+
+ u32 first = i;
+ u32 second = 0;
+ u32 third = i + 1;
+ indices.add(first);
+ indices.add(second);
+ indices.add(third);
+ }
+
+ mesh.load(&vertices.data[0], vertices.numElements, &indices.data[0], indices.numElements, &renderer);
+ vertices.deallocate();
+ indices.deallocate();
+}
+
+Circleish::~Circleish()
+{
+ mesh.unload();
+}
+
+void Circleish::render()
+{
+ mesh.render(&renderer);
+}
diff --git a/themes/src/shapes_2d.h b/themes/src/shapes_2d.h
index acb8522..8e08504 100644
--- a/themes/src/shapes_2d.h
+++ b/themes/src/shapes_2d.h
@@ -26,4 +26,23 @@ class RectangularGradient
Mesh2D mesh;
};
+
+/// Supports full and partial circles
+class Circleish
+{
+public:
+ Circleish(
+ Renderer2d& renderer,
+ f32 radius,
+ Vector4 color,
+ i32 segments,
+ i32 segment_start = 0,
+ i32 segment_end = 0);
+ ~Circleish();
+ void render();
+
+ Renderer2d& renderer;
+ Mesh2D mesh;
+};
+
#endif