support closing the Window with 'q' or ESC on linux
This commit is contained in:
parent
8c38903445
commit
6570f7fafc
1 changed files with 15 additions and 6 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue