add gui.create_frame

This commit is contained in:
MihailRis 2026-02-04 13:10:49 +03:00
parent 3014329280
commit 463098aa1e
8 changed files with 84 additions and 24 deletions

View file

@ -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<Shader>("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<UINode> node) {
container->add(std::move(node));
}
void GUI::addFrame(std::shared_ptr<Frame> frame) {
frames[frame->getOutputTexture()] = std::move(frame);
}
void GUI::remove(UINode* node) noexcept {
container->remove(node);
}