X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fsdl.c;h=f3846da7491d6862b55416414cab925328575252;hb=4cc378525f493292a995869afcf0c45f1f38f951;hp=f782961d2a509f9e43ea67d7f729ad32eca3b89f;hpb=9dcf51eadcd8fb8e1ba937b6a8db76096cc09b05;p=rocksndiamonds.git diff --git a/src/sdl.c b/src/sdl.c index f782961d..f3846da7 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -22,6 +22,7 @@ inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface, int width, int height, int dst_x, int dst_y) { + SDL_Surface *surface = (dst_surface == window ? backbuffer : dst_surface); SDL_Rect src_rect, dst_rect; src_rect.x = src_x; @@ -34,19 +35,21 @@ inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface, dst_rect.w = width; dst_rect.h = height; - SDL_BlitSurface(src_surface, &src_rect, dst_surface, &dst_rect); -#if 1 - SDL_UpdateRect(dst_surface, dst_x, dst_y, width, height); -#endif + if (src_surface != backbuffer || dst_surface != window) + SDL_BlitSurface(src_surface, &src_rect, surface, &dst_rect); + + if (dst_surface == window) + SDL_UpdateRect(backbuffer, dst_x, dst_y, width, height); } -inline void SDLFillRectangle(SDL_Surface *surface, int x, int y, +inline void SDLFillRectangle(SDL_Surface *dst_surface, int x, int y, int width, int height, unsigned int color) { + SDL_Surface *surface = (dst_surface == window ? backbuffer : dst_surface); SDL_Rect rect; - unsigned int color_r = (color >> 2) && 0xff; - unsigned int color_g = (color >> 1) && 0xff; - unsigned int color_b = (color >> 0) && 0xff; + unsigned int color_r = (color >> 16) && 0xff; + unsigned int color_g = (color >> 8) && 0xff; + unsigned int color_b = (color >> 0) && 0xff; rect.x = x; rect.y = y; @@ -54,17 +57,19 @@ inline void SDLFillRectangle(SDL_Surface *surface, int x, int y, rect.h = height; SDL_FillRect(surface, &rect, - SDL_MapRGB(surface->format, color_r, color_g, color_b)); - SDL_UpdateRect(surface, x, y, width, height); + SDL_MapRGB(surface->format, color_r, color_g, color_b)); + + if (dst_surface == window) + SDL_UpdateRect(backbuffer, x, y, width, height); } inline void SDLDrawSimpleLine(SDL_Surface *surface, int from_x, int from_y, int to_x, int to_y, unsigned int color) { SDL_Rect rect; - unsigned int color_r = (color >> 2) && 0xff; - unsigned int color_g = (color >> 1) && 0xff; - unsigned int color_b = (color >> 0) && 0xff; + unsigned int color_r = (color >> 16) & 0xff; + unsigned int color_g = (color >> 8) & 0xff; + unsigned int color_b = (color >> 0) & 0xff; if (from_x > to_x) swap_numbers(&from_x, &to_x);