Skip to content

Commit d69a111

Browse files
committed
Set window size according to loaded image
1 parent 0148f60 commit d69a111

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

26_Autoexposure/main.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,21 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
275275
return false;
276276
m_gpuImg->setObjectDebugName("Autoexposure Image");
277277

278+
// set window size
279+
const auto imageExtent = m_gpuImg->getCreationParameters().extent;
280+
const VkExtent2D newWindowResolution = { imageExtent.width, imageExtent.height };
281+
282+
if (newWindowResolution.width != m_window->getWidth() || newWindowResolution.height != m_window->getHeight())
283+
{
284+
// Resize the window
285+
m_winMgr->setWindowSize(m_window.get(), newWindowResolution.width, newWindowResolution.height);
286+
// Don't want to rely on the Swapchain OUT_OF_DATE causing an implicit re-create in the `acquireNextImage` because the
287+
// swapchain may report OUT_OF_DATE after the next VBlank after the resize, not getting the message right away.
288+
m_surface->recreateSwapchain();
289+
}
290+
// Now show the window (ideally should happen just after present, but don't want to mess with acquire/recreation)
291+
m_winMgr->show(m_window.get());
292+
278293
// we don't want to overcomplicate the example with multi-queue
279294
auto queue = getGraphicsQueue();
280295
auto cmdbuf = m_cmdBufs[0].get();
@@ -314,14 +329,14 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
314329
IGPUImage::LAYOUT::TRANSFER_DST_OPTIMAL,
315330
cpuImgParams.image->getRegions()
316331
);
317-
318332
IGPUImageView::SCreationParams gpuImgViewParams = {
319333
.image = m_gpuImg,
320334
.viewType = IGPUImageView::ET_2D_ARRAY,
321335
.format = m_gpuImg->getCreationParameters().format
322336
};
323337

324338
m_gpuImgView = m_device->createImageView(std::move(gpuImgViewParams));
339+
queue->endCapture();
325340
}
326341

327342
return true;
@@ -334,7 +349,7 @@ class AutoexposureApp final : public examples::SimpleWindowedApplication, public
334349

335350
inline bool keepRunning() override
336351
{
337-
return false;
352+
return true;
338353
}
339354

340355
inline bool onAppTerminated() override

0 commit comments

Comments
 (0)