Mercurial > sdl-ios-xcode
comparison test/automated/render/render.c @ 3467:383c2058d973
pixels don't need to be dynamically allocated
Added a dump_screen() function to assist with test failure diagnosis
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 21 Nov 2009 05:25:08 +0000 |
parents | a288892cd24c |
children | da53c4046c65 |
comparison
equal
deleted
inserted
replaced
3466:a288892cd24c | 3467:383c2058d973 |
---|---|
56 static int render_compare( const char *msg, const SurfaceImage_t *s ) | 56 static int render_compare( const char *msg, const SurfaceImage_t *s ) |
57 { | 57 { |
58 (void) msg; | 58 (void) msg; |
59 (void) s; | 59 (void) s; |
60 int ret; | 60 int ret; |
61 void *pix; | 61 Uint8 pix[4*80*60]; |
62 SDL_Surface *testsur; | 62 SDL_Surface *testsur; |
63 | |
64 /* Allocate pixel space. */ | |
65 pix = malloc( 4*80*60 ); | |
66 if (SDL_ATassert( "malloc", pix!=NULL )) | |
67 return 1; | |
68 | 63 |
69 /* Read pixels. */ | 64 /* Read pixels. */ |
70 ret = SDL_RenderReadPixels( NULL, FORMAT, pix, 80*4 ); | 65 ret = SDL_RenderReadPixels( NULL, FORMAT, pix, 80*4 ); |
71 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) | 66 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) |
72 return 1; | 67 return 1; |
82 if (SDL_ATassert( msg, ret==0 )) | 77 if (SDL_ATassert( msg, ret==0 )) |
83 return 1; | 78 return 1; |
84 | 79 |
85 /* Clean up. */ | 80 /* Clean up. */ |
86 SDL_FreeSurface( testsur ); | 81 SDL_FreeSurface( testsur ); |
87 free(pix); | |
88 | 82 |
89 return 0; | 83 return 0; |
90 } | 84 } |
91 | 85 |
86 #if 0 | |
87 static int dump_screen( int index ) | |
88 { | |
89 int ret; | |
90 char name[1024]; | |
91 Uint8 pix[4*80*60]; | |
92 SDL_Surface *testsur; | |
93 SDL_RendererInfo info; | |
94 | |
95 /* Read pixels. */ | |
96 ret = SDL_RenderReadPixels( NULL, FORMAT, pix, 80*4 ); | |
97 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) | |
98 return 1; | |
99 | |
100 /* Create surface. */ | |
101 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, | |
102 RMASK, GMASK, BMASK, AMASK); | |
103 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL )) | |
104 return 1; | |
105 | |
106 /* Dump surface. */ | |
107 SDL_GetRendererInfo(&info); | |
108 sprintf(name, "%s-%s-%d.bmp", SDL_GetCurrentVideoDriver(), info.name, index); | |
109 SDL_SaveBMP(testsur, name); | |
110 | |
111 /* Clean up. */ | |
112 SDL_FreeSurface( testsur ); | |
113 | |
114 return 0; | |
115 } | |
116 #endif | |
92 | 117 |
93 /** | 118 /** |
94 * @brief Checks to see if functionality is supported. | 119 * @brief Checks to see if functionality is supported. |
95 */ | 120 */ |
96 static int render_isSupported( int code ) | 121 static int render_isSupported( int code ) |