D3DDevice.h
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:6k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Copyright (C) 1998-1999 DXGuide. All Rights Reserved.
- // File: D3DDevice.h
- #ifndef _D3DDEVICE__H
- #define _D3DDEVICE__H
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- #include "DDDevice.h"
- enum D3D_ML_COLORFLAGS
- {
- D3D_ML_AMBIENT = 0x00000001L,
- D3D_ML_DIFFUSE = 0x00000002L,
- D3D_ML_SPECULAR = 0x00000004L,
- D3D_M_EMISSIVE = 0x00000008L,
- };
- // Maintains the D3D surfaces, device, and viewport used for 3D rendering.
- class CD3DDevice : public CDDDevice
- {
- friend class CD3DLight; // for m_dwLightsNumber
- friend class CD3DMaterial;
- friend class CD3DVertexBuffer;
- friend class CDirectDraw;
- protected:
- CD3DDevice(void);
- virtual ~CD3DDevice();
- public:
- virtual bool Create(HWND hWnd, DWORD dwFlags);
- protected:
- bool CreateDirect3DInterface(DWORD dwFlags);
- bool CreateZBuffer(void);
- bool CreateD3DDevice(const GUID* const pDeviceGUID,
- CDDSurface* pDDSRenderTarget);
- public: // Information
- LPDIRECT3D7 GetDirect3D(void) const;
- CD3DMaterial* GetD3DMaterial(void) const;
- HRESULT GetCaps(LPD3DDEVICEDESC7 lpD3DDevDesc);
- HRESULT GetInfo(DWORD dwDevInfoID,
- LPVOID pDevInfoStruct, DWORD dwSize);
- D3DDEVICEDESC7 const* GetD3DDeviceDesc(void) const;
- D3DPRIMCAPS const* GetTriCaps(void) const;
- D3DPRIMCAPS const* GetLineCaps(void) const;
- D3DDEVICETYPE GetDeviceType(void) const;
- bool IsSupportMipmaps(void) const;
- bool IsSupportWBuffer(void) const;
- bool IsSupportDirectionalLights(void) const;
- bool IsSupportPositionalLights(void) const;
- public: // Device states
- HRESULT ApplyStateBlock(DWORD dwBlockHandle);
- HRESULT BeginStateBlock(void);
- HRESULT EndStateBlock(LPDWORD lpdwBlockHandle);
- HRESULT CaptureStateBlock(DWORD dwBlockHandle);
- HRESULT CreateStateBlock(D3DSTATEBLOCKTYPE d3dsbType,
- LPDWORD lpdwBlockHandle);
- HRESULT DeleteStateBlock(DWORD dwBlockHandle);
- HRESULT GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
- HRESULT SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
- HRESULT GetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
- LPDWORD lpdwRenderState);
- HRESULT SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
- DWORD dwRenderState);
- HRESULT GetRenderTarget(LPDIRECTDRAWSURFACE7* lplpRenderTarget);
- HRESULT SetRenderTarget(CDDSurface* pDDSNewRenderTarget);
- HRESULT GetTransform(
- D3DTRANSFORMSTATETYPE dtstTransformStateType,
- LPD3DMATRIX lpD3DMatrix);
- HRESULT SetTransform(
- D3DTRANSFORMSTATETYPE dtstTransformStateType,
- LPD3DMATRIX lpD3DMatrix);
- public:
- // Functions to support sprite-based rendering
- HRESULT ChangeRenderTarget(CDDSurface* pDDSNewTarget);
- public: // Creation
- HRESULT CreateVertexBuffer(
- LPD3DVERTEXBUFFERDESC lpVBDesc,
- LPDIRECT3DVERTEXBUFFER7* lpD3DVertexBuffer,
- DWORD dwFlags);
- public: // Miscellaneous
- HRESULT EvictManagedTextures(void);
- public: // Scenes
- HRESULT BeginScene(void);
- HRESULT EndScene(void);
- public: // Rendering
- HRESULT DrawPrimitive(
- D3DPRIMITIVETYPE dptPrimitiveType,
- DWORD dwVertexTypeDesc, LPVOID lpvVertices,
- DWORD dwVertexCount, DWORD dwFlags);
- HRESULT DrawIndexedPrimitive(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- DWORD dwVertexTypeDesc, LPVOID lpvVertices,
- DWORD dwVertexCount, LPWORD lpwIndices,
- DWORD dwIndexCount, DWORD dwFlags);
- HRESULT DrawPrimitiveStrided(
- D3DPRIMITIVETYPE dptPrimitiveType,
- DWORD dwVertexTypeDesc,
- LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray,
- DWORD dwVertexCount,
- DWORD dwFlags);
- HRESULT DrawIndexedPrimitiveStrided(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- DWORD dwVertexTypeDesc,
- LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray,
- DWORD dwVertexCount,
- LPWORD lpwIndices,
- DWORD dwIndexCount,
- DWORD dwFlags);
- HRESULT DrawPrimitiveVB(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- CD3DVertexBuffer* pD3DVertexBuffer,
- DWORD dwStartVertex,
- DWORD dwNumVertices,
- DWORD dwFlags);
- HRESULT DrawIndexedPrimitiveVB(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- CD3DVertexBuffer* pD3DVertexBuffer,
- DWORD dwStartVertex,
- DWORD dwNumVertices,
- LPWORD lpwIndices,
- DWORD dwIndexCount,
- DWORD dwFlags);
- public: // Miscellaneous
- HRESULT ComputeSphereVisibility(LPD3DVECTOR lpCenters,
- LPD3DVALUE lpRadii, DWORD dwNumSpheres,
- DWORD dwFlags, LPDWORD lpdwReturnValues);
- HRESULT MultiplyTransform(
- D3DTRANSFORMSTATETYPE dtstTransformStateType,
- LPD3DMATRIX lpD3DMatrix);
- public: // Textures
- HRESULT SetTexture(DWORD dwStage,
- LPDIRECTDRAWSURFACE7 lpTexture);
- HRESULT GetTexture(DWORD dwStage,
- LPDIRECTDRAWSURFACE7* lplpTexture);
- HRESULT ValidateDevice(LPDWORD lpdwPasses);
- HRESULT SetTextureStageState(DWORD dwStage,
- D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
- HRESULT GetTextureStageState(DWORD dwStage,
- D3DTEXTURESTAGESTATETYPE dwState, LPDWORD lpdwValue);
- HRESULT Load(LPDIRECTDRAWSURFACE7 lpDestTex,
- LPPOINT lpDestPoint, LPDIRECTDRAWSURFACE7 lpSrcTex,
- LPRECT lprcSrcRect, DWORD dwFlags);
- HRESULT PreLoad(LPDIRECTDRAWSURFACE7 lpddsTexture);
- public:
- void SetTextureColorStage(DWORD dwStage, D3DTEXTUREOP op, DWORD dwArg1, DWORD dwArg2);
- void SetTextureAlphaStage(DWORD dwStage, D3DTEXTUREOP op, DWORD dwArg1, DWORD dwArg2);
- public: // Lighting and Materials
- HRESULT SetMaterial(LPD3DMATERIAL7 lpMaterial);
- HRESULT GetMaterial(LPD3DMATERIAL7 lpMaterial);
- HRESULT SetLight(DWORD dwLightIndex, LPD3DLIGHT7 lpLight);
- HRESULT GetLight(DWORD dwLightIndex, LPD3DLIGHT7 lpLight);
- HRESULT LightEnable(DWORD dwLightIndex, BOOL bEnable);
- HRESULT GetLightEnable(DWORD dwLightIndex, BOOL* pbEnable) const;
- DWORD GetActiveLightsNumber(void) const;
- DWORD GetMaxActiveLights(void) const;
- public: // User-defined clip planes
- HRESULT GetClipPlane(DWORD dwIndex, D3DVALUE* pPlaneEquation);
- HRESULT SetClipPlane(DWORD dwIndex, D3DVALUE* pPlaneEquation);
- public: // Viewports
- HRESULT Clear(DWORD dwColor = CLR_INVALID);
- HRESULT GetViewport(LPD3DVIEWPORT7 lpViewport);
- HRESULT SetViewport(LPD3DVIEWPORT7 lpViewport);
- protected:
- DWORD m_dwLightsNumber;
- protected:
- const D3DDEVICEDESC7* m_pD3DDeviceDesc;
- CD3DMaterial* m_pD3DMaterial;
- LPDIRECT3DDEVICE7 m_lpD3DDevice;
- CDDSurface* m_pZBuffer;
- LPDIRECT3D7 m_lpD3D;
- };
- #include "D3DDevice.inl"
- #endif // _D3DDEVICE__H