Utilizator:
Parola:
Am uitat parola... | Cont nou!


Articole Resurse Echipe Competiții Proiecte Forum DevBlogs Locuri de muncă GDROMag Issue#1 GDROCon 2007

 
Forum » Programare » Altele » De ce nu imi apare text pe ecran?




Pagina 1 din 1 [ 1 ]

Mesaj Info autor
    Postat la 24 Jul 2010 17:48:24    Subiect: De ce nu imi apare text pe ecran?
Fuzzball info:

Fuzzball:

Salutare! Incerc sa fac un program care sa scrie pe ecran text D3DXFont dar nu imi apare nimic pe ecran. Sad

Am luat codul de pe siteul asta http://www.codesampler.com/dx9src/dx9src_5.htm#dx9_fps_controls si l-am adaptat pentru proiectul meu (deci teoretic ar trebui sa mearga, cel putin programul lor vad ca afiseaza text.

Am declarat o variabila globala in Globals.h

Cod sursă:

LPD3DXFONT        g_pd3dxFont  = NULL;
 


apoi am initializat-o cu un font in cApp::Init()

Cod sursă:

BOOL cApp::Init()
{
    
    m_pDevice->SetRenderState( D3DRS_LIGHTING, FALSE );


    //----------------------------------------------------------

    HRESULT hr;
    HDC hDC;
    int nHeight;
    int nPointSize = 18;

    hDC = GetDC( NULL );

    nHeight = -( MulDiv( nPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72 ) );

    ReleaseDC( NULL, hDC );

    // Create a font for statistics and help output
    hr = D3DXCreateFont( m_pDevice, nHeight, 0, FW_BOLD, 0, FALSE,
        DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
        DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"),
        &g_pd3dxFont );

    if( FAILED( hr ) )
        MessageBox(NULL,"Call to D3DXCreateFont failed!", "ERROR",MB_OK|MB_ICONEXCLAMATION);
 
  return TRUE;
}

 


Asta e codul pentru eliberarea fontului la sfarsitul programului:

Cod sursă:

void cApp::ShutDown()
{
    if( g_pd3dxFont != NULL )
        g_pd3dxFont->Release();
}
 


Iar codul care afiseaza textul in fiecare frame este urmatorul

Cod sursă:

BOOL cApp::Frame()
{
    
    m_pDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
        D3DCOLOR_COLORVALUE(0.0f, 0.0f, 0.0f, 1.0f), 1.0f, 0 );

    RECT destRect1;
    SetRect( &destRect1, 100, 100, 0, 0 );

    RECT destRect2;
    SetRect( &destRect2, 200, 200, 0, 0 );

    RECT destRect3;
    SetRect( &destRect3, 300, 300, 0, 0 );

    g_pd3dxFont->DrawText( NULL,"This is a line 1.", -1, &destRect1, DT_NOCLIP,
        D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) );

    g_pd3dxFont->DrawText( NULL,"This is a line 2.", -1, &destRect2, DT_NOCLIP,
        D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f) );

    g_pd3dxFont->DrawText( NULL,"This is a line 3.", -1, &destRect3, DT_NOCLIP,
        D3DXCOLOR(0.0f, 0.0f, 1.0f, 1.0f) );
    
    return TRUE;
}
 


Am uploadat tot proiectul la urmatoarea adresa
http://www.fileshare.ro/8340261619.81

Poate stie cineva de ce nu merge programul. Va multumesc foarte mult daca reusiti sa ii dati de capat!

Will code for food.


Status:
Înregistrat pe:
20 Apr 2008 16:32:46
Vârsta: 26 ani
Mesaje: 106
Locatie: Asteroid of neverending rape and faggotry
Programator

 
    Postat la 24 Jul 2010 18:06:32    Subiect: < fara subiect >
BloodRain info:

BloodRain:

In functia BOOL cApp::Frame() , ai uitat sa dai

    m_pDevice->BeginScene();
si     m_pDevice->EndScene();


Status:
Înregistrat pe:
01 Sep 2008 11:26:22
Vârsta: 21 ani
Mesaje: 37
Locatie:
Programator

 

Pagina 1 din 1 [ 1 ]


Server time: 16:09:36 10.02.2012



[ Termeni si conditii | Contact | F.A.Q. | Funny Pictures ]

© 2011 Copyright 7thFACTOR Entertainment - All rights reserved