From 268f6782217e55d6c3ffe3b4970876e88fa2dc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 2 Sep 2012 18:06:22 +0200 Subject: [PATCH] SceneGraph: Camera aspect ratio was not fixed after changing policy. Also added test for projectionSize(), which couldn't be added before because of gl*() calls. --- src/SceneGraph/Camera.cpp | 6 +++++- src/SceneGraph/Camera.h | 3 +-- src/SceneGraph/Test/CameraTest.cpp | 15 ++++++++++++++- src/SceneGraph/Test/CameraTest.h | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/SceneGraph/Camera.cpp b/src/SceneGraph/Camera.cpp index 4d6d3f305..13484dfdc 100644 --- a/src/SceneGraph/Camera.cpp +++ b/src/SceneGraph/Camera.cpp @@ -47,8 +47,12 @@ template Matrix4 aspectRatioFix(AspectRatioPolicy, const Vector2&, cons template Camera::Camera(ObjectType* parent): ObjectType(parent), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) {} -template void Camera::setViewport(const Math::Vector2& size) { +template void Camera::setAspectRatioPolicy(AspectRatioPolicy policy) { + _aspectRatioPolicy = policy; + fixAspectRatio(); +} +template void Camera::setViewport(const Math::Vector2& size) { _viewport = size; fixAspectRatio(); } diff --git a/src/SceneGraph/Camera.h b/src/SceneGraph/Camera.h index df3f82e61..b3104292c 100644 --- a/src/SceneGraph/Camera.h +++ b/src/SceneGraph/Camera.h @@ -73,7 +73,7 @@ template { void projection2D(); void orthographic(); void perspective(); + void projectionSizeViewport(); }; }}}