diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 903739654..bfb61bce1 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -50,6 +50,7 @@ #include "graphics/sp/sp_mesh_node.hpp" #include "graphics/sp/sp_shader_manager.hpp" #include "graphics/sp/sp_texture_manager.hpp" +#include "graphics/stk_text_billboard.hpp" #include "graphics/stk_tex_manager.hpp" #include "graphics/stk_texture.hpp" #include "graphics/sun.hpp" @@ -2351,6 +2352,7 @@ void IrrDriver::resizeWindow() // This will recreate the RTTs sbr->onLoadWorld(); } + STKTextBillboard::updateAllTextBillboards(); } #ifdef ENABLE_RECORDER diff --git a/src/graphics/stk_text_billboard.cpp b/src/graphics/stk_text_billboard.cpp index 826bc2f33..a453aa08f 100644 --- a/src/graphics/stk_text_billboard.cpp +++ b/src/graphics/stk_text_billboard.cpp @@ -93,6 +93,8 @@ void STKTextBillboard::updateAbsolutePosition() // ---------------------------------------------------------------------------- void STKTextBillboard::init(const core::stringw& text, FontWithFace* face) { + m_face = face; + m_text = text; m_chars = new std::vector(); core::dimension2du size = face->getDimension(text); face->drawText(text, core::rect(0, 0, size.Width, size.Height), @@ -263,6 +265,8 @@ void STKTextBillboard::init(const core::stringw& text, FontWithFace* face) // ---------------------------------------------------------------------------- void STKTextBillboard::initLegacy(const core::stringw& text, FontWithFace* face) { + m_face = face; + m_text = text; m_chars = new std::vector(); core::dimension2du size = face->getDimension(text); face->drawText(text, core::rect(0, 0, size.Width, size.Height), @@ -438,5 +442,34 @@ void STKTextBillboard::collectChar(video::ITexture* texture, colors)); } // collectChar +// ---------------------------------------------------------------------------- +void STKTextBillboard::reload() +{ + clearBuffer(); + if (CVS->isGLSL()) + init(m_text, m_face); + else + initLegacy(m_text, m_face); +} // reload + +// ---------------------------------------------------------------------------- +static void updateTextBillboard(core::list& List) +{ + core::list::Iterator I = List.begin(), E = List.end(); + for (; I != E; ++I) + { + if (STKTextBillboard* tb = dynamic_cast(*I)) + tb->reload(); + updateTextBillboard((*I)->getChildren()); + } +} // updateTextBillboard + +// ---------------------------------------------------------------------------- +void STKTextBillboard::updateAllTextBillboards() +{ + updateTextBillboard( + irr_driver->getSceneManager()->getRootSceneNode()->getChildren()); +} // updateAllTextBillboards + #endif // !SERVER_ONLY diff --git a/src/graphics/stk_text_billboard.hpp b/src/graphics/stk_text_billboard.hpp index 55e50cf85..8edbc3a8d 100644 --- a/src/graphics/stk_text_billboard.hpp +++ b/src/graphics/stk_text_billboard.hpp @@ -83,6 +83,10 @@ private: core::aabbox3df m_bbox; + FontWithFace* m_face; + + core::stringw m_text; + // ------------------------------------------------------------------------ float getDefaultScale(FontWithFace* face); public: @@ -94,6 +98,11 @@ public: const core::vector3df& scale = core::vector3df(1, 1, 1)); // ------------------------------------------------------------------------ ~STKTextBillboard() + { + clearBuffer(); + } + // ------------------------------------------------------------------------ + void clearBuffer() { #ifndef SERVER_ONLY if (m_instanced_array != 0) @@ -111,9 +120,12 @@ public: p.second->drop(); } m_gl_mb.clear(); + m_gl_tbs.clear(); #endif } // ------------------------------------------------------------------------ + void reload(); + // ------------------------------------------------------------------------ virtual void collectChar(video::ITexture* texture, const core::rect& dest_rect, const core::rect& source_rect, @@ -160,6 +172,8 @@ public: glBindBuffer(GL_ARRAY_BUFFER, 0); #endif } + // ------------------------------------------------------------------------ + static void updateAllTextBillboards(); }; #endif diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index 9b6a3888b..2938016a2 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -25,6 +25,7 @@ #include "font/regular_face.hpp" #include "graphics/camera_debug.hpp" #include "graphics/camera_fps.hpp" +#include "graphics/stk_text_billboard.hpp" #include "karts/explosion_animation.hpp" #include "graphics/irr_driver.hpp" #include "graphics/light.hpp" @@ -477,6 +478,9 @@ bool handleContextMenuAction(s32 cmd_id) font_manager->getFont()->reset(); font_manager->getFont()->reset(); font_manager->getFont()->reset(); +#ifndef SERVER_ONLY + STKTextBillboard::updateAllTextBillboards(); +#endif break; case DEBUG_FPS: UserConfigParams::m_display_fps =