title: Simple code to create an OpenGL cubemap from "cross layout" image file
body: <p>I'm looking for a simple <code>C</code> subroutine (in Linux) that takes a filename parameter and makes the 6 calls to <code>glTexImage2D</code> to define a "cubemap" texture (<code>GL_TEXTURE_CUBE_MAP</code>).</p>
  
  <p>I'd like to be able to read a "cross layout" file (horizontal or vertical) or a "Horizontal Strip" file, so this requires various cropping operations (and possibly some rotates to match the orientation that OpenGL expects).</p>
  
  <p>I'm sure this code exists, but I Googled around and only found fragments.</p>
  
  <p>I stumbled on the <code>GEGL / BABL</code> libraries.  This looks good.  A bit overkill, but it can read from a file ("<code>gegl:load</code>"), crop, rotate and BABL can do various pixel format operations (to match the OpenGL <code>GL_RGB</code> or <code>GL_RGBA</code> format).</p>
  
  <p>Also, it might be useful to read a "rectilinear" texture file and convert to the gnomic projections (I'm using MMPS for this now).</p>
  
  <p>I found this Python "gimpfu" code ( <a href="http://registry.gimp.org/files/cubemap-to-dds-v0.3.py.txt" rel="nofollow">http://registry.gimp.org/files/cubemap-to-dds-v0.3.py.txt</a> ) that converts from a "cross layout" to a multi-image DDS file, so that's similar to what I want, but I'd rather not have Python code in my app.  GIMP uses GEGL internally, so that's why I'm using that.</p>