mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Fix compilation on iOS. Fix shader compilation on OpenGL ES. Fix (harmless) GL errors on OpenGL ES 2. Resolves issue #1266.
--HG-- branch : minor
This commit is contained in:
@@ -217,7 +217,12 @@ void OpenGL::setupContext()
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
|
||||
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);
|
||||
@@ -1004,16 +1009,7 @@ bool OpenGL::rawTexStorage(TextureType target, int levels, PixelFormat pixelform
|
||||
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)
|
||||
glTexStorage2D(gltarget, levels, fmt.internalformat, width, height);
|
||||
@@ -1065,6 +1061,20 @@ bool OpenGL::rawTexStorage(TextureType target, int levels, PixelFormat pixelform
|
||||
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
|
||||
{
|
||||
switch (type)
|
||||
@@ -1432,7 +1442,7 @@ OpenGL::TextureFormat OpenGL::convertPixelFormat(PixelFormat pixelformat, bool r
|
||||
if (!isPixelFormatCompressed(pixelformat))
|
||||
{
|
||||
if (GLAD_ES_VERSION_2_0 && !(GLAD_ES_VERSION_3_0 && pixelformat == PIXELFORMAT_LA8)
|
||||
&& !renderbuffer)
|
||||
&& !renderbuffer && !isTexStorageSupported())
|
||||
{
|
||||
f.internalformat = f.externalformat;
|
||||
}
|
||||
|
||||
@@ -378,6 +378,7 @@ public:
|
||||
static GLint getGLWrapMode(Texture::WrapMode wmode);
|
||||
|
||||
static TextureFormat convertPixelFormat(PixelFormat pixelformat, bool renderbuffer, bool &isSRGB);
|
||||
static bool isTexStorageSupported();
|
||||
static bool isPixelFormatSupported(PixelFormat pixelformat, bool rendertarget, bool isSRGB);
|
||||
static bool hasTextureFilteringSupport(PixelFormat pixelformat);
|
||||
|
||||
|
||||
@@ -71,6 +71,15 @@ uniform LOVE_HIGHP_OR_MEDIUMP mat3 NormalMatrix;
|
||||
uniform LOVE_HIGHP_OR_MEDIUMP vec4 love_ScreenSize;]]
|
||||
|
||||
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)
|
||||
#define Texel texture
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user