From 3104e805b45960503cf4a5994708563813a9e7cd Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Sat, 2 Jan 2021 09:39:08 -0800 Subject: [PATCH] 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. --- examples/core/core_basic_window.c | 7 +++++++ src/core.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/core/core_basic_window.c b/examples/core/core_basic_window.c index 8177b3105..a0d6e9eff 100644 --- a/examples/core/core_basic_window.c +++ b/examples/core/core_basic_window.c @@ -19,8 +19,10 @@ * ********************************************************************************************/ +#include "TPOrbitCamera.h" #include "raylib.h" + int main(void) { // Initialization @@ -28,6 +30,11 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; + TPOrbitCamera cam; + InitTPOrbitCamera(&cam, 45, (Vector3) { 0, 0, 0 }); + + SetConfigFlags(FLAG_WINDOW_HIGHDPI) + InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); SetTargetFPS(60); // Set our game to run at 60 frames-per-second diff --git a/src/core.c b/src/core.c index 905367c9c..94caeef4d 100644 --- a/src/core.c +++ b/src/core.c @@ -4003,7 +4003,8 @@ static void SetupViewport(int width, int height) // Set orthographic projection to current framebuffer size // NOTE: Configured top-left corner as (0, 0) - rlOrtho(0, CORE.Window.render.width, CORE.Window.render.height, 0, 0.0f, 1.0f); + if (width > 0 && height > 0) + 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)