//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : Scene.h Data : 27.09.15 Versione : 1.6i8 // Contenuto : Dichiarazione della classe gestione textures. // // // // Modifiche : 27.09.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include #include class Scene ; //---------------------------------------------------------------------------- struct TextureData { std::string sFile ; double dDimX ; double dDimY ; int nWidth ; int nHeight ; int nImgWidth ; int nImgHeight ; unsigned int nTexId ; int nRepeat ; TextureData( void) : dDimX( 0), dDimY( 0), nWidth( 0), nHeight( 0), nImgWidth( 0), nImgHeight( 0), nTexId( 0), nRepeat( 0) {} TextureData( std::string sF, double dX, double dY, int nW, int nH, int nImgW, int nImgH, unsigned int nT, int nR) : sFile( sF), dDimX( dX), dDimY( dY), nWidth( nW), nHeight( nH), nImgWidth( nImgW), nImgHeight( nImgH), nTexId( nT), nRepeat( nR) {} } ; typedef std::unordered_map STRTEXTD_UMAP ; struct FIBITMAP ; //---------------------------------------------------------------------------- class TextureMgr { public : TextureMgr( void) ; ~TextureMgr( void) ; public : void SetScene( Scene* pScene) { m_pScene = pScene ; } bool Clear( void) ; bool SetTextureMaxLinPixels( int nMaxLinPix) ; bool LoadTexture( const std::string& sName, const std::string& sPath, double dMMxPix, double dDimX, double dDimY, int nRepeat) ; bool Exists( const std::string& sName) const ; bool GetPixels( const std::string& sName, int& nWidth, int& nHeight) const ; bool GetImagePixels( const std::string& sName, int& nWidth, int& nHeight) const ; bool GetDimensions( const std::string& sName, double& dDimX, double& dDimY) const ; bool ChangeDimensions( const std::string& sName, double dDimX, double dDimY) ; bool UnloadTexture( const std::string& sName) ; bool GetTextureData( const std::string& sName, unsigned int& nId, double& dDimX, double& dDimY) const ; private : bool LoadCalcTexture( const std::string& sName, double dMMxPix, double dDimX, double dDimY, int nRepeat) ; bool ReadImage( const std::string& sFile, FIBITMAP*& pDib, int& nFilePixX, int& nFilePixY) ; bool TestImageWithOpenGL( FIBITMAP*& pDib) ; private : Scene* m_pScene ; // puntatore alla scena int m_nMaxLinPix ; // massima dimensione lineare in pixel STRTEXTD_UMAP m_umTextData ; // dati delle textures } ;