Commit ef6f54e3 authored by Sam Lantinga's avatar Sam Lantinga

Added support for testing video flipping with graywin.c

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40539
parent 7af0922b
...@@ -36,7 +36,11 @@ void DrawBox(SDL_Surface *screen, int X, int Y, int width, int height) ...@@ -36,7 +36,11 @@ void DrawBox(SDL_Surface *screen, int X, int Y, int width, int height)
/* Do it! */ /* Do it! */
SDL_FillRect(screen, &area, color); SDL_FillRect(screen, &area, color);
SDL_UpdateRects(screen, 1, &area); if ( screen->flags & SDL_DOUBLEBUF ) {
SDL_Flip(screen);
} else {
SDL_UpdateRects(screen, 1, &area);
}
} }
SDL_Surface *CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags) SDL_Surface *CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags)
...@@ -65,18 +69,25 @@ SDL_Surface *CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags) ...@@ -65,18 +69,25 @@ SDL_Surface *CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags)
SDL_SetColors(screen, palette, 0, NUM_COLORS); SDL_SetColors(screen, palette, 0, NUM_COLORS);
/* Set the surface pixels and refresh! */ /* Set the surface pixels and refresh! */
if ( SDL_LockSurface(screen) < 0 ) { /* Use two loops in case the surface is double-buffered (both sides) */
fprintf(stderr, "Couldn't lock display surface: %s\n", for ( i=0; i<2; ++i ) {
SDL_GetError()); if ( SDL_LockSurface(screen) < 0 ) {
return(NULL); fprintf(stderr, "Couldn't lock display surface: %s\n",
} SDL_GetError());
buffer = (Uint8 *)screen->pixels; return(NULL);
for ( i=0; i<screen->h; ++i ) { }
memset(buffer,(i*(NUM_COLORS-1))/screen->h, screen->w * screen->format->BytesPerPixel); buffer = (Uint8 *)screen->pixels;
buffer += screen->pitch; for ( i=0; i<screen->h; ++i ) {
memset(buffer,(i*(NUM_COLORS-1))/screen->h, screen->w * screen->format->BytesPerPixel);
buffer += screen->pitch;
}
SDL_UnlockSurface(screen);
if ( screen->flags & SDL_DOUBLEBUF ) {
SDL_Flip(screen);
} else {
SDL_UpdateRect(screen, 0, 0, 0, 0);
}
} }
SDL_UnlockSurface(screen);
SDL_UpdateRect(screen, 0, 0, 0, 0);
return(screen); return(screen);
} }
...@@ -120,13 +131,16 @@ int main(int argc, char *argv[]) ...@@ -120,13 +131,16 @@ int main(int argc, char *argv[])
if ( argv[argc] && (strcmp(argv[argc], "-hwpalette") == 0) ) { if ( argv[argc] && (strcmp(argv[argc], "-hwpalette") == 0) ) {
videoflags |= SDL_HWPALETTE; videoflags |= SDL_HWPALETTE;
} else } else
if ( argv[argc] && (strcmp(argv[argc], "-flip") == 0) ) {
videoflags |= SDL_DOUBLEBUF;
} else
if ( argv[argc] && (strcmp(argv[argc], "-noframe") == 0) ) { if ( argv[argc] && (strcmp(argv[argc], "-noframe") == 0) ) {
videoflags |= SDL_NOFRAME; videoflags |= SDL_NOFRAME;
} else } else
if ( argv[argc] && (strcmp(argv[argc], "-fullscreen") == 0) ) { if ( argv[argc] && (strcmp(argv[argc], "-fullscreen") == 0) ) {
videoflags |= SDL_FULLSCREEN; videoflags |= SDL_FULLSCREEN;
} else { } else {
fprintf(stderr, "Usage: %s [-width] [-height] [-bpp] [-hw] [-hwpalette] [-noframe] [-fullscreen]\n", fprintf(stderr, "Usage: %s [-width] [-height] [-bpp] [-hw] [-hwpalette] [-flip] [-noframe] [-fullscreen]\n",
argv[0]); argv[0]);
exit(1); exit(1);
} }
......
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