Mercurial > sdl-ios-xcode
annotate test/automated/surface/surface.c @ 3719:15373e31daff gsoc2009_unit_tests
Moved some code around.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 07 Jul 2009 16:28:42 +0000 |
parents | 9d71382713b5 |
children | 09bbf9dc41ed |
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 { |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
28 unsigned int width; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
29 unsigned int height; |
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" |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
42 |
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 * @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
|
46 * |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
47 * @param sur Surface to compare. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
48 * @param img Image to compare against. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
49 * @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
|
50 */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
51 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
|
52 { |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
53 int ret; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
54 int i,j; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
55 Uint32 pix; |
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: |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
75 /* Paletted not supported atm. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
76 ret += 1; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
77 break; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
78 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
79 case 2: |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
80 /* 16 BPP not supported atm. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
81 ret += 1; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
82 break; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
83 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
84 case 3: |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
85 /* 24 BPP not supported atm. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
86 ret += 1; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
87 break; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
88 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
89 case 4: |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
90 ret += !( (p[0] == pd[0]) && |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
91 (p[1] == pd[1]) && |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
92 (p[2] == pd[2]) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
93 break; |
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 } |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
97 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
98 SDL_UnlockSurface( sur ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
99 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
100 return ret; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
101 } |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
102 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
103 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
104 /** |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
105 * @brief Tests sprite loading. |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
106 */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
107 static void surface_testLoad (void) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
108 { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
109 int ret; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
110 SDL_Surface *face, *rface, *testsur; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
111 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
112 SDL_ATbegin( "Load Test" ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
113 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
114 /* Create the blit surface. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
115 face = SDL_LoadBMP("../icon.bmp"); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
116 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
|
117 return; |
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 /* 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
|
120 if (face->format->palette) { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
121 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
|
122 *(Uint8 *) face->pixels); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
123 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
|
124 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
125 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
126 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
127 /* Create the test surface. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
128 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
|
129 RMASK, GMASK, BMASK, AMASK ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
130 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
|
131 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
132 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
133 /* Convert to 32 bit to compare. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
134 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
|
135 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
|
136 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
137 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
138 /* See if it's the same. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
139 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
|
140 surface_compare( rface, &img_face)==0 )) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
141 return; |
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 /* Clean up. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
144 SDL_FreeSurface( testsur ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
145 SDL_FreeSurface( rface ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
146 SDL_FreeSurface( face ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
147 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
148 SDL_ATend(); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
149 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
150 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
151 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
152 /** |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
153 * @brief Tests the SDL primitives for rendering. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
154 */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
155 static void surface_testPrimitives (void) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
156 { |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
157 int ret; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
158 int x, y; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
159 SDL_Rect rect; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
160 SDL_Surface *testsur; |
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 SDL_ATbegin( "Primitives Test" ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
163 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
164 /* Create the surface. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
165 testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
166 RMASK, GMASK, BMASK, AMASK ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
167 if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
168 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
169 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
170 /* Draw a rectangle. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
171 rect.x = 40; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
172 rect.y = 0; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
173 rect.w = 40; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
174 rect.h = 80; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
175 ret = SDL_FillRect( testsur, &rect, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
176 SDL_MapRGB( testsur->format, 13, 73, 200 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
177 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
178 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
179 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
180 /* Draw a rectangle. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
181 rect.x = 10; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
182 rect.y = 10; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
183 rect.w = 60; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
184 rect.h = 40; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
185 ret = SDL_FillRect( testsur, &rect, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
186 SDL_MapRGB( testsur->format, 200, 0, 100 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
187 if (SDL_ATassert( "SDL_FillRect", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
188 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
189 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
190 /* Draw some points like so: |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
191 * X.X.X.X.. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
192 * .X.X.X.X. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
193 * X.X.X.X.. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
194 for (y=0; y<3; y++) { |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
195 x = y % 2; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
196 for (; x<80; x+=2) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
197 ret = SDL_DrawPoint( testsur, x, y, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
198 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
|
199 if (SDL_ATassert( "SDL_DrawPoint", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
200 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
201 } |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
202 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
203 /* Draw some lines. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
204 ret = SDL_DrawLine( testsur, 0, 30, 80, 30, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
205 SDL_MapRGB( testsur->format, 0, 255, 0 ) ); |
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 ret = SDL_DrawLine( testsur, 40, 30, 40, 60, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
209 SDL_MapRGB( testsur->format, 55, 55, 5 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
210 if (SDL_ATassert( "SDL_DrawLine", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
211 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
212 ret = SDL_DrawLine( testsur, 0, 60, 80, 0, |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
213 SDL_MapRGB( testsur->format, 5, 105, 105 ) ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
214 if (SDL_ATassert( "SDL_DrawLine", ret == 0)) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
215 return; |
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 /* See if it's the same. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
218 if (SDL_ATassert( "Primitives output not the same.", |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
219 surface_compare( testsur, &img_primitives )==0 )) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
220 return; |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
221 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
222 /* Clean up. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
223 SDL_FreeSurface( testsur ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
224 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
225 SDL_ATend(); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
226 } |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
227 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
228 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
229 /** |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
230 * @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
|
231 */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
232 static void surface_testPrimitivesAlpha (void) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
233 { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
234 int ret; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
235 int i, j; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
236 SDL_Rect rect; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
237 SDL_Surface *testsur; |
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 SDL_ATbegin( "Primitives Alpha Test" ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
240 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
241 /* Create the surface. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
242 testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
243 RMASK, GMASK, BMASK, AMASK ); |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
244 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
|
245 return; |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
246 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
247 /* Create some rectangles for each blend mode. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
248 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
|
249 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
250 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
251 rect.x = 10; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
252 rect.y = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
253 rect.w = 40; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
254 rect.h = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
255 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
|
256 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
257 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
258 rect.x = 30; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
259 rect.y = 40; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
260 rect.w = 45; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
261 rect.h = 15; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
262 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
|
263 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
264 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
265 rect.x = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
266 rect.y = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
267 rect.w = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
268 rect.h = 25; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
269 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
|
270 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
271 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
272 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
273 /* Draw blended lines, lines for everyone. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
274 for (i=0; i<testsur->w; 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, i, 59, |
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, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
278 60+2*j, 240-2*j, 50, 3*j ); |
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 for (i=0; i<testsur->h; i+=2) { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
283 ret = SDL_BlendLine( testsur, 0, 0, 79, i, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
284 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
285 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
286 60+2*j, 240-2*j, 50, 3*j ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
287 if (SDL_ATassert( "SDL_BlendLine", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
288 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
289 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
290 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
291 /* Draw points. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
292 for (j=0; j<testsur->h; j+=3) { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
293 for (i=0; i<testsur->w; i+=3) { |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
294 ret = SDL_BlendPoint( testsur, i, j, |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
295 ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
296 ((((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
|
297 j*4, i*3, j*4, i*3 ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
298 if (SDL_ATassert( "SDL_BlendPoint", ret == 0)) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
299 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
300 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
301 } |
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 /* See if it's the same. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
304 if (SDL_ATassert( "Primitives output not the same.", |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
305 surface_compare( testsur, &img_blend )==0 )) |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
306 return; |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
307 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
308 /* Clean up. */ |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
309 SDL_FreeSurface( testsur ); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
310 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
311 SDL_ATend(); |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
312 } |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
313 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
314 |
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
315 /** |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
316 * @brief Tests some blitting routines. |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
317 */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
318 static void surface_testBlit (void) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
319 { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
320 int ret; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
321 SDL_Rect rect; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
322 SDL_Surface *face, *testsur; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
323 int i, j, ni, nj; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
324 int mode; |
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 SDL_ATbegin( "Blit Test" ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
327 |
3719 | 328 /* Create face surface. */ |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
329 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
|
330 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
|
331 RMASK, GMASK, BMASK, AMASK ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
332 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
|
333 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
334 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
335 /* Create the test surface. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
336 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
|
337 RMASK, GMASK, BMASK, AMASK ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
338 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
|
339 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
340 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
341 /* Steps to take. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
342 ni = 40; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
343 nj = 30; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
344 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
345 /* Constant values. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
346 rect.w = face->w; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
347 rect.h = face->h; |
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 /* Loop blit. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
350 for (j=0; j <= testsur->h - face->h; j+=4) { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
351 for (i=0; i <= testsur->w - face->w; i+=4) { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
352 /* Blitting. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
353 rect.x = i; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
354 rect.y = j; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
355 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
|
356 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
|
357 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
358 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
359 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
360 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
361 /* See if it's the same. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
362 if (SDL_ATassert( "Blitting output not the same.", |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
363 surface_compare( testsur, &img_blit )==0 )) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
364 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
365 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
366 /* Clean up. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
367 SDL_FreeSurface( face ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
368 SDL_FreeSurface( testsur ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
369 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
370 SDL_ATend(); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
371 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
372 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
373 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
374 /** |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
375 * @brief Tests some more blitting routines. |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
376 */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
377 static void surface_testBlitAlpha (void) |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
378 { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
379 int ret; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
380 SDL_Rect rect; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
381 SDL_Surface *face, *testsur; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
382 int i, j, ni, nj; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
383 int mode; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
384 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
385 SDL_ATbegin( "Blit Alpha Test" ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
386 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
387 /* Create the blit surface. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
388 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
|
389 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
|
390 RMASK, GMASK, BMASK, AMASK ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
391 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
|
392 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
393 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
394 /* Create the test surface. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
395 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
|
396 RMASK, GMASK, BMASK, AMASK ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
397 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
|
398 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
399 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
400 /* Steps to take. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
401 ni = 40; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
402 nj = 30; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
403 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
404 /* Constant values. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
405 rect.w = face->w; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
406 rect.h = face->h; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
407 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
408 /* Loop blit. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
409 for (j=0; j <= testsur->h - face->h; j+=4) { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
410 for (i=0; i <= testsur->w - face->w; i+=4) { |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
411 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
412 /* Set colour mod. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
413 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
|
414 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
|
415 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
416 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
417 /* Set alpha mod. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
418 ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
419 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
|
420 return; |
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 /* Crazy blending mode magic. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
423 mode = (i*j)%5; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
424 if (mode==0) mode = SDL_BLENDMODE_NONE; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
425 else if (mode==1) mode = SDL_BLENDMODE_MASK; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
426 else if (mode==2) mode = SDL_BLENDMODE_BLEND; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
427 else if (mode==3) mode = SDL_BLENDMODE_ADD; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
428 else if (mode==4) mode = SDL_BLENDMODE_MOD; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
429 ret = SDL_SetSurfaceBlendMode( face, mode ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
430 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
|
431 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
432 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
433 /* Blitting. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
434 rect.x = i; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
435 rect.y = j; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
436 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
|
437 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
|
438 return; |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
439 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
440 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
441 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
442 SDL_SaveBMP( testsur, "blit.bmp" ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
443 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
444 /* Clean up. */ |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
445 SDL_FreeSurface( face ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
446 SDL_FreeSurface( testsur ); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
447 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
448 SDL_ATend(); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
449 } |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
450 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
451 |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
452 /** |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
453 * @brief Entry point. |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
454 */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
455 int main( int argc, const char *argv[] ) |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
456 { |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
457 SDL_ATinit( "SDL_Surface" ); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
458 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
459 /* Initializes the SDL subsystems. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
460 SDL_Init(0); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
461 |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
462 surface_testLoad(); |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
463 surface_testPrimitives(); |
3716
ac6bc19a2dfb
Added surfarce blend rendering functions testcase.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
464 surface_testPrimitivesAlpha(); |
3718
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
465 surface_testBlit(); |
9d71382713b5
Added 3 new tests: loadsurface, blitting, alpha blitting.
Edgar Simo <bobbens@gmail.com>
parents:
3716
diff
changeset
|
466 /*surface_testBlitAlpha();*/ |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
467 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
468 /* Exit SDL. */ |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
469 SDL_Quit(); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
470 |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
471 return SDL_ATfinish(1); |
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
472 } |