Beispiel #1
0
bool CMatrixInspector::Update()
{
	HRESULT hr;
	CGraphicsManager * pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 * pDev = pGraphicsManager->GetDevice();

	hr = pDev->GetTransform(D3DTS_WORLD, &m_matWorld);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to get world transform", hr);
		return false;
	}

	hr = pDev->GetTransform(D3DTS_VIEW, &m_matView);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to get view transform", hr);
		return false;
	}

	hr = pDev->GetTransform(D3DTS_PROJECTION, &m_matProjection);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to get projection transform", hr);
		return false;
	}

	D3DXMatrixMultiply(&m_matAll, &m_matView, &m_matWorld);
	D3DXMatrixMultiply(&m_matAll, &m_matProjection, &m_matAll);

	return true;
}
Beispiel #2
0
bool CSprite::Render(const SFloatPoint & _pos) const
{
	HRESULT hr;

	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 *pDevice = pGraphicsManager->GetDevice();
	D3DXMATRIX matWorld, matTranslation;

	hr = pDevice->GetTransform(D3DTS_WORLD, &matWorld);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to get world transform", hr);
		return false;
	}

	D3DXMatrixTranslation(&matTranslation, _pos.m_fX, _pos.m_fY, 0.0f);
	hr = pDevice->MultiplyTransform(D3DTS_WORLD, &matTranslation);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to multiply world transform", hr);
		return false;
	}

	hr = pDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(SFaceVertex));
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set stream source", hr);
		return false;
	}

	hr = pDevice->SetFVF(SFaceVertex::_fvf);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set FVF", hr);
		return false;
	}

	hr = pDevice->SetTexture(0, m_pTexture);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set texture", hr);
		return false;
	}

	hr = pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to draw primitive", hr);
		return false;
	}

	hr = pDevice->SetTexture(0, NULL);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to reset texture", hr);
		return false;
	}

	hr = pDevice->SetTransform(D3DTS_WORLD, &matWorld);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to restore world transform", hr);
		return false;
	}

	return true;
}