aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-12-04 22:18:19 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-12-04 22:18:19 +0000
commit71c7ff06d8f4bbaa9e7b64b67abbcac5367f40fa (patch)
tree52c7689c845d9e0c7fc001f4b088fe5b980b284f /src
parentc36ef928e82170d174517002867ef6ccda3c7c2a (diff)
downloadimv-71c7ff06d8f4bbaa9e7b64b67abbcac5367f40fa.tar.gz
Handle null window/renderer gracefully
Diffstat (limited to 'src')
-rw-r--r--src/main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 009e35c..6e09339 100644
--- a/src/main.c
+++ b/src/main.c
@@ -223,10 +223,21 @@ int main(int argc, char** argv)
SDL_WINDOWPOS_CENTERED,
width, height,
SDL_WINDOW_RESIZABLE);
+ if(!window) {
+ fprintf(stderr, "SDL Failed to create window: %s\n", SDL_GetError());
+ SDL_Quit();
+ exit(1);
+ }
/* we'll use SDL's built-in renderer, hardware accelerated if possible */
SDL_Renderer *renderer =
SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+ if(!renderer) {
+ fprintf(stderr, "SDL Failed to create renderer: %s\n", SDL_GetError());
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+ exit(1);
+ }
/* use the appropriate resampling method */
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,