mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
19 lines
589 B
C++
19 lines
589 B
C++
#include "Canvas.hpp"
|
|
|
|
#include "graphics/core/Batch2D.hpp"
|
|
#include "graphics/core/DrawContext.hpp"
|
|
#include "graphics/core/Texture.hpp"
|
|
|
|
gui::Canvas::Canvas(ImageFormat inFormat, glm::uvec2 inSize) : UINode(inSize) {
|
|
ImageData data {inFormat, inSize.x, inSize.y};
|
|
mTexture = Texture::from(&data);
|
|
}
|
|
|
|
void gui::Canvas::draw(const DrawContext& pctx, const Assets& assets) {
|
|
auto pos = calcPos();
|
|
auto col = calcColor();
|
|
|
|
auto batch = pctx.getBatch2D();
|
|
batch->texture(mTexture.get());
|
|
batch->rect(pos.x, pos.y, size.x, size.y, 0, 0, 0, {}, false, true, col);
|
|
}
|