00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef LIBPROCTERCMAP_H
00019 #define LIBPROCTERCMAP_H
00020
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024
00025 #ifdef HAVE_STDINT_H
00026 #include <stdint.h>
00027 #else
00028 #include <libprocter/missing_includes.h>
00029 #endif
00030
00031 #include <libprocter/settings.h>
00032
00033 namespace libProcTer {
00034
00040 struct SColor
00041 {
00043
00044 uint8_t r,g,b;
00046 };
00047
00057 class CMapBase
00058 {
00059 public:
00061 CMapBase(unsigned int bpp)
00062 {
00063 m_Data = new uint8_t[bpp*PROCTER_TEX_RES*PROCTER_TEX_RES];
00064 m_BPP = bpp;
00065 }
00066
00068 CMapBase(const CMapBase &map)
00069 {
00070 m_BPP = map.getBPP();
00071 m_Data = new uint8_t[m_BPP*PROCTER_TEX_RES*PROCTER_TEX_RES];
00072 operator=(map);
00073 }
00074
00076 ~CMapBase()
00077 {
00078 delete [] m_Data;
00079 }
00080
00082 const CMapBase &operator=(const CMapBase &map)
00083 {
00084 uint8_t *ptr = map.m_Data;
00085 for(unsigned int i=0; i < m_BPP*PROCTER_TEX_RES*PROCTER_TEX_RES; i++)
00086 m_Data[i] = ptr[i];
00087
00088 return *this;
00089 }
00090
00092 inline unsigned int getBPP() const
00093 {return m_BPP;}
00094
00095 protected:
00097 uint8_t *m_Data;
00099 unsigned int m_BPP;
00100 };
00101
00112 template<typename T>
00113 class CMap : public CMapBase
00114 {
00115 public:
00117 CMap() : CMapBase(sizeof(T))
00118 {;}
00119
00121 inline T *getData()
00122 {return (T *)m_Data;}
00123
00125 inline const T *getData() const
00126 {return (const T *)m_Data;}
00127 };
00128
00129 }
00130
00131 #endif
00132
00133