コード例 #1
0
ファイル: Sprite.cpp プロジェクト: svdmaar/Coop
bool CSprite::_CreateBuffer()
{
	const int iVertexCount = 6;
	const UINT bufferSize = sizeof(SFaceVertex) * iVertexCount;
	HRESULT hr;

	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 *pDevice = pGraphicsManager->GetDevice();
	
	hr = pDevice->CreateVertexBuffer(bufferSize, 0, SFaceVertex::_fvf, D3DPOOL_DEFAULT, &m_pVertexBuffer, NULL);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to create vertex buffer for image rectangle", hr);
		return false;
	}

	SFaceVertex *pVertices = NULL;
	hr = m_pVertexBuffer->Lock(0, bufferSize, (void**)&pVertices, 0);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to lock image rectangle vertex buffer", hr);
		return false;
	}

	_FillRectVertices(pVertices);

	hr = m_pVertexBuffer->Unlock();
	if(FAILED(hr))
	{
		LogErrorHr("Failed to unlock image rectangle vertex buffer", hr);
		return false;
	}

	return true;
}
コード例 #2
0
void CAStarProcess::Render()
{
  CGraphicsManager* pGraphicsManager = GraphicsInstance;

  m_pAStarScene->Render();
  Math::Mat44f m;
  std::vector<Math::Vect3f>::iterator it = m_Path.begin(),
                                      it_end = m_Path.end();


  for ( ; it != it_end - 1; ++it )
  {
    Math::Vect3f l_ActualPoint = *it;
    Math::Vect3f l_NextPoint = *( it + 1 );

    pGraphicsManager->DrawLine( l_ActualPoint, l_NextPoint, Math::colMAGENTA );
  }

  /*  m.SetIdentity();
      m.Translate(m_PointInicial);
      pGraphicsManager->SetTransform(m);
      pGraphicsManager->DrawCube(0.2f, Math::colGREEN);
      m.SetIdentity();
      m.Translate(m_PointFinal);
      pGraphicsManager->SetTransform(m);
      pGraphicsManager->DrawCube(0.2f, Math::colRED);
      m.SetIdentity();
      pGraphicsManager->SetTransform(m);*/

  ScriptMInstance->RunCode( "render()" );
}
コード例 #3
0
ファイル: MatrixInspector.cpp プロジェクト: svdmaar/Coop
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;
}
コード例 #4
0
ファイル: PacmanScreen.cpp プロジェクト: svdmaar/Coop
bool CPacmanScreen::Render()
{
	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();

	if(!m_gameState.Update())
	{
		return false;
	}

	if(!pGraphicsManager->BeginScene())
	{
		return false;
	}

	if(!m_gameState.Render())
	{
		return false;
	}

	if(!_RenderDebugLine())
	{
		return false;
	}

	if(!pGraphicsManager->EndScene())
	{
		return false;
	}

	return true;
}
コード例 #5
0
ファイル: Button.cpp プロジェクト: svdmaar/Coop
bool CButton::Render() const
{
	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	const CFont *pFont = pGraphicsManager->GetArial();

	if(IsSelected())
	{
		if(!m_selectedRect.Render())
		{
			return false;
		}
	}
	else
	{
		if(!m_unselectedRect.Render())
		{
			return false;
		}
	}

	SFloatRect pos = GetPosition();
	float fX = 0.5f * (pos.m_fRight + pos.m_fLeft);
	float fY = 0.5f * (pos.m_fTop + pos.m_fBottom);
	float fTextheight = 0.5f * (pos.m_fTop - pos.m_fBottom);

	if(!pFont->RenderCentered(m_sCaption, fX, fY, fTextheight))
	{
		return false;
	}

	return true;
}
コード例 #6
0
ファイル: PacmanScreen.cpp プロジェクト: svdmaar/Coop
bool CPacmanScreen::_RenderDebugLine()
{
	string sDebugLine = CGui::GetDebugLine();

	CGraphicsManager * pGraphicsManager = CGraphicsManager::GetInstance();
	const CFont * pArial = pGraphicsManager->GetArial();

	SFloatRect rScreen = CGui::GetScreenRect();
	pArial->RenderCentered(sDebugLine, 0.0f, rScreen.m_fBottom + 1.0f, 2.0f);

	return true;	
}
コード例 #7
0
ファイル: PlayerSelectScreen.cpp プロジェクト: svdmaar/Coop
bool CPlayerSelectScreen::Render()
{
	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	CInputManager *pInputManager = CInputManager::GetInstance();

	if(!pGraphicsManager->BeginScene())
	{
		return false;
	}

	if(!m_gui.Render())
	{
		return false;
	}

	for(int iDevIndex = 0; iDevIndex < g_iMaxPlayerCount; iDevIndex++)
	{
		const CInputDevice *pInputDevice = pInputManager->GetDevice(iDevIndex);
		int iAddedIndex = 0;

		if(pInputDevice->DPadIsJustPressed(DIR_TOP))
		{
			iAddedIndex = -1;
		}
		else if(pInputDevice->DPadIsJustPressed(DIR_BOTTOM))
		{
			iAddedIndex = 1;
		}

		m_playerNameSelectors[iDevIndex].OnDPadInput(iAddedIndex);

		for(int iButtonIndex = 0; iButtonIndex < 2; iButtonIndex++)
		{
			if(pInputDevice->ButtonIsJustPressed(iButtonIndex))
			{
				m_playerNameSelectors[iDevIndex].OnButtonPressed(iButtonIndex);
			}
		}
	}

	if(!pGraphicsManager->EndScene())
	{
		return false;
	}

	return true;
}
コード例 #8
0
void CDrawQuadRendererCommand::Execute( CGraphicsManager& GM )
{
  BROFILER_CATEGORY( "CDrawQuadRendererCommand::Execute", Profiler::Color::Orchid )
    ActivateTextures();

    CRenderableObjectTechniqueManager* lROTM = ROTMInstance;

    const std::string& l_EffectTechName = lROTM->GetRenderableObjectTechniqueNameByVertexType(
            SCREEN_COLOR_VERTEX::GetVertexType() );

    CRenderableObjectTechnique* l_ROT = lROTM->GetResource( l_EffectTechName );

    CEffectTechnique* l_EffectTech =  l_ROT->GetEffectTechnique();
    uint32 width, height;
    GM.GetWidthAndHeight( width, height );
    RECT l_Rect = { 0, 0, ( long )width - 1, ( long )height - 1 };

    l_EffectTech->GetEffect()->SetLight( 0 );

    if( mSetPlayerLife )
    {
      CEffect* lEffect = l_EffectTech->GetEffect();

      float lLife = GUIInstance->GetWindow("HUD.xml")->GetElement("Life")->GetProgress();
      //LOG_INFO_APPLICATION("Setting life %5.2f", lLife);
      lLife = Math::Utils::Clamp(lLife, 0.05f, 100.0f);
      lEffect->SetLife(lLife);
    }

    if ( l_EffectTech )
    {
        GM.DrawColoredQuad2DTexturedInPixelsByEffectTechnique( l_EffectTech, l_Rect, m_Color,
                m_StageTextures[0].m_Texture, 0.0f, 0.0f, 1.0f, 1.0f );
    }
    else
    {
        GM.DrawColoredQuad2DTexturedInPixels( l_Rect, m_Color,
                                              m_StageTextures[0].m_Texture, 0.0f, 0.0f, 1.0f, 1.0f );
    }
}
コード例 #9
0
void CGameOverState::Render(void)
{
	CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance();
	CGraphicsManager* pGM = CGraphicsManager::GetInstance();

	ostringstream temp;
	if(AI)
	{
		temp << StringTable::GetInstance()->GetString("Defeated");
		//PUT_SOUND_HERE("AIwins")
	}
	else
	{
		temp << StringTable::GetInstance()->GetString("Player ") << " "<< Player<<StringTable::GetInstance()->GetString("  Wins!");
		//PUT_SOUND_HERE("GenericWin")
	}

	pTM->Draw(pGM->GetID(_T("scrollvert")), 20, -20, 1.5f, 1.2f);


	tempfont.Print(temp.str().c_str(),275,85,.6f,D3DXCOLOR(255,255,255,255));
	tempfont.Print(StringTable::GetInstance()->GetString("Press cancel to return...").c_str(), 100, 520, .4f, D3DCOLOR_ARGB(255, 255, 255, 255));

	if( m_nPage == 0 )
		tempfont.Print("Created", 325, 160, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
	else if( m_nPage == 1 )
		tempfont.Print("Damage", 325, 160, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
	else if( m_nPage == 2 )
		tempfont.Print("Killed", 350, 160, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
	else if( m_nPage == 3 )
		tempfont.Print("Champion", 310, 160, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
	else
		tempfont.Print("Player", 325, 160, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));

	tempfont.Print("Player 1", 190, 220, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
	tempfont.Print("Player 2", 465, 220, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));

	ostringstream oss;
	int p1Archer = 0, p2Archer = 0, p1Calv = 0, p2Calv = 0, p1Sword = 0, p2Sword = 0;
	// player 1
	CPlayer* player = CGameManager::GetInstance()->GetPlayer(0);
	CPlayer* player2 = CGameManager::GetInstance()->GetPlayer(1);
	if( m_nPage == 0 )
	{
		p1Archer = player->GetStats()->nArcherCreated;
		p1Calv = player->GetStats()->nCalvaryCreated;
		p1Sword = player->GetStats()->nSwordsmanCreated;
	}
	else if( m_nPage == 1 )
	{
		p1Archer = player->GetStats()->nArcherDamageDone;
		p1Calv = player->GetStats()->nCalvaryDamageDone;
		p1Sword = player->GetStats()->nSwordsmanDamageDone;
	}
	else if( m_nPage == 2 )
	{
		p1Archer = player->GetStats()->nArcherKilled;
		p1Calv = player->GetStats()->nCavalryKilled;
		p1Sword = player->GetStats()->nSwordsmanKilled;
	}
	// player 2
	if( m_nPage == 0 )
	{
		p2Archer = player2->GetStats()->nArcherCreated;
		p2Calv = player2->GetStats()->nCalvaryCreated;
		p2Sword = player2->GetStats()->nSwordsmanCreated;
	}
	else if( m_nPage == 1 )
	{
		p2Archer = player2->GetStats()->nArcherDamageDone;
		p2Calv = player2->GetStats()->nCalvaryDamageDone;
		p2Sword = player2->GetStats()->nSwordsmanDamageDone;
	}
	else if( m_nPage == 2 )
	{
		p2Archer = player2->GetStats()->nArcherKilled;
		p2Calv = player2->GetStats()->nCavalryKilled;
		p2Sword = player2->GetStats()->nSwordsmanKilled;
	}

	if( m_nPage < 3 )
	{
		// player 1
		// archer
		oss << p1Archer;
		tempfont.Print(oss.str().c_str(),245,285,.6f,D3DXCOLOR(255,255,255,255));
		oss.str("");
		// swordsman
		oss << p1Sword;
		tempfont.Print(oss.str().c_str(),245,345,.6f,D3DXCOLOR(255,255,255,255));
		oss.str("");
		// cavalry
		oss << p1Calv;
		tempfont.Print(oss.str().c_str(),245,405,.6f,D3DXCOLOR(255,255,255,255));
		oss.str("");

		// player 2
		// archer
		oss << p2Archer;
		tempfont.Print(oss.str().c_str(),525,285,.6f,D3DXCOLOR(255,255,255,255));
		oss.str("");
		// swordsman
		oss << p2Sword;
		tempfont.Print(oss.str().c_str(),525,345,.6f,D3DXCOLOR(255,255,255,255));
		oss.str("");
		// cavalry
		oss << p2Calv;
		tempfont.Print(oss.str().c_str(),525,405,.6f,D3DXCOLOR(255,255,255,255));
		oss.str("");

		pTM->Draw(pGM->GetID(_T("archerportrait")), 375, 275, .8f, .8f);
		pTM->Draw(pGM->GetID(_T("swordsmanportrait")), 375, 335, .8f, .8f);
		pTM->Draw(pGM->GetID(_T("cavalryportrait")), 375, 395, .8f, .8f);
	}
	else if( m_nPage == 3 )
	{
		oss << "AP";
		tempfont.Print(oss.str().c_str(), 380, 275, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");

		pTM->Draw(pGM->GetID(_T("damage")), 375, 325, .8f, .8f);
		pTM->Draw(pGM->GetID(_T("healicon")), 375, 400, .8f, .8f);
		// player 1
		// ap
		oss << player->GetStats()->nPlayerAPSpent;
		tempfont.Print(oss.str().c_str(), 245, 275, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// damage
		oss << player->GetStats()->nChampionDamageDone;
		tempfont.Print(oss.str().c_str(), 245, 340, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// healing
		oss << player->GetStats()->nChampionHealingDone;
		tempfont.Print(oss.str().c_str(), 245, 410, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// player 2
		// ap
		oss << player2->GetStats()->nPlayerAPSpent;
		tempfont.Print(oss.str().c_str(), 525, 275, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// damage
		oss << player2->GetStats()->nChampionDamageDone;
		tempfont.Print(oss.str().c_str(), 525, 340, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// healing
		oss << player2->GetStats()->nChampionHealingDone;
		tempfont.Print(oss.str().c_str(), 525, 410, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
	}
	else
	{
		oss << StringTable::GetInstance()->GetString("  Wood ");
		tempfont.Print(oss.str().c_str(), 350, 275, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");

		oss << StringTable::GetInstance()->GetString("  Metal ");
		tempfont.Print(oss.str().c_str(), 350, 325, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");

		oss << "EXP";
		tempfont.Print(oss.str().c_str(), 360, 385, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");

		// player2
		// wood
		oss << player2->GetStats()->nPlayerWoodEarned;
		tempfont.Print(oss.str().c_str(), 525, 275, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// metal
		oss << player2->GetStats()->nPlayerMetalEarned;
		tempfont.Print(oss.str().c_str(), 525, 325, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// exp
		oss << player2->GetStats()->nPlayerEXPEarned;
		tempfont.Print(oss.str().c_str(), 525, 385, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");

		// player1
		// wood
		oss << player->GetStats()->nPlayerWoodEarned;
		tempfont.Print(oss.str().c_str(), 245, 275, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// metal
		oss << player->GetStats()->nPlayerMetalEarned;
		tempfont.Print(oss.str().c_str(), 245, 325, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
		// exp
		oss << player->GetStats()->nPlayerEXPEarned;
		tempfont.Print(oss.str().c_str(), 245, 385, .6f, D3DCOLOR_ARGB(255, 255, 255, 255));
		oss.str("");
	}
	
}
コード例 #10
0
ファイル: Sprite.cpp プロジェクト: svdmaar/Coop
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;
}
コード例 #11
0
ファイル: Sprite.cpp プロジェクト: svdmaar/Coop
bool CSprite::_CreateTexture(const CBitmap& _bitmap)
{
	HRESULT hr;
	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 *pD3Device = pGraphicsManager->GetDevice();

	int iWidth = _bitmap.GetWidth();
	int iHeight = _bitmap.GetHeight();

	IDirect3DTexture9 *pSystemTexture = NULL;

	hr = pD3Device->CreateTexture((UINT)iWidth, (UINT)iHeight, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM,
		&pSystemTexture, NULL);
	if(FAILED(hr))
	{
		LogError("Failed to create system texture");
		return false;
	}

	D3DLOCKED_RECT lockedRect;
	memset(&lockedRect, 0, sizeof(lockedRect));

	hr = pSystemTexture->LockRect(0, &lockedRect, NULL, 0);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to lock system texture rect", hr);
		return false;
	}

	DWORD *pTexLocation = (DWORD *)lockedRect.pBits;
	for(int iRowIndex = 0; iRowIndex < iHeight; iRowIndex++)
	{
		memcpy(pTexLocation, _bitmap.GetRow(iRowIndex), sizeof(DWORD) * iWidth);

		for(int iColumnIndex = 0; iColumnIndex < iWidth; iColumnIndex++)
		{
			DWORD dwPixel = pTexLocation[iColumnIndex];

			if(dwPixel != g_dwBackgroundColor)
			{
				dwPixel |= 0xff000000l;
				pTexLocation[iColumnIndex] = dwPixel;
			}
		}

		BYTE *pTextureByteLocation = (BYTE *)pTexLocation;
		pTextureByteLocation += lockedRect.Pitch;
		
		pTexLocation = (DWORD *)pTextureByteLocation;
	}

	hr = pSystemTexture->UnlockRect(0);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to unlock system texture rect", hr);
		return false;
	}

	hr = pD3Device->CreateTexture(iWidth, iHeight, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pTexture, NULL);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to create video texture", hr);
		return false;
	}

	hr = pD3Device->UpdateTexture(pSystemTexture, m_pTexture);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to update video texture", hr);
		return false;
	}

	pSystemTexture->Release();

	return true;
}
コード例 #12
0
ファイル: Screen.cpp プロジェクト: svdmaar/Coop
bool CScreen::SetDefaultGraphicsSettings2D()
{
	HRESULT hr;
	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 *pDevice = pGraphicsManager->GetDevice();

	D3DXMATRIX identityTransform, projTransform;
	D3DXMatrixIdentity(&identityTransform);
	D3DXMatrixOrthoLH(&projTransform, 100.0f * pGraphicsManager->GetAspectRatio(), 100.0f, -1.0f, 1.0f);

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

	hr = pDevice->SetTransform(D3DTS_PROJECTION, &projTransform);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set projection transform", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set cull mode render state", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to enable z", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set z write enabled", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set lighting to false", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set alpha blending to true", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set alpha source render state", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set alpha dest render state", hr);
		return false;
	}

	return true;
}
コード例 #13
0
ファイル: Screen.cpp プロジェクト: svdmaar/Coop
bool CScreen::SetDefaultGraphicsSettings3D()
{
	HRESULT hr;

	D3DXMATRIX identityTransform, projTransform;
	D3DXMatrixIdentity(&identityTransform);
	D3DXMatrixPerspectiveFovLH(&projTransform, D3DX_PI / 4, 1.0f, 1.0f, 100.0f);

    D3DXVECTOR3 vEyePt(-10.0f, -10.0f, 10.0f);
    D3DXVECTOR3 vLookatPt(0.0f, 0.0f, 0.0f);
    D3DXVECTOR3 vUpVec(0.0f, 0.0f, 1.0f);
    D3DXMATRIXA16 matView;
    D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);

	D3DCOLORVALUE lightColor = {1.0f, 1.0f, 1.0f, 1.0f};
	D3DXVECTOR3 lightDir(-1.0f, 0.7f, -0.2f);

	D3DLIGHT9 light;
	setupDirectionalLight(light, lightColor, lightDir);

	D3DMATERIAL9 mtrl;
	ZeroMemory( &mtrl, sizeof( D3DMATERIAL9 ) );
	mtrl.Diffuse = lightColor;
	mtrl.Ambient = lightColor;
	mtrl.Ambient.g = 0.0f;

	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 *pDevice = pGraphicsManager->GetDevice();
	CCamera * pCamera = CCamera::GetInstance();

	hr = pDevice->SetTransform(D3DTS_WORLD, &identityTransform);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set world transform", hr);
		return false;
	}
		
	D3DXMATRIX camViewMat = pCamera->GetViewMatrix();
	hr = pDevice->SetTransform(D3DTS_VIEW, &camViewMat);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set view transform", hr);
		return false;
	}

	D3DXMATRIX camProjMat = pCamera->GetProjectionMatrix();
	hr = pDevice->SetTransform(D3DTS_PROJECTION, &camProjMat);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set projection transform", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set cull mode render state", hr);
		return false;
	}

	hr = pDevice->SetLight(0, &light);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set light 0", hr);
		return false;
	}

	hr = pDevice->SetMaterial(&mtrl);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set material", hr);
		return false;
	}

	hr = pDevice->LightEnable(0, TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to enable light", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_AMBIENT, 0x00202020);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set ambient color", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to enable z", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set z write enabled", hr);
		return false;
	}

	hr = pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set sampler state - MINFILTER", hr);
		return false;
	}

	hr = pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set sampler state - MAGFILTER", hr);
		return false;
	}

	hr = pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set sampler state - MIPFILTER", hr);
		return false;
	}

	return true;
}
コード例 #14
0
void CEndRenderSceneRendererCommand::Execute(CGraphicsManager &GM)
{
  BROFILER_CATEGORY( "CEndRenderSceneRendererCommand::Execute", Profiler::Color::Orchid )
	GM.EndScene();
}