Beispiel #1
0
void gkAuxRenderer::_FlushAllHelperDeferred( LPDIRECT3DDEVICE9 pDevice, bool clean )
{

	gkShaderPtr pShader = gkShaderManager::ms_AuxRenderer;

	Matrix44 viewMat = gkRendererD3D9::getShaderContent().getViewMatrix();
	Matrix44 projMat = gkRendererD3D9::getShaderContent().getProjectionMatrix();

	getRenderer()->SetRenderState(D3DRS_ZENABLE, FALSE);
	getRenderer()->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	getRenderer()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	getRenderer()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	getRenderer()->getDevice()->SetVertexDeclaration( gkRendererD3D9::m_generalDeclPt4F4 );

	// Bloommerge
	GKHANDLE hTech = pShader->FX_GetTechniqueByName("Render2D");
	pShader->FX_SetTechnique( hTech );
	{
		UINT cPasses;
		pShader->FX_Begin( &cPasses, 0 );
		for( UINT p = 0; p < cPasses; ++p )
		{
			pShader->FX_BeginPass( p );

			

			if (!m_vecScreenBoxVertexBuffer_Render.empty())
			{
				int size = m_vecScreenBoxVertexBuffer_Render.size();
				pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, m_vecScreenBoxVertexBuffer_Render.size() / 3, &(m_vecScreenBoxVertexBuffer_Render[0]), sizeof(GK_HELPER_2DVERTEX));
			}

			if (!m_vecScreenLineVertexBuffer_Render.empty())
			{
				int size = m_vecScreenLineVertexBuffer_Render.size();
				pDevice->DrawPrimitiveUP(D3DPT_LINELIST, m_vecScreenLineVertexBuffer_Render.size() / 2, &(m_vecScreenLineVertexBuffer_Render[0]), sizeof(GK_HELPER_2DVERTEX));
			}

			if (clean)
			{
				m_vecScreenBoxVertexBuffer_Render.clear();
				m_vecScreenLineVertexBuffer_Render.clear();
			}


			pShader->FX_EndPass();
		}
		pShader->FX_End();
	}

	//getRenderer()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
	//getRenderer()->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);


	

	GKHANDLE hTechT = pShader->FX_GetTechniqueByName("Render2DTexture");
	GKHANDLE hTechA = pShader->FX_GetTechniqueByName("Render2DTextureAlpha");
	GKHANDLE hTechD = pShader->FX_GetTechniqueByName("Render2DTextureDirect");
	

	getRenderer()->SetRenderState(D3DRS_ZENABLE, FALSE);
	if (!m_vecScreenBoxTexturedVertexBuffer_Render.empty())
	{
		int count = m_vecScreenBoxTexturedVertexBuffer_Render.size() / 6;
		//pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );

		for (int i=0; i < count; ++i)
		{

			ITexture* tex = m_vecScreenBoxTexture_Render[i];

			if (tex->format() == eTF_A8)
			{
				pShader->FX_SetTechnique( hTechA );
			}
			else if(!tex->dynamic())
			{
				pShader->FX_SetTechnique( hTechT );
			}
			else
			{
				pShader->FX_SetTechnique( hTechD );
			}

			
			{
				UINT cPasses;
				pShader->FX_Begin( &cPasses, 0 );
				for( UINT p = 0; p < cPasses; ++p )
				{
					pShader->FX_BeginPass( p );

					getRenderer()->getDevice()->SetVertexDeclaration( gkRendererD3D9::m_generalDeclPt4F2 );


					getRenderer()->getDevice()->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
					getRenderer()->getDevice()->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
					tex->Apply(0,0);

					pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, &(m_vecScreenBoxTexturedVertexBuffer_Render[i * 6]), sizeof(GK_HELPER_2DVERTEX_TEXTURED));

					//pDevice->SetTexture(0, NULL);

					pShader->FX_EndPass();
				}
				pShader->FX_End();
			}

		}
	}

	if (clean)
	{
		m_vecScreenBoxTexture_Render.clear();
		m_vecScreenBoxTexturedVertexBuffer_Render.clear();
	}


	getRenderer()->SetRenderState(D3DRS_ZENABLE, FALSE);
	getRenderer()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
	getRenderer()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	getRenderer()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	getRenderer()->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
}
Beispiel #2
0
 FOR_EACH_COLLECTION(i, mTextures)
 {
     ITexture* texture = i->Value;
     texture->Apply();
 }