Text working (mostly) again...

Switching to the Cocoa-based backend to the Open Agent Engine was more work than I expected. Typically, most of the problems ended up being caused by my own lack of understanding. Case in point: Text. The image in the preceeding post shows what I was getting when attempting to render Text: a mirror image of the text!

I initially thought this reversal was due to some endian foolishness in porting my PPC implementation to Intel. And to be sure, there have been a few areas where this has been an issue (mainly with interpretation of bytes in the image textures).

But it turns out, that it was due to two errors. (1) I decided to ditch the manual byte-swapping logic from the original implementation in favor of a sexier Affine Transform (violating the "If it ain't broke, don't fix it" rule), and (2) me (probably late at night) not recognizing that rotating an image 180-degrees does NOT give the same result as inverting the Y axis and drawing the image.

Thankfully, after staring at the logic a second (well, fifth) time the problem became obvious, and now I can display massive amounts of meaningless text. Rather than rotating 180-degrees, I need to apply a scaling affine transform with a Y-axis scale of -1.0, which flips the Y axis:

Of course, it's not perfect. Note that the height of the text row is wrong, causing parts of the text to be obscured. Still, it's a huge step forward.

Comments

Popular Posts