trying to draw text and terrain, only getting text

Started by
4 comments, last by Larsey 15 years, 9 months ago
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]
Advertisement
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...
Have you looked at the values of the rect? What are they? Are they reasonable?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

thought about it, but would not SetRectEmpty(&rc); deal with it?
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?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.

This topic is closed to new replies.

Advertisement