From d9b9c54a82059c74d9d96f19b119582903b5ba90 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 26 Jan 2018 20:45:56 -0800 Subject: Updated querying number of mip levels in GL texture to allow failure in older versions --- Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index cf40f66e..4d5fd1aa 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -117,11 +117,18 @@ static TextureDesc GetTextureDescFromGLHandle(DeviceContextGLImpl *pDeviceContex TexDesc.Depth = static_cast(TexDepth); } + // GL_TEXTURE_IMMUTABLE_LEVELS is only supported in GL4.3+ and GLES3.1+ GLint MipLevels = 0; glGetTexParameteriv(BindTarget, GL_TEXTURE_IMMUTABLE_LEVELS, &MipLevels); - CHECK_GL_ERROR( "Failed to get texture parameters through glGetTexParameteriv()" ); - VERIFY(TexDesc.MipLevels == 0 || TexDesc.MipLevels == static_cast(MipLevels), "Specified number of mip levels (", TexDesc.MipLevels, ") does not match the actual number of mip levels (", MipLevels, ")"); - TexDesc.MipLevels = static_cast(MipLevels); + if(glGetError() == GL_NO_ERROR) + { + VERIFY(TexDesc.MipLevels == 0 || TexDesc.MipLevels == static_cast(MipLevels), "Specified number of mip levels (", TexDesc.MipLevels, ") does not match the actual number of mip levels (", MipLevels, ")"); + TexDesc.MipLevels = static_cast(MipLevels); + } + else + { + VERIFY(TexDesc.MipLevels != 0, "Unable to query the number of mip levels, so it must be specified by the texture description."); + } ContextState.BindTexture(-1, BindTarget, GLObjectWrappers::GLTextureObj(false) ); return TexDesc; -- cgit v1.2.3