diff -u -r -X .diffignore freeciv/acconfig.h freeciv-imlib/acconfig.h --- freeciv/acconfig.h Sun Feb 28 23:42:30 1999 +++ freeciv-imlib/acconfig.h Thu Mar 4 13:47:05 1999 @@ -28,6 +28,7 @@ #undef HAVE_LIBXMU #undef HAVE_LIBXPM #undef HAVE_LIBXT +#undef HAVE_LIBIMLIB @BOTTOM@ diff -u -r -X .diffignore freeciv/client/Makefile.am freeciv-imlib/client/Makefile.am --- freeciv/client/Makefile.am Thu Feb 18 15:17:42 1999 +++ freeciv-imlib/client/Makefile.am Thu Mar 4 14:34:12 1999 @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in bin_PROGRAMS = civclient -INCLUDES = -I$(srcdir)/../common -I. $(X_CFLAGS) +INCLUDES = -I$(srcdir)/../common -I. $(X_CFLAGS) $(IMLIB_CFLAGS) BUILT_SOURCES = Freeciv.h @@ -12,7 +12,7 @@ $(srcdir)/ad2c $(srcdir)/../data/Freeciv >> Freeciv.h civclient_DEPENDENCIES = ad2c cityicon.ico freeciv.ico ../common/libcivcommon.a -civclient_LDADD = ../common/libcivcommon.a $(X_LIBS) $(X_EXTRA_LIBS) +civclient_LDADD = ../common/libcivcommon.a $(X_LIBS) $(X_EXTRA_LIBS) $(IMLIB_LIBS) civclient_SOURCES = \ cityicon.ico freeciv.ico ad2c \ diff -u -r -X .diffignore freeciv/client/graphics.c freeciv-imlib/client/graphics.c --- freeciv/client/graphics.c Sun Feb 21 12:54:39 1999 +++ freeciv-imlib/client/graphics.c Thu Mar 4 14:27:38 1999 @@ -22,6 +22,12 @@ #include #include +#ifdef HAVE_LIBIMLIB +#include +#include +#include +#endif + #include #include #include @@ -33,6 +39,10 @@ extern int display_depth; extern Widget map_canvas; extern Display *display; +#ifdef HAVE_LIBIMLIB +ImlibData *id; +ImlibImage *im; +#endif extern XColor colors[MAX_COLORS]; extern GC fill_bg_gc; extern GC civ_gc, font_gc; @@ -375,6 +385,38 @@ ***************************************************************************/ struct Sprite *load_xpmfile(char *filename) { +#ifdef HAVE_LIBIMLIB + struct Sprite *mysprite; + Pixmap mypixmap, mask_bitmap; + ImlibImage *im; + int w,h; + + im = Imlib_load_image(id,filename); + if (!im) + { + freelog(LOG_FATAL, "Failed reading XPM file: %s", filename); + freelog(LOG_FATAL, "The environment variable FREECIV_DATADIR is '%s'", + getenv("FREECIV_DATADIR") ? getenv("FREECIV_DATADIR") : ""); + freelog(LOG_FATAL, "Check if you got read permissions to the file"); + exit(1); + } + w=im->rgb_width; + h=im->rgb_height; + + Imlib_render(id,im,w,h); + mypixmap=Imlib_move_image(id,im); + mask_bitmap=Imlib_move_mask(id,im); + + if(!(mysprite=(struct Sprite *)malloc(sizeof(struct Sprite)))) { + freelog(LOG_FATAL, "failed mallocing sprite struct for %s", filename); + exit(1); + } + mysprite->pixmap=mypixmap; + mysprite->mask=mask_bitmap; + mysprite->has_mask=(mask_bitmap!=0); + mysprite->width=w; + mysprite->height=h; +#else struct Sprite *mysprite; Pixmap mypixmap, mask_bitmap; int err; @@ -385,14 +427,13 @@ attributes.colormap = cmap; attributes.closeness = 40000; -again: - if((err=XpmReadFileToPixmap(display, root_window, filename, &mypixmap, &mask_bitmap, &attributes))!=XpmSuccess) { if(err==XpmColorError || err==XpmColorFailed) { color_error(); goto again; } +again: freelog(LOG_FATAL, "Failed reading XPM file: %s", filename); freelog(LOG_FATAL, "The environment variable FREECIV_DATADIR is '%s'", @@ -411,6 +452,7 @@ mysprite->has_mask=(mask_bitmap!=0); mysprite->width=attributes.width; mysprite->height=attributes.height; +#endif /* HAVE_LIBIMLIB */ return mysprite; } diff -u -r -X .diffignore freeciv/client/xmain.c freeciv-imlib/client/xmain.c --- freeciv/client/xmain.c Mon Feb 22 15:15:19 1999 +++ freeciv-imlib/client/xmain.c Thu Mar 4 14:20:34 1999 @@ -33,6 +33,13 @@ #include #include +#ifdef HAVE_LIBIMLIB +#include +#include +#include +#include +#endif + #include #include #include @@ -138,6 +145,10 @@ /**************************************************************************/ Display *display; +#ifdef HAVE_LIBIMLIB +ImlibData *id; +ImlibImage *im; +#endif int display_depth; int screen_number; enum Display_color_type display_color_type; @@ -273,10 +284,13 @@ &fallback_resources[1], /* for missing app-defaults file */ XtNallowShellResize, True, NULL); - + display = XtDisplay(toplevel); +#ifdef HAVE_LIBIMLIB + id=Imlib_init(display); +#endif XtGetApplicationResources(toplevel, &appResources, resources, XtNumber(resources), NULL, 0); - + log_init(appResources.logfile); log_set_level(appResources.loglevel); @@ -333,7 +347,6 @@ boot_help_texts(); /* after log_init */ - display = XtDisplay(toplevel); screen_number=XScreenNumberOfScreen(XtScreen(toplevel)); display_depth=DefaultDepth(display, screen_number); root_window=DefaultRootWindow(display); diff -u -r -X .diffignore freeciv/config.h.in freeciv-imlib/config.h.in --- freeciv/config.h.in Sun Feb 28 23:42:30 1999 +++ freeciv-imlib/config.h.in Thu Mar 4 13:49:40 1999 @@ -43,6 +43,7 @@ #undef HAVE_LIBXMU #undef HAVE_LIBXPM #undef HAVE_LIBXT +#undef HAVE_LIBIMLIB /* Define if you have the gethostname function. */ #undef HAVE_GETHOSTNAME diff -u -r -X .diffignore freeciv/configure.in freeciv-imlib/configure.in --- freeciv/configure.in Mon Mar 1 14:50:23 1999 +++ freeciv-imlib/configure.in Thu Mar 4 14:22:03 1999 @@ -58,6 +58,12 @@ WITH_XAW3D=1 ) +AC_ARG_WITH(imlib, + [ --with-imlib compile with imlib ], + [WITH_IMLIB=1 + echo "We try to use imlib"] +) + AC_ARG_ENABLE(client, [ --disable-client do not compile the client], [case "${enableval}" in @@ -157,6 +163,9 @@ FC_CHECK_X_LIB(Xaw, main) else FC_CHECK_X_LIB(Xaw3d, main) + fi + if test x$WITH_IMLIB != x; then + AM_PATH_IMLIB(1.9.4,AC_DEFINE(HAVE_LIBIMLIB)) fi dnl Don't do following because don't want server to link with X: dnl LIBS="$LIBS $X_LIBS $X_EXTRA_LIBS"