D3DDevice.inl
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:10k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Copyright (C) 1999 DXGuide. All Rights Reserved.
- // File: D3DDevice.inl
- // Inlines for CD3DDevice
- #include "DirectX.h" // for REPORTDXERROR
- #include "D3DVertexBuffer.h" // for CD3DVertexBuffer
- inline LPDIRECT3D7 CD3DDevice::GetDirect3D(void) const
- {
- return m_lpD3D;
- }
- inline CD3DMaterial* CD3DDevice::GetD3DMaterial(void) const
- {
- return m_pD3DMaterial;
- }
- inline HRESULT CD3DDevice::GetInfo(DWORD dwDevInfoID,
- LPVOID pDevInfoStruct, DWORD dwSize)
- {
- HRESULT hr = m_lpD3DDevice->GetInfo(dwDevInfoID,
- pDevInfoStruct, dwSize);
- REPORTDXERROR(hr);
- return hr;
- }
- inline D3DDEVICEDESC7 const* CD3DDevice::GetD3DDeviceDesc(void) const
- {
- return m_pD3DDeviceDesc;
- }
- inline D3DPRIMCAPS const* CD3DDevice::GetTriCaps(void) const
- {
- return &(m_pD3DDeviceDesc->dpcTriCaps);
- }
- inline D3DPRIMCAPS const* CD3DDevice::GetLineCaps(void) const
- {
- return &(m_pD3DDeviceDesc->dpcLineCaps);
- }
- inline bool CD3DDevice::IsSupportMipmaps(void) const
- {
- return ((GetTriCaps()->dwTextureFilterCaps & (D3DPTFILTERCAPS_MIPNEAREST | D3DPTFILTERCAPS_MIPLINEAR)) != 0);
- }
- // Get triangle caps and check for w-buffering
- inline bool CD3DDevice::IsSupportWBuffer(void) const
- {
- return ((GetTriCaps()->dwRasterCaps & D3DPRASTERCAPS_WBUFFER) != 0);
- }
- inline bool CD3DDevice::IsSupportDirectionalLights(void) const
- {
- return ((m_pD3DDeviceDesc->dwVertexProcessingCaps & D3DVTXPCAPS_DIRECTIONALLIGHTS) != 0);
- }
- inline bool CD3DDevice::IsSupportPositionalLights(void) const
- {
- return ((m_pD3DDeviceDesc->dwVertexProcessingCaps & D3DVTXPCAPS_POSITIONALLIGHTS) != 0);
- }
- inline D3DDEVICETYPE CD3DDevice::GetDeviceType(void) const
- {
- return GetSelectedD3DDeviceInfoObject()->GetD3DDeviceType();
- }
- // -- Device states --
- inline HRESULT CD3DDevice::ApplyStateBlock(DWORD dwBlockHandle)
- {
- HRESULT hr = m_lpD3DDevice->ApplyStateBlock(dwBlockHandle);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::BeginStateBlock(void)
- {
- HRESULT hr = m_lpD3DDevice->BeginStateBlock();
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::EndStateBlock(LPDWORD lpdwBlockHandle)
- {
- HRESULT hr = m_lpD3DDevice->EndStateBlock(lpdwBlockHandle);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::CaptureStateBlock(DWORD dwBlockHandle)
- {
- HRESULT hr = m_lpD3DDevice->CaptureStateBlock(dwBlockHandle);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::CreateStateBlock(
- D3DSTATEBLOCKTYPE d3dsbType, LPDWORD lpdwBlockHandle)
- {
- HRESULT hr = m_lpD3DDevice->CreateStateBlock(
- d3dsbType, lpdwBlockHandle);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::DeleteStateBlock(DWORD dwBlockHandle)
- {
- HRESULT hr = m_lpD3DDevice->DeleteStateBlock(dwBlockHandle);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
- {
- HRESULT hr = m_lpD3DDevice->GetClipStatus(lpD3DClipStatus);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
- {
- HRESULT hr = m_lpD3DDevice->SetClipStatus(lpD3DClipStatus);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
- LPDWORD lpdwRenderState)
- {
- HRESULT hr = m_lpD3DDevice->GetRenderState(dwRenderStateType,
- lpdwRenderState);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::SetRenderState(
- D3DRENDERSTATETYPE dwRenderStateType,
- DWORD dwRenderState)
- {
- HRESULT hr = m_lpD3DDevice->SetRenderState(
- dwRenderStateType, dwRenderState);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetRenderTarget(
- LPDIRECTDRAWSURFACE7* lplpRenderTarget)
- {
- HRESULT hr = m_lpD3DDevice->GetRenderTarget(lplpRenderTarget);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetTransform(
- D3DTRANSFORMSTATETYPE dtstTransformStateType,
- LPD3DMATRIX lpD3DMatrix)
- {
- HRESULT hr = m_lpD3DDevice->GetTransform(
- dtstTransformStateType,
- lpD3DMatrix);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::SetTransform(
- D3DTRANSFORMSTATETYPE dtstTransformStateType,
- LPD3DMATRIX lpD3DMatrix)
- {
- HRESULT hr = m_lpD3DDevice->SetTransform(
- dtstTransformStateType,
- lpD3DMatrix);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::BeginScene(void)
- {
- HRESULT hr = m_lpD3DDevice->BeginScene();
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::EndScene(void)
- {
- HRESULT hr = m_lpD3DDevice->EndScene();
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::DrawPrimitive(
- D3DPRIMITIVETYPE dptPrimitiveType,
- DWORD dwVertexTypeDesc, LPVOID lpvVertices,
- DWORD dwVertexCount, DWORD dwFlags)
- {
- HRESULT hr = m_lpD3DDevice->DrawPrimitive(
- dptPrimitiveType, dwVertexTypeDesc,
- lpvVertices, dwVertexCount, dwFlags);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::DrawIndexedPrimitive(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- DWORD dwVertexTypeDesc, LPVOID lpvVertices,
- DWORD dwVertexCount, LPWORD lpwIndices,
- DWORD dwIndexCount, DWORD dwFlags)
- {
- HRESULT hr = m_lpD3DDevice->DrawIndexedPrimitive(
- d3dptPrimitiveType, dwVertexTypeDesc,
- lpvVertices, dwVertexCount, lpwIndices,
- dwIndexCount, dwFlags);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::DrawPrimitiveStrided(
- D3DPRIMITIVETYPE dptPrimitiveType,
- DWORD dwVertexTypeDesc,
- LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray,
- DWORD dwVertexCount,
- DWORD dwFlags)
- {
- HRESULT hr = m_lpD3DDevice->DrawPrimitiveStrided(
- dptPrimitiveType, dwVertexTypeDesc,
- lpVertexArray, dwVertexCount, dwFlags);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::DrawIndexedPrimitiveStrided(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- DWORD dwVertexTypeDesc,
- LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray,
- DWORD dwVertexCount,
- LPWORD lpwIndices,
- DWORD dwIndexCount,
- DWORD dwFlags)
- {
- HRESULT hr = m_lpD3DDevice->DrawIndexedPrimitiveStrided(
- d3dptPrimitiveType, dwVertexTypeDesc,
- lpVertexArray, dwVertexCount,
- lpwIndices, dwIndexCount, dwFlags);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::DrawPrimitiveVB(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- CD3DVertexBuffer* pD3DVertexBuffer,
- DWORD dwStartVertex,
- DWORD dwNumVertices,
- DWORD dwFlags)
- {
- HRESULT hr = m_lpD3DDevice->DrawPrimitiveVB(
- d3dptPrimitiveType, pD3DVertexBuffer->m_lpD3DVertexBuffer,
- dwStartVertex, dwNumVertices, dwFlags);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::DrawIndexedPrimitiveVB(
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- CD3DVertexBuffer* pD3DVertexBuffer,
- DWORD dwStartVertex,
- DWORD dwNumVertices,
- LPWORD lpwIndices,
- DWORD dwIndexCount,
- DWORD dwFlags)
- {
- HRESULT hr = m_lpD3DDevice->DrawIndexedPrimitiveVB(
- d3dptPrimitiveType,
- pD3DVertexBuffer->m_lpD3DVertexBuffer,
- dwStartVertex, dwNumVertices, lpwIndices,
- dwIndexCount, dwFlags);
- REPORTDXERROR(hr);
- return hr;
- }
- inline void CD3DDevice::SetTextureColorStage(DWORD dwStage, D3DTEXTUREOP op, DWORD dwArg1, DWORD dwArg2)
- {
- SetTextureStageState(dwStage, D3DTSS_COLOROP, op);
- SetTextureStageState(dwStage, D3DTSS_COLORARG1, dwArg1);
- SetTextureStageState(dwStage, D3DTSS_COLORARG2, dwArg2);
- }
- inline void CD3DDevice::SetTextureAlphaStage(DWORD dwStage, D3DTEXTUREOP op, DWORD dwArg1, DWORD dwArg2)
- {
- SetTextureStageState(dwStage, D3DTSS_ALPHAOP, op);
- SetTextureStageState(dwStage, D3DTSS_ALPHAARG1, dwArg1);
- SetTextureStageState(dwStage, D3DTSS_ALPHAARG2, dwArg2);
- }
- inline HRESULT CD3DDevice::SetMaterial(LPD3DMATERIAL7 lpMaterial)
- {
- HRESULT hr = m_lpD3DDevice->SetMaterial(lpMaterial);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetMaterial(LPD3DMATERIAL7 lpMaterial)
- {
- HRESULT hr = m_lpD3DDevice->GetMaterial(lpMaterial);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::SetLight(DWORD dwLightIndex, LPD3DLIGHT7 lpLight)
- {
- HRESULT hr = m_lpD3DDevice->SetLight(dwLightIndex, lpLight);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetLight(DWORD dwLightIndex, LPD3DLIGHT7 lpLight)
- {
- HRESULT hr = m_lpD3DDevice->GetLight(dwLightIndex, lpLight);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::LightEnable(DWORD dwLightIndex, BOOL bEnable)
- {
- HRESULT hr = m_lpD3DDevice->LightEnable(dwLightIndex, bEnable);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetLightEnable(DWORD dwLightIndex, BOOL* pbEnable) const
- {
- HRESULT hr = m_lpD3DDevice->GetLightEnable(dwLightIndex, pbEnable);
- REPORTDXERROR(hr);
- return hr;
- }
- inline DWORD CD3DDevice::GetMaxActiveLights(void) const
- {
- return m_pD3DDeviceDesc->dwMaxActiveLights;
- }
- inline HRESULT CD3DDevice::Load(LPDIRECTDRAWSURFACE7 lpDestTex,
- LPPOINT lpDestPoint, LPDIRECTDRAWSURFACE7 lpSrcTex,
- LPRECT lprcSrcRect, DWORD dwFlags)
- {
- HRESULT hr = m_lpD3DDevice->Load(lpDestTex,
- lpDestPoint, lpSrcTex, lprcSrcRect, dwFlags);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::PreLoad(LPDIRECTDRAWSURFACE7 lpddsTexture)
- {
- HRESULT hr = m_lpD3DDevice->PreLoad(lpddsTexture);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetClipPlane(DWORD dwIndex, D3DVALUE* pPlaneEquation)
- {
- HRESULT hr = m_lpD3DDevice->GetClipPlane(dwIndex, pPlaneEquation);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::SetClipPlane(DWORD dwIndex, D3DVALUE* pPlaneEquation)
- {
- HRESULT hr = m_lpD3DDevice->SetClipPlane(dwIndex, pPlaneEquation);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::GetViewport(LPD3DVIEWPORT7 lpViewport)
- {
- HRESULT hr = m_lpD3DDevice->GetViewport(lpViewport);
- REPORTDXERROR(hr);
- return hr;
- }
- inline HRESULT CD3DDevice::SetViewport(LPD3DVIEWPORT7 lpViewport)
- {
- HRESULT hr = m_lpD3DDevice->SetViewport(lpViewport);
- REPORTDXERROR(hr);
- return hr;
- }