diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-01-27 04:45:56 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-01-27 04:45:56 +0000 |
| commit | d9b9c54a82059c74d9d96f19b119582903b5ba90 (patch) | |
| tree | 4dcdb4678bcc287200a4669e30312ffbe4fe8d39 /Graphics/GraphicsEngineOpenGL | |
| parent | Fixed forward/backward slash issue when opening files on MacOS (diff) | |
| download | DiligentCore-d9b9c54a82059c74d9d96f19b119582903b5ba90.tar.gz DiligentCore-d9b9c54a82059c74d9d96f19b119582903b5ba90.zip | |
Updated querying number of mip levels in GL texture to allow failure in older versions
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
| -rw-r--r-- | Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
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<Uint32>(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<Uint32>(MipLevels), "Specified number of mip levels (", TexDesc.MipLevels, ") does not match the actual number of mip levels (", MipLevels, ")"); - TexDesc.MipLevels = static_cast<Uint32>(MipLevels); + if(glGetError() == GL_NO_ERROR) + { + VERIFY(TexDesc.MipLevels == 0 || TexDesc.MipLevels == static_cast<Uint32>(MipLevels), "Specified number of mip levels (", TexDesc.MipLevels, ") does not match the actual number of mip levels (", MipLevels, ")"); + TexDesc.MipLevels = static_cast<Uint32>(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; |
