Hey All
I go a quick question about rendering OC from a thread. I’m using OC with QT and have created a plugin with in which I have the OC stuff which is loaded by a QT application.
Without any thread I can view a rendered window attaching my view to the QT window as follows,
Handle(WNT_Window) theWNTWindow;
Handle(WNT_GraphicDevice) theGraphicDevice;
Handle(V3d_View) theView;
Handle(V3d_Viewer) theViewer;
Handle(AIS_InteractiveContext) theContext;
TCollection_ExtendedString aName("View 3D");
theGraphicDevice = new Graphic3d_WNTGraphicDevice();
theViewer = new V3d_Viewer(theGraphicDevice, aName.ToExtString());
theContext = new AIS_InteractiveContext(theViewer);
theView = theContext->CurrentViewer()->CreateView();
theWNTWindow = new WNT_Window(theGraphicDevice, reinterpret_cast(theWindowHandle) );
if(theView) theView->SetWindow(theWNTWindow);
After this I just call the following code if anything changes,
if(theView) theView -> Redraw();
This works fine.
The Problem comes with the thread (QThread), here I attach the plugin in my thread
::start( QThread::Priority priority )
{
theMutex.lock();
ADT_INTERFACE::ADT_OCInterface::InitLib();
theMutex.unlock();
theDoEventLoop = true;
QThread::start(priority);
}
Where InitLib executes the first code block.
Then I run an event loop which should render every little amount of time
::run()
{
while(theDoEventLoop)
{
theMutex.lock();
ADT_INTERFACE::ADT_OCInterface::RedrawView();
theMutex.unlock();
QThread::msleep(40);
}
The view seems to attach to the window ok using the winId but the render operation (although called) doesn’t seem to go to the window.
Thus my window is filled in with a dark grey color, but nothing is ever rendered over the top of it. Thus if I change the background color of the window to white, I continue to see a dark grey region.
Do anyone have any ideas?
Thanks
Teo