From 5d4aada52649e0a43ba6eb446b205a68cd0831f6 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Wed, 6 Jan 2021 04:21:58 -0800 Subject: [PATCH] Don't create an ortho matrix when the viewport is 0 in any axis. (#1504) * Don't create an ortho matrix when the viewport is 0 in any axis. Not all compilers divide by 0 and return inf, some segfault. The matrix is not used by anything when minimized, so it just needs to not be called. * Better fix that always ensures the rlgl matrix is always valid * Better fix that always ensures the rlgl matrix is always valid --- src/rlgl.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rlgl.h b/src/rlgl.h index 3d327a6f9..bc851668a 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1100,6 +1100,12 @@ void rlFrustum(double left, double right, double bottom, double top, double znea // Multiply the current matrix by an orthographic matrix generated by parameters void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar) { + if (right - left <= 0 || bottom - top <= 0) + { + *RLGL.State.currentMatrix = MatrixIdentity(); + return; + } + Matrix matOrtho = MatrixOrtho(left, right, bottom, top, znear, zfar); *RLGL.State.currentMatrix = MatrixMultiply(*RLGL.State.currentMatrix, matOrtho);