From 090c50795a4084301702a3c7744dbd6c4695b5d1 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 22 Mar 2016 18:05:26 -0300 Subject: [PATCH] Fix love.window.setMode crashing if a Canvas is active. --- src/modules/graphics/opengl/Canvas.cpp | 3 ++- src/modules/graphics/opengl/Graphics.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index d706148dd..97949a67d 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -521,7 +521,8 @@ void Canvas::stopGrab(bool switchingToOtherCanvas) // Make sure the canvas texture is up to date if we're using MSAA. resolveMSAA(false); - gl.matrices.projection.pop_back(); + if (gl.matrices.projection.size() > 1) + gl.matrices.projection.pop_back(); if (!switchingToOtherCanvas) { diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index fcf2b41f5..9a7d2d2a6 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -252,8 +252,6 @@ bool Graphics::setMode(int width, int height) created = true; - setViewportSize(width, height); - // Enable blending glEnable(GL_BLEND); @@ -310,6 +308,8 @@ bool Graphics::setMode(int width, int height) if (quadIndices == nullptr) quadIndices = new QuadIndices(20); + setViewportSize(width, height); + // Restore the graphics state. restoreState(states.back());