Пример #1
0
			Air::U1 System::SetBlendState( IBlendState* pState ){
				if(ISystem::SetBlendState(pState)){
					BLEND_DESC&	desc			=	m_pBS->m_pInfo->bs;
					RENDER_TARGET_BLEND&	b	=	desc.Blend[0];
					SetRenderState(D3DRS_ALPHATESTENABLE,	desc.AlphaToCoverageEnable);
					SetRenderState(D3DRS_ALPHABLENDENABLE,	b.BlendEnable);
					if(b.BlendEnable){
						SetRenderState(D3DRS_BLENDOP,		AirBlendOp_To_BlendOp9(b.BlendOp));
						SetRenderState(D3DRS_SRCBLEND,		AirBlend_To_Blend9(b.SrcBlend));
						SetRenderState(D3DRS_DESTBLEND,		AirBlend_To_Blend9(b.DestBlend));
						SetRenderState(D3DRS_SRCBLENDALPHA,	AirBlend_To_Blend9(b.SrcBlendAlpha));
						SetRenderState(D3DRS_DESTBLENDALPHA,AirBlend_To_Blend9(b.DestBlendAlpha));
						SetRenderState(D3DRS_BLENDOPALPHA,	AirBlendOp_To_BlendOp9(b.BlendOpAlpha));
					}
					SetRenderState(D3DRS_COLORWRITEENABLE,	b.RenderTargetWriteMask);
				}
				return	true;
			}
Пример #2
0
void OpenGLRenderer::SetRenderState(RenderState renderState, bool enable) {
	
	switch(renderState) {
		
		case AlphaBlending: {
			setGLState(GL_BLEND, enable);
			break;
		}
		
		case AlphaTest: {
			setGLState(GL_ALPHA_TEST, enable);
			break;
		}

		case ColorKey: {
			SetRenderState(AlphaTest, enable);
			if(enable)
				SetAlphaFunc(CmpNotEqual, 0.0f);
			break;
		}
		
		case DepthTest: {
			setGLState(GL_DEPTH_TEST, enable);
			break;
		}
		
		case DepthWrite: {
			glDepthMask(enable ? GL_TRUE : GL_FALSE);
			break;
		}
		
		case Fog: {
			setGLState(GL_FOG, enable);
			break;
		}
		
		case Lighting: {
			setGLState(GL_LIGHTING, enable);
			break;
		}
		
		case ZBias: {
			setGLState(GL_POLYGON_OFFSET_FILL, enable);
			break;
		}
		
		default:
			LogWarning << "unsupported render state: " << renderState;
	}
	
	CHECK_GL;
}
Пример #3
0
//==============================================================================
// draw
//------------------------------------------------------------------------------
void Parpix::draw(Renderer *renderer,Sprite2D* sprite) {
  const auto pDevice = renderer->getDevice();
  auto shader = renderer->getShader();

  shader->setPixShader("ps_parpix.cso");
  auto constTable = shader->getNowPixShader()->_constTable;

  pDevice->SetTexture(0,renderer->getNormalDepthTex());
  pDevice->SetTexture(1,renderer->getPosTex());
  pDevice->SetTexture(2,renderer->getColorTex());

  const SIZE size = App::instance().getWindowSize();
  const float w = (float)size.cx;
  const float h = (float)size.cy;

  Vec3 dir[4];
  Vec3 col[4];
  
  static float f = 0;

  f += 0.02f;

  col[0] = Vec3(1, 1, 0.1f);
  col[1] = Vec3(0.1f, 0.1f, 1);
  col[2] = Vec3(1, 1, 0.1f);
  col[3] = Vec3(0.3f, 0.3f, 1);

  for(int i = 0; i < 4; i++) {
    dir[i] = Vec3(cosf(f + D3DX_PI * 0.5f * i),1,sinf(f + D3DX_PI * 0.5f * i));
    dir[i]  *= 400;
    dir[i].y = 10;
  }

  constTable->SetFloatArray(pDevice,"gDLight",(float*)dir,sizeof(float) * 3 * 4);
  constTable->SetFloatArray(pDevice,"gDLightCol",(float*)col,sizeof(float) * 3 * 4);
  constTable->SetFloatArray(pDevice,"gCameraPos",(float*)&renderer->getCamera()->getCurrentCamera()->getPosP(),sizeof(float) * 3);
  constTable->SetFloat(pDevice,"gFar",2000);

  struct T4VERTEX {
    float p[4];
    float t[2];
  }  Vertex[4] = {
    {0.0f,0,0.1f,1.0f,0.0f,0.0f},
    {w,0,0.1f,1.0f,1.0f,0.0f},
    {w,h,0.1f,1.0f,1.0f,1.0f},
    {0.0f,h,0.1f,1.0f,0.0f,1.0f},
  };

  pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
  pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
  pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
  pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
  pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,Vertex,sizeof(T4VERTEX));
  pDevice->SetFVF(NULL);
  pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);		// ソース
  pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);	// デスト
  pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
}
Пример #4
0
void CHUDCompass::Render()
{
	if (!m_bDraw) return;

	SetRenderState();

	g_pDrawPrim->SetTexture(m_hBack);
	g_pDrawPrim->DrawPrim(&m_Poly[0]);


	g_pDrawPrim->SetTexture(m_hNeedle);
	g_pDrawPrim->DrawPrim(&m_Poly[1]);

}
Пример #5
0
			Air::U1 System::SetRasterizerState( IRasterizerState* pState ){
				if(ISystem::SetRasterizerState(pState)){
					RASTERIZER_DESC&	desc	=	m_pRS->m_pInfo->rs;
					SetRenderState(D3DRS_CULLMODE,				AirCull_To_Cull9(desc.CullMode));
					SetRenderState(D3DRS_FILLMODE,				AirFillMode_To_Fill9(desc.FillMode));
					SetRenderState(D3DRS_DEPTHBIAS,				desc.DepthBias);
					SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS,	desc.SlopeScaledDepthBias);
					SetRenderState(D3DRS_ANTIALIASEDLINEENABLE,	desc.AntialiasedLineEnable);
					SetRenderState(D3DRS_MULTISAMPLEANTIALIAS,	desc.MultisampleEnable);
					SetRenderState(D3DRS_SCISSORTESTENABLE,		desc.ScissorEnable);
				}
				return	true;
			}
Пример #6
0
    /** Render contents of queue. */
    void RenderQueue(const CCamera& camera,
        const std::vector<PLight>& lights)
    {

        for (const auto& task : m_renderQueue) {
            // Set layer render state.
            SetRenderState(task, camera);

            // Set common parameters.
            m_device->SetLights(lights);

            // Render mesh.
            m_device->Draw();
        }
    }
Пример #7
0
void CMeshOES2::DrawInternal(const CPrimList *pLists, int nLists)
{
    int i;
    for (i = 0; i < nLists; ++i)
    {
        if (pLists[i].m_NumIndices > 0)
            break;
    }
    if (i == nLists)
        return;
    Assert(!(ShaderAPI()->IsInSelectionMode()));
    if (!SetRenderState(0))
        return;
    s_nPrims = nLists;
    s_pPrims = pLists;
    ShaderAPI()->DrawMesh(this);
}
Пример #8
0
void Screen3D::DrawRectangle( int x, int y, int w, int h, D3DCOLOR color )
{
	ScreenVertex v[6];
	v[0] = ScreenVertex( x,    y,   1, color, 0, 0 );
	v[2] = ScreenVertex( x+w,  y+h, 1, color, 1, 1 );
	v[1] = ScreenVertex( x,    y+h, 1, color, 0, 1 );
	v[3] = ScreenVertex( x,    y,   1, color, 0, 0 );
	v[5] = ScreenVertex( x+w,  y,   1, color, 1, 0 );
	v[4] = ScreenVertex( x+w,  y+h, 1, color, 1, 1 );

	SetTexture(NULL, 0);
	SetFVF(D3DFVF_SCREENVERTEX);
	SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 2, v,  sizeof(ScreenVertex));
	ResetWireframeState();

}
Пример #9
0
void CHUDDistance::Render()
{
	if (!m_bDraw) return;

	if( m_bFadeOut )
	{
		m_fAlpha += g_pGameClientShell->GetFrameTime() * m_fFadeIncrement;

		if( m_fAlpha <= 0.0f )
		{
			m_bFadeOut	= false;
			m_bDraw		= false;
			m_fAlpha	= 0.0f;
			m_nFadeDir	= 1;
		}
	}
	else if( m_bBlink )
	{
		m_fAlpha += g_pGameClientShell->GetFrameTime() * m_fFadeIncrement;

		if (m_fAlpha < 0.0f)
		{
			m_fAlpha = 0.0f;
			m_nFadeDir = 1;
		}

		if (m_fAlpha > m_fMaxAlpha)
		{
			m_fAlpha = m_fMaxAlpha;
			m_nFadeDir = -1;
		}

		m_fFadeIncrement = m_nFadeDir * m_fBlinkSpeed * m_fDistPercent;
	}

	uint8 a = (uint8)( 255.0f * m_fAlpha );

	uint32 color = SET_ARGB(a,0xFF,0xFF,0xFF);
	g_pDrawPrim->SetRGBA(&m_Poly,color);

	SetRenderState();

	// draw our icons
	g_pDrawPrim->SetTexture(m_hIcon);
	g_pDrawPrim->DrawPrim(&m_Poly,1);
}
Пример #10
0
bool DirectxEngine::UpdateShader(const MeshData& quad)
{
    const int index = quad.ShaderID();
    if (index != NO_INDEX)
    {
        auto& shader = m_data->shaders[index];
        if(index != m_data->selectedShader)
        {
            SetSelectedShader(index);
            shader->UpdateConstantMatrix("viewProjection", m_data->viewProjection);
        }

        SetRenderState(false, m_data->isWireframe);
        EnableAlphaBlending(true, true);
        return true;
    }
    return false;
}
Пример #11
0
void DirectxEngine::RenderPostProcessing(const PostProcessing& post)
{
    m_data->useDiffuseTextures = post.UseDiffuseTextures();

    SetRenderState(false, false);
    EnableAlphaBlending(false, false);

    SetSelectedShader(POST_SHADER);
    auto& postShader = m_data->shaders[POST_SHADER];

    m_data->backBuffer.SetActive(m_data->context);

    postShader->SendTexture(m_data->context, 0, m_data->preEffectsTarget, SCENE_ID);
    postShader->SendTexture(m_data->context, 1, m_data->blurTarget, BLUR_ID);
    postShader->SendTexture(m_data->context, 2, m_data->sceneTarget, DEPTH_ID);

    postShader->UpdateConstantFloat("bloomIntensity", &post.BloomIntensity(), 1);
    postShader->UpdateConstantFloat("fadeAmount", &m_data->fadeAmount, 1);
    postShader->UpdateConstantFloat("contrast", &post.Contrast(), 1);
    postShader->UpdateConstantFloat("saturation", &post.Saturation(), 1);
    postShader->UpdateConstantFloat("dofStart", &post.DOFStart(), 1);
    postShader->UpdateConstantFloat("dofFade", &post.DOFFade(), 1);
    postShader->UpdateConstantFloat("fogStart", &post.FogStart(), 1);
    postShader->UpdateConstantFloat("fogFade", &post.FogFade(), 1);
    postShader->UpdateConstantFloat("fogColor", &post.FogColour().r, 3);
    postShader->UpdateConstantFloat("minimumColor", &post.MinColour().r, 3);
    postShader->UpdateConstantFloat("maximumColor", &post.MaxColour().r, 3);

    postShader->UpdateConstantFloat("finalMask", &post.Mask(PostProcessing::FINAL_MAP), 1);
    postShader->UpdateConstantFloat("sceneMask", &post.Mask(PostProcessing::SCENE_MAP), 1);
    postShader->UpdateConstantFloat("depthMask", &post.Mask(PostProcessing::DEPTH_MAP), 1);
    postShader->UpdateConstantFloat("blurSceneMask", &post.Mask(PostProcessing::BLUR_MAP), 1);
    postShader->UpdateConstantFloat("depthOfFieldMask", &post.Mask(PostProcessing::DOF_MAP), 1);
    postShader->UpdateConstantFloat("fogMask", &post.Mask(PostProcessing::FOG_MAP), 1);
    postShader->UpdateConstantFloat("bloomMask", &post.Mask(PostProcessing::BLOOM_MAP), 1);

    postShader->SendConstants(m_data->context);
    m_data->quad.Render(m_data->context);

    postShader->ClearTexture(m_data->context, 0);
    postShader->ClearTexture(m_data->context, 1);
    postShader->ClearTexture(m_data->context, 2);
}
Пример #12
0
void CHUDHealthEnergy::Render()
{
	SetRenderState();

	// hub center bit
	g_pDrawPrim->SetTexture(m_hHUDHubTex);
	g_pDrawPrim->DrawPrim(&m_HUDHub);

	g_pDrawPrim->SetTexture(m_hHUDTex);

	// reduce blink time, if any.
	// hack turn it off for now
	if (m_fHealthBlinkTime > 0.0f)
	{
		// reduce blink time
		// determine if it means that the blink is actually happening this frame
		m_fHealthBlinkTime = 0.0f;
	}
	m_bHealthBlink = false;

	// draw backgrounds
	g_pDrawPrim->DrawPrim(&m_HealthBG);
	g_pDrawPrim->DrawPrim(&m_EnergyBG);
	
	// draw bars
	if (m_bHealthBlink)
		g_pDrawPrim->DrawPrim(&m_HealthBlinkBar);
	else
		g_pDrawPrim->DrawPrim(&m_HealthBar);

	g_pDrawPrim->DrawPrim(&m_EnergyBar);
	
	// draw text
	if (m_pHealthStr)
		m_pHealthStr->Render();
	if (m_pEnergyStr)
		m_pEnergyStr->Render();

	if (g_pTronPlayerMgr->IsTransferringEnergy())
	{
		g_pDrawPrim->DrawPrim(&m_EnergyTransfer);
	}
}
Пример #13
0
void CHUDArmor::Render()
{
	SetRenderState();

	// Render the base
	g_pDrawPrim->SetTexture(m_hBaseTex);
	g_pDrawPrim->DrawPrim(&m_Base);

	// Render the correct pieces
	for (int i = 0; i < 6; i++)
	{
		// Do we have it?
		if (m_bHavePiece[i])
		{
			// Render the piece
			g_pDrawPrim->SetTexture(m_hArmorPieceTex[i]);
			g_pDrawPrim->DrawPrim(&m_ArmorPiece[i]);
		}
	}
}
Пример #14
0
void DirectxEngine::RenderPreEffects(const PostProcessing& post)
{
    SetRenderState(false, false);
    EnableAlphaBlending(false, false);

    m_data->preEffectsTarget.SetActive(m_data->context);

    SetSelectedShader(PRE_SHADER);
    auto& preShader = m_data->shaders[PRE_SHADER];
    
    preShader->UpdateConstantFloat("bloomStart", &post.BloomStart(), 1);
    preShader->UpdateConstantFloat("bloomFade", &post.BloomFade(), 1);
    preShader->SendConstants(m_data->context);

    preShader->SendTexture(m_data->context, 0, m_data->sceneTarget, SCENE_ID);
    
    m_data->quad.Render(m_data->context);

    preShader->ClearTexture(m_data->context, 0);
}
Пример #15
0
void gld_NEW_STENCIL(
	struct gl_context *ctx)
{
	GLD_context			*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx7		*gld	= GLD_GET_DX7_DRIVER(gldCtx);

	// Two-sided stencil. New for Mesa 5
	const GLuint		uiFace	= 0UL;

	struct gl_stencil_attrib *pStencil = &ctx->Stencil;

	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILENABLE, pStencil->Enabled ? TRUE : FALSE));
	if (pStencil->Enabled) {
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILFUNC, _gldConvertCompareFunc(pStencil->Function[uiFace])));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILREF, pStencil->Ref[uiFace]));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILMASK, pStencil->ValueMask[uiFace]));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILWRITEMASK, pStencil->WriteMask[uiFace]));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILFAIL, _gldConvertStencilOp(pStencil->FailFunc[uiFace])));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILZFAIL, _gldConvertStencilOp(pStencil->ZFailFunc[uiFace])));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILPASS, _gldConvertStencilOp(pStencil->ZPassFunc[uiFace])));
	}
}
Пример #16
0
void CHUDAmmoChooser::Render()
{
    if (!m_bDraw) return;

    SetRenderState();

    g_pDrawPrim->SetTexture( m_hWeaponIcon );
    SetupQuadUVs(m_WeaponPoly, m_hWeaponIcon, 0.0f, 0.0f, m_fTexScale, m_fTexScale);
    g_pDrawPrim->DrawPrim( &m_WeaponPoly, 1 );

    for (uint8 n = 0; m_hAmmoIcon[n] && n < kMaxAmmoTypes; n++)
    {
        g_pDrawPrim->SetTexture( m_hAmmoIcon[n] );
        SetupQuadUVs(m_AmmoPoly[n], m_hAmmoIcon[n], 0.0f, 0.0f, m_fTexScale, m_fTexScale);
        g_pDrawPrim->DrawPrim( &m_AmmoPoly[n], 1 );
    }

    m_pStr->Render();
    m_pWpnStr->Render();
}
Пример #17
0
void CHUDActivateObject::Render()
{

	if( m_nType != AOT_INVALID )
	{
		if (g_vtXUIUseOldHUD.GetFloat())
		{			
			SetRenderState();

			if( m_hIconTexture )
			{
				g_pDrawPrim->SetTexture( m_hIconTexture );
				g_pDrawPrim->DrawPrim( &m_IconPoly );
			}

			if( m_aObjects[ m_nType ] )
			{
				g_pDrawPrim->SetTexture( m_aObjects[ m_nType ] );
				g_pDrawPrim->DrawPrim( &m_ObjectRect );
			}

			if( m_aButton )
			{
				g_pDrawPrim->SetTexture( m_aButton );
				g_pDrawPrim->DrawPrim( &m_ButtonRect );
			}

			if (g_pGameClientShell->GetDifficulty() == GD_EASY && m_nType == AOT_GENERAL)
			{
				// Only render if we have an activate object and it is not disabled.
				if( m_pActivateObject && !m_pActivateObject->m_bDisabled )
					m_Text.Render();
			}

		}
	}
	else // we're not looking at an item pickup
	{
		m_bObjectTextureValid = false;
	}
}
Пример #18
0
void CHUDNavMarkerMgr::Render()
{
	SetRenderState();

	m_pArrowMarker = NULL;

	MarkerArray::iterator iter = m_ActiveMarkers.begin();
	while (iter != m_ActiveMarkers.end())
	{
		CHUDNavMarker* pMarker = (*iter);
		pMarker->Render();
		// should this marker draw an arrow?
		if (pMarker->IsActive() && !pMarker->IsOnScreen() && pMarker->GetPriority() > 0)
		{
			//check to see if the marker should be faded in MP
			if (!IsMultiplayerGameClient() || !MultiplayerFilter() || pMarker->GetFadeAngle() <= 0.0f)
			{
				if (pMarker->GetPriority() == 0xFF) 
				{
					pMarker->RenderArrow();
				}
				//check to see if this arrow has a higher priority than the current one slated to draw an arrow
				else if (!m_pArrowMarker ||												//if we don't have one already
					m_pArrowMarker->GetPriority() < pMarker->GetPriority() ||		//or this one is higer priority
					(m_pArrowMarker->GetPriority() == pMarker->GetPriority() &&	//or they have the same priority
					m_pArrowMarker->GetRange() > pMarker->GetRange())			// and this one is closer
					)
				{
					m_pArrowMarker = pMarker;
				}
			}

		}
		iter++;
	}

	if (m_pArrowMarker)
		m_pArrowMarker->RenderArrow();

}
Пример #19
0
bool DirectxEngine::UpdateShader(const Emitter& emitter, const IScene& scene)
{
    const int index = emitter.ShaderID();
    if (index != NO_INDEX)
    {
        auto& shader = m_data->shaders[index];
        if (index != m_data->selectedShader)
        {
            SetSelectedShader(index);
            shader->UpdateConstantFloat("depthNear", &scene.Post().DepthNear(), 1);
            shader->UpdateConstantFloat("depthFar", &scene.Post().DepthFar(), 1);
        }

        shader->UpdateConstantFloat("tint", &emitter.Tint().r, 4);

        SetRenderState(false, m_data->isWireframe);
        EnableAlphaBlending(true, false);

        return true;
    }
    return false;
}
Пример #20
0
void CHUDTimer::Render()
{
	if( !m_bDraw )
		return;

	SetRenderState();

	// If we're not paused, recalculate the time left.
	if( !m_bPause )
		m_fTimeLeft = m_fTime - g_pLTClient->GetGameTime( );

	// Update/Draw the timer if there is anytime left...
	if( m_fTimeLeft <= 0.0f )
	{
		m_bDraw	= false;
		return;
	}

	// Draw the string to the surface...

	int nMinutes = int(m_fTimeLeft) / 60;
	int nSeconds = m_fTimeLeft > 60.0 ? int(m_fTimeLeft) % 60 : int(m_fTimeLeft);

	wchar_t wBuffer[16] = L"";

	if (nMinutes != m_nLastMinutes || nSeconds != m_nLastSeconds)
	{
		m_nLastMinutes = nMinutes;
		m_nLastSeconds = nSeconds;

		FormatString("HUD_Timer_Format",wBuffer,LTARRAYSIZE(wBuffer),nMinutes, nSeconds);
		m_Text.SetText(wBuffer);
	}


	m_Text.Render();


}
Пример #21
0
void Screen3D::DrawSpritePoints( Point3D* pointlist, TextureHandle Image )
{

	SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID );
	// Figure out the vertices for the main window
	ScreenVertex WindowVertices[4];

	WindowVertices[0].z   = 0;WindowVertices[1].z   = 0;WindowVertices[2].z   = 0;WindowVertices[3].z   = 0;
	WindowVertices[0].RHW = 1;	WindowVertices[1].RHW = 1; WindowVertices[2].RHW = 1; WindowVertices[3].RHW = 1;
	WindowVertices[0].color = D3DCOLOR_RGBA(255, 255, 255, 255);WindowVertices[1].color = D3DCOLOR_RGBA(255, 255, 255, 255);
	WindowVertices[2].color = D3DCOLOR_RGBA(255, 255, 255, 255);WindowVertices[3].color = D3DCOLOR_RGBA(255, 255, 255, 255);

	WindowVertices[0].x   = pointlist[0].x;
	WindowVertices[0].y   = pointlist[0].y;
	WindowVertices[1].x   = pointlist[1].x;
	WindowVertices[1].y   = pointlist[1].y;
	WindowVertices[2].x   = pointlist[2].x;
	WindowVertices[2].y   = pointlist[2].y;
	WindowVertices[3].x   = pointlist[3].x;
	WindowVertices[3].y   = pointlist[3].y;



	WindowVertices[0].tu  = 0;
	WindowVertices[0].tv  = 0;
	WindowVertices[1].tu  = 1;
	WindowVertices[1].tv  = 0;
	WindowVertices[2].tu  = 0;
	WindowVertices[2].tv  = 1;
	WindowVertices[3].tu  = 1;
	WindowVertices[3].tv  = 1;


	SetTexture(Image, 0);
	SetFVF(D3DFVF_SCREENVERTEX);
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, WindowVertices,  sizeof(ScreenVertex));

	ResetWireframeState	();
}
Пример #22
0
void CHUDMessage::Render()
{
	// Sanity checks...
	if (!IsVisible()) return;

	if (m_hImage)
	{
		g_pDrawPrim->SetTexture(m_hImage);
		// set up the render state	
		SetRenderState();

		// draw our button
		g_pDrawPrim->DrawPrim(&m_Poly);
	}

	if (m_pText)
	{
		if (m_bDropShadow)
		{
			float px,py;
			m_pText->GetPosition(&px,&py);
			px += 2.0f;
			py += 2.0f;
			m_pText->SetColor(0xBF000000);
			m_pText->SetPosition(px,py);
			m_pText->Render();

			px -= 2.0f;
			py -= 2.0f;
			m_pText->SetColor(m_nTextColor);
			m_pText->SetPosition(px,py);
			
		}
		m_pText->Render();
		
	}
}
Пример #23
0
void CDynamicMeshOES2::Draw(int nFirstIndex, int nIndexCount)
{
	if (!(ShaderUtil()->OnDrawMesh(this, nFirstIndex, nIndexCount)))
	{
		MarkAsDrawn();
		return;
	}
	VPROF("CDynamicMeshOES2::Draw");
	m_HasDrawn = true;
	if (!(m_IndexOverride || m_VertexOverride ||
		((m_TotalVertices > 0) && ((m_TotalIndices > 0) || (m_Type == MATERIAL_POINTS))) ))
		return;

	if (!SetRenderState((m_VertexOverride || HasFlexMesh()) ? 0 : m_FirstVertex))
		return;
	int baseIndex = (!m_IndexOverride || (m_pIndexBuffer == MeshMgr()->GetDynamicIndexBuffer())) ? m_FirstIndex : 0;

	if (nIndexCount && (nFirstIndex != -1))
	{
		nFirstIndex += baseIndex;
	}
	else
	{
		nFirstIndex = baseIndex;
		if (m_IndexOverride)
			nIndexCount = m_pIndexBuffer->IndexCount();
		else
			nIndexCount = (m_Type == MATERIAL_POINTS) ? m_TotalVertices : m_TotalIndices;
	}
	Assert(nIndexCount);

	CPrimList prim(nFirstIndex, nIndexCount);
	s_nPrims = 1;
	s_pPrims = &prim;

	ShaderAPI()->DrawMesh(this);
}
Пример #24
0
void CHUDSprintBoost::Render()
{
	SetRenderState();

	LTPoly_GT4 iPolyLeft = m_IconPoly;
	LTPoly_GT4 iPolyRight = m_IconPoly;

	float fPercent = g_pMoveMgr->GetSprintBoostPercent();
	float fWidth = ( iPolyLeft.verts[ 1 ].pos.x - iPolyLeft.verts[ 0 ].pos.x );

	iPolyLeft.verts[ 0 ].uv.y = 0.0f;
	iPolyLeft.verts[ 1 ].uv.y = 0.0f;
	iPolyLeft.verts[ 2 ].uv.y = 0.5f;
	iPolyLeft.verts[ 3 ].uv.y = 0.5f;

	iPolyRight.verts[ 0 ].uv.y = 0.5f;
	iPolyRight.verts[ 1 ].uv.y = 0.5f;
	iPolyRight.verts[ 2 ].uv.y = 1.0f;
	iPolyRight.verts[ 3 ].uv.y = 1.0f;

	iPolyLeft.verts[ 1 ].uv.x = ( 1.0f - fPercent );
	iPolyLeft.verts[ 2 ].uv.x = ( 1.0f - fPercent );
	iPolyLeft.verts[ 1 ].pos.x -= ( fPercent * fWidth );
	iPolyLeft.verts[ 2 ].pos.x -= ( fPercent * fWidth );

	iPolyRight.verts[ 0 ].uv.x = ( 1.0f - fPercent );
	iPolyRight.verts[ 3 ].uv.x = ( 1.0f - fPercent );
	iPolyRight.verts[ 0 ].pos.x += ( ( 1.0f - fPercent ) * fWidth );
	iPolyRight.verts[ 3 ].pos.x += ( ( 1.0f - fPercent ) * fWidth );

	g_pDrawPrim->SetTexture( m_hIconTexture );
	g_pDrawPrim->DrawPrim( &iPolyLeft, 1 );

	g_pDrawPrim->SetTexture( m_hIconTexture );
	g_pDrawPrim->DrawPrim( &iPolyRight, 1 );
}
Пример #25
0
void gld_NEW_SCISSOR(
	struct gl_context *ctx)
{
	GLD_context			*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx9		*gld	= GLD_GET_DX9_DRIVER(gldCtx);

	// Bail if IHV driver cannot scissor
	if (!gld->bCanScissor)
		return;

	// Set scissor rect
	if (ctx->Scissor.Enabled) {
		RECT rcRect;
		// Keep in mind that RECT's need an extra row and column
		rcRect.left		= ctx->Scissor.X;
		rcRect.right	= ctx->Scissor.X + ctx->Scissor.Width; // + 1;
		rcRect.top 		= gldCtx->dwHeight - (ctx->Scissor.Y + ctx->Scissor.Height);
		rcRect.bottom 	= rcRect.top + ctx->Scissor.Height;
		IDirect3DDevice9_SetScissorRect(gld->pDev, &rcRect);
	}

	// Enable/disable scissor as required
	_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_SCISSORTESTENABLE, ctx->Scissor.Enabled));
}
Пример #26
0
//Restore the default render states
void Renderer::restoreRenderStates()
{
	SetRenderState(D3DRS_ALPHABLENDENABLE, m_bBlendEnable);
	SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
Пример #27
0
void gld_update_state_DX7(
	struct gl_context *ctx,
	GLuint new_state)
{
	GLD_context		*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx7	*gld	= GLD_GET_DX7_DRIVER(gldCtx);
	TNLcontext		*tnl = TNL_CONTEXT(ctx);
	GLD_pb_dx7		*gldPB;

	if (!gld || !gld->pDev)
		return;

	_swsetup_InvalidateState( ctx, new_state );
	_vbo_InvalidateState( ctx, new_state );
	_tnl_InvalidateState( ctx, new_state );

	// SetupIndex will be used in the pipelines for choosing setup function
	if ((ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE | DD_SEPARATE_SPECULAR)) ||
		(ctx->Fog.Enabled))
	{
		if (ctx->_TriangleCaps & DD_FLATSHADE)
			gld->iSetupFunc = GLD_SI_FLAT_EXTRAS;
		else
			gld->iSetupFunc = GLD_SI_SMOOTH_EXTRAS;
	} else {
		if (ctx->_TriangleCaps & DD_FLATSHADE)
			gld->iSetupFunc = GLD_SI_FLAT;	// Setup flat shade + texture
		else
			gld->iSetupFunc = GLD_SI_SMOOTH; // Setup smooth shade + texture
	}

	gld->bUseMesaTnL = _gldChooseInternalPipeline(ctx, gld);
	if (gld->bUseMesaTnL) {
		gldPB = &gld->PB2d;
		// DX7 Does not implement D3DRS_SOFTWAREVERTEXPROCESSING
//		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, TRUE));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CLIPPING, FALSE));
//		_GLD_DX7_DEV(SetVertexShader(gld->pDev, gldPB->dwFVF));
	} else {
		gldPB = &gld->PB3d;
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CLIPPING, TRUE));
//		if (gld->TnLPipeline == GLD_PIPELINE_D3D_VS_TWOSIDE) {
//			_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, !gld->VStwosidelight.bHardware));
//			_GLD_DX7_DEV(SetVertexShader(gld->pDev, gld->VStwosidelight.hShader));
//		} else {
			// DX7 Does not implement D3DRS_SOFTWAREVERTEXPROCESSING
//			_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, !gld->bHasHWTnL));
//			_GLD_DX7_DEV(SetVertexShader(gld->pDev, gldPB->dwFVF));
//		}
	}

#define _GLD_TEST_STATE(a)		\
	if (new_state & (a)) {		\
		gld##a(ctx);			\
		new_state &= ~(a);		\
	}

#define _GLD_TEST_STATE_DX7(a)	\
	if (new_state & (a)) {		\
		gld##a##_DX7(ctx);		\
		new_state &= ~(a);		\
	}

#define _GLD_IGNORE_STATE(a) new_state &= ~(a);

//	if (!gld->bUseMesaTnL) {
		// Not required if Mesa is doing the TnL.
	// Problem: If gld->bUseMesaTnL is TRUE when these are signaled,
	// then we'll miss updating the D3D TnL pipeline.
	// Therefore, don't test for gld->bUseMesaTnL
	_GLD_TEST_STATE(_NEW_MODELVIEW);
	_GLD_TEST_STATE(_NEW_PROJECTION);
//	}

	_GLD_TEST_STATE_DX7(_NEW_TEXTURE); // extern, so guard with _DX7
	_GLD_TEST_STATE(_NEW_COLOR);
	_GLD_TEST_STATE(_NEW_DEPTH);
	_GLD_TEST_STATE(_NEW_POLYGON);
	_GLD_TEST_STATE(_NEW_STENCIL);
	_GLD_TEST_STATE(_NEW_FOG);
	_GLD_TEST_STATE(_NEW_LIGHT);
	_GLD_TEST_STATE(_NEW_VIEWPORT);

	_GLD_IGNORE_STATE(_NEW_TRANSFORM);


// Stubs for future use.
/*	_GLD_TEST_STATE(_NEW_TEXTURE_MATRIX);
	_GLD_TEST_STATE(_NEW_COLOR_MATRIX);
	_GLD_TEST_STATE(_NEW_EVAL);
	_GLD_TEST_STATE(_NEW_HINT);
	_GLD_TEST_STATE(_NEW_LINE);
	_GLD_TEST_STATE(_NEW_PIXEL);
	_GLD_TEST_STATE(_NEW_POINT);
	_GLD_TEST_STATE(_NEW_POLYGONSTIPPLE);
	_GLD_TEST_STATE(_NEW_SCISSOR);
	_GLD_TEST_STATE(_NEW_PACKUNPACK);
	_GLD_TEST_STATE(_NEW_ARRAY);
	_GLD_TEST_STATE(_NEW_RENDERMODE);
	_GLD_TEST_STATE(_NEW_BUFFERS);
	_GLD_TEST_STATE(_NEW_MULTISAMPLE);
*/

// For debugging.
#if 0
#define _GLD_TEST_UNHANDLED_STATE(a)									\
	if (new_state & (a)) {									\
		gldLogMessage(GLDLOG_ERROR, "Unhandled " #a "\n");	\
	}
	_GLD_TEST_UNHANDLED_STATE(_NEW_TEXTURE_MATRIX);
	_GLD_TEST_UNHANDLED_STATE(_NEW_COLOR_MATRIX);
	_GLD_TEST_UNHANDLED_STATE(_NEW_EVAL);
	_GLD_TEST_UNHANDLED_STATE(_NEW_HINT);
	_GLD_TEST_UNHANDLED_STATE(_NEW_LINE);
	_GLD_TEST_UNHANDLED_STATE(_NEW_PIXEL);
	_GLD_TEST_UNHANDLED_STATE(_NEW_POINT);
	_GLD_TEST_UNHANDLED_STATE(_NEW_POLYGONSTIPPLE);
	_GLD_TEST_UNHANDLED_STATE(_NEW_SCISSOR);
	_GLD_TEST_UNHANDLED_STATE(_NEW_PACKUNPACK);
	_GLD_TEST_UNHANDLED_STATE(_NEW_ARRAY);
	_GLD_TEST_UNHANDLED_STATE(_NEW_RENDERMODE);
	_GLD_TEST_UNHANDLED_STATE(_NEW_BUFFERS);
	_GLD_TEST_UNHANDLED_STATE(_NEW_MULTISAMPLE);
#undef _GLD_UNHANDLED_STATE
#endif

#undef _GLD_TEST_STATE
}
Пример #28
0
void gld_NEW_POLYGON(
	struct gl_context *ctx)
{
	GLD_context			*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx7		*gld	= GLD_GET_DX7_DRIVER(gldCtx);

	D3DFILLMODE	d3dFillMode = D3DFILL_SOLID;
	D3DCULL		d3dCullMode = D3DCULL_NONE;
	int			iOffset = 0;

	// Fillmode
	switch (ctx->Polygon.FrontMode) {
	case GL_POINT:
		d3dFillMode = D3DFILL_POINT;
		break;
	case GL_LINE:
		d3dFillMode = D3DFILL_WIREFRAME;
		break;
	case GL_FILL:
		d3dFillMode = D3DFILL_SOLID;
		break;
	}
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FILLMODE, d3dFillMode));

	if (ctx->Polygon.CullFlag) {
		switch (ctx->Polygon.CullFaceMode) {
		case GL_BACK:
			if (ctx->Polygon.FrontFace == GL_CCW)
				d3dCullMode = D3DCULL_CW;
			else
				d3dCullMode = D3DCULL_CCW;
			break;
		case GL_FRONT:
			if (ctx->Polygon.FrontFace == GL_CCW)
				d3dCullMode = D3DCULL_CCW;
			else
				d3dCullMode = D3DCULL_CW;
			break;
		case GL_FRONT_AND_BACK:
			d3dCullMode = D3DCULL_NONE;
			break;
		default:
			break;
		}
	} else {
		d3dCullMode = D3DCULL_NONE;
	}
//	d3dCullMode = D3DCULL_NONE; // TODO: DEBUGGING
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CULLMODE, d3dCullMode));

	// Polygon offset
	// ZBIAS ranges from 0 to 16 and can only move towards the viewer
	// Mesa5: ctx->Polygon._OffsetAny removed
	if (ctx->Polygon.OffsetFill) {
		iOffset = (int)ctx->Polygon.OffsetUnits;
		if (iOffset < 0)
			iOffset = -iOffset;
		else
			iOffset = 0; // D3D can't push away
	}
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZBIAS, iOffset));
}
Пример #29
0
void CHUDCrosshair::Render()
{
	
	SetRenderState();
	if (g_pInterfaceMgr->IsOverlayActive(OVM_SCOPE))
	{
		if (!g_pPlayerMgr->UsingCamera())
			RenderScope();
		return;
	}

	// See if we can show a crosshair or not...
	if (g_pMoveMgr->GetVehicleMgr()->IsVehiclePhysics() &&
		!g_pMoveMgr->GetVehicleMgr()->CanShowCrosshair())
	{
		return;
	}

	if (!m_bEnabled)
		return;



	if (g_pPlayerMgr->IsPlayerDead())
	{
		g_pDrawPrim->SetTexture(LTNULL);
		g_pDrawPrim->SetRGBA(&m_Poly[2],argbWhite);

		float x = 319.0f * g_pInterfaceResMgr->GetXRatio();
		float y = 239.0f * g_pInterfaceResMgr->GetYRatio();
		float w = 2.0f * g_pInterfaceResMgr->GetXRatio();

		g_pDrawPrim->SetXYWH(&m_Poly[2],x,y,w,w);
		g_pDrawPrim->DrawPrim(&m_Poly[2],1);

	}
	else
	{
		g_pDrawPrim->SetTexture(m_hAccurate);
		g_pDrawPrim->DrawPrim(&m_Poly[0],1);

		if (GetConsoleInt("CrosshairDynamic",1))
		{
			g_pDrawPrim->SetTexture(m_hInaccurate);
			g_pDrawPrim->DrawPrim(&m_Poly[1],1);
		}
	}


	if( m_pStr )
	{
		m_pStr->SetPosition(m_x+2.0f,m_y+2.0f);
		m_pStr->SetColor(argbBlack);
		m_pStr->Render();

		m_pStr->SetPosition(m_x,m_y);
		if (m_bCanActivateTarget)
		{
			if (m_nTargetTeam == INVALID_TEAM)
			{
				m_pStr->SetColor(m_StrColor);
			}
			else
			{
				m_pStr->SetColor(m_TeamColor[m_nTargetTeam]);
			}
		}
		else
		{
			m_pStr->SetColor(m_StrDisColor);
		}

		m_pStr->Render();
	}

	if( m_pDbgStr )
	{
		m_pDbgStr->SetPosition(m_dbgx+1.0f,m_dbgy+1.0f);
		m_pDbgStr->SetColor(argbBlack);
		m_pDbgStr->Render();

		m_pDbgStr->SetColor(m_DbgColor);
		m_pDbgStr->SetPosition(m_dbgx,m_dbgy);
		m_pDbgStr->Render();
	}
}
Пример #30
0
	void DX9RenderSystem::SetLightingEnabled( bool enabled )
	{
		SetRenderState( D3DRS_LIGHTING, enabled );
	};