From 40279e843c2201f7b0fb23ec007b14f8cf7f14ad Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Sat, 2 Jan 2021 10:29:05 -0800 Subject: [PATCH] Better fix that always ensures the rlgl matrix is always valid --- src/core.c | 3 +-- src/rlgl.h | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index 94caeef4d..905367c9c 100644 --- a/src/core.c +++ b/src/core.c @@ -4003,8 +4003,7 @@ static void SetupViewport(int width, int height) // Set orthographic projection to current framebuffer size // NOTE: Configured top-left corner as (0, 0) - if (width > 0 && height > 0) - rlOrtho(0, CORE.Window.render.width, CORE.Window.render.height, 0, 0.0f, 1.0f); + rlOrtho(0, CORE.Window.render.width, CORE.Window.render.height, 0, 0.0f, 1.0f); rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix rlLoadIdentity(); // Reset current matrix (modelview) diff --git a/src/rlgl.h b/src/rlgl.h index 1b42c6413..f52309f70 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);