Discussion:
Text
(too old to reply)
m***@bmtmis.demon.co.uk
2008-02-15 11:50:05 UTC
Permalink
Hi,

Can anyone help me out with this problem please?

Using Visual Studio 2005, Using Latest DirectX SDK (Novemeber 2007).

Have solid cube rendered on screen fine. Cube is centred at origin and
has side length of 2 units. I want to put text on the screen saying
"(1,1,1)" located at the position of that vertex.

No problem:

*******************************************************************

Vector3 vector = new Vector3(1.0f, 1.0f, 1.0f);
vector.Project(m_device.Viewport,
m_device.Transform.Projection, m_device.Transform.View,
m_device.Transform.World);

TextFormatFlags flags = TextFormatFlags.Bottom |
TextFormatFlags.EndEllipsis;
TextRenderer.DrawText(e.Graphics, "(1,1,1)", this.Font,new
Rectangle((int)vector.X, (int)vector.Y, 40, 20), Color.White, flags);

*******************************************************************

But of course, text is always on top. So when (1,1,1) is hidden by
rest of cube, text is still visible.

Instead of using the GDI+ to draw the text, how can I get DirectX to
render the text. Lots of examples I've seen on the net say use
DrawText function etc. But in latest SDK DrawText function is not a
member of Device and I can see no text draing functions in the DirectX
or Dirext.Direct3D namespaces.

Thanks for any help,
Mitch.
John Rivers
2008-02-29 03:28:22 UTC
Permalink
Post by m***@bmtmis.demon.co.uk
Hi,
Can anyone help me out with this problem please?
Using Visual Studio 2005, Using Latest DirectX SDK (Novemeber 2007).
Have solid cube rendered on screen fine. Cube is centred at origin and
has side length of 2 units. I want to put text on the screen saying
"(1,1,1)" located at the position of that vertex.
*******************************************************************
Vector3 vector = new Vector3(1.0f, 1.0f, 1.0f);
vector.Project(m_device.Viewport,
m_device.Transform.Projection, m_device.Transform.View,
m_device.Transform.World);
TextFormatFlags flags = TextFormatFlags.Bottom |
TextFormatFlags.EndEllipsis;
TextRenderer.DrawText(e.Graphics, "(1,1,1)", this.Font,new
Rectangle((int)vector.X, (int)vector.Y, 40, 20), Color.White, flags);
- Mesh.TextFromFont (works well but a bit heavy for what you want)
- Use a font texture (use AngelCode's BMFont if you don't want to
write it yourself)
Post by m***@bmtmis.demon.co.uk
*******************************************************************
But of course, text is always on top. So when (1,1,1) is hidden by
rest of cube, text is still visible.
Instead of using the GDI+ to draw the text, how can I get DirectX to
render the text. Lots of examples I've seen on the net say use
DrawText function etc. But in latest SDK DrawText function is not a
member of Device and I can see no text draing functions in the DirectX
or Dirext.Direct3D namespaces.
Thanks for any help,
Mitch.
Loading...