Tue, 12/07/2021 - 14:13
Forums:
Hi Forum,
I established a docker, the system version show as follows:
Linux version 3.10.0-1160.45.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ), SMP Wed Oct 13 17:20:51 UTC 2021
CentOS Linux release 8.4.2105.
The Graphicscard infomation show as follows:
00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA
The OpenGL information show as follows:
GLvendor: Mesa/X.org
GLdevice: llvmpipe (LLVM 12.0.0, 256 bits)
GLversion: OpenGL ES 3.2 Mesa 21.1.5
GLSLversion: OpenGL ES GLSL ES 3.20
Max texture size: 16384
Max FBO dump size: 16384x16384
Max combined texture units: 192
Max MSAA samples: 4
Viewport: 640x480
ResolutionRatio: 1
I installed OpenCascade7.5.0 in the docker.
I try to dump png from step file in docker and it works, the png is exactly what I want, but the code gives the following error:
OpenGl_GraphicDriver, FAILED to release OpenGL context
OpenGl_GraphicDriver, EGL, eglTerminate FAILED
#0 0x00007f0b000c5f0c in malloc_consolidate (av=av@entry=0x7f0b00403bc0 <main_arena>) at malloc.c:4487
# 0x00007f0b000c73c0 in _int_free (av=0x7f0b00403bc0 <main_arena>, p=0x109c2c0, have_lock=<optimized out>) at malloc.c:4412
#2 0x00007f0b0491a625 in NCollection_BaseMap::Destroy(void (*)(NCollection_ListNode*, opencascade::handle<NCollection_BaseAllocator>&), bool) ()
at /opt/pera_simulator2/Occ/opencascade-7.5.0/install/lib/libTKernel.so.7
#3 0x00007f0b0591420b in OpenGl_GraphicDriver::~OpenGl_GraphicDriver() () at /opt/pera_simulator2/Occ/opencascade-7.5.0/install/lib/libTKOpenGl.so.7
#4 0x00007f0b059143c9 in OpenGl_GraphicDriver::~OpenGl_GraphicDriver() () at /opt/pera_simulator2/Occ/opencascade-7.5.0/install/lib/libTKOpenGl.so.7
#5 0x000000000040e59c in opencascade::handle<OpenGl_GraphicDriver>::EndScope()
(this=0x6143b8 <makePngByV3d(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, opencascade::handle<Message_Messenger>, int, int, double, double, char const*)::aGraphicDriver>) at /opt/pera_simulator2/Occ/opencascade-7.5.0/install/include/opencascade/Standard_Handle.hxx:394
#6 0x000000000040d5c2 in opencascade::handle<OpenGl_GraphicDriver>::~handle()
(this=0x6143b8 <makePngByV3d(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, opencascade::handle<Message_Messenger>, int, int, double, double, char const*)::aGraphicDriver>, __in_chrg=<optimized out>) at /opt/pera_simulator2/Occ/opencascade-7.5.0/install/include/opencascade/Standard_Handle.hxx:84
#7 0x00007f0b0007db0c in __run_exit_handlers (status=0, listp=0x7f0b00403758 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
#8 0x00007f0b0007dc40 in __GI_exit (status=<optimized out>) at exit.c:139
#9 0x00007f0b0006749a in __libc_start_main (main=0x40b20f <main(int, char**)>, argc=3, argv=0x7fff9ae03768, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff9ae03758)
at ../csu/libc-start.c:348
#10 0x000000000040628e in _start ()
Here is my main code:
Handle(Aspect_DisplayConnection) aDispConnection = new Aspect_DisplayConnection();
static Handle(OpenGl_GraphicDriver) aGraphicDriver;
if (aGraphicDriver.IsNull()) {
aGraphicDriver = new OpenGl_GraphicDriver(aDispConnection);
}
Handle(V3d_Viewer) aViewer = new V3d_Viewer(aGraphicDriver);
Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(aViewer);
if (aContext.IsNull()) {
return 1;
}
Handle(V3d_View) aView = aViewer->CreateView();
if (aView.IsNull()) {
return 1;
}
Handle(Xw_Window) aWindow = new Xw_Window(aContext->CurrentViewer()->Driver()->GetDisplayConnection(), "V3d", 0, 0, a, b);
aWindow->SetVirtual(Standard_True);
aView->SetWindow(aWindow);
if (!aWindow->IsMapped()) {
aWindow->Map();
}
aViewer->SetDefaultBackgroundColor(Quantity_Color(0.9, 0.9, 0.9, Quantity_TOC_RGB));
aViewer->SetLightOn();
aViewer->SetDefaultLights();
aViewer->SetComputedMode(false);
aViewer->SetViewOn(aView);
Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
aParams.Method = Graphic3d_RM_RASTERIZATION;
aParams.RaytracingDepth = 3;
aParams.IsShadowEnabled = true;
aParams.IsReflectionEnabled = true;
aParams.IsAntialiasingEnabled = true;
aParams.IsTransparentShadowEnabled = false;
aParams.ToReverseStereo = true;
aParams.StereoMode = Graphic3d_StereoMode::Graphic3d_StereoMode_QuadBuffer;
aParams.AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph::Anaglyph_RedCyan_Optimized;
aParams.FrustumCullingState = Graphic3d_RenderingParams::FrustumCulling::FrustumCulling_On;
aParams.LineFeather = 1.0;
aParams.NbMsaaSamples = 4;
aView->Redraw();
aView->Size(Width, Height);
aView->SetBackgroundColor(Quantity_TOC_RGB, 0.8, 0.8, 0.8);
aView->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Orthographic);
aView->SetImmediateUpdate(Standard_False);
Handle(AIS_Shape) aColoredShape = new AIS_Shape(shape);
aColoredShape->SetWidth(10.0);
aColoredShape->SetMaterial(Graphic3d_MaterialAspect(Graphic3d_NOM_NEON_GNC));
aContext->SetColor(aColoredShape, Quantity_Color(0.2, 0.2, 0.2, Quantity_TOC_RGB), false);
aContext->SetDisplayMode(AIS_Shaded, true);
aContext->Display(aColoredShape, false);
aView->FitAll();
aView->Redraw();
if (aView.IsNull()) {
return 1;
}
string pngname = path + "/thumb.png";
char pngfile[300];
strcpy(pngfile, pngname.c_str());
Standard_Boolean ok = aView->Dump(pngfile, Graphic3d_BT_RGB);
Does anyone know how to solve this problem?
Attachments:
Thu, 12/09/2021 - 16:32
I don't have Docker, but your sample doesn't crash for me in VirtualBox 18.04 and OCCT 7.6.0.
How do you setup X11 server in your case?
Have you tried OCCT 7.6.0?
Mon, 12/13/2021 - 10:47
I have already set X11 server in my case.
And I installed opencascade7.6.0 instead of old one in the same docker, it works!
Thank you Kirill, now it is working properly!
Wed, 12/28/2022 - 11:14
hi,i want to know how to use aDispConnection in docker,my docker image have no $DISPLAY,is it only config X11 server solution it?I want to convert .STL to 2d image like .jpg in docker ,thanks.
Wed, 12/28/2022 - 11:48
You may use Xvfb tool (xvfb-run) as alternative to real X11 desktop.
Wed, 12/28/2022 - 12:57
thanks!i can use aDispConnection now,but there report "Error: OpenGlGraphicDriver,GLX extension is unavailable" when i use OpenGlGraphicDriver in docker, I don't know why cause there can running normal in my centos7,thanks for your answer again。
Wed, 12/28/2022 - 13:36
You need to install OpenGL on your Linux station. I guess it might be
> RUN apt install libgl1-mesa-dev -y
Thu, 12/29/2022 - 12:14
I installed mesa-libGL-devel use yum now ,but there still report error.
there report "OpenGl_GraphicDriver,couldn't find compatible visual(RGBA,double-buffered)" then throwing an instance 'Aspect_GraphicDeviceDefinitionError'.
this is my a part of code:
Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
Handle (Graphic3d_GraphicDriver) aDriver = new OpenGl_GraphicDriver(aDisplayConnection);
Handle (Xw_Window) aWindow = new Xw_Window (aDisplayConnection, "My", 0,0,1024,768);
aWindow->SetVirtual (Standard_True);
Handle (V3d_Viewer) aViewer = new V3d_Viewer (aDriver);
Handle (AIS_InteractiveContext) aContext = new AIS_InteractiveContext (aViewer);
aContext->SetAutomaticHilight(Standard_False);
aContext->SetDisplayMode(AIS_Shaded, Standard_False);
Handle (V3d_View) aView = aViewer->CreateView ();
aView->SetWindow (aWindow);
when i use 'aView->SetWindow' then throwing that instance,Is that my Xvfb wrong config?
Thu, 12/29/2022 - 12:31
Please the script starting Xvfb server.