1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
hr = RenderToSurface->BeginScene( TextureSurface, NULL );
hr = Device->Clear ( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFF000000 , 1.0f, 0);
// Render to surface
CachedDevice->SetFVF ( D3DFVF_SPRITEVERTEX ) ;
CachedDevice->SetTexture ( 0, Texture );
CachedDevice->SetStreamSource ( 0, SpriteVB, 0 , sizeof ( SPRITEVERTEX ) ) ;
// adjust transforms
Matrix TextureWorld ;
D3DXMatrixScaling ( & TextureWorld , ( float ) DynamicTextureSize , ( float ) DynamicTextureSize , 1.0f ) ;
Device->SetTransform ( D3DTS_WORLD, & TextureWorld );
Matrix View ;
D3DXMatrixIdentity ( & View ) ;
Device->SetTransform ( D3DTS_VIEW , & View ) ;
Matrix Projection ;
D3DXMatrixOrthoLH ( & Projection , ( float ) DynamicTextureSize , ( float ) DynamicTextureSize , 0.0f , 1.0f ) ;
Device->SetTransform ( D3DTS_PROJECTION, & Projection ) ;
// Render the triangle list to texture
hr = Device->DrawPrimitive ( D3DPT_TRIANGLELIST, 4 , Width * Height * 2 ) ;
if ( FAILED ( hr ) )
{
return hr ;
} ;
hr = RenderToSurface->EndScene( 0 ) ; |
Partager