From 6570f7fafce8949c9779e090b7bd1e7ec0fd624a Mon Sep 17 00:00:00 2001 From: /jedi/ Date: Tue, 6 Nov 2018 09:40:27 +0100 Subject: [PATCH] support closing the Window with 'q' or ESC on linux --- src/hal/linux.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/hal/linux.cpp b/src/hal/linux.cpp index 72dbe2e..c5ebd9e 100644 --- a/src/hal/linux.cpp +++ b/src/hal/linux.cpp @@ -18,16 +18,19 @@ void hal_init() { exit(1); } - - /* //Create window - window = SDL_CreateWindow( "SDL Tutorial", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN|SDL_WINDOW_BORDERLESS ); - if( window == NULL ) { + //Create window + window = SDL_CreateWindow("SDL Tutorial", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, + SDL_WINDOW_SHOWN); //|SDL_WINDOW_BORDERLESS + if (window == nullptr) { printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() ); exit(1); } - */ - SDL_CreateWindowAndRenderer(SCREEN_WIDTH, SCREEN_HEIGHT, 0, &window, &renderer); + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + if (renderer == nullptr) { + printf("Renderer could not be created! SDL_Error: %s\n", SDL_GetError()); + exit(1); + } } @@ -62,6 +65,10 @@ void hal_render() { case SDLK_DOWN: input[I_DOWN]=true; break; + case 'q': + case 0x1b: //ESC + quit = true; + break; } break; @@ -79,6 +86,8 @@ void hal_render() { case SDLK_DOWN: input[I_DOWN]=false; break; + default: + printf("key %x\n", event.key.keysym.sym); } break;