From: kgv Date: Wed, 27 May 2020 10:36:17 +0000 (+0300) Subject: 0031580: Visualization, TKOpenGl - cubemap initialization error on OpenGL ES 2.0 X-Git-Tag: V7_5_0_beta~188 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=e4e3254a357475a5ab6ef314175205829c8c8a30;p=occt-copy.git 0031580: Visualization, TKOpenGl - cubemap initialization error on OpenGL ES 2.0 OpenGl_Texture::InitCubeMap() now avoids using sized internal format in case of GLES2. OpenGl_Sampler::applySamplerParams() now checks OpenGL version before setting GL_TEXTURE_WRAP_R. --- diff --git a/src/OpenGl/OpenGl_Sampler.cxx b/src/OpenGl/OpenGl_Sampler.cxx index 3ec1e07723..08fcd7c937 100644 --- a/src/OpenGl/OpenGl_Sampler.cxx +++ b/src/OpenGl/OpenGl_Sampler.cxx @@ -226,7 +226,10 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx, if (theTarget == GL_TEXTURE_3D || theTarget == GL_TEXTURE_CUBE_MAP) { - setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_R, aWrapMode); + if (theCtx->HasTextureBaseLevel()) + { + setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_R, aWrapMode); + } return; } diff --git a/src/OpenGl/OpenGl_Texture.cxx b/src/OpenGl/OpenGl_Texture.cxx index 383e7f5ef0..48d2739711 100644 --- a/src/OpenGl/OpenGl_Texture.cxx +++ b/src/OpenGl/OpenGl_Texture.cxx @@ -987,6 +987,13 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx, mySizeY = (GLsizei )theSize; myTextFormat = aFormat.Format(); mySizedFormat = aFormat.Internal(); +#if !defined(GL_ES_VERSION_2_0) + const GLint anIntFormat = aFormat.InternalFormat(); +#else + // ES 2.0 does not support sized formats and format conversions - them detected from data type + const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? aFormat.InternalFormat() : aFormat.PixelFormat(); +#endif + Bind (theCtx); applyDefaultSamplerParams (theCtx); @@ -1080,7 +1087,7 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx, } glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, - aFormat.InternalFormat(), + anIntFormat, GLsizei(theSize), GLsizei(theSize), 0, aFormat.PixelFormat(), aFormat.DataType(), aData);