Fixed love.graphics.clear(colortable) causing crashes in GLES 2.0 when a Canvas is active (resolves issue #1127).

This commit is contained in:
Alex Szpakowski
2016-02-14 00:26:02 -04:00
parent 5923e2ca5b
commit f7ee949af8
3 changed files with 14 additions and 5 deletions
+11 -5
View File
@@ -461,17 +461,23 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors)
if (colors.size() == 0)
return;
if (states.back().canvases.size() == 0)
size_t numcanvases = states.back().canvases.size();
if (numcanvases > 0 && colors.size() != numcanvases)
throw love::Exception("Number of clear colors must match the number of active canvases (%ld)", states.back().canvases.size());
// We want to take the single-color codepath if there's no active Canvas, or
// if there's only one active Canvas. The multi-color codepath (in the loop
// below) assumes MRT functions are available, and also may call more
// expensive GL functions which are unnecessary if only one Canvas is active.
if (numcanvases <= 1)
{
if (colors[0].enabled)
clear({colors[0].r, colors[0].g, colors[0].b, colors[0].a});
clear(colors[0].toColor());
return;
}
if (colors.size() != states.back().canvases.size())
throw love::Exception("Number of clear colors must match the number of active canvases (%ld)", states.back().canvases.size());
bool drawbuffermodified = false;
for (int i = 0; i < (int) colors.size(); i++)