"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSGraphicsLib/Src/DirectX/LSGDirectX9StandardTexture.h

00001 
00016 #ifndef __LSG_DIRECTX9STANDARDTEXTURE_H__
00017 #define __LSG_DIRECTX9STANDARDTEXTURE_H__
00018 
00019 #include "../LSGGraphicsLib.h"
00020 #include "../Texture/LSGTextureBase.h"
00021 #include "Image/LSIImage.h"
00022 #include "LSGDirectX9LosableResource.h"
00023 
00024 #ifdef LSG_DX9
00025 
00026 namespace lsg {
00027 
00034         class CDirectX9StandardTexture : public CTextureBase, public CDirectX9LosableResource {
00035                 friend class                                    CDirectX9RenderTarget;
00036                 friend class                                    CDirectX9RenderTargetManager;
00037         public :
00038                 // == Various constructors.
00039                 LSE_CALLCTOR                                    CDirectX9StandardTexture();
00040                 virtual LSE_CALLCTOR                    ~CDirectX9StandardTexture();
00041 
00042 
00043                 // == Functions.
00047                 virtual LSVOID LSE_CALL                 Reset();
00048 
00055                 virtual LSBOOL LSE_CALL                 Activate( LSUINT32 _ui32Slot );
00056 
00060                 virtual LSVOID LSE_CALL                 OnDeviceLost();
00061 
00067                 virtual LSBOOL LSE_CALL                 OnDeviceReset();
00068 
00076                 static LSBOOL LSE_CALL                  CopyTexelsToDirectX9Surface( IDirect3DSurface9 * _pd3dsSurface, const CImage &_iTexels );
00077 
00088                 static LSBOOL LSE_CALL                  CopyTexelsToDirectX9Surface( IDirect3DSurface9 * _pd3dsSurface,
00089                         const CImageLib::CTexelBuffer &_tbTexels, LSI_PIXEL_FORMAT _pfFormat,
00090                         LSUINT32 _ui32Width, LSUINT32 _ui32Height );
00091 
00102                 static LSBOOL LSE_CALL                  CopyTexelsToDirectX9SurfaceDxt( IDirect3DSurface9 * _pd3dsSurface,
00103                         const CImageLib::CTexelBuffer &_tbTexels, LSI_PIXEL_FORMAT _pfFormat,
00104                         LSUINT32 _ui32Width, LSUINT32 _ui32Height );
00105 
00106 
00107         protected :
00108                 // == Members.
00112                 CImage                                                  m_iTexels;
00113 
00117                 IDirect3DTexture9 *                             m_pd3dtTexture;
00118 
00122                 LSBOOL                                                  m_bFlip;
00123 
00127                 D3DTEXTUREFILTERTYPE                    m_tftDirectX9FilterType;
00128 
00129 
00130                 // == Functions.
00136                 LSBOOL LSE_CALL                                 CreateApiTexture();
00137 
00144                 virtual LSBOOL LSE_CALL                 SetAsColorRenderTarget( LSUINT32 _ui32Slot ) const;
00145 
00149                 virtual LSVOID LSE_CALL                 EndAsRenderTarget() const;
00150 
00159                 LSBOOL LSE_CALL                                 CreateApiTextureDxt( const CImage &_iImage, LSUINT32 _ui32Usage, D3DPOOL _pPool );
00160 
00169                 LSBOOL LSE_CALL                                 GenerateMipMaps( IDirect3DTexture9 * _pd3dtTexture, const CImage &_iImage );
00170 
00180                 LSBOOL LSE_CALL                                 GenerateMipMapsDxt( IDirect3DTexture9 * _pd3dtTexture, const CImage &_iImage );
00181 
00194                 static LSE_INLINE LSUINT64 LSE_CALL
00195                                                                                 GetTexelAt( const CImageLib::CTexelBuffer &_tbTexels, LSI_PIXEL_FORMAT _pfFormat,
00196                                                                                         LSI_PIXEL_FORMAT _pfReqFormat,
00197                                                                                         LSUINT32 _ui32RowWidth, LSUINT32 _ui32TexelSize,
00198                                                                                         LSUINT32 _ui32X, LSUINT32 _ui32Y );
00199 
00208         private :
00209                 typedef CTextureBase                    Parent;
00210         };
00211 
00212 
00213         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00214         // DEFINITIONS
00215         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00216         // == Functions.
00229         LSE_INLINE LSUINT64 LSE_CALL CDirectX9StandardTexture::GetTexelAt( const CImageLib::CTexelBuffer &_tbTexels, LSI_PIXEL_FORMAT _pfFormat,
00230                 LSI_PIXEL_FORMAT _pfReqFormat,
00231                 LSUINT32 _ui32RowWidth, LSUINT32 _ui32TexelSize,
00232                 LSUINT32 _ui32X, LSUINT32 _ui32Y ) {
00233                 return CImageLib::IntegerTexelToIntegerTexel( _pfFormat, _pfReqFormat, (*reinterpret_cast<const LSUINT64 *>(&_tbTexels[_ui32Y*_ui32RowWidth+_ui32X*_ui32TexelSize])) );
00234         }
00235 
00236 }       // namespace lsg
00237 
00238 #endif  // #ifdef LSG_DX9
00239 
00240 #endif  // __LSG_DIRECTX9STANDARDTEXTURE_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator