
i
i
i
i
i
i
i
i
15.6. Playing Movies or Live Video into Textures 425
HRESULT UpdateMappingD3D( LONG lActualW, LONG lTextureW,
LONG lActualH, LONG lTextureH ){
HRESULT hr = S_OK;
if(0 == lTextureW || 0 == lTextureH) return E_INVALIDARG;
FLOAT tuW = (FLOAT)lActualW / (FLOAT)lTextureW;
FLOAT tvH = (FLOAT)lActualH / (FLOAT)lTextureH;
// Alter the texture coordinates to comply with image map dimensions that
// are powers of two
CUSTOMVERTEX
*
pVertices; // get a pointer to the vertex data
if (FAILED(hr = g_pVB->Lock(0, 0, (void
**
)&pVertices, 0))) return E_FAIL;
for(DWORD i=0; i<nGrid; i++){ // go throug every vertex in grid
pVertices[2
*
i+0].tu = tuW
*
((FLOAT)i)/((FLOAT)nGrid-1.f); ...