[vtkusers] About vtkMultithreader
童宇辰
pu at me.ccu.edu.tw
Wed May 26 09:47:19 EDT 2004
Hi All.
Can somebody show me an examle how to use vtkMultiThreader class;
I'm using VTK under Win32 and Microsoft Visual C++. Do I have to use
vtkMultiThreader class or can I use MFC CWinThread class?
When I use MFC CWinThread class , I have a trouble about
OPENGL..(wglMakeCurrent failed in MakeCurrent(), error)
Here is some code that I Write
vtkRenderer* Renderer = vtkRenderer::New();
CWinThread* pThread;
pThread=AfxBeginThread(ChildThread,(LPVOID)this,THREAD_PRIORITY_NORMAL);
ChildThread
{
InitializeCriticalSection(&csObject);
MyFunc();
pThread=NULL;
}
MyFunc
{
....Do Something ...
myDraw();
}
myDraw()
{
...
Renderer->GetProps()->RemoveAllItems(); --->here have problem
...
}
The Problem Pipeline is ::
vtkWin32OpenGLRenderWindow::MakeCurrent();
{
// Try to avoid doing anything (for performance).
HGLRC current = wglGetCurrentContext();
if (this->ContextId != current)
{
if(this->IsPicking && current)
{
vtkErrorMacro("Attempting to call MakeCurrent for a different window"
" than the one doing the picking, this can causes
crashes"
" and/or bad pick results");
}
else
{
if (wglMakeCurrent(this->DeviceContext, this->ContextId) != TRUE)
{
LPVOID lpMsgBuf;
::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
vtkErrorMacro("wglMakeCurrent failed in MakeCurrent(), error: "
<< (LPCTSTR)lpMsgBuf);
::LocalFree( lpMsgBuf );
}
}
}
}
my GetLastError is 170 -->
The requested resource is in use. ERROR_BUSY
Why?
How Can I Do?
Thank you very much....
Tung. Taiwan
More information about the vtkusers
mailing list