1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0023668: OCCT automated testing: Using Mesa3d for 3D visualization on virtual Windows machines

Added advanced Draw Harness environment variable CSF_UserDllPath
to prepend DLL search path for system libraries like "opengl32.dll".

Added new Draw Harness command vglinfo to print OpenGL self info.
This commit is contained in:
kgv 2013-01-24 14:42:36 +04:00
parent 1981cb228a
commit dac04bfa38
2 changed files with 108 additions and 2 deletions

View File

@ -31,6 +31,7 @@
#include <Draw_Appli.hxx>
#include <OSD.hxx>
#include <OSD_Environment.hxx>
#include <OSD_Timer.hxx>
#ifdef HAVE_SYS_TIME_H
@ -159,13 +160,41 @@ void exitProc(ClientData /*dc*/)
// *******************************************************************
// main
// *******************************************************************
#ifdef WNT
#ifdef _WIN32
//Standard_EXPORT void Draw_Appli(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lps
Standard_EXPORT void Draw_Appli(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszLine, int nShow,const FDraw_InitAppli Draw_InitAppli)
#else
void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_InitAppli)
#endif
{
// prepend extra DLL search path to override system libraries like opengl32.dll
#ifdef _WIN32
OSD_Environment aUserDllEnv ("CSF_UserDllPath");
TCollection_AsciiString aUserDllPath = aUserDllEnv.Value();
if (!aUserDllPath.IsEmpty())
{
// This function available since Win XP SP1 #if (_WIN32_WINNT >= 0x0502).
// We retrieve dynamically here (kernel32 should be always preloaded).
typedef BOOL (WINAPI *SetDllDirectoryA_t)(const char* thePathName);
HMODULE aKern32Module = GetModuleHandleA ("kernel32");
SetDllDirectoryA_t aFunc = (aKern32Module != NULL)
? (SetDllDirectoryA_t )GetProcAddress (aKern32Module, "SetDllDirectoryA") : NULL;
if (aFunc != NULL)
{
aFunc (aUserDllPath.ToCString());
}
else
{
//std::cerr << "SetDllDirectoryA() is not available on this system!\n";
}
if (aKern32Module != NULL)
{
FreeLibrary (aKern32Module);
}
}
#endif
// *****************************************************************
// analyze arguments
// *****************************************************************
@ -174,7 +203,7 @@ void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_In
Standard_Integer i;
Standard_Boolean isInteractiveForced = Standard_False;
#ifdef WNT
#ifdef _WIN32
// On NT command line arguments are in the lpzline and not in argv
int argc = 0;
const int MAXARGS = 1024;

View File

@ -432,6 +432,79 @@ static int VImmediateFront (Draw_Interpretor& theDI,
return 0;
}
//==============================================================================
//function : VGlInfo
//purpose :
//==============================================================================
static int VGlInfo (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{
// get the active view
Handle(V3d_View) aView = ViewerTest::CurrentView();
if (aView.IsNull())
{
std::cerr << "No active view. Please call vinit.\n";
return 1;
}
if (theArgNb <= 1)
{
theDI << "OpenGL info:\n"
<< " GLvendor = '" << (const char* )glGetString(GL_VENDOR) << "'\n"
<< " GLdevice = '" << (const char* )glGetString(GL_RENDERER) << "'\n"
<< " GLversion = '" << (const char* )glGetString(GL_VERSION) << "'\n"
<< " GLSLversion = '" << (const char* )glGetString(GL_SHADING_LANGUAGE_VERSION) << "'\n";
return 0;
}
const Standard_Boolean isList = theArgNb >= 3;
for (Standard_Integer anIter = 1; anIter < theArgNb; ++anIter)
{
TCollection_AsciiString aName (theArgVec[anIter]);
aName.UpperCase();
const char* aValue = NULL;
if (aName.Search ("VENDOR") != -1)
{
aValue = (const char* )glGetString (GL_VENDOR);
}
else if (aName.Search ("RENDERER") != -1)
{
aValue = (const char* )glGetString (GL_RENDERER);
}
else if (aName.Search ("SHADING_LANGUAGE_VERSION") != -1
|| aName.Search ("GLSL") != -1)
{
aValue = (const char* )glGetString (GL_SHADING_LANGUAGE_VERSION);
}
else if (aName.Search ("VERSION") != -1)
{
aValue = (const char* )glGetString (GL_VERSION);
}
else if (aName.Search ("EXTENSIONS") != -1)
{
aValue = (const char* )glGetString (GL_EXTENSIONS);
}
else
{
std::cerr << "Unknown key '" << aName.ToCString() << "'\n";
return 1;
}
if (isList)
{
theDI << "{" << aValue << "} ";
}
else
{
theDI << aValue;
}
}
return 0;
}
//=======================================================================
//function : OpenGlCommands
//purpose :
@ -451,4 +524,8 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
"vimmediatefront : render immediate mode to front buffer or to back buffer",
__FILE__, VImmediateFront, aGroup);
theCommands.Add("vglinfo",
"vglinfo [GL_VENDOR] [GL_RENDERER] [GL_VERSION] [GL_SHADING_LANGUAGE_VERSION] [GL_EXTENSIONS]"
" : prints GL info",
__FILE__, VGlInfo, aGroup);
}