[SlimDX] Rendering Text Problem

Started by
1 comment, last by clarkm2 14 years, 7 months ago
I created a C# user control to render my DirectX screen, and I'm try to get the position of the text aligned with a 2D texture and the mouse position. So far, the texture and mouse position are correct, but the text is not getting positioned correctly. After a few tests, I got the following results: Expected (0,0), (100,100), (300,300) Actual (0,0), (125,125), (375,375) Adding a sprite interface to the DrawString function didn't seem to fix the problem, so I just left it out. Any suggestions would be helpful.


m_Font = new SlimDX.Direct3D9.Font(m_Device, 12, 0, FontWeight.Normal, 0, false, CharacterSet.Default,
                        Precision.Default, FontQuality.Antialiased | FontQuality.ClearTypeNatural | FontQuality.Proof, PitchAndFamily.DontCare,
                        "Arial");


//
BeginRender();
//
m_Font.DrawString(null, "Hello", 300, 300, Color.Red);
//
EndRender();


Advertisement
Your back buffer is probably a different size to the client area of the window (about 25% smaller from the look of those numbers), which will cause D3D to stretch it to fit.

Thanks, I didn't setup the backbuffer width/height for the PresentParameters object. In several C# tutorials this was not defined, so for some reason I thought it was defined when I created the device given the user control handle.

This topic is closed to new replies.

Advertisement