• Advertisement
Sign in to follow this  

How to display text

This topic is 2326 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 was wondering if anyone knows where I can find a tutorial that shows how to display text with Directx 10 as planning on making a simple spelling game for my son and updating it through the year with his spelling word lists from school. Thought this would be a fun way to get started with Directx as I'll be learning the fundamentals while making something to help my son with spelling words. Any help will be greatly appreciated. :)

Share this post


Link to post
Share on other sites
Advertisement

Hi I was wondering if anyone knows where I can find a tutorial that shows how to display text with Directx 10 as planning on making a simple spelling game for my son and updating it through the year with his spelling word lists from school. Thought this would be a fun way to get started with Directx as I'll be learning the fundamentals while making something to help my son with spelling words. Any help will be greatly appreciated. :)


Hey striker87,

There are many different ways to render text in Direct3D10, but the easiest route to take for a beginner is to make use of the ID3DX10Font interface. Essentially, you create a font with the D3DX10CreateFont function, then you can use the DrawText function to draw a specific string of text. If you need an example in code, I (or someone else) can make another post with an explicit example

Share this post


Link to post
Share on other sites

[quote name='striker87' timestamp='1318109188' post='4870594']
Hi I was wondering if anyone knows where I can find a tutorial that shows how to display text with Directx 10 as planning on making a simple spelling game for my son and updating it through the year with his spelling word lists from school. Thought this would be a fun way to get started with Directx as I'll be learning the fundamentals while making something to help my son with spelling words. Any help will be greatly appreciated. :)


Hey striker87,

There are many different ways to render text in Direct3D10, but the easiest route to take for a beginner is to make use of the ID3DX10Font interface. Essentially, you create a font with the D3DX10CreateFont function, then you can use the DrawText function to draw a specific string of text. If you need an example in code, I (or someone else) can make another post with an explicit example


[/quote]

Thanks Geiger for pointing me in the right direction and if you or anyone else can make an example that would be great. Again thanks for the help.

Share this post


Link to post
Share on other sites
So the steps that need to be taken are:
1. Initialize an instance of ID3DX10Font. This interface stores all of the properties of a particular font in your application
[font="Consolas, Courier, monospace"]
[/font]
ID3DX10Font* mFont;
D3DX10CreateFont( md3dDevice, // ID3D10Device
24, // Height of the font
0, // Width of the font
0, // Weight (or Boldness) of the font
0, // Mip-levels to generate of the font
false, // Italic?
DEFUALT_CHARSET, // Character set of the font
OUT_DEFAULT_PRECIS, // Default Precision[/font]
DEFAULT_QUALITY, // Default Quality
DEFAULT_PITCH | FF_DONTCARE, // Default Pitch and Family
L"Times New Roman", // Name of the font to use
&mFont // Pointer to the ID3DX10Font interface to initialize

) );

[font="monospace"]2. When you want to draw a particular string to the render target, use the font's [/font][font="monospace"]DrawText method:[/font]

[font="monospace"]RECT rectangle = { 0, 0, width, height };[/font]

[font="monospace"]mFont->DrawText( NULL, // "[/font][color="#2A2A2A"]Direct3D will render the string with its own sprite object." -- MSDN
[color="#2A2A2A"] L"Draw this string", // "String to draw to the render target
[color="#2A2A2A"] -1, // Specifies the number of characters in the string (-1 counts them for us)
[color="#2A2A2A"] &rectangle, // Pointer to the rectangle we want to draw out text in
[color="#2A2A2A"] DT_NOCLIP | DT_VCENTER | DT_CENTER, // Draws the text in the center of the rectangle (horz & vert) and can exceed the rectangles boundaries
[color="#2A2A2A"] D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) ); // White color

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement