summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO5
-rw-r--r--meson_options.txt2
-rwxr-xr-xrandom.sh4
-rw-r--r--src/assets.cc9
-rw-r--r--src/context.cc2
-rw-r--r--src/context_null.h1
-rw-r--r--src/context_x11.cc4
-rw-r--r--src/mauri.cc9
-rw-r--r--src/objects/effect.cc2
-rw-r--r--src/objects/material.cc2
-rw-r--r--src/objects/object.c1
-rw-r--r--src/objects/object.cc4
-rw-r--r--src/objects/object.h3
-rw-r--r--src/objects/pass.cc31
-rw-r--r--src/objects/pass.h3
-rw-r--r--src/shader.cc18
-rw-r--r--src/shader.h2
-rw-r--r--src/texture.cc7
-rw-r--r--src/visualizer.cc6
19 files changed, 74 insertions, 41 deletions
diff --git a/TODO b/TODO
index e058572..d8ebe24 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,8 @@
+decent looking:
+ - 1574428821
+ - 1457581889
+ - 2086821449
+
[ ] start commiting in a more structured way
- most of the bulk work is done so this will make things easier going forward
diff --git a/meson_options.txt b/meson_options.txt
index 9769862..af1d055 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1 +1 @@
-option('audio', type: 'boolean', value: true)
+option('audio', type: 'boolean', value: false)
diff --git a/random.sh b/random.sh
index cbe9cc3..ee99da7 100755
--- a/random.sh
+++ b/random.sh
@@ -2,8 +2,8 @@
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-WALLPAPERS_PATH=../../c/workshop_wallpapers
-BUILD_DIR=build-release
+WALLPAPERS_PATH=workshop_wallpapers
+BUILD_DIR=build
export mesa_glthread=true
diff --git a/src/assets.cc b/src/assets.cc
index 7251ceb..60199e2 100644
--- a/src/assets.cc
+++ b/src/assets.cc
@@ -29,8 +29,8 @@ Asset::Asset()
size = 0;
pos = 0;
data = nullptr;
- lasset = nullptr;
ltype = NONE;
+ lasset = nullptr;
}
static Asset asset_void = Asset();
@@ -42,8 +42,8 @@ Asset::Asset(const std::string &path, byte *begin, byte *end)
size = end - begin;
pos = 0;
data = begin;
- lasset = nullptr;
ltype = NONE;
+ lasset = nullptr;
}
Asset::Asset(const std::string &path)
@@ -74,8 +74,8 @@ Asset::Asset(const std::string &path)
pos = 0;
type = ASSET_FILE;
- lasset = nullptr;
ltype = NONE;
+ lasset = nullptr;
}
Asset::~Asset()
@@ -235,7 +235,8 @@ Asset *AssetManager::get_file(const std::string &part, FileTypeHint hint)
void AssetManager::write_files(const std::string &output_path)
{
- std::cout << std::filesystem::create_directories(output_path) << "\n";
+ if (!std::filesystem::create_directories(output_path))
+ return;
for (auto &asset : files)
{
diff --git a/src/context.cc b/src/context.cc
index 9f20b54..3f7f299 100644
--- a/src/context.cc
+++ b/src/context.cc
@@ -21,7 +21,7 @@ void set_context(Context *c)
_context = c;
}
-} // namespace Mauri
+}
using namespace Mauri;
diff --git a/src/context_null.h b/src/context_null.h
index 80a7593..f6ecdb1 100644
--- a/src/context_null.h
+++ b/src/context_null.h
@@ -5,6 +5,7 @@
namespace Mauri
{
+
class ContextNull : public Context
{
public:
diff --git a/src/context_x11.cc b/src/context_x11.cc
index 3108b8c..3e0b118 100644
--- a/src/context_x11.cc
+++ b/src/context_x11.cc
@@ -191,8 +191,8 @@ ContextX11::ContextX11(int width, int height, const std::string &name, bool wall
XSetWMProtocols(x11_d, window, &ATOM_WM_DELETE_WINDOW, 1);
- //XMoveWindow(x11_d, window, 1080, 0);
- XMoveWindow(x11_d, window, 0, 0);
+ XMoveWindow(x11_d, window, 1080, 0);
+ //XMoveWindow(x11_d, window, 0, 0);
XMapWindow(x11_d, window);
XFlush(x11_d);
diff --git a/src/mauri.cc b/src/mauri.cc
index 04934c8..23a393e 100644
--- a/src/mauri.cc
+++ b/src/mauri.cc
@@ -32,7 +32,8 @@ s32 main(s32 argc, char *argv[])
gst_init(&argc, &argv);
#endif
- set_context(new ContextGLFW(1920, 1080, "mauri", false));
+ set_context(new ContextGLFW(1600, 900, "mauri", false));
+ //set_context(new ContextX11(2560, 1440, "mauri", true));
//set_context(new ContextNull(1920, 1080, "mauri", false));
if (argc == 2)
@@ -43,16 +44,16 @@ s32 main(s32 argc, char *argv[])
return 1;
}
+ //asset_manager()->write_files("./output");
+
Parser parser;
Scene *scene = new Scene(parser, scene_path);
- //context->resize_window(scene->width / 2.f, scene->height / 2.f);
+ //context()->resize_window(scene->width, scene->height);
Engine engine(scene, &parser, true);
- //asset_manager()->write_files("./output");
-
engine.run();
delete scene;
diff --git a/src/objects/effect.cc b/src/objects/effect.cc
index 283d764..8e61964 100644
--- a/src/objects/effect.cc
+++ b/src/objects/effect.cc
@@ -59,6 +59,8 @@ void Effect::load(Engine *engine, Object *object, bool last)
{
Pass pass;
+ pass.intermidiate = false;
+
pass.object = object;
pass.effect = this;
diff --git a/src/objects/material.cc b/src/objects/material.cc
index 8b6f493..aae5940 100644
--- a/src/objects/material.cc
+++ b/src/objects/material.cc
@@ -39,6 +39,8 @@ void Material::load(Engine *engine, Object *object, MaterialType type, Pass *pas
case MATERIAL_MODEL:
Pass _pass;
+ _pass.intermidiate = false;
+
_pass.object = object;
_pass.effect = nullptr;
diff --git a/src/objects/object.c b/src/objects/object.c
deleted file mode 100644
index b498fd4..0000000
--- a/src/objects/object.c
+++ /dev/null
@@ -1 +0,0 @@
-/
diff --git a/src/objects/object.cc b/src/objects/object.cc
index d7d7aaa..bc744d1 100644
--- a/src/objects/object.cc
+++ b/src/objects/object.cc
@@ -253,9 +253,11 @@ Object::~Object()
if (image != nullptr)
delete image;
- delete gl_object;
delete gl_uv_object;
+ delete gl_object;
+ delete gl_object_flipped;
+
for (auto &pass : passes)
{
delete pass;
diff --git a/src/objects/object.h b/src/objects/object.h
index 3250b31..eb8ad5a 100644
--- a/src/objects/object.h
+++ b/src/objects/object.h
@@ -76,9 +76,10 @@ class Object
void update(Engine *engine);
void draw(Engine *engine);
+ vec3 origin;
+
private:
vec3 angles;
- vec3 origin;
vec3 scale;
std::string buffer_a;
diff --git a/src/objects/pass.cc b/src/objects/pass.cc
index f3a3509..e938823 100644
--- a/src/objects/pass.cc
+++ b/src/objects/pass.cc
@@ -30,9 +30,7 @@ Pass::Pass(Parser &p, json &root, PassStage stage)
for (auto &value : _uniforms.items())
{
- uniforms.emplace_back(
- new UniformOverride({vec4(0.f), value.key()})
- );
+ uniforms.emplace_back(new UniformOverride({vec4(0.f), value.key()}));
p.get_value<vec4>(_uniforms, value.key(), &uniforms.back()->value, vec4(0.f));
}
@@ -42,25 +40,30 @@ Pass::Pass(Parser &p, json &root, PassStage stage)
auto _material = root["material"];
if (_material.is_string())
+ {
material = new Material(p, _material);
+ }
auto _command = root["command"];
- if (_command.is_string())
+ if (_command.is_string() && _command == "copy")
{
- if (_command == "copy")
- command = COPY;
+ command = COPY;
}
auto _target = root["target"];
if (_target.is_string())
+ {
target = _target;
+ }
auto _source = root["source"];
if (_source.is_string())
+ {
source = _source;
+ }
binds[0] = "previous";
@@ -97,6 +100,8 @@ Pass::Pass(Parser &p, json &root, PassStage stage)
void Pass::load(Engine *engine, PassStage stage, Pass *pass)
{
+ intermidiate = true;
+
for (int i = 0; i < MAX_TEXTURES; i++)
{
if (textures[i].empty())
@@ -156,11 +161,13 @@ Pass::~Pass()
if (material != nullptr)
delete material;
- // TODO: refcounted?
- //for (auto &uniform : uniforms)
- //{
- // delete uniform;
- //}
+ if (intermidiate)
+ {
+ for (auto &uniform : uniforms)
+ {
+ delete uniform;
+ }
+ }
}
RenderPass::RenderPass(Engine *engine, Pass *pass)
@@ -208,8 +215,6 @@ RenderPass::RenderPass(Engine *engine, Pass *pass)
continue;
}
- texture_types[i] = STATIC;
-
// Check if texture is referencing a framebuffer.
textures[i] = engine->get_framebuffer_texture(pass->textures[i]);
diff --git a/src/objects/pass.h b/src/objects/pass.h
index cf31ca8..c8d8d0e 100644
--- a/src/objects/pass.h
+++ b/src/objects/pass.h
@@ -67,6 +67,7 @@ class Pass
std::array<std::string, MAX_TEXTURES> binds = {""};
bool combine;
+ bool intermidiate;
std::vector<UniformOverride *> uniforms;
std::vector<Combo> combos;
@@ -88,7 +89,7 @@ class RenderPass
Shader *shader = nullptr;
std::array<Texture *, MAX_TEXTURES> textures = {0};
- std::array<TextureType, MAX_TEXTURES> texture_types;
+ std::array<TextureType, MAX_TEXTURES> texture_types = {STATIC};
void draw(Engine *engine);
diff --git a/src/shader.cc b/src/shader.cc
index 0199897..ae8032a 100644
--- a/src/shader.cc
+++ b/src/shader.cc
@@ -19,6 +19,7 @@ static const char *gl_compat = \
"#define mediump\n"
"#define lowp\n"
"#define mul(x, y) (y * x)\n"
+ "#define max(x, y) max(y, x)\n"
"#define frac fract\n"
"#define CAST2(x) (vec2(x))\n"
"#define CAST3(x) (vec3(x))\n"
@@ -196,7 +197,9 @@ Shader::Shader(Parser *p, const std::string &name)
auto fs_asset = asset_manager()->get_file(name, FRAGMENT_SHADER);
if (vs_asset->type != ASSET_VOID)
+ {
build_shader_source(p, vs_asset->as_string(), vs_source, true);
+ }
else
{
log_error("failed to load shader file (%s)", name.c_str());
@@ -204,7 +207,9 @@ Shader::Shader(Parser *p, const std::string &name)
}
if (fs_asset->type != ASSET_VOID)
+ {
build_shader_source(p, fs_asset->as_string(), fs_source, true);
+ }
else
{
log_error("failed to load shader file (%s)", name.c_str());
@@ -222,10 +227,10 @@ void Shader::bind(Engine *engine, Object *object, mat4x4 *model, std::array<Text
continue;
#if UNIFORM_DEBUG
std::cout << uniform->uname << "(" << uniform->type << ")" << " "
- << (*uniform->value)[0] << " " << (*uniform->value)[1]
- << " " << (*uniform->value)[2] << " " << (*uniform->value)[3] << "\n";
+ << (*uniform->value)[0] << " " << (*uniform->value)[1] << " "
+ << (*uniform->value)[2] << " " << (*uniform->value)[3] << "\n";
#endif
- if (uniform->value != nullptr)
+ if (uniform->value != nullptr && uniform->type != TYPE_MAT4)
rshader->set_uniform(uniform->uname, uniform->type, glm::value_ptr(*uniform->value));
}
@@ -259,7 +264,12 @@ void Shader::bind(Engine *engine, Object *object, mat4x4 *model, std::array<Text
rshader->set_uniform("g_TexelSize", TYPE_VEC2, glm::value_ptr(engine->view.texel_size));
rshader->set_uniform("g_TexelSizeHalf", TYPE_VEC2, glm::value_ptr(engine->view.texel_half_size));
- rshader->set_uniform("g_PointerPosition", TYPE_VEC2, glm::value_ptr(engine->view.cursor_pos));
+ if (object) {
+ glm::vec2 cursor_pos = engine->view.cursor_pos;
+ rshader->set_uniform("g_PointerPosition", TYPE_VEC2, glm::value_ptr(cursor_pos));
+ } else {
+ rshader->set_uniform("g_PointerPosition", TYPE_VEC2, glm::value_ptr(engine->view.cursor_pos));
+ }
mat4x4 _model, _inverse;
diff --git a/src/shader.h b/src/shader.h
index f805952..e3519ff 100644
--- a/src/shader.h
+++ b/src/shader.h
@@ -20,7 +20,7 @@ struct Uniform
std::string uname;
UniformType type;
vec4 *value = nullptr;
- vec4 default_value;
+ vec4 default_value = vec4(0.f);
};
struct Combo
diff --git a/src/texture.cc b/src/texture.cc
index 36bd1d2..96a541b 100644
--- a/src/texture.cc
+++ b/src/texture.cc
@@ -1,4 +1,3 @@
-#include <type_traits>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
@@ -71,7 +70,7 @@ Texture::Texture(Asset *asset)
else
{
version = UNKNOWN;
- log_error("%s", "unknown texture version");
+ log_error("unknown texture version (%s)", asset->path.c_str());
}
textures.resize(image_count);
@@ -219,7 +218,7 @@ void Texture::save_to_file(const std::string &filename)
void Texture::update(f32 time)
{
- if (!is_gif || wrapped)
+ if (wrapped || !is_gif)
return;
if (time >= gif_update)
@@ -251,7 +250,9 @@ void Texture::update(f32 time)
Texture::~Texture()
{
if (!wrapped)
+ {
delete texture;
+ }
}
void Texture::bind(s32 index)
diff --git a/src/visualizer.cc b/src/visualizer.cc
index e4da2bf..a374cf2 100644
--- a/src/visualizer.cc
+++ b/src/visualizer.cc
@@ -13,6 +13,7 @@
#include "gst/gstsample.h"
#include "gst/gststructure.h"
#include "gst/gstutils.h"
+
#include "log.h"
#include "objects/material.h"
#include "visualizer.h"
@@ -23,7 +24,8 @@ static const float gausian_array[] = {.242, .399, .242};
void Visualizer::calc_cutoff()
{
- f64 freqconst = std::log10(low_freq_cap / (f64)high_freq_cap) / ((1.0 / (BAR_COUNT + 1.0)) - 1.0);
+ f64 freqconst = std::log10(low_freq_cap / (f64)high_freq_cap) /
+ ((1.0 / (BAR_COUNT + 1.0)) - 1.0);
for (s32 i = 0; i <= BAR_COUNT; ++i)
{
@@ -226,7 +228,7 @@ static void *main_thread(void *data)
switch (msg->type)
{
case GST_MESSAGE_ERROR:
- log_error("%s", "gstreamer pipeline died, audio wont work");
+ log_error("%s", "gstreamer pipeline died, audio won't work");
break;
default:
break;