Report an error if creating a render target fails
authorSam Lantinga <slouken@libsdl.org>
Thu, 03 Oct 2013 21:41:09 -0700
changeset 7781 3023b0270c94
parent 7780 e45655d26582
child 7782 e4ed6e54101e
Report an error if creating a render target fails
test/testrendertarget.c
--- a/test/testrendertarget.c	Thu Oct 03 20:48:52 2013 -0700
+++ b/test/testrendertarget.c	Thu Oct 03 21:41:09 2013 -0700
@@ -87,7 +87,7 @@
     return texture;
 }
 
-void
+SDL_bool
 DrawComposite(DrawState *s)
 {
     SDL_Rect viewport, R;
@@ -167,9 +167,10 @@
 
     /* Update the screen! */
     SDL_RenderPresent(s->renderer);
+    return SDL_TRUE;
 }
 
-void
+SDL_bool
 Draw(DrawState *s)
 {
     SDL_Rect viewport;
@@ -178,6 +179,10 @@
     SDL_RenderGetViewport(s->renderer, &viewport);
 
     target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h);
+    if (!target) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError());
+        return SDL_FALSE;
+    }
     SDL_SetRenderTarget(s->renderer, target);
 
     /* Draw the background */
@@ -206,6 +211,7 @@
 
     /* Update the screen! */
     SDL_RenderPresent(s->renderer);
+    return SDL_TRUE;
 }
 
 int
@@ -280,9 +286,9 @@
         }
         for (i = 0; i < state->num_windows; ++i) {
             if (test_composite) {
-                DrawComposite(&drawstates[i]);
+                if (!DrawComposite(&drawstates[i])) done = 1;
             } else {
-                Draw(&drawstates[i]);
+                if (!Draw(&drawstates[i])) done = 1;
             }
         }
     }