00001 #ifndef __Texture_h_
00002 #define __Texture_h_
00003
00004 class CTexture;
00005
00006 #include <stdio.h>
00007 #include <stdlib.h>
00008 #include <string.h>
00009 #include <windows.h>
00010 #include <GL/gl.h>
00011 #include <GL/glu.h>
00012
00013
00014 typedef struct tagPCXHEADER
00015 {
00016 char Manufacturer;
00017 char Version;
00018 char Encoding;
00019 char BitsPerPixel;
00020 WORD Xmin, Ymin;
00021 WORD Xmax, Ymax;
00022 WORD Hres, Vres;
00023 BYTE ColorMap[16][3];
00024 char Reserved;
00025 char ColorPlanes;
00026 WORD BytesPerLine;
00027 WORD PaletteType;
00028 char Filter[58];
00029 } *LPPCXHEADER;
00030
00031 #define PCX_MAGIC 0X0A // PCX magic number
00032 #define PCX_256_COLORS 0X0C // magic number for 256 colors
00033 #define PCX_HDR_SIZE 128 // size of PCX header
00034 #define PCX_MAXCOLORS 256
00035 #define PCX_MAXPLANES 4
00036 #define PCX_MAXVAL 255
00037
00038 #define MAX_TEXTURE_NAME_LENGTH 64
00039
00040 class CTexture
00041 {
00042 public:
00043
00044 CTexture();
00045 ~CTexture();
00046
00047
00048 bool LoadBMP (char *szFileName, bool mipmap);
00049 bool LoadBMP (char *szFileName);
00050 bool LoadPCX (BYTE *data, bool mipmap);
00051 bool LoadPCX (BYTE *data);
00052 bool LoadRAW (char *szFileName);
00053 void Free ();
00054 void Use ();
00055
00056 int getWidth();
00057 int getHeight();
00058
00059 private:
00060
00061
00062 bool Create (bool mipmap);
00063
00064
00065 bool PCX_PlanesToPixels(BYTE *pixels, BYTE *bitplanes, short bytesperline, short planes, short bitsperpixel);
00066 bool PCX_UnpackPixels(BYTE *pixels, BYTE *bitplanes, short bytesperline, short planes, short bitsperpixel);
00067
00068
00069 unsigned int m_nID;
00070 int m_nWidth, m_nHeight, m_nBits;
00071 };
00072
00073 #endif