   let cycles_cnt = 0;
 
   while is_running {
+    // Poll window events
+    sdl_step();
+
     // Get elapsed seconds (from start of loop)
     clk += float64(clock() - clk_o) / float64(CLOCKS_PER_SEC);
     clk_o = clock();


    // A single frame takes at least 70224 cycles to render
    if cycles_cnt >= 70224 {
      sdl_step();
      cycles_cnt = 0;
    }
  }

  // Create renderer
  _renderer = SDL_CreateRenderer(_window, -1,
    SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

  // White initial screen
  SDL_SetRenderDrawColor(_renderer, 255, 255, 255, 255);
  SDL_RenderClear(_renderer);
  SDL_RenderPresent(_renderer);
}

def sdl_fini() {
