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

ExCTexture Class Reference

#include <ExCTexture.h>

Inheritance diagram for ExCTexture:

ExCObject

Public Methods

 ExCTexture (void)
 ExCTexture (std::string FileName)
 ~ExCTexture (void)
void SetName (std::string Name)
bool LoadFile (std::string FileName)
void SetActive (void)
GLuint GetGlTextureId (void)

Data Fields

GLuint m_Texture
ExCImageLoaderm_Image

Constructor & Destructor Documentation

ExCTexture void   
 

Definition at line 27 of file ExCTexture.cpp.

References ExCTexture(), Guard, SetName(), and ExCObject::SetType().

Referenced by ExCTexture(), and ~ExCTexture().

00028 {
00029 Guard(ExCTexture::ExCTexture(void))
00030         SetName("ExCTexture");
00031         SetType(typeid(this).name());
00032 UnGuard
00033 }

ExCTexture std::string    FileName
 

Definition at line 35 of file ExCTexture.cpp.

References ExCTexture(), Guard, LoadFile(), SetName(), and ExCObject::SetType().

00036 {
00037 Guard(ExCTexture::ExCTexture(std::string FileName))
00038         SetName("ExCTexture");
00039         SetType(typeid(this).name());
00040         LoadFile(FileName);
00041 UnGuard
00042 }

~ExCTexture void   
 

Definition at line 44 of file ExCTexture.cpp.

References ExCTexture(), and Guard.

00045 {
00046 Guard(ExCTexture::~ExCTexture(void))
00047 UnGuard
00048 }


Member Function Documentation

GLuint GetGlTextureId void    [inline]
 

Definition at line 54 of file ExCTexture.h.

References m_Texture.

00055 {return m_Texture;}

bool LoadFile std::string    FileName [virtual]
 

Reimplemented from ExCObject.

Definition at line 73 of file ExCTexture.cpp.

References BMP, Guard, LoadFile(), ExCImageLoader::LoadImage(), ExCImageLoader::m_channels, ExCImageLoader::m_data, m_Image, ExCImageLoader::m_sizeX, ExCImageLoader::m_sizeY, m_Texture, ExCImageLoader::m_TextureType, PCX, PPM, PREFIX, SetName(), and TGA.

Referenced by ExCTexture(), and LoadFile().

00074 {
00075 Guard(ExCTexture::LoadFile(std::string FileName))
00076         m_Image= new ExCImageLoader;
00077         int Type = GL_RGB;
00078         std::string             StrPath;
00079         SetName(FileName);
00080         #ifdef UNIX_SRC
00081                 StrPath=PREFIX "/ExNihilo/Data/Textures/";
00082         #else
00083                 StrPath="../Data/Textures/";
00084         #endif
00085                 
00086         if(m_Image->LoadImage(StrPath+FileName))
00087         {
00088 
00089                 SetName(FileName);
00090                 glGenTextures(1,&m_Texture);
00091                 glBindTexture(GL_TEXTURE_2D,m_Texture);
00092                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
00093                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
00094                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
00095                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
00096                 //std::cout<<"Tex ID :"<<m_Texture<<std::endl;
00097                 switch (m_Image->m_TextureType)
00098                 {
00099                 case BMP:
00100                         gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, m_Image->m_sizeX, m_Image->m_sizeY, 
00101                                 GL_RGB, GL_UNSIGNED_BYTE, m_Image->m_data);
00102                         //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_Image->m_sizeX,m_Image->m_sizeY, 
00103                         //      0, GL_RGB, GL_UNSIGNED_BYTE, m_Image->m_data);
00104 
00105                         break;
00106                 case PCX:
00107                         gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, m_Image->m_sizeX,m_Image->m_sizeY,
00108                                 GL_RGBA, GL_UNSIGNED_BYTE, m_Image->m_data);
00109                         break;
00110                 case TGA:       
00111                         
00112             if(m_Image->m_channels == 4)Type = GL_RGBA;
00113                     gluBuild2DMipmaps(GL_TEXTURE_2D,m_Image->m_channels,m_Image->m_sizeX, 
00114                                           m_Image->m_sizeY, Type, GL_UNSIGNED_BYTE,m_Image->m_data);
00115             break;
00116                 case PPM:
00117                         gluBuild2DMipmaps(GL_TEXTURE_2D, 3, m_Image->m_sizeX, m_Image->m_sizeY,
00118                                 GL_RGB, GL_UNSIGNED_BYTE, m_Image->m_data);
00119                         break;
00120                 default:
00121                         break;
00122                 }
00123                 return true;
00124         }
00125 
00126         *Consol<<"ExCTexture Exception::unable to load file "<<FileName<<std::endl;
00127         delete m_Image;
00128 return false;
00129 UnGuard
00130 }

void SetActive void   
 

Definition at line 64 of file ExCTexture.cpp.

References Guard, m_Texture, and SetActive().

Referenced by SetActive().

00065 {
00066 Guard(ExCTexture::SetActive(void))
00067         
00068         glBindTexture(GL_TEXTURE_2D,m_Texture);
00069 UnGuard
00070 }

void SetName std::string    Name
 

Reimplemented from ExCObject.

Definition at line 50 of file ExCTexture.cpp.

References Guard, ExCObject::m_ObjectName, and SetName().

Referenced by ExCTexture(), LoadFile(), and SetName().

00051 {
00052 Guard(void ExCTexture::SetName(std::string       Name))
00053         if(Name.find(".")<Name.length())//if extension remove them
00054         {
00055                 Name.erase(Name.find("."),Name.length()-Name.find("."));
00056                 m_ObjectName=Name;
00057         }else
00058         {
00059                 m_ObjectName=Name;
00060         }
00061 UnGuard
00062 }


Field Documentation

ExCImageLoader* m_Image
 

Definition at line 41 of file ExCTexture.h.

Referenced by LoadFile().

GLuint m_Texture
 

Definition at line 40 of file ExCTexture.h.

Referenced by GetGlTextureId(), ExManagerTexture::GetTextureId(), LoadFile(), and SetActive().


The documentation for this class was generated from the following files:
Generated on Tue Dec 10 18:20:31 2002 for ExNihilo by doxygen1.3-rc1