Mercurial > sdl-ios-xcode
annotate test/automated/surface/surface.c @ 3741:808fad5fb593 gsoc2009_unit_tests
Added command line options.
Added verbosity levels.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 02 Aug 2009 18:58:03 +0000 |
parents | e451d5d288e9 |
children |
rev | line source |
---|---|
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1 /** |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
2 * Automated SDL_Surface test. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
3 * |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
4 * Written by Edgar Simo "bobbens" |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
5 * |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
6 * Released under Public Domain. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
7 */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
8 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
9 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
10 #include "SDL.h" |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
11 #include "SDL_surface.h" |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
12 #include "SDL_video.h" |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
13 #include "SDL_at.h" |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
14 |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
15 #include "common/common.h" |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
16 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
17 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
18 /* |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
19 * Pull in images for testcases. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
20 */ |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
21 #include "common/images.h" |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
22 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
23 |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
24 /* |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
25 * Prototypes. |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
26 */ |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
27 /* Testcases. */ |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
28 static void surface_testLoad( SDL_Surface *testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
29 static void surface_testPrimitives( SDL_Surface *testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
30 static void surface_testPrimitivesBlend( SDL_Surface *testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
31 static void surface_testBlit( SDL_Surface *testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
32 static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, int mode ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
33 static void surface_testBlitBlend( SDL_Surface *testsur ); |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
34 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
35 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
36 /** |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
37 * @brief Tests sprite loading. |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
38 */ |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
39 static void surface_testLoad( SDL_Surface *testsur ) |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
40 { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
41 int ret; |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
42 SDL_Surface *face, *rface; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
43 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
44 SDL_ATbegin( "Load Test" ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
45 |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
46 /* Clear surface. */ |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
47 ret = SDL_FillRect( testsur, NULL, |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
48 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
49 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
50 return; |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
51 |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
52 /* Create the blit surface. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
53 face = SDL_LoadBMP("../icon.bmp"); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
54 if (SDL_ATassert( "SDL_CreateLoadBmp", face != NULL)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
55 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
56 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
57 /* Set transparent pixel as the pixel at (0,0) */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
58 if (face->format->palette) { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
59 ret = SDL_SetColorKey(face, (SDL_SRCCOLORKEY | SDL_RLEACCEL), |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
60 *(Uint8 *) face->pixels); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
61 if (SDL_ATassert( "SDL_SetColorKey", ret == 0)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
62 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
63 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
64 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
65 /* Convert to 32 bit to compare. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
66 rface = SDL_ConvertSurface( face, testsur->format, 0 ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
67 if (SDL_ATassert( "SDL_ConvertSurface", rface != NULL)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
68 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
69 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
70 /* See if it's the same. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
71 if (SDL_ATassert( "Primitives output not the same.", |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
72 surface_compare( rface, &img_face)==0 )) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
73 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
74 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
75 /* Clean up. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
76 SDL_FreeSurface( rface ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
77 SDL_FreeSurface( face ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
78 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
79 SDL_ATend(); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
80 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
81 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
82 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
83 /** |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
84 * @brief Tests the SDL primitives for rendering. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
85 */ |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
86 static void surface_testPrimitives( SDL_Surface *testsur ) |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
87 { |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
88 int ret; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
89 int x, y; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
90 SDL_Rect rect; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
91 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
92 SDL_ATbegin( "Primitives Test" ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
93 |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
94 /* Clear surface. */ |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
95 ret = SDL_FillRect( testsur, NULL, |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
96 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
97 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
98 return; |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
99 |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
100 /* Create the surface. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
101 testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
102 RMASK, GMASK, BMASK, AMASK ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
103 if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
104 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
105 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
106 /* Draw a rectangle. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
107 rect.x = 40; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
108 rect.y = 0; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
109 rect.w = 40; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
110 rect.h = 80; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
111 ret = SDL_FillRect( testsur, &rect, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
112 SDL_MapRGB( testsur->format, 13, 73, 200 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
113 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
114 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
115 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
116 /* Draw a rectangle. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
117 rect.x = 10; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
118 rect.y = 10; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
119 rect.w = 60; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
120 rect.h = 40; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
121 ret = SDL_FillRect( testsur, &rect, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
122 SDL_MapRGB( testsur->format, 200, 0, 100 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
123 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
124 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
125 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
126 /* Draw some points like so: |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
127 * X.X.X.X.. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
128 * .X.X.X.X. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
129 * X.X.X.X.. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
130 for (y=0; y<3; y++) { |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
131 x = y % 2; |
3729 | 132 for (; x<80; x+=2) { |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
133 ret = SDL_DrawPoint( testsur, x, y, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
134 SDL_MapRGB( testsur->format, x*y, x*y/2, x*y/3 ) ); |
3729 | 135 if (SDL_ATassert( "SDL_DrawPoint", ret == 0)) |
136 return; | |
137 } | |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
138 } |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
139 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
140 /* Draw some lines. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
141 ret = SDL_DrawLine( testsur, 0, 30, 80, 30, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
142 SDL_MapRGB( testsur->format, 0, 255, 0 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
143 if (SDL_ATassert( "SDL_DrawLine", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
144 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
145 ret = SDL_DrawLine( testsur, 40, 30, 40, 60, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
146 SDL_MapRGB( testsur->format, 55, 55, 5 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
147 if (SDL_ATassert( "SDL_DrawLine", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
148 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
149 ret = SDL_DrawLine( testsur, 0, 60, 80, 0, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
150 SDL_MapRGB( testsur->format, 5, 105, 105 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
151 if (SDL_ATassert( "SDL_DrawLine", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
152 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
153 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
154 /* See if it's the same. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
155 if (SDL_ATassert( "Primitives output not the same.", |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
156 surface_compare( testsur, &img_primitives )==0 )) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
157 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
158 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
159 SDL_ATend(); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
160 } |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
161 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
162 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
163 /** |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
164 * @brief Tests the SDL primitives with alpha for rendering. |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
165 */ |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
166 static void surface_testPrimitivesBlend( SDL_Surface *testsur ) |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
167 { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
168 int ret; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
169 int i, j; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
170 SDL_Rect rect; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
171 |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
172 SDL_ATbegin( "Primitives Blend Test" ); |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
173 |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
174 /* Clear surface. */ |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
175 ret = SDL_FillRect( testsur, NULL, |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
176 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
177 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
178 return; |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
179 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
180 /* Create some rectangles for each blend mode. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
181 ret = SDL_BlendRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
182 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
183 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
184 rect.x = 10; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
185 rect.y = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
186 rect.w = 40; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
187 rect.h = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
188 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
189 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
190 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
191 rect.x = 30; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
192 rect.y = 40; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
193 rect.w = 45; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
194 rect.h = 15; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
195 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
196 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
197 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
198 rect.x = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
199 rect.y = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
200 rect.w = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
201 rect.h = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
202 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
203 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
204 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
205 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
206 /* Draw blended lines, lines for everyone. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
207 for (i=0; i<testsur->w; i+=2) { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
208 ret = SDL_BlendLine( testsur, 0, 0, i, 59, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
209 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
210 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, |
3722
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
211 60+2*i, 240-2*i, 50, 3*i ); |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
212 if (SDL_ATassert( "SDL_BlendLine", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
213 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
214 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
215 for (i=0; i<testsur->h; i+=2) { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
216 ret = SDL_BlendLine( testsur, 0, 0, 79, i, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
217 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
218 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, |
3722
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
219 60+2*i, 240-2*i, 50, 3*i ); |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
220 if (SDL_ATassert( "SDL_BlendLine", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
221 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
222 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
223 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
224 /* Draw points. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
225 for (j=0; j<testsur->h; j+=3) { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
226 for (i=0; i<testsur->w; i+=3) { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
227 ret = SDL_BlendPoint( testsur, i, j, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
228 ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
229 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
230 j*4, i*3, j*4, i*3 ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
231 if (SDL_ATassert( "SDL_BlendPoint", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
232 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
233 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
234 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
235 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
236 /* See if it's the same. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
237 if (SDL_ATassert( "Primitives output not the same.", |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
238 surface_compare( testsur, &img_blend )==0 )) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
239 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
240 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
241 SDL_ATend(); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
242 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
243 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
244 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
245 /** |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
246 * @brief Tests some blitting routines. |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
247 */ |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
248 static void surface_testBlit( SDL_Surface *testsur ) |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
249 { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
250 int ret; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
251 SDL_Rect rect; |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
252 SDL_Surface *face; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
253 int i, j, ni, nj; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
254 |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
255 SDL_ATbegin( "Blit Tests" ); |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
256 |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
257 /* Clear surface. */ |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
258 ret = SDL_FillRect( testsur, NULL, |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
259 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
260 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
261 return; |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
262 |
3719 | 263 /* Create face surface. */ |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
264 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
265 img_face.width, img_face.height, 32, img_face.width*4, |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
266 RMASK, GMASK, BMASK, AMASK ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
267 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
268 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
269 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
270 /* Constant values. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
271 rect.w = face->w; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
272 rect.h = face->h; |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
273 ni = testsur->w - face->w; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
274 nj = testsur->h - face->h; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
275 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
276 /* Loop blit. */ |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
277 for (j=0; j <= nj; j+=4) { |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
278 for (i=0; i <= ni; i+=4) { |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
279 /* Blitting. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
280 rect.x = i; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
281 rect.y = j; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
282 ret = SDL_BlitSurface( face, NULL, testsur, &rect ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
283 if (SDL_ATassert( "SDL_BlitSurface", ret == 0)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
284 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
285 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
286 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
287 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
288 /* See if it's the same. */ |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
289 if (SDL_ATassert( "Blitting output not the same (normal blit).", |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
290 surface_compare( testsur, &img_blit )==0 )) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
291 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
292 |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
293 /* Clear surface. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
294 ret = SDL_FillRect( testsur, NULL, |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
295 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
296 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
297 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
298 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
299 /* Test blitting with colour mod. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
300 for (j=0; j <= nj; j+=4) { |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
301 for (i=0; i <= ni; i+=4) { |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
302 /* Set colour mod. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
303 ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j ); |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
304 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0)) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
305 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
306 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
307 /* Blitting. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
308 rect.x = i; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
309 rect.y = j; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
310 ret = SDL_BlitSurface( face, NULL, testsur, &rect ); |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
311 if (SDL_ATassert( "SDL_BlitSurface", ret == 0)) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
312 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
313 } |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
314 } |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
315 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
316 /* See if it's the same. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
317 if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceColorMod).", |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
318 surface_compare( testsur, &img_blitColour )==0 )) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
319 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
320 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
321 /* Clear surface. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
322 ret = SDL_FillRect( testsur, NULL, |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
323 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
324 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
325 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
326 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
327 /* Restore colour. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
328 ret = SDL_SetSurfaceColorMod( face, 255, 255, 255 ); |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
329 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0)) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
330 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
331 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
332 /* Test blitting with colour mod. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
333 for (j=0; j <= nj; j+=4) { |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
334 for (i=0; i <= ni; i+=4) { |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
335 /* Set alpha mod. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
336 ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i ); |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
337 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0)) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
338 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
339 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
340 /* Blitting. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
341 rect.x = i; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
342 rect.y = j; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
343 ret = SDL_BlitSurface( face, NULL, testsur, &rect ); |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
344 if (SDL_ATassert( "SDL_BlitSurface", ret == 0)) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
345 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
346 } |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
347 } |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
348 |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
349 /* See if it's the same. */ |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
350 if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceAlphaMod).", |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
351 surface_compare( testsur, &img_blitAlpha )==0 )) |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
352 return; |
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
353 |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
354 /* Clean up. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
355 SDL_FreeSurface( face ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
356 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
357 SDL_ATend(); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
358 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
359 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
360 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
361 /** |
3721
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
362 * @brief Tests a blend mode. |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
363 */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
364 static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, int mode ) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
365 { |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
366 int ret; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
367 int i, j, ni, nj; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
368 SDL_Rect rect; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
369 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
370 /* Clear surface. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
371 ret = SDL_FillRect( testsur, NULL, |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
372 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
373 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
374 return 1; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
375 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
376 /* Steps to take. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
377 ni = testsur->w - face->w; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
378 nj = testsur->h - face->h; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
379 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
380 /* Constant values. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
381 rect.w = face->w; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
382 rect.h = face->h; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
383 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
384 /* Test blend mode. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
385 for (j=0; j <= nj; j+=4) { |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
386 for (i=0; i <= ni; i+=4) { |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
387 /* Set blend mode. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
388 ret = SDL_SetSurfaceBlendMode( face, mode ); |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
389 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0)) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
390 return 1; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
391 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
392 /* Blitting. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
393 rect.x = i; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
394 rect.y = j; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
395 ret = SDL_BlitSurface( face, NULL, testsur, &rect ); |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
396 if (SDL_ATassert( "SDL_BlitSurface", ret == 0)) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
397 return 1; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
398 } |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
399 } |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
400 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
401 return 0; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
402 } |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
403 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
404 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
405 /** |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
406 * @brief Tests some more blitting routines. |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
407 */ |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
408 static void surface_testBlitBlend( SDL_Surface *testsur ) |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
409 { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
410 int ret; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
411 SDL_Rect rect; |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
412 SDL_Surface *face; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
413 int i, j, ni, nj; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
414 int mode; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
415 |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
416 SDL_ATbegin( "Blit Blending Tests" ); |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
417 |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
418 /* Clear surface. */ |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
419 ret = SDL_FillRect( testsur, NULL, |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
420 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
421 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
422 return; |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
423 |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
424 /* Create the blit surface. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
425 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
426 img_face.width, img_face.height, 32, img_face.width*4, |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
427 RMASK, GMASK, BMASK, AMASK ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
428 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
429 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
430 |
3721
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
431 /* Set alpha mod. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
432 ret = SDL_SetSurfaceAlphaMod( face, 100 ); |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
433 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0)) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
434 return; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
435 |
3722
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
436 /* Steps to take. */ |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
437 ni = testsur->w - face->w; |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
438 nj = testsur->h - face->h; |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
439 |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
440 /* Constant values. */ |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
441 rect.w = face->w; |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
442 rect.h = face->h; |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
443 |
3721
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
444 /* Test None. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
445 if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
446 return; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
447 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_NONE).", |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
448 surface_compare( testsur, &img_blendNone )==0 )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
449 return; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
450 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
451 /* Test Mask. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
452 if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MASK )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
453 return; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
454 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MASK).", |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
455 surface_compare( testsur, &img_blendMask )==0 )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
456 return; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
457 |
3721
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
458 /* Test Blend. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
459 if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
460 return; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
461 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_BLEND).", |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
462 surface_compare( testsur, &img_blendBlend )==0 )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
463 return; |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
464 |
3721
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
465 /* Test Add. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
466 if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
467 return; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
468 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_ADD).", |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
469 surface_compare( testsur, &img_blendAdd )==0 )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
470 return; |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
471 |
3721
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
472 /* Test Mod. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
473 if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
474 return; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
475 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MOD).", |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
476 surface_compare( testsur, &img_blendMod )==0 )) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
477 return; |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
478 |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
479 /* Clear surface. */ |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
480 ret = SDL_FillRect( testsur, NULL, |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
481 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
482 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
9bb7758a9741
Doing individual blend mode testing when blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3720
diff
changeset
|
483 return; |
3720
09bbf9dc41ed
Changed the surface blit test to test colour and alpha mod individually.
Edgar Simo <bobbens@gmail.com>
parents:
3719
diff
changeset
|
484 |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
485 /* Loop blit. */ |
3723
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
486 for (j=0; j <= nj; j+=4) { |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
487 for (i=0; i <= ni; i+=4) { |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
488 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
489 /* Set colour mod. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
490 ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
491 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
492 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
493 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
494 /* Set alpha mod. */ |
3723
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
495 ret = SDL_SetSurfaceAlphaMod( face, (100/ni)*i ); |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
496 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
497 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
498 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
499 /* Crazy blending mode magic. */ |
3723
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
500 mode = (i/4*j/4) % 4; |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
501 if (mode==0) mode = SDL_BLENDMODE_MASK; |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
502 else if (mode==1) mode = SDL_BLENDMODE_BLEND; |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
503 else if (mode==2) mode = SDL_BLENDMODE_ADD; |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
504 else if (mode==3) mode = SDL_BLENDMODE_MOD; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
505 ret = SDL_SetSurfaceBlendMode( face, mode ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
506 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
507 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
508 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
509 /* Blitting. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
510 rect.x = i; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
511 rect.y = j; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
512 ret = SDL_BlitSurface( face, NULL, testsur, &rect ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
513 if (SDL_ATassert( "SDL_BlitSurface", ret == 0)) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
514 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
515 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
516 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
517 |
3723
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
518 /* Check to see if matches. */ |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
519 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLEND_*).", |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
520 surface_compare( testsur, &img_blendAll )==0 )) |
1496cdbb6055
* Added mixture of blending modes test.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
521 return; |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
522 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
523 /* Clean up. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
524 SDL_FreeSurface( face ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
525 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
526 SDL_ATend(); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
527 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
528 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
529 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
530 /** |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
531 * @brief Runs all the tests on the surface. |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
532 * |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
533 * @param testsur Surface to run tests on. |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
534 */ |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
535 void surface_runTests( SDL_Surface *testsur ) |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
536 { |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
537 /* Software surface blitting. */ |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
538 surface_testPrimitives( testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
539 surface_testPrimitivesBlend( testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
540 surface_testBlit( testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
541 surface_testBlitBlend( testsur ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
542 } |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
543 |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
544 |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
545 /** |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
546 * @brief Entry point. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
547 */ |
3740
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
3729
diff
changeset
|
548 #ifdef TEST_STANDALONE |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
549 int main( int argc, const char *argv[] ) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
550 { |
3722
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
551 (void) argc; |
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
552 (void) argv; |
3740
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
3729
diff
changeset
|
553 #else /* TEST_STANDALONE */ |
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
3729
diff
changeset
|
554 int test_surface (void) |
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
3729
diff
changeset
|
555 { |
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
3729
diff
changeset
|
556 #endif /* TEST_STANDALONE */ |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
557 int ret; |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
558 SDL_Surface *testsur; |
3722
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3721
diff
changeset
|
559 |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
560 SDL_ATinit( "SDL_Surface" ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
561 |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
562 SDL_ATbegin( "Initializing" ); |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
563 /* Initializes the SDL subsystems. */ |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
564 ret = SDL_Init(0); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
565 if (SDL_ATassert( "SDL_Init(0)", ret == 0)) |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
566 goto err; |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
567 |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
568 /* Now run on the video mode. */ |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
569 ret = SDL_InitSubSystem( SDL_INIT_VIDEO ); |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
570 if (SDL_ATassert( "SDL_InitSubSystem( SDL_INIT_VIDEO )", ret == 0)) |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
571 goto err; |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
572 |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
573 /* |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
574 * Surface on surface tests. |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
575 */ |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
576 /* Create the test surface. */ |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
577 testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
578 RMASK, GMASK, BMASK, AMASK ); |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
579 if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL)) |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
580 goto err; |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
581 SDL_ATend(); |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
582 /* Run surface on surface tests. */ |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
583 surface_testLoad( testsur ); |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
584 surface_runTests( testsur ); |
3724
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
585 /* Clean up. */ |
48e2b67bb2de
Use testsur as a parameter.
Edgar Simo <bobbens@gmail.com>
parents:
3723
diff
changeset
|
586 SDL_FreeSurface( testsur ); |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
587 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
588 /* Exit SDL. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
589 SDL_Quit(); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
590 |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
591 return SDL_ATfinish(); |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
592 |
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
593 err: |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
594 return SDL_ATfinish(); |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
595 } |
3728
97e9704fc267
Using common infrastructure.
Edgar Simo <bobbens@gmail.com>
parents:
3724
diff
changeset
|
596 |