1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
// je creé une texture dynamique
hRes=m_pD3DDevice->CreateTexture(TexW,TexH,1,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&pTexture,0);
hRes=pTexture->GetSurfaceLevel(0,&pSurface);
//je la met en render target
hRes=m_pD3DDevice->SetRenderTarget(0,pSurface);
// je clear et j'écris du texte dedans
m_pD3DDevice->Clear(0,NULL,D3DCLEAR_TARGET,0x00000000,1.0f,0);
pD3DXFont->DrawText(NULL,Text,(int)(strlen(Text)),&TextRect,Format|DT_EXPANDTABS,pD3DGFont->Color);
// je crée un quad (x,y,z,u,v) ici
// QuadText[..]=...
// puis je repasse mon backbuffer en render target
hRes=m_pD3DDevice->SetRenderTarget(0,m_pBBSurface);
// quelques rotations translations
m_pD3DDevice->GetTransform(D3DTS_WORLD, &matWorld);
D3DXMatrixRotationZ(&matRot,Angle/180.0f*D3DX_PI);
D3DXMatrixTranslation(&matTrans,BoxCenter.x,BoxCenter.y,0);
D3DXMatrixTranslation(&matTransAnchor,floorf(BoxCenter.x-Anchor.x)+0.5f,floorf(BoxCenter.y-Anchor.y)+0.5f,0);
matNewWorld=matTransAnchor*matRot*matTrans*matWorld;
m_pD3DDevice->SetTransform(D3DTS_WORLD,&matNewWorld);
// puis je trace
m_pD3DDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
m_pD3DDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
m_pD3DDevice->SetTexture(0,pTexture);
m_pD3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
m_pD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,QuadText,sizeof(VERTEXTEX)); |
Partager