0032203: Draw Harness, ViewerTest - drop dependency from OpenGL
authorkgv <kgv@opencascade.com>
Mon, 8 Mar 2021 17:34:41 +0000 (20:34 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 17 Mar 2021 16:56:54 +0000 (19:56 +0300)
Added TKOpenGlTest and TKD3DHostTest Draw Harness plugins.
TKOpenGlTest is automatically loaded by ViewerTest::ViewerInit().

Commands vgldebug, vvbo, vcaps and vuserdraw have been moved to TKOpenGlTest.
New command vglshaders lists GLSL programs defined by OpenGl_GraphicDriver,
previously implemented by "vshaderprog -list".

Added new command vdriver for graphic driver selection.
Removed erroneous code from command vstereo.

73 files changed:
CMakeLists.txt
adm/MODULES
adm/UDLIST
adm/qmake/OccModule.pri
samples/tcl/snowflake.tcl
src/D3DHost/D3DHost_GraphicDriverFactory.cxx [new file with mode: 0644]
src/D3DHost/D3DHost_GraphicDriverFactory.hxx [new file with mode: 0644]
src/D3DHost/FILES
src/D3DHostTest/D3DHostTest.cxx [new file with mode: 0644]
src/D3DHostTest/D3DHostTest.hxx [new file with mode: 0644]
src/D3DHostTest/FILES [new file with mode: 0644]
src/DrawResources/DrawPlugin
src/DrawResources/TestCommands.tcl
src/Graphic3d/FILES
src/Graphic3d/Graphic3d_GraphicDriver.hxx
src/Graphic3d/Graphic3d_GraphicDriverFactory.cxx [new file with mode: 0644]
src/Graphic3d/Graphic3d_GraphicDriverFactory.hxx [new file with mode: 0644]
src/OS/Draw.tcl
src/OS/Visualization.tcl
src/OpenGl/FILES
src/OpenGl/OpenGl_GraphicDriver.cxx
src/OpenGl/OpenGl_GraphicDriver.hxx
src/OpenGl/OpenGl_GraphicDriverFactory.cxx [new file with mode: 0644]
src/OpenGl/OpenGl_GraphicDriverFactory.hxx [new file with mode: 0644]
src/OpenGlTest/FILES [new file with mode: 0644]
src/OpenGlTest/OpenGlTest.cxx [new file with mode: 0644]
src/OpenGlTest/OpenGlTest.hxx [new file with mode: 0644]
src/OpenGlTest/OpenGlTest_Commands.cxx [new file with mode: 0644]
src/TKD3DHostTest/CMakeLists.txt [new file with mode: 0644]
src/TKD3DHostTest/EXTERNLIB [new file with mode: 0644]
src/TKD3DHostTest/FILES [new file with mode: 0644]
src/TKD3DHostTest/PACKAGES [new file with mode: 0644]
src/TKOpenGlTest/CMakeLists.txt [new file with mode: 0644]
src/TKOpenGlTest/EXTERNLIB [new file with mode: 0644]
src/TKOpenGlTest/FILES [new file with mode: 0644]
src/TKOpenGlTest/PACKAGES [new file with mode: 0644]
src/TKViewerTest/EXTERNLIB
src/ViewerTest/ViewerTest_OpenGlCommands.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/3rdparty/begin
tests/bugs/iges/begin
tests/bugs/vis/bug172
tests/bugs/vis/bug23654_MarkersRecompute
tests/bugs/vis/bug23747_2
tests/bugs/vis/bug24131_markers_bitmap
tests/bugs/vis/bug24131_markers_core
tests/bugs/vis/bug24131_markers_glsl
tests/bugs/vis/bug24131_markers_sprites
tests/bugs/vis/bug24728
tests/bugs/vis/bug25532
tests/bugs/vis/bug25611_1
tests/bugs/vis/bug25611_2
tests/bugs/vis/bug25854 [deleted file]
tests/bugs/vis/bug26312
tests/bugs/vis/bug26434
tests/bugs/vis/bug26599
tests/bugs/vis/bug27337
tests/bugs/vis/bug28099_text_core
tests/bugs/vis/bug29127
tests/bugs/vis/bug29412
tests/bugs/vis/bug29938
tests/bugs/vis/bug30713
tests/bugs/vis/bug79
tests/caf/bugs/B6
tests/caf/bugs/D2
tests/caf/presentation/begin
tests/geometry/begin
tests/lowalgos/begin
tests/mesh/begin
tests/v3d/begin
tests/v3d/glsl/d3dhost [new file with mode: 0644]
tests/xml/begin
tests/xml/data/ocaf/B6

index b8c22b2..85b8966 100644 (file)
@@ -416,6 +416,7 @@ endif()
 
 if (NOT USE_D3D)
   list (REMOVE_ITEM Visualization_TOOLKITS TKD3DHost)
+  list (REMOVE_ITEM Draw_TOOLKITS TKD3DHostTest)
 endif()
 
 # accumulate used toolkits (first level) in BUILD_TOOLKITS variable
index 2ec6ef3..58f65a0 100644 (file)
@@ -4,4 +4,4 @@ ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffs
 Visualization TKService TKV3d TKOpenGl 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 TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE
+Draw TKDraw TKTopTest TKOpenGlTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE
index 2f4e59a..3bbef06 100644 (file)
@@ -402,6 +402,8 @@ n HLRTest
 n MeshTest
 n SWDRAW
 n TObjDRAW
+n OpenGlTest
+n D3DHostTest
 n ViewerTest
 n XDEDRAW
 n XSDRAW
@@ -413,6 +415,8 @@ t TKDCAF
 t TKDraw
 t TKTObjDRAW
 t TKTopTest
+t TKOpenGlTest
+t TKD3DHostTest
 t TKViewerTest
 t TKXDEDRAW
 t TKXSDRAW
index 52870ab..84f2357 100644 (file)
@@ -16,6 +16,7 @@ for (aModuleIter, aModuleList) {
       !HAVE_VTK:equals (aToolKit, "TKIVtk")     { toSkipToolkit = 1 }
       !HAVE_VTK:equals (aToolKit, "TKIVtkDraw") { 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)
index 2819d7e..776c2c7 100644 (file)
@@ -3,7 +3,7 @@
 #Category: Modeling
 #Title: Snowflake - creation of 2d drawing
 
-pload MODELING AISV
+pload MODELING VISUALIZATION
 
 puts "Generating sample drawing of snowflake..."
 
diff --git a/src/D3DHost/D3DHost_GraphicDriverFactory.cxx b/src/D3DHost/D3DHost_GraphicDriverFactory.cxx
new file mode 100644 (file)
index 0000000..855c0dc
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (c) 2021 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 <D3DHost_GraphicDriverFactory.hxx>
+
+#include <D3DHost_GraphicDriver.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(D3DHost_GraphicDriverFactory, OpenGl_GraphicDriverFactory)
+
+// =======================================================================
+// function : D3DHost_GraphicDriverFactory
+// purpose  :
+// =======================================================================
+D3DHost_GraphicDriverFactory::D3DHost_GraphicDriverFactory()
+{
+  myName = "TKD3DHost";
+}
+
+// =======================================================================
+// function : CreateDriver
+// purpose  :
+// =======================================================================
+Handle(Graphic3d_GraphicDriver) D3DHost_GraphicDriverFactory::CreateDriver (const Handle(Aspect_DisplayConnection)& )
+{
+  Handle(D3DHost_GraphicDriver) aDriver = new D3DHost_GraphicDriver();
+  aDriver->ChangeOptions() = *myDefaultCaps;
+  aDriver->InitContext();
+  return aDriver;
+}
diff --git a/src/D3DHost/D3DHost_GraphicDriverFactory.hxx b/src/D3DHost/D3DHost_GraphicDriverFactory.hxx
new file mode 100644 (file)
index 0000000..5c1c0fe
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (c) 2021 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 _D3DHost_GraphicDriverFactory_Header
+#define _D3DHost_GraphicDriverFactory_Header
+
+#include <OpenGl_GraphicDriverFactory.hxx>
+
+//! This class for creation of D3DHost_GraphicDriver.
+class D3DHost_GraphicDriverFactory : public OpenGl_GraphicDriverFactory
+{
+  DEFINE_STANDARD_RTTIEXT(D3DHost_GraphicDriverFactory, OpenGl_GraphicDriverFactory)
+public:
+
+  //! Empty constructor.
+  Standard_EXPORT D3DHost_GraphicDriverFactory();
+
+  //! Creates new empty graphic driver.
+  Standard_EXPORT virtual Handle(Graphic3d_GraphicDriver) CreateDriver (const Handle(Aspect_DisplayConnection)& theDisp) Standard_OVERRIDE;
+
+};
+
+#endif //_D3DHost_GraphicDriverFactory_Header
index 2fc633e..65afdc4 100644 (file)
@@ -1,5 +1,7 @@
 D3DHost_GraphicDriver.hxx
 D3DHost_GraphicDriver.cxx
+D3DHost_GraphicDriverFactory.hxx
+D3DHost_GraphicDriverFactory.cxx
 D3DHost_FrameBuffer.hxx
 D3DHost_FrameBuffer.cxx
 D3DHost_View.hxx
diff --git a/src/D3DHostTest/D3DHostTest.cxx b/src/D3DHostTest/D3DHostTest.cxx
new file mode 100644 (file)
index 0000000..c785272
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (c) 2021 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 <D3DHostTest.hxx>
+
+#include <Draw_PluginMacro.hxx>
+#include <D3DHost_GraphicDriverFactory.hxx>
+
+// ======================================================================
+// function : Factory
+// purpose  :
+// ======================================================================
+void D3DHostTest::Factory (Draw_Interpretor& )
+{
+  static const Handle(D3DHost_GraphicDriverFactory) aFactory = new D3DHost_GraphicDriverFactory();
+  Graphic3d_GraphicDriverFactory::RegisterFactory (aFactory);
+#ifdef DEB
+  theDI << "Draw Plugin : D3DHost commands are loaded.\n";
+#endif
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(D3DHostTest)
diff --git a/src/D3DHostTest/D3DHostTest.hxx b/src/D3DHostTest/D3DHostTest.hxx
new file mode 100644 (file)
index 0000000..5ce4555
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (c) 2021 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 _D3DHostTest_HeaderFile
+#define _D3DHostTest_HeaderFile
+
+#include <Draw_Interpretor.hxx>
+
+//! This package defines a set of Draw commands for testing of TKD3DHost library.
+class D3DHostTest
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  //! Adds Draw commands to the draw interpretor.
+  Standard_EXPORT static void Commands (Draw_Interpretor& theDI);
+
+  //! Plugin entry point function.
+  Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
+};
+
+#endif // _D3DHostTest_HeaderFile
diff --git a/src/D3DHostTest/FILES b/src/D3DHostTest/FILES
new file mode 100644 (file)
index 0000000..fad410d
--- /dev/null
@@ -0,0 +1,2 @@
+D3DHostTest.cxx
+D3DHostTest.hxx
index 5ab992a..f0325d9 100755 (executable)
@@ -42,6 +42,8 @@ ALL                : MODELING, OCAFKERNEL, DATAEXCHANGE
 TOPTEST            : TKTopTest
 DCAF               : TKDCAF
 AISV               : TKViewerTest
+OPENGL             : TKOpenGlTest
+D3DHOST            : TKD3DHostTest
 XSDRAW             : TKXSDRAW
 XDEDRAW            : TKXDEDRAW
 TOBJ               : TKTObjDRAW
index 5310bc4..48dd1ee 100644 (file)
@@ -1145,7 +1145,7 @@ proc testfile {filelist} {
         file mkdir $tmpdir/$dir
 
         # make snapshot
-        pload AISV
+        pload VISUALIZATION
         uplevel vdisplay a
         uplevel vsetdispmode 1
         uplevel vfit
index 365f97f..3102afa 100755 (executable)
@@ -74,6 +74,8 @@ Graphic3d_FrameStatsTimer.hxx
 Graphic3d_GraduatedTrihedron.hxx
 Graphic3d_GraphicDriver.cxx
 Graphic3d_GraphicDriver.hxx
+Graphic3d_GraphicDriverFactory.cxx
+Graphic3d_GraphicDriverFactory.hxx
 Graphic3d_Group.cxx
 Graphic3d_Group.hxx
 Graphic3d_GroupAspect.hxx
index 20d6aed..ca6fbfb 100644 (file)
@@ -95,8 +95,14 @@ public:
   //! Removes view from graphic driver and releases its resources.
   virtual void RemoveView (const Handle(Graphic3d_CView)& theView) = 0;
 
-  //! enables/disables usage of OpenGL vertex buffer arrays while drawing primitiev arrays
+  //! enables/disables usage of OpenGL vertex buffer arrays while drawing primitive arrays
   virtual void EnableVBO (const Standard_Boolean status) = 0;
+
+  //! Returns TRUE if vertical synchronization with display refresh rate (VSync) should be used; TRUE by default.
+  virtual bool IsVerticalSync() const = 0;
+
+  //! Set if vertical synchronization with display refresh rate (VSync) should be used.
+  virtual void SetVerticalSync (bool theToEnable) = 0;
   
   //! Returns information about GPU memory usage.
   virtual Standard_Boolean MemoryInfo (Standard_Size& theFreeBytes, TCollection_AsciiString& theInfo) const = 0;
diff --git a/src/Graphic3d/Graphic3d_GraphicDriverFactory.cxx b/src/Graphic3d/Graphic3d_GraphicDriverFactory.cxx
new file mode 100644 (file)
index 0000000..5f75fba
--- /dev/null
@@ -0,0 +1,104 @@
+// Copyright (c) 2021 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 <Graphic3d_GraphicDriverFactory.hxx>
+
+#include <Graphic3d_GraphicDriver.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_GraphicDriverFactory, Standard_Transient)
+
+namespace
+{
+  static Graphic3d_GraphicDriverFactoryList& getDriverFactories()
+  {
+    static Graphic3d_GraphicDriverFactoryList TheFactories;
+    return TheFactories;
+  }
+}
+
+// =======================================================================
+// function : DriverFactories
+// purpose  :
+// =======================================================================
+const Graphic3d_GraphicDriverFactoryList& Graphic3d_GraphicDriverFactory::DriverFactories()
+{
+  return getDriverFactories();
+}
+
+// =======================================================================
+// function : RegisterFactory
+// purpose  :
+// =======================================================================
+void Graphic3d_GraphicDriverFactory::RegisterFactory (const Handle(Graphic3d_GraphicDriverFactory)& theFactory,
+                                                      bool theIsPreferred)
+{
+  const TCollection_AsciiString aName = theFactory->Name();
+  Graphic3d_GraphicDriverFactoryList& aFactories = getDriverFactories();
+  if (theIsPreferred)
+  {
+    UnregisterFactory (aName);
+    aFactories.Prepend (theFactory);
+    return;
+  }
+
+  for (Graphic3d_GraphicDriverFactoryList::Iterator anIter (aFactories); anIter.More(); anIter.Next())
+  {
+    if (TCollection_AsciiString::IsSameString (anIter.Value()->Name(), aName, false))
+    {
+      return;
+    }
+  }
+  aFactories.Append (theFactory);
+}
+
+// =======================================================================
+// function : UnregisterFactory
+// purpose  :
+// =======================================================================
+void Graphic3d_GraphicDriverFactory::UnregisterFactory (const TCollection_AsciiString& theName)
+{
+  Graphic3d_GraphicDriverFactoryList& aFactories = getDriverFactories();
+  for (Graphic3d_GraphicDriverFactoryList::Iterator anIter (aFactories); anIter.More();)
+  {
+    if (TCollection_AsciiString::IsSameString (anIter.Value()->Name(), theName, false))
+    {
+      aFactories.Remove (anIter);
+    }
+    else
+    {
+      anIter.Next();
+    }
+  }
+}
+
+// =======================================================================
+// function : DefaultDriverFactory
+// purpose  :
+// =======================================================================
+Handle(Graphic3d_GraphicDriverFactory) Graphic3d_GraphicDriverFactory::DefaultDriverFactory()
+{
+  const Graphic3d_GraphicDriverFactoryList& aMap = getDriverFactories();
+  return !aMap.IsEmpty()
+        ? aMap.First()
+        : Handle(Graphic3d_GraphicDriverFactory)();
+}
+
+// =======================================================================
+// function : Graphic3d_GraphicDriverFactory
+// purpose  :
+// =======================================================================
+Graphic3d_GraphicDriverFactory::Graphic3d_GraphicDriverFactory (const TCollection_AsciiString& theName)
+: myName (theName)
+{
+  //
+}
diff --git a/src/Graphic3d/Graphic3d_GraphicDriverFactory.hxx b/src/Graphic3d/Graphic3d_GraphicDriverFactory.hxx
new file mode 100644 (file)
index 0000000..a8a2343
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright (c) 2021 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 _Graphic3d_GraphicDriverFactory_HeaderFile
+#define _Graphic3d_GraphicDriverFactory_HeaderFile
+
+#include <NCollection_List.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_AsciiString.hxx>
+
+class Aspect_DisplayConnection;
+class Graphic3d_GraphicDriver;
+class Graphic3d_GraphicDriverFactory;
+typedef NCollection_List<Handle(Graphic3d_GraphicDriverFactory)> Graphic3d_GraphicDriverFactoryList;
+
+//! This class for creation of Graphic3d_GraphicDriver.
+class Graphic3d_GraphicDriverFactory : public Standard_Transient
+{
+  DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriverFactory, Standard_Transient)
+public:
+
+  //! Registers factory.
+  //! @param theFactory     [in] factory to register
+  //! @param theIsPreferred [in] add to the beginning of the list when TRUE, or add to the end otherwise
+  Standard_EXPORT static void RegisterFactory (const Handle(Graphic3d_GraphicDriverFactory)& theFactory,
+                                               bool theIsPreferred = false);
+
+  //! Unregisters factory.
+  Standard_EXPORT static void UnregisterFactory (const TCollection_AsciiString& theName);
+
+  //! Return default driver factory or NULL if no one was registered.
+  Standard_EXPORT static Handle(Graphic3d_GraphicDriverFactory) DefaultDriverFactory();
+
+  //! Return the global map of registered driver factories.
+  Standard_EXPORT static const Graphic3d_GraphicDriverFactoryList& DriverFactories();
+
+public:
+
+  //! Creates new empty graphic driver.
+  virtual Handle(Graphic3d_GraphicDriver) CreateDriver (const Handle(Aspect_DisplayConnection)& theDisp) = 0;
+
+  //! Return driver factory name.
+  const TCollection_AsciiString& Name() const { return myName; }
+
+protected:
+
+  //! Empty constructor.
+  Standard_EXPORT Graphic3d_GraphicDriverFactory (const TCollection_AsciiString& theName);
+
+protected:
+
+  TCollection_AsciiString myName;
+
+};
+
+#endif // _Graphic3d_GraphicDriverFactory_HeaderFile
index 90dfd7d..bfd7c72 100644 (file)
 ;# Liste des toolkits WOK sous forme de full path
 ;# 
 proc Draw:toolkits { } {
-    set aResult [list TKDraw TKTopTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw]
+  set aResult [list TKDraw TKTopTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw]
 
-    if { [info exists ::env(HAVE_VTK)] && $::env(HAVE_VTK) == "true" } {
-      lappend aResult "TKIVtkDraw"
+  lappend aResult "TKOpenGlTest"
+  if { "$::tcl_platform(platform)" == "windows" } {
+    if { [info exists ::env(HAVE_D3D)] } {
+      if { "$::env(HAVE_D3D)" == "true" } {
+        lappend aResult "TKD3DHostTest"
+      }
+    } elseif { [info exists ::env(VCVER)] && "$::env(VCVER)" != "vc8" && "$::env(VCVER)" != "vc9" && "$::env(VCVER)" != "vc10" } {
+      lappend aResult "TKD3DHostTest"
     }
+  }
+  if { [info exists ::env(HAVE_VTK)] && "$::env(HAVE_VTK)" == "true" } {
+    lappend aResult "TKIVtkDraw"
+  }
 
-    return $aResult
+  return $aResult
 }
 
 ;#
index 9b60999..05928f6 100644 (file)
 ;# Liste des toolkits WOK sous forme de full path
 ;# 
 proc Visualization:toolkits { } {
-    set aResult [list TKService \
-                     TKV3d \
-                     TKOpenGl \
-                     TKMeshVS]
+  set aResult [list TKService TKV3d TKMeshVS]
 
-    if { [info exists ::env(HAVE_VTK)] && "$::env(HAVE_VTK)" == "true" } {
-      lappend aResult "TKIVtk"
-    }
-
-    if { "$::tcl_platform(platform)" == "windows" } {
-      if { [info exists ::env(HAVE_D3D)] } {
-        if { "$::env(HAVE_D3D)" == "true" } {
-          lappend aResult "TKD3DHost"
-        }
-      } elseif { [info exists ::env(VCVER)] && "$::env(VCVER)" != "vc8" && "$::env(VCVER)" != "vc9" && "$::env(VCVER)" != "vc10" } {
+  lappend aResult "TKOpenGl"
+  if { "$::tcl_platform(platform)" == "windows" } {
+    if { [info exists ::env(HAVE_D3D)] } {
+      if { "$::env(HAVE_D3D)" == "true" } {
         lappend aResult "TKD3DHost"
       }
+    } elseif { [info exists ::env(VCVER)] && "$::env(VCVER)" != "vc8" && "$::env(VCVER)" != "vc9" && "$::env(VCVER)" != "vc10" } {
+      lappend aResult "TKD3DHost"
     }
+  }
+  if { [info exists ::env(HAVE_VTK)] && "$::env(HAVE_VTK)" == "true" } {
+    lappend aResult "TKIVtk"
+  }
 
-    return $aResult
+  return $aResult
 }
+
 ;#
 ;# Autres UDs a prendre.
 ;#
index 4717342..2ec64a1 100755 (executable)
@@ -108,6 +108,8 @@ OpenGl_LayerList.hxx
 OpenGl_LayerFilter.hxx
 OpenGl_GraphicDriver.cxx
 OpenGl_GraphicDriver.hxx
+OpenGl_GraphicDriverFactory.cxx
+OpenGl_GraphicDriverFactory.hxx
 OpenGl_IndexBuffer.cxx
 OpenGl_IndexBuffer.hxx
 OpenGl_Layer.hxx
index 3c1f511..f05d316 100644 (file)
@@ -548,6 +548,24 @@ void OpenGl_GraphicDriver::EnableVBO (const Standard_Boolean theToTurnOn)
   myCaps->vboDisable = !theToTurnOn;
 }
 
+// =======================================================================
+// function : IsVerticalSync
+// purpose  :
+// =======================================================================
+bool OpenGl_GraphicDriver::IsVerticalSync() const
+{
+  return myCaps->swapInterval == 1;
+}
+
+// =======================================================================
+// function : SetVerticalSync
+// purpose  :
+// =======================================================================
+void OpenGl_GraphicDriver::SetVerticalSync (bool theToEnable)
+{
+  myCaps->swapInterval = theToEnable ? 1 : 0;
+}
+
 // =======================================================================
 // function : GetSharedContext
 // purpose  :
index 1c91d0b..3e11dec 100644 (file)
@@ -153,7 +153,14 @@ public:
   //! VBO usage can be forbidden by this method even if it is supported by GL driver.
   //! Notice that disabling of VBO will cause rendering performance degradation.
   //! Warning! This method should be called only before any primitives are displayed in GL scene!
-  Standard_EXPORT void EnableVBO (const Standard_Boolean theToTurnOn) Standard_OVERRIDE;
+  Standard_EXPORT virtual void EnableVBO (const Standard_Boolean theToTurnOn) Standard_OVERRIDE;
+
+
+  //! Returns TRUE if vertical synchronization with display refresh rate (VSync) should be used; TRUE by default.
+  Standard_EXPORT virtual bool IsVerticalSync() const Standard_OVERRIDE;
+
+  //! Set if vertical synchronization with display refresh rate (VSync) should be used.
+  Standard_EXPORT virtual void SetVerticalSync (bool theToEnable) Standard_OVERRIDE;
 
   //! Returns information about GPU memory usage.
   //! Please read OpenGl_Context::MemoryInfo() for more description.
diff --git a/src/OpenGl/OpenGl_GraphicDriverFactory.cxx b/src/OpenGl/OpenGl_GraphicDriverFactory.cxx
new file mode 100644 (file)
index 0000000..cdc72c3
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (c) 2021 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 <OpenGl_GraphicDriverFactory.hxx>
+
+#include <OpenGl_GraphicDriver.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriverFactory, Graphic3d_GraphicDriverFactory)
+
+// =======================================================================
+// function : OpenGl_GraphicDriverFactory
+// purpose  :
+// =======================================================================
+OpenGl_GraphicDriverFactory::OpenGl_GraphicDriverFactory()
+: Graphic3d_GraphicDriverFactory ("TKOpenGl"),
+  myDefaultCaps (new OpenGl_Caps())
+{
+  //
+}
+
+// =======================================================================
+// function : CreateDriver
+// purpose  :
+// =======================================================================
+Handle(Graphic3d_GraphicDriver) OpenGl_GraphicDriverFactory::CreateDriver (const Handle(Aspect_DisplayConnection)& theDisp)
+{
+  Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver (theDisp, false);
+  aDriver->ChangeOptions() = *myDefaultCaps;
+  aDriver->InitContext();
+  return aDriver;
+}
diff --git a/src/OpenGl/OpenGl_GraphicDriverFactory.hxx b/src/OpenGl/OpenGl_GraphicDriverFactory.hxx
new file mode 100644 (file)
index 0000000..aede5bd
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (c) 2021 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 _OpenGl_GraphicDriverFactory_Header
+#define _OpenGl_GraphicDriverFactory_Header
+
+#include <Graphic3d_GraphicDriverFactory.hxx>
+#include <OpenGl_Caps.hxx>
+
+//! This class for creation of OpenGl_GraphicDriver.
+class OpenGl_GraphicDriverFactory : public Graphic3d_GraphicDriverFactory
+{
+  DEFINE_STANDARD_RTTIEXT(OpenGl_GraphicDriverFactory, Graphic3d_GraphicDriverFactory)
+public:
+
+  //! Empty constructor.
+  Standard_EXPORT OpenGl_GraphicDriverFactory();
+
+  //! Creates new empty graphic driver.
+  Standard_EXPORT virtual Handle(Graphic3d_GraphicDriver) CreateDriver (const Handle(Aspect_DisplayConnection)& theDisp) Standard_OVERRIDE;
+
+  //! Return default driver options.
+  const Handle(OpenGl_Caps)& DefaultOptions() const { return myDefaultCaps; }
+
+  //! Set default driver options.
+  void SetDefaultOptions (const Handle(OpenGl_Caps)& theOptions) { myDefaultCaps = theOptions; }
+
+protected:
+
+  Handle(OpenGl_Caps) myDefaultCaps;
+
+};
+
+#endif //_OpenGl_GraphicDriverFactory_Header
diff --git a/src/OpenGlTest/FILES b/src/OpenGlTest/FILES
new file mode 100644 (file)
index 0000000..267e9c4
--- /dev/null
@@ -0,0 +1,3 @@
+OpenGlTest.cxx
+OpenGlTest.hxx
+OpenGlTest_Commands.cxx
diff --git a/src/OpenGlTest/OpenGlTest.cxx b/src/OpenGlTest/OpenGlTest.cxx
new file mode 100644 (file)
index 0000000..4a3365d
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright (c) 2021 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 <OpenGlTest.hxx>
+
+#include <Draw_PluginMacro.hxx>
+#include <OpenGl_GraphicDriverFactory.hxx>
+
+// ======================================================================
+// function : Factory
+// purpose  :
+// ======================================================================
+void OpenGlTest::Factory (Draw_Interpretor& theDI)
+{
+  static const Handle(OpenGl_GraphicDriverFactory) aFactory = new OpenGl_GraphicDriverFactory();
+  Graphic3d_GraphicDriverFactory::RegisterFactory (aFactory);
+  OpenGlTest::Commands (theDI);
+#ifdef DEB
+  theDI << "Draw Plugin : OpenGL commands are loaded.\n";
+#endif
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(OpenGlTest)
diff --git a/src/OpenGlTest/OpenGlTest.hxx b/src/OpenGlTest/OpenGlTest.hxx
new file mode 100644 (file)
index 0000000..ec49b73
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (c) 2021 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 _OpenGlTest_HeaderFile
+#define _OpenGlTest_HeaderFile
+
+#include <Draw_Interpretor.hxx>
+
+//! This package defines a set of Draw commands for testing of TKOpenGl library.
+class OpenGlTest
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  //! Adds Draw commands to the draw interpretor.
+  Standard_EXPORT static void Commands (Draw_Interpretor& theDI);
+
+  //! Plugin entry point function.
+  Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
+};
+
+#endif // _OpenGlTest_HeaderFile
diff --git a/src/OpenGlTest/OpenGlTest_Commands.cxx b/src/OpenGlTest/OpenGlTest_Commands.cxx
new file mode 100644 (file)
index 0000000..7636ee6
--- /dev/null
@@ -0,0 +1,901 @@
+// Created on: 2012-04-09
+// Created by: Sergey ANIKIN
+// Copyright (c) 2012-2021 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 <OpenGlTest.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_ShaderObject.hxx>
+#include <Graphic3d_ShaderProgram.hxx>
+#include <Message.hxx>
+
+#include <OpenGl_Aspects.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_Element.hxx>
+#include <OpenGl_GlCore20.hxx>
+#include <OpenGl_GraphicDriver.hxx>
+#include <OpenGl_GraphicDriverFactory.hxx>
+#include <OpenGl_Group.hxx>
+#include <OpenGl_ShaderManager.hxx>
+#include <OpenGl_Workspace.hxx>
+
+#include <OSD_File.hxx>
+#include <OSD_OpenFile.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Select3D_SensitiveCurve.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
+
+#include <ViewerTest.hxx>
+#include <ViewerTest_AutoUpdater.hxx>
+
+static Handle(OpenGl_Caps) getDefaultCaps()
+{
+  Handle(OpenGl_GraphicDriverFactory) aFactory = Handle(OpenGl_GraphicDriverFactory)::DownCast (Graphic3d_GraphicDriverFactory::DefaultDriverFactory());
+  if (aFactory.IsNull())
+  {
+    for (Graphic3d_GraphicDriverFactoryList::Iterator aFactoryIter (Graphic3d_GraphicDriverFactory::DriverFactories());
+         aFactoryIter.More(); aFactoryIter.Next())
+    {
+      aFactory = Handle(OpenGl_GraphicDriverFactory)::DownCast (aFactoryIter.Value());
+      if (!aFactory.IsNull())
+      {
+        break;
+      }
+    }
+  }
+  if (aFactory.IsNull())
+  {
+    throw Standard_ProgramError ("Error: no OpenGl_GraphicDriverFactory registered");
+  }
+  return aFactory->DefaultOptions();
+}
+
+namespace
+{
+
+//=======================================================================
+//function : VUserDraw
+//purpose  : Checks availability and operation of UserDraw feature
+//=======================================================================
+class VUserDrawObj : public AIS_InteractiveObject
+{
+public:
+  // CASCADE RTTI
+  DEFINE_STANDARD_RTTI_INLINE(VUserDrawObj, AIS_InteractiveObject);
+
+  VUserDrawObj()
+  {
+    myCoords[0] = -10.;
+    myCoords[1] = -20.;
+    myCoords[2] = -30.;
+    myCoords[3] =  10.;
+    myCoords[4] =  20.;
+    myCoords[5] =  30.;
+  }
+
+public:
+  class Element : public OpenGl_Element
+  {
+  private:
+    Handle(VUserDrawObj) myIObj;
+
+  public:
+    Element (const Handle(VUserDrawObj)& theIObj) : myIObj (theIObj) {}
+
+    virtual ~Element() {}
+
+    virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
+    {
+      if (!myIObj.IsNull())
+        myIObj->Render(theWorkspace);
+    }
+
+    virtual void Release (OpenGl_Context*)
+    {
+      //
+    }
+
+  public:
+    DEFINE_STANDARD_ALLOC
+  };
+
+private:
+  // Virtual methods implementation
+  virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
+                        const Handle(Prs3d_Presentation)& thePrs,
+                        const Standard_Integer theMode) Standard_OVERRIDE;
+
+  virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                                 const Standard_Integer theMode) Standard_OVERRIDE;
+
+  // Called by VUserDrawElement
+  void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
+
+private:
+  GLfloat myCoords[6];
+  friend class Element;
+};
+
+void VUserDrawObj::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
+                           const Handle(Prs3d_Presentation)& thePrs,
+                           const Standard_Integer theMode)
+{
+  if (theMode != 0) { return; }
+  thePrs->Clear();
+
+  Graphic3d_Vec4 aBndMin (myCoords[0], myCoords[1], myCoords[2], 1.0f);
+  Graphic3d_Vec4 aBndMax (myCoords[3], myCoords[4], myCoords[5], 1.0f);
+  Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (thePrs->NewGroup());
+  aGroup->SetMinMaxValues (aBndMin.x(), aBndMin.y(), aBndMin.z(),
+                           aBndMax.x(), aBndMax.y(), aBndMax.z());
+  aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
+  VUserDrawObj::Element* anElem = new VUserDrawObj::Element (this);
+  aGroup->AddElement(anElem);
+
+  // invalidate bounding box of the scene
+  thePrsMgr->StructureManager()->Update();
+}
+
+void VUserDrawObj::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                                     const Standard_Integer theMode)
+{
+  if (theMode != 0) { return; }
+  Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
+  Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt(1, 5);
+  aPnts->SetValue(1, gp_Pnt(myCoords[0], myCoords[1], myCoords[2]));
+  aPnts->SetValue(2, gp_Pnt(myCoords[3], myCoords[4], myCoords[2]));
+  aPnts->SetValue(3, gp_Pnt(myCoords[3], myCoords[4], myCoords[5]));
+  aPnts->SetValue(4, gp_Pnt(myCoords[0], myCoords[1], myCoords[5]));
+  aPnts->SetValue(5, gp_Pnt(myCoords[0], myCoords[1], myCoords[2]));
+  Handle(Select3D_SensitiveCurve) aSensitive = new Select3D_SensitiveCurve(anEntityOwner, aPnts);
+  theSelection->Add(aSensitive);
+}
+
+void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
+{
+  const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
+
+  // To test linking against OpenGl_Workspace and all aspect classes
+  const OpenGl_Aspects* aMA = theWorkspace->Aspects();
+  aMA->Aspect()->MarkerType();
+  OpenGl_Vec4 aColor = theWorkspace->InteriorColor();
+
+  aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), Aspect_TOL_SOLID,
+                                          Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, false,
+                                          Handle(OpenGl_ShaderProgram)());
+  aCtx->SetColor4fv (aColor);
+
+  const OpenGl_Vec3 aVertArray[4] =
+  {
+    OpenGl_Vec3(myCoords[0], myCoords[1], myCoords[2]),
+    OpenGl_Vec3(myCoords[3], myCoords[4], myCoords[2]),
+    OpenGl_Vec3(myCoords[3], myCoords[4], myCoords[5]),
+    OpenGl_Vec3(myCoords[0], myCoords[1], myCoords[5]),
+  };
+  Handle(OpenGl_VertexBuffer) aVertBuffer = new OpenGl_VertexBuffer();
+  aVertBuffer->Init (aCtx, 3, 4, aVertArray[0].GetData());
+
+  // Finally draw something to make sure UserDraw really works
+  aVertBuffer->BindAttribute  (aCtx, Graphic3d_TOA_POS);
+  glDrawArrays(GL_LINE_LOOP, 0, aVertBuffer->GetElemsNb());
+  aVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS);
+  aVertBuffer->Release (aCtx.get());
+}
+
+} // end of anonymous namespace
+
+static Standard_Integer VUserDraw (Draw_Interpretor& ,
+                                   Standard_Integer argc,
+                                   const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    Message::SendFail ("Error: no active viewer");
+    return 1;
+  }
+
+  Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
+  if (aDriver.IsNull())
+  {
+    Message::SendFail ("Error: Graphic driver not available.");
+    return 1;
+  }
+
+  if (argc > 2)
+  {
+    Message::SendFail ("Syntax error: wrong number of arguments");
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+  ViewerTest::Display (aName, Handle(AIS_InteractiveObject)());
+
+  Handle(VUserDrawObj) anIObj = new VUserDrawObj();
+  ViewerTest::Display (aName, anIObj);
+
+  return 0;
+}
+
+//==============================================================================
+//function : VGlShaders
+//purpose  :
+//==============================================================================
+static Standard_Integer VGlShaders (Draw_Interpretor& theDI,
+                                    Standard_Integer  theArgNb,
+                                    const char**      theArgVec)
+{
+  Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+  if (aCtx.IsNull())
+  {
+    Message::SendFail ("Error: no active viewer");
+    return 1;
+  }
+
+  Handle(OpenGl_Context) aGlCtx;
+  if (Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aCtx->CurrentViewer()->Driver()))
+  {
+    aGlCtx = aDriver->GetSharedContext();
+  }
+  if (aGlCtx.IsNull())
+  {
+    Message::SendFail ("Error: no OpenGl_Context");
+    return 1;
+  }
+
+  bool toList = theArgNb < 2;
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+  {
+    TCollection_AsciiString anArg (theArgVec[anArgIter]);
+    anArg.LowerCase();
+    if (anArg == "-list")
+    {
+      toList = true;
+    }
+    else if ((anArg == "-update"
+           || anArg == "-dump"
+           || anArg == "-debug"
+           || anArg == "-reload"
+           || anArg == "-load")
+          && anArgIter + 1 < theArgNb)
+    {
+      TCollection_AsciiString aShaderName = theArgVec[++anArgIter];
+      Handle(OpenGl_ShaderProgram) aResProg;
+      if (!aGlCtx->GetResource (aShaderName, aResProg))
+      {
+        Message::SendFail() << "Syntax error: shader resource '" << aShaderName << "' is not found";
+        return 1;
+      }
+      if (aResProg->UpdateDebugDump (aGlCtx, "", false, anArg == "-dump"))
+      {
+        aCtx->UpdateCurrentViewer();
+      }
+      return 0;
+    }
+    else
+    {
+      Message::SendFail() << "Syntax error at '" << anArg << "'";
+      return 1;
+    }
+  }
+  if (toList)
+  {
+    for (OpenGl_Context::OpenGl_ResourcesMap::Iterator aResIter (aGlCtx->SharedResources()); aResIter.More(); aResIter.Next())
+    {
+      if (Handle(OpenGl_ShaderProgram) aResProg = Handle(OpenGl_ShaderProgram)::DownCast (aResIter.Value()))
+      {
+        theDI << aResProg->ResourceId() << " ";
+      }
+    }
+  }
+
+  return 0;
+}
+
+//! Auxiliary function for parsing glsl dump level argument.
+static Standard_Boolean parseGlslSourceFlag (Standard_CString               theArg,
+                                             OpenGl_ShaderProgramDumpLevel& theGlslDumpLevel)
+{
+  TCollection_AsciiString aTypeStr (theArg);
+  aTypeStr.LowerCase();
+  if (aTypeStr == "off"
+   || aTypeStr == "0")
+  {
+    theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
+  }
+  else if (aTypeStr == "short")
+  {
+    theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Short;
+  }
+  else if (aTypeStr == "full"
+        || aTypeStr == "1")
+  {
+    theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
+  }
+  else
+  {
+    return Standard_False;
+  }
+  return Standard_True;
+}
+
+//==============================================================================
+//function : VGlDebug
+//purpose  :
+//==============================================================================
+static int VGlDebug (Draw_Interpretor& theDI,
+                     Standard_Integer  theArgNb,
+                     const char**      theArgVec)
+{
+  Handle(OpenGl_GraphicDriver) aDriver;
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
+  if (!aView.IsNull())
+  {
+    aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
+  }
+  OpenGl_Caps* aDefCaps = getDefaultCaps().get();
+  OpenGl_Caps* aCaps    = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
+
+  if (theArgNb < 2)
+  {
+    TCollection_AsciiString aDebActive, aSyncActive;
+    if (aCaps == NULL)
+    {
+      aCaps = aDefCaps;
+    }
+    else
+    {
+      Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS),
+                                                                  "GL_ARB_debug_output");
+      aDebActive = isActive ? " (active)" : " (inactive)";
+      if (isActive)
+      {
+        // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
+        aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
+      }
+    }
+
+    TCollection_AsciiString aGlslCodeDebugStatus = TCollection_AsciiString()
+      + "glslSourceCode: "
+      + (aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Off
+         ? "Off"
+         : aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Short
+          ? "Short"
+          : "Full")
+      + "\n";
+    theDI << "debug:          " << (aCaps->contextDebug      ? "1" : "0") << aDebActive  << "\n"
+          << "sync:           " << (aCaps->contextSyncDebug  ? "1" : "0") << aSyncActive << "\n"
+          << "glslWarn:       " << (aCaps->glslWarnings      ? "1" : "0") << "\n"
+          << aGlslCodeDebugStatus
+          << "extraMsg:       " << (aCaps->suppressExtraMsg  ? "0" : "1") << "\n";
+    return 0;
+  }
+
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+  {
+    Standard_CString        anArg     = theArgVec[anArgIter];
+    TCollection_AsciiString anArgCase (anArg);
+    anArgCase.LowerCase();
+    Standard_Boolean toEnableDebug = Standard_True;
+    if (anArgCase == "-glsl"
+     || anArgCase == "-glslwarn"
+     || anArgCase == "-glslwarns"
+     || anArgCase == "-glslwarnings")
+    {
+      Standard_Boolean toShowWarns = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toShowWarns))
+      {
+        --anArgIter;
+      }
+      aDefCaps->glslWarnings = toShowWarns;
+      if (aCaps != NULL)
+      {
+        aCaps->glslWarnings = toShowWarns;
+      }
+    }
+    else if (anArgCase == "-extra"
+          || anArgCase == "-extramsg"
+          || anArgCase == "-extramessages")
+    {
+      Standard_Boolean toShow = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toShow))
+      {
+        --anArgIter;
+      }
+      aDefCaps->suppressExtraMsg = !toShow;
+      if (aCaps != NULL)
+      {
+        aCaps->suppressExtraMsg = !toShow;
+      }
+    }
+    else if (anArgCase == "-noextra"
+          || anArgCase == "-noextramsg"
+          || anArgCase == "-noextramessages")
+    {
+      Standard_Boolean toSuppress = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toSuppress))
+      {
+        --anArgIter;
+      }
+      aDefCaps->suppressExtraMsg = toSuppress;
+      if (aCaps != NULL)
+      {
+        aCaps->suppressExtraMsg = toSuppress;
+      }
+    }
+    else if (anArgCase == "-sync")
+    {
+      Standard_Boolean toSync = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toSync))
+      {
+        --anArgIter;
+      }
+      aDefCaps->contextSyncDebug = toSync;
+      if (toSync)
+      {
+        aDefCaps->contextDebug = Standard_True;
+      }
+    }
+    else if (anArgCase == "-glslsourcecode"
+          || anArgCase == "-glslcode")
+    {
+      OpenGl_ShaderProgramDumpLevel aGslsDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
+      if (++anArgIter < theArgNb
+      && !parseGlslSourceFlag (theArgVec[anArgIter], aGslsDumpLevel))
+      {
+        --anArgIter;
+      }
+      aDefCaps->glslDumpLevel = aGslsDumpLevel;
+      if (aCaps != NULL)
+      {
+        aCaps->glslDumpLevel = aGslsDumpLevel;
+      }
+    }
+    else if (anArgCase == "-debug")
+    {
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
+      {
+        --anArgIter;
+      }
+      aDefCaps->contextDebug = toEnableDebug;
+    }
+    else if (Draw::ParseOnOff (anArg, toEnableDebug)
+          && (anArgIter + 1 == theArgNb))
+    {
+      // simple alias to turn on almost everything
+      aDefCaps->contextDebug     = toEnableDebug;
+      aDefCaps->contextSyncDebug = toEnableDebug;
+      aDefCaps->glslWarnings     = toEnableDebug;
+      if (!toEnableDebug)
+      {
+        aDefCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
+      }
+      aDefCaps->suppressExtraMsg = !toEnableDebug;
+      if (aCaps != NULL)
+      {
+        aCaps->contextDebug     = toEnableDebug;
+        aCaps->contextSyncDebug = toEnableDebug;
+        aCaps->glslWarnings     = toEnableDebug;
+        if (!toEnableDebug)
+        {
+          aCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
+        }
+        aCaps->suppressExtraMsg = !toEnableDebug;
+      }
+    }
+    else
+    {
+      Message::SendFail() << "Syntax error at '" << anArg << "'";
+      return 1;
+    }
+  }
+
+  return 0;
+}
+
+//==============================================================================
+//function : VVbo
+//purpose  :
+//==============================================================================
+static int VVbo (Draw_Interpretor& theDI,
+                 Standard_Integer  theArgNb,
+                 const char**      theArgVec)
+{
+  const Standard_Boolean toSet    = (theArgNb > 1);
+  const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1;
+  if (toSet)
+  {
+    getDefaultCaps()->vboDisable = toUseVbo;
+  }
+
+  // get the context
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    if (!toSet)
+    {
+      Message::SendFail ("Error: no active viewer");
+    }
+    return 1;
+  }
+  Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
+  if (!aDriver.IsNull())
+  {
+    if (!toSet)
+    {
+      theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n";
+    }
+    else
+    {
+      aDriver->ChangeOptions().vboDisable = toUseVbo;
+    }
+  }
+
+  return 0;
+}
+
+//==============================================================================
+//function : VCaps
+//purpose  :
+//==============================================================================
+static int VCaps (Draw_Interpretor& theDI,
+                  Standard_Integer  theArgNb,
+                  const char**      theArgVec)
+{
+  OpenGl_Caps* aCaps = getDefaultCaps().get();
+  Handle(OpenGl_GraphicDriver)   aDriver;
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (!aContext.IsNull())
+  {
+    aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
+    aCaps   = &aDriver->ChangeOptions();
+  }
+
+  if (theArgNb < 2)
+  {
+    theDI << "sRGB:    " << (aCaps->sRGBDisable       ? "0" : "1") << "\n";
+    theDI << "VBO:     " << (aCaps->vboDisable        ? "0" : "1") << "\n";
+    theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
+    theDI << "SoftMode:" << (aCaps->contextNoAccel    ? "1" : "0") << "\n";
+    theDI << "FFP:     " << (aCaps->ffpEnable         ? "1" : "0") << "\n";
+    theDI << "PolygonMode: " << (aCaps->usePolygonMode ? "1" : "0") << "\n";
+    theDI << "DepthZeroToOne: " << (aCaps->useZeroToOneDepth ? "1" : "0") << "\n";
+    theDI << "VSync:   " <<  aCaps->swapInterval                   << "\n";
+    theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
+    theDI << "Stereo:  " << (aCaps->contextStereo ? "1" : "0") << "\n";
+    theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
+    theDI << "OpaqueAlpha: " << (aCaps->buffersOpaqueAlpha ? "1" : "0") << "\n";
+    theDI << "NoExt:"    << (aCaps->contextNoExtensions ? "1" : "0") << "\n";
+    theDI << "MaxVersion:" << aCaps->contextMajorVersionUpper << "." << aCaps->contextMinorVersionUpper << "\n";
+    theDI << "CompressTextures: " << (aCaps->compressedTexturesDisable ? "0" : "1") << "\n";
+    return 0;
+  }
+
+  ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+  {
+    Standard_CString        anArg     = theArgVec[anArgIter];
+    TCollection_AsciiString anArgCase (anArg);
+    anArgCase.LowerCase();
+    if (anUpdateTool.parseRedrawMode (anArg))
+    {
+      continue;
+    }
+    else if (anArgCase == "-vsync"
+          || anArgCase == "-swapinterval")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->swapInterval = toEnable;
+    }
+    else if (anArgCase == "-ffp")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->ffpEnable = toEnable;
+    }
+    else if (anArgCase == "-polygonmode")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->usePolygonMode = toEnable;
+    }
+    else if (anArgCase == "-srgb")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->sRGBDisable = !toEnable;
+    }
+    else if (anArgCase == "-compressedtextures")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->compressedTexturesDisable = !toEnable;
+    }
+    else if (anArgCase == "-vbo")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->vboDisable = !toEnable;
+    }
+    else if (anArgCase == "-sprite"
+          || anArgCase == "-sprites")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->pntSpritesDisable = !toEnable;
+    }
+    else if (anArgCase == "-depthzerotoone"
+          || anArgCase == "-zerotoonedepth"
+          || anArgCase == "-usezerotoonedepth"
+          || anArgCase == "-iszerotoonedepth")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->useZeroToOneDepth = toEnable;
+    }
+    else if (anArgCase == "-softmode")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->contextNoAccel = toEnable;
+    }
+    else if (anArgCase == "-opaquealpha"
+          || anArgCase == "-buffersOpaqueAlpha")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->buffersOpaqueAlpha = toEnable;
+    }
+    else if (anArgCase == "-winbuffer"
+          || anArgCase == "-windowbuffer"
+          || anArgCase == "-usewinbuffer"
+          || anArgCase == "-usewindowbuffer"
+          || anArgCase == "-usesystembuffer")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->useSystemBuffer = toEnable;
+    }
+    else if (anArgCase == "-accel"
+          || anArgCase == "-acceleration")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->contextNoAccel = !toEnable;
+    }
+    else if (anArgCase == "-compat"
+          || anArgCase == "-compatprofile"
+          || anArgCase == "-compatible"
+          || anArgCase == "-compatibleprofile")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->contextCompatible = toEnable;
+      if (!aCaps->contextCompatible)
+      {
+        aCaps->ffpEnable = Standard_False;
+      }
+    }
+    else if (anArgCase == "-core"
+          || anArgCase == "-coreprofile")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->contextCompatible = !toEnable;
+      if (!aCaps->contextCompatible)
+      {
+        aCaps->ffpEnable = Standard_False;
+      }
+    }
+    else if (anArgCase == "-stereo"
+          || anArgCase == "-quadbuffer")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->contextStereo = toEnable;
+    }
+    else if (anArgCase == "-noext"
+          || anArgCase == "-noextensions"
+          || anArgCase == "-noextension")
+    {
+      Standard_Boolean toDisable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !Draw::ParseOnOff (theArgVec[anArgIter], toDisable))
+      {
+        --anArgIter;
+      }
+      aCaps->contextNoExtensions = toDisable;
+    }
+    else if (anArgCase == "-maxversion"
+          || anArgCase == "-upperversion"
+          || anArgCase == "-limitversion")
+    {
+      Standard_Integer aVer[2] = { -2, -1 };
+      for (Standard_Integer aValIter = 0; aValIter < 2; ++aValIter)
+      {
+        if (anArgIter + 1 < theArgNb)
+        {
+          const TCollection_AsciiString aStr (theArgVec[anArgIter + 1]);
+          if (aStr.IsIntegerValue())
+          {
+            aVer[aValIter] = aStr.IntegerValue();
+            ++anArgIter;
+          }
+        }
+      }
+      if (aVer[0] < -1
+       || aVer[1] < -1)
+      {
+        Message::SendFail() << "Syntax error at '" << anArgCase << "'";
+        return 1;
+      }
+      aCaps->contextMajorVersionUpper = aVer[0];
+      aCaps->contextMinorVersionUpper = aVer[1];
+    }
+    else
+    {
+      Message::SendFail() << "Error: unknown argument '" << anArg << "'";
+      return 1;
+    }
+  }
+  if (aCaps != getDefaultCaps().get())
+  {
+    *getDefaultCaps() = *aCaps;
+  }
+  return 0;
+}
+
+//=======================================================================
+//function : Commands
+//purpose  :
+//=======================================================================
+void OpenGlTest::Commands (Draw_Interpretor& theCommands)
+{
+  const char* aGroup ="Commands for low-level TKOpenGl features";
+
+  theCommands.Add("vuserdraw",
+    "vuserdraw : name - simulates drawing with help of UserDraw",
+    __FILE__, VUserDraw, aGroup);
+  theCommands.Add("vglshaders",
+                  "vglshaders [-list] [-dump] [-reload] ShaderId"
+                  "\n\t\t:  -list   prints the list of registered GLSL programs"
+                  "\n\t\t:  -dump   dumps specified GLSL program (for debugging)"
+                  "\n\t\t:  -reload restores dump of specified GLSL program",
+    __FILE__, VGlShaders, aGroup);
+  theCommands.Add ("vcaps",
+            "vcaps [-sRGB {0|1}] [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
+    "\n\t\t:       [-compatibleProfile {0|1}] [-compressedTextures {0|1}]"
+    "\n\t\t:       [-vsync {0|1}] [-useWinBuffer {0|1}] [-opaqueAlpha {0|1}]"
+    "\n\t\t:       [-quadBuffer {0|1}] [-stereo {0|1}]"
+    "\n\t\t:       [-softMode {0|1}] [-noupdate|-update]"
+    "\n\t\t:       [-zeroToOneDepth {0|1}]"
+    "\n\t\t:       [-noExtensions {0|1}] [-maxVersion Major Minor]"
+    "\n\t\t: Modify particular graphic driver options:"
+    "\n\t\t:  sRGB     - enable/disable sRGB rendering"
+    "\n\t\t:  FFP      - use fixed-function pipeline instead of"
+    "\n\t\t:             built-in GLSL programs"
+    "\n\t\t:            (requires compatible profile)"
+    "\n\t\t:  polygonMode - use Polygon Mode instead of built-in GLSL programs"
+    "\n\t\t:  compressedTexture - allow uploading of GPU-supported compressed texture formats"
+    "\n\t\t:  VBO      - use Vertex Buffer Object (copy vertex"
+    "\n\t\t:             arrays to GPU memory)"
+    "\n\t\t:  sprite   - use textured sprites instead of bitmaps"
+    "\n\t\t:  vsync    - switch VSync on or off"
+    "\n\t\t:  opaqueAlpha - disable writes in alpha component of color buffer"
+    "\n\t\t:  winBuffer - allow using window buffer for rendering"
+    "\n\t\t:  zeroToOneDepth - use [0,1] depth range instead of [-1,1] range"
+    "\n\t\t: Context creation options:"
+    "\n\t\t:  softMode          - software OpenGL implementation"
+    "\n\t\t:  compatibleProfile - backward-compatible profile"
+    "\n\t\t:  quadbuffer        - QuadBuffer"
+    "\n\t\t:  noExtensions      - disallow usage of extensions"
+    "\n\t\t:  maxVersion        - force upper OpenGL version to be used"
+    "\n\t\t: These parameters control alternative"
+    "\n\t\t: rendering paths producing the same visual result when possible.",
+    __FILE__, VCaps, aGroup);
+  theCommands.Add ("vgldebug",
+            "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
+    "\n\t\t:          [-glslCode {off|short|full}] [-extraMsg {0|1}] [{0|1}]"
+    "\n\t\t: Request debug GL context. Should be called BEFORE vinit."
+    "\n\t\t: Debug context can be requested only on Windows"
+    "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!"
+    "\n\t\t:  -sync     - request synchronized debug GL context"
+    "\n\t\t:  -glslWarn - log GLSL compiler/linker warnings,"
+    "\n\t\t:              which are suppressed by default,"
+    "\n\t\t:  -glslCode - log GLSL program source code,"
+    "\n\t\t:              which are suppressed by default,"
+    "\n\t\t:  -extraMsg - log extra diagnostic messages from GL context,"
+    "\n\t\t:              which are suppressed by default",
+    __FILE__, VGlDebug, aGroup);
+  theCommands.Add ("vvbo",
+    "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
+    __FILE__, VVbo, aGroup);
+}
diff --git a/src/TKD3DHostTest/CMakeLists.txt b/src/TKD3DHostTest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5c3ad22
--- /dev/null
@@ -0,0 +1,3 @@
+project(TKD3DHostTest)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
diff --git a/src/TKD3DHostTest/EXTERNLIB b/src/TKD3DHostTest/EXTERNLIB
new file mode 100644 (file)
index 0000000..ba25691
--- /dev/null
@@ -0,0 +1,5 @@
+TKernel
+TKMath
+TKDraw
+TKD3DHost
+TKService
diff --git a/src/TKD3DHostTest/FILES b/src/TKD3DHostTest/FILES
new file mode 100644 (file)
index 0000000..ca4f0e5
--- /dev/null
@@ -0,0 +1,2 @@
+EXTERNLIB
+PACKAGES
diff --git a/src/TKD3DHostTest/PACKAGES b/src/TKD3DHostTest/PACKAGES
new file mode 100644 (file)
index 0000000..9cb5cc1
--- /dev/null
@@ -0,0 +1 @@
+D3DHostTest
diff --git a/src/TKOpenGlTest/CMakeLists.txt b/src/TKOpenGlTest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..31703f7
--- /dev/null
@@ -0,0 +1,3 @@
+project(TKOpenGlTest)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
diff --git a/src/TKOpenGlTest/EXTERNLIB b/src/TKOpenGlTest/EXTERNLIB
new file mode 100644 (file)
index 0000000..9781d81
--- /dev/null
@@ -0,0 +1,8 @@
+TKernel
+TKMath
+TKDraw
+TKOpenGl
+TKService
+TKV3d
+TKViewerTest
+CSF_OpenGlLibs
diff --git a/src/TKOpenGlTest/FILES b/src/TKOpenGlTest/FILES
new file mode 100644 (file)
index 0000000..ca4f0e5
--- /dev/null
@@ -0,0 +1,2 @@
+EXTERNLIB
+PACKAGES
diff --git a/src/TKOpenGlTest/PACKAGES b/src/TKOpenGlTest/PACKAGES
new file mode 100644 (file)
index 0000000..4df696d
--- /dev/null
@@ -0,0 +1 @@
+OpenGlTest
index 9181318..69ed86e 100755 (executable)
@@ -17,13 +17,11 @@ TKOffset
 TKMesh
 TKV3d
 TKDraw
-TKOpenGl
 CSF_TclLibs
 CSF_TclTkLibs
 CSF_XwLibs
 CSF_user32
 CSF_gdi32
-CSF_OpenGlLibs
 CSF_objc
 CSF_Appkit
 CSF_IOKit
index d8aff82..3273204 100644 (file)
 #include <ViewerTest.hxx>
 
 #include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
 #include <Draw.hxx>
 #include <Draw_Interpretor.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_ShaderObject.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
 #include <Image_AlienPixMap.hxx>
-#include <OpenGl_Aspects.hxx>
-#include <OpenGl_Context.hxx>
-#include <OpenGl_Element.hxx>
-#include <OpenGl_GlCore20.hxx>
-#include <OpenGl_GraphicDriver.hxx>
-#include <OpenGl_ShaderManager.hxx>
-#include <OpenGl_Workspace.hxx>
-#include <OSD_Environment.hxx>
+#include <Message.hxx>
 #include <OSD_File.hxx>
 #include <OSD_OpenFile.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <TCollection_AsciiString.hxx>
 #include <V3d_View.hxx>
 #include <V3d_Viewer.hxx>
-#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
+
 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
-#include <OpenGl_Group.hxx>
-#include <OSD_OpenFile.hxx>
 
-extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
-                                           const Handle(AIS_InteractiveObject)& theAISObj,
-                                           Standard_Boolean theReplaceIfExists = Standard_True);
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 
-namespace
-{
-
-//=======================================================================
-//function : VUserDraw
-//purpose  : Checks availability and operation of UserDraw feature
-//=======================================================================
-class VUserDrawObj : public AIS_InteractiveObject
-{
-public:
-  // CASCADE RTTI
-  DEFINE_STANDARD_RTTI_INLINE(VUserDrawObj, AIS_InteractiveObject);
-
-  VUserDrawObj()
-  {
-    myCoords[0] = -10.;
-    myCoords[1] = -20.;
-    myCoords[2] = -30.;
-    myCoords[3] =  10.;
-    myCoords[4] =  20.;
-    myCoords[5] =  30.;
-  }
-
-public:
-  class Element : public OpenGl_Element
-  {
-  private:
-    Handle(VUserDrawObj) myIObj;
-
-  public:
-    Element (const Handle(VUserDrawObj)& theIObj) : myIObj (theIObj) {}
-
-    virtual ~Element() {}
-
-    virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
-    {
-      if (!myIObj.IsNull())
-        myIObj->Render(theWorkspace);
-    }
-
-    virtual void Release (OpenGl_Context*)
-    {
-      //
-    }
-
-  public:
-    DEFINE_STANDARD_ALLOC
-  };
-
-private:
-  // Virtual methods implementation
-  virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
-                        const Handle(Prs3d_Presentation)& thePrs,
-                        const Standard_Integer theMode) Standard_OVERRIDE;
-
-  virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
-                                 const Standard_Integer theMode) Standard_OVERRIDE;
-
-  // Called by VUserDrawElement
-  void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
-
-private:
-  GLfloat myCoords[6];
-  friend class Element;
-};
-
-void VUserDrawObj::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
-                           const Handle(Prs3d_Presentation)& thePrs,
-                           const Standard_Integer /*theMode*/)
-{
-  thePrs->Clear();
-
-  Graphic3d_Vec4 aBndMin (myCoords[0], myCoords[1], myCoords[2], 1.0f);
-  Graphic3d_Vec4 aBndMax (myCoords[3], myCoords[4], myCoords[5], 1.0f);
-  Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (thePrs->NewGroup());
-  aGroup->SetMinMaxValues (aBndMin.x(), aBndMin.y(), aBndMin.z(),
-                           aBndMax.x(), aBndMax.y(), aBndMax.z());
-  aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
-  VUserDrawObj::Element* anElem = new VUserDrawObj::Element (this);
-  aGroup->AddElement(anElem);
-
-  // invalidate bounding box of the scene
-  thePrsMgr->StructureManager()->Update();
-}
-
-void VUserDrawObj::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
-                                     const Standard_Integer /*theMode*/)
-{
-  Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
-  Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt(1, 5);
-  aPnts->SetValue(1, gp_Pnt(myCoords[0], myCoords[1], myCoords[2]));
-  aPnts->SetValue(2, gp_Pnt(myCoords[3], myCoords[4], myCoords[2]));
-  aPnts->SetValue(3, gp_Pnt(myCoords[3], myCoords[4], myCoords[5]));
-  aPnts->SetValue(4, gp_Pnt(myCoords[0], myCoords[1], myCoords[5]));
-  aPnts->SetValue(5, gp_Pnt(myCoords[0], myCoords[1], myCoords[2]));
-  Handle(Select3D_SensitiveCurve) aSensitive = new Select3D_SensitiveCurve(anEntityOwner, aPnts);
-  theSelection->Add(aSensitive);
-}
-
-void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
-{
-  const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
-
-  // To test linking against OpenGl_Workspace and all aspect classes
-  const OpenGl_Aspects* aMA = theWorkspace->Aspects();
-  aMA->Aspect()->MarkerType();
-  OpenGl_Vec4 aColor = theWorkspace->InteriorColor();
-
-  aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), Aspect_TOL_SOLID,
-                                          Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, false,
-                                          Handle(OpenGl_ShaderProgram)());
-  aCtx->SetColor4fv (aColor);
-
-  const OpenGl_Vec3 aVertArray[4] =
-  {
-    OpenGl_Vec3(myCoords[0], myCoords[1], myCoords[2]),
-    OpenGl_Vec3(myCoords[3], myCoords[4], myCoords[2]),
-    OpenGl_Vec3(myCoords[3], myCoords[4], myCoords[5]),
-    OpenGl_Vec3(myCoords[0], myCoords[1], myCoords[5]),
-  };
-  Handle(OpenGl_VertexBuffer) aVertBuffer = new OpenGl_VertexBuffer();
-  aVertBuffer->Init (aCtx, 3, 4, aVertArray[0].GetData());
-
-  // Finally draw something to make sure UserDraw really works
-  aVertBuffer->BindAttribute  (aCtx, Graphic3d_TOA_POS);
-  glDrawArrays(GL_LINE_LOOP, 0, aVertBuffer->GetElemsNb());
-  aVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS);
-  aVertBuffer->Release (aCtx.get());
-}
-
-} // end of anonymous namespace
-
-static Standard_Integer VUserDraw (Draw_Interpretor& ,
-                                    Standard_Integer argc,
-                                    const char ** argv)
-{
-  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
-  if (aContext.IsNull())
-  {
-    Message::SendFail ("Error: no active viewer");
-    return 1;
-  }
-
-  Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
-  if (aDriver.IsNull())
-  {
-    Message::SendFail ("Error: Graphic driver not available.");
-    return 1;
-  }
-
-  if (argc > 2)
-  {
-    Message::SendFail ("Syntax error: wrong number of arguments");
-    return 1;
-  }
-
-  TCollection_AsciiString aName (argv[1]);
-  VDisplayAISObject(aName, Handle(AIS_InteractiveObject)());
-
-  Handle(VUserDrawObj) anIObj = new VUserDrawObj();
-  VDisplayAISObject(aName, anIObj);
-
-  return 0;
-}
-
 //==============================================================================
 //function : VImmediateFront
 //purpose  :
 //==============================================================================
 
-static int VImmediateFront (Draw_Interpretor& /*theDI*/,
+static int VImmediateFront (Draw_Interpretor& ,
                             Standard_Integer  theArgNb,
                             const char**      theArgVec)
 {
@@ -419,6 +230,7 @@ static int VGlInfo (Draw_Interpretor& theDI,
   return 0;
 }
 
+
 //! Parse shader type argument.
 static bool parseShaderTypeArg (Graphic3d_TypeOfShaderObject& theType,
                                 const TCollection_AsciiString& theArg)
@@ -468,7 +280,7 @@ static bool parseShaderTypeArg (Graphic3d_TypeOfShaderObject& theType,
 //function : VShaderProg
 //purpose  : Sets the pair of vertex and fragment shaders for the object
 //==============================================================================
-static Standard_Integer VShaderProg (Draw_Interpretor& theDI,
+static Standard_Integer VShaderProg (Draw_Interpretor& ,
                                      Standard_Integer  theArgNb,
                                      const char**      theArgVec)
 {
@@ -501,56 +313,6 @@ static Standard_Integer VShaderProg (Draw_Interpretor& theDI,
       TCollection_AsciiString aName = theArgVec[++anArgIter];
       aProgram->PushVariableFloat (aName, float (Draw::Atof (theArgVec[++anArgIter])));
     }
-    else if (anArg == "-list"
-          || ((anArg == "-update"
-            || anArg == "-dump"
-            || anArg == "-debug"
-            || anArg == "-reload"
-            || anArg == "-load")
-           && anArgIter + 1 < theArgNb))
-    {
-      Handle(OpenGl_Context) aGlCtx;
-      if (Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aCtx->CurrentViewer()->Driver()))
-      {
-        aGlCtx = aDriver->GetSharedContext();
-      }
-      if (aGlCtx.IsNull())
-      {
-        Message::SendFail ("Error: no OpenGl_Context");
-        return 1;
-      }
-
-      if (anArg == "-list")
-      {
-        for (OpenGl_Context::OpenGl_ResourcesMap::Iterator aResIter (aGlCtx->SharedResources()); aResIter.More(); aResIter.Next())
-        {
-          if (Handle(OpenGl_ShaderProgram) aResProg = Handle(OpenGl_ShaderProgram)::DownCast (aResIter.Value()))
-          {
-            theDI << aResProg->ResourceId() << " ";
-          }
-        }
-      }
-      else
-      {
-        TCollection_AsciiString aShaderName = theArgVec[++anArgIter];
-        Handle(OpenGl_ShaderProgram) aResProg;
-        if (!aGlCtx->GetResource (aShaderName, aResProg))
-        {
-          Message::SendFail() << "Syntax error: shader resource '" << aShaderName << "' is not found";
-          return 1;
-        }
-        if (aResProg->UpdateDebugDump (aGlCtx, "", false, anArg == "-dump"))
-        {
-          aCtx->UpdateCurrentViewer();
-        }
-      }
-      if (anArgIter + 1 < theArgNb)
-      {
-        Message::SendFail ("Syntax error: wrong number of arguments");
-        return 1;
-      }
-      return 0;
-    }
     else if (!aProgram.IsNull()
           &&  aProgram->ShaderObjects().IsEmpty()
           && (anArg == "-off"
@@ -1401,9 +1163,6 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
 {
   const char* aGroup ="Commands for low-level TKOpenGl features";
 
-  theCommands.Add("vuserdraw",
-    "vuserdraw : name - simulates drawing with help of UserDraw",
-    __FILE__, VUserDraw, aGroup);
   theCommands.Add("vimmediatefront",
     "vimmediatefront : render immediate mode to front buffer or to back buffer",
     __FILE__, VImmediateFront, aGroup);
@@ -1421,11 +1180,7 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
                   "\n\t\t:   [-header VersionHeader]"
                   "\n\t\t:   [-tessControl TessControlShader -tesseval TessEvaluationShader]"
                   "\n\t\t:   [-uniform Name FloatValue]"
-                  "\n\t\t: Assign custom GLSL program to presentation aspects."
-                  "\nvshader [-list] [-dump] [-reload] ShaderId"
-                  "\n\t\t:  -list   prints the list of registered GLSL programs"
-                  "\n\t\t:  -dump   dumps specified GLSL program (for debugging)"
-                  "\n\t\t:  -reload restores dump of specified GLSL program",
+                  "\n\t\t: Assign custom GLSL program to presentation aspects.",
     __FILE__, VShaderProg, aGroup);
   theCommands.Add("vshaderprog", "Alias for vshader", __FILE__, VShaderProg, aGroup);
   theCommands.Add("vlistmaterials",
index 033ab1e..f206d00 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <OpenGl_GlCore20.hxx>
+#if defined(_WIN32)
+  #include <windows.h>
+#endif
+
 #include <ViewerTest.hxx>
 
 #include <AIS_AnimationCamera.hxx>
@@ -45,6 +48,8 @@
 #include <Graphic3d_CubeMapPacked.hxx>
 #include <Graphic3d_CubeMapSeparate.hxx>
 #include <Graphic3d_GraduatedTrihedron.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
+#include <Graphic3d_GraphicDriverFactory.hxx>
 #include <Graphic3d_NameOfTextureEnv.hxx>
 #include <Graphic3d_Texture2Dmanual.hxx>
 #include <Graphic3d_TextureEnv.hxx>
@@ -53,6 +58,7 @@
 #include <Image_AlienPixMap.hxx>
 #include <Image_Diff.hxx>
 #include <Image_VideoRecorder.hxx>
+#include <Message.hxx>
 #include <Message_ProgressScope.hxx>
 #include <Message_ProgressRange.hxx>
 #include <NCollection_DataMap.hxx>
@@ -62,7 +68,6 @@
 #include <OSD.hxx>
 #include <OSD_Parallel.hxx>
 #include <OSD_Timer.hxx>
-#include <OpenGl_GraphicDriver.hxx>
 #include <Prs3d_ShadingAspect.hxx>
 #include <Prs3d_DatumAspect.hxx>
 #include <Prs3d_Drawer.hxx>
@@ -151,7 +156,6 @@ static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDis
 NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews;
 static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>  ViewerTest_myContexts;
 static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers;
-static OpenGl_Caps ViewerTest_myDefaultCaps;
 
 static void OSWindowSetup();
 
@@ -1677,7 +1681,18 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
     theViewToClone->Window()->Size (aPxWidth, aPxHeight);
   }
 
-  Handle(OpenGl_GraphicDriver) aGraphicDriver;
+  Handle(Graphic3d_GraphicDriverFactory) aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory();
+  if (aFactory.IsNull())
+  {
+    Draw::GetInterpretor().Eval ("pload OPENGL");
+    aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory();
+    if (aFactory.IsNull())
+    {
+      throw Standard_ProgramError("Error: no graphic driver factory found");
+    }
+  }
+
+  Handle(Graphic3d_GraphicDriver) aGraphicDriver;
   ViewerTest_Names aViewNames(theViewName);
   if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName ()))
     aViewNames.SetViewName (aViewNames.GetViewerName() + "/" + CreateName<Handle(V3d_View)>(ViewerTest_myViews, "View"));
@@ -1717,23 +1732,19 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
     SetDisplayConnection (new Aspect_DisplayConnection ());
   #endif
 
+    aGraphicDriver = aFactory->CreateDriver (GetDisplayConnection());
     if (isVirtual)
     {
       // don't waste the time waiting for VSync when window is not displayed on the screen
-      ViewerTest_myDefaultCaps.swapInterval = 0;
-      // alternatively we can disable buffer swap at all, but this might be inappropriate for testing
-      //ViewerTest_myDefaultCaps.buffersNoSwap = true;
+      aGraphicDriver->SetVerticalSync (false);
     }
-    aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection(), false);
-    aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
-    aGraphicDriver->InitContext();
 
     ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
     toCreateViewer = Standard_True;
   }
   else
   {
-    aGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast (ViewerTest_myDrivers.Find1 (aViewNames.GetDriverName()));
+    aGraphicDriver = ViewerTest_myDrivers.Find1 (aViewNames.GetDriverName());
   }
 
   //Dispose the window if input parameters are default
@@ -1919,6 +1930,143 @@ void ViewerTest::RedrawAllViews()
   }
 }
 
+//==============================================================================
+//function : VDriver
+//purpose  :
+//==============================================================================
+static int VDriver (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+{
+  if (theArgsNb == 1)
+  {
+    theDi << "Registered: ";
+    for (Graphic3d_GraphicDriverFactoryList::Iterator aFactoryIter (Graphic3d_GraphicDriverFactory::DriverFactories());
+         aFactoryIter.More(); aFactoryIter.Next())
+    {
+      const Handle(Graphic3d_GraphicDriverFactory)& aFactory = aFactoryIter.Value();
+      theDi << aFactory->Name() << " ";
+    }
+
+    theDi << "\n";
+    theDi << "Default: ";
+    if (Handle(Graphic3d_GraphicDriverFactory) aFactory =  Graphic3d_GraphicDriverFactory::DefaultDriverFactory())
+    {
+      theDi << aFactory->Name();
+    }
+    else
+    {
+      theDi << "NONE";
+    }
+    return 0;
+  }
+
+  TCollection_AsciiString aNewActive;
+  bool toLoad = false;
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
+  {
+    TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+    anArgCase.LowerCase();
+    if (anArgCase == "-list")
+    {
+      for (Graphic3d_GraphicDriverFactoryList::Iterator aFactoryIter (Graphic3d_GraphicDriverFactory::DriverFactories());
+           aFactoryIter.More(); aFactoryIter.Next())
+      {
+        const Handle(Graphic3d_GraphicDriverFactory)& aFactory = aFactoryIter.Value();
+        theDi << aFactory->Name() << " ";
+      }
+    }
+    else if ((anArgCase == "-default"
+           || anArgCase == "-load")
+          && aNewActive.IsEmpty())
+    {
+      toLoad = (anArgCase == "-load");
+      if (anArgIter + 1 < theArgsNb)
+      {
+        aNewActive = theArgVec[++anArgIter];
+      }
+      else if (toLoad)
+      {
+        theDi << "Syntax error at '" << theArgVec[anArgIter] << "'";
+        return 1;
+      }
+      else
+      {
+        if (Handle(Graphic3d_GraphicDriverFactory) aFactory =  Graphic3d_GraphicDriverFactory::DefaultDriverFactory())
+        {
+          theDi << aFactory->Name();
+        }
+        else
+        {
+          theDi << "NONE";
+        }
+      }
+    }
+    else if (aNewActive.IsEmpty())
+    {
+      aNewActive = theArgVec[anArgIter];
+    }
+    else
+    {
+      theDi << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
+      return 1;
+    }
+  }
+
+  if (!aNewActive.IsEmpty())
+  {
+    const TCollection_AsciiString aNameCopy = aNewActive;
+    if (TCollection_AsciiString::IsSameString (aNewActive, "gl", false)
+     || TCollection_AsciiString::IsSameString (aNewActive, "opengl", false)
+     || TCollection_AsciiString::IsSameString (aNewActive, "tkopengl", false))
+    {
+      aNewActive = "tkopengl";
+    }
+    else if (TCollection_AsciiString::IsSameString (aNewActive, "d3d", false)
+          || TCollection_AsciiString::IsSameString (aNewActive, "d3dhost", false)
+          || TCollection_AsciiString::IsSameString (aNewActive, "tkd3dhost", false))
+    {
+      aNewActive = "tkd3dhost";
+    }
+
+    if (toLoad)
+    {
+      if (aNewActive == "tkopengl")
+      {
+        Draw::GetInterpretor().Eval ("pload OPENGL");
+      }
+      else if (aNewActive == "tkd3dhost")
+      {
+        Draw::GetInterpretor().Eval ("pload D3DHOST");
+      }
+      else
+      {
+        theDi << "Syntax error: unable to load plugin for unknown driver factory '" << aNameCopy << "'";
+        return 1;
+      }
+    }
+
+    bool isFound = false;
+    for (Graphic3d_GraphicDriverFactoryList::Iterator aFactoryIter (Graphic3d_GraphicDriverFactory::DriverFactories());
+         aFactoryIter.More(); aFactoryIter.Next())
+    {
+      Handle(Graphic3d_GraphicDriverFactory) aFactory = aFactoryIter.Value();
+      if (TCollection_AsciiString::IsSameString (aFactory->Name(), aNewActive, false))
+      {
+        Graphic3d_GraphicDriverFactory::RegisterFactory (aFactory, true);
+        isFound = true;
+        break;
+      }
+    }
+
+    if (!isFound)
+    {
+      theDi << "Syntax error: driver factory '" << aNameCopy << "' not found";
+      return 1;
+    }
+  }
+
+  return 0;
+}
+
 //==============================================================================
 //function : Vinit
 //purpose  : Create the window viewer and initialize all the global variable
@@ -6486,527 +6634,6 @@ static int VFps (Draw_Interpretor& theDI,
   return 0;
 }
 
-//! Auxiliary function for parsing glsl dump level argument.
-static Standard_Boolean parseGlslSourceFlag (Standard_CString               theArg,
-                                             OpenGl_ShaderProgramDumpLevel& theGlslDumpLevel)
-{
-  TCollection_AsciiString aTypeStr (theArg);
-  aTypeStr.LowerCase();
-  if (aTypeStr == "off"
-   || aTypeStr == "0")
-  {
-    theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
-  }
-  else if (aTypeStr == "short")
-  {
-    theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Short;
-  }
-  else if (aTypeStr == "full"
-        || aTypeStr == "1")
-  {
-    theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
-  }
-  else
-  {
-    return Standard_False;
-  }
-  return Standard_True;
-}
-
-//==============================================================================
-//function : VGlDebug
-//purpose  :
-//==============================================================================
-
-static int VGlDebug (Draw_Interpretor& theDI,
-                     Standard_Integer  theArgNb,
-                     const char**      theArgVec)
-{
-  Handle(OpenGl_GraphicDriver) aDriver;
-  Handle(V3d_View) aView = ViewerTest::CurrentView();
-  if (!aView.IsNull())
-  {
-    aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
-  }
-  OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps;
-  OpenGl_Caps* aCaps    = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
-
-  if (theArgNb < 2)
-  {
-    TCollection_AsciiString aDebActive, aSyncActive;
-    if (aCaps == NULL)
-    {
-      aCaps = aDefCaps;
-    }
-    else
-    {
-      Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS),
-                                                                  "GL_ARB_debug_output");
-      aDebActive = isActive ? " (active)" : " (inactive)";
-      if (isActive)
-      {
-        // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
-        aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
-      }
-    }
-
-    TCollection_AsciiString aGlslCodeDebugStatus = TCollection_AsciiString()
-      + "glslSourceCode: "
-      + (aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Off
-         ? "Off"
-         : aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Short
-          ? "Short"
-          : "Full")
-      + "\n";
-    theDI << "debug:          " << (aCaps->contextDebug      ? "1" : "0") << aDebActive  << "\n"
-          << "sync:           " << (aCaps->contextSyncDebug  ? "1" : "0") << aSyncActive << "\n"
-          << "glslWarn:       " << (aCaps->glslWarnings      ? "1" : "0") << "\n"
-          << aGlslCodeDebugStatus
-          << "extraMsg:       " << (aCaps->suppressExtraMsg  ? "0" : "1") << "\n";
-    return 0;
-  }
-
-  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
-  {
-    Standard_CString        anArg     = theArgVec[anArgIter];
-    TCollection_AsciiString anArgCase (anArg);
-    anArgCase.LowerCase();
-    Standard_Boolean toEnableDebug = Standard_True;
-    if (anArgCase == "-glsl"
-     || anArgCase == "-glslwarn"
-     || anArgCase == "-glslwarns"
-     || anArgCase == "-glslwarnings")
-    {
-      Standard_Boolean toShowWarns = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toShowWarns))
-      {
-        --anArgIter;
-      }
-      aDefCaps->glslWarnings = toShowWarns;
-      if (aCaps != NULL)
-      {
-        aCaps->glslWarnings = toShowWarns;
-      }
-    }
-    else if (anArgCase == "-extra"
-          || anArgCase == "-extramsg"
-          || anArgCase == "-extramessages")
-    {
-      Standard_Boolean toShow = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toShow))
-      {
-        --anArgIter;
-      }
-      aDefCaps->suppressExtraMsg = !toShow;
-      if (aCaps != NULL)
-      {
-        aCaps->suppressExtraMsg = !toShow;
-      }
-    }
-    else if (anArgCase == "-noextra"
-          || anArgCase == "-noextramsg"
-          || anArgCase == "-noextramessages")
-    {
-      Standard_Boolean toSuppress = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toSuppress))
-      {
-        --anArgIter;
-      }
-      aDefCaps->suppressExtraMsg = toSuppress;
-      if (aCaps != NULL)
-      {
-        aCaps->suppressExtraMsg = toSuppress;
-      }
-    }
-    else if (anArgCase == "-sync")
-    {
-      Standard_Boolean toSync = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toSync))
-      {
-        --anArgIter;
-      }
-      aDefCaps->contextSyncDebug = toSync;
-      if (toSync)
-      {
-        aDefCaps->contextDebug = Standard_True;
-      }
-    }
-    else if (anArgCase == "-glslsourcecode"
-          || anArgCase == "-glslcode")
-    {
-      OpenGl_ShaderProgramDumpLevel aGslsDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
-      if (++anArgIter < theArgNb
-      && !parseGlslSourceFlag (theArgVec[anArgIter], aGslsDumpLevel))
-      {
-        --anArgIter;
-      }
-      aDefCaps->glslDumpLevel = aGslsDumpLevel;
-      if (aCaps != NULL)
-      {
-        aCaps->glslDumpLevel = aGslsDumpLevel;
-      }
-    }
-    else if (anArgCase == "-debug")
-    {
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
-      {
-        --anArgIter;
-      }
-      aDefCaps->contextDebug = toEnableDebug;
-    }
-    else if (Draw::ParseOnOff (anArg, toEnableDebug)
-          && (anArgIter + 1 == theArgNb))
-    {
-      // simple alias to turn on almost everything
-      aDefCaps->contextDebug     = toEnableDebug;
-      aDefCaps->contextSyncDebug = toEnableDebug;
-      aDefCaps->glslWarnings     = toEnableDebug;
-      if (!toEnableDebug)
-      {
-        aDefCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
-      }
-      aDefCaps->suppressExtraMsg = !toEnableDebug;
-      if (aCaps != NULL)
-      {
-        aCaps->contextDebug     = toEnableDebug;
-        aCaps->contextSyncDebug = toEnableDebug;
-        aCaps->glslWarnings     = toEnableDebug;
-        if (!toEnableDebug)
-        {
-          aCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
-        }
-        aCaps->suppressExtraMsg = !toEnableDebug;
-      }
-    }
-    else
-    {
-      Message::SendFail() << "Syntax error at '" << anArg << "'";
-      return 1;
-    }
-  }
-
-  return 0;
-}
-
-//==============================================================================
-//function : VVbo
-//purpose  :
-//==============================================================================
-
-static int VVbo (Draw_Interpretor& theDI,
-                 Standard_Integer  theArgNb,
-                 const char**      theArgVec)
-{
-  const Standard_Boolean toSet    = (theArgNb > 1);
-  const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1;
-  if (toSet)
-  {
-    ViewerTest_myDefaultCaps.vboDisable = toUseVbo;
-  }
-
-  // get the context
-  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
-  if (aContextAIS.IsNull())
-  {
-    if (!toSet)
-    {
-      Message::SendFail ("Error: no active viewer");
-    }
-    return 1;
-  }
-  Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
-  if (!aDriver.IsNull())
-  {
-    if (!toSet)
-    {
-      theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n";
-    }
-    else
-    {
-      aDriver->ChangeOptions().vboDisable = toUseVbo;
-    }
-  }
-
-  return 0;
-}
-
-//==============================================================================
-//function : VCaps
-//purpose  :
-//==============================================================================
-
-static int VCaps (Draw_Interpretor& theDI,
-                  Standard_Integer  theArgNb,
-                  const char**      theArgVec)
-{
-  OpenGl_Caps* aCaps = &ViewerTest_myDefaultCaps;
-  Handle(OpenGl_GraphicDriver)   aDriver;
-  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
-  if (!aContext.IsNull())
-  {
-    aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
-    aCaps   = &aDriver->ChangeOptions();
-  }
-
-  if (theArgNb < 2)
-  {
-    theDI << "sRGB:    " << (aCaps->sRGBDisable       ? "0" : "1") << "\n";
-    theDI << "VBO:     " << (aCaps->vboDisable        ? "0" : "1") << "\n";
-    theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
-    theDI << "SoftMode:" << (aCaps->contextNoAccel    ? "1" : "0") << "\n";
-    theDI << "FFP:     " << (aCaps->ffpEnable         ? "1" : "0") << "\n";
-    theDI << "PolygonMode: " << (aCaps->usePolygonMode ? "1" : "0") << "\n";
-    theDI << "DepthZeroToOne: " << (aCaps->useZeroToOneDepth ? "1" : "0") << "\n";
-    theDI << "VSync:   " <<  aCaps->swapInterval                   << "\n";
-    theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
-    theDI << "Stereo:  " << (aCaps->contextStereo ? "1" : "0") << "\n";
-    theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
-    theDI << "OpaqueAlpha: " << (aCaps->buffersOpaqueAlpha ? "1" : "0") << "\n";
-    theDI << "NoExt:"    << (aCaps->contextNoExtensions ? "1" : "0") << "\n";
-    theDI << "MaxVersion:" << aCaps->contextMajorVersionUpper << "." << aCaps->contextMinorVersionUpper << "\n";
-    theDI << "CompressTextures: " << (aCaps->compressedTexturesDisable ? "0" : "1") << "\n";
-    return 0;
-  }
-
-  ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
-  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
-  {
-    Standard_CString        anArg     = theArgVec[anArgIter];
-    TCollection_AsciiString anArgCase (anArg);
-    anArgCase.LowerCase();
-    if (anUpdateTool.parseRedrawMode (anArg))
-    {
-      continue;
-    }
-    else if (anArgCase == "-vsync"
-          || anArgCase == "-swapinterval")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->swapInterval = toEnable;
-    }
-    else if (anArgCase == "-ffp")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->ffpEnable = toEnable;
-    }
-    else if (anArgCase == "-polygonmode")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->usePolygonMode = toEnable;
-    }
-    else if (anArgCase == "-srgb")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->sRGBDisable = !toEnable;
-    }
-    else if (anArgCase == "-compressedtextures")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->compressedTexturesDisable = !toEnable;
-    }
-    else if (anArgCase == "-vbo")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->vboDisable = !toEnable;
-    }
-    else if (anArgCase == "-sprite"
-          || anArgCase == "-sprites")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->pntSpritesDisable = !toEnable;
-    }
-    else if (anArgCase == "-depthzerotoone"
-          || anArgCase == "-zerotoonedepth"
-          || anArgCase == "-usezerotoonedepth"
-          || anArgCase == "-iszerotoonedepth")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->useZeroToOneDepth = toEnable;
-    }
-    else if (anArgCase == "-softmode")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->contextNoAccel = toEnable;
-    }
-    else if (anArgCase == "-opaquealpha"
-          || anArgCase == "-buffersOpaqueAlpha")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->buffersOpaqueAlpha = toEnable;
-    }
-    else if (anArgCase == "-winbuffer"
-          || anArgCase == "-windowbuffer"
-          || anArgCase == "-usewinbuffer"
-          || anArgCase == "-usewindowbuffer"
-          || anArgCase == "-usesystembuffer")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->useSystemBuffer = toEnable;
-    }
-    else if (anArgCase == "-accel"
-          || anArgCase == "-acceleration")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->contextNoAccel = !toEnable;
-    }
-    else if (anArgCase == "-compat"
-          || anArgCase == "-compatprofile"
-          || anArgCase == "-compatible"
-          || anArgCase == "-compatibleprofile")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->contextCompatible = toEnable;
-      if (!aCaps->contextCompatible)
-      {
-        aCaps->ffpEnable = Standard_False;
-      }
-    }
-    else if (anArgCase == "-core"
-          || anArgCase == "-coreprofile")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->contextCompatible = !toEnable;
-      if (!aCaps->contextCompatible)
-      {
-        aCaps->ffpEnable = Standard_False;
-      }
-    }
-    else if (anArgCase == "-stereo"
-          || anArgCase == "-quadbuffer")
-    {
-      Standard_Boolean toEnable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
-      {
-        --anArgIter;
-      }
-      aCaps->contextStereo = toEnable;
-    }
-    else if (anArgCase == "-noext"
-          || anArgCase == "-noextensions"
-          || anArgCase == "-noextension")
-    {
-      Standard_Boolean toDisable = Standard_True;
-      if (++anArgIter < theArgNb
-      && !Draw::ParseOnOff (theArgVec[anArgIter], toDisable))
-      {
-        --anArgIter;
-      }
-      aCaps->contextNoExtensions = toDisable;
-    }
-    else if (anArgCase == "-maxversion"
-          || anArgCase == "-upperversion"
-          || anArgCase == "-limitversion")
-    {
-      Standard_Integer aVer[2] = { -2, -1 };
-      for (Standard_Integer aValIter = 0; aValIter < 2; ++aValIter)
-      {
-        if (anArgIter + 1 < theArgNb)
-        {
-          const TCollection_AsciiString aStr (theArgVec[anArgIter + 1]);
-          if (aStr.IsIntegerValue())
-          {
-            aVer[aValIter] = aStr.IntegerValue();
-            ++anArgIter;
-          }
-        }
-      }
-      if (aVer[0] < -1
-       || aVer[1] < -1)
-      {
-        Message::SendFail() << "Syntax error at '" << anArgCase << "'";
-        return 1;
-      }
-      aCaps->contextMajorVersionUpper = aVer[0];
-      aCaps->contextMinorVersionUpper = aVer[1];
-    }
-    else
-    {
-      Message::SendFail() << "Error: unknown argument '" << anArg << "'";
-      return 1;
-    }
-  }
-  if (aCaps != &ViewerTest_myDefaultCaps)
-  {
-    ViewerTest_myDefaultCaps = *aCaps;
-  }
-  return 0;
-}
 
 //==============================================================================
 //function : VMemGpu
@@ -10403,15 +10030,17 @@ static int VStereo (Draw_Interpretor& theDI,
                     const char**      theArgVec)
 {
   Handle(V3d_View) aView = ViewerTest::CurrentView();
-  if (theArgNb < 2)
+  if (aView.IsNull())
   {
-    if (aView.IsNull())
-    {
-      Message::SendFail ("Error: no active viewer");
-      return 0;
-    }
+    Message::SendFail ("Error: no active viewer");
+    return 0;
+  }
 
-    Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo;
+  Handle(Graphic3d_Camera) aCamera = aView->Camera();
+  Graphic3d_RenderingParams* aParams = &aView->ChangeRenderingParams();
+  if (theArgNb < 2)
+  {
+    Standard_Boolean isActive = aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo;
     theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n";
     if (isActive)
     {
@@ -10444,16 +10073,7 @@ static int VStereo (Draw_Interpretor& theDI,
     return 0;
   }
 
-  Handle(Graphic3d_Camera) aCamera;
-  Graphic3d_RenderingParams*   aParams   = NULL;
-  Graphic3d_StereoMode         aMode     = Graphic3d_StereoMode_QuadBuffer;
-  if (!aView.IsNull())
-  {
-    aParams   = &aView->ChangeRenderingParams();
-    aMode     = aParams->StereoMode;
-    aCamera   = aView->Camera();
-  }
-
+  Graphic3d_StereoMode aMode = aParams->StereoMode;
   ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
   for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
   {
@@ -10473,12 +10093,10 @@ static int VStereo (Draw_Interpretor& theDI,
         return 1;
       }
 
-      if (!aCamera.IsNull()
-       &&  aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
+      if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
       {
         aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
       }
-      ViewerTest_myDefaultCaps.contextStereo = Standard_False;
       return 0;
     }
     else if (aFlag == "1"
@@ -10490,11 +10108,7 @@ static int VStereo (Draw_Interpretor& theDI,
         return 1;
       }
 
-      if (!aCamera.IsNull())
-      {
-        aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
-      }
-      ViewerTest_myDefaultCaps.contextStereo = Standard_True;
+      aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
       if (aParams->StereoMode != Graphic3d_StereoMode_OpenVR)
       {
         return 0;
@@ -10535,7 +10149,7 @@ static int VStereo (Draw_Interpretor& theDI,
 
       if (aMode == Graphic3d_StereoMode_QuadBuffer)
       {
-        ViewerTest_myDefaultCaps.contextStereo = Standard_True;
+        Message::SendInfo() << "Warning: make sure to call 'vcaps -stereo 1' before creating a view";
       }
     }
     else if (aFlag == "-anaglyph"
@@ -10556,7 +10170,7 @@ static int VStereo (Draw_Interpretor& theDI,
     {
       if (aMode == Graphic3d_StereoMode_QuadBuffer)
       {
-        ViewerTest_myDefaultCaps.contextStereo = Standard_True;
+        Message::SendInfo() << "Warning: make sure to call 'vcaps -stereo 1' before creating a view";
       }
     }
     else if (anArgIter + 1 < theArgNb
@@ -10594,15 +10208,12 @@ static int VStereo (Draw_Interpretor& theDI,
     }
   }
 
-  if (!aView.IsNull())
+  aParams->StereoMode = aMode;
+  aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
+  if (aParams->StereoMode == Graphic3d_StereoMode_OpenVR)
   {
-    aParams->StereoMode = aMode;
-    aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
-    if (aParams->StereoMode == Graphic3d_StereoMode_OpenVR)
-    {
-      // initiate implicit continuous rendering
-      ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
-    }
+    // initiate implicit continuous rendering
+    ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
   }
   return 0;
 }
@@ -14732,6 +14343,15 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
   Tcl_CreateExitHandler (ViewerTest_ExitProc, 0);
 
   const char *group = "ZeViewer";
+  theCommands.Add("vdriver",
+          "vdriver [-list] [-default DriverName] [-load DriverName]"
+    "\n\t\t: Manages active graphic driver factory."
+    "\n\t\t: Prints current active driver when called without arguments."
+    "\n\t\t: Makes specified driver active when ActiveName argument is specified."
+    "\n\t\t:  -list    print registered factories"
+    "\n\t\t:  -default define which factory should be used by default (to be used by next vinit call)"
+    "\n\t\t:  -load    try loading factory plugin and set it as default one",
+                  __FILE__, VDriver, group);
   theCommands.Add("vinit",
           "vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]"
     "\n\t\t:     [-exitOnClose] [-closeOnEscape] [-cloneActive] [-virtual {on|off}=off] [-2d_mode {on|off}=off]"
@@ -15070,23 +14690,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
   theCommands.Add ("vfps",
     "vfps [framesNb=100] [-duration seconds] : estimate average frame rate for active view",
     __FILE__, VFps, group);
-  theCommands.Add ("vgldebug",
-            "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
-    "\n\t\t:          [-glslCode {off|short|full}] [-extraMsg {0|1}] [{0|1}]"
-    "\n\t\t: Request debug GL context. Should be called BEFORE vinit."
-    "\n\t\t: Debug context can be requested only on Windows"
-    "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!"
-    "\n\t\t:  -sync     - request synchronized debug GL context"
-    "\n\t\t:  -glslWarn - log GLSL compiler/linker warnings,"
-    "\n\t\t:              which are suppressed by default,"
-    "\n\t\t:  -glslCode - log GLSL program source code,"
-    "\n\t\t:              which are suppressed by default,"
-    "\n\t\t:  -extraMsg - log extra diagnostic messages from GL context,"
-    "\n\t\t:              which are suppressed by default",
-    __FILE__, VGlDebug, group);
-  theCommands.Add ("vvbo",
-    "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
-    __FILE__, VVbo, group);
   theCommands.Add ("vstereo",
             "vstereo [0|1] [-mode Mode] [-reverse {0|1}]"
     "\n\t\t:         [-mirrorComposer] [-hmdfov2d AngleDegrees] [-unitFactor MetersFactor]"
@@ -15109,39 +14712,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n\t\t:  redCyan, redCyanSimple, yellowBlue, yellowBlueSimple,"
     "\n\t\t:  greenMagentaSimple",
     __FILE__, VStereo, group);
-  theCommands.Add ("vcaps",
-            "vcaps [-sRGB {0|1}] [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
-    "\n\t\t:       [-compatibleProfile {0|1}] [-compressedTextures {0|1}]"
-    "\n\t\t:       [-vsync {0|1}] [-useWinBuffer {0|1}] [-opaqueAlpha {0|1}]"
-    "\n\t\t:       [-quadBuffer {0|1}] [-stereo {0|1}]"
-    "\n\t\t:       [-softMode {0|1}] [-noupdate|-update]"
-    "\n\t\t:       [-zeroToOneDepth {0|1}]"
-    "\n\t\t:       [-noExtensions {0|1}] [-maxVersion Major Minor]"
-    "\n\t\t: Modify particular graphic driver options:"
-    "\n\t\t:  sRGB     - enable/disable sRGB rendering"
-    "\n\t\t:  FFP      - use fixed-function pipeline instead of"
-    "\n\t\t:             built-in GLSL programs"
-    "\n\t\t:            (requires compatible profile)"
-    "\n\t\t:  polygonMode - use Polygon Mode instead of built-in GLSL programs"
-    "\n\t\t:  compressedTexture - allow uploading of GPU-supported compressed texture formats"
-    "\n\t\t:  VBO      - use Vertex Buffer Object (copy vertex"
-    "\n\t\t:             arrays to GPU memory)"
-    "\n\t\t:  sprite   - use textured sprites instead of bitmaps"
-    "\n\t\t:  vsync    - switch VSync on or off"
-    "\n\t\t:  opaqueAlpha - disable writes in alpha component of color buffer"
-    "\n\t\t:  winBuffer - allow using window buffer for rendering"
-    "\n\t\t:  zeroToOneDepth - use [0,1] depth range instead of [-1,1] range"
-    "\n\t\t: Context creation options:"
-    "\n\t\t:  softMode          - software OpenGL implementation"
-    "\n\t\t:  compatibleProfile - backward-compatible profile"
-    "\n\t\t:  quadbuffer        - QuadBuffer"
-    "\n\t\t:  noExtensions      - disallow usage of extensions"
-    "\n\t\t:  maxVersion        - force upper OpenGL version to be used"
-    "\n\t\t: Unlike vrenderparams, these parameters control alternative"
-    "\n\t\t: rendering paths producing the same visual result when"
-    "\n\t\t: possible."
-    "\n\t\t: Command is intended for testing old hardware compatibility.",
-    __FILE__, VCaps, group);
   theCommands.Add ("vmemgpu",
     "vmemgpu [f]: print system-dependent GPU memory information if available;"
     " with f option returns free memory in bytes",
index fde964c..fd1ba96 100755 (executable)
@@ -1,18 +1,12 @@
 cpulimit 1000
 
-if { [array get Draw_Groups "Primitive building commands"] == "" } {
-    pload TOPTEST
-}
-
-if { [array get Draw_Groups "ZeViewer"] == "" } {
-    pload AISV
-}
+pload TOPTEST VISUALIZATION
 
 if { [info exists imagedir] == 0 } {
-    set imagedir .
+  set imagedir .
 }
-if { [info exists test_image ] == 0 } {
  set test_image photo
+if { [info exists test_image] == 0 } {
+ set test_image photo
 }
 
 vinit View1
index a2e8811..3d6d039 100755 (executable)
@@ -1,12 +1,3 @@
-pload XDE
-pload AISV
+pload XDE VISUALIZATION
 
 set subgroup iges
-
-
-
-
-
-
-
-
index 9452117..e386eae 100755 (executable)
@@ -2,13 +2,13 @@ puts "========"
 puts "OCC172"
 puts "========"
 
-pload XDE
+pload XDE VISUALIZATION
 
-# disable VBO to avoid false memory leaks reported
-# on NVidia graphics, see issue #29996
+# disable VBO to avoid false memory leaks reported on NVIDIA graphics, see issue #29996
+pload OPENGL
 vcaps -vbo 0
 
-vinit
+vinit View1
 restore [locate_data_file OCC162.brep] s 
 vdisplay s
 
index 51aaf67..ccf1f30 100644 (file)
@@ -3,6 +3,7 @@ puts "OCC23654 Markers recompute"
 puts "========"
 
 pload VISUALIZATION
+pload OPENGL
 vcaps -sprites
 source $env(CSF_OCCTSamplesPath)/tcl/markers.tcl
 
index 4a817b8..c29fcff 100644 (file)
@@ -4,10 +4,13 @@ puts "Checking environment mapping in general"
 puts "============"
 puts ""
 
+pload MODELING VISUALIZATION
+
 # enable FFP until bug-fix for GLSL
+pload OPENGL
 vcaps -ffp 1
 
-vinit
+vinit View1
 vclear
 vaxo
 psphere b 20
index 1c5d7a1..7519ed1 100644 (file)
@@ -3,6 +3,7 @@ puts "OCC24131 Markers using deprecated glBitmap"
 puts "========"
 
 pload VISUALIZATION
+pload OPENGL
 vcaps -sprites 0 -ffp 1
 source $env(CSF_OCCTSamplesPath)/tcl/markers.tcl
 vdump $imagedir/${casename}.png
index c2c603d..f80a905 100644 (file)
@@ -3,6 +3,7 @@ puts "OCC24131 Markers using GLSL programs in Core Profile"
 puts "========"
 
 pload VISUALIZATION
+pload OPENGL
 vcaps -core
 source $env(CSF_OCCTSamplesPath)/tcl/markers.tcl
 vdump $imagedir/${casename}.png
index 6a4e33b..fe2d3c2 100644 (file)
@@ -3,6 +3,7 @@ puts "OCC24131 Markers using GLSL programs in Compatible Profile"
 puts "========"
 
 pload VISUALIZATION
+pload OPENGL
 vcaps -compatibleProfile -sprites 1 -ffp 0
 source $env(CSF_OCCTSamplesPath)/tcl/markers.tcl
 vdump $imagedir/${casename}.png
index 0dff22b..150af2b 100644 (file)
@@ -3,6 +3,7 @@ puts "OCC24131 Markers using Point Sprites and FFP"
 puts "========"
 
 pload VISUALIZATION
+pload OPENGL
 vcaps -sprites 1 -ffp 1
 source $env(CSF_OCCTSamplesPath)/tcl/markers.tcl
 vdump $imagedir/${casename}.png
index 1e7a6a4..d1121a8 100644 (file)
@@ -1,12 +1,10 @@
 puts "============"
-puts "CR24728"
+puts "CR24728: Test image dumping with software accelerated GL context"
 puts "============"
 puts ""
 
-############################################################
-#  Test image dumping with software accelerated GL context
-############################################################
-
+pload MODELING VISUALIZATION
+pload OPENGL
 vcaps -softMode 1 -ffp 1
 vinit View1
 
index 80f66c0..df49d66 100644 (file)
@@ -8,6 +8,7 @@ puts ""
 #######################################################################
 
 pload MODELING VISUALIZATION
+pload OPENGL
 psphere s 0.5
 tclean  s
 incmesh s 0.001
index 7c81318..120c897 100644 (file)
@@ -8,9 +8,6 @@ puts "Displaying \'zbufftrihedron\' interferes with \'vgraduatedtrihedron\'"
 
 set anImage $imagedir/${casename}.png
 
-# enable FFP until bug-fix for GLSL
-vcaps -ffp 1
-
 vinit View1
 psphere s 10
 vdisplay s
@@ -21,6 +18,3 @@ vgraduatedtrihedron -on
 vzbufftrihedron
 
 vdump $anImage
-vclear
-vclose View1 
-
index ab90447..ceb6a95 100644 (file)
@@ -7,14 +7,6 @@ puts "Displaying \'zbufftrihedron\' interferes with \'vgraduatedtrihedron\'"
 puts "Test graduated trihedron parameters"
 ############################################################################
 
-set anImage1 $imagedir/${casename}_1.png
-set anImage2 $imagedir/${casename}_2.png
-set anImage3 $imagedir/${casename}_3.png
-set anImage4 $imagedir/${casename}_4.png
-
-# enable FFP until bug-fix for GLSL
-vcaps -ffp 1
-
 vinit View1
 psphere s 10
 vdisplay s
@@ -24,18 +16,16 @@ vsetdispmode s 1
 
 # Font and color parameters
 vgraduatedtrihedron -on -xname X(mm) -yname Y(mm) -zname Z(mm) -xnamecolor PINK -ycolor GREENYELLOW -namefont Courier -valuesfont Courier
-vdump $anImage1
+vdump $imagedir/${casename}_1.png
 
 # Boolean parameters
 vgraduatedtrihedron -on -xdrawname off -ydrawvalues off -zdrawticks off
-vdump $anImage2
+vdump $imagedir/${casename}_2.png
 
 # Tickmark parameters
 vgraduatedtrihedron -on -xticks 10 -xticklength 15 -xvaluesoffset 20 -xnameoffset 40
-vdump $anImage3
+vdump $imagedir/${casename}_3.png
 
-#Arrow parameters
+# Arrow parameters
 vgraduatedtrihedron -on -arrowlength 50
-vdump $anImage4
-vclose View1
-
+vdump $imagedir/${casename}_4.png
diff --git a/tests/bugs/vis/bug25854 b/tests/bugs/vis/bug25854
deleted file mode 100644 (file)
index 45ec071..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-puts "============"
-puts "CR25854"
-puts "============"
-puts ""
-
-############################################################
-# Visualization, TKOpenGl - add option to request Core profile 3.2+
-############################################################
-
-vcaps -coreProfile
-vcaps
-vinit
-vglinfo
-box b 1 2 3
-vdisplay b
-vfit
-
-vdump $imagedir/${casename}.png
index c94faaa..41d75bc 100644 (file)
@@ -8,8 +8,6 @@ vinit View1
 vclear
 vaxo
 
-# Disable ffp
-vcaps -ffp 0
 # draw color scale
 vcolorscale cs -demo
 vdump ${imagedir}/${casename}_View1.png
index 565d189..3920a10 100644 (file)
@@ -35,7 +35,6 @@ vtextureenv on 0
 
 vdump $imagedir/${casename}_2.png
 
-vcaps -ffp 0
 vmoveto 100 300
 vmoveto 0 0
 
index 7906621..0ddb846 100755 (executable)
@@ -1,14 +1,8 @@
 puts "============"
-puts "CR26599"
+puts "CR26599: Visualization, TKOpenGl - gradient background should reset model transformation in Core profile"
 puts "============"
 puts ""
 
-##########################################################################################
-# Visualization, TKOpenGl - gradient background should reset model transformation in Core profile
-##########################################################################################
-
-vcaps -ffp 0
-
 vinit View1
 vclear
 vaxo
index cd09fe4..59ecaa2 100644 (file)
@@ -5,6 +5,7 @@ puts "================"
 pload MODELING VISUALIZATION
 
 # Ray-Tracing doesn't work with Compatible Profile on macOS
+pload OPENGL
 if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
 
 box b 10 10 10
index 402f7f7..6b5efdc 100644 (file)
@@ -5,6 +5,7 @@ puts "============"
 puts ""
 
 pload MODELING VISUALIZATION
+pload OPENGL
 
 vclear
 vcaps -core 1
index ebb94b0..a657b7f 100644 (file)
@@ -8,6 +8,7 @@ box b 1 2 3
 
 # request software OpenGL implementation - which is OpenGL 1.1 in case of Windows
 # (test case is useless for other systems)
+pload OPENGL
 vcaps -softMode 1
 
 # disable FPE signals -- these often occur in software OpenGL drivers
index b0038e8..b2d5822 100644 (file)
@@ -4,6 +4,7 @@ puts "# ==================================================================="
 puts ""
 
 pload VISUALIZATION
+pload OPENGL
 vcaps -vsync 0
 vinit View1
 vglinfo
index 3a91311..8a4a8dd 100644 (file)
@@ -4,6 +4,7 @@ puts "============"
 puts ""
 
 pload MODELING VISUALIZATION
+pload OPENGL
 box b 1 2 3
 vcaps -core
 vclear
index f3f888f..57baf18 100644 (file)
@@ -3,6 +3,7 @@ puts "0030713: Visualization, TKOpenGl - stipple line artifacts on Intel UHD Gra
 puts "============="
 
 pload MODELING VISUALIZATION
+pload OPENGL
 box b 1 2 3
 vclear
 vcaps -core
index 47c3132..b4ef25a 100644 (file)
@@ -2,11 +2,13 @@ puts "========"
 puts "OCC79"
 puts "========"
 
-# disable VBO to avoid false memory leaks reported
-# on NVidia graphics, see issue #29996
+pload VISUALIZATION
+
+# disable VBO to avoid false memory leaks reported on NVIDIA graphics, see issue #29996
+pload OPENGL
 vcaps -vbo 0
 
-vinit
+vinit View1
 restore [locate_data_file OCC162.brep] s
 vdisplay s
 
index e5fd637..9ca4500 100755 (executable)
@@ -7,6 +7,8 @@ puts "OCC1228"
 puts "================"
 puts ""
 
+pload VISUALIZATION
+
 # Presentation attributes
 #
 # Testing attribute: TPrsStd_AISPresentation
index 163756b..7f76936 100644 (file)
@@ -57,7 +57,7 @@ proc checkarray {name array expected} {
   }
 }
 
-pload TOPTEST
+pload TOPTEST VISUALIZATION
 
 Close D -silent
 
index e888e6a..aae0ee2 100644 (file)
@@ -1,6 +1 @@
-if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
-       pload TOPTEST
-}
-if { [array get Draw_Groups "ZeViewer"] == "" } {
-       pload AISV
-}
+pload TOPTEST VISUALIZATION
index 00b2190..80d1485 100755 (executable)
@@ -1,7 +1,5 @@
-if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
-    pload TOPTEST
-    pload AISV
-}
+pload TOPTEST VISUALIZATION
+
 # To prevent loops limit to 10 minutes
 cpulimit 600
 
index b752ad2..690541f 100644 (file)
@@ -1,7 +1,5 @@
-if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
-    pload TOPTEST
-    pload AISV
-}
+pload TOPTEST VISUALIZATION
+
 # To prevent loops limit to 1 minutes
 cpulimit 60
 
index 4442d0f..2cd09eb 100755 (executable)
@@ -22,9 +22,4 @@ set bug_cross ""
 set bug_async ""
 set bug_freenodes ""
 
-if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
-       pload TOPTEST
-}
-if { [array get Draw_Groups "ZeViewer"] == "" } {
-       pload AISV
-}
+pload TOPTEST VISUALIZATION
index 0818770..ef09111 100755 (executable)
@@ -2,6 +2,8 @@ cpulimit 300
 set group "v3d"
 
 pload VISUALIZATION TOPTEST
+
+pload OPENGL
 vgldebug -glslWarn 1
 
 if { [info exists imagedir] == 0 } {
diff --git a/tests/v3d/glsl/d3dhost b/tests/v3d/glsl/d3dhost
new file mode 100644 (file)
index 0000000..a8e5667
--- /dev/null
@@ -0,0 +1,27 @@
+puts "============"
+puts "0026392: Visualization, TKD3DHost - provide straight-forward base for integration of TKOpenGl viewer into D3D-based application"
+puts "============"
+puts ""
+
+set to_dump_screen 0
+if { ![checkplatform -windows] } {
+  puts "This test case is applicable only to Windows platform"
+  return
+}
+
+pload MODELING VISUALIZATION
+vdriver -load D3DHOST
+vclear
+vinit View1
+box b 3 0 0 1 2 3
+psphere s 1
+vdisplay -dispMode 1 b s
+set anInfo [vglinfo]
+if { [regexp {D3Dinterop} $anInfo] } {
+  puts "OK: D3Dinterop has been found"
+} else {
+  puts "Error: D3Dinterop is expected"
+}
+vfit
+vrenderparams -shadingModel PHONG
+vdump ${imagedir}/${casename}.png
index 476f067..8395623 100755 (executable)
@@ -1,5 +1,4 @@
-pload TOPTEST
-pload DCAF
+pload TOPTEST DCAF
 
 cpulimit 300
 
index ea6734a..05c5ea1 100644 (file)
@@ -1,6 +1,8 @@
 set aTestName "caf003-A4"
 puts ${aTestName}
 
+pload VISUALIZATION
+
 # Set NamedShape attribute
 box aBox1 100 200 300
 set aLabel 0:2