X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2Frender.cpp;h=be59d2357befaa1eae6481008e8852d8ae64617d;hb=54deb92306a3de4fc1ee17fb7081a8b92f16ddda;hp=1a6d1abd80c124e7367969b863b84771ffc6b40b;hpb=50f35affb16c78bd3d0b420f5ba37d74fcac391f;p=blank.git diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 1a6d1ab..be59d23 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -1,7 +1,6 @@ #include "BlendedSprite.hpp" #include "Font.hpp" #include "Format.hpp" -#include "Text.hpp" #include "Texture.hpp" #include "Viewport.hpp" @@ -102,8 +101,8 @@ bool Font::HasGlyph(Uint16 c) const noexcept { } -glm::tvec2 Font::TextSize(const char *text) const { - glm::tvec2 size; +glm::ivec2 Font::TextSize(const char *text) const { + glm::ivec2 size; if (TTF_SizeUTF8(handle, text, &size.x, &size.y) != 0) { throw std::runtime_error(TTF_GetError()); } @@ -158,45 +157,6 @@ void Format::ReadPixelFormat(const SDL_PixelFormat &fmt) { } -Text::Text() noexcept -: tex() -, sprite() -, bg(1.0f, 1.0f, 1.0f, 0.0f) -, fg(1.0f, 1.0f, 1.0f, 1.0f) -, size(0.0f) -, pos(0.0f) -, grav(Gravity::NORTH_WEST) -, pivot(Gravity::NORTH_WEST) -, dirty(false) -, visible(false) { - -} - -void Text::Set(const Font &font, const char *text) { - font.Render(text, tex); - size = font.TextSize(text); - dirty = true; -} - -void Text::Update() { - sprite.LoadRect(size.x, size.y, align(pivot, size)); - dirty = false; -} - -void Text::Render(Viewport &viewport) noexcept { - if (dirty) { - Update(); - } - BlendedSprite &prog = viewport.SpriteProgram(); - viewport.SetCursor(pos, grav); - prog.SetM(viewport.Cursor()); - prog.SetTexture(tex); - prog.SetBG(bg); - prog.SetFG(fg); - sprite.Draw(); -} - - Texture::Texture() : handle(0) , width(0)