Bonjours.... j'ai un gros gros problème.....
j'ai fait une petite classe, pour encapsuler tout ce qui est en rapport avec le texte... ;)
mon programme marche très bien en mode fenetré... en revanche, il plante très rapidement en mode fullscreen... et je ne vois vraiment pas pourquoi... si quelqu'un pouvait m'éclairer ca serait très gentil!
le header :
struct Font_Adaptateur {std::vector<LPD3DXFONT> Font;};
class D3D_font
{
public:
D3D_font(D3D_object* d3d_object);
virtual ~D3D_font();
HRESULT D3D_font:: Create_Font (UINT Height, UINT* Font_i);
D3D_font:: DrawText (UINT Adaptateur_i,UINT Font_i,char* texte);
D3D_object* DX;
Font_Adaptateur* Font_Ecran;
std::vector<LPD3DXFONT>::iterator Font_it;
RECT screen_rect;
};
le cpp:
D3D_font::D3D_font(D3D_object* d3d_object)
{
DX = d3d_object;
Font_Ecran = new Font_Adaptateur[DX->Adaptateur_Count];
screen_rect.left = 0;
screen_rect.top = 0;
screen_rect.right = DX->Width;
screen_rect.bottom = DX->Height;
}
D3D_font::~D3D_font()
{
if(Font_Ecran!=NULL) delete [] Font_Ecran;
}
HRESULT D3D_font::Create_Font(UINT Height, UINT* Font_i)
{
for(UINT Adaptateur_i = 0 ; Adaptateur_i < DX->Adaptateur_Count ; Adaptateur_i++)
{
HFONT Tempory_HFont = CreateFont( Height, 0, 0, 0, FW_BOLD, FALSE,
FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
VARIABLE_PITCH, "Arial" );
if( Tempory_HFont == NULL ) return E_FAIL;
LPD3DXFONT Tempory_Font;
if( FAILED( D3DXCreateFont( DX->Device[Adaptateur_i], Tempory_HFont, &Tempory_Font))) return E_FAIL;
if(Tempory_Font == NULL){ return E_FAIL; }
Font_Ecran[Adaptateur_i].Font.push_back(Tempory_Font);
*Font_i = Font_Ecran[Adaptateur_i].Font.size() - 1;
}
return S_OK;
}
D3D_font::DrawText(UINT Adaptateur_i,UINT Font_i,char* texte)
{
if(Font_Ecran!=NULL){
if(Font_Ecran[Adaptateur_i].Font[Font_i]!=NULL)
{
if( SUCCEEDED( Font_Ecran[Adaptateur_i].Font[Font_i]->Begin() ) )
{
Font_Ecran[Adaptateur_i].Font[Font_i]->DrawText(texte,-1,&screen_rect,DT_CENTER | DT_BOTTOM, D3DCOLOR_XRGB(0,0,255));
Font_Ecran[Adaptateur_i].Font[Font_i]->End();
}
}
}
l'appel dans le programme :
VOID Render()
{
for(UINT Adaptateur_i = 0; Adaptateur_i < DX->Adaptateur_Count; Adaptateur_i++)
{
if(DX->Device[Adaptateur_i] != NULL)
{
DX->Device[Adaptateur_i]->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
if( SUCCEEDED( DX->Device[Adaptateur_i]->BeginScene() ) )
{
DX->Device[Adaptateur_i]->SetStreamSource( 0, DX->VertexBuffer[Adaptateur_i], 0, sizeof(CUSTOMVERTEX) );
DX->Device[Adaptateur_i]->SetFVF( D3DFVF_CUSTOMVERTEX );
DX->Device[Adaptateur_i]->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
DF->DrawText(Adaptateur_i,F0,"test");//Ca ne plante pas si je retire cette ligne!!!
DX->Device[Adaptateur_i]->EndScene();
}
DX->Device[Adaptateur_i]->Present( NULL, NULL, NULL, NULL );
}
}
}
je sais que c'est un peu dure de voir comme ca, ds un code partielle mais bon... y a peut être une raison fondamentalle qui va vous sauter au yeux...
encore merci d'avance
loic,