Dawn/archive/ui/UISprite.cpp
2023-03-05 12:58:59 -08:00

43 lines
999 B
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "UISprite.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
UISprite::UISprite(UICanvas *canvas) : UIComponent(canvas) {
this->mesh.createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
}
void UISprite::updatePositions() {
UIComponent::updatePositions();
QuadMesh::bufferQuadMesh(
&this->mesh,
glm::vec2(0, 0), glm::vec2(0, 0),
glm::vec2(this->width, this->height), glm::vec2(1, 1),
0, 0
);
}
std::vector<struct ShaderPassItem> UISprite::getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) {
std::vector<struct ShaderPassItem> items;
items.push_back(this->getGame()->renderManager.uiShaderProgram.getUIPassItem(
projection,
view,
transform,
this->texture,
this->color,
&this->mesh,
this->z
));
return items;
}