Files
EgtGraphics/TextureMgr.h
T
Dario Sassi 4a8c2c2e1b EgtGraphics 1.6j1 :
- aggiunto TextureMgr per gestire le textures caricate
- fatte modifiche per visualizzare gli oggetti con le textures (solo opachi).
2015-10-11 18:02:06 +00:00

69 lines
2.5 KiB
C++

//----------------------------------------------------------------------------
// 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 <string>
#include <unordered_map>
class Scene ;
//----------------------------------------------------------------------------
struct TextureData {
std::string sFile ;
double dDimX ;
double dDimY ;
int nWidth ;
int nHeight ;
unsigned int nTexId ;
int nRepeat ;
TextureData( void)
: dDimX( 0), dDimY( 0), nWidth( 0), nHeight( 0), nTexId( 0), nRepeat( 0) {}
TextureData( std::string sF, double dX, double dY, int nW, int nH, unsigned int nT, int nR)
: sFile( sF), dDimX( dX), dDimY( dY), nWidth( nW), nHeight( nH), nTexId( nT), nRepeat( nR) {}
} ;
typedef std::unordered_map<std::string,TextureData> STRTEXTD_UMAP ;
struct FIBITMAP ;
//----------------------------------------------------------------------------
class TextureMgr
{
public :
TextureMgr( void) ;
~TextureMgr( void) ;
public :
void SetScene( Scene* pScene)
{ m_pScene = pScene ; }
bool Clear( void) ;
bool LoadTexture( const std::string& sName, const std::string& sPath,
double dMMxPix, double dDimX, double dDimY, int nRepeat) ;
bool Exists( const std::string& sName) ;
bool GetPixels( const std::string& sName, int& nWidth, int& nHeight) ;
bool GetDimensions( const std::string& sName, double& dDimX, double& dDimY) ;
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) ;
private :
bool LoadCalcTexture( const std::string& sName,
double dMMxPix, double dDimX, double dDimY, int nRepeat) ;
bool ReadImage( const std::string& sFile, FIBITMAP*& pDib) ;
bool TestImageWithOpenGL( FIBITMAP*& pDib) ;
private :
Scene* m_pScene ; // puntatore alla scena
STRTEXTD_UMAP m_umTextData ; // dati delle textures
} ;