Sign in to follow this  
beebs1

Fonts

Recommended Posts

Hiya, I'm having some trouble using ID3DXFont - it does not seem to be drawing any text. The code I'm using:
// init function...
ID3DXFont *pFont;

if( FAILED( D3DXCreateFont(
    pDevice,
    -10,
    10,
    FW_NORMAL,
    1,
    false,
    DEFAULT_CHARSET,
    OUT_DEFAULT_PRECIS,
    ANTIALIASED_QUALITY,
    VARIABLE_PITCH,
    "Arial",
    &m_pFont ) ) ) return false;

// drawing function...
std::string strTest = "test message";

RECT fontRect;
fontRect.top = 10;
fontRect.left = 10;
fontRect.right = 500;
fontRect.bottom = 500;

pFont->DrawText(
    NULL,
    strTest.c_str(),
    -1,
    &fontRect,
    NULL,
    D3DCOLOR_ARGB( 0, 0, 255, 255 ) );
Any ideas what could be wrong? It isn't working in both windowed and fullscreen mode, the app runs fine but nothing is drawn. Also, the drawing function is called between Begin/EndScene(). Many thanks for any help :)

Share this post


Link to post
Share on other sites
Don't worry, fixed it. The alpha component of the colour was 0, so the text was completely transparent.

Share this post


Link to post
Share on other sites
If you've got alphablending turned on, then you won't see anything because you specified an alpha value of zero in your color parameter. Try D3DCOLOR_ARGB( 255, 0, 255, 255 ) instead.

edit - Doh! Too slooowwwww.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this