Valcaris
24-01-2010 01:49:59
I'm trying to figure out how to show a RTT in MyGUI.
I've poked around the forums a bit and I've found a class called MyGUI::Canvas and I tried calling its setRenderItemTexture() function, but I don't seem to get anything showing up. Here are some snippets:
My layout file:
My code (doctored slightly):
Everything seems to compile fine, but it throws an exception in MyGUI_RenderItem.cpp line 95:
Any help, ideas, or suggestions would be appreciated. Thanks!
I've poked around the forums a bit and I've found a class called MyGUI::Canvas and I tried calling its setRenderItemTexture() function, but I don't seem to get anything showing up. Here are some snippets:
My layout file:
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Canvas" skin="Canvas" position_real="0.75 0.75 0.25 0.25" layer="Main" name="Minimap"/>
</MyGUI>
My code (doctored slightly):
// create the texture for the RTT
Ogre::TexturePtr m_texture;
m_texture = Ogre::TextureManager::getSingleton().createManual("MinimapTex",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
128, 128, 0, Ogre::PF_R8G8B8,
Ogre::TU_RENDERTARGET);
// the RTT will receive data from a Camera which is set up below
Ogre::RenderTexture* renderTexture = m_texture->getBuffer()->getRenderTarget();
Ogre::Camera* camera = m_sceneManager->createCamera("MinimapCamera");
Ogre::SceneNode* cameraNode = m_sceneManager->getRootSceneNode()->createChildSceneNode("MinimapCameraNode", Ogre::Vector3( 0, 5000.0, 0 ) );
cameraNode->attachObject( camera );
camera->lookAt(Ogre::Vector3::ZERO);
camera->setNearClipDistance(1);
renderTexture->addViewport(camera);
renderTexture->getViewport(0)->setClearEveryFrame(false);
renderTexture->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
// set up the MyGUI stuff
MyGUI::OgreTexture oT("blahTex", "blahG");
oT.setOgreTexture(m_texture);
MyGUI::CanvasPtr minimapCanvas = gui->findWidget<MyGUI::Canvas>("Minimap");
// send the RTT to the GUI
minimapCanvas->setRenderItemTexture(&oT);
Everything seems to compile fine, but it throws an exception in MyGUI_RenderItem.cpp line 95:
MYGUI_EXCEPT("texture pointer is not valid, texture name '" << mTextureName << "'");
Any help, ideas, or suggestions would be appreciated. Thanks!