Add text billboard resizing
This commit is contained in:
parent
81def6cb65
commit
83a49068e4
@ -50,6 +50,7 @@
|
|||||||
#include "graphics/sp/sp_mesh_node.hpp"
|
#include "graphics/sp/sp_mesh_node.hpp"
|
||||||
#include "graphics/sp/sp_shader_manager.hpp"
|
#include "graphics/sp/sp_shader_manager.hpp"
|
||||||
#include "graphics/sp/sp_texture_manager.hpp"
|
#include "graphics/sp/sp_texture_manager.hpp"
|
||||||
|
#include "graphics/stk_text_billboard.hpp"
|
||||||
#include "graphics/stk_tex_manager.hpp"
|
#include "graphics/stk_tex_manager.hpp"
|
||||||
#include "graphics/stk_texture.hpp"
|
#include "graphics/stk_texture.hpp"
|
||||||
#include "graphics/sun.hpp"
|
#include "graphics/sun.hpp"
|
||||||
@ -2351,6 +2352,7 @@ void IrrDriver::resizeWindow()
|
|||||||
// This will recreate the RTTs
|
// This will recreate the RTTs
|
||||||
sbr->onLoadWorld();
|
sbr->onLoadWorld();
|
||||||
}
|
}
|
||||||
|
STKTextBillboard::updateAllTextBillboards();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_RECORDER
|
#ifdef ENABLE_RECORDER
|
||||||
|
@ -93,6 +93,8 @@ void STKTextBillboard::updateAbsolutePosition()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void STKTextBillboard::init(const core::stringw& text, FontWithFace* face)
|
void STKTextBillboard::init(const core::stringw& text, FontWithFace* face)
|
||||||
{
|
{
|
||||||
|
m_face = face;
|
||||||
|
m_text = text;
|
||||||
m_chars = new std::vector<STKTextBillboardChar>();
|
m_chars = new std::vector<STKTextBillboardChar>();
|
||||||
core::dimension2du size = face->getDimension(text);
|
core::dimension2du size = face->getDimension(text);
|
||||||
face->drawText(text, core::rect<s32>(0, 0, size.Width, size.Height),
|
face->drawText(text, core::rect<s32>(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)
|
void STKTextBillboard::initLegacy(const core::stringw& text, FontWithFace* face)
|
||||||
{
|
{
|
||||||
|
m_face = face;
|
||||||
|
m_text = text;
|
||||||
m_chars = new std::vector<STKTextBillboardChar>();
|
m_chars = new std::vector<STKTextBillboardChar>();
|
||||||
core::dimension2du size = face->getDimension(text);
|
core::dimension2du size = face->getDimension(text);
|
||||||
face->drawText(text, core::rect<s32>(0, 0, size.Width, size.Height),
|
face->drawText(text, core::rect<s32>(0, 0, size.Width, size.Height),
|
||||||
@ -438,5 +442,34 @@ void STKTextBillboard::collectChar(video::ITexture* texture,
|
|||||||
colors));
|
colors));
|
||||||
} // collectChar
|
} // 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<scene::ISceneNode*>& List)
|
||||||
|
{
|
||||||
|
core::list<scene::ISceneNode*>::Iterator I = List.begin(), E = List.end();
|
||||||
|
for (; I != E; ++I)
|
||||||
|
{
|
||||||
|
if (STKTextBillboard* tb = dynamic_cast<STKTextBillboard*>(*I))
|
||||||
|
tb->reload();
|
||||||
|
updateTextBillboard((*I)->getChildren());
|
||||||
|
}
|
||||||
|
} // updateTextBillboard
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void STKTextBillboard::updateAllTextBillboards()
|
||||||
|
{
|
||||||
|
updateTextBillboard(
|
||||||
|
irr_driver->getSceneManager()->getRootSceneNode()->getChildren());
|
||||||
|
} // updateAllTextBillboards
|
||||||
|
|
||||||
#endif // !SERVER_ONLY
|
#endif // !SERVER_ONLY
|
||||||
|
|
||||||
|
@ -83,6 +83,10 @@ private:
|
|||||||
|
|
||||||
core::aabbox3df m_bbox;
|
core::aabbox3df m_bbox;
|
||||||
|
|
||||||
|
FontWithFace* m_face;
|
||||||
|
|
||||||
|
core::stringw m_text;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
float getDefaultScale(FontWithFace* face);
|
float getDefaultScale(FontWithFace* face);
|
||||||
public:
|
public:
|
||||||
@ -94,6 +98,11 @@ public:
|
|||||||
const core::vector3df& scale = core::vector3df(1, 1, 1));
|
const core::vector3df& scale = core::vector3df(1, 1, 1));
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
~STKTextBillboard()
|
~STKTextBillboard()
|
||||||
|
{
|
||||||
|
clearBuffer();
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
void clearBuffer()
|
||||||
{
|
{
|
||||||
#ifndef SERVER_ONLY
|
#ifndef SERVER_ONLY
|
||||||
if (m_instanced_array != 0)
|
if (m_instanced_array != 0)
|
||||||
@ -111,9 +120,12 @@ public:
|
|||||||
p.second->drop();
|
p.second->drop();
|
||||||
}
|
}
|
||||||
m_gl_mb.clear();
|
m_gl_mb.clear();
|
||||||
|
m_gl_tbs.clear();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
void reload();
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
virtual void collectChar(video::ITexture* texture,
|
virtual void collectChar(video::ITexture* texture,
|
||||||
const core::rect<float>& dest_rect,
|
const core::rect<float>& dest_rect,
|
||||||
const core::rect<irr::s32>& source_rect,
|
const core::rect<irr::s32>& source_rect,
|
||||||
@ -160,6 +172,8 @@ public:
|
|||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
static void updateAllTextBillboards();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "font/regular_face.hpp"
|
#include "font/regular_face.hpp"
|
||||||
#include "graphics/camera_debug.hpp"
|
#include "graphics/camera_debug.hpp"
|
||||||
#include "graphics/camera_fps.hpp"
|
#include "graphics/camera_fps.hpp"
|
||||||
|
#include "graphics/stk_text_billboard.hpp"
|
||||||
#include "karts/explosion_animation.hpp"
|
#include "karts/explosion_animation.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/light.hpp"
|
#include "graphics/light.hpp"
|
||||||
@ -477,6 +478,9 @@ bool handleContextMenuAction(s32 cmd_id)
|
|||||||
font_manager->getFont<BoldFace>()->reset();
|
font_manager->getFont<BoldFace>()->reset();
|
||||||
font_manager->getFont<DigitFace>()->reset();
|
font_manager->getFont<DigitFace>()->reset();
|
||||||
font_manager->getFont<RegularFace>()->reset();
|
font_manager->getFont<RegularFace>()->reset();
|
||||||
|
#ifndef SERVER_ONLY
|
||||||
|
STKTextBillboard::updateAllTextBillboards();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case DEBUG_FPS:
|
case DEBUG_FPS:
|
||||||
UserConfigParams::m_display_fps =
|
UserConfigParams::m_display_fps =
|
||||||
|
Loading…
Reference in New Issue
Block a user