Browse Source

Don’t try to create the standard/default array texture shader if array textures are not supported.

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
cb9aa857d7

+ 6 - 0
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();
 		}

+ 3 - 0
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();
 		}