title: Directx9.0 Texture Mapping rendering
body: <p>I would like to swap my texture on run-time on my texture (Contain sprite sheet). However, I have problem understand what is rasterizer and I don't know what kind of matrix I should pass in.</p>
  
  <pre><code>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(&amp;m_mtxTexture);
  
  m_mtxTexture._41= 1.0f;
  m_mtxTexture._42= 1.0f;
  
  
  g_pd3dDevice-&gt;SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
  g_pd3dDevice-&gt;SetFVF( D3DFVF_CUSTOMVERTEX );
  g_pd3dDevice-&gt;SetIndices(g_pIB);
  
  m_mtxTexture._11= 0.f;
  m_mtxTexture._12= 0.f;
  //m_mtxTexture._33= 1.f;
  g_pd3dDevice-&gt;SetTexture(0, g_pTexture );  
  g_pd3dDevice-&gt;SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
  g_pd3dDevice-&gt;SetTransform(D3DTS_TEXTURE0, &amp;m_mtxTexture);
  
  g_pd3dDevice-&gt;DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
  </code></pre>