Better fix that always ensures the rlgl matrix is always valid

This commit is contained in:
Jeffery Myers 2021-01-02 10:29:05 -08:00
parent 3104e805b4
commit 7433012b42
2 changed files with 7 additions and 2 deletions

View File

@ -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)

View File

@ -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);