Jump to content
  • Advertisement
Sign in to follow this  
Magos

LPD3DXFONT, bad clipping

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

When drawing text using LPD3DXFONT->DrawText() you specify a RECT in which the text should be. Generally this works fine except when the RECT.left or RECT.top parameters are negative, meaning the rect is (slightly) outside to the left or top of the screen. This clips away more of the text than it should. Screenshot: http://img25.imageshack.us/my.php?loc=img25&image=DrawTextError.jpg The flags I use are: DT_LEFT | DT_WORDBREAK | DT_NOPREFIX I've tried lots of other flag combos too (including DT_NOCLIP) but nothing helps. How do you make proper clipping when drawing outside the screen? (To the left and top. Right and bottom clipping works fine)

Share this post


Link to post
Share on other sites
Advertisement
I just used DT_WORDBREAK with a top and left of -5 and -5 and it seemed to work fine. Your link seems to redirect to the index3.php page. Can you post your pic somewhere else?

Share this post


Link to post
Share on other sites
Here is a test program. A text is displayed at the mouse's position. Move the mouse so the text goes outside to the left (or top) and you'll see that the text is weirdly slipped.

http://seiken.co.uk/mgp/MLibrary/BuggyDrawText.zip

Share this post


Link to post
Share on other sites
Ops, I accidently picked an earlier version. Here is the correct one, with text displayed at the mouse (same link as before):

http://seiken.co.uk/mgp/MLibrary/BuggyDrawText.zip

Share this post


Link to post
Share on other sites
I think what you want to do is cap the left and top to the bounds of the window. Instead of going negative, set to 0 so the text always stays in the window. Post the code where you update the rect and draw the text and maybe more people can help.

Share this post


Link to post
Share on other sites
Well, the point is I want to be able to render it outside the screen making only parts of it show.

Here is the method for rendering text:

//+-----------------------------------------------------------------------------
//| Renders text on the screen
//+-----------------------------------------------------------------------------
BOOL Magos::DllMGraphics::RenderText(INT FontId, STRING Text, CONST MVector2D& Position, CONST MColor& TintColor)
{
//Data
DWORD Flags;
RECT TempRect;
std::string TempText = Text;

//Aborts if uninitialized
if(State == MGRAPHICS_UNINITIALIZED)
{
ErrorMessage = "Unable to render, MGraphics is uninitialized!";
return FALSE;
}

//Aborts if the font ID is invalid
if(!ValidFont(FontId))
{
ErrorMessage = "The given font ID is invalid!";
return FALSE;
}

//Aborts if no string is given (which causes a crash)
if(TempText == "") return TRUE;

//Sets the flags
Flags = DT_LEFT | DT_WORDBREAK | DT_NOPREFIX;

//Sets up the location rect
TempRect.left = Position.X;
TempRect.top = Position.Y;
TempRect.right = ScreenWidth;
TempRect.bottom = ScreenHeight;

//Renders the text
if(FontList[FontId].Font->DrawText(TempText.c_str(), TempText.length(), &TempRect, Flags, MCOLOR(TintColor)) == 0)
{
ErrorMessage = "Unable to render text!";
return FALSE;
}

//Returns success
return TRUE;
}

Share this post


Link to post
Share on other sites
I've tried nearly every possible flag combo, and even no flags at all (0) but with no results. Has anyone successfully rendered text outside the screen? I'd really like to know that. If not I'm going to assume that this is a bug or miss by the DX implementers. Thanks for your help so far!

Share this post


Link to post
Share on other sites
Here I render "This text is rendered outside the window with top = left = -10."

I use rect.top = rect.left = -10;
My flag is just DT_WORDBREAK;

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!