My Project
ContentLoaderTexture.h
1 #pragma once
2 #include "TextureEntity.h"
3 #include "IDataLoader.h"
4 
5 namespace ParaEngine
6 {
7  struct AssetFileEntry;
8 
14  class CTextureLoader : public IDataLoader
15  {
16  public:
17  friend struct TextureEntity;
18 
20  asset_ptr<TextureEntity> m_asset;
21  // if this is "", m_asset->GetLocalFileName() is used.
22  std::string m_sFileName;
24  void** m_ppTexture;
25 
27  D3DFORMAT m_dwTextureFormat;
30  // the color key(default to 0): Color value to replace with transparent black, or 0 to disable the color key. This is always a 32-bit ARGB color,
31  // independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys.
32  // Thus, for opaque black, the value would be equal to 0xFF000000. COLOR_XRGB(0,0,0)
33  Color m_dwColorKey;
34 
35  char* m_pData;
36  int m_cBytes;
37  CParaFile m_file;
38 
41  public:
45  CTextureLoader(asset_ptr<TextureEntity>& pAsset, const char* sFileName = NULL);
46  ~CTextureLoader();
47 
49  HRESULT CleanUp();
50 
51  // overrides
52  public:
54  const char* GetFileName();
55 
57  const char* GetKeyName();
58 
60  HRESULT Decompress(void** ppData, int* pcBytes);
62  HRESULT Destroy();
65  HRESULT Load();
66  };
67 
72  {
73  public:
74  friend struct TextureEntity;
75 
77  asset_ptr<TextureEntity> m_asset;
81  void** m_ppTexture;
82 
84  D3DFORMAT m_dwTextureFormat;
87  // the color key(default to 0): Color value to replace with transparent black, or 0 to disable the color key. This is always a 32-bit ARGB color,
88  // independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys.
89  // Thus, for opaque black, the value would be equal to 0xFF000000. COLOR_XRGB(0,0,0)
90  Color m_dwColorKey;
91 
92  char* m_pData;
93  int m_cBytes;
94  private:
95  // This is a private function that either Locks and copies the data (D3D9)
96  bool PopulateTexture();
97 
98  public:
99  CTextureProcessor(asset_ptr<TextureEntity>& pAsset);
101 
103  RenderDevicePtr GetRenderDevice();
104 
106  HRESULT CleanUp();
107 
108  // overrides
109  public:
110  HRESULT LockDeviceObject();
111  HRESULT UnLockDeviceObject();
112  HRESULT Destroy();
113  HRESULT Process(void* pData, int cBytes);
114  HRESULT CopyToResource();
115  void SetResourceError();
116  };
117 }
CTextureLoader implementation of IDataLoader it will first search locally.
Definition: ContentLoaderTexture.h:14
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
CTextureProcessor implementation of IDataProcessor.
Definition: ContentLoaderTexture.h:71
light-weighted file record header in memory.
Definition: AssetManifest.h:10
D3DFORMAT m_dwTextureFormat
the format of the texture, default to D3DFMT_UNKNOWN
Definition: ContentLoaderTexture.h:84
different physics engine has different winding order.
Definition: EventBinding.h:32
HRESULT Decompress(void **ppData, int *pcBytes)
Decompress is called by one of the processing threads to decompress the data.
Definition: ContentLoaderTexture.cpp:50
const char * GetFileName()
get file name
Definition: ContentLoaderTexture.cpp:28
AssetFileEntry * m_pAssetFileEntry
the loader failed because the asset file the following file needs to be downloaded from the asset web...
Definition: ContentLoaderTexture.h:40
a very thin wrapper to DirectX device with a portable version of openGL implementation.
Definition: RenderDeviceDirectX.h:10
asset_ptr< TextureEntity > m_asset
the asset file that this texture loader will update to
Definition: ContentLoaderTexture.h:20
void ** m_ppTexture
if this is NULL, the m_asset->m_pTexture is sued.
Definition: ContentLoaderTexture.h:24
RenderDevicePtr m_pDevice
if this is NULL, the default device is used.
Definition: ContentLoaderTexture.h:79
const char * GetKeyName()
get key name
Definition: ContentLoaderTexture.cpp:41
HRESULT Destroy()
Destroy is called by the graphics thread when it has consumed the data.
Definition: ContentLoaderTexture.cpp:103
CTextureLoader(asset_ptr< TextureEntity > &pAsset, const char *sFileName=NULL)
Definition: ContentLoaderTexture.cpp:15
IDataProcessor is an interface that the AsyncLoader class uses to process and copy data into locked r...
Definition: IDataLoader.h:76
UINT m_nMipLevels
Mip levels, default to D3DX_DEFAULT.
Definition: ContentLoaderTexture.h:86
HRESULT CleanUp()
clean up everything
Definition: ContentLoaderTexture.cpp:61
it presents a real or virtual file in ParaEngine.
Definition: ParaFile.h:31
IDataLoader is an interface that the AsyncLoader class uses to load data from disk.
Definition: IDataLoader.h:14
HRESULT Load()
Load is called from the IO thread to load data.
Definition: ContentLoaderTexture.cpp:122
UINT m_nMipLevels
Mip levels, default to D3DX_DEFAULT.
Definition: ContentLoaderTexture.h:29
D3DFORMAT m_dwTextureFormat
the format of the texture, default to D3DFMT_UNKNOWN
Definition: ContentLoaderTexture.h:27
void ** m_ppTexture
if this is NULL, the m_asset->m_pTexture is sued.
Definition: ContentLoaderTexture.h:81
Definition: ParaColor.h:275
asset_ptr< TextureEntity > m_asset
the asset file that this texture loader will update to
Definition: ContentLoaderTexture.h:77