예제 #1
0
void DisplayProfile(sf::RenderWindow * renderWindow, CProfileIterator * iter, int x, int & y)
{
    if (!renderWindow) return;
    FontManager * fontManager = FontManager::Get();

    y += 15;
    while ( !iter->Is_Done() )
    {
        sf::Text text("", *fontManager->GetFont(""));
        text.setCharacterSize(12);
        ostringstream texte;
        if ( CProfileManager::Get_Frame_Count_Since_Reset() != 0 )
            texte << fixed <<  iter->Get_Current_Name()   << " Calls/Frame:" << iter->Get_Current_Total_Calls()/CProfileManager::Get_Frame_Count_Since_Reset()
                                                << " Time/Frame:" << iter->Get_Current_Total_Time()/CProfileManager::Get_Frame_Count_Since_Reset()
                                                << " %Time/Parent " << iter->Get_Current_Total_Time()/iter->Get_Current_Parent_Total_Time()*100.0f;
        text.setString(texte.str());
        text.setPosition(x,y);
        renderWindow->draw(text);

        //Childs
        CProfileIterator * childIter = CProfileManager::Get_Iterator();
        *childIter = *iter;
        childIter->Enter_Child(0);
        DisplayProfile(renderWindow, childIter, x+15, y);
        CProfileManager::Release_Iterator(childIter);

        y += 15;
        iter->Next();
    }
}
예제 #2
0
파일: Weapon.cpp 프로젝트: fathat/game-src
void Weapon::DrawHUD( Screen3D& Screen, MeshManager& MM, FontManager& FM, Camera& Viewer )
{

	HitPlayer = false;

	Screen.Clear(true);
	// Set the matrices to the origin
    D3DXMATRIX matWorld;
    D3DXMatrixIdentity( &matWorld );
    Screen.SetTransform(  matWorld );

//Set render states
					ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
					ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
					ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
					ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
					ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
					ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
					ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );
					ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
					ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
					ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );

	//Draw the weapon model
	WeaponFont = FM.GetFont("Lucida Console", 16);
	Screen.D3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );

	Matrix ViewMatrix = Viewer.GetLookAtMatrix(  -10 );
	Matrix WorldMatrix;
	Matrix DisplacementMat;
	Matrix DisplacementMat2;
	Matrix ScaleMatrix;


	Screen.SetRenderState(D3DRS_ALPHABLENDENABLE,   TRUE);
	Screen.SetRenderState(D3DRS_SRCBLEND,           D3DBLEND_ONE);
	Screen.SetRenderState(D3DRS_DESTBLEND,          D3DBLEND_ONE);
	Screen.SetRenderState(D3DRS_ALPHATESTENABLE, FALSE );
	Screen.SetRenderState(D3DRS_ZENABLE, FALSE );

	RECT muzzleDim = { Screen.GetWidth()/2, Screen.GetHeight()/2-Screen.GetHeight()/5,Screen.GetWidth()/2+(Screen.GetHeight()/5)*2, Screen.GetHeight()/2+Screen.GetHeight()/5};

	int fade = (int)(MuzzleFlashFade*255.0f);
	Screen.DrawSpriteRect( muzzleDim, MuzzleFlash, true, D3DCOLOR_RGBA( fade, fade, fade, fade ) );
	Screen.SetRenderState(D3DRS_ZENABLE, TRUE );

	Screen.SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
	//Screen.SetTextureMode( TMSphereMap);
	//Screen.SetTexture(GlossMap, 1);


	
	Matrix RMat;
	RMat.Rotate( Viewer.Yaw, Viewer.Pitch, Viewer.Roll);
	ScreenPtr->D3DDevice->MultiplyTransform( D3DTS_TEXTURE1, &RMat.Mat );
		
	//draw
	if(!RightHanded)
	{
		//First, apply a -1 scale to the transform
		//matrix so that the gun draws on the opposite side
		//(since it's left handed). Also, change the 
		//culling order so it doesn't draw inside out.
		Screen.SetRenderState( D3DRS_CULLMODE, D3DCULL_CW);

		DisplacementMat.Translate( 0.10f, 3.1f, -4.3f);
		ScaleMatrix.Scale( -1, 1, 1 );
		D3DXMatrixMultiply(&DisplacementMat.Mat, &DisplacementMat.Mat, &ScaleMatrix.Mat);
		D3DXMatrixMultiply(&ViewMatrix.Mat, &ViewMatrix.Mat, &DisplacementMat.Mat);
		D3DXMatrixInverse(&WorldMatrix.Mat, NULL, &ViewMatrix.Mat);
		Screen.SetTransform(WorldMatrix);


		//Draw the mesh now and return the culling state
		//DisplayMesh.Draw( Screen );
		Screen.SetRenderState(D3DRS_LIGHTING, FALSE );
		MeshA.Draw( Screen, WorldMatrix );
		Screen.SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
		D3DMATRIX OldState;
		Screen.D3DDevice->GetTransform( D3DTS_VIEW, &OldState);
		
		Matrix I;
		Screen.SetViewTransform(I);

		
				
		
		Smoke.MoveSpawn( -1.0f, -1.2f, 9.0f);
		Smoke.Draw( Screen, Viewer );
		
		if(DualWeapons)
		{
			Smoke.MoveSpawn( 1.0f, -1.1f, 8.0f);
			Smoke.Draw( Screen, Viewer );
		}
		
		Screen.D3DDevice->SetTransform( D3DTS_VIEW, &OldState);
       
	}
	else
	{
		DisplacementMat.Translate( -0.10f, 3.1f, -4.3f);
		D3DXMatrixMultiply(&ViewMatrix.Mat, &ViewMatrix.Mat, &DisplacementMat.Mat);
		D3DXMatrixInverse(&WorldMatrix.Mat, NULL, &ViewMatrix.Mat);
		Screen.SetTransform(WorldMatrix);

		//Draw the weapon
		Screen.D3DDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE );
		MeshA.Draw( Screen, WorldMatrix );
		Screen.D3DDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );

		Matrix I;
		Screen.SetViewTransform(I);
				

		Smoke.MoveSpawn( 1.0f, -1.1f, 8.0f);
		Smoke.Draw( Screen, Viewer );

		if(DualWeapons)
		{
			Smoke.MoveSpawn( -1.0f, -1.1f, 8.0f);
			Smoke.Draw( Screen, Viewer );
		}

	}

	//Show the ammo information by the weapon
	Screen.D3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
	ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
	ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
	ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

	Screen.SetRenderState(D3DRS_ZENABLE, FALSE );
	if(ShowAmmoAmount)
	{

		
		TextureHandle hAmmoBox = Screen.GetTextureHandle( "..\\base\\art\\UI\\icons\\ammobox.bmp", "..\\base\\art\\UI\\icons\\ammobox_a.bmp");
		Screen.DrawSprite(  Screen.GetWidth() - 145.0f, (Real)Screen.GetHeight() - 40.0f, Screen.TM.GetTexture( hAmmoBox ));
		WeaponFont->Draw(Screen, Screen.GetWidth() - 105.0f, (Real)Screen.GetHeight() - 32.0f, false, D3DCOLOR_RGBA(255, 255, 255, 255), "%d", ClipAmmo);
		WeaponFont->Draw(Screen, Screen.GetWidth() - 60.0f,  (Real)Screen.GetHeight() - 32.0f, false, D3DCOLOR_RGBA(255, 0, 0, 255), "%d", Ammo);
	}

		
	Screen.TM.SetTextureMode( TMNormal, 0, true);

	//draw the aimer
	if(ShowAmmoAmount)
	{
		Texture* AimerPtr = Screen.TM.GetTexture( Aimer );
		

		Screen.SetRenderState(D3DRS_ALPHABLENDENABLE,   TRUE);
		Screen.SetRenderState(D3DRS_SRCBLEND,           D3DBLEND_SRCALPHA);
		Screen.SetRenderState(D3DRS_DESTBLEND,          D3DBLEND_INVSRCALPHA);
		Screen.SetRenderState(D3DRS_ALPHATESTENABLE, FALSE );

		RECT Dimensions;
		Dimensions.left   = Screen.GetWidth() /2 - (AimerPtr->GetWidth()/2);
		Dimensions.top   = Screen.GetHeight()/2 - (AimerPtr->GetHeight()/2);
		Dimensions.right  = Screen.GetWidth() /2 + AimerPtr->GetWidth()/2-1;
		Dimensions.bottom = Screen.GetHeight()/2 + AimerPtr->GetHeight()/2-1;
	
	
		if(AimerPtr)
			Screen.DrawSprite(Screen.GetWidth()/2 - (AimerPtr->GetWidth()/2), Screen.GetHeight()/2 - (AimerPtr->GetHeight()/2), AimerPtr);


	

		
	}

	ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	Screen.SetRenderState(D3DRS_ZENABLE, TRUE );
	Screen.SetRenderState( D3DRS_FOGENABLE,  TRUE );

}