Mercurial > sdl-ios-xcode
comparison test/automated/render/render.c @ 5156:3e4086b3bcd2
Fixed compiling with the latest API changes
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 02 Feb 2011 14:34:24 -0800 |
parents | e743b9c3f6d6 |
children | e2b3f003e085 |
comparison
equal
deleted
inserted
replaced
5155:3b85dfaf2893 | 5156:3e4086b3bcd2 |
---|---|
23 #define SCREEN_H 60 | 23 #define SCREEN_H 60 |
24 | 24 |
25 #define FACE_W img_face.width | 25 #define FACE_W img_face.width |
26 #define FACE_H img_face.height | 26 #define FACE_H img_face.height |
27 | 27 |
28 static SDL_Renderer *renderer; | |
28 | 29 |
29 /* | 30 /* |
30 * Prototypes. | 31 * Prototypes. |
31 */ | 32 */ |
32 static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error ); | 33 static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error ); |
65 /* Explicitly specify the rect in case the window isn't expected size... */ | 66 /* Explicitly specify the rect in case the window isn't expected size... */ |
66 rect.x = 0; | 67 rect.x = 0; |
67 rect.y = 0; | 68 rect.y = 0; |
68 rect.w = 80; | 69 rect.w = 80; |
69 rect.h = 60; | 70 rect.h = 60; |
70 ret = SDL_RenderReadPixels( &rect, FORMAT, pix, 80*4 ); | 71 ret = SDL_RenderReadPixels(renderer, &rect, FORMAT, pix, 80*4 ); |
71 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) | 72 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) |
72 return 1; | 73 return 1; |
73 | 74 |
74 /* Create surface. */ | 75 /* Create surface. */ |
75 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, | 76 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, |
96 Uint8 pix[4*80*60]; | 97 Uint8 pix[4*80*60]; |
97 SDL_Surface *testsur; | 98 SDL_Surface *testsur; |
98 SDL_RendererInfo info; | 99 SDL_RendererInfo info; |
99 | 100 |
100 /* Read pixels. */ | 101 /* Read pixels. */ |
101 ret = SDL_RenderReadPixels( NULL, FORMAT, pix, 80*4 ); | 102 ret = SDL_RenderReadPixels(renderer, NULL, FORMAT, pix, 80*4 ); |
102 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) | 103 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) |
103 return 1; | 104 return 1; |
104 | 105 |
105 /* Create surface. */ | 106 /* Create surface. */ |
106 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, | 107 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, |
107 RMASK, GMASK, BMASK, AMASK); | 108 RMASK, GMASK, BMASK, AMASK); |
108 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL )) | 109 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL )) |
109 return 1; | 110 return 1; |
110 | 111 |
111 /* Dump surface. */ | 112 /* Dump surface. */ |
112 SDL_GetRendererInfo(&info); | 113 SDL_GetRendererInfo(renderer,&info); |
113 sprintf(name, "%s-%s-%d.bmp", SDL_GetCurrentVideoDriver(), info.name, index); | 114 sprintf(name, "%s-%s-%d.bmp", SDL_GetCurrentVideoDriver(), info.name, index); |
114 SDL_SaveBMP(testsur, name); | 115 SDL_SaveBMP(testsur, name); |
115 | 116 |
116 /* Clean up. */ | 117 /* Clean up. */ |
117 SDL_FreeSurface( testsur ); | 118 SDL_FreeSurface( testsur ); |
138 Uint8 r, g, b, a; | 139 Uint8 r, g, b, a; |
139 | 140 |
140 fail = 0; | 141 fail = 0; |
141 | 142 |
142 /* Set colour. */ | 143 /* Set colour. */ |
143 ret = SDL_SetRenderDrawColor( 100, 100, 100, 100 ); | 144 ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 ); |
144 if (!render_isSupported(ret)) | 145 if (!render_isSupported(ret)) |
145 fail = 1; | 146 fail = 1; |
146 ret = SDL_GetRenderDrawColor( &r, &g, &b, &a ); | 147 ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a ); |
147 if (!render_isSupported(ret)) | 148 if (!render_isSupported(ret)) |
148 fail = 1; | 149 fail = 1; |
149 /* Restore natural. */ | 150 /* Restore natural. */ |
150 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE ); | 151 ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); |
151 if (!render_isSupported(ret)) | 152 if (!render_isSupported(ret)) |
152 fail = 1; | 153 fail = 1; |
153 | 154 |
154 /* Something failed, consider not available. */ | 155 /* Something failed, consider not available. */ |
155 if (fail) | 156 if (fail) |
170 int ret; | 171 int ret; |
171 SDL_BlendMode mode; | 172 SDL_BlendMode mode; |
172 | 173 |
173 fail = 0; | 174 fail = 0; |
174 | 175 |
175 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND ); | 176 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); |
176 if (!render_isSupported(ret)) | 177 if (!render_isSupported(ret)) |
177 fail = 1; | 178 fail = 1; |
178 ret = SDL_GetRenderDrawBlendMode( &mode ); | 179 ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); |
179 if (!render_isSupported(ret)) | 180 if (!render_isSupported(ret)) |
180 fail = 1; | 181 fail = 1; |
181 ret = (mode != SDL_BLENDMODE_BLEND); | 182 ret = (mode != SDL_BLENDMODE_BLEND); |
182 if (!render_isSupported(ret)) | 183 if (!render_isSupported(ret)) |
183 fail = 1; | 184 fail = 1; |
184 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD ); | 185 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); |
185 if (!render_isSupported(ret)) | 186 if (!render_isSupported(ret)) |
186 fail = 1; | 187 fail = 1; |
187 ret = SDL_GetRenderDrawBlendMode( &mode ); | 188 ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); |
188 if (!render_isSupported(ret)) | 189 if (!render_isSupported(ret)) |
189 fail = 1; | 190 fail = 1; |
190 ret = (mode != SDL_BLENDMODE_ADD); | 191 ret = (mode != SDL_BLENDMODE_ADD); |
191 if (!render_isSupported(ret)) | 192 if (!render_isSupported(ret)) |
192 fail = 1; | 193 fail = 1; |
193 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE ); | 194 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
194 if (!render_isSupported(ret)) | 195 if (!render_isSupported(ret)) |
195 fail = 1; | 196 fail = 1; |
196 ret = SDL_GetRenderDrawBlendMode( &mode ); | 197 ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); |
197 if (!render_isSupported(ret)) | 198 if (!render_isSupported(ret)) |
198 fail = 1; | 199 fail = 1; |
199 ret = (mode != SDL_BLENDMODE_NONE); | 200 ret = (mode != SDL_BLENDMODE_NONE); |
200 if (!render_isSupported(ret)) | 201 if (!render_isSupported(ret)) |
201 fail = 1; | 202 fail = 1; |
227 0xff000000 /* Alpha bit mask. */ | 228 0xff000000 /* Alpha bit mask. */ |
228 #endif | 229 #endif |
229 ); | 230 ); |
230 if (face == NULL) | 231 if (face == NULL) |
231 return 0; | 232 return 0; |
232 tface = SDL_CreateTextureFromSurface( 0, face ); | 233 tface = SDL_CreateTextureFromSurface(renderer, 0, face ); |
233 SDL_FreeSurface(face); | 234 SDL_FreeSurface(face); |
234 | 235 |
235 return tface; | 236 return tface; |
236 } | 237 } |
237 | 238 |
314 static int render_clearScreen (void) | 315 static int render_clearScreen (void) |
315 { | 316 { |
316 int ret; | 317 int ret; |
317 | 318 |
318 /* Set colour. */ | 319 /* Set colour. */ |
319 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE ); | 320 ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); |
320 /* | 321 /* |
321 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 322 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
322 return -1; | 323 return -1; |
323 */ | 324 */ |
324 | 325 |
325 /* Clear screen. */ | 326 /* Clear screen. */ |
326 ret = SDL_RenderFillRect( NULL ); | 327 ret = SDL_RenderFillRect(renderer, NULL ); |
327 /* | 328 /* |
328 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) | 329 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
329 return -1; | 330 return -1; |
330 */ | 331 */ |
331 | 332 |
332 /* Set defaults. */ | 333 /* Set defaults. */ |
333 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE ); | 334 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
334 /* | 335 /* |
335 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 336 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
336 return -1; | 337 return -1; |
337 */ | 338 */ |
338 ret = SDL_SetRenderDrawColor( 255, 255, 255, SDL_ALPHA_OPAQUE ); | 339 ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE ); |
339 /* | 340 /* |
340 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 341 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
341 return -1; | 342 return -1; |
342 */ | 343 */ |
343 | 344 |
356 /* Write pixels. */ | 357 /* Write pixels. */ |
357 rect.x = 0; | 358 rect.x = 0; |
358 rect.y = 0; | 359 rect.y = 0; |
359 rect.w = 80; | 360 rect.w = 80; |
360 rect.h = 60; | 361 rect.h = 60; |
361 ret = SDL_RenderWritePixels( &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel ); | 362 ret = SDL_RenderWritePixels(renderer, &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel ); |
362 if (SDL_ATassert( "SDL_RenderWritePixels", ret==0) ) | 363 if (SDL_ATassert( "SDL_RenderWritePixels", ret==0) ) |
363 return 1; | 364 return 1; |
364 | 365 |
365 /* See if it's the same. */ | 366 /* See if it's the same. */ |
366 if (render_compare( "Read/write output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE )) | 367 if (render_compare( "Read/write output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE )) |
390 /* Draw a rectangle. */ | 391 /* Draw a rectangle. */ |
391 rect.x = 40; | 392 rect.x = 40; |
392 rect.y = 0; | 393 rect.y = 0; |
393 rect.w = 40; | 394 rect.w = 40; |
394 rect.h = 80; | 395 rect.h = 80; |
395 ret = SDL_SetRenderDrawColor( 13, 73, 200, SDL_ALPHA_OPAQUE ); | 396 ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE ); |
396 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 397 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
397 return -1; | 398 return -1; |
398 ret = SDL_RenderFillRect( &rect ); | 399 ret = SDL_RenderFillRect(renderer, &rect ); |
399 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) | 400 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
400 return -1; | 401 return -1; |
401 | 402 |
402 /* Draw a rectangle. */ | 403 /* Draw a rectangle. */ |
403 rect.x = 10; | 404 rect.x = 10; |
404 rect.y = 10; | 405 rect.y = 10; |
405 rect.w = 60; | 406 rect.w = 60; |
406 rect.h = 40; | 407 rect.h = 40; |
407 ret = SDL_SetRenderDrawColor( 200, 0, 100, SDL_ALPHA_OPAQUE ); | 408 ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE ); |
408 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 409 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
409 return -1; | 410 return -1; |
410 ret = SDL_RenderFillRect( &rect ); | 411 ret = SDL_RenderFillRect(renderer, &rect ); |
411 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) | 412 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
412 return -1; | 413 return -1; |
413 | 414 |
414 /* Draw some points like so: | 415 /* Draw some points like so: |
415 * X.X.X.X.. | 416 * X.X.X.X.. |
416 * .X.X.X.X. | 417 * .X.X.X.X. |
417 * X.X.X.X.. */ | 418 * X.X.X.X.. */ |
418 for (y=0; y<3; y++) { | 419 for (y=0; y<3; y++) { |
419 x = y % 2; | 420 x = y % 2; |
420 for (; x<80; x+=2) { | 421 for (; x<80; x+=2) { |
421 ret = SDL_SetRenderDrawColor( x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE ); | 422 ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE ); |
422 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 423 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
423 return -1; | 424 return -1; |
424 ret = SDL_RenderDrawPoint( x, y ); | 425 ret = SDL_RenderDrawPoint(renderer, x, y ); |
425 if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0)) | 426 if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0)) |
426 return -1; | 427 return -1; |
427 } | 428 } |
428 } | 429 } |
429 | 430 |
430 /* Draw some lines. */ | 431 /* Draw some lines. */ |
431 ret = SDL_SetRenderDrawColor( 0, 255, 0, SDL_ALPHA_OPAQUE ); | 432 ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE ); |
432 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 433 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
433 return -1; | 434 return -1; |
434 ret = SDL_RenderDrawLine( 0, 30, 80, 30 ); | 435 ret = SDL_RenderDrawLine(renderer, 0, 30, 80, 30 ); |
435 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 436 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
436 return -1; | 437 return -1; |
437 ret = SDL_SetRenderDrawColor( 55, 55, 5, SDL_ALPHA_OPAQUE ); | 438 ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE ); |
438 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 439 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
439 return -1; | 440 return -1; |
440 ret = SDL_RenderDrawLine( 40, 30, 40, 60 ); | 441 ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 ); |
441 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 442 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
442 return -1; | 443 return -1; |
443 ret = SDL_SetRenderDrawColor( 5, 105, 105, SDL_ALPHA_OPAQUE ); | 444 ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE ); |
444 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 445 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
445 return -1; | 446 return -1; |
446 ret = SDL_RenderDrawLine( 0, 0, 29, 29 ); | 447 ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 ); |
447 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 448 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
448 return -1; | 449 return -1; |
449 ret = SDL_RenderDrawLine( 29, 30, 0, 59 ); | 450 ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 ); |
450 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 451 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
451 return -1; | 452 return -1; |
452 ret = SDL_RenderDrawLine( 79, 0, 50, 29 ); | 453 ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 ); |
453 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 454 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
454 return -1; | 455 return -1; |
455 ret = SDL_RenderDrawLine( 79, 59, 50, 30 ); | 456 ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 ); |
456 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 457 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
457 return -1; | 458 return -1; |
458 | 459 |
459 /* See if it's the same. */ | 460 /* See if it's the same. */ |
460 if (render_compare( "Primitives output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE )) | 461 if (render_compare( "Primitives output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE )) |
480 /* Need drawcolour and blendmode or just skip test. */ | 481 /* Need drawcolour and blendmode or just skip test. */ |
481 if (!render_hasDrawColor() || !render_hasBlendModes()) | 482 if (!render_hasDrawColor() || !render_hasBlendModes()) |
482 return 0; | 483 return 0; |
483 | 484 |
484 /* Create some rectangles for each blend mode. */ | 485 /* Create some rectangles for each blend mode. */ |
485 ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 ); | 486 ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 ); |
486 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 487 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
487 return -1; | 488 return -1; |
488 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE ); | 489 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
489 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 490 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
490 return -1; | 491 return -1; |
491 ret = SDL_RenderFillRect( NULL ); | 492 ret = SDL_RenderFillRect(renderer, NULL ); |
492 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) | 493 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
493 return -1; | 494 return -1; |
494 rect.x = 10; | 495 rect.x = 10; |
495 rect.y = 25; | 496 rect.y = 25; |
496 rect.w = 40; | 497 rect.w = 40; |
497 rect.h = 25; | 498 rect.h = 25; |
498 ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 ); | 499 ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 ); |
499 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 500 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
500 return -1; | 501 return -1; |
501 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD ); | 502 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); |
502 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 503 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
503 return -1; | 504 return -1; |
504 ret = SDL_RenderFillRect( &rect ); | 505 ret = SDL_RenderFillRect(renderer, &rect ); |
505 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) | 506 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
506 return -1; | 507 return -1; |
507 rect.x = 30; | 508 rect.x = 30; |
508 rect.y = 40; | 509 rect.y = 40; |
509 rect.w = 45; | 510 rect.w = 45; |
510 rect.h = 15; | 511 rect.h = 15; |
511 ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 ); | 512 ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 ); |
512 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 513 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
513 return -1; | 514 return -1; |
514 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND ); | 515 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); |
515 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 516 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
516 return -1; | 517 return -1; |
517 ret = SDL_RenderFillRect( &rect ); | 518 ret = SDL_RenderFillRect(renderer, &rect ); |
518 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) | 519 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
519 return -1; | 520 return -1; |
520 rect.x = 25; | 521 rect.x = 25; |
521 rect.y = 25; | 522 rect.y = 25; |
522 rect.w = 25; | 523 rect.w = 25; |
523 rect.h = 25; | 524 rect.h = 25; |
524 ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 ); | 525 ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 ); |
525 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 526 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
526 return -1; | 527 return -1; |
527 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD ); | 528 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
528 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 529 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
529 return -1; | 530 return -1; |
530 ret = SDL_RenderFillRect( &rect ); | 531 ret = SDL_RenderFillRect(renderer, &rect ); |
531 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) | 532 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
532 return -1; | 533 return -1; |
533 | 534 |
534 /* Draw blended lines, lines for everyone. */ | 535 /* Draw blended lines, lines for everyone. */ |
535 for (i=0; i<SCREEN_W; i+=2) { | 536 for (i=0; i<SCREEN_W; i+=2) { |
536 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i ); | 537 ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); |
537 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 538 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
538 return -1; | 539 return -1; |
539 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : | 540 ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
540 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD ); | 541 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); |
541 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 542 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
542 return -1; | 543 return -1; |
543 ret = SDL_RenderDrawLine( 0, 0, i, 59 ); | 544 ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 ); |
544 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 545 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
545 return -1; | 546 return -1; |
546 } | 547 } |
547 for (i=0; i<SCREEN_H; i+=2) { | 548 for (i=0; i<SCREEN_H; i+=2) { |
548 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i ); | 549 ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); |
549 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 550 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
550 return -1; | 551 return -1; |
551 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : | 552 ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
552 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD ); | 553 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); |
553 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 554 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
554 return -1; | 555 return -1; |
555 ret = SDL_RenderDrawLine( 0, 0, 79, i ); | 556 ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i ); |
556 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) | 557 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
557 return -1; | 558 return -1; |
558 } | 559 } |
559 | 560 |
560 /* Draw points. */ | 561 /* Draw points. */ |
561 for (j=0; j<SCREEN_H; j+=3) { | 562 for (j=0; j<SCREEN_H; j+=3) { |
562 for (i=0; i<SCREEN_W; i+=3) { | 563 for (i=0; i<SCREEN_W; i+=3) { |
563 ret = SDL_SetRenderDrawColor( j*4, i*3, j*4, i*3 ); | 564 ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 ); |
564 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 565 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
565 return -1; | 566 return -1; |
566 ret = SDL_SetRenderDrawBlendMode( ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : | 567 ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : |
567 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD ); | 568 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); |
568 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) | 569 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0)) |
569 return -1; | 570 return -1; |
570 ret = SDL_RenderDrawPoint( i, j ); | 571 ret = SDL_RenderDrawPoint(renderer, i, j ); |
571 if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0)) | 572 if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0)) |
572 return -1; | 573 return -1; |
573 } | 574 } |
574 } | 575 } |
575 | 576 |
614 for (j=0; j <= nj; j+=4) { | 615 for (j=0; j <= nj; j+=4) { |
615 for (i=0; i <= ni; i+=4) { | 616 for (i=0; i <= ni; i+=4) { |
616 /* Blitting. */ | 617 /* Blitting. */ |
617 rect.x = i; | 618 rect.x = i; |
618 rect.y = j; | 619 rect.y = j; |
619 ret = SDL_RenderCopy( tface, NULL, &rect ); | 620 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
620 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) | 621 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) |
621 return -1; | 622 return -1; |
622 } | 623 } |
623 } | 624 } |
624 | 625 |
671 return -1; | 672 return -1; |
672 | 673 |
673 /* Blitting. */ | 674 /* Blitting. */ |
674 rect.x = i; | 675 rect.x = i; |
675 rect.y = j; | 676 rect.y = j; |
676 ret = SDL_RenderCopy( tface, NULL, &rect ); | 677 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
677 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) | 678 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) |
678 return -1; | 679 return -1; |
679 } | 680 } |
680 } | 681 } |
681 | 682 |
733 return -1; | 734 return -1; |
734 | 735 |
735 /* Blitting. */ | 736 /* Blitting. */ |
736 rect.x = i; | 737 rect.x = i; |
737 rect.y = j; | 738 rect.y = j; |
738 ret = SDL_RenderCopy( tface, NULL, &rect ); | 739 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
739 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) | 740 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) |
740 return -1; | 741 return -1; |
741 } | 742 } |
742 } | 743 } |
743 | 744 |
783 return -1; | 784 return -1; |
784 | 785 |
785 /* Blitting. */ | 786 /* Blitting. */ |
786 rect.x = i; | 787 rect.x = i; |
787 rect.y = j; | 788 rect.y = j; |
788 ret = SDL_RenderCopy( tface, NULL, &rect ); | 789 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
789 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) | 790 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) |
790 return -1; | 791 return -1; |
791 } | 792 } |
792 } | 793 } |
793 | 794 |
883 return -1; | 884 return -1; |
884 | 885 |
885 /* Blitting. */ | 886 /* Blitting. */ |
886 rect.x = i; | 887 rect.x = i; |
887 rect.y = j; | 888 rect.y = j; |
888 ret = SDL_RenderCopy( tface, NULL, &rect ); | 889 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
889 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) | 890 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) |
890 return -1; | 891 return -1; |
891 } | 892 } |
892 } | 893 } |
893 | 894 |
971 int i, j, nd, nr; | 972 int i, j, nd, nr; |
972 int ret; | 973 int ret; |
973 const char *driver, *str; | 974 const char *driver, *str; |
974 char msg[256]; | 975 char msg[256]; |
975 SDL_Window *w; | 976 SDL_Window *w; |
976 SDL_RendererInfo renderer; | 977 SDL_RendererInfo info; |
977 | 978 |
978 /* Initializes the SDL subsystems. */ | 979 /* Initializes the SDL subsystems. */ |
979 ret = SDL_Init(0); | 980 ret = SDL_Init(0); |
980 if (ret != 0) | 981 if (ret != 0) |
981 return -1; | 982 return -1; |
1012 /* | 1013 /* |
1013 * Initialize. | 1014 * Initialize. |
1014 */ | 1015 */ |
1015 SDL_ATbegin( "Initializing video mode" ); | 1016 SDL_ATbegin( "Initializing video mode" ); |
1016 /* Initialize video mode. */ | 1017 /* Initialize video mode. */ |
1017 ret = SDL_VideoInit( driver, 0 ); | 1018 ret = SDL_VideoInit( driver ); |
1018 if (SDL_ATvassert( ret==0, "SDL_VideoInit( %s, 0 )", driver )) | 1019 if (SDL_ATvassert( ret==0, "SDL_VideoInit( %s, 0 )", driver )) |
1019 goto err_cleanup; | 1020 goto err_cleanup; |
1020 /* Check to see if it's the one we want. */ | 1021 /* Check to see if it's the one we want. */ |
1021 str = SDL_GetCurrentVideoDriver(); | 1022 str = SDL_GetCurrentVideoDriver(); |
1022 if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0)) | 1023 if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0)) |
1045 80, 60, SDL_WINDOW_SHOWN ); | 1046 80, 60, SDL_WINDOW_SHOWN ); |
1046 if (SDL_ATassert( "SDL_CreateWindow", w!=NULL )) | 1047 if (SDL_ATassert( "SDL_CreateWindow", w!=NULL )) |
1047 goto err_cleanup; | 1048 goto err_cleanup; |
1048 | 1049 |
1049 /* Get renderer info. */ | 1050 /* Get renderer info. */ |
1050 ret = SDL_GetRenderDriverInfo( j, &renderer ); | 1051 ret = SDL_GetRenderDriverInfo( j, &info ); |
1051 if (ret != 0) | 1052 if (ret != 0) |
1052 goto err_cleanup; | 1053 goto err_cleanup; |
1053 | 1054 |
1054 /* Set testcase name. */ | 1055 /* Set testcase name. */ |
1055 SDL_snprintf( msg, sizeof(msg), "Renderer %s", renderer.name ); | 1056 SDL_snprintf( msg, sizeof(msg), "Renderer %s", info.name ); |
1056 SDL_ATprintVerbose( 1, " %d) %s\n", j+1, renderer.name ); | 1057 SDL_ATprintVerbose( 1, " %d) %s\n", j+1, info.name ); |
1057 SDL_ATbegin( msg ); | 1058 SDL_ATbegin( msg ); |
1058 | 1059 |
1059 /* Set renderer. */ | 1060 /* Set renderer. */ |
1060 ret = SDL_CreateRenderer( w, j, 0 ); | 1061 renderer = SDL_CreateRenderer( w, j, 0 ); |
1061 if (SDL_ATassert( "SDL_CreateRenderer", ret==0 )) | 1062 if (SDL_ATassert( "SDL_CreateRenderer", renderer!=0 )) |
1062 goto err_cleanup; | 1063 goto err_cleanup; |
1063 | 1064 |
1064 /* | 1065 /* |
1065 * Run tests. | 1066 * Run tests. |
1066 */ | 1067 */ |