annotate test/testvidinfo.c @ 821:30168104389f

Date: Sat, 14 Feb 2004 14:52:40 +0200 From: "Mike Gorchak" Subject: Batch of the QNX6 fixes for the SDL 1. Updated readme.QNX 2. Fixed crashes during intensive window updating under fast machines (got over 200 rectangles for update). 3. Fixed double-buffered fullscreen modes, now it works as needed. 4. Fixed Photon detection algorithm. 5. Fixed HWSURFACE update function. 6. Added SDL_PHOTON_FULLSCREEN_REFRESH environment variable support for control refresh rates under Photon. 7. Added 640x400 fullscreen mode emulation via 640x480 (if videodriver not supports original 640x400 mode of course) shifted by 40 vertical pixels from begin, to center it. It's needed for some old DOS games which ran in doubled 320x200 mode. 8. Added available video ram amount support. 8. Added hardware surface allocation/deallocation support if current videomode and videodriver supports it. 9. Added hardware filling support. 10. Added hardware blits support (simple and colorkeyed). And I've added to testvidinfo test color-keyed blits benchmark (maybe need to add alpha blits benchmark too ?). Currently Photon not supporting any alpha hardware blittings (all drivers lack of alpha blitting code support, only software alpha blitting exist in photon, which is hundreds times slowest than the SDL's one). So I've not added the alpha support. I suppose new QNX 6.3 will have the hardware alpha support, so when it will be done, I'll add alpha support.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 14 Feb 2004 20:22:21 +0000
parents 1b8ea19e9ee4
children 05c551e5bc64
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
479
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
14 #define FLAG_MASK (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
15
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
16 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
17 {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
18 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
19 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
20 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
21 } else {
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_SWSURFACE");
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
23 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
24 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
25 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
26 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
27 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
28 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
29 }
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
30 if ( flags & SDL_SRCCOLORKEY ) {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
31 printf(" | SDL_SRCCOLORKEY");
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
32 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
33 if ( flags & SDL_RLEACCEL ) {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
34 printf(" | SDL_RLEACCEL");
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
35 }
479
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
36 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
37
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
38 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
39 {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
40 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
41 int maxx;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
42 int maxy;
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
43 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
44
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
45 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
46 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
47 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
48 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
49 if ( maxx ) {
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
50 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
51 } else {
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
52 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
53 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
54 if ( maxy ) {
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
55 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
56 } else {
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
57 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
58 }
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
59 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
60 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
61 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
62 }
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
63 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
64 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
65
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
66 return i;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
67 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
68
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
69 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
70 {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
71 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
72 Uint32 frames;
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
73 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
74 int i;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
75 Uint8 r, g, b;
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
76 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
77 SDL_Event event;
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
78
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
79 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
80 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
81 return 0;
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
82 }
479
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
83
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
84 /* 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
85 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
86 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
87 frames = 0;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
88 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
89 r = i;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
90 g = 0;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
91 b = 0;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
92 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
93 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
94 ++frames;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
95 }
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 = 0;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
98 g = i;
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 = 0;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
107 b = i;
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 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
113 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
114 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
115 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
116 } else {
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
117 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
118 }
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
119
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
120 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
121 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
122 return 0;
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
123 }
479
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
124
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
125 /* 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
126 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
127 if ( ! bmp ) {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
128 printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
482
6417071ba2e5 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 480
diff changeset
129 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
130 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
131 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
132 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
133 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
134 printf("\n");
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
135 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
136 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
137 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
138 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
139 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
140 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
141 } else {
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
142 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
143 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
144
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
145 /* run the colorkeyed blit test */
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
146 bmpcc = SDL_LoadBMP("sample.bmp");
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
147 if ( ! bmpcc ) {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
148 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
149 return 0;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
150 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
151 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
152 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
153 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
154
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
155 PrintFlags(bmpcc->flags);
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
156 printf("\n");
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
157 then = SDL_GetTicks();
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
158 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
159 now = SDL_GetTicks();
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
160 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
161 if ( seconds > 0.0f ) {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
162 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
163 } else {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
164 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
165 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
166
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
167 /* 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
168 tmp = bmp;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
169 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
170 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
171 if ( ! bmp ) {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
172 printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
482
6417071ba2e5 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 480
diff changeset
173 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
174 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
175 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
176 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
177 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
178 printf("\n");
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
179 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
180 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
181 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
182 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
183 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
184 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
185 } else {
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
186 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
187 }
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
188
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
189 /* run the colorkeyed blit test */
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
190 tmp = bmpcc;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
191 bmpcc = SDL_DisplayFormat(bmpcc);
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
192 SDL_FreeSurface(tmp);
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
193 if ( ! bmpcc ) {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
194 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
195 return 0;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
196 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
197 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
198 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
199 PrintFlags(bmpcc->flags);
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
200 printf("\n");
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
201 then = SDL_GetTicks();
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
202 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
203 now = SDL_GetTicks();
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
204 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
205 if ( seconds > 0.0f ) {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
206 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
207 } else {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
208 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
209 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
210
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 524
diff changeset
211 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
212 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
213
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
214 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
215 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
216 return 0;
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
217 }
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
218 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
219 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
220
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
221 void RunVideoTests()
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
222 {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
223 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
224 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
225 } mode_list[] = {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
226 { 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
227 { 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
228 { 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
229 };
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
230 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
231 (SDL_SWSURFACE),
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
232 (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
233 (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
234 (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
235 };
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
236 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
237 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
238
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
239 /* 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
240 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
241 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
242 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
243 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
244 printf("===================================\n");
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
245 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
246 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
247 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
248 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
249 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
250 printf("\n");
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
251 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
252 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
253 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
254 flags[j]);
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
255 if ( ! screen ) {
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
256 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
257 continue;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
258 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
259 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
260 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
261 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
262 printf("\n");
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
263 continue;
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
264 }
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
265 if ( ! RunModeTests(screen) ) {
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
266 return;
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
267 }
479
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
268 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
269 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
270 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
271
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 int main(int argc, char *argv[])
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274 const SDL_VideoInfo *info;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 int i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 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
277 char driver[128];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 fprintf(stderr,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 "Couldn't initialize SDL: %s\n", SDL_GetError());
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 exit(1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 }
480
92596bfe8446 Fixed some bugs and added some features to the -benchmark facility
Sam Lantinga <slouken@libsdl.org>
parents: 479
diff changeset
284 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
285 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
286 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 info = SDL_GetVideoInfo();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 "Current display: %d bits-per-pixel\n",info->vfmt->BitsPerPixel);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 if ( info->vfmt->palette == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 printf(" Red Mask = 0x%.8x\n", info->vfmt->Rmask);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 printf(" Green Mask = 0x%.8x\n", info->vfmt->Gmask);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 printf(" Blue Mask = 0x%.8x\n", info->vfmt->Bmask);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 /* Print available fullscreen video modes */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296 modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 if ( modes == (SDL_Rect **)0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 printf("No available fullscreen video modes\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 } else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 if ( modes == (SDL_Rect **)-1 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 printf("No special fullscreen video modes\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 printf("Fullscreen video modes:\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 for ( i=0; modes[i]; ++i ) {
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
305 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
306 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308 if ( info->wm_available ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309 printf("A window manager is available\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 if ( info->hw_available ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 printf("Hardware surfaces are available (%dK video memory)\n",
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 info->video_mem);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315 if ( info->blit_hw ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
316 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
317 "Copy blits between hardware surfaces are accelerated\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
319 if ( info->blit_hw_CC ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
321 "Colorkey blits between hardware surfaces are accelerated\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
322 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
323 if ( info->blit_hw_A ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 "Alpha blits between hardware surfaces are accelerated\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327 if ( info->blit_sw ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329 "Copy blits from software surfaces to hardware surfaces are accelerated\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331 if ( info->blit_sw_CC ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333 "Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
335 if ( info->blit_sw_A ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337 "Alpha blits from software surfaces to hardware surfaces are accelerated\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339 if ( info->blit_fill ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340 printf(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 "Color fills on hardware surfaces are accelerated\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
342 }
479
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 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
345 RunVideoTests();
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
346 }
c0a1744bc2cf Added a -benchmark flag for testing the speeds of various video modes
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
347
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
348 SDL_Quit();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
349 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350 }