From 2269ddcf7ec67b72ddd2b192716cf5a468fd1a23 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 10 May 2020 16:03:24 -0700 Subject: GL backend: fixed GetTextureInternalFormat function to allow texture fromat query failure (to spport GL_TEXTURE_EXTERNAL_OES) --- .../GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 27c94eb0..06e49cd6 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -126,15 +126,32 @@ static GLenum GetTextureInternalFormat(GLContextState& GLState, GLenum BindTarge GLint GlFormat = 0; #if GL_TEXTURE_INTERNAL_FORMAT glGetTexLevelParameteriv(QueryBindTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &GlFormat); - CHECK_GL_ERROR("Failed to get texture format through glGetTexLevelParameteriv()"); - VERIFY(GlFormat != 0, "Unable to get texture format"); - VERIFY(TexFmtFromDesc == TEX_FORMAT_UNKNOWN || static_cast(GlFormat) == TexFormatToGLInternalTexFormat(TexFmtFromDesc), "Texture format does not match the format specified by the texture description"); + if (glGetError() == GL_NO_ERROR && GlFormat != 0) + { + VERIFY(TexFmtFromDesc == TEX_FORMAT_UNKNOWN || static_cast(GlFormat) == TexFormatToGLInternalTexFormat(TexFmtFromDesc), "Texture format does not match the format specified by the texture description"); + } + else + { + if (TexFmtFromDesc != TEX_FORMAT_UNKNOWN) + { + GlFormat = TexFormatToGLInternalTexFormat(TexFmtFromDesc); + } + else + { + LOG_WARNING_MESSAGE("Unable to query internal texture format while the format specified by texture description is TEX_FORMAT_UNKNOWN."); + } + } #else if (TexFmtFromDesc != TEX_FORMAT_UNKNOWN) + { GlFormat = TexFormatToGLInternalTexFormat(TexFmtFromDesc); + } else - UNSUPPORTED("Texture format cannot be queried and must be provided by the texture description"); + { + LOG_WARNING_MESSAGE("Texture format query is not supported while the format specified by texture description is TEX_FORMAT_UNKNOWN."); + } #endif + GLState.BindTexture(-1, BindTarget, GLObjectWrappers::GLTextureObj::Null()); return GlFormat; -- cgit v1.2.3