FIX: Position of Text
This commit is contained in:
parent
be0eb3bae8
commit
441ea64a2f
@ -10,7 +10,7 @@
|
||||
class Font;
|
||||
|
||||
|
||||
class UiText : public UiComponent, public std::enable_shared_from_this<UiText> {
|
||||
class UiText : public UiComponent {
|
||||
public:
|
||||
UiText(Font& font, std::string text, const glm::vec2& relativePos, const glm::vec2& relativeSize);
|
||||
void setText(const std::string& text);
|
||||
|
||||
@ -28,8 +28,12 @@ void TextRenderer::renderText(const UiText &textToRender) const {
|
||||
const Font& font = textToRender.getFont();
|
||||
const std::string& text = textToRender.getText();
|
||||
|
||||
float x = d.x;
|
||||
float y = d.y;
|
||||
float screenX = d.x * Application::getInstance().getWindow().GetWidth();
|
||||
float screenY = d.y * Application::getInstance().getWindow().GetHeight();
|
||||
|
||||
float x = screenX;
|
||||
float y = screenY;
|
||||
|
||||
|
||||
float scale = 1.0f;
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ void UILayer::onAttach() {
|
||||
|
||||
Font myFont("/usr/share/fonts/TTF/DejaVuSans.ttf", 48);
|
||||
font = std::make_unique<Font>(myFont);
|
||||
auto text = std::make_unique<UiText>(*font, "Hello World!", glm::vec2(0.5f, 0.5f), glm::vec2(0.3f, 0.1f));
|
||||
auto text = std::make_unique<UiText>(*font, "Hello World!", glm::vec2(0.5f, 0.5f), glm::vec2(1.f));
|
||||
|
||||
rootContainer->addChild(std::move(text));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user