19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Simple program -- figure out what kind of video display we have */ 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h> 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h> 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h> 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <string.h> 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL.h" 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define NUM_BLITS 10 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define NUM_UPDATES 500 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define FLAG_MASK (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | \ 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCEL | \ 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_RLEACCELOK) 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid PrintFlags(Uint32 flags) 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("0x%8.8x", (flags & FLAG_MASK)); 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( flags & SDL_HWSURFACE ) { 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" SDL_HWSURFACE"); 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" SDL_SWSURFACE"); 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( flags & SDL_FULLSCREEN ) { 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" | SDL_FULLSCREEN"); 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( flags & SDL_DOUBLEBUF ) { 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" | SDL_DOUBLEBUF"); 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( flags & SDL_SRCCOLORKEY ) { 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" | SDL_SRCCOLORKEY"); 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( flags & SDL_SRCALPHA ) { 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" | SDL_SRCALPHA"); 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( flags & SDL_RLEACCEL ) { 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" | SDL_RLEACCEL"); 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( flags & SDL_RLEACCELOK ) { 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" | SDL_RLEACCELOK"); 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount) 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i, j; 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int maxx; 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int maxy; 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect dst; 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall maxx = (int)screen->w - bmp->w + 1; 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall maxy = (int)screen->h - bmp->h + 1; 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i = 0; i < NUM_UPDATES; ++i ) { 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( j = 0; j < blitcount; ++j ) { 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( maxx ) { 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.x = rand() % maxx; 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.x = 0; 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( maxy ) { 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.y = rand() % maxy; 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.y = 0; 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.w = bmp->w; 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.h = bmp->h; 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_BlitSurface(bmp, NULL, screen, &dst); 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return i; 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint RunModeTests(SDL_Surface *screen) 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 then, now; 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 frames; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall float seconds; 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 r, g, b; 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *bmp, *bmpcc, *tmp; 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Event event; 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* First test fills and screen update speed */ 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Running color fill and fullscreen update test\n"); 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then = SDL_GetTicks(); 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = 0; 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i = 0; i < 256; ++i ) { 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall r = i; 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall g = 0; 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall b = 0; 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b)); 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++frames; 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i = 0; i < 256; ++i ) { 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall r = 0; 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall g = i; 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall b = 0; 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b)); 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++frames; 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i = 0; i < 256; ++i ) { 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall r = 0; 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall g = 0; 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall b = i; 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b)); 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++frames; 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall now = SDL_GetTicks(); 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall seconds = (float)(now - then) / 1000.0f; 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( seconds > 0.0f ) { 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames, seconds, (float)frames / seconds); 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d fills and flips in zero seconds!n", frames); 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* clear the screen after fill test */ 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* run the generic blit test */ 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmp = SDL_LoadBMP("sample.bmp"); 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! bmp ) { 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Running freshly loaded blit test: %dx%d at %d bpp, flags: ", 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmp->w, bmp->h, bmp->format->BitsPerPixel); 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(bmp->flags); 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then = SDL_GetTicks(); 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = RunBlitTests(screen, bmp, NUM_BLITS); 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall now = SDL_GetTicks(); 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall seconds = (float)(now - then) / 1000.0f; 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( seconds > 0.0f ) { 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* clear the screen after blit test */ 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* run the colorkeyed blit test */ 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmpcc = SDL_LoadBMP("sample.bmp"); 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! bmpcc ) { 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Running freshly loaded cc blit test: %dx%d at %d bpp, flags: ", 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels); 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(bmpcc->flags); 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then = SDL_GetTicks(); 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = RunBlitTests(screen, bmpcc, NUM_BLITS); 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall now = SDL_GetTicks(); 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall seconds = (float)(now - then) / 1000.0f; 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( seconds > 0.0f ) { 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* clear the screen after cc blit test */ 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* run the generic blit test */ 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tmp = bmp; 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmp = SDL_DisplayFormat(bmp); 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(tmp); 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! bmp ) { 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Running display format blit test: %dx%d at %d bpp, flags: ", 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmp->w, bmp->h, bmp->format->BitsPerPixel); 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(bmp->flags); 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then = SDL_GetTicks(); 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = RunBlitTests(screen, bmp, NUM_BLITS); 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall now = SDL_GetTicks(); 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall seconds = (float)(now - then) / 1000.0f; 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( seconds > 0.0f ) { 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* clear the screen after blit test */ 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* run the colorkeyed blit test */ 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tmp = bmpcc; 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmpcc = SDL_DisplayFormat(bmpcc); 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(tmp); 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! bmpcc ) { 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Running display format cc blit test: %dx%d at %d bpp, flags: ", 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(bmpcc->flags); 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then = SDL_GetTicks(); 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = RunBlitTests(screen, bmpcc, NUM_BLITS); 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall now = SDL_GetTicks(); 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall seconds = (float)(now - then) / 1000.0f; 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( seconds > 0.0f ) { 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* clear the screen after cc blit test */ 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* run the alpha blit test only if screen bpp>8 */ 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bmp->format->BitsPerPixel>8) 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(bmp); 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmp = SDL_LoadBMP("sample.bmp"); 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetAlpha(bmp, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tmp = bmp; 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmp = SDL_DisplayFormat(bmp); 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(tmp); 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! bmp ) { 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Running display format alpha blit test: %dx%d at %d bpp, flags: ", 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmp->w, bmp->h, bmp->format->BitsPerPixel); 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(bmp->flags); 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then = SDL_GetTicks(); 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = RunBlitTests(screen, bmp, NUM_BLITS); 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall now = SDL_GetTicks(); 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall seconds = (float)(now - then) / 1000.0f; 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( seconds > 0.0f ) { 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* clear the screen after alpha blit test */ 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Flip(screen); 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* run the cc+alpha blit test only if screen bpp>8 */ 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bmp->format->BitsPerPixel>8) 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(bmpcc); 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmpcc = SDL_LoadBMP("sample.bmp"); 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetAlpha(bmpcc, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels); 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tmp = bmpcc; 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmpcc = SDL_DisplayFormat(bmpcc); 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(tmp); 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! bmpcc ) { 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Running display format cc+alpha blit test: %dx%d at %d bpp, flags: ", 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(bmpcc->flags); 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then = SDL_GetTicks(); 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = RunBlitTests(screen, bmpcc, NUM_BLITS); 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall now = SDL_GetTicks(); 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall seconds = (float)(now - then) / 1000.0f; 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( seconds > 0.0f ) { 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d cc+alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%d cc+alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(bmpcc); 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(bmp); 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( SDL_PollEvent(&event) ) { 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event.type == SDL_KEYDOWN ) 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid RunVideoTests() 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static const struct { 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int w, h, bpp; 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } mode_list[] = { 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 640, 480, 8 }, { 640, 480, 16 }, { 640, 480, 32 }, 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 800, 600, 8 }, { 800, 600, 16 }, { 800, 600, 32 }, 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1024, 768, 8 }, { 1024, 768, 16 }, { 1024, 768, 32 } 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static const Uint32 flags[] = { 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (SDL_SWSURFACE), 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (SDL_SWSURFACE | SDL_FULLSCREEN), 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (SDL_HWSURFACE | SDL_FULLSCREEN), 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF) 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i, j; 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *screen; 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Test out several different video mode combinations */ 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_WM_SetCaption("SDL Video Benchmark", "vidtest"); 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ShowCursor(0); 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i = 0; i < SDL_TABLESIZE(mode_list); ++i ) { 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( j = 0; j < SDL_TABLESIZE(flags); ++j ) { 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("===================================\n"); 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Setting video mode: %dx%d at %d bpp, flags: ", 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list[i].w, 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list[i].h, 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list[i].bpp); 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(flags[j]); 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen = SDL_SetVideoMode(mode_list[i].w, 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list[i].h, 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list[i].bpp, 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall flags[j]); 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! screen ) { 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Setting video mode failed: %s\n", SDL_GetError()); 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (screen->flags & FLAG_MASK) != flags[j] ) { 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Flags didn't match: "); 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PrintFlags(screen->flags); 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! RunModeTests(screen) ) { 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint main(int argc, char *argv[]) 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const SDL_VideoInfo *info; 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect **modes; 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char driver[128]; 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall "Couldn't initialize SDL: %s\n", SDL_GetError()); 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall exit(1); 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_VideoDriverName(driver, sizeof(driver)) ) { 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Video driver: %s\n", driver); 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info = SDL_GetVideoInfo(); 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Current display: %dx%d, %d bits-per-pixel\n", 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->current_w, info->current_h, info->vfmt->BitsPerPixel); 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->vfmt->palette == NULL ) { 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" Red Mask = 0x%.8x\n", info->vfmt->Rmask); 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" Green Mask = 0x%.8x\n", info->vfmt->Gmask); 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf(" Blue Mask = 0x%.8x\n", info->vfmt->Bmask); 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Print available fullscreen video modes */ 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modes = SDL_ListModes(NULL, SDL_FULLSCREEN); 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( modes == (SDL_Rect **)0 ) { 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("No available fullscreen video modes\n"); 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( modes == (SDL_Rect **)-1 ) { 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("No special fullscreen video modes\n"); 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Fullscreen video modes:\n"); 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; modes[i]; ++i ) { 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\t%dx%dx%d\n", modes[i]->w, modes[i]->h, info->vfmt->BitsPerPixel); 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->wm_available ) { 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("A window manager is available\n"); 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->hw_available ) { 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Hardware surfaces are available (%dK video memory)\n", 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall info->video_mem); 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->blit_hw ) { 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Copy blits between hardware surfaces are accelerated\n"); 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->blit_hw_CC ) { 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Colorkey blits between hardware surfaces are accelerated\n"); 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->blit_hw_A ) { 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Alpha blits between hardware surfaces are accelerated\n"); 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->blit_sw ) { 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Copy blits from software surfaces to hardware surfaces are accelerated\n"); 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->blit_sw_CC ) { 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Colorkey blits from software surfaces to hardware surfaces are accelerated\n"); 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->blit_sw_A ) { 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Alpha blits from software surfaces to hardware surfaces are accelerated\n"); 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( info->blit_fill ) { 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Color fills on hardware surfaces are accelerated\n"); 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( argv[1] && (strcmp(argv[1], "-benchmark") == 0) ) { 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RunVideoTests(); 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Quit(); 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 466