Fix an indirect movie texture crash (reset PixelStore)
Simplify texture handling: m_ID is const (can't be changed after load at all); preference overrides are handled in RageTexture; reloads no longer need a parameter
This commit is contained in:
@@ -117,9 +117,9 @@ RageBitmapTexture::~RageBitmapTexture()
|
||||
glDeleteTextures(1, &m_uGLTextureID);
|
||||
}
|
||||
|
||||
void RageBitmapTexture::Reload( RageTextureID ID )
|
||||
void RageBitmapTexture::Reload()
|
||||
{
|
||||
RageTexture::Reload(ID);
|
||||
RageTexture::Reload();
|
||||
DISPLAY->SetTexture(0);
|
||||
|
||||
if(m_uGLTextureID)
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual ~RageBitmapTexture();
|
||||
/* only called by RageTextureManager::InvalidateTextures */
|
||||
virtual void Invalidate() { m_uGLTextureID = 0; }
|
||||
virtual void Reload( RageTextureID name );
|
||||
virtual void Reload();
|
||||
|
||||
private:
|
||||
void Create(); // called by constructor and Reload
|
||||
|
||||
@@ -79,7 +79,7 @@ RageMovieTexture::~RageMovieTexture()
|
||||
glDeleteTextures(1, &m_uGLTextureID);
|
||||
}
|
||||
|
||||
void RageMovieTexture::Reload( RageTextureID ID )
|
||||
void RageMovieTexture::Reload()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@@ -116,6 +116,9 @@ void RageMovieTexture::Update(float fDeltaTime)
|
||||
min(m_iSourceHeight, m_iTextureHeight),
|
||||
GL_BGR, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
/* Must unset PixelStore when we're done! */
|
||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
virtual ~RageMovieTexture();
|
||||
void Update(float fDeltaTime);
|
||||
|
||||
virtual void Reload( RageTextureID ID );
|
||||
virtual void Reload();
|
||||
|
||||
virtual void Play();
|
||||
virtual void Pause();
|
||||
|
||||
@@ -21,7 +21,7 @@ void RageTextureID::Init()
|
||||
iAlphaBits = 4;
|
||||
bDither = false;
|
||||
bStretch = false;
|
||||
iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
||||
iColorDepth = -1; /* default */
|
||||
bHotPinkColorKey = false;
|
||||
}
|
||||
|
||||
@@ -39,19 +39,36 @@ bool RageTextureID::equal(const RageTextureID &rhs) const
|
||||
}
|
||||
|
||||
|
||||
RageTexture::RageTexture( RageTextureID name )
|
||||
RageTexture::RageTexture( RageTextureID name ):
|
||||
m_ID(name)
|
||||
{
|
||||
// LOG->Trace( "RageTexture::RageTexture()" );
|
||||
|
||||
m_ID = m_ActualID = name;
|
||||
m_iRefCount = 1;
|
||||
|
||||
SetActualID();
|
||||
m_iSourceWidth = m_iSourceHeight = 0;
|
||||
m_iTextureWidth = m_iTextureHeight = 0;
|
||||
m_iImageWidth = m_iImageHeight = 0;
|
||||
m_iFramesWide = m_iFramesHigh = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Set the initial ActualID; this is what the actual texture will start
|
||||
* from. */
|
||||
void RageTexture::SetActualID()
|
||||
{
|
||||
m_ActualID = m_ID;
|
||||
|
||||
/* Texture color depth preference can be overridden. */
|
||||
if(m_ID.iColorDepth == -1)
|
||||
m_ActualID.iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
||||
|
||||
/* The max texture size can never be higher than the preference,
|
||||
* since it might be set to something to fix driver problems. */
|
||||
m_ActualID.iMaxSize = min(m_ActualID.iMaxSize, TEXTUREMAN->GetMaxTextureResolution());
|
||||
}
|
||||
|
||||
RageTexture::~RageTexture()
|
||||
{
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
RageTexture( RageTextureID file );
|
||||
virtual ~RageTexture() = 0;
|
||||
virtual void Update( float fDeltaTime ) {}
|
||||
virtual void Reload( RageTextureID ID ) { m_ID = m_ActualID = ID; }
|
||||
virtual void Reload() { SetActualID(); }
|
||||
virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */
|
||||
virtual unsigned int GetGLTextureID() = 0; // accessed by RageDisplay
|
||||
|
||||
@@ -99,7 +99,9 @@ public:
|
||||
|
||||
private:
|
||||
/* The file we were asked to load. (This is never changed.) */
|
||||
RageTextureID m_ID;
|
||||
const RageTextureID m_ID;
|
||||
|
||||
void SetActualID();
|
||||
|
||||
protected:
|
||||
/* We might change settings when loading (due to hints, hardware
|
||||
|
||||
@@ -88,8 +88,6 @@ RageTexture* RageTextureManager::LoadTexture( RageTextureID ID )
|
||||
}
|
||||
|
||||
// the texture is not already loaded. Load it.
|
||||
ID.iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
||||
ID.iMaxSize = TEXTUREMAN->GetMaxTextureResolution();
|
||||
|
||||
CString sDir, sFName, sExt;
|
||||
splitpath( ID.filename, sDir, sFName, sExt );
|
||||
@@ -200,24 +198,7 @@ void RageTextureManager::ReloadAll()
|
||||
for( std::map<RageTextureID, RageTexture*>::iterator i = m_mapPathToTexture.begin();
|
||||
i != m_mapPathToTexture.end(); ++i)
|
||||
{
|
||||
RageTexture* pTexture = i->second;
|
||||
|
||||
/* A note on how this really works:
|
||||
*
|
||||
* The ID identifies a texture, and all of the parameters needed
|
||||
* to produce it. When we load a texture, iColorDepth is pulled
|
||||
* from GetTextureColorDepth(). Now we're reloading it, probably
|
||||
* due to a change in display settings, so we need to update that
|
||||
* to the current setting and reload it. This will also change
|
||||
* the data in our map (which is OK; it's not part of the ordering)
|
||||
* to reflect this. */
|
||||
|
||||
/* Update the settings that are based on preferences. */
|
||||
RageTextureID ID = i->first;
|
||||
ID.iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
||||
ID.iMaxSize = TEXTUREMAN->GetMaxTextureResolution();
|
||||
|
||||
pTexture->Reload( ID );
|
||||
i->second->Reload();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user