From 6cd699e55fb6c59fd96c37dc3d85dbf96aeae684 Mon Sep 17 00:00:00 2001 From: valid-ptr Date: Fri, 4 Dec 2020 18:19:29 +0300 Subject: [PATCH] GLExtensions: isTextureCompressionASTCSupported (ASTC compression texture), isTextureLODBiasSupported (is needed for GL_TEXTURE_LOD_BIAS) flags added --- include/osg/GLExtensions | 2 ++ src/osg/GLExtensions.cpp | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index aa868e9cf..f7196ae81 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -521,6 +521,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced bool isTextureCompressionETC2Supported; bool isTextureCompressionRGTCSupported; bool isTextureCompressionPVRTCSupported; + bool isTextureCompressionASTCSupported; bool isTextureMirroredRepeatSupported; bool isTextureEdgeClampSupported; bool isTextureBorderClampSupported; @@ -530,6 +531,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced bool isShadowSupported; bool isShadowAmbientSupported; bool isTextureMaxLevelSupported; + bool isTextureLODBiasSupported; GLint maxTextureSize; bool isClientStorageSupported; bool isTextureIntegerEXTSupported; diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index c2cf99eb5..932230b92 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -866,6 +866,11 @@ GLExtensions::GLExtensions(unsigned int in_contextID): isTextureCompressionRGTCSupported = validContext && isGLExtensionSupported(contextID,"GL_EXT_texture_compression_rgtc"); isTextureCompressionPVRTCSupported = isTextureCompressionPVRTC2BPPSupported;//covered by same extension + isTextureCompressionASTCSupported = validContext && (isGLExtensionSupported(contextID, "GL_KHR_texture_compression_astc_hdr") || + isGLExtensionSupported(contextID, "GL_KHR_texture_compression_astc_ldr") || + isGLExtensionSupported(contextID, "GL_OES_texture_compression_astc") || + isGLExtensionSupported(contextID, "WEBGL_compressed_texture_astc")); + isTextureMirroredRepeatSupported = validContext && (builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_IBM_texture_mirrored_repeat", 1.4f) || @@ -906,18 +911,22 @@ GLExtensions::GLExtensions(unsigned int in_contextID): { maxTextureSize = osg_max_size; } + +#if defined(__EMSCRIPTEN__) + isTextureMaxLevelSupported = (glVersion >= 3.0f); // WebGL 2.0 (OpenGL ES 3.0) + isTextureLODBiasSupported = (glVersion >= 3.0f) || isGLExtensionSupported(contextID, "GL_EXT_texture_lod_bias"); +#else isTextureMaxLevelSupported = (glVersion >= 1.2f); + isTextureLODBiasSupported = (glVersion >= 1.2f) || isGLExtensionSupported(contextID, "GL_EXT_texture_lod_bias"); +#endif isTextureStorageEnabled = validContext && ((glVersion >= 4.2f) || isGLExtensionSupported(contextID, "GL_ARB_texture_storage")); if (isTextureStorageEnabled) { std::string value; - if (getEnvVar("OSG_GL_TEXTURE_STORAGE", value)) - { - if (value=="OFF" || value=="DISABLE") isTextureStorageEnabled = false; - else isTextureStorageEnabled = true; - } + if (getEnvVar("OSG_GL_TEXTURE_STORAGE", value) && (value == "OFF" || value == "DISABLE")) + isTextureStorageEnabled = false; } setGLExtensionFuncPtr(glTexStorage1D,"glTexStorage1D","glTexStorage1DARB", validContext);