Smart Pointers in C++

I just programmed this up for a friend who’s wrestling with good ol’ dynamic allocation issues in C++.  It’s a “smart pointer” class that takes all the hard work out of managing dynamic memory.  You can find this kind of stuff elsewhere on the net too, but here’s my take:

Read the rest of this entry »

iPhone 2D projection matrix, FPU

iPhoneCore (Plasmacore for iPhone) is nearing completion!

Item 1:  I had an interesting issue today.  I’d just got my graphics all drawing when I noticed that my bitmap text was blurry.

Using a trick I’d learned in DirectX, I first tried subtracting 0.5 from each drawing coordinate to compensate for center-of-texel sampling like you have to do in DX.  The text was instantly crisp.  However:

I then thought I’d see if lines & points needed a 0.5 adjustment, so I drew some lines on the edges of the screen.  This graphics test worked fine on the simulator, but on the actual iPhone another problem appeared: floating point error was messing up pixel precision!  If I drew lines in screen columns 0, 1, 2, 3, and 319, then line 0 wouldn’t show up, lines 1 & 2 would both be in column 1, column2 would be skipped, and columns 3 and 319 would be fine.

Read the rest of this entry »