Sign in to follow this  
Daniel Miller

Very fun Direct3D.Font problem

Recommended Posts

This is the overload of Direct3D.Font.DrawText I am using:
public int DrawText(
    Sprite sprite,
    string text,
    Point pos,
    Color color
);
You are allowed to pass null for sprite, which means Direct3D will pick one for you. If I do this, DrawText works exactly how I would expect. However, I have my own sprite that I want to use. When I specify it (within sprite.Begin()/End()) all I get is rectangles of the specified color the size of each letter. EDIT: The function is not failing. What gives? [Edited by - Daniel Miller on June 29, 2005 2:27:45 PM]

Share this post


Link to post
Share on other sites
Thanks, but that is the same as Color.Transparent. If I specify, for example, Color.Red, my sprite appears red. If I use Color.Transparent, it dissapears. Is this because my sprite doesn't have an alpha channel (it was made in Paint)?

By the way, it only dissapears if I use the SpriteFlags.AlphaBlend flag. Should I have two sets of Sprite.Begin/End?

Share this post


Link to post
Share on other sites
1. Using two begin/end blocks should work but may incur a minor performance penalty depending on the volume of rendering you are doing.

2. Try using 0xFFFFFFFF instead of 0xFFFFFF, put it in an unchecked block or the compiler will complain.

3. Make sure you are using a texture format that does not have an alpha channel or that you are filling it correctly. If I recall correctly you can also specify a mask color when you are loading a texture.

Share this post


Link to post
Share on other sites
How are you loading your texture? Are you using TextureLoader.FromFile? If you use one of the longer forms you can specify the format and a colorKey for transparancy. Using this you will at least know what dx is doing internally with your texture. You may have to fool around to find a format your card supports, (most the cards I have used support R5G6B5 and X8R8G8B8 as non-alpha formats). Also make sure you specify 0 as the color key.

Did you mess around with any of the texture states before entering your sprite block? Usually sprite sets this all up correctly for you, but it may only adjust the states it is directly intrested in.

Also -- this is probably not the problem, but if you left the zbuffer on, you may want to turn it off. You may also want to use the SortDepthBackToFront sprite flag if you are drawing sprites with alpha.

Share this post


Link to post
Share on other sites
Wait a minute, what is the actual problem, DrawText or your custom font?
As you said, it works when specifying NULL, are you sure you aren't doing something wrong with your font, invalid size, bad character placement och forgetting some data that DrawText requires (I would guess it needs some kind of CHAR->RECT mapping).

Share this post


Link to post
Share on other sites
Quote:
Original post by GroZZleR
Color.White will preserve your texture's colours. Color.Transparent seems like it would make them all transparent, but that's just what my gut is telling me.


Yes, Color.White did it. But I am not making that up, look here!

MSDN...

Look in the parameter section. Thanks a lot! [smile]

edit: I sent feedback on that topic to Microsoft.

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