From Wang Rui, "I've encountered a strange problem that osgviewerMFC doesn't work well
with the StatsHandler. When the 's' key is pressed, the rendering window will be halted. I tried solving the problem by commenting a line in CMFC_OSG_MDIView::OnKeyDown() and it seems to work now. Another improvement here is to use a thread class derived from OpenThreads to replace the old _beginthread(). It helps a lot in keeping a high frame rate when you open more than one MDI child windows. And the application using OpenThreads in my opinion will be more compatible and portable."
This commit is contained in:
@@ -75,9 +75,10 @@ int CMFC_OSG_MDIView::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
|
||||
void CMFC_OSG_MDIView::OnDestroy()
|
||||
{
|
||||
delete mThreadHandle;
|
||||
if(mOSG != 0) delete mOSG;
|
||||
|
||||
WaitForSingleObject(mThreadHandle, 1000);
|
||||
//WaitForSingleObject(mThreadHandle, 1000);
|
||||
|
||||
CView::OnDestroy();
|
||||
}
|
||||
@@ -93,13 +94,15 @@ void CMFC_OSG_MDIView::OnInitialUpdate()
|
||||
mOSG->InitOSG(csFileName.GetString());
|
||||
|
||||
// Start the thread to do OSG Rendering
|
||||
mThreadHandle = (HANDLE)_beginthread(&cOSG::Render, 0, mOSG);
|
||||
//mThreadHandle = (HANDLE)_beginthread(&cOSG::Render, 0, mOSG);
|
||||
mThreadHandle = new CRenderingThread(mOSG);
|
||||
mThreadHandle->start();
|
||||
}
|
||||
|
||||
void CMFC_OSG_MDIView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
{
|
||||
// Pass Key Presses into OSG
|
||||
mOSG->getViewer()->getEventQueue()->keyPress(nChar);
|
||||
//mOSG->getViewer()->getEventQueue()->keyPress(nChar);
|
||||
|
||||
// Close Window on Escape Key
|
||||
if(nChar == VK_ESCAPE)
|
||||
|
||||
Reference in New Issue
Block a user