Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

ExManagerTexture.cpp

Go to the documentation of this file.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  * $Id: ExManagerTexture.cpp,v 1.38 2002/12/08 17:57:06 data Exp $
00021  *
00022  */
00023  
00024 #include "ExManagerTexture.h"
00025 
00026 bool ExManagerTexture::m_flag = false; 
00027 ExManagerTexture* ExManagerTexture::m_instance = NULL; 
00028 
00029 ExManagerTexture* ExManagerTexture::CreateSingleton(void){
00030 Guard(ExManagerTexture* ExManagerTexture::CreateSingleton(void))
00031         if(!m_flag)
00032         {
00033                 m_flag = true; // We are creating the error log now, so set flag to true
00034                 m_instance = new ExManagerTexture; // Create the error log
00035         }else
00036         {
00037                 std::cout<<"Error singleton already created"<<std::endl;
00038         }
00039         return m_instance; 
00040 UnGuard
00041 }
00042 
00043 ExManagerTexture::ExManagerTexture(void)
00044 {
00045 Guard(ExManagerTexture::ExManagerTexture(void))
00046         
00047 UnGuard
00048 }
00049 
00050 
00051 ExManagerTexture::~ExManagerTexture(void)
00052 {
00053 Guard(ExManagerTexture::~ExManagerTexture(void))
00054 UnGuard
00055 }
00056 
00057 void  ExManagerTexture::Init(void)
00058 {
00059 Guard(void  ExManagerTexture::Init(void))
00060         ExManagerObject<ExCTexture>::Init();
00061 //      Add("back.bmp");
00062 UnGuard
00063 }
00064 
00065 void  ExManagerTexture::Reset(void)
00066 {
00067 Guard(void  ExManagerTexture::Reset(void))
00068         ExManagerObject<ExCTexture>::Reset();
00069 UnGuard
00070 }
00071 
00072 bool  ExManagerTexture::Init(std::string FileName)
00073 {
00074 Guard(bool  ExManagerTexture::Init(std::string FileName))
00075         //openf file and load object
00076 
00077         return true;
00078 UnGuard
00079 }
00080 
00081 bool ExManagerTexture::CheckExist(std::string  name)
00082 {
00083 Guard(ExManagerTexture::CheckExist(std::string  name))
00084         if(name.find(".")<name.length())//if extension remove them
00085         {
00086                 name.erase(name.find("."),name.length()-name.find("."));
00087         }
00088         if(ManagerId->GetObjectId(name,typeid(ExCTexture).name())==-1)return true;
00089         return false;
00090 UnGuard
00091 }
00092 
00093 
00094 bool ExManagerTexture::Load(std::string FileName)
00095 {
00096 Guard(ExManagerTexture::Load(std::string FileName))
00097         if(FileName.find(".")<FileName.length())//if extension remove them
00098         {
00099                 FileName.erase(FileName.find("."),FileName.length()-FileName.find("."));
00100         }
00101         if(!CheckExist(FileName)){return true;}
00102         
00103         try
00104         {
00105                 return  Add(ExCTexture(FileName));
00106         }catch(ExCExpFileNotFound)
00107         {
00108                 *Consol<<"Exception file not found texture not added"<<std::endl;
00109                 return false;
00110         }
00111         catch(ExCExpNullPointer)
00112         {
00113                 *Consol<<"Exception null pointer texture not added"<<std::endl;
00114                 return false;
00115         }
00116         
00117 UnGuard
00118 }
00119 
00120 bool ExManagerTexture::Add(std::string FileName)
00121 {
00122 Guard(ExManagerTexture::Add(std::string FileName))
00123         return Load(FileName);
00124 UnGuard
00125 }
00126 
00127 bool ExManagerTexture::Add(ExCTexture object)
00128 {
00129 Guard(ExManagerTexture::Add(ExCTexture object))
00130         if(!CheckExist(object.GetName())){return true;}
00131         return ExManagerObject<ExCTexture>::Add(object);
00132 UnGuard
00133 }
00134 
00135 bool ExManagerTexture::SetCurrentObject(std::string Name)
00136 {
00137 Guard(ExManagerTexture::SetCurrentObject(std::string Name))
00138         
00139         if(Name.find(".")<Name.length())//if extension remove them
00140         {
00141                 Name.erase(Name.find("."),Name.length()-Name.find("."));
00142         }
00143         try
00144         {       
00145                 m_CurrentObjectId=ManagerId->GetObjectId(Name,typeid(ExCTexture).name());
00146                 glBindTexture(GL_TEXTURE_2D,GetObject(m_CurrentObjectId)->m_Texture);
00147                 return true;
00148                 //std::cout<<"ExManagerTexture ::"<<Name<<" Current object"<<std::endl;
00149         }catch(...)
00150         {
00151                 if(!Load(Name))
00152                 {
00153                         std::cout<<"ExManagerTexture ::Exception can make :"<<Name<<" Current object"<<std::endl;
00154                         return true;
00155                 }
00156                 return false;
00157         }
00158 UnGuard
00159 }
00160 
00161 bool ExManagerTexture::SetCurrentObject(ExNihilo::ExId id)
00162 {
00163 Guard(ExManagerTexture::SetCurrentObject(ExNihilo::ExId id))
00164         if(GetObject(id)!=NULL)
00165         {
00166                 m_CurrentObjectId=id;
00167                 try
00168                 {       
00169                         glBindTexture(GL_TEXTURE_2D,GetObject(m_CurrentObjectId)->m_Texture);
00170                         return true;
00171                         //std::cout<<"ExManagerTexture ::"<<Name<<" Current object"<<std::endl;
00172                         }catch(...)
00173                         {
00174                                 std::cout<<"ExManagerTexture ::Exception can make :"<<m_CurrentObjectId<<" Current object"<<std::endl;
00175                                 return false;
00176                         }
00177         }
00178         return false;
00179 UnGuard
00180 }
00181 
00182 GLint ExManagerTexture::GetTextureId(std::string Name)
00183 {
00184 Guard(ExManagerTexture::GetTextureId(std::string Name))
00185         
00186         if(Name.find(".")<Name.length())//if extension remove them
00187         {
00188                 Name.erase(Name.find("."),Name.length()-Name.find("."));
00189         }
00190         try
00191         {       
00192                 m_CurrentObjectId=ManagerId->GetObjectId(Name,typeid(ExCTexture).name());
00193                 return GetObject(m_CurrentObjectId)->m_Texture;
00194                 //std::cout<<"ExManagerTexture ::"<<Name<<" Current object"<<std::endl;
00195         }catch(...)
00196         {
00197                 if(!Load(Name))
00198                 {
00199                         std::cout<<"ExManagerTexture ::Exception can make :"<<Name<<" Current object"<<std::endl;
00200                         return -1;
00201                 }
00202                 return -1;
00203         }
00204 UnGuard
00205 }
00206 
00207 GLint ExManagerTexture::GetTextureId(ExNihilo::ExId id)
00208 {
00209 Guard(ExManagerTexture::GetTextureId(ExNihilo::ExId id))
00210         if(GetObject(id)!=NULL)
00211         {
00212                 m_CurrentObjectId=id;
00213                 try
00214                 {       
00215                         return GetObject(m_CurrentObjectId)->m_Texture;
00216                         //std::cout<<"ExManagerTexture ::"<<Name<<" Current object"<<std::endl;
00217                         }catch(...)
00218                         {
00219                                 std::cout<<"ExManagerTexture ::Exception can make :"<<m_CurrentObjectId<<" Current object"<<std::endl;
00220                                 return -1;
00221                         }
00222         }
00223         return -1;
00224 UnGuard
00225 }
00226 
00227 
00228 ExCAction ExManagerTexture::InputAction(ExCAction Action)
00229 {
00230 Guard(ExCAction ExManagerTexture::InputAction(ExCAction Action))
00231         switch(Action.m_Action)
00232         {
00233         case LIST_TEXTURE:
00234                 List();
00235                 break;
00236         case LOAD_TEXTURE:
00237                 break;
00238         case UNLOAD_TEXTURE:
00239                 break;
00240         }
00241         if(Action.m_NextAction){return *Action.m_NextAction;}
00242         else{return NOTHING;}
00243 UnGuard
00244 }
00245 

Generated on Tue Dec 10 18:20:07 2002 for ExNihilo by doxygen1.3-rc1