Sign in to follow this  
Larsey

trying to draw text and terrain, only getting text

Recommended Posts

Maybe its my swap chain, or my font function not want to release itself :-/ my main drawing function looks like this: void DrawGame() { // Draw the terrain object DrawTerrain(); // Draw the fonts DrawFont(); } before DrawGame you have UpdateGame and so. After you have some cleanup and pSwapChain->Present(0, 0); Now over to my problem - i fire up my little app. For a splitt second( less than 0.5 sec, ive got superman eyes :)) you get to view my terrain, then it gets replaced by my text with its white background. No flicker just the text replacing the terrain. After that you are only able to view the text. My theory - my drawfont function takes over the scene and do not release it again. My DrawFont: void DrawFont() { // Create and Initialize the destination rectangle RECT rc; SetRectEmpty(&rc); // Use the GetFontRectangle helper function to get the proper size // of the rectangle. GetFontRectangle(TEXT("This is a test string"), &rc); pFontSprite->Begin(D3DX10_SPRITE_SORT_TEXTURE); // Draw the text to the screen HRESULT hr = pFont->DrawText( pFontSprite, TEXT("This is a test string"), -1, &rc, DT_LEFT, D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) ); pFontSprite->End(); } Anyone?? :D :D [Edited by - Larsey on July 26, 2008 10:54:14 AM]

Share this post


Link to post
Share on other sites
forgot the getrect func:

void GetFontRectangle(LPCWSTR text, RECT *rect)
{
// Using DT_CALCRECT causes the rectangle to be determined but
// nothing to be drawn
pFont->DrawText(NULL,
text,
-1,
rect,
DT_CALCRECT | DT_LEFT,
D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f));
}

i have been troubleshooting a lot. commenting ( /* */ ) the DrawText in DrawFont() results in a white screen. so i think GetFontRectangle() does something where it only should have grabbed the size of the text :(


please, anybody know whats wrong? my skull might start to bleed because ive been slamming my head about this problem all day...

the app builds and runs...

Share this post


Link to post
Share on other sites
I was suggesting that you look at the values of the rectangle following your call to:

GetFontRectangle(TEXT("This is a test string"), &rc);

to see if they were reasonable, say after 1 sec.

Also, if you comment out the DrawFont() call in DrawGame(), is the terrain drawn properly?

Share this post


Link to post
Share on other sites
if i comment DrawFont() in DrawGame() the terrain is drawn properly!

ill just have to work on it today. it is strange. as i said earlier, if i comment ->DrawText() in the DrawFont() function my screen becomes white. The fill color of the rect is also white. My guess, is that the rect is drawn to the screen, filling the size of the screen. With no comments DrawText comes after the rect calculation of the text and is layer above and both is written.

This may seem like a BS conclusion but thats how things seems right now.

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