Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
531 lines (489 loc) · 16 KB

testvidinfo.c

File metadata and controls

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