test/testvidinfo.c
author Patrice Mandin <patmandin@gmail.com>
Thu, 19 Jan 2006 21:28:52 +0000
changeset 1257 448a9a64537b
parent 886 05c551e5bc64
child 1545 8d9bb0cf2c2a
permissions -rw-r--r--
[PATCH] SDL_GetVideoMode() does not find best mode, part 2

Following commit 1.51, I come accross a problem when SDL must choose between
several video modes that could suit the one asked.

If I ask 320x240 with this list:
768x480 768x240 640x400 640x200 384x480 384x240 320x400 320x200

The smallest selectables modes are 384x240 and 320x400. And SDL choose the later
in this list, but 384x240 is more suitable. So I added a check to compare
the pixel count (surface) of modes, and select the one which has the smallest
pixel count.

In my example, 384x240 has 92160 pixels, and 320x400 has 128000 pixels. So now
SDL will choose 384x240 for the asked 320x240 mode.
slouken@0
     1
slouken@0
     2
/* Simple program -- figure out what kind of video display we have */
slouken@0
     3
slouken@479
     4
#include <stdlib.h>
slouken@0
     5
#include <stdio.h>
slouken@0
     6
#include <stdlib.h>
slouken@524
     7
#include <string.h>
slouken@0
     8
slouken@0
     9
#include "SDL.h"
slouken@0
    10
slouken@480
    11
#define NUM_BLITS	10
slouken@480
    12
#define NUM_UPDATES	500
slouken@480
    13
slouken@886
    14
#define FLAG_MASK	(SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | \
slouken@886
    15
                         SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCEL  | \
slouken@886
    16
                         SDL_RLEACCELOK)
slouken@479
    17
slouken@479
    18
void PrintFlags(Uint32 flags)
slouken@479
    19
{
slouken@479
    20
	printf("0x%8.8x", (flags & FLAG_MASK));
slouken@479
    21
	if ( flags & SDL_HWSURFACE ) {
slouken@479
    22
		printf(" SDL_HWSURFACE");
slouken@479
    23
	} else {
slouken@479
    24
		printf(" SDL_SWSURFACE");
slouken@479
    25
	}
slouken@479
    26
	if ( flags & SDL_FULLSCREEN ) {
slouken@479
    27
		printf(" | SDL_FULLSCREEN");
slouken@479
    28
	}
slouken@479
    29
	if ( flags & SDL_DOUBLEBUF ) {
slouken@479
    30
		printf(" | SDL_DOUBLEBUF");
slouken@479
    31
	}
slouken@821
    32
	if ( flags & SDL_SRCCOLORKEY ) {
slouken@821
    33
		printf(" | SDL_SRCCOLORKEY");
slouken@821
    34
	}
slouken@886
    35
	if ( flags & SDL_SRCALPHA ) {
slouken@886
    36
		printf(" | SDL_SRCALPHA");
slouken@886
    37
	}
slouken@821
    38
	if ( flags & SDL_RLEACCEL ) {
slouken@821
    39
		printf(" | SDL_RLEACCEL");
slouken@821
    40
	}
slouken@886
    41
	if ( flags & SDL_RLEACCELOK ) {
slouken@886
    42
		printf(" | SDL_RLEACCELOK");
slouken@886
    43
	}
slouken@479
    44
}
slouken@479
    45
slouken@479
    46
int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount)
slouken@479
    47
{
slouken@479
    48
	int i, j;
slouken@479
    49
	int maxx;
slouken@479
    50
	int maxy;
slouken@480
    51
	SDL_Rect dst;
slouken@479
    52
slouken@480
    53
	maxx = (int)screen->w - bmp->w + 1;
slouken@480
    54
	maxy = (int)screen->h - bmp->h + 1;
slouken@480
    55
	for ( i = 0; i < NUM_UPDATES; ++i ) {
slouken@479
    56
		for ( j = 0; j < blitcount; ++j ) {
slouken@479
    57
			if ( maxx ) {
slouken@480
    58
				dst.x = rand() % maxx;
slouken@479
    59
			} else {
slouken@480
    60
				dst.x = 0;
slouken@479
    61
			}
slouken@479
    62
			if ( maxy ) {
slouken@480
    63
				dst.y = rand() % maxy;
slouken@479
    64
			} else {
slouken@480
    65
				dst.y = 0;
slouken@479
    66
			}
slouken@480
    67
			dst.w = bmp->w;
slouken@480
    68
			dst.h = bmp->h;
slouken@480
    69
			SDL_BlitSurface(bmp, NULL, screen, &dst);
slouken@479
    70
		}
slouken@480
    71
		SDL_Flip(screen);
slouken@479
    72
	}
slouken@479
    73
slouken@479
    74
	return i;
slouken@479
    75
}
slouken@479
    76
slouken@480
    77
int RunModeTests(SDL_Surface *screen)
slouken@479
    78
{
slouken@479
    79
	Uint32 then, now;
slouken@479
    80
	Uint32 frames;
slouken@480
    81
	float seconds;
slouken@479
    82
	int i;
slouken@479
    83
	Uint8 r, g, b;
slouken@821
    84
	SDL_Surface *bmp, *bmpcc, *tmp;
slouken@480
    85
	SDL_Event event;
slouken@480
    86
slouken@480
    87
	while ( SDL_PollEvent(&event) ) {
slouken@480
    88
		if ( event.type == SDL_KEYDOWN )
slouken@480
    89
			return 0;
slouken@480
    90
	}
slouken@479
    91
slouken@479
    92
	/* First test fills and screen update speed */
slouken@479
    93
	printf("Running color fill and fullscreen update test\n");
slouken@479
    94
	then = SDL_GetTicks();
slouken@479
    95
	frames = 0;
slouken@479
    96
	for ( i = 0; i < 256; ++i ) {
slouken@479
    97
		r = i;
slouken@479
    98
		g = 0;
slouken@479
    99
		b = 0;
slouken@479
   100
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
slouken@479
   101
		SDL_Flip(screen);
slouken@479
   102
		++frames;
slouken@479
   103
	}
slouken@479
   104
	for ( i = 0; i < 256; ++i ) {
slouken@479
   105
		r = 0;
slouken@479
   106
		g = i;
slouken@479
   107
		b = 0;
slouken@479
   108
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
slouken@479
   109
		SDL_Flip(screen);
slouken@479
   110
		++frames;
slouken@479
   111
	}
slouken@479
   112
	for ( i = 0; i < 256; ++i ) {
slouken@479
   113
		r = 0;
slouken@479
   114
		g = 0;
slouken@479
   115
		b = i;
slouken@479
   116
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
slouken@479
   117
		SDL_Flip(screen);
slouken@479
   118
		++frames;
slouken@479
   119
	}
slouken@479
   120
	now = SDL_GetTicks();
slouken@480
   121
	seconds = (float)(now - then) / 1000.0f;
slouken@480
   122
	if ( seconds > 0.0f ) {
slouken@480
   123
		printf("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames, seconds, (float)frames / seconds);
slouken@480
   124
	} else {
slouken@480
   125
		printf("%d fills and flips in zero seconds!n", frames);
slouken@480
   126
	}
slouken@480
   127
slouken@886
   128
        /* clear the screen after fill test */
slouken@886
   129
        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
slouken@886
   130
	SDL_Flip(screen);
slouken@886
   131
slouken@480
   132
	while ( SDL_PollEvent(&event) ) {
slouken@480
   133
		if ( event.type == SDL_KEYDOWN )
slouken@480
   134
			return 0;
slouken@480
   135
	}
slouken@479
   136
slouken@821
   137
        /* run the generic blit test */
slouken@479
   138
	bmp = SDL_LoadBMP("sample.bmp");
slouken@479
   139
	if ( ! bmp ) {
slouken@479
   140
		printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
slouken@482
   141
		return 0;
slouken@479
   142
	}
slouken@479
   143
	printf("Running freshly loaded blit test: %dx%d at %d bpp, flags: ",
slouken@479
   144
		bmp->w, bmp->h, bmp->format->BitsPerPixel);
slouken@479
   145
	PrintFlags(bmp->flags);
slouken@479
   146
	printf("\n");
slouken@479
   147
	then = SDL_GetTicks();
slouken@480
   148
	frames = RunBlitTests(screen, bmp, NUM_BLITS);
slouken@479
   149
	now = SDL_GetTicks();
slouken@480
   150
	seconds = (float)(now - then) / 1000.0f;
slouken@480
   151
	if ( seconds > 0.0f ) {
slouken@480
   152
		printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
slouken@480
   153
	} else {
slouken@480
   154
		printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
slouken@479
   155
	}
slouken@479
   156
slouken@886
   157
        /* clear the screen after blit test */
slouken@886
   158
        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
slouken@886
   159
	SDL_Flip(screen);
slouken@886
   160
slouken@886
   161
	while ( SDL_PollEvent(&event) ) {
slouken@886
   162
		if ( event.type == SDL_KEYDOWN )
slouken@886
   163
			return 0;
slouken@886
   164
	}
slouken@886
   165
slouken@821
   166
        /* run the colorkeyed blit test */
slouken@821
   167
	bmpcc = SDL_LoadBMP("sample.bmp");
slouken@821
   168
	if ( ! bmpcc ) {
slouken@821
   169
		printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
slouken@821
   170
		return 0;
slouken@821
   171
	}
slouken@821
   172
	printf("Running freshly loaded cc blit test: %dx%d at %d bpp, flags: ",
slouken@821
   173
		bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
slouken@821
   174
        SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels);
slouken@821
   175
slouken@821
   176
	PrintFlags(bmpcc->flags);
slouken@821
   177
	printf("\n");
slouken@821
   178
	then = SDL_GetTicks();
slouken@821
   179
	frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
slouken@821
   180
	now = SDL_GetTicks();
slouken@821
   181
	seconds = (float)(now - then) / 1000.0f;
slouken@821
   182
	if ( seconds > 0.0f ) {
slouken@821
   183
		printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
slouken@821
   184
	} else {
slouken@821
   185
		printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
slouken@821
   186
	}
slouken@821
   187
slouken@886
   188
        /* clear the screen after cc blit test */
slouken@886
   189
        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
slouken@886
   190
	SDL_Flip(screen);
slouken@886
   191
slouken@886
   192
	while ( SDL_PollEvent(&event) ) {
slouken@886
   193
		if ( event.type == SDL_KEYDOWN )
slouken@886
   194
			return 0;
slouken@886
   195
	}
slouken@886
   196
slouken@821
   197
        /* run the generic blit test */
slouken@479
   198
	tmp = bmp;
slouken@479
   199
	bmp = SDL_DisplayFormat(bmp);
slouken@479
   200
	SDL_FreeSurface(tmp);
slouken@479
   201
	if ( ! bmp ) {
slouken@479
   202
		printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
slouken@482
   203
		return 0;
slouken@479
   204
	}
slouken@479
   205
	printf("Running display format blit test: %dx%d at %d bpp, flags: ",
slouken@479
   206
		bmp->w, bmp->h, bmp->format->BitsPerPixel);
slouken@479
   207
	PrintFlags(bmp->flags);
slouken@479
   208
	printf("\n");
slouken@479
   209
	then = SDL_GetTicks();
slouken@480
   210
	frames = RunBlitTests(screen, bmp, NUM_BLITS);
slouken@479
   211
	now = SDL_GetTicks();
slouken@480
   212
	seconds = (float)(now - then) / 1000.0f;
slouken@480
   213
	if ( seconds > 0.0f ) {
slouken@480
   214
		printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
slouken@480
   215
	} else {
slouken@480
   216
		printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
slouken@479
   217
	}
slouken@821
   218
slouken@886
   219
        /* clear the screen after blit test */
slouken@886
   220
        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
slouken@886
   221
	SDL_Flip(screen);
slouken@886
   222
slouken@886
   223
	while ( SDL_PollEvent(&event) ) {
slouken@886
   224
		if ( event.type == SDL_KEYDOWN )
slouken@886
   225
			return 0;
slouken@886
   226
	}
slouken@886
   227
slouken@821
   228
        /* run the colorkeyed blit test */
slouken@821
   229
	tmp = bmpcc;
slouken@821
   230
	bmpcc = SDL_DisplayFormat(bmpcc);
slouken@821
   231
	SDL_FreeSurface(tmp);
slouken@821
   232
	if ( ! bmpcc ) {
slouken@821
   233
		printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
slouken@821
   234
		return 0;
slouken@821
   235
	}
slouken@821
   236
	printf("Running display format cc blit test: %dx%d at %d bpp, flags: ",
slouken@821
   237
		bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
slouken@821
   238
	PrintFlags(bmpcc->flags);
slouken@821
   239
	printf("\n");
slouken@821
   240
	then = SDL_GetTicks();
slouken@821
   241
	frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
slouken@821
   242
	now = SDL_GetTicks();
slouken@821
   243
	seconds = (float)(now - then) / 1000.0f;
slouken@821
   244
	if ( seconds > 0.0f ) {
slouken@821
   245
		printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
slouken@821
   246
	} else {
slouken@821
   247
		printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
slouken@821
   248
	}
slouken@821
   249
slouken@886
   250
        /* clear the screen after cc blit test */
slouken@886
   251
        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
slouken@886
   252
	SDL_Flip(screen);
slouken@886
   253
slouken@886
   254
	while ( SDL_PollEvent(&event) ) {
slouken@886
   255
		if ( event.type == SDL_KEYDOWN )
slouken@886
   256
			return 0;
slouken@886
   257
	}
slouken@886
   258
slouken@886
   259
        /* run the alpha blit test only if screen bpp>8 */
slouken@886
   260
        if (bmp->format->BitsPerPixel>8)
slouken@886
   261
        {
slouken@886
   262
		SDL_FreeSurface(bmp);
slouken@886
   263
                bmp = SDL_LoadBMP("sample.bmp");
slouken@886
   264
		SDL_SetAlpha(bmp, SDL_SRCALPHA, 85); /* 85 - 33% alpha */
slouken@886
   265
		tmp = bmp;
slouken@886
   266
		bmp = SDL_DisplayFormat(bmp);
slouken@886
   267
		SDL_FreeSurface(tmp);
slouken@886
   268
		if ( ! bmp ) {
slouken@886
   269
			printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
slouken@886
   270
			return 0;
slouken@886
   271
		}
slouken@886
   272
		printf("Running display format alpha blit test: %dx%d at %d bpp, flags: ",
slouken@886
   273
			bmp->w, bmp->h, bmp->format->BitsPerPixel);
slouken@886
   274
		PrintFlags(bmp->flags);
slouken@886
   275
		printf("\n");
slouken@886
   276
		then = SDL_GetTicks();
slouken@886
   277
		frames = RunBlitTests(screen, bmp, NUM_BLITS);
slouken@886
   278
		now = SDL_GetTicks();
slouken@886
   279
		seconds = (float)(now - then) / 1000.0f;
slouken@886
   280
		if ( seconds > 0.0f ) {
slouken@886
   281
			printf("%d alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
slouken@886
   282
		} else {
slouken@886
   283
			printf("%d alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
slouken@886
   284
		}
slouken@886
   285
	}
slouken@886
   286
slouken@886
   287
        /* clear the screen after alpha blit test */
slouken@886
   288
        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
slouken@886
   289
	SDL_Flip(screen);
slouken@886
   290
slouken@886
   291
	while ( SDL_PollEvent(&event) ) {
slouken@886
   292
		if ( event.type == SDL_KEYDOWN )
slouken@886
   293
			return 0;
slouken@886
   294
	}
slouken@886
   295
slouken@886
   296
        /* run the cc+alpha blit test only if screen bpp>8 */
slouken@886
   297
        if (bmp->format->BitsPerPixel>8)
slouken@886
   298
        {
slouken@886
   299
		SDL_FreeSurface(bmpcc);
slouken@886
   300
                bmpcc = SDL_LoadBMP("sample.bmp");
slouken@886
   301
		SDL_SetAlpha(bmpcc, SDL_SRCALPHA, 85); /* 85 - 33% alpha */
slouken@886
   302
                SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels);
slouken@886
   303
		tmp = bmpcc;
slouken@886
   304
		bmpcc = SDL_DisplayFormat(bmpcc);
slouken@886
   305
		SDL_FreeSurface(tmp);
slouken@886
   306
		if ( ! bmpcc ) {
slouken@886
   307
			printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
slouken@886
   308
			return 0;
slouken@886
   309
		}
slouken@886
   310
		printf("Running display format cc+alpha blit test: %dx%d at %d bpp, flags: ",
slouken@886
   311
			bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
slouken@886
   312
		PrintFlags(bmpcc->flags);
slouken@886
   313
		printf("\n");
slouken@886
   314
		then = SDL_GetTicks();
slouken@886
   315
		frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
slouken@886
   316
		now = SDL_GetTicks();
slouken@886
   317
		seconds = (float)(now - then) / 1000.0f;
slouken@886
   318
		if ( seconds > 0.0f ) {
slouken@886
   319
			printf("%d cc+alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
slouken@886
   320
		} else {
slouken@886
   321
			printf("%d cc+alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
slouken@886
   322
		}
slouken@886
   323
	}
slouken@886
   324
slouken@821
   325
	SDL_FreeSurface(bmpcc);
slouken@479
   326
	SDL_FreeSurface(bmp);
slouken@480
   327
slouken@480
   328
	while ( SDL_PollEvent(&event) ) {
slouken@480
   329
		if ( event.type == SDL_KEYDOWN )
slouken@480
   330
			return 0;
slouken@480
   331
	}
slouken@480
   332
	return 1;
slouken@479
   333
}
slouken@479
   334
slouken@479
   335
void RunVideoTests()
slouken@479
   336
{
slouken@479
   337
	static const struct {
slouken@479
   338
		int w, h, bpp;
slouken@479
   339
	} mode_list[] = {
slouken@479
   340
		{ 640, 480, 8 }, { 640, 480, 16 }, { 640, 480, 32 },
slouken@479
   341
		{ 800, 600, 8 }, { 800, 600, 16 }, { 800, 600, 32 },
slouken@479
   342
		{ 1024, 768, 8 }, { 1024, 768, 16 }, { 1024, 768, 32 }
slouken@479
   343
	};
slouken@479
   344
	static const Uint32 flags[] = {
slouken@479
   345
		(SDL_SWSURFACE),
slouken@479
   346
		(SDL_SWSURFACE | SDL_FULLSCREEN),
slouken@479
   347
		(SDL_HWSURFACE | SDL_FULLSCREEN),
slouken@479
   348
		(SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF)
slouken@479
   349
	};
slouken@479
   350
	int i, j;
slouken@479
   351
	SDL_Surface *screen;
slouken@479
   352
slouken@479
   353
	/* Test out several different video mode combinations */
slouken@480
   354
	SDL_WM_SetCaption("SDL Video Benchmark", "vidtest");
slouken@480
   355
	SDL_ShowCursor(0);
slouken@479
   356
	for ( i = 0; i < SDL_TABLESIZE(mode_list); ++i ) {
slouken@479
   357
		for ( j = 0; j < SDL_TABLESIZE(flags); ++j ) {
slouken@479
   358
			printf("===================================\n");
slouken@479
   359
			printf("Setting video mode: %dx%d at %d bpp, flags: ",
slouken@479
   360
			                          mode_list[i].w,
slouken@479
   361
			                          mode_list[i].h,
slouken@479
   362
			                          mode_list[i].bpp);
slouken@479
   363
			PrintFlags(flags[j]);
slouken@479
   364
			printf("\n");
slouken@479
   365
			screen = SDL_SetVideoMode(mode_list[i].w,
slouken@479
   366
			                          mode_list[i].h,
slouken@479
   367
			                          mode_list[i].bpp,
slouken@479
   368
			                          flags[j]);
slouken@479
   369
			if ( ! screen ) {
slouken@479
   370
				printf("Setting video mode failed: %s\n", SDL_GetError());
slouken@479
   371
				continue;
slouken@479
   372
			}
slouken@479
   373
			if ( (screen->flags & FLAG_MASK) != flags[j] ) {
slouken@479
   374
				printf("Flags didn't match: ");
slouken@479
   375
				PrintFlags(screen->flags);
slouken@479
   376
				printf("\n");
slouken@479
   377
				continue;
slouken@479
   378
			}
slouken@480
   379
			if ( ! RunModeTests(screen) ) {
slouken@480
   380
				return;
slouken@480
   381
			}
slouken@479
   382
		}
slouken@479
   383
	}
slouken@479
   384
}
slouken@479
   385
slouken@0
   386
int main(int argc, char *argv[])
slouken@0
   387
{
slouken@0
   388
	const SDL_VideoInfo *info;
slouken@0
   389
	int i;
slouken@0
   390
	SDL_Rect **modes;
slouken@480
   391
	char driver[128];
slouken@0
   392
slouken@0
   393
	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
slouken@0
   394
		fprintf(stderr,
slouken@0
   395
			"Couldn't initialize SDL: %s\n", SDL_GetError());
slouken@0
   396
		exit(1);
slouken@0
   397
	}
slouken@480
   398
	if ( SDL_VideoDriverName(driver, sizeof(driver)) ) {
slouken@480
   399
		printf("Video driver: %s\n", driver);
slouken@480
   400
	}
slouken@0
   401
	info = SDL_GetVideoInfo();
slouken@0
   402
	printf(
slouken@0
   403
"Current display: %d bits-per-pixel\n",info->vfmt->BitsPerPixel);
slouken@0
   404
	if ( info->vfmt->palette == NULL ) {
slouken@0
   405
		printf("	Red Mask = 0x%.8x\n", info->vfmt->Rmask);
slouken@0
   406
		printf("	Green Mask = 0x%.8x\n", info->vfmt->Gmask);
slouken@0
   407
		printf("	Blue Mask = 0x%.8x\n", info->vfmt->Bmask);
slouken@0
   408
	}
slouken@0
   409
	/* Print available fullscreen video modes */
slouken@0
   410
	modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
slouken@0
   411
	if ( modes == (SDL_Rect **)0 ) {
slouken@0
   412
		printf("No available fullscreen video modes\n");
slouken@0
   413
	} else
slouken@0
   414
	if ( modes == (SDL_Rect **)-1 ) {
slouken@0
   415
		printf("No special fullscreen video modes\n");
slouken@0
   416
	} else {
slouken@0
   417
		printf("Fullscreen video modes:\n");
slouken@0
   418
		for ( i=0; modes[i]; ++i ) {
slouken@266
   419
			printf("\t%dx%dx%d\n", modes[i]->w, modes[i]->h, info->vfmt->BitsPerPixel);
slouken@0
   420
		}
slouken@0
   421
	}
slouken@0
   422
	if ( info->wm_available ) {
slouken@0
   423
		printf("A window manager is available\n");
slouken@0
   424
	}
slouken@0
   425
	if ( info->hw_available ) {
slouken@0
   426
		printf("Hardware surfaces are available (%dK video memory)\n",
slouken@0
   427
			info->video_mem);
slouken@0
   428
	}
slouken@0
   429
	if ( info->blit_hw ) {
slouken@0
   430
		printf(
slouken@0
   431
"Copy blits between hardware surfaces are accelerated\n");
slouken@0
   432
	}
slouken@0
   433
	if ( info->blit_hw_CC ) {
slouken@0
   434
		printf(
slouken@0
   435
"Colorkey blits between hardware surfaces are accelerated\n");
slouken@0
   436
	}
slouken@0
   437
	if ( info->blit_hw_A ) {
slouken@0
   438
		printf(
slouken@0
   439
"Alpha blits between hardware surfaces are accelerated\n");
slouken@0
   440
	}
slouken@0
   441
	if ( info->blit_sw ) {
slouken@0
   442
		printf(
slouken@0
   443
"Copy blits from software surfaces to hardware surfaces are accelerated\n");
slouken@0
   444
	}
slouken@0
   445
	if ( info->blit_sw_CC ) {
slouken@0
   446
		printf(
slouken@0
   447
"Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
slouken@0
   448
	}
slouken@0
   449
	if ( info->blit_sw_A ) {
slouken@0
   450
		printf(
slouken@0
   451
"Alpha blits from software surfaces to hardware surfaces are accelerated\n");
slouken@0
   452
	}
slouken@0
   453
	if ( info->blit_fill ) {
slouken@0
   454
		printf(
slouken@0
   455
"Color fills on hardware surfaces are accelerated\n");
slouken@0
   456
	}
slouken@479
   457
slouken@479
   458
	if ( argv[1] && (strcmp(argv[1], "-benchmark") == 0) ) {
slouken@479
   459
		RunVideoTests();
slouken@479
   460
	}
slouken@479
   461
slouken@0
   462
	SDL_Quit();
slouken@0
   463
	return(0);
slouken@0
   464
}