Archived

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

directx text rendering

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

Hi, I am new to programming in DirectX and I picked up a copy of Trick of the windows gameprogramming gurus. This book has helped alot and I recommend it to anyone new to directx. But my question is how does one write there own text rendering system. In this book he talks about how most programmers do this, because TextOut() and DrawText() are slow, but he never explains how to do this. does anyone know of a tutorial or site that will better explain how to do this. Thanks

Share this post


Link to post
Share on other sites
text rednering the simple way.
step 1. create a font texture
step 2. load said font texture into video memory
step 3. take said loaded font texture in video memory and render quads using uv coordinates that represent the box around the particular letter you want.
step 4. revel in the fact that you too now have a fine text library

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
notice the 3D in CD3DFont, this is for Direct 3D. Obviously this person is reffering to directdraw you dumb ass. So if you dont know the answer, dont post crap and send the newbie''s on a wild goose chase, next time just shut your fucking mouth.

As for your question JesGDev, the methods are based upon using a bitmap image full of all the characters you want to use in your font. eg. letters and numbers. What do you is read each char from the string you want to display, then blt that char to the screen (using a srcRect to define the char on the bitmap). Sorry but i dont know any sites with tutorials on this.

Share this post


Link to post
Share on other sites
Okay, anon, your being a total ass. Whats your problem. JesGDev could easily be using dx8 even though the book is in ddraw. In that, he would be using the font class or font functions. NeXe''s site has a good tutorial about writing a font engine in dx8.

About the question, what anon said. The Zen of Direct3D Game programming tells how to do it. Its a fairly good book on d3d8 but the information about a font engine can be used in different apis and all because all that really changes is the way it renders the text.

Share this post


Link to post
Share on other sites
Cool - now I can add dumbass to my resume! Rock on!

Anyway, even if you are using DirectDraw the basic ideas behind CD3DFont remain the same - it's a question of using surfaces instead of using a texture. So, unlike you, I am not leading JesGDev on a wild goose chase because I'm pointing them to solid code that can at least get them started *somewhere*. Also, the DirectDraw method you describe involves keeping track of the coordinates on each character (especially for variable width fonts) and keeping track of the current position when drawing. All that is covered conceptually with CD3DFont.

So: "...So if you dont know the answer, dont post crap.."

Also, the advantage of using Direct3D is that there are lots of tutorials, wrappers, and samples that I could point you to. Usually, DrunkenHyena will chime in with a plug for his DirectX text wrapper, so I'll leave that to him. The D3D way is very easily portable to OpenGL if you care.

My opinion of DirectDraw. If you are learning DirectX anew, I'd recommend going with the latest and the greatest, which means moving over to the Direct3D side of the world. People might argue that DirectDraw is still valuable, but it's becoming a legacy API more than anything else. People might argue that DirectDraw is still better for older cards, but with sub $100 GF3 Ti200s on the market, this is becoming a bad argument. Just my two cents...

Anon, please share your vast pool of knowledge with us, but don't post anonymously. We want to give credit where it is due.


Edited by - CrazedGenius on December 16, 2001 2:53:15 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
My opinion of DirectDraw. If you are learning DirectX anew, I''d recommend going with the latest and the greatest, which means moving over to the Direct3D side of the world.


Unless someone has prior experience with another Graphics API I would higly disagree with you. DirectDraw is an excellent place for new people to start so that they may learn the basics of graphics development.

Share this post


Link to post
Share on other sites
Yes and no - it's also a good place to pick up some very bad habits.

For instance, I see alot of people doing silly things with locking textures (when they don't need to) in DX8 because that was the right way to do things in the preDX8 days. They're not silly, they just have a mindset that needs to be tweaked for Direct3D.

Also, I think "the basics" are changing. I would argue that they have changed already. For instance, if you wanted to move a rectangle across the screen on 2D hardware, you would pick a source rect, pick a dest rect, blit, move the dest rect, and repeat. Now, there is no such thing as (new) 2D hardware. The new hardware is highly tuned for the following: create vertices with certain texture coordinates, move the vertices either by matrix transformations or locking the vertex buffer, render and repeat. Oh, and by the way, you get scaling, rotation, alpha blending, and more "for free".

It's the same simple graphics operation and it has totally different "basics". You *can* do things the old way on new hardware, but if you compare the two methods on the ways that they do or don't make effective use of the hardware, the DirectDraw method will lose every time in "real world" tests.

If you are starting from scratch, there is no point to learning everything there is to know about blit because blit ain't the *best* way no more. And I guarantee that you will pick up at least one bad habit.

Another way that the basics are changing is that in DirectDraw everything revolved around a surface. In Direct3D surfaces are really only used in advanced techniques like render to texture operations or dynamic textures. The most basic part of DirectDraw is not at all basic in Direct3D. You can go very far in Direct3D without ever using a surface directly.

Finally, people say the DirectDraw is so much easier than Direct3D. It's easy until you want to do something that is hard. People ask questions about effects like rotation and blending that are difficult in DirectDraw but are mindlessly easy in Direct3D. It's a difference in learning curves. DirectDraw has an gentle curve that turns very steep at the point that you are ready to do something interesting. Direct3D is very steep at the beginning, but levels off when things get interesting. I think you break even in terms of effort and Direct3D is a better long term skill.


Edited by - CrazedGenius on December 16, 2001 3:20:51 AM

Share this post


Link to post
Share on other sites