PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

DrawText: Invalid RECT?

Greetings,

I am porting an engine to PPC and I have just a brief question. This is in regards to the "DrawText" function.

Basicially, I'm getting an error which translates to GDERR_INVALIDRECT. I presume that this is referring to the Font RECT's correct?

Right now, I am keeping things simple so I am using the default system font for now, I have made sure that the PNG file(s) are copied to the correct directory on the emulator (the same as all my other dll's + exe).

By looking in the "watch" window, I can see that the PNG file(s) are loaded correctly as the data within the member vars look correct.

So what could be causing this error?

I've made sure that the destination surface and the destination coordinates are correct. The same with the flags and so forth.

Here's how I am calling it:

DrawText( lpbb->lx , lpbb->ly , lpItem->sText, pDefaultFont, dwFlags, NULL, 0UL, NULL )

The 'pDefaultFont' is the return variable from 'GapiDisplay::GetSystemFont().

Any ideas?
I wanted to add that the "dwFlags" that are being sent in the DrawText call are GDDRAWTEXT_CENTER.

What I've noticed is that if I send 0UL (no alignment options) then the call returns WITHOUT an error.

So basicially, if I use any alignment flags DrawText() calls fail - if I just leave the argument as 0UL, then the call succeeds.

Any ideas?
Basicially, I'm getting an error which translates to GDERR_INVALIDRECT. I presume that this is referring to the Font RECT's correct?


GDERR_INVALIDRECT is returned if you are trying to draw outside the surface boundaries. Try enabling clipping on the destination surface if you want the font to be clipped to surface boundaries, otherwise drawing will fail with this error code.

//Johan
Ok I'll try that however, if I am trying to blit the text "Select" , using GDDRAWTEXT_CENTER on a surface that is 180 (w) x 60 (h) how would that be out of bounds? Especially since my starting X and Y is 0 and 1.

I know Blits fail if the rectangle I am blitting falls outside of the source surfaces' area but the text I am blitting should all be within the surfaces' dimensions.
If you center on 0,1 then your leading portion of the text will be outside the surface boundaries... just going by what you stated in your previous message.
Oh ok - I think I see what's going on here. Please let me know if this a correct assumption:

When I say DrawText with an X and Y coordinate, the function is actually placing the CENTER of the text at that X and Y ? For example, if I blit the word "Select" at 0(x) and 1(y) then it the letters 'Sel' will actually be off the screen (on the left side)? So basicially, it's taking the word and centering the text at that specified X,Y coord? Assuming that you're using the GDDRAWTEXT_CENTER flag.

If so, that's a strange way of doing it but it would make sense as to why it was failing.
Ah, you must have posted just as I was writing that.

But ok thanks - yes that makes sense. Personally, I think it would have made more sense if perhaps we supplied a RECT structure (as an argument) then the DrawText function would format the text to the confines of that area. That way, when you blit, you can always use an absoluate set of coordinates that you don't need to worry about changing each time you want to change the formatting.

However, with the functions supplied (in the 2.05 API) this is something that I set up myself - I just thought that DrawText would already act in this fashion.

Thanks
That is correct. It took me a little getting used to, the convention of the font alignments... for your information as well, if you left-align, it aligns the left edge of the test to the coordinates you put. But somewhat counterintuitively, if you right-align, then the RIGHT-EDGE of the text is aligned to the coordinates. This is actually a very handy convention, but a bit out of the ordinary.
Yes it sure is out of the ordinary. However, that is the way they chose to do things. No matter, I've just written in a proper text formatting system so now I won't have to worry about it at all.

Thanks guys