00001
00044
00045 #ifndef _CTEXTURE_H_
00046 #define _CTEXTURE_H_
00047
00048
00049
00050
00057
00058 class CTexture
00059 {
00060 public:
00061 CTexture(void){m_ImageDataKept = false;}
00062 virtual ~CTexture(){;}
00063
00065 virtual int Load(char *name, int id, int textureMode, bool keepimagedata) = 0;
00066
00067 unsigned char *GetImageData(void) const {return m_ImageData;}
00068 int GetImageWidth(void) const {return m_ImageWidth;}
00069 int GetImageHeight(void) const {return m_ImageHeight;}
00070 int GetImageDepth(void) const {return m_ImageDepth;}
00071 int GetImageSize(void) const {return m_Size;}
00072 int IsPowerOf2(int n) const {return (n & -n) == n;}
00073
00074 protected:
00075 int m_ImageWidth, m_ImageHeight, m_ImageDepth, m_Size, m_ImagePixelSize;
00076 bool m_ImageDataKept;
00077 unsigned char *m_ImageData;
00078 GLenum m_TextureFormat;
00079 };
00080
00081
00082
00086
00087 typedef struct TGA_HEADER
00088 {
00089 char extra;
00090 unsigned char colourmap;
00091 unsigned char imagetype;
00092 char filler[9];
00093 unsigned char width[2];
00094 unsigned char height[2];
00095 unsigned char depth;
00096 };
00097
00098
00099
00104
00105 class CTextureTGA : CTexture
00106 {
00107 public:
00108 CTextureTGA();
00109 ~CTextureTGA();
00110
00112 int Load(char *name, int id,int textureMode, bool keepimagedata);
00113
00114 private:
00115 unsigned char *ReadData(FILE *file);
00116 };
00117
00118
00119
00120
00121 #endif