Jump to content
  • Advertisement
Sign in to follow this  
jdub

Is There Any Way To Clip Text Using Id3Dxfont?

This topic is 2812 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'm trying to create scrolling debug output in my game. Is there any way that I can clip the text that comes [font="'Segoe UI"]from drawing using ID3DXFont?[/font]

Share this post


Link to post
Share on other sites
Advertisement
I don't know if there's any way to make ID3DXFont clip it itself...but you could definitely do it by setting a scissor rectangle.

Share this post


Link to post
Share on other sites

I'm trying to create scrolling debug output in my game. Is there any way that I can clip the text that comes [font="Segoe UI"]from drawing using ID3DXFont?[/font]


There is a pRect parameter on the DrawText() function, that should clip the text to draw only within that rectangle, if you don't specify the DT_NOCLIP format option.

Share this post


Link to post
Share on other sites
Okay so I am trying to set up a Scissor Rectangle. The text I'm rendering clearly is not inside the rectangle however, is still being rendererd. Any help?
Also... I'm using SlimDX and C# however the code should be similar to dx/c++


device.ScissorRect = new Rectangle(new Point(0, 0), new Size(10, 10));
device.SetRenderState(RenderState.ScissorTestEnable, true);
renderer.DrawText("Hello World", new Point(75, 75)); // Clearly not inside the rect!!
device.SetRenderState(RenderState.ScissorTestEnable, false);

Share this post


Link to post
Share on other sites

I'm trying to create scrolling debug output in my game. Is there any way that I can clip the text that comes [font="Segoe UI"]from drawing using ID3DXFont?[/font]


Typically, you need to draw your UI in layers to cut off the text. For example, Draw the background of your window, then the text, then some sort of border around the text area big enough that it will cut the text off giving the appearance you are seeking. If you have a transparent background for your text, then i dunno :P

Share this post


Link to post
Share on other sites

Typically, you need to draw your UI in layers to cut off the text. For example, Draw the background of your window, then the text, then some sort of border around the text area big enough that it will cut the text off giving the appearance you are seeking. If you have a transparent background for your text, then i dunno :P


You need to pass in the Rectangle to the SlimDX DrawString function specifying the bounding area you want it to be in. I imagine its overriding the device state that you are setting (so that it can render the text properly itself).

Use this overload of DrawString:
public int DrawString( Sprite sprite, string text, Rectangle rectangle, DrawTextFormat format, Color4 color)

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!