From b8ef513c8f7c78c9a46d62126ff549121cf07caf Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 17 Mar 2021 21:03:04 +0300 Subject: [PATCH] 0032206: Visualization, TKOpenGl - move out OpenGL ES support to dedicated library TKOpenGles Added TKOpenGles and TKOpenGlesTest toolkits built with HAVE_GLES2 macros. Added CSF_OpenGlesLibs as alternative to CSF_OpenGlLibs. --- CMakeLists.txt | 28 ++++++++++++++-- adm/MODULES | 4 +-- adm/UDLIST | 4 +++ adm/cmake/egl.cmake | 2 +- adm/cmake/gles2.cmake | 2 +- adm/cmake/occt_csf.cmake | 25 +++++--------- adm/cmake/occt_toolkit.cmake | 7 ++++ adm/cmake/vardescr.cmake | 5 +-- adm/genproj.tcl | 33 ++++++++++--------- adm/qmake/OccCppConfig.pri | 3 +- adm/qmake/OccModule.pri | 5 +++ adm/qmake/OccToolkit.pri | 20 +++++++---- adm/templates/env.bat | 2 +- adm/templates/env.sh | 2 +- adm/templates/template.vc10 | 16 ++++----- adm/templates/template.vc10x | 16 ++++----- dox/upgrade/upgrade.md | 8 +++++ .../UIKitSample.xcodeproj/project.pbxproj | 8 ++--- .../jnisample/OcctJniActivity.java | 2 +- .../jniviewer/app/src/main/jni/CMakeLists.txt | 2 +- samples/qt/AndroidQt/OCCT.pri | 4 +-- samples/webgl/CMakeLists.txt | 2 +- samples/webgl/WasmOcctView.cpp | 2 +- src/Draw/Draw_BasicCommands.cxx | 9 ++--- src/DrawResources/DrawPlugin | 3 ++ src/OS/Draw.tcl | 3 ++ src/OS/Visualization.tcl | 3 ++ src/OpenGl/OpenGl_GraphicDriver.cxx | 20 +++++++---- src/OpenGl/OpenGl_GraphicDriver.hxx | 7 +--- src/OpenGl/OpenGl_GraphicDriverFactory.cxx | 8 ++++- src/TKOpenGles/CMakeLists.txt | 4 +++ src/TKOpenGles/EXTERNLIB | 12 +++++++ src/TKOpenGles/FILES | 3 ++ src/TKOpenGles/PACKAGES | 1 + src/TKOpenGlesTest/CMakeLists.txt | 3 ++ src/TKOpenGlesTest/EXTERNLIB | 8 +++++ src/TKOpenGlesTest/FILES | 2 ++ src/TKOpenGlesTest/PACKAGES | 1 + src/ViewerTest/ViewerTest_ViewerCommands.cxx | 17 +++++++++- tests/v3d/glsl/opengles | 22 +++++++++++++ 40 files changed, 233 insertions(+), 95 deletions(-) create mode 100644 src/TKOpenGles/CMakeLists.txt create mode 100644 src/TKOpenGles/EXTERNLIB create mode 100644 src/TKOpenGles/FILES create mode 100644 src/TKOpenGles/PACKAGES create mode 100644 src/TKOpenGlesTest/CMakeLists.txt create mode 100644 src/TKOpenGlesTest/EXTERNLIB create mode 100644 src/TKOpenGlesTest/FILES create mode 100644 src/TKOpenGlesTest/PACKAGES create mode 100644 tests/v3d/glsl/opengles diff --git a/CMakeLists.txt b/CMakeLists.txt index 85b896650b..d565e393d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,6 +414,14 @@ if (NOT DEFINED BUILD_DOC_Overview) set (BUILD_DOC_Overview ${CAN_DOXYGEN_BE_USED} CACHE BOOL "${BUILD_DOC_Overview_DESCR}") endif() +if (ANDROID OR IOS OR EMSCRIPTEN OR "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") + list (REMOVE_ITEM Visualization_TOOLKITS TKOpenGl) + list (REMOVE_ITEM Draw_TOOLKITS TKOpenGlTest) +elseif (NOT USE_GLES2) + list (REMOVE_ITEM Visualization_TOOLKITS TKOpenGles) + list (REMOVE_ITEM Draw_TOOLKITS TKOpenGlesTest) +endif() + if (NOT USE_D3D) list (REMOVE_ITEM Visualization_TOOLKITS TKD3DHost) list (REMOVE_ITEM Draw_TOOLKITS TKD3DHostTest) @@ -486,7 +494,8 @@ endif() OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE) OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL) OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE USE_FREETYPE) -OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_GLES2) +OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_OPENGL) +OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlesLibs CAN_USE_GLES2) OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB) OCCT_IS_PRODUCT_REQUIRED (CSF_EIGEN CAN_USE_EIGEN) @@ -607,6 +616,16 @@ else() OCCT_CHECK_AND_UNSET ("INSTALL_FFMPEG") endif() +# OpenGL +if (CAN_USE_OPENGL) + set (USE_OPENGL ON CACHE BOOL "${USE_OPENGL_DESCR}") + if (USE_OPENGL) + add_definitions (-DHAVE_OPENGL_EXT) + endif() +else() + OCCT_CHECK_AND_UNSET ("USE_OPENGL") +endif() + # OpenGL ES 2.0 if (CAN_USE_GLES2) if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") @@ -616,9 +635,9 @@ if (CAN_USE_GLES2) endif() if (USE_GLES2) - add_definitions (-DHAVE_GLES2) + add_definitions (-DHAVE_GLES2_EXT) OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/egl") - OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2") + OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2") else() OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL") OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2") @@ -1140,6 +1159,9 @@ foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS}) endforeach() list (REMOVE_DUPLICATES OCCT_MODULES_ENABLED) list (REMOVE_DUPLICATES OCCT_COMPILE_DEFINITIONS) +# these macros are defined for specific tookits, not globalwise +list (REMOVE_ITEM OCCT_COMPILE_DEFINITIONS HAVE_OPENGL) +list (REMOVE_ITEM OCCT_COMPILE_DEFINITIONS HAVE_GLES2) # export compile definitions and C/C++ flags for each configuration to OpenCASCADE config files foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES}) diff --git a/adm/MODULES b/adm/MODULES index 58f65a004e..724bf81776 100644 --- a/adm/MODULES +++ b/adm/MODULES @@ -1,7 +1,7 @@ FoundationClasses TKernel TKMath ModelingData TKG2d TKG3d TKGeomBase TKBRep ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing -Visualization TKService TKV3d TKOpenGl TKMeshVS TKIVtk TKD3DHost +Visualization TKService TKV3d TKOpenGl TKOpenGles TKMeshVS TKIVtk TKD3DHost ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF DataExchange TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh -Draw TKDraw TKTopTest TKOpenGlTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE +Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE diff --git a/adm/UDLIST b/adm/UDLIST index 3bbef06c91..3f3993a157 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -207,6 +207,7 @@ n Image n Media n MeshVS n OpenGl +n OpenGles n D3DHost n Prs3d n PrsMgr @@ -224,6 +225,7 @@ r Shaders r XRResources t TKMeshVS t TKOpenGl +t TKOpenGles t TKD3DHost t TKService t TKV3d @@ -403,6 +405,7 @@ n MeshTest n SWDRAW n TObjDRAW n OpenGlTest +n OpenGlesTest n D3DHostTest n ViewerTest n XDEDRAW @@ -416,6 +419,7 @@ t TKDraw t TKTObjDRAW t TKTopTest t TKOpenGlTest +t TKOpenGlesTest t TKD3DHostTest t TKViewerTest t TKXDEDRAW diff --git a/adm/cmake/egl.cmake b/adm/cmake/egl.cmake index d6b1c4b651..396ff05d24 100644 --- a/adm/cmake/egl.cmake +++ b/adm/cmake/egl.cmake @@ -1,3 +1,3 @@ # EGL -THIRDPARTY_PRODUCT("EGL" "EGL/egl.h" "CSF_OpenGlLibs" "") +THIRDPARTY_PRODUCT("EGL" "EGL/egl.h" "CSF_OpenGlesLibs" "") diff --git a/adm/cmake/gles2.cmake b/adm/cmake/gles2.cmake index adbb78735f..ecc4f8d2b7 100644 --- a/adm/cmake/gles2.cmake +++ b/adm/cmake/gles2.cmake @@ -1,3 +1,3 @@ # OpenGL ES 2.0 -THIRDPARTY_PRODUCT("GLES2" "GLES2/gl2.h" "CSF_OpenGlLibs" "") +THIRDPARTY_PRODUCT("GLES2" "GLES2/gl2.h" "CSF_OpenGlesLibs" "") diff --git a/adm/cmake/occt_csf.cmake b/adm/cmake/occt_csf.cmake index 46d22ff4e3..4d716241b0 100644 --- a/adm/cmake/occt_csf.cmake +++ b/adm/cmake/occt_csf.cmake @@ -74,12 +74,8 @@ if (WIN32) set (CSF_psapi "psapi.lib") set (CSF_winmm "winmm.lib") set (CSF_d3d9 "D3D9.lib") - if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" OR USE_GLES2) - set (CSF_OpenGlLibs "libEGL libGLESv2") - else() - set (CSF_OpenGlLibs "opengl32.lib") - endif() - + set (CSF_OpenGlLibs "opengl32.lib") + set (CSF_OpenGlesLibs "libEGL libGLESv2") else() if (APPLE) @@ -100,9 +96,9 @@ else() OCCT_CHECK_AND_UNSET (IOKit_LIB) if (IOS) - find_library (OpenGlLibs_LIB NAMES OpenGLES) - set (CSF_OpenGlLibs ${OpenGlLibs_LIB}) - OCCT_CHECK_AND_UNSET (OpenGlLibs_LIB) + find_library (OpenGlesLibs_LIB NAMES OpenGLES) + set (CSF_OpenGlesLibs ${OpenGlesLibs_LIB}) + OCCT_CHECK_AND_UNSET (OpenGlesLibs_LIB) elseif (USE_GLX) set (CSF_OpenGlLibs GL) set (CSF_XwLibs "X11 Xext Xmu Xi") @@ -111,18 +107,15 @@ else() set (CSF_OpenGlLibs ${OpenGlLibs_LIB}) OCCT_CHECK_AND_UNSET (OpenGlLibs_LIB) endif() - + elseif (ANDROID) set (CSF_ThreadLibs "c") - set (CSF_OpenGlLibs "EGL GLESv2") + set (CSF_OpenGlesLibs "EGL GLESv2") set (CSF_androidlog "log") elseif (UNIX) set (CSF_ThreadLibs "pthread rt stdc++") - if (USE_GLES2) - set (CSF_OpenGlLibs "EGL GLESv2") - else() - set (CSF_OpenGlLibs "GL") - endif() + set (CSF_OpenGlLibs "GL") + set (CSF_OpenGlesLibs "EGL GLESv2") set (CSF_XwLibs "X11 Xext Xmu Xi") set (CSF_dl "dl") set (CSF_fontconfig "fontconfig") diff --git a/adm/cmake/occt_toolkit.cmake b/adm/cmake/occt_toolkit.cmake index 12d6cd6025..acbaac55ec 100644 --- a/adm/cmake/occt_toolkit.cmake +++ b/adm/cmake/occt_toolkit.cmake @@ -303,6 +303,13 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) else() # get CSF_ value set (CURRENT_CSF ${${USED_ITEM}}) if (NOT "x${CURRENT_CSF}" STREQUAL "x") + if ("${CURRENT_CSF}" STREQUAL "CSF_OpenGlLibs") + add_definitions (-DHAVE_OPENGL) + endif() + if ("${CURRENT_CSF}" STREQUAL "CSF_OpenGlesLibs") + add_definitions (-DHAVE_GLES2) + endif() + set (LIBRARY_FROM_CACHE 0) separate_arguments (CURRENT_CSF) foreach (CSF_LIBRARY ${CURRENT_CSF}) diff --git a/adm/cmake/vardescr.cmake b/adm/cmake/vardescr.cmake index 91b124ffca..19182d8e9b 100644 --- a/adm/cmake/vardescr.cmake +++ b/adm/cmake/vardescr.cmake @@ -174,9 +174,10 @@ set (USE_EGL_DESCR "Indicates whether EGL should be used in OCCT visualization module instead of conventional OpenGL context creation APIs") +set (USE_OPENGL_DESCR +"Indicates whether OpenGL desktop should be used in OCCT visualization module") set (USE_GLES2_DESCR -"Indicates whether OpenGL ES 2.0 should be used in OCCT visualization -module instead of desktop OpenGL") +"Indicates whether OpenGL ES 2.0 should be used in OCCT visualization module") set (USE_TBB_DESCR "Indicates whether TBB is used or not. TBB stands for Threading Building Blocks, diff --git a/adm/genproj.tcl b/adm/genproj.tcl index 59042819c5..fe11d4ff2e 100644 --- a/adm/genproj.tcl +++ b/adm/genproj.tcl @@ -1461,9 +1461,7 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} { set aLibsMap(CSF_netapi32) "netapi32" set aLibsMap(CSF_winmm) "winmm" set aLibsMap(CSF_OpenGlLibs) "opengl32" - if { "$::HAVE_GLES2" == "true" } { - set aLibsMap(CSF_OpenGlLibs) "libEGL libGLESv2" - } + set aLibsMap(CSF_OpenGlesLibs) "libEGL libGLESv2" set aLibsMap(CSF_psapi) "Psapi" set aLibsMap(CSF_d3d9) "d3d9" @@ -1484,14 +1482,18 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} { } } else { set aLibsMap(CSF_dl) "dl" + set aLibsMap(CSF_OpenGlLibs) "GL" + set aLibsMap(CSF_OpenGlesLibs) "EGL GLESv2" if { "$theOS" == "mac" || "$theOS" == "ios" } { - set aLibsMap(CSF_objc) "objc" + set aLibsMap(CSF_objc) "objc" + set aLibsMap(CSF_OpenGlLibs) "" + set aLibsMap(CSF_OpenGlesLibs) "" + set aFrmsMap(CSF_OpenGlLibs) "OpenGL" + set aFrmsMap(CSF_OpenGlesLibs) "OpenGLES" if { "$theOS" == "ios" } { - set aFrmsMap(CSF_Appkit) "UIKit" - set aFrmsMap(CSF_OpenGlLibs) "OpenGLES" + set aFrmsMap(CSF_Appkit) "UIKit" } else { - set aFrmsMap(CSF_Appkit) "AppKit" - set aFrmsMap(CSF_OpenGlLibs) "OpenGL" + set aFrmsMap(CSF_Appkit) "AppKit" } set aFrmsMap(CSF_IOKit) "IOKit" set aFrmsMap(CSF_TclLibs) "Tcl" @@ -1500,24 +1502,17 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} { set aLibsMap(CSF_TclTkLibs) "" set aLibsMap(CSF_QT) "QtCore QtGui" } elseif { "$theOS" == "android" } { - set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2" set aLibsMap(CSF_androidlog) "log" } else { set aLibsMap(CSF_fontconfig) "fontconfig" if { "$theOS" == "qnx" } { # CSF_ThreadLibs - pthread API is part of libc on QNX - set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2" } else { set aLibsMap(CSF_ThreadLibs) "pthread rt" - set aLibsMap(CSF_OpenGlLibs) "GL" set aLibsMap(CSF_TclTkLibs) "X11 tk8.6" set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi" set aLibsMap(CSF_MotifLibs) "X11" } - - if { "$::HAVE_GLES2" == "true" } { - set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2" - } } } } @@ -1785,9 +1780,14 @@ proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap theSrcDir global path set aHasQtDep "false" + set aTkDefines "" foreach aCsfElem [osutils:tk:csfInExternlib "$path/$theSrcDir/${theToolKit}/EXTERNLIB"] { if { "$aCsfElem" == "CSF_QT" } { set aHasQtDep "true" + } elseif { "$aCsfElem" == "CSF_OpenGlLibs" } { + set aTkDefines "$aTkDefines;HAVE_OPENGL" + } elseif { "$aCsfElem" == "CSF_OpenGlesLibs" } { + set aTkDefines "$aTkDefines;HAVE_GLES2" } } set theProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 0] @@ -1822,9 +1822,9 @@ proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap theSrcDir # depending on VC version regsub -all -- {__TKDEP__} $theProjTmpl [osutils:depLibraries $aUsedLibs $anOsReleaseLibs $theVcVer] theProjTmpl regsub -all -- {__TKDEP_DEBUG__} $theProjTmpl [osutils:depLibraries $aUsedLibs $anOsDebugLibs $theVcVer] theProjTmpl + regsub -all -- {__TKDEFINES__} $theProjTmpl $aTkDefines theProjTmpl set anIncPaths "..\\..\\..\\inc" -# set aTKDefines "" set aFilesSection "" set aVcFilesCxx(units) "" set aVcFilesHxx(units) "" @@ -2108,6 +2108,7 @@ proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap theSrcDir set aVCRTVer [string range $theVcVer 0 3] regsub -all -- {__TKDEP__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsReleaseLibs $theVcVer] aProjTmpl regsub -all -- {__TKDEP_DEBUG__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsDebugLibs $theVcVer] aProjTmpl + regsub -all -- {__TKDEFINES__} $aProjTmpl "" aProjTmpl set aFilesSection "" set aVcFilesCxx(units) "" diff --git a/adm/qmake/OccCppConfig.pri b/adm/qmake/OccCppConfig.pri index d85502816a..85c837f141 100644 --- a/adm/qmake/OccCppConfig.pri +++ b/adm/qmake/OccCppConfig.pri @@ -153,5 +153,4 @@ win32 { } } -#OBJECTS_DIR = $$DESTDIR/../obj$${MY_BUILDTYPE}/$${TARGET} -OBJECTS_DIR = $$DESTDIR/../obj$${MY_BUILDTYPE} +OBJECTS_DIR = $$DESTDIR/../obj$${MY_BUILDTYPE}/$${TARGET} diff --git a/adm/qmake/OccModule.pri b/adm/qmake/OccModule.pri index 84f2357032..1fcd67fe5c 100644 --- a/adm/qmake/OccModule.pri +++ b/adm/qmake/OccModule.pri @@ -15,9 +15,14 @@ for (aModuleIter, aModuleList) { equals (aToolKit, $$OCC_MODULE_NAME) { toSkipToolkit = 1 } !HAVE_VTK:equals (aToolKit, "TKIVtk") { toSkipToolkit = 1 } !HAVE_VTK:equals (aToolKit, "TKIVtkDraw") { toSkipToolkit = 1 } + #!HAVE_OPENGL: equals (aToolKit, "TKOpenGl") { toSkipToolkit = 1 } + #!HAVE_OPENGL: equals (aToolKit, "TKOpenGlTest") { toSkipToolkit = 1 } + !HAVE_GLES2: equals (aToolKit, "TKOpenGles") { toSkipToolkit = 1 } + !HAVE_GLES2: equals (aToolKit, "TKOpenGlesTest") { toSkipToolkit = 1 } !win32: equals (aToolKit, "TKD3DHost") { toSkipToolkit = 1 } !win32: equals (aToolKit, "TKD3DHostTest") { toSkipToolkit = 1 } equals (toSkipToolkit, 0) { + #warning(aToolKit($$OCC_MODULE_NAME)=$$aToolKit) eval(occtkgen_$${aToolKit}.input = $$_PRO_FILE_PWD_/../OccToolkit.pro.in) eval(occtkgen_$${aToolKit}.output = $$_PRO_FILE_PWD_/$${aToolKit}/$${aToolKit}.pro) diff --git a/adm/qmake/OccToolkit.pri b/adm/qmake/OccToolkit.pri index abe95b51d3..c7398ae4f9 100644 --- a/adm/qmake/OccToolkit.pri +++ b/adm/qmake/OccToolkit.pri @@ -36,7 +36,7 @@ win32 { CSF_wsock32 = -lwsock32 CSF_netapi32 = -lnetapi32 CSF_OpenGlLibs = -lopengl32 - HAVE_GLES2 { CSF_OpenGlLibs = -llibEGL -llibGLESv2 } + CSF_OpenGlesLibs = -llibEGL -llibGLESv2 CSF_psapi = -lPsapi CSF_winmm = -lwinmm CSF_d3d9 = -ld3d9 @@ -46,12 +46,12 @@ win32 { } else:mac { CSF_dl = -ldl CSF_objc = -lobjc + CSF_OpenGlLibs = -framework OpenGL + CSF_OpenGlesLibs = -framework OpenGLES iphoneos { CSF_Appkit = -framework UIKit - CSF_OpenGlLibs = -framework OpenGLES } else { CSF_Appkit = -framework AppKit - CSF_OpenGlLibs = -framework OpenGL } CSF_IOKit = -framework IOKit CSF_TclLibs = -framework Tcl @@ -60,17 +60,19 @@ win32 { CSF_dl = -ldl CSF_ThreadLibs = -lpthread -lrt CSF_OpenGlLibs = -lGL + CSF_OpenGlesLibs = -lEGL -lGLESv2 CSF_TclTkLibs = -lX11 -ltk8.6 CSF_XwLibs = -lX11 -lXext -lXmu -lXi CSF_MotifLibs = -lX11 CSF_fontconfig = -lfontconfig - HAVE_GLES2 { CSF_OpenGlLibs = -lEGL -lGLESv2 } } for (aCfgIter, CONFIG) { aRes = $$find(aCfgIter, "^HAVE_") - count(aRes, 1) { - DEFINES += $$aCfgIter + !equals(aCfgIter, "HAVE_GLES2") { + count(aRes, 1) { + DEFINES += $$aCfgIter + } } } @@ -103,6 +105,12 @@ for (anExternLib, anExternLibs) { count(hasCsf, 1) { aList = $$split($$anExternLib, "\n") LIBS += $$aList + equals(anExternLib, "CSF_OpenGlLibs") { + DEFINES += "HAVE_OPENGL" + } + equals(anExternLib, "CSF_OpenGlesLibs") { + DEFINES += "HAVE_GLES2" + } } else { LIBS += -l$$anExternLib } diff --git a/adm/templates/env.bat b/adm/templates/env.bat index 203e972412..4b26b4ccb9 100644 --- a/adm/templates/env.bat +++ b/adm/templates/env.bat @@ -185,7 +185,7 @@ if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DH if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%" if ["%HAVE_FFMPEG%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FFMPEG" & set "CSF_DEFINES=HAVE_FFMPEG;%CSF_DEFINES%" if ["%HAVE_VTK%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_VTK" & set "CSF_DEFINES=HAVE_VTK;%CSF_DEFINES%" -if ["%HAVE_GLES2%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GLES2" & set "CSF_DEFINES=HAVE_GLES2;%CSF_DEFINES%" +if ["%HAVE_GLES2%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GLES2_EXT" & set "CSF_DEFINES=HAVE_GLES2_EXT;%CSF_DEFINES%" if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_D3D" & set "CSF_DEFINES=HAVE_D3D;%CSF_DEFINES%" if ["%HAVE_ZLIB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_ZLIB" & set "CSF_DEFINES=HAVE_ZLIB;%CSF_DEFINES%" if ["%HAVE_LIBLZMA%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_LIBLZMA" & set "CSF_DEFINES=HAVE_LIBLZMA;%CSF_DEFINES%" diff --git a/adm/templates/env.sh b/adm/templates/env.sh index 578b3ef183..91a59315db 100644 --- a/adm/templates/env.sh +++ b/adm/templates/env.sh @@ -102,7 +102,7 @@ if [ "$HAVE_TBB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -D if [ "$HAVE_OPENCL" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENCL"; fi if [ "$HAVE_FREEIMAGE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREEIMAGE"; fi if [ "$HAVE_FFMPEG" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FFMPEG"; fi -if [ "$HAVE_GLES2" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_GLES2"; fi +if [ "$HAVE_GLES2" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_GLES2_EXT"; fi if [ "$HAVE_VTK" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_VTK"; fi if [ "$HAVE_ZLIB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_ZLIB"; fi if [ "$HAVE_LIBLZMA" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_LIBLZMA"; fi diff --git a/adm/templates/template.vc10 b/adm/templates/template.vc10 index a7a20639b1..158733423c 100644 --- a/adm/templates/template.vc10 +++ b/adm/templates/template.vc10 @@ -90,7 +90,7 @@ true MaxSpeed OnlyExplicitInline - NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) true Async MultiThreadedDLL @@ -107,7 +107,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP__ @@ -138,7 +138,7 @@ true Disabled OnlyExplicitInline - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) Async MultiThreadedDebugDLL .\..\..\..\win32\__VCVER__\objd\__TKNAM__/ @@ -156,7 +156,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - _DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP_DEBUG__ @@ -186,7 +186,7 @@ true MaxSpeed OnlyExplicitInline - NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) true Async MultiThreadedDLL @@ -203,7 +203,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP__ @@ -234,7 +234,7 @@ true Disabled OnlyExplicitInline - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) Async MultiThreadedDebugDLL .\..\..\..\win64\__VCVER__\objd\__TKNAM__/ @@ -252,7 +252,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - _DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP_DEBUG__ diff --git a/adm/templates/template.vc10x b/adm/templates/template.vc10x index 08dc4bb7a4..07f9c750fe 100644 --- a/adm/templates/template.vc10x +++ b/adm/templates/template.vc10x @@ -85,7 +85,7 @@ true MaxSpeed OnlyExplicitInline - NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) true Async MultiThreadedDLL @@ -100,7 +100,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP__ @@ -130,7 +130,7 @@ true Disabled OnlyExplicitInline - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) Async MultiThreadedDebugDLL .\..\..\..\win32\__VCVER__\objd\__XQTNAM__/ @@ -146,7 +146,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - _DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP_DEBUG__ @@ -175,7 +175,7 @@ true MaxSpeed OnlyExplicitInline - NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) true Async MultiThreadedDLL @@ -190,7 +190,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - NDEBUG;No_Exception;$(CSF_DEFINES);%(PreprocessorDefinitions) + NDEBUG;No_Exception;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP__ @@ -219,7 +219,7 @@ true Disabled OnlyExplicitInline - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) Async MultiThreadedDebugDLL .\..\..\..\win64\__VCVER__\objd\__XQTNAM__/ @@ -235,7 +235,7 @@ ..\..\..\inc;$(CSF_OPT_INC);%(AdditionalIncludeDirectories) - _DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions) + _DEBUG;__TKDEFINES__;$(CSF_DEFINES);%(PreprocessorDefinitions) __TKDEP_DEBUG__ diff --git a/dox/upgrade/upgrade.md b/dox/upgrade/upgrade.md index 547917530d..d41c636374 100644 --- a/dox/upgrade/upgrade.md +++ b/dox/upgrade/upgrade.md @@ -2229,3 +2229,11 @@ Existing code defining nodal colors should be updated to: - Use *Graphic3d_TOSM_UNLIT* shading model when lighting is not needed. - Adjust diffuse/ambient material coefficients, which have been previously ignored. - Remove code multiplying nodal colors, intended to compensate over-brightness due to addition of specular color from material definition, as specular component is now also modulated by a vertex color. + +@subsection upgrade_occt760_tkopengles TKOpenGles library + +OCCT now provides two separate toolkits - *TKOpenGl* depending on desktop OpenGL and *TKOpenGles* depending on OpenGL ES. +Both libraries can be now built simultaneously on systems providing both APIs (like desktop Linux). + +Existing applications depending on OpenGL ES (mobile projects first of all) should be adjusted to link against *TKOpenGles*. +Note that both *TKOpenGl* and *TKOpenGles* keep exporting classes with the same name, so applications should not attempt to link both libraries simultaneously. diff --git a/samples/ios/UIKitSample/UIKitSample.xcodeproj/project.pbxproj b/samples/ios/UIKitSample/UIKitSample.xcodeproj/project.pbxproj index 83043d9aec..a83efb466a 100644 --- a/samples/ios/UIKitSample/UIKitSample.xcodeproj/project.pbxproj +++ b/samples/ios/UIKitSample/UIKitSample.xcodeproj/project.pbxproj @@ -32,7 +32,7 @@ 0A7DEE351E2D2AE000267B9B /* libTKXCAF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE151E2D2AC000267B9B /* libTKXCAF.a */; }; 0A7DEE371E2D2AE000267B9B /* libTKXDESTEP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE171E2D2AC700267B9B /* libTKXDESTEP.a */; }; 0A7DEE3E1E2D2B8100267B9B /* libTKBO.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE021E2D2A7F00267B9B /* libTKBO.a */; }; - 0A7DEE3F1E2D2BB000267B9B /* libTKOpenGl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE091E2D2A9700267B9B /* libTKOpenGl.a */; }; + 0A7DEE3F1E2D2BB000267B9B /* libTKOpenGles.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE091E2D2A9700267B9B /* libTKOpenGles.a */; }; 0A7DEE401E2D2BEA00267B9B /* libTKSTEP209.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE0F1E2D2AAB00267B9B /* libTKSTEP209.a */; }; 0A7DEE411E2D2C1500267B9B /* libTKXSBase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE1D1E2D2ADC00267B9B /* libTKXSBase.a */; }; 0AAE0DE61EAF816E00C1F65B /* screw.step in Resources */ = {isa = PBXBuildFile; fileRef = 0AAE0DE51EAF816D00C1F65B /* screw.step */; }; @@ -82,7 +82,7 @@ 0A7DEE061E2D2A8C00267B9B /* libTKIGES.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKIGES.a; path = ../occt/lib/libTKIGES.a; sourceTree = ""; }; 0A7DEE071E2D2A8F00267B9B /* libTKMeshVS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKMeshVS.a; path = ../occt/lib/libTKMeshVS.a; sourceTree = ""; }; 0A7DEE081E2D2A9300267B9B /* libTKOffset.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKOffset.a; path = ../occt/lib/libTKOffset.a; sourceTree = ""; }; - 0A7DEE091E2D2A9700267B9B /* libTKOpenGl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKOpenGl.a; path = ../occt/lib/libTKOpenGl.a; sourceTree = ""; }; + 0A7DEE091E2D2A9700267B9B /* libTKOpenGles.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKOpenGles.a; path = ../occt/lib/libTKOpenGles.a; sourceTree = ""; }; 0A7DEE0A1E2D2A9A00267B9B /* libTKPrim.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKPrim.a; path = ../occt/lib/libTKPrim.a; sourceTree = ""; }; 0A7DEE0B1E2D2A9D00267B9B /* libTKService.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKService.a; path = ../occt/lib/libTKService.a; sourceTree = ""; }; 0A7DEE0C1E2D2AA100267B9B /* libTKStd.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKStd.a; path = ../occt/lib/libTKStd.a; sourceTree = ""; }; @@ -135,7 +135,7 @@ 0AE286641EB0D29B00A9D719 /* libz.tbd in Frameworks */, 0A7DEE411E2D2C1500267B9B /* libTKXSBase.a in Frameworks */, 0A7DEE401E2D2BEA00267B9B /* libTKSTEP209.a in Frameworks */, - 0A7DEE3F1E2D2BB000267B9B /* libTKOpenGl.a in Frameworks */, + 0A7DEE3F1E2D2BB000267B9B /* libTKOpenGles.a in Frameworks */, 0A7DEE3E1E2D2B8100267B9B /* libTKBO.a in Frameworks */, 0A7DEE2B1E2D2AE000267B9B /* libTKService.a in Frameworks */, 0A7DEE2E1E2D2AE000267B9B /* libTKSTEP.a in Frameworks */, @@ -234,7 +234,7 @@ 0A7DEE061E2D2A8C00267B9B /* libTKIGES.a */, 0A7DEE071E2D2A8F00267B9B /* libTKMeshVS.a */, 0A7DEE081E2D2A9300267B9B /* libTKOffset.a */, - 0A7DEE091E2D2A9700267B9B /* libTKOpenGl.a */, + 0A7DEE091E2D2A9700267B9B /* libTKOpenGles.a */, 0A7DEE0A1E2D2A9A00267B9B /* libTKPrim.a */, 0A7DEE0B1E2D2A9D00267B9B /* libTKService.a */, 0A7DEE0C1E2D2AA100267B9B /* libTKStd.a */, diff --git a/samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniActivity.java b/samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniActivity.java index 83a3e2b099..b92c4ae98d 100644 --- a/samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniActivity.java +++ b/samples/java/jniviewer/app/src/main/java/com/opencascade/jnisample/OcctJniActivity.java @@ -147,7 +147,7 @@ public class OcctJniActivity extends Activity implements OnClickListener || !loadLibVerbose ("TKService", aLoaded, aFailed) || !loadLibVerbose ("TKHLR", aLoaded, aFailed) || !loadLibVerbose ("TKV3d", aLoaded, aFailed) - || !loadLibVerbose ("TKOpenGl", aLoaded, aFailed) + || !loadLibVerbose ("TKOpenGles", aLoaded, aFailed) // application code || !loadLibVerbose ("TKJniSample", aLoaded, aFailed)) { diff --git a/samples/java/jniviewer/app/src/main/jni/CMakeLists.txt b/samples/java/jniviewer/app/src/main/jni/CMakeLists.txt index 4862495e43..59e131dfc0 100644 --- a/samples/java/jniviewer/app/src/main/jni/CMakeLists.txt +++ b/samples/java/jniviewer/app/src/main/jni/CMakeLists.txt @@ -11,7 +11,7 @@ set (anOcctLibs TKIGES TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP # OCCT Visualization - TKService TKHLR TKV3d TKOpenGl + TKService TKHLR TKV3d TKOpenGles ) set(aLibDeps "") diff --git a/samples/qt/AndroidQt/OCCT.pri b/samples/qt/AndroidQt/OCCT.pri index 2a5e52a6a1..c8773d3963 100644 --- a/samples/qt/AndroidQt/OCCT.pri +++ b/samples/qt/AndroidQt/OCCT.pri @@ -38,7 +38,7 @@ LIBS += -lTKernel \ -lTKMesh \ -lTKHLR \ -lTKV3d \ - -lTKOpenGl + -lTKOpenGles # IMPORTANT. load libraries in a proper order ANDROID_EXTRA_LIBS = $$3rdparty_lib_path/libfreeimage.so \ @@ -56,4 +56,4 @@ ANDROID_EXTRA_LIBS = $$3rdparty_lib_path/libfreeimage.so \ $$occt_lib_path/libTKMesh.so \ $$occt_lib_path/libTKHLR.so \ $$occt_lib_path/libTKV3d.so \ - $$occt_lib_path/libTKOpenGl.so + $$occt_lib_path/libTKOpenGles.so diff --git a/samples/webgl/CMakeLists.txt b/samples/webgl/CMakeLists.txt index a3d7ef3052..1f7d3af3bd 100644 --- a/samples/webgl/CMakeLists.txt +++ b/samples/webgl/CMakeLists.txt @@ -64,7 +64,7 @@ else() set(OCCT_BIN_DIR) endif() -set(OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGl TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel) +set(OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGles TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel) add_executable(${APP_TARGET} ${SOURCES}) target_link_libraries( diff --git a/samples/webgl/WasmOcctView.cpp b/samples/webgl/WasmOcctView.cpp index ec8e5f7254..c1a30ea709 100644 --- a/samples/webgl/WasmOcctView.cpp +++ b/samples/webgl/WasmOcctView.cpp @@ -710,7 +710,7 @@ EM_BOOL WasmOcctView::onTouchEvent (int theEventType, const EmscriptenTouchEvent myDoubleTapTimer.Stop(); myDoubleTapTimer.Reset(); myDoubleTapTimer.Start(); - SelectInViewer (Graphic3d_Vec2i (myClickTouch.From), false); + SelectInViewer (Graphic3d_Vec2i (myClickTouch.From), AIS_SelectionScheme_Replace); } } hasUpdates = true; diff --git a/src/Draw/Draw_BasicCommands.cxx b/src/Draw/Draw_BasicCommands.cxx index 0270aaf7a0..138e8831c8 100644 --- a/src/Draw/Draw_BasicCommands.cxx +++ b/src/Draw/Draw_BasicCommands.cxx @@ -358,10 +358,11 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c #else di << "FFmpeg disabled\n"; #endif -#ifdef HAVE_GLES2 - di << "OpenGL: ES2\n"; -#else - di << "OpenGL: desktop\n"; +#ifdef HAVE_OPENGL_EXT + di << "OpenGL: enabled (HAVE_OPENGL_EXT)\n"; +#endif +#ifdef HAVE_GLES2_EXT + di << "OpenGL ES: enabled (HAVE_GLES2_EXT)\n"; #endif #ifdef HAVE_OPENVR di << "OpenVR enabled (HAVE_OPENVR)\n"; diff --git a/src/DrawResources/DrawPlugin b/src/DrawResources/DrawPlugin index f0325d99cc..b9938be7af 100755 --- a/src/DrawResources/DrawPlugin +++ b/src/DrawResources/DrawPlugin @@ -42,7 +42,10 @@ ALL : MODELING, OCAFKERNEL, DATAEXCHANGE TOPTEST : TKTopTest DCAF : TKDCAF AISV : TKViewerTest +GL : TKOpenGlTest OPENGL : TKOpenGlTest +GLES : TKOpenGlesTest +OPENGLES : TKOpenGlesTest D3DHOST : TKD3DHostTest XSDRAW : TKXSDRAW XDEDRAW : TKXDEDRAW diff --git a/src/OS/Draw.tcl b/src/OS/Draw.tcl index bfd7c72bf2..a72770b69e 100644 --- a/src/OS/Draw.tcl +++ b/src/OS/Draw.tcl @@ -18,6 +18,9 @@ proc Draw:toolkits { } { set aResult [list TKDraw TKTopTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw] lappend aResult "TKOpenGlTest" + if { [info exists ::env(HAVE_GLES2)] && "$::env(HAVE_GLES2)" == "true" } { + lappend aResult "TKOpenGlesTest" + } if { "$::tcl_platform(platform)" == "windows" } { if { [info exists ::env(HAVE_D3D)] } { if { "$::env(HAVE_D3D)" == "true" } { diff --git a/src/OS/Visualization.tcl b/src/OS/Visualization.tcl index 05928f6c41..cf881b5ca7 100644 --- a/src/OS/Visualization.tcl +++ b/src/OS/Visualization.tcl @@ -18,6 +18,9 @@ proc Visualization:toolkits { } { set aResult [list TKService TKV3d TKMeshVS] lappend aResult "TKOpenGl" + if { [info exists ::env(HAVE_GLES2)] && "$::env(HAVE_GLES2)" == "true" } { + lappend aResult "TKOpenGles" + } if { "$::tcl_platform(platform)" == "windows" } { if { [info exists ::env(HAVE_D3D)] } { if { "$::env(HAVE_D3D)" == "true" } { diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index f05d316325..e212d6480f 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -145,15 +145,18 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio const Standard_Boolean theToInitialize) : Graphic3d_GraphicDriver (theDisp), myIsOwnContext (Standard_False), -#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) - myEglDisplay ((Aspect_Display )EGL_NO_DISPLAY), - myEglContext ((Aspect_RenderingContext )EGL_NO_CONTEXT), + myEglDisplay (NULL), + myEglContext (NULL), myEglConfig (NULL), -#endif myCaps (new OpenGl_Caps()), myMapOfView (1, NCollection_BaseAllocator::CommonBaseAllocator()), myMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator()) { +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) + myEglDisplay = (Aspect_Display )EGL_NO_DISPLAY; + myEglContext = (Aspect_RenderingContext )EGL_NO_CONTEXT; +#endif + #if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) if (myDisplayConnection.IsNull()) { @@ -354,7 +357,6 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext() return Standard_True; } -#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) // ======================================================================= // function : InitEglContext // purpose : @@ -364,6 +366,7 @@ Standard_Boolean OpenGl_GraphicDriver::InitEglContext (Aspect_Display t void* theEglConfig) { ReleaseContext(); +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) #if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) if (myDisplayConnection.IsNull()) { @@ -390,8 +393,13 @@ Standard_Boolean OpenGl_GraphicDriver::InitEglContext (Aspect_Display t } chooseVisualInfo(); return Standard_True; -} +#else + (void )theEglDisplay; + (void )theEglContext; + (void )theEglConfig; + throw Standard_NotImplemented ("OpenGl_GraphicDriver::InitEglContext() is not implemented"); #endif +} // ======================================================================= // function : chooseVisualInfo diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index 3e11decff9..b8ceb33c9f 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -68,7 +68,6 @@ public: //! Perform initialization of default OpenGL context. Standard_EXPORT Standard_Boolean InitContext(); -#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) //! Initialize default OpenGL context using existing one. //! @param theEglDisplay EGL connection to the Display //! @param theEglContext EGL rendering context @@ -76,7 +75,6 @@ public: Standard_EXPORT Standard_Boolean InitEglContext (Aspect_Display theEglDisplay, Aspect_RenderingContext theEglContext, void* theEglConfig); -#endif //! Request limit of graphic resource of specific type. Standard_EXPORT virtual Standard_Integer InquireLimit (const Graphic3d_TypeOfLimit theType) const Standard_OVERRIDE; @@ -175,11 +173,9 @@ public: //! any context will be returned otherwise Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext (bool theBound = false) const; -#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) Aspect_Display getRawGlDisplay() const { return myEglDisplay; } Aspect_RenderingContext getRawGlContext() const { return myEglContext; } void* getRawGlConfig() const { return myEglConfig; } -#endif //! Set device lost flag for redrawn views. Standard_EXPORT void setDeviceLost(); @@ -200,11 +196,10 @@ protected: protected: Standard_Boolean myIsOwnContext; //!< indicates that shared context has been created within OpenGl_GraphicDriver -#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) + Aspect_Display myEglDisplay; //!< EGL connection to the Display : EGLDisplay Aspect_RenderingContext myEglContext; //!< EGL rendering context : EGLContext void* myEglConfig; //!< EGL configuration : EGLConfig -#endif Handle(OpenGl_Caps) myCaps; NCollection_Map myMapOfView; diff --git a/src/OpenGl/OpenGl_GraphicDriverFactory.cxx b/src/OpenGl/OpenGl_GraphicDriverFactory.cxx index cdc72c32b9..9f6a6a783c 100644 --- a/src/OpenGl/OpenGl_GraphicDriverFactory.cxx +++ b/src/OpenGl/OpenGl_GraphicDriverFactory.cxx @@ -15,6 +15,12 @@ #include +#ifdef HAVE_GLES2 + #define OpenGl_DRIVER_NAME "TKOpenGles" +#else + #define OpenGl_DRIVER_NAME "TKOpenGl" +#endif + IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriverFactory, Graphic3d_GraphicDriverFactory) // ======================================================================= @@ -22,7 +28,7 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriverFactory, Graphic3d_GraphicDriverF // purpose : // ======================================================================= OpenGl_GraphicDriverFactory::OpenGl_GraphicDriverFactory() -: Graphic3d_GraphicDriverFactory ("TKOpenGl"), +: Graphic3d_GraphicDriverFactory (OpenGl_DRIVER_NAME), myDefaultCaps (new OpenGl_Caps()) { // diff --git a/src/TKOpenGles/CMakeLists.txt b/src/TKOpenGles/CMakeLists.txt new file mode 100644 index 0000000000..097b28b559 --- /dev/null +++ b/src/TKOpenGles/CMakeLists.txt @@ -0,0 +1,4 @@ +project(TKOpenGles) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +#add_definitions("-DOCCT_OPENGL") diff --git a/src/TKOpenGles/EXTERNLIB b/src/TKOpenGles/EXTERNLIB new file mode 100644 index 0000000000..431d1dbeb4 --- /dev/null +++ b/src/TKOpenGles/EXTERNLIB @@ -0,0 +1,12 @@ +TKernel +TKService +TKMath +CSF_TBB +CSF_FREETYPE +CSF_OpenGlesLibs +CSF_user32 +CSF_gdi32 +CSF_XwLibs +CSF_Appkit +CSF_IOKit +CSF_objc diff --git a/src/TKOpenGles/FILES b/src/TKOpenGles/FILES new file mode 100644 index 0000000000..b635bba4eb --- /dev/null +++ b/src/TKOpenGles/FILES @@ -0,0 +1,3 @@ +DEFINES +EXTERNLIB +PACKAGES diff --git a/src/TKOpenGles/PACKAGES b/src/TKOpenGles/PACKAGES new file mode 100644 index 0000000000..ba040129b2 --- /dev/null +++ b/src/TKOpenGles/PACKAGES @@ -0,0 +1 @@ +OpenGl diff --git a/src/TKOpenGlesTest/CMakeLists.txt b/src/TKOpenGlesTest/CMakeLists.txt new file mode 100644 index 0000000000..ea6e85654a --- /dev/null +++ b/src/TKOpenGlesTest/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKOpenGlesTest) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKOpenGlesTest/EXTERNLIB b/src/TKOpenGlesTest/EXTERNLIB new file mode 100644 index 0000000000..875d0a6066 --- /dev/null +++ b/src/TKOpenGlesTest/EXTERNLIB @@ -0,0 +1,8 @@ +TKernel +TKMath +TKDraw +TKOpenGles +TKService +TKV3d +TKViewerTest +CSF_OpenGlesLibs diff --git a/src/TKOpenGlesTest/FILES b/src/TKOpenGlesTest/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKOpenGlesTest/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKOpenGlesTest/PACKAGES b/src/TKOpenGlesTest/PACKAGES new file mode 100644 index 0000000000..4df696d9e3 --- /dev/null +++ b/src/TKOpenGlesTest/PACKAGES @@ -0,0 +1 @@ +OpenGlTest diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index f206d0064d..21ed5533a5 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -1688,7 +1688,12 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory(); if (aFactory.IsNull()) { - throw Standard_ProgramError("Error: no graphic driver factory found"); + Draw::GetInterpretor().Eval ("pload GLES"); + aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory(); + if (aFactory.IsNull()) + { + throw Standard_ProgramError("Error: no graphic driver factory found"); + } } } @@ -2020,6 +2025,12 @@ static int VDriver (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const c { aNewActive = "tkopengl"; } + else if (TCollection_AsciiString::IsSameString (aNewActive, "gles", false) + || TCollection_AsciiString::IsSameString (aNewActive, "opengles", false) + || TCollection_AsciiString::IsSameString (aNewActive, "tkopengles", false)) + { + aNewActive = "tkopengles"; + } else if (TCollection_AsciiString::IsSameString (aNewActive, "d3d", false) || TCollection_AsciiString::IsSameString (aNewActive, "d3dhost", false) || TCollection_AsciiString::IsSameString (aNewActive, "tkd3dhost", false)) @@ -2033,6 +2044,10 @@ static int VDriver (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const c { Draw::GetInterpretor().Eval ("pload OPENGL"); } + else if (aNewActive == "tkopengles") + { + Draw::GetInterpretor().Eval ("pload GLES"); + } else if (aNewActive == "tkd3dhost") { Draw::GetInterpretor().Eval ("pload D3DHOST"); diff --git a/tests/v3d/glsl/opengles b/tests/v3d/glsl/opengles new file mode 100644 index 0000000000..4e3e53a4b5 --- /dev/null +++ b/tests/v3d/glsl/opengles @@ -0,0 +1,22 @@ +puts "============" +puts "0032206: Visualization, TKOpenGl - move out OpenGL ES support to dedicated library TKOpenGles" +puts "============" +puts "" + +set to_dump_screen 0 +pload MODELING VISUALIZATION +vdriver -load GLES +vclear +vinit View1 +box b 3 0 0 1 2 3 +psphere s 1 +vdisplay -dispMode 1 b s +set anInfo [vglinfo] +if { [regexp {OpenGL ES} $anInfo] } { + puts "OK: OpenGL ES has been found" +} else { + puts "Error: OpenGL ES is expected" +} +vfit +vrenderparams -shadingModel PHONG +vdump ${imagedir}/${casename}.png