]> OCCT Git - occt.git/commitdiff
0032154: Tests - include vglinfo into Tests Summary
authorkgv <kgv@opencascade.com>
Mon, 22 Feb 2021 06:58:50 +0000 (09:58 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 25 Feb 2021 15:55:29 +0000 (18:55 +0300)
Command testgrid now includes vglinfo into summary.
Command vinit has been extended by -virtual option creating an offscreen window.
Command vglinfo now splits long values into multiple lines.
Added test case v3d/glsl/glinfo dumping OpenGL context creation info.

OpenGl_Window - fixed initialization of OpenGL 4.6 Core Profile (was limited to 4.5).

src/DrawResources/TestCommands.tcl
src/OpenGl/OpenGl_Window.cxx
src/ViewerTest/ViewerTest.hxx
src/ViewerTest/ViewerTest_OpenGlCommands.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/v3d/glsl/glinfo [new file with mode: 0644]

index 3618873058bffcf26ab059138ccb040cad6f41c4..5310bc489329d6615e3e99dd255b09a6be46efbb 100644 (file)
@@ -559,6 +559,9 @@ proc testgrid {args} {
     lappend log "Host: [info hostname]"
     lappend log "Started on: [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S}]"
     catch {lappend log "DRAW build:\n[dversion]" }
+    catch { pload VISUALIZATION; vinit g/v/info -virtual -w 2 -h 2 }
+    catch { lappend log "[vglinfo -complete -lineWidth 80]" }
+    catch { vclose g/v/info 0 }
     lappend log "Environment:"
     foreach envar [lsort [array names env]] {
         lappend log "$envar=\"$env($envar)\""
index 157fe789fa7b8547cefc170fa2c3b8d7f3cafe99..8d1a3c617b2dab956056a5d7ba239523454614b2 100644 (file)
@@ -417,7 +417,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
         // Try to create the core profile of highest OpenGL version supported by OCCT
         // (this will be done automatically by some drivers when requesting 3.2,
         //  but some will not (e.g. AMD Catalyst) since WGL_ARB_create_context_profile specification allows both implementations).
-        for (int aLowVer4 = 5; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4)
+        for (int aLowVer4 = 6; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4)
         {
           aCoreCtxAttribs[1] = 4;
           aCoreCtxAttribs[3] = aLowVer4;
@@ -555,7 +555,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
       };
 
       // try to create the core profile of highest OpenGL version supported by OCCT
-      for (int aLowVer4 = 5; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4)
+      for (int aLowVer4 = 6; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4)
       {
         aCoreCtxAttribs[1] = 4;
         aCoreCtxAttribs[3] = aLowVer4;
index 2068a447185a8b58f6b3f595ce40f176eb49fe7c..0b84c9775c6c85f280b5cf18e43599c8a2301f80 100644 (file)
@@ -55,13 +55,15 @@ public:
   //! @param theViewName    name of newly created View
   //! @oaram theDisplayName display name
   //! @param theViewToClone when specified, the new View will copy properties of existing one
+  //! @param theIsVirtual   force creation of virtual off-screen window within interactive session
   Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft   = 0,
                                                              const Standard_Integer thePxTop    = 0,
                                                              const Standard_Integer thePxWidth  = 0,
                                                              const Standard_Integer thePxHeight = 0,
                                                              const TCollection_AsciiString& theViewName = "",
                                                              const TCollection_AsciiString& theDisplayName = "",
-                                                             const Handle(V3d_View)& theViewToClone = Handle(V3d_View)());
+                                                             const Handle(V3d_View)& theViewToClone = Handle(V3d_View)(),
+                                                             const Standard_Boolean theIsVirtual = false);
 
   Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
 
index 4015fa1301916ab383be2d0d85588a4c2ce18e1f..0399c111819ec792be62a0e361f24484977872be 100644 (file)
@@ -284,32 +284,72 @@ static int VGlInfo (Draw_Interpretor& theDI,
     return 1;
   }
 
-  Standard_Integer anArgIter = 1;
   Graphic3d_DiagnosticInfo anInfoLevel = Graphic3d_DiagnosticInfo_Basic;
-  if (theArgNb == 2)
+  Standard_Integer aLineWidth = 80;
+  NCollection_Sequence<TCollection_AsciiString> aKeys;
+  TColStd_IndexedDataMapOfStringString aDict;
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
   {
-    TCollection_AsciiString aName (theArgVec[1]);
+    TCollection_AsciiString aName (theArgVec[anArgIter]);
     aName.LowerCase();
+    TCollection_AsciiString aValue;
     if (aName == "-short")
     {
-      ++anArgIter;
       anInfoLevel = Graphic3d_DiagnosticInfo_Short;
     }
     else if (aName == "-basic")
     {
-      ++anArgIter;
       anInfoLevel = Graphic3d_DiagnosticInfo_Basic;
     }
     else if (aName == "-complete"
           || aName == "-full")
     {
-      ++anArgIter;
       anInfoLevel = Graphic3d_DiagnosticInfo_Complete;
     }
+    else if (anArgIter + 1 < theArgNb
+          && (aName == "-maxwidth"
+           || aName == "-maxlinewidth"
+           || aName == "-linewidth"))
+    {
+      aLineWidth = Draw::Atoi (theArgVec[++anArgIter]);
+      if (aLineWidth < 0)
+      {
+        aLineWidth = IntegerLast();
+      }
+    }
+    else if (aName.Search ("vendor") != -1)
+    {
+      aKeys.Append ("GLvendor");
+    }
+    else if (aName.Search ("renderer") != -1)
+    {
+      aKeys.Append ("GLdevice");
+    }
+    else if (aName.Search ("shading_language_version") != -1
+          || aName.Search ("glsl") != -1)
+    {
+      aKeys.Append ("GLSLversion");
+    }
+    else if (aName.Search ("version") != -1)
+    {
+      aKeys.Append ("GLversion");
+    }
+    else if (aName.Search ("extensions") != -1)
+    {
+      aKeys.Append ("GLextensions");
+    }
+    else if (aName.Search ("extensions") != -1)
+    {
+      aKeys.Append ("GLextensions");
+    }
+    else
+    {
+      Message::SendFail() << "Syntax error: unknown key '" << aName << "'";
+      return 1;
+    }
   }
 
-  TColStd_IndexedDataMapOfStringString aDict;
-  if (anArgIter >= theArgNb)
+  if (aKeys.IsEmpty())
   {
     aView->DiagnosticInformation (aDict, anInfoLevel);
     TCollection_AsciiString aText;
@@ -319,7 +359,42 @@ static int VGlInfo (Draw_Interpretor& theDI,
       {
         aText += "\n";
       }
-      aText += TCollection_AsciiString("  ") + aValueIter.Key() + ": " + aValueIter.Value();
+      if ((aValueIter.Key().Length() + aValueIter.Value().Length() + 4) <= aLineWidth)
+      {
+        aText += TCollection_AsciiString("  ") + aValueIter.Key() + ": " + aValueIter.Value();
+        continue;
+      }
+
+      // split into lines
+      aText += TCollection_AsciiString("  ") + aValueIter.Key() + ":";
+      TCollection_AsciiString aSubList;
+      for (Standard_Integer aTokenIter = 1;; ++aTokenIter)
+      {
+        TCollection_AsciiString aToken = aValueIter.Value().Token (" ", aTokenIter);
+        if (aToken.IsEmpty())
+        {
+          break;
+        }
+
+        if (!aSubList.IsEmpty()
+         && (aSubList.Length() + aToken.Length() + 5) > aLineWidth)
+        {
+          aText += TCollection_AsciiString("\n    ") + aSubList;
+          aSubList = aToken;
+        }
+        else
+        {
+          if (!aSubList.IsEmpty())
+          {
+            aSubList += " ";
+          }
+          aSubList += aToken;
+        }
+      }
+      if (!aSubList.IsEmpty())
+      {
+        aText += TCollection_AsciiString("\n    ") + aSubList;
+      }
     }
 
     theDI << "OpenGL info:\n"
@@ -327,41 +402,11 @@ static int VGlInfo (Draw_Interpretor& theDI,
     return 0;
   }
 
-  const Standard_Boolean isList = theArgNb >= 3;
   aView->DiagnosticInformation (aDict, Graphic3d_DiagnosticInfo_Complete);
-  for (; anArgIter < theArgNb; ++anArgIter)
+  for (NCollection_Sequence<TCollection_AsciiString>::Iterator aKeyIter (aKeys); aKeyIter.More(); aKeyIter.Next())
   {
-    TCollection_AsciiString aName (theArgVec[anArgIter]);
-    aName.UpperCase();
-    TCollection_AsciiString aValue;
-    if (aName.Search ("VENDOR") != -1)
-    {
-      aValue = searchInfo (aDict, "GLvendor");
-    }
-    else if (aName.Search ("RENDERER") != -1)
-    {
-      aValue = searchInfo (aDict, "GLdevice");
-    }
-    else if (aName.Search ("SHADING_LANGUAGE_VERSION") != -1
-          || aName.Search ("GLSL") != -1)
-    {
-      aValue = searchInfo (aDict, "GLSLversion");
-    }
-    else if (aName.Search ("VERSION") != -1)
-    {
-      aValue = searchInfo (aDict, "GLversion");
-    }
-    else if (aName.Search ("EXTENSIONS") != -1)
-    {
-      aValue = searchInfo (aDict, "GLextensions");
-    }
-    else
-    {
-      Message::SendFail() << "Syntax error: unknown key '" << aName.ToCString() << "'";
-      return 1;
-    }
-
-    if (isList)
+    TCollection_AsciiString aValue = searchInfo (aDict, aKeyIter.Value());
+    if (aKeys.Length() > 1)
     {
       theDI << "{" << aValue << "} ";
     }
@@ -1363,10 +1408,12 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
     "vimmediatefront : render immediate mode to front buffer or to back buffer",
     __FILE__, VImmediateFront, aGroup);
   theCommands.Add("vglinfo",
-                "vglinfo [-short|-basic|-complete]"
+                "vglinfo [-short|-basic|-complete] [-lineWidth Value=80]"
         "\n\t\t:         [GL_VENDOR] [GL_RENDERER] [GL_VERSION]"
         "\n\t\t:         [GL_SHADING_LANGUAGE_VERSION] [GL_EXTENSIONS]"
-        "\n\t\t: print OpenGL info",
+        "\n\t\t: print OpenGL info."
+        "\n\t\t:  -lineWidth split values longer than specified value into multiple lines;"
+        "\n\t\t:             -1 disables splitting.",
     __FILE__, VGlInfo, aGroup);
   theCommands.Add("vshader",
                   "vshader name -vert VertexShader -frag FragmentShader [-geom GeometryShader]"
index a99bcfdee6abdaf8d1a8b735f5c49617f51377be..750f8569fdd462e79fbe92e3c193c0f74b4c53d6 100644 (file)
@@ -1658,7 +1658,8 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
                                                 const Standard_Integer thePxHeight,
                                                 const TCollection_AsciiString& theViewName,
                                                 const TCollection_AsciiString& theDisplayName,
-                                                const Handle(V3d_View)& theViewToClone)
+                                                const Handle(V3d_View)& theViewToClone,
+                                                const Standard_Boolean theIsVirtual)
 {
   // Default position and dimension of the viewer window.
   // Note that left top corner is set to be sufficiently small to have
@@ -1670,6 +1671,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
   Standard_Integer aPxWidth  = 409;
   Standard_Integer aPxHeight = 409;
   Standard_Boolean toCreateViewer = Standard_False;
+  const Standard_Boolean isVirtual = Draw_VirtualWindows || theIsVirtual;
   if (!theViewToClone.IsNull())
   {
     theViewToClone->Window()->Size (aPxWidth, aPxHeight);
@@ -1715,7 +1717,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
     SetDisplayConnection (new Aspect_DisplayConnection ());
   #endif
 
-    if (Draw_VirtualWindows)
+    if (isVirtual)
     {
       // don't waste the time waiting for VSync when window is not displayed on the screen
       ViewerTest_myDefaultCaps.swapInterval = 0;
@@ -1833,7 +1835,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
   // Create window
 #if defined(_WIN32)
   VT_GetWindow() = new WNT_Window (aTitle.ToCString(), WClass(),
-                                    Draw_VirtualWindows ? WS_POPUP : WS_OVERLAPPEDWINDOW,
+                                   isVirtual ? WS_POPUP : WS_OVERLAPPEDWINDOW,
                                     aPxLeft, aPxTop,
                                     aPxWidth, aPxHeight,
                                     Quantity_NOC_BLACK);
@@ -1849,7 +1851,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
                                   aPxLeft, aPxTop,
                                   aPxWidth, aPxHeight);
 #endif
-  VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
+  VT_GetWindow()->SetVirtual (isVirtual);
 
   // View setup
   Handle(V3d_View) aView;
@@ -1927,6 +1929,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
 {
   TCollection_AsciiString aViewName, aDisplayName;
   Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
+  Standard_Boolean isVirtual = false;
   Handle(V3d_View) aCopyFrom;
   TCollection_AsciiString aName, aValue;
   int is2dMode = -1;
@@ -1964,6 +1967,16 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
     {
       aPxHeight = Draw::Atoi (theArgVec[++anArgIt]);
     }
+    else if (anArgCase == "-virtual"
+          || anArgCase == "-offscreen")
+    {
+      isVirtual = true;
+      if (anArgIt + 1 < theArgsNb
+       && Draw::ParseOnOff (theArgVec[anArgIt + 1], isVirtual))
+      {
+        ++anArgIt;
+      }
+    }
     else if (anArgCase == "-exitonclose")
     {
       ViewerTest_EventManager::ToExitOnCloseView() = true;
@@ -2081,7 +2094,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
   }
 
   TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
-                                                            aViewName, aDisplayName, aCopyFrom);
+                                                            aViewName, aDisplayName, aCopyFrom, isVirtual);
   if (is2dMode != -1)
   {
     ViewerTest_V3dView::SetCurrentView2DMode (is2dMode == 1);
@@ -14677,7 +14690,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
   const char *group = "ZeViewer";
   theCommands.Add("vinit",
           "vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]"
-    "\n\t\t:     [-exitOnClose] [-closeOnEscape] [-cloneActive] [-2d_mode {on|off}=off]"
+    "\n\t\t:     [-exitOnClose] [-closeOnEscape] [-cloneActive] [-virtual {on|off}=off] [-2d_mode {on|off}=off]"
   #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
     "\n\t\t:     [-display displayName]"
   #endif
@@ -14693,9 +14706,10 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
 #endif
     "\n\t\t:  -left,  -top    pixel position of left top corner of the window."
     "\n\t\t:  -width, -height width and height of window respectively."
-    "\n\t\t:  -cloneActive floag to copy camera and dimensions of active view."
+    "\n\t\t:  -cloneActive flag to copy camera and dimensions of active view."
     "\n\t\t:  -exitOnClose when specified, closing the view will exit application."
     "\n\t\t:  -closeOnEscape when specified, view will be closed on pressing Escape."
+    "\n\t\t:  -virtual create an offscreen window within interactive session"
     "\n\t\t:  -2d_mode when on, view will not react on rotate scene events"
     "\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.",
     __FILE__,VInit,group);
diff --git a/tests/v3d/glsl/glinfo b/tests/v3d/glsl/glinfo
new file mode 100644 (file)
index 0000000..557befe
--- /dev/null
@@ -0,0 +1,46 @@
+puts "============"
+puts "Print OpenGL info"
+puts "============"
+puts ""
+
+set to_dump_screen 0
+pload VISUALIZATION
+vclose ALL 0
+
+puts "=== Create compatible profile ==="
+vgldebug 0
+vcaps -core 0 -maxVersion -1 -1 -softMode 0
+vinit g1/v/info
+vglinfo -complete -lineWidth 80
+vclose ALL 0
+
+puts "=== Create core profile ==="
+vgldebug 0
+vcaps -core 1 -maxVersion -1 -1 -softMode 0
+vinit g1/v/info
+vglinfo -complete -lineWidth 80
+vclose ALL 0
+
+puts "=== Create version-restricted profile ==="
+vgldebug 0
+vcaps -core 0 -maxVersion 2 1 -softMode 0
+vinit g1/v/info
+vglinfo -complete -lineWidth 80
+vclose ALL 0
+
+puts "=== Create software emulated profile ==="
+vgldebug 0
+vcaps -core 0 -maxVersion -1 -1 -softMode 1
+vinit g1/v/info
+vglinfo -complete -lineWidth 80
+vclose ALL 0
+
+puts "=== Create debug profile ==="
+vgldebug 1
+vcaps -core 0 -maxVersion -1 -1 -softMode 0
+vinit g1/v/info
+vglinfo -complete -lineWidth 80
+vclose ALL 0
+
+vgldebug 0
+vcaps -core 0 -maxVersion -1 -1 -softMode 0