]> git.lizzy.rs Git - irrlicht.git/commitdiff
Prevent crash when creating CCameraSceneNode while rendertarget has height 0
authorcutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475>
Mon, 30 May 2022 20:13:28 +0000 (20:13 +0000)
committersfan5 <sfan5@live.de>
Fri, 24 Mar 2023 16:09:11 +0000 (17:09 +0100)
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6405 dfc29bdd-3216-0410-991c-e03cc46cb475

source/Irrlicht/CCameraSceneNode.cpp

index aaa752f433a2f118e537fab48d5957d331abed39..77d8c28fd54d5b22cfa90f1cdbaa486d0b4bb427 100644 (file)
@@ -28,16 +28,16 @@ CCameraSceneNode::CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 i
 \r
        // set default projection\r
        Fovy = core::PI / 2.5f; // Field of view, in radians.\r
+       Aspect = 4.0f / 3.0f;   // Aspect ratio.\r
 \r
        const video::IVideoDriver* const d = mgr?mgr->getVideoDriver():0;\r
        if (d)\r
        {\r
-               Aspect = (f32)d->getCurrentRenderTargetSize().Width /\r
-                       (f32)d->getCurrentRenderTargetSize().Height;\r
+               if ( d->getCurrentRenderTargetSize().Height )\r
+                       Aspect = (f32)d->getCurrentRenderTargetSize().Width /\r
+                               (f32)d->getCurrentRenderTargetSize().Height;\r
                HasD3DStyleProjectionMatrix = d->getDriverType() != video::EDT_OPENGL;\r
        }\r
-       else\r
-               Aspect = 4.0f / 3.0f;   // Aspect ratio.\r
 \r
        ViewArea.setFarNearDistance(ZFar - ZNear);\r
        recalculateProjectionMatrix();\r