Skip to main content
GameDev.net gamedev.net
🔒 Locked

Font Engine

Started by dev578 Apr 8, 2006 at 12:08 PM 1 replies 750+ views
Original Post
dev578
dev578
I am trying to make a font engine without using ID3DXSprite. On initialization of the font, I store the font in a structure (the width of the character, the bits of the character). This is read in from a text file. My problem now is when the text is rendered, I lock a texture and transfer the bits of the needed characters to the texture. To test I made an integer that increases in value every frame, and then render it with my font class. As you can imagine, it laggs like hell. But heres the thing, using ID3DXFont, it doesn't. I can imagine I am loosing the speed when I am locking the texture. I have been looking around, and at two places I have heard to make a texture with all the characters on it, and "pull the characters out using texture coords." ...? What do they mean? I don't know, but there must be some other way to blit text to the screen, ID3DXFont does it much faster than mine. Anyone had any experience with this? Thank you, Dev578
xyzzy00
xyzzy00
What you want to do is have a texture in video memory which contains all your glyphs. Then, when you want to draw a glyph, you simply need to draw a textured quad (2 triangles) with the appropriate texture coordinates for each glyph. This is what D3DXFont does. This is much faster than your lock-and-copy method, since the glyphs don't have to be uploaded to the video card each frame.

xyzzy
dev578
dev578
Ah, so you draw a textured quad for each character. It just didn't occur to me to do this because you then need to store all of those vertices. I can see how it would definately be better than locking though. Thank you, Rating++.

Dev578

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.