Archived

This topic is now archived and is closed to further replies.

ID3DXFont - Begin / End

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

I was playing around with ID3DXFont (I''m using DX8) and found it boring, so I made my own font system that works from a bmp. Basically it loads a bmp containing the characters and stores it on a surface. When ever I draw text it copies rects from the surface to a texture and draws a quad with the texture on it. Its pretty simple and probably not that efficient, but I can rotate, scale and multi-texture so I''m happy(er). My problem is that the characters lose all of their color (ie they end up black) unless I perform the draw method between the ID3DXFont::Begin / End. I can''t figure out why this is because I don''t have anything in my code that references the the font interface and all my other graphics end up showing up normally. Is there something I''m missing that is happening between the Begin/End methods? Thanks in advance..

Share this post


Link to post
Share on other sites
Thanks, thats a good idea.. and it works well. Only its the same problem.. the texture ends up black unless I put the draw statement between a Begin/End.

..after a bit more playing...

If I do this before the draw:

SetTextureStageState(1, D3DTSS_COLORARG1 , D3DTA_CURRENT);

it works fine.. I get the color of the original bmp (or the diffuse color I set). Then after the draw I disable it using:

SetTextureStageState(1, D3DTSS_COLORARG1 , D3DTA_TEXTURE);


Share this post


Link to post
Share on other sites
I suspect that you might have problems with lighting. Try diabling lighting.

Also, why do you transfer it to a surface and then to a texture? Why not just read the whole thing directly into a texture? If you''re doing this so you can grab a rectangle then I would say you could do that simply by adjusting the UV coordinates of your quad. I think this would improve performance, but I could be wrong. I''m fairly new to all this.

"Good code will come and go, but bad code sticks around."

Share this post


Link to post
Share on other sites
Well its not the lighting because I have disabled it or at least I think I have.

Is this all I have to do to disable it?
m_pkD3DDevice->SetRenderState ( D3DRS_LIGHTING , FALSE ) ;


I''m not sure how I would implement what you''re suggesting regarding the UV coords unless I draw multiple quads (one for each character). I''m pretty new at this stuff too so maybe I''m just not understanding what you mean..

Share this post


Link to post
Share on other sites
I was suggesting one quad for each character but I see your point that this might not be faster. Still, you could render it all with a single call to DrawPrimitive if you stored them as a triangle strip or triangle list so I think it would still be fast. However it could be more difficult to rotate this than your way of doing it. On the other hand you could rotate each character separately and do "word art" (like bending a word, etc.) but that's probably not something that's very useful anyway.

"Good code will come and go, but bad code sticks around."

p.s. You might want to make sure your doing your transparency (alpha stuff) correctly. Do you have alpha test enabled? etc.

[edited by - TreborZehn on March 25, 2004 12:57:18 PM]

Share this post


Link to post
Share on other sites
I see what you mean now about how just using a texture could be faster.. and certainly more flexible from the point of view that as you said you would be able to rotate each character.

As for the alpha stuff I think I've got it setup right..
m_pkD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE );
m_pkD3DDevice->SetRenderState(D3DRS_ALPHAREF, 0x01);
m_pkD3DDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_GREATEREQUAL);

When I load a bmp, I specify the transparent color and set all pixels of that color to have an alpha of 0.

[edited by - devlaxe on March 25, 2004 4:23:27 PM]

Share this post


Link to post
Share on other sites
Looks reasonable. A few more debug ideas...

1) Try using the D3DDEVTYPT_REF if you haven''t already.

2) By-pass loading your texture into a surface and just load a small texture onto your quad and run your render code.

3) turn off all alpha test/transparency, etc.

"Good code will come and go, but bad code sticks around."

Share this post


Link to post
Share on other sites