annotate test/testvidinfo.c @ 4046:3a9e60224efe SDL-1.2

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