MDX+Text - help please

Hi Folks

I am trying to render some 2D text that I can rotate.

I have found a site with a wrapper that does 2D but its also got a few other types of text in their and is all very confusing. Besides I would like to do it with MDX functions rather than a lib that someone else wrote.

If anyone out their can please help me to write some simple text to screen and rotate it in the XY plane I would be very grateful.

Reply here or msn bigal_nz at hotmail.com or Al Grant in New Zealang on skype.

Cheers

-Al

(Using C#)

[562 byte] By [BigAl_NZ] at [2007-12-23]
# 1
Hi, here an example derived from the one present in the SDK (insert it before your EndScene):

int height;
int logPixels;
// Initialize all of the fonts
using (System.Drawing.Graphics g = CreateGraphics())
{
System.IntPtr dc = g.GetHdc();
logPixels = GetDeviceCaps(dc, LogPixelsY);
g.ReleaseHdc(dc);
}

string fontName = "Arial";
const int FontSize = 15;
height = -FontSize * logPixels / 72;
Sprite batchSprite = new Sprite(device);
Direct3D.Font font = new Direct3D.Font(device, height, 0, FontWeight.Bold,
1, false, CharacterSet.Default, Precision.Default, FontQuality.Default,
PitchAndFamily.DefaultPitch | PitchAndFamily.FamilyDoNotCare, fontName);

batchSprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortTexture);
Matrix m = new Matrix();
m.RotateZ(0.17f); // <-- Rotation angle in radiants
batchSprite.Transform = m;
font.DrawText(batchSprite, "Draw text rotated.", 0, 0,
unchecked((int)0xffffffff));
batchSprite.End();
font.Dispose();
batchSprite.Dispose();

And then insert the following in your class declaration, for example:

public class MyWellClass : Form
{
private const int LogPixelsY = 90;
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
private static extern int GetDeviceCaps(IntPtr hdc, int cap);
....
}

Obviously you can move the creation of sprite and font outside the rendering loop in order to avoid the continuous memory allocation/deallocation overhead.

Enjoy,

- AGPX

AGPX at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2

There is a MeshFromFont function. The resulting mesh is fully transformable, rotate it or whatever. Since I'm at work I can't look up anything for you but it may be in the SampleFramework, can't remember.

Bubba

BubbaRichard at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...