-#ifdef HAVE_XPM
- {
- char **xpm_data = 0;
- int result = XpmReadFileToData (filename, &xpm_data);
- switch (result) {
- case XpmSuccess:
- {
- XImage *image = xpm_to_ximage (dpy, visual, cmap, xpm_data);
-
- clear_gl_error();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
- image->width, image->height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, image->data);
- check_gl_error("texture");
-
- /* setup parameters for texturing */
- glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, image->width);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- return;
- }
- break;
-
- case XpmOpenFailed:
- fprintf (stderr, "%s: file %s doesn't exist.\n", progname, filename);
- exit (-1);
- break;
-
- case XpmFileInvalid:
- /* Fall through and try it as an XBM. */
- break;
-
- case XpmNoMemory:
- fprintf (stderr, "%s: XPM: out of memory\n", progname);
- exit (-1);
- break;
-
- default:
- fprintf (stderr, "%s: XPM: unknown error code %d\n", progname, result);
- exit (-1);
- break;
- }
- }
-#endif /* HAVE_XPM */
+ clear_gl_error();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ image->width, image->height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, image->data);
+ sprintf (buf, "texture: %.100s (%dx%d)",
+ filename, image->width, image->height);
+ check_gl_error(buf);