EgtGraphics :
- migliorata gestione textures.
This commit is contained in:
+35
-2
@@ -21,7 +21,6 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
TextureMgr::TextureMgr( void)
|
||||
{
|
||||
@@ -42,7 +41,7 @@ TextureMgr::~TextureMgr( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::LoadTexture( const string& sName, const string& sFile, double dDimX, double dDimY, bool bRepeat)
|
||||
TextureMgr::LoadTexture( const string& sName, const string& sFile, double dMMxPix, double dDimX, double dDimY, bool bRepeat)
|
||||
{
|
||||
// verifico se immagine già caricata
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
@@ -93,6 +92,12 @@ TextureMgr::LoadTexture( const string& sName, const string& sFile, double dDimX,
|
||||
// rendo non corrente questa texture
|
||||
glBindTexture( GL_TEXTURE_2D, 0) ;
|
||||
|
||||
// se dati mm/pixel determino le dimensioni fisiche della texture
|
||||
if ( dMMxPix > EPS_SMALL && ( dDimX < EPS_SMALL || dDimY < EPS_SMALL)) {
|
||||
dDimX = dMMxPix * nWidth ;
|
||||
dDimY = dMMxPix * nHeight ;
|
||||
}
|
||||
|
||||
// salvo i dati
|
||||
TextureData textData( sFile, dDimX, dDimY, nWidth, nHeight, nTexName, bRepeat) ;
|
||||
m_umTextData.emplace( sName, textData) ;
|
||||
@@ -116,6 +121,34 @@ TextureMgr::UnloadTexture( const std::string& sName)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::GetPixels( const std::string& sName, int& nWidth, int& nHeight)
|
||||
{
|
||||
// ricerca della texture di nome dato
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
if ( iIter == m_umTextData.end())
|
||||
return false ;
|
||||
// restituisco le dimensioni in pixel
|
||||
nWidth = iIter->second.nWidth ;
|
||||
nHeight = iIter->second.nHeight ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::GetDimensions( const std::string& sName, double& dDimX, double& dDimY)
|
||||
{
|
||||
// ricerca della texture di nome dato
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
if ( iIter == m_umTextData.end())
|
||||
return false ;
|
||||
// restituisco le dimensioni fisiche
|
||||
dDimX = iIter->second.dDimX ;
|
||||
dDimY = iIter->second.dDimY ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::ChangeDimensions( const std::string& sName, double dDimX, double dDimY)
|
||||
|
||||
Reference in New Issue
Block a user