//=================================================================
//
// Copyright (c) Microsoft Corporation 1999 - All Rights Reserved.
//
//=================================================================

#pragma once

#include "3dmath.h"
#include "color.h"
#include "wrappertypes.h"
#include "transform.h"
#include "grftypes.h"

class SurfaceClass;
class CDirect3DDevice;
class CDirect3DViewport;

#ifdef USE_DX7_INTERFACE
#define MAX_LIGHTS		2
#endif
//#include "softwaredevice.h"

//========================================================================
//
//========================================================================
class SurfaceClass
{
public:
	DDSURFACEDESC2			SurfaceDesc;
	IDirectDrawSurface7		*pSurface;
	BOOL					locked;
	DWORD					fmt;

	SurfaceClass();
	~SurfaceClass();

	HRESULT Set(IDirectDrawSurface7 *p);
	HRESULT Lock(void);
	HRESULT Unlock(void);
};

//========================================================================
//
//========================================================================

// bit used to enable/disable intensity shading
const int BLADE_INTENSITYSHADING = 0x001;
// bit used in overloading mono enable to also enable pixel doubling
const int BLADE_PIXDOUBLE = 0x100;
// bit used in overloading mono enable to also indicate that surfaces rather
// than textures are being passed to SetTexture
const int BLADE_TEXTURES_ARE_SURFACES = 0x200;
// bit used in overloading mono enable to also enable monochrome fog (based
// only on the blue component of the fog color)
const int BLADE_MONO_FOG = 0x400;


//JJ Fix-A-Roo
#define MAX_DEVICES 16

#ifdef USE_DX7_INTERFACE
class CDirect3DDevice : public IDirect3DDevice3, public IDirect3DDevice7
#else
class CDirect3DDevice : public IDirect3DDevice3
#endif
{
	friend class CDirect3DViewport;
	friend class CDirect3DVertexBuffer;
	friend class CDirectDraw;

	//JJ Fix-A-Roo -- had to do this
	friend IDirect3DVertexBuffer7* WINAPI GetDXVB(LPDIRECT3DVERTEXBUFFER7 pVBuf,LPDIRECT3DDEVICE7 pDevice);

public:
	/*** IUnknown methods ***/
	STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj);
	STDMETHOD_(ULONG,AddRef)(THIS);
	STDMETHOD_(ULONG,Release)(THIS);

	/*** IDirect3DDevice3 methods ***/
	STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC,LPD3DDEVICEDESC);
	STDMETHOD(GetStats)(THIS_ LPD3DSTATS);
	STDMETHOD(AddViewport)(THIS_ LPDIRECT3DVIEWPORT3);
	STDMETHOD(DeleteViewport)(THIS_ LPDIRECT3DVIEWPORT3);
	STDMETHOD(NextViewport)(THIS_ LPDIRECT3DVIEWPORT3,LPDIRECT3DVIEWPORT3*,DWORD);
	STDMETHOD(EnumTextureFormats)(THIS_ LPD3DENUMPIXELFORMATSCALLBACK,LPVOID);
	STDMETHOD(BeginScene)(THIS);
	STDMETHOD(EndScene)(THIS);
	STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D3*);
	STDMETHOD(SetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT3);
	STDMETHOD(GetCurrentViewport)(THIS_ LPDIRECT3DVIEWPORT3 *);
	STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE4,DWORD);
	STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE4 *);
	STDMETHOD(Begin)(THIS_ D3DPRIMITIVETYPE,DWORD,DWORD);
	STDMETHOD(BeginIndexed)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD);
	STDMETHOD(Vertex)(THIS_ LPVOID);
	STDMETHOD(Index)(THIS_ WORD);
	STDMETHOD(End)(THIS_ DWORD);
	STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE,LPDWORD);
	STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE,DWORD);
	STDMETHOD(GetLightState)(THIS_ D3DLIGHTSTATETYPE,LPDWORD);
	STDMETHOD(SetLightState)(THIS_ D3DLIGHTSTATETYPE,DWORD);
	STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX);
	STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX);
	STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,LPD3DMATRIX);
	STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD);
	STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,LPWORD,DWORD,DWORD);
	STDMETHOD(SetClipStatus)(THIS_ LPD3DCLIPSTATUS);
	STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS);
	STDMETHOD(DrawPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,DWORD);
	STDMETHOD(DrawIndexedPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPWORD,DWORD,DWORD);
	STDMETHOD(DrawPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,DWORD,DWORD,DWORD);
	STDMETHOD(DrawIndexedPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,LPWORD,DWORD,DWORD);
	STDMETHOD(ComputeSphereVisibility)(THIS_ LPD3DVECTOR,LPD3DVALUE,DWORD,DWORD,LPDWORD);
	STDMETHOD(GetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,LPDWORD);
	STDMETHOD(SetTextureStageState)(THIS_ DWORD,D3DTEXTURESTAGESTATETYPE,DWORD);
	STDMETHOD(ValidateDevice)(THIS_ LPDWORD);
	STDMETHOD(GetTexture)(THIS_ DWORD,LPDIRECT3DTEXTURE2 *);
	STDMETHOD(SetTexture)(THIS_ DWORD,LPDIRECT3DTEXTURE2);

#ifdef USE_DX7_INTERFACE
	STDMETHOD(GetCaps)(THIS_ LPD3DDEVICEDESC7);
	STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D7*);
	STDMETHOD(SetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE7,DWORD);
	STDMETHOD(GetRenderTarget)(THIS_ LPDIRECTDRAWSURFACE7 *);
	STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD);
	STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT7);
	STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT7);
	STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL7);
	STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL7);
	STDMETHOD(SetLight)(THIS_ DWORD,LPD3DLIGHT7);
	STDMETHOD(GetLight)(THIS_ DWORD,LPD3DLIGHT7);
	STDMETHOD(BeginStateBlock)(THIS);
	STDMETHOD(EndStateBlock)(THIS_ LPDWORD);
	STDMETHOD(PreLoad)(THIS_ LPDIRECTDRAWSURFACE7);
	STDMETHOD(DrawPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,DWORD);
	STDMETHOD(DrawIndexedPrimitiveVB)(THIS_ D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,LPWORD,DWORD,DWORD);
	STDMETHOD(GetTexture)(THIS_ DWORD,LPDIRECTDRAWSURFACE7 *);
	STDMETHOD(SetTexture)(THIS_ DWORD,LPDIRECTDRAWSURFACE7);
	STDMETHOD(ApplyStateBlock)(THIS_ DWORD);
	STDMETHOD(CaptureStateBlock)(THIS_ DWORD);
	STDMETHOD(DeleteStateBlock)(THIS_ DWORD);
	STDMETHOD(GetInfo)(THIS_ DWORD,LPVOID,DWORD);
	STDMETHOD(Load)(THIS_ LPDIRECTDRAWSURFACE7,LPPOINT,LPDIRECTDRAWSURFACE7,LPRECT,DWORD);
	STDMETHOD(LightEnable)(THIS_ DWORD,BOOL);
	STDMETHOD(GetLightEnable)(THIS_ DWORD,BOOL*);
	STDMETHOD(SetClipPlane)(THIS_ DWORD,D3DVALUE*);
	STDMETHOD(GetClipPlane)(THIS_ DWORD,D3DVALUE*);
    STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE,LPDWORD);
#endif

	int GetDirectXBaseObjectRefCount(void)
	{
		if (m_pDevice3)
		{
			m_pDevice3->AddRef();
			return m_pDevice3->Release();
		}
		else
			return -1;
	}



private:
	//JJ Fix-A-Roo; static members for keeping track of Created Blade Devices
	static int		s_nDevCnt;
	static IDirect3DDevice7* s_pDeviceList[MAX_DEVICES];


	WORD			*m_pwColorMap;
	WORD			m_rgwColorTable[32 * 256];
	
	GRFRENDERDEVICE	m_imgdev;
	
	int				m_cxTexWidth;
	int				m_cyTexHeight;
	
	float			m_cfxTexWidth;
	float			m_cfyTexHeight;

#ifdef USE_DX7_INTERFACE
	D3DVIEWPORT7	m_viewport;
	D3DMATERIAL7	m_material;
	D3DLIGHT7		m_light[MAX_LIGHTS];
	D3DCOLORVALUE	m_diffuse;			// diffuse material * diffise light color
	D3DCOLORVALUE	m_ambient;			// ambient material * ambient render state
	D3DCOLOR		m_ambient_color;	// m_ambient converted to a D3DCOLOR
	D3DVECTOR		m_light_dir;		// light direction in model space
#endif
	
	/*** Internal functions ***/

    inline void DrawTriangle(D3DTLVERTEX *P0, D3DTLVERTEX *P1, D3DTLVERTEX *P2)
    {
	    ASSERT(m_Target.pSurface != NULL);

	    ASSERT(P0->sx >= 0.0);
	    ASSERT(P0->sy >= 0.0);
	    ASSERT(P0->sx <= m_imgdev.GetScreenWidth());
	    ASSERT(P0->sy <= m_imgdev.GetScreenHeight());

	    ASSERT(P1->sx >= 0.0);
	    ASSERT(P1->sy >= 0.0);
	    ASSERT(P1->sx <= m_imgdev.GetScreenWidth());
	    ASSERT(P1->sy <= m_imgdev.GetScreenHeight());

	    ASSERT(P2->sx >= 0.0);
	    ASSERT(P2->sy >= 0.0);
	    ASSERT(P2->sx <= m_imgdev.GetScreenWidth());
	    ASSERT(P2->sy <= m_imgdev.GetScreenHeight());

	    ASSERT(P2->sz >= 0.0);

	    ASSERT(m_imgdev.GetScreenWidth()  == (int)m_Target.SurfaceDesc.dwWidth);
	    ASSERT(m_imgdev.GetScreenHeight() == (int)m_Target.SurfaceDesc.dwHeight);

        m_imgdev.DrawTri(P0, P1, P2);
    }

    void DrawLine(THIS_ D3DTLVERTEX *v0, D3DTLVERTEX *v1);
	void DrawPoint(THIS_ D3DTLVERTEX *v0);

	inline void convert_vertex(GRFVERTEX * v, D3DTLVERTEX * d3d);

	IDirect3D3			*m_pDirect3D3;
#ifdef USE_DX7_INTERFACE
	IDirect3DDevice7	*m_pDevice7;
#endif
	IDirect3DDevice3	*m_pDevice3;
	IDirect3DViewport3	*m_pViewport3;

	int					m_cRef;

	SurfaceClass		m_Target;
	SurfaceClass		m_ZBuffer;
	SurfaceClass		m_Texture;

	D3DMATRIX			m_mtxWorld;
	D3DMATRIX			m_mtxView;
	D3DMATRIX			m_mtxProjection;
	D3DMATRIX			m_mtxClip;

	D3DMATRIX			m_mtxPC;	// Projection * Clip
	D3DMATRIX			m_mtxVPC;	// View * Projection x Clip
	D3DMATRIX			m_mtxWVPC;	// World * View * Projection * Clip

	D3DVIEWPORT2		m_vdViewportData;

	D3DCLIPSTATUS		m_csClipStatus;

	float				m_xScale;
	float				m_yScale;

	float				m_xOffset;
	float				m_yOffset;

	WORD				m_dwTransformFlags;

	enum
	{
#ifdef USE_DX7_INTERFACE
		MAX_RENDER_STATE		= D3DRENDERSTATE_CLIPPLANEENABLE,
		MAX_TEXTURE_STAGE_STATE	= D3DTSS_TEXTURETRANSFORMFLAGS,
#else
		MAX_RENDER_STATE		= D3DRENDERSTATE_TEXTUREFACTOR,
		MAX_TEXTURE_STAGE_STATE	= D3DTSS_BUMPENVLOFFSET,
#endif
	};

	DWORD m_rgdwRenderState[MAX_RENDER_STATE + 1];
	DWORD m_rgdwTextureStageState[MAX_TEXTURE_STAGE_STATE + 1];

	DWORD m_dwStatus;

	/*** Internal functions ***/

private:
	void UpdateWorldTransform(void);
	void UpdateViewTransform(void);
	void UpdateProjectionTransform(void);
	void UpdateClipTransform(void);
	void UpdateTransforms(void);
	void UpdateLighting(void);

	void SetClipCodes(D3DTLVERTEX * ptlvIn, GRFCLIPVERTEX * pvOut, int c);

	void ComputeScreenCoordinates(GRFCLIPVERTEX ** rgpcvIn, int cIn);

	void ClipAndDrawTriangle(GRFCLIPVERTEX * pcv1, GRFCLIPVERTEX * pcv2, GRFCLIPVERTEX * pcv3, DWORD dwClipFlags);
	void ClipAndDrawLine(GRFCLIPVERTEX * pcv1, GRFCLIPVERTEX * pcv2, DWORD dwClipFlags);
	void ClipAndDrawPoint(GRFCLIPVERTEX *pcv);

public:
//	SoftwareDevice(IDirect3D *pDirect3D = NULL, IDirect3DDevice * pDevice = NULL);

    BOOL AlphaBlend(void);
    BOOL SrcBlend(void);
    BOOL DestBlend(void);
    BOOL AlphaTest(void);
    BOOL ZWrite(void);
    BOOL ZCompare(void);
    BOOL Fog(void);
    BOOL ShadeGouraud(void);
    BOOL MonoEnable(void);
    BOOL TexBlendDecal(void);
    BOOL TexBlendModulateAlpha(void);
    BOOL TexBlendModulateUseDiffuseAlpha(void);
    BOOL TexBlendModulateUseTextureAlpha(void);
    BOOL TexBlendModulateUseNoAlpha(void);
    BOOL TexBlendDecalUseNoAlpha(void);
#ifdef USE_DX7_INTERFACE
	BOOL TexBlendAlphaOnly(void);
	BOOL TexBlendAlphaModulateOnly(void);
#endif
    BOOL TextureMap(void);
    DWORD TexelFormat(void);
    BOOL Perspective(void);
    BOOL PixDouble(void);
    BOOL TextureWrapU(void);
    BOOL TextureWrapV(void);
    BOOL MonoFog(void);

    BOOL CDirect3DDevice::TexturesAreSurfaces(void)
    {
        return !!(m_rgdwRenderState[D3DRENDERSTATE_MONOENABLE] & BLADE_TEXTURES_ARE_SURFACES);
    }

    BOOL Cull(void) { return m_rgdwRenderState[D3DRENDERSTATE_CULLMODE] != D3DCULL_NONE; }

    BOOL CullCCW(void);
    BOOL CullCW(void);

    DWORD CDirect3DDevice::FogColor(void)
    {
        return m_rgdwRenderState[D3DRENDERSTATE_FOGCOLOR];
    }

    DWORD CDirect3DDevice::SkipLastPixel(void)
    {
        // note that D3DRENDERSTATE_LASTPIXEL set to 1 means *skip* last pixel
        return m_rgdwRenderState[D3DRENDERSTATE_LASTPIXEL];
    }

    static HRESULT Static_GetCaps(LPD3DDEVICEDESC, LPD3DDEVICEDESC);
	static HRESULT Static_GetCaps(LPD3DDEVICEDESC7);


	CDirect3DDevice(IDirect3D *pDirect3D = NULL, IDirect3DDevice * pDevice = NULL);
	~CDirect3DDevice();
};




//========================================================================
//
//========================================================================
class CDirect3DViewport : public IDirect3DViewport3
{
    friend class CDirectDraw;
    friend class CDirect3DDevice;

public:
    /*** IUnknown methods ***/
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj);
    STDMETHOD_(ULONG,AddRef)(THIS);
    STDMETHOD_(ULONG,Release)(THIS);

    /*** IDirect3DViewport2 methods ***/
    STDMETHOD(Initialize)(THIS_ LPDIRECT3D);
    STDMETHOD(GetViewport)(THIS_ LPD3DVIEWPORT);
    STDMETHOD(SetViewport)(THIS_ LPD3DVIEWPORT);
    STDMETHOD(TransformVertices)(THIS_ DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD);
    STDMETHOD(LightElements)(THIS_ DWORD,LPD3DLIGHTDATA);
    STDMETHOD(SetBackground)(THIS_ D3DMATERIALHANDLE);
    STDMETHOD(GetBackground)(THIS_ LPD3DMATERIALHANDLE,LPBOOL);
    STDMETHOD(SetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE);
    STDMETHOD(GetBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE*,LPBOOL);
    STDMETHOD(Clear)(THIS_ DWORD,LPD3DRECT,DWORD);
    STDMETHOD(AddLight)(THIS_ LPDIRECT3DLIGHT);
    STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DLIGHT);
    STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD);
    STDMETHOD(GetViewport2)(THIS_ LPD3DVIEWPORT2);
    STDMETHOD(SetViewport2)(THIS_ LPD3DVIEWPORT2);
    STDMETHOD(SetBackgroundDepth2)(THIS_ LPDIRECTDRAWSURFACE4);
    STDMETHOD(GetBackgroundDepth2)(THIS_ LPDIRECTDRAWSURFACE4*,LPBOOL);
    STDMETHOD(Clear2)(THIS_ DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD);

protected:
	CDirect3DDevice *		m_pDevice;
	D3DVIEWPORT2			m_data;
	IDirect3DLight* 		m_pLight;
	int						m_cRef;

	CDirect3DViewport() :
		m_pDevice(NULL),
		m_pLight(NULL),
		m_cRef(0)
		{;}

	~CDirect3DViewport() {;}
};

//========================================================================
//CDirect3DMaterial
//========================================================================
class CDirect3DMaterial : public IDirect3DMaterial3
{
    friend class CDirectDraw;
    friend class CDirect3DDevice;

public:
    /*** IUnknown methods ***/
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj);
    STDMETHOD_(ULONG,AddRef)(THIS);
    STDMETHOD_(ULONG,Release)(THIS);

    /*** IDirect3DMaterial3 methods ***/
    STDMETHOD(SetMaterial)(THIS_ LPD3DMATERIAL);
    STDMETHOD(GetMaterial)(THIS_ LPD3DMATERIAL);
    STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE3,LPD3DMATERIALHANDLE);

protected:
    D3DMATERIAL     m_mat;
    int             m_cRef;

    CDirect3DMaterial() : m_cRef(0) {}
    ~CDirect3DMaterial()            {}
};

//========================================================================
//CDirect3DLight
//========================================================================
class CDirect3DLight : public IDirect3DLight
{
    friend class CDirectDraw;
    friend class CDirect3DDevice;

public:
    /*** IUnknown methods ***/
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj);
    STDMETHOD_(ULONG,AddRef)(THIS);
    STDMETHOD_(ULONG,Release)(THIS);

    /*** IDirect3DLight methods ***/
    STDMETHOD(Initialize)(THIS_ LPDIRECT3D);
    STDMETHOD(SetLight)(THIS_ LPD3DLIGHT);
    STDMETHOD(GetLight)(THIS_ LPD3DLIGHT);

protected:
    D3DLIGHT2       m_light;
    int             m_cRef;

    CDirect3DLight() : m_cRef(0) {}
    ~CDirect3DLight()            {}
};

//========================================================================
//CDirect3DVertexBuffer
//========================================================================
#ifdef USE_DX7_INTERFACE
class CDirect3DVertexBuffer : public IDirect3DVertexBuffer, public IDirect3DVertexBuffer7
{
    friend class CDirectDraw;
    friend class CDirect3DDevice;

	//JJ Fix-A-Roo;  Needed for our calls
	friend IDirect3DVertexBuffer7* WINAPI GetDXVB(LPDIRECT3DVERTEXBUFFER7 pVBuf,LPDIRECT3DDEVICE7 pDevice);

public:
    /*** IUnknown methods ***/
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj);
    STDMETHOD_(ULONG,AddRef)(THIS);
    STDMETHOD_(ULONG,Release)(THIS);

    /*** IDirect3DVertexBuffer methods ***/
    STDMETHOD(Lock)(THIS_ DWORD,LPVOID*,LPDWORD);
    STDMETHOD(Unlock)(THIS);
    STDMETHOD(ProcessVertices)(THIS_ DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER,DWORD,LPDIRECT3DDEVICE3,DWORD);
    STDMETHOD(GetVertexBufferDesc)(THIS_ LPD3DVERTEXBUFFERDESC);
    STDMETHOD(Optimize)(THIS_ LPDIRECT3DDEVICE3,DWORD);

    /*** IDirect3DVertexBuffer7 methods ***/
    STDMETHOD(ProcessVertices)(THIS_ DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER7,DWORD,LPDIRECT3DDEVICE7,DWORD);
    STDMETHOD(Optimize)(THIS_ LPDIRECT3DDEVICE7,DWORD);
    STDMETHOD(ProcessVerticesStrided)(THIS_ DWORD,DWORD,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPDIRECT3DDEVICE7,DWORD);

private:
	CDirect3DVertexBuffer();
	~CDirect3DVertexBuffer();

	int						m_cRef;

	//JJ Fix-A-Roo
	LPDIRECT3DVERTEXBUFFER7 m_pOptimizedBuf;
	LPDIRECT3DVERTEXBUFFER7 m_pRawBuf;

	D3DVERTEXBUFFERDESC		m_VBDesc;
	bool					m_bOptimized;

};
#endif // USE_DX7_INTERFACE
