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