Files
itgmania212121/stepmania/src/RageTextureManager.h
T

127 lines
4.2 KiB
C++
Raw Normal View History

2005-02-13 03:00:19 +00:00
/* RageTextureManager - Interface for loading textures. */
2004-05-06 02:40:33 +00:00
2002-11-16 07:36:02 +00:00
#ifndef RAGE_TEXTURE_MANAGER_H
#define RAGE_TEXTURE_MANAGER_H
2001-11-03 10:52:42 +00:00
#include "RageTexture.h"
2002-09-07 08:20:10 +00:00
#include <map>
2001-11-03 10:52:42 +00:00
struct RageTextureManagerPrefs
{
int m_iTextureColorDepth;
int m_iMovieColorDepth;
bool m_bDelayedDelete;
int m_iMaxTextureResolution;
2004-08-28 09:29:55 +00:00
bool m_bMipMaps;
RageTextureManagerPrefs()
{
m_bDelayedDelete = false;
m_iMovieColorDepth = 16;
m_iTextureColorDepth = 16;
m_iMaxTextureResolution = 1024;
2004-08-28 09:29:55 +00:00
m_bMipMaps = false;
}
RageTextureManagerPrefs(
int iTextureColorDepth,
int iMovieColorDepth,
bool bDelayedDelete,
2004-08-28 09:29:55 +00:00
int iMaxTextureResolution,
bool bMipMaps )
{
2004-08-28 09:29:55 +00:00
m_bDelayedDelete = bDelayedDelete;
m_iMovieColorDepth = iMovieColorDepth;
m_iTextureColorDepth = iTextureColorDepth;
m_iMaxTextureResolution = iMaxTextureResolution;
2004-08-28 09:29:55 +00:00
m_bMipMaps = bMipMaps;
}
2005-02-13 03:00:19 +00:00
bool operator!=( const RageTextureManagerPrefs& rhs ) const
{
return
m_iTextureColorDepth != rhs.m_iTextureColorDepth ||
m_iMovieColorDepth != rhs.m_iMovieColorDepth ||
m_bDelayedDelete != rhs.m_bDelayedDelete ||
2004-08-28 09:29:55 +00:00
m_iMaxTextureResolution != rhs.m_iMaxTextureResolution ||
m_bMipMaps != rhs.m_bMipMaps;
}
};
2001-11-03 10:52:42 +00:00
class RageTextureManager
{
public:
2003-04-18 23:55:20 +00:00
RageTextureManager();
2001-11-03 10:52:42 +00:00
~RageTextureManager();
2005-06-17 00:30:07 +00:00
void Update( float fDeltaTime );
2001-11-03 10:52:42 +00:00
RageTexture* LoadTexture( RageTextureID ID );
2005-07-03 02:30:45 +00:00
RageTexture* CopyTexture( RageTexture *pCopy ); // returns a ref to the same texture, not a deep copy
bool IsTextureRegistered( RageTextureID ID ) const;
void RegisterTexture( RageTextureID ID, RageTexture *p );
2003-06-10 19:24:00 +00:00
void VolatileTexture( RageTextureID ID );
void UnloadTexture( RageTexture *t );
2002-04-28 20:42:32 +00:00
void ReloadAll();
2001-11-03 10:52:42 +00:00
bool SetPrefs( RageTextureManagerPrefs prefs );
RageTextureManagerPrefs GetPrefs() { return m_Prefs; };
RageTextureID::TexPolicy GetDefaultTexturePolicy() const { return m_TexturePolicy; }
void SetDefaultTexturePolicy( RageTextureID::TexPolicy p ) { m_TexturePolicy = p; }
2003-04-18 23:55:20 +00:00
// call this between Screens
2005-06-17 00:30:07 +00:00
void DeleteCachedTextures() { GarbageCollect( screen_changed ); }
2003-04-18 23:55:20 +00:00
// call this on switch theme
2005-06-17 00:30:07 +00:00
void DoDelayedDelete() { GarbageCollect( delayed_delete ); }
2003-04-18 23:55:20 +00:00
void InvalidateTextures();
2005-06-17 00:30:07 +00:00
void AdjustTextureID( RageTextureID &ID ) const;
void DiagnosticOutput() const;
2003-04-24 19:51:27 +00:00
void DisableOddDimensionWarning() { m_iNoWarnAboutOddDimensions++; }
void EnableOddDimensionWarning() { m_iNoWarnAboutOddDimensions--; }
bool GetOddDimensionWarning() const { return m_iNoWarnAboutOddDimensions == 0; }
2005-06-17 00:30:07 +00:00
private:
2003-04-18 23:55:20 +00:00
void DeleteTexture( RageTexture *t );
2003-06-10 19:24:00 +00:00
enum GCType { screen_changed, delayed_delete };
2003-04-18 23:55:20 +00:00
void GarbageCollect( GCType type );
2003-06-10 19:24:00 +00:00
RageTexture* LoadTextureInternal( RageTextureID ID );
2005-06-17 00:30:07 +00:00
RageTextureManagerPrefs m_Prefs;
std::map<RageTextureID, RageTexture*> m_mapPathToTexture;
int m_iNoWarnAboutOddDimensions;
RageTextureID::TexPolicy m_TexturePolicy;
2001-11-03 10:52:42 +00:00
};
2002-05-19 01:59:48 +00:00
extern RageTextureManager* TEXTUREMAN; // global and accessable from anywhere in our program
2002-11-16 07:36:02 +00:00
#endif
2004-05-06 02:40:33 +00:00
/*
* Copyright (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/