summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cache/clangd/index/assets.cc.23B79FF96D65AF01.idxbin0 -> 3034 bytes
-rw-r--r--.cache/clangd/index/assets.h.1F4A45CE4A88EE50.idxbin0 -> 2908 bytes
-rw-r--r--.cache/clangd/index/context.cc.29D2991336B691E0.idxbin0 -> 1090 bytes
-rw-r--r--.cache/clangd/index/context.h.2258FC505D7BFE7A.idxbin0 -> 1094 bytes
-rw-r--r--.cache/clangd/index/context_glfw.cc.4B2B0770E8112A48.idxbin0 -> 1968 bytes
-rw-r--r--.cache/clangd/index/context_glfw.h.D427F9C1DD1FA20F.idxbin0 -> 898 bytes
-rw-r--r--.cache/clangd/index/context_null.h.7B5A64DED10E9D58.idxbin0 -> 952 bytes
-rw-r--r--.cache/clangd/index/context_x11.cc.0F598D995E81BABA.idxbin0 -> 4720 bytes
-rw-r--r--.cache/clangd/index/context_x11.h.73FA3E08604A605C.idxbin0 -> 1912 bytes
-rw-r--r--.cache/clangd/index/effect.cc.0BC9ED9FBEAF7230.idxbin0 -> 2084 bytes
-rw-r--r--.cache/clangd/index/effect.h.C9BA75F9C2CEBE09.idxbin0 -> 1408 bytes
-rw-r--r--.cache/clangd/index/engine.cc.54C290F3F5FEB67B.idxbin0 -> 3876 bytes
-rw-r--r--.cache/clangd/index/engine.h.0BA065D269C810C5.idxbin0 -> 2554 bytes
-rw-r--r--.cache/clangd/index/framebuffer.cc.C4658B2F26DF7D26.idxbin0 -> 1104 bytes
-rw-r--r--.cache/clangd/index/framebuffer.h.8A056E5C24972123.idxbin0 -> 596 bytes
-rw-r--r--.cache/clangd/index/gl.c.58D5E00F09226E2F.idxbin0 -> 84718 bytes
-rw-r--r--.cache/clangd/index/gl.cc.3791D0ADA616F76B.idxbin0 -> 6166 bytes
-rw-r--r--.cache/clangd/index/gl.h.4110C3685F72B241.idxbin0 -> 165332 bytes
-rw-r--r--.cache/clangd/index/gl.h.BC2D32DDBB22B90E.idxbin0 -> 3288 bytes
-rw-r--r--.cache/clangd/index/json.h.0271679A1AAEA3F1.idxbin0 -> 2166 bytes
-rw-r--r--.cache/clangd/index/khrplatform.h.63C8D2DA1E712281.idxbin0 -> 1912 bytes
-rw-r--r--.cache/clangd/index/log.h.3F43BA97A2EE1858.idxbin0 -> 298 bytes
-rw-r--r--.cache/clangd/index/material.cc.8E7E7195608167B3.idxbin0 -> 1470 bytes
-rw-r--r--.cache/clangd/index/material.h.868C4B7FDCFED6E5.idxbin0 -> 842 bytes
-rw-r--r--.cache/clangd/index/mauri.cc.49D5933B36D8F675.idxbin0 -> 1022 bytes
-rw-r--r--.cache/clangd/index/model.cc.1BDD17FEDEE6EEC2.idxbin0 -> 1414 bytes
-rw-r--r--.cache/clangd/index/model.h.83755EB2F4D6C2A8.idxbin0 -> 918 bytes
-rw-r--r--.cache/clangd/index/object.cc.35629F50251FA494.idxbin0 -> 3884 bytes
-rw-r--r--.cache/clangd/index/object.h.2E0F1AB9C8DA6021.idxbin0 -> 2642 bytes
-rw-r--r--.cache/clangd/index/pass.cc.EFADF6DB77056E1A.idxbin0 -> 5206 bytes
-rw-r--r--.cache/clangd/index/pass.h.75192BF26A8A1B14.idxbin0 -> 2904 bytes
-rw-r--r--.cache/clangd/index/s3tc.cpp.9B38B3A2C81E9A69.idxbin0 -> 574 bytes
-rw-r--r--.cache/clangd/index/s3tc.h.9467401D5B25AA10.idxbin0 -> 614 bytes
-rw-r--r--.cache/clangd/index/scene.cc.49BFEFBD57AFA1FC.idxbin0 -> 1908 bytes
-rw-r--r--.cache/clangd/index/scene.h.F137EBF68DF6DE19.idxbin0 -> 1490 bytes
-rw-r--r--.cache/clangd/index/shader.cc.EE8E91B2245F196F.idxbin0 -> 4462 bytes
-rw-r--r--.cache/clangd/index/shader.h.1B848452B04B0F75.idxbin0 -> 1964 bytes
-rw-r--r--.cache/clangd/index/stb_image.h.71C3424DBA0BB687.idxbin0 -> 73208 bytes
-rw-r--r--.cache/clangd/index/texture.cc.70699AAA88190AB7.idxbin0 -> 3156 bytes
-rw-r--r--.cache/clangd/index/texture.h.DA51BC96BACD3711.idxbin0 -> 3228 bytes
-rw-r--r--.cache/clangd/index/util.cc.95B656C3E176A8EB.idxbin0 -> 736 bytes
-rw-r--r--.cache/clangd/index/util.h.7065F6174EA563A6.idxbin0 -> 1078 bytes
-rw-r--r--.cache/clangd/index/visualizer.cc.1609983AB117C639.idxbin0 -> 4570 bytes
-rw-r--r--.cache/clangd/index/visualizer.h.BF456546CAE489EE.idxbin0 -> 2562 bytes
-rw-r--r--.gitignore2
-rw-r--r--TODO18
-rw-r--r--meson.build41
-rw-r--r--meson_options.txt2
-rwxr-xr-xrandom.sh32
-rw-r--r--src/context_x11.cc4
-rw-r--r--src/engine.cc7
-rw-r--r--src/framebuffer.cc10
-rw-r--r--src/framebuffer.h2
-rw-r--r--src/mauri.cc4
-rw-r--r--src/objects/object.cc8
-rw-r--r--src/objects/object.h4
-rw-r--r--src/objects/pass.cc83
-rw-r--r--src/objects/pass.h1
-rw-r--r--src/shader.cc63
-rw-r--r--src/shader.h4
-rw-r--r--src/texture.cc226
-rw-r--r--src/texture.h33
-rw-r--r--src/util.h1
63 files changed, 372 insertions, 173 deletions
diff --git a/.cache/clangd/index/assets.cc.23B79FF96D65AF01.idx b/.cache/clangd/index/assets.cc.23B79FF96D65AF01.idx
new file mode 100644
index 0000000..2730c7a
--- /dev/null
+++ b/.cache/clangd/index/assets.cc.23B79FF96D65AF01.idx
Binary files differ
diff --git a/.cache/clangd/index/assets.h.1F4A45CE4A88EE50.idx b/.cache/clangd/index/assets.h.1F4A45CE4A88EE50.idx
new file mode 100644
index 0000000..f1c956a
--- /dev/null
+++ b/.cache/clangd/index/assets.h.1F4A45CE4A88EE50.idx
Binary files differ
diff --git a/.cache/clangd/index/context.cc.29D2991336B691E0.idx b/.cache/clangd/index/context.cc.29D2991336B691E0.idx
new file mode 100644
index 0000000..e6b4144
--- /dev/null
+++ b/.cache/clangd/index/context.cc.29D2991336B691E0.idx
Binary files differ
diff --git a/.cache/clangd/index/context.h.2258FC505D7BFE7A.idx b/.cache/clangd/index/context.h.2258FC505D7BFE7A.idx
new file mode 100644
index 0000000..54755a6
--- /dev/null
+++ b/.cache/clangd/index/context.h.2258FC505D7BFE7A.idx
Binary files differ
diff --git a/.cache/clangd/index/context_glfw.cc.4B2B0770E8112A48.idx b/.cache/clangd/index/context_glfw.cc.4B2B0770E8112A48.idx
new file mode 100644
index 0000000..403b43b
--- /dev/null
+++ b/.cache/clangd/index/context_glfw.cc.4B2B0770E8112A48.idx
Binary files differ
diff --git a/.cache/clangd/index/context_glfw.h.D427F9C1DD1FA20F.idx b/.cache/clangd/index/context_glfw.h.D427F9C1DD1FA20F.idx
new file mode 100644
index 0000000..26f69e6
--- /dev/null
+++ b/.cache/clangd/index/context_glfw.h.D427F9C1DD1FA20F.idx
Binary files differ
diff --git a/.cache/clangd/index/context_null.h.7B5A64DED10E9D58.idx b/.cache/clangd/index/context_null.h.7B5A64DED10E9D58.idx
new file mode 100644
index 0000000..c2faa31
--- /dev/null
+++ b/.cache/clangd/index/context_null.h.7B5A64DED10E9D58.idx
Binary files differ
diff --git a/.cache/clangd/index/context_x11.cc.0F598D995E81BABA.idx b/.cache/clangd/index/context_x11.cc.0F598D995E81BABA.idx
new file mode 100644
index 0000000..108b106
--- /dev/null
+++ b/.cache/clangd/index/context_x11.cc.0F598D995E81BABA.idx
Binary files differ
diff --git a/.cache/clangd/index/context_x11.h.73FA3E08604A605C.idx b/.cache/clangd/index/context_x11.h.73FA3E08604A605C.idx
new file mode 100644
index 0000000..ec77f00
--- /dev/null
+++ b/.cache/clangd/index/context_x11.h.73FA3E08604A605C.idx
Binary files differ
diff --git a/.cache/clangd/index/effect.cc.0BC9ED9FBEAF7230.idx b/.cache/clangd/index/effect.cc.0BC9ED9FBEAF7230.idx
new file mode 100644
index 0000000..2a2bc62
--- /dev/null
+++ b/.cache/clangd/index/effect.cc.0BC9ED9FBEAF7230.idx
Binary files differ
diff --git a/.cache/clangd/index/effect.h.C9BA75F9C2CEBE09.idx b/.cache/clangd/index/effect.h.C9BA75F9C2CEBE09.idx
new file mode 100644
index 0000000..3f98e4e
--- /dev/null
+++ b/.cache/clangd/index/effect.h.C9BA75F9C2CEBE09.idx
Binary files differ
diff --git a/.cache/clangd/index/engine.cc.54C290F3F5FEB67B.idx b/.cache/clangd/index/engine.cc.54C290F3F5FEB67B.idx
new file mode 100644
index 0000000..5fbd31d
--- /dev/null
+++ b/.cache/clangd/index/engine.cc.54C290F3F5FEB67B.idx
Binary files differ
diff --git a/.cache/clangd/index/engine.h.0BA065D269C810C5.idx b/.cache/clangd/index/engine.h.0BA065D269C810C5.idx
new file mode 100644
index 0000000..3d7d200
--- /dev/null
+++ b/.cache/clangd/index/engine.h.0BA065D269C810C5.idx
Binary files differ
diff --git a/.cache/clangd/index/framebuffer.cc.C4658B2F26DF7D26.idx b/.cache/clangd/index/framebuffer.cc.C4658B2F26DF7D26.idx
new file mode 100644
index 0000000..dcb0b26
--- /dev/null
+++ b/.cache/clangd/index/framebuffer.cc.C4658B2F26DF7D26.idx
Binary files differ
diff --git a/.cache/clangd/index/framebuffer.h.8A056E5C24972123.idx b/.cache/clangd/index/framebuffer.h.8A056E5C24972123.idx
new file mode 100644
index 0000000..6ea77f4
--- /dev/null
+++ b/.cache/clangd/index/framebuffer.h.8A056E5C24972123.idx
Binary files differ
diff --git a/.cache/clangd/index/gl.c.58D5E00F09226E2F.idx b/.cache/clangd/index/gl.c.58D5E00F09226E2F.idx
new file mode 100644
index 0000000..7e37a92
--- /dev/null
+++ b/.cache/clangd/index/gl.c.58D5E00F09226E2F.idx
Binary files differ
diff --git a/.cache/clangd/index/gl.cc.3791D0ADA616F76B.idx b/.cache/clangd/index/gl.cc.3791D0ADA616F76B.idx
new file mode 100644
index 0000000..6937f27
--- /dev/null
+++ b/.cache/clangd/index/gl.cc.3791D0ADA616F76B.idx
Binary files differ
diff --git a/.cache/clangd/index/gl.h.4110C3685F72B241.idx b/.cache/clangd/index/gl.h.4110C3685F72B241.idx
new file mode 100644
index 0000000..7630949
--- /dev/null
+++ b/.cache/clangd/index/gl.h.4110C3685F72B241.idx
Binary files differ
diff --git a/.cache/clangd/index/gl.h.BC2D32DDBB22B90E.idx b/.cache/clangd/index/gl.h.BC2D32DDBB22B90E.idx
new file mode 100644
index 0000000..2e926b4
--- /dev/null
+++ b/.cache/clangd/index/gl.h.BC2D32DDBB22B90E.idx
Binary files differ
diff --git a/.cache/clangd/index/json.h.0271679A1AAEA3F1.idx b/.cache/clangd/index/json.h.0271679A1AAEA3F1.idx
new file mode 100644
index 0000000..08803a7
--- /dev/null
+++ b/.cache/clangd/index/json.h.0271679A1AAEA3F1.idx
Binary files differ
diff --git a/.cache/clangd/index/khrplatform.h.63C8D2DA1E712281.idx b/.cache/clangd/index/khrplatform.h.63C8D2DA1E712281.idx
new file mode 100644
index 0000000..b67b9b8
--- /dev/null
+++ b/.cache/clangd/index/khrplatform.h.63C8D2DA1E712281.idx
Binary files differ
diff --git a/.cache/clangd/index/log.h.3F43BA97A2EE1858.idx b/.cache/clangd/index/log.h.3F43BA97A2EE1858.idx
new file mode 100644
index 0000000..cd2a885
--- /dev/null
+++ b/.cache/clangd/index/log.h.3F43BA97A2EE1858.idx
Binary files differ
diff --git a/.cache/clangd/index/material.cc.8E7E7195608167B3.idx b/.cache/clangd/index/material.cc.8E7E7195608167B3.idx
new file mode 100644
index 0000000..f12b76c
--- /dev/null
+++ b/.cache/clangd/index/material.cc.8E7E7195608167B3.idx
Binary files differ
diff --git a/.cache/clangd/index/material.h.868C4B7FDCFED6E5.idx b/.cache/clangd/index/material.h.868C4B7FDCFED6E5.idx
new file mode 100644
index 0000000..66971b8
--- /dev/null
+++ b/.cache/clangd/index/material.h.868C4B7FDCFED6E5.idx
Binary files differ
diff --git a/.cache/clangd/index/mauri.cc.49D5933B36D8F675.idx b/.cache/clangd/index/mauri.cc.49D5933B36D8F675.idx
new file mode 100644
index 0000000..e7565b6
--- /dev/null
+++ b/.cache/clangd/index/mauri.cc.49D5933B36D8F675.idx
Binary files differ
diff --git a/.cache/clangd/index/model.cc.1BDD17FEDEE6EEC2.idx b/.cache/clangd/index/model.cc.1BDD17FEDEE6EEC2.idx
new file mode 100644
index 0000000..4d0be3a
--- /dev/null
+++ b/.cache/clangd/index/model.cc.1BDD17FEDEE6EEC2.idx
Binary files differ
diff --git a/.cache/clangd/index/model.h.83755EB2F4D6C2A8.idx b/.cache/clangd/index/model.h.83755EB2F4D6C2A8.idx
new file mode 100644
index 0000000..af773b0
--- /dev/null
+++ b/.cache/clangd/index/model.h.83755EB2F4D6C2A8.idx
Binary files differ
diff --git a/.cache/clangd/index/object.cc.35629F50251FA494.idx b/.cache/clangd/index/object.cc.35629F50251FA494.idx
new file mode 100644
index 0000000..ba6f662
--- /dev/null
+++ b/.cache/clangd/index/object.cc.35629F50251FA494.idx
Binary files differ
diff --git a/.cache/clangd/index/object.h.2E0F1AB9C8DA6021.idx b/.cache/clangd/index/object.h.2E0F1AB9C8DA6021.idx
new file mode 100644
index 0000000..6866ffa
--- /dev/null
+++ b/.cache/clangd/index/object.h.2E0F1AB9C8DA6021.idx
Binary files differ
diff --git a/.cache/clangd/index/pass.cc.EFADF6DB77056E1A.idx b/.cache/clangd/index/pass.cc.EFADF6DB77056E1A.idx
new file mode 100644
index 0000000..0a67bec
--- /dev/null
+++ b/.cache/clangd/index/pass.cc.EFADF6DB77056E1A.idx
Binary files differ
diff --git a/.cache/clangd/index/pass.h.75192BF26A8A1B14.idx b/.cache/clangd/index/pass.h.75192BF26A8A1B14.idx
new file mode 100644
index 0000000..324c7e4
--- /dev/null
+++ b/.cache/clangd/index/pass.h.75192BF26A8A1B14.idx
Binary files differ
diff --git a/.cache/clangd/index/s3tc.cpp.9B38B3A2C81E9A69.idx b/.cache/clangd/index/s3tc.cpp.9B38B3A2C81E9A69.idx
new file mode 100644
index 0000000..cb6ed2b
--- /dev/null
+++ b/.cache/clangd/index/s3tc.cpp.9B38B3A2C81E9A69.idx
Binary files differ
diff --git a/.cache/clangd/index/s3tc.h.9467401D5B25AA10.idx b/.cache/clangd/index/s3tc.h.9467401D5B25AA10.idx
new file mode 100644
index 0000000..168dc10
--- /dev/null
+++ b/.cache/clangd/index/s3tc.h.9467401D5B25AA10.idx
Binary files differ
diff --git a/.cache/clangd/index/scene.cc.49BFEFBD57AFA1FC.idx b/.cache/clangd/index/scene.cc.49BFEFBD57AFA1FC.idx
new file mode 100644
index 0000000..3df65a1
--- /dev/null
+++ b/.cache/clangd/index/scene.cc.49BFEFBD57AFA1FC.idx
Binary files differ
diff --git a/.cache/clangd/index/scene.h.F137EBF68DF6DE19.idx b/.cache/clangd/index/scene.h.F137EBF68DF6DE19.idx
new file mode 100644
index 0000000..542831b
--- /dev/null
+++ b/.cache/clangd/index/scene.h.F137EBF68DF6DE19.idx
Binary files differ
diff --git a/.cache/clangd/index/shader.cc.EE8E91B2245F196F.idx b/.cache/clangd/index/shader.cc.EE8E91B2245F196F.idx
new file mode 100644
index 0000000..b1f5e3c
--- /dev/null
+++ b/.cache/clangd/index/shader.cc.EE8E91B2245F196F.idx
Binary files differ
diff --git a/.cache/clangd/index/shader.h.1B848452B04B0F75.idx b/.cache/clangd/index/shader.h.1B848452B04B0F75.idx
new file mode 100644
index 0000000..96569e3
--- /dev/null
+++ b/.cache/clangd/index/shader.h.1B848452B04B0F75.idx
Binary files differ
diff --git a/.cache/clangd/index/stb_image.h.71C3424DBA0BB687.idx b/.cache/clangd/index/stb_image.h.71C3424DBA0BB687.idx
new file mode 100644
index 0000000..1fdaa67
--- /dev/null
+++ b/.cache/clangd/index/stb_image.h.71C3424DBA0BB687.idx
Binary files differ
diff --git a/.cache/clangd/index/texture.cc.70699AAA88190AB7.idx b/.cache/clangd/index/texture.cc.70699AAA88190AB7.idx
new file mode 100644
index 0000000..db4a36d
--- /dev/null
+++ b/.cache/clangd/index/texture.cc.70699AAA88190AB7.idx
Binary files differ
diff --git a/.cache/clangd/index/texture.h.DA51BC96BACD3711.idx b/.cache/clangd/index/texture.h.DA51BC96BACD3711.idx
new file mode 100644
index 0000000..e292f95
--- /dev/null
+++ b/.cache/clangd/index/texture.h.DA51BC96BACD3711.idx
Binary files differ
diff --git a/.cache/clangd/index/util.cc.95B656C3E176A8EB.idx b/.cache/clangd/index/util.cc.95B656C3E176A8EB.idx
new file mode 100644
index 0000000..6ec2c14
--- /dev/null
+++ b/.cache/clangd/index/util.cc.95B656C3E176A8EB.idx
Binary files differ
diff --git a/.cache/clangd/index/util.h.7065F6174EA563A6.idx b/.cache/clangd/index/util.h.7065F6174EA563A6.idx
new file mode 100644
index 0000000..43c4f73
--- /dev/null
+++ b/.cache/clangd/index/util.h.7065F6174EA563A6.idx
Binary files differ
diff --git a/.cache/clangd/index/visualizer.cc.1609983AB117C639.idx b/.cache/clangd/index/visualizer.cc.1609983AB117C639.idx
new file mode 100644
index 0000000..f8edd04
--- /dev/null
+++ b/.cache/clangd/index/visualizer.cc.1609983AB117C639.idx
Binary files differ
diff --git a/.cache/clangd/index/visualizer.h.BF456546CAE489EE.idx b/.cache/clangd/index/visualizer.h.BF456546CAE489EE.idx
new file mode 100644
index 0000000..abf148e
--- /dev/null
+++ b/.cache/clangd/index/visualizer.h.BF456546CAE489EE.idx
Binary files differ
diff --git a/.gitignore b/.gitignore
index 5c30beb..cd9449f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
build*/
-random.sh
compile_commands.json
.clangd/
+.cache/
diff --git a/TODO b/TODO
index 9658924..75e1b56 100644
--- a/TODO
+++ b/TODO
@@ -4,9 +4,9 @@
[x] cleanup visualizer code
-[ ] cleanup build system
- - glad automation
- - meson wrap for s3tc
+[X] cleanup build system
+
+[ ] more acurate visualizer
[ ] seperate program to extract scene.pkg
@@ -26,12 +26,24 @@ 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/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,
diff --git a/meson.build b/meson.build
index 9d772de..4a34dfb 100644
--- a/meson.build
+++ b/meson.build
@@ -18,21 +18,21 @@ if host_machine.system() == 'linux'
endif
mauri_src = [
- 'src/assets.cc',
- 'src/mauri.cc',
- 'src/util.cc',
- 'src/gl.cc',
- 'src/shader.cc',
- 'src/engine.cc',
- 'src/texture.cc',
- 'src/framebuffer.cc',
- 'src/context.cc',
- 'src/objects/scene.cc',
- 'src/objects/object.cc',
- 'src/objects/model.cc',
- 'src/objects/material.cc',
- 'src/objects/pass.cc',
- 'src/objects/effect.cc'
+ 'src/assets.cc',
+ 'src/mauri.cc',
+ 'src/util.cc',
+ 'src/gl.cc',
+ 'src/shader.cc',
+ 'src/engine.cc',
+ 'src/texture.cc',
+ 'src/framebuffer.cc',
+ 'src/context.cc',
+ 'src/objects/scene.cc',
+ 'src/objects/object.cc',
+ 'src/objects/model.cc',
+ 'src/objects/material.cc',
+ 'src/objects/pass.cc',
+ 'src/objects/effect.cc'
]
stbi = subproject('stb_image').get_variable('stbi')
@@ -41,21 +41,20 @@ s3tc = subproject('s3tc-dxt-decompression').get_variable('s3tc')
mauri_deps = [stbi, glad, s3tc]
-if host_machine.system() == 'windows'
+if host_machine.system() != 'linux'
lz4 = subproject('lz4').get_variable('lz4')
glm = cmake.subproject('glm').dependency('glm')
json = subproject('json').get_variable('nlohmann_json_dep')
- mauri_deps += [lz4, glm, json]
+ glfw = cmake.subproject('glfw').dependency('glfw', required: true)
else
lz4 = dependency('liblz4', required: true)
glm = dependency('glm', required: true)
json = dependency('nlohmann_json', required: true)
- dl = compiler.find_library('dl', required: true)
- mauri_deps += [lz4, glm, json, dl]
+ glfw = dependency('glfw3', required: false)
+ mauri_deps += [compiler.find_library('dl', required: true)]
endif
-#glfw = dependency('glfw3', required: false)
-glfw = cmake.subproject('glfw').dependency('glfw')
+mauri_deps += [lz4, glm, json]
if glfw.found()
mauri_deps += [glfw]
diff --git a/meson_options.txt b/meson_options.txt
index af1d055..9769862 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1 +1 @@
-option('audio', type: 'boolean', value: false)
+option('audio', type: 'boolean', value: true)
diff --git a/random.sh b/random.sh
new file mode 100755
index 0000000..a9910c9
--- /dev/null
+++ b/random.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+WALLPAPERS_PATH=../../c/workshop_wallpapers
+BUILD_DIR=build-release
+
+export mesa_glthread=true
+
+if [[ $1 == "audio" ]]
+then
+ while : ; do
+ DIR=$(find $WALLPAPERS_PATH -maxdepth 1 -type d | shuf | head -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 | head -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 | head -n 1)
+fi
+
+echo $DIR
+
+cd $BUILD_DIR
+./mauri ../$DIR/scene.pkg
+cd ..
diff --git a/src/context_x11.cc b/src/context_x11.cc
index b1e36ea..24a3271 100644
--- a/src/context_x11.cc
+++ b/src/context_x11.cc
@@ -3,6 +3,7 @@
#include "context.h"
#include "engine.h"
#include "log.h"
+
#include <X11/Xlib.h>
using namespace Mauri;
@@ -190,7 +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, 1080, 0);
+ XMoveWindow(x11_d, window, 0, 0);
XMapWindow(x11_d, window);
XFlush(x11_d);
diff --git a/src/engine.cc b/src/engine.cc
index 2ee3a49..a49851d 100644
--- a/src/engine.cc
+++ b/src/engine.cc
@@ -143,7 +143,7 @@ void Engine::draw()
{
for (auto& buffer : framebuffers)
{
- buffer->buffer->clear(vec4{0.f, 0.f, 0.f, 0.f});
+ buffer->buffer->clear(vec4{0.f, 0.f, 0.f, 1.f});
}
if (scene->clear_enabled)
@@ -156,7 +156,8 @@ void Engine::draw()
Render::bind_framebuffer(0);
default_object->bind();
- minimal_shader->bind(this, &default_model_flipped);
+
+ minimal_shader->bind(this, nullptr, &default_model_flipped, nullptr);
combine_buffer->texture->bind(0);
@@ -172,7 +173,7 @@ void Engine::run()
{
const f32 TARGET_FPS = 60.f;
- f32 time = context->current_time();
+ time = context->current_time();
while (!context->should_close())
{
diff --git a/src/framebuffer.cc b/src/framebuffer.cc
index 15f0129..6f65ab0 100644
--- a/src/framebuffer.cc
+++ b/src/framebuffer.cc
@@ -13,10 +13,10 @@ Framebuffer::Framebuffer(std::string name, f32 width, f32 height, f32 scale)
texture->texture = buffer->texture;
- texture->texture_res[0] = buffer->width;
- texture->texture_res[1] = buffer->height;
- texture->texture_res[2] = buffer->width;
- texture->texture_res[3] = buffer->height;
+ texture->texture_resolution[0] = buffer->width;
+ texture->texture_resolution[1] = buffer->height;
+ texture->texture_resolution[2] = buffer->width;
+ texture->texture_resolution[3] = buffer->height;
}
Framebuffer::~Framebuffer()
@@ -26,4 +26,4 @@ Framebuffer::~Framebuffer()
if (buffer != nullptr)
delete buffer;
-} \ No newline at end of file
+}
diff --git a/src/framebuffer.h b/src/framebuffer.h
index 69d224f..3d1051f 100644
--- a/src/framebuffer.h
+++ b/src/framebuffer.h
@@ -23,4 +23,4 @@ class Framebuffer
}
-#endif // _FRAMEBUFFER_H \ No newline at end of file
+#endif // _FRAMEBUFFER_H
diff --git a/src/mauri.cc b/src/mauri.cc
index a3f7aa3..4e70580 100644
--- a/src/mauri.cc
+++ b/src/mauri.cc
@@ -33,7 +33,7 @@ s32 main(s32 argc, char *argv[])
//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 ContextGLFW(1920, 1080, "mauri", false);
//Context *context = new ContextX11(1920, 1080, "mauri", false);
//Context *context = new ContextNull(1920, 1080, "mauri", false);
@@ -49,7 +49,7 @@ s32 main(s32 argc, char *argv[])
Scene *scene = new Scene(parser, scene_path);
- //context->resize_window(scene->width, scene->height);
+ //context->resize_window(scene->width / 2.f, scene->height / 2.f);
Engine engine(scene, context, &parser, true);
diff --git a/src/objects/object.cc b/src/objects/object.cc
index 600e2a6..8e6cc3d 100644
--- a/src/objects/object.cc
+++ b/src/objects/object.cc
@@ -30,10 +30,12 @@ Object::Object(Parser &p, json &root)
p.get_value<vec2>(root, "size", &size, vec2(0.f));
p.get_value<vec3>(root, "scale", &scale, vec3(0.f));
p.get_value<vec3>(root, "origin", &origin, vec3(0.f));
- origin[2] = 0.f;
+ //origin[2] = 0.f;
p.get_value<s32>(root, "colorBlendMode", &color_blend_mode, 0);
+ p.get_value<f32>(root, "alpha", &alpha, 1.f);
+
p.get_value<bool>(root, "visible", &visible, true);
auto _image = root["image"];
@@ -56,8 +58,7 @@ void Object::get_model(f32 width, f32 height, bool flip)
{
model = mat4x4(1.f);
- model = glm::translate(model, vec3{-width, -height, 0.f});
-
+ model = glm::translate(model, vec3{-width, -height, -origin[2]});
model = glm::translate(model, origin * 2.f);
model = glm::rotate(model, angles[0], vec3{1.f, 0.f, 0.f});
@@ -66,6 +67,7 @@ void Object::get_model(f32 width, f32 height, bool flip)
model = glm::scale(model, scale);
+ //mat4x4 _ortho = glm::ortho(-width, width, height, -height, 0.0099999997764825821f, 10000.f);
mat4x4 _ortho = glm::ortho(-width, width, height, -height, 0.f, 1.f);
if (flip)
diff --git a/src/objects/object.h b/src/objects/object.h
index 00cfe86..47fe2cc 100644
--- a/src/objects/object.h
+++ b/src/objects/object.h
@@ -52,6 +52,9 @@ class Object
s32 color_blend_mode;
+ f32 alpha;
+ vec3 color;
+
std::string get_target_buffer() const;
std::string get_texture_buffer() const;
@@ -72,7 +75,6 @@ class Object
Model *image = nullptr;
vec3 angles;
- vec3 color;
vec3 origin;
vec3 scale;
diff --git a/src/objects/pass.cc b/src/objects/pass.cc
index 96a349a..2d9edf5 100644
--- a/src/objects/pass.cc
+++ b/src/objects/pass.cc
@@ -31,7 +31,8 @@ Pass::Pass(Parser &p, json &root, PassStage stage)
for (auto &value : _uniforms.items())
{
uniforms.emplace_back(
- new UniformOverride({vec4(0.f), value.key()}));
+ new UniformOverride({vec4(0.f), value.key()})
+ );
p.get_value<vec4>(_uniforms, value.key(), &uniforms.back()->value, vec4(0.f));
}
@@ -75,13 +76,23 @@ Pass::Pass(Parser &p, json &root, PassStage stage)
break;
}
- for (int i = 0; i < MAX_TEXTURES; i++)
+ auto _textures = root["textures"];
+
+ for (int i = 0; i < _textures.size(); i++)
{
- auto texture = root["textures"][i];
+ auto texture = _textures[i];
if (texture.is_string())
{
textures[i] = texture;
}
+ else
+ {
+ // "null" in this case is different that empty
+ // because it means that this texture was listed
+ // in the pass, whereas empty strings where not.
+ // "null" means use default and apply combos
+ textures[i] = "null";
+ }
}
for (auto &combo : root["combos"].items())
@@ -97,6 +108,10 @@ void Pass::load(Engine *engine, PassStage stage, Pass *pass)
if (textures[i].empty())
continue;
+ // Only set pass->textures[i] to "null" if its not already set.
+ if (textures[i] == "null" && !pass->textures[i].empty())
+ continue;
+
pass->textures[i] = textures[i];
}
@@ -184,9 +199,15 @@ RenderPass::RenderPass(Engine *engine, Pass *pass)
for (int i = 0; i < MAX_TEXTURES; i++)
{
- // If there is no texture at "i" use default shader from the texture.
- if (pass->textures[i].empty() && !shader->textures[i].empty())
- pass->textures[i] = shader->textures[i];
+ if (!shader->textures[i].empty())
+ {
+ // If there is no texture at "i" use default shader from the texture.
+ if (pass->textures[i] == "null")
+ pass->textures[i] = shader->textures[i];
+
+ if (!shader->texture_combos[i].empty() && !pass->textures[i].empty())
+ pass->combos.push_back(Combo { shader->texture_combos[i], 1 });
+ }
if (pass->textures[i].empty())
continue;
@@ -207,7 +228,6 @@ RenderPass::RenderPass(Engine *engine, Pass *pass)
for (auto &shader_uniform : shader->uniforms)
{
- auto default_value = true;
for (auto &uniform_override : pass->uniforms)
{
if (shader_uniform->name.empty())
@@ -218,33 +238,9 @@ RenderPass::RenderPass(Engine *engine, Pass *pass)
// to the value stored in the parser. This allows changing that value
// to have instant effect.
shader_uniform->value = &uniform_override->value;
- default_value = false;
break;
}
}
- if (default_value)
- shader_uniform->value = &shader_uniform->default_value;
- }
-
- for (auto &uniform : shader->uniforms)
- {
- // ex: g_Texture2Resolution (vec4)
- // ^ index
- if (uniform->uname.compare(0, 9, "g_Texture") == 0 &&
- uniform->uname.compare(10, 10, "Resolution") == 0)
- {
- auto index = uniform->uname[9] - '0';
- if (textures[index] != nullptr)
- uniform->value = &textures[index]->texture_res;
- else
- {
- // If there is no texture at this index we assume this texture will
- // be the previous framebuffer.
- auto texture = engine->get_framebuffer_texture(object->get_texture_buffer());
- if (texture != nullptr)
- uniform->value = &texture->texture_res;
- }
- }
}
for (auto &pass_combo : pass->combos)
@@ -348,26 +344,25 @@ void RenderPass::draw(Engine *engine)
_target->buffer->bind();
- shader->bind(engine, model);
- robject->bind();
-
for (int i = 0; i < shader->texture_count; i++)
{
- if (textures[i] != nullptr)
- textures[i]->bind(i);
- else
+ if (textures[i] != nullptr && !textures[i]->dynamic)
+ continue;
+
+ auto texture = engine->get_framebuffer_texture(object->get_texture_buffer());
+
+ if (texture != nullptr)
{
- // Assume this index will be the previous framebuffer.
- auto texture = engine->get_framebuffer_texture(object->get_texture_buffer());
- if (texture != nullptr)
- texture->bind(i);
+ texture->dynamic = true;
+ textures[i] = texture;
}
}
+ shader->bind(engine, object, model, &textures);
+ robject->bind();
+
if (target == nullptr)
- {
object->swap_buffer();
- }
if (combine)
{
@@ -387,7 +382,7 @@ void RenderPass::draw(Engine *engine)
#if FRAME_STEP
_target->buffer->blit(0, engine->context->width, engine->context->height);
engine->context->swap_buffers();
- std::this_thread::sleep_for(std::chrono::seconds(2));
+ std::this_thread::sleep_for(std::chrono::seconds(1));
#endif
break;
diff --git a/src/objects/pass.h b/src/objects/pass.h
index 6b8f2a9..b84fbf3 100644
--- a/src/objects/pass.h
+++ b/src/objects/pass.h
@@ -77,7 +77,6 @@ class RenderPass
RenderPass(Engine *engine, Pass *pass);
~RenderPass();
-
Shader *shader = nullptr;
void draw(Engine *engine);
diff --git a/src/shader.cc b/src/shader.cc
index 245a6de..0199897 100644
--- a/src/shader.cc
+++ b/src/shader.cc
@@ -4,6 +4,7 @@
#include <glm/matrix.hpp>
#include <sstream>
+#include <regex>
#include "assets.h"
#include "gl.h"
@@ -24,6 +25,7 @@ static const char *gl_compat = \
"#define CAST4(x) (vec4(x))\n"
"#define CAST3X3(x) (mat3(x))\n"
"#define saturate(x) (clamp(x, 0.0, 1.0))\n"
+ "#define lerp mix\n"
"#define texSample2D texture2D\n"
"#define texSample2DLod texture2DLod\n"
"#define texture2DLod texture2D\n"
@@ -32,7 +34,10 @@ static const char *gl_compat = \
"#define ddy(x) dFdy(-(x))\n"
"#define GLSL 1\n";
-static const char *version = "#version 120\n";
+static const char *version = "#version 130\n";
+
+//static const std::regex mod_regex("(\\(.*\\)\\s*)?(\\w*\\s*)%\\s*(\\w*)");
+//static const std::regex uint_regex("uint\\s*=(.*)");
using namespace Mauri;
@@ -116,7 +121,7 @@ void Shader::build_shader_source(Parser *p, const std::string &isource, std::str
auto combo = root["combo"];
if (!combo.is_null())
- combos.emplace_back(Combo { combo, 1 });
+ texture_combos[(int)uniform->default_value[0]] = combo;
break;
}
@@ -132,10 +137,12 @@ void Shader::build_shader_source(Parser *p, const std::string &isource, std::str
break;
}
}
+
+ uniform->value = &uniform->default_value;
uniforms.emplace_back(uniform);
}
- else if (line.compare(0, 10, "// [COMBO]") == 0)
+ else if (line.compare(0, 9, "// [COMBO") == 0)
{
auto open = line.find('{');
auto combo = line.substr(open, line.length() - open);
@@ -145,14 +152,23 @@ void Shader::build_shader_source(Parser *p, const std::string &isource, std::str
combos.emplace_back(Combo { root["combo"], root["default"] });
}
- if (!cut_line) res += line + "\n";
+ if (!cut_line)
+ {
+ //line = std::regex_replace(line, mod_regex, "mod($1$2, $3)");
+ //line = std::regex_replace(line, mod_regex, "uint(uint($1$2) % $3)");
+ //line = std::regex_replace(line, uint_regex, "int int($1)");
+ res += line + "\n";
+ }
}
}
std::string Combo::to_string()
{
+ transform(name.begin(), name.end(), name.begin(), ::toupper);
+
std::stringstream _combo;
_combo << "#define " << name << " " << value << "\n";
+
return _combo.str();
}
@@ -196,7 +212,7 @@ Shader::Shader(Parser *p, const std::string &name)
}
}
-void Shader::bind(Engine *engine, mat4x4 *model)
+void Shader::bind(Engine *engine, Object *object, mat4x4 *model, std::array<Texture *, MAX_TEXTURES> *textures)
{
rshader->bind();
@@ -204,11 +220,40 @@ void Shader::bind(Engine *engine, mat4x4 *model)
{
if (uniform->uname.find('[') != std::string::npos)
continue;
- //std::cout << uniform->uname << " " << uniform->value[0] << "\n";
+#if UNIFORM_DEBUG
+ std::cout << uniform->uname << "(" << uniform->type << ")" << " "
+ << (*uniform->value)[0] << " " << (*uniform->value)[1]
+ << " " << (*uniform->value)[2] << " " << (*uniform->value)[3] << "\n";
+#endif
if (uniform->value != nullptr)
rshader->set_uniform(uniform->uname, uniform->type, glm::value_ptr(*uniform->value));
}
+ if (textures != nullptr)
+ {
+ for (int i = 0; i < texture_count; i++)
+ {
+ auto texture = (*textures)[i];
+
+ if (texture == nullptr)
+ continue;
+
+ texture->update(engine->time);
+
+ auto index = std::to_string(i);
+
+ auto texture_resolution = "g_Texture" + index + "Resolution";
+ auto texture_translation = "g_Texture" + index + "Translation";
+ auto texture_rotation = "g_Texture" + index + "Rotation";
+
+ rshader->set_uniform(texture_resolution, TYPE_VEC4, glm::value_ptr(texture->texture_resolution));
+ rshader->set_uniform(texture_translation, TYPE_VEC2, glm::value_ptr(texture->texture_translation));
+ rshader->set_uniform(texture_rotation, TYPE_VEC4, glm::value_ptr(texture->texture_rotation));
+
+ texture->bind(i);
+ }
+ }
+
rshader->set_uniform("g_Time", TYPE_FLOAT, &engine->time);
rshader->set_uniform("g_TexelSize", TYPE_VEC2, glm::value_ptr(engine->view.texel_size));
@@ -228,6 +273,12 @@ 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));
+ if (object != nullptr)
+ {
+ rshader->set_uniform("g_Alpha", TYPE_FLOAT, &object->alpha);
+ rshader->set_uniform("g_Color", TYPE_VEC3, glm::value_ptr(object->color));
+ }
+
#ifdef BUILD_AUDIO
if (engine->audio_enabled)
{
diff --git a/src/shader.h b/src/shader.h
index 63bd868..f805952 100644
--- a/src/shader.h
+++ b/src/shader.h
@@ -31,6 +31,7 @@ struct Combo
};
class Engine;
+class Object;
class Shader
{
@@ -44,10 +45,11 @@ class Shader
std::vector<Combo> combos;
std::array<std::string, MAX_TEXTURES> textures = {""};
+ std::array<std::string, MAX_TEXTURES> texture_combos = {""};
u32 texture_count = 0;
- void bind(Engine *engine, mat4x4 *model);
+ void bind(Engine *engine, Object *object, mat4x4 *model, std::array<Texture *, MAX_TEXTURES> *textures);
void compile();
private:
diff --git a/src/texture.cc b/src/texture.cc
index fbd894b..8ef1ae3 100644
--- a/src/texture.cc
+++ b/src/texture.cc
@@ -1,3 +1,4 @@
+#include <type_traits>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
@@ -25,10 +26,8 @@ Texture::Texture(Asset *asset)
{
hash = asset->hash;
- // auto type = asset->read_str(9);
- // auto itype = asset->read_str(9);
-
- asset->seek(18);
+ auto type = asset->reads(9);
+ auto itype = asset->reads(9);
auto format = (TextureFormat)asset->read<u32>();
@@ -36,16 +35,18 @@ Texture::Texture(Asset *asset)
flags.u.i = asset->read<u32>();
+ is_gif = flags.u.flags.IS_GIF == 1;
+
auto texture_width = asset->read<u32>();
auto texture_height = asset->read<u32>();
width = asset->read<u32>();
height = asset->read<u32>();
- texture_res[0] = texture_width;
- texture_res[1] = texture_height;
- texture_res[2] = width;
- texture_res[3] = height;
+ texture_resolution[0] = texture_width;
+ texture_resolution[1] = texture_height;
+ texture_resolution[2] = width;
+ texture_resolution[3] = height;
asset->seek(4);
@@ -55,21 +56,20 @@ Texture::Texture(Asset *asset)
auto iformat = -1;
+ auto image_count = asset->read<u32>();
+
if (container.compare(0, 8, "TEXB0003") == 0)
{
version = TEXB0003;
- asset->seek(4);
iformat = asset->read<u32>();
}
else if (container.compare(0, 8, "TEXB0002") == 0)
{
version = TEXB0002;
- asset->seek(4);
}
else if (container.compare(0, 8, "TEXB0001") == 0)
{
version = TEXB0001;
- asset->seek(4);
}
else
{
@@ -77,96 +77,166 @@ Texture::Texture(Asset *asset)
log_error("%s", "unknown texture version");
}
- auto mm_count = asset->read<u32>();
-
- texture = new RenderTexture(flags.u.flags.NO_INTERPOLATION, flags.u.flags.CLAMP_UV, mm_count);
-
- for (int i = 0; i < mm_count; i++)
+ for (int s = 0; s < image_count; s++)
{
- auto mwidth = asset->read<u32>();
- auto mheight = asset->read<u32>();
+ auto mm_count = asset->read<u32>();
- auto lz4_compressed = false;
- auto decompressed_byte_count = 0;
+ auto _texture = new RenderTexture(flags.u.flags.NO_INTERPOLATION, flags.u.flags.CLAMP_UV, mm_count);
- if (version == TEXB0002 || version == TEXB0003)
+ for (int i = 0; i < mm_count; i++)
{
- lz4_compressed = asset->read<u32>() == 1;
- decompressed_byte_count = asset->read<u32>();
- }
+ auto mwidth = asset->read<u32>();
+ auto mheight = asset->read<u32>();
- auto byte_count = asset->read<u32>();
+ auto lz4_compressed = false;
+ auto decompressed_byte_count = 0;
- if (!lz4_compressed)
- decompressed_byte_count = byte_count;
+ if (version == TEXB0002 || version == TEXB0003)
+ {
+ lz4_compressed = asset->read<u32>() == 1;
+ decompressed_byte_count = asset->read<u32>();
+ }
- auto buffer = asset->ptr();
+ auto byte_count = asset->read<u32>();
- if (lz4_compressed)
- {
- auto decompressed = new char[decompressed_byte_count];
- LZ4_decompress_safe(reinterpret_cast<char *>(buffer), decompressed,
- byte_count, decompressed_byte_count);
- buffer = reinterpret_cast<byte *>(decompressed);
- }
+ if (!lz4_compressed)
+ decompressed_byte_count = byte_count;
- if (iformat == -1)
- {
- switch (format)
+ auto buffer = asset->ptr();
+
+ if (lz4_compressed)
{
- case RGBA8888:
- texture->upload(buffer, mwidth, mheight, i, GL_RGBA, true);
- break;
- case DXT5: {
- auto decompressed = new u32[decompressed_byte_count];
- BlockDecompressImageDXT5(mwidth, mheight, buffer, decompressed);
- texture->upload(reinterpret_cast<byte *>(decompressed),
- mwidth, mheight, i, GL_RGBA, true, true);
- delete[] decompressed;
- log_warn("%s", "DXT5 Texture");
- break;
+ auto decompressed = new char[decompressed_byte_count];
+ LZ4_decompress_safe(reinterpret_cast<char *>(buffer), decompressed,
+ byte_count, decompressed_byte_count);
+ buffer = reinterpret_cast<byte *>(decompressed);
}
- case DXT1: {
- auto decompressed = new u32[decompressed_byte_count * 2];
- BlockDecompressImageDXT1(mwidth, mheight, buffer, decompressed);
- texture->upload(reinterpret_cast<byte *>(decompressed),
- mwidth, mheight, i, GL_RGBA, true, true);
- delete[] decompressed;
- log_warn("%s", "DXT1 Texture");
- break;
+
+ if (iformat == -1)
+ {
+ switch (format)
+ {
+ case RGBA8888:
+ _texture->upload(buffer, mwidth, mheight, i, GL_RGBA, true);
+ break;
+ case DXT5: {
+ auto decompressed = new u32[decompressed_byte_count];
+ BlockDecompressImageDXT5(mwidth, mheight, buffer, decompressed);
+ _texture->upload(reinterpret_cast<byte *>(decompressed),
+ mwidth, mheight, i, GL_RGBA, true, true);
+ delete[] decompressed;
+ log_warn("%s", "DXT5 Texture");
+ break;
+ }
+ case DXT1: {
+ auto decompressed = new u32[decompressed_byte_count * 2];
+ BlockDecompressImageDXT1(mwidth, mheight, buffer, decompressed);
+ _texture->upload(reinterpret_cast<byte *>(decompressed),
+ mwidth, mheight, i, GL_RGBA, true, true);
+ delete[] decompressed;
+ log_warn("%s", "DXT1 Texture");
+ break;
+ }
+ case DXT3:
+ log_warn("%s", "DXT3 Texture");
+ break;
+ case RG88:
+ _texture->upload(buffer, mwidth, mheight, i, GL_RG, true);
+ log_warn("%s", "RG88 Texture");
+ break;
+ case R8:
+ _texture->upload(buffer, mwidth, mheight, i, GL_RED, true);
+ log_warn("%s", "RG8 Texture");
+ break;
+ default:
+ log_warn("%s", "Uknown Texture");
+ break;
+ }
}
- case DXT3:
- log_warn("%s", "DXT3 Texture");
- break;
- case RG88:
- texture->upload(buffer, mwidth, mheight, i, GL_RG, true);
- log_warn("%s", "RG88 Texture");
- break;
- case R8:
- texture->upload(buffer, mwidth, mheight, i, GL_RED, true);
- log_warn("%s", "RG8 Texture");
- break;
- default:
- log_warn("%s", "Uknown Texture");
- break;
+ else
+ {
+ auto data = load_image_rgba(buffer, decompressed_byte_count);
+ _texture->upload(data, mwidth, mheight, i, GL_RGBA, true);
+ free(data);
}
+
+ if (lz4_compressed)
+ delete[] buffer;
+
+ asset->seek(byte_count);
}
- else
+
+ textures.push_back(_texture);
+ }
+
+ texture = textures[0];
+
+ if (is_gif)
+ {
+ auto gif_container = asset->reads(9);
+
+ auto frame_count = asset->read<u32>();
+
+ if (gif_container.compare(0, 8, "TEXS0002") == 0) {}
+ else if (gif_container.compare(0, 8, "TEXS0003") == 0)
{
- auto data = load_image_rgba(buffer, decompressed_byte_count);
- texture->upload(data, mwidth, mheight, i, GL_RGBA, true);
- free(data);
+ gif_width = asset->read<u32>();
+ gif_height = asset->read<u32>();
}
- if (lz4_compressed)
- delete[] buffer;
+ for (int i = 0; i < frame_count; i++)
+ {
+ frames.push_back(TextureFrame {
+ asset->read<u32>(), // id
+ asset->read<f32>(), // frame_time
+ asset->read<f32>(), // x
+ asset->read<f32>(), // y
+ asset->read<f32>(), // width
+ asset->read<f32>(), // unknown0
+ asset->read<f32>(), // unknown1
+ asset->read<f32>(), // height
+ });
+ }
+ }
- asset->seek(byte_count);
+ for (auto &frame : frames)
+ {
+ //std::cout << frame.id << "\n";
+ //std::cout << frame.x << " " << frame.y << "\n";
+ //std::cout << frame.frame_time << "\n";
+ //std::cout << frame.unknown0 << " " << frame.unknown1 << "\n";
}
asset->reset();
}
+void Texture::update(f32 time)
+{
+ if (!is_gif || wrapped) return;
+
+ if (time >= gif_update)
+ {
+ auto frame = &frames[gif_frame_index];
+
+ texture = textures[frame->id];
+
+ texture_rotation[0] = 0.06201;
+ texture_rotation[1] = 0.0;
+ texture_rotation[2] = 0.0;
+ texture_rotation[3] = 0.06885;
+
+ texture_translation[0] = 0.74414;
+ texture_translation[1] = 0.61963;
+
+ gif_frame_index++;
+
+ if (gif_frame_index >= frames.size())
+ gif_frame_index = 0;
+
+ gif_update = time + frame->frame_time;
+ }
+}
+
Texture::~Texture()
{
if (!wrapped)
diff --git a/src/texture.h b/src/texture.h
index 5093e87..3f2e6fa 100644
--- a/src/texture.h
+++ b/src/texture.h
@@ -11,6 +11,7 @@ using namespace glm;
namespace Mauri
{
+
enum TextureFormat
{
RGBA8888 = 0,
@@ -29,6 +30,7 @@ enum TextureVersion
UNKNOWN
};
+// TODO make better
struct TextureFlags
{
union {
@@ -43,6 +45,18 @@ struct TextureFlags
} u;
};
+struct TextureFrame
+{
+ u32 id;
+ f32 frame_time;
+ f32 x;
+ f32 y;
+ f32 width;
+ f32 unknown0;
+ f32 unknown1;
+ f32 height;
+};
+
class Texture
{
public:
@@ -57,12 +71,29 @@ class Texture
u64 hash;
bool wrapped = false;
+ bool dynamic = false;
+
+ bool is_gif;
- vec4 texture_res;
+ u32 gif_width;
+ u32 gif_height;
+
+ u32 gif_frame_index = 0;
+
+ f32 gif_update = 0;
+
+ std::vector<TextureFrame> frames;
+
+ vec4 texture_resolution;
+ vec2 texture_translation;
+ vec4 texture_rotation = vec4(0.f);
RenderTexture *texture;
+ std::vector<RenderTexture *> textures;
+
void bind(s32 index);
+ void update(f32 time);
};
} // namespace Mauri
diff --git a/src/util.h b/src/util.h
index 8eb26ed..1c351f2 100644
--- a/src/util.h
+++ b/src/util.h
@@ -7,6 +7,7 @@
using namespace nlohmann;
#define FRAME_STEP 0
+#define UNIFORM_DEBUG 0
typedef uint32_t u32;
typedef int32_t s32;