diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 5147b76d9..dde5eeaed 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -794,16 +794,13 @@ int Graphics::getMaxPointSize() const return (int)max; } -void Graphics::print(const char *str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky) +void Graphics::print(const std::string &str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky) { if (currentFont != 0) - { - std::string text(str); - currentFont->print(text, x, y, 0.0, angle, sx, sy, ox, oy, kx, ky); - } + currentFont->print(str, x, y, 0.0, angle, sx, sy, ox, oy, kx, ky); } -void Graphics::printf(const char *str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky) +void Graphics::printf(const std::string &str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky) { if (currentFont == 0) return; @@ -811,8 +808,7 @@ void Graphics::printf(const char *str, float x, float y, float wrap, AlignMode a using std::string; using std::vector; - string text(str); - vector lines_to_draw = currentFont->getWrap(text, wrap); + vector lines_to_draw = currentFont->getWrap(str, wrap); glPushMatrix(); diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index 523b65ffc..241961693 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -386,7 +386,7 @@ public: * @param kx Shear along the x-axis. * @param ky Shear along the y-axis. **/ - void print(const char *str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky); + void print(const std::string &str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky); /** * Draw formatted text on screen at the specified coordinates. @@ -404,7 +404,7 @@ public: * @param kx Shear along the x-axis. * @param ky Shear along the y-axis. **/ - void printf(const char *str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky); + void printf(const std::string &str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky); /** * Draws a point at (x,y). diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index e7b8b3dc7..bafa44521 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -1161,7 +1161,7 @@ int w_drawg(lua_State *L) int w_print(lua_State *L) { - const char *str = luaL_checkstring(L, 1); + std::string str = luax_checkstring(L, 1); float x = (float)luaL_checknumber(L, 2); float y = (float)luaL_checknumber(L, 3); float angle = (float)luaL_optnumber(L, 4, 0.0f); @@ -1184,7 +1184,7 @@ int w_print(lua_State *L) int w_printf(lua_State *L) { - const char *str = luaL_checkstring(L, 1); + std::string str = luax_checkstring(L, 1); float x = (float)luaL_checknumber(L, 2); float y = (float)luaL_checknumber(L, 3); float wrap = (float)luaL_checknumber(L, 4);