Added a test to check the read/write pixels API
authorSam Lantinga <slouken@libsdl.org>
Mon, 14 Dec 2009 06:35:59 +0000
changeset 35585f038ec1a1af
parent 3557 7184580ab756
child 3559 5f26a7eb5ff0
Added a test to check the read/write pixels API
test/automated/common/common.c
test/automated/render/render.c
     1.1 --- a/test/automated/common/common.c	Mon Dec 14 06:35:27 2009 +0000
     1.2 +++ b/test/automated/common/common.c	Mon Dec 14 06:35:59 2009 +0000
     1.3 @@ -82,7 +82,6 @@
     1.4  
     1.5        bpp = sur->format->BytesPerPixel;
     1.6  
     1.7 -      /* Compare image - should be same format. */
     1.8        if (bpp == 4) {
     1.9           for (j=0; j<sur->h; j++) {
    1.10              for (i=0; i<sur->w; i++) {
     2.1 --- a/test/automated/render/render.c	Mon Dec 14 06:35:27 2009 +0000
     2.2 +++ b/test/automated/render/render.c	Mon Dec 14 06:35:59 2009 +0000
     2.3 @@ -37,6 +37,7 @@
     2.4  static int render_hasTexAlpha (void);
     2.5  static int render_clearScreen (void);
     2.6  /* Testcases. */
     2.7 +static int render_testReadWrite (void);
     2.8  static int render_testPrimitives (void);
     2.9  static int render_testPrimitivesBlend (void);
    2.10  static int render_testBlit (void);
    2.11 @@ -363,6 +364,31 @@
    2.12  
    2.13  
    2.14  /**
    2.15 + * @brief Test reading and writing framebuffer
    2.16 + */
    2.17 +static int render_testReadWrite (void)
    2.18 +{
    2.19 +   int ret;
    2.20 +   SDL_Rect rect;
    2.21 +
    2.22 +   /* Write pixels. */
    2.23 +   rect.x = 0;
    2.24 +   rect.y = 0;
    2.25 +   rect.w = 80;
    2.26 +   rect.h = 60;
    2.27 +   ret = SDL_RenderWritePixels( &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel );
    2.28 +   if (SDL_ATassert( "SDL_RenderWritePixels", ret==0) )
    2.29 +      return 1;
    2.30 +
    2.31 +   /* See if it's the same. */
    2.32 +   if (render_compare( "Read/write output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE ))
    2.33 +      return -1;
    2.34 +
    2.35 +   return 0;
    2.36 +}
    2.37 +
    2.38 +
    2.39 +/**
    2.40   * @brief Tests the SDL primitives for rendering.
    2.41   */
    2.42  static int render_testPrimitives (void)
    2.43 @@ -932,6 +958,9 @@
    2.44        SDL_ATprintVerbose( 1, "      Texture Alpha Mod supported\n" );
    2.45  
    2.46     /* Software surface blitting. */
    2.47 +   ret = render_testReadWrite();
    2.48 +   if (ret)
    2.49 +      return -1;
    2.50     ret = render_testPrimitives();
    2.51     if (ret)
    2.52        return -1;