fix up bit depth stuff
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
|
||||
#include "RageBitmapTexture.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageException.h"
|
||||
@@ -88,8 +87,9 @@ RageBitmapTexture::~RageBitmapTexture()
|
||||
glDeleteTextures(1, &m_uGLTextureID);
|
||||
}
|
||||
|
||||
void RageBitmapTexture::Reload( RageTextureID name )
|
||||
void RageBitmapTexture::Reload( RageTextureID ID )
|
||||
{
|
||||
RageTexture::Reload(ID);
|
||||
DISPLAY->SetTexture(0);
|
||||
|
||||
if(m_uGLTextureID)
|
||||
@@ -122,7 +122,7 @@ void RageBitmapTexture::Create()
|
||||
else if( HintString.Find("1 alpha") != -1 ) m_ActualID.iAlphaBits = 1;
|
||||
else if( HintString.Find("1alpha") != -1 ) m_ActualID.iAlphaBits = 1;
|
||||
else if( HintString.Find("0alpha") != -1 ) m_ActualID.iAlphaBits = 0;
|
||||
if( HintString.Find("dither") != -1 ) m_ActualID.bDither = true;
|
||||
if( HintString.Find("dither") != -1 ) m_ActualID.bDither = true;
|
||||
|
||||
/* Load the image into an SDL surface. */
|
||||
/* XXX we were lowercasing this before */
|
||||
@@ -135,7 +135,7 @@ void RageBitmapTexture::Create()
|
||||
/* Figure out which texture format to use. */
|
||||
GLenum fmtTexture;
|
||||
|
||||
if( TEXTUREMAN->GetTextureColorDepth() == 16 )
|
||||
if( m_ActualID.iColorDepth == 16 )
|
||||
{
|
||||
/* Bits of alpha in the source: */
|
||||
int src_alpha_bits = 8 - img->format->Aloss;
|
||||
@@ -164,10 +164,10 @@ void RageBitmapTexture::Create()
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( TEXTUREMAN->GetTextureColorDepth() == 32 )
|
||||
else if( m_ActualID.iColorDepth == 32 )
|
||||
fmtTexture = GL_RGBA8;
|
||||
else
|
||||
RageException::Throw( "Invalid color depth: %d bits", TEXTUREMAN->GetTextureColorDepth() );
|
||||
RageException::Throw( "Invalid color depth: %d bits", m_ActualID.iColorDepth );
|
||||
|
||||
/* Cap the max texture size to the hardware max. */
|
||||
m_ActualID.iMaxSize = min( m_ActualID.iMaxSize, DISPLAY->GetMaxTextureSize() );
|
||||
|
||||
@@ -9,18 +9,21 @@
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "RageTexture.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include <string.h>
|
||||
|
||||
void RageTextureID::Init()
|
||||
{
|
||||
iMaxSize = 2048;
|
||||
iMipMaps = 4;
|
||||
iAlphaBits = 4;
|
||||
bDither = false;
|
||||
bStretch = false;
|
||||
iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RageTexture constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
RageTexture::RageTexture( RageTextureID name )
|
||||
{
|
||||
// LOG->Trace( "RageTexture::RageTexture()" );
|
||||
|
||||
@@ -26,20 +26,14 @@ struct RageTextureID
|
||||
int iMaxSize;
|
||||
int iMipMaps;
|
||||
int iAlphaBits;
|
||||
int iColorDepth;
|
||||
bool bDither;
|
||||
bool bStretch;
|
||||
|
||||
/* Define an ordering so this can be used in a set<>. */
|
||||
bool operator< (const RageTextureID &rhs) const { return filename < rhs.filename; }
|
||||
void Init();
|
||||
|
||||
void Init()
|
||||
{
|
||||
iMaxSize = 2048;
|
||||
iMipMaps = 4;
|
||||
iAlphaBits = 4;
|
||||
bDither = false;
|
||||
bStretch = false;
|
||||
}
|
||||
RageTextureID() { Init(); }
|
||||
RageTextureID(const CString &fn) { Init(); filename=fn; }
|
||||
};
|
||||
@@ -53,7 +47,7 @@ public:
|
||||
RageTexture( RageTextureID file );
|
||||
virtual ~RageTexture() = 0;
|
||||
virtual void Update( float fDeltaTime ) {}
|
||||
virtual void Reload( RageTextureID file ) = 0;
|
||||
virtual void Reload( RageTextureID ID ) { m_ID = m_ActualID = ID; }
|
||||
virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */
|
||||
virtual unsigned int GetGLTextureID() = 0; // accessed by RageDisplay
|
||||
|
||||
|
||||
@@ -191,7 +191,21 @@ void RageTextureManager::ReloadAll()
|
||||
{
|
||||
RageTexture* pTexture = i->second;
|
||||
|
||||
pTexture->Reload( i->first );
|
||||
/* 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();
|
||||
|
||||
pTexture->Reload( ID );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user