struct UnitEntry;
struct ProcessedVertex
{
Vec4f TransformedProjectionPos;
Vec2f TexCoord;
RGBColor Diffuse;
};
const DWORD ProcessedFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0);
class VBuffer
{
public:
VBuffer(HANDLE _Handle)
{
Handle = _Handle;
}
void Update(BufferLockData &Data, D3DVERTEXBUFFER_DESC &_Desc);
D3DVERTEXBUFFER_DESC Desc; Vector<BYTE> Buffer; HANDLE Handle; };
class IBuffer
{
public:
IBuffer(HANDLE _Handle)
{
Handle = _Handle;
}
__forceinline DWORD GetIndex(UINT Index) const
{
if(Desc.Format == D3DFMT_INDEX16)
{
return ((WORD *)Buffer.CArray())[Index];
}
else
{
return ((DWORD *)Buffer.CArray())[Index];
}
}
__forceinline DWORD Length() const
{
if(Desc.Format == D3DFMT_INDEX16)
{
return Buffer.Length() / sizeof(WORD);
}
else
{
return Buffer.Length() / sizeof(DWORD);
}
}
void Update(BufferLockData &Data, D3DINDEXBUFFER_DESC &_Desc);
D3DINDEXBUFFER_DESC Desc; Vector<BYTE> Buffer; HANDLE Handle; };
typedef map<ULONGLONG, UINT> BufferHashMap;
class BufferHasher
{
public:
BufferHasher();
ULONGLONG Hash(const char *Buffer, ULONG BufferLength);
BufferHashMap MaterialMap;
};
class Texture
{
public:
Texture(HANDLE Handle)
{
_Handle = Handle;
_BmpHash = 0;
_Type = RenderUninitialized;
}
void Update(const Bitmap &Bmp, const D3DSURFACE_DESC &Desc);
__forceinline const String& ID() const
{
return _ID;
}
__forceinline const String& Filename() const
{
return _Filename;
}
__forceinline const Bitmap& Bmp() const
{
return _Bmp;
}
__forceinline UINT BmpHash() const
{
return _BmpHash;
}
__forceinline RenderType Type() const
{
return _Type;
}
__forceinline UnitEntry* Unit() const
{
return _Unit;
}
private:
static bool IsFontBitmap(const Bitmap &Bmp);
static bool IsProceduralBitmap(const Bitmap &Bmp);
static bool IsScrapBitmap(const Bitmap &Bmp);
static bool IsMovieBitmap(const Bitmap &Bmp);
String _ID; String _Filename; RenderType _Type; D3DSURFACE_DESC _Desc; HANDLE _Handle; Bitmap _Bmp; UINT _BmpHash; UnitEntry* _Unit; };