don't attempt to restore managed resources in GraphicsDevice::OnNewContext() if it's the first run (e.g. when things are guaranteed to be loaded already)

This commit is contained in:
Gered 2013-04-01 19:21:07 -04:00
parent 7f032498d7
commit 34bcbfaec9
2 changed files with 15 additions and 4 deletions

View file

@ -45,6 +45,8 @@ const unsigned int MAX_GPU_ATTRIB_SLOTS = 8;
GraphicsDevice::GraphicsDevice(GameWindow *window)
{
STACK_TRACE;
m_hasNewContextRunYet = FALSE;
m_boundVertexBuffer = NULL;
m_boundIndexBuffer = NULL;
m_boundShader = NULL;
@ -147,10 +149,17 @@ void GraphicsDevice::OnNewContext()
m_debugRenderer = new GeometryDebugRenderer(this);
m_solidColorTextures->OnNewContext();
for (ManagedResourceList::iterator i = m_managedResources.begin(); i != m_managedResources.end(); ++i)
(*i)->OnNewContext();
// don't attempt to restore old graphics resources if this is the first
// new context event (meaning, any managed resources will be loaded at this point!)
if (m_hasNewContextRunYet)
{
m_solidColorTextures->OnNewContext();
for (ManagedResourceList::iterator i = m_managedResources.begin(); i != m_managedResources.end(); ++i)
(*i)->OnNewContext();
}
m_hasNewContextRunYet = TRUE;
}
void GraphicsDevice::OnLostContext()

View file

@ -386,6 +386,8 @@ private:
Sprite2DShader *m_sprite2dShader;
Sprite3DShader *m_sprite3dShader;
DebugShader *m_debugShader;
BOOL m_hasNewContextRunYet;
};
inline void GraphicsDevice::SetTextureParameters(const TextureParameters &params)