support closing the Window with 'q' or ESC on linux

This commit is contained in:
j3d1 2018-11-06 09:40:27 +01:00
parent 8c38903445
commit 6570f7fafc

View file

@ -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;