Skip to content
Snippets Groups Projects
Commit 55f9c51c authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#34] Correct camera aspect ratio on resize

parent 2b83be1a
No related branches found
No related tags found
1 merge request!43Resolve "Resizing-Event"
......@@ -18,6 +18,14 @@ int main(int argc, const char** argv) {
vkcv::CameraManager cameraManager(window, window.getWidth(), window.getHeight());
window.initEvents();
window.e_resize.add([&cameraManager](int width, int height) {
auto& camera = cameraManager.getCamera();
float near;
float far;
camera.getNearFar(near, far);
const float aspectRatio = static_cast<float>(width) / height;
camera.setPerspective(camera.getFov(), aspectRatio, near, far);
});
vkcv::Core core = vkcv::Core::create(
window,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment