Maybe a bug?

wilsonwing

12-05-2009 03:19:59

Sometimes crash if I change viewport.

I have create 2 GUIManager (say GUIManagerA and GUIManagerB, and some ) and 2 Ogre SceneManager(SceneManagerA, SceneManagerB).
I only set SceneManager to GUIManager and no viewport is set.


Sometimes I needd to swapped Scene from A to B(SceneManagerA -> SceneManagerB also GUIManagerA -> GUIManagerB will be swapped) , and the viewport changes , too.
Swapped like this

Camera *camera = gameScene->getCamera();
m_pWindow->removeAllViewports();
Viewport *viewPort = m_pWindow->addViewport(camera);
viewPort->setBackgroundColour(ColourValue(0,0,0));
camera->setAspectRatio(Real(viewPort->getActualWidth()) / Real(viewPort->getActualHeight()));
viewPort->setOverlaysEnabled(true);


Most time there is no problem.
But sometimes it crashed at

//quickguibrush.cpp
void Brush::setRenderTarget(Ogre::Viewport* vp)
{
if(vp == NULL)
mRenderTarget = mDefaultViewport;
else
mRenderTarget = vp;

// Set new viewport on render system and reset clip region
mTargetWidth = mRenderTarget->getActualWidth();
mTargetHeight = mRenderTarget->getActualHeight();

mRenderSystem->_setViewport(mRenderTarget);
mRenderSystem->_setCullingMode(Ogre::CULL_NONE);//here <-------
//sometimes crash if change scene too quick(or maybe frequently).
//Only set scenemanager to QuickGUIManager, no viewport set ,I think vp is mDefaultViewport

setClipRegion(Rect(mRenderTarget->getActualLeft(), mRenderTarget->getActualTop(), mRenderTarget->getActualWidth(), mRenderTarget->getActualHeight()));
}


Here's some GUI thing I created

Ogre::UTFString font = "MeFont.cfmingeb.12";

QuickGUI::Sheet* defaultSheet = m_pGUIManager->getActiveSheet();

QuickGUI::Factory<QuickGUI::WidgetDesc>* descFactory = QuickGUI::FactoryManager::getSingleton().getWidgetDescFactory();

QuickGUI::ButtonDesc* l_pButtonD = dynamic_cast<QuickGUI::ButtonDesc*>(descFactory->getInstance("DefaultButtonDesc"));
QuickGUI::TextBoxDesc* l_pTextBoxD = dynamic_cast<QuickGUI::TextBoxDesc*>(descFactory->getInstance("DefaultTextBoxDesc"));

l_pButtonD->resetToDefault();
l_pButtonD->widget_dimensions.size = QuickGUI::Size(300,50);
l_pButtonD->widget_dimensions.position = QuickGUI::Point(100,100);
l_pButtonD->textDesc.segments.push_back(QuickGUI::TextSegment(font, Ogre::ColourValue::Red, Ogre::UTFString(L"now font : " + font )));
m_pTestButton = defaultSheet->createButton(l_pButtonD);


l_pTextBoxD->resetToDefault();
l_pTextBoxD->textbox_defaultFontName = font;
l_pTextBoxD->widget_dimensions = QuickGUI::Rect(150,500,200,26);
m_pTextBoxInput = defaultSheet->createTextBox(l_pTextBoxD);

l_pTextBoxD->widget_dimensions = QuickGUI::Rect(150,400,200,26);
m_pTextBoxCandidate = defaultSheet->createTextBox(l_pTextBoxD);
m_pTextBoxCandidate->setEnabled(false);



I am not sure if I code wrong somewhere or a bug.
I tried create no QuickGUI objects, but only the 2 GUIManagers. Then the problem didn't appear.

Using QUICKQUI_9.02 VS2005 Ogre1.6.0

kungfoomasta

12-05-2009 07:56:13

When a GUIManager is created, if the viewport it not specified, the first found camera's viewport is used. If you change viewports, or destroy and create new ones, you will need to let the GUIManager know via setViewport. Otherwise the GUIManager may try to use a viewport that doesn't exist, or is not valid.


Viewport *viewPort = m_pWindow->addViewport(camera);
myGUIManager->setViewport(viewPort);

wilsonwing

12-05-2009 12:17:18

When a GUIManager is created, if the viewport it not specified, the first found camera's viewport is used. If you change viewports, or destroy and create new ones, you will need to let the GUIManager know via setViewport. Otherwise the GUIManager may try to use a viewport that doesn't exist, or is not valid.


Viewport *viewPort = m_pWindow->addViewport(camera);
myGUIManager->setViewport(viewPort);


My bad :oops:
I'll do it, THANKS.