diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index 568705f2b4..66acc14457 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -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) diff --git a/stepmania/src/RageBitmapTexture.h b/stepmania/src/RageBitmapTexture.h index e4752dd02f..3b2ad0cc96 100644 --- a/stepmania/src/RageBitmapTexture.h +++ b/stepmania/src/RageBitmapTexture.h @@ -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 diff --git a/stepmania/src/RageMovieTexture.cpp b/stepmania/src/RageMovieTexture.cpp index d0c7d96f13..f363898fae 100644 --- a/stepmania/src/RageMovieTexture.cpp +++ b/stepmania/src/RageMovieTexture.cpp @@ -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(); } diff --git a/stepmania/src/RageMovieTexture.h b/stepmania/src/RageMovieTexture.h index a87bfd90be..5e1bdd19da 100644 --- a/stepmania/src/RageMovieTexture.h +++ b/stepmania/src/RageMovieTexture.h @@ -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(); diff --git a/stepmania/src/RageTexture.cpp b/stepmania/src/RageTexture.cpp index 7dc00029d6..0071e34608 100644 --- a/stepmania/src/RageTexture.cpp +++ b/stepmania/src/RageTexture.cpp @@ -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() { diff --git a/stepmania/src/RageTexture.h b/stepmania/src/RageTexture.h index 84d6254d0c..64c4decc3c 100644 --- a/stepmania/src/RageTexture.h +++ b/stepmania/src/RageTexture.h @@ -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 diff --git a/stepmania/src/RageTextureManager.cpp b/stepmania/src/RageTextureManager.cpp index 2f7a6aa01d..fd24682160 100644 --- a/stepmania/src/RageTextureManager.cpp +++ b/stepmania/src/RageTextureManager.cpp @@ -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::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(); } }