mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-16 17:02:32 +00:00
Handle resize in the triangle example
This commit is contained in:
parent
7b0217d51c
commit
637a0883e7
@ -188,15 +188,35 @@ int main() {
|
||||
#error "Unsupported WGPU_TARGET"
|
||||
#endif
|
||||
|
||||
int prev_width = 0;
|
||||
int prev_height = 0;
|
||||
glfwGetWindowSize(window, &prev_width, &prev_height);
|
||||
|
||||
WGPUSwapChainId swap_chain = wgpu_device_create_swap_chain(device, surface,
|
||||
&(WGPUSwapChainDescriptor){
|
||||
.usage = WGPUTextureUsageFlags_OUTPUT_ATTACHMENT,
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.width = 640,
|
||||
.height = 480,
|
||||
.width = prev_width,
|
||||
.height = prev_height,
|
||||
});
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
glfwGetWindowSize(window, &width, &height);
|
||||
if (width != prev_width || height != prev_height) {
|
||||
prev_width = width;
|
||||
prev_height = height;
|
||||
|
||||
swap_chain = wgpu_device_create_swap_chain(device, surface,
|
||||
&(WGPUSwapChainDescriptor){
|
||||
.usage = WGPUTextureUsageFlags_OUTPUT_ATTACHMENT,
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.width = width,
|
||||
.height = height,
|
||||
});
|
||||
}
|
||||
|
||||
WGPUSwapChainOutput next_texture =
|
||||
wgpu_swap_chain_get_next_texture(swap_chain);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user