mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +03:00
0028826: Visualization, TKOpenGl - fix compatibility with strict OpenGL ES drivers
OpenGl_ShaderProgram::Initialize() - precision declarations have been moved after the list of enabled extensions. Declarations.glsl - the fragment shader outputs have been re-declared as array for proper assignment of default locations (draw buffers). OpenGl_FrameBuffer - GL_HALF_FLOAT is now used instead of GL_HALF_FLOAT_OES on OpenGL ES 3.2+. OpenGl_Texture - fixed initialization of Image_Format_RGB32 image format on OpenGL ES 3.0+.
This commit is contained in:
@@ -266,29 +266,51 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
case Image_Format_BGRA:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_RGBA8;
|
||||
#else
|
||||
if (!theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_BGRA_EXT;
|
||||
#endif
|
||||
thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_RGB32:
|
||||
{
|
||||
theTextFormat = GL_RGB8;
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// ask driver to convert data to RGB8 to save memory
|
||||
theTextFormat = GL_RGB8;
|
||||
#else
|
||||
// conversion is not supported
|
||||
theTextFormat = GL_RGBA8;
|
||||
#endif
|
||||
thePixelFormat = GL_RGBA;
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_BGR32:
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_RGB8;
|
||||
#else
|
||||
if (!theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_BGRA_EXT;
|
||||
#endif
|
||||
thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
@@ -590,8 +612,13 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
|
||||
theSizeX, theSizeY, 0,
|
||||
thePixelFormat, theDataType, aDataPtr);
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
const GLenum anErr = glGetError();
|
||||
if (anErr != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Error: 2D texture ") + theSizeX + "x" + theSizeY
|
||||
+ " IF: " + int(anIntFormat) + " PF: " + int(thePixelFormat) + " DT: " + int(theDataType)
|
||||
+ " can not be created with error " + int(anErr) + ".");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
return false;
|
||||
@@ -663,8 +690,13 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
|
||||
theSizeX, theSizeY, 0,
|
||||
thePixelFormat, theDataType, theImage->Data());
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
const GLenum aTexImgErr = glGetError();
|
||||
if (aTexImgErr != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Error: 2D texture ") + theSizeX + "x" + theSizeY
|
||||
+ " IF: " + int(anIntFormat) + " PF: " + int(thePixelFormat) + " DT: " + int(theDataType)
|
||||
+ " can not be created with error " + int(aTexImgErr) + ".");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user