Jump to content
  • Advertisement
Sign in to follow this  
Bigfoot Nick

'DrawText' on top of sprite

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

'DrawText' on top of sprite I'm trying to use "DrawTextA" to write some wordage on top of a sprite that I've already drawn. The problem is everytime the sprite shows up OVER the text. I've searched on GameDev and found this post very close to my problem, but the solution didn't help me: http://www.gamedev.net/community/forums/topic.asp?topic_id=443817&whichpage=1� Here's what I'm working with:
[SOURCE]
//Create Font
D3DXCreateFont(d3ddev,
30,
0,
0,
1,
FALSE,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH || FF_DONTCARE,
L"ARIAL",
&dxfont);

....

//Make a little sprite of mine appear only if the PageUp key is held down
D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 position(450.0f, 700.0f, 0.0f);
if(KEY_DOWN(0x21))
{
d3dspt->Draw(sprite, NULL, &center, &position, D3DCOLOR_ARGB(240, 255, 255, 255));
}

//Create a RECT and write some stuff in it
RECT textbox; SetRect(&textbox, 455, 705, 555, 780);
			
dxfont->DrawTextA(NULL, 
"Test Info",
9,
&textbox,
DT_CENTER | DT_VCENTER,
D3DCOLOR_ARGB(255, 255, 255, 255));

[/SOURCE]
So when I run that, the words "Test Info" show up, but when I press the page up key (or if I just take out the section where I have to press Page Up) then all that shows up is the box (and since it's slightly transparent, I can see a white 'smudge' underneath it where I know the text is...

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure about the question nor am I sure about Unmanaged DirectX (I'm Using Managed Code)! Beginning to wonder why I'm posting, but anyhoo I think disabling the depth buffer might solve the problem.

Share this post


Link to post
Share on other sites
First, check the z-buffer (it actually should not affect anything as the sprite does not use it).
Then, use D3DXSprite::End () (or whatever it is) before using other drawing function (well, in this case maybe you could just pass the sprite pointer as the first parameter to DrawTextA (i think it is)) because when you do this, the sprite sorts and draws anything you passed to it earlier, so the text gets overlapped if you do this after calling DrawText.

Share this post


Link to post
Share on other sites
@ReaVeR

I actually did what you suggested backwards, but it worked, you're a rockstar! Thanks! All I needed to do was pass 'd3dspt' as the first argument in my DrawTextA function and it put the text 'on top of' the sprite! Thanks again.

@AntiGuy

Thanks for the suggestion, but I read the posts backwards and got the answer I needed! :)

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!