1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0032154: Tests - include vglinfo into Tests Summary

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).
This commit is contained in:
kgv
2021-02-22 09:58:50 +03:00
committed by bugmaster
parent 02a2beaad9
commit 72ed06442e
6 changed files with 166 additions and 54 deletions

View 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);

View 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]"

View 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);