EgtGraphics 1.6j1 :
- aggiunto TextureMgr per gestire le textures caricate - fatte modifiche per visualizzare gli oggetti con le textures (solo opachi).
This commit is contained in:
Binary file not shown.
+1
-3
@@ -234,9 +234,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="OpenGL.h" />
|
||||
<ClInclude Include="Scene.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClCompile Include="SceneTexture.cpp">
|
||||
<FileType>CppHeader</FileType>
|
||||
</ClCompile>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="TextureMgr.h" />
|
||||
</ItemGroup>
|
||||
@@ -253,6 +250,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="SceneGrid.cpp" />
|
||||
<ClCompile Include="SceneSelect.cpp" />
|
||||
<ClCompile Include="SceneSnap.cpp" />
|
||||
<ClCompile Include="SceneTexture.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
|
||||
@@ -163,8 +163,10 @@ class Scene : public IEGrScene
|
||||
return true ; }
|
||||
// Texture
|
||||
virtual bool LoadTexture( const std::string& sName, const std::string& sFile,
|
||||
double dMMxPix, double dDimX, double dDimY, bool bRepeat) ;
|
||||
double dMMxPix, double dDimX, double dDimY, int nRepeat) ;
|
||||
virtual bool UnloadTexture( const std::string& sName) ;
|
||||
virtual bool UnloadAllTextures( void) ;
|
||||
virtual bool ExistsTexture( const std::string& sName) ;
|
||||
virtual bool GetTexturePixels( const std::string& sName, int& nWidth, int& nHeight) ;
|
||||
virtual bool GetTextureDimensions( const std::string& sName, double& dDimX, double& dDimY) ;
|
||||
virtual bool ChangeTextureDimensions( const std::string& sName, double dDimX, double dDimY) ;
|
||||
@@ -175,6 +177,8 @@ class Scene : public IEGrScene
|
||||
bool MakeCurrent( void) ;
|
||||
GLEWContext* glewGetContext( void)
|
||||
{ return &m_glewc ; }
|
||||
int GetOpenGLver( void)
|
||||
{ return m_nOglVer ; }
|
||||
// Geometry
|
||||
Color GetMark( void)
|
||||
{ return m_colMark ; }
|
||||
@@ -237,6 +241,7 @@ class Scene : public IEGrScene
|
||||
HGLRC m_hRC ; // OpenGL Rendering Context
|
||||
WGLEWContext m_wglewc ; // WGLEW Context
|
||||
GLEWContext m_glewc ; // GLEW Context
|
||||
int m_nOglVer ; // OpenGL Version
|
||||
bool m_bNewWay ; // flag che indica nuova modalità (OpenGL 3.0 in poi)
|
||||
// Camera
|
||||
Point3d m_ptCenter ; // centro verso cui è rivolta la camera
|
||||
|
||||
@@ -52,12 +52,15 @@ Scene::Scene( void)
|
||||
m_hRC = nullptr ;
|
||||
memset( &m_wglewc, 0, sizeof( WGLEWContext)) ;
|
||||
memset( &m_glewc, 0, sizeof( GLEWContext)) ;
|
||||
m_nOglVer = 0 ;
|
||||
m_bNewWay = false ;
|
||||
// Camera e viewport
|
||||
m_ptCenter = ORIG ;
|
||||
SetCamera( 0, 0, 0) ;
|
||||
m_nViewportW = 0 ;
|
||||
m_nViewportH = 0 ;
|
||||
// Textures
|
||||
m_TextMgr.SetScene( this) ;
|
||||
// Sfondo
|
||||
m_colBackTop.Set( 176, 176, 176) ;
|
||||
m_colBackBottom.Set( 176, 176, 176) ;
|
||||
@@ -214,6 +217,20 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
|
||||
if ( ! m_bNewWay)
|
||||
LOG_INFO( GetEGrLogger(), "OpenGL old way rendering !")
|
||||
|
||||
// determino la versione di OpenGL
|
||||
m_nOglVer = 0 ;
|
||||
const char* p ;
|
||||
if ( ( p = reinterpret_cast<const char*> ( glGetString( GL_VERSION))) != nullptr) {
|
||||
string sOglVer = p ;
|
||||
STRVECTOR vsTok ;
|
||||
Tokenize( sOglVer, ".", vsTok) ;
|
||||
if ( vsTok.size() >= 2) {
|
||||
int nMaj, nMin ;
|
||||
if ( FromString( vsTok[0], nMaj) && FromString( vsTok[1], nMin))
|
||||
m_nOglVer = 10 * nMaj + nMin ;
|
||||
}
|
||||
}
|
||||
|
||||
// reset stato di errore di OpenGL
|
||||
glGetError() ;
|
||||
|
||||
@@ -857,6 +874,10 @@ Scene::Destroy( void)
|
||||
// cancellazione eventuali ObjEgrGraphics attaccati a oggetti geometrici
|
||||
DeleteObjGraphicsGroup( GDB_ID_ROOT) ;
|
||||
|
||||
// cancellazione textures
|
||||
if ( ! m_TextMgr.Clear())
|
||||
LOG_ERROR( GetEGrLogger(), "Error uloading textures from OpenGl") ;
|
||||
|
||||
// cancellazione rendering context
|
||||
wglMakeCurrent( nullptr, nullptr) ;
|
||||
if ( m_hRC != nullptr) {
|
||||
|
||||
+13
-19
@@ -415,38 +415,32 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
||||
}
|
||||
|
||||
// eventuale texture
|
||||
string sTxtName ;
|
||||
if ( iIter.GetInfo( "!TNA", sTxtName)) {
|
||||
|
||||
string sTxrName ;
|
||||
if ( iIter.GetTextureName( sTxrName)) {
|
||||
// rendo corrente la texture
|
||||
GLuint texName ;
|
||||
double dTextDimS ;
|
||||
double dTextDimT ;
|
||||
if ( m_TextMgr.GetTextureData( sTxtName, texName, dTextDimS, dTextDimT)) {
|
||||
if ( m_TextMgr.GetTextureData( sTxrName, texName, dTextDimS, dTextDimT)) {
|
||||
glEnable( GL_TEXTURE_2D) ;
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ;
|
||||
glBindTexture( GL_TEXTURE_2D, texName) ;
|
||||
}
|
||||
|
||||
// recupero il riferimento dell' oggetto
|
||||
//Frame3d frRef ;
|
||||
//iIter.GetGlobFrame( frRef) ;
|
||||
// recupero il riferimento della texture
|
||||
Frame3d frTxt ;
|
||||
iIter.GetInfo( "!TFR", frTxt) ;
|
||||
//frTxt.ToLoc( frRef) ;
|
||||
Frame3d frTxr ;
|
||||
iIter.GetTextureFrame( frTxr) ;
|
||||
// creo piano per la S
|
||||
GLfloat PlaneS[4] ;
|
||||
PlaneS[0] = GLfloat( frTxt.VersX().x / dTextDimS) ;
|
||||
PlaneS[1] = GLfloat( frTxt.VersX().y / dTextDimS) ;
|
||||
PlaneS[2] = GLfloat( frTxt.VersX().z / dTextDimS) ;
|
||||
PlaneS[3] = GLfloat( - frTxt.VersX() * ( frTxt.Orig() - ORIG) / dTextDimS) ;
|
||||
PlaneS[0] = GLfloat( frTxr.VersX().x / dTextDimS) ;
|
||||
PlaneS[1] = GLfloat( frTxr.VersX().y / dTextDimS) ;
|
||||
PlaneS[2] = GLfloat( frTxr.VersX().z / dTextDimS) ;
|
||||
PlaneS[3] = GLfloat( - frTxr.VersX() * ( frTxr.Orig() - ORIG) / dTextDimS) ;
|
||||
// creo piano per la T
|
||||
GLfloat PlaneT[4] ;
|
||||
PlaneT[0] = GLfloat( frTxt.VersY().x / dTextDimT) ;
|
||||
PlaneT[1] = GLfloat( frTxt.VersY().y / dTextDimT) ;
|
||||
PlaneT[2] = GLfloat( frTxt.VersY().z / dTextDimT) ;
|
||||
PlaneT[3] = GLfloat( - frTxt.VersY() * ( frTxt.Orig() - ORIG) / dTextDimT) ;
|
||||
PlaneT[0] = GLfloat( frTxr.VersY().x / dTextDimT) ;
|
||||
PlaneT[1] = GLfloat( frTxr.VersY().y / dTextDimT) ;
|
||||
PlaneT[2] = GLfloat( frTxr.VersY().z / dTextDimT) ;
|
||||
PlaneT[3] = GLfloat( - frTxr.VersY() * ( frTxr.Orig() - ORIG) / dTextDimT) ;
|
||||
// setto generazione automatica coordinate S e T per texture
|
||||
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
||||
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
||||
|
||||
+16
-2
@@ -20,9 +20,9 @@ using namespace std ;
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::LoadTexture( const string& sName, const string& sFile,
|
||||
double dMMxPix, double dDimX, double dDimY, bool bRepeat)
|
||||
double dMMxPix, double dDimX, double dDimY, int nRepeat)
|
||||
{
|
||||
return m_TextMgr.LoadTexture( sName, sFile, dMMxPix, dDimX, dDimY, bRepeat) ;
|
||||
return m_TextMgr.LoadTexture( sName, sFile, dMMxPix, dDimX, dDimY, nRepeat) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -32,6 +32,20 @@ Scene::UnloadTexture( const string& sName)
|
||||
return m_TextMgr.UnloadTexture( sName) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::UnloadAllTextures( void)
|
||||
{
|
||||
return m_TextMgr.Clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::ExistsTexture( const string& sName)
|
||||
{
|
||||
return m_TextMgr.Exists( sName) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::GetTexturePixels( const string& sName, int& nWidth, int& nHeight)
|
||||
|
||||
+149
-41
@@ -24,29 +24,49 @@ using namespace std ;
|
||||
//----------------------------------------------------------------------------
|
||||
TextureMgr::TextureMgr( void)
|
||||
{
|
||||
// inserisco le texture standard calcolate : Chessboard e Lines
|
||||
|
||||
m_pScene = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
TextureMgr::~TextureMgr( void)
|
||||
{
|
||||
Clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::Clear( void)
|
||||
{
|
||||
// verifico il contesto OpenGL
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
// scarico le texture da OpenGL
|
||||
for ( auto iIter = m_umTextData.begin() ; iIter != m_umTextData.end() ; ++ iIter) {
|
||||
GLuint nTextId = iIter->second.nTexId ;
|
||||
glDeleteTextures( 1, &nTextId) ;
|
||||
}
|
||||
// pulisco i dati
|
||||
m_umTextData.clear() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::LoadTexture( const string& sName, const string& sFile, double dMMxPix, double dDimX, double dDimY, bool bRepeat)
|
||||
TextureMgr::LoadTexture( const string& sName, const string& sFile,
|
||||
double dMMxPix, double dDimX, double dDimY, int nRepeat)
|
||||
{
|
||||
// verifico il contesto OpenGL
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// verifico se immagine già caricata
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
if ( iIter != m_umTextData.end())
|
||||
return ( EqualNoCase( iIter->second.sFile, sFile) && iIter->second.bRepeat == bRepeat) ;
|
||||
return ( EqualNoCase( iIter->second.sFile, sFile) && iIter->second.nRepeat == nRepeat) ;
|
||||
|
||||
// se texture calcolata
|
||||
if ( sFile.empty())
|
||||
return LoadCalcTexture( sName, dMMxPix, dDimX, dDimY, nRepeat) ;
|
||||
|
||||
// leggo l'immagine dal file
|
||||
FIBITMAP* pDib = nullptr ;
|
||||
@@ -61,6 +81,10 @@ TextureMgr::LoadTexture( const string& sName, const string& sFile, double dMMxPi
|
||||
FreeImage_Unload( pTmpDib) ;
|
||||
}
|
||||
|
||||
// recupero le dimensioni in pixel originali dell'immagine
|
||||
int nOriWidth = FreeImage_GetWidth( pDib) ;
|
||||
int nOriHeight = FreeImage_GetHeight( pDib) ;
|
||||
|
||||
// se necessario e possibile, la riduco alle dimensioni caricabili da OpenGL corrente
|
||||
if ( ! TestImageWithOpenGL( pDib))
|
||||
return false ;
|
||||
@@ -69,13 +93,27 @@ TextureMgr::LoadTexture( const string& sName, const string& sFile, double dMMxPi
|
||||
int nWidth = FreeImage_GetWidth( pDib) ;
|
||||
int nHeight = FreeImage_GetHeight( pDib) ;
|
||||
|
||||
// determino il flag di ripetizione
|
||||
GLint nFlag ;
|
||||
switch ( nRepeat) {
|
||||
default : // TXR_CLAMP
|
||||
nFlag = (( m_pScene->GetOpenGLver() < 13) ? GL_CLAMP : GL_CLAMP_TO_BORDER) ;
|
||||
break ;
|
||||
case TXR_REPEAT :
|
||||
nFlag = GL_REPEAT ;
|
||||
break ;
|
||||
case TXR_MIRROR :
|
||||
nFlag = (( m_pScene->GetOpenGLver() < 14) ? GL_REPEAT : GL_MIRRORED_REPEAT) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
// carico l'immagine in OpenGL come texture
|
||||
GLuint nTexName ;
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 4) ;
|
||||
glGenTextures( 1, &nTexName) ;
|
||||
glBindTexture( GL_TEXTURE_2D, nTexName) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ( bRepeat ? GL_REPEAT : GL_CLAMP_TO_BORDER)) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ( bRepeat ? GL_REPEAT : GL_CLAMP_TO_BORDER)) ;
|
||||
glBindTexture( GL_TEXTURE_2D, nTexName) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, nFlag) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, nFlag) ;
|
||||
float color[] = { 0.9f, 0.9f, 0.9f, 1.0f} ;
|
||||
glTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) ;
|
||||
@@ -94,12 +132,12 @@ TextureMgr::LoadTexture( const string& sName, const string& sFile, double dMMxPi
|
||||
|
||||
// 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 ;
|
||||
dDimX = dMMxPix * nOriWidth ;
|
||||
dDimY = dMMxPix * nOriHeight ;
|
||||
}
|
||||
|
||||
// salvo i dati
|
||||
TextureData textData( sFile, dDimX, dDimY, nWidth, nHeight, nTexName, bRepeat) ;
|
||||
TextureData textData( sFile, dDimX, dDimY, nWidth, nHeight, nTexName, nRepeat) ;
|
||||
m_umTextData.emplace( sName, textData) ;
|
||||
|
||||
return true ;
|
||||
@@ -107,8 +145,96 @@ TextureMgr::LoadTexture( const string& sName, const string& sFile, double dMMxPi
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::UnloadTexture( const std::string& sName)
|
||||
TextureMgr::LoadCalcTexture( const string& sName,
|
||||
double dMMxPix, double dDimX, double dDimY, int nRepeat)
|
||||
{
|
||||
// verifico il contesto OpenGL
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// verifico se immagine già caricata
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
if ( iIter != m_umTextData.end())
|
||||
return ( iIter->second.sFile.empty() && iIter->second.nRepeat == nRepeat) ;
|
||||
|
||||
// le texture calcolate sono : Chessboard e Lines
|
||||
if ( ! EqualNoCase( sName, "Chessboard") && ! EqualNoCase( sName, "Lines"))
|
||||
return false ;
|
||||
bool bChess = ( EqualNoCase( sName, "Chessboard")) ;
|
||||
|
||||
// creo l'immagine
|
||||
const int IMG_WIDTH = 64 ;
|
||||
const int IMG_HEIGHT = 64 ;
|
||||
GLubyte Image[IMG_HEIGHT][IMG_WIDTH][4] ;
|
||||
for ( int i = 0 ; i < IMG_HEIGHT ; ++ i) {
|
||||
for ( int j = 0 ; j < IMG_WIDTH ; ++ j) {
|
||||
int c ;
|
||||
if ( bChess)
|
||||
c = (((i & 0x8) == 0) ^ ((j & 0x8) == 0)) * 255 ;
|
||||
else
|
||||
c = ((i & 0x8) == 0) * 255 ;
|
||||
Image[i][j][0] = (GLubyte) c ;
|
||||
Image[i][j][1] = (GLubyte) c ;
|
||||
Image[i][j][2] = (GLubyte) c ;
|
||||
Image[i][j][3] = (GLubyte) 255 ;
|
||||
}
|
||||
}
|
||||
|
||||
// determino il flag di ripetizione
|
||||
GLint nFlag ;
|
||||
switch ( nRepeat) {
|
||||
default : // TXR_CLAMP
|
||||
nFlag = (( m_pScene->GetOpenGLver() < 13) ? GL_CLAMP : GL_CLAMP_TO_BORDER) ;
|
||||
break ;
|
||||
case TXR_REPEAT :
|
||||
nFlag = GL_REPEAT ;
|
||||
break ;
|
||||
case TXR_MIRROR :
|
||||
nFlag = (( m_pScene->GetOpenGLver() < 14) ? GL_REPEAT : GL_MIRRORED_REPEAT) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
// carico l'immagine in OpenGL come texture
|
||||
GLuint nTexName ;
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 4) ;
|
||||
glGenTextures( 1, &nTexName) ;
|
||||
glBindTexture( GL_TEXTURE_2D, nTexName) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, nFlag) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, nFlag) ;
|
||||
float color[] = { 0.9f, 0.9f, 0.9f, 1.0f} ;
|
||||
glTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) ;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) ;
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, IMG_WIDTH, IMG_HEIGHT,
|
||||
0, GL_BGRA, GL_UNSIGNED_BYTE, &Image) ;
|
||||
|
||||
// verifico che la texture sia stata veramente caricata
|
||||
if ( ! glIsTexture( nTexName))
|
||||
return false ;
|
||||
|
||||
// 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 * IMG_WIDTH ;
|
||||
dDimY = dMMxPix * IMG_HEIGHT ;
|
||||
}
|
||||
|
||||
// salvo i dati
|
||||
TextureData textData( "", dDimX, dDimY, IMG_WIDTH, IMG_HEIGHT, nTexName, nRepeat) ;
|
||||
m_umTextData.emplace( sName, textData) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::UnloadTexture( const string& sName)
|
||||
{
|
||||
// verifico il contesto OpenGL
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
// cerco la texture, se non la trovo già ok
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
if ( iIter == m_umTextData.end())
|
||||
@@ -123,7 +249,16 @@ TextureMgr::UnloadTexture( const std::string& sName)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::GetPixels( const std::string& sName, int& nWidth, int& nHeight)
|
||||
TextureMgr::Exists( const string& sName)
|
||||
{
|
||||
// ricerca della texture di nome dato
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
return ( iIter != m_umTextData.end()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::GetPixels( const string& sName, int& nWidth, int& nHeight)
|
||||
{
|
||||
// ricerca della texture di nome dato
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
@@ -137,7 +272,7 @@ TextureMgr::GetPixels( const std::string& sName, int& nWidth, int& nHeight)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::GetDimensions( const std::string& sName, double& dDimX, double& dDimY)
|
||||
TextureMgr::GetDimensions( const string& sName, double& dDimX, double& dDimY)
|
||||
{
|
||||
// ricerca della texture di nome dato
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
@@ -151,7 +286,7 @@ TextureMgr::GetDimensions( const std::string& sName, double& dDimX, double& dDim
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::ChangeDimensions( const std::string& sName, double dDimX, double dDimY)
|
||||
TextureMgr::ChangeDimensions( const string& sName, double dDimX, double dDimY)
|
||||
{
|
||||
// ricerca della texture di nome dato
|
||||
auto iIter = m_umTextData.find( sName) ;
|
||||
@@ -251,30 +386,3 @@ TextureMgr::TestImageWithOpenGL( FIBITMAP*& pDib)
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//// !!! PROVVISORIO Textures
|
||||
//#define checkImageWidth 64
|
||||
//#define checkImageHeight 64
|
||||
//static GLubyte checkImage[checkImageHeight][checkImageWidth][4];
|
||||
//static GLuint texName;
|
||||
//
|
||||
//void makeCheckImage(void)
|
||||
//{
|
||||
// int i, j, c;
|
||||
//
|
||||
// for (i = 0; i < checkImageHeight; i++) {
|
||||
// for (j = 0; j < checkImageWidth; j++) {
|
||||
// c = (((i&0x8)==0)^((j&0x8)==0))*255;
|
||||
// checkImage[i][j][0] = (GLubyte) c;
|
||||
// checkImage[i][j][1] = (GLubyte) c;
|
||||
// checkImage[i][j][2] = (GLubyte) c;
|
||||
// checkImage[i][j][3] = (GLubyte) 255;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//#include "\EgtDev\Extern\FreeImage\Include\FreeImage.h"
|
||||
//#include "\EgtDev\Include\EgtStringConverter.h"
|
||||
//#include <string>
|
||||
|
||||
+15
-6
@@ -16,6 +16,8 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class Scene ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct TextureData {
|
||||
std::string sFile ;
|
||||
@@ -24,12 +26,12 @@ struct TextureData {
|
||||
int nWidth ;
|
||||
int nHeight ;
|
||||
unsigned int nTexId ;
|
||||
bool bRepeat ;
|
||||
int nRepeat ;
|
||||
|
||||
TextureData( void)
|
||||
: dDimX( 0), dDimY( 0), nWidth( 0), nHeight( 0), nTexId( 0), bRepeat( false) {}
|
||||
TextureData( std::string sF, double dX, double dY, int nW, int nH, unsigned int nT, bool bR)
|
||||
: sFile( sF), dDimX( dX), dDimY( dY), nWidth( nW), nHeight( nH), nTexId( nT), bRepeat( bR) {}
|
||||
: 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 ;
|
||||
|
||||
@@ -43,8 +45,12 @@ class TextureMgr
|
||||
~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, bool bRepeat) ;
|
||||
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) ;
|
||||
@@ -52,9 +58,12 @@ class TextureMgr
|
||||
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 :
|
||||
STRTEXTD_UMAP m_umTextData ;
|
||||
Scene* m_pScene ; // puntatore alla scena
|
||||
STRTEXTD_UMAP m_umTextData ; // dati delle textures
|
||||
} ;
|
||||
Reference in New Issue
Block a user