X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fx11.c;h=196bd8e71c1aee17c67aaf12cf3f2c959715b8f3;hb=c4e1a476135ce36417cdd797481feeaaff4301af;hp=4dfb1431ff9c05afe89d6feac2483e5345fca90e;hpb=998be01ad92a672b69b11e24d472f6c0c076817f;p=rocksndiamonds.git diff --git a/src/libgame/x11.c b/src/libgame/x11.c index 4dfb1431..196bd8e7 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -12,13 +12,14 @@ ***********************************************************/ #include "system.h" +#include "pcx.h" #include "misc.h" #if defined(TARGET_X11) static void X11InitDisplay(); -static DrawWindow X11InitWindow(); +static DrawWindow *X11InitWindow(); inline void X11InitVideoDisplay(void) { @@ -29,7 +30,7 @@ inline void X11InitVideoDisplay(void) video.default_depth = XDefaultDepth(display, screen); } -inline void X11InitVideoBuffer(DrawBuffer *backbuffer, DrawWindow *window) +inline void X11InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window) { *window = X11InitWindow(); @@ -86,9 +87,9 @@ static void X11InitDisplay() #endif /* !PLATFORM_MSDOS */ } -static DrawWindow X11InitWindow() +static DrawWindow *X11InitWindow() { - DrawWindow new_window = CreateBitmapStruct(); + DrawWindow *new_window = CreateBitmapStruct(); unsigned int border_width = 4; XGCValues gc_values; unsigned long gc_valuemask; @@ -234,4 +235,45 @@ static DrawWindow X11InitWindow() return new_window; } +Bitmap *X11LoadImage(char *filename) +{ + Bitmap *new_bitmap = CreateBitmapStruct(); + int pcx_err; + +#if defined(PLATFORM_MSDOS) + rest(100); +#endif + + pcx_err = Read_PCX_to_Pixmap(display, window->drawable, window->gc, filename, + &new_bitmap->drawable, &new_bitmap->clip_mask); + switch(pcx_err) + { + case PCX_Success: + break; + case PCX_OpenFailed: + Error(ERR_EXIT, "cannot open PCX file '%s'", filename); + case PCX_ReadFailed: + Error(ERR_EXIT, "cannot read PCX file '%s'", filename); + case PCX_FileInvalid: + Error(ERR_EXIT, "invalid PCX file '%s'", filename); + case PCX_NoMemory: + Error(ERR_EXIT, "not enough memory for PCX file '%s'", filename); + case PCX_ColorFailed: + Error(ERR_EXIT, "cannot get colors for PCX file '%s'", filename); + default: + break; + } + + if (!new_bitmap->drawable) + Error(ERR_EXIT, "cannot get graphics for '%s'", filename); + + if (!new_bitmap->clip_mask) + Error(ERR_EXIT, "cannot get clipmask for '%s'", filename); + + /* set GraphicContext inheritated from Window */ + new_bitmap->gc = window->gc; + + return new_bitmap; +} + #endif /* TARGET_X11 */