diff options
Diffstat (limited to 'src/renderer.c')
-rw-r--r-- | src/renderer.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/renderer.c b/src/renderer.c index 3f01e88..d68287c 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -327,6 +327,12 @@ static int r_xsection_alloc(SDL_Renderer *renderer, SDL_Texture **texture, int old_width, old_height; if (*texture) { + if (!width || !height) { + SDL_DestroyTexture(*texture); + *texture = NULL; + return 0; + } + SDL_QueryTexture(*texture, NULL, NULL, &old_width, &old_height); if (old_width != width || old_height != height) { @@ -335,6 +341,9 @@ static int r_xsection_alloc(SDL_Renderer *renderer, SDL_Texture **texture, } } + if (!width || !height) + return 0; + if (!*texture) { *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_BGR888, SDL_TEXTUREACCESS_STREAMING, @@ -405,6 +414,9 @@ int r_xsection_update(r_window *rw, r_xsection *xsection, phy_sim *sim, return 1; } + if (!width || !height) + return 0; + SDL_LockTexture(xsection->texture, NULL, (void**)&pixels, &pitch); if (flags & XSECTION_XY) { |