我想在运行时在纹理上交换纹理(包含精灵表)。但是,我有问题了解什么是光栅化器,我不知道应该传递什么样的矩阵。
class CUSTOMVERTEXBEN
{
public:
FLOAT x, y, z, rhw; // The transformed position for the vertex
DWORD color; // The vertex color
`enter code here`FLOAT tu, tv;
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
D3DXMATRIX m_mtxTexture;
D3DXMatrixIdentity(&m_mtxTexture);
m_mtxTexture._41= 1.0f;
m_mtxTexture._42= 1.0f;
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->SetIndices(g_pIB);
m_mtxTexture._11= 0.f;
m_mtxTexture._12= 0.f;
//m_mtxTexture._33= 1.f;
g_pd3dDevice->SetTexture(0, g_pTexture );
g_pd3dDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
g_pd3dDevice->SetTransform(D3DTS_TEXTURE0, &m_mtxTexture);
g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
答案 0 :(得分:0)
如果您正在使用精灵表,则需要将UV坐标从一个精灵转换为另一个精灵。您可以使用UV变换执行此操作。您可以为当前设置的任何纹理设置变换(通常是纹理索引0)。有关详细信息,请参阅here。