comparison test/automated/render/render.c @ 3731:f5ddf1b670f0 gsoc2009_unit_tests

Converted another testcase to the render system.
author Edgar Simo <bobbens@gmail.com>
date Wed, 15 Jul 2009 08:50:24 +0000
parents dafd796f0c95
children ca544951b504
comparison
equal deleted inserted replaced
3730:dafd796f0c95 3731:f5ddf1b670f0
15 15
16 /* 16 /*
17 * Pull in images for testcases. 17 * Pull in images for testcases.
18 */ 18 */
19 #include "common/images.h" 19 #include "common/images.h"
20
21
22 #define SCREEN_W 80
23 #define SCREEN_H 60
20 24
21 25
22 /* 26 /*
23 * Prototypes. 27 * Prototypes.
24 */ 28 */
169 173
170 /* See if it's the same. */ 174 /* See if it's the same. */
171 if (render_compare( "Primitives output not the same.", &img_primitives )) 175 if (render_compare( "Primitives output not the same.", &img_primitives ))
172 return; 176 return;
173 } 177 }
174 #if 0
175 178
176 179
177 /** 180 /**
178 * @brief Tests the SDL primitives with alpha for rendering. 181 * @brief Tests the SDL primitives with alpha for rendering.
179 */ 182 */
181 { 184 {
182 int ret; 185 int ret;
183 int i, j; 186 int i, j;
184 SDL_Rect rect; 187 SDL_Rect rect;
185 188
186 SDL_ATbegin( "Primitives Blend Test" );
187
188 /* Clear surface. */ 189 /* Clear surface. */
189 ret = SDL_FillRect( testsur, NULL, 190 if (render_clearScreen())
190 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
191 if (SDL_ATassert( "SDL_FillRect", ret == 0))
192 return; 191 return;
193 192
194 /* Create some rectangles for each blend mode. */ 193 /* Create some rectangles for each blend mode. */
195 ret = SDL_BlendRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 ); 194 ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 );
196 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) 195 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
196 return;
197 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
198 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
199 return;
200 ret = SDL_RenderFill( NULL );
201 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
197 return; 202 return;
198 rect.x = 10; 203 rect.x = 10;
199 rect.y = 25; 204 rect.y = 25;
200 rect.w = 40; 205 rect.w = 40;
201 rect.h = 25; 206 rect.h = 25;
202 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 ); 207 ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 );
203 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) 208 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
209 return;
210 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
211 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
212 return;
213 ret = SDL_RenderFill( &rect );
214 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
204 return; 215 return;
205 rect.x = 30; 216 rect.x = 30;
206 rect.y = 40; 217 rect.y = 40;
207 rect.w = 45; 218 rect.w = 45;
208 rect.h = 15; 219 rect.h = 15;
209 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 ); 220 ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 );
210 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) 221 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
222 return;
223 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
224 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
225 return;
226 ret = SDL_RenderFill( &rect );
227 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
211 return; 228 return;
212 rect.x = 25; 229 rect.x = 25;
213 rect.y = 25; 230 rect.y = 25;
214 rect.w = 25; 231 rect.w = 25;
215 rect.h = 25; 232 rect.h = 25;
216 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 ); 233 ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 );
217 if (SDL_ATassert( "SDL_BlendRect", ret == 0)) 234 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
235 return;
236 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
237 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
238 return;
239 ret = SDL_RenderFill( &rect );
240 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
218 return; 241 return;
219 242
220 /* Draw blended lines, lines for everyone. */ 243 /* Draw blended lines, lines for everyone. */
221 for (i=0; i<testsur->w; i+=2) { 244 for (i=0; i<SCREEN_W; i+=2) {
222 ret = SDL_BlendLine( testsur, 0, 0, i, 59, 245 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
223 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : 246 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
224 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
225 60+2*i, 240-2*i, 50, 3*i );
226 if (SDL_ATassert( "SDL_BlendLine", ret == 0))
227 return; 247 return;
228 } 248 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
229 for (i=0; i<testsur->h; i+=2) { 249 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
230 ret = SDL_BlendLine( testsur, 0, 0, 79, i, 250 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
231 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
232 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
233 60+2*i, 240-2*i, 50, 3*i );
234 if (SDL_ATassert( "SDL_BlendLine", ret == 0))
235 return; 251 return;
252 ret = SDL_RenderLine( 0, 0, i, 59 );
253 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
254 return;
255 }
256 for (i=0; i<SCREEN_H; i+=2) {
257 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
258 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
259 return;
260 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
261 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
262 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
263 return;
264 ret = SDL_RenderLine( 0, 0, 79, i );
265 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
266 return;
236 } 267 }
237 268
238 /* Draw points. */ 269 /* Draw points. */
239 for (j=0; j<testsur->h; j+=3) { 270 for (j=0; j<SCREEN_H; j+=3) {
240 for (i=0; i<testsur->w; i+=3) { 271 for (i=0; i<SCREEN_W; i+=3) {
241 ret = SDL_BlendPoint( testsur, i, j, 272 ret = SDL_SetRenderDrawColor( j*4, i*3, j*4, i*3 );
242 ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : 273 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
243 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, 274 return;
244 j*4, i*3, j*4, i*3 ); 275 ret = SDL_SetRenderDrawBlendMode( ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
245 if (SDL_ATassert( "SDL_BlendPoint", ret == 0)) 276 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
246 return; 277 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
278 return;
279 ret = SDL_RenderPoint( i, j );
280 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
281 return;
247 } 282 }
248 } 283 }
249 284
250 /* See if it's the same. */ 285 /* See if it's the same. */
251 if (SDL_ATassert( "Primitives output not the same.", 286 if (render_compare( "Blended primitives output not the same.", &img_primitives ))
252 render_compare( testsur, &img_blend )==0 )) 287 return;
253 return; 288 }
254 289 #if 0
255 SDL_ATend();
256 }
257 290
258 291
259 /** 292 /**
260 * @brief Tests some blitting routines. 293 * @brief Tests some blitting routines.
261 */ 294 */