Litmus Test

June 26, 2009 · Posted in Stuff, dev · Comment 

The other night Danny and I were talking about tag clouds and a possible experiment that could be done using something called Wordle (see this post for more info about Wordle). The experiments requires that the news cycle be on “autopilot,” i.e., a general representation of what’s going on in the world over a long stretch of time. The recent swath of high-profile celebrity deaths has thrown a kink into the works (to put it lightly), so hopefully I’ll be able to put up some results in a week or two.

In completely other news, I’ve located another excellent source of OpenGL ES tutorials, this time from Simon Maurice. Jeff Lamarche, whose tutorials I posted a few weeks ago, has also added some new content and updated his project template to work with the new iPhone OS. Good stuff.

Phantom Functions

June 10, 2009 · Posted in dev · Comment 

Not that they’re very spooky, but function calls that don’t do anything can be a real time-sink. The call in question: glPolygonOffset(), a terribly useful function which I was using to prevent Z-fighting. Everything worked as expected in the iPhone simulator, but nothing happened when run from the real hardware! After an hour of searching through the code and documentation, it turns out the answer is pretty straightforward: polygon offset is not supported by the hardware.

The fact that the compiler didn’t kick out a warning or error would seem to suggest that the feature is available in later models. My test platform uses PowerVR’s MBX Lite 3D GPU, as do all models up until Monday’s announcement. Still, Apple is able to tailor the SDK’s header files exactly to their devices capabilities, so it’s a touch frustrating. On the bright side, there’s a workaround for coders who needed glPolygonOffset to draw edge geometry:

        #define EDGE_OFFSET 0.00001

        glDepthRange(EDGE_OFFSET, 1.0);
        /* draw all non-edge geometry */

        glDepthRange(0.0, 1.0 - EDGE_OFFSET);
        /* draw all edges */

There’s a couple more good ideas actually, but the above code works fine for a low-power device.

I am an Idiot

June 2, 2009 · Posted in dev · Comment 

Learned two things today:

1). An array of pointers is possible without stuffing it inside a struct. GLuint **texturePtr; creates a pointer to a pointer, and since a pointer can easily point to an array allocated with new, it follows that such a pointer could point to an array of pointers pointing to more stuff. Lesson learned.

2). The statement int allocSize = n * 16 – 8; GLfloat *vertices = new GLfloat[allocSize]; is only useful when n > 0. Whoops.

 

Update: It’s done! This most productive weekend has turned out a mostly-functional lightweight OpenGL-based sprite library.