00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _RM_UTILITIES_DDS_SURFACE_H_
00020 #define _RM_UTILITIES_DDS_SURFACE_H_
00021
00022 #include "RmDDSLoaderTypes.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class RMUTIL_API RmDDSSurface
00034 {
00035 public :
00036 RmDDSSurface();
00037 virtual ~RmDDSSurface();
00038
00039
00040
00041
00042 bool Create( RM_DDS_PIXEL_FORMAT pixelFormat, int width, int height );
00043 void Destroy();
00044
00045
00046
00047
00048 RM_DDS_BYTE* GetBuffer() { return m_pBuffer; };
00049 const RM_DDS_BYTE* GetBuffer() const { return m_pBuffer; };
00050
00051
00052
00053
00054 RM_DDS_BYTE* GetScanLine( int y );
00055 const RM_DDS_BYTE* GetScanLine( int y ) const;
00056
00057
00058
00059
00060 RM_DDS_BYTE* GetPixel( int x, int y );
00061 const RM_DDS_BYTE* GetPixel( int x, int y ) const;
00062
00063
00064
00065
00066 RM_DDS_BYTE* GetDXTBlock( int bx, int by );
00067 const RM_DDS_BYTE* GetDXTBlock( int bx, int by ) const;
00068
00069
00070
00071
00072 int GetWidth() const { return m_width; };
00073 int GetHeight() const { return m_height; };
00074
00075
00076 int GetBlockWidth() const { return m_blockWidth; };
00077 int GetBlockHeight() const { return m_blockHeight; };
00078
00079
00080 int GetPitch() const { return m_pitch; };
00081 int GetBytesPerPixel() const { return m_bytesPerPixel; };
00082
00083
00084 int GetDXTBlockSize() const { return m_DXTBlockSize; };
00085
00086 bool IsRGBAFormat() const;
00087 bool IsDXTFormat() const;
00088 bool IsLuminanceFormat() const;
00089
00090
00091 int GetTotalSize() const;
00092
00093
00094 RM_DDS_PIXEL_FORMAT GetPixelFormat() const { return m_pixelFormat; };
00095
00096
00097 bool ChangeFormatToRGBA( RmDDSSurface *pSurface );
00098
00099 private :
00100 RM_DDS_PIXEL_FORMAT m_pixelFormat;
00101 RM_DDS_BYTE *m_pBuffer;
00102 int m_width;
00103 int m_height;
00104 int m_pitch;
00105 int m_bytesPerPixel;
00106
00107 int m_blockWidth;
00108 int m_blockHeight;
00109 int m_DXTBlockSize;
00110
00111
00112
00113
00114 bool DecompressToRGBA( RmDDSSurface *pSurface );
00115 void DecompressDXTBlock( RM_DDS_PIXEL_FORMAT format, RM_DDS_BYTE *pDXTBlock, RM_DDS_BYTE *pDestBlock );
00116 void DecompressDXT1Block( RM_DDS_BYTE *pDXTBlock, RM_DDS_BYTE *pDestBlock, bool bUseTransparency );
00117 void DecompressDXT2_3Block( RM_DDS_BYTE *pDXTBlock, RM_DDS_BYTE *pDestBlock );
00118 void DecompressDXT4_5Block( RM_DDS_BYTE *pDXTBlock, RM_DDS_BYTE *pDestBlock );
00119
00120
00121 bool LuminanceToRGBA( RmDDSSurface *pSurface );
00122 };
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 class RMUTIL_API RmDDSTexture
00133 {
00134 public :
00135 RmDDSTexture();
00136 virtual ~RmDDSTexture();
00137
00138
00139
00140
00141 bool Create( RM_DDS_PIXEL_FORMAT pixelFormat, int width, int height,
00142 int numMipmaps );
00143 void Destroy();
00144
00145
00146
00147
00148 int GetNumMipmaps() const { return m_numMipmaps; };
00149
00150 RmDDSSurface* GetMipmap( int level );
00151 const RmDDSSurface* GetMipmap( int level ) const;
00152
00153
00154
00155
00156 int GetWidth() const { return m_width; };
00157 int GetHeight() const { return m_height; };
00158
00159 RM_DDS_PIXEL_FORMAT GetPixelFormat() const { return m_pixelFormat; };
00160
00161 private :
00162 int m_numMipmaps;
00163 RmDDSSurface *m_pMipmaps;
00164
00165 RM_DDS_PIXEL_FORMAT m_pixelFormat;
00166 int m_width;
00167 int m_height;
00168 };
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 class RMUTIL_API RmDDSCubemap
00179 {
00180 public :
00181 RmDDSCubemap();
00182 virtual ~RmDDSCubemap();
00183
00184
00185
00186
00187 bool Create( RM_DDS_PIXEL_FORMAT pixelFormat, int width, int height,
00188 int numMipmaps );
00189 void Destroy();
00190
00191
00192
00193
00194 RmDDSTexture* GetFace( RM_DDS_CUBEMAP_FACE whichFace );
00195 const RmDDSTexture* GetFace( RM_DDS_CUBEMAP_FACE whichFace ) const;
00196
00197
00198
00199
00200 int GetNumMipmaps() const { return m_numMipmaps; };
00201 int GetWidth() const { return m_width; };
00202 int GetHeight() const { return m_height; };
00203
00204 RM_DDS_PIXEL_FORMAT GetPixelFormat() const { return m_pixelFormat; };
00205
00206 private :
00207 RmDDSTexture *m_pFaces;
00208 int m_numMipmaps;
00209
00210 RM_DDS_PIXEL_FORMAT m_pixelFormat;
00211 int m_width;
00212 int m_height;
00213 };
00214
00215 #endif // __RmDDSSurface_H__