comparison test/automated/render/render.c @ 3685:64ce267332c6

Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 21 Jan 2010 06:21:52 +0000
parents f638ded38b8a
children 35afe807b51c
comparison
equal deleted inserted replaced
3684:cc564f08884f 3685:64ce267332c6
41 static int render_testPrimitives (void); 41 static int render_testPrimitives (void);
42 static int render_testPrimitivesBlend (void); 42 static int render_testPrimitivesBlend (void);
43 static int render_testBlit (void); 43 static int render_testBlit (void);
44 static int render_testBlitColour (void); 44 static int render_testBlitColour (void);
45 static int render_testBlitAlpha (void); 45 static int render_testBlitAlpha (void);
46 static int render_testBlitBlendMode( SDL_TextureID tface, int mode ); 46 static int render_testBlitBlendMode( SDL_Texture * tface, int mode );
47 static int render_testBlitBlend (void); 47 static int render_testBlitBlend (void);
48 48
49 49
50 /** 50 /**
51 * @brief Compares screen pixels with image pixels. 51 * @brief Compares screen pixels with image pixels.
223 223
224 224
225 /** 225 /**
226 * @brief Loads the test face. 226 * @brief Loads the test face.
227 */ 227 */
228 static SDL_TextureID render_loadTestFace (void) 228 static SDL_Texture * render_loadTestFace (void)
229 { 229 {
230 SDL_Surface *face; 230 SDL_Surface *face;
231 SDL_TextureID tface; 231 SDL_Texture *tface;
232 232
233 /* Create face surface. */ 233 /* Create face surface. */
234 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, 234 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
235 img_face.width, img_face.height, 32, img_face.width*4, 235 img_face.width, img_face.height, 32, img_face.width*4,
236 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 236 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
259 */ 259 */
260 static int render_hasTexColor (void) 260 static int render_hasTexColor (void)
261 { 261 {
262 int fail; 262 int fail;
263 int ret; 263 int ret;
264 SDL_TextureID tface; 264 SDL_Texture *tface;
265 Uint8 r, g, b; 265 Uint8 r, g, b;
266 266
267 /* Get test face. */ 267 /* Get test face. */
268 tface = render_loadTestFace(); 268 tface = render_loadTestFace();
269 if (tface == 0) 269 if (tface == 0)
294 */ 294 */
295 static int render_hasTexAlpha (void) 295 static int render_hasTexAlpha (void)
296 { 296 {
297 int fail; 297 int fail;
298 int ret; 298 int ret;
299 SDL_TextureID tface; 299 SDL_Texture *tface;
300 Uint8 a; 300 Uint8 a;
301 301
302 /* Get test face. */ 302 /* Get test face. */
303 tface = render_loadTestFace(); 303 tface = render_loadTestFace();
304 if (tface == 0) 304 if (tface == 0)
604 */ 604 */
605 static int render_testBlit (void) 605 static int render_testBlit (void)
606 { 606 {
607 int ret; 607 int ret;
608 SDL_Rect rect; 608 SDL_Rect rect;
609 SDL_TextureID tface; 609 SDL_Texture *tface;
610 int i, j, ni, nj; 610 int i, j, ni, nj;
611 611
612 /* Clear surface. */ 612 /* Clear surface. */
613 if (render_clearScreen()) 613 if (render_clearScreen())
614 return -1; 614 return -1;
656 */ 656 */
657 static int render_testBlitColour (void) 657 static int render_testBlitColour (void)
658 { 658 {
659 int ret; 659 int ret;
660 SDL_Rect rect; 660 SDL_Rect rect;
661 SDL_TextureID tface; 661 SDL_Texture *tface;
662 int i, j, ni, nj; 662 int i, j, ni, nj;
663 663
664 /* Clear surface. */ 664 /* Clear surface. */
665 if (render_clearScreen()) 665 if (render_clearScreen())
666 return -1; 666 return -1;
714 */ 714 */
715 static int render_testBlitAlpha (void) 715 static int render_testBlitAlpha (void)
716 { 716 {
717 int ret; 717 int ret;
718 SDL_Rect rect; 718 SDL_Rect rect;
719 SDL_TextureID tface; 719 SDL_Texture *tface;
720 int i, j, ni, nj; 720 int i, j, ni, nj;
721 721
722 /* Clear surface. */ 722 /* Clear surface. */
723 if (render_clearScreen()) 723 if (render_clearScreen())
724 return -1; 724 return -1;
772 772
773 773
774 /** 774 /**
775 * @brief Tests a blend mode. 775 * @brief Tests a blend mode.
776 */ 776 */
777 static int render_testBlitBlendMode( SDL_TextureID tface, int mode ) 777 static int render_testBlitBlendMode( SDL_Texture * tface, int mode )
778 { 778 {
779 int ret; 779 int ret;
780 int i, j, ni, nj; 780 int i, j, ni, nj;
781 SDL_Rect rect; 781 SDL_Rect rect;
782 782
818 */ 818 */
819 static int render_testBlitBlend (void) 819 static int render_testBlitBlend (void)
820 { 820 {
821 int ret; 821 int ret;
822 SDL_Rect rect; 822 SDL_Rect rect;
823 SDL_TextureID tface; 823 SDL_Texture *tface;
824 int i, j, ni, nj; 824 int i, j, ni, nj;
825 int mode; 825 int mode;
826 826
827 /* Clear surface. */ 827 /* Clear surface. */
828 if (render_clearScreen()) 828 if (render_clearScreen())
1002 int failed; 1002 int failed;
1003 int i, j, nd, nr; 1003 int i, j, nd, nr;
1004 int ret; 1004 int ret;
1005 const char *driver, *str; 1005 const char *driver, *str;
1006 char msg[256]; 1006 char msg[256];
1007 SDL_WindowID wid; 1007 SDL_Window *w;
1008 SDL_RendererInfo renderer; 1008 SDL_RendererInfo renderer;
1009 1009
1010 /* Initializes the SDL subsystems. */ 1010 /* Initializes the SDL subsystems. */
1011 ret = SDL_Init(0); 1011 ret = SDL_Init(0);
1012 if (ret != 0) 1012 if (ret != 0)
1052 /* Check to see if it's the one we want. */ 1052 /* Check to see if it's the one we want. */
1053 str = SDL_GetCurrentVideoDriver(); 1053 str = SDL_GetCurrentVideoDriver();
1054 if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0)) 1054 if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0))
1055 goto err_cleanup; 1055 goto err_cleanup;
1056 /* Create window. */ 1056 /* Create window. */
1057 wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1057 w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
1058 80, 60, SDL_WINDOW_SHOWN ); 1058 80, 60, SDL_WINDOW_SHOWN );
1059 if (SDL_ATassert( "SDL_CreateWindow", wid!=0 )) 1059 if (SDL_ATassert( "SDL_CreateWindow", w!=NULL ))
1060 goto err_cleanup; 1060 goto err_cleanup;
1061 /* Check title. */ 1061 /* Check title. */
1062 str = SDL_GetWindowTitle( wid ); 1062 str = SDL_GetWindowTitle( w );
1063 if (SDL_ATassert( "SDL_GetWindowTitle", SDL_strcmp(msg,str)==0)) 1063 if (SDL_ATassert( "SDL_GetWindowTitle", SDL_strcmp(msg,str)==0))
1064 goto err_cleanup; 1064 goto err_cleanup;
1065 /* Get renderers. */ 1065 /* Get renderers. */
1066 nr = SDL_GetNumRenderDrivers(); 1066 nr = SDL_GetNumRenderDrivers();
1067 if (SDL_ATassert("SDL_GetNumRenderDrivers", nr>=0)) 1067 if (SDL_ATassert("SDL_GetNumRenderDrivers", nr>=0))
1070 SDL_ATend(); 1070 SDL_ATend();
1071 for (j=0; j<nr; j++) { 1071 for (j=0; j<nr; j++) {
1072 1072
1073 /* We have to recreate window each time, because opengl and opengles renderers */ 1073 /* We have to recreate window each time, because opengl and opengles renderers */
1074 /* both add SDL_WINDOW_OPENGL flag for window, that was last used */ 1074 /* both add SDL_WINDOW_OPENGL flag for window, that was last used */
1075 SDL_DestroyWindow(wid); 1075 SDL_DestroyWindow(w);
1076 wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1076 w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
1077 80, 60, SDL_WINDOW_SHOWN ); 1077 80, 60, SDL_WINDOW_SHOWN );
1078 if (SDL_ATassert( "SDL_CreateWindow", wid!=0 )) 1078 if (SDL_ATassert( "SDL_CreateWindow", w!=NULL ))
1079 goto err_cleanup; 1079 goto err_cleanup;
1080 1080
1081 /* Get renderer info. */ 1081 /* Get renderer info. */
1082 ret = SDL_GetRenderDriverInfo( j, &renderer ); 1082 ret = SDL_GetRenderDriverInfo( j, &renderer );
1083 if (ret != 0) 1083 if (ret != 0)
1087 SDL_snprintf( msg, sizeof(msg), "Renderer %s", renderer.name ); 1087 SDL_snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
1088 SDL_ATprintVerbose( 1, " %d) %s\n", j+1, renderer.name ); 1088 SDL_ATprintVerbose( 1, " %d) %s\n", j+1, renderer.name );
1089 SDL_ATbegin( msg ); 1089 SDL_ATbegin( msg );
1090 1090
1091 /* Set renderer. */ 1091 /* Set renderer. */
1092 ret = SDL_CreateRenderer( wid, j, 0 ); 1092 ret = SDL_CreateRenderer( w, j, 0 );
1093 if (SDL_ATassert( "SDL_CreateRenderer", ret==0 )) 1093 if (SDL_ATassert( "SDL_CreateRenderer", ret==0 ))
1094 goto err_cleanup; 1094 goto err_cleanup;
1095 1095
1096 /* 1096 /*
1097 * Run tests. 1097 * Run tests.