1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032465: Visualization, TKOpenGles - invalid enum on GL_RGBA16F initialization in Edge 92

GL_HALF_FLOAT_OES from OpenGL ES 2.0 extension
is now avoided within OpenGL ES 3.0+ context in favor of GL_HALF_FLOAT.

emscripten_webgl_enable_extension() is now called for all extensions
checked by OpenGl_Context::CheckExtension().
So far this doesn't solve any problem, but looks more logical and provisional.
This commit is contained in:
kgv 2021-06-28 22:58:37 +03:00
parent 16222b8cd2
commit 0770d850d6
2 changed files with 43 additions and 31 deletions

View File

@ -74,25 +74,6 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Context,Standard_Transient)
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <emscripten/html5.h>
//! Check if WebGL extension is available and activate it
//! (usage of extension without activation will generate errors).
static bool checkEnableWebGlExtension (const OpenGl_Context& theCtx,
const char* theExtName)
{
if (!theCtx.CheckExtension (theExtName))
{
return false;
}
if (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE aWebGlCtx = emscripten_webgl_get_current_context())
{
if (emscripten_webgl_enable_extension (aWebGlCtx, theExtName))
{
return true;
}
}
return false;
}
#endif
namespace
@ -892,7 +873,25 @@ Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const
Messenger()->Send ("TKOpenGL: glGetString (GL_EXTENSIONS) has returned NULL! No GL context?", Message_Warning);
return Standard_False;
}
return CheckExtension (anExtString, theExtName);
if (!CheckExtension (anExtString, theExtName))
{
return Standard_False;
}
#ifdef __EMSCRIPTEN__
//! Check if WebGL extension is available and activate it
//! (usage of extension without activation will generate errors).
if (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE aWebGlCtx = emscripten_webgl_get_current_context())
{
if (emscripten_webgl_enable_extension (aWebGlCtx, theExtName))
{
return Standard_True;
}
}
return Standard_False;
#else
return Standard_True;
#endif
}
// =======================================================================
@ -1700,14 +1699,14 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
mySupportedFormats->Add (Image_Format_AlphaF);
mySupportedFormats->Add (Image_Format_RGBF);
mySupportedFormats->Add (Image_Format_RGBAF);
if (hasHalfFloatBuffer)
if (hasHalfFloatBuffer != OpenGl_FeatureNotAvailable)
{
mySupportedFormats->Add (Image_Format_RGBAF_half);
}
if (arbTexRG)
{
mySupportedFormats->Add (Image_Format_RGF);
if (hasHalfFloatBuffer)
if (hasHalfFloatBuffer != OpenGl_FeatureNotAvailable)
{
mySupportedFormats->Add (Image_Format_RGF_half);
}
@ -1722,7 +1721,7 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
}
#ifdef __EMSCRIPTEN__
if (checkEnableWebGlExtension (*this, "GL_WEBGL_compressed_texture_s3tc")) // GL_WEBGL_compressed_texture_s3tc_srgb for sRGB formats
if (CheckExtension ("GL_WEBGL_compressed_texture_s3tc")) // GL_WEBGL_compressed_texture_s3tc_srgb for sRGB formats
{
mySupportedFormats->Add (Image_CompressedFormat_RGB_S3TC_DXT1);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT1);
@ -1730,7 +1729,7 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT5);
}
if (!extPDS
&& checkEnableWebGlExtension (*this, "GL_WEBGL_depth_texture"))
&& CheckExtension ("GL_WEBGL_depth_texture"))
{
extPDS = true; // WebGL 1.0 extension (in WebGL 2.0 core)
}
@ -2012,7 +2011,7 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString
addInfo (theDict, "GLvendor", (const char*)::glGetString (GL_VENDOR));
addInfo (theDict, "GLdevice", (const char*)::glGetString (GL_RENDERER));
#ifdef __EMSCRIPTEN__
if (checkEnableWebGlExtension (*this, "GL_WEBGL_debug_renderer_info"))
if (CheckExtension ("GL_WEBGL_debug_renderer_info"))
{
if (const char* aVendor = (const char*)::glGetString (0x9245))
{

View File

@ -455,12 +455,25 @@ void OpenGl_GlFunctions::load (OpenGl_Context& theCtx,
theCtx.hasDrawBuffers = OpenGl_FeatureInExtensions;
}
theCtx.hasFloatBuffer = isGlGreaterEqualShort (3, 2) ? OpenGl_FeatureInCore :
checkExtensionShort ("GL_EXT_color_buffer_float") ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
theCtx.hasHalfFloatBuffer = isGlGreaterEqualShort (3, 2) ? OpenGl_FeatureInCore :
checkExtensionShort ("GL_EXT_color_buffer_half_float") ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
// float textures available since OpenGL ES 3.0+,
// but renderable only since 3.2+ or with extension
theCtx.hasFloatBuffer = theCtx.hasHalfFloatBuffer = OpenGl_FeatureNotAvailable;
if (isGlGreaterEqualShort (3, 2))
{
theCtx.hasFloatBuffer = theCtx.hasHalfFloatBuffer = OpenGl_FeatureInCore;
}
else
{
if (checkExtensionShort ("GL_EXT_color_buffer_float"))
{
theCtx.hasFloatBuffer = isGlGreaterEqualShort (3, 0) ? OpenGl_FeatureInCore : OpenGl_FeatureInExtensions;
}
if (checkExtensionShort ("GL_EXT_color_buffer_half_float"))
{
// GL_HALF_FLOAT_OES for OpenGL ES 2.0 and GL_HALF_FLOAT for OpenGL ES 3.0+
theCtx.hasHalfFloatBuffer = isGlGreaterEqualShort (3, 0) ? OpenGl_FeatureInCore : OpenGl_FeatureInExtensions;
}
}
theCtx.oesSampleVariables = checkExtensionShort ("GL_OES_sample_variables");
theCtx.oesStdDerivatives = checkExtensionShort ("GL_OES_standard_derivatives");