summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Assets.cpp44
-rw-r--r--src/Assets.hpp32
-rw-r--r--src/meson.build41
3 files changed, 71 insertions, 46 deletions
diff --git a/src/Assets.cpp b/src/Assets.cpp
index dc2495e..7cf361c 100644
--- a/src/Assets.cpp
+++ b/src/Assets.cpp
@@ -1,41 +1,19 @@
#include "Assets.hpp"
-namespace MC::Assets {
-
-Char const* Shaders::terrain::vertex =
-#include "../assets/generated/shaders/terrain.vert.glsl.include"
-;
-
-Char const* Shaders::terrain::fragment =
-#include "../assets/generated/shaders/terrain.frag.glsl.include"
-;
-
-Char const* Shaders::clouds::vertex =
-#include "../assets/generated/shaders/clouds.vert.glsl.include"
-;
+#define ASSET(ns, name, raw_name) \
+ namespace ns { Char const* name = ::MC::Assets::Files::raw_name; }
-Char const* Shaders::clouds::fragment =
-#include "../assets/generated/shaders/clouds.frag.glsl.include"
-;
+#define SHADER_ASSET(name) \
+ ASSET(Shaders::name, vertex, shaders_##name##_vertex) \
+ ASSET(Shaders::name, fragment, shaders_##name##_fragment)
-Char const* Shaders::image_viewer::vertex =
-#include "../assets/generated/shaders/image_viewer.vert.glsl.include"
-;
-
-Char const* Shaders::image_viewer::fragment =
-#include "../assets/generated/shaders/image_viewer.frag.glsl.include"
-;
-
-Char const* Shaders::block_outline::vertex =
-#include "../assets/generated/shaders/block_outline.vert.glsl.include"
-;
+namespace MC::Assets {
-Char const* Shaders::block_outline::fragment =
-#include "../assets/generated/shaders/block_outline.frag.glsl.include"
-;
+SHADER_ASSET(terrain)
+SHADER_ASSET(clouds)
+SHADER_ASSET(block_outline)
+SHADER_ASSET(image_viewer)
-Char const* Images::atlas =
-#include "../assets/generated/images/atlas.ppm.include"
-;
+ASSET(Images, atlas, images_atlas_ppm)
} \ No newline at end of file
diff --git a/src/Assets.hpp b/src/Assets.hpp
index f4b2f46..0de6d90 100644
--- a/src/Assets.hpp
+++ b/src/Assets.hpp
@@ -2,23 +2,29 @@
#include "Common/Sizes.hpp"
-namespace MC::Assets {
-
-namespace Shaders {
-
-#define MC_ASSETS_SHADER(name) namespace name { extern Char const* vertex; extern Char const* fragment; }
+#define MC_DECLARE_ASSET(ns, name, raw_name) \
+ namespace Files { extern char const* raw_name; } \
+ namespace ns { extern Char const* name; }
-MC_ASSETS_SHADER(terrain)
-MC_ASSETS_SHADER(clouds)
-MC_ASSETS_SHADER(block_outline)
-MC_ASSETS_SHADER(image_viewer)
+#define MC_DECLARE_SHADER_ASSET(name) \
+ MC_DECLARE_ASSET(Shaders::name, vertex, shaders_##name##_vertex) \
+ MC_DECLARE_ASSET(Shaders::name, fragment, shaders_##name##_fragment)
-}
+namespace MC::Assets {
-namespace Images {
+MC_DECLARE_SHADER_ASSET(terrain)
+MC_DECLARE_SHADER_ASSET(clouds)
+MC_DECLARE_SHADER_ASSET(block_outline)
+MC_DECLARE_SHADER_ASSET(image_viewer)
-extern Char const* atlas;
+MC_DECLARE_ASSET(Images, atlas, images_atlas_ppm)
}
-} \ No newline at end of file
+// NOTE: We need to declare dependencies both in Assets.cpp and and here
+// in Assets.hpp but only because we rename the variable name from it's
+// file name to a more readable name. If we didn't do that we could just
+// declare the variable in the hpp file, without needing another compilation
+// unit at all.
+// This would work easily if there was a using x = y; directive that didn't
+// just work for types but for variables as well. But there isn't, I think.. :( \ No newline at end of file
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..9a33eed
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,41 @@
+source_files = files([
+ 'main.cpp',
+ 'Game.cpp',
+ 'Render.cpp',
+ 'Input.cpp',
+ 'Time.cpp',
+ 'Transform.cpp',
+ 'Assets.cpp',
+
+ 'Math/AABB.cpp',
+ 'Math/Grid.cpp',
+ 'Math/Interpolation.cpp',
+ 'Math/Perlin.cpp',
+ 'Math/Random.cpp',
+
+ 'Util/ImageViewer.cpp',
+
+ 'GFX/Camera.cpp',
+ 'GFX/Mesh.cpp',
+ 'GFX/Resources.cpp',
+ 'GFX/Texture.cpp',
+ 'GFX/Window.cpp',
+ 'GFX/Util/Primitives.cpp',
+ 'GFX/Image/PPMParser.cpp',
+ 'GFX/Image/RawImage.cpp',
+ 'GFX/Shading/Shader.cpp',
+ 'GFX/Shading/Program.cpp',
+ 'GFX/Shading/Uniform.cpp',
+
+ 'World/World.cpp',
+ 'World/Chunk.cpp',
+ 'World/ChunkRegistry.cpp',
+ 'World/Clouds.cpp',
+ 'World/Generation/Generator.cpp',
+ 'World/Generation/Lighting.cpp',
+ 'World/Generation/Decoration.cpp',
+ 'World/Generation/ChunkNeighbors.cpp',
+ 'World/Generation/ChunkMeshing.cpp',
+
+ 'Entities/Player.cpp',
+]) \ No newline at end of file