/* This was grabbed from here: ** http://www.cs.utah.edu/classes/cs5610/assignments/lab2/ ** ** Though I modified the function name to be a little clearer ** ** (Note the example uses 'components' in an odd way, that ** makes assumptions about the values of the #defines used ** for the internal format parameter to glTexImage2D(). ** This should still work, but could be improved) ** ** -Chris (1/23/2006) */ /* * ReadRGB() - read in an image file in SGI 'libimage' format * currently its very simple minded and converts all images * to RGBA8 regardless of the input format and returns the * original number of components in the appropriate parameter. * * * the components are converted as follows * L -> LLL 1.0 * LA -> LLL A * RGB -> RGB 1.0 * RGBA -> RGB A * * A simple OpenGL-based usage example: * * ... * #include "readrgb.h" * ... * * void init(void) * { * static unsigned *image; * static int width, height, components; * * image = ReadRGB("earth.rgb", &width, &height, &components); * * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); * glTexImage2D(GL_TEXTURE_2D, 0, components, width, * height, 0, GL_RGBA, GL_UNSIGNED_BYTE, * image); * * free(image); * ... * } * */ unsigned * ReadRGB(const char *name, int *width, int *height, int *components);