Jump to content
  • Advertisement
Sign in to follow this  
fuzzball

Why I don't see any text on the screen?

This topic is 3006 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to make a program to test the D3DXFont but the problem is that I don't see anything on the screen. I've tried two ways to create the font in the same program and neither of them work: one is the traditional way with a global pointer to the D3DXFont interface and one with a wrapper based on D3DXFont I've found on the net.

This is the part of the code that creates the fonts and draws some text on the screen (using both the wrapper class located in the files DXText.h and DXText.cpp and the global variable to the D3DXFont interface). There are 3 virtual methods located in the cApp class; Init, Frame and ShutDown. These 3 methods are overridden in cApp.cpp file.

(I've uploaded the entire program here if you would like to test it and see what is wrong:)

http://rapidshare.com/files/408257591/Font_Testing.rar

BOOL cApp::Init()
{
m_Font.SetColorRGB(255, 255, 255);
m_Font.SetSize(30);
m_TextManager.SetTextBoxBoundaries(50, 50, 200, 50);


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

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;
}

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

BOOL cApp::Frame()
{
m_TextManager.DrawText(m_Font, m_pDevice, "Hello World!");

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;
}

I've uploaded the entire program here if you would like to test it and see what is wrong:

http://rapidshare.com/files/408257591/Font_Testing.rar

Share this post


Link to post
Share on other sites
Advertisement
maybe because of

virtual BOOL Frame(){return TRUE;}; //called once each frame;

in system_core.h

You never call cApp.Frame().

Share this post


Link to post
Share on other sites
Oops! Thanks for mentioning that out! I fixed this problem by replacing the CApplication App in "winmain.cpp" file with its derived class CApp. Sadly this is not the entire solution to the problem as I'm still not getting anything to appear on screen. :(

Share this post


Link to post
Share on other sites
What happens when you trace through?

Find if it is entering the frame function, if not, fix it, if it is, then there is something wrong in the function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!