X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2Frender.cpp;h=96bcb12bf7cde601f972c82072aa87d9042c3ffe;hb=2025d49798b93180237b6ce62d3ff5d6ee8ebc6e;hp=5a0e492cd1d0343ba915fefba30bd957c1d7ff74;hpb=be413456f57da06e918ae7bf4c4f35e5198ff7ce;p=blobs.git diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 5a0e492..96bcb12 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -18,6 +18,10 @@ namespace blobs { namespace graphics { +Font::Font(const std::string &src, int size, long index) +: Font(src.c_str(), size, index) { +} + Font::Font(const char *src, int size, long index) : handle(TTF_OpenFontIndex(src, size, index)) { if (!handle) { @@ -115,12 +119,20 @@ glm::ivec2 Font::TextSize(const char *text) const { return size; } +glm::ivec2 Font::TextSize(const std::string &text) const { + return TextSize(text.c_str()); +} + Texture Font::Render(const char *text) const { Texture tex; Render(text, tex); return tex; } +Texture Font::Render(const std::string &text) const { + return Render(text.c_str()); +} + void Font::Render(const char *text, Texture &tex) const { SDL_Surface *srf = TTF_RenderUTF8_Blended(handle, text, { 0xFF, 0xFF, 0xFF, 0xFF }); if (!srf) { @@ -132,6 +144,10 @@ void Font::Render(const char *text, Texture &tex) const { SDL_FreeSurface(srf); } +void Font::Render(const std::string &text, Texture &tex) const { + Render(text.c_str(), tex); +} + Format::Format() noexcept : format(GL_BGRA) , type(GL_UNSIGNED_INT_8_8_8_8_REV)