|
|
|
@ -22,10 +22,38 @@ CORRADE_TEST_MAIN(Magnum::SceneGraph::Test::CameraTest) |
|
|
|
namespace Magnum { namespace SceneGraph { namespace Test { |
|
|
|
namespace Magnum { namespace SceneGraph { namespace Test { |
|
|
|
|
|
|
|
|
|
|
|
CameraTest::CameraTest() { |
|
|
|
CameraTest::CameraTest() { |
|
|
|
addTests(&CameraTest::orthographic, |
|
|
|
addTests(&CameraTest::fixAspectRatio, |
|
|
|
|
|
|
|
&CameraTest::orthographic, |
|
|
|
&CameraTest::perspective); |
|
|
|
&CameraTest::perspective); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CameraTest::fixAspectRatio() { |
|
|
|
|
|
|
|
/* Division by zero */ |
|
|
|
|
|
|
|
Math::Vector2<GLsizei> sizeZeroY(400, 0); |
|
|
|
|
|
|
|
Math::Vector2<GLsizei> sizeZeroX(0, 300); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Implementation::Camera<3>::fixAspectRatio(Implementation::AspectRatioPolicy::Clip, sizeZeroY), Matrix4()); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Implementation::Camera<3>::fixAspectRatio(Implementation::AspectRatioPolicy::Extend, sizeZeroX), Matrix4()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Math::Vector2<GLsizei> size(400, 300); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Not preserved */ |
|
|
|
|
|
|
|
CORRADE_COMPARE(Implementation::Camera<3>::fixAspectRatio(Implementation::AspectRatioPolicy::NotPreserved, size), Matrix4()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Clip */ |
|
|
|
|
|
|
|
Matrix4 expectedClip(1.0f, 0.0f, 0.0f, 0.0f, |
|
|
|
|
|
|
|
0.0f, 4.0f/3.0f, 0.0f, 0.0f, |
|
|
|
|
|
|
|
0.0f, 0.0f, 1.0f, 0.0f, |
|
|
|
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Implementation::Camera<3>::fixAspectRatio(Implementation::AspectRatioPolicy::Clip, size), expectedClip); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Extend */ |
|
|
|
|
|
|
|
Matrix4 expectedExtend(3.0f/4.0f, 0.0f, 0.0f, 0.0f, |
|
|
|
|
|
|
|
0.0f, 1.0f, 0.0f, 0.0f, |
|
|
|
|
|
|
|
0.0f, 0.0f, 1.0f, 0.0f, |
|
|
|
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f); |
|
|
|
|
|
|
|
CORRADE_COMPARE(Implementation::Camera<3>::fixAspectRatio(Implementation::AspectRatioPolicy::Extend, size), expectedExtend); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CameraTest::orthographic() { |
|
|
|
void CameraTest::orthographic() { |
|
|
|
Camera3D camera; |
|
|
|
Camera3D camera; |
|
|
|
camera.setOrthographic(5, 1, 9); |
|
|
|
camera.setOrthographic(5, 1, 9); |
|
|
|
|