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