From 73382cbc58e7f43941b311094d4fe6b1a0988cab Mon Sep 17 00:00:00 2001 From: kgv Date: Sun, 24 Jan 2021 18:31:54 +0300 Subject: [PATCH] 0032081: Visualization - WebGL sample errors when run in Safari browser --- samples/webgl/CMakeLists.txt | 3 ++- src/OpenGl/OpenGl_Context.cxx | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/samples/webgl/CMakeLists.txt b/samples/webgl/CMakeLists.txt index 3a32e698da..7838293f5c 100644 --- a/samples/webgl/CMakeLists.txt +++ b/samples/webgl/CMakeLists.txt @@ -14,7 +14,8 @@ endif() # customize build set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_WEBGL2=1") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_WEBGL2=1") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s MAX_WEBGL_VERSION=2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --bind") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s SAFE_HEAP=1") diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 097e12fefe..d4f12d0270 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -1156,6 +1156,20 @@ void OpenGl_Context::ReadGlVersion (Standard_Integer& theGlVerMajor, // read numbers theGlVerMajor = atoi (aMajorStr); theGlVerMinor = atoi (aMinorStr); +#if defined(__EMSCRIPTEN__) + if (theGlVerMajor >= 3) + { + if (!toCheckVer3 + || ::strstr (aVerStr, "WebGL 1.0") != NULL) + { + Message::SendWarning() << "Warning! OpenGL context reports version " << theGlVerMajor << "." << theGlVerMinor + << " but WebGL 2.0 was unavailable\n" + << "Fallback to OpenGL ES 2.0 will be used instead of reported version"; + theGlVerMajor = 2; + theGlVerMinor = 0; + } + } +#endif if (theGlVerMajor <= 0) { -- 2.39.5