Commit 7a4a7129 authored by Sam Lantinga's avatar Sam Lantinga

Fixed testalpha screen clear for screen formats with an alpha channel

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403267
parent b64cf822
...@@ -36,44 +36,43 @@ FillBackground(SDL_Surface * screen) ...@@ -36,44 +36,43 @@ FillBackground(SDL_Surface * screen)
} }
buffer = (Uint8 *) screen->pixels; buffer = (Uint8 *) screen->pixels;
switch (screen->format->BytesPerPixel) { switch (screen->format->BytesPerPixel) {
case 1: case 1:
case 3: case 3:
for (i = 0; i < screen->h; ++i) { for (i = 0; i < screen->h; ++i) {
memset(buffer, (i * 255) / screen->h, memset(buffer, (i * 255) / screen->h,
screen->w * screen->format->BytesPerPixel); screen->w * screen->format->BytesPerPixel);
buffer += screen->pitch; buffer += screen->pitch;
} }
break; break;
case 2: case 2:
for (i = 0; i < screen->h; ++i) { for (i = 0; i < screen->h; ++i) {
Uint16 *buffer16; Uint16 *buffer16;
Uint16 color; Uint16 color;
gradient = ((i * 255) / screen->h); gradient = ((i * 255) / screen->h);
color = (Uint16) SDL_MapRGB(screen->format, color = (Uint16) SDL_MapRGB(screen->format,
gradient, gradient, gradient); gradient, gradient, gradient);
buffer16 = (Uint16 *) buffer; buffer16 = (Uint16 *) buffer;
for (k = 0; k < screen->w; k++) { for (k = 0; k < screen->w; k++) {
*buffer16++ = color; *buffer16++ = color;
}
buffer += screen->pitch;
} }
break; buffer += screen->pitch;
case 4: }
for (i = 0; i < screen->h; ++i) { break;
Uint32 *buffer32; case 4:
Uint32 color; for (i = 0; i < screen->h; ++i) {
Uint32 *buffer32;
gradient = ((i * 255) / screen->h); Uint32 color;
color = SDL_MapRGB(screen->format,
gradient, gradient, gradient); gradient = ((i * 255) / screen->h);
buffer32 = (Uint32 *) buffer; color = SDL_MapRGB(screen->format, gradient, gradient, gradient);
for (k = 0; k < screen->w; k++) { buffer32 = (Uint32 *) buffer;
*buffer32++ = color; for (k = 0; k < screen->w; k++) {
} *buffer32++ = color;
buffer += screen->pitch;
} }
break; buffer += screen->pitch;
}
break;
} }
SDL_UnlockSurface(screen); SDL_UnlockSurface(screen);
...@@ -523,7 +522,8 @@ main(int argc, char *argv[]) ...@@ -523,7 +522,8 @@ main(int argc, char *argv[])
area.y = event.button.y - 16; area.y = event.button.y - 16;
area.w = 32; area.w = 32;
area.h = 32; area.h = 32;
SDL_FillRect(screen, &area, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_FillRect(screen, &area,
SDL_MapRGB(screen->format, 0, 0, 0));
SDL_UpdateRects(screen, 1, &area); SDL_UpdateRects(screen, 1, &area);
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment