Background Texture on iOs

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
littleogre
Gnoblar
Posts: 1
Joined: Mon Jun 30, 2014 12:37 pm

Background Texture on iOs

Post by littleogre »

Hi everyone,

I have a little problem on iOS, I'm traying to display an image on the background, I followed this link http://www.ogre3d.org/tikiwiki/tiki-ind ... ackgrounds , and I plugged the solution into the template project provided for iOs :

Code: Select all

void DemoApp::setupDemoScene()
{
    // Create background material
    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("Background", "General");
    material->getTechnique(0)->getPass(0)->createTextureUnitState("spheremap.png");
    material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
    material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
    material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
    
    // Create background rectangle covering the whole screen
    Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
    rect->setCorners(-1.0, 1.0, 1.0, -1.0);
    rect->setMaterial("Background");
    
    // Render the background before everything else
    rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
    
    // Use infinite AAB to always stay visible
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    rect->setBoundingBox(aabInf);
    
    // Attach background to the scene
    Ogre::SceneNode* node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
    node->attachObject(rect);
    
    // Example of background scrolling
    material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setScrollAnimation(-0.25, 0.0);
    
    // Don't forget to delete the Rectangle2D in the destructor of your application:
    delete rect;
    
//	OgreFramework::getSingletonPtr()->m_pSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
//    
//	OgreFramework::getSingletonPtr()->m_pSceneMgr->createLight("Light")->setPosition(75,75,75);
//
//	m_pOgreHeadEntity = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("OgreHeadEntity", "ogrehead.mesh");
//	m_pOgreHeadNode = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode");
//	m_pOgreHeadNode->attachObject(m_pOgreHeadEntity);
}
However, for some mysterious reasons, the background stays balck.
The texture is loaded correctly, as I can assign it to the ogre head (setMaterail). It's just that the rectangle dont want to appear.
I'm using ogre 1.9 on iOS.

Any idea ?

PS: I'm writing an AR application, the next step is to display the camera stream into the background using dynamic texture, any better idea for doing that ?
SAM_tak
Gnoblar
Posts: 17
Joined: Wed May 25, 2011 5:17 pm

Re: Background Texture on iOs

Post by SAM_tak »

don't delete rect while using it.

I think reason is Ogre::Rectangle2d object was deleted.