hud refactor (part II)

This commit is contained in:
MihailRis
2024-01-07 19:22:29 +03:00
parent 8118afce5c
commit e493c67dfa
13 changed files with 142 additions and 91 deletions
+6 -6
View File
@@ -2,6 +2,7 @@
#include <glm/ext.hpp>
#include "../assets/Assets.h"
#include "../graphics/Viewport.h"
#include "../graphics/Shader.h"
#include "../graphics/Texture.h"
@@ -11,10 +12,10 @@
#include "../voxels/Block.h"
#include "ContentGfxCache.h"
BlocksPreview::BlocksPreview(Shader* shader,
Atlas* atlas,
const ContentGfxCache* cache)
: shader(shader), atlas(atlas), cache(cache) {
BlocksPreview::BlocksPreview(Assets* assets, const ContentGfxCache* cache)
: shader(assets->getShader("ui3d")),
atlas(assets->getAtlas("blocks")),
cache(cache) {
batch = std::make_unique<Batch3D>(1024);
}
@@ -37,9 +38,8 @@ void BlocksPreview::draw(const Block* def, int x, int y, int size, glm::vec4 tin
uint width = viewport->getWidth();
uint height = viewport->getHeight();
y = height - y - 1;
y = height - y - 1 - 35 /* magic garbage */;
x += 2;
y -= 35;
glm::vec3 offset (x/float(width) * 2, y/float(height) * 2, 0.0f);
shader->uniformMatrix("u_apply", glm::translate(glm::mat4(1.0f), offset));