Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed testalpha screen clear for screen formats with an alpha channel
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 29, 2008
1 parent 9a720fc commit 47b6344
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions test/testalpha.c
Expand Up @@ -36,44 +36,43 @@ FillBackground(SDL_Surface * screen)
}
buffer = (Uint8 *) screen->pixels;
switch (screen->format->BytesPerPixel) {
case 1:
case 3:
for (i = 0; i < screen->h; ++i) {
memset(buffer, (i * 255) / screen->h,
screen->w * screen->format->BytesPerPixel);
buffer += screen->pitch;
}
break;
case 2:
for (i = 0; i < screen->h; ++i) {
Uint16 *buffer16;
Uint16 color;

gradient = ((i * 255) / screen->h);
color = (Uint16) SDL_MapRGB(screen->format,
gradient, gradient, gradient);
buffer16 = (Uint16 *) buffer;
for (k = 0; k < screen->w; k++) {
*buffer16++ = color;
}
buffer += screen->pitch;
case 1:
case 3:
for (i = 0; i < screen->h; ++i) {
memset(buffer, (i * 255) / screen->h,
screen->w * screen->format->BytesPerPixel);
buffer += screen->pitch;
}
break;
case 2:
for (i = 0; i < screen->h; ++i) {
Uint16 *buffer16;
Uint16 color;

gradient = ((i * 255) / screen->h);
color = (Uint16) SDL_MapRGB(screen->format,
gradient, gradient, gradient);
buffer16 = (Uint16 *) buffer;
for (k = 0; k < screen->w; k++) {
*buffer16++ = color;
}
break;
case 4:
for (i = 0; i < screen->h; ++i) {
Uint32 *buffer32;
Uint32 color;

gradient = ((i * 255) / screen->h);
color = SDL_MapRGB(screen->format,
gradient, gradient, gradient);
buffer32 = (Uint32 *) buffer;
for (k = 0; k < screen->w; k++) {
*buffer32++ = color;
}
buffer += screen->pitch;
buffer += screen->pitch;
}
break;
case 4:
for (i = 0; i < screen->h; ++i) {
Uint32 *buffer32;
Uint32 color;

gradient = ((i * 255) / screen->h);
color = SDL_MapRGB(screen->format, gradient, gradient, gradient);
buffer32 = (Uint32 *) buffer;
for (k = 0; k < screen->w; k++) {
*buffer32++ = color;
}
break;
buffer += screen->pitch;
}
break;
}

SDL_UnlockSurface(screen);
Expand Down Expand Up @@ -523,7 +522,8 @@ main(int argc, char *argv[])
area.y = event.button.y - 16;
area.w = 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);
}
break;
Expand Down

0 comments on commit 47b6344

Please sign in to comment.