Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Report an error if creating a render target fails
  • Loading branch information
slouken committed Oct 4, 2013
1 parent 5098984 commit 9cbd05d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/testrendertarget.c
Expand Up @@ -87,7 +87,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
return texture;
}

void
SDL_bool
DrawComposite(DrawState *s)
{
SDL_Rect viewport, R;
Expand Down Expand Up @@ -167,9 +167,10 @@ DrawComposite(DrawState *s)

/* Update the screen! */
SDL_RenderPresent(s->renderer);
return SDL_TRUE;
}

void
SDL_bool
Draw(DrawState *s)
{
SDL_Rect viewport;
Expand All @@ -178,6 +179,10 @@ Draw(DrawState *s)
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 */
Expand Down Expand Up @@ -206,6 +211,7 @@ Draw(DrawState *s)

/* Update the screen! */
SDL_RenderPresent(s->renderer);
return SDL_TRUE;
}

int
Expand Down Expand Up @@ -280,9 +286,9 @@ main(int argc, char *argv[])
}
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;
}
}
}
Expand Down

0 comments on commit 9cbd05d

Please sign in to comment.