Dicewars-Siedler/src/game/UILayer.cpp

44 lines
1016 B
C++

//
// Created by sebastian on 09.02.26.
//
#include "UILayer.h"
#include "../engine/core/gui/uiComponent/UiImage.h"
#include "../engine/renderer/loader/Loader.h"
#include "../engine/renderer/model/GUITexture.h"
UILayer::UILayer() {
Loader& loader = Loader::instance();
guiRenderer = std::make_unique<GUIRenderer>(loader);
}
void UILayer::onAttach() {
Layer::onAttach();
rootContainer = std::make_unique<UiContainer>();
auto image = std::make_unique<UiImage>(
Loader::instance().loadTextureFromFile("assets/textures/texture.png").getTextureID(),
glm::vec2(0.5f, 0.5f), glm::vec2(0.5f)
);
rootContainer->addChild(std::move(image));
}
void UILayer::onUpdate() {
Layer::onUpdate();
std::vector<GUITexture> guiTextures;
if (rootContainer) {
rootContainer->collectRenderData(guiTextures);
}
printf("Found UI Textures: %lu\n", guiTextures.size());
guiRenderer->render(guiTextures);
}
void UILayer::onDetach() {
Layer::onDetach();
}