You tend to forget the stuff under your abstractions...

Decided to get at least *some* PyOpenGL stuff done this weekend, so played around a little with the texture-atlas-based text rendering stuff.  I went with a spike test rather than trying to refactor the whole font engine in OpenGLContext at the first go.

I spent the longest time figuring out why the texture always came out blank, and it wasn't until I read through the code of (my own) TextureUniform class that I recalled that it's the texture *unit* that you specify for a sampler2D, *not* the texture integer.  I haven't had to use a raw texture sampler in quite a while and I'd just managed to forget that little detail.  Since both texture and unit are just small integers, there's no warning from the GL.

In the Scenegraph-level API you just say TextureUniform( value = ImageTexture( url=[ "someimage.jpg" ]) ) and the uniform gets an image texture that will be loaded, bound to the appropriate texture unit (with the units automatically allocated for the required textures) and then that unit is passed into the uniform.

This seems especially to be a problem for "awkward" APIs, the ones that I think "gee, that's a junk API" when I first see them.  I try to hide the awkwardness behind some bit of utility code and then my mind just "forgets" that it was ever there, so that months or years later I have to re-discover the brokenness.  It is especially annoying (or maybe that's "cool"? or "neat"?) when I spend a few hours discovering some annoying feature like this, do a Google search to see if anyone else has ever come across this ridiculous anti-feature or has a better approach and my own blog is in the top page of hits :) .

Maybe it's a blessing, would I be a happier person if every time I thought of the any API I was struck dumb by the horror of all the dirty little unfinished corners, instead of just remembering the clean and understandable core that wasn't all that bad?  Maybe it's part of some mental defense mechanism that is standing between me and the brink of madness.  Or maybe it's just that I'm not really a "detail-oriented" person and anything that doesn't fit the big pattern just drops out as details that someone else should be handling.


Comments are closed.


Pingbacks are closed.