0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model
[occt.git] / src / OpenGl / OpenGl_Sampler.cxx
index 54c1e25..4fcfca4 100644 (file)
@@ -223,7 +223,8 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
   }
 #endif
   setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_T, aWrapMode);
-  if (theTarget == GL_TEXTURE_3D)
+  if (theTarget == GL_TEXTURE_3D
+   || theTarget == GL_TEXTURE_CUBE_MAP)
   {
     setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_R, aWrapMode);
     return;
@@ -261,6 +262,13 @@ 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()))
+  {
+    setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_BASE_LEVEL, theParams->BaseLevel());
+    setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_LEVEL,  theParams->MaxLevel());
+  }
 }
 
 // =======================================================================