comparison test/automated/render/render.c @ 3466:a288892cd24c

SDL_RenderReadPixels() needs to flush asynchronous operations before it reads. The semantics are that it reads the back buffer, and those pixels may not be available once SDL_RenderPresent() has happened.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Nov 2009 05:05:19 +0000
parents 09136f534198
children 383c2058d973
comparison
equal deleted inserted replaced
3465:0cbfec87e4f1 3466:a288892cd24c
327 /* 327 /*
328 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) 328 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
329 return -1; 329 return -1;
330 */ 330 */
331 331
332 /* Flush all asynchronous operations */
333 SDL_RenderPresent();
334
335 return 0; 332 return 0;
336 } 333 }
337 334
338 335
339 /** 336 /**
410 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) 407 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
411 return -1; 408 return -1;
412 ret = SDL_RenderLine( 0, 60, 80, 0 ); 409 ret = SDL_RenderLine( 0, 60, 80, 0 );
413 if (SDL_ATassert( "SDL_RenderLine", ret == 0)) 410 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
414 return -1; 411 return -1;
415
416 /* Flush all asynchronous operations */
417 SDL_RenderPresent();
418 412
419 /* See if it's the same. */ 413 /* See if it's the same. */
420 if (render_compare( "Primitives output not the same.", &img_primitives )) 414 if (render_compare( "Primitives output not the same.", &img_primitives ))
421 return -1; 415 return -1;
422 416
531 if (SDL_ATassert( "SDL_RenderPoint", ret == 0)) 525 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
532 return -1; 526 return -1;
533 } 527 }
534 } 528 }
535 529
536 /* Flush all asynchronous operations */
537 SDL_RenderPresent();
538
539 /* See if it's the same. */ 530 /* See if it's the same. */
540 if (render_compare( "Blended primitives output not the same.", &img_blend )) 531 if (render_compare( "Blended primitives output not the same.", &img_blend ))
541 return -1; 532 return -1;
542 533
543 return 0; 534 return 0;
586 } 577 }
587 578
588 /* Clean up. */ 579 /* Clean up. */
589 SDL_DestroyTexture( tface ); 580 SDL_DestroyTexture( tface );
590 581
591 /* Flush all asynchronous operations */
592 SDL_RenderPresent();
593
594 /* See if it's the same. */ 582 /* See if it's the same. */
595 if (render_compare( "Blit output not the same.", &img_blit )) 583 if (render_compare( "Blit output not the same.", &img_blit ))
596 return -1; 584 return -1;
597 585
598 return 0; 586 return 0;
646 } 634 }
647 635
648 /* Clean up. */ 636 /* Clean up. */
649 SDL_DestroyTexture( tface ); 637 SDL_DestroyTexture( tface );
650 638
651 /* Flush all asynchronous operations */
652 SDL_RenderPresent();
653
654 /* See if it's the same. */ 639 /* See if it's the same. */
655 if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).", 640 if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).",
656 &img_blitColour )) 641 &img_blitColour ))
657 return -1; 642 return -1;
658 643
711 } 696 }
712 697
713 /* Clean up. */ 698 /* Clean up. */
714 SDL_DestroyTexture( tface ); 699 SDL_DestroyTexture( tface );
715 700
716 /* Flush all asynchronous operations */
717 SDL_RenderPresent();
718
719 /* See if it's the same. */ 701 /* See if it's the same. */
720 if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).", 702 if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
721 &img_blitAlpha )) 703 &img_blitAlpha ))
722 return -1; 704 return -1;
723 705
760 ret = SDL_RenderCopy( tface, NULL, &rect ); 742 ret = SDL_RenderCopy( tface, NULL, &rect );
761 if (SDL_ATassert( "SDL_RenderCopy", ret == 0)) 743 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
762 return -1; 744 return -1;
763 } 745 }
764 } 746 }
765
766 /* Flush all asynchronous operations */
767 SDL_RenderPresent();
768 747
769 return 0; 748 return 0;
770 } 749 }
771 750
772 751
880 } 859 }
881 } 860 }
882 861
883 /* Clean up. */ 862 /* Clean up. */
884 SDL_DestroyTexture( tface ); 863 SDL_DestroyTexture( tface );
885
886 /* Flush all asynchronous operations */
887 SDL_RenderPresent();
888 864
889 /* Check to see if matches. */ 865 /* Check to see if matches. */
890 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).", 866 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
891 &img_blendAll )) 867 &img_blendAll ))
892 return -1; 868 return -1;