• Advertisement
Sign in to follow this  

[SlimDX] Rendering Text Problem

This topic is 3091 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

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();


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


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

  • Advertisement