when the window size has been changed, how can i do to remain one of view size in vsg mulitviews sample? #725
-
In the multiviews sample, when i adjust the window size, The two view size should be changed at same time. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The resizing the vsg::View's viewport and adjustment of the Camera projection matrices in response to a window resize is handled by the vsg::WindowResizeHandler class: https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/app/WindowResizeHandler.h The vsg::RenderGraph that handles the rendering for a window "has a" WindowSizeHandler that is automatically assigned in the RenderGraph constructor: https://github.com/vsg-dev/VulkanSceneGraph/blob/master/src/vsg/app/RenderGraph.cpp#L29 The WindowResizeHandler is invoked automatically by the RenderGraph::resized() method, you don't need to call this as it's handled for you: https://github.com/vsg-dev/VulkanSceneGraph/blob/master/src/vsg/app/RenderGraph.cpp#L147 The WindowResizeHandler just teats all View's the same are resizes the viewport and associated pojection matrix to retain the same width/height ratios that each View had before the resize. However, it doesn't have any mechanism for handling the usage case you describe, so out of the box the VSG can't do what you want. I personally haven't tried to implement what you describe but the approach I would take would be to write a subclass from vsg::WindowResizeHandler that overrides the apply(View&) method and provides the different behavior for the different views within this custom method. The present implementation looks like: https://github.com/vsg-dev/VulkanSceneGraph/blob/master/src/vsg/app/WindowResizeHandler.cpp#L107 Note, Vulkan supports multiple viewports per ViewportState as part of the multiview extension, for the vast majority of applications there will just be one viewport entry and in your own code you can probably make this simplification. multiview is typically used for things like rendering of stereo images for HMDs. To identify the View's and how you want to teat them you'll need to add a meta value to the View, or assign a ref_ptr or oberser_ptr with the behavior option to the custom WindowResizehandler, then use this in your custom apply(View&) method. The VSG's meta value scheme is used like:
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
hi Robert, |
Beta Was this translation helpful? Give feedback.
The resizing the vsg::View's viewport and adjustment of the Camera projection matrices in response to a window resize is handled by the vsg::WindowResizeHandler class:
https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/app/WindowResizeHandler.h
The vsg::RenderGraph that handles the rendering for a window "has a" WindowSizeHandler that is automatically assigned in the RenderGraph constructor:
https://github.com/vsg-dev/VulkanSceneGraph/blob/master/src/vsg/app/RenderGraph.cpp#L29
The WindowResizeHandler is invoked automatically by the RenderGraph::resized() method, you don't need to call this as it's handled for you:
https://github.com/vsg-dev/VulkanSceneGraph/blob/master/s…