summaryrefslogtreecommitdiff
path: root/src/renderer.c
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2016-04-06 00:26:28 +0200
committerPaweł Redman <pawel.redman@gmail.com>2016-04-06 00:26:28 +0200
commit5659a1baba94d10f76e72c8bbb9fa7576ab4f19b (patch)
tree1f096951e2233dc897c5c083eac3a700fa27ecca /src/renderer.c
parentc7acaee6651a84ef9102b29350c37803c8f435a9 (diff)
Proper console, run-time sim editing.
Diffstat (limited to 'src/renderer.c')
-rw-r--r--src/renderer.c12
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) {