Apply a texture to a shape in OpenGL

The OpenGL object jit.gl.gridshape allows you to create and render standard 3D geometrical shapes (cube, sphere, cone, etc.). It creates those shapes using a number of polygons attached together on a grid, thus its name. To make those objects look a bit more interesting—either more realistic or more unusual—you can apply a texture to the surface of the object. The visual content of the texture comes from a 2D image matrix (e.g., jit.matrix) which then gets wrapped around the object's surface.