From f7d79bd4e21c9a6210c2256fe0f6e560127236c1 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Thu, 15 Oct 2020 14:12:39 -0400 Subject: cleanup build --- src/engine.cc | 11 ++++++++--- src/engine.h | 14 ++++++++++---- src/mauri.cc | 16 +++++++++++----- src/objects/effect.cc | 7 ++++--- src/objects/object.cc | 13 ++++++++----- src/objects/pass.cc | 1 - src/shader.cc | 8 ++++++-- src/visualizer.cc | 1 - 8 files changed, 47 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/engine.cc b/src/engine.cc index b744f8d..98de4aa 100644 --- a/src/engine.cc +++ b/src/engine.cc @@ -3,13 +3,12 @@ #include "context.h" #include "json.h" #include "shader.h" -#include "src/gl.h" +#include "gl.h" #include "texture.h" #include "framebuffer.h" #include "objects/object.h" #include "objects/scene.h" -#include "visualizer.h" #include #include @@ -77,10 +76,14 @@ Engine::Engine(Scene *scene, Context *context, Parser *parser, bool audio) scene->load(this); +#ifdef BUILD_AUDIO if (audio_enabled) { visualizer = new Visualizer(); } +#else + audio_enabled = false; +#endif } Framebuffer *Engine::get_framebuffer(const std::string &name) @@ -106,7 +109,7 @@ Texture *Engine::get_framebuffer_texture(const std::string &name) return nullptr; } -void Engine::create_framebuffer(std::string name, f32 width, f32 height, f32 scale) +void Engine::create_framebuffer(const std::string &name, f32 width, f32 height, f32 scale) { framebuffers.emplace_back(new Framebuffer(name, width, height, scale)); } @@ -197,5 +200,7 @@ Engine::~Engine() delete default_object; delete minimal_shader; +#ifdef BUILD_AUDIO delete visualizer; +#endif } diff --git a/src/engine.h b/src/engine.h index 8dc5093..e46e5a2 100644 --- a/src/engine.h +++ b/src/engine.h @@ -8,7 +8,10 @@ #include "shader.h" #include "texture.h" #include "framebuffer.h" + +#ifdef BUILD_AUDIO #include "visualizer.h" +#endif using namespace glm; @@ -43,18 +46,21 @@ struct View class Engine { public: - Engine(Scene *scene, Context *context, Parser *parser, bool visualizer); + Engine(Scene *scene, Context *context, Parser *parser, bool audio); ~Engine(); + View view; + Scene *scene; Parser *parser; Context *context; +#ifdef BUILD_AUDIO Visualizer *visualizer; - bool audio_enabled; +#endif - View view; + bool audio_enabled; f32 time; @@ -69,7 +75,7 @@ class Engine std::vector framebuffers; - void create_framebuffer(std::string name, f32 width, f32 height, f32 scale); + void create_framebuffer(const std::string &name, f32 width, f32 height, f32 scale); Framebuffer *get_framebuffer(const std::string &name); Texture *get_framebuffer_texture(const std::string &name); diff --git a/src/mauri.cc b/src/mauri.cc index f1493e4..83b7655 100644 --- a/src/mauri.cc +++ b/src/mauri.cc @@ -3,12 +3,17 @@ #include "gl.h" #include "json.h" #include "util.h" -#include "visualizer.h" #include "context.h" +#include "context_null.h" + +#ifdef BUILD_GLFW #include "context_glfw.h" +#endif + +#ifdef BUILD_X11 #include "context_x11.h" -#include "context_null.h" +#endif #include "objects/scene.h" @@ -18,17 +23,18 @@ using namespace Mauri; static std::string scene_path = "scene.json"; - s32 main(s32 argc, char *argv[]) { srand(time(NULL)); +#ifdef BUILD_AUDIO gst_init(&argc, &argv); +#endif //Context *context = new ContextX11(2560, 1440, "mauri", true); //Context *context = new ContextGLFW(720, 1280, "mauri", false); - Context *context = new ContextGLFW(1280, 720, "mauri", false); - //Context *context = new ContextX11(1920, 1080, "mauri", false); + //Context *context = new ContextGLFW(1280, 720, "mauri", false); + Context *context = new ContextX11(1920, 1080, "mauri", false); //Context *context = new ContextNull(1920, 1080, "mauri", false); if (argc == 2) diff --git a/src/objects/effect.cc b/src/objects/effect.cc index 1ab5a96..6fbf71b 100644 --- a/src/objects/effect.cc +++ b/src/objects/effect.cc @@ -4,14 +4,12 @@ #include "../log.h" #include "effect.h" -#include "fmt/core.h" #include "object.h" #include "objects/pass.h" #include -#include #include using namespace Mauri; @@ -47,7 +45,10 @@ Effect::Effect(Parser &p, json &root) void Effect::load(Engine *engine, Object *object, bool last) { - buffer_id = fmt::format("_{}_{}", object->id, id); + std::stringstream _buffer_id; + _buffer_id << "_" << object->id << "_" << id; + + buffer_id = _buffer_id.str(); for (auto &fbo : fbos) { diff --git a/src/objects/object.cc b/src/objects/object.cc index 1ed2053..8613b2a 100644 --- a/src/objects/object.cc +++ b/src/objects/object.cc @@ -6,13 +6,10 @@ #include #include -#include - #include "../gl.h" #include "../json.h" #include "../log.h" -#include "fmt/format.h" #include "objects/effect.h" #include "objects/model.h" #include "objects/object.h" @@ -117,8 +114,14 @@ void Object::load(Engine *engine) origin[1] = size[1] / 2.f; } - buffer_a = fmt::format("_rt_imageLayerComposite_{}_a", id); - buffer_b = fmt::format("_rt_imageLayerComposite_{}_b", id); + + std::stringstream _buffer_a, _buffer_b; + + _buffer_a << "_rt_imageLayerComposite_" << id << "_a"; + _buffer_b << "_rt_imageLayerComposite_" << id << "_b"; + + buffer_a = _buffer_a.str(); + buffer_b = _buffer_b.str(); engine->create_framebuffer(buffer_a, size[0], size[1], 1.f); engine->create_framebuffer(buffer_b, size[0], size[1], 1.f); diff --git a/src/objects/pass.cc b/src/objects/pass.cc index 689dda4..04eb8e3 100644 --- a/src/objects/pass.cc +++ b/src/objects/pass.cc @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/src/shader.cc b/src/shader.cc index a524a2c..c0df777 100644 --- a/src/shader.cc +++ b/src/shader.cc @@ -3,7 +3,7 @@ #include #include -#include +#include #include "assets.h" #include "gl.h" @@ -151,7 +151,9 @@ void Shader::build_shader_source(Parser *p, const std::string &isource, std::str std::string Combo::to_string() { - return fmt::format("#define {} {}\n", name, value); + std::stringstream _combo; + _combo << "#define " << name << " " << value << "\n"; + return _combo.str(); } void Shader::compile() @@ -226,6 +228,7 @@ void Shader::bind(Engine *engine, mat4x4 *model) rshader->set_uniform("g_ModelViewProjectionMatrix", TYPE_MAT4, glm::value_ptr(_model)); rshader->set_uniform("g_ModelViewProjectionMatrixInverse", TYPE_MAT4, glm::value_ptr(_inverse)); +#ifdef BUILD_AUDIO if (engine->audio_enabled) { g_mutex_lock(&engine->visualizer->mutex); @@ -241,6 +244,7 @@ void Shader::bind(Engine *engine, mat4x4 *model) g_mutex_unlock(&engine->visualizer->mutex); } +#endif } Shader::~Shader() diff --git a/src/visualizer.cc b/src/visualizer.cc index 349478b..a76c613 100644 --- a/src/visualizer.cc +++ b/src/visualizer.cc @@ -6,7 +6,6 @@ #include #include "assets.h" -#include "fmt/format.h" #include "gst/gstcaps.h" #include "gst/gstelement.h" #include "gst/gstmemory.h" -- cgit v1.2.3-101-g0448