Report an error if creating a render target fails
parent
509898460c
commit
9cbd05df1e
|
@ -87,7 +87,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
SDL_bool
|
||||||
DrawComposite(DrawState *s)
|
DrawComposite(DrawState *s)
|
||||||
{
|
{
|
||||||
SDL_Rect viewport, R;
|
SDL_Rect viewport, R;
|
||||||
|
@ -167,9 +167,10 @@ DrawComposite(DrawState *s)
|
||||||
|
|
||||||
/* Update the screen! */
|
/* Update the screen! */
|
||||||
SDL_RenderPresent(s->renderer);
|
SDL_RenderPresent(s->renderer);
|
||||||
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
SDL_bool
|
||||||
Draw(DrawState *s)
|
Draw(DrawState *s)
|
||||||
{
|
{
|
||||||
SDL_Rect viewport;
|
SDL_Rect viewport;
|
||||||
|
@ -178,6 +179,10 @@ Draw(DrawState *s)
|
||||||
SDL_RenderGetViewport(s->renderer, &viewport);
|
SDL_RenderGetViewport(s->renderer, &viewport);
|
||||||
|
|
||||||
target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h);
|
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);
|
SDL_SetRenderTarget(s->renderer, target);
|
||||||
|
|
||||||
/* Draw the background */
|
/* Draw the background */
|
||||||
|
@ -206,6 +211,7 @@ Draw(DrawState *s)
|
||||||
|
|
||||||
/* Update the screen! */
|
/* Update the screen! */
|
||||||
SDL_RenderPresent(s->renderer);
|
SDL_RenderPresent(s->renderer);
|
||||||
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -280,9 +286,9 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
for (i = 0; i < state->num_windows; ++i) {
|
||||||
if (test_composite) {
|
if (test_composite) {
|
||||||
DrawComposite(&drawstates[i]);
|
if (!DrawComposite(&drawstates[i])) done = 1;
|
||||||
} else {
|
} else {
|
||||||
Draw(&drawstates[i]);
|
if (!Draw(&drawstates[i])) done = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue