From cd43c08f2b7be9b9ffd97c0eff04c5e3d629ef7b Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 14 Feb 2020 19:29:51 +0300 Subject: [PATCH] 0031372: Visualization, TKOpenGl - failed to create texture on OpenGL ES 2.0 due to unknown GL_TEXTURE_BASE_LEVEL OpenGl_Sampler::applySamplerParams() has been corrected to check for OpenGL ES 3.0 when applying GL_TEXTURE_BASE_LEVEL/GL_TEXTURE_MAX_LEVEL parameters. --- src/OpenGl/OpenGl_Context.hxx | 10 ++++++++++ src/OpenGl/OpenGl_Sampler.cxx | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index 9808544835..4d89de5eda 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -495,6 +495,16 @@ public: //! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1). Standard_Integer TextureWrapClamp() const { return myTexClamp; } + //! @return true if texture parameters GL_TEXTURE_BASE_LEVEL/GL_TEXTURE_MAX_LEVEL are supported. + Standard_Boolean HasTextureBaseLevel() const + { + #if !defined(GL_ES_VERSION_2_0) + return IsGlGreaterEqual (1, 2); + #else + return IsGlGreaterEqual (3, 0); + #endif + } + //! @return maximum degree of anisotropy texture filter Standard_Integer MaxDegreeOfAnisotropy() const { return myAnisoMax; } diff --git a/src/OpenGl/OpenGl_Sampler.cxx b/src/OpenGl/OpenGl_Sampler.cxx index 4fcfca4ed8..6e7bb10de6 100644 --- a/src/OpenGl/OpenGl_Sampler.cxx +++ b/src/OpenGl/OpenGl_Sampler.cxx @@ -263,8 +263,8 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx, setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, aDegree); } - if (theCtx->IsGlGreaterEqual(1, 2) && - (theSampler == NULL || !theSampler->isValidSampler())) + if (theCtx->HasTextureBaseLevel() + && (theSampler == NULL || !theSampler->isValidSampler())) { setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_BASE_LEVEL, theParams->BaseLevel()); setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_LEVEL, theParams->MaxLevel());