From cb9aa857d7d70ead2d5e24c608221542010a1c67 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 1 Mar 2017 21:19:37 -0400 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20try=20to=20create=20the=20stand?= =?UTF-8?q?ard/default=20array=20texture=20shader=20if=20array=20textures?= =?UTF-8?q?=20are=20not=20supported.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : minor --- src/modules/graphics/opengl/Graphics.cpp | 6 ++++++ src/modules/graphics/opengl/SpriteBatch.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index a4c4288e7..45e5a94f6 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -273,6 +273,9 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b // We always need a default shader. for (int i = 0; i < Shader::STANDARD_MAX_ENUM; i++) { + if (i == Shader::STANDARD_ARRAY && !isSupported(FEATURE_ARRAY_TEXTURE)) + continue; + if (!Shader::standardShaders[i]) Shader::standardShaders[i] = newShader(defaultShaderCode[i][target][gammacorrect]); } @@ -345,6 +348,9 @@ void Graphics::flushStreamDraws() if (textype == TEXTURE_2D_ARRAY && Shader::isDefaultActive()) { + if (!Shader::standardShaders[Shader::STANDARD_ARRAY]) + throw love::Exception("Standard array texture shader has not been initialized!"); + prevdefaultshader = Shader::current; Shader::standardShaders[Shader::STANDARD_ARRAY]->attach(); } diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index f81a03b64..fbdd9dbd8 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -68,6 +68,9 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m) if (textype == TEXTURE_2D_ARRAY && Shader::isDefaultActive()) { + if (!Shader::standardShaders[Shader::STANDARD_ARRAY]) + throw love::Exception("Standard array texture shader has not been initialized!"); + prevdefaultshader = Shader::current; Shader::standardShaders[Shader::STANDARD_ARRAY]->attach(); }