From f1a9751af6cc6aa0bac91e7f28fc43b1a4cb64fd Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sat, 15 Jul 2023 01:16:04 -0400 Subject: cleanup, finalize notes, add README.md --- NOTES | 46 ++++++++++++++++++++++++++++++++ README.md | 1 + TODO | 70 ------------------------------------------------- attic/line_count.sh | 2 ++ attic/random.sh | 30 +++++++++++++++++++++ meson.build | 19 +++++--------- scripts/line_count.sh | 2 -- scripts/random.sh | 32 ---------------------- src/assets.cc | 4 +-- src/context.cc | 1 - src/context.h | 2 +- src/context_glfw.cc | 4 --- src/context_glfw.h | 1 - src/context_x11.cc | 4 --- src/context_x11.h | 6 ++--- src/engine.cc | 1 + src/engine.h | 5 +--- src/framebuffer.h | 2 +- src/gl.cc | 5 +--- src/gl.h | 2 ++ src/mauri.cc | 49 ++++++++++++++-------------------- src/objects/effect.cc | 8 +----- src/objects/effect.h | 1 + src/objects/material.cc | 8 +----- src/objects/model.cc | 6 ----- src/objects/model.h | 3 --- src/objects/object.cc | 10 ++----- src/objects/object.h | 2 -- src/objects/pass.cc | 9 ------- src/objects/pass.h | 7 ----- src/objects/scene.cc | 6 ----- src/objects/scene.h | 4 --- src/shader.cc | 4 --- src/shader.h | 3 +-- src/texture.cc | 6 ----- src/texture.h | 2 +- src/util.h | 2 ++ src/visualizer.cc | 3 --- 38 files changed, 124 insertions(+), 248 deletions(-) create mode 100644 NOTES create mode 100644 README.md delete mode 100644 TODO create mode 100755 attic/line_count.sh create mode 100755 attic/random.sh delete mode 100755 scripts/line_count.sh delete mode 100755 scripts/random.sh diff --git a/NOTES b/NOTES new file mode 100644 index 0000000..227110d --- /dev/null +++ b/NOTES @@ -0,0 +1,46 @@ +I haven't touched the actual wallpaper engine implementation of this project in years... +if I had the motivation to continue working on a project like this, I would probably +start from scratch. I could have made much better use of available reverse engineering +tools (mainly renderdoc) to avoid the tons of trial and error that produced the convoluted +logic contained in this code. + +TODO: +[ ] make gl_enabled toggleable in code (i.e. toggleable at runtime) +[ ] objects with blendmode other than 0 have extra pass using blendpassthrough shader +[ ] more acurate visualizer + +Not Implemented: +[ ] mouse paralax +[ ] camera shake +[ ] particles +[ ] javascript scripting +And much, much more... + +Known Issues: +./mauri ../../../c/workshop_wallpapers/1703298496/scene.pkg + - xray only works in the middle + +./mauri ../../../c/workshop_wallpapers/2212570435/scene.pkg + - eyes not positioned correctly + +./mauri ../../../c/workshop_wallpapers/1829251189/scene.pkg + - xray is flipped/flickering + +./mauri ../../../c/workshop_wallpapers/2216609166/scene.pkg + - left side not drawing? + +./mauri ../../../c/workshop_wallpapers/2178257725/scene.pkg + - rotate breaks it + +./mauri ../../../c/workshop_wallpapers/1938288759/scene.pkg + - visualizer not drawn correctly + +./mauri ../../../c/workshop_wallpapers/2157658616/scene.pkg + - parse error + +./mauri ../../../c/workshop_wallpapers/1778616550/scene.pkg + - first object has different blendmode, so we need to handle "combine" passes differently. + The final pass should draw to the objects framebuffer as well as to the combine buffer, + but using the "passthroughblend" shader. + +And many others that either crash or are completely broken. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c63ea70 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# marui: Wallpaper Engine Implementation (for Linux) diff --git a/TODO b/TODO deleted file mode 100644 index 7a2aa97..0000000 --- a/TODO +++ /dev/null @@ -1,70 +0,0 @@ -decent looking: - - 1574428821 - - 1457581889 - - 2086821449 - -[ ] make gl_enabled toggleable in code (i.e. toggleable at runtime) - -[ ] cleanup pass on non-objects (asset, texture, shader, etc) - -[ ] objects with blendmode other than 0 have extra pass using blendpassthrough shader - -[ ] really analyze the structue of a pass/object and try to simplify the code - - verify if the model/robject order is correct (renderdoc) - -[ ] more acurate visualizer - -[x] gifs - - https://github.com/notscuffed/repkg/blob/master/RePKG.Application/Texture/TexFrameInfoContainerReader.cs - - still kinda broken tho... - -Broken: -[ ] ./mauri ../../../c/workshop_wallpapers/1703298496/scene.pkg - - xray only works in the middle - -[X] ./mauri ../../../c/workshop_wallpapers/2048972911/scene.pkg - - black background - -[ ] ./mauri ../../../c/workshop_wallpapers/2212570435/scene.pkg - - eyes not positioned correctly - -[ ] ./mauri ../../../c/workshop_wallpapers/1829251189/scene.pkg - - xray is flipped/flickering - -[ ] ./mauri ../../../c/workshop_wallpapers/2216609166/scene.pkg - - left side not draw? - -[ ] ./mauri ../../../c/workshop_wallpapers/2178257725/scene.pkg - - rotate breaks it - -[ ] ./mauri ../../../c/workshop_wallpapers/1938288759/scene.pkg - - visualizer not drawn correctly - -[ ] ./mauri ../../../c/workshop_wallpapers/2157658616/scene.pkg - - parse error - -[ ] ./mauri ../../../c/workshop_wallpapers/1778616550/scene.pkg - - first object has different blendmode, so we need to handle "combine" passes differently. - The final pass should draw to the objects framebuffer as well as to the combine buffer, - but using the "passthroughblend" shader. - -[X] ./mauri ../../../c/workshop_wallpapers/2008251577/scene.pkg - - effect doesnt draw correctly - - It was because of incorrect GL_TEXTURE_WRAP - - should analyze this in renderdoc - -[X] if version 2 is defined as a combo, g_Alpha and g_Color need to be set from the object - visible should be a draw time check not handled when parsing - -[ ] mouse paralax -[ ] camera shake - -// long term - -[ ] separate gui and engine in mauri - - engine should be a shared library - - there should be a cli interface along with gui - -[ ] javascript scripting - -[ ] particles diff --git a/attic/line_count.sh b/attic/line_count.sh new file mode 100755 index 0000000..dbc74af --- /dev/null +++ b/attic/line_count.sh @@ -0,0 +1,2 @@ +#!/bin/sh +find ./src -type f | xargs wc -l diff --git a/attic/random.sh b/attic/random.sh new file mode 100755 index 0000000..f6cb285 --- /dev/null +++ b/attic/random.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +BUILD_DIR=build-release2 +WALLPAPERS_PATH=workshop_wallpapers_3-12-23 + +export mesa_glthread=true + +if [[ $1 == "audio" ]] +then + while : ; do + DIR=$(find $WALLPAPERS_PATH -maxdepth 1 -type d | shuf -n 1) + RES=$(cat $DIR/project.json | jq '.["general"]["supportsaudioprocessing"]') + [[ "$RES" == 'null' || "$RES" == 'false' ]] || break + done +elif [[ $1 == "safe" ]] +then + while : ; do + DIR=$(find $WALLPAPERS_PATH -maxdepth 1 -type d | shuf -n 1) + RES=$(cat $DIR/project.json | jq '.["contentrating"]') + [[ "$RES" == 'null' || "$RES" != '"Everyone"' ]] || break + done +else + DIR=$(find $WALLPAPERS_PATH -maxdepth 1 -type d | shuf -n 1) +fi + +echo $DIR + +cd $BUILD_DIR +./mauri ../$DIR/scene.pkg +cd .. diff --git a/meson.build b/meson.build index 09ffb93..eb8d1fa 100644 --- a/meson.build +++ b/meson.build @@ -1,15 +1,10 @@ -project('mauri', 'cpp', - version: '0.1', +project('mauri', 'cpp', version: '0.12', default_options: ['warning_level=3', 'cpp_std=c++20']) if get_option('buildtype').startswith('debug') add_project_arguments('-D_DEBUG_', language: 'cpp') endif -compiler = meson.get_compiler('cpp') - -cmake = import('cmake') - if host_machine.system() == 'linux' add_project_arguments('-Wno-sign-compare', language: 'cpp') add_project_arguments('-Wno-unused-parameter', language: 'cpp') @@ -18,9 +13,12 @@ if host_machine.system() == 'linux' add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp') endif +compiler = meson.get_compiler('cpp') +cmake = import('cmake') + mauri_src = [ - 'src/assets.cc', 'src/mauri.cc', + 'src/assets.cc', 'src/util.cc', 'src/gl.cc', 'src/shader.cc', @@ -78,14 +76,9 @@ endif if get_option('audio') gstreamer = dependency('gstreamer-1.0', required: true) fftw3 = dependency('fftw3', required: true) - mauri_src += 'src/visualizer.cc' mauri_deps += [gstreamer, fftw3] - add_project_arguments('-DBUILD_AUDIO', language: 'cpp') endif -executable('mauri', mauri_src, - dependencies: mauri_deps, - install: true -) +executable('mauri', mauri_src, dependencies: mauri_deps, install: true) diff --git a/scripts/line_count.sh b/scripts/line_count.sh deleted file mode 100755 index dbc74af..0000000 --- a/scripts/line_count.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -find ./src -type f | xargs wc -l diff --git a/scripts/random.sh b/scripts/random.sh deleted file mode 100755 index 446a4a4..0000000 --- a/scripts/random.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -#cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -WALLPAPERS_PATH=workshop_wallpapers_11-8-21 -BUILD_DIR=build-release - -export mesa_glthread=true - -if [[ $1 == "audio" ]] -then - while : ; do - DIR=$(find $WALLPAPERS_PATH -maxdepth 1 -type d | shuf -n 1) - RES=$(cat $DIR/project.json | jq '.["general"]["supportsaudioprocessing"]') - [[ "$RES" == 'null' || "$RES" == 'false' ]] || break - done -elif [[ $1 == "safe" ]] -then - while : ; do - DIR=$(find $WALLPAPERS_PATH -maxdepth 1 -type d | shuf -n 1) - RES=$(cat $DIR/project.json | jq '.["contentrating"]') - [[ "$RES" == 'null' || "$RES" != '"Everyone"' ]] || break - done -else - DIR=$(find $WALLPAPERS_PATH -maxdepth 1 -type d | shuf -n 1) -fi - -echo $DIR - -cd $BUILD_DIR -./mauri ../$DIR/scene.pkg -cd .. diff --git a/src/assets.cc b/src/assets.cc index de9d802..d48cffd 100644 --- a/src/assets.cc +++ b/src/assets.cc @@ -2,10 +2,8 @@ #include #include -#include "assets.h" -#include "log.h" -#include "util.h" #include "texture.h" +#include "assets.h" namespace Mauri { diff --git a/src/context.cc b/src/context.cc index 32952f9..f40790f 100644 --- a/src/context.cc +++ b/src/context.cc @@ -1,5 +1,4 @@ #include "context.h" -#include "log.h" namespace Mauri { diff --git a/src/context.h b/src/context.h index a726f56..bc824b6 100644 --- a/src/context.h +++ b/src/context.h @@ -1,8 +1,8 @@ #ifndef _CONTEXT_H #define _CONTEXT_H -#include #include +#include #include "util.h" diff --git a/src/context_glfw.cc b/src/context_glfw.cc index 63594eb..c4f7d17 100644 --- a/src/context_glfw.cc +++ b/src/context_glfw.cc @@ -1,8 +1,4 @@ #include "context_glfw.h" -#include "context.h" -#include "log.h" - -#include "objects/pass.h" using namespace Mauri; diff --git a/src/context_glfw.h b/src/context_glfw.h index 34f2f96..3d11775 100644 --- a/src/context_glfw.h +++ b/src/context_glfw.h @@ -5,7 +5,6 @@ #include #include "context.h" -#include "util.h" namespace Mauri { diff --git a/src/context_x11.cc b/src/context_x11.cc index 3f36aae..a35a9f2 100644 --- a/src/context_x11.cc +++ b/src/context_x11.cc @@ -1,9 +1,5 @@ #include "context_x11.h" -#include "context.h" -#include "engine.h" -#include "log.h" - using namespace Mauri; static Atom ATOM_WM_DELETE_WINDOW, ATOM__NET_ACTIVE_WINDOW; diff --git a/src/context_x11.h b/src/context_x11.h index b10cb37..7e4a5a8 100644 --- a/src/context_x11.h +++ b/src/context_x11.h @@ -1,8 +1,6 @@ #ifndef _CONTEXT_X11_H #define _CONTEXT_X11_H -#include "context.h" - #include #include @@ -11,9 +9,9 @@ #include #include - #include -#include + +#include "context.h" #define XWIN_ALL_DESKTOPS 0xFFFFFFFF diff --git a/src/engine.cc b/src/engine.cc index 29d77f9..d6e597b 100644 --- a/src/engine.cc +++ b/src/engine.cc @@ -1,5 +1,6 @@ #include +#include "context.h" #include "engine.h" #include "objects/object.h" diff --git a/src/engine.h b/src/engine.h index 214321c..95b92ab 100644 --- a/src/engine.h +++ b/src/engine.h @@ -1,11 +1,8 @@ #ifndef _ENGINE_H #define _ENGINE_H -#include "context.h" -#include "gl.h" -#include "shader.h" -#include "texture.h" #include "framebuffer.h" +#include "shader.h" #ifdef BUILD_AUDIO #include "visualizer.h" diff --git a/src/framebuffer.h b/src/framebuffer.h index 3d1051f..9b373fa 100644 --- a/src/framebuffer.h +++ b/src/framebuffer.h @@ -1,8 +1,8 @@ #ifndef _FRAMEBUFFER_H #define _FRAMEBUFFER_H -#include "texture.h" #include "gl.h" +#include "texture.h" namespace Mauri { diff --git a/src/gl.cc b/src/gl.cc index 4dffb08..c45d641 100644 --- a/src/gl.cc +++ b/src/gl.cc @@ -1,10 +1,7 @@ -#include - -#include "gl.h" #include "log.h" #include "texture.h" -#include "util.h" #include "context.h" +#include "gl.h" using namespace Mauri; diff --git a/src/gl.h b/src/gl.h index 7a5fc07..3ee6ab6 100644 --- a/src/gl.h +++ b/src/gl.h @@ -1,6 +1,8 @@ #ifndef _GL_H #define _GL_H +#include + #include "util.h" namespace Mauri diff --git a/src/mauri.cc b/src/mauri.cc index 3c9533f..330daa9 100644 --- a/src/mauri.cc +++ b/src/mauri.cc @@ -1,12 +1,8 @@ #include "assets.h" #include "engine.h" -#include "gl.h" -#include "json.h" -#include "util.h" #include "context.h" #include "context_null.h" -#include #ifdef BUILD_GLFW #include "context_glfw.h" @@ -20,11 +16,20 @@ using namespace Mauri; -static std::string scene_path = "scene.json"; +static const std::string scene_path = "scene.json"; s32 main(s32 argc, char *argv[]) { - //srand(time(NULL)); + if (argc != 2) + { + printf("Usage: %s \n", argv[0]); + return EXIT_FAILURE; + } + + if (!asset_manager()->load_package(std::string(argv[1]))) + { + return EXIT_FAILURE; + } #ifdef BUILD_AUDIO gst_init(&argc, &argv); @@ -32,37 +37,23 @@ s32 main(s32 argc, char *argv[]) set_context(new ContextGLFW(1920, 1080, "mauri", false)); //set_context(new ContextX11(1920, 1080, "mauri", false)); - //set_context(new ContextGLFW(2560, 1440, "mauri", false)); - //set_context(new ContextX11(2560, 1440, "mauri", true)); //set_context(new ContextNull(1920, 1080, "mauri", false)); - if (argc == 2) - { - if (!asset_manager()->load_package(std::string(argv[1]))) - { - set_context(nullptr); - return 1; - } + Parser parser; + Scene *scene = new Scene(parser, scene_path); + //context()->resize_window(scene->width, scene->height); + Engine *engine = new Engine(scene, &parser, true); - Parser parser; + //asset_manager()->write_files("./output"); - Scene *scene = new Scene(parser, scene_path); + engine->run(); - //context()->resize_window(scene->width / 1.75, scene->height / 1.75); - //context()->resize_window(scene->width, scene->height); - - Engine engine(scene, &parser, true); - - //asset_manager()->write_files("./output"); - - engine.run(); - - delete scene; - } + delete scene; + delete engine; asset_manager()->unload_package(); set_context(nullptr); - return 0; + return EXIT_SUCCESS; } diff --git a/src/objects/effect.cc b/src/objects/effect.cc index 9257061..72d9e7e 100644 --- a/src/objects/effect.cc +++ b/src/objects/effect.cc @@ -1,11 +1,5 @@ -#include "../assets.h" -#include "../engine.h" -#include "../json.h" -#include "../log.h" - -#include "effect.h" -#include "object.h" #include "pass.h" +#include "effect.h" using namespace Mauri; diff --git a/src/objects/effect.h b/src/objects/effect.h index 8be54e7..558396b 100644 --- a/src/objects/effect.h +++ b/src/objects/effect.h @@ -2,6 +2,7 @@ #define _EFFECT_H #include "../util.h" +#include "../json.h" #include "../engine.h" #include "../texture.h" diff --git a/src/objects/material.cc b/src/objects/material.cc index b99b918..0957214 100644 --- a/src/objects/material.cc +++ b/src/objects/material.cc @@ -1,11 +1,5 @@ -#include "../assets.h" -#include "../engine.h" -#include "../json.h" -#include "../log.h" - -#include "material.h" -#include "object.h" #include "pass.h" +#include "material.h" using namespace Mauri; diff --git a/src/objects/model.cc b/src/objects/model.cc index 8af3224..1517b23 100644 --- a/src/objects/model.cc +++ b/src/objects/model.cc @@ -1,10 +1,4 @@ -#include "../assets.h" -#include "../json.h" -#include "../log.h" - -#include "material.h" #include "model.h" -#include "pass.h" using namespace Mauri; diff --git a/src/objects/model.h b/src/objects/model.h index a9b2b01..0d5b313 100644 --- a/src/objects/model.h +++ b/src/objects/model.h @@ -1,9 +1,6 @@ #ifndef _MODEL_H #define _MODEL_H -#include "../engine.h" -#include "../json.h" - #include "material.h" namespace Mauri diff --git a/src/objects/object.cc b/src/objects/object.cc index 833620a..73a16b3 100644 --- a/src/objects/object.cc +++ b/src/objects/object.cc @@ -1,12 +1,6 @@ -#include "../gl.h" -#include "../json.h" -#include "../log.h" - -#include "effect.h" -#include "model.h" -#include "object.h" -#include "scene.h" #include "pass.h" +#include "scene.h" +#include "object.h" using namespace Mauri; diff --git a/src/objects/object.h b/src/objects/object.h index 37b8bce..1a79c6c 100644 --- a/src/objects/object.h +++ b/src/objects/object.h @@ -1,8 +1,6 @@ #ifndef _OBJECT_H #define _OBJECT_H -#include "../engine.h" - #include "model.h" #include "effect.h" diff --git a/src/objects/pass.cc b/src/objects/pass.cc index 12d2cda..e6a9bfa 100644 --- a/src/objects/pass.cc +++ b/src/objects/pass.cc @@ -1,17 +1,8 @@ #include -#include "../assets.h" -#include "../engine.h" #include "../gl.h" -#include "../json.h" -#include "../shader.h" -#include "../texture.h" #include "pass.h" -#include "material.h" -#include "model.h" -#include "object.h" -#include "scene.h" using namespace Mauri; diff --git a/src/objects/pass.h b/src/objects/pass.h index d2806d9..97348a3 100644 --- a/src/objects/pass.h +++ b/src/objects/pass.h @@ -1,13 +1,6 @@ #ifndef _PASS_H #define _PASS_H -#include "../json.h" -#include "../context.h" -#include "../engine.h" -#include "../gl.h" -#include "../shader.h" -#include "../texture.h" - #include "object.h" #define MAX_TEXTURES 8 diff --git a/src/objects/scene.cc b/src/objects/scene.cc index 6df5e02..8331b15 100644 --- a/src/objects/scene.cc +++ b/src/objects/scene.cc @@ -1,10 +1,4 @@ -#include "../assets.h" -#include "../json.h" -#include "../log.h" -#include "../util.h" - #include "scene.h" -#include "pass.h" using namespace Mauri; diff --git a/src/objects/scene.h b/src/objects/scene.h index 8f13f3a..672df96 100644 --- a/src/objects/scene.h +++ b/src/objects/scene.h @@ -1,10 +1,6 @@ #ifndef _SCENE_H #define _SCENE_H -#include "../assets.h" -#include "../engine.h" -#include "../json.h" - #include "object.h" namespace Mauri diff --git a/src/shader.cc b/src/shader.cc index 4862bb6..45c3e3e 100644 --- a/src/shader.cc +++ b/src/shader.cc @@ -1,10 +1,6 @@ #include #include -#include "assets.h" -#include "gl.h" -#include "json.h" -#include "log.h" #include "shader.h" #include "objects/object.h" diff --git a/src/shader.h b/src/shader.h index 1d41be7..593ffa2 100644 --- a/src/shader.h +++ b/src/shader.h @@ -1,9 +1,8 @@ #ifndef _SHADER_H #define _SHADER_H -#include "gl.h" -#include "texture.h" #include "json.h" +#include "texture.h" #define MAX_TEXTURES 8 diff --git a/src/texture.cc b/src/texture.cc index 8016034..0cc2699 100644 --- a/src/texture.cc +++ b/src/texture.cc @@ -5,15 +5,9 @@ #include #include -#include #include -#include "assets.h" -#include "engine.h" -#include "gl.h" -#include "log.h" #include "texture.h" -#include "util.h" using namespace Mauri; diff --git a/src/texture.h b/src/texture.h index 8c5477a..cf6491d 100644 --- a/src/texture.h +++ b/src/texture.h @@ -1,9 +1,9 @@ #ifndef _TEXTURE_H #define _TEXTURE_H -#include "assets.h" #include "gl.h" #include "util.h" +#include "assets.h" namespace Mauri { diff --git a/src/util.h b/src/util.h index c38569d..3b88745 100644 --- a/src/util.h +++ b/src/util.h @@ -6,6 +6,8 @@ #include #include +#include "log.h" + using namespace nlohmann; using namespace glm; diff --git a/src/visualizer.cc b/src/visualizer.cc index ddffde2..8ef34d0 100644 --- a/src/visualizer.cc +++ b/src/visualizer.cc @@ -1,11 +1,8 @@ #include -#include "log.h" #include "assets.h" #include "visualizer.h" -#include "objects/material.h" - using namespace Mauri; static const float gausian_array[] = {.242, .399, .242}; -- cgit v1.2.3-101-g0448