comparison test/testsprite.c @ 107:01fcac5d146e

Fixed crash in testsprite when using the -fast option (nobody caught this?)
author Sam Lantinga <slouken@lokigames.com>
date Fri, 13 Jul 2001 10:20:43 +0000
parents 74212992fb08
children 2f5a6062db86
comparison
equal deleted inserted replaced
106:63ec24e0575f 107:01fcac5d146e
90 } 90 }
91 sprites_visible = 1; 91 sprites_visible = 1;
92 } 92 }
93 93
94 /* This is a way of telling whether or not to use hardware surfaces */ 94 /* This is a way of telling whether or not to use hardware surfaces */
95 Uint32 FastestFlags(Uint32 flags) 95 Uint32 FastestFlags(Uint32 flags, int width, int height, int bpp)
96 { 96 {
97 const SDL_VideoInfo *info; 97 const SDL_VideoInfo *info;
98 98
99 /* Hardware acceleration is only used in fullscreen mode */ 99 /* Hardware acceleration is only used in fullscreen mode */
100 flags |= SDL_FULLSCREEN; 100 flags |= SDL_FULLSCREEN;
110 */ 110 */
111 if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { 111 if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
112 /* Direct hardware blitting without double-buffering 112 /* Direct hardware blitting without double-buffering
113 causes really bad flickering. 113 causes really bad flickering.
114 */ 114 */
115 SDL_Surface *screen = SDL_GetVideoSurface(); 115 if ( info->video_mem*1024 > (height*width*bpp/8) ) {
116 if ( info->video_mem > (screen->h*screen->pitch) ) {
117 flags |= SDL_DOUBLEBUF; 116 flags |= SDL_DOUBLEBUF;
118 } else { 117 } else {
119 flags &= ~SDL_HWSURFACE; 118 flags &= ~SDL_HWSURFACE;
120 } 119 }
121 } 120 }
162 video_bpp = atoi(argv[argc]); 161 video_bpp = atoi(argv[argc]);
163 videoflags &= ~SDL_ANYFORMAT; 162 videoflags &= ~SDL_ANYFORMAT;
164 --argc; 163 --argc;
165 } else 164 } else
166 if ( strcmp(argv[argc], "-fast") == 0 ) { 165 if ( strcmp(argv[argc], "-fast") == 0 ) {
167 videoflags = FastestFlags(videoflags); 166 videoflags = FastestFlags(videoflags, width, height, video_bpp);
168 } else 167 } else
169 if ( strcmp(argv[argc], "-hw") == 0 ) { 168 if ( strcmp(argv[argc], "-hw") == 0 ) {
170 videoflags ^= SDL_HWSURFACE; 169 videoflags ^= SDL_HWSURFACE;
171 } else 170 } else
172 if ( strcmp(argv[argc], "-flip") == 0 ) { 171 if ( strcmp(argv[argc], "-flip") == 0 ) {