Advertisement Jump to content
Sign in to follow this  

trying to draw text and terrain, only getting text

This topic is 3831 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

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
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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!