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