#include <ExManagerTexture.h>
Public Methods | |
ExManagerTexture (void) | |
~ExManagerTexture (void) | |
void | SetManagerId (ExManagerId *Id) |
void | Reset (void) |
void | Init (void) |
bool | Init (char *FileName) |
bool | CheckExist (const char *name) |
bool | AddTexture (const char *name) |
GLuint | GetTexture (char *name) |
bool | SetActiveTexture (char *name) |
void | ListAllTexture (void) |
Data Fields | |
std::ostrstream * | Consol |
void(* | WriteToConsol )(const char *Label) |
Private Attributes | |
ExManagerId * | ManagerId |
std::vector< ExCTexture > | m_VecTextures |
std::vector< ExCTexture >::iterator | m_ItVecTextures |
int | m_CouterTextures |
|
Definition at line 26 of file ExManagerTexture.cpp. References ExManagerTexture(), Guard, m_CouterTextures, and UnGuard. Referenced by ExManagerTexture(), and ~ExManagerTexture().
00027 { 00028 Guard(ExManagerTexture::ExManagerTexture(void)) 00029 m_CouterTextures=0; 00030 UnGuard 00031 } |
|
Definition at line 34 of file ExManagerTexture.cpp. References ExManagerTexture(), Guard, and UnGuard.
00035 { 00036 Guard(ExManagerTexture::~ExManagerTexture(void)) 00037 UnGuard 00038 } |
|
Definition at line 89 of file ExManagerTexture.cpp. References AddTexture(), tImage::channels, CheckExist(), Consol, tImage::data, ExCTexture::GetFileName(), Guard, LoadBMP(), LoadJPG(), LoadTGA(), m_CouterTextures, ExCTexture::m_Texture, m_VecTextures, PREFIX, ExCTexture::SetFileName(), tImage::sizeX, tImage::sizeY, and UnGuard. Referenced by AddTexture(), ExCComposed::LoadAsc(), ExCMap::LoadMap(), ExCInterface::LoadTextureInterface(), and ExManagerConsole::SetConsoleBackGroudTexture().
00090 { 00091 Guard(ExManagerTexture::AddTexture(const char * name)) 00092 if(CheckExist(name)){return true;} 00093 //cheking extension type 00094 ExCTexture *texture; 00095 bool Loaded=false; 00096 tImage *image; 00097 std::string StrPath,FileName(name); 00098 image= new tImage(); 00099 texture= new ExCTexture; 00100 #ifdef UNIX_SRC 00101 StrPath=PREFIX "/ExNihilo/Data/Textures/"; 00102 #else 00103 StrPath="../Data/Textures/"; 00104 #endif 00105 //watching for file exentions type 00106 if(FileName.find(".bmp")==(FileName.length()-4)) 00107 { 00108 Loaded=LoadBMP(image,StrPath+FileName); 00109 if(!Loaded)return false; 00110 } 00111 if(FileName.find(".tga")==(FileName.length()-4)) 00112 { 00113 Loaded=LoadTGA(image,StrPath+FileName); 00114 if(!Loaded)return false; 00115 } 00116 if(FileName.find(".jpg")==(FileName.length()-4)) 00117 { 00118 Loaded=LoadJPG(image,StrPath+FileName); 00119 if(!Loaded)return false; 00120 } 00121 // no aviable extension was found 00122 if(!Loaded) 00123 { 00124 //watch if there is a extension 00125 if(FileName.find(".")<FileName.length()) 00126 { 00127 //ther is a unknow extension 00128 *Consol<<"File format not supported :"<<FileName.data()<<std::endl; 00129 } 00130 } 00131 //there is no extension try to find correct extension 00132 if(!Loaded)Loaded = LoadBMP(image,StrPath+FileName+".bmp"); 00133 if(!Loaded)Loaded = LoadTGA(image,StrPath+FileName+".tga"); 00134 if(!Loaded)Loaded = LoadJPG(image,StrPath+FileName+".jpg"); 00135 if(Loaded) 00136 { 00137 texture->SetFileName(name); 00138 m_CouterTextures++; 00139 00140 glGenTextures(1,&texture->m_Texture); 00141 glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 00142 glBindTexture(GL_TEXTURE_2D,texture->m_Texture); 00143 // Assume that the texture is a 24 bit RGB texture (We convert 16-bit ones to 24-bit) 00144 int textureType = GL_RGB; 00145 // If the image is 32-bit (4 channels), then we need to specify GL_RGBA for an alpha 00146 if(image->channels == 4)textureType = GL_RGBA; 00147 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 00148 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 00149 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 00150 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 00151 gluBuild2DMipmaps(GL_TEXTURE_2D,4, image->sizeX, image->sizeY, textureType, GL_UNSIGNED_BYTE, image->data); 00152 // Build Mipmaps (builds different versions of the picture for distances - looks better) 00153 //gluBuild2DMipmaps(GL_TEXTURE_2D,image->channels,image->sizeX,image->sizeY, textureType, GL_UNSIGNED_BYTE, image->data); 00154 //Assign the mip map levels and texture info 00155 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); 00156 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 00157 m_VecTextures.push_back(*texture); 00158 *Consol<<"MannagerTexture:: New texture added "<<texture->GetFileName()<<" with Id:"<<texture->m_Texture<<std::endl; 00159 return true; 00160 } 00161 *Consol<<"MannagerTexture:: Error loading texture :"<<FileName.data()<<std::endl; 00162 return false; 00163 UnGuard 00164 } |
|
Definition at line 65 of file ExManagerTexture.cpp. References CheckExist(), Guard, m_CouterTextures, m_ItVecTextures, m_VecTextures, and UnGuard. Referenced by AddTexture(), and CheckExist().
00066 { 00067 Guard(ExManagerTexture::CheckExist(const char * name)) 00068 std::string FileName(name); 00069 if(FileName.find(".")<FileName.length())//if extension remove them 00070 { 00071 FileName.erase(FileName.find("."),FileName.length()-FileName.find(".")); 00072 } 00073 if(m_CouterTextures>0) 00074 { 00075 for(m_ItVecTextures=m_VecTextures.begin();m_ItVecTextures!=m_VecTextures.end();m_ItVecTextures++) 00076 { 00077 00078 if(strcmp(m_ItVecTextures->GetFileName(),FileName.data())==0) 00079 { 00080 return true; 00081 } 00082 } 00083 } 00084 return false; 00085 UnGuard 00086 } |
|
Definition at line 167 of file ExManagerTexture.cpp. References GetTexture(), Guard, m_ItVecTextures, m_VecTextures, and UnGuard. Referenced by GetTexture().
00168 { 00169 Guard(ExManagerTexture::GetTexture(char * name)) 00170 for(m_ItVecTextures=m_VecTextures.begin();m_ItVecTextures!=m_VecTextures.end();m_ItVecTextures++) 00171 { 00172 if(strcmp(m_ItVecTextures->GetFileName(),name)==0) 00173 { 00174 return m_ItVecTextures->GetGlTextureId(); 00175 } 00176 } 00177 return (GLuint) 0; 00178 UnGuard 00179 } |
|
Definition at line 57 of file ExManagerTexture.cpp. References Guard, Init(), and UnGuard.
00058 { 00059 Guard(bool ExManagerTexture::Init(char * FileName)) 00060 //openf file and load object 00061 return true; 00062 UnGuard 00063 } |
|
Definition at line 50 of file ExManagerTexture.cpp. References Guard, Init(), and UnGuard. Referenced by Init(), and InitManager().
00051 { 00052 Guard(void ExManagerTexture::Init(void)) 00053 UnGuard 00054 } |
|
Definition at line 206 of file ExManagerTexture.cpp. References Consol, Guard, ListAllTexture(), m_ItVecTextures, m_VecTextures, and UnGuard. Referenced by ListAllTexture(), and ExManagerCommand::ProcessAction().
00207 { 00208 Guard(ExManagerTexture::ListAllTexture(void)) 00209 for(m_ItVecTextures=m_VecTextures.begin();m_ItVecTextures!=m_VecTextures.end();m_ItVecTextures++) 00210 { 00211 *Consol<<"Texture Id:"<<m_ItVecTextures->m_Texture<<" Material name:"<<m_ItVecTextures->GetFileName()<<std::endl; 00212 } 00213 *Consol<<"Number of texture in manager :"<<m_VecTextures.size()<<std::endl; 00214 UnGuard 00215 } |
|
Definition at line 41 of file ExManagerTexture.cpp. References Guard, m_CouterTextures, m_VecTextures, Reset(), and UnGuard. Referenced by ExManagerCommand::ProcessAction(), and Reset().
00042 { 00043 Guard(void ExManagerTexture::Reset(void)) 00044 m_VecTextures.clear(); 00045 m_CouterTextures=0; 00046 UnGuard 00047 } |
|
Definition at line 181 of file ExManagerTexture.cpp. References Guard, m_ItVecTextures, m_VecTextures, SetActiveTexture(), and UnGuard. Referenced by ExCMap::BuildSkyBox(), ExCOctree::BuilList(), ExCMap::BuilList(), ExManagerConsole::DrawConsole(), ExCInterface::DrawInterface(), ExCMap::DrawMeshInFrustrum(), ExCEntite::DrawWithoutList(), ExCMap::LoadMap(), and SetActiveTexture().
00182 { 00183 Guard(ExManagerTexture::SetActiveTexture(char * name)) 00184 std::string FileName(name); 00185 if(FileName.find(".")<FileName.length())//if extension remove them 00186 { 00187 FileName.erase(FileName.find("."),FileName.length()-FileName.find(".")); 00188 memset(name,0,strlen(name)); 00189 sprintf(name,"%s",FileName.data()); 00190 } 00191 for(m_ItVecTextures=m_VecTextures.begin();m_ItVecTextures!=m_VecTextures.end();m_ItVecTextures++) 00192 { 00193 if (m_ItVecTextures->GetFileName () != NULL && name != NULL) 00194 { 00195 if (strcmp(m_ItVecTextures->GetFileName(),name)==0) 00196 { 00197 m_ItVecTextures->SetActive(); 00198 return true; 00199 } 00200 } 00201 } 00202 return false; 00203 UnGuard 00204 } |
|
Definition at line 64 of file ExManagerTexture.h. Referenced by SetManagerLink().
00064 {ManagerId = Id;} |
|
Definition at line 61 of file ExManagerTexture.h. Referenced by AddTexture(), ListAllTexture(), and SetManagerLink(). |
|
Definition at line 45 of file ExManagerTexture.h. Referenced by AddTexture(), CheckExist(), ExManagerTexture(), and Reset(). |
|
Definition at line 44 of file ExManagerTexture.h. Referenced by CheckExist(), GetTexture(), ListAllTexture(), and SetActiveTexture(). |
|
Definition at line 43 of file ExManagerTexture.h. Referenced by AddTexture(), CheckExist(), GetTexture(), ListAllTexture(), Reset(), and SetActiveTexture(). |
|
Definition at line 41 of file ExManagerTexture.h. |
|
Referenced by SetManagerLink(). |