X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=b9309408a4d1966ea687f6fa0db5b7d04fb64aa4;hb=3ae70b9d27b4b2c038f35b0aa5985c368542a486;hp=f751fe85be2a5e568b94c6929f3ea79fc5f3d0ee;hpb=ae0e3de423fa4a5a60969bed8adf11e5d147b4dc;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index f751fe85..b9309408 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -85,7 +85,7 @@ static void SDLSetWindowIcon(char *basename) } /* set transparent color */ - SDL_SetColorKey(surface, SDL_SRCCOLORKEY, + SDL_SetColorKey(surface, SET_TRANSPARENT_PIXEL, SDL_MapRGB(surface->format, 0x00, 0x00, 0x00)); SDL_WM_SetIcon(surface, NULL); @@ -140,6 +140,13 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, fullscreen_xoffset = (fullscreen_width - video.width) / 2; fullscreen_yoffset = (fullscreen_height - video.height) / 2; +#if 1 + checked_free(video.fullscreen_modes); + + video.fullscreen_modes = NULL; + video.fullscreen_mode_current = NULL; +#endif + /* get available hardware supported fullscreen modes */ modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); @@ -228,7 +235,11 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, should never be drawn to directly, it would do no harm nevertheless. */ /* create additional (symbolic) buffer for double-buffering */ +#if 1 + ReCreateBitmap(window, video.width, video.height, video.depth); +#else *window = CreateBitmap(video.width, video.height, video.depth); +#endif } boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) @@ -241,6 +252,10 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) if (*backbuffer == NULL) *backbuffer = CreateBitmapStruct(); + /* (real bitmap might be larger in fullscreen mode with video offsets) */ + (*backbuffer)->width = video.width; + (*backbuffer)->height = video.height; + if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available) { setFullscreenParameters(setup.fullscreen_mode); @@ -292,11 +307,11 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) (*backbuffer)->surface = new_surface; video.fullscreen_enabled = FALSE; + success = TRUE; } } - #if 1 SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); @@ -423,6 +438,17 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height, int dst_x = x, dst_y = y; unsigned int time_last, time_current; + /* check if screen size has changed */ + if (surface_source != NULL && (video.width != surface_source->w || + video.height != surface_source->h)) + { + SDL_FreeSurface(surface_source); + SDL_FreeSurface(surface_target); + SDL_FreeSurface(surface_black); + + initialization_needed = TRUE; + } + src_rect.x = src_x; src_rect.y = src_y; src_rect.w = width; @@ -1308,12 +1334,17 @@ int zoomSurfaceRGBA_scaleDownBy2(SDL_Surface *src, SDL_Surface *dst) { int x, y; tColorRGBA *sp, *csp, *dp; - int sgap, dgap; +#if 0 + int sgap; +#endif + int dgap; /* pointer setup */ sp = csp = (tColorRGBA *) src->pixels; dp = (tColorRGBA *) dst->pixels; +#if 0 sgap = src->pitch - src->w * 4; +#endif dgap = dst->pitch - dst->w * 4; for (y = 0; y < dst->h; y++) @@ -1360,7 +1391,10 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst) { int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy; tColorRGBA *sp, *csp, *dp; - int sgap, dgap; +#if 0 + int sgap; +#endif + int dgap; /* use specialized zoom function when scaling down to exactly half size */ if (src->w == 2 * dst->w && @@ -1399,7 +1433,9 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst) /* pointer setup */ sp = csp = (tColorRGBA *) src->pixels; dp = (tColorRGBA *) dst->pixels; +#if 0 sgap = src->pitch - src->w * 4; +#endif dgap = dst->pitch - dst->w * 4; csay = say; @@ -1670,7 +1706,7 @@ Bitmap *SDLLoadImage(char *filename) UPDATE_BUSY_STATE(); /* create native transparent surface for current image */ - SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY, + SDL_SetColorKey(sdl_image_tmp, SET_TRANSPARENT_PIXEL, SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00)); if ((new_bitmap->surface_masked = SDL_DisplayFormat(sdl_image_tmp)) == NULL) {