Fix some RTT-related leaks

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8503 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-05-02 01:39:23 +00:00
parent b183a8b250
commit 532053d319
6 changed files with 22 additions and 6 deletions

View File

@ -1354,10 +1354,13 @@ bool IrrDriver::OnEvent(const irr::SEvent &event)
/** Begins a rendering to a texture.
* \param dimension The size of the texture.
* \param name Name of the texture.
* \param persistent_texture Whether the created RTT texture should persist in
* memory after the RTTProvider is deleted
*/
IrrDriver::RTTProvider::RTTProvider(const core::dimension2du &dimension,
const std::string &name)
{
const std::string &name, bool persistent_texture)
{
m_persistent_texture = persistent_texture;
m_video_driver = irr_driver->getVideoDriver();
m_render_target_texture =
m_video_driver->addRenderTargetTexture(dimension,
@ -1377,6 +1380,9 @@ IrrDriver::RTTProvider::RTTProvider(const core::dimension2du &dimension,
IrrDriver::RTTProvider::~RTTProvider()
{
tearDownRTTScene();
if (!m_persistent_texture)
irr_driver->removeTexture(m_render_target_texture);
} // ~RTTProvider
// ----------------------------------------------------------------------------

View File

@ -194,6 +194,8 @@ public:
* in between beginRenderToTexture() and endRenderToTexture calls. */
video::ITexture *m_render_target_texture;
bool m_persistent_texture;
/** Main node of the RTT scene */
scene::ISceneNode *m_rtt_main_node;
@ -206,7 +208,7 @@ public:
public:
RTTProvider(const core::dimension2du &dimension,
const std::string &name);
const std::string &name, bool persistent_texture);
~RTTProvider();

View File

@ -150,7 +150,7 @@ void ModelViewWidget::update(float delta)
{
std::string name = "model view ";
name += m_properties[PROP_ID].c_str();
m_rtt_provider = new IrrDriver::RTTProvider(core::dimension2d< u32 >(512, 512), name );
m_rtt_provider = new IrrDriver::RTTProvider(core::dimension2d< u32 >(512, 512), name, false);
m_rtt_provider->setupRTTScene(m_models, m_model_location, m_model_scale, m_model_frames);
}
@ -184,3 +184,9 @@ void ModelViewWidget::setRotateTo(float targetAngle, float speed)
m_rotation_target = targetAngle;
}
void ModelViewWidget::elementRemoved()
{
delete m_rtt_provider;
m_rtt_provider = NULL;
IconButtonWidget::elementRemoved();
}

View File

@ -71,6 +71,8 @@ namespace GUIEngine
void update(float delta);
virtual void elementRemoved();
/** Disables any model rotation */
void setRotateOff();

View File

@ -83,7 +83,7 @@ void RaceGUIBase::createMarkerTexture()
IrrDriver::RTTProvider rttProvider(core::dimension2du(m_marker_rendered_size
*npower2,
m_marker_rendered_size),
"RaceGUI::markers");
"RaceGUI::markers", true);
scene::ICameraSceneNode *camera = irr_driver->addCameraSceneNode();
core::matrix4 projection;
projection.buildProjectionMatrixOrthoLH((float)(m_marker_rendered_size*npower2),

View File

@ -624,7 +624,7 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2du &dimension,
const std::string &name,
const video::SColor &fill_color)
{
IrrDriver::RTTProvider rttProvider(dimension, name);
IrrDriver::RTTProvider rttProvider(dimension, name, true);
video::SColor red(128, 255, 0, 0);
createMesh(/*show_invisible part of the track*/ false,
/*track_color*/ &fill_color,