/// \param textureName Name of texture you want to set in the effect file.
/// \param index Texture index to set.  This is pulled from the DirectX device.
void Effect::setTextureFromDevice(const std::string &textureName, int index)
{
  if (!m_pEffect) return;

  IDirect3DBaseTexture9* pTexture;

  // get texture from device
  pD3DDevice->GetTexture(index,&pTexture);

  // pass texture to effect file
  m_pEffect->SetTexture(textureName.c_str(), pTexture);

  pTexture->Release();

  return;
}
Beispiel #2
0
HRESULT HookIDirect3DDevice9::GetTexture(LPVOID _this, DWORD Stage,IDirect3DBaseTexture9** ppTexture)
{
	LOG_API();
	return pD3Dev->GetTexture(Stage, ppTexture);
}
Beispiel #3
0
void RageDisplay_D3D::SendCurrentMatrices()
{
	RageMatrix m;
	RageMatrixMultiply( &m, GetCentering(), GetProjectionTop() );

	/* Convert to OpenGL-style "pixel-centered" coords */
	RageMatrix m2 = GetCenteringMatrix( -0.5f, -0.5f, 0, 0 );
	RageMatrix projection;
	RageMatrixMultiply( &projection, &m2, &m );
	g_pd3dDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)&projection );

	g_pd3dDevice->SetTransform( D3DTS_VIEW, (D3DMATRIX*)GetViewTop() );
	g_pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)GetWorldTop() );

	for( unsigned tu = 0; tu < 2; tu++ )
	{
		// Optimization opportunity: Turn off texture transform if not using texture coords.
		g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
		
		// If no texture is set for this texture unit, don't bother setting it up.
		IDirect3DBaseTexture9* pTexture = NULL;
		g_pd3dDevice->GetTexture( tu, &pTexture );
		if( pTexture == NULL )
			 continue;
		pTexture->Release();

		if( g_bSphereMapping[tu] )
		{
			static const RageMatrix tex = RageMatrix
			(
				0.5f,   0.0f,  0.0f, 0.0f,
				0.0f,  -0.5f,  0.0f, 0.0f,
				0.0f,   0.0f,  0.0f, 0.0f,
				0.5f,  -0.5f,  0.0f, 1.0f
			);
			g_pd3dDevice->SetTransform( (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+tu), (D3DMATRIX*)&tex );

			// Tell D3D to use transformed reflection vectors as texture co-ordinate 0
			// and then transform this coordinate by the specified texture matrix.
			g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
		}
		else
		{
			/*
			 * Direct3D is expecting a 3x3 matrix loaded into the 4x4 in order to transform
			 * the 2-component texture coordinates.  We currently only use translate and scale,
			 * and ignore the z component entirely, so convert the texture matrix from
			 * 4x4 to 3x3 by dropping z.
			 */

			const RageMatrix &tex1 = *GetTextureTop();
			const RageMatrix tex2 = RageMatrix
			(
				tex1.m[0][0], tex1.m[0][1],  tex1.m[0][3],	0,
				tex1.m[1][0], tex1.m[1][1],  tex1.m[1][3],	0,
				tex1.m[3][0], tex1.m[3][1],  tex1.m[3][3],	0,
				0,				0,			0,		0
			);
			g_pd3dDevice->SetTransform( D3DTRANSFORMSTATETYPE(D3DTS_TEXTURE0+tu), (D3DMATRIX*)&tex2 );

			g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU );
		}
	}
}