From 1ce0716bb1c66843f8046e4504badc5b759eea41 Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 31 Aug 2016 19:34:32 +0300 Subject: [PATCH] 0027811: Configuration - allow building TKOpenGl with OpenGL ES on Windows OpenGl_ShaderManager::prepareStdProgramFboBlit() now tries using extension GL_EXT_frag_depth within OpenGL ES 2.0 when OpenGL ES 3.0 is not available. OpenGl_View::blitBuffers() now disables Depth test when copying depth values is not supported by OpenGL ES 2.0 hardware. Fixed building for UWP with SDK 10.0.10240.0 Fixed building TKService, TKV3d and TKOpenGl for UWP. OSD_Environment now defines global environment map for emulating desktop behavior on UWP. --- CMakeLists.txt | 28 ++++ adm/cmake/egl.cmake | 6 + adm/cmake/gles2.cmake | 6 + adm/cmake/occt_csf.cmake | 6 +- adm/cmake/tcl.cmake | 4 +- adm/cmake/tk.cmake | 4 +- adm/cmake/vardescr.cmake | 12 +- adm/genconf.tcl | 24 ++- adm/genconfdeps.tcl | 148 +++++++++++++++++++ adm/genproj.tcl | 7 + adm/templates/OpenCASCADEConfig.cmake.in | 1 + adm/templates/custom.build.bat.in | 2 + adm/templates/custom.install.bat.in | 2 + adm/templates/env.bat | 3 + adm/templates/env.bat.in | 2 + adm/templates/env.sh | 4 + src/Aspect/Aspect_NeutralWindow.cxx | 111 ++++++++++++++ src/Aspect/Aspect_NeutralWindow.hxx | 123 +++++++++++++++ src/Aspect/FILES | 2 + src/Font/Font_FontMgr.cxx | 5 +- src/OSD/OSD_Environment.cxx | 32 ++-- src/OSD/OSD_signal.cxx | 2 + src/OpenGl/OpenGl_AVIWriter.hxx | 9 +- src/OpenGl/OpenGl_Context.cxx | 3 + src/OpenGl/OpenGl_Context.hxx | 1 + src/OpenGl/OpenGl_GlFunctions.hxx | 12 +- src/OpenGl/OpenGl_GraphicDriver.cxx | 35 +++-- src/OpenGl/OpenGl_GraphicDriver.hxx | 6 +- src/OpenGl/OpenGl_ShaderManager.cxx | 5 + src/OpenGl/OpenGl_View_Redraw.cxx | 7 + src/OpenGl/OpenGl_Window.cxx | 14 +- src/Standard/Standard_Mutex.cxx | 8 - src/ViewerTest/ViewerTest_OpenGlCommands.cxx | 8 + src/WNT/WNT_WClass.cxx | 6 +- src/WNT/WNT_WClass.hxx | 17 +-- src/WNT/WNT_Window.cxx | 6 +- src/WNT/WNT_Window.hxx | 17 +-- 37 files changed, 602 insertions(+), 86 deletions(-) create mode 100644 adm/cmake/egl.cmake create mode 100644 adm/cmake/gles2.cmake create mode 100644 src/Aspect/Aspect_NeutralWindow.cxx create mode 100644 src/Aspect/Aspect_NeutralWindow.hxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 356714015d..ee5e9edc3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -501,6 +501,34 @@ else() OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE") endif() +# OpenGL ES 2.0 +OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_GLES2) +if (WIN32 AND CAN_USE_GLES2) + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") + set (USE_GLES2 ON) + else() + set (USE_GLES2 OFF CACHE BOOL "${USE_GLES2_DESCR}") + endif() + + if (USE_GLES2) + add_definitions (-DHAVE_GLES2) + OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/egl") + OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2") + else() + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL") + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2") + OCCT_CHECK_AND_UNSET ("INSTALL_EGL") + OCCT_CHECK_AND_UNSET ("INSTALL_GLES2") + endif() +else() + OCCT_CHECK_AND_UNSET ("USE_GLES2") + + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL") + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2") + OCCT_CHECK_AND_UNSET ("INSTALL_EGL") + OCCT_CHECK_AND_UNSET ("INSTALL_GLES2") +endif() + # GL2PS # search for CSF_GL2PS variable in EXTERNLIB of each being used toolkit OCCT_IS_PRODUCT_REQUIRED (CSF_GL2PS CAN_USE_GL2PS) diff --git a/adm/cmake/egl.cmake b/adm/cmake/egl.cmake new file mode 100644 index 0000000000..fcbcbc7e9b --- /dev/null +++ b/adm/cmake/egl.cmake @@ -0,0 +1,6 @@ +# EGL +if (WIN32) + THIRDPARTY_PRODUCT("EGL" "EGL/egl.h" "libEGL" "libEGL") +else() + THIRDPARTY_PRODUCT("EGL" "EGL/egl.h" "EGL" "EGL") +endif() diff --git a/adm/cmake/gles2.cmake b/adm/cmake/gles2.cmake new file mode 100644 index 0000000000..d834b66e3d --- /dev/null +++ b/adm/cmake/gles2.cmake @@ -0,0 +1,6 @@ +# OpenGL ES 2.0 +if (WIN32) + THIRDPARTY_PRODUCT("GLES2" "GLES2/gl2.h" "libGLESv2" "libGLESv2") +else() + THIRDPARTY_PRODUCT("GLES2" "GLES2/gl2.h" "GLESv2" "GLESv2") +endif() diff --git a/adm/cmake/occt_csf.cmake b/adm/cmake/occt_csf.cmake index 100b57a340..47071f8e86 100644 --- a/adm/cmake/occt_csf.cmake +++ b/adm/cmake/occt_csf.cmake @@ -36,7 +36,11 @@ if (WIN32) set (CSF_winspool "Winspool.lib") set (CSF_psapi "Psapi.lib") set (CSF_AviLibs "ws2_32.lib vfw32.lib") - set (CSF_OpenGlLibs "opengl32.lib") + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" OR USE_GLES2) + set (CSF_OpenGlLibs "libEGL.lib libGLESv2.lib") + else() + set (CSF_OpenGlLibs "opengl32.lib") + endif() if (USE_FREETYPE) set (CSF_FREETYPE "freetype.lib") diff --git a/adm/cmake/tcl.cmake b/adm/cmake/tcl.cmake index 5e7686470b..5bed15eec0 100644 --- a/adm/cmake/tcl.cmake +++ b/adm/cmake/tcl.cmake @@ -80,7 +80,7 @@ if (BUILD_SHARED_LIBS) if (WIN32) if (NOT 3RDPARTY_TCL_DLL) - set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll) + set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll .a) set (DLL_FOLDER_FOR_SEARCH "") if (3RDPARTY_TCL_DLL_DIR) @@ -147,7 +147,7 @@ if (BUILD_SHARED_LIBS) if (WIN32) if (NOT 3RDPARTY_TCL_DLL) - set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll) + set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll .a) set (DLL_FOLDER_FOR_SEARCH "") if (3RDPARTY_TCL_DLL_DIR) diff --git a/adm/cmake/tk.cmake b/adm/cmake/tk.cmake index 5f58ae07bf..09f2f23c27 100644 --- a/adm/cmake/tk.cmake +++ b/adm/cmake/tk.cmake @@ -84,7 +84,7 @@ if (BUILD_SHARED_LIBS) if (WIN32) if (NOT 3RDPARTY_TK_DLL) - set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") + set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll" ".a") set (DLL_FOLDER_FOR_SEARCH "") if (3RDPARTY_TK_DLL_DIR) @@ -151,7 +151,7 @@ if (BUILD_SHARED_LIBS) if (WIN32) if (NOT 3RDPARTY_TK_DLL) - set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") + set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll" ".a") set (DLL_FOLDER_FOR_SEARCH "") if (3RDPARTY_TK_DLL_DIR) diff --git a/adm/cmake/vardescr.cmake b/adm/cmake/vardescr.cmake index eb64e81a69..875107073a 100644 --- a/adm/cmake/vardescr.cmake +++ b/adm/cmake/vardescr.cmake @@ -72,6 +72,8 @@ INSTALL_MESSAGE (INSTALL_SAMPLES "OCCT samples") INSTALL_MESSAGE (INSTALL_TEST_CASES "non-regression OCCT test scripts") INSTALL_MESSAGE (INSTALL_DOC_Overview "OCCT overview documentation (HTML format)") INSTALL_MESSAGE (INSTALL_FREEIMAGE "FreeImage binaries") +INSTALL_MESSAGE (INSTALL_EGL "EGL binaries") +INSTALL_MESSAGE (INSTALL_GLES2 "OpenGL ES 2.0 binaries") INSTALL_MESSAGE (INSTALL_FREETYPE "FreeType binaries") INSTALL_MESSAGE (INSTALL_GL2PS "GL2PS binaries") INSTALL_MESSAGE (INSTALL_TBB "TBB binaries") @@ -127,6 +129,14 @@ set (USE_FREEIMAGE_DESCR "Indicates whether Freeimage product should be used in OCCT visualization module for support of popular graphics image formats (PNG, BMP etc)") +set (USE_EGL_DESCR +"Indicates whether EGL should be used in OCCT visualization +module instead of conventional OpenGL context creation APIs") + +set (USE_GLES2_DESCR +"Indicates whether OpenGL ES 2.0 should be used in OCCT visualization +module instead of desktop OpenGL") + set (USE_GL2PS_DESCR "Indicates whether GL2PS product should be used in OCCT visualization module for support of vector image formats (PS, EPS etc)") @@ -148,7 +158,7 @@ set (USE_D3D_DESCR "Indicates whether optional Direct3D wrapper in OCCT visualiz macro (BUILD_MODULE MODULE_NAME) set (ENABLE_MODULE TRUE) - set (OCCT_MODULES_FOR_UWP FoundationClasses ModelingAlgorithms ModelingData) + set (OCCT_MODULES_FOR_UWP FoundationClasses ModelingAlgorithms ModelingData DataExchange Visualization) list (FIND OCCT_MODULES_FOR_UWP ${OCCT_MODULE} CAN_BE_USED_IN_UWP) if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND CAN_BE_USED_IN_UWP EQUAL -1) set (ENABLE_MODULE FALSE) diff --git a/adm/genconf.tcl b/adm/genconf.tcl index 6b22f1004b..802ed4972b 100644 --- a/adm/genconf.tcl +++ b/adm/genconf.tcl @@ -127,6 +127,16 @@ proc wokdep:gui:UpdateList {} { wokdep:SearchTclTk anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs wokdep:SearchFreeType anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs wokdep:SearchX11 anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs + if { "$::HAVE_GLES2" == "true" } { + if { "$::HAVE_GL2PS" == "true" } { + lappend anIncErrs "Error: gl2ps can not be used within OpenGL ES" + } + if { "$::HAVE_D3D" == "true" } { + lappend anIncErrs "Error: Direct3D can not be used within OpenGL ES" + } + wokdep:SearchEGL anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs + wokdep:SearchGLES anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs + } if { "$::HAVE_FREEIMAGE" == "true" } { wokdep:SearchFreeImage anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs } @@ -384,6 +394,10 @@ checkbutton .myFrame.myChecks.myGl2psCheck -offvalue "false" -onvalue "true ttk::label .myFrame.myChecks.myGl2psLbl -text "Use GL2PS" checkbutton .myFrame.myChecks.myTbbCheck -offvalue "false" -onvalue "true" -variable HAVE_TBB -command wokdep:gui:UpdateList ttk::label .myFrame.myChecks.myTbbLbl -text "Use Intel TBB" +if { "$::tcl_platform(os)" != "Darwin" } { + checkbutton .myFrame.myChecks.myGlesCheck -offvalue "false" -onvalue "true" -variable HAVE_GLES2 -command wokdep:gui:UpdateList + ttk::label .myFrame.myChecks.myGlesLbl -text "Use OpenGL ES" +} if { "$::tcl_platform(platform)" == "windows" } { checkbutton .myFrame.myChecks.myD3dCheck -offvalue "false" -onvalue "true" -variable HAVE_D3D -command wokdep:gui:UpdateList ttk::label .myFrame.myChecks.myD3dLbl -text "Use Direct3D" @@ -487,10 +501,8 @@ grid .myFrame.myChecks.myTbbCheck -row $aCheckRowIter -column 2 -sticky e grid .myFrame.myChecks.myTbbLbl -row $aCheckRowIter -column 3 -sticky w grid .myFrame.myChecks.myQt4Check -row $aCheckRowIter -column 4 -sticky e grid .myFrame.myChecks.myQt4Lbl -row $aCheckRowIter -column 5 -sticky w -if { "$::tcl_platform(platform)" == "windows" } { - grid .myFrame.myChecks.myD3dCheck -row $aCheckRowIter -column 6 -sticky e - grid .myFrame.myChecks.myD3dLbl -row $aCheckRowIter -column 7 -sticky w -} +grid .myFrame.myChecks.myGlesCheck -row $aCheckRowIter -column 6 -sticky e +grid .myFrame.myChecks.myGlesLbl -row $aCheckRowIter -column 7 -sticky w #grid .myFrame.myChecks.myOpenClCheck -row $aCheckRowIter -column 6 -sticky e #grid .myFrame.myChecks.myOpenClLbl -row $aCheckRowIter -column 7 -sticky w incr aCheckRowIter @@ -500,6 +512,10 @@ grid .myFrame.myChecks.myVtkCheck -row $aCheckRowIter -column 2 -sticky e grid .myFrame.myChecks.myVtkLbl -row $aCheckRowIter -column 3 -sticky w grid .myFrame.myChecks.myJDKCheck -row $aCheckRowIter -column 4 -sticky e grid .myFrame.myChecks.myJDKLbl -row $aCheckRowIter -column 5 -sticky w +if { "$::tcl_platform(platform)" == "windows" } { + grid .myFrame.myChecks.myD3dCheck -row $aCheckRowIter -column 6 -sticky e + grid .myFrame.myChecks.myD3dLbl -row $aCheckRowIter -column 7 -sticky w +} incr aCheckRowIter if { "$::tcl_platform(os)" == "Darwin" } { grid .myFrame.myChecks.myMacGLXCheck -row $aCheckRowIter -column 0 -sticky e diff --git a/adm/genconfdeps.tcl b/adm/genconfdeps.tcl index 1fc7f841be..d6f40f89bd 100644 --- a/adm/genconfdeps.tcl +++ b/adm/genconfdeps.tcl @@ -47,6 +47,7 @@ set HAVE_FREEIMAGE "false" set HAVE_GL2PS "false" set HAVE_TBB "false" set HAVE_D3D "false" +set HAVE_GLES2 "false" set HAVE_OPENCL "false" set HAVE_VTK "false" set MACOSX_USE_GLX "false" @@ -89,6 +90,9 @@ if { [info exists ::env(HAVE_TBB)] } { if { [info exists ::env(HAVE_D3D)] } { set HAVE_D3D "$::env(HAVE_D3D)" } +if { [info exists ::env(HAVE_GLES2)] } { + set HAVE_GLES2 "$::env(HAVE_GLES2)" +} if { [info exists ::env(HAVE_OPENCL)] } { set HAVE_OPENCL "$::env(HAVE_OPENCL)" } @@ -647,6 +651,148 @@ proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBi return "$isFound" } +# Search EGL library placement +proc wokdep:SearchEGL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} { + upvar $theErrInc anErrInc + upvar $theErrLib32 anErrLib32 + upvar $theErrLib64 anErrLib64 + upvar $theErrBin32 anErrBin32 + upvar $theErrBin64 anErrBin64 + + set isFound "true" + set aHeaderPath [wokdep:SearchHeader "EGL/egl.h"] + if { "$aHeaderPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$::ARCH" ] + if { "$aPath" == "" || ![file exists "$aPath/include/EGL/egl.h"] } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ] + } + + if { "$aPath" != "" && [file exists "$aPath/include/EGL/egl.h"] } { + lappend ::CSF_OPT_INC "$aPath/include" + } else { + lappend anErrInc "Error: 'EGL/egl.h' not found (EGL)" + set isFound "false" + } + } + + set aLibName "EGL" + if { "$::tcl_platform(platform)" == "windows" } { + # awkward exception + set aLibName "libEGL" + } + + foreach anArchIter {64 32} { + set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"] + if { "$aLibPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ] + set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"] + if { "$aLibPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ] + set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"] + } + + if { "$aLibPath" != "" } { + lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib" + } else { + lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (EGL)" + if { "$::ARCH" == "$anArchIter"} { set isFound "false" } + } + } + + if { "$::tcl_platform(platform)" == "windows" } { + set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter"] + if { "$aDllPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ] + set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"] + if { "$aDllPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ] + set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"] + } + + if { "$aDllPath" != "" } { + lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin" + } else { + lappend anErrBin$anArchIter "Error: 'libEGL.dll' not found (EGL)" + if { "$::ARCH" == "$anArchIter"} { set isFound "false" } + } + } + } + } + + return "$isFound" +} + +# Search OpenGL ES 2.0 library placement +proc wokdep:SearchGLES {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} { + upvar $theErrInc anErrInc + upvar $theErrLib32 anErrLib32 + upvar $theErrLib64 anErrLib64 + upvar $theErrBin32 anErrBin32 + upvar $theErrBin64 anErrBin64 + + set isFound "true" + set aHeaderPath [wokdep:SearchHeader "GLES2/gl2.h"] + if { "$aHeaderPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$::ARCH" ] + if { "$aPath" == "" || ![file exists "$aPath/include/GLES2/gl2.h"] } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ] + } + + if { "$aPath" != "" && [file exists "$aPath/include/GLES2/gl2.h"] } { + lappend ::CSF_OPT_INC "$aPath/include" + } else { + lappend anErrInc "Error: 'GLES2/gl2.h' not found (OpenGL ES 2.0)" + set isFound "false" + } + } + + set aLibName "GLESv2" + if { "$::tcl_platform(platform)" == "windows" } { + # awkward exception + set aLibName "libGLESv2" + } + + foreach anArchIter {64 32} { + set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"] + if { "$aLibPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$anArchIter" ] + set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"] + if { "$aLibPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ] + set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"] + } + + if { "$aLibPath" != "" } { + lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib" + } else { + lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (OpenGL ES 2.0)" + if { "$::ARCH" == "$anArchIter"} { set isFound "false" } + } + } + + if { "$::tcl_platform(platform)" == "windows" } { + set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter"] + if { "$aDllPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ] + set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"] + if { "$aDllPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ] + set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"] + } + + if { "$aDllPath" != "" } { + lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin" + } else { + lappend anErrBin$anArchIter "Error: 'libGLESv2.dll' not found (OpenGL ES 2.0)" + if { "$::ARCH" == "$anArchIter"} { set isFound "false" } + } + } + } + } + + return "$isFound" +} + # Auxiliary function, gets VTK version to set default search directory proc wokdep:VtkVersion { thePath } { set aResult "6.1" @@ -932,6 +1078,7 @@ proc wokdep:SaveCustom {} { puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE" puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS" puts $aFile "set HAVE_TBB=$::HAVE_TBB" + puts $aFile "set HAVE_GLES2=$::HAVE_GLES2" puts $aFile "set HAVE_D3D=$::HAVE_D3D" puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL" puts $aFile "set HAVE_VTK=$::HAVE_VTK" @@ -982,6 +1129,7 @@ proc wokdep:SaveCustom {} { puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE" puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS" puts $aFile "export HAVE_TBB=$::HAVE_TBB" + puts $aFile "export HAVE_GLES2=$::HAVE_GLES2" puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL" puts $aFile "export HAVE_VTK=$::HAVE_VTK" if { "$::tcl_platform(os)" == "Darwin" } { diff --git a/adm/genproj.tcl b/adm/genproj.tcl index c8645131b7..237f05a367 100644 --- a/adm/genproj.tcl +++ b/adm/genproj.tcl @@ -1106,6 +1106,9 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } { set aLibsMap(CSF_netapi32) "netapi32" set aLibsMap(CSF_AviLibs) "ws2_32 vfw32" set aLibsMap(CSF_OpenGlLibs) "opengl32" + if { "$::HAVE_GLES2" == "true" } { + set aLibsMap(CSF_OpenGlLibs) "libEGL libGLESv2" + } set aLibsMap(CSF_winspool) "Winspool" set aLibsMap(CSF_psapi) "Psapi" set aLibsMap(CSF_d3d9) "d3d9" @@ -1139,6 +1142,10 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } { set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi" set aLibsMap(CSF_MotifLibs) "X11" } + + if { "$::HAVE_GLES2" == "true" } { + set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2" + } } } } diff --git a/adm/templates/OpenCASCADEConfig.cmake.in b/adm/templates/OpenCASCADEConfig.cmake.in index 46ce0ab510..ca45c3f1cf 100644 --- a/adm/templates/OpenCASCADEConfig.cmake.in +++ b/adm/templates/OpenCASCADEConfig.cmake.in @@ -61,6 +61,7 @@ set (OpenCASCADE_WITH_FREEIMAGE @USE_FREEIMAGE@) set (OpenCASCADE_WITH_GL2PS @USE_GL2PS@) set (OpenCASCADE_WITH_TBB @USE_TBB@) set (OpenCASCADE_WITH_VTK @USE_VTK@) +set (OpenCASCADE_WITH_GLES2 @USE_GLES2@) @SET_OpenCASCADE_WITH_D3D@ @SET_OpenCASCADE_WITH_GLX@ diff --git a/adm/templates/custom.build.bat.in b/adm/templates/custom.build.bat.in index e27d66bc99..7682b07697 100644 --- a/adm/templates/custom.build.bat.in +++ b/adm/templates/custom.build.bat.in @@ -6,6 +6,8 @@ if /I "%VCVER%" == "@COMPILER@" ( set "TK_DIR=@3RDPARTY_TK_DLL_DIR@" set "FREETYPE_DIR=@3RDPARTY_FREETYPE_DLL_DIR@" set "FREEIMAGE_DIR=@3RDPARTY_FREEIMAGE_DLL_DIR@" + set "EGL_DIR=@3RDPARTY_EGL_DLL_DIR@" + set "GLES2_DIR=@3RDPARTY_GLES2_DLL_DIR@" set "GL2PS_DIR=@3RDPARTY_GL2PS_DLL_DIR@" set "TBB_DIR=@3RDPARTY_TBB_DLL_DIR@" set "VTK_DIR=@3RDPARTY_VTK_DLL_DIR@" diff --git a/adm/templates/custom.install.bat.in b/adm/templates/custom.install.bat.in index e3cd47c111..4fb05ac420 100644 --- a/adm/templates/custom.install.bat.in +++ b/adm/templates/custom.install.bat.in @@ -8,6 +8,8 @@ if /I "%VCVER%" == "@COMPILER@" ( set "TK_DIR=@USED_3RDPARTY_TK_DIR@" set "FREETYPE_DIR=@USED_3RDPARTY_FREETYPE_DIR@" set "FREEIMAGE_DIR=@USED_3RDPARTY_FREEIMAGE_DIR@" + set "EGL_DIR=@USED_3RDPARTY_EGL_DIR@" + set "GLES2_DIR=@USED_3RDPARTY_GLES2_DIR@" set "GL2PS_DIR=@USED_3RDPARTY_GL2PS_DIR@" set "TBB_DIR=@USED_3RDPARTY_TBB_DIR@" set "VTK_DIR=@USED_3RDPARTY_VTK_DIR@" diff --git a/adm/templates/env.bat b/adm/templates/env.bat index 17852495cc..5ac65bcfe3 100644 --- a/adm/templates/env.bat +++ b/adm/templates/env.bat @@ -20,6 +20,7 @@ set "HAVE_OPENCL=false" set "HAVE_FREEIMAGE=false" set "HAVE_GL2PS=false" set "HAVE_VTK=false" +set "HAVE_GLES2=false" set "HAVE_D3D=false" set "CSF_OPT_INC=" set "CSF_OPT_LIB32=" @@ -62,12 +63,14 @@ if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DH if ["%HAVE_GL2PS%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GL2PS" if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" if ["%HAVE_VTK%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_VTK" +if ["%HAVE_GLES2%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GLES2" if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_D3D" if ["%HAVE_TBB%"] == ["true"] set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%" if ["%HAVE_OPENCL%"] == ["true"] set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%" if ["%HAVE_GL2PS%"] == ["true"] set "CSF_DEFINES=HAVE_GL2PS;%CSF_DEFINES%" if ["%HAVE_FREEIMAGE%"] == ["true"] set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%" if ["%HAVE_VTK%"] == ["true"] set "CSF_DEFINES=HAVE_VTK;%CSF_DEFINES%" +if ["%HAVE_GLES2%"] == ["true"] set "CSF_DEFINES=HAVE_GLES2;%CSF_DEFINES%" if ["%HAVE_D3D%"] == ["true"] set "CSF_DEFINES=HAVE_D3D;%CSF_DEFINES%" rem Eliminate VS warning diff --git a/adm/templates/env.bat.in b/adm/templates/env.bat.in index 27e15b1c9b..0820cdb8a0 100644 --- a/adm/templates/env.bat.in +++ b/adm/templates/env.bat.in @@ -29,6 +29,8 @@ if not ["%TCL_DIR%"] == [""] set "PATH=%TCL_DIR%;%PATH%" if not ["%TK_DIR%"] == [""] set "PATH=%TK_DIR%;%PATH%" if not ["%FREETYPE_DIR%"] == [""] set "PATH=%FREETYPE_DIR%;%PATH%" if not ["%FREEIMAGE_DIR%"] == [""] set "PATH=%FREEIMAGE_DIR%;%PATH%" +if not ["%EGL_DIR%"] == [""] set "PATH=%EGL_DIR%;%PATH%" +if not ["%GLES2_DIR%"] == [""] set "PATH=%GLES2_DIR%;%PATH%" if not ["%GL2PS_DIR%"] == [""] set "PATH=%GL2PS_DIR%;%PATH%" if not ["%TBB_DIR%"] == [""] set "PATH=%TBB_DIR%;%PATH%" if not ["%VTK_DIR%"] == [""] set "PATH=%VTK_DIR%;%PATH%" diff --git a/adm/templates/env.sh b/adm/templates/env.sh index 751610e228..94e395c048 100644 --- a/adm/templates/env.sh +++ b/adm/templates/env.sh @@ -12,6 +12,7 @@ export HAVE_OPENCL="false"; export HAVE_FREEIMAGE="false"; export HAVE_GL2PS="false"; export HAVE_VTK="false"; +export HAVE_GLES2="false"; export MACOSX_USE_GLX="false"; export CSF_OPT_INC="" export CSF_OPT_LIB32="" @@ -102,6 +103,9 @@ fi if [ "$HAVE_GL2PS" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_GL2PS" fi +if [ "$HAVE_GLES2" == "true" ]; then + export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_GLES2" +fi if [ "$HAVE_VTK" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_VTK" fi diff --git a/src/Aspect/Aspect_NeutralWindow.cxx b/src/Aspect/Aspect_NeutralWindow.cxx new file mode 100644 index 0000000000..d53d7b16eb --- /dev/null +++ b/src/Aspect/Aspect_NeutralWindow.cxx @@ -0,0 +1,111 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +IMPLEMENT_STANDARD_RTTIEXT(Aspect_NeutralWindow, Aspect_Window) + +// ======================================================================= +// function : Aspect_NeutralWindow +// purpose : +// ======================================================================= +Aspect_NeutralWindow::Aspect_NeutralWindow() +: myHandle (0), + myParentHandle (0), + myFBConfig (0), + myPosX (0), + myPosY (0), + myWidth (0), + myHeight (0), + myIsMapped (Standard_True) {} + +// ======================================================================= +// function : SetNativeHandles +// purpose : +// ======================================================================= +Standard_Boolean Aspect_NeutralWindow::SetNativeHandles (Aspect_Drawable theWindow, + Aspect_Drawable theParentWindow, + Aspect_FBConfig theFbConfig) +{ + if (myHandle == theWindow + && myParentHandle == theParentWindow + && myFBConfig == theFbConfig) + { + return Standard_False; + } + + myHandle = theWindow; + myParentHandle = theParentWindow; + myFBConfig = theFbConfig; + return Standard_True; +} + +// ======================================================================= +// function : SetPosition +// purpose : +// ======================================================================= +Standard_Boolean Aspect_NeutralWindow::SetPosition (Standard_Integer theX1, + Standard_Integer theY1) +{ + if (myPosX == theX1 + && myPosY == theY1) + { + return Standard_False; + } + + myPosX = theX1; + myPosY = theY1; + return Standard_True; +} + +// ======================================================================= +// function : SetPosition +// purpose : +// ======================================================================= +Standard_Boolean Aspect_NeutralWindow::SetPosition (Standard_Integer theX1, Standard_Integer theY1, + Standard_Integer theX2, Standard_Integer theY2) +{ + Standard_Integer aWidthNew = theX2 - theX1; + Standard_Integer aHeightNew = theY2 - theY1; + if (myPosX == theX1 + && myPosY == theY1 + && myWidth == aWidthNew + && myHeight == aHeightNew) + { + return Standard_False; + } + + myPosX = theX1; + myWidth = aWidthNew; + myPosY = theY1; + myHeight = aHeightNew; + return Standard_True; +} + +// ======================================================================= +// function : SetSize +// purpose : +// ======================================================================= +Standard_Boolean Aspect_NeutralWindow::SetSize (const Standard_Integer theWidth, + const Standard_Integer theHeight) +{ + if (myWidth == theWidth + && myHeight == theHeight) + { + return Standard_False; + } + + myWidth = theWidth; + myHeight = theHeight; + return Standard_True; +} diff --git a/src/Aspect/Aspect_NeutralWindow.hxx b/src/Aspect/Aspect_NeutralWindow.hxx new file mode 100644 index 0000000000..cab0f969b1 --- /dev/null +++ b/src/Aspect/Aspect_NeutralWindow.hxx @@ -0,0 +1,123 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Aspect_NeutralWindow_HeaderFile +#define _Aspect_NeutralWindow_HeaderFile + +#include + +//! Defines a platform-neutral window. +//! This class is intended to be used in context when window management (including OpenGL context creation) +//! is performed on application side (e.g. using external framework). +//! +//! Window properties should be managed by application and assigned to this class as properties. +class Aspect_NeutralWindow : public Aspect_Window +{ + DEFINE_STANDARD_RTTIEXT(Aspect_NeutralWindow, Aspect_Window) +public: + + //! Empty constructor. + //! Note that window is considered "mapped" by default. + Standard_EXPORT Aspect_NeutralWindow(); + + //! Return native handle of this drawable. + virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE { return myHandle; } + + //! Return native handle of the parent drawable. + virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return myParentHandle; } + + //! Return FBConfig. + virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return myFBConfig; } + + //! Set native handle. + //! @return true if definition has been changed + Standard_EXPORT Standard_Boolean SetNativeHandle (Aspect_Drawable theWindow) { return SetNativeHandles (theWindow, 0, 0); } + + //! Set native handles. + //! @return true if definition has been changed + Standard_EXPORT Standard_Boolean SetNativeHandles (Aspect_Drawable theWindow, + Aspect_Drawable theParentWindow, + Aspect_FBConfig theFbConfig); + + //! Return true if window is not hidden. + virtual Standard_Boolean IsMapped() const Standard_OVERRIDE { return myIsMapped; } + + //! Change window mapped flag to TRUE. + virtual void Map() const Standard_OVERRIDE { myIsMapped = Standard_True; } + + //! Change window mapped flag to FALSE. + virtual void Unmap() const Standard_OVERRIDE { myIsMapped = Standard_False; } + + //! Resize window - do nothing. + virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; } + + //! Map window - do nothing. + virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; } + + //! Returns window ratio equal to the physical width/height dimensions. + virtual Quantity_Ratio Ratio() const Standard_OVERRIDE + { + return (myWidth != 0 && myHeight != 0) + ? Quantity_Ratio(myWidth) / Quantity_Ratio(myHeight) + : 1.0; + } + + //! Return the window position. + virtual void Position (Standard_Integer& theX1, Standard_Integer& theY1, + Standard_Integer& theX2, Standard_Integer& theY2) const Standard_OVERRIDE + { + theX1 = myPosX; + theX2 = myPosX + myWidth; + theY1 = myPosY; + theY2 = myPosY + myHeight; + } + + //! Set the window position. + //! @return true if position has been changed + Standard_EXPORT Standard_Boolean SetPosition (Standard_Integer theX1, + Standard_Integer theY1); + + //! Set the window position. + //! @return true if position has been changed + Standard_EXPORT Standard_Boolean SetPosition (Standard_Integer theX1, Standard_Integer theY1, + Standard_Integer theX2, Standard_Integer theY2); + + //! Return the window size. + virtual void Size (Standard_Integer& theWidth, + Standard_Integer& theHeight) const Standard_OVERRIDE + { + theWidth = myWidth; + theHeight = myHeight; + } + + //! Set the window size. + //! @return true if size has been changed + Standard_EXPORT Standard_Boolean SetSize (const Standard_Integer theWidth, + const Standard_Integer theHeight); + +protected: + + Aspect_Drawable myHandle; + Aspect_Drawable myParentHandle; + Aspect_FBConfig myFBConfig; + Standard_Integer myPosX; + Standard_Integer myPosY; + Standard_Integer myWidth; + Standard_Integer myHeight; + mutable Standard_Boolean myIsMapped; + +}; + +DEFINE_STANDARD_HANDLE(Aspect_NeutralWindow, Aspect_Window) + +#endif // _Aspect_NeutralWindow_HeaderFile diff --git a/src/Aspect/FILES b/src/Aspect/FILES index 4920a1bc52..9f42897043 100755 --- a/src/Aspect/FILES +++ b/src/Aspect/FILES @@ -25,6 +25,8 @@ Aspect_Grid.cxx Aspect_Grid.hxx Aspect_GridDrawMode.hxx Aspect_GridType.hxx +Aspect_NeutralWindow.cxx +Aspect_NeutralWindow.hxx Aspect_Handle.hxx Aspect_HatchStyle.hxx Aspect_IdentDefinitionError.hxx diff --git a/src/Font/Font_FontMgr.cxx b/src/Font/Font_FontMgr.cxx index de8e3c6745..6c62f60225 100644 --- a/src/Font/Font_FontMgr.cxx +++ b/src/Font/Font_FontMgr.cxx @@ -316,7 +316,10 @@ void Font_FontMgr::InitFontDataBase() myListOfFonts.Clear(); Handle(Font_FTLibrary) aFtLibrary; -#if defined(_WIN32) +#if defined(OCCT_UWP) + // system font files are not accessible + (void )aFtLibrary; +#elif defined(_WIN32) // font directory is placed in "C:\Windows\Fonts\" UINT aStrLength = GetSystemWindowsDirectoryA (NULL, 0); diff --git a/src/OSD/OSD_Environment.cxx b/src/OSD/OSD_Environment.cxx index d3ed551773..8a4e4e9eb5 100644 --- a/src/OSD/OSD_Environment.cxx +++ b/src/OSD/OSD_Environment.cxx @@ -240,13 +240,22 @@ Standard_Integer OSD_Environment::Error() const #include +#include #include +#include #if defined(_MSC_VER) #pragma warning( disable : 4700 ) #endif -#ifndef OCCT_UWP +#ifdef OCCT_UWP +namespace +{ + // emulate global map of environment variables + static Standard_Mutex THE_ENV_LOCK; + static NCollection_DataMap THE_ENV_MAP; +} +#else static void __fastcall _set_error ( OSD_Error&, DWORD ); #endif @@ -278,9 +287,11 @@ void OSD_Environment :: SetValue ( const TCollection_AsciiString& Value ) { TCollection_AsciiString OSD_Environment::Value() { -#ifndef OCCT_UWP myValue.Clear(); - +#ifdef OCCT_UWP + Standard_Mutex::Sentry aLock (THE_ENV_LOCK); + THE_ENV_MAP.Find (myName, myValue); +#else SetLastError (ERROR_SUCCESS); wchar_t* anEnvVal = NULL; NCollection_UtfWideString aNameWide (myName.ToCString()); @@ -308,11 +319,8 @@ TCollection_AsciiString OSD_Environment::Value() Reset(); } myValue = aValue.ToCString(); - return myValue; -#else - myValue = ""; - return myValue; #endif + return myValue; } void OSD_Environment :: SetName ( const TCollection_AsciiString& name ) { @@ -329,7 +337,10 @@ TCollection_AsciiString OSD_Environment :: Name () const { void OSD_Environment::Build() { -#ifndef OCCT_UWP +#ifdef OCCT_UWP + Standard_Mutex::Sentry aLock(THE_ENV_LOCK); + THE_ENV_MAP.Bind (myName, myValue); +#else NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "=" + myValue.ToCString(); _wputenv (aSetVariable.ToUtfWide().ToCString()); #endif @@ -337,7 +348,10 @@ void OSD_Environment::Build() void OSD_Environment::Remove() { -#ifndef OCCT_UWP +#ifdef OCCT_UWP + Standard_Mutex::Sentry aLock(THE_ENV_LOCK); + THE_ENV_MAP.UnBind (myName); +#else NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "="; _wputenv (aSetVariable.ToUtfWide().ToCString()); #endif diff --git a/src/OSD/OSD_signal.cxx b/src/OSD/OSD_signal.cxx index 99968bf844..6f0451a343 100644 --- a/src/OSD/OSD_signal.cxx +++ b/src/OSD/OSD_signal.cxx @@ -363,6 +363,7 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal) { #if !defined(__CYGWIN32__) && !defined(__MINGW32__) Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling +#if !defined(OCCT_UWP) || defined(NTDDI_WIN10_TH2) LPTOP_LEVEL_EXCEPTION_FILTER aPreviousFilter; OSD_Environment env ("CSF_DEBUG_MODE"); @@ -382,6 +383,7 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal) // Replaces the existing top-level exception filter for all existing and all future threads // in the calling process aPreviousFilter = ::SetUnhandledExceptionFilter (/*(LPTOP_LEVEL_EXCEPTION_FILTER)*/ WntHandler); +#endif // NTDDI_WIN10_TH2 // Signal handlers will only be used when the method ::raise() will be used // Handlers must be set for every thread diff --git a/src/OpenGl/OpenGl_AVIWriter.hxx b/src/OpenGl/OpenGl_AVIWriter.hxx index 9d80aa8f45..96ad331978 100644 --- a/src/OpenGl/OpenGl_AVIWriter.hxx +++ b/src/OpenGl/OpenGl_AVIWriter.hxx @@ -16,10 +16,13 @@ #ifndef __OPENGL_AVIWRITER_H #define __OPENGL_AVIWRITER_H -#ifdef _MSC_VER +#if defined(_WIN32) + #include +#endif -#define THIS void -#include +#include + +#if defined(_MSC_VER) && !defined(OCCT_UWP) #include #include diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 848282c5d1..cf724a84f2 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -134,6 +134,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) arbDbg (NULL), arbFBO (NULL), arbFBOBlit (NULL), + extFragDepth (Standard_False), extGS (NULL), extBgra(Standard_False), extAnis(Standard_False), @@ -1200,6 +1201,8 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) { arbFBOBlit = (OpenGl_ArbFBOBlit* )(&(*myFuncs)); } + extFragDepth = !IsGlGreaterEqual(3, 0) + && CheckExtension ("GL_EXT_frag_depth"); if (IsGlGreaterEqual (3, 1) && FindProc ("glTexStorage2DMultisample", myFuncs->glTexStorage2DMultisample)) { diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index dd7a83a30d..8bb04444c7 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -721,6 +721,7 @@ public: //! @name extensions OpenGl_ArbDbg* arbDbg; //!< GL_ARB_debug_output OpenGl_ArbFBO* arbFBO; //!< GL_ARB_framebuffer_object OpenGl_ArbFBOBlit* arbFBOBlit; //!< glBlitFramebuffer function, moved out from OpenGl_ArbFBO structure for compatibility with OpenGL ES 2.0 + Standard_Boolean extFragDepth; //!< GL_EXT_frag_depth on OpenGL ES 2.0 (gl_FragDepthEXT built-in variable, before OpenGL ES 3.0) OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4 Standard_Boolean extBgra; //!< GL_EXT_bgra or GL_EXT_texture_format_BGRA8888 on OpenGL ES Standard_Boolean extAnis; //!< GL_EXT_texture_filter_anisotropic diff --git a/src/OpenGl/OpenGl_GlFunctions.hxx b/src/OpenGl/OpenGl_GlFunctions.hxx index 34da9ac7e2..ff09ebb4aa 100644 --- a/src/OpenGl/OpenGl_GlFunctions.hxx +++ b/src/OpenGl/OpenGl_GlFunctions.hxx @@ -22,6 +22,9 @@ #include #endif +#include +#include + #ifndef APIENTRY #define APIENTRY #endif @@ -45,7 +48,12 @@ #include #endif #define __X_GL_H // prevent chaotic gl.h inclusions to avoid compile errors -#elif defined(HAVE_GLES2) || defined(__ANDROID__) || defined(__QNX__) +#elif defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) + #if defined(_WIN32) + // Angle OpenGL ES headers do not define function prototypes even for core functions, + // however OCCT is expected to be linked against libGLESv2 + #define GL_GLEXT_PROTOTYPES + #endif #include //#include #else @@ -178,7 +186,7 @@ #define GL_DEBUG_SEVERITY_LOW 0x9148 #endif -#if defined(__ANDROID__) || defined(__QNX__) +#if !defined(HAVE_EGL) && (defined(__ANDROID__) || defined(__QNX__) || defined(HAVE_GLES2) || defined(OCCT_UWP)) #define HAVE_EGL #endif diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 83cf40da17..3664947be5 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -13,6 +13,10 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#if defined(_WIN32) + #include +#endif + #include #include #include @@ -44,7 +48,7 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver) #include // XOpenDisplay() #endif -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) #include #endif @@ -61,7 +65,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio const Standard_Boolean theToInitialize) : Graphic3d_GraphicDriver (theDisp), myIsOwnContext (Standard_False), -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) myEglDisplay ((Aspect_Display )EGL_NO_DISPLAY), myEglContext ((Aspect_RenderingContext )EGL_NO_CONTEXT), myEglConfig (NULL), @@ -82,7 +86,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio || ::getenv ("CALL_SYNCHRO_X") != NULL; XSynchronize (aDisplay, toSync); -#if !defined(HAVE_EGL) +#if !defined(HAVE_EGL) && !defined(HAVE_GLES2) // does the server know about OpenGL & GLX? int aDummy; if (!XQueryExtension (aDisplay, "GLX", &aDummy, &aDummy, &aDummy)) @@ -206,7 +210,7 @@ void OpenGl_GraphicDriver::ReleaseContext() aWindow->GetGlContext()->forcedRelease(); } -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) if (myIsOwnContext) { if (myEglContext != (Aspect_RenderingContext )EGL_NO_CONTEXT) @@ -241,7 +245,7 @@ void OpenGl_GraphicDriver::ReleaseContext() Standard_Boolean OpenGl_GraphicDriver::InitContext() { ReleaseContext(); -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) #if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) if (myDisplayConnection.IsNull()) @@ -322,17 +326,18 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext() ::Message::DefaultMessenger()->Send ("Error: EGL is unable to create OpenGL context!", Message_Fail); return Standard_False; } - if (eglMakeCurrent ((EGLDisplay )myEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, (EGLContext )myEglContext) != EGL_TRUE) - { - ::Message::DefaultMessenger()->Send ("Error: EGL is unable bind OpenGL context!", Message_Fail); - return Standard_False; - } + // eglMakeCurrent() fails or even crash with EGL_NO_SURFACE on some implementations + //if (eglMakeCurrent ((EGLDisplay )myEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, (EGLContext )myEglContext) != EGL_TRUE) + //{ + // ::Message::DefaultMessenger()->Send ("Error: EGL is unable bind OpenGL context!", Message_Fail); + // return Standard_False; + //} #endif myIsOwnContext = Standard_True; return Standard_True; } -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) // ======================================================================= // function : InitEglContext // purpose : @@ -778,7 +783,7 @@ Standard_Boolean OpenGl_GraphicDriver::ViewExists (const Handle(Aspect_Window)& // Parse the list of views to find // a view with the specified window -#if defined(_WIN32) +#if defined(_WIN32) && !defined(OCCT_UWP) const Handle(WNT_Window) THEWindow = Handle(WNT_Window)::DownCast (AWindow); Aspect_Handle TheSpecifiedWindowId = THEWindow->HWindow (); #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) @@ -788,7 +793,7 @@ Standard_Boolean OpenGl_GraphicDriver::ViewExists (const Handle(Aspect_Window)& #else NSView* TheSpecifiedWindowId = THEWindow->HView(); #endif -#elif defined(__ANDROID__) || defined(__QNX__) +#elif defined(__ANDROID__) || defined(__QNX__) || defined(OCCT_UWP) (void )AWindow; int TheSpecifiedWindowId = -1; #else @@ -804,7 +809,7 @@ Standard_Boolean OpenGl_GraphicDriver::ViewExists (const Handle(Aspect_Window)& { const Handle(Aspect_Window) AspectWindow = aView->Window(); -#if defined(_WIN32) +#if defined(_WIN32) && !defined(OCCT_UWP) const Handle(WNT_Window) theWindow = Handle(WNT_Window)::DownCast (AspectWindow); Aspect_Handle TheWindowIdOfView = theWindow->HWindow (); #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) @@ -814,7 +819,7 @@ Standard_Boolean OpenGl_GraphicDriver::ViewExists (const Handle(Aspect_Window)& #else NSView* TheWindowIdOfView = theWindow->HView(); #endif -#elif defined(__ANDROID__) || defined(__QNX__) +#elif defined(__ANDROID__) || defined(__QNX__) || defined(OCCT_UWP) int TheWindowIdOfView = 0; #else const Handle(Xw_Window) theWindow = Handle(Xw_Window)::DownCast (AspectWindow); diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index 29a40b9c3a..fe14f3a4e0 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -100,7 +100,7 @@ public: //! Perform initialization of default OpenGL context. Standard_EXPORT Standard_Boolean InitContext(); -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) //! Initialize default OpenGL context using existing one. //! @param theEglDisplay EGL connection to the Display //! @param theEglContext EGL rendering context @@ -193,7 +193,7 @@ public: //! Could return NULL-handle if no window created by this driver. Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext() const; -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) Aspect_Display getRawGlDisplay() const { return myEglDisplay; } Aspect_RenderingContext getRawGlContext() const { return myEglContext; } void* getRawGlConfig() const { return myEglConfig; } @@ -209,7 +209,7 @@ public: protected: Standard_Boolean myIsOwnContext; //!< indicates that shared context has been created within OpenGl_GraphicDriver -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) Aspect_Display myEglDisplay; //!< EGL connection to the Display : EGLDisplay Aspect_RenderingContext myEglContext; //!< EGL rendering context : EGLContext void* myEglConfig; //!< EGL configuration : EGLConfig diff --git a/src/OpenGl/OpenGl_ShaderManager.cxx b/src/OpenGl/OpenGl_ShaderManager.cxx index 735adc9f6c..270c5e96b4 100644 --- a/src/OpenGl/OpenGl_ShaderManager.cxx +++ b/src/OpenGl/OpenGl_ShaderManager.cxx @@ -913,6 +913,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit() { aProgramSrc->SetHeader ("#version 300 es"); } + else if (myContext->extFragDepth) + { + aProgramSrc->SetHeader ("#extension GL_EXT_frag_depth : enable" + EOL"#define gl_FragDepth gl_FragDepthEXT"); + } else { // there is no way to draw into depth buffer diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index 55d11d6dbb..5985b030fd 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -1388,6 +1388,13 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo, aCtx->core20fwd->glDepthFunc (GL_ALWAYS); aCtx->core20fwd->glDepthMask (GL_TRUE); aCtx->core20fwd->glEnable (GL_DEPTH_TEST); + #if defined(GL_ES_VERSION_2_0) + if (!aCtx->IsGlGreaterEqual (3, 0) + && !aCtx->extFragDepth) + { + aCtx->core20fwd->glDisable (GL_DEPTH_TEST); + } + #endif myWorkspace->DisableTexture(); diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index 1c442e49b6..2a0d43072f 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -27,7 +27,7 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Window,MMgt_TShared) -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) #include #endif @@ -37,7 +37,7 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Window,MMgt_TShared) namespace { -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) // #elif defined(_WIN32) @@ -173,7 +173,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver, Standard_Boolean isCoreProfile = Standard_False; -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) EGLDisplay anEglDisplay = (EGLDisplay )theDriver->getRawGlDisplay(); EGLContext anEglContext = (EGLContext )theDriver->getRawGlContext(); EGLConfig anEglConfig = (EGLConfig )theDriver->getRawGlConfig(); @@ -616,7 +616,7 @@ OpenGl_Window::~OpenGl_Window() // release "GL" context if it is owned by window // Mesa implementation can fail to destroy GL context if it set for current thread. // It should be safer to unset thread GL context before its destruction. -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) if ((EGLSurface )myGlContext->myWindow != EGL_NO_SURFACE) { eglDestroySurface ((EGLDisplay )myGlContext->myDisplay, @@ -678,7 +678,7 @@ Standard_Boolean OpenGl_Window::Activate() // ======================================================================= void OpenGl_Window::Resize() { -#if !defined(_WIN32) && !defined(HAVE_EGL) && !defined(__ANDROID__) && !defined(__QNX__) +#if !defined(_WIN32) && !defined(HAVE_EGL) Display* aDisp = (Display* )myGlContext->myDisplay; if (aDisp == NULL) return; @@ -695,7 +695,7 @@ void OpenGl_Window::Resize() myWidth = aWidth; myHeight = aHeight; -#if !defined(_WIN32) && !defined(HAVE_EGL) && !defined(__ANDROID__) && !defined(__QNX__) +#if !defined(_WIN32) && !defined(HAVE_EGL) XResizeWindow (aDisp, myGlContext->myWindow, (unsigned int )myWidth, (unsigned int )myHeight); XSync (aDisp, False); #endif @@ -712,7 +712,7 @@ void OpenGl_Window::Init() if (!Activate()) return; -#if defined(HAVE_EGL) || defined(__ANDROID__) || defined(__QNX__) +#if defined(HAVE_EGL) eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_WIDTH, &myWidth); eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_HEIGHT, &myHeight); #elif defined(_WIN32) diff --git a/src/Standard/Standard_Mutex.cxx b/src/Standard/Standard_Mutex.cxx index ee10a87631..0de020f540 100644 --- a/src/Standard/Standard_Mutex.cxx +++ b/src/Standard/Standard_Mutex.cxx @@ -13,14 +13,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// On Windows, function TryEnterCriticalSection has appeared in Windows NT -// and is surrounded by #ifdef in MS VC++ 7.1 headers. -// Thus to use it we need to define appropriate macro saying that we wil -// run on Windows NT 4.0 at least -#if ((defined(_WIN32) || defined(__WIN32__)) && !defined(_WIN32_WINNT)) - #define _WIN32_WINNT 0x0400 -#endif - #include #include diff --git a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx index 13cea1470a..d520f9959e 100644 --- a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx +++ b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx @@ -165,6 +165,7 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const aTA->Aspect()->Font(); OpenGl_Vec4 aColor = theWorkspace->LineColor(); +#if !defined(GL_ES_VERSION_2_0) // Finally draw something to make sure UserDraw really works glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); @@ -176,6 +177,7 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const glVertex3f(myCoords[0], myCoords[1], myCoords[5]); glEnd(); glPopAttrib(); +#endif } } // end of anonymous namespace @@ -222,6 +224,7 @@ static int VFeedback (Draw_Interpretor& theDI, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/) { +#if !defined(GL_ES_VERSION_2_0) // get the active view Handle(V3d_View) aView = ViewerTest::CurrentView(); if (aView.IsNull()) @@ -363,6 +366,11 @@ static int VFeedback (Draw_Interpretor& theDI, << "Buffer size GL_3D_COLOR: " << aLen3D_rgba * double(sizeof(GLfloat)) / double(1024 * 1024) << " MiB\n"; return 0; } +#else + (void )theDI; + std::cout << "Command is unsupported on current platform.\n"; + return 1; +#endif } //============================================================================== diff --git a/src/WNT/WNT_WClass.cxx b/src/WNT/WNT_WClass.cxx index 51a153ebad..e3f7271727 100644 --- a/src/WNT/WNT_WClass.cxx +++ b/src/WNT/WNT_WClass.cxx @@ -14,12 +14,15 @@ #include +#include + #include #include #include -#include #include +#if defined(_WIN32) && !defined(OCCT_UWP) + #include IMPLEMENT_STANDARD_RTTIEXT(WNT_WClass,MMgt_TShared) @@ -78,3 +81,4 @@ WNT_WClass::~WNT_WClass () } // end WNT_WClass :: Destroy +#endif // _WIN32 diff --git a/src/WNT/WNT_WClass.hxx b/src/WNT/WNT_WClass.hxx index 6b28ffe293..b6809b1766 100644 --- a/src/WNT/WNT_WClass.hxx +++ b/src/WNT/WNT_WClass.hxx @@ -18,8 +18,10 @@ #define _WNT_WClass_HeaderFile #include -#include +#if defined(_WIN32) && !defined(OCCT_UWP) + +#include #include #include #include @@ -80,24 +82,13 @@ friend class WNT_Window; protected: - Standard_CString lpszName; Aspect_Handle hInstance; Standard_Address lpfnWndProc; - -private: - - - - }; - #include - - - - +#endif // _WIN32 #endif // _WNT_WClass_HeaderFile diff --git a/src/WNT/WNT_Window.cxx b/src/WNT/WNT_Window.cxx index 201853f00a..99f3bbd811 100644 --- a/src/WNT/WNT_Window.cxx +++ b/src/WNT/WNT_Window.cxx @@ -15,6 +15,9 @@ // include windows.h first to have all definitions available #include +#include + +#if defined(_WIN32) && !defined(OCCT_UWP) #include #include @@ -22,7 +25,6 @@ #include #include #include -#include #include @@ -354,3 +356,5 @@ void WNT_Window::SetPos (const Standard_Integer theX, const Standard_Integer th aXRight = theX1; aYBottom = theY1; } + +#endif // _WIN32 diff --git a/src/WNT/WNT_Window.hxx b/src/WNT/WNT_Window.hxx index b7b6f3c0f6..6e0b78b4c0 100644 --- a/src/WNT/WNT_Window.hxx +++ b/src/WNT/WNT_Window.hxx @@ -18,8 +18,10 @@ #define _WNT_Window_HeaderFile #include -#include +#if defined(_WIN32) && !defined(OCCT_UWP) + +#include #include #include #include @@ -118,7 +120,6 @@ public: protected: - Standard_Integer aXLeft; Standard_Integer aYTop; Standard_Integer aXRight; @@ -128,19 +129,9 @@ protected: Aspect_Handle myHParentWindow; Standard_Boolean myIsForeign; - -private: - - - - }; - #include - - - - +#endif // _WIN32 #endif // _WNT_Window_HeaderFile