- Colormap cmap = mi->xgwa.colormap;
-
-#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);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
- image->width, image->height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, image->data);
-
- /* 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 */
-
-#ifdef HAVE_XMU
- {
- planetstruct *gp = &planets[MI_SCREEN(mi)];
- unsigned int width = 0;
- unsigned int height = 0;
- unsigned char *data = 0;
- int xhot, yhot;
- int status = XmuReadBitmapDataFromFile (filename, &width, &height, &data,
- &xhot, &yhot);
- if (status != Success)
- {
-# ifdef HAVE_XPM
- fprintf (stderr, "%s: not an XPM file: %s\n", progname, filename);
-# endif
- fprintf (stderr, "%s: not an XBM file: %s\n", progname, filename);
- exit (1);
- }
-
- setup_xbm_texture ((char *) data, width, height, &gp->fg, &gp->bg);
- }
-#else /* !XMU */
-
-# ifdef HAVE_XPM
- fprintf (stderr, "%s: not an XPM file: %s\n", progname, filename);
-# endif
- fprintf (stderr, "%s: your vendor doesn't ship the standard Xmu library.\n",
- progname);
- fprintf (stderr, "%s: we can't load XBM files without it.\n",progname);
- exit (1);
-#endif /* !XMU */
+ char buf[1024];
+
+ XImage *image = file_to_ximage (dpy, visual, filename);
+ if (!image) return False;
+
+ clear_gl_error();
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, image->width);
+ 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);
+ return True;