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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| bool CCadre::Initiation(LPDIRECT3DDEVICE9 pd3dDevice)
{
float PanelWidth = 50.0f;
float PanelHeight = 100.0f;
if ( FAILED( pd3dDevice->CreateVertexBuffer ( 4 * sizeof ( VERTEX2D ),
D3DUSAGE_WRITEONLY, D3DFVF_VERTEX2D,
D3DPOOL_MANAGED, & m_pVb , NULL ) ) )
{
return false;
} ;
VERTEX2D* pVertices = NULL;
m_pVb->Lock( 0, 0, ( void * * ) &pVertices,0);
//m_pVb->Lock( 0, 0, ( void * * ) & v, 0 );
//Set all the colors to white
pVertices[0].color = pVertices[1].color = pVertices[2].color = pVertices[3].color = 0xffffffff;
//Set positions and texture coordinates
pVertices[0].x = pVertices[3].x = -PanelWidth / 2.0f;
pVertices[1].x = pVertices[2].x = PanelWidth / 2.0f;
pVertices[0].y = pVertices[1].y = PanelHeight / 2.0f;
pVertices[2].y = pVertices[3].y = -PanelHeight / 2.0f;
pVertices[0].z = pVertices[1].z = pVertices[2].z = pVertices[3].z = 1.0f;
//pVertices[0].rhw = pVertices[1].rhw = pVertices[2].rhw = pVertices[3].rhw = 1.0f;
pVertices[1].u = pVertices[2].u = 1.0f;
pVertices[0].u = pVertices[3].u = 0.0f;
pVertices[0].v = pVertices[1].v = 0.0f;
pVertices[2].v = pVertices[3].v = 1.0f;
m_pVb->Unlock();
return true;
}
bool CCadre::Rendu(LPDIRECT3DDEVICE9 pd3dDevice)
{/*
pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
pd3dDevice->SetFVF ( D3DFVF_VERTEX2D );
// pd3dDevice->SetVertexShader(D3DFVF_VERTEX2D);
pd3dDevice->SetStreamSource(0, m_pVb,0, sizeof(VERTEX2D));
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
*/
// pd3dDevice->SetTexture ( 0, m_pTexture ) ;
D3DXMATRIX Ortho2D;
D3DXMATRIX Identity;
D3DXMatrixOrthoLH(&Ortho2D, 800, 600, 0.0f, 1.0f);
D3DXMatrixIdentity(&Identity);
pd3dDevice->SetTransform(D3DTS_PROJECTION, &Ortho2D);
pd3dDevice->SetTransform(D3DTS_WORLD, &Identity);
pd3dDevice->SetTransform(D3DTS_VIEW, &Identity);
pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
pd3dDevice->SetFVF ( D3DFVF_VERTEX2D );
pd3dDevice->SetStreamSource( 0, m_pVb, 0 , sizeof ( VERTEX2D ) );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN , 0 , 2);
return 1;
} |
Partager