displaying text with DirectX

This is a discussion on displaying text with DirectX within the Game Programming forums, part of the General Programming Boards category; Now I am using Direct X. I want to display text on screen. Andre's Windows Game Programming book says to ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    39

    Question displaying text with DirectX

    Now I am using Direct X. I want to display text on screen.

    Andre's Windows Game Programming book says to use Windows GDI with Direct X or I should make my own text blitter.

    How should I proceed? Should I make my own blitter, and if so can you point me to a tutorial or anything helpful?
    Its all in your mind...

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    4
    It depends on what you want. If you just want text displayed and you don't care how it looks, go with the GDI since it's easy, even though it's slow. If you want the text to look a certain way, and you don't want to mess around with fonts in Win GDI, make your own text blitter.

    I've never made a full text blitter, but I've made one for numbers, and it's not too hard. Basically, you use a paint program to draw the letters (A-Z) in bitmap cells, then you load the cells into an array. If you're using Andre LaMothe's "Tricks of the Windows...", you can make a 26 frame BOB object, and load A-Z into frames 0-25 of the BOB. Then, for each character of the string to display, you use the formula

    str[pos] - 'A'

    to get the frame for that letter. You should make sure the character is in the range 'A'-'Z'. Of course, this example is just uppercase. You could extend it to print lowercase, punctuation, numbers, or the whole ASCII set pretty easily if you felt like it...

  3. #3
    Registered User Coder's Avatar
    Join Date
    Aug 2001
    Location
    Cairo, Egypt
    Posts
    128

    if(bUsingDirectXGraphics)

    you can use the CD3DFont class that comes with the framework in the SDK.
    Or you can use D3DX's font routines
    Muhammad Haggag

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    39

    Two good ideas

    I am using DirectX7 at the moment but I will soon switch to DX8.

    Mr.Burns: I get what you are saying and I think that method would be more appropriate for a specific game or a project. Its tedious and has to be changed everytime I want a different font.

    But thanks for the idea because I will use it when I start programming a game.



    Coder: Soon I will get to DX8 and I guess it wont be a problem anymore. Thanks.


    How is Mr.Burns method? If I were to write this whole post using it, it would take a while?
    Its all in your mind...

  5. #5
    V-man
    Guest
    It also depends on how much text you want to put onscreen, and how often.

    Assuming you're not going to be using the functions an insane number of times, just use the GDI and use TextOut. It's fast enough that it's unlikely to make a huge difference in frame rates. Honestly, although you probably don't want to use the win GDI to draw your whole window all the time, the speed increase you'll gain by making your own blitter is small.

    The REAL advantage to your own blitter is complete control of every aspect of the font -- you know exactly how it will appear, all of the time, no matter what. If you don't need this, the GDI isn't really a bad choice.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. text on 2d tiles in DirectX?
    By Quantum1024 in forum Game Programming
    Replies: 4
    Last Post: 04-26-2006, 11:40 PM
  2. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 04:13 AM
  3. Replies: 3
    Last Post: 05-25-2005, 01:50 PM
  4. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 04:18 PM
  5. Problems displaying content of a text file
    By melissa in forum C++ Programming
    Replies: 5
    Last Post: 11-12-2001, 05:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21