Skip to content
July 12, 2009 / Abe Pralle

Dynamic texture sheets, iPhone and Android dev, UTF-8 source files

Some odds and ends:

ITEM: We finished up Wyrmhunter for the iPhone a week ago and submitted it to Apple.  They haven’t gotten around to approving it yet, but we’re hopeful it’ll be soon.

ITEM: One of the last major things was a revamp of my dynamic texture sheet management system.  With its already limited drawing speed, the best bet for the iPhone is to place all images on one big texture (or several), queue up a bunch of triangles as different images are drawn, and then render everything at once.  Even better is if you don’t have to lay things out yourself but can have Plasmacore do it for you as you dynamically load and unload images.

Read more…

May 13, 2009 / Abe Pralle

iPhone drawing speed – Part 2

I just finished implementing an automatic texture sheet system for iPhone Plasmacore.  By default it automatically places image textures onto a single 1024×1024 texture sheet, creating additional sheets if you run out of room.  In addition I’ve transparently buffered all drawing calls, so drawing 50 images will just store up 100 triangles and then render them all at once later.

There’s significant speed-up over my previous implementation, but you’ll still have to be careful.  The results:

  • I altered the system to redraw at 30 fps instead of 60.  Even a blank screen can’t quite hold steady at 60 fps, so I’d rather aim for a steady 30 fps on iPhone.  No changes required to your Plasmacore programs.
  • iPhone Plasmacore can draw about 9280/x square images in 1/30 second, where x is the size of a single dimension of the image (16 px or higher; smaller images are roughly the same).  [Edit: make that “9280 / sqrt(x)” where x is the number of pixels per image].  So around 580 16×16 pixel images, 290 32×32 images, or 145 64×64 images.
  • Sound effects will probably slow it down a bit more; I need to do some further testing with that.

Looking good for modestly complex games!

May 6, 2009 / Abe Pralle

iPhone drawing speed

I’ve been doing some initial drawing tests on the iPhone with so-so results.

Turns out it uses a graphics chip that renders different tile sections of the screen in parallel.  I couldn’t find any info on how big the tiles are offhand.

Here are my very informal results. [Clarification: I’m drawing tile/sprite images as a series of individual calls, each with its own 2D transform]

In 1/60th of a second, the iPhone can draw about:
24 textured polygons in the same spot, quarter-screen size or less.
OR 75 spaced-out polys (32×32 in this case)
OR 6 full-screen polys.

– This is with a tight drawing-only loop.  Logic & sound adds a bit of overhead – not an excessive amount but then again every bit hurts.
– Things that didn’t significantly improve the speed: turning off texturing, turning off back-buffer clear, turning off alpha blending, using texture formats with fewer bytes per pixel.

In light of this I’m gonna tweak Plasmacore for iPhone so that it’s CYOB (Clear Your Own Backbuffer).  Not to save time clearing the backbuffer, but to allow you to get tricky (if you want) and only redraw altered portions of the screen.  The good news is that Plasmacore (as usual) will still update() at 60fps no matter how slow the draw() is going, so things might get a little rougher but they won’t get slower.

A final tip will be to avoid drawing font-based text – use prerendered words!

May 3, 2009 / Abe Pralle

Slag wrapper methods

I’ve been encountering some programming situations lately that cried out for some aspect-oriented features that weren’t in Slag – until tonight!

Read more…

April 12, 2009 / Abe Pralle

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 more…

April 2, 2009 / Abe Pralle

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 more…

February 2, 2009 / Abe Pralle

Quick thoughts on game prototyping and managing risk (Gamasutra)

“We are always going to be dealing with a succession of low-level, non-critical, non-fatal failures that we can then kind of attenuate and make less frequent and make less severe,” the Far Cry 2 developer continues.

“The only way that I can think of at this stage to kind of manage that problem is to embrace it and say, ‘Great. Let’s make sure that we’re prototyping things. Let’s make sure that we’re putting stuff into the game as fast as possible so that we can see if we’re even on the right path with it.'”