【发布时间】:2019-04-01 07:50:00
【问题描述】:
我已按照https://vulkan-tutorial.com 的教程进行操作...我在没有使用 GLFW 扩展的情况下创建了它。到目前为止,我已经完成了“交换链娱乐”,一切都已正确设置和渲染。
但是,我似乎无法正常调整大小!
我已经连接到 XCB_RESIZE_REQUEST 并正在设置我的信息结构,如下所示:
if (resize->width > 0) { info.width = resize->width; }
if (resize->height > 0) { info.height = resize->height; }
info.framebufferResized = true;
导致(在下一次drawFrame() 调用中)recreateSwapchain() 被调用:
if (res == VK_ERROR_OUT_OF_DATE_KHR || res == VK_SUBOPTIMAL_KHR || info.framebufferResized) {
info.framebufferResized = false;
recreateSwapchain();
} else if (res != VK_SUCCESS) {
throw runtime_error("failed to present swap chain image!");
}
recreateSwapchain() {
vkDeviceWaitIdle(info.device);
cleanupSwapchain();
querySwapchainSupport(info.physicalDevice);
createSwapchain();
createImageViews();
createRenderPass();
createGraphicsPipeline();
createFramebuffers();
createCommandBuffers();
}
我做了一些调试,发现swapchainSupport.capabilities.minImageExtent.width(和高度)并没有从初始值改变!..就是这个调用
querySwapchainSupport(VkPhysicalDevice physicalDevice) {
VkResult res = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
physicalDevice, info.surface, &info.swapchainSupport.capabilities);
assert(res == VK_SUCCESS);
不使用新的窗口大小更新info.swapchainSupport.capabilities。
任何帮助或 cmets 将不胜感激。
示例截图:
【问题讨论】:
-
我宁愿不使用诸如 GLFW 之类的库。因为我很可能希望在某个时候定位移动设备;
-
你为什么看
minImageExtent而不是currentExtent? -
当前、最小值和最大值都保持不变:800x600