]> git.localhorst.tv Git - blobs.git/blobdiff - src/graphics/render.cpp
basic info box
[blobs.git] / src / graphics / render.cpp
index 5a0e492cd1d0343ba915fefba30bd957c1d7ff74..96bcb12bf7cde601f972c82072aa87d9042c3ffe 100644 (file)
 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)