MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / resize

Method resize

framework/hpp_api_vulkan_sample.cpp:108–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108bool HPPApiVulkanSample::resize(const uint32_t, const uint32_t)
109{
110 if (!prepared)
111 {
112 return false;
113 }
114
115 get_render_context().handle_surface_changes();
116
117 // Don't recreate the swapchain if the dimensions haven't changed
118 if (extent == get_render_context().get_surface_extent())
119 {
120 return false;
121 }
122
123 extent = get_render_context().get_surface_extent();
124
125 prepared = false;
126
127 // Ensure all operations on the device have been finished before destroying resources
128 get_device().get_handle().waitIdle();
129
130 create_swapchain_buffers();
131
132 // Recreate the frame buffers
133 get_device().get_handle().destroyImageView(depth_stencil.view);
134 get_device().get_handle().destroyImage(depth_stencil.image);
135 get_device().get_handle().freeMemory(depth_stencil.mem);
136 setup_depth_stencil();
137 for (uint32_t i = 0; i < framebuffers.size(); i++)
138 {
139 get_device().get_handle().destroyFramebuffer(framebuffers[i]);
140 framebuffers[i] = nullptr;
141 }
142 setup_framebuffer();
143
144 if (extent.width && extent.height && has_gui())
145 {
146 get_gui().resize(extent.width, extent.height);
147 }
148
149 rebuild_command_buffers();
150
151 get_device().get_handle().waitIdle();
152
153 if (extent.width && extent.height)
154 {
155 camera.update_aspect_ratio(static_cast<float>(extent.width) / static_cast<float>(extent.height));
156 }
157
158 // Notify derived class
159 view_changed();
160
161 prepared = true;
162 return true;
163}
164
165void HPPApiVulkanSample::create_render_context()

Callers 1

Calls 4

sizeMethod · 0.80
update_aspect_ratioMethod · 0.80
get_handleMethod · 0.45

Tested by

no test coverage detected