Avoid calling RenderTarget::update from within loadResource

deque
scrawl 11 years ago
parent 8c26f802e6
commit 4a26dcb2ad

@ -504,6 +504,7 @@ namespace MWGui
void InventoryWindow::doRenderUpdate () void InventoryWindow::doRenderUpdate ()
{ {
mPreview->onFrame();
if (mPreviewDirty) if (mPreviewDirty)
{ {
mPreviewDirty = false; mPreviewDirty = false;

@ -37,6 +37,7 @@ namespace MWRender
, mViewport(NULL) , mViewport(NULL)
, mCamera(NULL) , mCamera(NULL)
, mNode(NULL) , mNode(NULL)
, mRecover(false)
{ {
mCharacter.mCell = NULL; mCharacter.mCell = NULL;
} }
@ -46,6 +47,16 @@ namespace MWRender
} }
void CharacterPreview::onFrame()
{
if (mRecover)
{
setupRenderTarget();
mRenderTarget->update();
mRecover = false;
}
}
void CharacterPreview::setup () void CharacterPreview::setup ()
{ {
mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC); mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
@ -127,9 +138,9 @@ namespace MWRender
tex->createInternalResources(); tex->createInternalResources();
setupRenderTarget(); mRenderTarget = NULL;
mViewport = NULL;
mRenderTarget->update(); mRecover = true;
} }
void CharacterPreview::setupRenderTarget() void CharacterPreview::setupRenderTarget()
@ -223,6 +234,10 @@ namespace MWRender
mViewport->setDimensions (0, 0, std::min(1.f, float(mSizeX) / float(512)), std::min(1.f, float(mSizeY) / float(1024))); mViewport->setDimensions (0, 0, std::min(1.f, float(mSizeX) / float(512)), std::min(1.f, float(mSizeY) / float(1024)));
mTexture->load(); mTexture->load();
if (!mRenderTarget)
setupRenderTarget();
mRenderTarget->update(); mRenderTarget->update();
mSelectionBuffer->update(); mSelectionBuffer->update();

@ -34,8 +34,13 @@ namespace MWRender
virtual void rebuild(); virtual void rebuild();
void onFrame();
void loadResource(Ogre::Resource *resource); void loadResource(Ogre::Resource *resource);
private:
bool mRecover; // Texture content was lost and needs to be re-rendered
private: private:
CharacterPreview(const CharacterPreview&); CharacterPreview(const CharacterPreview&);
CharacterPreview& operator=(const CharacterPreview&); CharacterPreview& operator=(const CharacterPreview&);

@ -51,9 +51,9 @@ namespace Render
tex->createInternalResources(); tex->createInternalResources();
setupRenderTarget(); mRenderTarget = NULL;
mRenderTarget->update(); // Don't need to re-render texture, because we have a copy in system memory (mBuffer)
} }
SelectionBuffer::~SelectionBuffer() SelectionBuffer::~SelectionBuffer()
@ -65,6 +65,9 @@ namespace Render
{ {
Ogre::MaterialManager::getSingleton ().addListener (this); Ogre::MaterialManager::getSingleton ().addListener (this);
if (mRenderTarget == NULL)
setupRenderTarget();
mRenderTarget->update(); mRenderTarget->update();
Ogre::MaterialManager::getSingleton ().removeListener (this); Ogre::MaterialManager::getSingleton ().removeListener (this);

Loading…
Cancel
Save