Browse Source

Fix compilation on iOS. Fix shader compilation on OpenGL ES. Fix (harmless) GL errors on OpenGL ES 2. Resolves issue #1266.

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

+ 2 - 0
src/modules/audio/openal/Effect.h

@@ -21,6 +21,8 @@
 #ifndef LOVE_AUDIO_OPENAL_EFFECTS_H
 #ifndef LOVE_AUDIO_OPENAL_EFFECTS_H
 #define LOVE_AUDIO_OPENAL_EFFECTS_H
 #define LOVE_AUDIO_OPENAL_EFFECTS_H
 
 
+#include "common/config.h"
+
 // OpenAL
 // OpenAL
 #ifdef LOVE_APPLE_USE_FRAMEWORKS // Frameworks have different include paths.
 #ifdef LOVE_APPLE_USE_FRAMEWORKS // Frameworks have different include paths.
 #ifdef LOVE_IOS
 #ifdef LOVE_IOS

+ 22 - 12
src/modules/graphics/opengl/OpenGL.cpp

@@ -217,7 +217,12 @@ void OpenGL::setupContext()
 		glActiveTexture(GL_TEXTURE0 + i);
 		glActiveTexture(GL_TEXTURE0 + i);
 
 
 		for (int j = 0; j < TEXTURE_MAX_ENUM; j++)
 		for (int j = 0; j < TEXTURE_MAX_ENUM; j++)
-			glBindTexture(getGLTextureType((TextureType) j), 0);
+		{
+			TextureType textype = (TextureType) j;
+
+			if (isTextureTypeSupported(textype))
+				glBindTexture(getGLTextureType(textype), 0);
+		}
 	}
 	}
 
 
 	glActiveTexture(GL_TEXTURE0);
 	glActiveTexture(GL_TEXTURE0);
@@ -1004,16 +1009,7 @@ bool OpenGL::rawTexStorage(TextureType target, int levels, PixelFormat pixelform
 		glTexParameteri(gltarget, GL_TEXTURE_SWIZZLE_A, fmt.swizzle[3]);
 		glTexParameteri(gltarget, GL_TEXTURE_SWIZZLE_A, fmt.swizzle[3]);
 	}
 	}
 
 
-	bool supportsTexStorage = GLAD_VERSION_4_2 || GLAD_ARB_texture_storage;
-
-	// Apparently there are bugs with glTexStorage on some Android drivers. I'd
-	// rather not find out the hard way, so we'll avoid it for now...
-#ifndef LOVE_ANDROID
-	if (GLAD_ES_VERSION_3_0)
-		supportsTexStorage = true;
-#endif
-
-	if (supportsTexStorage)
+	if (isTexStorageSupported())
 	{
 	{
 		if (target == TEXTURE_2D || target == TEXTURE_CUBE)
 		if (target == TEXTURE_2D || target == TEXTURE_CUBE)
 			glTexStorage2D(gltarget, levels, fmt.internalformat, width, height);
 			glTexStorage2D(gltarget, levels, fmt.internalformat, width, height);
@@ -1065,6 +1061,20 @@ bool OpenGL::rawTexStorage(TextureType target, int levels, PixelFormat pixelform
 	return gltarget != GL_ZERO;
 	return gltarget != GL_ZERO;
 }
 }
 
 
+bool OpenGL::isTexStorageSupported()
+{
+	bool supportsTexStorage = GLAD_VERSION_4_2 || GLAD_ARB_texture_storage;
+
+	// Apparently there are bugs with glTexStorage on some Android drivers. I'd
+	// rather not find out the hard way, so we'll avoid it for now...
+#ifndef LOVE_ANDROID
+	if (GLAD_ES_VERSION_3_0)
+		supportsTexStorage = true;
+#endif
+
+	return supportsTexStorage;
+}
+
 bool OpenGL::isTextureTypeSupported(TextureType type) const
 bool OpenGL::isTextureTypeSupported(TextureType type) const
 {
 {
 	switch (type)
 	switch (type)
@@ -1432,7 +1442,7 @@ OpenGL::TextureFormat OpenGL::convertPixelFormat(PixelFormat pixelformat, bool r
 	if (!isPixelFormatCompressed(pixelformat))
 	if (!isPixelFormatCompressed(pixelformat))
 	{
 	{
 		if (GLAD_ES_VERSION_2_0 && !(GLAD_ES_VERSION_3_0 && pixelformat == PIXELFORMAT_LA8)
 		if (GLAD_ES_VERSION_2_0 && !(GLAD_ES_VERSION_3_0 && pixelformat == PIXELFORMAT_LA8)
-			&& !renderbuffer)
+			&& !renderbuffer && !isTexStorageSupported())
 		{
 		{
 			f.internalformat = f.externalformat;
 			f.internalformat = f.externalformat;
 		}
 		}

+ 1 - 0
src/modules/graphics/opengl/OpenGL.h

@@ -378,6 +378,7 @@ public:
 	static GLint getGLWrapMode(Texture::WrapMode wmode);
 	static GLint getGLWrapMode(Texture::WrapMode wmode);
 
 
 	static TextureFormat convertPixelFormat(PixelFormat pixelformat, bool renderbuffer, bool &isSRGB);
 	static TextureFormat convertPixelFormat(PixelFormat pixelformat, bool renderbuffer, bool &isSRGB);
+	static bool isTexStorageSupported();
 	static bool isPixelFormatSupported(PixelFormat pixelformat, bool rendertarget, bool isSRGB);
 	static bool isPixelFormatSupported(PixelFormat pixelformat, bool rendertarget, bool isSRGB);
 	static bool hasTextureFilteringSupport(PixelFormat pixelformat);
 	static bool hasTextureFilteringSupport(PixelFormat pixelformat);
 
 

+ 9 - 0
src/modules/graphics/wrap_Graphics.lua

@@ -71,6 +71,15 @@ uniform LOVE_HIGHP_OR_MEDIUMP mat3 NormalMatrix;
 uniform LOVE_HIGHP_OR_MEDIUMP vec4 love_ScreenSize;]]
 uniform LOVE_HIGHP_OR_MEDIUMP vec4 love_ScreenSize;]]
 
 
 GLSL.FUNCTIONS = [[
 GLSL.FUNCTIONS = [[
+#ifdef GL_ES
+	#if __VERSION__ >= 300 || defined(GL_EXT_texture_array)
+		precision lowp sampler2DArray;
+	#endif
+	#if __VERSION__ >= 300 || defined(GL_OES_texture_3D)
+		precision lowp sampler3D;
+	#endif
+#endif
+
 #if __VERSION__ >= 130 && !defined(LOVE_GLSL1_ON_GLSL3)
 #if __VERSION__ >= 130 && !defined(LOVE_GLSL1_ON_GLSL3)
 	#define Texel texture
 	#define Texel texture
 #else
 #else