AtomicBoolean windowIsResizing;
AtomicReference<VulkanExtent2D> windowExtent;

GLFW.glfwSetWindowSizeCallback(
  window,
  GLFWWindowSizeCallback.create((_, _, _) -> {
    windowIsResizing.set(true);
  })
);

GLFW.glfwSetFramebufferSizeCallback(
  window,
  GLFWFramebufferSizeCallback.create((_, width, height) -> {
    windowExtent.set(
      VulkanExtent2D.builder()
        .setWidth(width)
        .setHeight(height)
        .build());
  })
);

final int framesInFlight = 2;
int frameNumber = 0;
while (rendering) {
  this.windowIsResizing.set(false);
  GLFW.glfwPollEvents();

  if (!windowIsResizing.get()) {
    final var frameIndex =
      new JCSwapchainFrameIndex(frameNumber % framesInFlight);
    final var frame = swapChainManager.acquire(frameIndex);

    // Record commands, then submit and present:
    final var submitInfo =
      JCSwapchainSubmitInfo.builder()
        .addCommandBuffers(commandBuffer)
        .build();
    frame.submitAndPresent(submitInfo);
    ++frameNumber;
  } else {
    pauseOneFrame();
  }
}
