diff test/automated/render/render.c @ 5156:3e4086b3bcd2

Fixed compiling with the latest API changes
author Sam Lantinga <slouken@libsdl.org>
date Wed, 02 Feb 2011 14:34:24 -0800
parents e743b9c3f6d6
children e2b3f003e085
line wrap: on
line diff
--- a/test/automated/render/render.c	Tue Feb 01 21:51:54 2011 -0800
+++ b/test/automated/render/render.c	Wed Feb 02 14:34:24 2011 -0800
@@ -25,6 +25,7 @@
 #define FACE_W       img_face.width
 #define FACE_H       img_face.height
 
+static SDL_Renderer *renderer;
 
 /*
  * Prototypes.
@@ -67,7 +68,7 @@
    rect.y = 0;
    rect.w = 80;
    rect.h = 60;
-   ret = SDL_RenderReadPixels( &rect, FORMAT, pix, 80*4 );
+   ret = SDL_RenderReadPixels(renderer, &rect, FORMAT, pix, 80*4 );
    if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
       return 1;
 
@@ -98,7 +99,7 @@
    SDL_RendererInfo info;
 
    /* Read pixels. */
-   ret = SDL_RenderReadPixels( NULL, FORMAT, pix, 80*4 );
+   ret = SDL_RenderReadPixels(renderer, NULL, FORMAT, pix, 80*4 );
    if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
       return 1;
 
@@ -109,7 +110,7 @@
       return 1;
 
    /* Dump surface. */
-   SDL_GetRendererInfo(&info);
+   SDL_GetRendererInfo(renderer,&info);
    sprintf(name, "%s-%s-%d.bmp", SDL_GetCurrentVideoDriver(), info.name, index);
    SDL_SaveBMP(testsur, name);
 
@@ -140,14 +141,14 @@
    fail = 0;
 
    /* Set colour. */
-   ret = SDL_SetRenderDrawColor( 100, 100, 100, 100 );
+   ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawColor( &r, &g, &b, &a );
+   ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
    if (!render_isSupported(ret))
       fail = 1;
    /* Restore natural. */
-   ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
    if (!render_isSupported(ret))
       fail = 1;
 
@@ -172,28 +173,28 @@
 
    fail = 0;
 
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
    if (!render_isSupported(ret))
       fail = 1;
    ret = (mode != SDL_BLENDMODE_BLEND);
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
    if (!render_isSupported(ret))
       fail = 1;
    ret = (mode != SDL_BLENDMODE_ADD);
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
    if (!render_isSupported(ret))
       fail = 1;
    ret = (mode != SDL_BLENDMODE_NONE);
@@ -229,7 +230,7 @@
          );
    if (face == NULL)
       return 0;
-   tface = SDL_CreateTextureFromSurface( 0, face );
+   tface = SDL_CreateTextureFromSurface(renderer, 0, face );
    SDL_FreeSurface(face);
 
    return tface;
@@ -316,26 +317,26 @@
    int ret;
 
    /* Set colour. */
-   ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
    /*
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
    */
 
    /* Clear screen. */
-   ret = SDL_RenderFillRect( NULL );
+   ret = SDL_RenderFillRect(renderer, NULL );
    /*
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    */
 
    /* Set defaults. */
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    /*
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
    */
-   ret = SDL_SetRenderDrawColor( 255, 255, 255, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE );
    /*
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
@@ -358,7 +359,7 @@
    rect.y = 0;
    rect.w = 80;
    rect.h = 60;
-   ret = SDL_RenderWritePixels( &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel );
+   ret = SDL_RenderWritePixels(renderer, &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel );
    if (SDL_ATassert( "SDL_RenderWritePixels", ret==0) )
       return 1;
 
@@ -392,10 +393,10 @@
    rect.y = 0;
    rect.w = 40;
    rect.h = 80;
-   ret = SDL_SetRenderDrawColor( 13, 73, 200, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
 
@@ -404,10 +405,10 @@
    rect.y = 10;
    rect.w = 60;
    rect.h = 40;
-   ret = SDL_SetRenderDrawColor( 200, 0, 100, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
 
@@ -418,41 +419,41 @@
    for (y=0; y<3; y++) {
       x = y % 2;
       for (; x<80; x+=2) {
-         ret = SDL_SetRenderDrawColor( x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
+         ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
          if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
             return -1;
-         ret = SDL_RenderDrawPoint( x, y );
+         ret = SDL_RenderDrawPoint(renderer, x, y );
          if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
             return -1;
       }
    }
 
    /* Draw some lines. */
-   ret = SDL_SetRenderDrawColor( 0, 255, 0, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 0, 30, 80, 30 );
+   ret = SDL_RenderDrawLine(renderer, 0, 30, 80, 30 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawColor( 55, 55, 5, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 40, 30, 40, 60 );
+   ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawColor( 5, 105, 105, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 0, 0, 29, 29 );
+   ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 29, 30, 0, 59 );
+   ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 79, 0, 50, 29 );
+   ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 79, 59, 50, 30 );
+   ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
 
@@ -482,77 +483,77 @@
       return 0;
 
    /* Create some rectangles for each blend mode. */
-   ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 );
+   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( NULL );
+   ret = SDL_RenderFillRect(renderer, NULL );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    rect.x = 10;
    rect.y = 25;
    rect.w = 40;
    rect.h = 25;
-   ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 );
+   ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    rect.x = 30;
    rect.y = 40;
    rect.w = 45;
    rect.h = 15;
-   ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 );
+   ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    rect.x = 25;
    rect.y = 25;
    rect.w = 25;
    rect.h = 25;
-   ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 );
+   ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
 
    /* Draw blended lines, lines for everyone. */
    for (i=0; i<SCREEN_W; i+=2)  {
-      ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
+      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
       if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
          return -1;
-      ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
-            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
+      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
+            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
       if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
          return -1;
-      ret = SDL_RenderDrawLine( 0, 0, i, 59 );
+      ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 );
       if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
          return -1;
    }
    for (i=0; i<SCREEN_H; i+=2)  {
-      ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
+      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
       if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
          return -1;
-      ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
-            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
+      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
+            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
       if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
          return -1;
-      ret = SDL_RenderDrawLine( 0, 0, 79, i );
+      ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i );
       if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
          return -1;
    }
@@ -560,14 +561,14 @@
    /* Draw points. */
    for (j=0; j<SCREEN_H; j+=3) {
       for (i=0; i<SCREEN_W; i+=3) {
-         ret = SDL_SetRenderDrawColor( j*4, i*3, j*4, i*3 );
+         ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 );
          if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
             return -1;
-         ret = SDL_SetRenderDrawBlendMode( ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
-               ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
+         ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
+               ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
          if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
             return -1;
-         ret = SDL_RenderDrawPoint( i, j );
+         ret = SDL_RenderDrawPoint(renderer, i, j );
          if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
             return -1;
       }
@@ -616,7 +617,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -673,7 +674,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -735,7 +736,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -785,7 +786,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -885,7 +886,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -973,7 +974,7 @@
    const char *driver, *str;
    char msg[256];
    SDL_Window *w;
-   SDL_RendererInfo renderer;
+   SDL_RendererInfo info;
 
    /* Initializes the SDL subsystems. */
    ret = SDL_Init(0);
@@ -1014,7 +1015,7 @@
        */
       SDL_ATbegin( "Initializing video mode" );
       /* Initialize video mode. */
-      ret = SDL_VideoInit( driver, 0 );
+      ret = SDL_VideoInit( driver );
       if (SDL_ATvassert( ret==0, "SDL_VideoInit( %s, 0 )", driver ))
          goto err_cleanup;
       /* Check to see if it's the one we want. */
@@ -1047,18 +1048,18 @@
             goto err_cleanup;
 
          /* Get renderer info. */
-         ret = SDL_GetRenderDriverInfo( j, &renderer );
+         ret = SDL_GetRenderDriverInfo( j, &info );
          if (ret != 0)
             goto err_cleanup;
 
          /* Set testcase name. */
-         SDL_snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
-         SDL_ATprintVerbose( 1, "    %d) %s\n", j+1, renderer.name );
+         SDL_snprintf( msg, sizeof(msg), "Renderer %s", info.name );
+         SDL_ATprintVerbose( 1, "    %d) %s\n", j+1, info.name );
          SDL_ATbegin( msg );
 
          /* Set renderer. */
-         ret = SDL_CreateRenderer( w, j, 0 );
-         if (SDL_ATassert( "SDL_CreateRenderer", ret==0 ))
+         renderer = SDL_CreateRenderer( w, j, 0 );
+         if (SDL_ATassert( "SDL_CreateRenderer", renderer!=0 ))
             goto err_cleanup;
 
          /*