comparison test/automated/render/render.c @ 3738:c875baafce36 gsoc2009_unit_tests

Changed placeholder for SDL_ReadPixels.
author Edgar Simo <bobbens@gmail.com>
date Sun, 02 Aug 2009 15:41:49 +0000
parents 27b4b4d71011
children 651b261e591d
comparison
equal deleted inserted replaced
3737:9689eaa6d2e3 3738:c875baafce36
54 */ 54 */
55 static int render_compare( const char *msg, const SurfaceImage_t *s ) 55 static int render_compare( const char *msg, const SurfaceImage_t *s )
56 { 56 {
57 (void) msg; 57 (void) msg;
58 (void) s; 58 (void) s;
59 #if 0
60 int ret; 59 int ret;
61 void *pix; 60 void *pix;
62 SDL_Surface *testsur; 61 SDL_Surface *testsur;
63 62
64 /* Allocate pixel space. */ 63 /* Allocate pixel space. */
65 pix = malloc( 4*80*60 ); 64 pix = malloc( 4*80*60 );
66 if (SDL_ATassert( "malloc", pix!=NULL )) 65 if (SDL_ATassert( "malloc", pix!=NULL ))
67 return 1; 66 return 1;
68 67
69 /* Read pixels. */ 68 /* Read pixels. */
69 #if 0
70 ret = SDL_RenderReadPixels( NULL, pix, 80*4 ); 70 ret = SDL_RenderReadPixels( NULL, pix, 80*4 );
71 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) 71 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
72 return 1; 72 return 1;
73 #else
74 int i, j;
75 Uint8 *buf = pix;
76 const Uint8 *read_pix;
77 Uint8 *write_pix;
78 for (j=0; j<s->height; j++) {
79 for (i=0; i<s->width; i++) {
80 read_pix = &s->pixel_data[ (j*80 + i) * s->bytes_per_pixel ];
81 write_pix = &buf[ (j*80 + i) * 4 ];
82 write_pix[0] = read_pix[0];
83 write_pix[1] = read_pix[1];
84 write_pix[2] = read_pix[2];
85 write_pix[3] = SDL_ALPHA_OPAQUE;
86 }
87 }
88 #endif
73 89
74 /* Create surface. */ 90 /* Create surface. */
75 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, 91 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4,
76 RMASK, GMASK, BMASK, AMASK ); 92 RMASK, GMASK, BMASK, AMASK );
77 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL )) 93 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL ))
83 return 1; 99 return 1;
84 100
85 /* Clean up. */ 101 /* Clean up. */
86 SDL_FreeSurface( testsur ); 102 SDL_FreeSurface( testsur );
87 free(pix); 103 free(pix);
88 #endif
89 104
90 return 0; 105 return 0;
91 } 106 }
92 107
93 108