diff --git a/res/scripts/hud.lua b/res/scripts/hud.lua
index a0e363b99..d10d00e1e 100644
--- a/res/scripts/hud.lua
+++ b/res/scripts/hud.lua
@@ -127,7 +127,12 @@ function on_hud_open()
hud.default_hand_controller = update_hand
- gui.root.root:add("")
+ local name = "gui/no_icon"
+ gui.create_frame(name, {16, 16})
+
+ local document = Document.new(name)
+ document.root:add("")
+ document.root.color = {255, 0, 0, 255}
end
function on_hud_render()
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index 9afe0824a..70bb5dae9 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -305,6 +305,7 @@ void Engine::renderFrame() {
screen->draw(time.getDelta());
DrawContext ctx(nullptr, *window, nullptr);
+ gui->renderFrames(ctx, *assets->getStorage());
gui->draw(ctx, *assets->getStorage());
}
diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp
index d2702bb19..7677ca9f8 100644
--- a/src/graphics/ui/GUI.cpp
+++ b/src/graphics/ui/GUI.cpp
@@ -8,6 +8,7 @@
#include "elements/Label.hpp"
#include "elements/Menu.hpp"
#include "elements/Panel.hpp"
+#include "elements/Frame.hpp"
#include "elements/UINode.hpp"
#include "engine/Engine.hpp"
#include "frontend/UiDocument.hpp"
@@ -262,6 +263,21 @@ void GUI::postAct() {
}
}
+void GUI::renderFrames(const DrawContext& pctx, Assets& assets) {
+ auto ctx = pctx.sub(batch2D.get());
+
+ auto uishader = assets.get("ui");
+ uishader->use();
+ uishader->uniformMatrix("u_projview", uicamera->getProjView());
+
+ batch2D->begin();
+ for (auto& [outputTexture, frame] : frames) {
+ frame->updateOutput(assets);
+ frame->draw(ctx, assets);
+ }
+ batch2D->flush();
+}
+
void GUI::draw(const DrawContext& pctx, const Assets& assets) {
auto ctx = pctx.sub(batch2D.get());
@@ -337,6 +353,10 @@ void GUI::add(std::shared_ptr node) {
container->add(std::move(node));
}
+void GUI::addFrame(std::shared_ptr frame) {
+ frames[frame->getOutputTexture()] = std::move(frame);
+}
+
void GUI::remove(UINode* node) noexcept {
container->remove(node);
}
diff --git a/src/graphics/ui/GUI.hpp b/src/graphics/ui/GUI.hpp
index a27872d76..b990d93ab 100644
--- a/src/graphics/ui/GUI.hpp
+++ b/src/graphics/ui/GUI.hpp
@@ -61,6 +61,7 @@ namespace gui {
class UINode;
class Container;
class Menu;
+ class Frame;
/// @brief The main UI controller
class GUI {
@@ -80,6 +81,7 @@ namespace gui {
std::shared_ptr