block.material + minor refactor

This commit is contained in:
MihailRis
2024-04-25 05:12:45 +03:00
parent 8730b03a52
commit b1a79e3a6e
9 changed files with 35 additions and 16 deletions
+8 -4
View File
@@ -4,6 +4,7 @@
#include "../../graphics/ui/elements/Menu.hpp"
#include "../../graphics/core/Batch2D.hpp"
#include "../../graphics/core/Shader.hpp"
#include "../../graphics/core/Texture.hpp"
#include "../../window/Window.h"
#include "../../window/Camera.h"
#include "../../engine.h"
@@ -16,7 +17,7 @@ MenuScreen::MenuScreen(Engine* engine) : Screen(engine) {
menu->reset();
menu->setPage("main");
uicamera.reset(new Camera(glm::vec3(), Window::height));
uicamera = std::make_unique<Camera>(glm::vec3(), Window::height);
uicamera->perspective = false;
uicamera->flipped = true;
}
@@ -28,23 +29,26 @@ void MenuScreen::update(float delta) {
}
void MenuScreen::draw(float delta) {
auto assets = engine->getAssets();
Window::clear();
Window::setBgColor(glm::vec3(0.2f));
uicamera->setFov(Window::height);
Shader* uishader = engine->getAssets()->getShader("ui");
Shader* uishader = assets->getShader("ui");
uishader->use();
uishader->uniformMatrix("u_projview", uicamera->getProjView());
uint width = Window::width;
uint height = Window::height;
auto bg = assets->getTexture("gui/menubg");
batch->begin();
batch->texture(engine->getAssets()->getTexture("gui/menubg"));
batch->texture(bg);
batch->rect(
0, 0,
width, height, 0, 0, 0,
UVRegion(0, 0, width/64, height/64),
UVRegion(0, 0, width/bg->getWidth(), height/bg->getHeight()),
false, false, glm::vec4(1.0f)
);
batch->flush();