Below is the info for loading tifs in OpenGL.. the first bit are examples of how to use it; the last bits are two files: readTextures.ccp and readTextures.h
You need to download Sam Leffler's libtif library. (use google to search for libtif and OpenGL)
GLuint TextureIDs[2]; //CALL THIS FUNCTION IN YOUR INIT() function, only needs to be called once void load_textures(){ //OpenGL allocates space for texture ids glGenTextures(2, TextureIDs); //load texture ids with textures //loads tiff texture int i=0; readTiffImage("wood2_light.tif", &(TextureIDs[i])); i++; readTiffImage("wood2_dark.tif", &(TextureIDs[i])); i++; } //example of how to use the textureids to "bind" a texture void display(){ //clear the buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, TextureIDs[CUR_TEXTURE_I]); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glPushMatrix(); glTranslatef(0,0,-block_depth/2.0); glScalef(block_scale*tableScale, block_scale*tableScale, block_depth); glBegin(GL_POLYGON); glTexCoord3f(T,T,0); glVertex3f(1,1,0); glTexCoord3f(T,0,0); glVertex3f(1,-1,0); glTexCoord3f(0,0,0); glVertex3f(-1,-1,0); glTexCoord3f(0,T,0); glVertex3f(-1,1,0); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D); } --------------- Save below as readTexture.cpp ---------------- #include "readTextures.h" /*Using Sam Leffler's libtiff library */ TIFFRGBAImage img; uint32 *raster; size_t npixels; int imgwidth, imgheight, imgcomponents; int hasABGR = 0; char *imgfilename = NULL; int readTiffImage(char *name, GLuint *textureID){ TIFF *tif; char emsg[1024]; glBindTexture(GL_TEXTURE_2D, *textureID); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); tif = TIFFOpen(name, "r"); if (tif == NULL){ fprintf(stderr, "tif == NULL\n"); exit(1); } if (TIFFRGBAImageBegin(&img, tif, 0,emsg)){ npixels = img.width*img.height; raster = (uint32 *)_TIFFmalloc(npixels*sizeof(uint32)); if (raster != NULL){ if (TIFFRGBAImageGet(&img, raster, img.width, img.height) == 0){ TIFFError(name, emsg); exit(1); } } TIFFRGBAImageEnd(&img); fprintf(stderr, "Read image %s (%d x %d)\n", name, img.width, img.height); } else { TIFFError(name, emsg); exit(1); } imgwidth = img.width; imgheight = img.height; // code based upon // http://www.opengl.org/developers/code/mjktips/libtiff/showtiff.c /* If cannot directly display ABGR format, we need to reverse the component ordering in each pixel. :-( */ if (!hasABGR) { int i; for (i = 0; i < npixels; i++) { register unsigned char *cp = (unsigned char *) &raster[i]; int t; t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } } glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgwidth, imgheight,0, GL_RGBA, GL_UNSIGNED_BYTE,raster); } int writetiff(char *filename, char *description, int x, int y, int width, int height, int compression){ TIFF *file; GLubyte *image, *p; int i; file = TIFFOpen(filename, "w"); if (file == NULL) { return 1; } image = (GLubyte *) malloc(width * height * sizeof(GLubyte) * 3); /* OpenGL's default 4 byte pack alignment would leave extra bytes at the end of each image row so that each full row contained a number of bytes divisible by 4. Ie, an RGB row with 3 pixels and 8-bit componets would be laid out like "RGBRGBRGBxxx" where the last three "xxx" bytes exist just to pad the row out to 12 bytes (12 is divisible by 4). To make sure the rows are packed as tight as possible (no row padding), set the pack alignment to 1. */ glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, image); TIFFSetField(file, TIFFTAG_IMAGEWIDTH, (uint32) width); TIFFSetField(file, TIFFTAG_IMAGELENGTH, (uint32) height); TIFFSetField(file, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(file, TIFFTAG_COMPRESSION, compression); TIFFSetField(file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); TIFFSetField(file, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(file, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(file, TIFFTAG_IMAGEDESCRIPTION, description); p = image; for (i = height - 1; i >= 0; i--) { if (TIFFWriteScanline(file, p, i, 0) < 0) { free(image); TIFFClose(file); return 1; } p += width * sizeof(GLubyte) * 3; } TIFFClose(file); return 0; } --------------- Save below as readTexture.h ---------------- #ifndef _READTEXTURE_H #define _READTEXTURE_H #include#include #include int readTiffImage(char *name, GLuint *textureID); int writetiff(char *filename, char *description, int x, int y, int width, int height, int compression); #endif //_READTEXTURE_H