Tue, 07/23/2019 - 16:53
Hi,
my current project uses Qt for GUI purposes and integrates OpenCASCADE. However, I am unable to dump the front buffer of my V3d_View into a pixmap (using ToPixMap) or directly store them to disk using the Dump-method. I am able to reproduce the issue when running the AndroidQt sample and trying to call myView->Dump() after loading a shape inside the ReadShapeFromFile method. Here's the code:
bool AndroidQt::ReadShapeFromFile (QString theFilePath)
{
//
// Sample code left out.
//
//Image_AlienPixMap img;
//if (myView->ToPixMap(img, 1024, 1024))
// return img.Save("C:\\test.bmp");
return myView->Dump("C:\\test.bmp");
}
Here is whats logged after calling ToPixMap (either from Dump or my code):
TKOpenGl.WinSystem | Type: Error | ID: 170 | Severity: High | Message:
wglMakeCurrent() has failed. The requested resource is in use.Warning, on screen buffer is used for image dump - content might be invalid
TKOpenGl.WinSystem | Type: Error | ID: 170 | Severity: High | Message:
wglMakeCurrent() has failed. The requested resource is in use.TKOpenGl.WinSystem | Type: Error | ID: 170 | Severity: High | Message:
wglMakeCurrent() has failed. The requested resource is in use.TKOpenGl.WinSystem | Type: Error | ID: 6 | Severity: High | Message:
wglMakeCurrent() has failed. Invalid handle.
Any ideas whats going on here?
Thanks in advance!
Tue, 07/23/2019 - 21:21
First of all, familiarize yourself with two-threaded QtQuick design:
https://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html
There are (at least) two working threads in QtQuick application - one processing GUI (what you get in "normal" callbacks) and another one if for OpenGL rendering.
Within AndroidQt sample, OCCT 3D Viewer is embedded into QtQuick rendering graph (at the very beginning),
so that any actions implying rendering (like dumping view using ToPixMap() method) should be done only in rendering thread,
while others should care about multi-threaded synchronization to avoid data races.
Wed, 07/24/2019 - 16:30
I tested moving the code into the rendering logic (i.e. beforeRendering) and indeed it works there. So sorry for asking an OT question and thank you for answering anyway! :)